DGtal 1.4.0
Loading...
Searching...
No Matches
SetOfSurfels.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 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
21 *
22 * @date 2011/11/27
23 *
24 * Implementation of inline methods defined in SetOfSurfels.h
25 *
26 * This file is part of the DGtal library.
27 */
28
29
30//////////////////////////////////////////////////////////////////////////////
31#include <cstdlib>
32#include <iterator>
33#include "DGtal/topology/helpers/Surfaces.h"
34//////////////////////////////////////////////////////////////////////////////
35
36///////////////////////////////////////////////////////////////////////////////
37// IMPLEMENTATION of inline methods.
38///////////////////////////////////////////////////////////////////////////////
39
40//-----------------------------------------------------------------------------
41template <typename TKSpace, typename TSurfelSet>
42inline
43DGtal::SetOfSurfels<TKSpace,TSurfelSet>::Tracker
44::~Tracker()
45{}
46//-----------------------------------------------------------------------------
47template <typename TKSpace, typename TSurfelSet>
48inline
49DGtal::SetOfSurfels<TKSpace,TSurfelSet>::Tracker
50::Tracker( ConstAlias<DigitalSurfaceContainer> aSurface,
51 const Surfel & s )
52 : mySurface( aSurface ), myNeighborhood()
53{
54 myNeighborhood.init( & surface().space(),
55 & surface().surfelAdjacency(),
56 s );
57}
58//-----------------------------------------------------------------------------
59template <typename TKSpace, typename TSurfelSet>
60inline
61DGtal::SetOfSurfels<TKSpace,TSurfelSet>::Tracker
62::Tracker( const Tracker & other )
63 : mySurface( other.mySurface ), myNeighborhood( other.myNeighborhood )
64{
65}
66//-----------------------------------------------------------------------------
67template <typename TKSpace, typename TSurfelSet>
68inline
69const typename DGtal::SetOfSurfels<TKSpace,TSurfelSet>::Tracker::DigitalSurfaceContainer &
70DGtal::SetOfSurfels<TKSpace,TSurfelSet>::Tracker
71::surface() const
72{
73 return mySurface;
74}
75//-----------------------------------------------------------------------------
76template <typename TKSpace, typename TSurfelSet>
77inline
78const typename DGtal::SetOfSurfels<TKSpace,TSurfelSet>::Tracker::Surfel &
79DGtal::SetOfSurfels<TKSpace,TSurfelSet>::Tracker::current() const
80{
81 return myNeighborhood.surfel();
82}
83//-----------------------------------------------------------------------------
84template <typename TKSpace, typename TSurfelSet>
85inline
86DGtal::Dimension
87DGtal::SetOfSurfels<TKSpace,TSurfelSet>::Tracker
88::orthDir() const
89{
90 return myNeighborhood.orthDir();
91}
92//-----------------------------------------------------------------------------
93template <typename TKSpace, typename TSurfelSet>
94inline
95void
96DGtal::SetOfSurfels<TKSpace,TSurfelSet>::Tracker
97::move( const Surfel & s )
98{
99 ASSERT( surface().isInside( s ) );
100 myNeighborhood.setSurfel( s );
101}
102//-----------------------------------------------------------------------------
103template <typename TKSpace, typename TSurfelSet>
104inline
105DGtal::uint8_t
106DGtal::SetOfSurfels<TKSpace,TSurfelSet>::Tracker
107::adjacent( Surfel & s, Dimension d, bool pos ) const
108{
109 return static_cast<uint8_t>
110 ( myNeighborhood.getAdjacentOnSurfelPredicate( s, surface().surfelPredicate(), d, pos ) );
111}
112
113///////////////////////////////////////////////////////////////////////////////
114// ----------------------- Standard services ------------------------------
115
116//-----------------------------------------------------------------------------
117template <typename TKSpace, typename TSurfelSet>
118inline
119DGtal::SetOfSurfels<TKSpace,TSurfelSet>::~SetOfSurfels()
120{
121}
122//-----------------------------------------------------------------------------
123template <typename TKSpace, typename TSurfelSet>
124inline
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 )
131{
132}
133//-----------------------------------------------------------------------------
134template <typename TKSpace, typename TSurfelSet>
135inline
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 )
143{
144}
145//-----------------------------------------------------------------------------
146template <typename TKSpace, typename TSurfelSet>
147inline
148typename DGtal::SetOfSurfels<TKSpace,TSurfelSet>::SurfelSet &
149DGtal::SetOfSurfels<TKSpace,TSurfelSet>::surfelSet()
150{
151 return mySurfelSet;
152}
153//-----------------------------------------------------------------------------
154template <typename TKSpace, typename TSurfelSet>
155inline
156const
157typename DGtal::SetOfSurfels<TKSpace,TSurfelSet>::SurfelSet &
158DGtal::SetOfSurfels<TKSpace,TSurfelSet>::surfelSet() const
159{
160 return mySurfelSet;
161}
162//-----------------------------------------------------------------------------
163template <typename TKSpace, typename TSurfelSet>
164inline
165const
166typename DGtal::SetOfSurfels<TKSpace,TSurfelSet>::Adjacency &
167DGtal::SetOfSurfels<TKSpace,TSurfelSet>::surfelAdjacency() const
168{
169 return mySurfelAdjacency;
170}
171//-----------------------------------------------------------------------------
172template <typename TKSpace, typename TSurfelSet>
173inline
174typename DGtal::SetOfSurfels<TKSpace,TSurfelSet>::Adjacency &
175DGtal::SetOfSurfels<TKSpace,TSurfelSet>::surfelAdjacency()
176{
177 return mySurfelAdjacency;
178}
179//-----------------------------------------------------------------------------
180template <typename TKSpace, typename TSurfelSet>
181inline
182const
183typename DGtal::SetOfSurfels<TKSpace,TSurfelSet>::SurfelPredicate &
184DGtal::SetOfSurfels<TKSpace,TSurfelSet>::surfelPredicate() const
185{
186 return mySurfelPredicate;
187}
188
189//-----------------------------------------------------------------------------
190// --------- CDigitalSurfaceContainer realization -------------------------
191//-----------------------------------------------------------------------------
192template <typename TKSpace, typename TSurfelSet>
193inline
194const typename DGtal::SetOfSurfels<TKSpace,TSurfelSet>::KSpace &
195DGtal::SetOfSurfels<TKSpace,TSurfelSet>::space() const
196{
197 return myKSpace;
198}
199//-----------------------------------------------------------------------------
200template <typename TKSpace, typename TSurfelSet>
201inline
202bool
203DGtal::SetOfSurfels<TKSpace,TSurfelSet>::isInside
204( const Surfel & s ) const
205{
206 return mySurfelPredicate( s );
207}
208//-----------------------------------------------------------------------------
209template <typename TKSpace, typename TSurfelSet>
210inline
211typename DGtal::SetOfSurfels<TKSpace,TSurfelSet>::SurfelConstIterator
212DGtal::SetOfSurfels<TKSpace,TSurfelSet>::begin() const
213{
214 return mySurfelSet.begin();
215}
216//-----------------------------------------------------------------------------
217template <typename TKSpace, typename TSurfelSet>
218inline
219typename DGtal::SetOfSurfels<TKSpace,TSurfelSet>::SurfelConstIterator
220DGtal::SetOfSurfels<TKSpace,TSurfelSet>::end() const
221{
222 return mySurfelSet.end();
223}
224//-----------------------------------------------------------------------------
225template <typename TKSpace, typename TSurfelSet>
226inline
227typename DGtal::SetOfSurfels<TKSpace,TSurfelSet>::Size
228DGtal::SetOfSurfels<TKSpace,TSurfelSet>::nbSurfels() const
229{
230 return (unsigned int)mySurfelSet.size();
231}
232//-----------------------------------------------------------------------------
233template <typename TKSpace, typename TSurfelSet>
234inline
235bool
236DGtal::SetOfSurfels<TKSpace,TSurfelSet>::empty() const
237{
238 return mySurfelSet.empty();
239}
240//-----------------------------------------------------------------------------
241template <typename TKSpace, typename TSurfelSet>
242inline
243typename DGtal::SetOfSurfels<TKSpace,TSurfelSet>::DigitalSurfaceTracker*
244DGtal::SetOfSurfels<TKSpace,TSurfelSet>::newTracker
245( const Surfel & s ) const
246{
247 return new Tracker( *this, s );
248}
249//-----------------------------------------------------------------------------
250template <typename TKSpace, typename TSurfelSet>
251inline
252DGtal::Connectedness
253DGtal::SetOfSurfels<TKSpace,TSurfelSet>::connectedness() const
254{
255 return UNKNOWN;
256}
257
258// ------------------------- Hidden services ------------------------------
259
260///////////////////////////////////////////////////////////////////////////////
261// Interface - public :
262
263/**
264 * Writes/Displays the object on an output stream.
265 * @param out the output stream where the object is written.
266 */
267template <typename TKSpace, typename TSurfelSet>
268inline
269void
270DGtal::SetOfSurfels<TKSpace,TSurfelSet>::selfDisplay ( std::ostream & out ) const
271{
272 out << "[SetOfSurfels]";
273}
274
275/**
276 * Checks the validity/consistency of the object.
277 * @return 'true' if the object is valid, 'false' otherwise.
278 */
279template <typename TKSpace, typename TSurfelSet>
280inline
281bool
282DGtal::SetOfSurfels<TKSpace,TSurfelSet>::isValid() const
283{
284 return true;
285}
286
287
288
289///////////////////////////////////////////////////////////////////////////////
290// Implementation of inline functions //
291
292template <typename TKSpace, typename TSurfelSet>
293inline
294std::ostream&
295DGtal::operator<< ( std::ostream & out,
296 const SetOfSurfels<TKSpace,TSurfelSet> & object )
297{
298 object.selfDisplay( out );
299 return out;
300}
301
302// //
303///////////////////////////////////////////////////////////////////////////////
304
305