From 0fb60af4e0c4820718b73c937036b53efb938d7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valque=20L=C3=A9o?= Date: Wed, 3 Dec 2025 18:09:21 +0100 Subject: [PATCH] use vector and binary_search instead of set for boundaries vertices --- .../CGAL/Polygon_mesh_processing/clip_convex.h | 15 +++++++-------- .../Polygon_mesh_processing/internal/kernel.h | 4 ++-- .../Polygon_mesh_processing/test_mesh_kernel.cpp | 4 ++-- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip_convex.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip_convex.h index 55a6b5c9b1f..1f275a35c2d 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip_convex.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/clip_convex.h @@ -48,7 +48,6 @@ void clip_convex(PolygonMesh& pm, using FT = typename GT::FT; using Point_3 = typename GT::Point_3; - using Vector_3 = typename GT::Vector_3; Default_visitor default_visitor; Visitor_ref visitor = choose_parameter(get_parameter_reference(np, internal_np::visitor), default_visitor); @@ -139,13 +138,11 @@ void clip_convex(PolygonMesh& pm, if(sign(sp_trg)==EQUAL && direction_to_zero!=POSITIVE){ // Search a vertex around trg coming from positive side bool no_positive_side = true; - bool no_negative_side = true; for(auto v: vertices_around_target(trg ,pm)){ Oriented_side side_v = oriented_side(plane, get(vpm, v)); if(side_v==ON_POSITIVE_SIDE){ src = v; sp_src = sq(plane, get(vpm, src)); - // CGAL_assertion(sq(plane, get(vpm, src)) == sp_src); no_positive_side = false; break; } @@ -163,7 +160,7 @@ void clip_convex(PolygonMesh& pm, // Cut the convex along the plane by marching along crossing edges starting from the previous edge std::vector boundaries; - std::set boundaries_vertices; + std::vector boundaries_vertices; halfedge_descriptor h = halfedge(src, trg, pm).first; if(sign(sp_trg)!=EQUAL) @@ -191,7 +188,7 @@ void clip_convex(PolygonMesh& pm, while(side_trg == ON_ORIENTED_BOUNDARY){ // The edge is along the plane, add it to boundaries boundaries.emplace_back(h); - boundaries_vertices.emplace(target(h, pm)); + boundaries_vertices.emplace_back(target(h, pm)); set_halfedge(target(h, pm), h, pm); h = next(h, pm); @@ -226,7 +223,7 @@ void clip_convex(PolygonMesh& pm, // Split the face halfedge_descriptor sh = CGAL::Euler::split_face(h_previous, h, pm); boundaries.emplace_back(sh); - boundaries_vertices.emplace(target(sh, pm)); + boundaries_vertices.emplace_back(target(sh, pm)); set_halfedge(target(sh, pm), sh, pm); CGAL_assertion(target(sh, pm) == target(h, pm)); @@ -236,11 +233,13 @@ void clip_convex(PolygonMesh& pm, CGAL_assertion(is_valid_polygon_mesh(pm)); CGAL_assertion(!boundaries.empty()); - // Remove the negative side + // ________________________ Remove the negative side _________________________ std::set vertices_to_remove; std::set edges_to_remove; std::set faces_to_remove; + std::sort(boundaries_vertices.begin(), boundaries_vertices.end()); + // Go through to find all elements to delete face_descriptor start_face(face(halfedge(src, pm), pm)); std::stack stack; @@ -259,7 +258,7 @@ void clip_convex(PolygonMesh& pm, if((std::find(boundaries.begin(), boundaries.end(), h)==boundaries.end()) && (std::find(boundaries.begin(), boundaries.end(), opposite(h,pm))==boundaries.end())){ // TODO avoid this linear operation edges_to_remove.emplace(edge(h, pm)); - if(boundaries_vertices.find(target(h, pm))==boundaries_vertices.end()) + if(!std::binary_search(boundaries_vertices.begin(), boundaries_vertices.end(), target(h, pm))) vertices_to_remove.emplace(target(h, pm)); CGAL_assertion(oriented_side(plane, get(vpm, target(h, pm)))!=ON_NEGATIVE_SIDE); face_descriptor fn = face(opposite(h, pm), pm); diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/kernel.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/kernel.h index e1c422d072b..28117776a20 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/kernel.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/kernel.h @@ -348,8 +348,8 @@ public: Construct_point_3(plane_range_pointer planes) : m_planes(planes){} Point_3 operator()(plane_descriptor a, plane_descriptor b, plane_descriptor c){ const std::vector &planes = *m_planes; - auto res = CGAL::Intersections::internal::intersection_point(planes[a].first, planes[b].first, planes[c].first, Kernel()); - return Point_3(a, b, c, *res); + auto res = intersection(planes[a].first, planes[b].first, planes[c].first); + return Point_3(a, b, c, std::get(*res)); } Point_3 operator()(plane_descriptor a, plane_descriptor b, plane_descriptor c, Geometric_point_3 p){ diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_mesh_kernel.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_mesh_kernel.cpp index 366734d4611..4cc977354b9 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_mesh_kernel.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_mesh_kernel.cpp @@ -279,9 +279,9 @@ int main(int argc, char** argv) // test_kernel(filename); // test_kernel_with_rounding(filename); // test_exact_kernel(filename); - test_exact_kernel_with_rounding(filename); + // test_exact_kernel_with_rounding(filename); // test_trettner_kernel(filename); - // test_trettner_epeck_kernel(filename); + test_trettner_epeck_kernel(filename); // test_kernel_with_chull(filename); // test_kernel_with_chull_and_constructions(filename); }