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 4d321fca81c..1608ff04613 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 @@ -12,7 +12,7 @@ typedef K::Vector_3 Vector; typedef CGAL::Surface_mesh Surface_mesh; typedef boost::graph_traits::vertex_descriptor vertex_descriptor; -typedef boost::graph_traits::face_descriptor face_descriptor; +typedef boost::graph_traits::face_descriptor face_descriptor; int main(int argc, char* argv[]) { @@ -25,13 +25,12 @@ int main(int argc, char* argv[]) return 1; } - Surface_mesh::Property_map fnormals; - Surface_mesh::Property_map vnormals; - bool created; - boost::tie(fnormals, created) - = mesh.add_property_map("f:normals", Vector(0, 0, 0)); - boost::tie(vnormals, created) - = mesh.add_property_map("v:normals", Vector(0, 0, 0)); + Surface_mesh::Property_map fnormals = + mesh.add_property_map + ("f:normals", CGAL::NULL_VECTOR).first; + Surface_mesh::Property_map vnormals = + mesh.add_property_map + ("v:normals", CGAL::NULL_VECTOR).first; CGAL::Polygon_mesh_processing::compute_normals(mesh, vnormals, @@ -43,7 +42,7 @@ int main(int argc, char* argv[]) BOOST_FOREACH(face_descriptor fd, faces(mesh)){ std::cout << fnormals[fd] << std::endl; } - std::cout << "Normals at vertices :" << std::endl; + std::cout << "Vertex normals :" << std::endl; BOOST_FOREACH(vertex_descriptor vd, vertices(mesh)){ std::cout << vnormals[vd] << std::endl; } 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 cac91a8f950..353612c246d 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 @@ -15,6 +15,7 @@ typedef Kernel::Compare_dihedral_angle_3 Compare_dihedral_ang typedef CGAL::Surface_mesh Mesh; +namespace PMP = CGAL::Polygon_mesh_processing; template struct Constraint : public boost::put_get_helper > @@ -29,16 +30,17 @@ struct Constraint : public boost::put_get_helper > :g_(NULL) {} - Constraint(G & g, double bound) + Constraint(G& g, double bound) : g_(&g), bound_(bound) {} - bool operator[](edge_descriptor e) const { + bool operator[](edge_descriptor e) const + { const G& g = *g_; - return compare_(g.point(source(e,g)), + return compare_(g.point(source(e, g)), g.point(target(e, g)), - g.point(target(next(halfedge(e,g),g),g)), - g.point(target(next(opposite(halfedge(e,g),g),g),g)), + g.point(target(next(halfedge(e, g), g), g)), + g.point(target(next(opposite(halfedge(e, g), g), g), g)), bound_) == CGAL::SMALLER; } @@ -49,7 +51,8 @@ struct Constraint : public boost::put_get_helper > template -struct Put_true { +struct Put_true +{ Put_true(const PM pm) :pm(pm) {} @@ -80,29 +83,28 @@ int main(int argc, char* argv[]) std::vector cc; face_descriptor fd = *faces(mesh).first; - CGAL::Polygon_mesh_processing::connected_component(fd, - mesh, - std::back_inserter(cc)); + PMP::connected_component(fd, + mesh, + std::back_inserter(cc)); std::cerr << "Connected components without edge constraints" << std::endl; std::cerr << cc.size() << " faces in the CC of " << fd << std::endl; - - + // Instead of writing the faces into a container, you can set a face property to true typedef Mesh::Property_map F_select_map; - F_select_map fselect_map; - fselect_map = mesh.add_property_map("f:select", false).first; - CGAL::Polygon_mesh_processing::connected_component(fd, - mesh, - boost::make_function_output_iterator(Put_true(fselect_map))); + F_select_map fselect_map = + mesh.add_property_map("f:select", false).first; + PMP::connected_component(fd, + mesh, + boost::make_function_output_iterator(Put_true(fselect_map))); std::cerr << "\nConnected components with edge constraints (dihedral angle < 3/4 pi)" << std::endl; - Mesh::Property_map fccmap; - fccmap = mesh.add_property_map("f:CC").first; - std::size_t num = CGAL::Polygon_mesh_processing::connected_components(mesh, - fccmap, - CGAL::Polygon_mesh_processing::parameters::edge_is_constrained_map(Constraint(mesh, bound))); + Mesh::Property_map fccmap = + mesh.add_property_map("f:CC").first; + std::size_t num = PMP::connected_components(mesh, + fccmap, + PMP::parameters::edge_is_constrained_map(Constraint(mesh, bound))); std::cerr << "- The graph has " << num << " connected components (face connectivity)" << std::endl; typedef std::map Components_size; @@ -116,9 +118,9 @@ int main(int argc, char* argv[]) } std::cerr << "- We keep the two largest components" << std::endl; - CGAL::Polygon_mesh_processing::keep_largest_connected_components(mesh, - 2, - CGAL::Polygon_mesh_processing::parameters::edge_is_constrained_map(Constraint(mesh, bound))); + PMP::keep_largest_connected_components(mesh, + 2, + PMP::parameters::edge_is_constrained_map(Constraint(mesh, bound))); return 0; } diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/polygon_soup_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/polygon_soup_example.cpp index 29691278838..104d601d6ed 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/polygon_soup_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/polygon_soup_example.cpp @@ -41,15 +41,14 @@ int main(int argc, char* argv[]) if (!CGAL::Polygon_mesh_processing::is_outward_oriented(mesh)) CGAL::Polygon_mesh_processing::reverse_face_orientations(mesh); - std::ofstream out("mesh-oriented.off"); + std::ofstream out("elephant-oriented1.off"); out << mesh; out.close(); - CGAL::Polygon_mesh_processing::reverse_face_orientations(mesh); - { - std::ofstream out("elephant-oriented2.off"); - out << mesh; - out.close(); - } + CGAL::Polygon_mesh_processing::reverse_face_orientations(mesh); + std::ofstream out2("elephant-oriented2.off"); + out2 << mesh; + out2.close(); + return 0; } diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/remove_degeneracies_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/remove_degeneracies_example.cpp index c90c08cd88f..a4f6626870f 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/remove_degeneracies_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/remove_degeneracies_example.cpp @@ -24,7 +24,7 @@ int main(int argc, char* argv[]) std::size_t nb = CGAL::Polygon_mesh_processing::remove_degenerate_faces(mesh); - std::cerr << "There were " << nb << " degenerate faces in this mesh" << std::endl; + std::cerr << nb << " degenerate faces removed" << std::endl; mesh.collect_garbage(); std::cout << mesh << std::endl; return 0; 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 e3f62087204..f92ea525302 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 @@ -7,9 +7,11 @@ #include typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef CGAL::Surface_mesh Mesh; +typedef CGAL::Surface_mesh Mesh; 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/pig.off"; @@ -22,19 +24,19 @@ int main(int argc, char* argv[]) return 1; } - bool intersecting = CGAL::Polygon_mesh_processing::does_self_intersect(mesh, - CGAL::Polygon_mesh_processing::parameters::vertex_point_map(get(CGAL::vertex_point, mesh))); + bool intersecting = PMP::does_self_intersect(mesh, + PMP::parameters::vertex_point_map(get(CGAL::vertex_point, mesh))); std::cout << (intersecting ? "There are self-intersections." : "There is no self-intersection.") << std::endl; std::vector > intersected_tris; - CGAL::Polygon_mesh_processing::self_intersections(mesh, + PMP::self_intersections(mesh, std::back_inserter(intersected_tris), - CGAL::Polygon_mesh_processing::parameters::vertex_point_map(get(CGAL::vertex_point, mesh))); + PMP::parameters::vertex_point_map(get(CGAL::vertex_point, mesh))); - std::cout << intersected_tris.size() << " pairs of triangles are intersecting." << std::endl; + std::cout << intersected_tris.size() << " pairs of triangles intersect." << std::endl; return 0; }