From ba5e5e041cc8c2557e08c9e7bf0ee98ada4024d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 7 Feb 2022 09:36:26 +0100 Subject: [PATCH 1/4] avoid std::size_t to FT conversion --- .../internal/Hole_filling/Triangulate_hole_polyline.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h index 4f1e2b7fac8..12317131be3 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h @@ -1326,7 +1326,7 @@ triangulate_hole_polyline_with_cdt(const PointRange& points, } FT x = FT(0), y = FT(0), z = FT(0); - std::size_t num_normals = 0; + FT num_normals = 0; const Point_3& ref_point = P[0]; const std::size_t size = P.size() - 1; for (std::size_t i = 1; i < size - 1; ++i) { @@ -1361,9 +1361,9 @@ triangulate_hole_polyline_with_cdt(const PointRange& points, } // Setting the final normal. - x /= static_cast(num_normals); - y /= static_cast(num_normals); - z /= static_cast(num_normals); + x /= num_normals; + y /= num_normals; + z /= num_normals; const Vector_3 avg_normal = Vector_3(x, y, z); // std::cout << "avg normal: " << avg_normal << std::endl; From 705fee5659bed36f13e9264e2e00f8221850cb34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 7 Feb 2022 18:35:07 +0100 Subject: [PATCH 2/4] avoid cascading with Lazy --- .../internal/Hole_filling/Triangulate_hole_polyline.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h index 12317131be3..daa50a3d974 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h @@ -1326,7 +1326,7 @@ triangulate_hole_polyline_with_cdt(const PointRange& points, } FT x = FT(0), y = FT(0), z = FT(0); - FT num_normals = 0; + int num_normals = 0; const Point_3& ref_point = P[0]; const std::size_t size = P.size() - 1; for (std::size_t i = 1; i < size - 1; ++i) { @@ -1361,9 +1361,10 @@ triangulate_hole_polyline_with_cdt(const PointRange& points, } // Setting the final normal. - x /= num_normals; - y /= num_normals; - z /= num_normals; + FT ft_nn(num_normals); + x /= ft_nn; + y /= ft_nn; + z /= ft_nn; const Vector_3 avg_normal = Vector_3(x, y, z); // std::cout << "avg normal: " << avg_normal << std::endl; From 3e90db4824a96d92accec3f78bf647aefe74cf65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 8 Feb 2022 17:00:23 +0100 Subject: [PATCH 3/4] prevent another size_t to FT --- .../Hole_filling/Triangulate_hole_polyline.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h index daa50a3d974..9bb40428d30 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h @@ -1243,7 +1243,7 @@ bool is_planar_2( const Squared_distance_3 squared_distance_3 = traits.compute_squared_distance_3_object(); - const std::size_t n = points.size() - 1; // the first equals to the last + const double n(points.size() - 1); // the first equals to the last if (n < 3) { return false; // cant be a plane! } @@ -1255,8 +1255,8 @@ bool is_planar_2( // Compute covariance matrix. FT xx = FT(0), yy = FT(0), zz = FT(0); FT xy = FT(0), xz = FT(0), yz = FT(0); - for (std::size_t i = 0; i < n; ++i) { - const Point_3& p = points[i]; + for (const Point_3& p : points) + { const FT dx = p.x() - centroid.x(); const FT dy = p.y() - centroid.y(); const FT dz = p.z() - centroid.z(); @@ -1280,12 +1280,12 @@ bool is_planar_2( CGAL_assertion(avg_normal != typename Traits::Vector_3()); const Plane_3 plane = Plane_3(centroid, avg_normal); FT avg_squared_distance = FT(0); - for (std::size_t i = 0; i < n; ++i) { - const Point_3& p = points[i]; + for (const Point_3& p : points) + { const Point_3 q = projection_3(plane, p); avg_squared_distance += CGAL::abs(squared_distance_3(p, q)); } - avg_squared_distance /= static_cast(n); + avg_squared_distance /= FT(n); // std::cout << "avg squared distance: " << avg_squared_distance << std::endl; CGAL_assertion(max_squared_distance >= FT(0)); From 62b54dab3fc73aded9679e6bbaa483cd57924dd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 9 Feb 2022 19:04:45 +0100 Subject: [PATCH 4/4] workaround MSVC warning --- .../internal/Hole_filling/Triangulate_hole_polyline.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h index 9bb40428d30..01bfe3912bb 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h @@ -1243,7 +1243,7 @@ bool is_planar_2( const Squared_distance_3 squared_distance_3 = traits.compute_squared_distance_3_object(); - const double n(points.size() - 1); // the first equals to the last + const double n = static_cast(points.size() - 1); // the first equals to the last if (n < 3) { return false; // cant be a plane! }