31#if defined(DigitalSurfaceBoostGraphInterface_RECURSES)
32#error Recursive header files inclusion detected in DigitalSurfaceBoostGraphInterface.h
35#define DigitalSurfaceBoostGraphInterface_RECURSES
37#if !defined DigitalSurfaceBoostGraphInterface_h
39#define DigitalSurfaceBoostGraphInterface_h
45#include <boost/iterator/iterator_facade.hpp>
46#include <boost/graph/graph_traits.hpp>
47#include <boost/graph/properties.hpp>
48#include <boost/property_map/property_map.hpp>
49#include "DGtal/base/Common.h"
50#include "DGtal/base/ConstAlias.h"
51#include "DGtal/base/CountedPtr.h"
52#include "DGtal/topology/DigitalSurface.h"
92 template <
class TDigitalSurfaceContainer >
93 struct graph_traits<
DGtal::DigitalSurface< TDigitalSurfaceContainer > >
173 :
public iterator_facade< adjacency_iterator,
175 bidirectional_traversal_tag,
181 : myIterator(), myVertices( 0 ) {}
185 : myIterator( it ), myVertices(
vertices ) {}
190 ASSERT( myIterator != myVertices->end() );
197 bool thisAtEnd = ( myIterator == myVertices->end() );
199 if ( thisAtEnd || otherAtEnd )
return thisAtEnd && otherAtEnd;
215 friend class iterator_core_access;
252 :
public iterator_facade< out_edge_iterator,
254 bidirectional_traversal_tag,
260 : myIterator(), myOutEdges( 0 ) {}
264 : myIterator( it ), myOutEdges(
out_edges ) {}
269 ASSERT( myIterator != myOutEdges->end() );
276 bool thisAtEnd = ( myIterator == myOutEdges->end() );
278 if ( thisAtEnd || otherAtEnd )
return thisAtEnd && otherAtEnd;
294 friend class iterator_core_access;
330 :
public iterator_facade< edge_iterator,
332 forward_traversal_tag,
349 friend class iterator_core_access;
375 template <
class TDigitalSurfaceContainer >
377 typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::vertex_descriptor
381 return digSurf.
tail( edge );
388 template <
class TDigitalSurfaceContainer >
390 typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::vertex_descriptor
394 return digSurf.
head( edge );
402 template <
class TDigitalSurfaceContainer >
404 typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::vertex_iterator,
405 typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::vertex_iterator
413 template <
class TDigitalSurfaceContainer >
415 typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::vertices_size_type
418 return digSurf.
size();
428 template <
class TDigitalSurfaceContainer >
431 typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::adjacency_iterator,
432 typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::adjacency_iterator
437 typedef typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >
438 ::adjacency_iterator Iterator;
439 typedef typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >
442 std::back_insert_iterator< Container > outIt = std::back_inserter( *ptrAdjVertices );
444 return std::make_pair( Iterator( ptrAdjVertices->begin(), ptrAdjVertices ),
445 Iterator( ptrAdjVertices->end(), ptrAdjVertices ) );
457 template <
class TDigitalSurfaceContainer >
460 typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::out_edge_iterator,
461 typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::out_edge_iterator
466 typedef typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >
467 ::out_edge_iterator Iterator;
468 typedef typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >
471 return std::make_pair( Iterator( ptrOutEdges->begin(), ptrOutEdges ),
472 Iterator( ptrOutEdges->end(), ptrOutEdges ) );
482 template <
class TDigitalSurfaceContainer >
484 typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::degree_size_type
488 return digSurf.
degree( u );
497 template <
class TDigitalSurfaceContainer >
500 typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::edge_iterator,
501 typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::edge_iterator
505 typedef typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::edge_iterator
507 return std::make_pair( edge_iterator( digSurf, digSurf.
begin(), digSurf.
end() ),
508 edge_iterator( digSurf, digSurf.
end(), digSurf.
end() ) );
515 template <
class TDigitalSurfaceContainer >
517 typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::edges_size_type
520 typedef typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::edge_iterator
522 typedef typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::edges_size_type
524 edges_size_type nbEdges = 0;
525 for ( std::pair< edge_iterator, edge_iterator > ve =
boost::edges( digSurf );
526 ve.first != ve.second; ++ve.first )
537#include "DGtal/graph/DigitalSurfaceBoostGraphInterface.ih"
544#undef DigitalSurfaceBoostGraphInterface_RECURSES
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
ArcRange outArcs(const Vertex &v) const
DigitalSurfaceContainer::SurfelConstIterator ConstIterator
Vertex tail(const Arc &a) const
KSpace::Size Size
Defines how to represent a size (unsigned integral type).
Surfel Vertex
Defines the type for a vertex.
ConstIterator begin() const
std::vector< Arc > ArcRange
The range of arcs is defined as a vector.
ConstIterator end() const
Size degree(const Vertex &v) const
void writeNeighbors(OutputIterator &it, const Vertex &v) const
Vertex head(const Arc &a) const
DGtal::CountedPtr< AdjacentVertexContainer > myVertices
adjacency_iterator(typename AdjacentVertexContainer::const_iterator it, const DGtal::CountedPtr< AdjacentVertexContainer > &vertices)
bool equal(const adjacency_iterator &other) const
AdjacentVertexContainer::const_iterator myIterator
The iterator pointing in the container of adjacent vertices.
const Vertex & dereference() const
edge_iterator(ConstAlias< Adapted > graph, const vertex_iterator &itB, const vertex_iterator &itE)
const Arc & dereference() const
std::pair< out_edge_iterator, out_edge_iterator > myOutEdgeRange
bool equal(const edge_iterator &other) const
std::pair< vertex_iterator, vertex_iterator > myVertexRange
out_edge_iterator(typename OutEdgeContainer::const_iterator it, const DGtal::CountedPtr< OutEdgeContainer > &out_edges)
DGtal::CountedPtr< OutEdgeContainer > myOutEdges
bool equal(const out_edge_iterator &other) const
OutEdgeContainer::const_iterator myIterator
The iterator pointing in the container of out edges.
const Arc & dereference() const
DGtal is the top-level namespace which contains all DGtal functions and types.
std::pair< typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::edge_iterator, typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::edge_iterator > edges(const DGtal::DigitalSurface< TDigitalSurfaceContainer > &digSurf)
graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::edges_size_type num_edges(const DGtal::DigitalSurface< TDigitalSurfaceContainer > &digSurf)
std::pair< typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::adjacency_iterator, typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::adjacency_iterator > adjacent_vertices(typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::vertex_descriptor u, const DGtal::DigitalSurface< TDigitalSurfaceContainer > &digSurf)
graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::vertices_size_type num_vertices(const DGtal::DigitalSurface< TDigitalSurfaceContainer > &digSurf)
graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::degree_size_type out_degree(typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::vertex_descriptor u, const DGtal::DigitalSurface< TDigitalSurfaceContainer > &digSurf)
std::pair< typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::out_edge_iterator, typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::out_edge_iterator > out_edges(typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::vertex_descriptor u, const DGtal::DigitalSurface< TDigitalSurfaceContainer > &digSurf)
std::pair< typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::vertex_iterator, typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::vertex_iterator > vertices(const DGtal::DigitalSurface< TDigitalSurfaceContainer > &digSurf)
Go to http://www.sgi.com/tech/stl/Container.html.
Adapted::Arc Arc
(oriented) edge type
Adapted::ConstIterator vertex_iterator
static vertex_descriptor null_vertex()
Adapted::Size degree_size_type
the type for counting out or in edges
undirected_tag directed_category
the graph is undirected.
Adapted::Size vertices_size_type
the type for counting vertices
Adapted::Vertex Vertex
Vertex type.
std::vector< vertex_descriptor > AdjacentVertexContainer
This is the intermediate data structure that is used for visiting adjacent vertices.
Adapted::Size edges_size_type
the type for counting edges
Vertex vertex_descriptor
Vertex type.
Adapted::ArcRange OutEdgeContainer
This is the intermediate data structure that is used for storing out edges.
disallow_parallel_edge_tag edge_parallel_category
the graph does not allow parallel edges.
DigitalSurface_graph_traversal_category traversal_category
the graph satisfies AdjacencyListGraph and VertexListGraph concepts.
Arc edge_descriptor
(oriented) edge type
DGtal::DigitalSurface< TDigitalSurfaceContainer > Adapted
the adapted DGtal graph class.