DGtal  0.9.2
FunctorOnCells.h
1 
17 #pragma once
18 
34 #if defined(FunctorOnCells_RECURSES)
35 #error Recursive header files inclusion detected in FunctorOnCells.h
36 #else // defined(FunctorOnCells_RECURSES)
37 
38 #define FunctorOnCells_RECURSES
39 
40 #if !defined FunctorOnCells_h
41 
42 #define FunctorOnCells_h
43 
45 // Inclusions
46 #include <iostream>
47 #include "DGtal/base/Common.h"
48 #include "DGtal/base/Alias.h"
49 #include "DGtal/base/ConstAlias.h"
50 
51 #include "DGtal/kernel/CSpace.h"
52 #include "DGtal/kernel/CPointFunctor.h"
53 
55 
56 namespace DGtal
57 {
58 
60  // template class FunctorOnCells
69  template <typename TFunctorOnPoints, typename TKSpace>
71  {
72  // ----------------------- Standard services ------------------------------
73  public:
74 
76  typedef TFunctorOnPoints FunctorOnPoints;
77  typedef TKSpace KSpace;
78  typedef int Quantity;
79  typedef typename FunctorOnPoints::Point Point;
80  typedef typename FunctorOnPoints::Value Value;
81  typedef typename KSpace::SCell Cell;
82 
84  //BOOST_CONCEPT_ASSERT(( CSpace< KSpace > ));
85 
93  : f(&functor),
94  myKSpace(&kspace)
95  {}
96 
101  FunctorOnCells ( const FunctorOnCells & other )
102  : f( other.f ), myKSpace( other.myKSpace )
103  {}
104 
108  ~FunctorOnCells();
109 
110 
111  // ----------------------- Interface --------------------------------------
112  public:
120  Quantity operator()( const Cell & aCell ) const
121  {
122  return ( f->operator()( myKSpace->sCoords(aCell) ) == NumberTraits< Value >::ZERO ) ? NumberTraits<Quantity>::ZERO : NumberTraits<Quantity>::ONE;
123  }
124 
129  void selfDisplay ( std::ostream & out ) const;
130 
135  bool isValid() const;
136 
143  {
144  if( this != &other )
145  {
146  f = other.f;
147  myKSpace = other.myKSpace;
148  }
149  return *this;
150  }
151 
155  const KSpace& space() const
156  {
157  return *myKSpace;
158  }
159 
160  // ------------------------- Protected Datas ------------------------------
161  private:
162  // ------------------------- Private Datas --------------------------------
163  private:
165  FunctorOnPoints * f;
166 
168  const KSpace * myKSpace;
169 
170  // ------------------------- Hidden services ------------------------------
171  protected:
172 
177  FunctorOnCells();
178 
179  private:
180 
181  // ------------------------- Internals ------------------------------------
182  private:
183 
184  }; // end of class FunctorOnCells
185 
186 
193  template <typename TF, typename TKS>
194  std::ostream&
195  operator<< ( std::ostream & out, const FunctorOnCells<TF, TKS> & object );
196 
197 } // namespace DGtal
198 
199 
201 // Includes inline functions.
202 #include "DGtal/geometry/surfaces/FunctorOnCells.ih"
203 
204 // //
206 
207 #endif // !defined FunctorOnCells_h
208 
209 #undef FunctorOnCells_RECURSES
210 #endif // else defined(FunctorOnCells_RECURSES)
const KSpace & space() const
const KSpace * myKSpace
Const pointor on Khalimsky Space. Used to convert Cell -> Point.
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:186
bool isValid() const
FunctorOnPoints::Point Point
void selfDisplay(std::ostream &out) const
TFunctorOnPoints FunctorOnPoints
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: Alias.h:182
FunctorOnCells & operator=(const FunctorOnCells &other)
Quantity operator()(const Cell &aCell) const
FunctorOnCells(Alias< FunctorOnPoints > functor, ConstAlias< KSpace > kspace)
Aim: Convert a functor on Digital Point to a Functor on Khalimsky Cell.
FunctorOnCells(const FunctorOnCells &other)
Aim: The traits class for all models of Cinteger.
Definition: NumberTraits.h:69
BOOST_CONCEPT_ASSERT((concepts::CPointFunctor< FunctorOnPoints >))
DGtal is the top-level namespace which contains all DGtal functions and types.
FunctorOnPoints * f
Const pointor on Functor on Points. Used on operator() to get the return value.
FunctorOnPoints::Value Value
Aim: Defines a functor on points.
Definition: CPointFunctor.h:88
FunctorOnCells< TFunctorOnPoints, TKSpace > Self