36 #include "FemlabMeshReader.hpp"
45 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
47 const std::string& rNodeFileName,
48 const std::string& rElementFileName,
49 const std::string& rEdgeFileName)
53 std::string node_file_name = rPathBaseName + rNodeFileName;
54 this->mNodeRawData = this->GetRawDataFromFile(node_file_name);
57 this->mNodeData = TokenizeStringsToDoubles(this->mNodeRawData);
60 this->mpNodeIterator = this->mNodeData.begin();
64 std::string element_file_name = rPathBaseName + rElementFileName;
65 this->mElementRawData = this->GetRawDataFromFile(element_file_name);
68 this->mElementData = TokenizeStringsToInts(this->mElementRawData, SPACE_DIM + 1);
69 this->mpElementIterator = this->mElementData.begin();
77 std::string edge_file_name = rPathBaseName + rEdgeFileName;
78 this->mFaceRawData = this->GetRawDataFromFile(edge_file_name);
81 this->mFaceData = TokenizeStringsToInts(this->mFaceRawData, SPACE_DIM);
82 this->mpFaceIterator = this->mFaceData.begin();
85 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
89 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
90 std::vector < std::vector<double> >
93 std::vector < std::vector < double > >tokenized_data;
96 unsigned dimension_count = 0;
97 std::vector < std::string >::const_iterator the_iterator;
98 for (the_iterator = rRawData.begin(); the_iterator != rRawData.end();
101 const std::string& r_line_of_data = *the_iterator;
102 std::stringstream line_stream (r_line_of_data);
104 if (dimension_count == 0)
107 while (!line_stream.eof())
111 std::vector < double >x_coord;
112 line_stream >> item_coord;
113 x_coord.push_back (item_coord);
114 tokenized_data.push_back (x_coord);
119 unsigned current_node = 0;
122 while (!line_stream.eof())
125 line_stream >> item_coord;
126 tokenized_data[current_node].push_back (item_coord);
134 if (SPACE_DIM != dimension_count)
136 EXCEPTION(
"SPACE_DIM != dimension read from file");
138 return (tokenized_data);
141 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
142 std::vector < std::vector < unsigned > >
145 std::vector < std::vector < unsigned > >tokenized_data;
148 for (
unsigned i = 0; i < dimensionOfObject; i++)
150 const std::string& r_line_of_data = rRawData[i];
151 std::stringstream line_stream (r_line_of_data);
156 while (!line_stream.eof())
160 std::vector < unsigned >first_index;
161 line_stream >> item_index;
162 first_index.push_back ((
unsigned) (item_index - 0.5));
163 tokenized_data.push_back (first_index);
168 unsigned current_node = 0;
171 while (!line_stream.eof())
174 line_stream >> item_index;
175 tokenized_data[current_node].
176 push_back ((
unsigned) (item_index - 0.5));
181 return (tokenized_data);
std::vector< std::vector< double > > TokenizeStringsToDoubles(const std::vector< std::string > &rRawData)
FemlabMeshReader(const std::string &rPathBaseName, const std::string &rNodeFileName, const std::string &rElementFileName, const std::string &rEdgeFileName)
#define EXCEPTION(message)
std::vector< std::vector< unsigned > > TokenizeStringsToInts(const std::vector< std::string > &rRawData, unsigned dimensionOfObject)
virtual ~FemlabMeshReader()