Skip to content

Commit

Permalink
Merge remote-tracking branch 'cgal/5.6.x-branch' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
sloriot committed Dec 23, 2024
2 parents 8f499a4 + 06fa730 commit cb3e182
Show file tree
Hide file tree
Showing 7 changed files with 359 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,10 @@ class Face_graph_output_builder
boost::dynamic_bitset<> coplanar_patches_of_tm2_for_union_and_intersection(nb_patches_tm2,false);
patch_status_not_set_tm1.set();
patch_status_not_set_tm2.set();
// extra containers used when entire connected components are identical (filled only if needed)
std::vector<std::size_t> coplanar_tm1_to_coplanar_tm2;
std::vector<vertex_descriptor> extreme_vertex_per_cc_1;
std::vector<vertex_descriptor> extreme_vertex_per_cc_2;

// first set coplanar status of patches using the coplanar faces collected during the
// extra intersection edges collected. This is important in the case of full connected components
Expand Down Expand Up @@ -1847,8 +1851,61 @@ class Face_graph_output_builder
{
if (coplanar_patches_of_tm1.test(patch_id))
{
if (is_tm1_inside_out == is_tm2_inside_out)
// Two "identical" coplanar patches that are entire connected components
//we have the correspondance between cpln patches thanks to faces in tm1_coplanar_faces and tm2_coplanar_faces
CGAL_assertion(tm1_coplanar_faces.size()==tm2_coplanar_faces.size());
if (coplanar_tm1_to_coplanar_tm2.empty()) // fill container only once
{
coplanar_tm1_to_coplanar_tm2.resize(nb_patches_tm1, NID);
for (std::size_t i=0; i<tm1_coplanar_faces.size(); ++i)
{
std::size_t pid1 = tm1_patch_ids[get(fids1, tm1_coplanar_faces[i])];
std::size_t pid2 = tm2_patch_ids[get(fids2, tm2_coplanar_faces[i])];
coplanar_tm1_to_coplanar_tm2[pid1]=pid2;
}

const vertex_descriptor null_v = boost::graph_traits<TriangleMesh>::null_vertex();
extreme_vertex_per_cc_1.assign(nb_patches_tm1, null_v);
for (face_descriptor fd : faces(tm1))
{
std::size_t patch_id = tm1_patch_ids[get(fids1, fd)];
if (!coplanar_patches_of_tm1.test(patch_id)) continue;
halfedge_descriptor hd=halfedge(fd, tm1);
for (halfedge_descriptor h : CGAL::halfedges_around_face(hd, tm1))
{
vertex_descriptor vd = target(h, tm1);
if (extreme_vertex_per_cc_1[patch_id]==null_v || get(vpm1,extreme_vertex_per_cc_1[patch_id])<get(vpm1,vd))
extreme_vertex_per_cc_1[patch_id]=vd;
}
}

extreme_vertex_per_cc_2.assign(nb_patches_tm2, null_v);
for (face_descriptor fd : faces(tm2))
{
std::size_t patch_id = tm2_patch_ids[get(fids2, fd)];
if (!coplanar_patches_of_tm2.test(patch_id)) continue;
halfedge_descriptor hd=halfedge(fd, tm2);
for (halfedge_descriptor h : CGAL::halfedges_around_face(hd, tm2))
{
vertex_descriptor vd = target(h, tm2);
if (extreme_vertex_per_cc_2[patch_id]==null_v || get(vpm2,extreme_vertex_per_cc_2[patch_id])<get(vpm2,vd))
extreme_vertex_per_cc_2[patch_id]=vd;
}
}
}

const std::size_t patch_id2=coplanar_tm1_to_coplanar_tm2[patch_id];
CGAL_assertion(patch_id2!=NID);

bool is_oo_tm1 = ::CGAL::Polygon_mesh_processing::internal::is_outward_oriented(extreme_vertex_per_cc_1[patch_id], tm1, parameters::vertex_point_map(vpm1)),
is_oo_tm2 = ::CGAL::Polygon_mesh_processing::internal::is_outward_oriented(extreme_vertex_per_cc_2[patch_id2], tm2, parameters::vertex_point_map(vpm2));

if (is_oo_tm1==is_oo_tm2)
{
coplanar_patches_of_tm1_for_union_and_intersection.set(patch_id);
coplanar_patches_of_tm2_for_union_and_intersection.set(patch_id2);
patch_status_not_set_tm2.reset( patch_id2 );
}
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -879,14 +879,14 @@ namespace internal {
std::array<halfedge_descriptor, 2> r1 = internal::is_badly_shaped(
face(he, mesh_),
mesh_, vpmap_, vcmap_, ecmap_, gt_,
cap_threshold, // bound on the angle: above 160 deg => cap
4, // bound on shortest/longest edge above 4 => needle
cap_threshold, // bound on the angle: above 160 deg => cap
0,// collapse length threshold : not needed here
0); // flip triangle height threshold

std::array<halfedge_descriptor, 2> r2 = internal::is_badly_shaped(
face(opposite(he, mesh_), mesh_),
mesh_, vpmap_, vcmap_, ecmap_, gt_, cap_threshold, 4, 0, 0);
mesh_, vpmap_, vcmap_, ecmap_, gt_, 4, cap_threshold, 0, 0);

const bool badly_shaped = (r1[0] != boost::graph_traits<PolygonMesh>::null_halfedge()//needle
|| r1[1] != boost::graph_traits<PolygonMesh>::null_halfedge()//cap
Expand Down
Loading

0 comments on commit cb3e182

Please sign in to comment.