DGtal  0.9.2
UmbrellaComputer.h
1 
17 #pragma once
18 
31 #if defined(UmbrellaComputer_RECURSES)
32 #error Recursive header files inclusion detected in UmbrellaComputer.h
33 #else // defined(UmbrellaComputer_RECURSES)
34 
35 #define UmbrellaComputer_RECURSES
36 
37 #if !defined UmbrellaComputer_h
38 
39 #define UmbrellaComputer_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
45 #include "DGtal/topology/CDigitalSurfaceTracker.h"
47 
48 namespace DGtal
49 {
50 
52  // template class UmbrellaComputer
86  template <typename TDigitalSurfaceTracker>
88  {
89  // Concept checks
91 
92  // ----------------------- public types ------------------------------
93  public:
94  typedef TDigitalSurfaceTracker DigitalSurfaceTracker;
95  typedef typename DigitalSurfaceTracker::DigitalSurfaceContainer DigitalSurfaceContainer;
96  typedef typename DigitalSurfaceContainer::KSpace KSpace;
97  typedef typename DigitalSurfaceContainer::Surfel Surfel;
98  typedef typename DigitalSurfaceContainer::Size Size;
99  typedef typename KSpace::SCell SCell;
100 
105  struct State
106  {
108  Surfel surfel;
112  bool epsilon;
115  inline State(){}
116  inline State( const Surfel & _surfel,
117  Dimension _k, bool _epsilon, Dimension _j )
118  : surfel( _surfel ), k( _k ), epsilon( _epsilon ), j( _j )
119  {}
120  inline bool operator==( const State & other ) const
121  {
122  return ( surfel == other.surfel )
123  && ( k == other.k )
124  && ( epsilon == other.epsilon )
125  && ( j == other.j );
126  }
127  inline bool operator<( const State & other ) const
128  {
129  return ( surfel < other.surfel )
130  || ( ( surfel == other.surfel )
131  && ( ( k < other.k )
132  || ( ( k == other.k )
133  && ( ( epsilon < other.epsilon )
134  || ( ( epsilon == other.epsilon)
135  && ( j < other.j ) ) ) ) ) );
136  }
137  };
138 
139  // ----------------------- Standard services ------------------------------
140  public:
141 
144 
147 
152  UmbrellaComputer( const UmbrellaComputer & other );
153 
160  operator=( const UmbrellaComputer & other );
161 
178  void init( const DigitalSurfaceTracker & tracker,
179  Dimension k, bool epsilon, Dimension j );
180 
189  void setState( const State & aState );
190 
197  void getState( State & aState ) const;
198 
200  const State & state() const;
201 
203  const KSpace & space() const;
204 
205  // ----------------------- Accessor services ------------------------------
206  public:
207 
209  const Surfel & surfel() const;
210 
212  SCell separator() const;
213 
215  SCell pivot() const;
216 
218  Dimension orthDir() const;
219 
221  Dimension trackDir() const;
222 
224  bool trackOrientation() const;
225 
227  Dimension separatorDir() const;
228 
230  bool separatorOrientation() const;
231 
232  // ----------------------- Pivoting services ------------------------------
233  public:
234 
241  unsigned int next();
242 
249  unsigned int previous();
250 
259  bool adjacent();
260 
261 
262 
263  // ----------------------- Interface --------------------------------------
264  public:
265 
270  void selfDisplay ( std::ostream & out ) const;
271 
276  bool isValid() const;
277 
278  // ------------------------- Protected Datas ------------------------------
279  private:
280  // ------------------------- Private Datas --------------------------------
281  private:
282 
284  DigitalSurfaceTracker* myTracker;
286  State myState;
287 
288  // ------------------------- Hidden services ------------------------------
289  protected:
290 
291  // ------------------------- Internals ------------------------------------
292  private:
293 
294  }; // end of class UmbrellaComputer
295 
296 
303  template <typename TDigitalSurfaceTracker>
304  std::ostream&
305  operator<< ( std::ostream & out, const UmbrellaComputer<TDigitalSurfaceTracker> & object );
306 
307 } // namespace DGtal
308 
309 
311 // Includes inline functions.
312 #include "DGtal/topology/UmbrellaComputer.ih"
313 
314 // //
316 
317 #endif // !defined UmbrellaComputer_h
318 
319 #undef UmbrellaComputer_RECURSES
320 #endif // else defined(UmbrellaComputer_RECURSES)
DigitalSurfaceContainer::Size Size
DigitalSurfaceTracker * myTracker
Tracker used to move on the digital surface.
SCell separator() const
TDigitalSurfaceTracker DigitalSurfaceTracker
DGtal::uint32_t Dimension
Definition: Common.h:113
Dimension trackDir() const
bool separatorOrientation() const
bool epsilon
Orientation to find separator (true = positively along k-axis)
void setState(const State &aState)
void init(const DigitalSurfaceTracker &tracker, Dimension k, bool epsilon, Dimension j)
bool operator<(const State &other) const
SCell pivot() const
unsigned int previous()
State(const Surfel &_surfel, Dimension _k, bool _epsilon, Dimension _j)
State myState
Current state for the umbrella.
Dimension k
Direction to find separator, k in sDirs(surfel).
Dimension separatorDir() const
void getState(State &aState) const
DigitalSurfaceTracker::DigitalSurfaceContainer DigitalSurfaceContainer
bool operator==(const State &other) const
bool trackOrientation() const
DGtal is the top-level namespace which contains all DGtal functions and types.
Dimension j
Track direction (j != k), j in sDirs(surfel).
BOOST_CONCEPT_ASSERT((concepts::CDigitalSurfaceTracker< TDigitalSurfaceTracker >))
Aim: Useful for computing umbrellas on 'DigitalSurface's, ie set of n-1 cells around a n-3 cell...
UmbrellaComputer()
Constructor. The object is not valid.
const KSpace & space() const
Accessor to the digital space.
void selfDisplay(std::ostream &out) const
UmbrellaComputer & operator=(const UmbrellaComputer &other)
Surfel surfel
Current surfel.
~UmbrellaComputer()
Destructor.
const State & state() const
Accessor to current state.
DigitalSurfaceContainer::Surfel Surfel
const Surfel & surfel() const
DigitalSurfaceContainer::KSpace KSpace
Dimension orthDir() const