diff --git a/AABB_tree/examples/AABB_tree/AABB_cached_bbox_example.cpp b/AABB_tree/examples/AABB_tree/AABB_cached_bbox_example.cpp index 8aa5505ad26..dc81b53098d 100644 --- a/AABB_tree/examples/AABB_tree/AABB_cached_bbox_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_cached_bbox_example.cpp @@ -1,7 +1,5 @@ -#include -#include - #include + #include #include #include @@ -9,6 +7,9 @@ #include #include +#include +#include + typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef K::FT FT; typedef K::Point_3 Point_3; @@ -26,8 +27,12 @@ void triangle_mesh(const char* fname) typedef CGAL::AABB_tree Tree; TriangleMesh tmesh; - std::ifstream in(fname); - in >> tmesh; + if(!CGAL::read_polygon_mesh(fname, tmesh) || CGAL::is_triangle_mesh(tmesh)) + { + std::cerr << "Invalid input." << std::endl; + return; + } + Timer t; t.start(); Tree tree(faces(tmesh).first, faces(tmesh).second, tmesh); @@ -36,7 +41,6 @@ void triangle_mesh(const char* fname) std::cout << "Closest point to ORIGIN:" << tree.closest_point(CGAL::ORIGIN) << std::endl; } - Bbox_3 bbox(boost::graph_traits::face_descriptor fd, const Surface_mesh& p) { @@ -47,7 +51,6 @@ Bbox_3 bbox(boost::graph_traits::face_descriptor fd, return res; } - void surface_mesh_cache_bbox(const char* fname) { typedef boost::graph_traits::face_descriptor face_descriptor; @@ -64,9 +67,9 @@ void surface_mesh_cache_bbox(const char* fname) t.start(); Bbox_pmap bb = tmesh.add_property_map("f:bbox",Bbox_3()).first; - for(face_descriptor fd : faces(tmesh)){ + for(face_descriptor fd : faces(tmesh)) put(bb, fd, bbox(fd,tmesh)); - } + Traits traits(bb); Tree tree(traits); tree.insert(faces(tmesh).first, faces(tmesh).second, tmesh); @@ -77,7 +80,6 @@ void surface_mesh_cache_bbox(const char* fname) std::cout << "Closest point to ORIGIN:" << tree.closest_point(CGAL::ORIGIN) << std::endl; } - int main(int argc, char* argv[]) { std::cout << "Polyhedron_3" << std::endl; diff --git a/AABB_tree/examples/AABB_tree/AABB_ray_shooting_example.cpp b/AABB_tree/examples/AABB_tree/AABB_ray_shooting_example.cpp index 84321218cd6..2a8bfbec29b 100644 --- a/AABB_tree/examples/AABB_tree/AABB_ray_shooting_example.cpp +++ b/AABB_tree/examples/AABB_tree/AABB_ray_shooting_example.cpp @@ -1,14 +1,15 @@ -#include -#include - #include +#include + #include #include -#include #include #include #include +#include +#include + typedef CGAL::Simple_cartesian K; typedef K::FT FT; typedef K::Point_3 Point; @@ -24,8 +25,8 @@ typedef CGAL::AABB_traits Traits; typedef CGAL::AABB_tree Tree; typedef boost::optional::Type> Ray_intersection; - -struct Skip { +struct Skip +{ face_descriptor fd; Skip(const face_descriptor fd) @@ -44,14 +45,20 @@ struct Skip { int main(int argc, char* argv[]) { const char* filename = (argc > 1) ? argv[1] : "data/tetrahedron.off"; - std::ifstream input(filename); + Mesh mesh; - input >> mesh; + if(!CGAL::read_polygon_mesh(filename, mesh)) + { + std::cerr << "Invalid input." << std::endl; + return 1; + } + Tree tree(faces(mesh).first, faces(mesh).second, mesh); double d = CGAL::Polygon_mesh_processing::is_outward_oriented(mesh)?-1:1; - for(face_descriptor fd : faces(mesh)){ + for(face_descriptor fd : faces(mesh)) + { halfedge_descriptor hd = halfedge(fd,mesh); Point p = CGAL::centroid(mesh.point(source(hd,mesh)), mesh.point(target(hd,mesh)), @@ -61,13 +68,16 @@ int main(int argc, char* argv[]) Ray ray(p,d * v); Skip skip(fd); Ray_intersection intersection = tree.first_intersection(ray, skip); - if(intersection){ + if(intersection) + { if(boost::get(&(intersection->first))){ const Point* p = boost::get(&(intersection->first) ); std::cout << *p << std::endl; } } } + std::cerr << "done" << std::endl; + return 0; } diff --git a/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/reconstruction_structured.cpp b/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/reconstruction_structured.cpp index e7a7b4ba5e5..e2c9d92048e 100644 --- a/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/reconstruction_structured.cpp +++ b/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/reconstruction_structured.cpp @@ -113,8 +113,7 @@ int main (int argc, char* argv[]) const char* fname = (argc>1) ? argv[1] : "data/cube.pwn"; // Loading point set from a file. - if (!CGAL::read_points(fname, - std::back_inserter(points), + if (!CGAL::read_points(fname, std::back_inserter(points), CGAL::parameters::point_map(Point_map()). normal_map(Normal_map()))) { diff --git a/BGL/examples/BGL_surface_mesh/connected_components.cpp b/BGL/examples/BGL_surface_mesh/connected_components.cpp index b2009f0da35..e76fe3c31f7 100644 --- a/BGL/examples/BGL_surface_mesh/connected_components.cpp +++ b/BGL/examples/BGL_surface_mesh/connected_components.cpp @@ -14,9 +14,14 @@ typedef boost::graph_traits::vertex_descriptor vertex_descriptor; int main(int argc, char* argv[]) { + const char* filename = (argc > 1) ? argv[1] : "data/prim.off"; + Mesh sm; - std::ifstream in((argc>1)?argv[1]:"data/prim.off"); - in >> sm; + if(!CGAL::read_polygon_mesh(filename, sm)) + { + std::cerr << "Invalid input." << std::endl; + return 1; + } Mesh::Property_map ccmap; ccmap = sm.add_property_map("v:CC").first; diff --git a/BGL/examples/BGL_surface_mesh/prim.cpp b/BGL/examples/BGL_surface_mesh/prim.cpp index f54256de873..c98b0b4a582 100644 --- a/BGL/examples/BGL_surface_mesh/prim.cpp +++ b/BGL/examples/BGL_surface_mesh/prim.cpp @@ -14,10 +14,15 @@ typedef boost::graph_traits::vertex_descriptor vertex_descriptor; int main(int argc, char* argv[]) { + const char* filename = (argc>1) ? argv[1] : "data/prim.off"; + Mesh P; - //std::cin >> P; - std::ifstream in((argc>1)?argv[1]:"data/prim.off"); - in >> P; + if(!CGAL::read_polygon_mesh(filename, P)) + { + std::cerr << "Invalid input." << std::endl; + return 1; + } + Mesh::Property_map predecessor; predecessor = P.add_property_map("v:predecessor").first; diff --git a/BGL/examples/BGL_surface_mesh/seam_mesh.cpp b/BGL/examples/BGL_surface_mesh/seam_mesh.cpp index 98cf38e8b4c..92e446a0ee7 100644 --- a/BGL/examples/BGL_surface_mesh/seam_mesh.cpp +++ b/BGL/examples/BGL_surface_mesh/seam_mesh.cpp @@ -4,14 +4,15 @@ #include #include + #include +#include #include #include #include #include - typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_3 Point; typedef CGAL::Surface_mesh Mesh; @@ -30,12 +31,16 @@ typedef boost::graph_traits::halfedge_descriptor halfedge_descr typedef boost::graph_traits::edge_descriptor edge_descriptor; typedef boost::graph_traits::face_descriptor face_descriptor; - int main(int argc, char* argv[]) { + const char* filename = (argc>1) ? argv[1] : "data/cube.off"; + Mesh sm; - std::ifstream in((argc>1) ? argv[1] : "data/cube.off"); - in >> sm; + if(!CGAL::read_polygon_mesh(filename, sm)) + { + std::cerr << "Invalid input." << std::endl; + return 1; + } Seam_edge_pmap seam_edge_pm = sm.add_property_map("e:on_seam", false).first; diff --git a/BGL/examples/BGL_surface_mesh/surface_mesh_dual.cpp b/BGL/examples/BGL_surface_mesh/surface_mesh_dual.cpp index 91c2b51c79e..0031a0e2cd4 100644 --- a/BGL/examples/BGL_surface_mesh/surface_mesh_dual.cpp +++ b/BGL/examples/BGL_surface_mesh/surface_mesh_dual.cpp @@ -37,12 +37,13 @@ typedef boost::graph_traits::edge_descriptor edge_descriptor; int main(int argc, char* argv[]) { - Mesh primal; const char* filename = (argc > 1) ? argv[1] : "data/prim.off"; - std::ifstream in(filename); - if(!(in >> primal)) { - std::cerr << "Error reading polyhedron from file " << filename << std::endl; - return EXIT_FAILURE; + + Mesh primal; + if(!CGAL::read_polygon_mesh(filename, primal)) + { + std::cerr << "Invalid input." << std::endl; + return 1; } Dual dual(primal); diff --git a/BGL/examples/BGL_surface_mesh/surface_mesh_partition.cpp b/BGL/examples/BGL_surface_mesh/surface_mesh_partition.cpp index 3abe54c8953..3fa6921f638 100644 --- a/BGL/examples/BGL_surface_mesh/surface_mesh_partition.cpp +++ b/BGL/examples/BGL_surface_mesh/surface_mesh_partition.cpp @@ -13,11 +13,15 @@ typedef CGAL::Surface_mesh SM; int main(int argc, char** argv) { - const char* filename = (argc>1)?argv[1]:"data/blobby.off"; + const char* filename = (argc>1) ? argv[1] : "data/blobby.off"; int number_of_parts = (argc>2) ? atoi(argv[2]) : 8; SM sm; - CGAL::read_polygon_mesh(filename, sm); + if(!CGAL::read_polygon_mesh(filename, sm)) + { + std::cerr << "Invalid input." << std::endl; + return 1; + } // The vertex <--> partition_id property map typedef SM::Property_map Vertex_id_map; diff --git a/Classification/examples/Classification/example_classification.cpp b/Classification/examples/Classification/example_classification.cpp index 377038f7058..327aa1e0aa8 100644 --- a/Classification/examples/Classification/example_classification.cpp +++ b/Classification/examples/Classification/example_classification.cpp @@ -47,12 +47,11 @@ typedef Classification::Feature::Vertical_dispersion int main (int argc, char** argv) { - std::string filename (argc > 1 ? argv[1] : "data/b9.ply"); - std::ifstream in (filename.c_str()); - std::vector pts; + const char* filename = (argc > 1) ? argv[1] : "data/b9.ply"; std::cerr << "Reading input" << std::endl; - if (!in || !(CGAL::read_points(in, std::back_inserter(pts)))) + std::vector pts; + if (!(CGAL::read_points(filename, std::back_inserter(pts)))) { std::cerr << "Error: cannot read " << filename << std::endl; return EXIT_FAILURE; diff --git a/Classification/examples/Classification/example_cluster_classification.cpp b/Classification/examples/Classification/example_cluster_classification.cpp index 3c4b08f60e6..3731851e758 100644 --- a/Classification/examples/Classification/example_cluster_classification.cpp +++ b/Classification/examples/Classification/example_cluster_classification.cpp @@ -49,19 +49,16 @@ typedef Classification::Cluster Clu int main (int argc, char** argv) { - std::string filename = "data/b9.ply"; - std::string filename_config = "data/b9_clusters_config.gz"; - - if (argc > 1) - filename = argv[1]; - if (argc > 2) - filename_config = argv[2]; - - std::ifstream in (filename.c_str(), std::ios::binary); - Point_set pts; + std::string filename = (argc>1) ? argv[1] : "data/b9.ply"; + std::string filename_config = (argc>2) ? argv[2] : "data/b9_clusters_config.gz"; std::cerr << "Reading input" << std::endl; - in >> pts; + Point_set pts; + if(!(CGAL::read_point_set(filename, pts))) + { + std::cerr << "Error: cannot read " << filename << std::endl; + return EXIT_FAILURE; + } std::cerr << "Estimating normals" << std::endl; CGAL::Real_timer t; diff --git a/Classification/examples/Classification/example_feature.cpp b/Classification/examples/Classification/example_feature.cpp index 87638724e84..68d75446f17 100644 --- a/Classification/examples/Classification/example_feature.cpp +++ b/Classification/examples/Classification/example_feature.cpp @@ -67,11 +67,10 @@ public: int main (int argc, char** argv) { std::string filename (argc > 1 ? argv[1] : "data/b9.ply"); - std::ifstream in (filename.c_str()); std::vector pts; std::cerr << "Reading input" << std::endl; - if (!in || !(CGAL::read_points(in, std::back_inserter(pts)))) + if (!(CGAL::read_points(filename, std::back_inserter(pts)))) { std::cerr << "Error: cannot read " << filename << std::endl; return EXIT_FAILURE; diff --git a/Classification/examples/Classification/example_mesh_classification.cpp b/Classification/examples/Classification/example_mesh_classification.cpp index 465b3a4bfcd..5205d1188ed 100644 --- a/Classification/examples/Classification/example_mesh_classification.cpp +++ b/Classification/examples/Classification/example_mesh_classification.cpp @@ -3,17 +3,17 @@ // converts 64 to 32 bits integers #endif +#include +#include + +#include +#include + #include #include #include #include -#include -#include -#include - -#include - typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_3 Point; typedef CGAL::Surface_mesh Mesh; @@ -31,19 +31,15 @@ typedef Classification::Mesh_feature_generator int main (int argc, char** argv) { - std::string filename = "data/b9_mesh.off"; - std::string filename_config = "data/b9_mesh_config.gz"; + std::string filename = (argc>1) ? argv[1] : "data/b9_mesh.off"; + std::string filename_config = (argc>2) ? argv[2] : "data/b9_mesh_config.gz"; - if (argc > 1) - filename = argv[1]; - if (argc > 2) - filename_config = argv[2]; - - std::ifstream in (filename.c_str()); Mesh mesh; - - std::cerr << "Reading input" << std::endl; - in >> mesh; + if(!CGAL::read_polygon_mesh(filename, mesh)) + { + std::cerr << "Invalid input." << std::endl; + return 1; + } std::cerr << "Generating features" << std::endl; CGAL::Real_timer t; diff --git a/Classification/examples/Classification/example_opencv_random_forest.cpp b/Classification/examples/Classification/example_opencv_random_forest.cpp index e0cd90e51f0..1ba80fe89df 100644 --- a/Classification/examples/Classification/example_opencv_random_forest.cpp +++ b/Classification/examples/Classification/example_opencv_random_forest.cpp @@ -36,15 +36,11 @@ typedef Classification::Point_set_feature_generator int main (int argc, char** argv) { - std::string filename = "data/b9_training.ply"; - - if (argc > 1) - filename = argv[1]; - - std::ifstream in (filename.c_str(), std::ios::binary); - Point_set pts; + std::string filename = (argc > 1) ? argv[1] : "data/b9_training.ply"; std::cerr << "Reading input" << std::endl; + std::ifstream in (filename.c_str(), std::ios::binary); + Point_set pts; in >> pts; Imap label_map; diff --git a/Classification/examples/Classification/example_tensorflow_neural_network.cpp b/Classification/examples/Classification/example_tensorflow_neural_network.cpp index 01fd4f1cac2..2d2092c4338 100644 --- a/Classification/examples/Classification/example_tensorflow_neural_network.cpp +++ b/Classification/examples/Classification/example_tensorflow_neural_network.cpp @@ -36,15 +36,11 @@ typedef Classification::Point_set_feature_generator int main (int argc, char** argv) { - std::string filename = "data/b9_training.ply"; - - if (argc > 1) - filename = argv[1]; - - std::ifstream in (filename.c_str(), std::ios::binary); - Point_set pts; + std::string filename = (argc > 1) ? argv[1] : "data/b9_training.ply"; std::cerr << "Reading input" << std::endl; + std::ifstream in (filename.c_str(), std::ios::binary); + Point_set pts; in >> pts; Imap label_map; diff --git a/Classification/examples/Classification/gis_tutorial_example.cpp b/Classification/examples/Classification/gis_tutorial_example.cpp index 62686301d76..0037212b88e 100644 --- a/Classification/examples/Classification/gis_tutorial_example.cpp +++ b/Classification/examples/Classification/gis_tutorial_example.cpp @@ -218,7 +218,7 @@ int main (int argc, char** argv) CGAL::copy_face_graph (dsm, dsm_mesh); std::ofstream dsm_ofile ("dsm.ply", std::ios_base::binary); CGAL::set_binary_mode (dsm_ofile); - CGAL::write_ply (dsm_ofile, dsm_mesh); + CGAL::write_PLY (dsm_ofile, dsm_mesh); dsm_ofile.close(); //! [Save DSM] @@ -323,7 +323,7 @@ int main (int argc, char** argv) std::ofstream tin_colored_ofile ("colored_tin.ply", std::ios_base::binary); CGAL::set_binary_mode (tin_colored_ofile); - CGAL::write_ply (tin_colored_ofile, tin_colored_mesh); + CGAL::write_PLY (tin_colored_ofile, tin_colored_mesh); tin_colored_ofile.close(); //! [Save TIN with info] @@ -416,7 +416,7 @@ int main (int argc, char** argv) // Save original DTM std::ofstream dtm_ofile ("dtm.ply", std::ios_base::binary); CGAL::set_binary_mode (dtm_ofile); - CGAL::write_ply (dtm_ofile, dtm_mesh); + CGAL::write_PLY (dtm_ofile, dtm_mesh); dtm_ofile.close(); std::cerr << face_selection.size() << " face(s) are selected for removal" << std::endl; @@ -440,7 +440,7 @@ int main (int argc, char** argv) // Save filtered DTM std::ofstream dtm_holes_ofile ("dtm_with_holes.ply", std::ios_base::binary); CGAL::set_binary_mode (dtm_holes_ofile); - CGAL::write_ply (dtm_holes_ofile, dtm_mesh); + CGAL::write_PLY (dtm_holes_ofile, dtm_mesh); dtm_holes_ofile.close(); // Get all holes @@ -478,7 +478,7 @@ int main (int argc, char** argv) // Save DTM with holes filled std::ofstream dtm_filled_ofile ("dtm_filled.ply", std::ios_base::binary); CGAL::set_binary_mode (dtm_filled_ofile); - CGAL::write_ply (dtm_filled_ofile, dtm_mesh); + CGAL::write_PLY (dtm_filled_ofile, dtm_mesh); dtm_filled_ofile.close(); //! [Hole filling] @@ -491,7 +491,7 @@ int main (int argc, char** argv) std::ofstream dtm_remeshed_ofile ("dtm_remeshed.ply", std::ios_base::binary); CGAL::set_binary_mode (dtm_remeshed_ofile); - CGAL::write_ply (dtm_remeshed_ofile, dtm_mesh); + CGAL::write_PLY (dtm_remeshed_ofile, dtm_mesh); dtm_remeshed_ofile.close(); //! [Remeshing] diff --git a/Convex_hull_3/examples/Convex_hull_3/dynamic_hull_3.cpp b/Convex_hull_3/examples/Convex_hull_3/dynamic_hull_3.cpp index a572a299fbb..673dbe679f5 100644 --- a/Convex_hull_3/examples/Convex_hull_3/dynamic_hull_3.cpp +++ b/Convex_hull_3/examples/Convex_hull_3/dynamic_hull_3.cpp @@ -16,11 +16,11 @@ typedef CGAL::Surface_mesh Surface_mesh; int main() { CGAL::Random_points_in_sphere_3 gen(100.0); - std::list points; + std::list points; // generate 250 points randomly in a sphere of radius 100.0 // and insert them into the triangulation - std::copy_n(gen, 250, std::back_inserter(points) ); + std::copy_n(gen, 250, std::back_inserter(points)); Delaunay T; T.insert(points.begin(), points.end()); diff --git a/Convex_hull_3/examples/Convex_hull_3/dynamic_hull_LCC_3.cpp b/Convex_hull_3/examples/Convex_hull_3/dynamic_hull_LCC_3.cpp index f9511065e85..722cfb51dff 100644 --- a/Convex_hull_3/examples/Convex_hull_3/dynamic_hull_LCC_3.cpp +++ b/Convex_hull_3/examples/Convex_hull_3/dynamic_hull_LCC_3.cpp @@ -18,11 +18,11 @@ typedef CGAL::Linear_cell_complex_for_bgl_combinatorial_map_helper int main() { CGAL::Random_points_in_sphere_3 gen(100.0); - std::list points; + std::list points; // generate 250 points randomly in a sphere of radius 100.0 // and insert them into the triangulation - std::copy_n(gen, 250, std::back_inserter(points) ); + std::copy_n(gen, 250, std::back_inserter(points)); Delaunay T; T.insert(points.begin(), points.end()); diff --git a/Convex_hull_3/examples/Convex_hull_3/dynamic_hull_OM_3.cpp b/Convex_hull_3/examples/Convex_hull_3/dynamic_hull_OM_3.cpp index 8172a82cb64..49f25e9ec80 100644 --- a/Convex_hull_3/examples/Convex_hull_3/dynamic_hull_OM_3.cpp +++ b/Convex_hull_3/examples/Convex_hull_3/dynamic_hull_OM_3.cpp @@ -16,17 +16,16 @@ typedef K::Point_3 Point_3; typedef CGAL::Delaunay_triangulation_3 Delaunay; typedef Delaunay::Vertex_handle Vertex_handle; - typedef OpenMesh::TriMesh_ArrayKernelT Surface_mesh; int main() { CGAL::Random_points_in_sphere_3 gen(100.0); - std::list points; + std::list points; // generate 250 points randomly in a sphere of radius 100.0 // and insert them into the triangulation - std::copy_n(gen, 250, std::back_inserter(points) ); + std::copy_n(gen, 250, std::back_inserter(points)); Delaunay T; T.insert(points.begin(), points.end()); diff --git a/Convex_hull_3/examples/Convex_hull_3/dynamic_hull_SM_3.cpp b/Convex_hull_3/examples/Convex_hull_3/dynamic_hull_SM_3.cpp index 6bcf35908a5..cc72dc6ceff 100644 --- a/Convex_hull_3/examples/Convex_hull_3/dynamic_hull_SM_3.cpp +++ b/Convex_hull_3/examples/Convex_hull_3/dynamic_hull_SM_3.cpp @@ -17,11 +17,11 @@ typedef CGAL::Surface_mesh Polyhedron_3; int main() { CGAL::Random_points_in_sphere_3 gen(100.0); - std::list points; + std::list points; // generate 250 points randomly in a sphere of radius 100.0 // and insert them into the triangulation - std::copy_n(gen, 250, std::back_inserter(points) ); + std::copy_n(gen, 250, std::back_inserter(points)); Delaunay T; T.insert(points.begin(), points.end()); diff --git a/Convex_hull_3/examples/Convex_hull_3/extreme_indices_3.cpp b/Convex_hull_3/examples/Convex_hull_3/extreme_indices_3.cpp index d5c8c8080d0..4a65e65dace 100644 --- a/Convex_hull_3/examples/Convex_hull_3/extreme_indices_3.cpp +++ b/Convex_hull_3/examples/Convex_hull_3/extreme_indices_3.cpp @@ -8,23 +8,20 @@ #include #include - typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef K::Point_3 Point_3; int main(int argc, char* argv[]) { - std::ifstream in( (argc>1)? argv[1] : "data/star.off"); + const char* filename = (argc>1) ? argv[1] : "data/star.off"; - if(!in) + std::vector points; + if(!CGAL::read_points(filename, std::back_inserter(points))) { std::cerr<< "Cannot open input file." < points; - CGAL::read_points(in, std::back_inserter(points)); - //This will contain the extreme vertices std::vector extreme_point_indices; @@ -33,6 +30,7 @@ int main(int argc, char* argv[]) boost::counting_iterator(points.size())), std::back_inserter(extreme_point_indices), CGAL::make_extreme_points_traits_adapter(CGAL::make_property_map(points))); + //print the number of extreme vertices std::cout << "Indices of points on the convex hull are:\n"; std::copy(extreme_point_indices.begin(), extreme_point_indices.end(), std::ostream_iterator(std::cout, " ")); diff --git a/Convex_hull_3/examples/Convex_hull_3/extreme_points_3_sm.cpp b/Convex_hull_3/examples/Convex_hull_3/extreme_points_3_sm.cpp index 3cb71eaf3bb..d429e92a5b8 100644 --- a/Convex_hull_3/examples/Convex_hull_3/extreme_points_3_sm.cpp +++ b/Convex_hull_3/examples/Convex_hull_3/extreme_points_3_sm.cpp @@ -1,21 +1,24 @@ #include + #include #include #include + #include #include - typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef K::Point_3 Point_3; typedef CGAL::Surface_mesh Mesh; int main(int argc, char* argv[]) { - std::ifstream in( (argc>1)? argv[1] : "data/star.off"); + const char* filename = (argc>1) ? argv[1] : "data/star.off"; Mesh sm; - if(! in || !(in >> sm) || !sm.is_valid()){ - std::cerr<<"Not a valid off file."< Surface_mesh; int main(int argc, char* argv[]) { - std::ifstream in( (argc>1)? argv[1] : "data/star.off"); - + const char* filename = (argc>1) ? argv[1] : "data/star.off"; Surface_mesh poly; - if(!(in >> poly)) + if(!CGAL::read_polygon_mesh(filename, poly)) { - std::cerr<<"Could not find input file."< -#include -#include -#include +#include +#include + +#include #include #include -#include +#include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef K::Point_3 @@ -15,12 +17,11 @@ typedef OpenMesh::TriMesh_ArrayKernelT Mesh; int main(int argc, char* argv[]) { - std::ifstream in( (argc>1)? argv[1] : "data/cube.xyz"); + std::ifstream in((argc>1) ? argv[1] : "data/cube.xyz"); std::vector points; Point_3 p, n; - while(in >> p >> n){ + while(in >> p >> n) points.push_back(p); - } // define polyhedron to hold convex hull Mesh poly; @@ -28,12 +29,10 @@ int main(int argc, char* argv[]) // compute convex hull of non-collinear points CGAL::convex_hull_3(points.begin(), points.end(), poly); - Mesh sm; - CGAL::convex_hull_3(points.begin(), points.end(), sm); - CGAL::write_off((argc>2)?argv[2]:"out.off", sm); + CGAL::write_polygon_mesh((argc>2)?argv[2]:"out.off", sm); return 0; } diff --git a/Convex_hull_3/test/Convex_hull_3/test_extreme_points.cpp b/Convex_hull_3/test/Convex_hull_3/test_extreme_points.cpp index 80005b504b6..90d8c264f4f 100644 --- a/Convex_hull_3/test/Convex_hull_3/test_extreme_points.cpp +++ b/Convex_hull_3/test/Convex_hull_3/test_extreme_points.cpp @@ -1,5 +1,6 @@ #include #include + #include #include #include @@ -7,18 +8,17 @@ #include #include #include + #include #include #include #include #include - typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Polyhedron_3 Polyhedron_3; typedef K::Point_3 Point_3; - void test_function_overload() { std::vector points; diff --git a/Heat_method_3/examples/Heat_method_3/heat_method.cpp b/Heat_method_3/examples/Heat_method_3/heat_method.cpp index 83fbe35c0ac..dbe02789fdd 100644 --- a/Heat_method_3/examples/Heat_method_3/heat_method.cpp +++ b/Heat_method_3/examples/Heat_method_3/heat_method.cpp @@ -5,7 +5,6 @@ #include #include - typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_3 Point_3; typedef CGAL::Surface_mesh Triangle_mesh; @@ -15,12 +14,14 @@ typedef Triangle_mesh::Property_map Vertex_distance_ma int main(int argc, char* argv[]) { - Triangle_mesh tm; const char* filename = (argc > 1) ? argv[1] : "./data/elephant.off"; - std::ifstream input(filename); - if (!input || !(input >> tm) || tm.is_empty()) { - std::cerr << "Not a valid off file." << std::endl; - return 1; + + Triangle_mesh tm; + if(!CGAL::read_polygon_mesh(filename, tm) || + CGAL::is_empty(tm) || !CGAL::is_triangle_mesh(tm)) + { + std::cerr << "Invalid input file." << std::endl; + return EXIT_FAILURE; } //property map for the distance values to the source set @@ -31,7 +32,8 @@ int main(int argc, char* argv[]) CGAL::Heat_method_3::estimate_geodesic_distances(tm, vertex_distance, source) ; std::cout << "Source vertex " << source << " at: " << tm.point(source) << std::endl; - for(vertex_descriptor vd : vertices(tm)){ + for(vertex_descriptor vd : vertices(tm)) + { std::cout << vd << " ("<< tm.point(vd) << ")" << " is at distance " << get(vertex_distance, vd) << std::endl; } diff --git a/Heat_method_3/examples/Heat_method_3/heat_method_polyhedron.cpp b/Heat_method_3/examples/Heat_method_3/heat_method_polyhedron.cpp index ebf6aba4470..b2ef2f2ca34 100644 --- a/Heat_method_3/examples/Heat_method_3/heat_method_polyhedron.cpp +++ b/Heat_method_3/examples/Heat_method_3/heat_method_polyhedron.cpp @@ -2,11 +2,11 @@ #include #include +#include + #include #include -#include - typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_3 Point_3; typedef CGAL::Polyhedron_3 Triangle_mesh; diff --git a/Heat_method_3/examples/Heat_method_3/heat_method_surface_mesh.cpp b/Heat_method_3/examples/Heat_method_3/heat_method_surface_mesh.cpp index ca8fa43edc6..88e12912805 100644 --- a/Heat_method_3/examples/Heat_method_3/heat_method_surface_mesh.cpp +++ b/Heat_method_3/examples/Heat_method_3/heat_method_surface_mesh.cpp @@ -1,10 +1,11 @@ #include #include + #include + #include #include - typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_3 Point_3; typedef CGAL::Surface_mesh Triangle_mesh; @@ -13,16 +14,16 @@ typedef boost::graph_traits::vertex_descriptor vertex_descriptor; typedef Triangle_mesh::Property_map Vertex_distance_map; typedef CGAL::Heat_method_3::Surface_mesh_geodesic_distances_3 Heat_method; - - int main(int argc, char* argv[]) { - Triangle_mesh tm; const char* filename = (argc > 1) ? argv[1] : "./data/sphere.off"; - std::ifstream input(filename); - if (!input || !(input >> tm) || tm.is_empty()) { - std::cerr << "Not a valid off file." << std::endl; - return 1; + + Triangle_mesh tm; + if(!CGAL::read_polygon_mesh(filename, tm) || + CGAL::is_empty(tm) || !CGAL::is_triangle_mesh(tm)) + { + std::cerr << "Invalid input file." << std::endl; + return EXIT_FAILURE; } //property map for the distance values to the source set diff --git a/Heat_method_3/examples/Heat_method_3/heat_method_surface_mesh_direct.cpp b/Heat_method_3/examples/Heat_method_3/heat_method_surface_mesh_direct.cpp index 9a68ab07581..b63a02748fa 100644 --- a/Heat_method_3/examples/Heat_method_3/heat_method_surface_mesh_direct.cpp +++ b/Heat_method_3/examples/Heat_method_3/heat_method_surface_mesh_direct.cpp @@ -19,11 +19,11 @@ typedef CGAL::Heat_method_3::Surface_mesh_geodesic_distances_3 1) ? argv[1] : "./data/elephant.off"; - std::ifstream input(filename); - if (!input || !(input >> tm) || tm.is_empty()) { - std::cerr << "Not a valid off file." << std::endl; - return 1; + if(!CGAL::read_polygon_mesh(filename, tm) || + CGAL::is_empty(tm) || !CGAL::is_triangle_mesh(tm)) + { + std::cerr << "Invalid input file." << std::endl; + return EXIT_FAILURE; } //property map for the distance values to the source set diff --git a/Optimal_bounding_box/examples/Optimal_bounding_box/obb_example.cpp b/Optimal_bounding_box/examples/Optimal_bounding_box/obb_example.cpp index 7818660b161..4b786a85ee4 100644 --- a/Optimal_bounding_box/examples/Optimal_bounding_box/obb_example.cpp +++ b/Optimal_bounding_box/examples/Optimal_bounding_box/obb_example.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include @@ -19,9 +20,10 @@ typedef CGAL::Surface_mesh Surface_mesh; int main(int argc, char** argv) { - std::ifstream input((argc > 1) ? argv[1] : "data/pig.off"); + const char* filename = (argc > 1) ? argv[1] : "data/pig.off"; + Surface_mesh sm; - if(!input || !(input >> sm) || sm.is_empty()) + if(!PMP::read_polygon_mesh(filename, sm) || sm.is_empty()) { std::cerr << "Invalid input file." << std::endl; return EXIT_FAILURE; diff --git a/Optimal_bounding_box/examples/Optimal_bounding_box/obb_with_point_maps_example.cpp b/Optimal_bounding_box/examples/Optimal_bounding_box/obb_with_point_maps_example.cpp index 9129aef472d..4b8210a813d 100644 --- a/Optimal_bounding_box/examples/Optimal_bounding_box/obb_with_point_maps_example.cpp +++ b/Optimal_bounding_box/examples/Optimal_bounding_box/obb_with_point_maps_example.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -20,9 +21,10 @@ namespace CP = CGAL::parameters; int main(int argc, char** argv) { - std::ifstream input((argc > 1) ? argv[1] : "data/pig.off"); + const char* filename = (argc > 1) ? argv[1] : "data/pig.off"; + Surface_mesh sm; - if (!input || !(input >> sm) || sm.is_empty()) + if(!CGAL::Polygon_mesh_processing::read_polygon_mesh(filename, sm) || sm.is_empty()) { std::cerr << "Invalid input file." << std::endl; return EXIT_FAILURE; diff --git a/Optimal_bounding_box/examples/Optimal_bounding_box/rotated_aabb_tree_example.cpp b/Optimal_bounding_box/examples/Optimal_bounding_box/rotated_aabb_tree_example.cpp index ecd12b4a436..176ca6ff53b 100644 --- a/Optimal_bounding_box/examples/Optimal_bounding_box/rotated_aabb_tree_example.cpp +++ b/Optimal_bounding_box/examples/Optimal_bounding_box/rotated_aabb_tree_example.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include @@ -32,9 +33,10 @@ private: int main(int argc, char** argv) { - std::ifstream input((argc > 1) ? argv[1] : "data/pig.off"); + const char* filename = (argc > 1) ? argv[1] : "data/pig.off"; + Surface_mesh sm; - if (!input || !(input >> sm) || sm.is_empty()) + if(!CGAL::Polygon_mesh_processing::read_polygon_mesh(filename, sm) || sm.is_empty()) { std::cerr << "Invalid input file." << std::endl; return EXIT_FAILURE; diff --git a/Point_set_3/examples/Point_set_3/draw_point_set_3.cpp b/Point_set_3/examples/Point_set_3/draw_point_set_3.cpp index 701eb615f9c..1adcd7245f3 100644 --- a/Point_set_3/examples/Point_set_3/draw_point_set_3.cpp +++ b/Point_set_3/examples/Point_set_3/draw_point_set_3.cpp @@ -14,8 +14,8 @@ typedef CGAL::Point_set_3 Point_set; int main (int argc, char** argv) { const char* filename = argc > 1 ? argv[1] : "data/oni.xyz"; - Point_set point_set; + Point_set point_set; if(!CGAL::read_point_set(filename, point_set)) { std::cerr << "Can't read input file " << filename << std::endl; diff --git a/Point_set_3/examples/Point_set_3/point_set_read_ply.cpp b/Point_set_3/examples/Point_set_3/point_set_read_ply.cpp index f6d86c9e389..9b60f42c2fa 100644 --- a/Point_set_3/examples/Point_set_3/point_set_read_ply.cpp +++ b/Point_set_3/examples/Point_set_3/point_set_read_ply.cpp @@ -48,7 +48,7 @@ int main (int argc, char** argv) std::ofstream out ("out.ply", std::ios_base::binary); // Mandatory on Windows CGAL::set_binary_mode (out); // Select binary mode (ASCII is default) - out << point_set; // same as `CGAL::write_ply_point_set (out, point_set)` + out << point_set; // same as `CGAL::write_PLY(out, point_set)` } else // ASCII output { diff --git a/Point_set_3/examples/Point_set_3/point_set_read_xyz.cpp b/Point_set_3/examples/Point_set_3/point_set_read_xyz.cpp index 7184af60db7..c9ce2d6e757 100644 --- a/Point_set_3/examples/Point_set_3/point_set_read_xyz.cpp +++ b/Point_set_3/examples/Point_set_3/point_set_read_xyz.cpp @@ -16,10 +16,9 @@ int main (int argc, char** argv) { const char* fname = argc > 1 ? argv[1] : "data/oni.xyz"; + // Reading input Point_set point_set; - - // Reading input in XYZ format - if(!CGAL::read_point_set(fname, point_set)) + if(!CGAL::read_XYZ(fname, point_set)) { std::cerr << "Can't read input file " << std::endl; return EXIT_FAILURE; diff --git a/Point_set_3/include/CGAL/Point_set_3/IO.h b/Point_set_3/include/CGAL/Point_set_3/IO.h index 8f2d09700f4..4bad70e4002 100644 --- a/Point_set_3/include/CGAL/Point_set_3/IO.h +++ b/Point_set_3/include/CGAL/Point_set_3/IO.h @@ -152,7 +152,7 @@ template std::ostream& operator<<(std::ostream& os, const CGAL::Point_set_3& ps) { - write_ply_point_set(os, ps); + write_PLY(os, ps); return os; } diff --git a/Point_set_processing_3/examples/Point_set_processing_3/average_spacing_example.cpp b/Point_set_processing_3/examples/Point_set_processing_3/average_spacing_example.cpp index 3a4df48d0cf..7d21a8237af 100644 --- a/Point_set_processing_3/examples/Point_set_processing_3/average_spacing_example.cpp +++ b/Point_set_processing_3/examples/Point_set_processing_3/average_spacing_example.cpp @@ -22,7 +22,7 @@ int main(int argc, char*argv[]) { const char* fname = (argc>1)?argv[1]:"data/sphere_20k.xyz"; - // Reads a .xyz point set file in points. + // Reads a file in points. // As the point is the second element of the tuple (that is with index 1) // we use a property map that accesses the 1st element of the tuple. diff --git a/Point_set_processing_3/examples/Point_set_processing_3/bilateral_smooth_point_set_example.cpp b/Point_set_processing_3/examples/Point_set_processing_3/bilateral_smooth_point_set_example.cpp index 91f3464af72..74e24fd4269 100644 --- a/Point_set_processing_3/examples/Point_set_processing_3/bilateral_smooth_point_set_example.cpp +++ b/Point_set_processing_3/examples/Point_set_processing_3/bilateral_smooth_point_set_example.cpp @@ -25,7 +25,7 @@ int main(int argc, char*argv[]) const char* input_filename = (argc>1) ? argv[1] : "data/fin90_with_PCA_normals.xyz"; const char* output_filename = (argc>2) ? argv[2] : "data/fin90_with_PCA_normals_bilateral_smoothed.xyz"; - // Reads a .xyz point set file in points[] * with normals *. + // Reads a point set file in points[] * with normals *. std::vector points; if(!CGAL::read_points(input_filename, std::back_inserter(points), CGAL::parameters::point_map(CGAL::First_of_pair_property_map()) diff --git a/Point_set_processing_3/examples/Point_set_processing_3/edges_example.cpp b/Point_set_processing_3/examples/Point_set_processing_3/edges_example.cpp index 394144a2041..24d29c76fbc 100644 --- a/Point_set_processing_3/examples/Point_set_processing_3/edges_example.cpp +++ b/Point_set_processing_3/examples/Point_set_processing_3/edges_example.cpp @@ -20,7 +20,7 @@ typedef std::array Covariance; int main (int , char**) { - // Reads a .xyz point set file in points[]. + // Reads a polygon mesh file in points[]. std::list points; if(!CGAL::read_points("data/fandisk.off", std::back_inserter(points), diff --git a/Point_set_processing_3/examples/Point_set_processing_3/grid_simplification_example.cpp b/Point_set_processing_3/examples/Point_set_processing_3/grid_simplification_example.cpp index 081175cf681..ac026943b61 100644 --- a/Point_set_processing_3/examples/Point_set_processing_3/grid_simplification_example.cpp +++ b/Point_set_processing_3/examples/Point_set_processing_3/grid_simplification_example.cpp @@ -12,9 +12,10 @@ typedef Kernel::Point_3 Point; int main(int argc, char*argv[]) { - // Reads a .xyz point set file in points[]. - std::vector points; const char* fname = (argc>1) ? argv[1] : "data/oni.xyz"; + + // Reads a point set file in points[]. + std::vector points; if(!CGAL::read_points(fname, std::back_inserter(points))) { std::cerr << "Error: cannot read file " << fname << std::endl; diff --git a/Point_set_processing_3/examples/Point_set_processing_3/grid_simplify_indices.cpp b/Point_set_processing_3/examples/Point_set_processing_3/grid_simplify_indices.cpp index 7355e5be182..7280c133f5e 100644 --- a/Point_set_processing_3/examples/Point_set_processing_3/grid_simplify_indices.cpp +++ b/Point_set_processing_3/examples/Point_set_processing_3/grid_simplify_indices.cpp @@ -13,10 +13,11 @@ typedef Kernel::Vector_3 Vector; int main(int argc, char*argv[]) { + const char* fname = (argc>1) ? argv[1] : "data/fin90_with_PCA_normals.xyz"; + // Reads a .xyz point set file in points[]. std::vector points; std::vector normals; - const char* fname = (argc>1) ? argv[1] : "data/fin90_with_PCA_normals.xyz"; std::ifstream stream(fname); Point p; Vector v; diff --git a/Point_set_processing_3/examples/Point_set_processing_3/hierarchy_simplification_example.cpp b/Point_set_processing_3/examples/Point_set_processing_3/hierarchy_simplification_example.cpp index ebec64008a5..8226659a32d 100644 --- a/Point_set_processing_3/examples/Point_set_processing_3/hierarchy_simplification_example.cpp +++ b/Point_set_processing_3/examples/Point_set_processing_3/hierarchy_simplification_example.cpp @@ -15,9 +15,10 @@ typedef Kernel::Point_3 Point; int main(int argc, char*argv[]) { + const char* fname = (argc>1) ? argv[1] : "data/oni.xyz"; + // Reads a point set file in points[]. std::vector points; - const char* fname = (argc>1)?argv[1]:"data/oni.xyz"; if(!CGAL::read_points(fname, std::back_inserter(points))) { std::cerr << "Error: cannot read file " << fname << std::endl; diff --git a/Point_set_processing_3/examples/Point_set_processing_3/normal_estimation.cpp b/Point_set_processing_3/examples/Point_set_processing_3/normal_estimation.cpp index 9e96b034864..3fdb8f53e0f 100644 --- a/Point_set_processing_3/examples/Point_set_processing_3/normal_estimation.cpp +++ b/Point_set_processing_3/examples/Point_set_processing_3/normal_estimation.cpp @@ -240,11 +240,10 @@ int main(int argc, char * argv[]) // Loads point set //*************************************** - // Reads a .off or .xyz point set file in points[]. + // Reads a point set file in points[]. PointList points; std::cerr << "Open " << input_filename << " for reading..." << std::endl; - // If OFF file format if(!CGAL::read_points(input_filename.c_str(), std::back_inserter(points), CGAL::parameters::point_map(CGAL::First_of_pair_property_map()))) { diff --git a/Point_set_processing_3/examples/Point_set_processing_3/normals_example.cpp b/Point_set_processing_3/examples/Point_set_processing_3/normals_example.cpp index 1317d915b36..9eb5e9b634a 100644 --- a/Point_set_processing_3/examples/Point_set_processing_3/normals_example.cpp +++ b/Point_set_processing_3/examples/Point_set_processing_3/normals_example.cpp @@ -25,7 +25,7 @@ int main(int argc, char*argv[]) { const char* fname = (argc>1) ? argv[1] : "data/sphere_1k.xyz"; - // Reads a .xyz point set file in points[]. + // Reads a point set file in points[]. std::list points; if(!CGAL::read_points(fname, std::back_inserter(points), diff --git a/Point_set_processing_3/examples/Point_set_processing_3/read_las_example.cpp b/Point_set_processing_3/examples/Point_set_processing_3/read_las_example.cpp index 15955da3756..8cf2f1be534 100644 --- a/Point_set_processing_3/examples/Point_set_processing_3/read_las_example.cpp +++ b/Point_set_processing_3/examples/Point_set_processing_3/read_las_example.cpp @@ -17,11 +17,10 @@ typedef std::pair PointWithColor; int main(int argc, char*argv[]) { const char* fname = (argc>1) ? argv[1] : "data/pig_points.las"; + // Reads a .las point set file with normal vectors and colors - - std::vector points; // store points std::ifstream in(fname, std::ios_base::binary); - + std::vector points; // store points if(!CGAL::read_LAS_with_properties(in, std::back_inserter (points), CGAL::make_las_point_reader(CGAL::First_of_pair_property_map()), std::make_tuple(CGAL::Second_of_pair_property_map(), diff --git a/Point_set_processing_3/examples/Point_set_processing_3/read_write_xyz_point_set_example.cpp b/Point_set_processing_3/examples/Point_set_processing_3/read_write_xyz_point_set_example.cpp index c1bfc88bf71..33e49442e6c 100644 --- a/Point_set_processing_3/examples/Point_set_processing_3/read_write_xyz_point_set_example.cpp +++ b/Point_set_processing_3/examples/Point_set_processing_3/read_write_xyz_point_set_example.cpp @@ -1,4 +1,5 @@ #include + #include #include #include @@ -18,29 +19,30 @@ typedef std::pair Pwn; int main(int argc, char*argv[]) { - const char* fname = (argc>1)?argv[1]:"data/oni.xyz"; - // Reads a .xyz point set file in points[]. - // Note: read_points() requires an output iterator - // over points and as well as property maps to access each - // point position and normal. - std::vector points; - if(!CGAL::read_XYZ(fname, - std::back_inserter(points), - CGAL::parameters::point_map(CGAL::First_of_pair_property_map()) - .normal_map(CGAL::Second_of_pair_property_map()))) - { - std::cerr << "Error: cannot read file " << fname << std::endl; - return EXIT_FAILURE; - } + const char* fname = (argc>1) ? argv[1] : "data/oni.xyz"; - // Saves point set. - // Note: write_XYZ() requires property maps to access each - // point position and normal. - if(!CGAL::write_XYZ("oni_copy.xyz", points, - CGAL::parameters::point_map(CGAL::First_of_pair_property_map()) - .normal_map(CGAL::Second_of_pair_property_map()) - .stream_precision(17))) - return EXIT_FAILURE; + // Reads a .xyz point set file in points[]. + // Note: read_points() requires an output iterator + // over points and as well as property maps to access each + // point position and normal. + std::vector points; + if(!CGAL::read_XYZ(fname, + std::back_inserter(points), + CGAL::parameters::point_map(CGAL::First_of_pair_property_map()) + .normal_map(CGAL::Second_of_pair_property_map()))) + { + std::cerr << "Error: cannot read file " << fname << std::endl; + return EXIT_FAILURE; + } - return EXIT_SUCCESS; + // Saves point set. + // Note: write_XYZ() requires property maps to access each + // point position and normal. + if(!CGAL::write_XYZ("oni_copy.xyz", points, + CGAL::parameters::point_map(CGAL::First_of_pair_property_map()) + .normal_map(CGAL::Second_of_pair_property_map()) + .stream_precision(17))) + return EXIT_FAILURE; + + return EXIT_SUCCESS; } diff --git a/Point_set_processing_3/examples/Point_set_processing_3/registration_with_OpenGR.cpp b/Point_set_processing_3/examples/Point_set_processing_3/registration_with_OpenGR.cpp index 99dbe1e5a82..983d5b5b811 100644 --- a/Point_set_processing_3/examples/Point_set_processing_3/registration_with_OpenGR.cpp +++ b/Point_set_processing_3/examples/Point_set_processing_3/registration_with_OpenGR.cpp @@ -1,6 +1,7 @@ #include + #include -#include +#include #include #include diff --git a/Point_set_processing_3/examples/Point_set_processing_3/registration_with_pointmatcher.cpp b/Point_set_processing_3/examples/Point_set_processing_3/registration_with_pointmatcher.cpp index 44d904d645c..f5171e46e04 100644 --- a/Point_set_processing_3/examples/Point_set_processing_3/registration_with_pointmatcher.cpp +++ b/Point_set_processing_3/examples/Point_set_processing_3/registration_with_pointmatcher.cpp @@ -1,6 +1,7 @@ #include + #include -#include +#include #include #include #include diff --git a/Point_set_processing_3/examples/Point_set_processing_3/scale_estimation_example.cpp b/Point_set_processing_3/examples/Point_set_processing_3/scale_estimation_example.cpp index 44ad52df5ae..094de32e4aa 100644 --- a/Point_set_processing_3/examples/Point_set_processing_3/scale_estimation_example.cpp +++ b/Point_set_processing_3/examples/Point_set_processing_3/scale_estimation_example.cpp @@ -25,9 +25,8 @@ int main (int argc, char** argv) CGAL::Timer task_timer; - std::vector points; - // read input + std::vector points; if(!CGAL::read_points(fname, std::back_inserter(points))) { std::cerr << "Error: can't read input file" << std::endl; diff --git a/Point_set_processing_3/examples/Point_set_processing_3/structuring_example.cpp b/Point_set_processing_3/examples/Point_set_processing_3/structuring_example.cpp index 1e1b6bfc4e3..11ce92c5aac 100644 --- a/Point_set_processing_3/examples/Point_set_processing_3/structuring_example.cpp +++ b/Point_set_processing_3/examples/Point_set_processing_3/structuring_example.cpp @@ -25,15 +25,16 @@ typedef CGAL::Shape_detection::Plane Plane; int main (int argc, char** argv) { + const char* filename = (argc>1) ? argv[1] : "data/cube.pwn"; + // Points with normals. Pwn_vector points; // Loading point set from a file. - if (!CGAL::read_points((argc>1 ? argv[1] : "data/cube.pwn"), - std::back_inserter(points), - CGAL::parameters::point_map(Point_map()) - .normal_map(Normal_map()))) + if(!CGAL::read_points(filename, std::back_inserter(points), + CGAL::parameters::point_map(Point_map()) + .normal_map(Normal_map()))) { std::cerr << "Error: cannot read file cube.pwn" << std::endl; return EXIT_FAILURE; diff --git a/Point_set_processing_3/test/Point_set_processing_3/read_test.cpp b/Point_set_processing_3/test/Point_set_processing_3/read_test.cpp index 38425020f11..e4dacad400d 100644 --- a/Point_set_processing_3/test/Point_set_processing_3/read_test.cpp +++ b/Point_set_processing_3/test/Point_set_processing_3/read_test.cpp @@ -1,13 +1,13 @@ #include -#include -#include #include +#include +#include -#include #include -#include #include +#include +#include typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_3 Point_3; @@ -25,8 +25,7 @@ bool read(std::string s) bool read(std::string s, std::vector& pv_pairs) { - return CGAL::read_points(s, - back_inserter(pv_pairs), + return CGAL::read_points(s, back_inserter(pv_pairs), CGAL::parameters::point_map(CGAL::First_of_pair_property_map()) .normal_map(CGAL::Second_of_pair_property_map())); } @@ -34,19 +33,17 @@ bool read(std::string s, bool read_off(std::string s, std::vector& pv_pairs) { - return CGAL::read_OFF(s, - back_inserter(pv_pairs), - CGAL::parameters::point_map(CGAL::First_of_pair_property_map()). - normal_map(CGAL::Second_of_pair_property_map())); + return CGAL::read_OFF(s, back_inserter(pv_pairs), + CGAL::parameters::point_map(CGAL::First_of_pair_property_map()) + .normal_map(CGAL::Second_of_pair_property_map())); } bool read_ply(std::string s, std::vector& pv_pairs) { - return CGAL::read_PLY(s, - back_inserter(pv_pairs), - CGAL::parameters::point_map(CGAL::First_of_pair_property_map()). - normal_map(CGAL::Second_of_pair_property_map())); + return CGAL::read_PLY(s, back_inserter(pv_pairs), + CGAL::parameters::point_map(CGAL::First_of_pair_property_map()) + .normal_map(CGAL::Second_of_pair_property_map())); } int main() diff --git a/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/tutorial_example.cpp b/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/tutorial_example.cpp index 594961714d4..a763eb28516 100644 --- a/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/tutorial_example.cpp +++ b/Poisson_surface_reconstruction_3/examples/Poisson_surface_reconstruction_3/tutorial_example.cpp @@ -141,7 +141,7 @@ int main(int argc, char*argv[]) std::ofstream f ("out.ply", std::ios_base::binary); CGAL::set_binary_mode (f); - CGAL::write_ply (f, output_mesh); + CGAL::write_PLY(f, output_mesh); f.close (); //! [Output poisson] diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/compute_normals_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/compute_normals_example.cpp index cd7ba66f2e4..62a9174d816 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/compute_normals_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/compute_normals_example.cpp @@ -2,11 +2,10 @@ #include #include +#include -#include #include - -namespace PMP = CGAL::Polygon_mesh_processing; +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel K; @@ -17,14 +16,16 @@ typedef CGAL::Surface_mesh Surface_mesh; typedef boost::graph_traits::vertex_descriptor vertex_descriptor; typedef boost::graph_traits::face_descriptor face_descriptor; +namespace PMP = CGAL::Polygon_mesh_processing; + int main(int argc, char* argv[]) { const char* filename = (argc > 1) ? argv[1] : "data/eight.off"; - std::ifstream input(filename); Surface_mesh mesh; - if (!input || !(input >> mesh) || mesh.is_empty()) { - std::cerr << "Not a valid off file." << std::endl; + if(!PMP::read_polygon_mesh(filename, mesh)) + { + std::cerr << "Invalid input." << std::endl; return 1; } diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/compute_normals_example_OM.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/compute_normals_example_OM.cpp index 410a4a2848a..39ff0afdc19 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/compute_normals_example_OM.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/compute_normals_example_OM.cpp @@ -9,16 +9,14 @@ #include #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef K::Point_3 Point; -typedef K::Vector_3 Vector; - -typedef OpenMesh::PolyMesh_ArrayKernelT< > Mesh; - -typedef boost::graph_traits::vertex_descriptor vertex_descriptor; -typedef boost::graph_traits::face_descriptor face_descriptor; +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef K::Point_3 Point; +typedef K::Vector_3 Vector; +typedef OpenMesh::PolyMesh_ArrayKernelT< > Mesh; +typedef boost::graph_traits::vertex_descriptor vertex_descriptor; +typedef boost::graph_traits::face_descriptor face_descriptor; int main(int argc, char* argv[]) { @@ -33,26 +31,23 @@ int main(int argc, char* argv[]) mesh.add_property(vnormals.handle()); Vector v(0, 0, 0); - for(vertex_descriptor vd : vertices(mesh)){ - put(vnormals, vd, v); - } - for(face_descriptor fd : faces(mesh)){ - put(fnormals, fd, v); - } - CGAL::Polygon_mesh_processing::compute_normals - (mesh, - vnormals, - fnormals, - CGAL::Polygon_mesh_processing::parameters::vertex_point_map(get(CGAL::vertex_point, mesh)). - geom_traits(K())); + for(vertex_descriptor vd : vertices(mesh)) + put(vnormals, vd, v); + + for(face_descriptor fd : faces(mesh)) + put(fnormals, fd, v); + + CGAL::Polygon_mesh_processing::compute_normals(mesh, vnormals, fnormals, + CGAL::parameters::vertex_point_map(get(CGAL::vertex_point, mesh)) + .geom_traits(K())); std::cout << "Face normals :" << std::endl; - for(face_descriptor fd : faces(mesh)){ + for(face_descriptor fd : faces(mesh)) std::cout << fnormals[fd] << std::endl; - } + std::cout << "Normals at vertices :" << std::endl; - for(vertex_descriptor vd : vertices(mesh)){ + for(vertex_descriptor vd : vertices(mesh)) std::cout << vnormals[vd] << std::endl; - } + return 0; } diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/compute_normals_example_Polyhedron.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/compute_normals_example_Polyhedron.cpp index 0b4032cc7d1..b8c732a0c1b 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/compute_normals_example_Polyhedron.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/compute_normals_example_Polyhedron.cpp @@ -1,31 +1,35 @@ #include #include -#include -#include -#include +#include +#include // #include // #include +#include + #include #include +#include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef K::Point_3 Point; -typedef K::Vector_3 Vector; +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef K::Point_3 Point; +typedef K::Vector_3 Vector; -typedef CGAL::Polyhedron_3 Polyhedron; -typedef boost::graph_traits::vertex_descriptor vertex_descriptor; -typedef boost::graph_traits::face_descriptor face_descriptor; +typedef CGAL::Polyhedron_3 Polyhedron; +typedef boost::graph_traits::vertex_descriptor vertex_descriptor; +typedef boost::graph_traits::face_descriptor face_descriptor; + +namespace PMP = CGAL::Polygon_mesh_processing; int main(int argc, char* argv[]) { const char* filename = (argc > 1) ? argv[1] : "data/eight.off"; - std::ifstream input(filename); Polyhedron mesh; - if (!input || !(input >> mesh) || mesh.is_empty()) { - std::cerr << "Not a valid off file." << std::endl; + if(!PMP::read_polygon_mesh(filename, mesh)) + { + std::cerr << "Invalid input." << std::endl; return 1; } @@ -36,17 +40,16 @@ int main(int argc, char* argv[]) // CGAL::Unique_hash_map fnormals; // boost::unordered_map vnormals; - CGAL::Polygon_mesh_processing::compute_normals(mesh, - boost::make_assoc_property_map(vnormals), - boost::make_assoc_property_map(fnormals)); + PMP::compute_normals(mesh, boost::make_assoc_property_map(vnormals), + boost::make_assoc_property_map(fnormals)); std::cout << "Face normals :" << std::endl; - for(face_descriptor fd: faces(mesh)){ + for(face_descriptor fd: faces(mesh)) std::cout << fnormals[fd] << std::endl; - } + std::cout << "Vertex normals :" << std::endl; - for(vertex_descriptor vd: vertices(mesh)){ + for(vertex_descriptor vd: vertices(mesh)) std::cout << vnormals[vd] << std::endl; - } + return 0; } diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/connected_components_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/connected_components_example.cpp index 8469158c573..a415c924f76 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/connected_components_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/connected_components_example.cpp @@ -2,8 +2,11 @@ #include #include +#include + #include #include + #include #include #include @@ -69,11 +72,11 @@ struct Put_true int main(int argc, char* argv[]) { const char* filename = (argc > 1) ? argv[1] : "data/blobby_3cc.off"; - std::ifstream input(filename); Mesh mesh; - if (!input || !(input >> mesh) || mesh.is_empty()) { - std::cerr << "Not a valid off file." << std::endl; + if(!PMP::read_polygon_mesh(filename, mesh)) + { + std::cerr << "Invalid input." << std::endl; return 1; } diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_LCC.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_LCC.cpp index e942637a616..dd9749b2682 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_LCC.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_LCC.cpp @@ -6,11 +6,11 @@ #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; -typedef Kernel::Point_3 Point; -typedef CGAL::Linear_cell_complex_traits<3, Kernel> MyTraits; -typedef CGAL::Linear_cell_complex_for_bgl_combinatorial_map_helper - <2, 3, MyTraits>::type LCC; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; +typedef Kernel::Point_3 Point; + +typedef CGAL::Linear_cell_complex_traits<3, Kernel> MyTraits; +typedef CGAL::Linear_cell_complex_for_bgl_combinatorial_map_helper<2, 3, MyTraits>::type LCC; namespace PMP = CGAL::Polygon_mesh_processing; @@ -18,11 +18,13 @@ int main(int argc, char* argv[]) { const char* filename1 = (argc > 1) ? argv[1] : "data/blobby.off"; const char* filename2 = (argc > 2) ? argv[2] : "data/eight.off"; - std::ifstream input(filename1); LCC mesh1, mesh2; - CGAL::Polygon_mesh_processing::IO::read_polygon_mesh(filename1, mesh1); - CGAL::Polygon_mesh_processing::IO::read_polygon_mesh(filename2, mesh2); + if(!PMP::read_polygon_mesh(filename1, mesh1) || !PMP::read_polygon_mesh(filename2, mesh2)) + { + std::cerr << "Invalid input." << std::endl; + return 1; + } std::cout << "Number of vertices before corefinement " << num_vertices(mesh1) << " and " diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_SM.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_SM.cpp index 77244f43fa6..f9de85eef70 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_SM.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_SM.cpp @@ -2,11 +2,13 @@ #include #include +#include #include +#include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef CGAL::Surface_mesh Mesh; +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Surface_mesh Mesh; namespace PMP = CGAL::Polygon_mesh_processing; @@ -14,19 +16,11 @@ int main(int argc, char* argv[]) { const char* filename1 = (argc > 1) ? argv[1] : "data/blobby.off"; const char* filename2 = (argc > 2) ? argv[2] : "data/eight.off"; - std::ifstream input(filename1); Mesh mesh1, mesh2; - if (!input || !(input >> mesh1)) + if(!PMP::read_polygon_mesh(filename1, mesh1) || !PMP::read_polygon_mesh(filename2, mesh2)) { - std::cerr << "First mesh is not a valid off file." << std::endl; - return 1; - } - input.close(); - input.open(filename2); - if (!input || !(input >> mesh2)) - { - std::cerr << "Second mesh is not a valid off file." << std::endl; + std::cerr << "Invalid input." << std::endl; return 1; } diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_consecutive_bool_op.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_consecutive_bool_op.cpp index 7b13f109a6d..0338230f3fa 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_consecutive_bool_op.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_consecutive_bool_op.cpp @@ -3,15 +3,19 @@ #include #include +#include #include +#include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef CGAL::Exact_predicates_exact_constructions_kernel EK; -typedef CGAL::Surface_mesh Mesh; -typedef boost::graph_traits::vertex_descriptor vertex_descriptor; -typedef Mesh::Property_map Exact_point_map; -typedef Mesh::Property_map Exact_point_computed; +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Exact_predicates_exact_constructions_kernel EK; + +typedef CGAL::Surface_mesh Mesh; +typedef boost::graph_traits::vertex_descriptor vertex_descriptor; + +typedef Mesh::Property_map Exact_point_map; +typedef Mesh::Property_map Exact_point_computed; namespace PMP = CGAL::Polygon_mesh_processing; namespace params = PMP::parameters; @@ -66,19 +70,11 @@ int main(int argc, char* argv[]) { const char* filename1 = (argc > 1) ? argv[1] : "data/blobby.off"; const char* filename2 = (argc > 2) ? argv[2] : "data/eight.off"; - std::ifstream input(filename1); Mesh mesh1, mesh2; - if (!input || !(input >> mesh1)) + if(!PMP::read_polygon_mesh(filename1, mesh1) || !PMP::read_polygon_mesh(filename2, mesh2)) { - std::cerr << "First mesh is not a valid off file." << std::endl; - return 1; - } - input.close(); - input.open(filename2); - if (!input || !(input >> mesh2)) - { - std::cerr << "Second mesh is not a valid off file." << std::endl; + std::cerr << "Invalid input." << std::endl; return 1; } @@ -111,9 +107,11 @@ int main(int argc, char* argv[]) output << mesh2; return 0; } + std::cout << "Union could not be computed\n"; return 1; } + std::cout << "Intersection could not be computed\n"; return 1; } diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_difference_remeshed.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_difference_remeshed.cpp index f12868c033a..9b67d691b4f 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_difference_remeshed.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_difference_remeshed.cpp @@ -1,22 +1,27 @@ #include #include + #include +#include #include + #include #include +#include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef CGAL::Surface_mesh Mesh; -typedef boost::graph_traits::edge_descriptor edge_descriptor; -typedef boost::graph_traits::face_descriptor face_descriptor; -typedef boost::graph_traits::halfedge_descriptor halfedge_descriptor; +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; + +typedef CGAL::Surface_mesh Mesh; +typedef boost::graph_traits::halfedge_descriptor halfedge_descriptor; +typedef boost::graph_traits::edge_descriptor edge_descriptor; +typedef boost::graph_traits::face_descriptor face_descriptor; namespace PMP = CGAL::Polygon_mesh_processing; namespace params = PMP::parameters; - -struct Vector_pmap_wrapper{ +struct Vector_pmap_wrapper +{ std::vector& vect; Vector_pmap_wrapper(std::vector& v) : vect(v) {} friend bool get(const Vector_pmap_wrapper& m, face_descriptor f) @@ -33,19 +38,11 @@ int main(int argc, char* argv[]) { const char* filename1 = (argc > 1) ? argv[1] : "data/blobby.off"; const char* filename2 = (argc > 2) ? argv[2] : "data/eight.off"; - std::ifstream input(filename1); Mesh mesh1, mesh2; - if (!input || !(input >> mesh1)) + if(!PMP::read_polygon_mesh(filename1, mesh1) || !PMP::read_polygon_mesh(filename2, mesh2)) { - std::cerr << "First mesh is not a valid off file." << std::endl; - return 1; - } - input.close(); - input.open(filename2); - if (!input || !(input >> mesh2)) - { - std::cerr << "Second mesh is not a valid off file." << std::endl; + std::cerr << "Invalid input." << std::endl; return 1; } @@ -105,11 +102,8 @@ int main(int argc, char* argv[]) << " faces were selected for the remeshing step\n"; // remesh the region around the intersection polylines - PMP::isotropic_remeshing( - selected_faces, - 0.02, - mesh1, - params::edge_is_constrained_map(is_constrained_map) ); + PMP::isotropic_remeshing(selected_faces, 0.02, mesh1, + params::edge_is_constrained_map(is_constrained_map)); std::ofstream output("difference_remeshed.off"); output.precision(17); diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_mesh_union.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_mesh_union.cpp index 150a1db0782..d4f92394a72 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_mesh_union.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_mesh_union.cpp @@ -2,11 +2,12 @@ #include #include +#include #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef CGAL::Surface_mesh Mesh; +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Surface_mesh Mesh; namespace PMP = CGAL::Polygon_mesh_processing; @@ -14,26 +15,18 @@ int main(int argc, char* argv[]) { const char* filename1 = (argc > 1) ? argv[1] : "data/blobby.off"; const char* filename2 = (argc > 2) ? argv[2] : "data/eight.off"; - std::ifstream input(filename1); Mesh mesh1, mesh2; - if (!input || !(input >> mesh1)) + if(!PMP::read_polygon_mesh(filename1, mesh1) || !PMP::read_polygon_mesh(filename2, mesh2)) { - std::cerr << "First mesh is not a valid off file." << std::endl; - return 1; - } - input.close(); - input.open(filename2); - if (!input || !(input >> mesh2)) - { - std::cerr << "Second mesh is not a valid off file." << std::endl; + std::cerr << "Invalid input." << std::endl; return 1; } Mesh out; bool valid_union = PMP::corefine_and_compute_union(mesh1,mesh2, out); - if (valid_union) + if(valid_union) { std::cout << "Union was successfully computed\n"; std::ofstream output("union.off"); @@ -41,6 +34,8 @@ int main(int argc, char* argv[]) output << out; return 0; } + std::cout << "Union could not be computed\n"; + return 1; } diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_mesh_union_and_intersection.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_mesh_union_and_intersection.cpp index dda4e2f1f96..52fe89de94b 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_mesh_union_and_intersection.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_mesh_union_and_intersection.cpp @@ -2,11 +2,13 @@ #include #include +#include #include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef CGAL::Surface_mesh Mesh; +typedef CGAL::Surface_mesh Mesh; namespace PMP = CGAL::Polygon_mesh_processing; namespace params = CGAL::Polygon_mesh_processing::parameters; @@ -15,19 +17,11 @@ int main(int argc, char* argv[]) { const char* filename1 = (argc > 1) ? argv[1] : "data/blobby.off"; const char* filename2 = (argc > 2) ? argv[2] : "data/eight.off"; - std::ifstream input(filename1); Mesh mesh1, mesh2; - if (!input || !(input >> mesh1)) + if(!PMP::read_polygon_mesh(filename1, mesh1) || !PMP::read_polygon_mesh(filename2, mesh2)) { - std::cerr << "First mesh is not a valid off file." << std::endl; - return 1; - } - input.close(); - input.open(filename2); - if (!input || !(input >> mesh2)) - { - std::cerr << "Second mesh is not a valid off file." << std::endl; + std::cerr << "Invalid input." << std::endl; return 1; } diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_mesh_union_with_attributes.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_mesh_union_with_attributes.cpp index 05e5d219ba9..b616dfd3948 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_mesh_union_with_attributes.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_mesh_union_with_attributes.cpp @@ -1,12 +1,16 @@ #include #include -#include + #include +#include + +#include #include +#include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef CGAL::Surface_mesh Mesh; +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Surface_mesh Mesh; namespace PMP = CGAL::Polygon_mesh_processing; @@ -46,19 +50,11 @@ int main(int argc, char* argv[]) { const char* filename1 = (argc > 1) ? argv[1] : "data/blobby.off"; const char* filename2 = (argc > 2) ? argv[2] : "data/eight.off"; - std::ifstream input(filename1); Mesh mesh1, mesh2; - if (!input || !(input >> mesh1)) + if(!PMP::read_polygon_mesh(filename1, mesh1) || !PMP::read_polygon_mesh(filename2, mesh2)) { - std::cerr << "First mesh is not a valid off file." << std::endl; - return 1; - } - input.close(); - input.open(filename2); - if (!input || !(input >> mesh2)) - { - std::cerr << "Second mesh is not a valid off file." << std::endl; + std::cerr << "Invalid input." << std::endl; return 1; } diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_polyhedron_union.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_polyhedron_union.cpp index 96d76e874a6..71bdd4cd2f7 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_polyhedron_union.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_polyhedron_union.cpp @@ -3,11 +3,12 @@ #include #include +#include #include +#include - -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Polyhedron_3 Mesh; namespace PMP = CGAL::Polygon_mesh_processing; @@ -16,19 +17,11 @@ int main(int argc, char* argv[]) { const char* filename1 = (argc > 1) ? argv[1] : "data/blobby.off"; const char* filename2 = (argc > 2) ? argv[2] : "data/eight.off"; - std::ifstream input(filename1); Mesh mesh1, mesh2; - if (!input || !(input >> mesh1)) + if(!PMP::read_polygon_mesh(filename1, mesh1) || !PMP::read_polygon_mesh(filename2, mesh2)) { - std::cerr << "First mesh is not a valid off file." << std::endl; - return 1; - } - input.close(); - input.open(filename2); - if (!input || !(input >> mesh2)) - { - std::cerr << "Second mesh is not a valid off file." << std::endl; + std::cerr << "Invalid input." << std::endl; return 1; } diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/detect_features_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/detect_features_example.cpp index 8bdf2c551e1..a95c322fc77 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/detect_features_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/detect_features_example.cpp @@ -1,8 +1,11 @@ #include #include + #include +#include #include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Surface_mesh Mesh; @@ -13,12 +16,11 @@ namespace PMP = CGAL::Polygon_mesh_processing; int main(int argc, char* argv[]) { const char* filename = (argc > 1) ? argv[1] : "data/P.off"; - std::ifstream input(filename); Mesh mesh; - if (!input || !(input >> mesh)) + if(!PMP::read_polygon_mesh(filename, mesh)) { - std::cerr << "Not a valid input file." << std::endl; + std::cerr << "Invalid input." << std::endl; return 1; } @@ -41,7 +43,6 @@ int main(int argc, char* argv[]) ++nb_sharp_edges; } - std::cout<<"This mesh contains "< #include +#include #include #include + #include #include #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; -typedef Kernel::Point_3 Point; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; +typedef Kernel::Point_3 Point; -typedef CGAL::Surface_mesh Mesh; -typedef boost::graph_traits::face_descriptor face_descriptor; -typedef boost::graph_traits::faces_size_type faces_size_type; +typedef CGAL::Surface_mesh Mesh; +typedef boost::graph_traits::face_descriptor face_descriptor; +typedef boost::graph_traits::faces_size_type faces_size_type; typedef Mesh::Property_map FCCmap; - typedef CGAL::Face_filtered_graph Filtered_graph; +typedef CGAL::Face_filtered_graph Filtered_graph; namespace PMP = CGAL::Polygon_mesh_processing; - int main(int argc, char* argv[]) { - std::ifstream input((argc > 1) ? argv[1] : "data/blobby_3cc.off"); + const char* filename = (argc > 1) ? argv[1] : "data/blobby_3cc.off"; Mesh mesh; - if (!input || !(input >> mesh) || mesh.is_empty()) { - std::cerr << "Not a valid off file." << std::endl; + if(!PMP::read_polygon_mesh(filename, mesh)) + { + std::cerr << "Invalid input." << std::endl; return 1; } FCCmap fccmap = mesh.add_property_map("f:CC").first; - faces_size_type num = PMP::connected_components(mesh,fccmap); - std::cerr << "- The graph has " << num << " connected components (face connectivity)" << std::endl; - Filtered_graph ffg(mesh, 0, fccmap); - std::cout << "The faces in component 0 are:" << std::endl; - for(boost::graph_traits::face_descriptor f : faces(ffg)){ - std::cout << f << std::endl; - } + Filtered_graph ffg(mesh, 0, fccmap); + for(boost::graph_traits::face_descriptor f : faces(ffg)) + std::cout << f << std::endl; - if(num>1){ + if(num > 1) + { std::vector components; components.push_back(0); components.push_back(1); - ffg.set_selected_faces(components, fccmap); - std::cout << "The faces in components 0 and 1 are:" << std::endl; - for(Filtered_graph::face_descriptor f : faces(ffg)){ - std::cout << f << std::endl; - } + ffg.set_selected_faces(components, fccmap); + for(Filtered_graph::face_descriptor f : faces(ffg)) + std::cout << f << std::endl; } + return 0; } diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/hausdorff_distance_remeshing_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/hausdorff_distance_remeshing_example.cpp index 1b032454d43..0ef14cfaf3f 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/hausdorff_distance_remeshing_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/hausdorff_distance_remeshing_example.cpp @@ -1,17 +1,18 @@ #include #include + #include #include #define TAG CGAL::Parallel_if_available_tag -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef K::Point_3 Point; -typedef CGAL::Surface_mesh Mesh; +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef K::Point_3 Point; +typedef CGAL::Surface_mesh Mesh; namespace PMP = CGAL::Polygon_mesh_processing; -int main() +int main(int, char**) { Mesh tm1, tm2; CGAL::make_tetrahedron(Point(.0,.0,.0), @@ -19,11 +20,13 @@ int main() Point(1,1,1), Point(1,.0,2), tm1); - tm2=tm1; + tm2 = tm1; CGAL::Polygon_mesh_processing::isotropic_remeshing(tm2.faces(),.05, tm2); std::cout << "Approximated Hausdorff distance: " << CGAL::Polygon_mesh_processing::approximate_Hausdorff_distance (tm1, tm2, PMP::parameters::number_of_points_per_area_unit(4000)) << std::endl; + + return 0; } diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example.cpp index 0ee96329302..2a98bb66781 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example.cpp @@ -1,26 +1,31 @@ #include #include + +#include #include #include #include #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; -typedef CGAL::Polyhedron_3 Polyhedron; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; -typedef Polyhedron::Halfedge_handle Halfedge_handle; -typedef Polyhedron::Facet_handle Facet_handle; -typedef Polyhedron::Vertex_handle Vertex_handle; +typedef CGAL::Polyhedron_3 Polyhedron; + +typedef Polyhedron::Vertex_handle Vertex_handle; +typedef Polyhedron::Halfedge_handle Halfedge_handle; +typedef Polyhedron::Facet_handle Facet_handle; + +namespace PMP = CGAL::Polygon_mesh_processing; int main(int argc, char* argv[]) { const char* filename = (argc > 1) ? argv[1] : "data/mech-holes-shark.off"; - std::ifstream input(filename); Polyhedron poly; - if ( !input || !(input >> poly) || poly.empty() ) { - std::cerr << "Not a valid off file." << std::endl; + if(!PMP::read_polygon_mesh(filename, poly)) + { + std::cerr << "Invalid input." << std::endl; return 1; } @@ -32,14 +37,12 @@ int main(int argc, char* argv[]) { std::vector patch_facets; std::vector patch_vertices; - bool success = std::get<0>( - CGAL::Polygon_mesh_processing::triangulate_refine_and_fair_hole( - poly, - h, - std::back_inserter(patch_facets), - std::back_inserter(patch_vertices), - CGAL::Polygon_mesh_processing::parameters::vertex_point_map(get(CGAL::vertex_point, poly)). - geom_traits(Kernel())) ); + bool success = std::get<0>(PMP::triangulate_refine_and_fair_hole(poly, + h, + std::back_inserter(patch_facets), + std::back_inserter(patch_vertices), + PMP::parameters::vertex_point_map(get(CGAL::vertex_point, poly)) + .geom_traits(Kernel()))); std::cout << " Number of facets in constructed patch: " << patch_facets.size() << std::endl; std::cout << " Number of vertices in constructed patch: " << patch_vertices.size() << std::endl; @@ -54,5 +57,6 @@ int main(int argc, char* argv[]) std::ofstream out("filled.off"); out.precision(17); out << poly << std::endl; + return 0; } diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example_LCC.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example_LCC.cpp index 842da24ab3e..7dd03e34d99 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example_LCC.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example_LCC.cpp @@ -9,46 +9,47 @@ #include #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; -typedef Kernel::Point_3 Point; -typedef CGAL::Linear_cell_complex_traits<3, Kernel> MyTraits; -typedef CGAL::Linear_cell_complex_for_bgl_combinatorial_map_helper - <2, 3, MyTraits>::type LCC; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; +typedef Kernel::Point_3 Point; +typedef CGAL::Linear_cell_complex_traits<3, Kernel> MyTraits; +typedef CGAL::Linear_cell_complex_for_bgl_combinatorial_map_helper<2, 3, MyTraits>::type LCC; -typedef boost::graph_traits::halfedge_descriptor halfedge_descriptor; -typedef boost::graph_traits::face_descriptor face_descriptor; -typedef boost::graph_traits::vertex_descriptor vertex_descriptor; -typedef boost::graph_traits::halfedge_iterator halfedge_iterator; +typedef boost::graph_traits::vertex_descriptor vertex_descriptor; +typedef boost::graph_traits::halfedge_descriptor halfedge_descriptor; +typedef boost::graph_traits::face_descriptor face_descriptor; + +namespace PMP = CGAL::Polygon_mesh_processing; int main(int argc, char* argv[]) { const char* filename = (argc > 1) ? argv[1] : "data/mech-holes-shark.off"; + LCC mesh; - CGAL::Polygon_mesh_processing::IO::read_polygon_mesh(filename, mesh); + if(!PMP::read_polygon_mesh(filename, mesh)) + { + std::cerr << "Invalid input." << std::endl; + return 1; + } // Incrementally fill the holes unsigned int nb_holes = 0; - for ( halfedge_iterator it=halfedges(mesh).begin(); - it!=halfedges(mesh).end(); ++it) + for ( halfedge_descriptor h : halfedges(mesh)) { - halfedge_descriptor h=*it; if(is_border(h,mesh)) { std::vector patch_facets; std::vector patch_vertices; - bool success = std::get<0>( - CGAL::Polygon_mesh_processing::triangulate_refine_and_fair_hole( - mesh, - h, - std::back_inserter(patch_facets), - std::back_inserter(patch_vertices), - CGAL::Polygon_mesh_processing::parameters::vertex_point_map(get(CGAL::vertex_point, mesh)). - geom_traits(Kernel())) ); + bool success = std::get<0>(PMP::triangulate_refine_and_fair_hole(mesh, + h, + std::back_inserter(patch_facets), + std::back_inserter(patch_vertices), + PMP::parameters::vertex_point_map(get(CGAL::vertex_point, mesh)) + .geom_traits(Kernel()))); std::cout << "* Number of facets in constructed patch: " << patch_facets.size() << std::endl; std::cout << " Number of vertices in constructed patch: " << patch_vertices.size() << std::endl; std::cout << " Is fairing successful: " << success << std::endl; - nb_holes++; + ++nb_holes; } } diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example_OM.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example_OM.cpp index 2f49e93037f..0fe0a3f9114 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example_OM.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example_OM.cpp @@ -1,29 +1,30 @@ #include +#include +#include +#include + #include #include -#include -#include - -#include #include #include #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; -typedef OpenMesh::PolyMesh_ArrayKernelT< > Mesh; +typedef OpenMesh::PolyMesh_ArrayKernelT< > Mesh; -typedef boost::graph_traits::vertex_descriptor vertex_descriptor; -typedef boost::graph_traits::halfedge_descriptor halfedge_descriptor; -typedef boost::graph_traits::face_descriptor face_descriptor; +typedef boost::graph_traits::vertex_descriptor vertex_descriptor; +typedef boost::graph_traits::halfedge_descriptor halfedge_descriptor; +typedef boost::graph_traits::face_descriptor face_descriptor; + +namespace PMP = CGAL::Polygon_mesh_processing; int main(int argc, char* argv[]) { const char* filename = (argc > 1) ? argv[1] : "data/mech-holes-shark.off"; - Mesh mesh; OpenMesh::IO::read_mesh(mesh, filename); @@ -35,14 +36,11 @@ int main(int argc, char* argv[]) { std::vector patch_facets; std::vector patch_vertices; - bool success = std::get<0>( - CGAL::Polygon_mesh_processing::triangulate_refine_and_fair_hole( - mesh, - h, - std::back_inserter(patch_facets), - std::back_inserter(patch_vertices), - CGAL::Polygon_mesh_processing::parameters::vertex_point_map(get(CGAL::vertex_point, mesh)). - geom_traits(Kernel())) ); + bool success = std::get<0>(PMP::triangulate_refine_and_fair_hole(mesh, h, + std::back_inserter(patch_facets), + std::back_inserter(patch_vertices), + CGAL::parameters::vertex_point_map(get(CGAL::vertex_point, mesh)) + .geom_traits(Kernel()))); CGAL_assertion(CGAL::is_valid_polygon_mesh(mesh)); @@ -57,6 +55,7 @@ int main(int argc, char* argv[]) std::cout << std::endl; std::cout << nb_holes << " holes have been filled" << std::endl; - OpenMesh::IO::write_mesh(mesh, "filled_OM.off"); + OpenMesh::IO::write_mesh(mesh, "filled_OM.off"); + return 0; } diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example_SM.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example_SM.cpp index 6eb8bd06195..e79778f984d 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example_SM.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/hole_filling_example_SM.cpp @@ -3,6 +3,7 @@ #include #include +#include #include @@ -12,12 +13,14 @@ #include typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; -typedef Kernel::Point_3 Point; -typedef CGAL::Surface_mesh Mesh; +typedef Kernel::Point_3 Point; +typedef CGAL::Surface_mesh Mesh; -typedef boost::graph_traits::halfedge_descriptor halfedge_descriptor; -typedef boost::graph_traits::face_descriptor face_descriptor; -typedef boost::graph_traits::vertex_descriptor vertex_descriptor; +typedef boost::graph_traits::vertex_descriptor vertex_descriptor; +typedef boost::graph_traits::halfedge_descriptor halfedge_descriptor; +typedef boost::graph_traits::face_descriptor face_descriptor; + +namespace PMP = CGAL::Polygon_mesh_processing; bool is_small_hole(halfedge_descriptor h, Mesh & mesh, double max_hole_diam, int max_num_hole_edges) @@ -48,22 +51,22 @@ int main(int argc, char* argv[]) { const char* filename = (argc > 1) ? argv[1] : "data/mech-holes-shark.off"; + Mesh mesh; + if(!PMP::read_polygon_mesh(filename, mesh)) + { + std::cerr << "Invalid input." << std::endl; + return 1; + } + // Both of these must be positive in order to be considered double max_hole_diam = (argc > 2) ? boost::lexical_cast(argv[2]): -1.0; int max_num_hole_edges = (argc > 3) ? boost::lexical_cast(argv[3]) : -1; - std::ifstream input(filename); - Mesh mesh; - if ( !input || !(input >> mesh) ) { - std::cerr << "Not a valid off file." << std::endl; - return 1; - } - unsigned int nb_holes = 0; std::vector border_cycles; // collect one halfedge per boundary cycle - CGAL::Polygon_mesh_processing::extract_boundary_cycles(mesh, std::back_inserter(border_cycles)); + PMP::extract_boundary_cycles(mesh, std::back_inserter(border_cycles)); for(halfedge_descriptor h : border_cycles) { @@ -73,12 +76,10 @@ int main(int argc, char* argv[]) std::vector patch_facets; std::vector patch_vertices; - bool success = std::get<0>( - CGAL::Polygon_mesh_processing::triangulate_refine_and_fair_hole( - mesh, - h, - std::back_inserter(patch_facets), - std::back_inserter(patch_vertices)) ); + bool success = std::get<0>(PMP::triangulate_refine_and_fair_hole(mesh, + h, + std::back_inserter(patch_facets), + std::back_inserter(patch_vertices))); std::cout << "* Number of facets in constructed patch: " << patch_facets.size() << std::endl; std::cout << " Number of vertices in constructed patch: " << patch_vertices.size() << std::endl; @@ -94,5 +95,6 @@ int main(int argc, char* argv[]) std::cout << "Mesh written to: " << outfile << std::endl; out.precision(17); out << mesh << std::endl; + return 0; } diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/isotropic_remeshing_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/isotropic_remeshing_example.cpp index 4058aa68a60..de6491e0cbc 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/isotropic_remeshing_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/isotropic_remeshing_example.cpp @@ -3,16 +3,18 @@ #include #include +#include #include + #include #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef CGAL::Surface_mesh Mesh; +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Surface_mesh Mesh; -typedef boost::graph_traits::halfedge_descriptor halfedge_descriptor; -typedef boost::graph_traits::edge_descriptor edge_descriptor; +typedef boost::graph_traits::halfedge_descriptor halfedge_descriptor; +typedef boost::graph_traits::edge_descriptor edge_descriptor; namespace PMP = CGAL::Polygon_mesh_processing; @@ -32,11 +34,11 @@ struct halfedge2edge int main(int argc, char* argv[]) { const char* filename = (argc > 1) ? argv[1] : "data/pig.off"; - std::ifstream input(filename); Mesh mesh; - if (!input || !(input >> mesh) || !CGAL::is_triangle_mesh(mesh)) { - std::cerr << "Not a valid input file." << std::endl; + if(!PMP::read_polygon_mesh(filename, mesh) || !CGAL::is_triangle_mesh(mesh)) + { + std::cerr << "Invalid input." << std::endl; return 1; } @@ -45,24 +47,18 @@ int main(int argc, char* argv[]) std::cout << "Split border..."; - std::vector border; - PMP::border_halfedges(faces(mesh), - mesh, - boost::make_function_output_iterator(halfedge2edge(mesh, border))); - PMP::split_long_edges(border, target_edge_length, mesh); + std::vector border; + PMP::border_halfedges(faces(mesh), mesh, boost::make_function_output_iterator(halfedge2edge(mesh, border))); + PMP::split_long_edges(border, target_edge_length, mesh); std::cout << "done." << std::endl; std::cout << "Start remeshing of " << filename << " (" << num_faces(mesh) << " faces)..." << std::endl; - PMP::isotropic_remeshing( - faces(mesh), - target_edge_length, - mesh, - PMP::parameters::number_of_iterations(nb_iter) - .protect_constraints(true)//i.e. protect border, here - ); + PMP::isotropic_remeshing(faces(mesh), target_edge_length, mesh, + PMP::parameters::number_of_iterations(nb_iter) + .protect_constraints(true)); //i.e. protect border, here std::cout << "Remeshing done." << std::endl; diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/isotropic_remeshing_of_patch_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/isotropic_remeshing_of_patch_example.cpp index db803c04d9c..c61fbfa8904 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/isotropic_remeshing_of_patch_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/isotropic_remeshing_of_patch_example.cpp @@ -3,17 +3,19 @@ #include #include +#include #include + #include #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef CGAL::Surface_mesh Mesh; +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef boost::graph_traits::halfedge_descriptor halfedge_descriptor; -typedef boost::graph_traits::edge_descriptor edge_descriptor; -typedef boost::graph_traits::face_descriptor face_descriptor; +typedef CGAL::Surface_mesh Mesh; +typedef boost::graph_traits::halfedge_descriptor halfedge_descriptor; +typedef boost::graph_traits::edge_descriptor edge_descriptor; +typedef boost::graph_traits::face_descriptor face_descriptor; namespace PMP = CGAL::Polygon_mesh_processing; @@ -33,11 +35,11 @@ struct halfedge2edge int main(int argc, char* argv[]) { const char* filename = (argc > 1) ? argv[1] : "data/pig.off"; - std::ifstream input(filename); Mesh mesh; - if (!input || !(input >> mesh) || !CGAL::is_triangle_mesh(mesh)) { - std::cerr << "Not a valid input file." << std::endl; + if(!PMP::read_polygon_mesh(filename, mesh) || !CGAL::is_triangle_mesh(mesh)) + { + std::cerr << "Invalid input." << std::endl; return 1; } diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/locate_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/locate_example.cpp index 2235be77dfd..1f82e441566 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/locate_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/locate_example.cpp @@ -1,14 +1,14 @@ #include - #include +#include +#include + #include #include #include #include #include -#include -#include typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef K::FT FT; diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/manifoldness_repair_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/manifoldness_repair_example.cpp index 67fec9c8cf3..94274b740b3 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/manifoldness_repair_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/manifoldness_repair_example.cpp @@ -1,10 +1,10 @@ #include +#include + +#include +#include #include -#include -#include -#include - #include #include @@ -24,9 +24,8 @@ void merge_vertices(vertex_descriptor v_keep, vertex_descriptor v_rm, Mesh& mesh { std::cout << "merging vertices " << v_keep << " and " << v_rm << std::endl; - for(halfedge_descriptor h : CGAL::halfedges_around_target(v_rm, mesh)){ + for(halfedge_descriptor h : CGAL::halfedges_around_target(v_rm, mesh)) set_target(h, v_keep, mesh); // to ensure that no halfedge points at the deleted vertex - } remove_vertex(v_rm, mesh); } @@ -34,13 +33,12 @@ void merge_vertices(vertex_descriptor v_keep, vertex_descriptor v_rm, Mesh& mesh int main(int argc, char* argv[]) { const char* filename = (argc > 1) ? argv[1] : "data/blobby.off"; - std::ifstream input(filename); Mesh mesh; - if(!input || !(input >> mesh) || num_vertices(mesh) == 0) + if(!PMP::read_polygon_mesh(filename, mesh) || CGAL::is_empty(mesh)) { - std::cerr << filename << " is not a valid off file." << std::endl; - return EXIT_FAILURE; + std::cerr << "Invalid input." << std::endl; + return 1; } // Artificially create non-manifoldness for the sake of the example by merging some vertices diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/mesh_slicer_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/mesh_slicer_example.cpp index 2794e7ab88d..c8708ba8570 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/mesh_slicer_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/mesh_slicer_example.cpp @@ -1,32 +1,35 @@ #include #include + +#include +#include + #include #include #include -#include - #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef CGAL::Surface_mesh Mesh; +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Surface_mesh Mesh; -typedef std::vector Polyline_type; -typedef std::list< Polyline_type > Polylines; +typedef std::vector Polyline_type; +typedef std::list Polylines; -typedef CGAL::AABB_halfedge_graph_segment_primitive HGSP; -typedef CGAL::AABB_traits AABB_traits; -typedef CGAL::AABB_tree AABB_tree; +typedef CGAL::AABB_halfedge_graph_segment_primitive HGSP; +typedef CGAL::AABB_traits AABB_traits; +typedef CGAL::AABB_tree AABB_tree; + +namespace PMP = CGAL::Polygon_mesh_processing; int main(int argc, char* argv[]) { const char* filename = (argc > 1) ? argv[1] : "data/eight.off"; - std::ifstream input(filename); Mesh mesh; - if (!input || !(input >> mesh) || mesh.is_empty() - || !CGAL::is_triangle_mesh(mesh)) { - std::cerr << "Not a valid input file." << std::endl; + if(!PMP::read_polygon_mesh(filename, mesh) || CGAL::is_empty(mesh) || !CGAL::is_triangle_mesh(mesh)) + { + std::cerr << "Invalid input." << std::endl; return 1; } diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/mesh_smoothing_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/mesh_smoothing_example.cpp index ac081ec84ef..21046c672a7 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/mesh_smoothing_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/mesh_smoothing_example.cpp @@ -1,8 +1,9 @@ #include - #include + #include #include +#include #include #include @@ -17,13 +18,12 @@ namespace PMP = CGAL::Polygon_mesh_processing; int main(int argc, char** argv) { const char* filename = argc > 1 ? argv[1] : "data/anchor_dense.off"; - std::ifstream input(filename); Mesh mesh; - if (!input || !(input >> mesh) || mesh.is_empty()) + if(!PMP::read_polygon_mesh(filename, mesh)) { - std::cerr << "Not a valid .off file." << std::endl; - return EXIT_FAILURE; + std::cerr << "Invalid input." << std::endl; + return 1; } // Constrain edges with a dihedral angle over 60° diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/orientation_pipeline_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/orientation_pipeline_example.cpp index aab205af422..bfb6d31f783 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/orientation_pipeline_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/orientation_pipeline_example.cpp @@ -1,114 +1,68 @@ #include - #include #include #include #include - +#include #include #include +#include -#include #include #include +#include +#include + +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef K::Point_3 Point_3; + +typedef CGAL::Surface_mesh Mesh; + +namespace PMP = CGAL::Polygon_mesh_processing; int main(int argc, char** argv) { - typedef CGAL::Exact_predicates_inexact_constructions_kernel K; - typedef K::Point_3 Point_3; - typedef CGAL::Surface_mesh Mesh; + const char* input_filename = (argc < 2) ? "data/blobby-shuffled.off" : argv[1]; + const char* reference_filename = (argc < 2) ? "data/blobby.off" : argv[2]; std::vector points; - std::vector< std::vector > polygons; - Mesh ref1; - const char* input_filename = argc<2 ? "data/blobby-shuffled.off" : argv[1]; - std::ifstream input(input_filename); - if ( !input){ + std::vector > polygons; + if(!CGAL::read_polygon_soup(input_filename, points, polygons) || + points.size() == 0 || polygons.size() == 0) + { std::cerr << "Error: can not read input file.\n"; return 1; } - typedef K::Point_3 Point_3; - CGAL::File_scanner_OFF scanner(input); - points.resize(scanner.size_of_vertices()); - polygons.resize(scanner.size_of_facets()); - //read points - for (std::size_t i = 0; i < scanner.size_of_vertices(); ++i) - { - double x, y, z, w; - scanner.scan_vertex( x, y, z, w); - points[i] = Point_3(x, y, z, w); - scanner.skip_to_next_vertex( i); - } - //read triangles - for (std::size_t i = 0; i < scanner.size_of_facets(); ++i) - { - std::size_t no; - scanner.scan_facet( no, i); - polygons[i].resize(no); - for(std::size_t j = 0; j < no; ++j) { - std::size_t id; - scanner.scan_facet_vertex_index(id, i); - if(id < scanner.size_of_vertices()) - { - polygons[i][j] = id; - } - else - { - std::cerr << "Error: input file not valid.\n"; - return 1; - } - } - } - input.close(); - - if(points.size() == 0 || polygons.size()==0) + Mesh ref1; + if(!PMP::read_polygon_mesh(reference_filename, ref1)) { - std::cerr << "Error: input file not valid.\n"; + std::cerr << "Invalid input." << std::endl; return 1; } - const char* reference_filename = argc<2 ? "data/blobby.off" : argv[2]; - input.open(reference_filename); + std::cout << "Is the soup a polygon mesh ? : " << PMP::is_polygon_soup_a_polygon_mesh(polygons) << std::endl; - if ( !input || !(input >> ref1)){ - std::cerr << "Error: can not read reference file.\n"; - return 1; - } - input.close(); + PMP::orient_triangle_soup_with_reference_triangle_mesh(ref1, points, polygons); - std::cout << "Is the soup a polygon mesh ? : " - << CGAL::Polygon_mesh_processing::is_polygon_soup_a_polygon_mesh(polygons) - << std::endl; + std::cout << "And now ? : " << PMP::is_polygon_soup_a_polygon_mesh(polygons) << std::endl; - CGAL::Polygon_mesh_processing::orient_triangle_soup_with_reference_triangle_mesh(ref1, points, polygons); + PMP::duplicate_non_manifold_edges_in_polygon_soup(points, polygons); - std::cout << "And now ? : " - << CGAL::Polygon_mesh_processing::is_polygon_soup_a_polygon_mesh(polygons) - << std::endl; - - CGAL::Polygon_mesh_processing::duplicate_non_manifold_edges_in_polygon_soup(points, polygons); - - std::cout << "And now ? : " - << CGAL::Polygon_mesh_processing::is_polygon_soup_a_polygon_mesh(polygons) - << std::endl; + std::cout << "And now ? : " << PMP::is_polygon_soup_a_polygon_mesh(polygons) << std::endl; Mesh poly; - CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh( - points, polygons, poly); + PMP::polygon_soup_to_polygon_mesh(points, polygons, poly); typedef boost::property_map >::type Fccmap; Fccmap fccmap = get(CGAL::dynamic_face_property_t(), poly); - std::cout< #include -#include +#include +#include #include #include #include #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef K::Point_3 Point; -typedef CGAL::Polyhedron_3 Polyhedron; +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef K::Point_3 Point; +typedef CGAL::Polyhedron_3 Polyhedron; + +namespace PMP = CGAL::Polygon_mesh_processing; double max_coordinate(const Polyhedron& poly) { @@ -28,13 +31,11 @@ double max_coordinate(const Polyhedron& poly) int main(int argc, char* argv[]) { const char* filename = (argc > 1) ? argv[1] : "data/eight.off"; - std::ifstream input(filename); Polyhedron poly; - if (!input || !(input >> poly) || poly.empty() - || !CGAL::is_triangle_mesh(poly)) + if(!PMP::read_polygon_mesh(filename, poly) || CGAL::is_empty(poly) || !CGAL::is_triangle_mesh(poly)) { - std::cerr << "Not a valid input file." << std::endl; + std::cerr << "Invalid input." << std::endl; return 1; } diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/point_inside_example_OM.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/point_inside_example_OM.cpp index 292b9709f7a..9066a85077b 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/point_inside_example_OM.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/point_inside_example_OM.cpp @@ -1,24 +1,22 @@ #include +#include +#include +#include + #include #include -#include - -#include - -#include - #include #include #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef OpenMesh::PolyMesh_ArrayKernelT< > Mesh; -typedef K::Point_3 Point; +typedef OpenMesh::PolyMesh_ArrayKernelT< > Mesh; +typedef K::Point_3 Point; -typedef boost::graph_traits::vertex_descriptor vertex_descriptor; +typedef boost::graph_traits::vertex_descriptor vertex_descriptor; double max_coordinate(const Mesh& mesh) { @@ -42,7 +40,7 @@ int main(int argc, char* argv[]) Mesh mesh; OpenMesh::IO::read_mesh(mesh, filename); - if (!CGAL::is_triangle_mesh(mesh)) + if (CGAL::is_empty(mesh) || !CGAL::is_triangle_mesh(mesh)) { std::cerr << "Input geometry is not triangulated." << std::endl; return EXIT_FAILURE; diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/random_perturbation_SM_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/random_perturbation_SM_example.cpp index e040195334f..70004cc1d79 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/random_perturbation_SM_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/random_perturbation_SM_example.cpp @@ -2,35 +2,34 @@ #include #include +#include #include #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef K::Point_3 Point; +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef K::Point_3 Point; -typedef CGAL::Surface_mesh Surface_mesh; -typedef boost::graph_traits::vertex_descriptor vertex_descriptor; -typedef boost::graph_traits::face_descriptor face_descriptor; +typedef CGAL::Surface_mesh Surface_mesh; +typedef boost::graph_traits::vertex_descriptor vertex_descriptor; +typedef boost::graph_traits::face_descriptor face_descriptor; + +namespace PMP = CGAL::Polygon_mesh_processing; int main(int argc, char* argv[]) { const char* filename = (argc > 1) ? argv[1] : "data/eight.off"; - std::ifstream input(filename); Surface_mesh mesh; - if (!input || !(input >> mesh) || mesh.is_empty()) { - std::cerr << "Not a valid off file." << std::endl; + if(!PMP::read_polygon_mesh(filename, mesh)) + { + std::cerr << "Invalid input." << std::endl; return 1; } const double max_size = (argc > 2) ? atof(argv[2]) : 0.02; - namespace PMP = CGAL::Polygon_mesh_processing; - PMP::random_perturbation( - mesh, - max_size, - PMP::parameters::vertex_point_map(mesh.points()).geom_traits(K())); + PMP::random_perturbation(mesh, max_size, CGAL::parameters::vertex_point_map(mesh.points()).geom_traits(K())); std::ofstream out("data/eight_perturbed.off"); out.precision(17); diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/refine_fair_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/refine_fair_example.cpp index 23b9af70099..188c0968fa9 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/refine_fair_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/refine_fair_example.cpp @@ -4,15 +4,17 @@ #include #include +#include #include #include - typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; -typedef CGAL::Polyhedron_3 Polyhedron; -typedef Polyhedron::Vertex_handle Vertex_handle; +typedef CGAL::Polyhedron_3 Polyhedron; +typedef Polyhedron::Vertex_handle Vertex_handle; + +namespace PMP = CGAL::Polygon_mesh_processing; // extract vertices which are at most k (inclusive) // far from vertex v in the graph of edges @@ -33,9 +35,8 @@ void extract_k_ring(Vertex_handle v, Polyhedron::Halfedge_around_vertex_circulator e(v->vertex_begin()), e_end(e); do { Vertex_handle new_v = e->opposite()->vertex(); - if (D.insert(std::make_pair(new_v, dist_v + 1)).second) { + if (D.insert(std::make_pair(new_v, dist_v + 1)).second) qv.push_back(new_v); - } } while (++e != e_end); } } @@ -43,23 +44,21 @@ void extract_k_ring(Vertex_handle v, int main(int argc, char* argv[]) { const char* filename = (argc > 1) ? argv[1] : "data/blobby.off"; - std::ifstream input(filename); Polyhedron poly; - if ( !input || !(input >> poly) || poly.empty() - || !CGAL::is_triangle_mesh(poly)) { - std::cerr << "Not a valid input file." << std::endl; + if(!PMP::read_polygon_mesh(filename, poly) || !CGAL::is_triangle_mesh(poly)) + { + std::cerr << "Invalid input." << std::endl; return 1; } std::vector new_facets; std::vector new_vertices; - CGAL::Polygon_mesh_processing::refine(poly, - faces(poly), - std::back_inserter(new_facets), - std::back_inserter(new_vertices), - CGAL::Polygon_mesh_processing::parameters::density_control_factor(2.)); + PMP::refine(poly, faces(poly), + std::back_inserter(new_facets), + std::back_inserter(new_vertices), + CGAL::parameters::density_control_factor(2.)); std::ofstream refined_off("refined.off"); refined_off.precision(17); @@ -72,7 +71,7 @@ int main(int argc, char* argv[]) std::vector region; extract_k_ring(v, 12/*e.g.*/, region); - bool success = CGAL::Polygon_mesh_processing::fair(poly, region); + bool success = PMP::fair(poly, region); std::cout << "Fairing : " << (success ? "succeeded" : "failed") << std::endl; std::ofstream faired_off("faired.off"); diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/self_intersections_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/self_intersections_example.cpp index a44efca2da7..75e7e45c3a0 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/self_intersections_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/self_intersections_example.cpp @@ -2,6 +2,8 @@ #include #include +#include + #include #include @@ -17,13 +19,12 @@ namespace PMP = CGAL::Polygon_mesh_processing; int main(int argc, char* argv[]) { const char* filename = (argc > 1) ? argv[1] : "data/pig.off"; - std::ifstream input(filename); Mesh mesh; - if (!input || !(input >> mesh) || !CGAL::is_triangle_mesh(mesh)) + if(!PMP::read_polygon_mesh(filename, mesh) || !CGAL::is_triangle_mesh(mesh)) { - std::cerr << "Not a valid input file." << std::endl; - return EXIT_FAILURE; + std::cerr << "Invalid input." << std::endl; + return 1; } std::cout << "Using parallel mode? " << std::is_same::value << std::endl; diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/shape_smoothing_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/shape_smoothing_example.cpp index 6d5e7f75bd5..850b6b1dd00 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/shape_smoothing_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/shape_smoothing_example.cpp @@ -1,7 +1,8 @@ #include - #include + #include +#include #include #include @@ -14,13 +15,12 @@ namespace PMP = CGAL::Polygon_mesh_processing; int main(int argc, char* argv[]) { const char* filename = (argc > 1) ? argv[1] : "data/pig.off"; - std::ifstream input(filename); Mesh mesh; - if (!input || !(input >> mesh) || mesh.is_empty()) + if(!PMP::read_polygon_mesh(filename, mesh)) { - std::cerr << "Not a valid .off file." << std::endl; - return EXIT_FAILURE; + std::cerr << "Invalid input." << std::endl; + return 1; } const unsigned int nb_iterations = (argc > 2) ? std::atoi(argv[2]) : 10; diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/stitch_borders_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/stitch_borders_example.cpp index bd364a60773..1106c1ed5a2 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/stitch_borders_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/stitch_borders_example.cpp @@ -3,21 +3,24 @@ #include #include +#include #include #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef CGAL::Polyhedron_3 Polyhedron; +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Polyhedron_3 Polyhedron; + +namespace PMP = CGAL::Polygon_mesh_processing; int main(int argc, char* argv[]) { const char* filename = (argc > 1) ? argv[1] : "data/full_border_quads.off"; - std::ifstream input(filename); Polyhedron mesh; - if (!input || !(input >> mesh) || mesh.is_empty()) { - std::cerr << "Not a valid off file." << std::endl; + if(!PMP::read_polygon_mesh(filename, mesh)) + { + std::cerr << "Invalid input." << std::endl; return 1; } @@ -26,7 +29,7 @@ int main(int argc, char* argv[]) std::cout << "\t Number of halfedges :\t" << mesh.size_of_halfedges() << std::endl; std::cout << "\t Number of facets :\t" << mesh.size_of_facets() << std::endl; - CGAL::Polygon_mesh_processing::stitch_borders(mesh); + PMP::stitch_borders(mesh); std::cout << "Stitching done : " << std::endl; std::cout << "\t Number of vertices :\t" << mesh.size_of_vertices() << std::endl; diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/stitch_borders_example_OM.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/stitch_borders_example_OM.cpp index 057d32ae47d..5791ce9f078 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/stitch_borders_example_OM.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/stitch_borders_example_OM.cpp @@ -1,17 +1,16 @@ - #include +#include + #include #include #include -#include #include #include typedef CGAL::Exact_predicates_inexact_constructions_kernel K; - typedef OpenMesh::PolyMesh_ArrayKernelT< > Mesh; int main(int argc, char* argv[]) { @@ -25,8 +24,7 @@ int main(int argc, char* argv[]) std::cout << "\t Number of halfedges :\t" << num_halfedges(mesh) << std::endl; std::cout << "\t Number of facets :\t" << num_faces(mesh) << std::endl; - CGAL::Polygon_mesh_processing::stitch_borders(mesh, - CGAL::Polygon_mesh_processing::parameters::vertex_point_map(get(CGAL::vertex_point, mesh))); + CGAL::Polygon_mesh_processing::stitch_borders(mesh, CGAL::parameters::vertex_point_map(get(CGAL::vertex_point, mesh))); mesh.garbage_collection(); std::cout << "Stitching done : " << std::endl; diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/surface_mesh_intersection.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/surface_mesh_intersection.cpp index 01c5a7d65b7..c07f6a4d188 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/surface_mesh_intersection.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/surface_mesh_intersection.cpp @@ -1,40 +1,33 @@ #include #include -#include #include +#include -namespace PMP=CGAL::Polygon_mesh_processing; +#include #include #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; -typedef Kernel::Point_3 Point; -typedef CGAL::Surface_mesh Mesh; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; +typedef Kernel::Point_3 Point; +typedef CGAL::Surface_mesh Mesh; -typedef boost::graph_traits::halfedge_descriptor halfedge_descriptor; -typedef boost::graph_traits::face_descriptor face_descriptor; -typedef boost::graph_traits::vertex_descriptor vertex_descriptor; +typedef boost::graph_traits::vertex_descriptor vertex_descriptor; +typedef boost::graph_traits::halfedge_descriptor halfedge_descriptor; +typedef boost::graph_traits::face_descriptor face_descriptor; + +namespace PMP = CGAL::Polygon_mesh_processing; int main(int argc, char* argv[]) { const char* filename1 = (argc > 1) ? argv[1] : "data/blobby.off"; - std::ifstream input(filename1); - - Mesh mesh1; - if ( !input || !(input >> mesh1) ) { - std::cerr << filename1 << " is not a valid off file." << std::endl; - return 1; - } - input.close(); - const char* filename2 = (argc > 2) ? argv[2] : "data/eight.off"; - input.open(filename2); - Mesh mesh2; - if ( !input || !(input >> mesh2) ) { - std::cerr << filename2 << " is not a valid off file." << std::endl; + Mesh mesh1, mesh2; + if(!PMP::read_polygon_mesh(filename1, mesh1) || !PMP::read_polygon_mesh(filename2, mesh2)) + { + std::cerr << "Invalid input." << std::endl; return 1; } diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_faces_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_faces_example.cpp index 63528119d44..c73bb39c787 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_faces_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_faces_example.cpp @@ -2,33 +2,36 @@ #include #include +#include +#include #include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; -typedef Kernel::Point_3 Point; -typedef CGAL::Surface_mesh Surface_mesh; +typedef Kernel::Point_3 Point; +typedef CGAL::Surface_mesh Surface_mesh; + +namespace PMP = CGAL::Polygon_mesh_processing; int main(int argc, char* argv[]) { const char* filename = (argc > 1) ? argv[1] : "data/P.off"; const char* outfilename = (argc > 2) ? argv[2] : "P_tri.off"; - std::ifstream input(filename); Surface_mesh mesh; - if (!input || !(input >> mesh) || mesh.is_empty()) + if(!PMP::read_polygon_mesh(filename, mesh)) { - std::cerr << "Not a valid off file." << std::endl; + std::cerr << "Invalid input." << std::endl; return 1; } - CGAL::Polygon_mesh_processing::triangulate_faces(mesh); + PMP::triangulate_faces(mesh); // Confirm that all faces are triangles. - for(boost::graph_traits::face_descriptor fit : faces(mesh)) - if (next(next(halfedge(fit, mesh), mesh), mesh) - != prev(halfedge(fit, mesh), mesh)) + for(boost::graph_traits::face_descriptor f : faces(mesh)) + if(!CGAL::is_triangle(halfedge(f, mesh), mesh)) std::cerr << "Error: non-triangular face left in mesh." << std::endl; std::ofstream cube_off(outfilename); diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_faces_example_OM.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_faces_example_OM.cpp index 0e0d78d2129..fdf7983509b 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_faces_example_OM.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_faces_example_OM.cpp @@ -9,21 +9,20 @@ #include typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; -typedef Kernel::Point_3 Point; +typedef Kernel::Point_3 Point; -typedef OpenMesh::PolyMesh_ArrayKernelT< > Mesh; +typedef OpenMesh::PolyMesh_ArrayKernelT< > Mesh; int main(int argc, char* argv[]) { const char* filename = (argc > 1) ? argv[1] : "data/cube_quad.off"; const char* outfilename = (argc > 2) ? argv[2] : "cube_tri.off"; - std::ifstream input(filename); Mesh mesh; OpenMesh::IO::read_mesh(mesh, filename); CGAL::Polygon_mesh_processing::triangulate_faces(mesh, - CGAL::Polygon_mesh_processing::parameters::vertex_point_map(get(CGAL::vertex_point, mesh)). + CGAL::parameters::vertex_point_map(get(CGAL::vertex_point, mesh)). geom_traits(Kernel())); mesh.garbage_collection(); diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_polyline_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_polyline_example.cpp index 9564cc89c98..204dd3e2ed5 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_polyline_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/triangulate_polyline_example.cpp @@ -1,4 +1,5 @@ #include + #include #include @@ -6,7 +7,7 @@ #include typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; -typedef Kernel::Point_3 Point; +typedef Kernel::Point_3 Point; int main() { @@ -41,9 +42,8 @@ int main() polyline_collinear.push_back(Point(4.,0.,0.)); std::vector patch_will_be_empty; - CGAL::Polygon_mesh_processing::triangulate_hole_polyline( - polyline_collinear, - back_inserter(patch_will_be_empty)); + CGAL::Polygon_mesh_processing::triangulate_hole_polyline(polyline_collinear, + back_inserter(patch_will_be_empty)); CGAL_assertion(patch_will_be_empty.empty()); return 0; diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/volume_connected_components.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/volume_connected_components.cpp index 948706a87df..c800b9e3c27 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/volume_connected_components.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/volume_connected_components.cpp @@ -1,14 +1,17 @@ #include #include + #include +#include + #include -#include #include +#include #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; -typedef CGAL::Surface_mesh Surface_mesh; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; +typedef CGAL::Surface_mesh Surface_mesh; namespace PMP = CGAL::Polygon_mesh_processing; namespace params = CGAL::parameters; @@ -16,33 +19,35 @@ namespace params = CGAL::parameters; int main(int argc, char** argv) { const char* filename = (argc > 1) ? argv[1] : "data/blobby.off"; - std::ifstream input(filename); - assert(input); - Surface_mesh sm; - input >> sm; + + Surface_mesh mesh; + if(!PMP::read_polygon_mesh(filename, mesh)) + { + std::cerr << "Invalid input." << std::endl; + return 1; + } // property map to assign a volume id for each face Surface_mesh::Property_map vol_id_map = - sm.add_property_map().first; + mesh.add_property_map().first; - std::vector err_codes; // fill the volume id map - std::size_t nb_vol = - PMP::volume_connected_components(sm, - vol_id_map, - params::error_codes(std::ref(err_codes))); - + std::vector err_codes; + std::size_t nb_vol = PMP::volume_connected_components(mesh, vol_id_map, + params::error_codes(std::ref(err_codes))); std::cout << "Found " << nb_vol << " volumes\n"; // write each volume in an OFF file typedef CGAL::Face_filtered_graph Filtered_graph; - Filtered_graph vol_mesh(sm, 0, vol_id_map); + Filtered_graph vol_mesh(mesh, 0, vol_id_map); for(std::size_t id = 0; id < nb_vol; ++id) { - if (err_codes[id] != PMP::VALID_VOLUME) + if(err_codes[id] != PMP::VALID_VOLUME) std::cerr << "There is an issue with volume #" << id << "\n"; + if(id > 0) vol_mesh.set_selected_faces(id, vol_id_map); + Surface_mesh out; CGAL::copy_face_graph(vol_mesh, out); std::ostringstream oss; diff --git a/Polygonal_surface_reconstruction/examples/Polygonal_surface_reconstruction/polyfit_example_model_complexty_control.cpp b/Polygonal_surface_reconstruction/examples/Polygonal_surface_reconstruction/polyfit_example_model_complexty_control.cpp index 16097f674e0..f1283f251d2 100644 --- a/Polygonal_surface_reconstruction/examples/Polygonal_surface_reconstruction/polyfit_example_model_complexty_control.cpp +++ b/Polygonal_surface_reconstruction/examples/Polygonal_surface_reconstruction/polyfit_example_model_complexty_control.cpp @@ -50,13 +50,11 @@ int main() CGAL::Timer t; t.start(); - if (!input_stream || - !CGAL::read_PLY_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_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; return EXIT_FAILURE; @@ -93,8 +91,7 @@ int main() } else { const std::string& output_file = "data/building_result-0.05.off"; - std::ofstream output_stream(output_file.c_str()); - if (output_stream && CGAL::write_off(output_stream, model)) + if (CGAL::write_OFF(output_file, model)) std::cout << " Done. Saved to " << output_file << ". Time: " << t.time() << " sec." << std::endl; else { std::cerr << " Failed saving file." << std::endl; @@ -111,8 +108,7 @@ int main() } else { const std::string& output_file = "data/building_result-0.5.off"; - std::ofstream output_stream(output_file.c_str()); - if (output_stream && CGAL::write_off(output_stream, model)) + if (CGAL::write_OFF(output_file, model)) std::cout << " Done. Saved to " << output_file << ". Time: " << t.time() << " sec." << std::endl; else { std::cerr << " Failed saving file." << std::endl; @@ -129,8 +125,7 @@ int main() } else { const std::string& output_file = "data/building_result-0.7.off"; - std::ofstream output_stream(output_file.c_str()); - if (output_stream && CGAL::write_off(output_stream, model)) + if (CGAL::write_OFF(output_file, model)) std::cout << " Done. Saved to " << output_file << ". Time: " << t.time() << " sec." << std::endl; else { std::cerr << " Failed saving file." << std::endl; diff --git a/Polygonal_surface_reconstruction/examples/Polygonal_surface_reconstruction/polyfit_example_user_provided_planes.cpp b/Polygonal_surface_reconstruction/examples/Polygonal_surface_reconstruction/polyfit_example_user_provided_planes.cpp index 584799e034f..dbe23f024fb 100644 --- a/Polygonal_surface_reconstruction/examples/Polygonal_surface_reconstruction/polyfit_example_user_provided_planes.cpp +++ b/Polygonal_surface_reconstruction/examples/Polygonal_surface_reconstruction/polyfit_example_user_provided_planes.cpp @@ -50,13 +50,11 @@ int main() CGAL::Timer t; t.start(); - if (!input_stream || - !CGAL::read_PLY_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_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; return EXIT_FAILURE; @@ -92,8 +90,7 @@ int main() // Saves the mesh model const std::string& output_file("data/ball_result.off"); - std::ofstream output_stream(output_file.c_str()); - if (output_stream && CGAL::write_off(output_stream, model)) + if (CGAL::write_OFF(output_file, model)) std::cout << " Done. Saved to " << output_file << ". Time: " << t.time() << " sec." << std::endl; else { std::cerr << " Failed saving file." << std::endl; diff --git a/Polygonal_surface_reconstruction/examples/Polygonal_surface_reconstruction/polyfit_example_with_region_growing.cpp b/Polygonal_surface_reconstruction/examples/Polygonal_surface_reconstruction/polyfit_example_with_region_growing.cpp index 73981738bb3..a30cfd29c01 100644 --- a/Polygonal_surface_reconstruction/examples/Polygonal_surface_reconstruction/polyfit_example_with_region_growing.cpp +++ b/Polygonal_surface_reconstruction/examples/Polygonal_surface_reconstruction/polyfit_example_with_region_growing.cpp @@ -101,9 +101,8 @@ int main() CGAL::Timer t; t.start(); - if (!CGAL::read_points(input_file.c_str(), - std::back_inserter(points), - CGAL::parameters::point_map(Point_map()).normal_map(Normal_map()))) { + if (!CGAL::read_points(input_file.c_str(), 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; @@ -176,8 +175,7 @@ int main() std::cout << "Saving..."; t.reset(); const std::string& output_file("data/cube_result.off"); - std::ofstream output_stream(output_file.c_str()); - if (output_stream && CGAL::write_off(output_stream, model)) + if (CGAL::write_OFF(output_file, model)) std::cout << " Done. Saved to " << output_file << ". Time: " << t.time() << " sec." << std::endl; else { std::cerr << " Failed saving file." << std::endl; 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 0cbe5d2375f..0f8365be9a7 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 @@ -68,9 +68,8 @@ int main() CGAL::Timer t; t.start(); - if (!CGAL::read_points(input_file.c_str(), - std::back_inserter(points), - CGAL::parameters::point_map(Point_map()).normal_map(Normal_map()))) + if (!CGAL::read_points(input_file.c_str(), 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; @@ -127,8 +126,7 @@ int main() } const std::string& output_file("data/cube_result.off"); - std::ofstream output_stream(output_file.c_str()); - if (output_stream && CGAL::write_off(output_stream, model)) + if (CGAL::write_OFF(output_file, model)) std::cout << " Done. Saved to " << output_file << ". Time: " << t.time() << " sec." << std::endl; else { std::cerr << " Failed saving file." << std::endl; @@ -142,7 +140,7 @@ int main() algo.output_candidate_faces(candidate_faces); const std::string& candidate_faces_file("data/cube_candidate_faces.off"); std::ofstream candidate_stream(candidate_faces_file.c_str()); - if (candidate_stream && CGAL::write_off(candidate_stream, candidate_faces)) + if (CGAL::write_OFF(candidate_stream, candidate_faces)) std::cout << "Candidate faces saved to " << candidate_faces_file << "." << std::endl; return EXIT_SUCCESS; diff --git a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.h b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.h index eb6ecb51a1e..31e7cfdb324 100644 --- a/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.h +++ b/Polyhedron/demo/Polyhedron/Scene_points_with_normal_item.h @@ -1,16 +1,22 @@ #ifndef POINT_SET_ITEM_H #define POINT_SET_ITEM_H + #include #include #include + #include "Scene_points_with_normal_item_config.h" -#include + +#include +#include + #include "Kernel_type.h" #include "Point_set_3.h" + #include -#include struct Scene_points_with_normal_item_priv; + // point set typedef Point_set_3 Point_set; typedef CGAL::Surface_mesh SMesh; diff --git a/Polyhedron/examples/Polyhedron/polyhedron_self_intersection.cpp b/Polyhedron/examples/Polyhedron/polyhedron_self_intersection.cpp index fc6516a0c70..4b604f9e48c 100644 --- a/Polyhedron/examples/Polyhedron/polyhedron_self_intersection.cpp +++ b/Polyhedron/examples/Polyhedron/polyhedron_self_intersection.cpp @@ -104,7 +104,7 @@ struct Intersect_facets { } }; -void write_off() { +void write_OFF() { cout << "OFF\n" << (triangles.size() * 3) << ' ' << triangles.size() << " 0\n"; for ( std::vector::iterator i = triangles.begin(); @@ -154,7 +154,7 @@ int main(int argc, char* argv[]) { cerr << "Intersection ... " << endl; intersection( P); cerr << "Intersection : " << user_time.time() << " seconds." << endl; - write_off(); + write_OFF(); return 0; } diff --git a/Spatial_searching/examples/Spatial_searching/circular_query.cpp b/Spatial_searching/examples/Spatial_searching/circular_query.cpp index dacb895a54a..1d0d57349c9 100644 --- a/Spatial_searching/examples/Spatial_searching/circular_query.cpp +++ b/Spatial_searching/examples/Spatial_searching/circular_query.cpp @@ -12,14 +12,13 @@ typedef CGAL::Search_traits_2 Traits; typedef CGAL::Fuzzy_sphere Fuzzy_circle; typedef CGAL::Kd_tree Tree; -int main() { - +int main() +{ const int N = 30; Tree tree; Random_points_iterator rpg; - for(int i = 0; i < N; i++){ + for(int i = 0; i < N; i++) tree.insert(*rpg++); - } // fuzziness = 0 diff --git a/Spatial_searching/examples/Spatial_searching/distance_browsing.cpp b/Spatial_searching/examples/Spatial_searching/distance_browsing.cpp index 8ef9f285c0e..e889ac00ace 100644 --- a/Spatial_searching/examples/Spatial_searching/distance_browsing.cpp +++ b/Spatial_searching/examples/Spatial_searching/distance_browsing.cpp @@ -17,8 +17,8 @@ struct X_not_positive { // An iterator that only enumerates dD points with positive x-coordinate typedef CGAL::Filter_iterator NN_positive_x_iterator; -int main() { - +int main() +{ Tree tree; tree.insert(Point_d(0,0)); tree.insert(Point_d(1,1)); diff --git a/Spatial_searching/examples/Spatial_searching/fuzzy_range_query.cpp b/Spatial_searching/examples/Spatial_searching/fuzzy_range_query.cpp index 238627377d1..6baec0e9775 100644 --- a/Spatial_searching/examples/Spatial_searching/fuzzy_range_query.cpp +++ b/Spatial_searching/examples/Spatial_searching/fuzzy_range_query.cpp @@ -16,8 +16,8 @@ typedef CGAL::Kd_tree Tree; typedef CGAL::Fuzzy_sphere Fuzzy_sphere; typedef CGAL::Fuzzy_iso_box Fuzzy_iso_box; -int main() { - +int main() +{ const int N = 1000; // generator for random data points in the square ( (-1000,-1000), (1000,1000) ) Random_points_iterator rpit(4, 1000.0); diff --git a/Spatial_searching/examples/Spatial_searching/general_neighbor_searching.cpp b/Spatial_searching/examples/Spatial_searching/general_neighbor_searching.cpp index 2fde8477868..2a7a6df3fd6 100644 --- a/Spatial_searching/examples/Spatial_searching/general_neighbor_searching.cpp +++ b/Spatial_searching/examples/Spatial_searching/general_neighbor_searching.cpp @@ -13,15 +13,16 @@ typedef CGAL::Manhattan_distance_iso_box_point Distance; typedef CGAL::K_neighbor_search Neighbor_search; typedef Neighbor_search::Tree Tree; -int main() { +int main() +{ const int N = 1000; const unsigned int K = 10; Tree tree; Random_points_iterator rpit(4,1000.0); - for(int i = 0; i < N; i++){ + for(int i = 0; i < N; i++) tree.insert(*rpit++); - } + Point_d pp(0.1,0.1,0.1,0.1); Point_d qq(0.2,0.2,0.2,0.2); Iso_box_d query(pp,qq); diff --git a/Spatial_searching/examples/Spatial_searching/iso_rectangle_2_query.cpp b/Spatial_searching/examples/Spatial_searching/iso_rectangle_2_query.cpp index 4ef739e9819..21a36102f39 100644 --- a/Spatial_searching/examples/Spatial_searching/iso_rectangle_2_query.cpp +++ b/Spatial_searching/examples/Spatial_searching/iso_rectangle_2_query.cpp @@ -14,8 +14,8 @@ typedef CGAL::Search_traits_2 Traits; typedef CGAL::Kd_tree Tree; typedef CGAL::Fuzzy_iso_box Fuzzy_iso_box; -int -main() { +int main() +{ const int N = 1000; std::list points; @@ -23,9 +23,8 @@ main() { Tree tree; Random_points_iterator rpg; - for(int i = 0; i < N; i++){ + for(int i = 0; i < N; i++) tree.insert(*rpg++); - } std::list result; diff --git a/Spatial_searching/examples/Spatial_searching/nearest_neighbor_searching.cpp b/Spatial_searching/examples/Spatial_searching/nearest_neighbor_searching.cpp index 8055c8be058..7afc7fdff33 100644 --- a/Spatial_searching/examples/Spatial_searching/nearest_neighbor_searching.cpp +++ b/Spatial_searching/examples/Spatial_searching/nearest_neighbor_searching.cpp @@ -12,7 +12,8 @@ typedef CGAL::Search_traits_2 TreeTraits; typedef CGAL::Orthogonal_k_neighbor_search Neighbor_search; typedef Neighbor_search::Tree Tree; -int main() { +int main() +{ const unsigned int N = 1; std::list points; @@ -20,18 +21,14 @@ int main() { Tree tree(points.begin(), points.end()); - Point_d query(0,0); - // Initialize the search structure, and search all N points - + Point_d query(0,0); Neighbor_search search(tree, query, N); // report the N nearest neighbors and their distance // This should sort all N points by increasing distance from origin - for(Neighbor_search::iterator it = search.begin(); it != search.end(); ++it){ + for(Neighbor_search::iterator it = search.begin(); it != search.end(); ++it) std::cout << it->first << " "<< std::sqrt(it->second) << std::endl; - } - return 0; } diff --git a/Spatial_searching/examples/Spatial_searching/searching_polyhedron_vertices.cpp b/Spatial_searching/examples/Spatial_searching/searching_polyhedron_vertices.cpp index c85878bce01..67ad9eb4f9d 100644 --- a/Spatial_searching/examples/Spatial_searching/searching_polyhedron_vertices.cpp +++ b/Spatial_searching/examples/Spatial_searching/searching_polyhedron_vertices.cpp @@ -22,7 +22,8 @@ typedef K_neighbor_search::Tree Tree; typedef Tree::Splitter Splitter; typedef K_neighbor_search::Distance Distance; -int main(int argc, char* argv[]) { +int main(int argc, char* argv[]) +{ Mesh mesh; std::ifstream in((argc>1)?argv[1]:"data/tripod.off"); in >> mesh; @@ -31,16 +32,12 @@ int main(int argc, char* argv[]) { Vertex_point_pmap vppmap = get(CGAL::vertex_point,mesh); // Insert number_of_data_points in the tree - Tree tree( - vertices(mesh).begin(), - vertices(mesh).end(), - Splitter(), - Traits(vppmap) - ); + Tree tree(vertices(mesh).begin(), vertices(mesh).end(), Splitter(), Traits(vppmap)); + + // search K nearest neighbours Point_3 query(0.0, 0.0, 0.0); Distance tr_dist(vppmap); - // search K nearest neighbours K_neighbor_search search(tree, query, K,0,true,tr_dist); std::cout <<"The "<< K << " nearest vertices to the query point at (0,0,0) are:" << std::endl; for(K_neighbor_search::iterator it = search.begin(); it != search.end(); it++){ diff --git a/Spatial_searching/examples/Spatial_searching/searching_polyhedron_vertices_with_fuzzy_sphere.cpp b/Spatial_searching/examples/Spatial_searching/searching_polyhedron_vertices_with_fuzzy_sphere.cpp index b91104edaed..7837196f644 100644 --- a/Spatial_searching/examples/Spatial_searching/searching_polyhedron_vertices_with_fuzzy_sphere.cpp +++ b/Spatial_searching/examples/Spatial_searching/searching_polyhedron_vertices_with_fuzzy_sphere.cpp @@ -27,7 +27,7 @@ int main(int argc, char* argv[]) { Mesh mesh; std::ifstream in((argc>1)?argv[1]:"data/tripod.off"); - in >> mesh; + in >> mesh; Vertex_point_pmap vppmap = get(CGAL::vertex_point,mesh); Traits traits(vppmap); diff --git a/Spatial_searching/examples/Spatial_searching/searching_sphere_orthogonally.cpp b/Spatial_searching/examples/Spatial_searching/searching_sphere_orthogonally.cpp index 1bd9d0e0d0b..ae113d93cb3 100644 --- a/Spatial_searching/examples/Spatial_searching/searching_sphere_orthogonally.cpp +++ b/Spatial_searching/examples/Spatial_searching/searching_sphere_orthogonally.cpp @@ -1,8 +1,10 @@ #include + #include #include #include #include + typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_2 Point_2; typedef CGAL::Random_points_in_square_2 Random_points_iterator; @@ -13,24 +15,28 @@ typedef CGAL::Orthogonal_k_neighbor_search Neighbor_search typedef TreeTraits::Construct_center_d Construct_center_d; typedef TreeTraits::Compute_squared_radius_d Compute_squared_radius_d; typedef Neighbor_search::Tree Tree; -int main() { + +int main() +{ const int N = 1000; const unsigned int K = 10; + Tree tree; Random_points_iterator rpg; - for(int i = 0; i < N; i++){ + for(int i = 0; i < N; ++i) tree.insert(*rpg++); - } + Sphere_2 query(*rpg,0.5); Distance tr_dist; Point_2 center = Construct_center_d()(query); Neighbor_search N1(tree, center, K, 0.0, false); // eps=0.0, nearest=false + std::cout << "For the query circle " << std::endl - << "The " << K << " approximate furthest neighbors are: " << std::endl; + << "The " << K << " approximate furthest neighbors are: " << std::endl; double radius = Compute_squared_radius_d()(query); - for (Neighbor_search::iterator it = N1.begin();it != N1.end();it++) { + for (Neighbor_search::iterator it = N1.begin();it != N1.end();it++) std::cout << " Point " << it->first << " at distance = " << tr_dist.inverse_of_transformed_distance(it->second - radius) << std::endl; - } + return 0; } diff --git a/Spatial_searching/examples/Spatial_searching/searching_surface_mesh_vertices.cpp b/Spatial_searching/examples/Spatial_searching/searching_surface_mesh_vertices.cpp index 1d004f4262c..b9faabfeb64 100644 --- a/Spatial_searching/examples/Spatial_searching/searching_surface_mesh_vertices.cpp +++ b/Spatial_searching/examples/Spatial_searching/searching_surface_mesh_vertices.cpp @@ -23,31 +23,35 @@ typedef K_neighbor_search::Tree Tree; typedef Tree::Splitter Splitter; typedef K_neighbor_search::Distance Distance; -int main(int argc, char* argv[]) { +int main(int argc, char* argv[]) +{ + const char* filename = (argc>1) ? argv[1] : "data/tripod.off"; + Mesh mesh; - std::cerr << argc <1)?argv[1]:"data/tripod.off"); - in >> mesh; + if(!CGAL::read_polygon_mesh(filename, mesh)) + { + std::cerr << "Invalid input." << std::endl; + return 1; + } + const unsigned int K = 5; Vertex_point_pmap vppmap = get(CGAL::vertex_point,mesh); // Insert number_of_data_points in the tree - Tree tree( - vertices(mesh).begin(), - vertices(mesh).end(), - Splitter(), - Traits(vppmap) - ); + Tree tree(vertices(mesh).begin(), vertices(mesh).end(), Splitter(), Traits(vppmap)); + + // search K nearest neighbours Point_3 query(0.0, 0.0, 0.0); Distance tr_dist(vppmap); - // search K nearest neighbours K_neighbor_search search(tree, query, K,0,true,tr_dist); std::cout <<"The "<< K << " nearest vertices to the query point at (0,0,0) are:" << std::endl; - for(K_neighbor_search::iterator it = search.begin(); it != search.end(); it++){ + for(K_neighbor_search::iterator it = search.begin(); it != search.end(); it++) + { std::cout << "vertex " << it->first << " : " << vppmap[it->first] << " at distance " << tr_dist.inverse_of_transformed_distance(it->second) << std::endl; } + return 0; } diff --git a/Spatial_searching/examples/Spatial_searching/searching_with_circular_query.cpp b/Spatial_searching/examples/Spatial_searching/searching_with_circular_query.cpp index 1800f63318d..51d5b24f417 100644 --- a/Spatial_searching/examples/Spatial_searching/searching_with_circular_query.cpp +++ b/Spatial_searching/examples/Spatial_searching/searching_with_circular_query.cpp @@ -14,8 +14,8 @@ typedef CGAL::Fuzzy_sphere Fuzzy_circle; typedef CGAL::Kd_tree Tree; typedef CGAL::Random Random; -int main() { - +int main() +{ const int N=1000; // generator for random data points in the square ( (-1,-1), (1,1) ) @@ -31,20 +31,19 @@ int main() { Fuzzy_circle default_range(center, 0.2); boost::optional any = tree.search_any_point(default_range); - if(any){ + if(any) std::cout << *any << " is in the query circle\n"; - }else{ + else std::cout << "Empty query circle\n"; - } + std::list result; tree.search(std::back_inserter(result), default_range); std::cout << "\nPoints in cirle with center " << center << " and radius 0.2" << std::endl; std::list::iterator it; - for (it=result.begin(); (it != result.end()); ++it) { + for (it=result.begin(); (it != result.end()); ++it) std::cout << *it << std::endl; - } result.clear(); // approximate range searching using value 0.1 for fuzziness parameter @@ -54,9 +53,9 @@ int main() { std::cout << "\n\nPoints in cirle with center " << center << " and fuzzy radius [0.1,0.3]" << std::endl; - for (it=result.begin(); (it != result.end()); ++it) { + for (it=result.begin(); (it != result.end()); ++it) std::cout << *it << std::endl; - } + std::cout << "\ndone" << std::endl; return 0; } diff --git a/Spatial_searching/examples/Spatial_searching/searching_with_point_with_info.cpp b/Spatial_searching/examples/Spatial_searching/searching_with_point_with_info.cpp index 7c7d109ae7e..1298707c2d1 100644 --- a/Spatial_searching/examples/Spatial_searching/searching_with_point_with_info.cpp +++ b/Spatial_searching/examples/Spatial_searching/searching_with_point_with_info.cpp @@ -22,7 +22,8 @@ typedef CGAL::Orthogonal_k_neighbor_search K_neighbor_search; typedef K_neighbor_search::Tree Tree; typedef K_neighbor_search::Distance Distance; -int main() { +int main() +{ const unsigned int K = 5; // generator for random data points in the cube ( (-1,-1,-1), (1,1,1) ) Random_points_iterator rpit( 1.0); @@ -46,14 +47,13 @@ int main() { indices.push_back(6); // Insert number_of_data_points in the tree - Tree tree( - boost::make_zip_iterator(boost::make_tuple( points.begin(),indices.begin() )), - boost::make_zip_iterator(boost::make_tuple( points.end(),indices.end() ) ) - ); + Tree tree(boost::make_zip_iterator(boost::make_tuple( points.begin(),indices.begin())), + boost::make_zip_iterator(boost::make_tuple( points.end(),indices.end()))); + + // search K nearest neighbours Point_3 query(0.0, 0.0, 0.0); Distance tr_dist; - // search K nearest neighbours K_neighbor_search search(tree, query, K); for(K_neighbor_search::iterator it = search.begin(); it != search.end(); it++){ std::cout << " d(q, nearest neighbor)= " diff --git a/Spatial_searching/examples/Spatial_searching/searching_with_point_with_info_inplace.cpp b/Spatial_searching/examples/Spatial_searching/searching_with_point_with_info_inplace.cpp index 3c5f93a511f..38aab7884ba 100644 --- a/Spatial_searching/examples/Spatial_searching/searching_with_point_with_info_inplace.cpp +++ b/Spatial_searching/examples/Spatial_searching/searching_with_point_with_info_inplace.cpp @@ -12,7 +12,8 @@ typedef Kernel::Point_3 Point_3; //definition of a non-mutable lvalue property map, //with the get function as a friend function to give it //access to the private member -class My_point_property_map{ +class My_point_property_map +{ const std::vector& points; public: typedef Point_3 value_type; @@ -39,7 +40,8 @@ typedef K_neighbor_search::Tree Tree; typedef Tree::Splitter Splitter; typedef K_neighbor_search::Distance Distance; -int main() { +int main() +{ const unsigned int K = 5; // generator for random data points in the cube ( (-1,-1,-1), (1,1,1) ) Random_points_iterator rpit( 1.0); @@ -56,16 +58,15 @@ int main() { My_point_property_map ppmap(points); // Insert number_of_data_points in the tree - Tree tree( - boost::counting_iterator(0), - boost::counting_iterator(points.size()), - Splitter(), - Traits(ppmap) - ); + Tree tree(boost::counting_iterator(0), + boost::counting_iterator(points.size()), + Splitter(), + Traits(ppmap)); + + // search K nearest neighbours Point_3 query(0.0, 0.0, 0.0); Distance tr_dist(ppmap); - // search K nearest neighbours K_neighbor_search search(tree, query, K,0,true,tr_dist); for(K_neighbor_search::iterator it = search.begin(); it != search.end(); it++){ std::cout << " d(q, nearest neighbor)= " diff --git a/Spatial_searching/examples/Spatial_searching/searching_with_point_with_info_pmap.cpp b/Spatial_searching/examples/Spatial_searching/searching_with_point_with_info_pmap.cpp index 3c137d18e1b..dfe94d8626d 100644 --- a/Spatial_searching/examples/Spatial_searching/searching_with_point_with_info_pmap.cpp +++ b/Spatial_searching/examples/Spatial_searching/searching_with_point_with_info_pmap.cpp @@ -21,7 +21,8 @@ typedef K_neighbor_search::Tree Tree; typedef Tree::Splitter Splitter; typedef K_neighbor_search::Distance Distance; -int main() { +int main() +{ const unsigned int K = 5; // generator for random data points in the cube ( (-1,-1,-1), (1,1,1) ) Random_points_iterator rpit( 1.0); @@ -38,21 +39,22 @@ int main() { My_point_property_map ppmap(points); // Insert number_of_data_points in the tree - Tree tree( - boost::counting_iterator(0), - boost::counting_iterator(points.size()), - Splitter(), - Traits(ppmap) - ); + Tree tree(boost::counting_iterator(0), + boost::counting_iterator(points.size()), + Splitter(), + Traits(ppmap)); + + // search K nearest neighbours Point_3 query(0.0, 0.0, 0.0); Distance tr_dist(ppmap); - // search K nearest neighbours K_neighbor_search search(tree, query, K,0,true,tr_dist); - for(K_neighbor_search::iterator it = search.begin(); it != search.end(); it++){ + for(K_neighbor_search::iterator it = search.begin(); it != search.end(); it++) + { std::cout << " d(q, nearest neighbor)= " << tr_dist.inverse_of_transformed_distance(it->second) << " " << points[it->first] << " " << it->first << std::endl; } + return 0; } diff --git a/Spatial_searching/examples/Spatial_searching/splitter_worst_cases.cpp b/Spatial_searching/examples/Spatial_searching/splitter_worst_cases.cpp index 1c46a740022..cdb2fe8bcd5 100644 --- a/Spatial_searching/examples/Spatial_searching/splitter_worst_cases.cpp +++ b/Spatial_searching/examples/Spatial_searching/splitter_worst_cases.cpp @@ -18,7 +18,8 @@ typedef std::vector Points; int main() { Points sliding_worst_case; - for (int i = 0 ,j = 1; i < 10 ; ++i , j *= 2){ + for (int i = 0 ,j = 1; i < 10 ; ++i , j *= 2) + { sliding_worst_case.push_back(Point_2(((double)i)/10 , 0)); sliding_worst_case.push_back(Point_2( (double)j , 0)); } @@ -39,11 +40,10 @@ int main() tree2.clear(); Points median_worst_case; - for(int i = 0 ; i < 19 ; ++i){ + for(int i = 0 ; i < 19 ; ++i) median_worst_case.push_back(Point_2( 0 , i)); - } - median_worst_case.push_back(Point_2(20,0)); + median_worst_case.push_back(Point_2(20,0)); Tree_median tree3(median_worst_case.begin() , median_worst_case.end() , median); @@ -59,5 +59,6 @@ int main() tree4.build(); tree4.statistics(std::cout); tree4.clear(); + return 0; -} \ No newline at end of file +} diff --git a/Spatial_searching/examples/Spatial_searching/user_defined_point_and_distance.cpp b/Spatial_searching/examples/Spatial_searching/user_defined_point_and_distance.cpp index c8cfd5c40bb..1a9acf384a5 100644 --- a/Spatial_searching/examples/Spatial_searching/user_defined_point_and_distance.cpp +++ b/Spatial_searching/examples/Spatial_searching/user_defined_point_and_distance.cpp @@ -12,7 +12,8 @@ typedef CGAL::Search_traits K_neighbor_search; typedef K_neighbor_search::Tree Tree; -int main() { +int main() +{ const int N = 1000; const unsigned int K = 5; // generator for random data points in the cube ( (-1,-1,-1), (1,1,1) ) @@ -27,16 +28,20 @@ int main() { // search K nearest neighbours K_neighbor_search search(tree, query, K); - for(K_neighbor_search::iterator it = search.begin(); it != search.end(); it++){ + for(K_neighbor_search::iterator it = search.begin(); it != search.end(); it++) + { std::cout << " d(q, nearest neighbor)= " << tr_dist.inverse_of_transformed_distance(it->second) << std::endl; } + // search K furthest neighbour searching, with eps=0, search_nearest=false K_neighbor_search search2(tree, query, K, 0.0, false); - for(K_neighbor_search::iterator it = search2.begin(); it != search2.end(); it++){ + for(K_neighbor_search::iterator it = search2.begin(); it != search2.end(); it++) + { std::cout << " d(q, furthest neighbor)= " << tr_dist.inverse_of_transformed_distance(it->second) << std::endl; } + return 0; } diff --git a/Spatial_searching/examples/Spatial_searching/using_fair_splitting_rule.cpp b/Spatial_searching/examples/Spatial_searching/using_fair_splitting_rule.cpp index 01cae8eec63..62d691170c7 100644 --- a/Spatial_searching/examples/Spatial_searching/using_fair_splitting_rule.cpp +++ b/Spatial_searching/examples/Spatial_searching/using_fair_splitting_rule.cpp @@ -14,7 +14,8 @@ typedef CGAL::Fair Fair; typedef CGAL::Orthogonal_k_neighbor_search Neighbor_search; typedef Neighbor_search::Tree Tree; -int main() { +int main() +{ const unsigned int N = 1000; // generator for random data points in the square ( (-1,-1), (1,1) ) Random_points_iterator rpit( 1.0); @@ -32,8 +33,8 @@ int main() { // report the N nearest neighbors and their distance // This should sort all N points by increasing distance from origin - for(Neighbor_search::iterator it = search.begin(); it != search.end(); ++it){ + for(Neighbor_search::iterator it = search.begin(); it != search.end(); ++it) std::cout << it->first << " "<< std::sqrt(it->second) << std::endl; - } + return 0; } diff --git a/Spatial_searching/examples/Spatial_searching/weighted_Minkowski_distance.cpp b/Spatial_searching/examples/Spatial_searching/weighted_Minkowski_distance.cpp index 5c1ee97c55f..c6810d574a0 100644 --- a/Spatial_searching/examples/Spatial_searching/weighted_Minkowski_distance.cpp +++ b/Spatial_searching/examples/Spatial_searching/weighted_Minkowski_distance.cpp @@ -13,13 +13,12 @@ typedef CGAL::Weighted_Minkowski_distance Distance; typedef CGAL::Orthogonal_k_neighbor_search K_neighbor_search; typedef K_neighbor_search::Tree Tree; - -int main() { +int main() +{ const int D = 2; const int N = 1000; const unsigned int K = 5; - Random_points_iterator rpit( 1.0); Tree tree(N_Random_points_iterator(rpit,0), @@ -32,8 +31,8 @@ int main() { K_neighbor_search search(tree, query, K, 0.0, true, tr_dist); - for (K_neighbor_search::iterator it = search.begin(); it!=search.end(); ++it){ + for (K_neighbor_search::iterator it = search.begin(); it!=search.end(); ++it) std::cout << "Point " << (*it).first << " at distance = " << (*it).second << std::endl; - } + return 0; } diff --git a/Stream_support/doc/Stream_support/File_formats/Supported_file_formats.txt b/Stream_support/doc/Stream_support/File_formats/Supported_file_formats.txt index 30b18edc11f..eac672bf485 100644 --- a/Stream_support/doc/Stream_support/File_formats/Supported_file_formats.txt +++ b/Stream_support/doc/Stream_support/File_formats/Supported_file_formats.txt @@ -48,8 +48,8 @@ and it is only supported for the CGAL::Surface_mesh. The following \cgal data structures can be exported into the `OFF` file format: - `CGAL::Surface_mesh` (\link PkgSurfaceMeshIOFunc write_OFF(std::ostream&, const Surface_mesh

