Add BGL doc.

This commit is contained in:
Philipp Möller 2012-09-18 14:10:54 +00:00
parent d59f28537d
commit ada75c9e45
19 changed files with 1216 additions and 0 deletions

17
.gitattributes vendored
View File

@ -1426,6 +1426,23 @@ Arrangement_on_surface_2/test/Sweep_line_2/cgal_test_with_cmake eol=lf
Arrangement_on_surface_2/test/Sweep_line_2/test_sweep.cpp eol=lf
Arrangement_on_surface_2/test/Sweep_line_2/test_sweep_conic.cpp eol=lf
Arrangement_on_surface_2/todo -text
BGL/doc/BGL/BGL.txt -text
BGL/doc/BGL/CGAL/HalfedgeDS_face_max_base_with_id.h -text
BGL/doc/BGL/CGAL/HalfedgeDS_halfedge_max_base_with_id.h -text
BGL/doc/BGL/CGAL/HalfedgeDS_vertex_max_base_with_id.h -text
BGL/doc/BGL/CGAL/Polyhedron_items_with_id_3.h -text
BGL/doc/BGL/CGAL/Triangulation_vertex_base_with_id_2.h -text
BGL/doc/BGL/CGAL/boost/graph/graph_traits_Arrangement_2.h -text
BGL/doc/BGL/CGAL/boost/graph/graph_traits_Polyhedron_3.h -text
BGL/doc/BGL/CGAL/boost/graph/graph_traits_Triangulation_2.h -text
BGL/doc/BGL/CGAL/boost/graph/halfedge_graph_traits_Polyhedron_3.h -text
BGL/doc/BGL/CGAL/boost/graph/properties.h -text
BGL/doc/BGL/Concepts/HalfedgeGraph.h -text
BGL/doc/BGL/PackageDescription.txt -text
BGL/doc/BGL/fig/emst-detail.png -text svneol=unset#image/png
BGL/doc/BGL/fig/emst.jpg -text svneol=unset#image/jpeg
BGL/doc/BGL/fig/ex_bgl.gif -text svneol=unset#image/gif
BGL/doc/BGL/fig/ex_bgl.pdf -text svneol=unset#application/pdf
BGL/doc_tex/BGL/fig/emst-detail.png -text
BGL/doc_tex/BGL/fig/emst.jpg -text
BGL/doc_tex/BGL/fig/ex_bgl.fig -text svneol=unset#application/octet-stream

335
BGL/doc/BGL/BGL.txt Normal file
View File

