35 #include "VertexMeshReader.hpp" 41 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
43 : mFilesBaseName(pathBaseName),
44 mIndexFromZero(false),
49 mNumElementAttributes(0)
55 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
61 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
67 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
73 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
80 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
90 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
97 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
108 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
111 std::vector<double> node_data;
116 std::stringstream buffer_stream(buffer);
119 buffer_stream >> index;
128 for (
unsigned i=0; i<SPACE_DIM+1; i++)
130 buffer_stream >> node_value;
131 node_data.push_back(node_value);
138 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
147 std::stringstream buffer_stream(buffer);
149 unsigned element_index;
150 buffer_stream >> element_index;
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);
184 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
193 std::stringstream buffer_stream(buffer);
195 unsigned element_index;
196 buffer_stream >> element_index;
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;
261 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
268 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
276 EXCEPTION(
"Could not open data file: " + file_name);
280 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
284 std::string file_name;
290 EXCEPTION(
"Could not open data file: " + file_name);
294 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
300 std::stringstream buffer_stream(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);
318 std::stringstream element_buffer_stream(buffer);
323 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
330 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
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);
std::ifstream mElementsFile
VertexElementData GetNextElementDataWithFaces()
#define EXCEPTION(message)
ElementData GetNextFaceData()
unsigned mNumElementAttributes
unsigned GetNumElementAttributes() const
std::vector< ElementData > Faces
void GetNextLineFromStream(std::ifstream &fileStream, std::string &rawLine)
std::vector< unsigned > NodeIndices
unsigned GetNumElements() const
VertexMeshReader(std::string pathBaseName)
unsigned GetNumNodes() const
unsigned GetNumEdges() const
ElementData GetNextElementData()
std::string mFilesBaseName
std::vector< double > GetNextNode()
unsigned GetNumFaces() const
unsigned mNumNodeAttributes
std::vector< unsigned > NodeIndices