DGtal 1.3.0
|
Aim: Computes the preimage of the 2D Euclidean shapes crossing a sequence of n straigth segments in O(n), with the algorithm of O'Rourke (1981). More...
#include <DGtal/geometry/tools/Preimage2D.h>
Public Types | |
typedef Shape::Point | Point |
typedef Shape::Point | Vector |
typedef std::list< Point > | Container |
Public Member Functions | |
Preimage2D (const Point &firstPoint, const Point &secondPoint, const Shape &aShape) | |
~Preimage2D () | |
Preimage2D (const Preimage2D &other) | |
Preimage2D & | operator= (const Preimage2D &other) |
bool | operator== (const Preimage2D &other) const |
bool | operator!= (const Preimage2D &other) const |
bool | isLeftExteriorAtTheFront (const Point &aP, const Point &aQ) |
bool | isLeftExteriorAtTheBack (const Point &aP, const Point &aQ) |
bool | isRightExteriorAtTheFront (const Point &aP, const Point &aQ) |
bool | isRightExteriorAtTheBack (const Point &aP, const Point &aQ) |
bool | canBeAddedAtTheFront (const Point &aP, const Point &aQ) |
bool | canBeAddedAtTheBack (const Point &aP, const Point &aQ) |
bool | addFront (const Point &aP, const Point &aQ) |
bool | addBack (const Point &aP, const Point &aQ) |
void | selfDisplay (std::ostream &out) const |
bool | isValid () const |
Point | Uf () const |
Point | Ul () const |
Point | Lf () const |
Point | Ll () const |
void | getSeparatingStraightLine (double &alpha, double &beta, double &gamma) const |
const Shape & | shape () const |
const Container & | pHull () const |
const Container & | qHull () const |
std::string | className () const |
Private Types | |
typedef std::list< Point >::iterator | ForwardIterator |
typedef std::list< Point >::reverse_iterator | BackwardIterator |
typedef std::list< Point >::const_iterator | ConstForwardIterator |
typedef std::list< Point >::const_reverse_iterator | ConstBackwardIterator |
typedef functors::Point2ShapePredicate< Shape, false, true > | PHullBackQHullFrontPred |
typedef functors::Point2ShapePredicate< Shape, true, true > | QHullBackPHullFrontPred |
typedef functors::Point2ShapePredicate< Shape, true, true > | PHullFrontQHullBackPred |
typedef functors::Point2ShapePredicate< Shape, false, true > | QHullFrontPHullBackPred |
typedef functors::Point2ShapePredicate< Shape, true, false > | FrontPHullUpdatePred |
typedef functors::Point2ShapePredicate< Shape, false, false > | FrontQHullUpdatePred |
typedef functors::Point2ShapePredicate< Shape, false, false > | BackPHullUpdatePred |
typedef functors::Point2ShapePredicate< Shape, true, false > | BackQHullUpdatePred |
Private Member Functions | |
template<typename Iterator , typename Predicate > | |
void | update (const Point &aPoint, Container &aContainer, Iterator &anIterator, const Iterator &anEndIterator) |
Private Attributes | |
Shape | myShape |
Container | myPHull |
Container | myQHull |
Aim: Computes the preimage of the 2D Euclidean shapes crossing a sequence of n straigth segments in O(n), with the algorithm of O'Rourke (1981).
For all i from 0 to n, the straight segment i is described by its two end points Pi and Qi. The set of shapes considered here are those that can be uniquely defined by two points and that separate the 2D plane into two disjoint parts (e.g. straight lines, circles passing through a given point). Consequently, the points Pi and the points Qi are assumed to lie in either side of the shape.
The user of this class has to decide from its input set of segments and the shape used whether a linear-time algorithm is possible or not. If yes (e.g. preimage of straight lines crossing a set of vertical segments of increasing x-coordinate) the algorithm of O'Rourke will return the right output.
Shape | a model of COrientableHypersurface |
You can define your preimage type from a given shape type as follows:
Here is another example:
Then, here is the basic usage of this class:
Definition at line 93 of file Preimage2D.h.
|
private |
Definition at line 130 of file Preimage2D.h.
|
private |
Definition at line 132 of file Preimage2D.h.
|
private |
Definition at line 110 of file Preimage2D.h.
|
private |
Definition at line 112 of file Preimage2D.h.
|
private |
Definition at line 111 of file Preimage2D.h.
typedef std::list<Point> DGtal::Preimage2D< Shape >::Container |
Definition at line 103 of file Preimage2D.h.
|
private |
Definition at line 109 of file Preimage2D.h.
|
private |
Definition at line 126 of file Preimage2D.h.
|
private |
Definition at line 128 of file Preimage2D.h.
|
private |
Definition at line 117 of file Preimage2D.h.
|
private |
Definition at line 121 of file Preimage2D.h.
typedef Shape::Point DGtal::Preimage2D< Shape >::Point |
Definition at line 100 of file Preimage2D.h.
|
private |
Definition at line 119 of file Preimage2D.h.
|
private |
Definition at line 123 of file Preimage2D.h.
typedef Shape::Point DGtal::Preimage2D< Shape >::Vector |
Definition at line 101 of file Preimage2D.h.
DGtal::Preimage2D< Shape >::Preimage2D | ( | const Point & | firstPoint, |
const Point & | secondPoint, | ||
const Shape & | aShape | ||
) |
Constructor.
firstPoint | the end point of the first straight segment expected to lie in the interior of the separating shapes |
secondPoint | the end point of the first straight segment expected to lie in the exterior of the separating shapes |
aShape | any shape |
DGtal::Preimage2D< Shape >::~Preimage2D | ( | ) |
Destructor. Does nothing.
DGtal::Preimage2D< Shape >::Preimage2D | ( | const Preimage2D< Shape > & | other | ) |
Copy constructor.
other | the object to clone. |
bool DGtal::Preimage2D< Shape >::addBack | ( | const Point & | aP, |
const Point & | aQ | ||
) |
Updates the current preimage with the constraints involved by the two end points of a new segment (adding to the back with respect to a clockwise-oriented scan)
Nb: in O(n)
aP | the end point of the new straight segment expected to lie in the interior of the separating shapes |
aQ | the end point of the new straight segment expected to lie in the exterior of the separating shapes |
Referenced by main().
bool DGtal::Preimage2D< Shape >::addFront | ( | const Point & | aP, |
const Point & | aQ | ||
) |
Updates the current preimage with the constraints involved by the two end points of a new segment (adding to the front with respect to a clockwise-oriented scan)
Nb: in O(n)
aP | the end point of the new straight segment expected to lie in the interior of the separating shapes |
aQ | the end point of the new straight segment expected to lie in the exterior of the separating shapes |
Referenced by main().
bool DGtal::Preimage2D< Shape >::canBeAddedAtTheBack | ( | const Point & | aP, |
const Point & | aQ | ||
) |
Decide whether a new constraint can be added at the back (with respect to a clockwise-oriented scan) without making the preimage empty or not
aP | the end point of the new straight segment expected to lie in the interior of the separating shapes |
aQ | the end point of the new straight segment expected to lie in the exterior of the separating shapes |
bool DGtal::Preimage2D< Shape >::canBeAddedAtTheFront | ( | const Point & | aP, |
const Point & | aQ | ||
) |
Decide whether a new constraint can be added at the front (with respect to a clockwise-oriented scan) without making the preimage empty or not
aP | the end point of the new straight segment expected to lie in the interior of the separating shapes |
aQ | the end point of the new straight segment expected to lie in the exterior of the separating shapes |
std::string DGtal::Preimage2D< Shape >::className | ( | ) | const |
Default drawing style object.
void DGtal::Preimage2D< Shape >::getSeparatingStraightLine | ( | double & | alpha, |
double & | beta, | ||
double & | gamma | ||
) | const |
Get the parameters of one separating straight line
alpha | (returned) y-component of the normal |
beta | (returned) x-component of the normal |
gamma | (returned) intercept |
bool DGtal::Preimage2D< Shape >::isLeftExteriorAtTheBack | ( | const Point & | aP, |
const Point & | aQ | ||
) |
Decide whether a new constraint that is added at the back (with respect to a clockwise-oriented scan) makes the preimage empty because of point aQ or not
aP | the end point of the new straight segment expected to lie in the interior of the separating shapes |
aQ | the end point of the new straight segment expected to lie in the exterior of the separating shapes |
bool DGtal::Preimage2D< Shape >::isLeftExteriorAtTheFront | ( | const Point & | aP, |
const Point & | aQ | ||
) |
Decide whether a new constraint that is added at the front (with respect to a clockwise-oriented scan) makes the preimage empty because of point aP or not
aP | the end point of the new straight segment expected to lie in the interior of the separating shapes |
aQ | the end point of the new straight segment expected to lie in the exterior of the separating shapes |
bool DGtal::Preimage2D< Shape >::isRightExteriorAtTheBack | ( | const Point & | aP, |
const Point & | aQ | ||
) |
Decide whether a new constraint that is added at the front (with respect to a clockwise-oriented scan) makes the preimage empty because of point aP or not
aP | the end point of the new straight segment expected to lie in the interior of the separating shapes |
aQ | the end point of the new straight segment expected to lie in the exterior of the separating shapes |
bool DGtal::Preimage2D< Shape >::isRightExteriorAtTheFront | ( | const Point & | aP, |
const Point & | aQ | ||
) |
Decide whether a new constraint that is added at the front (with respect to a clockwise-oriented scan) makes the preimage empty because of point aQ or not
aP | the end point of the new straight segment expected to lie in the interior of the separating shapes |
aQ | the end point of the new straight segment expected to lie in the exterior of the separating shapes |
bool DGtal::Preimage2D< Shape >::isValid | ( | ) | const |
Checks the validity/consistency of the object.
Point DGtal::Preimage2D< Shape >::Lf | ( | ) | const |
Point DGtal::Preimage2D< Shape >::Ll | ( | ) | const |
bool DGtal::Preimage2D< Shape >::operator!= | ( | const Preimage2D< Shape > & | other | ) | const |
Difference operator
other | the object to compare with. |
Preimage2D & DGtal::Preimage2D< Shape >::operator= | ( | const Preimage2D< Shape > & | other | ) |
Assignment.
other | the object to copy. |
bool DGtal::Preimage2D< Shape >::operator== | ( | const Preimage2D< Shape > & | other | ) | const |
Equality operator
other | the object to compare with. |
NB: linear in the size of myPHull and myQHull
|
inline |
Definition at line 348 of file Preimage2D.h.
References DGtal::Preimage2D< Shape >::myPHull.
|
inline |
Definition at line 356 of file Preimage2D.h.
References DGtal::Preimage2D< Shape >::myQHull.
void DGtal::Preimage2D< Shape >::selfDisplay | ( | std::ostream & | out | ) | const |
Writes/Displays the object on an output stream.
out | the output stream where the object is written. |
|
inline |
Definition at line 340 of file Preimage2D.h.
References DGtal::Preimage2D< Shape >::myShape.
Point DGtal::Preimage2D< Shape >::Uf | ( | ) | const |
Point DGtal::Preimage2D< Shape >::Ul | ( | ) | const |
|
private |
Updates the current preimage
Nb: in O(n)
aPoint | a new vertex of the preimage, |
aContainer | the STL-like container to be updated, |
anIterator | an iterator to its front (resp. back) |
anEndIterator | an iterator pointing after its back (resp. before its front). |
Iterator | the type of Iterator (either Container::iterator or Container::reverse_iterator) |
Predicate | the type of Predicate |
|
private |
Lower part of the preimage (whose vertices are Pi points)
Definition at line 388 of file Preimage2D.h.
Referenced by DGtal::Preimage2D< Shape >::pHull().
|
private |
Upper part of the preimage. (whose vertices are Qi points)
Definition at line 393 of file Preimage2D.h.
Referenced by DGtal::Preimage2D< Shape >::qHull().
|
private |
Shape used to separate the input points
Definition at line 381 of file Preimage2D.h.
Referenced by DGtal::Preimage2D< Shape >::shape().