@ -0,0 +1,335 @@
\page chapterBGL CGAL and the Boost Graph Library
namespace CGAL {
/*!
\mainpage CGAL and the Boost Graph Library
\anchor chapterBGL
\authors Andreas Fabri and Fernando Cacciola and Ron Wein
Many geometric data structures can be interpreted as graphs, as they consist of
vertices, edges and faces. This is the case for the halfedge data structure,
for the polyhedron, for arrangements and for triangulations. With means of
duality one can also interpret faces as vertices and edges between adjacent
faces as edges of the dual graph.
As the scope of \cgal is geometry and not graph algorithms, we
provide the necessary classes and functions that allow to use the
algorithms of the <A HREF="http://www.boost.org/libs/graph/doc/index.html">Boost Graph Library (sc{Bgl})</A> \cite cgal:sll-bgl-02 for \cgal data structures.
# A Short Introduction to the Boost Graph Library #
The algorithms of the \sc{Bgl} operate on models of the various <I>graph concepts</I>.
The <I>traits class</I> `boost::graph_traits` allows the algorithms to determine the types of vertices and edges.
<I>Free functions</I> that operator on graphs allow the algorithms to obtain,
for example, the source vertex of an edge, or all edges incident to a vertex. The algorithms
use <I>property maps</I> to associate information to vertices and edges.
The algorithms allow <I>visitors</I> to register callbacks that will be called
during the execution of the algorithms. Finally, the graph algorithms use
the <I>named parameter</I> mechanism, which allows to pass the arguments in
arbitrary order.
## Graph Concepts ##
The \sc{Bgl} introduces several graph concepts, which have different sets of characteristics and requirements,
as for example whether one can enumerate all vertices or all edges, whether one only can get the outgoing
edges of a vertex, or also the ingoing edges, or whether one can add and remove vertices and edges or not.
Graph concepts in the \sc{Bgl} manual: <A HREF="http://www.boost.org/libs/graph/doc/graph_concepts.html"><TT>http://www.boost.org/libs/graph/doc/graph_concepts.html</TT></A>
## The Graph Traits Class ##
The algorithms determine types with the help of the traits class
<A HREF="http://www.boost.org/libs/graph/doc/graph_traits.html">`boost::graph_traits`</A>. Such types are the `vertex_descriptor`
which is equivalent to a vertex handle in \cgal data structures, the
`vertex_iterator` which is similar to the vertex iterators in
\cgal data structures, and the `out_edge_iterator` which is
similar to edge circulators, which allow to enumerate the edges
incident to a vertex. The latter two are similar and not equivalent,
because their value type is a `vertex_descriptor`, whereas in
\cgal handles, iterators, and cicrulators all have the same value
type, namely the vertex type. Given a graph type `G` the
declaration of a vertex descriptor looks as follows:
`boost::graph_traits<G>::vertex_descriptor vd;`.<BR>
The graph traits in the \sc{Bgl} manual: <A HREF="http://www.boost.org/libs/graph/doc/graph_traits.html"><TT>http://www.boost.org/libs/graph/doc/graph_traits.html</TT></A>
## Free Functions for Exploring a Graph ##
The algorithms obtain incidence information with the help of global
functions like `pair<vertex_iterator,vertex_iterator> vertices(const Graph& g);` for getting an iterator range which allows
to enumerate all vertices, or `int num_vertices(const Graph&);` for getting the number of vertices of a graph, or
`vertex_descriptor source(edge_descriptor, const Graph&`, for
getting the source vertex of an edge. Note, that the
way we have written the types is a simplification, that is in reality
the signature of the first of the above functions is
`pair<boost::graph_traits<Graph>::vertex_iterator,boost::graph_traits<Graph>::vertex_iterator> vertices(const Graph& g);`.<BR>
The free functions required for graph concepts: <A HREF="http://www.boost.org/libs/graph/doc/graph_concepts.html"><TT>http://www.boost.org/libs/graph/doc/graph_concepts.html</TT></A>
## Property Maps ##
Another feature used heavily in the \sc{Bgl} is the <I>property map</I>
which is offered by the Boost Property Map Library.
Property maps are used to attach information to vertices and edges. It is again
a traits class and some free functions for obtaining the property map from
a graph, and for getting and putting properties.
The free functions are `get` and `put`. The first one is overloaded.
One version allows to obtain a property map for a given property tag. For example
`m = get(g, boost::vertex_index)` gives us a property map that associates
an index in the range `[0, num_vertices(g))` to each vertex
descriptor of the graph. The second version of the `get` function
allows to read it as follows for a vertex descriptor `vd`:
`int vdi = get(m, vd)`. Just as `get` allows to read data,
`put` allows to write them. For example, the Dijksta's shortest path algorithm writes
the predecessor of each vertex, as well as the distance to the source in such a
property map.
The data themselves may be stored in the vertex or edge, or they may
be stored in an external data structure, or they may be computed on
the fly. This is an "implementation detail" of the particular property map.<BR>
Property maps in the Boost manuals: <A HREF="http://www.boost.org/libs/property_map/doc/property_map.html"><TT>http://www.boost.org/libs/property_map/doc/property_map.html</TT></A>
## Visitors ##
Visitors are ojects that provide functions that get called at
specified event points by the algorithm they visit. The notion of
visitors is a design pattern, and also used in \cgal, e.g., the `Arr_observer<Arrangement>`
in the arrangement package.
The functions as well as the event points are library specific. Event
points in graph algorithms are, for example, when a vertex is traversed the first time, or when
all outgoing edges of a vertex are traversed.<BR>
Visitors in the \sc{Bgl} manual: <A HREF="http://www.boost.org/libs/graph/doc/visitor_concepts.html"><TT>http://www.boost.org/libs/graph/doc/visitor_concepts.html</TT></A>
## Named Parameters ##
The algorithms of the \sc{Bgl} often have many parameters. Although the default
value is most often appropriate, one has to write them explicitly, if one only
wants to deviate from the default for the last one. The solution to this problem
is to first write a tag and then the parameter, which for
Dijkstra's shortest path algorithm, might look as follows:
<PRE>
std::vector<vertex_descriptor> p(num_vertices(g));
std::vector<int> d(num_vertices(g));
vertex_descriptor s = vertex(A, g);
dijkstra_shortest_paths(g, s, predecessor_map(&p[0]).distance_map(&d[0]));
</PRE>
The named parameters in the example use the tags `predecessor_map` and `distance_map` and
they are concatenated with the dot operator.<BR>
Named parameters in the \sc{Bgl} manual: <A HREF="http://www.boost.org/libs/graph/doc/bgl_named_params.html"><TT>http://www.boost.org/libs/graph/doc/bgl_named_params.html</TT></A>
# Extensions of the BGL #
\cgal provides the partial specializations and free functions such that
several data structures become model of some of the \sc{Bgl} graph concepts.
Furthermore, we define the new graph concept `HalfedgeGraph`, a traits class `halfedge_graph_traits`,
and free functions for accessing opposite edges as well as the clockwise and
counterclockwise neighbor of an edge around a given vertex.
These extensions are used by the surface simplification algorithms which follow
the design of the \sc{Bgl} as sketched in the previous section.
# Header Files, Namespaces, and Naming Conventions #
As we interface two libraries we have to explain what resides in which namespace,
and what naming conventions we apply to what.
Partial specializations of the `boost::graph_traits<Graph>` for the \cgal package
`Package` are in the namespace `boost` and in the headerfile `<CGAL/boost/graph/graph_traits_Package.h>`.
The `halfedge_graph_traits` class is in the namespace `CGAL`,
but it is not capitalized as the `boost::graph_traits` is not.
The same holds for the types and enums for vertex and edge properties.
# Polyhedral Surfaces as Model of the Boost Graph Concept #
The class `Polyhedron_3` is model of the graph concept. Furthermore
this chapter introduces a new graph concept, the `HalfedgeGraph`.
## Example: Minimum Spanning Tree of a Polyhedral Surface ##
The example code computes the minimum spanning tree on a polyhedral surface.
More examples can be found in Chapter \ref chaptermeshsimplification on surface mesh simplification.
\cgalexample{kruskal.cpp}
## Example: Using Vertices, and Edges with an ID ##
The following example program shows a call to the \sc{Bgl}
Kruskal's minimum spanning tree algorithm accessing the id()
field stored in a Polyhedron vertex.
The main function illustrates the access to the id() field.
\cgalexample{kruskal_with_stored_id.cpp}
# Triangulations as Models of the Boost Graph Concept #
Triangulations have vertices and faces. Edges are pairs of a face and the
index of the edge.
Particular care has to be taken with the infinite vertex, and its incident
edges. One can either use a `boost::filtered_graph`, which makes the infinite edges
invisible, or one can have a property map that returns an infinite length
for these edges.
A classical example for an algorithm that is a combination of
computational geometry and graph theory is the <I>Euclidean Minimum
Spanning Tree</I> for a point set in the plane. It can be computed by
running the minimum spanning tree algorithm on a Delaunay
triangulation of the point set.
## Example: Euclidean Minimum Spanning Tree ##
In the following example we create a Delaunay triangulation and run Kruskal's minimum
spanning tree algorithm on it. Because the vertex handles of the triangulation are not indices
in an array, we have to provide a property map that maps vertex handles to
int's in the range `[0, t.number_of_vertices())`.
\cgalexample{emst.cpp}
## Example: Storing the Vertex ID in the Vertex ##
The algorithms of the \sc{Bgl} extensively use of the indices of
vertices. In the previous example we stored the index in a `std::map`
and turned that map in a property map. This property map was then
passed as argument to the shortest path function.
If the user does not pass explicitly a property map, the graph algorithms
use the property map returned by the call `boost::get(boost::vertex_index,ft)`.
This property map assumes that the vertex has a
member function `id()` that returns a reference to an int.
Therefore \cgal offers a class `Triangulation_vertex_base_with_id_2`.
It is in the users responsibility to set the indices properly.
The example further illustrates that the graph traits also works
for the Delaunay triangulation.
\cgalexample{dijkstra_with_internal_properties.cpp}
# Arrangements as Models of the Boost Graph Concept #
For the arrangements \cgal offers the graph traits for the arrangement
itself as well as for its dual graph.
\subsection arr_sssecbgl_primal Example for the Arrangement as Graph
Arrangement instances are adapted to <I>boost</I> graphs by specializing the
`boost:graph_traits` template for `Arrangement_2` instances. The
graph-traits states the graph concepts that the arrangement class models
(see below) and defines the types required by these concepts.
In this specialization the `Arrangement_2` vertices correspond to the
graph vertices, where two vertices are adjacent if there is at least one
halfedge connecting them. More precisely, `Arrangement_2::Vertex_handle`
is the graph-vertex type, while `Arrangement_2::Halfedge_handle` is the
graph-edge type. As halfedges are directed, we consider the graph to be
directed as well. Moreover, as several interior-disjoint \f$ x\f$-monotone curves
(say circular arcs) may share two common endpoints, inducing an arrangement
with two vertices that are connected with several edges, we allow parallel
edges in our <I>boost</I> graph.
Given an `Arrangement_2` instance, we can efficiently traverse its
vertices and halfedges. Thus, the arrangement graph is a model of the concepts
`VertexListGraph` and `EdgeListGraph` introduced by the \sc{bgl}.
At the same time, we use an iterator adapter of the circulator over the
halfedges incident to a vertex (`Halfedge_around_vertex_circulator` - see
Section \ref arr_sssectr_vertex), so it is possible to go over the ingoing
and outgoing edges of a vertex in linear time. Thus, our arrangement graph
is a model of the concept `BidirectionalGraph` (this concept refines
`IncidenceGraph`, which requires only the traversal of outgoing edges).
It is important to notice that the vertex descriptors we use are
`Vertex_handle` objects and <I>not</I> vertex indices. However, in order
to gain more efficiency in most \sc{Bgl} algorithm, it is better to have them
indexed \f$ 0, 1, \ldots, (n-1)\f$, where \f$ n\f$ is the number of vertices. We
therefore introduce the `Arr_vertex_index_map<Arrangement>` class-template,
which maintains a mapping of vertex handles to indices, as required by the
sc{bgl}. An instance of this class must be attached to a valid arrangement
vertex when it is created. It uses the notification mechanism (see
Section \ref arr_secnotif) to automatically maintain the mapping of vertices
to indices, even when new vertices are inserted into the arrangement or
existing vertices are removed.
In most algorithm provided by the \sc{bgl}, the output is given by
<I>property maps</I>, such that each map entry corresponds to a vertex.
For example, when we compute the shortest paths from a given source vertex
\f$ s\f$ to all other vertices we can obtain a map of distances and a map of
predecessors - namely for each \f$ v\f$ vertex we have its distance from \f$ s\f$
and a descriptor of the vertex that precedes \f$ v\f$ in the shortest path from \f$ s\f$.
If the vertex descriptors are simply indices, one can use vectors to
efficiently represent the property maps. As this is not the case with the
arrangement graph, we offer the `Arr_vertex_property_map<Arrangement,Type>`
template allows for an efficient mapping of `Vertex_handle` objects to
properties of type `Type`. Note however that unlike the
`Arr_vertex_index_map` class, the vertex property-map class is not
kept synchronized with the number of vertices in the arrangement, so it
should not be reused in calls to \sc{Bgl} functions in case the arrangement
is modified in between these calls.
\anchor arr_figex_bgl
\image html ex_bgl.gif
<center><b>
An arrangement of 7 line segments, as constructed by `ex_bgl_primal_adapter.cpp` and `ex_bgl_dual_adapter.cpp`. The breadth-first visit times for the arrangement faces, starting from the unbounded face \f$ f_0\f$, are shown is brackets.
</b></center>
In the following example we construct an arrangement of 7 line segments,
as shown in Figure \ref arr_figex_bgl,
then use Dijkstra's shortest-paths algorithm from the \sc{Bgl} to compute
the graph distance of all vertices from the leftmost vertex in the
arrangement \f$ v_0\f$. Note the usage of the `Arr_vertex_index_map` and
the `Arr_vertex_property_map` classes. The latter one, instantiated by
the type `double` is used to map vertices to their distances from \f$ v_0\f$.
\cgalexample{primal.cpp}
\subsection arr_sssecbgl_dual Example for the Dual of an Arrangement as Graph
It is possible to give a dual graph representation for an arrangement instance,
such that each arrangement face corresponds to a graph vertex and two vertices
are adjacent iff the corresponding faces share a common edge on their
boundaries. This is done by specializing the
`boost:graph_traits` template for `Dual<Arrangement_2>` instances,
where `Dual<Arrangement_2>` is a template specialization that gives a
dual interpretation to an arrangement instance.
In dual representation, `Arrangement_2::Face_handle`
is the graph-vertex type, while `Arrangement_2::Halfedge_handle` is the
graph-edge type. We treat the graph edges as directed, such that a halfedge
`e` is directed from \f$ f_1\f$, which is its incident face, to \f$ f_2\f$, which
is the incident face of its twin halfedge. As two arrangement faces may
share more than a single edge on their boundary, we allow parallel
edges in our <I>boost</I> graph. As is the case in the primal graph, the dual
arrangement graph is also a model of the concepts `VertexListGraph`,
`EdgeListGraph` and `BidirectionalGraph` (thus also of
`IncidenceGraph`).
Since we use `Face_handle` objects as the vertex descriptors, we define
the `Arr_face_index_map<Arrangement>` class-template, which maintains an
efficient mapping of face handles to indices. We also provide the template
`Arr_face_property_map<Arrangement,Type>` for associating arbitrary
data with the arrangement faces.
In the following example we construct the same arrangement as in
example `ex_bgl_primal_adapter.cpp` (see Figure \ref arr_figex_bgl),
and perform breadth-first search on the graph faces, starting from the
unbounded face. We extend the \sc{Dcel} faces
with an unsigned integer, marking the discover time of the face and use a
breadth-first-search visitor to obtain these times and update the faces
accordingly:
\cgalexample{dual.cpp}
*/
} /* namespace CGAL */

