From 164e6c54e6bc7f40e4abc12f7594b7fbf013ee3c Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 28 Apr 2017 17:26:39 +0200 Subject: [PATCH] Recommend Surface_mesh --- .../Surface_mesh_shortest_path.txt | 10 +++++++++- .../Surface_mesh_shortest_path/dependencies | 1 + .../Surface_mesh_shortest_path/examples.txt | 3 ++- .../Surface_mesh_shortest_path/CMakeLists.txt | 1 + .../shortest_path_sequence.cpp | 20 +++++++------------ .../shortest_paths_multiple_sources.cpp | 17 ++++++---------- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Surface_mesh_shortest_path/doc/Surface_mesh_shortest_path/Surface_mesh_shortest_path.txt b/Surface_mesh_shortest_path/doc/Surface_mesh_shortest_path/Surface_mesh_shortest_path.txt index 457c213fc25..b6106973b0c 100644 --- a/Surface_mesh_shortest_path/doc/Surface_mesh_shortest_path/Surface_mesh_shortest_path.txt +++ b/Surface_mesh_shortest_path/doc/Surface_mesh_shortest_path/Surface_mesh_shortest_path.txt @@ -38,7 +38,8 @@ of the input surface mesh. For efficiency reason, index property maps for vertices, halfedges and faces are internally used. For each simplex type the property map must provide an index between 0 and the number of simplices. We recommend to use -the class `CGAL::Polyhedron_3` as model of `FaceListGraph` with the item class `CGAL::Polyhedron_items_with_id_3`, +the class `CGAL::Surface_mesh` as model of `FaceListGraph`. +If you use the class `CGAL::Polyhedron_3`, you should use it with the item class `CGAL::Polyhedron_items_with_id_3`, for which default property maps are provided. This item class associates to each simplex an index that provides a \f$O(1)\f$ time access to the indices. Note that the initialization of the property maps requires a call to `set_halfedgeds_items_id()`. @@ -100,6 +101,13 @@ but it will be extremely slow. Indeed, in order to compute the distance along th \subsection Surface_mesh_shortest_pathSimpleExample Simple Example +The following example shows how to get the shortest path to every vertex from an arbitrary source point on a surface. +The shortest path class needs to have an index associated to each vertex, halfedge and face, which is naturally given for the class `Surface_mesh`. + +\cgalExample{Surface_mesh_shortest_path/shortest_paths.cpp} + +\subsection Surface_mesh_shortest_pathExampleWithId Example Using Polyhedron_3 + The following example shows how to get the shortest path to every vertex from an arbitrary source point on the surface. Note that this example uses the `Polyhedron_items_with_id_3` item class. The shortest path class needs to have an index associated to each vertex, halfedge and face. Using this item class provide an efficient direct access to the required indices. \cgalExample{Surface_mesh_shortest_path/shortest_paths_with_id.cpp} diff --git a/Surface_mesh_shortest_path/doc/Surface_mesh_shortest_path/dependencies b/Surface_mesh_shortest_path/doc/Surface_mesh_shortest_path/dependencies index 09295b112f8..4ebf712f418 100644 --- a/Surface_mesh_shortest_path/doc/Surface_mesh_shortest_path/dependencies +++ b/Surface_mesh_shortest_path/doc/Surface_mesh_shortest_path/dependencies @@ -7,4 +7,5 @@ Stream_support BGL AABB_tree Polyhedron +Surface_mesh Number_types diff --git a/Surface_mesh_shortest_path/doc/Surface_mesh_shortest_path/examples.txt b/Surface_mesh_shortest_path/doc/Surface_mesh_shortest_path/examples.txt index 9967a54e1d6..bdb3f6e7aff 100644 --- a/Surface_mesh_shortest_path/doc/Surface_mesh_shortest_path/examples.txt +++ b/Surface_mesh_shortest_path/doc/Surface_mesh_shortest_path/examples.txt @@ -1,7 +1,8 @@ /*! +\example Surface_mesh_shortest_path/shortest_paths.cpp \example Surface_mesh_shortest_path/shortest_paths_with_id.cpp \example Surface_mesh_shortest_path/shortest_paths_no_id.cpp \example Surface_mesh_shortest_path/shortest_paths_OpenMesh.cpp \example Surface_mesh_shortest_path/shortest_paths_multiple_sources.cpp \example Surface_mesh_shortest_path/shortest_path_sequence.cpp -*/ \ No newline at end of file +*/ diff --git a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/CMakeLists.txt b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/CMakeLists.txt index aaef527195e..7bd9a0eee37 100644 --- a/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/CMakeLists.txt +++ b/Surface_mesh_shortest_path/examples/Surface_mesh_shortest_path/CMakeLists.txt @@ -21,6 +21,7 @@ if ( CGAL_FOUND ) create_single_source_cgal_program( "shortest_paths_multiple_sources.cpp" ) create_single_source_cgal_program( "shortest_paths_no_id.cpp" ) create_single_source_cgal_program( "shortest_paths_with_id.cpp" ) + create_single_source_cgal_program( "shortest_paths.cpp" ) find_package( OpenMesh QUIET ) if ( OpenMesh_FOUND ) 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 1cbbba6a7a1..4c9701370ca 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,27 +1,24 @@ #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 Polyhedron_3; -typedef CGAL::Surface_mesh_shortest_path_traits Traits; +typedef CGAL::Surface_mesh Mesh; +typedef CGAL::Surface_mesh_shortest_path_traits Traits; typedef CGAL::Surface_mesh_shortest_path Surface_mesh_shortest_path; typedef Traits::Barycentric_coordinates Barycentric_coordinates; -typedef boost::graph_traits Graph_traits; +typedef boost::graph_traits Graph_traits; typedef Graph_traits::vertex_iterator vertex_iterator; typedef Graph_traits::face_iterator face_iterator; typedef Graph_traits::vertex_descriptor vertex_descriptor; @@ -57,9 +54,9 @@ struct Sequence_collector // A visitor to print what a variant contains using boost::apply_visitor struct Print_visitor : public boost::static_visitor<> { int i; - Polyhedron_3& g; + Mesh& g; - Print_visitor(Polyhedron_3& g) :i(-1), g(g) {} + Print_visitor(Mesh& g) :i(-1), g(g) {} void operator()(vertex_descriptor v) { @@ -85,14 +82,11 @@ struct Print_visitor : public boost::static_visitor<> { int main(int argc, char** argv) { // read input polyhedron - Polyhedron_3 polyhedron; + Mesh polyhedron; std::ifstream input((argc>1)?argv[1]:"data/elephant.off"); input >> polyhedron; input.close(); - // initialize indices of vertices, halfedges and faces - CGAL::set_halfedgeds_items_id(polyhedron); - // 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 402cc86c8af..894e9086a38 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 @@ -6,20 +6,18 @@ #include #include - -#include -#include +#include #include -#include + typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; -typedef CGAL::Polyhedron_3 Polyhedron_3; -typedef CGAL::Surface_mesh_shortest_path_traits Traits; +typedef CGAL::Surface_mesh Mesh; +typedef CGAL::Surface_mesh_shortest_path_traits Traits; typedef CGAL::Surface_mesh_shortest_path Surface_mesh_shortest_path; typedef Surface_mesh_shortest_path::Face_location Face_location; -typedef boost::graph_traits Graph_traits; +typedef boost::graph_traits Graph_traits; typedef Graph_traits::vertex_iterator vertex_iterator; typedef Graph_traits::face_iterator face_iterator; typedef Graph_traits::face_descriptor face_descriptor; @@ -27,14 +25,11 @@ typedef Graph_traits::face_descriptor face_descriptor; int main(int argc, char** argv) { // read input polyhedron - Polyhedron_3 polyhedron; + Mesh polyhedron; std::ifstream input((argc>1)?argv[1]:"data/elephant.off"); input >> polyhedron; input.close(); - // initialize indices of vertices, halfedges and faces - CGAL::set_halfedgeds_items_id(polyhedron); - // pick up some source points inside faces, const unsigned int randSeed = argc > 2 ? boost::lexical_cast(argv[2]) : 7915421; CGAL::Random rand(randSeed);