&, const NamedParameters&)\endlink) -- Any structure that is a model of the concept `FaceGraph` (\link PkgBGLIOFct write_OFF(std::ostream&,const FaceGraph&,const NamedParameters&)\endlink) -- `CGAL::Point_set_3` (\ref write_off_point_set()) +- Any structure that is a model of the concept `FaceGraph` (\link PkgBGLIOFct write_OFF(std::ostream&, const FaceGraph&,const NamedParameters&)\endlink) +- `CGAL::Point_set_3` (\ref write_OFF()) Polygon soups can also be exported using the function write_OFF(). Note that we only support OFF, and COFF for CGAL::Surface_mesh. diff --git a/Surface_mesh/benchmark/surface_mesh_performance.h b/Surface_mesh/benchmark/surface_mesh_performance.h index 47700cd2142..e114d73c45e 100644 --- a/Surface_mesh/benchmark/surface_mesh_performance.h +++ b/Surface_mesh/benchmark/surface_mesh_performance.h @@ -283,7 +283,7 @@ private: namespace SMS = CGAL::Surface_mesh_simplification ; mesh.clear(); - bool b = CGAL::read_off(mesh, _filename); + bool b = CGAL::read_OFF(_filename, mesh); SMS::Count_ratio_stop_predicate stop(0.1); int r = SMS::edge_collapse(mesh, stop); } diff --git a/Surface_mesh/examples/Surface_mesh/check_orientation.cpp b/Surface_mesh/examples/Surface_mesh/check_orientation.cpp index b438f393ea3..9247a696694 100644 --- a/Surface_mesh/examples/Surface_mesh/check_orientation.cpp +++ b/Surface_mesh/examples/Surface_mesh/check_orientation.cpp @@ -5,6 +5,7 @@ typedef CGAL::Simple_cartesian K; typedef CGAL::Surface_mesh Mesh; typedef Mesh::Vertex_index vertex_descriptor; typedef Mesh::Face_index face_descriptor; + int main() { Mesh m; diff --git a/Surface_mesh/examples/Surface_mesh/draw_surface_mesh.cpp b/Surface_mesh/examples/Surface_mesh/draw_surface_mesh.cpp index a04a092fc5c..60e390b95c8 100644 --- a/Surface_mesh/examples/Surface_mesh/draw_surface_mesh.cpp +++ b/Surface_mesh/examples/Surface_mesh/draw_surface_mesh.cpp @@ -1,6 +1,8 @@ #include #include + #include + #include typedef CGAL::Simple_cartesian Kernel; @@ -9,11 +11,16 @@ typedef CGAL::Surface_mesh Mesh; int main(int argc, char* argv[]) { - Mesh sm1; - std::ifstream in1((argc>1)?argv[1]:"data/elephant.off"); - in1 >> sm1; + const char* filename = (argc>1) ? argv[1] : "data/elephant.off"; - CGAL::draw(sm1); + Mesh sm; + if(!CGAL::read_polygon_mesh(filename, sm)) + { + std::cerr << "Invalid input file." << std::endl; + return EXIT_FAILURE; + } + + CGAL::draw(sm); return EXIT_SUCCESS; } diff --git a/Surface_mesh/examples/Surface_mesh/sm_bgl.cpp b/Surface_mesh/examples/Surface_mesh/sm_bgl.cpp index 5977a8053aa..2b8ed489c49 100644 --- a/Surface_mesh/examples/Surface_mesh/sm_bgl.cpp +++ b/Surface_mesh/examples/Surface_mesh/sm_bgl.cpp @@ -18,8 +18,12 @@ typedef boost::graph_traits::vertex_descriptor vertex_descriptor; int main(int /* argc */, char* argv[]) { Mesh sm; - std::ifstream in(argv[1]); - in >> sm; + if(!CGAL::read_polygon_mesh(argv[1], sm)) + { + std::cerr << "Invalid input file." << std::endl; + return EXIT_FAILURE; + } + Mesh::Property_map predecessor; predecessor = sm.add_property_map("v:predecessor").first; diff --git a/Surface_mesh/examples/Surface_mesh/sm_circulators.cpp b/Surface_mesh/examples/Surface_mesh/sm_circulators.cpp index f33bc672c0d..05a166dc567 100644 --- a/Surface_mesh/examples/Surface_mesh/sm_circulators.cpp +++ b/Surface_mesh/examples/Surface_mesh/sm_circulators.cpp @@ -1,13 +1,13 @@ -#include - - #include #include +#include + typedef CGAL::Simple_cartesian K; typedef CGAL::Surface_mesh Mesh; typedef Mesh::Vertex_index vertex_descriptor; typedef Mesh::Face_index face_descriptor; + int main() { Mesh m; diff --git a/Surface_mesh/examples/Surface_mesh/sm_derivation.cpp b/Surface_mesh/examples/Surface_mesh/sm_derivation.cpp index 3589b291eab..7e0237aa61f 100644 --- a/Surface_mesh/examples/Surface_mesh/sm_derivation.cpp +++ b/Surface_mesh/examples/Surface_mesh/sm_derivation.cpp @@ -1,8 +1,10 @@ -#include #include #include + #include +#include + typedef CGAL::Simple_cartesian K; typedef K::Point_3 Point_3; diff --git a/Surface_mesh/examples/Surface_mesh/sm_do_intersect.cpp b/Surface_mesh/examples/Surface_mesh/sm_do_intersect.cpp index 69e3b2550ab..1f9f8cc4d95 100644 --- a/Surface_mesh/examples/Surface_mesh/sm_do_intersect.cpp +++ b/Surface_mesh/examples/Surface_mesh/sm_do_intersect.cpp @@ -1,14 +1,16 @@ -#include -#include -#include +#include +#include + +#include +#include #include #include #include -#include -#include -#include -#include + +#include +#include +#include typedef CGAL::Exact_predicates_exact_constructions_kernel K; @@ -110,19 +112,21 @@ unsigned int intersect(const Mesh& P, const Mesh& Q) { int main(int argc, char* argv[]) { - std::cout.precision(17); - Mesh P, Q; - - if(argc < 3) { + if(argc < 3) + { std::cerr << "Usage: do_intersect " << std::endl; return EXIT_FAILURE; } - std::ifstream inP(argv[1]); - inP >> P; + std::cout.precision(17); + + Mesh P, Q; + if(!CGAL::read_polygon_mesh(argv[1], P) || !CGAL::read_polygon_mesh(argv[2], Q)) + { + std::cerr << "Invalid input files." << std::endl; + return EXIT_FAILURE; + } - std::ifstream inQ(argv[2]); - inQ >> Q; Timer timer; timer.start(); unsigned int num_intersections = intersect(P,Q); diff --git a/Surface_mesh/examples/Surface_mesh/sm_draw_small_faces.cpp b/Surface_mesh/examples/Surface_mesh/sm_draw_small_faces.cpp index 9534e39ead8..a243b14e4f3 100644 --- a/Surface_mesh/examples/Surface_mesh/sm_draw_small_faces.cpp +++ b/Surface_mesh/examples/Surface_mesh/sm_draw_small_faces.cpp @@ -14,9 +14,14 @@ typedef K::FT FT; int main(int argc, char* argv[]) { + const char* filename = (argc>1) ? argv[1] : "data/elephant.off"; + Mesh sm; - std::ifstream input((argc>1)?argv[1]:"data/elephant.off"); - input>>sm; + if(!CGAL::read_polygon_mesh(filename, sm)) + { + std::cerr << "Invalid input file." << std::endl; + return EXIT_FAILURE; + } CGAL::Polygon_mesh_processing::triangulate_faces(sm); diff --git a/Surface_mesh/examples/Surface_mesh/sm_join.cpp b/Surface_mesh/examples/Surface_mesh/sm_join.cpp index 0114f817372..62fdf2f369d 100644 --- a/Surface_mesh/examples/Surface_mesh/sm_join.cpp +++ b/Surface_mesh/examples/Surface_mesh/sm_join.cpp @@ -1,9 +1,9 @@ #include #include + #include #include - typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_3 Point; typedef CGAL::Surface_mesh Mesh; @@ -12,11 +12,15 @@ typedef boost::graph_traits::vertex_descriptor vertex_descriptor; int main(int argc, char* argv[]) { - Mesh sm1, sm2; - std::ifstream in1((argc>1)?argv[1]:"data/triangle.off"); - in1 >> sm1; + const char* filename1 = (argc>1) ? argv[1] : "data/triangle.off"; + const char* filename2 = (argc>2) ? argv[2] : "data/quad.off"; - std::ifstream in2((argc>2)?argv[2]:"data/quad.off"); + Mesh sm1, sm2; + if(!CGAL::read_polygon_mesh(filename1, sm1) || !CGAL::read_polygon_mesh(filename2, sm2)) + { + std::cerr << "Invalid input files." << std::endl; + return EXIT_FAILURE; + } Mesh::Property_map name1, name2; bool created; @@ -24,15 +28,10 @@ int main(int argc, char* argv[]) boost::tie(name1, created) = sm1.add_property_map("v:name","hello"); boost::tie(name2, created) = sm2.add_property_map("v:name","world"); - in2 >> sm2; - sm1 += sm2; - - for(vertex_descriptor vd : vertices(sm1)){ + for(vertex_descriptor vd : vertices(sm1)) std::cerr << vd << " " << name1[vd] < #include +#include + #include #include #include -#include - - typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_3 Point; typedef CGAL::Surface_mesh Mesh; @@ -16,8 +15,7 @@ typedef boost::graph_traits::vertex_descriptor vertex_descriptor; typedef boost::graph_traits::vertex_iterator vertex_iterator; typedef boost::graph_traits::edge_descriptor edge_descriptor; -void -kruskal(const Mesh& sm) +void kruskal(const Mesh& sm) { // We use the default edge weight which is the squared length of the edge @@ -57,12 +55,14 @@ kruskal(const Mesh& sm) "}# Shape\n"; } - -int main(int,char** argv) { - +int main(int argc, char** argv) +{ Mesh sm; - std::ifstream input(argv[1]); - input >> sm; + if(argc < 2 || !CGAL::read_polygon_mesh(argv[1], sm)) + { + std::cerr << "Invalid input file." << std::endl; + return EXIT_FAILURE; + } kruskal(sm); diff --git a/Surface_mesh/examples/Surface_mesh/sm_properties.cpp b/Surface_mesh/examples/Surface_mesh/sm_properties.cpp index 793b23ebf2b..6cb870f6194 100644 --- a/Surface_mesh/examples/Surface_mesh/sm_properties.cpp +++ b/Surface_mesh/examples/Surface_mesh/sm_properties.cpp @@ -3,7 +3,6 @@ #include #include - typedef CGAL::Simple_cartesian K; typedef CGAL::Surface_mesh Mesh; typedef Mesh::Vertex_index vertex_descriptor; @@ -11,7 +10,6 @@ typedef Mesh::Face_index face_descriptor; int main() { - Mesh m; vertex_descriptor v0 = m.add_vertex(K::Point_3(0,2,0)); vertex_descriptor v1 = m.add_vertex(K::Point_3(2,2,0)); diff --git a/Surface_mesh/test/Surface_mesh/SM_common.h b/Surface_mesh/test/Surface_mesh/SM_common.h index 11b3c0e8912..fa6d89fb5ee 100644 --- a/Surface_mesh/test/Surface_mesh/SM_common.h +++ b/Surface_mesh/test/Surface_mesh/SM_common.h @@ -115,10 +115,9 @@ struct Surface_fixture_3 { }; -struct Cube_fixture { - Cube_fixture() { - CGAL::read_mesh(m, "cube.off"); - } +struct Cube_fixture +{ + Cube_fixture() { CGAL::read_mesh(m, "cube.off"); } Sm m; diff --git a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_approximation_2_example.cpp b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_approximation_2_example.cpp index 4c55cbc3a6c..30781891e59 100644 --- a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_approximation_2_example.cpp +++ b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_approximation_2_example.cpp @@ -1,23 +1,31 @@ +#include + +#include +#include +#include + #include #include -#include -#include -#include - -typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; -typedef CGAL::Surface_mesh Mesh; -typedef boost::graph_traits::face_descriptor face_descriptor; -typedef Mesh::Property_map Face_proxy_pmap; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; +typedef CGAL::Surface_mesh Mesh; +typedef boost::graph_traits::face_descriptor face_descriptor; +typedef Mesh::Property_map Face_proxy_pmap; namespace VSA = CGAL::Surface_mesh_approximation; -int main() +int main(int argc, char** argv) { + const char* filename = (argc > 1) ? argv[1] : "data/bear.off"; + // read input surface triangle mesh Mesh mesh; - std::ifstream file("data/bear.off"); - file >> mesh; + if(!CGAL::Polygon_mesh_processing::read_polygon_mesh(filename, mesh) || + !CGAL::is_triangle_mesh(mesh)) + { + std::cerr << "Invalid input file." << std::endl; + return EXIT_FAILURE; + } // output indexed triangle mesh std::vector anchors; @@ -33,12 +41,12 @@ int main() // free function interface with named parameters VSA::approximate_triangle_mesh(mesh, CGAL::parameters::min_error_drop(0.05). // seeding with minimum error drop - number_of_iterations(40). // set number of clustering iterations after seeding - subdivision_ratio(0.3). // set chord subdivision ratio threshold when meshing - face_proxy_map(fpxmap). // get face partition map - proxies(std::back_inserter(proxies)). // output proxies - anchors(std::back_inserter(anchors)). // output anchor points - triangles(std::back_inserter(triangles))); // output indexed triangles + number_of_iterations(40). // set number of clustering iterations after seeding + subdivision_ratio(0.3). // set chord subdivision ratio threshold when meshing + face_proxy_map(fpxmap). // get face partition map + proxies(std::back_inserter(proxies)). // output proxies + anchors(std::back_inserter(anchors)). // output anchor points + triangles(std::back_inserter(triangles))); // output indexed triangles return EXIT_SUCCESS; } diff --git a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_approximation_example.cpp b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_approximation_example.cpp index 91865d19e9d..bf12a72cc6f 100644 --- a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_approximation_example.cpp +++ b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_approximation_example.cpp @@ -1,13 +1,15 @@ -#include -#include - #include #include + #include #include #include #include +#include + +#include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef CGAL::Surface_mesh Mesh; @@ -15,12 +17,18 @@ typedef CGAL::Surface_mesh Mesh; namespace VSA = CGAL::Surface_mesh_approximation; namespace PMP = CGAL::Polygon_mesh_processing; -int main() +int main(int argc, char** argv) { + const char* filename = (argc > 1) ? argv[1] : "data/bear.off"; + // read input surface triangle mesh Mesh mesh; - std::ifstream file("data/bear.off"); - file >> mesh; + if(!CGAL::Polygon_mesh_processing::read_polygon_mesh(filename, mesh) || + !CGAL::is_triangle_mesh(mesh)) + { + std::cerr << "Invalid input file." << std::endl; + return EXIT_FAILURE; + } // output indexed triangles std::vector anchors; @@ -29,10 +37,10 @@ int main() // free function interface with named parameters bool is_manifold = VSA::approximate_triangle_mesh(mesh, CGAL::parameters::seeding_method(VSA::HIERARCHICAL). // hierarchical seeding - max_number_of_proxies(200). // seeding with maximum number of proxies - number_of_iterations(30). // number of clustering iterations after seeding - anchors(std::back_inserter(anchors)). // anchor vertices - triangles(std::back_inserter(triangles))); // indexed triangles + max_number_of_proxies(200). // seeding with maximum number of proxies + number_of_iterations(30). // number of clustering iterations after seeding + anchors(std::back_inserter(anchors)). // anchor vertices + triangles(std::back_inserter(triangles))); // indexed triangles std::cout << "#anchor vertices: " << anchors.size() << std::endl; std::cout << "#triangles: " << triangles.size() << std::endl; diff --git a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_class_interface_example.cpp b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_class_interface_example.cpp index 50efcc5a8a2..2a61fab2f81 100644 --- a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_class_interface_example.cpp +++ b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_class_interface_example.cpp @@ -1,9 +1,11 @@ -#include -#include - #include #include + #include +#include + +#include +#include namespace VSA = CGAL::Surface_mesh_approximation; @@ -16,13 +18,16 @@ typedef CGAL::Variational_shape_approximation Mesh_appro // L21 error metric typedef Mesh_approximation::Error_metric L21_metric; -int main() +int main(int argc, char** argv) { + const char* filename = (argc > 1) ? argv[1] : "data/bear.off"; + // reads input surface triangle mesh Mesh mesh; - std::ifstream file("data/bear.off"); - if (!file || !(file >> mesh) || !CGAL::is_triangle_mesh(mesh)) { - std::cerr << "Invalid off file." << std::endl; + if(!CGAL::Polygon_mesh_processing::read_polygon_mesh(filename, mesh) || + !CGAL::is_triangle_mesh(mesh)) + { + std::cerr << "Invalid input file." << std::endl; return EXIT_FAILURE; } diff --git a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_isotropic_metric_example.cpp b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_isotropic_metric_example.cpp index d3e1dd71e8c..bad0c2dc1ef 100644 --- a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_isotropic_metric_example.cpp +++ b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_isotropic_metric_example.cpp @@ -1,11 +1,12 @@ -#include -#include - #include #include #include #include +#include + +#include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef Kernel::FT FT; @@ -30,31 +31,38 @@ struct Compact_metric_point_proxy // we keep a precomputed property map to speed up computations Compact_metric_point_proxy(const Face_center_map ¢er_pmap_, const Face_area_map &area_pmap_) - : center_pmap(center_pmap_), area_pmap(area_pmap_) {} + : center_pmap(center_pmap_), area_pmap(area_pmap_) + { } // compute and return error from a face to a proxy, // defined as the Euclidean distance between // the face center of mass and proxy point. - FT compute_error(const face_descriptor &f, const Mesh &, const Proxy &px) const { + FT compute_error(const face_descriptor &f, const Mesh &, const Proxy &px) const + { return CGAL::sqrt(CGAL::squared_distance(center_pmap[f], px)); } // template functor to compute a best-fit // proxy from a range of faces template - Proxy fit_proxy(const FaceRange &faces, const Mesh &) const { + Proxy fit_proxy(const FaceRange &faces, const Mesh &) const + { // fitting center Vector_3 center = CGAL::NULL_VECTOR; FT sum_areas = FT(0.0); - for(const face_descriptor f : faces) { + for(const face_descriptor f : faces) + { center = center + (center_pmap[f] - CGAL::ORIGIN) * area_pmap[f]; sum_areas += area_pmap[f]; } + // deal with case where sum = 0 - if (center == CGAL::NULL_VECTOR || sum_areas <= FT(0.0)) { + if (center == CGAL::NULL_VECTOR || sum_areas <= FT(0.0)) + { std::cerr << "Error: degenerate geometry." << std::endl; std::exit(EXIT_FAILURE); } + center = center / sum_areas; return CGAL::ORIGIN + center; } @@ -66,20 +74,26 @@ struct Compact_metric_point_proxy typedef CGAL::Variational_shape_approximation< Mesh, Vertex_point_map, Compact_metric_point_proxy> Approximation; -int main() +int main(int argc, char** argv) { - // reads input mesh + const char* filename = (argc > 1) ? argv[1] : "data/bear.off"; + + // reads input surface triangle mesh Mesh mesh; - std::ifstream file("data/bear.off"); - file >> mesh; + if(!CGAL::Polygon_mesh_processing::read_polygon_mesh(filename, mesh) || + !CGAL::is_triangle_mesh(mesh)) + { + std::cerr << "Invalid input file." << std::endl; + return EXIT_FAILURE; + } // constructs precomputed face normal and area map Vertex_point_map vpmap = get(boost::vertex_point, const_cast(mesh)); - Face_area_map area_pmap = - mesh.add_property_map("f:area", FT(0.0)).first; - Face_center_map center_pmap = - mesh.add_property_map("f:center", CGAL::ORIGIN).first; - for(face_descriptor f : faces(mesh)) { + Face_area_map area_pmap = mesh.add_property_map("f:area", FT(0.0)).first; + Face_center_map center_pmap = mesh.add_property_map("f:center", CGAL::ORIGIN).first; + + for(face_descriptor f : faces(mesh)) + { const halfedge_descriptor he = halfedge(f, mesh); const Point_3 &p0 = vpmap[source(he, mesh)]; const Point_3 &p1 = vpmap[target(he, mesh)]; @@ -95,9 +109,8 @@ int main() Approximation approx(mesh, vpmap, error_metric); // approximates via 200 proxies and 30 iterations - approx.initialize_seeds( - CGAL::parameters::seeding_method(VSA::HIERARCHICAL) - .max_number_of_proxies(200)); + approx.initialize_seeds(CGAL::parameters::seeding_method(VSA::HIERARCHICAL) + .max_number_of_proxies(200)); approx.run(30); return EXIT_SUCCESS; diff --git a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_segmentation_example.cpp b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_segmentation_example.cpp index 7fe1b13bf82..dc3c5a57b8a 100644 --- a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_segmentation_example.cpp +++ b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_segmentation_example.cpp @@ -1,9 +1,11 @@ -#include -#include - #include #include + #include +#include + +#include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef CGAL::Surface_mesh Mesh; @@ -12,23 +14,28 @@ typedef Mesh::Property_map Face_proxy_pmap; namespace VSA = CGAL::Surface_mesh_approximation; -int main() +int main(int argc, char** argv) { - // reads input mesh + const char* filename = (argc > 1) ? argv[1] : "data/bear.off"; + + // reads input surface triangle mesh Mesh mesh; - std::ifstream file("data/bear.off"); - file >> mesh; + if(!CGAL::Polygon_mesh_processing::read_polygon_mesh(filename, mesh) || + !CGAL::is_triangle_mesh(mesh)) + { + std::cerr << "Invalid input file." << std::endl; + return EXIT_FAILURE; + } // face proxy index property map - Face_proxy_pmap fpxmap = - mesh.add_property_map("f:proxy_id", 0).first; + Face_proxy_pmap fpxmap = mesh.add_property_map("f:proxy_id", 0).first; // free function interface with named parameters VSA::approximate_triangle_mesh(mesh, - CGAL::parameters::max_number_of_proxies(200). // first stop criterion - min_error_drop(0.05). // second stop criterion - number_of_iterations(30). // number of relaxation iterations after seeding - face_proxy_map(fpxmap)); // output face-proxy map + CGAL::parameters::max_number_of_proxies(200). // first stop criterion + min_error_drop(0.05). // second stop criterion + number_of_iterations(30). // number of relaxation iterations after seeding + face_proxy_map(fpxmap)); // output face-proxy map // iterates over faces and outputs segment id to console for(face_descriptor f : faces(mesh)) diff --git a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_simple_approximation_example.cpp b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_simple_approximation_example.cpp index d311245a9a3..81f326e4573 100644 --- a/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_simple_approximation_example.cpp +++ b/Surface_mesh_approximation/examples/Surface_mesh_approximation/vsa_simple_approximation_example.cpp @@ -1,21 +1,29 @@ -#include -#include - #include #include + #include +#include + +#include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef CGAL::Surface_mesh Mesh; namespace VSA = CGAL::Surface_mesh_approximation; -int main() +int main(int argc, char** argv) { - // read input surface triangle mesh + const char* filename = (argc > 1) ? argv[1] : "data/bear.off"; + + // reads input surface triangle mesh Mesh mesh; - std::ifstream file("data/bear.off"); - file >> mesh; + if(!CGAL::Polygon_mesh_processing::read_polygon_mesh(filename, mesh) || + !CGAL::is_triangle_mesh(mesh)) + { + std::cerr << "Invalid input file." << std::endl; + return EXIT_FAILURE; + } // The output will be an indexed triangle mesh std::vector anchors; @@ -23,10 +31,10 @@ int main() // free function interface with named parameters VSA::approximate_triangle_mesh(mesh, - CGAL::parameters::verbose_level(VSA::MAIN_STEPS). - max_number_of_proxies(200). - anchors(std::back_inserter(anchors)). // anchor points - triangles(std::back_inserter(triangles))); // indexed triangles + CGAL::parameters::verbose_level(VSA::MAIN_STEPS). + max_number_of_proxies(200). + anchors(std::back_inserter(anchors)). // anchor points + triangles(std::back_inserter(triangles))); // indexed triangles std::cout << "#anchor points: " << anchors.size() << std::endl; std::cout << "#triangles: " << triangles.size() << std::endl; diff --git a/Surface_mesh_deformation/examples/Surface_mesh_deformation/all_roi_assign_example.cpp b/Surface_mesh_deformation/examples/Surface_mesh_deformation/all_roi_assign_example.cpp index 683f98e3625..188e4de4e0f 100644 --- a/Surface_mesh_deformation/examples/Surface_mesh_deformation/all_roi_assign_example.cpp +++ b/Surface_mesh_deformation/examples/Surface_mesh_deformation/all_roi_assign_example.cpp @@ -5,7 +5,7 @@ #include #include - +#include typedef CGAL::Simple_cartesian Kernel; typedef CGAL::Polyhedron_3 Polyhedron; diff --git a/Surface_mesh_deformation/examples/Surface_mesh_deformation/all_roi_assign_example_Surface_mesh.cpp b/Surface_mesh_deformation/examples/Surface_mesh_deformation/all_roi_assign_example_Surface_mesh.cpp index f7ee48804b1..a66e4152b3c 100644 --- a/Surface_mesh_deformation/examples/Surface_mesh_deformation/all_roi_assign_example_Surface_mesh.cpp +++ b/Surface_mesh_deformation/examples/Surface_mesh_deformation/all_roi_assign_example_Surface_mesh.cpp @@ -13,11 +13,17 @@ typedef boost::graph_traits::halfedge_iterator halfedge_iterator; typedef CGAL::Surface_mesh_deformation Surface_mesh_deformation; -int main() +int main(int argc, char** argv) { + const char* filename = (argc > 1) ? argv[1] : "data/plane.off"; + Mesh mesh; - std::ifstream in("data/plane.off"); - in >>mesh; + if(!CGAL::read_polygon_mesh(filename, mesh)) + { + std::cerr << "Invalid input file." << std::endl; + return EXIT_FAILURE; + } + // Create a deformation object Surface_mesh_deformation deform_mesh(mesh); diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/discrete_authalic.cpp b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/discrete_authalic.cpp index 4d776571306..1f71c6e1d69 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/discrete_authalic.cpp +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/discrete_authalic.cpp @@ -28,14 +28,14 @@ namespace SMP = CGAL::Surface_mesh_parameterization; int main(int argc, char** argv) { - std::ifstream in((argc>1) ? argv[1] : "data/three_peaks.off"); - if(!in) { - std::cerr << "Problem loading the input data" << std::endl; - return EXIT_FAILURE; - } + const char* filename = (argc>1) ? argv[1] : "data/three_peaks.off"; SurfaceMesh sm; - in >> sm; + if(!CGAL::read_polygon_mesh(filename, sm)) + { + std::cerr << "Invalid input file." << std::endl; + return EXIT_FAILURE; + } // A halfedge on the border halfedge_descriptor bhd = CGAL::Polygon_mesh_processing::longest_border(sm).first; diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/lscm.cpp b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/lscm.cpp index 73227f630cc..637a2cf62a5 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/lscm.cpp +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/lscm.cpp @@ -38,14 +38,14 @@ namespace SMP = CGAL::Surface_mesh_parameterization; int main(int argc, char** argv) { - std::ifstream in_mesh((argc>1) ? argv[1] : "data/lion.off"); - if(!in_mesh){ - std::cerr << "Error: problem loading the input data" << std::endl; - return EXIT_FAILURE; - } + const char* filename = (argc>1) ? argv[1] : "data/lion.off"; SurfaceMesh sm; - in_mesh >> sm; + if(!CGAL::read_polygon_mesh(filename, sm)) + { + std::cerr << "Invalid input file." << std::endl; + return EXIT_FAILURE; + } // Two property maps to store the seam edges and vertices Seam_edge_pmap seam_edge_pm = sm.add_property_map("e:on_seam", false).first; diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/orbifold.cpp b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/orbifold.cpp index 041b8ed405d..44eaf8f6ec5 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/orbifold.cpp +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/orbifold.cpp @@ -45,16 +45,15 @@ int main(int argc, char** argv) CGAL::Timer task_timer; task_timer.start(); - const char* mesh_filename = (argc>1) ? argv[1] : "data/bear.off"; - std::ifstream in_mesh(mesh_filename); - if(!in_mesh) { - std::cerr << "Error: problem loading the input data" << std::endl; + const char* filename = (argc>1) ? argv[1] : "data/bear.off"; + + SurfaceMesh sm; + if(!CGAL::read_polygon_mesh(filename, sm)) + { + std::cerr << "Invalid input file." << std::endl; return EXIT_FAILURE; } - SurfaceMesh sm; // underlying mesh of the seam mesh - in_mesh >> sm; - // Selection file that contains the cones and possibly the path between cones // -- the first line for the cones indices // -- the second line must be empty diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/simple_parameterization.cpp b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/simple_parameterization.cpp index a5aeba4f2f3..b40a8bf48cc 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/simple_parameterization.cpp +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/simple_parameterization.cpp @@ -23,14 +23,14 @@ namespace SMP = CGAL::Surface_mesh_parameterization; int main(int argc, char** argv) { - std::ifstream in((argc>1) ? argv[1] : "data/nefertiti.off"); - if(!in) { - std::cerr << "Problem loading the input data" << std::endl; - return EXIT_FAILURE; - } + const char* filename = (argc>1) ? argv[1] : "data/nefertiti.off"; SurfaceMesh sm; - in >> sm; + if(!CGAL::read_polygon_mesh(filename, sm)) + { + std::cerr << "Invalid input file." << std::endl; + return EXIT_FAILURE; + } // a halfedge on the border halfedge_descriptor bhd = CGAL::Polygon_mesh_processing::longest_border(sm).first; diff --git a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/extract_segmentation_into_mesh_example.cpp b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/extract_segmentation_into_mesh_example.cpp index c226c867b5a..dd5ab74df9d 100644 --- a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/extract_segmentation_into_mesh_example.cpp +++ b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/extract_segmentation_into_mesh_example.cpp @@ -1,10 +1,12 @@ #include #include -#include + +#include #include #include -#include +#include #include + #include #include #include @@ -15,14 +17,16 @@ typedef boost::graph_traits::face_descriptor face_descriptor; int main(int argc, char** argv ) { + const char* filename = (argc > 1) ? argv[1] : "data/cactus.off"; + SM mesh; - if (argc==2){ - std::ifstream input(argv[1]); - input >> mesh; - } else { - std::ifstream cactus("data/cactus.off"); - cactus >> mesh; + if(!CGAL::Polygon_mesh_processing::read_polygon_mesh(filename, mesh) || + !CGAL::is_triangle_mesh(mesh)) + { + std::cerr << "Invalid input file." << std::endl; + return EXIT_FAILURE; } + typedef SM::Property_map Facet_double_map; Facet_double_map sdf_property_map; @@ -46,6 +50,7 @@ int main(int argc, char** argv ) if(id > 0) segment_mesh.set_selected_faces(id, segment_property_map); std::cout << "Segment "< #include -#include +#include #include #include @@ -16,7 +16,8 @@ int main() // create and read Polyhedron Polyhedron mesh; std::ifstream input("data/cactus.off"); - if ( !input || !(input >> mesh) || mesh.empty() || ( !CGAL::is_triangle_mesh(mesh)) ) { + if ( !input || !(input >> mesh) || mesh.empty() || ( !CGAL::is_triangle_mesh(mesh)) ) + { std::cerr << "Input is not a triangle mesh" << std::endl; return EXIT_FAILURE; } @@ -29,7 +30,6 @@ int main() // compute SDF values std::pair min_max_sdf = CGAL::sdf_values(mesh, sdf_property_map); - // It is possible to compute the raw SDF values and post-process them using // the following lines: // const std::size_t number_of_rays = 25; // cast 25 rays per face @@ -43,9 +43,9 @@ int main() << " maximum SDF: " << min_max_sdf.second << std::endl; // print SDF values - for(face_descriptor f : faces(mesh)) { + for(face_descriptor f : faces(mesh)) std::cout << sdf_property_map[f] << " "; - } + std::cout << std::endl; return EXIT_SUCCESS; } diff --git a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_from_sdf_values_LCC_example.cpp b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_from_sdf_values_LCC_example.cpp index 1ff8786ad70..543e8563155 100644 --- a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_from_sdf_values_LCC_example.cpp +++ b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_from_sdf_values_LCC_example.cpp @@ -1,8 +1,8 @@ #include #include - #include -#include + +#include #include #include #include @@ -12,51 +12,57 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef CGAL::Linear_cell_complex_traits<3, Kernel> MyTraits; -typedef CGAL::Linear_cell_complex_for_bgl_combinatorial_map_helper - <2, 3, MyTraits>::type LCC; +typedef CGAL::Linear_cell_complex_for_bgl_combinatorial_map_helper<2, 3, MyTraits>::type LCC; typedef LCC::Attribute_const_handle<2>::type Facet_const_handle; -int main() +int main(int argc, char** argv) { - // create and read LCC - LCC mesh; - CGAL::read_polygon_mesh("data/cactus.off", mesh); + const char* filename = (argc > 1) ? argv[1] : "data/cactus.off"; - // create a property-map for SDF values - typedef CGAL::Unique_hash_map Facet_double_map; - Facet_double_map internal_sdf_map; - boost::associative_property_map sdf_property_map(internal_sdf_map); + // create and read LCC + LCC mesh; + if(!CGAL::Polygon_mesh_processing::read_polygon_mesh(filename, mesh) || + !CGAL::is_triangle_mesh(mesh)) + { + std::cerr << "Invalid input file." << std::endl; + return EXIT_FAILURE; + } - // compute SDF values using default parameters for number of rays, and cone angle - CGAL::sdf_values(mesh, sdf_property_map); + // create a property-map for SDF values + typedef CGAL::Unique_hash_map Facet_double_map; + Facet_double_map internal_sdf_map; + boost::associative_property_map sdf_property_map(internal_sdf_map); - // create a property-map for segment-ids - typedef CGAL::Unique_hash_map Facet_int_map; - Facet_int_map internal_segment_map; - boost::associative_property_map segment_property_map(internal_segment_map); + // compute SDF values using default parameters for number of rays, and cone angle + CGAL::sdf_values(mesh, sdf_property_map); - // segment the mesh using default parameters for number of levels, and smoothing lambda - // Any other scalar values can be used instead of using SDF values computed using the CGAL function - std::size_t number_of_segments = CGAL::segmentation_from_sdf_values(mesh, sdf_property_map, - segment_property_map); + // create a property-map for segment-ids + typedef CGAL::Unique_hash_map Facet_int_map; + Facet_int_map internal_segment_map; + boost::associative_property_map segment_property_map(internal_segment_map); - std::cout << "Number of segments: " << number_of_segments << std::endl; - // print segment-ids - for(LCC::Attribute_range<2>::type::const_iterator facet_it=mesh.attributes<2>().begin(); - facet_it!=mesh.attributes<2>().end(); ++facet_it) - { - // ids are between [0, number_of_segments -1] - std::cout << segment_property_map[facet_it] << " "; - } - std::cout << std::endl; + // segment the mesh using default parameters for number of levels, and smoothing lambda + // Any other scalar values can be used instead of using SDF values computed using the CGAL function + std::size_t number_of_segments = CGAL::segmentation_from_sdf_values(mesh, sdf_property_map, + segment_property_map); - const std::size_t number_of_clusters = 4; // use 4 clusters in soft clustering - const double smoothing_lambda = 0.3; // importance of surface features, suggested to be in-between [0,1] + std::cout << "Number of segments: " << number_of_segments << std::endl; + // print segment-ids + for(LCC::Attribute_range<2>::type::const_iterator facet_it=mesh.attributes<2>().begin(); + facet_it!=mesh.attributes<2>().end(); ++facet_it) + { + // ids are between [0, number_of_segments -1] + std::cout << segment_property_map[facet_it] << " "; + } + std::cout << std::endl; - // Note that we can use the same SDF values (sdf_property_map) over and over again for segmentation. - // This feature is relevant for segmenting the mesh several times with different parameters. - CGAL::segmentation_from_sdf_values( - mesh, sdf_property_map, segment_property_map, number_of_clusters, smoothing_lambda); + const std::size_t number_of_clusters = 4; // use 4 clusters in soft clustering + const double smoothing_lambda = 0.3; // importance of surface features, suggested to be in-between [0,1] - return EXIT_SUCCESS; + // Note that we can use the same SDF values (sdf_property_map) over and over again for segmentation. + // This feature is relevant for segmenting the mesh several times with different parameters. + CGAL::segmentation_from_sdf_values( + mesh, sdf_property_map, segment_property_map, number_of_clusters, smoothing_lambda); + + return EXIT_SUCCESS; } diff --git a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_from_sdf_values_OpenMesh_example.cpp b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_from_sdf_values_OpenMesh_example.cpp index fa2bd07f024..1147555e177 100644 --- a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_from_sdf_values_OpenMesh_example.cpp +++ b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_from_sdf_values_OpenMesh_example.cpp @@ -14,23 +14,22 @@ #include typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; - typedef OpenMesh::PolyMesh_ArrayKernelT Mesh; - typedef boost::graph_traits::face_descriptor face_descriptor; int main(int argc, char** argv ) { - Mesh mesh; - if (argc==2) - OpenMesh::IO::read_mesh(mesh, argv[1]); - else - OpenMesh::IO::read_mesh(mesh, "data/cactus.off"); + const char* filename = (argc > 1) ? argv[1] : "data/cactus.off"; - if (!CGAL::is_triangle_mesh(mesh)){ + Mesh mesh; + OpenMesh::IO::read_mesh(mesh, filename); + + if (!CGAL::is_triangle_mesh(mesh)) + { std::cerr << "Input geometry is not triangulated." << std::endl; return EXIT_FAILURE; } + std::cout << "#F : " << num_faces(mesh) << std::endl; std::cout << "#H : " << num_halfedges(mesh) << std::endl; std::cout << "#V : " << num_vertices(mesh) << std::endl; diff --git a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_from_sdf_values_SM_example.cpp b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_from_sdf_values_SM_example.cpp index 074554286d6..9aebc8cb0fa 100644 --- a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_from_sdf_values_SM_example.cpp +++ b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_from_sdf_values_SM_example.cpp @@ -1,33 +1,33 @@ #include #include + #include +#include #include #include #include -typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; -typedef Kernel::Point_3 Point_3; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; +typedef Kernel::Point_3 Point_3; -typedef CGAL::Surface_mesh Mesh; +typedef CGAL::Surface_mesh Mesh; -typedef boost::graph_traits::vertex_descriptor vertex_descriptor; -typedef boost::graph_traits::face_descriptor face_descriptor; +typedef boost::graph_traits::vertex_descriptor vertex_descriptor; +typedef boost::graph_traits::face_descriptor face_descriptor; int main(int argc, char** argv ) { + const char* filename = (argc > 1) ? argv[1] : "data/cactus.off"; + Mesh mesh; - if (argc==2){ - std::ifstream input(argv[1]); - input >> mesh; - } else { - std::ifstream cactus("data/cactus.off"); - cactus >> mesh; - } - if (!CGAL::is_triangle_mesh(mesh)){ - std::cerr << "Input is not a triangle mesh" << std::endl; + if(!CGAL::Polygon_mesh_processing::read_polygon_mesh(filename, mesh) || + !CGAL::is_triangle_mesh(mesh)) + { + std::cerr << "Invalid input file." << std::endl; return EXIT_FAILURE; } + typedef Mesh::Property_map Facet_double_map; Facet_double_map sdf_property_map; @@ -61,5 +61,6 @@ int main(int argc, char** argv ) // Note that we can use the same SDF values (sdf_property_map) over and over again for segmentation. // This feature is relevant for segmenting the mesh several times with different parameters. CGAL::segmentation_from_sdf_values(mesh, sdf_property_map, segment_property_map, number_of_clusters, smoothing_lambda); + return EXIT_SUCCESS; } diff --git a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_from_sdf_values_example.cpp b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_from_sdf_values_example.cpp index c84eb49b149..fe3545add76 100644 --- a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_from_sdf_values_example.cpp +++ b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_from_sdf_values_example.cpp @@ -1,7 +1,7 @@ #include #include -#include +#include #include #include @@ -16,7 +16,8 @@ int main() // create and read Polyhedron Polyhedron mesh; std::ifstream input("data/cactus.off"); - if ( !input || !(input >> mesh) || mesh.empty() || ( !CGAL::is_triangle_mesh(mesh))) { + if ( !input || !(input >> mesh) || mesh.empty() || ( !CGAL::is_triangle_mesh(mesh))) + { std::cerr << "Input is not a triangle mesh." << std::endl; return EXIT_FAILURE; } diff --git a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_via_sdf_values_example.cpp b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_via_sdf_values_example.cpp index 41fbb550d55..4024b686495 100644 --- a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_via_sdf_values_example.cpp +++ b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_via_sdf_values_example.cpp @@ -1,7 +1,7 @@ #include #include -#include +#include #include #include @@ -13,28 +13,29 @@ typedef boost::graph_traits::face_descriptor face_descriptor; int main() { - // create and read Polyhedron - Polyhedron mesh; - std::ifstream input("data/cactus.off"); - if ( !input || !(input >> mesh) || mesh.empty() || ( !CGAL::is_triangle_mesh(mesh)) ) { - std::cerr << "Input is not a triangle mesh" << std::endl; - return EXIT_FAILURE; - } + // create and read Polyhedron + Polyhedron mesh; + std::ifstream input("data/cactus.off"); + if ( !input || !(input >> mesh) || mesh.empty() || ( !CGAL::is_triangle_mesh(mesh)) ) + { + std::cerr << "Input is not a triangle mesh" << std::endl; + return EXIT_FAILURE; + } - // create a property-map for segment-ids - typedef std::map Face_int_map; - Face_int_map internal_segment_map; - boost::associative_property_map segment_property_map(internal_segment_map); + // create a property-map for segment-ids + typedef std::map Face_int_map; + Face_int_map internal_segment_map; + boost::associative_property_map segment_property_map(internal_segment_map); - // calculate SDF values and segment the mesh using default parameters. - std::size_t number_of_segments = CGAL::segmentation_via_sdf_values(mesh, segment_property_map); + // calculate SDF values and segment the mesh using default parameters. + std::size_t number_of_segments = CGAL::segmentation_via_sdf_values(mesh, segment_property_map); - std::cout << "Number of segments: " << number_of_segments << std::endl; + std::cout << "Number of segments: " << number_of_segments << std::endl; - // print segment-ids - for(face_descriptor f : faces(mesh) ) { - std::cout << segment_property_map[f] << " "; - } - std::cout << std::endl; - return EXIT_SUCCESS; + // print segment-ids + for(face_descriptor f : faces(mesh) ) { + std::cout << segment_property_map[f] << " "; + } + std::cout << std::endl; + return EXIT_SUCCESS; } diff --git a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_with_facet_ids_example.cpp b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_with_facet_ids_example.cpp index e8e5ae4dcba..afc25865d98 100644 --- a/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_with_facet_ids_example.cpp +++ b/Surface_mesh_segmentation/examples/Surface_mesh_segmentation/segmentation_with_facet_ids_example.cpp @@ -1,8 +1,8 @@ #include #include #include -#include +#include #include #include diff --git a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_path_sequence.cpp b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_path_sequence.cpp index da8dc35475b..512b2882ae0 100644 --- a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_path_sequence.cpp +++ b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_path_sequence.cpp @@ -1,18 +1,16 @@ -#include -#include -#include - #include #include - #include - #include #include #include +#include +#include +#include + typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef CGAL::Surface_mesh Triangle_mesh; typedef CGAL::Surface_mesh_shortest_path_traits Traits; @@ -81,10 +79,15 @@ struct Print_visitor : public boost::static_visitor<> { int main(int argc, char** argv) { + const char* filename = (argc>1) ? argv[1] : "data/elephant.off"; + Triangle_mesh tmesh; - std::ifstream input((argc>1)?argv[1]:"data/elephant.off"); - input >> tmesh; - input.close(); + if(!CGAL::read_polygon_mesh(filename, tmesh) || + !CGAL::is_triangle_mesh(tmesh)) + { + std::cerr << "Invalid input file." << std::endl; + return EXIT_FAILURE; + } // pick up a random face const unsigned int randSeed = argc > 2 ? boost::lexical_cast(argv[2]) : 7915421; diff --git a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_path_with_locate.cpp b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_path_with_locate.cpp index de1ef93fb47..5ce5baa5733 100644 --- a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_path_with_locate.cpp +++ b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_path_with_locate.cpp @@ -1,11 +1,11 @@ #include +#include #include #include #include #include -#include #include @@ -34,9 +34,15 @@ typedef CGAL::AABB_tree AABB_tre int main(int argc, char** argv) { + const char* filename = (argc>1) ? argv[1] : "data/elephant.off"; + Triangle_mesh tmesh; - std::ifstream input((argc>1) ? argv[1] : "data/elephant.off"); - input >> tmesh; + if(!CGAL::read_polygon_mesh(filename, tmesh) || + !CGAL::is_triangle_mesh(tmesh)) + { + std::cerr << "Invalid input file." << std::endl; + return EXIT_FAILURE; + } Surface_mesh_shortest_path shortest_paths(tmesh); diff --git a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths.cpp b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths.cpp index 1f3102e4bf0..b2e89af7120 100644 --- a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths.cpp +++ b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths.cpp @@ -1,16 +1,15 @@ -#include -#include -#include - #include - -#include #include #include +#include #include +#include +#include +#include + typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef CGAL::Surface_mesh Triangle_mesh; typedef CGAL::Surface_mesh_shortest_path_traits Traits; @@ -21,10 +20,15 @@ typedef Graph_traits::face_iterator face_iterator; int main(int argc, char** argv) { + const char* filename = (argc>1) ? argv[1] : "data/elephant.off"; + Triangle_mesh tmesh; - std::ifstream input((argc>1)?argv[1]:"data/elephant.off"); - input >> tmesh; - input.close(); + if(!CGAL::read_polygon_mesh(filename, tmesh) || + !CGAL::is_triangle_mesh(tmesh)) + { + std::cerr << "Invalid input file." << std::endl; + return EXIT_FAILURE; + } // pick up a random face const unsigned int randSeed = argc > 2 ? boost::lexical_cast(argv[2]) : 7915421; diff --git a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_OpenMesh.cpp b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_OpenMesh.cpp index aa40d6f0727..cef847b5406 100644 --- a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_OpenMesh.cpp +++ b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_OpenMesh.cpp @@ -1,25 +1,22 @@ +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + #include #include #include #include -#include - -#include - -#include -#include - -#include -#include - -#include - -#include -#include - -#include - typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef OpenMesh::PolyMesh_ArrayKernelT<> Triangle_mesh; @@ -39,6 +36,12 @@ int main(int argc, char** argv) Triangle_mesh tmesh; OpenMesh::IO::read_mesh(tmesh, (argc>1)?argv[1]:"data/elephant.off"); + if(!CGAL::is_triangle_mesh(tmesh)) + { + std::cerr << "Invalid input file." << std::endl; + return EXIT_FAILURE; + } + // pick up a random face const unsigned int randSeed = argc > 2 ? boost::lexical_cast(argv[2]) : 7915421; CGAL::Random rand(randSeed); diff --git a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_multiple_sources.cpp b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_multiple_sources.cpp index e9c14eb2625..2b921527dd2 100644 --- a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_multiple_sources.cpp +++ b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_multiple_sources.cpp @@ -1,17 +1,14 @@ +#include +#include + +#include +#include + #include #include #include #include -#include - -#include -#include - -#include - - - typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef CGAL::Surface_mesh Triangle_mesh; typedef CGAL::Surface_mesh_shortest_path_traits Traits; @@ -24,11 +21,15 @@ typedef Graph_traits::face_descriptor face_descriptor; int main(int argc, char** argv) { - // read input tmesh + const char* filename = (argc>1) ? argv[1] : "data/elephant.off"; + Triangle_mesh tmesh; - std::ifstream input((argc>1)?argv[1]:"data/elephant.off"); - input >> tmesh; - input.close(); + if(!CGAL::read_polygon_mesh(filename, tmesh) || + !CGAL::is_triangle_mesh(tmesh)) + { + std::cerr << "Invalid input file." << std::endl; + return EXIT_FAILURE; + } // pick up some source points inside faces, const unsigned int randSeed = argc > 2 ? boost::lexical_cast(argv[2]) : 7915421; diff --git a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_no_id.cpp b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_no_id.cpp index fe9489bfb9d..32a2412b47e 100644 --- a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_no_id.cpp +++ b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_no_id.cpp @@ -1,16 +1,16 @@ +#include +#include + +#include +#include + +#include + #include #include #include #include -#include -#include -#include -#include - - -#include - typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef CGAL::Polyhedron_3 Triangle_mesh; typedef CGAL::Surface_mesh_shortest_path_traits Traits; @@ -30,15 +30,12 @@ typedef Graph_traits::vertex_iterator vertex_iterator; typedef Graph_traits::halfedge_iterator halfedge_iterator; typedef Graph_traits::face_iterator face_iterator; - - int main(int argc, char** argv) { Triangle_mesh tmesh; std::ifstream input((argc>1)?argv[1]:"data/elephant.off"); input >> tmesh; - input.close(); // pick up a random face const unsigned int randSeed = argc > 2 ? boost::lexical_cast(argv[2]) : 7915421; diff --git a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_with_id.cpp b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_with_id.cpp index 8f3cfef94e8..ba417ecb285 100644 --- a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_with_id.cpp +++ b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/shortest_paths_with_id.cpp @@ -1,19 +1,17 @@ -#include -#include -#include -#include - #include - -#include - #include #include #include +#include #include +#include +#include +#include +#include + typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef CGAL::Polyhedron_3 Triangle_mesh; typedef CGAL::Surface_mesh_shortest_path_traits Traits; @@ -28,7 +26,6 @@ int main(int argc, char** argv) Triangle_mesh tmesh; std::ifstream input((argc>1)?argv[1]:"data/elephant.off"); input >> tmesh; - input.close(); // initialize indices of vertices, halfedges and faces CGAL::set_halfedgeds_items_id(tmesh); diff --git a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_linear_cell_complex.cpp b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_linear_cell_complex.cpp index 69d0df8396d..8fbc1763b86 100644 --- a/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_linear_cell_complex.cpp +++ b/Surface_mesh_simplification/examples/Surface_mesh_simplification/edge_collapse_linear_cell_complex.cpp @@ -23,7 +23,7 @@ int main(int argc, char** argv) { LCC lcc; const char* filename = (argc > 1) ? argv[1] : "data/cube-meshed.off"; - std::ifstream is(filename); + if(!CGAL::read_polygon_mesh(filename, lcc)) { std::cerr << "Failed to read input mesh: " << filename << std::endl; @@ -60,7 +60,7 @@ int main(int argc, char** argv) lcc.display_characteristics(std::cout) << ", is_valid=" << CGAL::is_valid(lcc) << std::endl; - CGAL::write_off((argc > 3 ? argv[3] : "out.off"), lcc); + CGAL::write_polygon_mesh((argc > 3 ? argv[3] : "out.off"), lcc); return EXIT_SUCCESS; } diff --git a/Surface_mesh_topology/examples/Surface_mesh_topology/path_homotopy_with_sm_and_polyhedron.cpp b/Surface_mesh_topology/examples/Surface_mesh_topology/path_homotopy_with_sm_and_polyhedron.cpp index bd66e4c4232..e9696cbc65a 100644 --- a/Surface_mesh_topology/examples/Surface_mesh_topology/path_homotopy_with_sm_and_polyhedron.cpp +++ b/Surface_mesh_topology/examples/Surface_mesh_topology/path_homotopy_with_sm_and_polyhedron.cpp @@ -46,7 +46,7 @@ int main(int argc, char** argv) { LCC_3_cmap lcc; - if (!CGAL::load_off(lcc, file.c_str())) + if (!CGAL::read_polygon_mesh(lcc, file.c_str())) { std::cout<<"ERROR reading file "< pts; - if( !CGAL::read_points( filename, // input ifstream + if( !CGAL::read_XYZ( filename, // input ifstream back_inserter(pts) ) ) { // output iterator over points showError( QObject::tr("Error: cannot read file %1.").arg(filename) ); } @@ -201,9 +201,9 @@ void Scene::savePointsXYZ(const char* filename) /* Use CGAL::write_xyz_points to write out data */ /* Note: this function writes out points only (normals are ignored) */ - if( !CGAL::write_xyz_points( fout, // output ofstream - CGAL::make_range (m_dt.points_begin(), // first output point - m_dt.points_end()) ) ) { // past-the-end output point + if( !CGAL::write_XYZ( fout, // output ofstream + CGAL::make_range( m_dt.points_begin(), // first output point + m_dt.points_end()) ) ) { // past-the-end output point showError( QObject::tr("Error: cannot read file %1.").arg(filename) ); } }