View File

@ -0,0 +1,58 @@
namespace CGAL {
/*!
\ingroup PkgBGL
The class `HalfedgeDS_face_max_base_with_id` is a model of the `HalfedgeDSFace`
concept. `Refs` is an instantiation of a `HalfedgeDS`. It is
equivalent to `CGAL::HalfedgeDS_face_base< Refs, CGAL::Tag_true>`
with an added integer field which can be used to index faces
in \sc{Bgl} algorithms..
The class contains support for the incident halfedge pointer
and the required type definitions.
It can be used for deriving own faces.
Note that the user is in charge to set the index correctly before
running a graph algorithm.
\models ::HalfedgeDSFace
\sa `HalfedgeDS<Traits,Items,Alloc>`
\sa `HalfedgeDSItems`
\sa `PolyhedronItems_3`
\sa `CGAL::HalfedgeDS_min_items`
\sa `CGAL::HalfedgeDS_vertex_min_base<Refs>`
\sa `CGAL::HalfedgeDS_halfedge_min_base<Refs>`
\sa `CGAL::HalfedgeDS_face_base<Refs>`
\sa `CGAL::HalfedgeDS_vertex_max_base_with_id<Refs>`
\sa `CGAL::HalfedgeDS_halfedge_max_base_with_id<Refs>`
\sa `CGAL::Polyhedron_items_with_id_3`
*/
template< typename Refs >
class HalfedgeDS_face_max_base_with_id {
public:
/// \name Creation
/// @{
/*!
default constructor.
*/
HalfedgeDS_face_max_base_with_id();
/*!
Returns the index.
*/
int id() const;
/*!
Returns a reference to the index stored in the face.
*/
int& id();
/// @}
}; /* end HalfedgeDS_face_max_base_with_id */
} /* end namespace CGAL */

