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.
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.
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/>.
18 * @file SetOfSurfels.ih
19 * @author Jacques-Olivier Lachaud (\c jacques-olivier.lachaud@univ-savoie.fr )
20 * Laboratory of Mathematics (CNRS, UMR 5127), University of Savoie, France
24 * Implementation of inline methods defined in SetOfSurfels.h
26 * This file is part of the DGtal library.
30//////////////////////////////////////////////////////////////////////////////
33#include "DGtal/topology/helpers/Surfaces.h"
34//////////////////////////////////////////////////////////////////////////////
36///////////////////////////////////////////////////////////////////////////////
37// IMPLEMENTATION of inline methods.
38///////////////////////////////////////////////////////////////////////////////
40//-----------------------------------------------------------------------------
41template <typename TKSpace, typename TSurfelSet>
43DGtal::SetOfSurfels<TKSpace,TSurfelSet>::Tracker
46//-----------------------------------------------------------------------------
47template <typename TKSpace, typename TSurfelSet>
49DGtal::SetOfSurfels<TKSpace,TSurfelSet>::Tracker
50::Tracker( ConstAlias<DigitalSurfaceContainer> aSurface,
52 : mySurface( aSurface ), myNeighborhood()
54 myNeighborhood.init( & surface().space(),
55 & surface().surfelAdjacency(),
58//-----------------------------------------------------------------------------
59template <typename TKSpace, typename TSurfelSet>
61DGtal::SetOfSurfels<TKSpace,TSurfelSet>::Tracker
62::Tracker( const Tracker & other )
63 : mySurface( other.mySurface ), myNeighborhood( other.myNeighborhood )
66//-----------------------------------------------------------------------------
67template <typename TKSpace, typename TSurfelSet>
69const typename DGtal::SetOfSurfels<TKSpace,TSurfelSet>::Tracker::DigitalSurfaceContainer &
70DGtal::SetOfSurfels<TKSpace,TSurfelSet>::Tracker
75//-----------------------------------------------------------------------------
76template <typename TKSpace, typename TSurfelSet>
78const typename DGtal::SetOfSurfels<TKSpace,TSurfelSet>::Tracker::Surfel &
79DGtal::SetOfSurfels<TKSpace,TSurfelSet>::Tracker::current() const
81 return myNeighborhood.surfel();
83//-----------------------------------------------------------------------------
84template <typename TKSpace, typename TSurfelSet>
87DGtal::SetOfSurfels<TKSpace,TSurfelSet>::Tracker
90 return myNeighborhood.orthDir();
92//-----------------------------------------------------------------------------
93template <typename TKSpace, typename TSurfelSet>
96DGtal::SetOfSurfels<TKSpace,TSurfelSet>::Tracker
97::move( const Surfel & s )
99 ASSERT( surface().isInside( s ) );
100 myNeighborhood.setSurfel( s );
102//-----------------------------------------------------------------------------
103template <typename TKSpace, typename TSurfelSet>
106DGtal::SetOfSurfels<TKSpace,TSurfelSet>::Tracker
107::adjacent( Surfel & s, Dimension d, bool pos ) const
109 return static_cast<uint8_t>
110 ( myNeighborhood.getAdjacentOnSurfelPredicate( s, surface().surfelPredicate(), d, pos ) );
113///////////////////////////////////////////////////////////////////////////////
114// ----------------------- Standard services ------------------------------
116//-----------------------------------------------------------------------------
117template <typename TKSpace, typename TSurfelSet>
119DGtal::SetOfSurfels<TKSpace,TSurfelSet>::~SetOfSurfels()
122//-----------------------------------------------------------------------------
123template <typename TKSpace, typename TSurfelSet>
125DGtal::SetOfSurfels<TKSpace,TSurfelSet>::SetOfSurfels
126( const SetOfSurfels & other )
127 : myKSpace( other.myKSpace ),
128 mySurfelSet( other.mySurfelSet ),
129 mySurfelPredicate( other.mySurfelPredicate ),
130 mySurfelAdjacency( other.mySurfelAdjacency )
133//-----------------------------------------------------------------------------
134template <typename TKSpace, typename TSurfelSet>
136DGtal::SetOfSurfels<TKSpace,TSurfelSet>::SetOfSurfels
137( ConstAlias<KSpace> aKSpace,
138 const Adjacency & adj,
139 SurfelSet aSetOfSurfels )
140 : myKSpace( aKSpace ), mySurfelSet( aSetOfSurfels ),
141 mySurfelPredicate( mySurfelSet ),
142 mySurfelAdjacency( adj )
145//-----------------------------------------------------------------------------
146template <typename TKSpace, typename TSurfelSet>
148typename DGtal::SetOfSurfels<TKSpace,TSurfelSet>::SurfelSet &
149DGtal::SetOfSurfels<TKSpace,TSurfelSet>::surfelSet()
153//-----------------------------------------------------------------------------
154template <typename TKSpace, typename TSurfelSet>
157typename DGtal::SetOfSurfels<TKSpace,TSurfelSet>::SurfelSet &
158DGtal::SetOfSurfels<TKSpace,TSurfelSet>::surfelSet() const
162//-----------------------------------------------------------------------------
163template <typename TKSpace, typename TSurfelSet>
166typename DGtal::SetOfSurfels<TKSpace,TSurfelSet>::Adjacency &
167DGtal::SetOfSurfels<TKSpace,TSurfelSet>::surfelAdjacency() const
169 return mySurfelAdjacency;
171//-----------------------------------------------------------------------------
172template <typename TKSpace, typename TSurfelSet>
174typename DGtal::SetOfSurfels<TKSpace,TSurfelSet>::Adjacency &
175DGtal::SetOfSurfels<TKSpace,TSurfelSet>::surfelAdjacency()
177 return mySurfelAdjacency;
179//-----------------------------------------------------------------------------
180template <typename TKSpace, typename TSurfelSet>
183typename DGtal::SetOfSurfels<TKSpace,TSurfelSet>::SurfelPredicate &
184DGtal::SetOfSurfels<TKSpace,TSurfelSet>::surfelPredicate() const
186 return mySurfelPredicate;
189//-----------------------------------------------------------------------------
190// --------- CDigitalSurfaceContainer realization -------------------------
191//-----------------------------------------------------------------------------
192template <typename TKSpace, typename TSurfelSet>
194const typename DGtal::SetOfSurfels<TKSpace,TSurfelSet>::KSpace &
195DGtal::SetOfSurfels<TKSpace,TSurfelSet>::space() const
199//-----------------------------------------------------------------------------
200template <typename TKSpace, typename TSurfelSet>
203DGtal::SetOfSurfels<TKSpace,TSurfelSet>::isInside
204( const Surfel & s ) const
206 return mySurfelPredicate( s );
208//-----------------------------------------------------------------------------
209template <typename TKSpace, typename TSurfelSet>
211typename DGtal::SetOfSurfels<TKSpace,TSurfelSet>::SurfelConstIterator
212DGtal::SetOfSurfels<TKSpace,TSurfelSet>::begin() const
214 return mySurfelSet.begin();
216//-----------------------------------------------------------------------------
217template <typename TKSpace, typename TSurfelSet>
219typename DGtal::SetOfSurfels<TKSpace,TSurfelSet>::SurfelConstIterator
220DGtal::SetOfSurfels<TKSpace,TSurfelSet>::end() const
222 return mySurfelSet.end();
224//-----------------------------------------------------------------------------
225template <typename TKSpace, typename TSurfelSet>
227typename DGtal::SetOfSurfels<TKSpace,TSurfelSet>::Size
228DGtal::SetOfSurfels<TKSpace,TSurfelSet>::nbSurfels() const
230 return (unsigned int)mySurfelSet.size();
232//-----------------------------------------------------------------------------
233template <typename TKSpace, typename TSurfelSet>
236DGtal::SetOfSurfels<TKSpace,TSurfelSet>::empty() const
238 return mySurfelSet.empty();
240//-----------------------------------------------------------------------------
241template <typename TKSpace, typename TSurfelSet>
243typename DGtal::SetOfSurfels<TKSpace,TSurfelSet>::DigitalSurfaceTracker*
244DGtal::SetOfSurfels<TKSpace,TSurfelSet>::newTracker
245( const Surfel & s ) const
247 return new Tracker( *this, s );
249//-----------------------------------------------------------------------------
250template <typename TKSpace, typename TSurfelSet>
253DGtal::SetOfSurfels<TKSpace,TSurfelSet>::connectedness() const
258// ------------------------- Hidden services ------------------------------
260///////////////////////////////////////////////////////////////////////////////
261// Interface - public :
264 * Writes/Displays the object on an output stream.
265 * @param out the output stream where the object is written.
267template <typename TKSpace, typename TSurfelSet>
270DGtal::SetOfSurfels<TKSpace,TSurfelSet>::selfDisplay ( std::ostream & out ) const
272 out << "[SetOfSurfels]";
276 * Checks the validity/consistency of the object.
277 * @return 'true' if the object is valid, 'false' otherwise.
279template <typename TKSpace, typename TSurfelSet>
282DGtal::SetOfSurfels<TKSpace,TSurfelSet>::isValid() const
289///////////////////////////////////////////////////////////////////////////////
290// Implementation of inline functions //
292template <typename TKSpace, typename TSurfelSet>
295DGtal::operator<< ( std::ostream & out,
296 const SetOfSurfels<TKSpace,TSurfelSet> & object )
298 object.selfDisplay( out );
303///////////////////////////////////////////////////////////////////////////////