43 namespace SpatialDomains
65 TiXmlDocument doc(infilename);
67 bool loadOkay = doc.LoadFile();
68 std::stringstream errstr;
69 errstr <<
"Unable to load file: " << infilename <<
"\n";
70 errstr << doc.ErrorDesc() <<
" (Line " << doc.ErrorRow()
71 <<
", Column " << doc.ErrorCol() <<
")";
82 TiXmlHandle docHandle(&doc);
84 TiXmlElement* mesh = NULL;
87 mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
89 ASSERTL0(mesh,
"Unable to find GEOMETRY tag in file.");
99 TiXmlHandle docHandle(&doc);
100 TiXmlElement* mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
101 TiXmlElement* field = NULL;
104 field = mesh->FirstChildElement(
"ELEMENT");
106 ASSERTL0(field,
"Unable to find ELEMENT tag in file.");
108 int nextElementNumber = -1;
113 TiXmlElement *segment = field->FirstChildElement(
"S");
120 int err = segment->QueryIntAttribute(
"ID", &indx);
121 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read element attribute ID.");
124 TiXmlNode* elementChild = segment->FirstChild();
125 while(elementChild && elementChild->Type() != TiXmlNode::TINYXML_TEXT)
127 elementChild = elementChild->NextSibling();
130 ASSERTL0(elementChild,
"Unable to read element description body.");
131 std::string elementStr = elementChild->ToText()->ValueStr();
135 int vertex1, vertex2;
136 std::istringstream elementDataStrm(elementStr.c_str());
140 elementDataStrm >> vertex1;
141 elementDataStrm >> vertex2;
143 ASSERTL0(!elementDataStrm.fail(), (std::string(
"Unable to read element data for SEGMENT: ") + elementStr).c_str());
148 seg->SetGlobalID(indx);
154 (std::string(
"Unable to read element data for segment: ") + elementStr).c_str());
158 segment = segment->NextSiblingElement(
"S");
161 ASSERTL0(nextElementNumber >= 0,
"At least one element must be specified.");
166 TiXmlHandle docHandle(&doc);
169 TiXmlElement* mesh = docHandle.FirstChildElement(
"NEKTAR").FirstChildElement(
"GEOMETRY").Element();
170 TiXmlElement* field = NULL;
172 ASSERTL0(mesh,
"Unable to find GEOMETRY tag in file.");
175 field = mesh->FirstChildElement(
"COMPOSITE");
177 ASSERTL0(field,
"Unable to find COMPOSITE tag in file.");
179 TiXmlElement *node = field->FirstChildElement(
"C");
182 int nextCompositeNumber = -1;
189 nextCompositeNumber++;
192 int err = node->QueryIntAttribute(
"ID", &indx);
193 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read attribute ID.");
196 TiXmlNode* compositeChild = node->FirstChild();
201 while(compositeChild && compositeChild->Type() != TiXmlNode::TINYXML_TEXT)
203 compositeChild = compositeChild->NextSibling();
206 ASSERTL0(compositeChild,
"Unable to read composite definition body.");
207 std::string compositeStr = compositeChild->ToText()->ValueStr();
211 std::istringstream compositeDataStrm(compositeStr.c_str());
216 std::string prevCompositeElementStr;
218 while (!compositeDataStrm.fail())
220 std::string compositeElementStr;
221 compositeDataStrm >> compositeElementStr;
223 if (!compositeDataStrm.fail())
233 if (compositeElementStr.length() > 0)
237 prevCompositeElementStr = compositeElementStr;
244 (std::string(
"Unable to read COMPOSITE data for composite: ") + compositeStr).c_str());
248 node = node->NextSiblingElement(
"C");
251 ASSERTL0(nextCompositeNumber >= 0,
"At least one composite must be specified.");
264 std::istringstream tokenStream(token);
265 std::istringstream prevTokenStream(prevToken);
272 std::string::size_type indxBeg = token.find_first_of(
'[') + 1;
273 std::string::size_type indxEnd = token.find_last_of(
']') - 1;
275 ASSERTL0(indxBeg <= indxEnd, (std::string(
"Error reading index definition:") + token).c_str());
277 std::string indxStr = token.substr(indxBeg, indxEnd - indxBeg + 1);
279 typedef vector<unsigned int> SeqVectorType;
280 SeqVectorType seqVector;
287 prevTokenStream >> prevType;
290 bool validSequence = (prevToken.empty() ||
291 (type ==
'V' && prevType ==
'V') ||
292 (type ==
'S' && prevType ==
'S'));
294 ASSERTL0(validSequence, (std::string(
"Invalid combination of composite items: ")
295 + type +
" and " + prevType +
".").c_str());
304 char errStr[16] =
"";
305 ::sprintf(errStr,
"%d", *iter);
320 char errStr[16] =
"";
321 ::sprintf(errStr,
"%d", *iter);