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

Method extract_faces_from_voxels

src/IO/VEGAParser.cpp:221–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

219}
220
221void VEGAParser::extract_faces_from_voxels() {
222 if (m_vertex_per_voxel != 4) {
223 throw NotImplementedError("Only tet element is supported");
224 }
225 m_faces.clear();
226
227 typedef std::map<Triplet, unsigned short> FaceCounter;
228 FaceCounter face_counter;
229 for (const auto& voxel : m_voxels) {
230 assert(voxel.size() == 4);
231 Triplet voxel_faces[4] = {
232 Triplet(voxel[0], voxel[2], voxel[1]),
233 Triplet(voxel[0], voxel[1], voxel[3]),
234 Triplet(voxel[0], voxel[3], voxel[2]),
235 Triplet(voxel[1], voxel[2], voxel[3])
236 };
237
238 for (size_t j=0; j<4; j++) {
239 if (face_counter.find(voxel_faces[j]) == face_counter.end()) {
240 face_counter[voxel_faces[j]] = 1;
241 } else {
242 face_counter[voxel_faces[j]] += 1;
243 }
244 }
245 }
246
247 std::vector<int> vertex_buffer;
248 for (FaceCounter::const_iterator itr = face_counter.begin();
249 itr!=face_counter.end(); itr++) {
250 assert(itr->second == 1 || itr->second == 2);
251 if (itr->second == 1) {
252 const VectorI& f = itr->first.get_ori_data();
253 m_faces.push_back(f);
254 }
255 }
256 m_num_faces = m_faces.size();
257 m_vertex_per_face = 3;
258}

Callers 1

MeshFactory.cppFile · 0.45

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