View File

@ -0,0 +1,57 @@
namespace CGAL {
/*!
\ingroup PkgBGL
The class `HalfedgeDS_halfedge_max_base_with_id` is a model of the `HalfedgeDSHalfedge`
concept. `Refs` is an instantiation of a `HalfedgeDS`.
It is equivalent to `CGAL::HalfedgeDS_halfedge_base< Refs, CGAL::Tag_true, CGAL::Tag_true, CGAL::Tag_true>` with an added integer
field which can be used to index halfedges in \sc{Bgl} algorithms.
The class contains support for the previous, next, opposite, vertex and
face pointers and the required type definitions.
It can be used for deriving own halfedges.
Note that the user is in charge to set the index correctly before
running a graph algorithm.
\models ::HalfedgeDSHalfedge
\sa `HalfedgeDS<Traits,Items,Alloc>`
\sa `HalfedgeDSItems`
\sa `PolyhedronItems_3`
\sa `CGAL::HalfedgeDS_min_items`
\sa `CGAL::HalfedgeDS_vertex_min_base<Refs>`
\sa `CGAL::HalfedgeDS_face_min_base<Refs>`
\sa `CGAL::HalfedgeDS_halfedge_base<Refs>`
\sa `CGAL::HalfedgeDS_vertex_max_base_with_id<Refs>`
\sa `CGAL::HalfedgeDS_face_max_base_with_id<Refs>`
\sa `CGAL::Polyhedron_items_with_id_3`
*/
template< typename Refs >
class HalfedgeDS_halfedge_max_base_with_id {
public:
/// \name Creation
/// @{
/*!
default constructor.
*/
HalfedgeDS_halfedge_max_base_with_id();
/*!
Returns the index.
*/
int id() const;
/*!
Returns a reference to the index stored in the halfedge.
*/
int& id();
/// @}
}; /* end HalfedgeDS_halfedge_max_base_with_id */
} /* end namespace CGAL */

View File

@ -0,0 +1,57 @@
namespace CGAL {
/*!
\ingroup PkgBGL
The class `HalfedgeDS_vertex_max_base_with_id` is a model of the `HalfedgeDSVertex`
concept. `Refs` is an instantiation of a `HalfedgeDS`. It is
equivalent to `CGAL::HalfedgeDS_vertex_base< Refs, CGAL::Tag_true>`
with an added integer field which can be used to index vertices
in \sc{Bgl} algorithms..
The class contains support for the point and the required type definitions.
It can be used for deriving own vertices.
Note that the user is in charge to set the index correctly before
running a graph algorithm.
\models ::HalfedgeDSVertex
\sa `HalfedgeDS<Traits,Items,Alloc>`
\sa `HalfedgeDSItems`
\sa `PolyhedronItems_3`
\sa `CGAL::HalfedgeDS_min_items`
\sa `CGAL::HalfedgeDS_halfedge_min_base<Refs>`
\sa `CGAL::HalfedgeDS_face_min_base<Refs>`
\sa `CGAL::HalfedgeDS_vertex_base<Refs>`
\sa `CGAL::HalfedgeDS_halfedge_max_base_with_id<Refs>`
\sa `CGAL::HalfedgeDS_face_max_base_with_id<Refs>`
\sa `CGAL::Polyhedron_items_with_id_3`
*/
template< typename Refs >
class HalfedgeDS_vertex_max_base_with_id {
public:
/// \name Creation
/// @{
/*!
default constructor.
*/
HalfedgeDS_vertex_max_base_with_id();
/*!
Returns the index.
*/
int id() const;
/*!
Returns a reference to the index stored in the vertex.
*/
int& id();
/// @}
}; /* end HalfedgeDS_vertex_max_base_with_id */
} /* end namespace CGAL */

View File

@ -0,0 +1,63 @@
namespace CGAL {
/*!
\ingroup PkgBGL
The class `Polyhedron_items_with_id_3` is a model of the `PolyhedronItems_3`
concept. It provides definitions for vertices with points, halfedges,
and faces with plane equations, all of them with an additional integer
field which can be used to index the items in a \sc{Bgl} algorithm.
The polyhedron traits class must provide the respective types for
the point and the plane equation.
Vertices and facets both contain a halfedge handle to an incident
halfedge.
\models PolyhedronItems_3
### Operations ###
Supported as required by the `PolyhedronItems_3` concept.
### Additional methods in all three items ###
\code
int id() const; // Returns the index.
int& id(); // Returns a reference to the index stored in the item.
\endcode
\sa `CGAL::Polyhedron_3<Traits>`
\sa `CGAL::Polyhedron_min_items_3`
\sa `CGAL::HalfedgeDS_min_items`
\sa `CGAL::HalfedgeDS_items_2`
\sa `CGAL::HalfedgeDS_vertex_max_base_with_id<Refs>`
\sa `CGAL::HalfedgeDS_halfedge_max_base_with_id<Refs>`
\sa `CGAL::HalfedgeDS_face_max_base_with_id<Refs>`
*/
class Polyhedron_items_with_id_3 {
public:
template < class Refs, class Traits>
struct Vertex_wrapper {
typedef typename Traits::Point_3 Point;
typedef CGAL::Tag_true Supports_vertex_point;
};
template < class Refs, class Traits>
struct Face_wrapper {
typedef typename Traits::Plane_3 Plane;
typedef CGAL::Tag_true Supports_face_plane;
};
/// \name Creation
/// @{
/*!
default constructor.
*/
Polyhedron_items_with_id_3();
/// @}
}; /* end Polyhedron_items_with_id_3 */
} /* end namespace CGAL */

