49 std::string node_file_name = rPathBaseName +
".pts";
50 this->mNodeRawData = this->GetRawDataFromFile(node_file_name);
53 std::stringstream node_header_stream(this->mNodeRawData[0]);
55 node_header_stream >> num_nodes;
58 if (SPACE_DIM != 3 || ELEMENT_DIM != 3)
60 EXCEPTION(
"You have asked to read non-3D data. All Memfem data is in 3D.");
64 this->mNodeData = TokenizeStringsToDoubles(this->mNodeRawData);
67 this->mpNodeIterator = this->mNodeData.begin();
70 if (num_nodes != this->mNodeData.size())
75 EXCEPTION(
"Number of nodes does not match expected number declared in header");
80 std::string element_file_name = rPathBaseName +
".tetras";
81 this->mElementRawData = this->GetRawDataFromFile(element_file_name);
84 std::stringstream element_header_stream(this->mElementRawData[0]);
85 unsigned num_elements;
86 element_header_stream >> num_elements;
89 this->mElementData = TokenizeStringsToInts(this->mElementRawData, SPACE_DIM+1,
true);
90 this->mpElementIterator = this->mElementData.begin();
93 if (num_elements != this->mElementData.size())
98 EXCEPTION(
"Number of elements does not match expected number declared in header");
103 std::string face_file_name = rPathBaseName +
".tri";
104 this->mFaceRawData = this->GetRawDataFromFile(face_file_name);
109 this->mFaceData = TokenizeStringsToInts(this->mFaceRawData, SPACE_DIM,
false);
110 this->mpFaceIterator = this->mFaceData.begin();
119 const std::vector<std::string>& rRawData)
121 std::vector<std::vector<double> > tokenized_data;
124 std::vector<std::string>::const_iterator the_iterator;
125 for (the_iterator = rRawData.begin(); the_iterator != rRawData.end(); the_iterator++ )
127 const std::string& r_line_of_data = *the_iterator;
128 std::stringstream line_stream(r_line_of_data);
130 if (the_iterator != rRawData.begin())
132 std::vector<double> current_coords;
135 for (
unsigned i=0; i<SPACE_DIM; i++)
138 line_stream >> item_coord;
139 current_coords.push_back(item_coord);
143 tokenized_data.push_back(current_coords);
147 return tokenized_data;
152 const std::vector<std::string>& rRawData,
153 unsigned dimensionOfObject,
156 std::vector<std::vector<unsigned> > tokenized_data;
158 std::vector<std::string>::const_iterator the_iterator;
159 for (the_iterator = rRawData.begin(); the_iterator != rRawData.end(); the_iterator++ )
161 const std::string& r_line_of_data = *the_iterator;
162 std::stringstream line_stream(r_line_of_data);
164 if (readHeader ==
false || the_iterator != rRawData.begin())
166 std::vector<unsigned> current_indices;
168 for (
unsigned i=0; i<dimensionOfObject; i++)
171 line_stream >> item_index;
174 current_indices.push_back(item_index);
177 tokenized_data.push_back(current_indices);
181 return tokenized_data;