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

Method extract_faces_from_voxels

src/IO/NodeParser.cpp:282–319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

280}
281
282void NodeParser::extract_faces_from_voxels() {
283 if (m_vertex_per_voxel != 4) {
284 throw NotImplementedError("Only tet element is supported");
285 }
286 m_faces.clear();
287
288 typedef std::map<Triplet, unsigned short> FaceCounter;
289 FaceCounter face_counter;
290 for (const auto& voxel : m_voxels) {
291 assert(voxel.size() == 4);
292 Triplet voxel_faces[4] = {
293 Triplet(voxel[0], voxel[2], voxel[1]),
294 Triplet(voxel[0], voxel[1], voxel[3]),
295 Triplet(voxel[0], voxel[3], voxel[2]),
296 Triplet(voxel[1], voxel[2], voxel[3])
297 };
298
299 for (size_t j=0; j<4; j++) {
300 if (face_counter.find(voxel_faces[j]) == face_counter.end()) {
301 face_counter[voxel_faces[j]] = 1;
302 } else {
303 face_counter[voxel_faces[j]] += 1;
304 }
305 }
306 }
307
308 std::vector<int> vertex_buffer;
309 for (FaceCounter::const_iterator itr = face_counter.begin();
310 itr!=face_counter.end(); itr++) {
311 assert(itr->second == 1 || itr->second == 2);
312 if (itr->second == 1) {
313 const VectorI& f = itr->first.get_ori_data();
314 m_faces.push_back(f);
315 }
316 }
317 m_num_faces = m_faces.size();
318 m_vertex_per_face = 3;
319}

Callers

nothing calls this directly

Calls 7

NotImplementedErrorClass · 0.85
TripletClass · 0.85
findMethod · 0.80
clearMethod · 0.45
sizeMethod · 0.45
endMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected