Skip to content

Commit

Permalink
factorize cap checks
Browse files Browse the repository at this point in the history
  • Loading branch information
sloriot committed Dec 10, 2024
1 parent 116c0ec commit c3e4e32
Showing 1 changed file with 22 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,24 @@ bool remove_almost_degenerate_faces(const FaceRange& face_range,
int kk=0;
std::ofstream(std::string("tmp/n-00000.off")) << tmesh;
#endif

auto run_cap_check = [&](halfedge_descriptor h, bool consider_for_collapse=true)
{
halfedge_descriptor cap_h = internal::is_it_a_cap(face(h, tmesh), tmesh, vpm, vcm, ecm, gt,
cap_threshold, flip_triangle_height_threshold_squared);
if(cap_h != null_h)
{
#ifdef CGAL_PMP_DEBUG_REMOVE_DEGENERACIES_EXTRA
std::cout << "\t\t But the face is a cap" << std::endl;
#endif
edges_to_flip.insert(cap_h);
}
else
{
if (consider_for_collapse) next_edges_to_collapse.insert(h);
}
};

while(!edges_to_collapse.empty())
{
// note that on the first iteration, 'h' does not indicate a known needle
Expand All @@ -772,15 +790,7 @@ bool remove_almost_degenerate_faces(const FaceRange& face_range,
#ifdef CGAL_PMP_DEBUG_REMOVE_DEGENERACIES_EXTRA
std::cout << "\t Needle criterion not verified" << std::endl;
#endif
halfedge_descriptor cap_h = internal::is_it_a_cap(face(h, tmesh), tmesh, vpm, vcm, ecm, gt,
cap_threshold, flip_triangle_height_threshold_squared);
if(cap_h != null_h)
{
#ifdef CGAL_PMP_DEBUG_REMOVE_DEGENERACIES_EXTRA
std::cout << "\t\t But the face is a cap" << std::endl;
#endif
edges_to_flip.insert(cap_h);
}
run_cap_check(h, false);
continue;
}
else
Expand Down Expand Up @@ -809,20 +819,7 @@ bool remove_almost_degenerate_faces(const FaceRange& face_range,
#ifdef CGAL_PMP_DEBUG_REMOVE_DEGENERACIES_EXTRA
std::cout << "\t Geometrically invalid edge collapse!" << std::endl;
#endif
halfedge_descriptor cap_h = internal::is_it_a_cap(face(h, tmesh), tmesh, vpm, vcm, ecm, gt,
cap_threshold, flip_triangle_height_threshold_squared);
if(cap_h != null_h)
{
#ifdef CGAL_PMP_DEBUG_REMOVE_DEGENERACIES_EXTRA
std::cout << "\t\t But the face is a cap" << std::endl;
#endif
edges_to_flip.insert(cap_h);
}
else
{
next_edges_to_collapse.insert(h);
}

run_cap_check(h);
continue;
}

Expand All @@ -831,20 +828,7 @@ bool remove_almost_degenerate_faces(const FaceRange& face_range,
#ifdef CGAL_PMP_DEBUG_REMOVE_DEGENERACIES_EXTRA
std::cout << "\t edge collapse prevented by the user functor" << std::endl;
#endif
halfedge_descriptor cap_h = internal::is_it_a_cap(face(h, tmesh), tmesh, vpm, vcm, ecm, gt,
cap_threshold, flip_triangle_height_threshold_squared);
if(cap_h != null_h)
{
#ifdef CGAL_PMP_DEBUG_REMOVE_DEGENERACIES_EXTRA
std::cout << "\t\t But the face is a cap" << std::endl;
#endif
edges_to_flip.insert(cap_h);
}
else
{
next_edges_to_collapse.insert(h);
}

run_cap_check(h);
continue;
}

Expand Down Expand Up @@ -934,20 +918,7 @@ bool remove_almost_degenerate_faces(const FaceRange& face_range,
#ifdef CGAL_PMP_DEBUG_REMOVE_DEGENERACIES_EXTRA
std::cout << "\t Uncollapsable edge!" << std::endl;
#endif

halfedge_descriptor cap_h = internal::is_it_a_cap(face(h, tmesh), tmesh, vpm, vcm, ecm, gt,
cap_threshold, flip_triangle_height_threshold_squared);
if(cap_h != null_h)
{
#ifdef CGAL_PMP_DEBUG_REMOVE_DEGENERACIES_EXTRA
std::cout << "\t\t But the face is a cap" << std::endl;
#endif
edges_to_flip.insert(cap_h);
}
else
{
next_edges_to_collapse.insert(h);
}
run_cap_check(h);
}
}

Expand Down

0 comments on commit c3e4e32

Please sign in to comment.