DGtal 1.4.0
Loading...
Searching...
No Matches
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)
38#define FunctorOnCells_RECURSES
39
40#if !defined FunctorOnCells_h
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
56namespace 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
102 : f( other.f ), myKSpace( other.myKSpace )
103 {}
104
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
169
170 // ------------------------- Hidden services ------------------------------
171 protected:
172
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)
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition Alias.h:183
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition ConstAlias.h:187
Aim: Convert a functor on Digital Point to a Functor on Khalimsky Cell.
FunctorOnCells(const FunctorOnCells &other)
BOOST_CONCEPT_ASSERT((concepts::CPointFunctor< FunctorOnPoints >))
FunctorOnCells & operator=(const FunctorOnCells &other)
void selfDisplay(std::ostream &out) const
FunctorOnPoints::Value Value
const KSpace & space() const
FunctorOnPoints::Point Point
FunctorOnCells(Alias< FunctorOnPoints > functor, ConstAlias< KSpace > kspace)
Quantity operator()(const Cell &aCell) const
FunctorOnPoints * f
Const pointor on Functor on Points. Used on operator() to get the return value.
TFunctorOnPoints FunctorOnPoints
FunctorOnCells< TFunctorOnPoints, TKSpace > Self
const KSpace * myKSpace
Const pointor on Khalimsky Space. Used to convert Cell -> Point.
bool isValid() const
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
Aim: The traits class for all models of Cinteger.
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
Aim: Defines a functor on points.