src/graphics, src/parsing: drawing model initial state
This commit is contained in:
parent
5f2abbda15
commit
79cae53525
|
@ -55,12 +55,12 @@
|
||||||
|
|
||||||
<savedstates id="texte" date="1630000000" author="Qui courrait dans l'herbe'">
|
<savedstates id="texte" date="1630000000" author="Qui courrait dans l'herbe'">
|
||||||
<state id="initial" date="1630000000" author="Une souris verte">
|
<state id="initial" date="1630000000" author="Une souris verte">
|
||||||
<arrow site="1" weight="1" x="0"/>
|
<arrow site="0" weight="1" x="0"/>
|
||||||
<arrow site="2" weight="1" x="1"/>
|
<arrow site="1" weight="1" x="1"/>
|
||||||
<arrow site="1" weight="1" x="10"/>
|
<arrow site="0" weight="1" x="10"/>
|
||||||
<arrow site="2" weight="1" x="11"/>
|
<arrow site="1" weight="1" x="11"/>
|
||||||
<arrow site="1" weight="1" x="20"/>
|
<arrow site="0" weight="1" x="20"/>
|
||||||
<arrow site="2" weight="1" x="21"/>
|
<arrow site="1" weight="1" x="21"/>
|
||||||
|
|
||||||
<!-- Three dimers 1-1 are drawn in the global space
|
<!-- Three dimers 1-1 are drawn in the global space
|
||||||
at locations (0,1) (10,11) and (20,21) -->
|
at locations (0,1) (10,11) and (20,21) -->
|
||||||
|
|
|
@ -58,6 +58,17 @@ enum
|
||||||
N_MODE
|
N_MODE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Structure describing an arrow
|
||||||
|
*/
|
||||||
|
struct arrow_t {
|
||||||
|
uint load;
|
||||||
|
uint site;
|
||||||
|
uint x;
|
||||||
|
uint y;
|
||||||
|
uint z;
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read a file from filename into a provided buffer
|
* Read a file from filename into a provided buffer
|
||||||
*
|
*
|
||||||
|
|
|
@ -255,17 +255,6 @@ static inline void print_stack(int stack_id)
|
||||||
|
|
||||||
void graphics_model_setup (const int stack_id);
|
void graphics_model_setup (const int stack_id);
|
||||||
|
|
||||||
/*
|
|
||||||
* Structure describing an arrow
|
|
||||||
*/
|
|
||||||
struct arrow_t {
|
|
||||||
GLuint load;
|
|
||||||
GLuint site;
|
|
||||||
GLuint x;
|
|
||||||
GLuint y;
|
|
||||||
GLuint z;
|
|
||||||
};
|
|
||||||
|
|
||||||
int draw_one_arrow_vertex (const int stack_id,
|
int draw_one_arrow_vertex (const int stack_id,
|
||||||
int space_X,
|
int space_X,
|
||||||
int space_Y,
|
int space_Y,
|
||||||
|
|
|
@ -33,4 +33,7 @@ bool model_shutdown(void);
|
||||||
char model_get_dim(void);
|
char model_get_dim(void);
|
||||||
long model_get_dim_value(const char *axis);
|
long model_get_dim_value(const char *axis);
|
||||||
char model_get_multiplicity(void);
|
char model_get_multiplicity(void);
|
||||||
|
bool model_get_next_state(char *new_state_id);
|
||||||
|
bool model_get_next_arrow(struct arrow_t *new_arrow,
|
||||||
|
const char *state_id,
|
||||||
|
char dimension);
|
||||||
|
|
|
@ -239,6 +239,7 @@ void graphics_model_setup (const int stack_id)
|
||||||
long space_X;
|
long space_X;
|
||||||
long space_Y;
|
long space_Y;
|
||||||
long space_Z;
|
long space_Z;
|
||||||
|
long announced_arrows_nb;
|
||||||
int density_max;
|
int density_max;
|
||||||
char multiplicity;
|
char multiplicity;
|
||||||
|
|
||||||
|
@ -283,12 +284,12 @@ void graphics_model_setup (const int stack_id)
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/* draw_space_ridges_vertex (stack_id, stack->buffer_vertex_size, */
|
draw_space_ridges_vertex (stack_id, stack->buffer_vertex_size,
|
||||||
/* space_X, space_Y, space_Z); */
|
space_X, space_Y, space_Z);
|
||||||
/* draw_space_ridges_lines (stack_id); */
|
draw_space_ridges_lines (stack_id);
|
||||||
/* draw_grids_on_space_faces_vertex (stack_id, space_X, space_Y, space_Z); */
|
draw_grids_on_space_faces_vertex (stack_id, space_X, space_Y, space_Z);
|
||||||
/* draw_grids_on_space_faces_lines (stack_id, stack->buffer_lines_size, */
|
draw_grids_on_space_faces_lines (stack_id, stack->buffer_lines_size,
|
||||||
/* space_X, space_Y, space_Z); */
|
space_X, space_Y, space_Z);
|
||||||
|
|
||||||
stack->buffer_vertex_0_arrow = stack->buffer_vertex_size;
|
stack->buffer_vertex_0_arrow = stack->buffer_vertex_size;
|
||||||
stack->buffer_colors_0_arrow = stack->buffer_colors_size;
|
stack->buffer_colors_0_arrow = stack->buffer_colors_size;
|
||||||
|
@ -300,15 +301,28 @@ void graphics_model_setup (const int stack_id)
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
char state_id[30] = {0};
|
||||||
|
struct arrow_t arrow = {0};
|
||||||
|
|
||||||
for (int i = 0; i < density_max; i++) {
|
assert(model_get_next_state(&state_id));
|
||||||
|
|
||||||
|
g_print("[GRAPH DEBUG] first state is = %s\n", state_id);
|
||||||
|
|
||||||
|
announced_arrows_nb = model_get_state_arrows_count(state_id);
|
||||||
|
|
||||||
|
g_print("[GRAPH DEBUG] announced_arrows_nb is = %ld\n", announced_arrows_nb);
|
||||||
|
|
||||||
|
while (model_get_next_arrow(&arrow, &state_id, dimension)) {
|
||||||
|
g_print("[GRAPH DEBUG] cur arrow has x = %d\n", arrow.x);
|
||||||
stack->arrows_nb =
|
stack->arrows_nb =
|
||||||
set_arrow (stack_id, stack->arrows_nb, space_X, space_Y, space_Z,
|
set_arrow (stack_id, stack->arrows_nb, space_X, space_Y, space_Z,
|
||||||
1, // load
|
arrow.load, // load
|
||||||
rand() % 6, // site
|
arrow.site, // site
|
||||||
rand() % space_X, // x
|
arrow.x, // x
|
||||||
rand() % space_Y, // y
|
arrow.y, // y
|
||||||
rand() % space_Z); // z
|
arrow.z); // z
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stack->arrows_nb != announced_arrows_nb)
|
||||||
|
g_printerr("ARGH : all the arrows have not been parsed !\n");
|
||||||
|
}
|
||||||
|
|
|
@ -35,6 +35,15 @@
|
||||||
|
|
||||||
#include "../../include/base.h"
|
#include "../../include/base.h"
|
||||||
|
|
||||||
|
#define READ_SITE 1 << 0
|
||||||
|
#define READ_WEIGHT 1 << 1
|
||||||
|
#define READ_X 1 << 2
|
||||||
|
#define READ_Y 1 << 3
|
||||||
|
#define READ_Z 1 << 4
|
||||||
|
#define SUCCESSFUL_READ_ARROW_X (READ_SITE | READ_WEIGHT | READ_X)
|
||||||
|
#define SUCCESSFUL_READ_ARROW_XY (READ_SITE | READ_WEIGHT | READ_X | READ_Y)
|
||||||
|
#define SUCCESSFUL_READ_ARROW_XYZ (READ_SITE | READ_WEIGHT | READ_X | READ_Y | READ_Z)
|
||||||
|
|
||||||
static xmlDocPtr model;
|
static xmlDocPtr model;
|
||||||
static xmlHashTablePtr model_hashtable;
|
static xmlHashTablePtr model_hashtable;
|
||||||
|
|
||||||
|
@ -99,7 +108,7 @@ bool model_shutdown(void)
|
||||||
static inline xmlNodePtr getNextChild(xmlNodePtr node, xmlChar *last)
|
static inline xmlNodePtr getNextChild(xmlNodePtr node, xmlChar *last)
|
||||||
{
|
{
|
||||||
while (node != NULL && xmlStrcmp(node->name, last)) {
|
while (node != NULL && xmlStrcmp(node->name, last)) {
|
||||||
// printf(" <>--- line n°%lu <%s>\n", xmlGetLineNo(node), node->name);
|
// //printf(" <>--- line n°%lu <%s>\n", xmlGetLineNo(node), node->name);
|
||||||
node = node->next;
|
node = node->next;
|
||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
|
@ -118,7 +127,7 @@ static inline xmlChar* getFirstTag(xmlChar *path)
|
||||||
path = (xmlChar *)xmlStrchr(path, '/');
|
path = (xmlChar *)xmlStrchr(path, '/');
|
||||||
path = xmlStrsub (path, 1, xmlStrlen(path));
|
path = xmlStrsub (path, 1, xmlStrlen(path));
|
||||||
|
|
||||||
printf("%s = %s + / + %s\n", preop,\
|
//printf("%s = %s + / + %s\n", preop,\
|
||||||
xmlStrsub (preop, 0, xmlStrlen(preop) - xmlStrlen(path) - 1), path);
|
xmlStrsub (preop, 0, xmlStrlen(preop) - xmlStrlen(path) - 1), path);
|
||||||
|
|
||||||
return xmlStrsub (preop, 0, xmlStrlen(preop) - xmlStrlen(path) - 1);
|
return xmlStrsub (preop, 0, xmlStrlen(preop) - xmlStrlen(path) - 1);
|
||||||
|
@ -129,7 +138,7 @@ static inline xmlChar* getLastTag(xmlChar *path)
|
||||||
while ((ulong)xmlStrchr (path, '/'))
|
while ((ulong)xmlStrchr (path, '/'))
|
||||||
path = splitStrAtSlash((xmlChar *)path);
|
path = splitStrAtSlash((xmlChar *)path);
|
||||||
|
|
||||||
// printf("last tag in the path = <%s>\n", path);
|
// //printf("last tag in the path = <%s>\n", path);
|
||||||
return path; // which is no more the given path but only its last tag !
|
return path; // which is no more the given path but only its last tag !
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,52 +187,51 @@ static xmlNodePtr model_get_node(xmlChar *path)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
static long model_get_node_attrib(xmlNodePtr node)
|
static inline long model_get_node_long_attrib(xmlNodePtr node, char *id)
|
||||||
{
|
{
|
||||||
long value = 0;
|
xmlAttr *attribute;
|
||||||
|
xmlChar* value;
|
||||||
|
long ret_value;
|
||||||
|
|
||||||
if (node && node->properties) {
|
if (node && node->properties) {
|
||||||
xmlAttr* attribute = node->properties;
|
attribute = node->properties;
|
||||||
xmlChar* value_txt = NULL;
|
|
||||||
char *ptr;
|
|
||||||
|
|
||||||
while(attribute && attribute->name && attribute->children) {
|
while(attribute && attribute->name && attribute->children) {
|
||||||
value_txt = xmlNodeListGetString(node->doc, attribute->children, 1);
|
if (!xmlStrcmp(attribute->name, (const xmlChar *)id)) {
|
||||||
value = strtol((char *)value_txt, &ptr, 10);
|
value = xmlNodeListGetString(node->doc, attribute->children, 1);
|
||||||
printf ("model_get_node_attrib <%s> = %s = %ld\n",\
|
ret_value = strtol((char *)value, NULL, 0);
|
||||||
attribute->name, value_txt, value);
|
xmlFree(value);
|
||||||
|
return ret_value;
|
||||||
|
}
|
||||||
attribute = attribute->next;
|
attribute = attribute->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return value;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static long model_get_state_arrows_nb(xmlNodePtr node)
|
static inline bool model_get_node_str_attrib(xmlNodePtr node,
|
||||||
|
char *id,
|
||||||
|
char *dest)
|
||||||
{
|
{
|
||||||
long arrows_nb= 0;
|
xmlAttr *attribute;
|
||||||
printf ("VRB0 model_get_state_arrows_nb <%s> start at line %ld\n",
|
xmlChar* value;
|
||||||
node->name, xmlGetLineNo(node));
|
|
||||||
|
|
||||||
while (node && node->next) {
|
if (node && node->properties) {
|
||||||
printf ("%s %ld >", (xmlChar *)node->name, arrows_nb);
|
attribute = node->properties;
|
||||||
if (!xmlStrcmp(node->name, (xmlChar *)"arrow")) ++arrows_nb;
|
while(attribute && attribute->name && attribute->children) {
|
||||||
printf (" %ld ", arrows_nb);
|
if (!xmlStrcmp(attribute->name, (const xmlChar *)id)) {
|
||||||
node = node->next;
|
value = xmlNodeListGetString(node->doc, attribute->children, 1);
|
||||||
|
strcpy(dest, value);
|
||||||
|
xmlFree(value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
attribute = attribute->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf ("\n");
|
|
||||||
printf ("VRB0 model_get_state_arrows_nb = %ld end at line %ld\n",
|
|
||||||
arrows_nb, xmlGetLineNo(node));
|
|
||||||
|
|
||||||
return arrows_nb;
|
|
||||||
}
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
char model_get_dim(void)
|
char model_get_dim(void)
|
||||||
|
@ -247,20 +255,7 @@ long model_get_dim_value(const char *axis)
|
||||||
xmlNodePtr node = model_get_node(
|
xmlNodePtr node = model_get_node(
|
||||||
(xmlChar *)"parameters/space-param/dimension");
|
(xmlChar *)"parameters/space-param/dimension");
|
||||||
|
|
||||||
if (node && node->properties) {
|
return model_get_node_long_attrib(node, axis);
|
||||||
attribute = node->properties;
|
|
||||||
|
|
||||||
while(attribute && attribute->name && attribute->children) {
|
|
||||||
if (!xmlStrcmp(attribute->name, (const xmlChar *)axis)) {
|
|
||||||
value = xmlNodeListGetString(node->doc, attribute->children, 1);
|
|
||||||
ret_value = strtol((char *)value, NULL, 0);
|
|
||||||
xmlFree(value);
|
|
||||||
return ret_value;
|
|
||||||
}
|
|
||||||
attribute = attribute->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char model_get_multiplicity(void)
|
char model_get_multiplicity(void)
|
||||||
|
@ -277,132 +272,212 @@ char model_get_multiplicity(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char model_get_condition(void)
|
bool model_get_next_state(char *new_state_id)
|
||||||
{
|
{
|
||||||
|
static xmlNodePtr cur_node = NULL;
|
||||||
xmlAttr *attribute;
|
xmlAttr *attribute;
|
||||||
xmlChar *value;
|
xmlChar *value;
|
||||||
xmlNodePtr node = model_get_node(
|
|
||||||
(xmlChar *)"parameters/space-param/dimension");
|
|
||||||
|
|
||||||
if (xmlHasProp (node, (xmlChar *) "z")) return 3;
|
if (cur_node == NULL) {
|
||||||
if (xmlHasProp (node, (xmlChar *) "y")) return 2;
|
// Get first state
|
||||||
if (xmlHasProp (node, (xmlChar *) "x")) return 1;
|
cur_node = model_get_node((xmlChar *)"savedstates/state");
|
||||||
return 0;
|
|
||||||
|
} else {
|
||||||
|
// Get next state
|
||||||
|
if (cur_node->next)
|
||||||
|
cur_node = cur_node->next;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char model_get_cond_tree (xmlChar *path)
|
// Lookup in properties
|
||||||
|
if (model_get_node_str_attrib(cur_node, "id", new_state_id))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
cur_node = NULL;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
long model_get_state_arrows_count(const char *state_id)
|
||||||
{
|
{
|
||||||
xmlNodePtr node = model_get_node(path);
|
xmlNodePtr cur_node = NULL;
|
||||||
node = node->xmlChildrenNode;
|
xmlAttr *attribute;
|
||||||
node = getNextChild(node, (xmlChar *)"condition");
|
long value = 0;
|
||||||
node = xmlCopyNodeList (node->xmlChildrenNode);
|
bool found = false;
|
||||||
printf("model_get_cond_tree(\"%s\") > line n°%ld\n", path, xmlGetLineNo(node));
|
char temp_char[25];
|
||||||
return 0;
|
uint check = 0; // bit field checker
|
||||||
|
|
||||||
|
//printf("NEW CALL : cur_node = %p\n", cur_node);
|
||||||
|
|
||||||
|
assert(state_id);
|
||||||
|
|
||||||
|
// Get first state node
|
||||||
|
cur_node = model_get_node((xmlChar *)"savedstates/state");
|
||||||
|
|
||||||
|
// Lookup in properties
|
||||||
|
while (cur_node && cur_node->properties) {
|
||||||
|
attribute = cur_node->properties;
|
||||||
|
|
||||||
|
// Look for the id attribute
|
||||||
|
if (model_get_node_str_attrib(cur_node, "id", &temp_char)) {
|
||||||
|
if (!xmlStrcmp(temp_char, (const xmlChar *)state_id)) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cur_node = cur_node->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
int model_get_cond (xmlChar *path, xmlChar *node_id)
|
// Check if the state has been found
|
||||||
|
if (!found) {
|
||||||
|
cur_node = NULL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Count arrows
|
||||||
|
if (cur_node->children) {
|
||||||
|
cur_node = cur_node->children;
|
||||||
|
while (cur_node) {
|
||||||
|
if (!xmlStrcmp(cur_node->name, (const xmlChar *)"arrow"))
|
||||||
|
value++;
|
||||||
|
cur_node = cur_node->next;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool model_get_next_arrow(struct arrow_t *new_arrow,
|
||||||
|
const char *state_id,
|
||||||
|
char dimension)
|
||||||
{
|
{
|
||||||
xmlNodePtr node = model_get_node(path);
|
static xmlNodePtr cur_node = NULL;
|
||||||
printf("model_get_cond(...) {...node->name = %s...}\n", node->name);
|
xmlAttr *attribute;
|
||||||
node = getNextChild(node->next, (xmlChar *)"condition");
|
xmlChar *value;
|
||||||
node = getNextChild(node->next, (xmlChar *)"condition");
|
bool found = false;
|
||||||
|
char temp_char[25];
|
||||||
|
uint check = 0; // bit field checker
|
||||||
|
|
||||||
if (xmlHasProp (node, (xmlChar *) "site")) {
|
//printf("NEW CALL : cur_node = %p\n", cur_node);
|
||||||
printf(" node %s has attribute site\n", node->name);
|
|
||||||
|
assert(new_arrow);
|
||||||
|
assert(state_id);
|
||||||
|
|
||||||
|
if (cur_node == NULL) {
|
||||||
|
// Get first state node
|
||||||
|
cur_node = model_get_node((xmlChar *)"savedstates/state");
|
||||||
|
|
||||||
|
// Lookup in properties
|
||||||
|
while (cur_node && cur_node->properties) {
|
||||||
|
attribute = cur_node->properties;
|
||||||
|
|
||||||
|
// Look for the id attribute
|
||||||
|
if (model_get_node_str_attrib(cur_node, "id", &temp_char)) {
|
||||||
|
if (!xmlStrcmp(temp_char, (const xmlChar *)state_id)) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cur_node = cur_node->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xmlHasProp (node, (xmlChar *) "node_id")) {
|
// Check if the state has been found
|
||||||
printf(" node %s has attribute %s with value %hhn %s %s\n",
|
if (!found) {
|
||||||
node->name,
|
cur_node = NULL;
|
||||||
xmlHasProp (node, (xmlChar *) "node_id")->name,
|
return false;
|
||||||
xmlGetProp (node, (xmlChar *) "node_id"),
|
|
||||||
(xmlChar *)"?! xmlGetProp is deprecated !",
|
|
||||||
(xmlChar *)"");
|
|
||||||
}
|
|
||||||
node = getNextChild(node->next, (xmlChar *)"condition");
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int model_get_objects_list(xmlChar *path)
|
// Get first arrow
|
||||||
{
|
if (cur_node->children) {
|
||||||
return xmlGetLineNo(model_get_node(path));
|
cur_node = cur_node->children;
|
||||||
|
|
||||||
|
found = false;
|
||||||
|
while (cur_node && cur_node->name) {
|
||||||
|
if (!xmlStrcmp(cur_node->name, (const xmlChar *)"arrow")) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
cur_node = cur_node->next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
xmlChar *model_get_states_list(xmlChar *path)
|
// Check if the state has been found
|
||||||
{
|
if (!found) {
|
||||||
xmlNodePtr node = model_get_node(path);
|
cur_node = NULL;
|
||||||
return (xmlChar *)xmlNodeGetContent(node);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* long model_get_state_arrows_count(xmlChar *path, long n) */
|
} else {
|
||||||
/* { */
|
// Get next arrow
|
||||||
/* // Ici, je sais que c'est le 'PREMIER' état qui est demandé car n == 0 */
|
found = false;
|
||||||
/* char compl[] = "/state/arrow"; */
|
while (cur_node->next) {
|
||||||
/* char *new_p = calloc(1, (sizeof(compl) + strlen((char *)path)) * sizeof(char)); */
|
cur_node = cur_node->next;
|
||||||
/* strcat(new_p, (char *)path); */
|
if (!xmlStrcmp(cur_node->name, (const xmlChar *)"arrow")) {
|
||||||
/* strcat(new_p + strlen((char *)path), compl); // printf("%s\n", new_p); */
|
found = true;
|
||||||
|
break;
|
||||||
/* xmlNodePtr node = model_get_node((xmlChar *)new_p); */
|
}
|
||||||
/* long size = model_get_state_arrows_nb(node); */
|
|
||||||
/* int dim = model_get_dim((xmlChar *)"parameters/space-param/dimension"); */
|
|
||||||
/* printf("VRB0 model_get_saved_state(size = %ld)->%p<-attrib dim = %d size = %ld\n",\ */
|
|
||||||
/* size, (xmlNodePtr)model_get_node_attrib(node), dim, size * ( 2 + dim ) * sizeof(int)); */
|
|
||||||
|
|
||||||
/* int c = 0; */
|
|
||||||
/* int *t = calloc(1, (size * ( 2 + dim ) * sizeof(int))); */
|
|
||||||
/* // int rk = 0; */
|
|
||||||
/* // int *s = calloc(1, ( 2 + dim ) * sizeof(int)); */
|
|
||||||
|
|
||||||
/* if(1) */
|
|
||||||
/* { */
|
|
||||||
/* long arrows_nb= 0; */
|
|
||||||
/* printf ("VRB4 model_get_state_arrows_nb <%s> start at line %ld\n",\ */
|
|
||||||
/* node->name, xmlGetLineNo(node)); */
|
|
||||||
/* while (node && node->next){ */
|
|
||||||
/* if (!xmlStrcmp(node->name, (xmlChar *)"arrow")) ++arrows_nb; */
|
|
||||||
/* if (!xmlStrcmp(node->name, (xmlChar *)"arrow")) printf ("VRB4 %s-%ld ",\ */
|
|
||||||
/* (xmlChar *)node->name, arrows_nb); */
|
|
||||||
/* if (node && node->properties) { */
|
|
||||||
/* xmlAttr* attribute = node->properties; */
|
|
||||||
/* while(attribute) */
|
|
||||||
/* { */
|
|
||||||
/* xmlChar* value = xmlNodeListGetString(node->doc, attribute->children, 1); */
|
|
||||||
/* printf("v=%s ", value); */
|
|
||||||
/* *(t + c) = strtol((char*)value, NULL, 0); */
|
|
||||||
/* ++c; */
|
|
||||||
/* xmlFree(value); */
|
|
||||||
/* attribute = attribute->next; */
|
|
||||||
/* } */
|
|
||||||
/* printf("\n"); */
|
|
||||||
/* } */
|
|
||||||
/* node = node->next; */
|
|
||||||
/* } */
|
|
||||||
/* printf ("VRB4 model_get_state_arrows_nb = %ld end at line %ld\n",\ */
|
|
||||||
/* arrows_nb, xmlGetLineNo(node)); */
|
|
||||||
/* for(int k = 0; k < c; k++) printf("%d ", *(t + k)); printf("\n"); */
|
|
||||||
/* return arrows_nb; */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* return (long) size * ( 2 + dim ) * sizeof(int); */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
int model_get_state(xmlChar *path, xmlChar *state_id)
|
|
||||||
{
|
|
||||||
printf("model_get_state (%s -> %s state)\n", path, state_id);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int model_get_conditions_list(xmlChar *path)
|
// Check if the state has been found
|
||||||
{
|
if (!found) {
|
||||||
printf("model_get_conditions_list(%s)\n", path);
|
cur_node = NULL;
|
||||||
return 0;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int model_get_transitions_list(xmlChar *path)
|
//printf("DURING CALL : cur_node = %p\n", cur_node);
|
||||||
{
|
//printf("DURING CALL : cur_node->name = %s\n", cur_node->name);
|
||||||
printf("model_get_transitions_list(%s)\n", path);
|
|
||||||
return 0;
|
// Lookup in properties
|
||||||
|
if (cur_node && cur_node->properties) {
|
||||||
|
attribute = cur_node->properties;
|
||||||
|
|
||||||
|
while(attribute && attribute->name && attribute->children) {
|
||||||
|
//printf("attr name : %s\n", attribute->name);
|
||||||
|
if (!xmlStrcmp(attribute->name, (const xmlChar *)"site")) {
|
||||||
|
value = xmlNodeListGetString(cur_node->doc, attribute->children, 1);
|
||||||
|
new_arrow->site = strtol((char *)value, NULL, 0);
|
||||||
|
xmlFree(value);
|
||||||
|
check |= READ_SITE;
|
||||||
|
}
|
||||||
|
if (!xmlStrcmp(attribute->name, (const xmlChar *)"weight")) {
|
||||||
|
value = xmlNodeListGetString(cur_node->doc, attribute->children, 1);
|
||||||
|
new_arrow->load = strtol((char *)value, NULL, 0);
|
||||||
|
xmlFree(value);
|
||||||
|
check |= READ_WEIGHT;
|
||||||
|
}
|
||||||
|
if (!xmlStrcmp(attribute->name, (const xmlChar *)"x")) {
|
||||||
|
value = xmlNodeListGetString(cur_node->doc, attribute->children, 1);
|
||||||
|
new_arrow->x = strtol((char *)value, NULL, 0);
|
||||||
|
xmlFree(value);
|
||||||
|
check |= READ_X;
|
||||||
|
}
|
||||||
|
if (!xmlStrcmp(attribute->name, (const xmlChar *)"y")) {
|
||||||
|
value = xmlNodeListGetString(cur_node->doc, attribute->children, 1);
|
||||||
|
new_arrow->y = strtol((char *)value, NULL, 0);
|
||||||
|
xmlFree(value);
|
||||||
|
check |= READ_Y;
|
||||||
|
}
|
||||||
|
if (!xmlStrcmp(attribute->name, (const xmlChar *)"z")) {
|
||||||
|
value = xmlNodeListGetString(cur_node->doc, attribute->children, 1);
|
||||||
|
new_arrow->z = strtol((char *)value, NULL, 0);
|
||||||
|
xmlFree(value);
|
||||||
|
check |= READ_Z;
|
||||||
|
}
|
||||||
|
attribute = attribute->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch(dimension) {
|
||||||
|
case 3:
|
||||||
|
return (bool)(check & SUCCESSFUL_READ_ARROW_XYZ);
|
||||||
|
case 2:
|
||||||
|
return (bool)(check & SUCCESSFUL_READ_ARROW_XY);
|
||||||
|
case 1:
|
||||||
|
return (bool)(check & SUCCESSFUL_READ_ARROW_X);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cur_node = NULL;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue