DGtal  1.5.beta
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)
35 #define UmbrellaComputer_RECURSES
36 
37 #if !defined UmbrellaComputer_h
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
85  template <typename TDigitalSurfaceTracker>
87  {
88  // Concept checks
90 
91  // ----------------------- public types ------------------------------
92  public:
93  typedef TDigitalSurfaceTracker DigitalSurfaceTracker;
94  typedef typename DigitalSurfaceTracker::DigitalSurfaceContainer DigitalSurfaceContainer;
98  typedef typename KSpace::SCell SCell;
99 
104  struct State
105  {
111  bool epsilon;
114  inline State(){}
115  inline State( const Surfel & _surfel,
116  Dimension _k, bool _epsilon, Dimension _j )
117  : surfel( _surfel ), k( _k ), epsilon( _epsilon ), j( _j )
118  {}
119  inline bool operator==( const State & other ) const
120  {
121  return ( surfel == other.surfel )
122  && ( k == other.k )
123  && ( epsilon == other.epsilon )
124  && ( j == other.j );
125  }
126  inline bool operator<( const State & other ) const
127  {
128  return ( surfel < other.surfel )
129  || ( ( surfel == other.surfel )
130  && ( ( k < other.k )
131  || ( ( k == other.k )
132  && ( ( epsilon < other.epsilon )
133  || ( ( epsilon == other.epsilon)
134  && ( j < other.j ) ) ) ) ) );
135  }
136  };
137 
138  // ----------------------- Standard services ------------------------------
139  public:
140 
143 
146 
152 
159  operator=( const UmbrellaComputer & other );
160 
177  void init( const DigitalSurfaceTracker & tracker,
178  Dimension k, bool epsilon, Dimension j );
179 
188  void setState( const State & aState );
189 
196  void getState( State & aState ) const;
197 
199  const State & state() const;
200 
202  const KSpace & space() const;
203 
204  // ----------------------- Accessor services ------------------------------
205  public:
206 
208  const Surfel & surfel() const;
209 
211  SCell separator() const;
212 
214  SCell pivot() const;
215 
218 
221 
223  bool trackOrientation() const;
224 
227 
229  bool separatorOrientation() const;
230 
231  // ----------------------- Pivoting services ------------------------------
232  public:
233 
240  unsigned int next();
241 
248  unsigned int previous();
249 
258  bool adjacent();
259 
260 
261 
262  // ----------------------- Interface --------------------------------------
263  public:
264 
269  void selfDisplay ( std::ostream & out ) const;
270 
275  bool isValid() const;
276 
277  // ------------------------- Protected Datas ------------------------------
278  private:
279  // ------------------------- Private Datas --------------------------------
280  private:
281 
286 
287  // ------------------------- Hidden services ------------------------------
288  protected:
289 
290  // ------------------------- Internals ------------------------------------
291  private:
292 
293  }; // end of class UmbrellaComputer
294 
295 
302  template <typename TDigitalSurfaceTracker>
303  std::ostream&
304  operator<< ( std::ostream & out, const UmbrellaComputer<TDigitalSurfaceTracker> & object );
305 
306 } // namespace DGtal
307 
308 
310 // Includes inline functions.
311 #include "DGtal/topology/UmbrellaComputer.ih"
312 
313 // //
315 
316 #endif // !defined UmbrellaComputer_h
317 
318 #undef UmbrellaComputer_RECURSES
319 #endif // else defined(UmbrellaComputer_RECURSES)
Aim: Useful for computing umbrellas on 'DigitalSurface's, ie set of n-1 cells around a n-3 cell.
const KSpace & space() const
Accessor to the digital space.
State myState
Current state for the umbrella.
Dimension orthDir() const
TDigitalSurfaceTracker DigitalSurfaceTracker
UmbrellaComputer & operator=(const UmbrellaComputer &other)
~UmbrellaComputer()
Destructor.
Dimension separatorDir() const
bool trackOrientation() const
DigitalSurfaceContainer::Surfel Surfel
void setState(const State &aState)
const Surfel & surfel() const
void getState(State &aState) const
const State & state() const
Accessor to current state.
DigitalSurfaceContainer::KSpace KSpace
DigitalSurfaceContainer::Size Size
UmbrellaComputer()
Constructor. The object is not valid.
Dimension trackDir() const
SCell separator() const
void init(const DigitalSurfaceTracker &tracker, Dimension k, bool epsilon, Dimension j)
unsigned int previous()
DigitalSurfaceTracker * myTracker
Tracker used to move on the digital surface.
DigitalSurfaceTracker::DigitalSurfaceContainer DigitalSurfaceContainer
UmbrellaComputer(const UmbrellaComputer &other)
bool separatorOrientation() const
BOOST_CONCEPT_ASSERT((concepts::CDigitalSurfaceTracker< TDigitalSurfaceTracker >))
void selfDisplay(std::ostream &out) const
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
DGtal::uint32_t Dimension
Definition: Common.h:136
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
Surfel surfel
Current surfel.
Dimension j
Track direction (j != k), j in sDirs(surfel).
State(const Surfel &_surfel, Dimension _k, bool _epsilon, Dimension _j)
Dimension k
Direction to find separator, k in sDirs(surfel).
bool operator<(const State &other) const
bool epsilon
Orientation to find separator (true = positively along k-axis)
bool operator==(const State &other) const
HalfEdgeDataStructure::Size Size