From 9eda4485d2283b6cb67ebaabbcf981ab2046c9cd Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Fri, 18 Aug 2023 11:06:30 +0200 Subject: [PATCH 1/3] changed the output from unoriented polygon soup to oriented polygon mesh --- .../include/CGAL/Polygonal_surface_reconstruction.h | 11 ++++++++++- .../internal/point_set_with_planes.h | 12 ++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Polygonal_surface_reconstruction/include/CGAL/Polygonal_surface_reconstruction.h b/Polygonal_surface_reconstruction/include/CGAL/Polygonal_surface_reconstruction.h index e78c2d390a65..9ca8016600b6 100644 --- a/Polygonal_surface_reconstruction/include/CGAL/Polygonal_surface_reconstruction.h +++ b/Polygonal_surface_reconstruction/include/CGAL/Polygonal_surface_reconstruction.h @@ -18,6 +18,10 @@ #include #include #include +#include +#include +#include +#include #include @@ -455,7 +459,12 @@ namespace CGAL { // Converts from internal data structure to the required `PolygonMesh`. output_mesh.clear(); // make sure it is empty. - CGAL::copy_face_graph(target_mesh, output_mesh); + std::vector points; + std::vector > polygons; + CGAL::Polygon_mesh_processing::polygon_mesh_to_polygon_soup(target_mesh, points, polygons); + CGAL::Polygon_mesh_processing::merge_duplicate_points_in_polygon_soup(points, polygons); + CGAL::Polygon_mesh_processing::orient_polygon_soup(points, polygons); + CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh(points, polygons, output_mesh); } else { error_message_ = "solving the binary program failed"; diff --git a/Polygonal_surface_reconstruction/include/CGAL/Polygonal_surface_reconstruction/internal/point_set_with_planes.h b/Polygonal_surface_reconstruction/include/CGAL/Polygonal_surface_reconstruction/internal/point_set_with_planes.h index 09d628e7f4e0..02e68d733ce6 100644 --- a/Polygonal_surface_reconstruction/include/CGAL/Polygonal_surface_reconstruction/internal/point_set_with_planes.h +++ b/Polygonal_surface_reconstruction/include/CGAL/Polygonal_surface_reconstruction/internal/point_set_with_planes.h @@ -67,6 +67,18 @@ namespace CGAL { delete supporting_plane_; supporting_plane_ = new Plane; CGAL::linear_least_squares_fitting_3(pts.begin(), pts.end(), *supporting_plane_, CGAL::Dimension_tag<0>()); + + // Check orientation + int vote_for_opposite = 0; + for (std::size_t i = 0; i < size(); i++) + if (supporting_plane_->orthogonal_vector() * point_set_->normal_map()[at(i)] < 0) + vote_for_opposite++; + else + vote_for_opposite--; + + if (vote_for_opposite > 0) + *supporting_plane_ = supporting_plane_->opposite(); + return supporting_plane_; } From d3b5cd997cfa98cb4de7d7415c2bd8ce6c66d989 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Fri, 18 Aug 2023 12:05:26 +0200 Subject: [PATCH 2/3] added Polygon_mesh_processing to dependencies --- .../doc/Polygonal_surface_reconstruction/dependencies | 1 + .../package_info/Polygonal_surface_reconstruction/dependencies | 1 + 2 files changed, 2 insertions(+) diff --git a/Polygonal_surface_reconstruction/doc/Polygonal_surface_reconstruction/dependencies b/Polygonal_surface_reconstruction/doc/Polygonal_surface_reconstruction/dependencies index 43aca366b54b..ffd752d9c821 100644 --- a/Polygonal_surface_reconstruction/doc/Polygonal_surface_reconstruction/dependencies +++ b/Polygonal_surface_reconstruction/doc/Polygonal_surface_reconstruction/dependencies @@ -5,5 +5,6 @@ Circulator Alpha_shapes_2 Surface_mesh Point_set_processing_3 +Polygon_mesh_processing Solver_interface Shape_detection diff --git a/Polygonal_surface_reconstruction/package_info/Polygonal_surface_reconstruction/dependencies b/Polygonal_surface_reconstruction/package_info/Polygonal_surface_reconstruction/dependencies index cf61d44e4ba4..650e4a65343e 100644 --- a/Polygonal_surface_reconstruction/package_info/Polygonal_surface_reconstruction/dependencies +++ b/Polygonal_surface_reconstruction/package_info/Polygonal_surface_reconstruction/dependencies @@ -22,6 +22,7 @@ Point_set_3 Point_set_processing_3 Polygon Polygonal_surface_reconstruction +Polygon_mesh_processing Principal_component_analysis Principal_component_analysis_LGPL Profiling_tools From 33e88b2e8fea8fd747a4095d7ab6665aaeb3456a Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Mon, 21 Aug 2023 11:33:50 +0200 Subject: [PATCH 3/3] removing PMP dependency following review [skip ci] --- .../doc/Polygonal_surface_reconstruction/dependencies | 1 - 1 file changed, 1 deletion(-) diff --git a/Polygonal_surface_reconstruction/doc/Polygonal_surface_reconstruction/dependencies b/Polygonal_surface_reconstruction/doc/Polygonal_surface_reconstruction/dependencies index ffd752d9c821..43aca366b54b 100644 --- a/Polygonal_surface_reconstruction/doc/Polygonal_surface_reconstruction/dependencies +++ b/Polygonal_surface_reconstruction/doc/Polygonal_surface_reconstruction/dependencies @@ -5,6 +5,5 @@ Circulator Alpha_shapes_2 Surface_mesh Point_set_processing_3 -Polygon_mesh_processing Solver_interface Shape_detection