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> </transitions>
</gem-graph-model> </gem-graph-model>

View File

@ -52,15 +52,14 @@
struct space_unit_t struct space_unit_t
{ {
bool lock; uint id;
struct arrow_t **sites; // Array of struct arrow_t* elements struct arrow_t *sites[]; // Array of struct arrow_t elements
// - lenght is multiplicity // - lenght is multiplicity
}; };
struct space_t struct space_t
{ {
// Dimensions of space. // Dimensions of space.
// Note that a value 0 is not allowed, minimum is 1
int x_dim; int x_dim;
int y_dim; int y_dim;
int z_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; xmlAttr *attribute;
xmlChar *value; xmlChar *value;
printlog("NEW CALL : cur_node = %p\n", cur_node);
if (cur_node == NULL) { if (cur_node == NULL) {
// Get first state // Get first state
cur_node = model_get_node(self, (xmlChar *)"conditions"); 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; return false;
} }
printlog("END CALL : cur_node = %p\n", cur_node);
// Lookup in properties // Lookup in properties
if (model_get_node_str_attrib(cur_node, "id", new_cond_id)) if (model_get_node_str_attrib(cur_node, "id", new_cond_id))
return true; return true;
@ -453,7 +457,7 @@ bool model_get_next_condition (struct model_t *self,
char temp_char[25]; char temp_char[25];
uint check = 0; // bit field checker 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(new_condition);
assert(cond_id); 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); printlog("DURING CALL : cur_node = %p\n", cur_node);
//printf("DURING CALL : cur_node->name = %s\n", cur_node->name); printlog("DURING CALL : cur_node->name = %s\n", cur_node->name);
// Lookup in properties // Lookup in properties
if (cur_node && cur_node->properties) { if (cur_node && cur_node->properties) {
@ -653,22 +657,16 @@ bool model_load (struct model_t *self)
// Dimensions // Dimensions
self->space = calloc (1, sizeof(struct space_t)); self->space = calloc (1, sizeof(struct space_t));
self->space->x_dim = 1; self->space->x_dim = 0;
self->space->y_dim = 1; self->space->y_dim = 0;
self->space->z_dim = 1; self->space->z_dim = 0;
switch(self->dimension) { switch(self->dimension) {
case 3: 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"); self->space->z_dim = model_get_dim_value (self, "z");
case 2: 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"); self->space->y_dim = model_get_dim_value (self, "y");
case 1: 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"); self->space->x_dim = model_get_dim_value (self, "x");
printlog("x_dim=%d, y_dim=%d, z_dim=%d\n", 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->units = calloc (self->space->x_dim
* self->space->y_dim * self->space->y_dim
* self->space->z_dim, * self->space->z_dim,
sizeof(struct space_unit_t)); sizeof(struct space_unit_t)
+ self->multiplicity * sizeof(struct arrow_t*));
// Multiplicity // Multiplicity
self->multiplicity = model_get_multiplicity(self); 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); printlog("Initial state : %s\n", &self->states[0].id);
// Initial state arrows // Initial state arrows
self->arrows = arrow_new (self->arrows); while (arrow = arrow_new (self->arrows),
model_get_next_arrow(self,
if (model_get_next_arrow(self, arrow,
self->arrows, &self->states[0].id,
&self->states[0].id, self->dimension)) {
self->dimension)) { if (arrow->x > self->space->x_dim ||
self->n_arrows++; arrow->y > self->space->y_dim ||
arrow->z > self->space->z_dim) {
while (model_get_next_arrow(self, printerr("Invalid coordinates for arrow %d (%d,%d,%d)\n",
arrow_new (self->arrows), self->n_arrows,
&self->states[0].id, arrow->x,
self->dimension)) { arrow->y,
self->n_arrows++; 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); printlog("Loaded %d arrows\n", self->n_arrows);