View File

@ -0,0 +1,48 @@
namespace CGAL {
/*!
\ingroup PkgBGL
The class `Triangulation_vertex_base_with_id_2` is a model of the
concept `TriangulationVertexBase_2`, the base vertex of a
2D-triangulation. It provides an integer field that can be used to
index vertices for \sc{Bgl} algorithms.
Note that the user is in charge to set the index correctly before
running a graph algorithm.
Parameters
--------------
The first template argument is the geometric traits class
`TriangulationTraits_2` which provides the `Point_2`.
The second template argument is a vertex base class from which
`Triangulation_vertex_base_with_id_2` derives. It has the default
value `Triangulation_vertex_base_2<TriangulationTraits_2>`.
\models ::TriangulationVertexBase_2
\sa `CGAL::Triangulation_vertex_base_2`
*/
template< typename TriangulationTraits_2, typename TriangulationVertexBase_2 >
class Triangulation_vertex_base_with_id_2 : public TriangulationVertexBase_2 {
public:
/// \name Access Functions
/// @{
/*!
Returns the index.
*/
int id() const;
/*!
Returns a reference to the index stored in the vertex.
*/
int& id();
/// @}
}; /* end Triangulation_vertex_base_with_id_2 */
} /* end namespace CGAL */

View File

@ -0,0 +1,96 @@
namespace boost {
/*!
\ingroup PkgBGL
The class `graph_traits` is a partial specialization of `boost::graph_traits`
for the class `CGAL::Arrangement_2`. It provides the types associated
to the
<A HREF="http://www.boost.org/libs/graph/doc/graph_concepts.html">graph</A> concepts
<A HREF="http://www.boost.org/libs/graph/doc/BidirectionalGraph.html">`BidirectionalGraph`</A> and
<A HREF="http://www.boost.org/libs/graph/doc/EdgeAndVertexListGraph.html">`EdgeAndVertexListGraph`</A>.
The const specialization, `boost::graph_traits< CGAL::Arrangement_2<Traits,Dcel> const>`
is also defined, using the constant handles in the arrangement.
*/
template< typename Traits, typename Dcel> >
class graph_traits< CGAL::Arrangement_2<Traits, Dcel> > {
public:
/// \name Types
/// @{
/*!
The vertex descriptor.
*/
typename CGAL::Arrangement_2::Vertex_handle vertex_descriptor;
/*!
The edge descriptor.
*/
typename CGAL::Arrangement_2::Halfedge_handle edge_descriptor;
/*!
An iterator corresponding to
`CGAL::Arrangement_2::Vertex_iterator`,
with the difference that its value type is a vertex descriptor and not
`CGAL::Arrangement_2::Vertex`.
*/
typedef Hidden_type vertex_iterator;
/*!
An iterator corresponding to
`CGAL::Arrangement_2::Halfedge_iterator`
with the difference that its value type is an edge descriptor and not
`CGAL::Arrangement_2::Halfedge`.
*/
typedef Hidden_type edge_iterator;
/*!
An edge iterator which only iterates over
the incoming edges around a vertex. It corresponds to a
`CGAL::Arrangement_2::Halfedge_around_vertex_circulator`
with the difference that its value type is an edge descriptor and not
`CGAL::Arrangement_2::Halfedge`.
*/
typedef Hidden_type in_edge_iterator;
/*!
An edge iterator which only iterates over
the outgoing halfedges around a vertex. It corresponds to a
`CGAL::Arrangement_2::Halfedge_around_vertex_circulator`
with the difference that its value type is an edge descriptor and not
`CGAL::Arrangement_2::Halfedge`.
*/
typedef Hidden_type out_edge_iterator;
/*!
Indicates that this graph does support multiedges.
*/
boost::sallow_parallel_edge_tag edge_parallel_category;
/*!
Indicates that this graph is bidirectional.
*/
boost::bidirectional_graph_tag traversal_category;
/*!
The size type of the vertex list.
*/
typename Arrangement_2::size_type vertices_size_type;
/*!
The size type of the edge list.
*/
typename Arrangement_2::size_type edges_size_type;
/*!
The size type of the adjacency list.
*/
typename Arrangement_2::size_type degree_size_type;
/// @}
}; /* end graph_traits */
} /* end namespace boost */

View File

