DGtal 1.3.0
Loading...
Searching...
No Matches
FP.h
1
17#pragma once
18
31#if defined(FP_RECURSES)
32#error Recursive header files inclusion detected in FP.h
33#else // defined(FP_RECURSES)
35#define FP_RECURSES
36
37#if !defined FP_h
39#define FP_h
40
42// Inclusions
43#include <iostream>
44#include <list>
45#include "DGtal/kernel/CInteger.h"
46#include "DGtal/kernel/PointVector.h"
47#include "DGtal/geometry/curves/ArithmeticalDSSComputer.h"
48#include "DGtal/base/Circulator.h"
49#include "DGtal/base/Exceptions.h"
50#include "DGtal/base/Common.h"
51#include "DGtal/io/Color.h"
53
54namespace DGtal
55{
56
57 namespace detail
58 {
60
73 template <typename TDSS>
75 {
76 public:
80 typedef TDSS DSS;
81 protected:
85 TDSS* myDSS;
86 public:
91 bool isExtendableFront() const
92 {
93 return myDSS->isExtendableFront();
94 }
101 {
102 return myDSS->extendFront();
103 }
110 {
111 return myDSS->retractBack();
112 }
117 typename DSS::ConstIterator end()
118 {
119 return myDSS->end();
120 }
121
126 virtual ~DSSDecorator() {}
131 virtual typename TDSS::Point firstLeaningPoint() const = 0;
136 virtual typename TDSS::Point lastLeaningPoint() const = 0;
141 virtual bool isInConvexPart() const = 0;
142 };
143
159 template <typename TDSS>
161 {
162 public:
168 {
169 this->myDSS = &aDSS;
170 }
175 typename TDSS::Point firstLeaningPoint() const
176 {
177 return this->myDSS->Uf();
178 }
183 typename TDSS::Point lastLeaningPoint() const
184 {
185 return this->myDSS->Ul();
186 }
191 bool isInConvexPart() const { return true; }
192
193 };
194
210 template <typename TDSS>
212 {
213 public:
219 {
220 this->myDSS = &aDSS;
221 }
226 typename TDSS::Point firstLeaningPoint() const
227 {
228 return this->myDSS->Lf();
229 }
234 typename TDSS::Point lastLeaningPoint() const
235 {
236 return this->myDSS->Ll();
237 }
242 bool isInConvexPart() const { return false; }
243 };
244
245 } //end namespace detail
247
248
250 // template class FP
291 template <typename TIterator, typename TInteger, int connectivity>
292 class FP
293 {
294
295 // ----------------------- Types ------------------------------
296 public:
297
298
300
303
306
308
309 typedef std::list<Point> Polygon;
310
311
312
313 // ----------------------- Standard services ------------------------------
314 public:
315
321 FP(const TIterator& itb, const TIterator& ite);
322
327
328 // ----------------------- Interface --------------------------------------
329 public:
330
334 const Polygon& polygon() const;
335
339 bool isClosed() const;
340
341
346 bool isValid() const;
347
348
352 typename Polygon::size_type size() const;
353
354
359 template <typename OutputIterator>
360 OutputIterator copyFP(OutputIterator result) const;
361
366 template <typename OutputIterator>
367 OutputIterator copyMLP(OutputIterator result) const;
368
369
370 // ------------------------- Protected Datas ------------------------------
371 private:
372
373 // ------------------------- Private Datas --------------------------------
374 private:
375
380
381 protected:
382
383
384
385 // ------------------------- Hidden services ------------------------------
386 private:
387
396 template<typename Adapter>
397 Adapter* initConvexityConcavity( typename Adapter::DSS &aDSS );
398
408 template<typename Adapter>
409 bool removingStep( Adapter* adapter );
410
422 template<typename Adapter>
423 bool addingStep( Adapter* adapter,
424 const typename Adapter::DSS::ConstIterator& itEnd );
425
433 template<typename Adapter>
434 void addingStep( Adapter* adapter );
435
436
442 void algorithm(const TIterator& itb, const TIterator& ite);
443
450 void algorithm(const TIterator& itb, const TIterator& ite, IteratorType );
451
458 void algorithm(const TIterator& itb, const TIterator& ite, CirculatorType );
459
460
461
462 // ------------------------- Hidden helpers ------------------------------
463
471 bool isValid(const Point& a,const Point& b, const Point& c) const;
472
479 bool quadrant (const Vector& v, const int& q) const;
480
489 RealPoint getRealPoint (const Point& a,const Point& b, const Point& c) const;
490
491
492 // ----------------------------------------------------------------------
498 FP ( const FP & other );
499
506 FP & operator= ( const FP & other );
507
508 // ------------------------- Display ------------------------------------
509 public:
510
515 void selfDisplay ( std::ostream & out ) const;
516
517
518 // --------------- CDrawableWithBoard2D realization --------------------
519 public:
520
524 std::string className() const;
525
526 }; // end of class FP
527
528
535 template <typename TIterator, typename TInteger, int connectivity>
536 std::ostream&
537 operator<< ( std::ostream & out, const FP<TIterator,TInteger,connectivity> & object );
538
539} // namespace DGtal
540
541
543// Includes inline functions.
544#include "DGtal/geometry/curves/FP.ih"
545
546// //
548
549#endif // !defined FP_h
550
551#undef FP_RECURSES
552#endif // else defined(FP_RECURSES)
Aim: This class is a wrapper around ArithmeticalDSS that is devoted to the dynamic recognition of dig...
Aim: Computes the faithful polygon (FP) of a range of 4/8-connected 2D Points.
Definition: FP.h:293
void algorithm(const TIterator &itb, const TIterator &ite, CirculatorType)
bool isValid(const Point &a, const Point &b, const Point &c) const
void algorithm(const TIterator &itb, const TIterator &ite, IteratorType)
DGtal::PointVector< 2, double > RealPoint
Definition: FP.h:304
DGtal::PointVector< 2, TInteger > Vector
Definition: FP.h:302
void algorithm(const TIterator &itb, const TIterator &ite)
DGtal::PointVector< 2, TInteger > Point
Definition: FP.h:301
DGtal::PointVector< 2, double > RealVector
Definition: FP.h:305
OutputIterator copyFP(OutputIterator result) const
Adapter * initConvexityConcavity(typename Adapter::DSS &aDSS)
DGtal::ArithmeticalDSSComputer< TIterator, TInteger, connectivity > DSSComputer
Definition: FP.h:307
bool isClosed() const
bool quadrant(const Vector &v, const int &q) const
BOOST_CONCEPT_ASSERT((concepts::CInteger< TInteger >))
const Polygon & polygon() const
std::list< Point > Polygon
Definition: FP.h:309
std::string className() const
bool addingStep(Adapter *adapter, const typename Adapter::DSS::ConstIterator &itEnd)
Polygon myPolygon
Definition: FP.h:379
RealPoint getRealPoint(const Point &a, const Point &b, const Point &c) const
bool removingStep(Adapter *adapter)
void addingStep(Adapter *adapter)
FP(const FP &other)
FP(const TIterator &itb, const TIterator &ite)
Polygon::size_type size() const
void selfDisplay(std::ostream &out) const
bool isValid() const
OutputIterator copyMLP(OutputIterator result) const
FP & operator=(const FP &other)
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:593
Aim: adapter for TDSS used by FP in CONCAVE parts. Has 2 methods:
Definition: FP.h:212
TDSS::Point firstLeaningPoint() const
Definition: FP.h:226
TDSS::Point lastLeaningPoint() const
Definition: FP.h:234
Aim: adapter for TDSS used by FP in CONVEX parts. Has 2 methods:
Definition: FP.h:161
TDSS::Point firstLeaningPoint() const
Definition: FP.h:175
TDSS::Point lastLeaningPoint() const
Definition: FP.h:183
Aim: Abstract DSSDecorator for ArithmeticalDSSComputer. Has 2 virtual methods returning the first and...
Definition: FP.h:75
virtual bool isInConvexPart() const =0
bool isExtendableFront() const
Definition: FP.h:91
virtual ~DSSDecorator()
Definition: FP.h:126
virtual TDSS::Point firstLeaningPoint() const =0
virtual TDSS::Point lastLeaningPoint() const =0
DSS::ConstIterator end()
Definition: FP.h:117
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
Aim: Concept checking for Integer Numbers. More precisely, this concept is a refinement of both CEucl...
Definition: CInteger.h:88