Commit 3851738e authored by Alexey Hohlov's avatar Alexey Hohlov
Browse files

Загрузка полигона из конфига

parent d25aaca2
......@@ -35,6 +35,7 @@ public:
float ReadFloat(std::string file, std::string path, std::string attr = "", float def = 0);
double ReadDouble(std::string file, std::string path, std::string attr = "", double def = 0);
std::string ReadStr(std::string file, std::string path, std::string attr = "", std::string def = "");
CPoly * ReadPolygon(std::string file, std::string path);
~CXMLConfig();
};
......@@ -86,6 +86,35 @@ bool CXMLConfig::ReadBool(std::string file, std::string path, std::string attr,
return ret;
}
CPoly * CXMLConfig::ReadPolygon(std::string file, std::string path)
{
CPoly * poly = NULL;
std::vector<std::string> p;
pugi::xml_node node;
if (configs.find(file) != configs.end()) {
if (configs[file].loaded) {
p = split(path,'/');
node = configs[file].doc->child(p[0].c_str());
for (size_t i = 1; i < p.size(); i++) {
node = node.child(p[i].c_str());
}
if (node) {
std::cout << "node found\n" << std::flush;
poly = new CPoly;
for (pugi::xml_node child: node.children()) {
poly->AddVertex(child.attribute("x").as_float(), child.attribute("y").as_float());
}
}
}
}
return poly;
}
CXMLConfig::~CXMLConfig()
{
for (auto& it : configs) {
......
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