@ -0,0 +1,98 @@
namespace boost {
/*!
\ingroup PkgBGL
The class `graph_traits` is a partial specialization of `boost::graph_traits`
for the class `Polyhedron_3`. It provides the types associated
to the
<A HREF="http://www.boost.org/libs/graph/doc/graph_concepts.html">graph</A> concepts
<A HREF="http://www.boost.org/libs/graph/doc/BidirectionalGraph.html">`BidirectionalGraph`</A> and
<A HREF="http://www.boost.org/libs/graph/doc/EdgeAndVertexListGraph.html">`EdgeAndVertexListGraph`</A>.
Types
--------------
The const specialization, `boost::graph_traits< CGAL::Polyhedron_3<Traits> const>`
is also defined, using the constant handles in the polyhedron.
*/
template< typename Traits> >
class graph_traits< CGAL::Polyhedron_3<Traits> > {
public:
/// \name Types
/// @{
/*!
The vertex descriptor.
*/
typename CGAL::Polyhedron_3::Vertex_handle vertex_descriptor;
/*!
The edge descriptor.
*/
typename CGAL::Polyhedron_3::Halfedge_handle edge_descriptor;
/*!
An iterator corresponding to
`CGAL::Polyhedron_3::Vertex_iterator`,
with the difference that its value type is a vertex descriptor and not
`CGAL::Polyhedron_3::Vertex`.
*/
typedef Hidden_type vertex_iterator;
/*!
An iterator corresponding to
`CGAL::Polyhedron_3::Halfedge_iterator`
with the difference that its value type is an edge descriptor and not
`CGAL::Polyhedron_3::Halfedge`.
*/
typedef Hidden_type edge_iterator;
/*!
An edge iterator which only iterates over
the incoming edges around a vertex. It corresponds to a
`CGAL::Polyhedron_3::Halfedge_around_vertex_circulator`
with the difference that its value type is an edge descriptor and not
`CGAL::Polyhedron_3::Halfedge`.
*/
typedef Hidden_type in_edge_iterator;
/*!
An edge iterator which only iterates over
the outgoing halfedges around a vertex. It corresponds to a
`CGAL::Polyhedron_3::Halfedge_around_vertex_circulator`
with the difference that its value type is an edge descriptor and not
`CGAL::Polyhedron_3::Halfedge`.
*/
typedef Hidden_type out_edge_iterator;
/*!
Indicates that this graph does not support multiedges.
*/
boost::disallow_parallel_edge_tag edge_parallel_category;
/*!
Indicates that this graph is bidirectional.
*/
boost::bidirectional_graph_tag traversal_category;
/*!
The size type of the vertex list.
*/
typename Polyhedron_3::size_type vertices_size_type;
/*!
The size type of the edge list.
*/
typename Polyhedron_3::size_type edges_size_type;
/*!
The size type of the adjacency list.
*/
typename Polyhedron_3::size_type degree_size_type;
/// @}
}; /* end graph_traits */
} /* end namespace boost */

View File

@ -0,0 +1,97 @@
namespace boost {
/*!
\ingroup PkgBGL
The triangulations of \cgal are all models of the concepts
`BidirectionalGraph` and `VertexAndEdgeListGraph` of the Boost Graph
Library \cite cgal:sll-bgl-02.
The class `graph_traits` is a partial specialization of the class
<A HREF="http://www.boost.org/libs/graph/doc/graph_traits.html">`boost::graph_traits<G>`</A>.
The mapping between vertices and edges of the triangulation and the
graph is rather straightforward, but there are some subtleties. The
value type of the \sc{Bgl} iterators is the vertex or edge descriptor,
whereas in \cgal all iterators and circulators are also handles and
hence have as value type Vertex or Edge.
The graph traits class for triangulations does not distinguish between
finite and infinite vertices and edges. As the edge weight computed
with the default property map of \sc{Bgl} algorithms (obtained with
`boost::get(t, boost::edge_weight)`) is the length of the edge,
the edge weight is not well defined for infinite edges. For algorithms
that make use of the edge weight the user must therefore
define a <A HREF="http://www.boost.org/libs/graph/doc/filtered_graph.html">`boost::filtered_graph`</A> or pass a property map to the
algorithm that returns "infinity" for infinite edges.
Note also that when you derive from the class `CGAL::Triangulation_2`
you must upcast the object in order to use this partial specialization.
For the user convenience, \cgal provides the partial specializations
for all 2D triangulation classes.
*/
template< typename GT, typename TDS> >
class graph_traits< CGAL::Triangulation_2<GT, TDS> > {
public:
/// \name Types
/// @{
/*!
The vertex descriptor.
*/
typedef Triangulation::Vertex_handle vertex_descriptor;
/*!
The edge descriptor. It is constructible from and convertible to `Triangulation::Edge`.
The edge descriptor is not a simple typedef, but a proper class,
because in an undirected graph
the edges `(u,v)` and `(v,u)` must be equal. This is not the case
for the Edge type of the triangulation.
*/
typedef Hidden_type edge_descriptor;
/*!
The vertex iterator type. Its value type is `vertex_descriptor`.
*/
typedef Hidden_type vertex_iterator;
/*!
The edge iterator type, Its value type is `edge_descriptor`.
*/
typedef Hidden_type edge_iterator;
/*!
An iterator for the outgoing edges incident to a vertex.
Its value type is `edge_descriptor`.
*/
typedef Hidden_type out_edge_iterator;
/*!
An iterator for the incoming edges incident to a vertex.
Its value type is `edge_descriptor`.
*/
typedef Hidden_type in_edge_iterator;
/*!
An iterator for the vertices adjacent to a vertex.
Its value type is `vertex_descriptor`.
*/
typedef Hidden_type adjacency_iterator;
/*!
*/
typedef boost::undirected_tag directed_category;
/*!
*/
typedef boost::disallow_parallel_edge_tag edge_parallel_category;
/// @}
}; /* end graph_traits */
} /* end namespace boost */

View File

@ -0,0 +1,35 @@
namespace CGAL {
/*!
\ingroup PkgBGL
The class `halfedge_graph_traits` is a partial specialization of `CGAL::halfedge_graph_traits`
for `Polyhedron_3`. It provides the types associated
to the `HalfedgeGraph` concept.
*/
template< typename Traits> >
class halfedge_graph_traits< Polyhedron_3<Traits> > {
public:
/// \name Types
/// @{
/*!
An edge iterator that iterates
over one of the two opposite edges forming an undirected edge.
The value type is `CGAL::Polyhedron_3::Halfedge_const_handle`.
*/
typedef Hidden_type undirected_edge_iterator;
/*!
The point type of the vertex.
*/
typename CGAL::Polyhedron_3<Traits>::Point_3 Point ;
/// @}
}; /* end halfedge_graph_traits */
} /* end namespace CGAL */

View File

