DGtal  1.1.0
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;
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;
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,
205 
206  // ----------------------- std public types ------------------------------
207  public:
209  typedef const InputPoint* const_pointer;
210  typedef const InputPoint& const_reference;
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 
271 
272  //-------------------- model of ForwardContainer -----------------------------
273  public:
274 
278  Size size() const;
279 
283  bool empty() const;
284 
289 
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 
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 
449 
457 
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;
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)
DGtal::ChordNaivePlaneComputer< Space, InputPoint, InternalScalar >
DGtal::ChordGenericStandardPlaneComputer::operator()
bool operator()(const Point &p) const
DGtal::ChordGenericStandardPlaneComputer::Transform::transformBack
void transformBack(Vector3D &v)
Definition: ChordGenericStandardPlaneComputer.h:184
DGtal::ChordGenericStandardPlaneComputer::getBounds
void getBounds(double &min, double &max) const
DGtal::ChordNaivePlaneComputer< Space, InputPoint, InternalScalar >::InputPointSet
std::set< InputPoint > InputPointSet
Definition: ChordNaivePlaneComputer.h:175
DGtal::ChordGenericStandardPlaneComputer::clear
void clear()
DGtal::concepts::CSpace
Aim: Defines the concept describing a digital space, ie a cartesian product of integer lines.
Definition: CSpace.h:106
DGtal::ChordGenericStandardPlaneComputer::size_type
InputPointSet::size_type size_type
Definition: ChordGenericStandardPlaneComputer.h:213
DGtal::ChordGenericStandardPlaneComputer::getNormal
void getNormal(Vector3D &normal) const
max
int max(int a, int b)
Definition: testArithmeticalDSS.cpp:1108
DGtal::ChordNaivePlaneComputer< Space, InputPoint, InternalScalar >::Component
InputVector::Component Component
Definition: ChordNaivePlaneComputer.h:171
DGtal::ChordGenericStandardPlaneComputer::Transform
Definition: ChordGenericStandardPlaneComputer.h:166
DGtal::NumberTraits
Aim: The traits class for all models of Cinteger.
Definition: NumberTraits.h:533
DGtal::ChordGenericStandardPlaneComputer::const_iterator
ConstIterator const_iterator
Definition: ChordGenericStandardPlaneComputer.h:208
DGtal::ChordGenericStandardPlaneComputer::getCharacteristics
void getCharacteristics(InternalVector &n, InternalScalar &imin, InternalScalar &imax, InputPoint &p_min, InputPoint &p_max) const
DGtal::ChordGenericStandardPlaneComputer::Transform::isPlusZOnX
bool isPlusZOnX() const
Definition: ChordGenericStandardPlaneComputer.h:177
DGtal::ChordGenericStandardPlaneComputer::_orthantsToErase
std::vector< Dimension > _orthantsToErase
Definition: ChordGenericStandardPlaneComputer.h:493
DGtal::ChordGenericStandardPlaneComputer::ChordComputer
ChordNaivePlaneComputer< Space, InputPoint, InternalScalar > ChordComputer
Definition: ChordGenericStandardPlaneComputer.h:135
DGtal::ChordGenericStandardPlaneComputer
Aim: A class that recognizes pieces of digital planes of given diagonal width. When the width is ,...
Definition: ChordGenericStandardPlaneComputer.h:123
DGtal::Dimension
DGtal::uint32_t Dimension
Definition: Common.h:133
DGtal::ChordGenericStandardPlaneComputer::getUnitNormal
void getUnitNormal(Vector3D &normal) const
DGtal::ChordGenericStandardPlaneComputer::OrthantIterator
std::vector< Dimension >::iterator OrthantIterator
Definition: ChordGenericStandardPlaneComputer.h:148
DGtal::ChordGenericStandardPlaneComputer::maximalPoint
InputPoint maximalPoint() const
DGtal::ChordGenericStandardPlaneComputer::isValid
bool isValid() const
DGtal::ChordGenericStandardPlaneComputer::OrthantConstIterator
std::vector< Dimension >::const_iterator OrthantConstIterator
Definition: ChordGenericStandardPlaneComputer.h:149
DGtal::ChordGenericStandardPlaneComputer::Transform::Transform
Transform()
Definition: ChordGenericStandardPlaneComputer.h:171
DGtal::ChordGenericStandardPlaneComputer::extendAsIs
bool extendAsIs(const InputPoint &p)
DGtal::ChordGenericStandardPlaneComputer::InternalScalar
TInternalScalar InternalScalar
Definition: ChordGenericStandardPlaneComputer.h:133
DGtal::ChordGenericStandardPlaneComputer::active
Dimension active() const
DGtal::concepts::CSignedNumber
Aim: Concept checking for Signed Numbers. Models of this concept should be listed in NumberTraits cla...
Definition: CSignedNumber.h:98
DGtal::ChordGenericStandardPlaneComputer::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CSpace< TSpace >))
DGtal::ChordGenericStandardPlaneComputer::value_type
InputPoint value_type
Definition: ChordGenericStandardPlaneComputer.h:211
DGtal::ChordNaivePlaneComputer< Space, InputPoint, InternalScalar >::ConstIterator
InputPointSet::const_iterator ConstIterator
Definition: ChordNaivePlaneComputer.h:177
DGtal::ChordGenericStandardPlaneComputer::myTransforms
static Transform myTransforms[4]
Definition: ChordGenericStandardPlaneComputer.h:492
DGtal::ChordGenericStandardPlaneComputer::Component
ChordComputer::Component Component
Definition: ChordGenericStandardPlaneComputer.h:136
DGtal::ChordGenericStandardPlaneComputer::InternalVector
ChordComputer::InternalVector InternalVector
Definition: ChordGenericStandardPlaneComputer.h:138
DGtal::ChordGenericStandardPlaneComputer::end
ConstIterator end() const
DGtal::ChordGenericStandardPlaneComputer::Transform::Value
InputPoint Value
Definition: ChordGenericStandardPlaneComputer.h:167
DGtal::ChordGenericStandardPlaneComputer::myComputers
ChordComputer myComputers[4]
Definition: ChordGenericStandardPlaneComputer.h:491
DGtal::ChordGenericStandardPlaneComputer::begin
ConstIterator begin() const
DGtal::ChordGenericStandardPlaneComputer::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CSignedNumber< TInternalScalar >))
DGtal::ChordGenericStandardPlaneComputer::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::ChordGenericStandardPlaneComputer::Transform::inverse
InputPoint inverse(const InputPoint &p) const
Definition: ChordGenericStandardPlaneComputer.h:179
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
DGtal::ChordGenericStandardPlaneComputer::primitive
Primitive primitive() const
DGtal::ChordGenericStandardPlaneComputer::init
void init(InternalScalar widthNumerator=NumberTraits< InternalScalar >::ONE, InternalScalar widthDenominator=NumberTraits< InternalScalar >::ONE)
DGtal::ChordGenericStandardPlaneComputer::invT
static Transform invT(Dimension orthant)
DGtal::ChordGenericStandardPlaneComputer::Primitive
ChordComputer::Primitive Primitive
Definition: ChordGenericStandardPlaneComputer.h:140
DGtal::ChordGenericStandardPlaneComputer::isExtendable
bool isExtendable(const InputPoint &p) const
DGtal::ChordGenericStandardPlaneComputer::InputPoint
TInputPoint InputPoint
Definition: ChordGenericStandardPlaneComputer.h:132
DGtal::ChordGenericStandardPlaneComputer::ChordGenericStandardPlaneComputer
ChordGenericStandardPlaneComputer(const ChordGenericStandardPlaneComputer &other)
DGtal::ChordGenericStandardPlaneComputer::const_reference
const InputPoint & const_reference
Definition: ChordGenericStandardPlaneComputer.h:210
DGtal::ChordGenericStandardPlaneComputer::Transform::transform
void transform(Vector3D &v)
Definition: ChordGenericStandardPlaneComputer.h:190
DGtal::ChordGenericStandardPlaneComputer::Space
TSpace Space
Definition: ChordGenericStandardPlaneComputer.h:131
DGtal::ChordNaivePlaneComputer< Space, InputPoint, InternalScalar >::Iterator
InputPointSet::iterator Iterator
Definition: ChordNaivePlaneComputer.h:178
DGtal::ChordGenericStandardPlaneComputer::Transform::value_type
InputPoint value_type
Definition: ChordGenericStandardPlaneComputer.h:168
DGtal::ChordNaivePlaneComputer< Space, InputPoint, InternalScalar >::Coordinate
InputPoint::Coordinate Coordinate
Definition: ChordNaivePlaneComputer.h:172
DGtal::ChordGenericStandardPlaneComputer::ChordGenericStandardPlaneComputer
ChordGenericStandardPlaneComputer()
DGtal::ChordGenericStandardPlaneComputer::Point
ChordComputer::Point Point
Definition: ChordGenericStandardPlaneComputer.h:139
DGtal::ChordGenericStandardPlaneComputer::difference_type
InputPointSet::difference_type difference_type
Definition: ChordGenericStandardPlaneComputer.h:212
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
DGtal::ChordNaivePlaneComputer< Space, InputPoint, InternalScalar >::Size
InputPointSet::size_type Size
Definition: ChordNaivePlaneComputer.h:176
DGtal::ChordGenericStandardPlaneComputer::InputPointSet
ChordComputer::InputPointSet InputPointSet
Definition: ChordGenericStandardPlaneComputer.h:141
DGtal::ChordGenericStandardPlaneComputer::InputPointSetConstIterator
ChordComputer::ConstIterator InputPointSetConstIterator
Definition: ChordGenericStandardPlaneComputer.h:143
DGtal::ChordGenericStandardPlaneComputer::empty
bool empty() const
DGtal::ParallelStrip
Aim: A parallel strip in the space is the intersection of two parallel half-planes such that each hal...
Definition: ParallelStrip.h:91
DGtal::ChordGenericStandardPlaneComputer::~ChordGenericStandardPlaneComputer
~ChordGenericStandardPlaneComputer()
DGtal::ChordGenericStandardPlaneComputer::Coordinate
ChordComputer::Coordinate Coordinate
Definition: ChordGenericStandardPlaneComputer.h:137
DGtal::ChordGenericStandardPlaneComputer::InputPointSetIterator
ChordComputer::Iterator InputPointSetIterator
Definition: ChordGenericStandardPlaneComputer.h:144
DGtal::ChordGenericStandardPlaneComputer::const_pointer
const InputPoint * const_pointer
Definition: ChordGenericStandardPlaneComputer.h:209
DGtal::ChordGenericStandardPlaneComputer::Transform::isPlusZOnY
bool isPlusZOnY() const
Definition: ChordGenericStandardPlaneComputer.h:178
DGtal::ChordGenericStandardPlaneComputer::BOOST_STATIC_ASSERT
BOOST_STATIC_ASSERT((TSpace::dimension==3))
DGtal::PointVector< 3, InternalScalar >
DGtal::ChordGenericStandardPlaneComputer::minimalPoint
InputPoint minimalPoint() const
DGtal::ChordGenericStandardPlaneComputer::t
static Transform t(Dimension orthant)
DGtal::ChordGenericStandardPlaneComputer::Transform::operator()
InputPoint operator()(const InputPoint &p) const
Definition: ChordGenericStandardPlaneComputer.h:173
DGtal::ChordGenericStandardPlaneComputer::Transform::Transform
Transform(bool posX, bool posY)
Definition: ChordGenericStandardPlaneComputer.h:172
DGtal::ChordGenericStandardPlaneComputer::max_size
Size max_size() const
DGtal::ChordGenericStandardPlaneComputer::operator=
ChordGenericStandardPlaneComputer & operator=(const ChordGenericStandardPlaneComputer &other)
DGtal::ChordGenericStandardPlaneComputer::Transform::_posX
bool _posX
Definition: ChordGenericStandardPlaneComputer.h:169
DGtal::ChordGenericStandardPlaneComputer::isExtendable
bool isExtendable(TInputIterator it, TInputIterator itE) const
DGtal::ChordGenericStandardPlaneComputer::ConstIterator
boost::transform_iterator< Transform, InputPointSetConstIterator, InputPoint, InputPoint > ConstIterator
Definition: ChordGenericStandardPlaneComputer.h:204
DGtal::ChordGenericStandardPlaneComputer::size
Size size() const
DGtal::ChordGenericStandardPlaneComputer::extend
bool extend(TInputIterator it, TInputIterator itE)
DGtal::ChordGenericStandardPlaneComputer::Size
ChordComputer::Size Size
Definition: ChordGenericStandardPlaneComputer.h:142
DGtal::ChordGenericStandardPlaneComputer::maxSize
Size maxSize() const
DGtal::ChordGenericStandardPlaneComputer::Transform::_posY
bool _posY
Definition: ChordGenericStandardPlaneComputer.h:170
DGtal::ChordGenericStandardPlaneComputer::extend
bool extend(const InputPoint &p)
DGtal::ChordGenericStandardPlaneComputer::myOrthants
std::vector< Dimension > myOrthants
Definition: ChordGenericStandardPlaneComputer.h:490
DGtal::ChordGenericStandardPlaneComputer::InputVector
InputPoint InputVector
Definition: ChordGenericStandardPlaneComputer.h:134
DGtal::ChordGenericStandardPlaneComputer::BOOST_STATIC_ASSERT
BOOST_STATIC_ASSERT((TInputPoint::dimension==3))