DGtal  1.3.beta
AlphaThickSegmentComputer.h
1 
17 #pragma once
18 
35 #if defined(AlphaThickSegmentComputer_RECURSES)
36 #error Recursive header files inclusion detected in AlphaThickSegmentComputer.h
37 #else // defined(AlphaThickSegmentComputer_RECURSES)
38 
39 #define AlphaThickSegmentComputer_RECURSES
40 
41 #if !defined AlphaThickSegmentComputer_h
42 
43 #define AlphaThickSegmentComputer_h
44 
46 // Inclusions
47 #include <iostream>
48 #include "DGtal/base/Common.h"
49 #include "DGtal/base/ReverseIterator.h"
50 #include "DGtal/kernel/SpaceND.h"
51 #include "DGtal/geometry/surfaces/ParallelStrip.h"
52 #include "DGtal/geometry/tools/MelkmanConvexHull.h"
53 #include "DGtal/geometry/tools/determinant/InHalfPlaneBySimple3x3Matrix.h"
55 
56 namespace DGtal
57 {
58 
60 // class AlphaThickSegmentComputer
124 template <typename TInputPoint,
125  typename TConstIterator = typename std::vector< TInputPoint >::const_iterator >
126 
128 {
129 
130  // ----------------------- public types --------------------------------------
131  BOOST_STATIC_ASSERT(( TInputPoint::dimension == 2 ));
132  BOOST_CONCEPT_ASSERT((boost_concepts::ReadableIterator<TConstIterator>));
133 
134 public:
138  typedef TInputPoint InputPoint;
139 
143  typedef std::vector< InputPoint > InputPointContainer;
144  typedef typename InputPointContainer::size_type Size;
145  typedef typename InputPointContainer::const_iterator ContainerConstIterator;
147 
148  typedef typename InputPointContainer::iterator Iterator;
149  typedef TConstIterator ConstIterator;
151 
157 
162 
163  // ----------------------- internal types --------------------------------------
164 
165 private:
166  struct State{
180  };
181 
182 
183  // ----------------------- Standard services ------------------------------
184 public:
185 
186 
187 
196  AlphaThickSegmentComputer(const double maximalThickness = 1.0,
198  const double thickCompPrecision=1e-6);
199 
200 
201 
206 
207 
214 
215 
223 
224 
228  Self getSelf() const;
229 
230 
234  Reverse getReverse() const;
235 
243  bool operator==( const AlphaThickSegmentComputer & other ) const;
244 
251  bool operator!=( const AlphaThickSegmentComputer & other ) const;
252 
253 
254 
255  //-------------------- model of ForwardContainer -----------------------------
256 public:
257 
263  Size size() const;
264 
265 
271  bool empty() const;
272 
273 
280 
281 
288 
294 
295 
301 
307  ConstIterator begin() const;
308 
309 
316  ConstIterator end() const;
317 
318 
322  Size max_size() const;
323 
324 
325 
326 
327  //-------------------- model of CForwardSegmentComputer ----------------
328 
329 public:
330 
338  void init(const ConstIterator &it);
339 
340 
352  bool extendFront();
353 
354 
364  bool isExtendableFront();
365 
366 
376  bool isExtendableFront(const InputPoint &aPoint);
377 
378 
390  bool extendFront(const InputPoint &aPoint);
391 
392 
393 
394  //-------------------- Primitive services -----------------------------
395 
396 
402  Primitive primitive() const;
403 
404 
405 
406 
407  // ----------------------- Interface --------------------------------------
408 public:
409 
410 
415  bool isValid() const;
416 
417 
423  std::pair<InputPoint, InputPoint> getExtremityPoints() const;
424 
425 
434  std::pair<std::pair<InputPoint, InputPoint>, InputPoint>
436 
437 
445  void computeParallelStripParams(double &mu, PointD &N, double &nu) const;
446 
447 
454  PointD getNormal() const;
455 
456 
460  double getThickness() const;
461 
462 
466  double getMu() const;
467 
468 
472  double getNu() const;
473 
474 
478  double getSegmentLength() const;
479 
480 
484  bool isStoringSegmentPoints() const;
485 
486 
490  unsigned int getNumberSegmentPoints() const;
491 
492 
493 
494  // ------------------------- Display services ------------------------------
495 
496 
500  std::vector<InputPoint> getConvexHull() const;
501 
502 
503 
521  void getBoundingBoxFromExtremPoints(const InputPoint &aFirstPt,
522  const InputPoint &aLastPt,
523  PointD &pt1LongestSegment1,
524  PointD &pt2LongestSegment1,
525  PointD &pt3LongestSegment2,
526  PointD &pt4LongestSegment2,
527  double minVisibleWidthBounds = 0.2) const;
528 
529 
548  void getBoundingBox(PointD &pt1LongestSegment1,
549  PointD &pt2LongestSegment1,
550  PointD &pt3LongestSegment2,
551  PointD &pt4LongestSegment2) const;
552 
553 
554 
555 
556 
560  std::string className() const;
561 
562 
568  void selfDisplay ( std::ostream & out ) const;
569 
570  // ------------------------- Protected Datas ------------------------------
571 protected:
572 
573 
578 
583 
584 
585 
586 
587  // ------------------------- Private Datas --------------------------------
588 private:
589 
594 
599 
604 
605 
610 
611 
616 
621 
623 
628 
629 
630 
631 
632  // ------------------------- Hidden services ------------------------------
633 protected:
634 
635 
636 
640  bool melkmanIsConvexValid() ;
641 
642 
652 
653 
654 
665  template<typename TPoint, typename TPointD>
666  bool projectOnStraightLine(const TPoint & ptA, const TPoint & ptB,
667  const TPoint & ptC, TPointD & ptProjected) const;
668 
669 
681  template<typename TConstIteratorG>
682  void computeExtremaPoints(const TConstIteratorG & itBegin, const TConstIteratorG & itEnd,
683  InputPoint & aFirstExtrPt, InputPoint & aLastExtrPt) const;
684 
685 
686  // ------------------------- Internals ------------------------------------
687 private:
688 
689 }; // end of class AlphaThickSegmentComputer
690 
691 
698 template <typename TInputPoint, typename TConstIterator>
699 std::ostream&
700 operator<< ( std::ostream & out, const AlphaThickSegmentComputer<TInputPoint, TConstIterator> & object );
701 
702 
703 } // namespace DGtal
704 
705 
707 // Includes inline functions.
708 #if !defined(BUILD_INLINE)
709 #include "DGtal/geometry/curves/AlphaThickSegmentComputer.ih"
710 #endif
711 
712 
713 // //
715 
716 #endif // !defined AlphaThickSegmentComputer_h
717 
718 #undef AlphaThickSegmentComputer_RECURSES
719 #endif // else defined(AlphaThickSegmentComputer_RECURSES)
DGtal::AlphaThickSegmentComputer::myEnd
ConstIterator myEnd
Definition: AlphaThickSegmentComputer.h:582
DGtal::AlphaThickSegmentComputer::State::actualThickness
double actualThickness
Definition: AlphaThickSegmentComputer.h:179
DGtal::AlphaThickSegmentComputer::Primitive
ParallelStrip< SpaceND< 2, DGtal::int32_t >,true, true > Primitive
Definition: AlphaThickSegmentComputer.h:150
DGtal::AlphaThickSegmentComputer::getMu
double getMu() const
DGtal::AlphaThickSegmentComputer::convexhullEnd
ConvexhullConstIterator convexhullEnd() const
DGtal::AlphaThickSegmentComputer::myMaximalThickness
double myMaximalThickness
Definition: AlphaThickSegmentComputer.h:598
DGtal::AlphaThickSegmentComputer::Self
AlphaThickSegmentComputer< InputPoint, ConstIterator > Self
Definition: AlphaThickSegmentComputer.h:158
DGtal::AlphaThickSegmentComputer::ThicknessDef
DGtal::functions::Hull2D::ThicknessDefinition ThicknessDef
Definition: AlphaThickSegmentComputer.h:146
DGtal::AlphaThickSegmentComputer::State::lastBack
InputPoint lastBack
Definition: AlphaThickSegmentComputer.h:171
DGtal::AlphaThickSegmentComputer::myPreviousState
State myPreviousState
Definition: AlphaThickSegmentComputer.h:620
DGtal::AlphaThickSegmentComputer::BOOST_STATIC_ASSERT
BOOST_STATIC_ASSERT((TInputPoint::dimension==2))
DGtal::AlphaThickSegmentComputer::State::lastFront
InputPoint lastFront
Definition: AlphaThickSegmentComputer.h:169
DGtal::AlphaThickSegmentComputer::getBoundingBoxFromExtremPoints
void getBoundingBoxFromExtremPoints(const InputPoint &aFirstPt, const InputPoint &aLastPt, PointD &pt1LongestSegment1, PointD &pt2LongestSegment1, PointD &pt3LongestSegment2, PointD &pt4LongestSegment2, double minVisibleWidthBounds=0.2) const
DGtal::AlphaThickSegmentComputer::myState
State myState
Definition: AlphaThickSegmentComputer.h:615
DGtal::AlphaThickSegmentComputer::InputPointContainer
std::vector< InputPoint > InputPointContainer
Definition: AlphaThickSegmentComputer.h:143
DGtal::AlphaThickSegmentComputer::Functor
DGtal::InHalfPlaneBySimple3x3Matrix< InputPoint, typename InputPoint::Component > Functor
Definition: AlphaThickSegmentComputer.h:160
DGtal::AlphaThickSegmentComputer::operator==
bool operator==(const AlphaThickSegmentComputer &other) const
DGtal::AlphaThickSegmentComputer::init
void init(const ConstIterator &it)
DGtal::AlphaThickSegmentComputer::State::melkmanCH
DGtal::MelkmanConvexHull< InputPoint, Functor > melkmanCH
Definition: AlphaThickSegmentComputer.h:167
DGtal::AlphaThickSegmentComputer::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::AlphaThickSegmentComputer::myThicknessCompPrecision
double myThicknessCompPrecision
Definition: AlphaThickSegmentComputer.h:603
aPoint
const Point aPoint(3, 4)
DGtal::AlphaThickSegmentComputer::ContainerConstIterator
InputPointContainer::const_iterator ContainerConstIterator
Definition: AlphaThickSegmentComputer.h:145
DGtal::AlphaThickSegmentComputer::isExtendableFront
bool isExtendableFront()
DGtal::AlphaThickSegmentComputer::extendFront
bool extendFront()
DGtal::AlphaThickSegmentComputer::operator!=
bool operator!=(const AlphaThickSegmentComputer &other) const
DGtal::AlphaThickSegmentComputer::operator=
AlphaThickSegmentComputer & operator=(const AlphaThickSegmentComputer &other)
DGtal::AlphaThickSegmentComputer::myThicknessDefinition
ThicknessDef myThicknessDefinition
Definition: AlphaThickSegmentComputer.h:609
DGtal::AlphaThickSegmentComputer::getNumberSegmentPoints
unsigned int getNumberSegmentPoints() const
DGtal::AlphaThickSegmentComputer::PointD
DGtal::PointVector< 2, double > PointD
Definition: AlphaThickSegmentComputer.h:156
DGtal::AlphaThickSegmentComputer::getAntipodalLeaningPoints
std::pair< std::pair< InputPoint, InputPoint >, InputPoint > getAntipodalLeaningPoints() const
DGtal::AlphaThickSegmentComputer
Aim: This class is devoted to the recognition of alpha thick segments as described in ....
Definition: AlphaThickSegmentComputer.h:127
DGtal::AlphaThickSegmentComputer::computeExtremaPoints
void computeExtremaPoints(const TConstIteratorG &itBegin, const TConstIteratorG &itEnd, InputPoint &aFirstExtrPt, InputPoint &aLastExtrPt) const
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
DGtal::AlphaThickSegmentComputer::getExtremityPoints
std::pair< InputPoint, InputPoint > getExtremityPoints() const
DGtal::AlphaThickSegmentComputer::ConstIterator
TConstIterator ConstIterator
Definition: AlphaThickSegmentComputer.h:149
DGtal::AlphaThickSegmentComputer::myIsStoringPoints
bool myIsStoringPoints
Definition: AlphaThickSegmentComputer.h:622
DGtal::AlphaThickSegmentComputer::empty
bool empty() const
DGtal::AlphaThickSegmentComputer::getNu
double getNu() const
DGtal::AlphaThickSegmentComputer::updateMainHeightAndAntiPodal
double updateMainHeightAndAntiPodal()
DGtal::AlphaThickSegmentComputer::State
Definition: AlphaThickSegmentComputer.h:166
DGtal::AlphaThickSegmentComputer::isStoringSegmentPoints
bool isStoringSegmentPoints() const
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::AlphaThickSegmentComputer::computeParallelStripParams
void computeParallelStripParams(double &mu, PointD &N, double &nu) const
DGtal::AlphaThickSegmentComputer::projectOnStraightLine
bool projectOnStraightLine(const TPoint &ptA, const TPoint &ptB, const TPoint &ptC, TPointD &ptProjected) const
DGtal::AlphaThickSegmentComputer::primitive
Primitive primitive() const
DGtal::AlphaThickSegmentComputer::getSelf
Self getSelf() const
DGtal::InHalfPlaneBySimple3x3Matrix
Aim: Class that implements an orientation functor, ie. it provides a way to compute the orientation o...
Definition: InHalfPlaneBySimple3x3Matrix.h:91
DGtal::AlphaThickSegmentComputer::isValid
bool isValid() const
DGtal::AlphaThickSegmentComputer::className
std::string className() const
DGtal::AlphaThickSegmentComputer::end
ConstIterator end() const
DGtal::AlphaThickSegmentComputer::InputPoint
TInputPoint InputPoint
Definition: AlphaThickSegmentComputer.h:138
DGtal::AlphaThickSegmentComputer::getNormal
PointD getNormal() const
DGtal::AlphaThickSegmentComputer::begin
ConstIterator begin() const
DGtal::AlphaThickSegmentComputer::melkmanIsConvexValid
bool melkmanIsConvexValid()
DGtal::AlphaThickSegmentComputer::containerEnd
ContainerConstIterator containerEnd() const
DGtal::AlphaThickSegmentComputer::getThickness
double getThickness() const
DGtal::AlphaThickSegmentComputer::Iterator
InputPointContainer::iterator Iterator
Definition: AlphaThickSegmentComputer.h:148
DGtal::AlphaThickSegmentComputer::Reverse
AlphaThickSegmentComputer< InputPoint, ReverseIterator< ConstIterator > > Reverse
Definition: AlphaThickSegmentComputer.h:159
DGtal::MelkmanConvexHull::ConstIterator
std::deque< Point >::const_iterator ConstIterator
Definition: MelkmanConvexHull.h:123
DGtal::ParallelStrip
Aim: A parallel strip in the space is the intersection of two parallel half-planes such that each hal...
Definition: ParallelStrip.h:90
DGtal::AlphaThickSegmentComputer::State::edgeQh
InputPoint edgeQh
Definition: AlphaThickSegmentComputer.h:175
DGtal::AlphaThickSegmentComputer::getBoundingBox
void getBoundingBox(PointD &pt1LongestSegment1, PointD &pt2LongestSegment1, PointD &pt3LongestSegment2, PointD &pt4LongestSegment2) const
DGtal::functions::Hull2D::HorizontalVerticalThickness
@ HorizontalVerticalThickness
Definition: Hull2DHelpers.h:78
DGtal::functions::Hull2D::ThicknessDefinition
ThicknessDefinition
The 2 thickness definitions.
Definition: Hull2DHelpers.h:78
DGtal::AlphaThickSegmentComputer::State::vertexSh
InputPoint vertexSh
Definition: AlphaThickSegmentComputer.h:177
DGtal::AlphaThickSegmentComputer::convexhullBegin
ConvexhullConstIterator convexhullBegin() const
DGtal::AlphaThickSegmentComputer::size
Size size() const
DGtal::MelkmanConvexHull
Aim: This class implements the on-line algorithm of Melkman for the computation of the convex hull of...
Definition: MelkmanConvexHull.h:89
DGtal::AlphaThickSegmentComputer::myNbPointsAddedFromIterators
unsigned int myNbPointsAddedFromIterators
Definition: AlphaThickSegmentComputer.h:627
DGtal::PointVector< 2, double >
DGtal::AlphaThickSegmentComputer::getSegmentLength
double getSegmentLength() const
DGtal::AlphaThickSegmentComputer::myPointContainer
InputPointContainer myPointContainer
Definition: AlphaThickSegmentComputer.h:593
DGtal::AlphaThickSegmentComputer::myBegin
ConstIterator myBegin
Definition: AlphaThickSegmentComputer.h:577
DGtal::AlphaThickSegmentComputer::State::edgePh
InputPoint edgePh
Definition: AlphaThickSegmentComputer.h:173
DGtal::AlphaThickSegmentComputer::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((boost_concepts::ReadableIterator< TConstIterator >))
DGtal::AlphaThickSegmentComputer::AlphaThickSegmentComputer
AlphaThickSegmentComputer(const double maximalThickness=1.0, const ThicknessDef &thicknessDefinition=functions::Hull2D::HorizontalVerticalThickness, const double thickCompPrecision=1e-6)
DGtal::AlphaThickSegmentComputer::Size
InputPointContainer::size_type Size
Definition: AlphaThickSegmentComputer.h:144
DGtal::AlphaThickSegmentComputer::ConvexhullConstIterator
DGtal::MelkmanConvexHull< InputPoint, Functor >::ConstIterator ConvexhullConstIterator
Definition: AlphaThickSegmentComputer.h:161
DGtal::AlphaThickSegmentComputer::~AlphaThickSegmentComputer
~AlphaThickSegmentComputer()
DGtal::AlphaThickSegmentComputer::getConvexHull
std::vector< InputPoint > getConvexHull() const
DGtal::AlphaThickSegmentComputer::getReverse
Reverse getReverse() const
DGtal::AlphaThickSegmentComputer::containerBegin
ContainerConstIterator containerBegin() const
DGtal::AlphaThickSegmentComputer::max_size
Size max_size() const