Spline::Spline(const char * filename, float precision) { controlPoints = loadXMLFile(filename); int size = controlPoints.size(); boost::numeric::ublas::matrix<float> leftM = fillLeftMatrix(size); boost::numeric::ublas::vector<float> vectorDx = initDeltaVector(size); boost::numeric::ublas::vector<float> vectorDy = initDeltaVector(size); boost::numeric::ublas::vector<float> vectorDz = initDeltaVector(size); boost::numeric::ublas::vector<float> vectorBx = fillRightVector(controlPoints,0); boost::numeric::ublas::vector<float> vectorBy = fillRightVector(controlPoints,1); boost::numeric::ublas::vector<float> vectorBz = fillRightVector(controlPoints,2); boost::numeric::ublas::matrix<float> inverseLeftM = gaussJordan(leftM); vectorDx = prod(inverseLeftM,vectorBx); vectorDy = prod(inverseLeftM,vectorBy); vectorDz = prod(inverseLeftM,vectorBz); for(unsigned int i=0 ; i<vectorDx.size() ; i++){ if(abs(vectorDx[i])<0.001) vectorDx[i]=0; if(abs(vectorDy[i])<0.001) vectorDy[i]=0; if(abs(vectorDz[i])<0.001) vectorDz[i]=0; } createSpline(0.001, precision, vectorDx, vectorDy, vectorDz); }
//Reads in the file passed in and returns it as an XML node XMLNode *xmlRead(char* file) { chrPtr = 0; loadXMLFile(file); XMLNode *docNode = xmlCreateNode(DOCUMENT_NODE, DOCUMENT_NAME, NULL); parseNode(docNode); free(xmlArray); return docNode; }
UAVFlightPlan::UAVFlightPlan(const string &s, PLAN_TYPE type, bool loop) :loop_(loop) { #ifdef USE_XML if (type == XML) { loadXMLFile(s); } #else if (type == QGC) { fromQGCFile(s); } #endif }
void SceneXMLParser::loadSimulation(const std::string& file_name, bool rendering_enabled, bool gpu_enabled, openglframework::GLFWViewer* viewer, Simulation** sim, scalar& dt, scalar& max_time, scalar& steps_per_sec_cap, openglframework::Color& bgcolor, std::string& description) { // Load the xml document std::vector<char> xmlchars; rapidxml::xml_document<> doc; loadXMLFile( file_name, xmlchars, doc ); // Attempt to locate the root node rapidxml::xml_node<>* node = doc.first_node("scene"); if( node == NULL ) { std::cerr << outputmod::startred << "ERROR IN XMLSCENEPARSER:" << outputmod::endred << "Failed to parse xml scene file. Failed to locate root <scene> node. Exiting." << std::endl; exit(1); } loadMaxTime(node, max_time); loadMaxSimFrequency(node, steps_per_sec_cap); if (rendering_enabled) { loadCamera(node, viewer); loadViewport(node, viewer); } Stepper* stepper = NULL; loadStepper(node, dt, &stepper); loadBackgroundColor(node, bgcolor); loadSceneDescriptionString(node, description); Scene* scene = new Scene(); loadSimpleGravityForces(node, *scene); loadFluids(node, *scene, gpu_enabled); SceneRenderer *renderer = NULL; if (rendering_enabled) renderer = new SceneRenderer(scene); *sim = new Simulation(scene, stepper, renderer); }
void TwoDSceneXMLParser::loadSceneFromXML( const std::string& filename, TwoDScene& twodscene, SceneStepper** scenestepper, scalar& dt, scalar& max_t, scalar& maxfreq, std::vector<renderingutils::Color>& particle_colors, std::vector<renderingutils::Color>& edge_colors, std::vector<renderingutils::ParticlePath>& particle_paths, renderingutils::Color& bgcolor, std::string& description, std::string& scenetag, TwoDimensionalDisplayController& display) { assert( *scenestepper == NULL ); //std::cout << "Loading scene: " << filename << std::endl; // Load the xml document std::vector<char> xmlchars; rapidxml::xml_document<> doc; loadXMLFile( filename, xmlchars, doc ); // Attempt to locate the root node rapidxml::xml_node<>* node = doc.first_node("scene"); if( node == NULL ) { std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse xml scene file. Failed to locate root <scene> node. Exiting." << std::endl; exit(1); } // TODO: Clear old state // Camera loadCameraLocation(node, display); // Scene loadParticles( node, twodscene ); loadEdges( node, twodscene ); loadSceneTag( node, scenetag ); // Forces loadSpringForces( node, twodscene ); loadSimpleGravityForces( node, twodscene ); loadGravitationalForces( node, twodscene ); loadDragDampingForces( node, twodscene ); loadVorexForces( node, twodscene ); // Integrator/solver loadIntegrator( node, scenestepper, dt ); loadMaxTime( node, max_t ); // UI loadMaxSimFrequency( node, maxfreq ); // Rendering state particle_colors.resize(twodscene.getNumParticles(),renderingutils::Color(0.650980392156863,0.294117647058824,0.0)); loadParticleColors( node, particle_colors ); edge_colors.resize(twodscene.getNumEdges(),renderingutils::Color(0.0,0.388235294117647,0.388235294117647)); loadEdgeColors( node, edge_colors ); loadBackgroundColor( node, bgcolor ); loadParticlePaths( node, dt, particle_paths ); std::string description_string; loadSceneDescriptionString( node, description ); }
XMLStack::XMLStack(char *xmlFilePath, bool isOn) { XMLVersion = 1.0; loggerOn = isOn; encoding = "ISO-8859-1"; state = XML_READY; if(xmlFilePath) state = loadXMLFile(xmlFilePath); else state = XML_FILE_NOT_FOUND; };
void StableFluidsSimXMLParser::loadExecutableSimulation( const std::string& file_name, scalar& max_time, int& velocity_pattern, std::string& description, std::string& scenetag, scalar &diff, scalar &visc ) { // Load the xml document std::vector<char> xmlchars; rapidxml::xml_document<> doc; loadXMLFile( file_name, xmlchars, doc ); // Attempt to locate the root node rapidxml::xml_node<>* node = doc.first_node("scene"); if( node == NULL ) { std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse xml scene file. Failed to locate root <scene> node. Exiting." << std::endl; exit(1); } // Determine what simulation type this is (particle, rigid body, etc) std::string simtype; loadSimulationType( node, simtype ); // Parse common state loadMaxTime( node, max_time ); loadSceneDescriptionString( node, description ); loadSceneTag( node, scenetag ); // Parse the user-requested simulation type. The default is a particle simulation. if( simtype == "stable-fluids" ) { loadVelocityPattern( node, velocity_pattern ); loadDiffusion( node, diff ); loadViscosity( node, visc ); } else { std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Invalid simtype '" << simtype << "' specified. Valid options are 'particle-system' and 'rigid-body'. Exiting." << std::endl; exit(1); } }
int main(int argc, char* argv[]) { // Basic syntax checking for "-x name" format while ((argc > 2) && (argv[1][0] == '-') && (argv[1][1] != '\x00') && (argv[1][2] == '\x00') && (argv[2][0] != '\x00') && (argv[2][0] != '-')) { switch (argv[1][1]) { case 's': --argc; ++argv; pSourceDirectory = argv[1]; break; } ++argv; --argc; } if (pSourceDirectory == NULL) { printf("\nWrong Arguments given !\n"); PrintUsage(); return 1; } printf("\nXBMC-XML2PO v0.96 by Team XBMC\n"); ProjRootDir = pSourceDirectory; ProjRootDir = AddSlash(ProjRootDir); if ((FileExist(ProjRootDir + "addon.xml")) && (FileExist(ProjRootDir + "resources" + DirSepChar + "language" + DirSepChar + "English" + DirSepChar + "strings.xml"))) projType = ADDON; else if ((FileExist(ProjRootDir + "addon.xml")) && (FileExist(ProjRootDir + "language" + DirSepChar + "English" + DirSepChar + "strings.xml"))) projType = SKIN; else if (FileExist(ProjRootDir + "addon.xml")) projType = ADDON_NOSTRINGS; else if (FileExist(ProjRootDir + "xbmc" + DirSepChar + "GUIInfoManager.h")) projType = CORE; else projType = UNKNOWN; std::string strprojType; switch (projType) { case ADDON: strprojType = "Addon with translatable strings"; WorkingDir = ProjRootDir + DirSepChar + "resources" + DirSepChar + "language"+ DirSepChar; break; case SKIN: strprojType = "Skin addon"; WorkingDir = ProjRootDir + DirSepChar + "language"+ DirSepChar; break; case ADDON_NOSTRINGS: strprojType = "Addon without any translatable strings"; break; case CORE: strprojType = "XBMC core"; WorkingDir = ProjRootDir + DirSepChar + "language" + DirSepChar; break; default: strprojType = "Unknown"; WorkingDir = ProjRootDir; break; } if (projType == ADDON || projType == ADDON_NOSTRINGS || projType == SKIN) loadAddonXMLFile(ProjRootDir + "addon.xml"); else if (projType == CORE) { ProjTextName = "XBMC Core"; ProjProvider = "Team XBMC"; ProjName = "xbmc.core"; LoadCoreVersion(ProjRootDir + "xbmc" + DirSepChar + "GUIInfoManager.h"); } printf ("Project type detected:\t%s\n", strprojType.c_str()); printf ("\nProject name:\t\t%s\n", ProjTextName.c_str()); printf ("Project id:\t\t%s\n", ProjName.c_str()); printf ("Project version:\t%s\n", ProjVersion.c_str()); printf ("Project provider:\t%s\n", ProjProvider.c_str()); if (projType == ADDON_NOSTRINGS) { if (!DirExists(ProjRootDir + "resources") && (!MakeDir(ProjRootDir + "resources"))) { printf ("fatal error: not able to create resources directory at dir: %s", ProjRootDir.c_str()); return 1; } if (!DirExists(ProjRootDir + "resources" + DirSepChar + "language") && (!MakeDir(ProjRootDir + "resources"+ DirSepChar + "language"))) { printf ("fatal error: not able to create language directory at dir: %s", (ProjRootDir + "resources").c_str()); return 1; } WorkingDir = ProjRootDir + "resources"+ DirSepChar + "language" + DirSepChar; for (itAddonXMLData = mapAddonXMLData.begin(); itAddonXMLData != mapAddonXMLData.end(); itAddonXMLData++) { if (!DirExists(WorkingDir + FindLang(itAddonXMLData->first)) && (!MakeDir(WorkingDir + FindLang(itAddonXMLData->first)))) { printf ("fatal error: not able to create %s language directory at dir: %s", itAddonXMLData->first.c_str(), WorkingDir.c_str()); return 1; } } } if (projType !=ADDON_NOSTRINGS && !loadXMLFile(xmlDocSourceInput, WorkingDir + "English" + DirSepChar + "strings.xml", &mapSourceXmlId, true)) { printf("Fatal error: no English source xml file found or it is corrupted\n"); return 1; } printf("\nResults:\n\n"); printf("Langcode\tString match\tOutput file\n"); printf("--------------------------------------------------------------\n"); ConvertXML2PO(WorkingDir + "English" + DirSepChar, "en", 2, "(n != 1)", false); DIR* Dir; struct dirent *DirEntry; Dir = opendir(WorkingDir.c_str()); int langcounter =0; std::map<std::string, CLangData> mapLangList; std::map<std::string, CLangData>::iterator itmapLangList; while((DirEntry=readdir(Dir))) { if (DirEntry->d_type == DT_DIR && DirEntry->d_name[0] != '.' && strcmp(DirEntry->d_name, "English")) { CLangData Langdat; Langdat.LLangCode = FindLangCode(DirEntry->d_name); Langdat.LPlurals = GetnPlurals(DirEntry->d_name); Langdat.LPlurForm = GetPlurForm(DirEntry->d_name); mapLangList [DirEntry->d_name] = Langdat; } } for (itmapLangList = mapLangList.begin(); itmapLangList != mapLangList.end(); itmapLangList++) { bool bRunConvert = false;; if (projType == ADDON_NOSTRINGS || projType == ADDON || projType == SKIN) bRunConvert = true; if ((projType != ADDON_NOSTRINGS && loadXMLFile(xmlDocForeignInput, WorkingDir + itmapLangList->first + DirSepChar + "strings.xml", &mapForeignXmlId, false)) || bRunConvert) { ConvertXML2PO(WorkingDir + itmapLangList->first + DirSepChar, itmapLangList->second.LLangCode, itmapLangList->second.LPlurals, itmapLangList->second.LPlurForm, true); langcounter++; } } printf("\nReady. Processed %i languages.\n", langcounter+1); if (bUnknownLangFound) printf("\nWarning: At least one language found with unpaired language code !\n" "Please edit the .po file manually and correct the language code, plurals !\n" "Also please report this to [email protected] if possible !\n\n"); return 0; }
XMLP_ret XMLProfileManager::loadDefaultXMLFile() { return loadXMLFile(DEFAULT_FASTRTPS_PROFILES); }
int main(int argc, char* argv[]) { bBreakLines = false; // By default we don't break lines // Basic syntax checking for "-x name" format while ((argc > 2) && (argv[1][0] == '-') && (argv[1][1] != '\x00') && (argv[1][2] == '\x00') && (argv[2][0] != '\x00') && (argv[2][0] != '-')) { switch (argv[1][1]) { case 's': --argc; ++argv; pSourceDirectory = argv[1]; break; case 'p': --argc; ++argv; pProjectName = argv[1]; break; case 'v': --argc; ++argv; pVersionNumber = argv[1]; break; case 'b': --argc; ++argv; pBreaklineOption = argv[1]; break; } ++argv; --argc; } if (pSourceDirectory == NULL) { printf("\nWrong Arguments given !\n"); PrintUsage(); return 1; } if (pBreaklineOption != NULL) bBreakLines = true; printf("\nXBMC-XML2PO v0.9 by Team XBMC\n"); printf("\nResults:\n\n"); printf("Langcode\tString match\tAuto contexts\tOutput file\n"); printf("--------------------------------------------------------------\n"); WorkingDir = pSourceDirectory; if (WorkingDir[0] != DirSepChar[0]) WorkingDir.append(DirSepChar); if (!loadXMLFile(xmlDocSourceInput, WorkingDir + "English" + DirSepChar + "strings.xml", &mapSourceXmlId, true)) { printf("Fatal error: no English source xml file found or it is corrupted\n"); return 1; } ConvertXML2PO(WorkingDir + "English" + DirSepChar, "en", 2, "(n != 1)", false); DIR* Dir; struct dirent *DirEntry; Dir = opendir(WorkingDir.c_str()); int langcounter =0; while((DirEntry=readdir(Dir))) { std::string LName = ""; if (DirEntry->d_type == DT_DIR && DirEntry->d_name[0] != '.' && strcmp(DirEntry->d_name, "English")) { if (loadXMLFile(xmlDocForeignInput, WorkingDir + DirEntry->d_name + DirSepChar + "strings.xml", &mapForeignXmlId, false)) { ConvertXML2PO(WorkingDir + DirEntry->d_name + DirSepChar, FindLangCode(DirEntry->d_name), GetnPlurals(DirEntry->d_name), GetPlurForm(DirEntry->d_name), true); langcounter++; } } } printf("\nReady. Processed %i languages.\n", langcounter+1); if (bUnknownLangFound) printf("\nWarning: At least one language found with unpaired language code !\n" "Please edit the .po file manually and correct the language code, plurals !\n" "Also please report this to [email protected] if possible !\n\n"); return 0; }
void XMLBuilder::build() { // set the node to document pointer by the file name. setNode(loadXMLFile()); }
std::vector<MapSelectData> XMLMapListParser::getMapList() { return loadXMLFile("list_map.xml"); }
SettingsManager::SettingsManager(){ settings=new ofxXmlSettings(); loadXMLFile(); }