DGtal 1.4.2
Loading...
Searching...
No Matches
DigitalSurfaceBoostGraphInterface.ih
1/**
2 * This program is free software: you can redistribute it and/or modify
3 * it under the terms of the GNU Lesser General Public License as
4 * published by the Free Software Foundation, either version 3 of the
5 * License, or (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 *
15 **/
16
17/**
18 * @file DigitalSurfaceBoostGraphInterface.ih
19 * @author Jacques-Olivier Lachaud (\c jacques-olivier.lachaud@univ-savoie.fr )
20 * Laboratory of Mathematics (CNRS, UMR 5127), University of Savoie, France
21 *
22 * @date 2013/01/20
23 *
24 * Implementation of inline methods defined in DigitalSurfaceBoostGraphInterface.h
25 *
26 * This file is part of the DGtal library.
27 */
28
29
30//////////////////////////////////////////////////////////////////////////////
31#include <cstdlib>
32//////////////////////////////////////////////////////////////////////////////
33
34///////////////////////////////////////////////////////////////////////////////
35// IMPLEMENTATION of inline methods.
36///////////////////////////////////////////////////////////////////////////////
37
38///////////////////////////////////////////////////////////////////////////////
39// ----------------------- Standard services ------------------------------
40
41template < class TDigitalSurfaceContainer >
42inline
43std::pair<
44 typename boost::graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::vertex_iterator,
45 typename boost::graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::vertex_iterator
46 >
47boost::vertices( const DGtal::DigitalSurface< TDigitalSurfaceContainer > & digSurf )
48{
49 return std::make_pair( digSurf.begin(), digSurf.end() );
50}
51//-----------------------------------------------------------------------------
52template < class TDigitalSurfaceContainer >
53inline
54boost::graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::edge_iterator::
55edge_iterator()
56 : myGraph( 0 )
57{}
58//-----------------------------------------------------------------------------
59template < class TDigitalSurfaceContainer >
60inline
61boost::graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::edge_iterator::
62edge_iterator( ConstAlias<Adapted> graph,
63 const vertex_iterator & itB, const vertex_iterator & itE )
64 : myGraph( &graph ),
65 myVertexRange( itB, itE ),
66 myOutEdgeRange()
67{
68 if ( myVertexRange.first != myVertexRange.second )
69 {
70 myOutEdgeRange = boost::out_edges( *myVertexRange.first, *myGraph );
71 }
72}
73//-----------------------------------------------------------------------------
74template < class TDigitalSurfaceContainer >
75inline
76const typename boost::graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::Arc &
77boost::graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::edge_iterator::
78dereference() const
79{
80 ASSERT( myVertexRange.first != myVertexRange.second );
81 ASSERT( myOutEdgeRange.first != myOutEdgeRange.second );
82 return *( myOutEdgeRange.first );
83}
84//-----------------------------------------------------------------------------
85template < class TDigitalSurfaceContainer >
86inline
87bool
88boost::graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::edge_iterator::
89equal( const edge_iterator & other ) const
90{
91 bool thisAtEnd = ( myVertexRange.first == myVertexRange.second );
92 bool otherAtEnd = ( other.myVertexRange.first == other.myVertexRange.second );
93 if ( thisAtEnd || otherAtEnd ) return thisAtEnd && otherAtEnd;
94 else
95 {
96 ASSERT( myOutEdgeRange.first != myOutEdgeRange.second );
97 ASSERT( other.myOutEdgeRange.first != other.myOutEdgeRange.second );
98 return *myOutEdgeRange.first == *other.myOutEdgeRange.first;
99 }
100}
101//-----------------------------------------------------------------------------
102template < class TDigitalSurfaceContainer >
103inline
104void
105boost::graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::edge_iterator::
106increment()
107{
108 ++myOutEdgeRange.first;
109 if ( myOutEdgeRange.first == myOutEdgeRange.second )
110 {
111 ++myVertexRange.first;
112 if ( myVertexRange.first != myVertexRange.second )
113 myOutEdgeRange = boost::out_edges( *myVertexRange.first, *myGraph );
114 }
115}
116
117// //
118///////////////////////////////////////////////////////////////////////////////
119
120