@ -0,0 +1,73 @@
namespace CGAL {
/*!
\ingroup PkgBGL
The constant `edge_is_border` is a
<A HREF="http://www.boost.org/libs/graph/doc/PropertyTag.html">property tag</A>
which refers to the property of an edge of being a border edge.
`edge_is_border` is an
<A HREF="http://www.boost.org/libs/graph/doc/using_property_maps.html">interior property</A>.
That is, a
<A HREF="http://www.boost.org/libs/property_map/doc/property_map.html">property map</A>
for `edge_is_border` can be extracted from any model of a `HalfedgeGraph`
using the <span class="textsc">Bgl</span>
<A HREF="http://www.boost.org/libs/graph/doc/PropertyGraph.html">PropertyGraph</A> interface: `boost::get(edge_is_border,graph)`
The Boolean flag that indicates if the edge is a border can be directly accessed via:
`boost::get(edge_is_border,graph,edge)`.
*/
enum edge_is_border_t { edge_is_border };
/*!
\ingroup PkgBGL
The constant `vertex_is_border` is a
<A HREF="http://www.boost.org/libs/graph/doc/PropertyTag.html">property tag</A> which refers to the property
of a vertex of being a border vertex.
`vertex_is_border` is an
<A HREF="http://www.boost.org/libs/graph/doc/using_property_maps.html">interior property</A>, that is, a
<A HREF="http://www.boost.org/libs/property_map/doc/property_map.html">property map</A>
for `vertex_is_border` can be extracted from any model of
a `HalfedgeGraph` using the <span class="textsc">Bgl</span>
<A HREF="http://www.boost.org/libs/graph/doc/PropertyGraph.html">PropertyGraph</A> interface:
`boost::get(vertex_is_border,graph)`
The Boolean flag that indicates if the vertex is a border can be directly accessed via:
`boost::get(vertex_is_border,graph,edge)`
*/
enum vertex_is_border_t { vertex_is_border };
/*!
\ingroup PkgBGL
The constant `vertex_point` is a <A HREF="http://www.boost.org/libs/graph/doc/PropertyTag.html">property tag</A> which refers to the geometric embedding property of a vertex of a `HalfedgeGraph`.
A `vertex_point` is an
<A HREF="http://www.boost.org/libs/graph/doc/using_property_maps.html">interior property</A>,
that is, a
<A HREF="http://www.boost.org/libs/property_map/doc/property_map.html">property map</A>
for a `vertex_point` can be extracted from any model of a `HalfedgeGraph`
using the <span class="textsc">Bgl</span>
<A HREF="http://www.boost.org/libs/graph/doc/PropertyGraph.html">PropertyGraph</A> interface:
`boost::get(vertex_point,graph)`
A point of a vertex can be directly accessed via:
- `boost::get(vertex_point,graph,vertex)`
- `boost::put(vertex_point,graph,vertex,newpoint)`
*/
enum vertex_point_t { vertex_point };
}
namespace boost {
/*!
\ingroup PkgBGL
The constant `edge_index` is a
<A HREF="http://www.boost.org/libs/graph/doc/PropertyTag.html">property tag</A> which identifies the <I>index</I> property
of an edge of a \sc{Bgl}
<A HREF="http://www.boost.org/libs/graph/doc/Graph.html">Graph</A>.
*/
enum edge_index_t { edge_index };
}

View File

@ -0,0 +1,141 @@
/*!
\ingroup PkgBGLConcepts
\cgalconcept
The concept `HalfedgeGraph` describes the requirements for a graph that is
structurally equivalent to a polyhedral surface represented by a
halfedge data structure, and it provides an interface for efficient
access to the opposite edge of an edge, and to the successor and
predecessor of an edge in the iterator range of the incoming edges of
a vertex. Each vertex has a geometric position in space. As in a
halfedge data structure we define the face adjacent to a halfedge to be
to the <I>left</I> of the halfedge.
Requirements
--------------
For each <I>directed edge</I> \f$ e=(v,w)\f$ its opposite edge \f$ e'=(w,v)\f$
must be part of the graph.
The incoming edges of a vertex \f$ v\f$ have a fixed order, that is all
calls of `in_edges(v,g)` must return the same iterator range,
modulo a cyclic permutation. The order must be <I>clockwise</I>.
As the `HalfedgeGraph` is equivalent to a polyhedral surface there must exist an embedding
for the vertices and edges such that the ordered edges do not intersect.
\refines <A HREF="http://www.boost.org/libs/graph/doc/BidirectionalGraph.html">BidirectionalGraph</A>
\refines <A HREF="http://www.boost.org/libs/graph/doc/PropertyGraph.html">PropertyGraph</A>
A model of `HalfedgeGraph` must have the <I>interior properties</I>
`edge_is_border` attached to its edges, and it must have
`vertex_is_border` and `vertex_point` attached to its vertices.
Associated Types
--------------
Because (directed) edges must come in pairs, there is the
additional notion of an <I>undirected edge</I>
\footnote{The directed edges are not called `halfedges` (as in a `HalfedgeDS`) because from the point of view of this graph, being a refinement of a sc{Bgl} graph, each directed edge is an edge in itself. In other words, the unqualified term edge refers to one and only one directed edge and not to a pair.}
for a pair of opposite directed edges. The number of undirected
edges is exactly half the number of directed edges. Note that the
notion of directed and undirected edges does not imply the
existence of two different types. The type `edge_descriptor` is
used for both. An undirected edge must be implicitly handled, and
there is no requirement on which of the directed edges of the
undirected edge must be used to represent it.
\code
// The type of the geometric location of a vertex.
typedef Hidden_type halfedge_graph_traits<HalfedgeGraph>::Point;
// An iterator that iterates over one and only one of the directed edges
// in each pair of opposite directed edges. The value type of the iterator
// is `boost::graph_traits<HalfedgeGraph>::edge_descriptor`.
typedef Hidden_type halfedge_graph_traits<HalfedgeGraph>::undirected_edge_iterator;
\endcode
Valid Expressions
--------------
Following the \sc{Bgl} design, the following graph operations are defined as free
rather than member functions.
\hasModel `CGAL::Polyhedron_3<Traits>`
*/
class HalfedgeGraph {
};
/*!
Returns the undirected edges of `g`.
\relates HalfedgeGraph
*/
template<class Graph>
std::pair<typename halfedge_graph_traits<HalfedgeGraph>::undirected_edge_iterator,
typename halfedge_graph_traits<HalfedgeGraph>::undirected_edge_iterator>
undirected_edges(const Graph& g);
/*!
Returns the opposite edge of `e`.
An edge \f$ e=(v,w)\f$ is said to be the <I>opposite edge</I> of edge
\f$ e'=(w,v)\f$.
\relates HalfedgeGraph
*/
template<class Graph>
typename boost::graph_traits<Graph const>::edge_descriptor
opposite_edge(typename boost::graph_traits<Graph const>::edge_descriptor e, Graph const& g );
/*!
Returns the clockwise neighbor of `e`.
An edge \f$ e'=(v,w)\f$ is called the <I>clockwise neighbor</I> of
edge \f$ e=(u,w)\f$, and \f$ e\f$ the <I>counterclockwise neighbor</I>
of \f$ e'\f$, iff there exist two iterators \f$ it\f$ and \f$ it'\f$
in the iterator range `in_edges(w,g)` such that `**it == e` and `**it'
== e'`, and `it' == it++` or `it` is the last and `it'` the first
iterator of the iterator range.
\relates HalfedgeGraph
*/
template<class Graph>
typename boost::graph_traits<Graph const>::edge_descriptor
next_edge_cw(typename boost::graph_traits<Graph const>::edge_descriptor e, Graph const& g );
/*!
Returns the counterclockwise neighbor of `e`.
\relates HalfedgeGraph
*/
template<class Graph>
typename boost::graph_traits<Graph const>::edge_descriptor
next_edge_ccw(typename boost::graph_traits<Graph const>::edge_descriptor e, Graph const& g );
/*!
Returns the successor of `e`.
An edge \f$ e'=(v,w)\f$ is called the <I>successor</I> of edge \f$
e=(u,v)\f$, and \f$ e\f$ the <I>predecessor</I> of \f$ e'\f$, iff \f$
e'\f$ is the clockwise neighbor of the opposite edge of \f$ e\f$.
\relates HalfedgeGraph
*/
template<class Graph>
typename boost::graph_traits<Graph const>::edge_descriptor
next_edge(typename boost::graph_traits<Graph const>::edge_descriptor e, Graph const& g );
/*!
Returns the predecessor of `e`.
An edge \f$ e'=(v,w)\f$ is called the <I>successor</I> of edge \f$
e=(u,v)\f$, and \f$ e\f$ the <I>predecessor</I> of \f$ e'\f$, iff \f$
e'\f$ is the clockwise neighbor of the opposite edge of \f$ e\f$.
\relates HalfedgeGraph
*/
template<class Graph>
typename boost::graph_traits<Graph const>::edge_descriptor
prev_edge(typename boost::graph_traits<Graph const>::edge_descriptor e, Graph const& g );

