Recommend Surface_mesh

This commit is contained in:
Andreas Fabri 2017-04-28 17:26:39 +02:00 committed by Maxime Gimeno
parent 1d109f9abd
commit 164e6c54e6
6 changed files with 26 additions and 26 deletions

View File

@ -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}

View File

@ -7,4 +7,5 @@ Stream_support
BGL
AABB_tree
Polyhedron
Surface_mesh
Number_types

View File

@ -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
*/
*/

View File

@ -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 )

View File

@ -1,27 +1,24 @@
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <iterator>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Random.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Polyhedron_items_with_id_3.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Surface_mesh_shortest_path.h>
#include <CGAL/boost/graph/iterator.h>
#include <boost/variant.hpp>
#include <boost/lexical_cast.hpp>
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Polyhedron_3<Kernel, CGAL::Polyhedron_items_with_id_3> Polyhedron_3;
typedef CGAL::Surface_mesh_shortest_path_traits<Kernel, Polyhedron_3> Traits;
typedef CGAL::Surface_mesh<Kernel::Point_3> Mesh;
typedef CGAL::Surface_mesh_shortest_path_traits<Kernel, Mesh> Traits;
typedef CGAL::Surface_mesh_shortest_path<Traits> Surface_mesh_shortest_path;
typedef Traits::Barycentric_coordinates Barycentric_coordinates;
typedef boost::graph_traits<Polyhedron_3> Graph_traits;
typedef boost::graph_traits<Mesh> 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<unsigned int>(argv[2]) : 7915421;
CGAL::Random rand(randSeed);

View File

@ -6,20 +6,18 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Random.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Polyhedron_items_with_id_3.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Surface_mesh_shortest_path.h>
#include <CGAL/boost/graph/iterator.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Polyhedron_3<Kernel, CGAL::Polyhedron_items_with_id_3> Polyhedron_3;
typedef CGAL::Surface_mesh_shortest_path_traits<Kernel, Polyhedron_3> Traits;
typedef CGAL::Surface_mesh<Kernel::Point_3> Mesh;
typedef CGAL::Surface_mesh_shortest_path_traits<Kernel, Mesh> Traits;
typedef CGAL::Surface_mesh_shortest_path<Traits> Surface_mesh_shortest_path;
typedef Surface_mesh_shortest_path::Face_location Face_location;
typedef boost::graph_traits<Polyhedron_3> Graph_traits;
typedef boost::graph_traits<Mesh> 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<unsigned int>(argv[2]) : 7915421;
CGAL::Random rand(randSeed);