DGtal  0.9.2
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
125 template <typename TInputPoint,
126  typename TConstIterator = typename std::vector< TInputPoint >::const_iterator >
127 
129 {
130 
131  // ----------------------- public types --------------------------------------
132  BOOST_STATIC_ASSERT(( TInputPoint::dimension == 2 ));
133  BOOST_CONCEPT_ASSERT((boost_concepts::ReadableIterator<TConstIterator>));
134 
135 public:
139  typedef TInputPoint InputPoint;
140 
144  typedef std::vector< InputPoint > InputPointContainer;
145  typedef typename InputPointContainer::size_type Size;
146  typedef typename InputPointContainer::const_iterator ContainerConstIterator;
148 
149  typedef typename InputPointContainer::iterator Iterator;
150  typedef TConstIterator ConstIterator;
152 
158 
163 
164  // ----------------------- internal types --------------------------------------
165 
166 private:
167  struct State{
170  InputPoint lastFront;
172  InputPoint lastBack;
174  InputPoint edgePh;
176  InputPoint edgeQh;
178  InputPoint vertexSh;
181  };
182 
183 
184  // ----------------------- Standard services ------------------------------
185 public:
186 
187 
188 
197  AlphaThickSegmentComputer(const double maximalThickness = 1.0,
198  const ThicknessDef &thicknessDefinition = functions::Hull2D::HorizontalVerticalThickness,
199  const double thickCompPrecision=1e-6);
200 
201 
202 
207 
208 
215 
216 
224 
225 
229  Self getSelf() const;
230 
231 
235  Reverse getReverse() const;
236 
244  bool operator==( const AlphaThickSegmentComputer & other ) const;
245 
252  bool operator!=( const AlphaThickSegmentComputer & other ) const;
253 
254 
255 
256  //-------------------- model of ForwardContainer -----------------------------
257 public:
258 
264  Size size() const;
265 
266 
272  bool empty() const;
273 
274 
280  ContainerConstIterator containerBegin() const;
281 
282 
288  ContainerConstIterator containerEnd() const;
289 
294  ConvexhullConstIterator convexhullBegin() const;
295 
296 
301  ConvexhullConstIterator convexhullEnd() const;
302 
308  ConstIterator begin() const;
309 
310 
317  ConstIterator end() const;
318 
319 
323  Size max_size() const;
324 
325 
326 
327 
328  //-------------------- model of CForwardSegmentComputer ----------------
329 
330 public:
331 
339  void init(const ConstIterator &it);
340 
341 
353  bool extendFront();
354 
355 
365  bool isExtendableFront();
366 
367 
377  bool isExtendableFront(const InputPoint &aPoint);
378 
379 
391  bool extendFront(const InputPoint &aPoint);
392 
393 
394 
395  //-------------------- Primitive services -----------------------------
396 
397 
403  Primitive primitive() const;
404 
405 
406 
407 
408  // ----------------------- Interface --------------------------------------
409 public:
410 
411 
416  bool isValid() const;
417 
418 
424  std::pair<InputPoint, InputPoint> getExtremityPoints() const;
425 
426 
435  std::pair<std::pair<InputPoint, InputPoint>, InputPoint>
437 
438 
446  void computeParallelStripParams(double &mu, PointD &N, double &nu) const;
447 
448 
455  PointD getNormal() const;
456 
457 
461  double getThickness() const;
462 
463 
467  double getMu() const;
468 
469 
473  double getNu() const;
474 
475 
479  double getSegmentLength() const;
480 
481 
485  bool isStoringSegmentPoints() const;
486 
487 
491  unsigned int getNumberSegmentPoints() const;
492 
493 
494 
495  // ------------------------- Display services ------------------------------
496 
497 
501  std::vector<InputPoint> getConvexHull() const;
502 
503 
504 
522  void getBoundingBoxFromExtremPoints(const InputPoint &aFirstPt,
523  const InputPoint &aLastPt,
524  PointD &pt1LongestSegment1,
525  PointD &pt2LongestSegment1,
526  PointD &pt3LongestSegment2,
527  PointD &pt4LongestSegment2,
528  double minVisibleWidthBounds = 0.2) const;
529 
530 
549  void getBoundingBox(PointD &pt1LongestSegment1,
550  PointD &pt2LongestSegment1,
551  PointD &pt3LongestSegment2,
552  PointD &pt4LongestSegment2) const;
553 
554 
555 
556 
557 
561  std::string className() const;
562 
563 
569  void selfDisplay ( std::ostream & out ) const;
570 
571  // ------------------------- Protected Datas ------------------------------
572 protected:
573 
574 
578  ConstIterator myBegin;
579 
583  ConstIterator myEnd;
584 
585 
586 
587 
588  // ------------------------- Private Datas --------------------------------
589 private:
590 
594  mutable InputPointContainer myPointContainer;
595 
600 
605 
606 
610  ThicknessDef myThicknessDefinition;
611 
612 
617 
622 
624 
629 
630 
631 
632 
633  // ------------------------- Hidden services ------------------------------
634 protected:
635 
636 
637 
641  bool melkmanIsConvexValid() ;
642 
643 
653 
654 
655 
666  template<typename TPointD>
667  bool projectOnStraightLine(const TPointD & ptA, const TPointD & ptB,
668  const TPointD & ptC, PointD & ptProjected) const;
669 
670 
682  template<typename TConstIteratorG>
683  void computeExtremaPoints(const TConstIteratorG & itBegin, const TConstIteratorG & itEnd,
684  InputPoint & aFirstExtrPt, InputPoint & aLastExtrPt) const;
685 
686 
687  // ------------------------- Internals ------------------------------------
688 private:
689 
690 }; // end of class AlphaThickSegmentComputer
691 
692 
699 template <typename TInputPoint, typename TConstIterator>
700 std::ostream&
701 operator<< ( std::ostream & out, const AlphaThickSegmentComputer<TInputPoint, TConstIterator> & object );
702 
703 
704 } // namespace DGtal
705 
706 
708 // Includes inline functions.
709 #if !defined(BUILD_INLINE)
710 #include "DGtal/geometry/curves/AlphaThickSegmentComputer.ih"
711 #endif
712 
713 
714 // //
716 
717 #endif // !defined AlphaThickSegmentComputer_h
718 
719 #undef AlphaThickSegmentComputer_RECURSES
720 #endif // else defined(AlphaThickSegmentComputer_RECURSES)
AlphaThickSegmentComputer(const double maximalThickness=1.0, const ThicknessDef &thicknessDefinition=functions::Hull2D::HorizontalVerticalThickness, const double thickCompPrecision=1e-6)
void init(const ConstIterator &it)
unsigned int getNumberSegmentPoints() const
bool operator!=(const AlphaThickSegmentComputer &other) const
std::deque< Point >::const_iterator ConstIterator
BOOST_CONCEPT_ASSERT((boost_concepts::ReadableIterator< TConstIterator >))
ConvexhullConstIterator convexhullBegin() const
Aim: A parallel strip in the space is the intersection of two parallel half-planes such that each hal...
Definition: ParallelStrip.h:90
std::vector< InputPoint > InputPointContainer
DGtal::InHalfPlaneBySimple3x3Matrix< InputPoint, typename InputPoint::Component > Functor
ConstIterator begin() const
ThicknessDefinition
The 2 thickness definitions.
Definition: Hull2DHelpers.h:78
bool projectOnStraightLine(const TPointD &ptA, const TPointD &ptB, const TPointD &ptC, PointD &ptProjected) const
std::pair< std::pair< InputPoint, InputPoint >, InputPoint > getAntipodalLeaningPoints() const
ConvexhullConstIterator convexhullEnd() const
Aim: This class implements the on-line algorithm of Melkman for the computation of the convex hull of...
std::pair< InputPoint, InputPoint > getExtremityPoints() const
DGtal::MelkmanConvexHull< InputPoint, Functor > melkmanCH
InputPointContainer::const_iterator ContainerConstIterator
void getBoundingBoxFromExtremPoints(const InputPoint &aFirstPt, const InputPoint &aLastPt, PointD &pt1LongestSegment1, PointD &pt2LongestSegment1, PointD &pt3LongestSegment2, PointD &pt4LongestSegment2, double minVisibleWidthBounds=0.2) const
bool operator==(const AlphaThickSegmentComputer &other) const
AlphaThickSegmentComputer & operator=(const AlphaThickSegmentComputer &other)
InputPointContainer::iterator Iterator
void getBoundingBox(PointD &pt1LongestSegment1, PointD &pt2LongestSegment1, PointD &pt3LongestSegment2, PointD &pt4LongestSegment2) const
DGtal::MelkmanConvexHull< InputPoint, Functor >::ConstIterator ConvexhullConstIterator
DGtal is the top-level namespace which contains all DGtal functions and types.
ContainerConstIterator containerBegin() const
DGtal::functions::Hull2D::ThicknessDefinition ThicknessDef
DGtal::PointVector< 2, double > PointD
BOOST_STATIC_ASSERT((TInputPoint::dimension==2))
std::string className() const
ParallelStrip< SpaceND< 2, DGtal::int32_t >,true, true > Primitive
AlphaThickSegmentComputer< InputPoint, ConstIterator > Self
ConstIterator end() const
void computeExtremaPoints(const TConstIteratorG &itBegin, const TConstIteratorG &itEnd, InputPoint &aFirstExtrPt, InputPoint &aLastExtrPt) const
std::vector< InputPoint > getConvexHull() const
Aim: This class is devoted to the recognition of alpha thick segments as described in ...
ContainerConstIterator containerEnd() const
Aim: Class that implements an orientation functor, ie. it provides a way to compute the orientation o...
AlphaThickSegmentComputer< InputPoint, ReverseIterator< ConstIterator > > Reverse
InputPointContainer::size_type Size
void computeParallelStripParams(double &mu, PointD &N, double &nu) const
void selfDisplay(std::ostream &out) const