DGtal 1.3.0
Loading...
Searching...
No Matches
COBAGenericStandardPlaneComputer.h
1
17#pragma once
18
31#if defined(COBAGenericStandardPlaneComputer_RECURSES)
32#error Recursive header files inclusion detected in COBAGenericStandardPlaneComputer.h
33#else // defined(COBAGenericStandardPlaneComputer_RECURSES)
35#define COBAGenericStandardPlaneComputer_RECURSES
36
37#if !defined COBAGenericStandardPlaneComputer_h
39#define COBAGenericStandardPlaneComputer_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/COBANaivePlaneComputer.h"
54
55namespace DGtal
56{
57
59 // template class COBAGenericStandardPlaneComputer
126 template < typename TSpace,
127 typename TInternalInteger >
129 {
130
133 BOOST_STATIC_ASSERT(( TSpace::dimension == 3 ));
134
135 // ----------------------- public types ------------------------------
136 public:
137 typedef TSpace Space;
138 typedef typename Space::Point Point;
139 typedef std::set< Point > PointSet;
140 typedef typename PointSet::size_type Size;
141 typedef typename PointSet::const_iterator PointSetConstIterator;
142 typedef typename PointSet::iterator PointSetIterator;
143 typedef TInternalInteger InternalInteger;
148
149 // ----------------------- internal types ------------------------------
150 private:
151 typedef std::vector<Dimension>::iterator OrthantIterator;
152 typedef std::vector<Dimension>::const_iterator OrthantConstIterator;
153
154 // --------- adapter types for standard to naive transformation --------
155 public:
167 struct Transform {
168 typedef Point Value;
170 bool _posX;
171 bool _posY;
172 inline Transform() {}
173 inline Transform( bool posX, bool posY ) : _posX( posX ), _posY( posY ) {}
174 inline Point operator()( const Point & p ) const
175 {
176 if ( _posX ) {
177 if ( _posY ) return Point( p[ 0 ] + p[ 2 ], p[ 1 ] + p[ 2 ], p[ 2 ] );
178 else return Point( p[ 0 ] + p[ 2 ], p[ 1 ] - p[ 2 ], p[ 2 ] );
179 } else {
180 if ( _posY ) return Point( p[ 0 ] - p[ 2 ], p[ 1 ] + p[ 2 ], p[ 2 ] );
181 else return Point( p[ 0 ] - p[ 2 ], p[ 1 ] - p[ 2 ], p[ 2 ] );
182 }
183 }
184 inline bool isPlusZOnX() const { return _posX; }
185 inline bool isPlusZOnY() const { return _posY; }
186 inline Point inverse( const Point & p ) const
187 {
188 if ( _posX ) {
189 if ( _posY ) return Point( p[ 0 ] - p[ 2 ], p[ 1 ] - p[ 2 ], p[ 2 ] );
190 else return Point( p[ 0 ] - p[ 2 ], p[ 1 ] + p[ 2 ], p[ 2 ] );
191 } else {
192 if ( _posY ) return Point( p[ 0 ] + p[ 2 ], p[ 1 ] - p[ 2 ], p[ 2 ] );
193 else return Point( p[ 0 ] + p[ 2 ], p[ 1 ] + p[ 2 ], p[ 2 ] );
194 }
195 }
196 template <typename Vector3D>
197 void transformBack( Vector3D & v )
198 {
199 if ( _posX ) v[ 2 ] += v[ 0 ];
200 else v[ 2 ] -= v[ 0 ];
201 if ( _posY ) v[ 2 ] += v[ 1 ];
202 else v[ 2 ] -= v[ 1 ];
203 }
204 template <typename Vector3D>
205 void transform( Vector3D & v )
206 {
207 if ( _posX ) v[ 2 ] -= v[ 0 ];
208 else v[ 2 ] += v[ 0 ];
209 if ( _posY ) v[ 2 ] -= v[ 1 ];
210 else v[ 2 ] += v[ 1 ];
211 }
212 };
213
219 typedef boost::transform_iterator<Transform,PointSetConstIterator,Point,Point>
221
222 // ----------------------- std public types ------------------------------
223 public:
225 typedef const Point* const_pointer;
226 typedef const Point& const_reference;
228 typedef typename PointSet::difference_type difference_type;
229 typedef typename PointSet::size_type size_type;
230
231 // ----------------------- Standard services ------------------------------
232 public:
233
238
244
250
257
262
267
272 void clear();
273
293 void init( InternalInteger diameter,
296
301
302 //-------------------- model of ForwardContainer -----------------------------
303 public:
304
308 Size size() const;
309
313 bool empty() const;
314
319
324
330 Size max_size() const;
331
336 Size maxSize() const;
337
338
339 //-------------------- model of concepts::CPointPredicate -----------------------------
340 public:
341
351 bool operator()( const Point & p ) const;
352
362 bool extendAsIs( const Point & p );
363
364 //-------------------- model of CIncrementalPrimitiveComputer -----------------------------
365 public:
366
377 bool extend( const Point & p );
378
389 bool isExtendable( const Point & p ) const;
390
391 //-------------------- model of CAdditivePrimitiveComputer -----------------------------
392 public:
393
407 template <typename TInputIterator>
408 bool extend( TInputIterator it, TInputIterator itE );
409
424 template <typename TInputIterator>
425 bool isExtendable( TInputIterator it, TInputIterator itE ) const;
426
427 //-------------------- Primitive services -----------------------------
428 public:
429
441
442 //-------------------- Parameters services -----------------------------
443 public:
444
451 template <typename Vector3D>
452 void getNormal( Vector3D & normal ) const;
453
460 template <typename Vector3D>
461 void getUnitNormal( Vector3D & normal ) const;
462
470 void getBounds( double & min, double & max ) const;
471
479
487
500 InternalInteger & imin, InternalInteger & imax,
501 Point & p_min, Point & p_max ) const;
502
503 // ----------------------- Interface --------------------------------------
504 public:
505
510 void selfDisplay ( std::ostream & out ) const;
511
516 bool isValid() const;
517
518 // ------------------------- Private Datas --------------------------------
519 private:
520 std::vector<Dimension> myOrthants;
523 mutable std::vector<Dimension> _orthantsToErase;
524 // ------------------------- Hidden services ------------------------------
525 protected:
531 static Transform t( Dimension orthant );
537 static Transform invT( Dimension orthant );
538
539 // ------------------------- Internals ------------------------------------
540 private:
541 }; // end of class COBAGenericStandardPlaneComputer
542
543
550 template <typename TSpace, typename TInternalInteger>
551 std::ostream&
553
554} // namespace DGtal
555
556
558// Includes inline functions.
559#include "DGtal/geometry/surfaces/COBAGenericStandardPlaneComputer.ih"
560
561// //
563
564#endif // !defined COBAGenericStandardPlaneComputer_h
565
566#undef COBAGenericStandardPlaneComputer_RECURSES
567#endif // else defined(COBAGenericStandardPlaneComputer_RECURSES)
Aim: A class that recognizes pieces of digital planes of given axis width. When the diagonal width is...
COBANaivePlaneComputer< Space, InternalInteger > COBAComputer
void getCharacteristics(IntegerVector3 &n, InternalInteger &imin, InternalInteger &imax, Point &p_min, Point &p_max) const
std::vector< Dimension >::const_iterator OrthantConstIterator
void getBounds(double &min, double &max) const
bool extend(TInputIterator it, TInputIterator itE)
COBAGenericStandardPlaneComputer & operator=(const COBAGenericStandardPlaneComputer &other)
IntegerComputer< InternalInteger > MyIntegerComputer
static Transform invT(Dimension orthant)
bool operator()(const Point &p) const
boost::transform_iterator< Transform, PointSetConstIterator, Point, Point > ConstIterator
void getUnitNormal(Vector3D &normal) const
BOOST_CONCEPT_ASSERT((concepts::CSpace< TSpace >))
void getNormal(Vector3D &normal) const
COBAGenericStandardPlaneComputer(const COBAGenericStandardPlaneComputer &other)
void init(InternalInteger diameter, InternalInteger widthNumerator=NumberTraits< InternalInteger >::ONE, InternalInteger widthDenominator=NumberTraits< InternalInteger >::ONE)
MyIntegerComputer & ic() const
bool isExtendable(const Point &p) const
static Transform t(Dimension orthant)
BOOST_STATIC_ASSERT((TSpace::dimension==3))
BOOST_CONCEPT_ASSERT((concepts::CInteger< TInternalInteger >))
bool isExtendable(TInputIterator it, TInputIterator itE) const
void selfDisplay(std::ostream &out) const
Aim: This class gathers several types and methods to make computation with integers.
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 Integer Numbers. More precisely, this concept is a refinement of both CEucl...
Definition: CInteger.h:88
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)