From f2cc4ff509adcf9162f51f4eec29e178f4a167c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 12 Dec 2023 11:40:01 +0100 Subject: [PATCH 1/3] Fix indentation --- .../poisson_and_parallel_mesh_3.cpp | 40 ++--- .../poisson_reconstruction_example.cpp | 164 +++++++++--------- 2 files changed, 102 insertions(+), 102 deletions(-) diff --git a/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_and_parallel_mesh_3.cpp b/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_and_parallel_mesh_3.cpp index e9f3ce3b5f6..edda8e71d46 100644 --- a/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_and_parallel_mesh_3.cpp +++ b/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_and_parallel_mesh_3.cpp @@ -84,7 +84,7 @@ void poisson_reconstruction(const PointSet& points, const char* output) // Computes average spacing FT average_spacing = CGAL::compute_average_spacing - (points, 6 /* knn = 1 ring */, params::point_map (Point_map())); + (points, 6 /* knn = 1 ring */, params::point_map(Point_map())); time.stop(); std::cout << "Average spacing : " << time.time() << " seconds." << std::endl; @@ -158,30 +158,30 @@ void poisson_reconstruction(const PointSet& points, const char* output) int main(int argc, char* argv[]) { - const std::string file = (argc < 2) ? CGAL::data_file_path("points_3/kitten.xyz") - : std::string(argv[1]); + const std::string file = (argc < 2) ? CGAL::data_file_path("points_3/kitten.xyz") + : std::string(argv[1]); - // Reads the point set file in points[]. - // Note: read_points() requires an iterator over points - // + property maps to access each point's position and normal. - PointList points; - if(!CGAL::IO::read_points(file, std::back_inserter(points), - params::point_map(Point_map()) - .normal_map(Normal_map()))) - { - std::cerr << "Error: cannot read file input file!" << std::endl; - return EXIT_FAILURE; - } + // Reads the point set file in points[]. + // Note: read_points() requires an iterator over points + // + property maps to access each point's position and normal. + PointList points; + if(!CGAL::IO::read_points(file, std::back_inserter(points), + params::point_map(Point_map()) + .normal_map(Normal_map()))) + { + std::cerr << "Error: cannot read file input file!" << std::endl; + return EXIT_FAILURE; + } - std::cout << "File " << file << " has been read, " << points.size() << " points." << std::endl; + std::cout << "File " << file << " has been read, " << points.size() << " points." << std::endl; - std::cout << "\n\n### Sequential mode ###" << std::endl; - poisson_reconstruction(points, "out_sequential.off"); + std::cout << "\n\n### Sequential mode ###" << std::endl; + poisson_reconstruction(points, "out_sequential.off"); #ifdef CGAL_LINKED_WITH_TBB - std::cout << "\n\n### Parallel mode ###" << std::endl; - poisson_reconstruction(points, "out_parallel.off"); + std::cout << "\n\n### Parallel mode ###" << std::endl; + poisson_reconstruction(points, "out_parallel.off"); #endif - return EXIT_SUCCESS; + return EXIT_SUCCESS; } diff --git a/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_reconstruction_example.cpp b/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_reconstruction_example.cpp index e19232017b6..b98ce0c8157 100644 --- a/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_reconstruction_example.cpp +++ b/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_reconstruction_example.cpp @@ -36,105 +36,105 @@ typedef CGAL::Implicit_surface_3 Surfac int main(int argc, char* argv[]) { - // Poisson options - FT sm_angle = 20.0; // Min triangle angle in degrees. - FT sm_radius = 100; // Max triangle size w.r.t. point set average spacing. - FT sm_distance = 0.25; // Surface Approximation error w.r.t. point set average spacing. + // Poisson options + FT sm_angle = 20.0; // Min triangle angle in degrees. + FT sm_radius = 100; // Max triangle size w.r.t. point set average spacing. + FT sm_distance = 0.25; // Surface Approximation error w.r.t. point set average spacing. - // Reads the point set file in points[]. - // Note: read_points() requires an iterator over points - // + property maps to access each point's position and normal. - PointList points; - char* filename = argv[1]; - if(!CGAL::IO::read_points(filename, std::back_inserter(points), - CGAL::parameters::point_map(Point_map()) - .normal_map (Normal_map()))) - { - std::cerr << "Error: cannot read file input file!" << std::endl; - return EXIT_FAILURE; - } + // Reads the point set file in points[]. + // Note: read_points() requires an iterator over points + // + property maps to access each point's position and normal. + PointList points; + char* filename = argv[1]; + if(!CGAL::IO::read_points(filename, std::back_inserter(points), + CGAL::parameters::point_map(Point_map()) + .normal_map (Normal_map()))) + { + std::cerr << "Error: cannot read file input file!" << std::endl; + return EXIT_FAILURE; + } - CGAL::Real_timer total_time; - total_time.start(); + CGAL::Real_timer total_time; + total_time.start(); - // Creates implicit function from the read points using the default solver. + // Creates implicit function from the read points using the default solver. - // Note: this method requires an iterator over points - // + property maps to access each point's position and normal. - Poisson_reconstruction_function function(points.begin(), points.end(), - Point_map(), Normal_map()); + // Note: this method requires an iterator over points + // + property maps to access each point's position and normal. + Poisson_reconstruction_function function(points.begin(), points.end(), + Point_map(), Normal_map()); - // Computes the Poisson indicator function f() - // at each vertex of the triangulation. - if ( ! function.compute_implicit_function() ) - return EXIT_FAILURE; + // Computes the Poisson indicator function f() + // at each vertex of the triangulation. + if (!function.compute_implicit_function()) + return EXIT_FAILURE; - // Computes average spacing - FT average_spacing = CGAL::compute_average_spacing - (points, 6 /* knn = 1 ring */, - CGAL::parameters::point_map (Point_map())); + // Computes average spacing + FT average_spacing = CGAL::compute_average_spacing + (points, 6 /* knn = 1 ring */, + CGAL::parameters::point_map (Point_map())); - // Gets one point inside the implicit surface - // and computes implicit function bounding sphere radius. - Point inner_point = function.get_inner_point(); - Sphere bsphere = function.bounding_sphere(); - FT radius = std::sqrt(bsphere.squared_radius()); + // Gets one point inside the implicit surface + // and computes implicit function bounding sphere radius. + Point inner_point = function.get_inner_point(); + Sphere bsphere = function.bounding_sphere(); + FT radius = std::sqrt(bsphere.squared_radius()); - std::cout << "inner_point = " << inner_point << std::endl; - std::cout << "bsphere = " << bsphere.center() - << "\tsqr = " << bsphere.squared_radius() << std::endl; - std::cout << "radius = " << radius << std::endl; + std::cout << "inner_point = " << inner_point << std::endl; + std::cout << "bsphere = " << bsphere.center() + << "\tsqr = " << bsphere.squared_radius() << std::endl; + std::cout << "radius = " << radius << std::endl; - // Defines the implicit surface: requires defining a - // conservative bounding sphere centered at inner point. - FT sm_sphere_radius = 5.0 * radius; - FT sm_dichotomy_error = sm_distance*average_spacing/1000.0; // Dichotomy error must be << sm_distance - std::cout << "dichotomy error = " << sm_dichotomy_error << std::endl; + // Defines the implicit surface: requires defining a + // conservative bounding sphere centered at inner point. + FT sm_sphere_radius = 5.0 * radius; + FT sm_dichotomy_error = sm_distance*average_spacing/1000.0; // Dichotomy error must be << sm_distance + std::cout << "dichotomy error = " << sm_dichotomy_error << std::endl; - Surface_3 surface(function, - Sphere(inner_point,sm_sphere_radius*sm_sphere_radius), - sm_dichotomy_error/sm_sphere_radius); + Surface_3 surface(function, + Sphere(inner_point,sm_sphere_radius*sm_sphere_radius), + sm_dichotomy_error/sm_sphere_radius); - std::cout << "Surface created." << std::endl; + std::cout << "Surface created." << std::endl; - // Defines surface mesh generation criteria - CGAL::Surface_mesh_default_criteria_3 criteria(sm_angle, // Min triangle angle (degrees) - sm_radius*average_spacing, // Max triangle size - sm_distance*average_spacing); // Approximation error + // Defines surface mesh generation criteria + CGAL::Surface_mesh_default_criteria_3 criteria(sm_angle, // Min triangle angle (degrees) + sm_radius*average_spacing, // Max triangle size + sm_distance*average_spacing); // Approximation error - // Generates surface mesh with manifold option - STr tr; // 3D Delaunay triangulation for surface mesh generation - C2t3 c2t3(tr); // 2D complex in 3D Delaunay triangulation - CGAL::make_surface_mesh(c2t3, // reconstructed mesh - surface, // implicit surface - criteria, // meshing criteria - CGAL::Manifold_with_boundary_tag()); // require manifold mesh + // Generates surface mesh with manifold option + STr tr; // 3D Delaunay triangulation for surface mesh generation + C2t3 c2t3(tr); // 2D complex in 3D Delaunay triangulation + CGAL::make_surface_mesh(c2t3, // reconstructed mesh + surface, // implicit surface + criteria, // meshing criteria + CGAL::Manifold_with_boundary_tag()); // require manifold mesh - if(tr.number_of_vertices() == 0) - return EXIT_FAILURE; + if(tr.number_of_vertices() == 0) + return EXIT_FAILURE; - // saves reconstructed surface mesh - std::ofstream out("kitten_poisson-20-30-0.375.off"); - Polyhedron output_mesh; - CGAL::facets_in_complex_2_to_triangle_mesh(c2t3, output_mesh); + // saves reconstructed surface mesh + std::ofstream out("kitten_poisson-20-30-0.375.off"); + Polyhedron output_mesh; + CGAL::facets_in_complex_2_to_triangle_mesh(c2t3, output_mesh); - total_time.stop(); - std::cout << "Total time : " << total_time.time() << " seconds." << std::endl; + total_time.stop(); + std::cout << "Total time : " << total_time.time() << " seconds." << std::endl; - out << output_mesh; + out << output_mesh; - /// [PMP_distance_snippet] - // computes the approximation error of the reconstruction - double max_dist = - CGAL::Polygon_mesh_processing::approximate_max_distance_to_point_set - (output_mesh, - CGAL::make_range (boost::make_transform_iterator - (points.begin(), CGAL::Property_map_to_unary_function()), - boost::make_transform_iterator - (points.end(), CGAL::Property_map_to_unary_function())), - 4000); - std::cout << "Max distance to point_set: " << max_dist << std::endl; - /// [PMP_distance_snippet] + /// [PMP_distance_snippet] + // computes the approximation error of the reconstruction + double max_dist = + CGAL::Polygon_mesh_processing::approximate_max_distance_to_point_set + (output_mesh, + CGAL::make_range (boost::make_transform_iterator + (points.begin(), CGAL::Property_map_to_unary_function()), + boost::make_transform_iterator + (points.end(), CGAL::Property_map_to_unary_function())), + 4000); + std::cout << "Max distance to point_set: " << max_dist << std::endl; + /// [PMP_distance_snippet] - return EXIT_SUCCESS; + return EXIT_SUCCESS; } From 1c1fe07289b7bc38a5c9ffe187e3f88c81afb3b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 12 Dec 2023 11:43:22 +0100 Subject: [PATCH 2/3] Fix input reading --- .../poisson_and_parallel_mesh_3.cpp | 4 ++-- .../poisson_reconstruction_example.cpp | 20 ++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_and_parallel_mesh_3.cpp b/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_and_parallel_mesh_3.cpp index edda8e71d46..dc8f8df663c 100644 --- a/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_and_parallel_mesh_3.cpp +++ b/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_and_parallel_mesh_3.cpp @@ -158,8 +158,8 @@ void poisson_reconstruction(const PointSet& points, const char* output) int main(int argc, char* argv[]) { - const std::string file = (argc < 2) ? CGAL::data_file_path("points_3/kitten.xyz") - : std::string(argv[1]); + const std::string file = (argc > 1) ? std::string(argv[1]) + : CGAL::data_file_path("points_3/kitten.xyz"); // Reads the point set file in points[]. // Note: read_points() requires an iterator over points diff --git a/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_reconstruction_example.cpp b/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_reconstruction_example.cpp index b98ce0c8157..cc1d801ead8 100644 --- a/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_reconstruction_example.cpp +++ b/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_reconstruction_example.cpp @@ -36,24 +36,26 @@ typedef CGAL::Implicit_surface_3 Surfac int main(int argc, char* argv[]) { - // Poisson options - FT sm_angle = 20.0; // Min triangle angle in degrees. - FT sm_radius = 100; // Max triangle size w.r.t. point set average spacing. - FT sm_distance = 0.25; // Surface Approximation error w.r.t. point set average spacing. + const std::string file = (argc > 1) ? std::string(argv[1]) + : CGAL::data_file_path("points_3/kitten.xyz"); // Reads the point set file in points[]. // Note: read_points() requires an iterator over points // + property maps to access each point's position and normal. PointList points; - char* filename = argv[1]; - if(!CGAL::IO::read_points(filename, std::back_inserter(points), - CGAL::parameters::point_map(Point_map()) - .normal_map (Normal_map()))) + if(!CGAL::IO::read_points(file, std::back_inserter(points), + CGAL::parameters::point_map(Point_map()) + .normal_map(Normal_map()))) { std::cerr << "Error: cannot read file input file!" << std::endl; return EXIT_FAILURE; } + // Poisson options + FT sm_angle = 20.0; // Min triangle angle in degrees. + FT sm_radius = 100; // Max triangle size w.r.t. point set average spacing. + FT sm_distance = 0.25; // Surface Approximation error w.r.t. point set average spacing. + CGAL::Real_timer total_time; total_time.start(); @@ -114,7 +116,7 @@ int main(int argc, char* argv[]) return EXIT_FAILURE; // saves reconstructed surface mesh - std::ofstream out("kitten_poisson-20-30-0.375.off"); + std::ofstream out("poisson_surface.off"); Polyhedron output_mesh; CGAL::facets_in_complex_2_to_triangle_mesh(c2t3, output_mesh); From 34b4b2cdf7ad7c62324a677533a4fbc5f74344a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 13 Dec 2023 09:39:51 +0100 Subject: [PATCH 3/3] Fix warning --- .../poisson_and_parallel_mesh_3.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_and_parallel_mesh_3.cpp b/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_and_parallel_mesh_3.cpp index dc8f8df663c..a039694fcff 100644 --- a/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_and_parallel_mesh_3.cpp +++ b/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/poisson_and_parallel_mesh_3.cpp @@ -113,9 +113,9 @@ void poisson_reconstruction(const PointSet& points, const char* output) time.start(); // Defines surface mesh generation criteria - CGAL::Mesh_criteria_3 criteria(params::facet_angle = sm_angle, - params::facet_size = sm_radius * average_spacing, - params::facet_distance = sm_distance * average_spacing); + Mesh_criteria criteria(params::facet_angle = sm_angle, + params::facet_size = sm_radius * average_spacing, + params::facet_distance = sm_distance * average_spacing); Mesh_domain domain = Mesh_domain::create_implicit_mesh_domain(surface, sm_sphere, params::relative_error_bound(sm_dichotomy_error / sm_sphere_radius));