void Query::filter_subset(std::set<NodeKey> &nodes, std::set<EdgeKey> &edges, std::set<FaceKey> &faces, std::set<TetrahedronKey> &tets) { nodes.clear(); edges.clear(); faces.clear(); for (auto t : tets){ for (auto f : mesh->get(t).face_keys()){ faces.insert(f); } } for (auto f : faces){ for (auto e : mesh->get(f).edge_keys()){ edges.insert(e); } } for (auto e : edges){ for (auto n : mesh->get(e).node_keys()){ nodes.insert(n); } } // exclude boundary vertices connected to non-manifold edges SimplexSet<TetrahedronKey> tetSet; for (auto t : tets){ tetSet += t; } std::set<TetrahedronKey> tetsToDelete; std::vector<EdgeKey> nonManifoldEdges; for (auto ek : edges){ auto faceKeys = mesh->get(ek).face_keys(); std::vector<TetrahedronKey> boundaryTets; for (auto fk : faceKeys){ Face & face = mesh->get(fk); auto intersection = face.tet_keys() & tetSet; if (intersection.size() == 1){ boundaryTets.push_back(intersection[0]); } } bool isNonManifoldEdge = boundaryTets.size()>2; // has more than two boundary edges if (isNonManifoldEdge){ for (auto tk : boundaryTets){ tetsToDelete.insert(tk); } } } if (!tetsToDelete.empty()){ for (auto tk : tetsToDelete){ tets.erase(tets.find(tk)); } filter_subset(nodes, edges, faces, tets); } }
void Query::filter_subset(std::set<NodeKey> &nodes, std::set<EdgeKey> &edges, std::set<FaceKey> &faces, std::set<TetrahedronKey> &tets) { nodes.clear(); edges.clear(); faces.clear(); for (auto t : tets){ for (auto f : mesh->get(t).face_keys()){ faces.insert(f); } } for (auto f : faces){ for (auto e : mesh->get(f).edge_keys()){ edges.insert(e); } } for (auto e : edges){ for (auto n : mesh->get(e).node_keys()){ nodes.insert(n); } } // exclude boundary vertices connected to non-manifold edges int maxKey = 0; for (auto t:tets){ maxKey = std::max(maxKey, (int)t); } std::vector<bool> tetLookup(maxKey+1, false); for (auto t:tets){ tetLookup[(int)t] = true; } std::set<TetrahedronKey> tetsToDelete; for (auto ek : edges){ auto faceKeys = mesh->get(ek).face_keys(); std::vector<TetrahedronKey> boundaryTets; for (auto fk : faceKeys){ Face & face = mesh->get(fk); auto intersection = face.tet_keys(); if (intersection.size() == 1 && tetLookup[(int)intersection[0]]){ boundaryTets.push_back(intersection[0]); } else if (intersection.size() == 2 && (tetLookup[(int)intersection[0]] ^ tetLookup[(int)intersection[1]])){ if (tetLookup[(int)intersection[0]]){ boundaryTets.push_back(intersection[0]); } else { boundaryTets.push_back(intersection[1]); } } } bool isNonManifoldEdge = boundaryTets.size()>2; // has more than two boundary edges if (isNonManifoldEdge){ for (auto tk : boundaryTets){ tetsToDelete.insert(tk); } } } if (!tetsToDelete.empty()){ for (auto tk : tetsToDelete) { auto iter = tets.find(tk); if (iter != tets.end()){ tets.erase(iter); } } filter_subset(nodes, edges, faces, tets); } }