DGtal 1.3.0
Loading...
Searching...
No Matches
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)
35#define ChordGenericStandardPlaneComputer_RECURSES
36
37#if !defined ChordGenericStandardPlaneComputer_h
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
55namespace 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 {
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;
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
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;
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)
Aim: A class that recognizes pieces of digital planes of given diagonal width. When the width is ,...
void selfDisplay(std::ostream &out) const
BOOST_STATIC_ASSERT((TSpace::dimension==3))
bool extendAsIs(const InputPoint &p)
void getUnitNormal(Vector3D &normal) const
BOOST_CONCEPT_ASSERT((concepts::CSignedNumber< TInternalScalar >))
bool operator()(const Point &p) const
bool extend(const InputPoint &p)
ChordGenericStandardPlaneComputer & operator=(const ChordGenericStandardPlaneComputer &other)
BOOST_STATIC_ASSERT((TInputPoint::dimension==3))
void getNormal(Vector3D &normal) const
bool isExtendable(const InputPoint &p) const
ChordNaivePlaneComputer< Space, InputPoint, InternalScalar > ChordComputer
bool isExtendable(TInputIterator it, TInputIterator itE) const
static Transform invT(Dimension orthant)
void init(InternalScalar widthNumerator=NumberTraits< InternalScalar >::ONE, InternalScalar widthDenominator=NumberTraits< InternalScalar >::ONE)
void getCharacteristics(InternalVector &n, InternalScalar &imin, InternalScalar &imax, InputPoint &p_min, InputPoint &p_max) const
std::vector< Dimension >::const_iterator OrthantConstIterator
boost::transform_iterator< Transform, InputPointSetConstIterator, InputPoint, InputPoint > ConstIterator
static Transform t(Dimension orthant)
void getBounds(double &min, double &max) const
bool extend(TInputIterator it, TInputIterator itE)
BOOST_CONCEPT_ASSERT((concepts::CSpace< TSpace >))
ChordGenericStandardPlaneComputer(const ChordGenericStandardPlaneComputer &other)
Aim: A parallel strip in the space is the intersection of two parallel half-planes such that each hal...
Definition: ParallelStrip.h:91
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
DGtal::uint32_t Dimension
Definition: Common.h:137
Aim: The traits class for all models of Cinteger.
Definition: NumberTraits.h:564
Aim: Concept checking for Signed Numbers. Models of this concept should be listed in NumberTraits cla...
Definition: CSignedNumber.h:98
Aim: Defines the concept describing a digital space, ie a cartesian product of integer lines.
Definition: CSpace.h:106
int max(int a, int b)