DGtal  1.3.beta
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:
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)
DGtal::FunctorOnCells::space
const KSpace & space() const
Definition: FunctorOnCells.h:155
DGtal::ConstAlias
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:186
DGtal::NumberTraits
Aim: The traits class for all models of Cinteger.
Definition: NumberTraits.h:562
DGtal::FunctorOnCells::Point
FunctorOnPoints::Point Point
Definition: FunctorOnCells.h:79
DGtal::FunctorOnCells::FunctorOnCells
FunctorOnCells(Alias< FunctorOnPoints > functor, ConstAlias< KSpace > kspace)
Definition: FunctorOnCells.h:92
DGtal::FunctorOnCells::operator=
FunctorOnCells & operator=(const FunctorOnCells &other)
Definition: FunctorOnCells.h:142
DGtal::FunctorOnCells::FunctorOnPoints
TFunctorOnPoints FunctorOnPoints
Definition: FunctorOnCells.h:76
DGtal::FunctorOnCells::Cell
KSpace::SCell Cell
Definition: FunctorOnCells.h:81
DGtal::SignedKhalimskyCell
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
Definition: KhalimskySpaceND.h:208
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
DGtal::FunctorOnCells::FunctorOnCells
FunctorOnCells()
DGtal::FunctorOnCells::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::FunctorOnCells::FunctorOnCells
FunctorOnCells(const FunctorOnCells &other)
Definition: FunctorOnCells.h:101
DGtal::FunctorOnCells
Aim: Convert a functor on Digital Point to a Functor on Khalimsky Cell.
Definition: FunctorOnCells.h:70
DGtal::FunctorOnCells::isValid
bool isValid() const
DGtal::FunctorOnCells::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CPointFunctor< FunctorOnPoints >))
DGtal::FunctorOnCells::f
FunctorOnPoints * f
Const pointor on Functor on Points. Used on operator() to get the return value.
Definition: FunctorOnCells.h:165
DGtal::FunctorOnCells::Self
FunctorOnCells< TFunctorOnPoints, TKSpace > Self
Definition: FunctorOnCells.h:75
DGtal::concepts::CPointFunctor
Aim: Defines a functor on points.
Definition: CPointFunctor.h:88
DGtal::Alias
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: Alias.h:182
DGtal::FunctorOnCells::KSpace
TKSpace KSpace
Definition: FunctorOnCells.h:77
DGtal::FunctorOnCells::Value
FunctorOnPoints::Value Value
Definition: FunctorOnCells.h:80
DGtal::FunctorOnCells::Quantity
int Quantity
Definition: FunctorOnCells.h:78
Point
MyPointD Point
Definition: testClone2.cpp:383
DGtal::FunctorOnCells::operator()
Quantity operator()(const Cell &aCell) const
Definition: FunctorOnCells.h:120
DGtal::FunctorOnCells::myKSpace
const KSpace * myKSpace
Const pointor on Khalimsky Space. Used to convert Cell -> Point.
Definition: FunctorOnCells.h:168
DGtal::FunctorOnCells::~FunctorOnCells
~FunctorOnCells()
Value
double Value
Definition: testSimpleRandomAccessRangeFromPoint.cpp:38