MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / extract_surface_from_hexs

Method extract_surface_from_hexs

src/IO/MSHParser.cpp:172–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170}
171
172void MSHParser::extract_surface_from_hexs() {
173 const VectorI& voxels = m_voxels;
174 const size_t num_vertex_per_voxel = vertex_per_voxel();
175 assert(num_vertex_per_voxel == 8);
176 typedef std::map<Quadruplet, int> FaceCounter;
177 FaceCounter face_counter;
178
179 for (size_t i=0; i<voxels.size(); i+=num_vertex_per_voxel) {
180 const VectorI voxel = voxels.segment(i, num_vertex_per_voxel);
181 Quadruplet voxel_faces[6] = {
182 Quadruplet(voxel[0], voxel[4], voxel[7], voxel[3]),
183 Quadruplet(voxel[1], voxel[2], voxel[6], voxel[5]),
184 Quadruplet(voxel[2], voxel[3], voxel[7], voxel[6]),
185 Quadruplet(voxel[0], voxel[1], voxel[5], voxel[4]),
186 Quadruplet(voxel[0], voxel[3], voxel[2], voxel[1]),
187 Quadruplet(voxel[4], voxel[5], voxel[6], voxel[7])
188 };
189 for (size_t j=0; j<6; j++) {
190 if (face_counter.find(voxel_faces[j]) == face_counter.end()) {
191 face_counter[voxel_faces[j]] = 1;
192 } else {
193 face_counter[voxel_faces[j]] += 1;
194 }
195 }
196 }
197
198 std::vector<int> vertex_buffer;
199 for (FaceCounter::const_iterator itr = face_counter.begin();
200 itr!=face_counter.end(); itr++) {
201 if (itr->second == 1) {
202 const VectorI& f = itr->first.get_ori_data();
203 vertex_buffer.push_back(f[0]);
204 vertex_buffer.push_back(f[1]);
205 vertex_buffer.push_back(f[2]);
206 vertex_buffer.push_back(f[3]);
207 }
208 }
209
210 m_faces.resize(vertex_buffer.size());
211 std::copy(vertex_buffer.begin(), vertex_buffer.end(), m_faces.data());
212}
213
214const VectorF& MSHParser::get_attribute(const std::string& name) const {
215 if (m_loader->is_node_field(name)) {

Callers

nothing calls this directly

Calls 5

QuadrupletClass · 0.85
findMethod · 0.80
sizeMethod · 0.45
endMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected