| 219 | } |
| 220 | |
| 221 | void 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 | } |
no test coverage detected