diff --git a/.gitignore b/.gitignore index 20228a69fcb..2e8ca1978a4 100644 --- a/.gitignore +++ b/.gitignore @@ -1206,3 +1206,5 @@ gmon.* /Stream_support/test/Stream_support/cgal_test_with_cmake /*.html /Snap_rounding_2/test/Snap_rounding_2/data/out +Polygonal_surface_reconstruction/examples/build* +Polygonal_surface_reconstruction/test/build* diff --git a/Polygonal_surface_reconstruction/examples/Polygonal_surface_reconstruction/polyfit_example_without_input_planes.cpp b/Polygonal_surface_reconstruction/examples/Polygonal_surface_reconstruction/polyfit_example_without_input_planes.cpp index c76a997ff72..338b97f2088 100644 --- a/Polygonal_surface_reconstruction/examples/Polygonal_surface_reconstruction/polyfit_example_without_input_planes.cpp +++ b/Polygonal_surface_reconstruction/examples/Polygonal_surface_reconstruction/polyfit_example_without_input_planes.cpp @@ -2,8 +2,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -23,10 +23,11 @@ typedef CGAL::Nth_of_tuple_property_map<0, PNI> Point_map; typedef CGAL::Nth_of_tuple_property_map<1, PNI> Normal_map; typedef CGAL::Nth_of_tuple_property_map<2, PNI> Plane_index_map; -typedef CGAL::Shape_detection_3::Shape_detection_traits Traits; -typedef CGAL::Shape_detection_3::Efficient_RANSAC Efficient_ransac; -typedef CGAL::Shape_detection_3::Plane Plane; -typedef CGAL::Shape_detection_3::Point_to_shape_index_map Point_to_shape_index_map; +typedef CGAL::Shape_detection::Efficient_RANSAC_traits Traits; + +typedef CGAL::Shape_detection::Efficient_RANSAC Efficient_ransac; +typedef CGAL::Shape_detection::Plane Plane; +typedef CGAL::Shape_detection::Point_to_shape_index_map Point_to_shape_index_map; typedef CGAL::Polygonal_surface_reconstruction Polygonal_surface_reconstruction; typedef CGAL::Surface_mesh Surface_mesh; diff --git a/Polygonal_surface_reconstruction/test/Polygonal_surface_reconstruction/polygonal_surface_reconstruction_test.cpp b/Polygonal_surface_reconstruction/test/Polygonal_surface_reconstruction/polygonal_surface_reconstruction_test.cpp index 94debbc6c11..8bbb6e44f04 100644 --- a/Polygonal_surface_reconstruction/test/Polygonal_surface_reconstruction/polygonal_surface_reconstruction_test.cpp +++ b/Polygonal_surface_reconstruction/test/Polygonal_surface_reconstruction/polygonal_surface_reconstruction_test.cpp @@ -11,7 +11,6 @@ #include #include -#include #ifndef SKIP_TEST_USING_GLPK #include @@ -32,16 +31,16 @@ typedef CGAL::GLPK_mixed_integer_program_traits GLPK_Solver; typedef CGAL::SCIP_mixed_integer_program_traits SCIP_Solver; -int main(int argc, char * argv[]) +int main(int argc, char* argv[]) { - std::cerr << "Testing the Polygonal Surface Reconstruction method...\n\n"; + std::cerr << "Testing the Polygonal Surface Reconstruction method...\n"; #if 0 argc = 2; - argv[1] = "data/icosahedron.pwn"; - //argv[1] = "data/house.ply"; - //argv[1] = "data/chair.ply"; - //argv[1] = "data/square.ply"; + argv[1] = "data/icosahedron.pwn"; + //argv[1] = "data/house.ply"; + //argv[1] = "data/chair.ply"; + //argv[1] = "data/square.ply"; #endif // usage @@ -49,7 +48,7 @@ int main(int argc, char * argv[]) std::cerr << "For the input point cloud, reconstruct a water-tight polygonal surface.\n"; std::cerr << "\n"; std::cerr << "Usage: " << argv[0] << " point_cloud_file" << std::endl; - std::cerr << "Input file formats are \'pwn\' and \'ply\'. No output.\n\n"; + std::cerr << "Input file formats are \'pwn\' and \'ply\'. No output.\n"; return EXIT_FAILURE; } @@ -57,50 +56,50 @@ int main(int argc, char * argv[]) //--------------------------------------------------------------------- - std::cerr << "--- Using Simple cartesian kernel\n\n"; + std::cerr << "--- Using Simple cartesian kernel"; //--------------------------------------------------------------------- #ifndef SKIP_TEST_USING_GLPK - std::cerr << "\n\t---- Using GLPK solver\n\n"; + std::cerr << "\n\t---- Using GLPK solver\n"; std::cerr << "\t\t---- using provided planes\n"; reconstruct(input_file, false); - std::cerr << "\n\t\t---- re-extract planes\n"; + std::cerr << "\t\t---- re-extract planes\n"; reconstruct(input_file, true); #endif - std::cerr << "\n\t---- Using SCIP solver\n\n"; + std::cerr << "\n\t---- Using SCIP solver\n"; std::cerr << "\t\t---- using provided planes\n"; reconstruct(input_file, false); - std::cerr << "\n\t\t---- re-extract planes\n\n"; + std::cerr << "\t\t---- re-extract planes\n"; reconstruct(input_file, true); //--------------------------------------------------------------------- - std::cerr << "\n--- Using Epick kernel\n\n"; + std::cerr << "\n--- Using Epick kernel"; //--------------------------------------------------------------------- #ifndef SKIP_TEST_USING_GLPK - std::cerr << "\t---- Using GLPK solver\n\n"; + std::cerr << "\n\t---- Using GLPK solver\n"; std::cerr << "\t\t---- using provided planes\n"; reconstruct(input_file, false); - std::cerr << "\n\t\t---- re-extract planes\n"; + std::cerr << "\t\t---- re-extract planes\n"; reconstruct(input_file, true); #endif - std::cerr << "\n\t---- Using SCIP solver\n\n"; + std::cerr << "\n\t---- Using SCIP solver\n"; std::cerr << "\t\t---- using provided planes\n"; reconstruct(input_file, false); - std::cerr << "\n\t\t---- re-extract planes\n"; + std::cerr << "\t\t---- re-extract planes\n"; reconstruct(input_file, true); } diff --git a/Polygonal_surface_reconstruction/test/Polygonal_surface_reconstruction/polygonal_surface_reconstruction_test_framework.h b/Polygonal_surface_reconstruction/test/Polygonal_surface_reconstruction/polygonal_surface_reconstruction_test_framework.h index 6929b9fa79c..53a89880293 100644 --- a/Polygonal_surface_reconstruction/test/Polygonal_surface_reconstruction/polygonal_surface_reconstruction_test_framework.h +++ b/Polygonal_surface_reconstruction/test/Polygonal_surface_reconstruction/polygonal_surface_reconstruction_test_framework.h @@ -4,8 +4,8 @@ #include #include #include -#include #include +#include #include #include @@ -22,32 +22,32 @@ template int reconstruct(const std::string& input_file, bool force_extract_planes) { - typedef typename Kernel::Point_3 Point; - typedef typename Kernel::Vector_3 Vector; - typedef CGAL::Polygonal_surface_reconstruction Polygonal_surface_reconstruction; - typedef CGAL::Surface_mesh Surface_mesh; + typedef typename Kernel::Point_3 Point; + typedef typename Kernel::Vector_3 Vector; + typedef CGAL::Polygonal_surface_reconstruction Polygonal_surface_reconstruction; + typedef CGAL::Surface_mesh Surface_mesh; - // Point with normal, and plane index - typedef boost::tuple PNI; - typedef std::vector Point_vector; - typedef CGAL::Nth_of_tuple_property_map<0, PNI> Point_map; - typedef CGAL::Nth_of_tuple_property_map<1, PNI> Normal_map; - typedef CGAL::Nth_of_tuple_property_map<2, PNI> Plane_index_map; + // Point with normal, and plane index + typedef boost::tuple PNI; + typedef std::vector Point_vector; + typedef CGAL::Nth_of_tuple_property_map<0, PNI> Point_map; + typedef CGAL::Nth_of_tuple_property_map<1, PNI> Normal_map; + typedef CGAL::Nth_of_tuple_property_map<2, PNI> Plane_index_map; - typedef CGAL::Shape_detection_3::Shape_detection_traits Traits; - typedef CGAL::Shape_detection_3::Efficient_RANSAC Efficient_ransac; - typedef CGAL::Shape_detection_3::Plane Plane; - typedef CGAL::Shape_detection_3::Point_to_shape_index_map Point_to_shape_index_map; + typedef CGAL::Shape_detection::Efficient_RANSAC_traits Traits; + typedef CGAL::Shape_detection::Efficient_RANSAC Efficient_ransac; + typedef CGAL::Shape_detection::Plane Plane; + typedef CGAL::Shape_detection::Point_to_shape_index_map Point_to_shape_index_map; Point_vector points; // Loads point set from a file. std::ifstream input_stream(input_file.c_str()); - if (!input_stream) { - std::cerr << " Error: cannot read file " << input_file << std::endl; - return EXIT_FAILURE; - } + if (!input_stream) { + std::cerr << " Error: cannot read file " << input_file << std::endl; + return EXIT_FAILURE; + } std::cout << "\t\t\tLoading point cloud: " << input_file << "..."; std::string extension = input_file.substr(input_file.find_last_of('.')); @@ -57,34 +57,34 @@ int reconstruct(const std::string& input_file, bool force_extract_planes) CGAL::Timer t; t.start(); if (extension == ".pwn") { - if (!CGAL::read_xyz_points( - input_stream, - std::back_inserter(points), - CGAL::parameters::point_map(Point_map()).normal_map(Normal_map()))) + if (!CGAL::read_xyz_points( + input_stream, + std::back_inserter(points), + CGAL::parameters::point_map(Point_map()).normal_map(Normal_map()))) { - std::cerr << " Error: cannot read file " << input_file << std::endl; + std::cerr << " Error: cannot read file " << input_file << std::endl; return EXIT_FAILURE; } else std::cout << " Done. " << points.size() << " points. Time: " << t.time() << " sec." << std::endl; } else if (extension == ".ply") { - if (!CGAL::read_ply_points_with_properties( - input_stream, - std::back_inserter(points), - CGAL::make_ply_point_reader(Point_map()), - CGAL::make_ply_normal_reader(Normal_map()), - std::make_pair(Plane_index_map(), CGAL::PLY_property("segment_index")))) + if (!CGAL::read_ply_points_with_properties( + input_stream, + std::back_inserter(points), + CGAL::make_ply_point_reader(Point_map()), + CGAL::make_ply_normal_reader(Normal_map()), + std::make_pair(Plane_index_map(), CGAL::PLY_property("segment_index")))) { - std::cerr << " Error: cannot read file " << input_file << std::endl; + std::cerr << " Error: cannot read file " << input_file << std::endl; return EXIT_FAILURE; } else std::cout << " Done. " << points.size() << " points. Time: " << t.time() << " sec." << std::endl; int max_plane_index = 0; - for (std::size_t i = 0; i < points.size(); ++i) { - int plane_index = points[i].template get<2>(); + for (std::size_t i = 0; i < points.size(); ++i) { + int plane_index = points[i].template get<2>(); if (plane_index > max_plane_index) max_plane_index = plane_index; } @@ -106,12 +106,12 @@ int reconstruct(const std::string& input_file, bool force_extract_planes) // Shape detection Efficient_ransac ransac; ransac.set_input(points); - ransac.template add_shape_factory(); + ransac.template add_shape_factory(); t.reset(); ransac.detect(); - typename Efficient_ransac::Plane_range planes = ransac.planes(); + typename Efficient_ransac::Plane_range planes = ransac.planes(); std::size_t num_planes = planes.size(); std::cout << " Done. " << num_planes << " planes extracted. Time: " << t.time() << " sec." << std::endl; @@ -121,7 +121,7 @@ int reconstruct(const std::string& input_file, bool force_extract_planes) for (std::size_t i = 0; i < points.size(); ++i) { // Use the get function from the property map that accesses the 3rd element of the tuple. int plane_index = get(shape_index_map, i); - points[i].template get<2>() = plane_index; + points[i].template get<2>() = plane_index; } } @@ -146,19 +146,19 @@ int reconstruct(const std::string& input_file, bool force_extract_planes) std::cout << "\t\t\tReconstructing..."; t.reset(); - if (!algo.template reconstruct(model)) { + if (!algo.template reconstruct(model)) { std::cerr << " Failed: " << algo.error_message() << std::endl; return EXIT_FAILURE; } - std::cout << " Done. Time: " << t.time() << " sec." << std::endl; + std::cout << " Done. Time: " << t.time() << " sec. "; if (model.is_valid()) { - std::cout << "\t\t\tReconstructed model has " << model.number_of_faces() << " faces" << std::endl; - return EXIT_FAILURE; + std::cout << "\tReconstructed model has " << model.number_of_faces() << " faces" << std::endl; + return EXIT_SUCCESS; } else { - std::cout << "\t\t\tReconstructed model is not valid. Reconstruction maybe failed?" << std::endl; - return EXIT_SUCCESS; + std::cout << "\tReconstructed model is not valid. Reconstruction maybe failed?" << std::endl; + return EXIT_FAILURE; } } diff --git a/Stream_support/include/CGAL/IO/PLY.h b/Stream_support/include/CGAL/IO/PLY.h index 80117459e41..104c85ce0ef 100644 --- a/Stream_support/include/CGAL/IO/PLY.h +++ b/Stream_support/include/CGAL/IO/PLY.h @@ -24,8 +24,6 @@ #include #include -#include - #include #include #include