void Driver::getPath(char xmlFile[20]) { p.loadFile(xmlFile); p.get_cloud_path(cpath); p.get_mobile_path(mpath); p.get_local_path(lpath); }
void TesterTool::loadMesh(const string& xmlFile, const string& binaryFile, vector<AttributeT>& attribs, vector<GroupT>& groups) { XmlParser xml; xml.loadFile(xmlFile); ifstream fin(binaryFile.c_str(), ios::binary); xml.pushTag("Mesh"); { int numVertices = xml.getAttribute("Vertices", "count", 0); int numAtributes = xml.getAttribute("Vertices", "attributes", 0); xml.pushTag("Vertices"); { for(int i = 0; i < numAtributes; ++i) { AttributeT attrib; std::string tmpAttribName = xml.getAttribute("Attribute", "name", "", i); attrib.name = new char[tmpAttribName.length()+1]; attrib.name[tmpAttribName.length()] = 0; memcpy(attrib.name, tmpAttribName.c_str(), tmpAttribName.size()); attrib.size = xml.getAttribute("Attribute", "size", 0, i); attrib.count = numVertices * attrib.size; attrib.values = new float[attrib.count]; for(int j = 0; j < numVertices; ++j) { for(int k = 0; k < attrib.size; ++k) { float val = 0.0f; fin.read((char *)(&val), sizeof(val)); attrib.values[j*attrib.size + k] = val; } } attribs.push_back(attrib); } } xml.popTag(); int numGroups = xml.getAttribute("Triangles", "groups", 0); string typeIndices = xml.getAttribute("Triangles", "type", ""); xml.pushTag("Triangles"); { for(int i = 0; i < numGroups; ++i) { GroupT group; group.type = new char[typeIndices.length()+1]; group.type[typeIndices.length()] = 0; memcpy(group.type, typeIndices.c_str(), typeIndices.size()); std::string tmpGrName = xml.getAttribute("Group", "name", "", i); group.name = new char[tmpGrName.length()+1]; group.name[tmpGrName.length()] = 0; memcpy(group.name, tmpGrName.c_str(), tmpGrName.size()); group.count = xml.getAttribute("Group", "count", 0, i); int numBytes = 0; if(string(group.type).compare("UNSIGNED_BYTE") == 0) { numBytes = group.count * 3 * static_cast<int>(sizeof(unsigned char)); } else if(string(group.type).compare("UNSIGNED_SHORT") == 0) { numBytes = group.count * 3 * static_cast<int>(sizeof(unsigned short)); } else if(string(group.type).compare("UNSIGNED_INT") == 0) { numBytes = group.count * 3 * static_cast<int>(sizeof(unsigned int)); } group.numBytes = numBytes; group.bytes = new unsigned char[numBytes]; for(int j = 0; j < group.count*3; ++j) { unsigned char val = 0; fin.read((char *)(&val), sizeof(val)); group.bytes[j] = val; } groups.push_back(group); } } xml.popTag(); } xml.popTag(); xml.clear(); fin.close(); }