Merge pull request #5429 from sloriot/PMP-coref_face_patch_init

Corefine: always init faces of patches
This commit is contained in:
Laurent Rineau 2021-03-03 17:33:02 +01:00
commit 83244deabb
1 changed files with 17 additions and 19 deletions

View File

@ -625,12 +625,9 @@ struct Patch_description{
// shared_edges will be filled by halfedges pointing in the patch // shared_edges will be filled by halfedges pointing in the patch
// that are inside `is_intersection_edge`, thus mesh boundary halfedges // that are inside `is_intersection_edge`, thus mesh boundary halfedges
// are not necessarily inside. // are not necessarily inside.
template <class PolygonMesh, class FaceIndexMap, class IsIntersectionEdge> template <class PolygonMesh, class IsIntersectionEdge>
void extract_patch_simplices( void extract_patch_simplices(
std::size_t patch_id,
PolygonMesh& pm, PolygonMesh& pm,
const FaceIndexMap fids,
const std::vector<std::size_t>& patch_ids,
std::vector<typename boost::graph_traits<PolygonMesh>::face_descriptor>& patch_faces, std::vector<typename boost::graph_traits<PolygonMesh>::face_descriptor>& patch_faces,
std::set<typename boost::graph_traits<PolygonMesh>::vertex_descriptor>& interior_vertices, std::set<typename boost::graph_traits<PolygonMesh>::vertex_descriptor>& interior_vertices,
std::vector<typename boost::graph_traits<PolygonMesh>::halfedge_descriptor>& interior_edges, std::vector<typename boost::graph_traits<PolygonMesh>::halfedge_descriptor>& interior_edges,
@ -642,11 +639,8 @@ void extract_patch_simplices(
typedef typename GT::vertex_descriptor vertex_descriptor; typedef typename GT::vertex_descriptor vertex_descriptor;
typedef typename GT::face_descriptor face_descriptor; typedef typename GT::face_descriptor face_descriptor;
for(face_descriptor f : faces(pm)) for(face_descriptor f : patch_faces)
{ {
if ( patch_ids[ get(fids, f) ]==patch_id )
{
patch_faces.push_back( f );
for(halfedge_descriptor h : for(halfedge_descriptor h :
halfedges_around_face(halfedge(f, pm),pm)) halfedges_around_face(halfedge(f, pm),pm))
{ {
@ -659,7 +653,6 @@ void extract_patch_simplices(
shared_edges.push_back(h); shared_edges.push_back(h);
} }
} }
}
std::set<vertex_descriptor> border_vertices; std::set<vertex_descriptor> border_vertices;
for(halfedge_descriptor h : shared_edges) for(halfedge_descriptor h : shared_edges)
@ -699,14 +692,19 @@ struct Patch_container{
, patch_ids(patch_ids) , patch_ids(patch_ids)
, fids(fids) , fids(fids)
, is_intersection_edge(is_intersection_edge) , is_intersection_edge(is_intersection_edge)
{} {
typedef boost::graph_traits<PolygonMesh> GT;
typedef typename GT::face_descriptor face_descriptor;
for(face_descriptor f : faces(pm))
patches[patch_ids[ get(fids, f) ]].faces.push_back( f );
}
Patch_description<PolygonMesh>& operator[](std::size_t i) { Patch_description<PolygonMesh>& operator[](std::size_t i) {
if ( !patches[i].is_initialized ) if ( !patches[i].is_initialized )
{ {
extract_patch_simplices( extract_patch_simplices(
i, pm, pm,
fids, patch_ids,
patches[i].faces, patches[i].interior_vertices, patches[i].faces, patches[i].interior_vertices,
patches[i].interior_edges, patches[i].shared_edges, patches[i].interior_edges, patches[i].shared_edges,
is_intersection_edge is_intersection_edge