File failed to load: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.3/config/TeX-MML-AM_CHTML/MathJax.js
DGtal 2.0.0
SCellsFunctors.h
1
16
17#pragma once
18
31
32#if defined(SCellsFunctors_RECURSES)
33#error Recursive header files inclusion detected in SCellsFunctors.h
34#else // defined(SCellsFunctors_RECURSES)
36#define SCellsFunctors_RECURSES
37
38#if !defined SCellsFunctors_h
40#define SCellsFunctors_h
41
43// Inclusions
44#include <iostream>
45#include <iterator>
46#include "DGtal/base/Common.h"
47#include "DGtal/base/ConstAlias.h"
48#include "DGtal/base/BasicBoolFunctors.h"
49#include "DGtal/kernel/SpaceND.h"
51
52// @since 0.8 In DGtal::functors
53namespace DGtal {
54 namespace functors {
55
57 // template class SCellToPoint
73 template <typename KSpace>
75 {
76 public:
77 typedef typename KSpace::Point Output;
78 typedef typename KSpace::SCell Input;
79
80 private:
84 const KSpace* myK;
85
86 public:
87
91 SCellToPoint() : myK(NULL) { }
97
103 : myK(other.myK) { }
104
112 {
113 if (this != &other)
114 {
115 myK = other.myK;
116 }
117 return *this;
118 }
119
126 Output operator()(const Input& aSCell) const
127 {
128 ASSERT( myK );
129 Input s = aSCell;
130 while ( myK->sDim(s) > 0 )
131 {
132 Input tmp( myK->sIndirectIncident( s, *myK->sDirs( s ) ) );
133 ASSERT( myK->sDim(tmp) < myK->sDim(s) );
134 s = tmp;
135 }
136 return Output( myK->sCoords(s) );
137 }
138
139 }; // end of class SCellToPoint
140
142 // template class SCellToArrow
150 template <typename KSpace>
152 {
153
154 public:
155
156 typedef typename KSpace::Point Point;
157 typedef typename KSpace::Vector Vector;
158 typedef std::pair<Point,Vector> Output;
159 typedef typename KSpace::SCell Input;
160
161 private:
165 const KSpace* myK;
166
167 public:
168
172 SCellToArrow() : myK(NULL) { }
178
184 : myK(other.myK) { }
185
192 {
193 if (this != &other)
194 {
195 myK = other.myK;
196 }
197 return *this;
198 }
199
206 Output operator()(const Input& s) const
207 {
208 ASSERT( myK );
209 //starting point of the arrow
210 Input pointel( myK->sIndirectIncident( s, *myK->sDirs( s ) ) );
211 Point p( myK->sCoords( pointel ) ); //integer coordinates
212 //displacement vector
213 Vector v( myK->sKCoords( s ) - myK->sKCoords( pointel ) );
214 return Output(p,v);
215 }
216
217 }; // end of class SCellToArrow
218
220 // template class SCellToInnerPoint
233 template <typename KSpace>
235 {
236
237 public:
238
239 typedef typename KSpace::Point Output;
240 typedef typename KSpace::SCell Input;
241
242 private:
246 const KSpace* myK;
247
248 public:
249
253 SCellToInnerPoint() : myK(NULL) { }
259
265 : myK(other.myK) { }
266
273 {
274 if (this != &other)
275 {
276 myK = other.myK;
277 }
278 return *this;
279 }
280
286 Output operator()(const Input& s) const
287 {
288 ASSERT( myK );
289 Input pixel( myK->sDirectIncident( s, *myK->sOrthDirs( s ) ) );
290 return Output( myK->sCoords( pixel ) ); //integer coordinates
291 }
292
293 }; // end of class SCellToInnerPoint
294
296 // template class SCellToOuterPoint
309 template <typename KSpace>
311 {
312 public:
313
314 typedef typename KSpace::Point Output;
315 typedef typename KSpace::SCell Input;
316
317 private:
321 const KSpace* myK;
322
323 public:
324
328 SCellToOuterPoint() : myK(NULL) { }
334
340 : myK(other.myK) { }
341
348 {
349 if (this != &other)
350 {
351 myK = other.myK;
352 }
353 return *this;
354 }
355
361 Output operator()(const Input& s) const
362 {
363 ASSERT( myK );
364 Input pixel( myK->sIndirectIncident( s, *myK->sOrthDirs( s ) ) );
365 return Output( myK->sCoords( pixel ) ); //integer coordinates
366 }
367
368 }; // end of class SCellToOuterPoint
369
371 // template class SCellToIncidentPoints
384 template <typename KSpace>
386 {
387
388 public:
389
390 typedef typename KSpace::Point Point;
391 typedef std::pair<Point,Point> Output;
392 typedef typename KSpace::SCell Input;
393
394 private:
398 const KSpace* myK;
399
400 public:
401
411
417 : myK(other.myK) { }
418
425 {
426 if (this != &other)
427 {
428 myK = other.myK;
429 }
430 return *this;
431 }
432
438 Output operator()(const Input& s) const
439 {
440 ASSERT( myK );
441 //inner point
442 Input innerPixel( myK->sDirectIncident( s, *myK->sOrthDirs( s ) ) );
443 //outer point
444 Input outerPixel( myK->sIndirectIncident( s, *myK->sOrthDirs( s ) ) );
445
446 return Output(myK->sCoords( innerPixel ),myK->sCoords( outerPixel ));
447 }
448
449 }; // end of class SCellToIncidentPoints
450
452 // template class SCellToCode
460 template <typename KSpace>
462 {
463
465
466 public:
467
468 typedef typename KSpace::Point Point;
469 typedef typename KSpace::Vector Vector;
470 typedef char Output;
471
472 typedef typename KSpace::SCell Input;
473
474 private:
478 const KSpace* myK;
479
480 public:
481
485 SCellToCode() : myK(NULL) { }
491
497 : myK(other.myK) { }
498
505 {
506 if (this != &other)
507 {
508 myK = other.myK;
509 }
510 return *this;
511 }
512
518 Output operator()(const Input& s) const
519 {
520 ASSERT( myK );
521 //starting point of the arrow
522 Input pointel( myK->sIndirectIncident( s, *myK->sDirs( s ) ) );
523 Point p( myK->sCoords( pointel ) ); //integer coordinates
524 //displacement vector
525 Vector v( myK->sKCoords( s ) - myK->sKCoords( pointel ) );
526 if (v == Vector(1,0)) return '0';
527 else if (v == Vector(0,1)) return '1';
528 else if (v == Vector(-1,0)) return '2';
529 else if (v == Vector(0,-1)) return '3';
530 else return 'e'; //e for error!
531 }
532
533 }; // end of class SCellToCode
534
535} // namespace functors
536} // namespace DGtal
537
538
540// Includes inline functions.
541//#include "DGtal/kernel/SCellsFunctors.ih"
542
543// //
545
546#endif // !defined SCellsFunctors_h
547
548#undef SCellsFunctors_RECURSES
549#endif // else defined(SCellsFunctors_RECURSES)
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition ConstAlias.h:187
PointVector< dim, Integer > Point
SignedKhalimskyCell< dim, Integer > SCell
PointVector< dim, Integer > Vector
static const constexpr Dimension dimension
Output operator()(const Input &s) const
std::pair< Point, Vector > Output
SCellToArrow & operator=(const SCellToArrow &other)
SCellToArrow(ConstAlias< KSpace > aK)
SCellToArrow(const SCellToArrow &other)
SCellToCode(const SCellToCode &other)
Output operator()(const Input &s) const
BOOST_STATIC_ASSERT(KSpace::dimension==2)
SCellToCode(ConstAlias< KSpace > aK)
SCellToCode & operator=(const SCellToCode &other)
Output operator()(const Input &s) const
SCellToIncidentPoints(ConstAlias< KSpace > aK)
SCellToIncidentPoints & operator=(const SCellToIncidentPoints &other)
SCellToIncidentPoints(const SCellToIncidentPoints &other)
SCellToInnerPoint & operator=(const SCellToInnerPoint &other)
SCellToInnerPoint(const SCellToInnerPoint &other)
SCellToInnerPoint(ConstAlias< KSpace > aK)
Output operator()(const Input &s) const
SCellToOuterPoint(const SCellToOuterPoint &other)
Output operator()(const Input &s) const
SCellToOuterPoint & operator=(const SCellToOuterPoint &other)
SCellToOuterPoint(ConstAlias< KSpace > aK)
SCellToPoint(const SCellToPoint &other)
SCellToPoint & operator=(const SCellToPoint &other)
Output operator()(const Input &aSCell) const
SCellToPoint(ConstAlias< KSpace > aK)
functors namespace gathers all DGtal functors.
DGtal is the top-level namespace which contains all DGtal functions and types.