Commit c71549e4 authored by Timothee Habra's avatar Timothee Habra

allow loading mbs with no user model

parent 0a3fda15
......@@ -61,9 +61,7 @@ Loop_arguments* init_simulation(void)
// MBSDataStruct initialization
MBSdata = loadMBSdata_xml(MBS_FILE);
printMbsData(MBSdata);
printMbsData(MBSdata);
//printMbsData(MBSdata);
if(MBSdata == NULL)
{
......
......@@ -410,7 +410,7 @@ MDS_ref_point_strct* MDS_ref_point_reader(xmlNodePtr node, xmlDocPtr doc)
if(!strcmp((const char*)cur_node->name,"bodyname"))
{
elementValue = xmlNodeListGetString(doc, cur_node->xmlChildrenNode, 1);
mds_ref_point_strct->bodyname = malloc(strlen((char*)elementValue)+1);
mds_ref_point_strct->bodyname = (char*) malloc(strlen((char*)elementValue)+1);
strcpy(mds_ref_point_strct->bodyname,(char*)elementValue);
xmlFree(elementValue);
//mds_ref_point_strct->bodyname = (char*)elementValue;
......@@ -418,7 +418,7 @@ MDS_ref_point_strct* MDS_ref_point_reader(xmlNodePtr node, xmlDocPtr doc)
if(!strcmp((const char*)cur_node->name,"pointname"))
{
elementValue = xmlNodeListGetString(doc, cur_node->xmlChildrenNode, 1);
mds_ref_point_strct->pointname = malloc(strlen((char*)elementValue)+1);
mds_ref_point_strct->pointname = (char*) malloc(strlen((char*)elementValue)+1);
strcpy(mds_ref_point_strct->pointname,(char*)elementValue);
xmlFree(elementValue);
//mds_ref_point_strct->pointname = (char*)elementValue;
......@@ -875,6 +875,7 @@ MDS_links_strct* MDS_links_reader(xmlNodePtr node, xmlDocPtr doc)
cur_node = cur_node->next;
}
mds_links_strct->link_list = (MDS_link_strct**) malloc(mds_links_strct->n_link * sizeof(MDS_link_strct*));
mds_links_strct->link3D_list = (MDS_link_strct**) malloc(mds_links_strct->n_link3D * sizeof(MDS_link_strct*));
// reading loop
cur_node = node->children;
......@@ -1091,6 +1092,7 @@ MDS_gen_strct* MDS_mbsDescR7_reader(xmlNodePtr node, xmlDocPtr doc)
xmlNodePtr cur_node;
MDS_gen_strct *mds_gen_strct;
int user_model_created = 0;
if (strcmp((const char*)node->name,"mbsDescR7"))
{
......@@ -1132,6 +1134,7 @@ MDS_gen_strct* MDS_mbsDescR7_reader(xmlNodePtr node, xmlDocPtr doc)
if(!strcmp((const char*)cur_node->name,"user_models"))
{
mds_gen_strct->user_models = MDS_user_models_reader(cur_node, doc);
user_model_created = 1;
}
if(!strcmp((const char*)cur_node->name,"x3D"))
{
......@@ -1140,6 +1143,12 @@ MDS_gen_strct* MDS_mbsDescR7_reader(xmlNodePtr node, xmlDocPtr doc)
}
cur_node = cur_node->next;
}
if(user_model_created == 0) // create a empty user model list, n_usermodel = 0;
{
mds_gen_strct->user_models = init_MDS_user_models_strct();
}
return mds_gen_strct;
}
......@@ -1224,7 +1233,7 @@ void MDS_structurer(MDS_gen_strct* mds_gen_strct)
mds_gen_strct->bodytree->qu = get_int_vec(mds_gen_strct->bodytree->n_qu);
mds_gen_strct->bodytree->qv = get_int_vec(mds_gen_strct->bodytree->n_qv);
mds_gen_strct->bodytree->qc = get_int_vec(mds_gen_strct->bodytree->n_qu);
mds_gen_strct->bodytree->qc = get_int_vec(mds_gen_strct->bodytree->n_qc);
mds_gen_strct->bodytree->qlocked = get_int_vec(mds_gen_strct->bodytree->n_qlocked);
mds_gen_strct->bodytree->qdriven = get_int_vec(mds_gen_strct->bodytree->n_qdriven);
mds_gen_strct->bodytree->qa = get_int_vec(mds_gen_strct->bodytree->n_qa);
......@@ -1419,7 +1428,7 @@ MDS_sensor_strct* init_MDS_sensor_strct(char* name)
mds_sensor_strct = (MDS_sensor_strct*) malloc(sizeof(MDS_sensor_strct));
mds_sensor_strct->name = malloc(strlen(name)+1);
mds_sensor_strct->name = (char*) malloc(strlen(name)+1);
strcpy(mds_sensor_strct->name,name);
mds_sensor_strct->Pos = 0;
......@@ -1444,7 +1453,7 @@ MDS_extforce_strct* init_MDS_extforce_strct(char* name)
mds_extforce_strct = (MDS_extforce_strct*) malloc(sizeof(MDS_extforce_strct));
mds_extforce_strct->name = malloc(strlen(name)+1);
mds_extforce_strct->name = (char*) malloc(strlen(name)+1);
strcpy(mds_extforce_strct->name,name);
mds_extforce_strct->Pos = 0;
......@@ -1470,7 +1479,7 @@ MDS_point_strct* init_MDS_point_strct(char* name)
mds_point_strct = (MDS_point_strct*) malloc(sizeof(MDS_point_strct));
mds_point_strct->name = malloc(strlen(name)+1);
mds_point_strct->name = (char*)malloc(strlen(name)+1);
strcpy(mds_point_strct->name,name);
mds_point_strct->pt = get_double_vec(3);
......@@ -1549,7 +1558,7 @@ MDS_joint_strct* init_MDS_joint_strct(char* name)
mds_joint_strct = (MDS_joint_strct*) malloc(sizeof(MDS_joint_strct));
mds_joint_strct->name = malloc(strlen(name)+1);
mds_joint_strct->name = (char*) malloc(strlen(name)+1);
strcpy(mds_joint_strct->name,name);
mds_joint_strct->type = 0;
......@@ -1583,7 +1592,7 @@ MDS_body_strct* init_MDS_body_strct(char* name)
mds_body_strct = (MDS_body_strct*) malloc(sizeof(MDS_body_strct));
mds_body_strct->name = malloc(strlen(name)+1);
mds_body_strct->name = (char*) malloc(strlen(name)+1);
strcpy(mds_body_strct->name,name);
mds_body_strct->parent = NULL;
......@@ -1686,7 +1695,7 @@ MDS_ball_strct* init_MDS_ball_strct(char* name)
mds_ball_strct = (MDS_ball_strct*) malloc(sizeof(MDS_ball_strct));
mds_ball_strct->name = malloc(strlen(name)+1);
mds_ball_strct->name = (char*) malloc(strlen(name)+1);
strcpy(mds_ball_strct->name,name);
mds_ball_strct->endpoint1 = NULL;
......@@ -1719,7 +1728,7 @@ MDS_rod_strct* init_MDS_rod_strct(char* name)
mds_rod_strct = (MDS_rod_strct*) malloc(sizeof(MDS_rod_strct));
mds_rod_strct->name = malloc(strlen(name)+1);
mds_rod_strct->name = (char*) malloc(strlen(name)+1);
strcpy(mds_rod_strct->name,name);
mds_rod_strct->length = 0.0;
......@@ -1758,7 +1767,7 @@ MDS_solid_strct* init_MDS_solid_strct(char* name)
mds_solid_strct = (MDS_solid_strct*) malloc(sizeof(MDS_solid_strct));
mds_solid_strct->name = malloc(strlen(name)+1);
mds_solid_strct->name = (char*) malloc(strlen(name)+1);
strcpy(mds_solid_strct->name,name);
mds_solid_strct->endpoint1 = NULL;
......@@ -1836,7 +1845,7 @@ MDS_link_strct* init_MDS_link_strct(char* name)
mds_link_strct = (MDS_link_strct*) malloc(sizeof(MDS_link_strct));
mds_link_strct->name = malloc(strlen(name)+1);
mds_link_strct->name = (char*) malloc(strlen(name)+1);
strcpy(mds_link_strct->name,name);
mds_link_strct->endpoint1 = NULL;
......@@ -1900,7 +1909,7 @@ MDS_parameter_strct* init_MDS_parameter_strct(char* name)
mds_parameter_strct = (MDS_parameter_strct*) malloc(sizeof(MDS_parameter_strct));
mds_parameter_strct->name = malloc(strlen(name)+1);
mds_parameter_strct->name = (char*) malloc(strlen(name)+1);
strcpy(mds_parameter_strct->name,name);
mds_parameter_strct->type = 0;
......@@ -1940,7 +1949,7 @@ MDS_user_model_strct* init_MDS_user_model_strct(char* name)
mds_user_model_strct = (MDS_user_model_strct*) malloc(sizeof(MDS_user_model_strct));
mds_user_model_strct->name = malloc(strlen(name)+1);
mds_user_model_strct->name = (char*) malloc(strlen(name)+1);
strcpy(mds_user_model_strct->name,name);
mds_user_model_strct->n_parameter = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment