handle all patches by operations

this workaround issue with boundary non-manifold vertices
that we needs to be imported
This commit is contained in:
Sébastien Loriot 2021-12-07 11:30:34 +01:00
parent 33fd57c0f1
commit 8ca5971699
1 changed files with 66 additions and 46 deletions

View File

@ -1086,9 +1086,17 @@ void append_patches_to_triangle_mesh(
Triangle_mesh_extension_helper<TriangleMesh, reverse_patch_orientation> Triangle_mesh_extension_helper<TriangleMesh, reverse_patch_orientation>
helper(tm_to_output_edges, tm, output); helper(tm_to_output_edges, tm, output);
std::vector<std::size_t> ids_of_patches_to_append;
ids_of_patches_to_append.reserve(patches_to_append.count());
for (std::size_t i=patches_to_append.find_first(); for (std::size_t i=patches_to_append.find_first();
i < patches_to_append.npos; i < patches_to_append.npos;
i = patches_to_append.find_next(i)) i = patches_to_append.find_next(i))
{
ids_of_patches_to_append.push_back(i);
}
std::vector<halfedge_descriptor> interior_vertex_halfedges;
for (std::size_t i : ids_of_patches_to_append)
{ {
#ifdef CGAL_COREFINEMENT_POLYHEDRA_DEBUG #ifdef CGAL_COREFINEMENT_POLYHEDRA_DEBUG
#warning the size of tm_to_output_edges will increase at each step \ #warning the size of tm_to_output_edges will increase at each step \
@ -1099,8 +1107,6 @@ void append_patches_to_triangle_mesh(
Patch_description<TriangleMesh>& patch = patches[i]; Patch_description<TriangleMesh>& patch = patches[i];
std::vector<halfedge_descriptor> interior_vertex_halfedges;
//insert interior halfedges and create interior vertices //insert interior halfedges and create interior vertices
for(halfedge_descriptor h : patch.interior_edges) for(halfedge_descriptor h : patch.interior_edges)
{ {
@ -1146,6 +1152,11 @@ void append_patches_to_triangle_mesh(
interior_vertex_halfedges.push_back( new_h_opp ); interior_vertex_halfedges.push_back( new_h_opp );
} }
} }
}
for (std::size_t i : ids_of_patches_to_append)
{
Patch_description<TriangleMesh>& patch = patches[i];
//create faces and connect halfedges //create faces and connect halfedges
for(face_descriptor f : patch.faces) for(face_descriptor f : patch.faces)
@ -1164,6 +1175,7 @@ void append_patches_to_triangle_mesh(
set_face(hedges[i], new_f, output); set_face(hedges[i], new_f, output);
} }
} }
}
// handle interior edges that are on the border of the mesh: // handle interior edges that are on the border of the mesh:
// they do not have a prev/next pointer set since only the pointers // they do not have a prev/next pointer set since only the pointers
@ -1178,6 +1190,9 @@ void append_patches_to_triangle_mesh(
// pointer to be set // pointer to be set
std::vector<halfedge_descriptor> border_halfedges_source_to_link; std::vector<halfedge_descriptor> border_halfedges_source_to_link;
std::vector<halfedge_descriptor> border_halfedges_target_to_link; std::vector<halfedge_descriptor> border_halfedges_target_to_link;
for (std::size_t i : ids_of_patches_to_append)
{
Patch_description<TriangleMesh>& patch = patches[i];
for(halfedge_descriptor h : patch.interior_edges) for(halfedge_descriptor h : patch.interior_edges)
if (is_border_edge(h,tm)) if (is_border_edge(h,tm))
{ {
@ -1204,6 +1219,8 @@ void append_patches_to_triangle_mesh(
CGAL_assertion(is_border(h_out,output) && is_border(h_out_next,output)); CGAL_assertion(is_border(h_out,output) && is_border(h_out_next,output));
set_next(h_out, h_out_next, output); set_next(h_out, h_out_next, output);
} }
}
// now the step (ii) we look for the candidate halfedge by turning around // now the step (ii) we look for the candidate halfedge by turning around
// the vertex in the direction of the interior of the patch // the vertex in the direction of the interior of the patch
for(halfedge_descriptor h_out : border_halfedges_target_to_link) for(halfedge_descriptor h_out : border_halfedges_target_to_link)
@ -1239,6 +1256,9 @@ void append_patches_to_triangle_mesh(
}while(h_out != next_around_vertex); }while(h_out != next_around_vertex);
} }
for (std::size_t i : ids_of_patches_to_append)
{
Patch_description<TriangleMesh>& patch = patches[i];
// For all patch boundary vertices, update the vertex pointer // For all patch boundary vertices, update the vertex pointer
// of all but the vertex halfedge // of all but the vertex halfedge
for(halfedge_descriptor h : patch.shared_edges) for(halfedge_descriptor h : patch.shared_edges)