DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Modifier.h
1 
17 #pragma once
18 
31 #if defined(Modifier_RECURSES)
32 #error Recursive header files inclusion detected in Modifier.h
33 #else // defined(Modifier_RECURSES)
34 
35 #define Modifier_RECURSES
36 
37 #if !defined Modifier_h
38 
39 #define Modifier_h
40 
42 // Inclusions
43 #include <iostream>
44 #include <utility>
45 
46 
47 #include "DGtal/base/Common.h"
48 #include "DGtal/kernel/PointVector.h"
49 
51 
52 namespace DGtal
53 {
54 
55 namespace deprecated
56 {
57 
59  // template class Point3dTo2dXY
74  template <typename Coordinate>
76  {
77 
78  public:
79 
82 
83  public:
84 
90  Output get(const Input& p) const
91  {
92  Input tmp = p;
93  return Output(tmp.at(0),tmp.at(1));
94  }
95 
96  }; // end of class Point3dTo2dXY
97 
99  // template class Point3dTo2dXZ
114  template <typename Coordinate>
116  {
117 
118  public:
119 
122 
123  public:
124 
130  Output get(const Input& p) const
131  {
132  Input tmp = p;
133  return Output(tmp.at(0),tmp.at(2));
134  }
135 
136  }; // end of class Point3dTo2dXZ
137 
139  // template class Point3dTo2dYZ
154  template <typename Coordinate>
156  {
157 
158  public:
159 
162 
163  public:
164 
170  Output get(const Input& p) const
171  {
172  Input tmp = p;
173  return Output(tmp.at(1),tmp.at(2));
174  }
175 
176  }; // end of class Point3dTo2dYZ
177 
179  // template class SCellToPoint
194  template <typename KSpace>
196  {
197 
198  private:
199  KSpace myK;
200 
201  public:
202 
203  typedef typename KSpace::Point Output;
204  typedef typename KSpace::SCell Input;
205 
206  public:
207 
216  SCellToPoint(KSpace aK) : myK(aK) { }
217 
223  : myK(other.myK) { }
224 
231  {
232  if ( this != &other )
233  {
234  myK = other.myK;
235  }
236  return *this;
237  }
238 
244  Output get(const Input& s) const
245  {
246  return Output( myK.sCoords(s) );
247  }
248 
249  }; // end of class SCellToPoint
250 
252  // template class SCellToMidPoint
268  template <typename KSpace>
270  {
271 
272  public:
273 
275  typedef typename KSpace::SCell Input;
276 
277  private:
278  KSpace myK;
279 
280  public:
281 
290  SCellToMidPoint(KSpace aK) : myK(aK) { }
291 
297  : myK(other.myK) { }
298 
305  {
306  if ( this != &other )
307  {
308  myK = other.myK;
309  }
310  return *this;
311  }
312 
318  Output get(const Input& s) const
319  {
320  Output o( myK.sKCoords(s) );
321  o /= 2;
322  return o;
323  }
324 
325  }; // end of class SCellToMidPoint
326 
328  // template class SCellToArrow
336  template <typename KSpace>
338  {
339 
340  public:
341 
342  typedef typename KSpace::Point Point;
343  typedef typename KSpace::Vector Vector;
344  typedef std::pair<Point,Vector> Output;
345 
346  typedef typename KSpace::SCell Input;
347 
348  private:
349  KSpace myK;
350 
351  public:
352 
357 
362  SCellToArrow(KSpace aK) : myK(aK) { }
363 
369  : myK(other.myK) { }
370 
377  {
378  if ( this != &other )
379  {
380  myK = other.myK;
381  }
382  return *this;
383  }
384 
391  Output get(const Input& s) const
392  {
393  //starting point of the arrow
394  Input pointel( myK.sIndirectIncident( s, *myK.sDirs( s ) ) );
395  Point p( myK.sCoords( pointel ) ); //integer coordinates
396  //displacement vector
397  Vector v( myK.sKCoords( s ) - myK.sKCoords( pointel ) );
398  return Output(p,v);
399  }
400 
401  }; // end of class SCellToArrow
402 
404  // template class SCellToInnerPoint
412  template <typename KSpace>
414  {
415  BOOST_STATIC_ASSERT(( KSpace::dimension == 2 ));
416 
417  public:
418 
419  typedef typename KSpace::Point Output;
420  typedef typename KSpace::SCell Input;
421 
422  private:
423  KSpace myK;
424 
425  public:
426 
435  SCellToInnerPoint(KSpace aK) : myK(aK) { }
436 
442  : myK(other.myK) { }
443 
450  {
451  if ( this != &other )
452  {
453  myK = other.myK;
454  }
455  return *this;
456  }
457 
463  Output get(const Input& s) const
464  {
465  Input pixel( myK.sIndirectIncident( s, *myK.sOrthDirs( s ) ) );
466  return Output( myK.sCoords( pixel ) ); //integer coordinates
467  }
468 
469  }; // end of class SCellToInnerPoint
470 
472  // template class SCellToOuterPoint
480  template <typename KSpace>
482  {
483  BOOST_STATIC_ASSERT(( KSpace::dimension == 2 ));
484 
485  public:
486 
487  typedef typename KSpace::Point Output;
488  typedef typename KSpace::SCell Input;
489 
490  private:
491  KSpace myK;
492 
493  public:
494 
503  SCellToOuterPoint(KSpace aK) : myK(aK) { }
504 
510  : myK(other.myK) { }
511 
518  {
519  if ( this != &other )
520  {
521  myK = other.myK;
522  }
523  return *this;
524  }
525 
531  Output get(const Input& s) const
532  {
533  Input pixel( myK.sDirectIncident( s, *myK.sOrthDirs( s ) ) );
534  return Output( myK.sCoords( pixel ) ); //integer coordinates
535  }
536 
537  }; // end of class SCellToOuterPoint
538 
540  // template class SCellToIncidentPoints
548  template <typename KSpace>
550  {
551 
552  BOOST_STATIC_ASSERT(( KSpace::dimension == 2 ));
553 
554  public:
555 
556  typedef typename KSpace::Point Point;
557  typedef std::pair<Point,Point> Output;
558 
559  typedef typename KSpace::SCell Input;
560 
561  private:
562  KSpace myK;
563 
564  public:
565 
574  SCellToIncidentPoints(KSpace aK) : myK(aK) { }
575 
581  : myK(other.myK) { }
582 
589  {
590  if ( this != &other )
591  {
592  myK = other.myK;
593  }
594  return *this;
595  }
596 
602  Output get(const Input& s) const
603  {
604  //inner point
605  Input innerPixel( myK.sIndirectIncident( s, *myK.sOrthDirs( s ) ) );
606  //outer point
607  Input outerPixel( myK.sDirectIncident( s, *myK.sOrthDirs( s ) ) );
608 
609  return Output(myK.sCoords( innerPixel ),myK.sCoords( outerPixel ));
610  }
611 
612  }; // end of class SCellToIncidentPoints
613 
615  // template class SCellToCode
623  template <typename KSpace>
625  {
626 
627  BOOST_STATIC_ASSERT( KSpace::dimension == 2 );
628 
629  public:
630 
631  typedef typename KSpace::Point Point;
632  typedef typename KSpace::Vector Vector;
633  typedef char Output;
634 
635  typedef typename KSpace::SCell Input;
636 
637  private:
638  KSpace myK;
639 
640  public:
641 
650  SCellToCode(KSpace aK) : myK(aK) { }
651 
656  SCellToCode(const SCellToCode& other)
657  : myK(other.myK) { }
658 
664  SCellToCode & operator= ( const SCellToCode & other )
665  {
666  if ( this != &other )
667  {
668  myK = other.myK;
669  }
670  return *this;
671  }
672 
678  Output get(const Input& s) const
679  {
680  //starting point of the arrow
681  Input pointel( myK.sIndirectIncident( s, *myK.sDirs( s ) ) );
682  Point p( myK.sCoords( pointel ) ); //integer coordinates
683  //displacement vector
684  Vector v( myK.sKCoords( s ) - myK.sKCoords( pointel ) );
685  if (v == Vector(1,0)) return '0';
686  else if (v == Vector(0,1)) return '1';
687  else if (v == Vector(-1,0)) return '2';
688  else if (v == Vector(0,-1)) return '3';
689  else return 'e'; //e for error!
690  }
691 
692  }; // end of class SCellToArrow
693 
694 } //namespace deprecated
695 
696 } // namespace DGtal
697 
698 
700 // Includes inline functions.
701 //#include "DGtal/base/Modifier.ih"
702 
703 // //
705 
706 #endif // !defined Modifier_h
707 
708 #undef Modifier_RECURSES
709 #endif // else defined(Modifier_RECURSES)