36 #include "PottsMeshReader.hpp" 38 template<
unsigned SPACE_DIM>
40 : mFilesBaseName(pathBaseName),
41 mIndexFromZero(false),
46 mNumElementAttributes(0)
52 template<
unsigned SPACE_DIM>
58 template<
unsigned SPACE_DIM>
64 template<
unsigned SPACE_DIM>
70 template<
unsigned SPACE_DIM>
80 template<
unsigned SPACE_DIM>
87 template<
unsigned SPACE_DIM>
98 template<
unsigned SPACE_DIM>
101 std::vector<double> node_data;
106 std::stringstream buffer_stream(buffer);
109 buffer_stream >> index;
118 for (
unsigned i=0; i<SPACE_DIM+1; i++)
120 buffer_stream >> node_value;
121 node_data.push_back(node_value);
128 template<
unsigned SPACE_DIM>
137 std::stringstream buffer_stream(buffer);
139 unsigned element_index;
140 buffer_stream >> element_index;
148 unsigned num_nodes_in_element;
149 buffer_stream >> num_nodes_in_element;
153 for (
unsigned i=0; i<num_nodes_in_element; i++)
155 buffer_stream >> node_index;
156 element_data.
NodeIndices.push_back(node_index - offset);
163 unsigned attribute_value;
164 buffer_stream >> attribute_value;
176 template<
unsigned SPACE_DIM>
183 template<
unsigned SPACE_DIM>
191 EXCEPTION(
"Could not open data file: " + file_name);
195 template<
unsigned SPACE_DIM>
199 std::string file_name;
205 EXCEPTION(
"Could not open data file: " + file_name);
209 template<
unsigned SPACE_DIM>
215 std::stringstream buffer_stream(buffer);
220 std::stringstream node_buffer_stream(buffer);
222 unsigned first_index;
223 node_buffer_stream >> first_index;
224 assert(first_index == 0 || first_index == 1);
233 std::stringstream element_buffer_stream(buffer);
238 template<
unsigned SPACE_DIM>
245 template<
unsigned SPACE_DIM>
252 getline(fileStream, rawLine);
254 if (fileStream.eof())
256 EXCEPTION(
"Cannot get the next line from node or element file due to incomplete data");
260 rawLine = rawLine.substr(0,rawLine.find(
'#', 0));
262 line_is_blank = (rawLine.find_first_not_of(
" \t", 0) == std::string::npos);
264 while (line_is_blank);
std::ifstream mElementsFile
std::vector< double > GetNextNode()
#define EXCEPTION(message)
unsigned GetNumNodes() const
unsigned GetNumElementAttributes() const
void GetNextLineFromStream(std::ifstream &fileStream, std::string &rawLine)
unsigned mNumNodeAttributes
unsigned mNumElementAttributes
std::vector< unsigned > NodeIndices
PottsMeshReader(std::string pathBaseName)
ElementData GetNextElementData()
unsigned GetNumFaces() const
ElementData GetNextFaceData()
std::string mFilesBaseName
unsigned GetNumElements() const