111 std::vector<double> node_data;
114 GetNextLineFromStream(mNodesFile, buffer);
116 std::stringstream buffer_stream(buffer);
119 buffer_stream >> index;
121 unsigned offset = mIndexFromZero ? 0 : 1;
122 if (index != mNodesRead + offset)
124 EXCEPTION(
"Data for node " << mNodesRead <<
" missing");
128 for (
unsigned i=0; i<SPACE_DIM+1; i++)
130 buffer_stream >> node_value;
131 node_data.push_back(node_value);
145 GetNextLineFromStream(mElementsFile, buffer);
147 std::stringstream buffer_stream(buffer);
149 unsigned element_index;
150 buffer_stream >> element_index;
152 unsigned offset = mIndexFromZero ? 0 : 1;
153 if (element_index != mElementsRead + offset)
155 EXCEPTION(
"Data for element " << mElementsRead <<
" missing");
158 unsigned num_nodes_in_element;
159 buffer_stream >> num_nodes_in_element;
163 for (
unsigned i=0; i<num_nodes_in_element; i++)
165 buffer_stream >> node_index;
166 element_data.
NodeIndices.push_back(node_index - offset);
169 if (mNumElementAttributes > 0)
171 assert(mNumElementAttributes == 1);
191 GetNextLineFromStream(mElementsFile, buffer);
193 std::stringstream buffer_stream(buffer);
195 unsigned element_index;
196 buffer_stream >> element_index;
198 unsigned offset = mIndexFromZero ? 0 : 1;
199 if (element_index != mElementsRead + offset)
201 EXCEPTION(
"Data for element " << mElementsRead <<
" missing");
205 unsigned num_nodes_in_element;
206 buffer_stream >> num_nodes_in_element;
209 for (
unsigned i=0; i<num_nodes_in_element; i++)
212 buffer_stream >> node_index;
213 element_data.
NodeIndices.push_back(node_index - offset);
217 unsigned num_faces_in_element;
218 buffer_stream >> num_faces_in_element;
220 element_data.
Faces.resize(num_faces_in_element);
221 for (
unsigned j=0; j<num_faces_in_element; j++)
228 buffer_stream >> face_index;
232 unsigned num_nodes_in_face;
233 buffer_stream >> num_nodes_in_face;
236 for (
unsigned i=0; i<num_nodes_in_face; i++)
238 unsigned node_index_face;
239 buffer_stream >> node_index_face;
240 face_data.
NodeIndices.push_back(node_index_face - offset);
245 element_data.
Faces[j] = face_data;
250 if (mNumElementAttributes > 0)
252 assert(mNumElementAttributes==1);
299 GetNextLineFromStream(mNodesFile, buffer);
300 std::stringstream buffer_stream(buffer);
301 buffer_stream >> mNumNodes >> mNumNodeAttributes;
304 GetNextLineFromStream(mNodesFile, buffer);
305 std::stringstream node_buffer_stream(buffer);
307 unsigned first_index;
308 node_buffer_stream >> first_index;
309 assert(first_index == 0 || first_index == 1);
310 mIndexFromZero = (first_index == 0);
315 GetNextLineFromStream(mNodesFile, buffer);
317 GetNextLineFromStream(mElementsFile, buffer);
318 std::stringstream element_buffer_stream(buffer);
320 element_buffer_stream >> mNumElements >> mNumElementAttributes;
337 getline(fileStream, rawLine);
339 if (fileStream.eof())
341 EXCEPTION(
"Cannot get the next line from node or element file due to incomplete data");
345 rawLine = rawLine.substr(0,rawLine.find(
'#', 0));
347 line_is_blank = (rawLine.find_first_not_of(
" \t", 0) == std::string::npos);
349 while (line_is_blank);