#include <boost/property_tree/ptree.hpp> #include <boost/property_tree/xml_parser.hpp> #include < boost/foreach.hpp> #include <boost/algorithm/string.hpp> #include <sstream> void SaveToXML () {US
ing namespace boost::p roperty_tree;
Ptree pt;
Writes the container data to XML for (int i = 0; i < s_ptsmap.size (); i++) {Std::stringstream ss_i;
Ss_i << "Vce_map." << "VEC" << i;
for (int j = 0; J < S_ptsmap[i]->size (); j + +) {Std::stringstream ss_j;
Ss_j << "." << "PT" << J;
Auto STR = ss_i.str () + SS_J.STR ();
Pt.add (STR + ". X", S_ptsmap[i]->at (J). x ());
Pt.add (STR + ". Y", S_ptsmap[i]->at (j). Y ());
Pt.add (STR + ". Z", S_ptsmap[i]->at (j). Z ());
}//boost library function boost::p roperty_tree::xml_writer_settings<std::string> settings (' \ t ', 1); Write_xml ("Res/tt.xml", PT, Std::locale (), SettinGS);
} void Readfromxml (const std::string& fileName) {using namespace boost::p roperty_tree;
Ptree pt, Vec_list, point_list;
Read_xml (FileName, PT);
Vec_list = Pt.get_child ("Vce_map");
int i = 0;
for (Auto VEC = Vec_list.begin (); Vec!= vec_list.end (); vec++) {Std::stringstream ss_i;
Ss_i << "Vce_map." << "VEC" << i;
Point_list = Pt.get_child (Ss_i.str ());
int j = 0;
for (Auto point = Point_list.begin (), point!= point_list.end (); point++) {Std::stringstream ss_j;
Ss_j << ". Pt" << J;
Auto STR = ss_i.str () + SS_J.STR ();
float x = pt.get<float> (STR + ". X");
Float y = pt.get<float> (STR + ". Y");
float z = pt.get<float> (STR + ". Z");
S_ptsmap[i]->push_back (OSG::VEC3 (x, Y, z));
j + +;
} i++;
}
}