DGtal  0.9.2
ChordGenericStandardPlaneComputer.h
1 
17 #pragma once
18 
31 #if defined(ChordGenericStandardPlaneComputer_RECURSES)
32 #error Recursive header files inclusion detected in ChordGenericStandardPlaneComputer.h
33 #else // defined(ChordGenericStandardPlaneComputer_RECURSES)
34 
35 #define ChordGenericStandardPlaneComputer_RECURSES
36 
37 #if !defined ChordGenericStandardPlaneComputer_h
38 
39 #define ChordGenericStandardPlaneComputer_h
40 
42 // Inclusions
43 #include <iostream>
44 #include <set>
45 #include "DGtal/base/Common.h"
46 #include "DGtal/base/IteratorAdapter.h"
47 #include "DGtal/kernel/CInteger.h"
48 #include "DGtal/kernel/CSpace.h"
49 #include "DGtal/kernel/SpaceND.h"
50 #include "DGtal/kernel/PointVector.h"
51 #include "DGtal/arithmetic/IntegerComputer.h"
52 #include "DGtal/geometry/surfaces/ChordNaivePlaneComputer.h"
54 
55 namespace DGtal
56 {
57 
59  // template class ChordGenericStandardPlaneComputer
119  template < typename TSpace,
120  typename TInputPoint,
121  typename TInternalScalar >
123  {
126  BOOST_STATIC_ASSERT(( TSpace::dimension == 3 ));
127  BOOST_STATIC_ASSERT(( TInputPoint::dimension == 3 ));
128 
129  // ----------------------- public types ------------------------------
130  public:
131  typedef TSpace Space;
132  typedef TInputPoint InputPoint;
133  typedef TInternalScalar InternalScalar;
134  typedef InputPoint InputVector;
139  typedef typename ChordComputer::Point Point;
142  typedef typename ChordComputer::Size Size;
145 
146  // ----------------------- internal types ------------------------------
147  private:
148  typedef std::vector<Dimension>::iterator OrthantIterator;
149  typedef std::vector<Dimension>::const_iterator OrthantConstIterator;
150 
151 
152  // --------- adapter types for standard to naive transformation --------
153  public:
154 
166  struct Transform {
167  typedef InputPoint Value;
168  typedef InputPoint value_type;
169  bool _posX;
170  bool _posY;
171  inline Transform() {}
172  inline Transform( bool posX, bool posY ) : _posX( posX ), _posY( posY ) {}
173  inline InputPoint operator()( const InputPoint & p ) const
174  { return InputPoint( p[ 0 ] + ( _posX ? p[ 2 ] : -p[ 2 ] ),
175  p[ 1 ] + ( _posY ? p[ 2 ] : -p[ 2 ] ),
176  p[ 2 ] ); }
177  inline bool isPlusZOnX() const { return _posX; }
178  inline bool isPlusZOnY() const { return _posY; }
179  inline InputPoint inverse( const InputPoint & p ) const
180  { return InputPoint( p[ 0 ] + ( _posX ? -p[ 2 ] : p[ 2 ] ),
181  p[ 1 ] + ( _posY ? -p[ 2 ] : p[ 2 ] ),
182  p[ 2 ] ); }
183  template <typename Vector3D>
184  void transformBack( Vector3D & v )
185  {
186  v[ 2 ] += ( _posX ? v[ 0 ] : -v[ 0 ] );
187  v[ 2 ] += ( _posY ? v[ 1 ] : -v[ 1 ] );
188  }
189  template <typename Vector3D>
190  void transform( Vector3D & v )
191  {
192  v[ 2 ] += ( _posX ? -v[ 0 ] : v[ 0 ] );
193  v[ 2 ] += ( _posY ? -v[ 1 ] : v[ 1 ] );
194  }
195  };
196 
202  typedef boost::transform_iterator<Transform,InputPointSetConstIterator,
203  InputPoint,InputPoint>
205 
206  // ----------------------- std public types ------------------------------
207  public:
209  typedef const InputPoint* const_pointer;
210  typedef const InputPoint& const_reference;
211  typedef InputPoint value_type;
212  typedef typename InputPointSet::difference_type difference_type;
213  typedef typename InputPointSet::size_type size_type;
214 
215  // ----------------------- Standard services ------------------------------
216  public:
217 
222 
228 
234 
241 
245  Dimension active() const;
246 
251  void clear();
252 
269  void init( InternalScalar widthNumerator = NumberTraits< InternalScalar >::ONE,
270  InternalScalar widthDenominator = NumberTraits< InternalScalar >::ONE );
271 
272  //-------------------- model of ForwardContainer -----------------------------
273  public:
274 
278  Size size() const;
279 
283  bool empty() const;
284 
288  ConstIterator begin() const;
289 
293  ConstIterator end() const;
294 
300  Size max_size() const;
301 
306  Size maxSize() const;
307 
308 
309  //-------------------- model of concepts::CPointPredicate -----------------------------
310  public:
311 
321  bool operator()( const Point & p ) const;
322 
323  //-------------------- model of CIncrementalPrimitiveComputer -----------------------------
324  public:
325 
335  bool extendAsIs( const InputPoint & p );
336 
347  bool extend( const InputPoint & p );
348 
359  bool isExtendable( const InputPoint & p ) const;
360 
361  //-------------------- model of CAdditivePrimitiveComputer -----------------------------
362  public:
363 
377  template <typename TInputIterator>
378  bool extend( TInputIterator it, TInputIterator itE );
379 
394  template <typename TInputIterator>
395  bool isExtendable( TInputIterator it, TInputIterator itE ) const;
396 
397  //-------------------- Primitive services -----------------------------
398  public:
399 
410  Primitive primitive() const;
411 
412  //-------------------- Parameters services -----------------------------
413  public:
414 
421  template <typename Vector3D>
422  void getNormal( Vector3D & normal ) const;
423 
430  template <typename Vector3D>
431  void getUnitNormal( Vector3D & normal ) const;
432 
440  void getBounds( double & min, double & max ) const;
441 
448  InputPoint minimalPoint() const;
449 
456  InputPoint maximalPoint() const;
457 
469  void getCharacteristics( InternalVector & n,
470  InternalScalar & imin, InternalScalar & imax,
471  InputPoint & p_min, InputPoint & p_max ) const;
472 
473  // ----------------------- Interface --------------------------------------
474  public:
475 
480  void selfDisplay ( std::ostream & out ) const;
481 
486  bool isValid() const;
487 
488  // ------------------------- Private Datas --------------------------------
489  private:
490  std::vector<Dimension> myOrthants;
491  ChordComputer myComputers[ 4 ];
492  static Transform myTransforms[ 4 ];
493  mutable std::vector<Dimension> _orthantsToErase;
494  // ------------------------- Hidden services ------------------------------
495  protected:
501  static Transform t( Dimension orthant );
507  static Transform invT( Dimension orthant );
508 
509  // ------------------------- Internals ------------------------------------
510  private:
511  }; // end of class ChordGenericStandardPlaneComputer
512 
513 
520  template <typename TSpace, typename TInputPoint, typename TInternalScalar>
521  std::ostream&
522  operator<< ( std::ostream & out,
524 
525 } // namespace DGtal
526 
527 
529 // Includes inline functions.
530 #include "DGtal/geometry/surfaces/ChordGenericStandardPlaneComputer.ih"
531 
532 // //
534 
535 #endif // !defined ChordGenericStandardPlaneComputer_h
536 
537 #undef ChordGenericStandardPlaneComputer_RECURSES
538 #endif // else defined(ChordGenericStandardPlaneComputer_RECURSES)
BOOST_CONCEPT_ASSERT((concepts::CSpace< TSpace >))
bool isExtendable(const InputPoint &p) const
static Transform invT(Dimension orthant)
DGtal::uint32_t Dimension
Definition: Common.h:113
Aim: A parallel strip in the space is the intersection of two parallel half-planes such that each hal...
Definition: ParallelStrip.h:90
ChordGenericStandardPlaneComputer & operator=(const ChordGenericStandardPlaneComputer &other)
bool operator()(const Point &p) const
boost::transform_iterator< Transform, InputPointSetConstIterator, InputPoint, InputPoint > ConstIterator
void getUnitNormal(Vector3D &normal) const
void getNormal(Vector3D &normal) const
static Transform t(Dimension orthant)
void getCharacteristics(InternalVector &n, InternalScalar &imin, InternalScalar &imax, InputPoint &p_min, InputPoint &p_max) const
Aim: Defines the concept describing a digital space, ie a cartesian product of integer lines...
Definition: CSpace.h:105
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
Aim: The traits class for all models of Cinteger.
Definition: NumberTraits.h:69
void getBounds(double &min, double &max) const
void selfDisplay(std::ostream &out) const
std::vector< Dimension >::const_iterator OrthantConstIterator
Aim: Concept checking for Signed Numbers. Models of this concept should be listed in NumberTraits cla...
Definition: CSignedNumber.h:97
DGtal is the top-level namespace which contains all DGtal functions and types.
bool extendAsIs(const InputPoint &p)
ChordNaivePlaneComputer< Space, InputPoint, InternalScalar > ChordComputer
void init(InternalScalar widthNumerator=NumberTraits< InternalScalar >::ONE, InternalScalar widthDenominator=NumberTraits< InternalScalar >::ONE)
bool extend(const InputPoint &p)
BOOST_STATIC_ASSERT((TSpace::dimension==3))
Aim: A class that recognizes pieces of digital planes of given diagonal width. When the width is ...