DGtal 1.3.0
Loading...
Searching...
No Matches
Preimage2D.h
1
17#pragma once
18
31#if defined(Preimage2D_RECURSES)
32#error Recursive header files inclusion detected in Preimage2D.h
33#else // defined(Preimage2D_RECURSES)
35#define Preimage2D_RECURSES
36
37#if !defined Preimage2D_h
39#define Preimage2D_h
40
42// Inclusions
43#include <iostream>
44#include <list>
45#include "DGtal/base/Common.h"
46#include "DGtal/base/OpInSTLContainers.h"
47#include "DGtal/shapes/fromPoints/Point2ShapePredicate.h"
48#include "DGtal/io/Color.h"
50
51namespace DGtal
52{
53
55 // template class Preimage2D
92 template <typename Shape>
94 {
95
96
97 // ----------------------- Types ------------------------------
98 public:
99
100 typedef typename Shape::Point Point;
101 typedef typename Shape::Point Vector;
102 //container of points
103 typedef std::list<Point> Container;
104
105
106 private:
107
108 //Iterators on the container
109 typedef typename std::list<Point>::iterator ForwardIterator;
110 typedef typename std::list<Point>::reverse_iterator BackwardIterator;
111 typedef typename std::list<Point>::const_iterator ConstForwardIterator;
112 typedef typename std::list<Point>::const_reverse_iterator ConstBackwardIterator;
113
114 //Predicates used to decide whether the preimage
115 //has to be updated or not
124 //Predicates used to update the hulls
133
134
135
136 // ----------------------- Standard services ------------------------------
137 public:
138
145 Preimage2D(const Point & firstPoint, const Point & secondPoint, const Shape & aShape );
146
151
156 Preimage2D ( const Preimage2D & other );
157
163 Preimage2D & operator= ( const Preimage2D & other );
164
175 bool operator==( const Preimage2D & other) const;
176
182 bool operator!=( const Preimage2D & other) const;
183
195 bool isLeftExteriorAtTheFront(const Point & aP, const Point & aQ);
196
208 bool isLeftExteriorAtTheBack(const Point & aP, const Point & aQ);
209
221 bool isRightExteriorAtTheFront(const Point & aP, const Point & aQ);
222
234 bool isRightExteriorAtTheBack(const Point & aP, const Point & aQ);
235
247 bool canBeAddedAtTheFront(const Point & aP, const Point & aQ);
248
260 bool canBeAddedAtTheBack(const Point & aP, const Point & aQ);
261
276 bool addFront(const Point & aP, const Point & aQ);
277
292 bool addBack(const Point & aP, const Point & aQ);
293
294 // ----------------------- Interface --------------------------------------
295 public:
296
301 void selfDisplay ( std::ostream & out ) const;
302
307 bool isValid() const;
308
312 Point Uf() const;
313
317 Point Ul() const;
318
322 Point Lf() const;
323
327 Point Ll() const;
328
335 void getSeparatingStraightLine(double& alpha, double& beta, double& gamma) const;
336
340 const Shape & shape() const
341 {
342 return myShape;
343 };
344
348 const Container & pHull() const
349 {
350 return myPHull;
351 };
352
356 const Container & qHull() const
357 {
358 return myQHull;
359 };
360
361 //------------------ display -------------------------------
366 //DrawableWithBoard2D* defaultStyle( std::string mode="" ) const;
367
371 std::string className() const;
372
373 // ------------------------- Protected Datas ------------------------------
374 private:
375 // ------------------------- Private Datas --------------------------------
376 private:
377
382
383 //lists of the vertices of the preimage
394
395 // ------------------------- Hidden services ------------------------------
396 protected:
397
398
399 private:
400
415 template <typename Iterator, typename Predicate>
416 void update(const Point & aPoint,
417 Container & aContainer,
418 Iterator & anIterator,
419 const Iterator & anEndIterator);
420
421
422
423 // ------------------------- Internals ------------------------------------
424 private:
425
426 }; // end of class Preimage2D
427
428
435 template <typename Shape>
436 std::ostream&
437 operator<< ( std::ostream & out, const Preimage2D<Shape> & object );
438
439
440} // namespace DGtal
441
442
444// Includes inline functions.
445#include "DGtal/geometry/tools/Preimage2D.ih"
446
447// //
449
450#endif // !defined Preimage2D_h
451
452#undef Preimage2D_RECURSES
453#endif // else defined(Preimage2D_RECURSES)
Aim: Computes the preimage of the 2D Euclidean shapes crossing a sequence of n straigth segments in O...
Definition: Preimage2D.h:94
functors::Point2ShapePredicate< Shape, true, true > QHullBackPHullFrontPred
Definition: Preimage2D.h:119
functors::Point2ShapePredicate< Shape, true, true > PHullFrontQHullBackPred
Definition: Preimage2D.h:121
bool addBack(const Point &aP, const Point &aQ)
Preimage2D(const Preimage2D &other)
functors::Point2ShapePredicate< Shape, false, false > BackPHullUpdatePred
Definition: Preimage2D.h:130
bool operator!=(const Preimage2D &other) const
std::list< Point >::iterator ForwardIterator
Definition: Preimage2D.h:109
bool addFront(const Point &aP, const Point &aQ)
void selfDisplay(std::ostream &out) const
functors::Point2ShapePredicate< Shape, false, true > PHullBackQHullFrontPred
Definition: Preimage2D.h:117
Container myQHull
Definition: Preimage2D.h:393
void update(const Point &aPoint, Container &aContainer, Iterator &anIterator, const Iterator &anEndIterator)
Preimage2D & operator=(const Preimage2D &other)
Point Lf() const
bool isRightExteriorAtTheFront(const Point &aP, const Point &aQ)
void getSeparatingStraightLine(double &alpha, double &beta, double &gamma) const
Preimage2D(const Point &firstPoint, const Point &secondPoint, const Shape &aShape)
functors::Point2ShapePredicate< Shape, false, false > FrontQHullUpdatePred
Definition: Preimage2D.h:128
bool isValid() const
std::list< Point > Container
Definition: Preimage2D.h:103
Point Ul() const
bool canBeAddedAtTheFront(const Point &aP, const Point &aQ)
Shape::Point Point
Definition: Preimage2D.h:100
functors::Point2ShapePredicate< Shape, false, true > QHullFrontPHullBackPred
Definition: Preimage2D.h:123
const Shape & shape() const
Definition: Preimage2D.h:340
bool operator==(const Preimage2D &other) const
Point Ll() const
const Container & pHull() const
Definition: Preimage2D.h:348
std::string className() const
bool isLeftExteriorAtTheFront(const Point &aP, const Point &aQ)
Shape::Point Vector
Definition: Preimage2D.h:101
bool canBeAddedAtTheBack(const Point &aP, const Point &aQ)
const Container & qHull() const
Definition: Preimage2D.h:356
std::list< Point >::const_iterator ConstForwardIterator
Definition: Preimage2D.h:111
std::list< Point >::reverse_iterator BackwardIterator
Definition: Preimage2D.h:110
functors::Point2ShapePredicate< Shape, true, false > BackQHullUpdatePred
Definition: Preimage2D.h:132
Point Uf() const
bool isRightExteriorAtTheBack(const Point &aP, const Point &aQ)
bool isLeftExteriorAtTheBack(const Point &aP, const Point &aQ)
std::list< Point >::const_reverse_iterator ConstBackwardIterator
Definition: Preimage2D.h:112
functors::Point2ShapePredicate< Shape, true, false > FrontPHullUpdatePred
Definition: Preimage2D.h:126
Container myPHull
Definition: Preimage2D.h:388
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
const Point aPoint(3, 4)