View File

@ -0,0 +1,21 @@
/// \defgroup PkgBGL CGAL and the Boost Graph Library
/// \defgroup PkgBGLConcepts Concepts
/// \ingroup PkgBGL
/*!
\addtogroup PkgBGL
\todo check generated documentation
\PkgDescriptionBegin{CGAL and the Boost Graph Library}
\PkgPicture{emst-detail.png}
\PkgAuthor{Andreas Fabri and Fernando Cacciola and Ron Wein}
\PkgDesc{This package provides a framework for interfacing \cgal data structures with the algorithms of the \sc{BGL}. It allows to run graph algorithms directly on \cgal data structures which are model of the \sc{BGL} graph concepts, for example the shortest path algorithm on a Delaunay triangulation in order to compute the Euclidean minimum spanning tree. Furthermore, it introduces a new graph concept, the `HalfedgeEdgeGraph`. This concept describes graphs which are embedded on surfaces.}
\PkgSince{3.3}
\cgalbib{cgal:cfw-cbgl}
\license{\ref licensesLGPL "LGPL"}
\PkgDescriptionEnd
This chapter introduces the concepts and classes that allow to interface \cgal data structures
with the algorithms of the \sc{Bgl}, as well as a new graph concept.
*/

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
BGL/doc/BGL/fig/emst.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
BGL/doc/BGL/fig/ex_bgl.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

BIN
BGL/doc/BGL/fig/ex_bgl.pdf Normal file

Binary file not shown.

View File

@ -229,6 +229,24 @@ namespace for the XML file to be processed properly. -->
</doxygen>
</project>
<project>
<name>CGAL and the Boost Graph Library</name>
<input>../BGL/doc</input>
<doxygen>
<string name="STRIP_FROM_PATH">../BGL/doc/BGL/</string>
<string name="STRIP_FROM_INC_PATH">../BGL/doc/BGL/</string>
<string name="GENERATE_TAGFILE">./tags/BGL.tag</string>
<string name="EXAMPLE_PATH">../BGL/examples</string>
<string name="IMAGE_PATH">../BGL/doc/BGL/fig</string>
<list name="TAGFILES" append="true">
<item>./tags/HalfedgeDS.tag=../../CGAL.CGAL.Halfedge-Data-Structures/html</item>
<item>./tags/Polyhedron.tag=../../CGAL.CGAL.3D-Polyhedral-Surface/html</item>
<item>./tags/Arrangement_on_surface_2.tag=../../CGAL.CGAL.2D-Arrangements/html</item>
<item>./tags/Triangulation_2.tag=../../CGAL.CGAL.2D-Triangulations/html</item>
</list>
</doxygen>
</project>
<project>
<name>3D Polyhedral Surface</name>
<input>../Polyhedron/doc</input>
@ -1134,6 +1152,7 @@ namespace for the XML file to be processed properly. -->
<item>../Geomview/doc/Geomview/fig</item>
<item>../GraphicsView/doc/GraphicsView/fig</item>
<item>../HalfedgeDS/doc/HalfedgeDS/fig</item>
<item>../BGL/doc/BGL/fig</item>
<item>../Combinatorial_map/doc/Combinatorial_map/fig</item>
<item>../Interval_skip_list/doc/Interval_skip_list/fig</item>
<item>../Nef_2/doc/Nef_2/fig</item>
@ -1206,6 +1225,7 @@ namespace for the XML file to be processed properly. -->
<item>./tags/Geomview.tag=../../CGAL.CGAL.Geomview/html</item>
<item>./tags/GraphicsView.tag=../../CGAL.CGAL.CGAL-and-the-Qt-Graphics-View-Framework/html</item>
<item>./tags/HalfedgeDS.tag=../../CGAL.CGAL.Halfedge-Data-Structures/html</item>
<item>./tags/BGL.tag=../../CGAL.CGAL.CGAL-and-the-Boost-Graph-Library/html</item>
<item>./tags/Combinatorial_map.tag=../../CGAL.CGAL.Combinatorial-Maps/html</item>
<item>./tags/Interval_skip_list.tag=../../CGAL.CGAL.Interval-Skip-List/html</item>
<item>./tags/Nef_2.tag=../../CGAL.CGAL.2D-Boolean-Operations-on-Nef-Polygons/html</item>