void PHolderListMgr::ReadPHolderListDES( char *newfile ) { FILE *fp; fp = fopen( newfile, "r" ); char temp[255]; fgets( temp, 255, fp ); Stringc line = temp; int nparm = line.convert_to_integer(); if( nparm > 0 ) { pHolderListMgrPtr->DelAllPHolders(); vector< Geom* > gVec = aircraftPtr->getGeomVec(); gVec.push_back( aircraftPtr->getUserGeom() ); for ( int i = 0 ; i < nparm ; i++ ) { fgets( temp, 255, fp ); line = temp; int istart = 0; int iend = line.search_for_substring(':'); int id = line.get_range( istart, iend-1 ).convert_to_integer(); istart = iend + 1; iend = line.search_for_substring( istart, ':' ); istart = iend + 1; iend = line.search_for_substring( istart, ':' ); Stringc group = line.get_range( istart, iend-1 ); istart = iend + 1; iend = line.search_for_substring( istart, ':' ); Stringc parm = line.get_range( istart, iend-1 ); istart = iend + 1; iend = line.get_length(); double val = line.get_range( istart, iend-1 ).convert_to_double(); Parm* p = parmMgrPtr->FindParm( gVec, id, group, parm ); if ( p ) { p->set_from_link( val ); p->get_geom()->parm_changed( p ); ParmHolder* ph = new ParmHolder(); ph->setParm( p ); m_PHolderVec.push_back( ph ); m_CurrPHolderIndex = (int)m_PHolderVec.size() - 1; } } } fclose( fp ); }
void PHolderListMgr::ReadPHolderListXDDM( char *newfile ) { pHolderListMgrPtr->DelAllPHolders(); //==== Read Xml File ====// xmlDocPtr doc; xmlNodePtr node; LIBXML_TEST_VERSION xmlKeepBlanksDefault(0); //==== Build an XML tree from a the file ====// doc = xmlParseFile(newfile); // if (doc == NULL) return 0; xmlNodePtr root = xmlDocGetRootElement(doc); if (root == NULL) { fprintf(stderr,"empty document\n"); xmlFreeDoc(doc); // return 0; } vector< Geom* > gVec = aircraftPtr->getGeomVec(); gVec.push_back( aircraftPtr->getUserGeom() ); vector< xmlNodePtr > vlist; int num_v = xmlGetNumNames( root, "Variable" ); for ( int i = 0 ; i < num_v ; i++ ) { xmlNodePtr var_node = xmlGetNode( root, "Variable", i ); vlist.push_back( var_node ); } int num_c = xmlGetNumNames( root, "Constant" ); for ( int i = 0 ; i < num_c ; i++ ) { xmlNodePtr cst_node = xmlGetNode( root, "Constant", i ); vlist.push_back( cst_node ); } int num_tot = num_v + num_c; for ( int i = 0 ; i < num_tot ; i++ ) { xmlNodePtr var_node = vlist[i]; if ( var_node ) { Stringc varname = Stringc( xmlFindPropString( var_node, "VSPVarName", " " ) ); int istart = 0; int iend = varname.search_for_substring(':'); int id = varname.get_range( istart, iend-1 ).convert_to_integer(); istart = iend + 1; iend = varname.search_for_substring( istart, ':' ); istart = iend + 1; iend = varname.search_for_substring( istart, ':' ); Stringc group = varname.get_range( istart, iend-1 ); istart = iend + 1; iend = varname.get_length(); Stringc parm = varname.get_range( istart, iend-1 ); Parm* p = parmMgrPtr->FindParm( gVec, id, group, parm ); if ( p ) { double val = xmlFindPropDouble( var_node, "Value", p->get() ); p->set_from_link( val ); p->get_geom()->parm_changed( p ); ParmHolder* ph = new ParmHolder(); ph->setParm( p ); const xmlChar* varstr = (xmlChar*) "Variable"; if( !xmlStrcmp(var_node->name, varstr ) ) ph->setDesType( XDDM_VAR ); else ph->setDesType( XDDM_CONST ); m_PHolderVec.push_back( ph ); m_CurrPHolderIndex = (int)m_PHolderVec.size() - 1; } } } //===== Free Doc =====// xmlFreeDoc( doc ); // return 1; }