WIP: devel : travail du mois de mars/avril #28

Draft
neox wants to merge 24 commits from devel into devel_orig
3 changed files with 48 additions and 29 deletions
Showing only changes of commit 19acd2672c - Show all commits

View File

@ -116,3 +116,4 @@
</transitions>
</gem-graph-model>

View File

@ -52,15 +52,14 @@
struct space_unit_t
{
bool lock;
struct arrow_t **sites; // Array of struct arrow_t* elements
uint id;
struct arrow_t *sites[]; // Array of struct arrow_t elements
// - lenght is multiplicity
};
struct space_t
{
// Dimensions of space.
// Note that a value 0 is not allowed, minimum is 1
int x_dim;
int y_dim;
int z_dim;

View File

@ -421,6 +421,8 @@ bool model_get_next_conditions (struct model_t *self, char *new_cond_id)
xmlAttr *attribute;
xmlChar *value;
printlog("NEW CALL : cur_node = %p\n", cur_node);
if (cur_node == NULL) {
// Get first state
cur_node = model_get_node(self, (xmlChar *)"conditions");
@ -433,6 +435,8 @@ bool model_get_next_conditions (struct model_t *self, char *new_cond_id)
return false;
}
printlog("END CALL : cur_node = %p\n", cur_node);
// Lookup in properties
if (model_get_node_str_attrib(cur_node, "id", new_cond_id))
return true;
@ -453,7 +457,7 @@ bool model_get_next_condition (struct model_t *self,
char temp_char[25];
uint check = 0; // bit field checker
//printf("NEW CALL : cur_node = %p\n", cur_node);
printlog("NEW CALL : cur_node = %p\n", cur_node);
assert(new_condition);
assert(cond_id);
@ -520,8 +524,8 @@ bool model_get_next_condition (struct model_t *self,
}
}
//printf("DURING CALL : cur_node = %p\n", cur_node);
//printf("DURING CALL : cur_node->name = %s\n", cur_node->name);
printlog("DURING CALL : cur_node = %p\n", cur_node);
printlog("DURING CALL : cur_node->name = %s\n", cur_node->name);
// Lookup in properties
if (cur_node && cur_node->properties) {
@ -653,22 +657,16 @@ bool model_load (struct model_t *self)
// Dimensions
self->space = calloc (1, sizeof(struct space_t));
self->space->x_dim = 1;
self->space->y_dim = 1;
self->space->z_dim = 1;
self->space->x_dim = 0;
self->space->y_dim = 0;
self->space->z_dim = 0;
switch(self->dimension) {
case 3:
// even in 1D, we must be able to see a grid, so prevent to be 0
if (self->space->z_dim)
self->space->z_dim = model_get_dim_value (self, "z");
case 2:
// even in 1D, we must be able to see a grid, so prevent to be 0
if (self->space->y_dim)
self->space->y_dim = model_get_dim_value (self, "y");
case 1:
// even in 1D, we must be able to see a grid, so prevent to be 0
if (self->space->x_dim)
self->space->x_dim = model_get_dim_value (self, "x");
printlog("x_dim=%d, y_dim=%d, z_dim=%d\n",
@ -685,7 +683,8 @@ bool model_load (struct model_t *self)
self->space->units = calloc (self->space->x_dim
* self->space->y_dim
* self->space->z_dim,
sizeof(struct space_unit_t));
sizeof(struct space_unit_t)
+ self->multiplicity * sizeof(struct arrow_t*));
// Multiplicity
self->multiplicity = model_get_multiplicity(self);
@ -705,20 +704,40 @@ bool model_load (struct model_t *self)
printlog("Initial state : %s\n", &self->states[0].id);
// Initial state arrows
self->arrows = arrow_new (self->arrows);
if (model_get_next_arrow(self,
self->arrows,
while (arrow = arrow_new (self->arrows),
model_get_next_arrow(self,
arrow,
&self->states[0].id,
self->dimension)) {
self->n_arrows++;
while (model_get_next_arrow(self,
arrow_new (self->arrows),
&self->states[0].id,
self->dimension)) {
self->n_arrows++;
if (arrow->x > self->space->x_dim ||
arrow->y > self->space->y_dim ||
arrow->z > self->space->z_dim) {
printerr("Invalid coordinates for arrow %d (%d,%d,%d)\n",
self->n_arrows,
arrow->x,
arrow->y,
arrow->z);
return false;
}
printlog("Loading arrow %d (%d,%d,%d, %d)\n",
self->n_arrows,
arrow->x,
arrow->y,
arrow->z,
arrow->site);
self->space->units [
arrow->x
+ self->space->x_dim * arrow->y
+ self->space->x_dim * self->space->y_dim * arrow->z
].sites[arrow->site] = arrow;
if (self->n_arrows == 0) {
self->arrows = arrow;
}
self->n_arrows++;
}
printlog("Loaded %d arrows\n", self->n_arrows);