DGtal  1.1.0
COBANaivePlaneComputer.h
1 
17 #pragma once
18 
33 #if defined(COBANaivePlaneComputer_RECURSES)
34 #error Recursive header files inclusion detected in COBANaivePlaneComputer.h
35 #else // defined(COBANaivePlaneComputer_RECURSES)
36 
37 #define COBANaivePlaneComputer_RECURSES
38 
39 #if !defined COBANaivePlaneComputer_h
40 
41 #define COBANaivePlaneComputer_h
42 
44 // Inclusions
45 #include <iostream>
46 #include <set>
47 #include "DGtal/base/Common.h"
48 #include "DGtal/kernel/CInteger.h"
49 #include "DGtal/kernel/CSpace.h"
50 #include "DGtal/kernel/SpaceND.h"
51 #include "DGtal/kernel/PointVector.h"
52 #include "DGtal/arithmetic/IntegerComputer.h"
53 #include "DGtal/arithmetic/LatticePolytope2D.h"
54 #include "DGtal/geometry/surfaces/ParallelStrip.h"
56 
57 namespace DGtal
58 {
59 
61  // template class COBANaivePlaneComputer
127  template < typename TSpace,
128  typename TInternalInteger >
130  {
131 
134  BOOST_STATIC_ASSERT(( TSpace::dimension == 3 ));
135 
136  // ----------------------- public types ------------------------------
137  public:
138  typedef TSpace Space;
139  typedef typename Space::Point Point;
140  typedef std::set< Point > PointSet;
141  typedef typename PointSet::size_type Size;
142  typedef typename PointSet::const_iterator ConstIterator;
143  typedef typename PointSet::iterator Iterator;
144  typedef TInternalInteger InternalInteger;
148 
149  // ----------------------- std public types ------------------------------
150  public:
151  typedef typename PointSet::const_iterator const_iterator;
152  typedef typename PointSet::const_pointer const_pointer;
153  typedef typename PointSet::const_reference const_reference;
154  typedef typename PointSet::value_type value_type;
155  typedef typename PointSet::difference_type difference_type;
156  typedef typename PointSet::size_type size_type;
157 
158  // ----------------------- internal types ------------------------------
159  private:
165 
171  struct State {
179  };
180 
181  // ----------------------- Standard services ------------------------------
182  public:
183 
188 
194 
200 
207 
212 
217  void clear();
218 
238  void init( Dimension axis, InternalInteger diameter,
241 
245  Size complexity() const;
246 
247  //-------------------- model of ForwardContainer -----------------------------
248  public:
249 
253  Size size() const;
254 
258  bool empty() const;
259 
264 
269 
275  Size max_size() const;
276 
281  Size maxSize() const;
282 
283 
284  //-------------------- model of concepts::CPointPredicate -----------------------------
285  public:
286 
296  bool operator()( const Point & p ) const;
297 
298  //-------------------- model of CIncrementalPrimitiveComputer -----------------------------
299  public:
300 
310  bool extendAsIs( const Point & p );
311 
322  bool extend( const Point & p );
323 
334  bool isExtendable( const Point & p ) const;
335 
336  //-------------------- model of CAdditivePrimitiveComputer -----------------------------
337  public:
338 
352  template <typename TInputIterator>
353  bool extend( TInputIterator it, TInputIterator itE );
354 
369  template <typename TInputIterator>
370  bool isExtendable( TInputIterator it, TInputIterator itE ) const;
371 
372  //-------------------- Primitive services -----------------------------
373  public:
374 
386 
387  //-------------------- Parameters services -----------------------------
388  public:
389 
396  template <typename Vector3D>
397  void getNormal( Vector3D & normal ) const;
398 
402  const IntegerVector3 & exactNormal() const;
403 
410  template <typename Vector3D>
411  void getUnitNormal( Vector3D & normal ) const;
412 
420  void getBounds( double & min, double & max ) const;
421 
428  const Point & minimalPoint() const;
429 
436  const Point & maximalPoint() const;
437 
438  // ----------------------- Interface --------------------------------------
439  public:
440 
445  void selfDisplay ( std::ostream & out ) const;
446 
451  bool isValid() const;
452 
453  // ------------------------- Private Datas --------------------------------
454  private:
459  State myState;
463  mutable State _state;
465  // ------------------------- Hidden services ------------------------------
466  protected:
467 
468 
469  // ------------------------- Internals ------------------------------------
470  private:
471 
480  void computeCentroidAndNormal( State & state ) const;
481 
495  void doubleCut( InternalPoint2 & grad, State & state ) const;
496 
510  template <typename TInputIterator>
511  void computeMinMax( State & state, TInputIterator itB, TInputIterator itE ) const;
512 
530  template <typename TInputIterator>
531  bool updateMinMax( State & state, TInputIterator itB, TInputIterator itE ) const;
532 
542  bool checkPlaneWidth( const State & state ) const;
543 
551  void computeGradient( InternalPoint2 & grad, const State & state ) const;
552 
553  }; // end of class COBANaivePlaneComputer
554 
555 
562  template <typename TSpace, typename TInternalInteger>
563  std::ostream&
564  operator<< ( std::ostream & out, const COBANaivePlaneComputer<TSpace, TInternalInteger> & object );
565 
566 } // namespace DGtal
567 
568 
570 // Includes inline functions.
571 #include "DGtal/geometry/surfaces/COBANaivePlaneComputer.ih"
572 
573 // //
575 
576 #endif // !defined COBANaivePlaneComputer_h
577 
578 #undef COBANaivePlaneComputer_RECURSES
579 #endif // else defined(COBANaivePlaneComputer_RECURSES)
DGtal::COBANaivePlaneComputer::InternalSpace2
SpaceND< 2, InternalInteger > InternalSpace2
Definition: COBANaivePlaneComputer.h:161
DGtal::COBANaivePlaneComputer::InternalPoint2
InternalSpace2::Point InternalPoint2
Definition: COBANaivePlaneComputer.h:162
DGtal::COBANaivePlaneComputer::primitive
Primitive primitive() const
DGtal::COBANaivePlaneComputer::init
void init(Dimension axis, InternalInteger diameter, InternalInteger widthNumerator=NumberTraits< InternalInteger >::ONE, InternalInteger widthDenominator=NumberTraits< InternalInteger >::ONE)
DGtal::COBANaivePlaneComputer::HalfSpace
ConvexPolygonZ2::HalfSpace HalfSpace
Definition: COBANaivePlaneComputer.h:164
DGtal::COBANaivePlaneComputer::COBANaivePlaneComputer
COBANaivePlaneComputer()
DGtal::concepts::CSpace
Aim: Defines the concept describing a digital space, ie a cartesian product of integer lines.
Definition: CSpace.h:106
DGtal::COBANaivePlaneComputer::size_type
PointSet::size_type size_type
Definition: COBANaivePlaneComputer.h:156
DGtal::concepts::CInteger
Aim: Concept checking for Integer Numbers. More precisely, this concept is a refinement of both CEucl...
Definition: CInteger.h:88
DGtal::COBANaivePlaneComputer::extend
bool extend(const Point &p)
DGtal::COBANaivePlaneComputer::clear
void clear()
max
int max(int a, int b)
Definition: testArithmeticalDSS.cpp:1108
DGtal::COBANaivePlaneComputer::_state
State _state
Definition: COBANaivePlaneComputer.h:463
DGtal::NumberTraits
Aim: The traits class for all models of Cinteger.
Definition: NumberTraits.h:533
DGtal::COBANaivePlaneComputer::doubleCut
void doubleCut(InternalPoint2 &grad, State &state) const
DGtal::COBANaivePlaneComputer::myPointSet
PointSet myPointSet
Definition: COBANaivePlaneComputer.h:458
DGtal::COBANaivePlaneComputer::size
Size size() const
DGtal::COBANaivePlaneComputer::State::min
InternalInteger min
Definition: COBANaivePlaneComputer.h:173
DGtal::COBANaivePlaneComputer::Space
TSpace Space
Definition: COBANaivePlaneComputer.h:138
DGtal::COBANaivePlaneComputer::getNormal
void getNormal(Vector3D &normal) const
DGtal::LatticePolytope2D< InternalSpace2 >
DGtal::IntegerComputer
Aim: This class gathers several types and methods to make computation with integers.
Definition: IntegerComputer.h:83
DGtal::COBANaivePlaneComputer::isExtendable
bool isExtendable(TInputIterator it, TInputIterator itE) const
DGtal::COBANaivePlaneComputer::end
ConstIterator end() const
DGtal::COBANaivePlaneComputer::const_pointer
PointSet::const_pointer const_pointer
Definition: COBANaivePlaneComputer.h:152
DGtal::COBANaivePlaneComputer::State::N
InternalPoint3 N
Definition: COBANaivePlaneComputer.h:178
DGtal::Dimension
DGtal::uint32_t Dimension
Definition: Common.h:133
DGtal::COBANaivePlaneComputer::extendAsIs
bool extendAsIs(const Point &p)
DGtal::COBANaivePlaneComputer::MyIntegerComputer
IntegerComputer< InternalInteger > MyIntegerComputer
Definition: COBANaivePlaneComputer.h:145
DGtal::COBANaivePlaneComputer::IntegerVector3
PointVector< 3, InternalInteger > IntegerVector3
Definition: COBANaivePlaneComputer.h:147
DGtal::COBANaivePlaneComputer::updateMinMax
bool updateMinMax(State &state, TInputIterator itB, TInputIterator itE) const
DGtal::COBANaivePlaneComputer::myState
State myState
Definition: COBANaivePlaneComputer.h:459
DGtal::COBANaivePlaneComputer::getUnitNormal
void getUnitNormal(Vector3D &normal) const
DGtal::COBANaivePlaneComputer::myG
InternalInteger myG
Definition: COBANaivePlaneComputer.h:456
DGtal::COBANaivePlaneComputer::max_size
Size max_size() const
DGtal::COBANaivePlaneComputer::Primitive
ParallelStrip< Space, true, true > Primitive
Definition: COBANaivePlaneComputer.h:146
DGtal::SpaceND
Definition: SpaceND.h:96
DGtal::COBANaivePlaneComputer::COBANaivePlaneComputer
COBANaivePlaneComputer(const COBANaivePlaneComputer &other)
DGtal::COBANaivePlaneComputer::Iterator
PointSet::iterator Iterator
Definition: COBANaivePlaneComputer.h:143
DGtal::COBANaivePlaneComputer::_v
InternalInteger _v
Definition: COBANaivePlaneComputer.h:462
DGtal::COBANaivePlaneComputer::InternalPoint3
PointVector< 3, InternalInteger > InternalPoint3
Definition: COBANaivePlaneComputer.h:160
DGtal::COBANaivePlaneComputer::difference_type
PointSet::difference_type difference_type
Definition: COBANaivePlaneComputer.h:155
DGtal::COBANaivePlaneComputer::State::centroid
InternalPoint3 centroid
Definition: COBANaivePlaneComputer.h:177
DGtal::COBANaivePlaneComputer::operator()
bool operator()(const Point &p) const
DGtal::COBANaivePlaneComputer::computeMinMax
void computeMinMax(State &state, TInputIterator itB, TInputIterator itE) const
DGtal::COBANaivePlaneComputer::extend
bool extend(TInputIterator it, TInputIterator itE)
DGtal::COBANaivePlaneComputer::State::max
InternalInteger max
Definition: COBANaivePlaneComputer.h:172
DGtal::COBANaivePlaneComputer::myCst2
InternalInteger myCst2
Definition: COBANaivePlaneComputer.h:461
DGtal::COBANaivePlaneComputer::InternalInteger
TInternalInteger InternalInteger
Definition: COBANaivePlaneComputer.h:144
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
DGtal::COBANaivePlaneComputer::const_iterator
PointSet::const_iterator const_iterator
Definition: COBANaivePlaneComputer.h:151
DGtal::COBANaivePlaneComputer::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::COBANaivePlaneComputer::State::ptMin
Point ptMin
Definition: COBANaivePlaneComputer.h:175
DGtal::COBANaivePlaneComputer::complexity
Size complexity() const
DGtal::COBANaivePlaneComputer::State::ptMax
Point ptMax
Definition: COBANaivePlaneComputer.h:174
DGtal::COBANaivePlaneComputer::operator=
COBANaivePlaneComputer & operator=(const COBANaivePlaneComputer &other)
DGtal::COBANaivePlaneComputer::State::cip
ConvexPolygonZ2 cip
Definition: COBANaivePlaneComputer.h:176
DGtal::COBANaivePlaneComputer::getBounds
void getBounds(double &min, double &max) const
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
DGtal::COBANaivePlaneComputer::ConvexPolygonZ2
LatticePolytope2D< InternalSpace2 > ConvexPolygonZ2
Definition: COBANaivePlaneComputer.h:163
DGtal::COBANaivePlaneComputer::myWidth
InternalPoint2 myWidth
Definition: COBANaivePlaneComputer.h:457
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::COBANaivePlaneComputer::~COBANaivePlaneComputer
~COBANaivePlaneComputer()
DGtal::COBANaivePlaneComputer::const_reference
PointSet::const_reference const_reference
Definition: COBANaivePlaneComputer.h:153
DGtal::ClosedIntegerHalfPlane
Aim: A half-space specified by a vector N and a constant c. The half-space is the set .
Definition: ClosedIntegerHalfPlane.h:64
DGtal::COBANaivePlaneComputer::begin
ConstIterator begin() const
DGtal::COBANaivePlaneComputer::myAxis
Dimension myAxis
Definition: COBANaivePlaneComputer.h:455
DGtal::COBANaivePlaneComputer::ic
MyIntegerComputer & ic() const
DGtal::COBANaivePlaneComputer::myCst1
InternalInteger myCst1
Definition: COBANaivePlaneComputer.h:460
DGtal::COBANaivePlaneComputer::BOOST_STATIC_ASSERT
BOOST_STATIC_ASSERT((TSpace::dimension==3))
DGtal::COBANaivePlaneComputer::State
Definition: COBANaivePlaneComputer.h:171
DGtal::PointVector< dim, Integer >
DGtal::COBANaivePlaneComputer::checkPlaneWidth
bool checkPlaneWidth(const State &state) const
DGtal::COBANaivePlaneComputer::PointSet
std::set< Point > PointSet
Definition: COBANaivePlaneComputer.h:140
DGtal::COBANaivePlaneComputer::value_type
PointSet::value_type value_type
Definition: COBANaivePlaneComputer.h:154
DGtal::COBANaivePlaneComputer::computeCentroidAndNormal
void computeCentroidAndNormal(State &state) const
DGtal::COBANaivePlaneComputer::minimalPoint
const Point & minimalPoint() const
DGtal::COBANaivePlaneComputer::empty
bool empty() const
DGtal::COBANaivePlaneComputer::isExtendable
bool isExtendable(const Point &p) const
DGtal::COBANaivePlaneComputer::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CSpace< TSpace >))
DGtal::COBANaivePlaneComputer
Aim: A class that contains the COBA algorithm (Emilie Charrier, Lilian Buzer, DGCI2008) for recognizi...
Definition: COBANaivePlaneComputer.h:130
DGtal::COBANaivePlaneComputer::maxSize
Size maxSize() const
DGtal::COBANaivePlaneComputer::computeGradient
void computeGradient(InternalPoint2 &grad, const State &state) const
DGtal::COBANaivePlaneComputer::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CInteger< TInternalInteger >))
InternalInteger
DGtal::int64_t InternalInteger
Definition: greedy-plane-segmentation-ex2.cpp:87
DGtal::COBANaivePlaneComputer::maximalPoint
const Point & maximalPoint() const
DGtal::COBANaivePlaneComputer::isValid
bool isValid() const
DGtal::COBANaivePlaneComputer::_grad
InternalPoint2 _grad
Definition: COBANaivePlaneComputer.h:464
DGtal::COBANaivePlaneComputer::ConstIterator
PointSet::const_iterator ConstIterator
Definition: COBANaivePlaneComputer.h:142
DGtal::COBANaivePlaneComputer::Point
Space::Point Point
Definition: COBANaivePlaneComputer.h:139
DGtal::COBANaivePlaneComputer::Size
PointSet::size_type Size
Definition: COBANaivePlaneComputer.h:141
DGtal::COBANaivePlaneComputer::exactNormal
const IntegerVector3 & exactNormal() const