DGtal
0.6.devel
|
#include <COBANaivePlane.h>
Data Structures | |
struct | State |
Public Types | |
typedef TSpace | Space |
typedef Space::Point | Point |
typedef std::set< Point > | PointSet |
typedef PointSet::size_type | Size |
typedef PointSet::const_iterator | ConstIterator |
typedef PointSet::iterator | Iterator |
typedef TInternalInteger | InternalInteger |
typedef IntegerComputer < InternalInteger > | MyIntegerComputer |
typedef PointSet::const_iterator | const_iterator |
typedef PointSet::const_pointer | const_pointer |
typedef PointSet::const_reference | const_reference |
typedef PointSet::value_type | value_type |
typedef PointSet::difference_type | difference_type |
typedef PointSet::size_type | size_type |
Public Member Functions | |
~COBANaivePlane () | |
COBANaivePlane () | |
COBANaivePlane (const COBANaivePlane &other) | |
COBANaivePlane & | operator= (const COBANaivePlane &other) |
MyIntegerComputer & | ic () const |
void | clear () |
void | init (Dimension axis, InternalInteger diameter, InternalInteger widthNumerator=NumberTraits< InternalInteger >::ONE, InternalInteger widthDenominator=NumberTraits< InternalInteger >::ONE) |
Size | complexity () const |
Size | size () const |
bool | empty () const |
ConstIterator | begin () const |
ConstIterator | end () const |
Size | max_size () const |
Size | maxSize () const |
bool | operator() (const Point &p) const |
bool | extendAsIs (const Point &p) |
bool | extend (const Point &p) |
bool | isExtendable (const Point &p) const |
template<typename TInputIterator > | |
bool | extend (TInputIterator it, TInputIterator itE) |
template<typename TInputIterator > | |
bool | isExtendable (TInputIterator it, TInputIterator itE) const |
template<typename Vector3D > | |
void | getNormal (Vector3D &normal) const |
template<typename Vector3D > | |
void | getUnitNormal (Vector3D &normal) const |
void | getBounds (double &min, double &max) const |
const Point & | minimalPoint () const |
const Point & | maximalPoint () const |
void | selfDisplay (std::ostream &out) const |
bool | isValid () const |
Private Types | |
typedef PointVector < 3, InternalInteger > | InternalPoint3 |
typedef SpaceND < 2, InternalInteger > | InternalSpace2 |
typedef InternalSpace2::Point | InternalPoint2 |
typedef LatticePolytope2D < InternalSpace2 > | ConvexPolygonZ2 |
typedef ConvexPolygonZ2::HalfSpace | HalfSpace |
Private Member Functions | |
BOOST_CONCEPT_ASSERT ((CSpace< TSpace >)) | |
BOOST_CONCEPT_ASSERT ((CInteger< TInternalInteger >)) | |
BOOST_STATIC_ASSERT ((TSpace::dimension==3)) | |
void | computeCentroidAndNormal (State &state) const |
void | doubleCut (InternalPoint2 &grad, State &state) const |
template<typename TInputIterator > | |
void | computeMinMax (State &state, TInputIterator itB, TInputIterator itE) const |
template<typename TInputIterator > | |
bool | updateMinMax (State &state, TInputIterator itB, TInputIterator itE) const |
bool | checkPlaneWidth (const State &state) const |
void | computeGradient (InternalPoint2 &grad, const State &state) const |
Aim: A class that contains the COBA algorithm (Emilie Charrier, Lilian Buzer, DGCI2008) for recognizing pieces of digital planes of given axis width. When the width is 1, it corresponds to naive planes. The axis is specified at initialization of the object.
Description of template class 'COBANaivePlane'
As a (3D) geometric primitive, it obeys to a subset of the concept CSegmentComputer. It is copy constructible, assignable. It is iterable (inner type ConstIterator, begin(), end()). It has methods extend(), extend( InputIterator, InputIterator) and isExtendable(), isExtendable(InputIterator, InputIterator). The object stores all the distinct points p
such that 'extend( p
)' was successful. It is thus a model of boost::ForwardContainer (non mutable).
It is also a model of CPointPredicate (returns 'true' iff a point is within the current bounds).
Note on complexity: The complexity is highly dependent on the way points are added to the object. Let D be the diameter and n be the number of points already added. Assume small integers. Complexity of adding a point that do not change the normal of the plane is \( O(\log(n)) \). When it changes the normal, the number of cuts is upper bounded by some \( O(\log(D)) \), each cut costs \( O(n+m\log(D) ) \), where m is the number of sides of the convex polygon of constraints. However, when recognizing a piece of naive plane, the number of times K where the normal should be updated is rather limited to some \( O(\log(D)) \).
Note on execution times: The user should favor int64_t instead of BigInteger whenever possible (diameter smaller than 500). The speed-up is between 10 and 20 for these diameters. For greater diameters, it is necessary to use BigInteger (see below).
TSpace | specifies the type of digital space in which lies input digital points. A model of CSpace. |
TInternalInteger | specifies the type of integer used in internal computations. The type should be able to hold integers of order (2*D^3)^2 if D is the diameter of the set of digital points. In practice, diameter is limited to 20 for int32_t, diameter is approximately 500 for int64_t, and whatever with BigInteger/GMP integers. For huge diameters, the slow-down is polylogarithmic with the diameter. |
Essentially a backport from ImaGene.
Model of boost::DefaultConstructible, boost::CopyConstructible, boost::Assignable, boost::ForwardContainer, CPointPredicate.
Definition at line 128 of file COBANaivePlane.h.
typedef PointSet::const_iterator DGtal::COBANaivePlane< TSpace, TInternalInteger >::const_iterator |
Definition at line 148 of file COBANaivePlane.h.
typedef PointSet::const_pointer DGtal::COBANaivePlane< TSpace, TInternalInteger >::const_pointer |
Definition at line 149 of file COBANaivePlane.h.
typedef PointSet::const_reference DGtal::COBANaivePlane< TSpace, TInternalInteger >::const_reference |
Definition at line 150 of file COBANaivePlane.h.
typedef PointSet::const_iterator DGtal::COBANaivePlane< TSpace, TInternalInteger >::ConstIterator |
Definition at line 141 of file COBANaivePlane.h.
|
private |
Definition at line 160 of file COBANaivePlane.h.
typedef PointSet::difference_type DGtal::COBANaivePlane< TSpace, TInternalInteger >::difference_type |
Definition at line 152 of file COBANaivePlane.h.
|
private |
Definition at line 161 of file COBANaivePlane.h.
typedef TInternalInteger DGtal::COBANaivePlane< TSpace, TInternalInteger >::InternalInteger |
Definition at line 143 of file COBANaivePlane.h.
|
private |
Definition at line 159 of file COBANaivePlane.h.
|
private |
Definition at line 157 of file COBANaivePlane.h.
|
private |
Definition at line 158 of file COBANaivePlane.h.
typedef PointSet::iterator DGtal::COBANaivePlane< TSpace, TInternalInteger >::Iterator |
Definition at line 142 of file COBANaivePlane.h.
typedef IntegerComputer< InternalInteger > DGtal::COBANaivePlane< TSpace, TInternalInteger >::MyIntegerComputer |
Definition at line 144 of file COBANaivePlane.h.
typedef Space::Point DGtal::COBANaivePlane< TSpace, TInternalInteger >::Point |
Definition at line 138 of file COBANaivePlane.h.
typedef std::set< Point > DGtal::COBANaivePlane< TSpace, TInternalInteger >::PointSet |
Definition at line 139 of file COBANaivePlane.h.
typedef PointSet::size_type DGtal::COBANaivePlane< TSpace, TInternalInteger >::Size |
Definition at line 140 of file COBANaivePlane.h.
typedef PointSet::size_type DGtal::COBANaivePlane< TSpace, TInternalInteger >::size_type |
Definition at line 153 of file COBANaivePlane.h.
typedef TSpace DGtal::COBANaivePlane< TSpace, TInternalInteger >::Space |
Definition at line 137 of file COBANaivePlane.h.
typedef PointSet::value_type DGtal::COBANaivePlane< TSpace, TInternalInteger >::value_type |
Definition at line 151 of file COBANaivePlane.h.
|
inline |
|
inline |
Constructor. The object is not valid and should be initialized.
Definition at line 52 of file COBANaivePlane.ih.
|
inline |
Copy constructor.
other | the object to clone. |
Definition at line 60 of file COBANaivePlane.ih.
ConstIterator DGtal::COBANaivePlane< TSpace, TInternalInteger >::begin | ( | ) | const |
|
private |
|
private |
|
private |
|
private |
state | the state where the normal state.N, the scalars state.min and state.max are used in computations. |
Definition at line 771 of file COBANaivePlane.ih.
References DGtal::COBANaivePlane< TSpace, TInternalInteger >::State::max, DGtal::COBANaivePlane< TSpace, TInternalInteger >::State::min, and DGtal::COBANaivePlane< TSpace, TInternalInteger >::State::N.
|
inline |
Clear the object, free memory. The plane keeps its main axis, diameter and width, but contains no point.
Definition at line 103 of file COBANaivePlane.ih.
References DGtal::COBANaivePlane< TSpace, TInternalInteger >::clear().
Referenced by DGtal::COBANaivePlane< TSpace, TInternalInteger >::clear().
|
inline |
Definition at line 176 of file COBANaivePlane.ih.
References DGtal::COBANaivePlane< TSpace, TInternalInteger >::size().
|
inlineprivate |
Recompute centroid of polygon of solution and deduce the current normal vector. It is called after any modification of the convex polygon representing the set of solution.
state | (modified) the state where the fields state.cip are used in computation and where fields state.centroid and state.N are updated. |
Definition at line 665 of file COBANaivePlane.ih.
References DGtal::COBANaivePlane< TSpace, TInternalInteger >::State::centroid, DGtal::LatticePolytope2D< TSpace, TSequence >::centroid(), DGtal::COBANaivePlane< TSpace, TInternalInteger >::State::cip, DGtal::LatticePolytope2D< TSpace, TSequence >::empty(), and DGtal::COBANaivePlane< TSpace, TInternalInteger >::State::N.
|
private |
grad | (updated) the value of a gradient used to cut the polygon of solutions. |
state | the state where the iterators state.indMin and state.indMax are used in computations. |
Definition at line 781 of file COBANaivePlane.ih.
References DGtal::COBANaivePlane< TSpace, TInternalInteger >::State::ptMax, and DGtal::COBANaivePlane< TSpace, TInternalInteger >::State::ptMin.
|
private |
Computes the min and max values/arguments of the scalar product between the normal state.N and the points in the range [itB,itE). Overwrites state.min, state.max at the start.
TInputIterator | any model of InputIterator. |
state | (modified) the state where the normal N is used in computation and where fields state.min, state.max, state.indMin, state.indMax are updated. |
itB | an input iterator on the first point of the range. |
itE | an input iterator after the last point of the range. |
Definition at line 712 of file COBANaivePlane.ih.
References DGtal::COBANaivePlane< TSpace, TInternalInteger >::State::max, DGtal::COBANaivePlane< TSpace, TInternalInteger >::State::min, DGtal::COBANaivePlane< TSpace, TInternalInteger >::State::N, DGtal::COBANaivePlane< TSpace, TInternalInteger >::State::ptMax, and DGtal::COBANaivePlane< TSpace, TInternalInteger >::State::ptMin.
|
inlineprivate |
Performs the double cut in parameter space according to the current gradient and width. The centroid and normals are no more valid (computeCentroidAndNormal should be called afterwards).
grad | (altered, but not modified) the gradient used to update the polygon of solutions state.cip. |
state | (modified) the state where the fields state.indMin, state.indMax, state.cip are used in computation and where field state.cip is updated. |
Definition at line 694 of file COBANaivePlane.ih.
References DGtal::COBANaivePlane< TSpace, TInternalInteger >::State::cip, DGtal::LatticePolytope2D< TSpace, TSequence >::cut(), DGtal::PointVector< dim, TEuclideanRing >::negate(), DGtal::COBANaivePlane< TSpace, TInternalInteger >::State::ptMax, and DGtal::COBANaivePlane< TSpace, TInternalInteger >::State::ptMin.
|
inline |
Definition at line 149 of file COBANaivePlane.ih.
References DGtal::COBANaivePlane< TSpace, TInternalInteger >::empty().
Referenced by DGtal::COBANaivePlane< TSpace, TInternalInteger >::empty().
ConstIterator DGtal::COBANaivePlane< TSpace, TInternalInteger >::end | ( | ) | const |
bool DGtal::COBANaivePlane< TSpace, TInternalInteger >::extend | ( | const Point & | p | ) |
Adds the point p and checks if we have still a digital plane of specified width. The plane parameters may be updated so as to include the new point.
p | any 3D point (in the specified diameter). |
Definition at line 207 of file COBANaivePlane.ih.
bool DGtal::COBANaivePlane< TSpace, TInternalInteger >::extend | ( | TInputIterator | it, |
TInputIterator | itE | ||
) |
Adds the range of points [it, itE) and checks if we have still a digital plane of specified width. The plane parameters may be updated so as to include all the new points. All points pointed by iterators should be in the diameter of this object.
TInputIterator | any model of InputIterator on Point. |
it | an iterator on the first element of the range of 3D points. |
itE | an iterator after the last element of the range of 3D points. |
Definition at line 369 of file COBANaivePlane.ih.
|
inline |
Adds the point p to this plane if it is within the current bounds. The plane parameters are not updated.
p | any 3D point (in the specified diameter). |
Definition at line 195 of file COBANaivePlane.ih.
|
inline |
If n is the unit normal to the current plane, then n.x >= min and n.x <= max are the two half-planes defining it.
min | the lower bound (corresponding to the unit vector). |
max | the upper bound (corresponding to the unit vector). |
Definition at line 586 of file COBANaivePlane.ih.
References DGtal::NumberTraits< T >::castToDouble().
|
inline |
Vector3D | any type T such that T.operator[](int i) returns a reference to a double. i ranges in 0,1,2. |
(updates) | the current normal vector |
Definition at line 544 of file COBANaivePlane.ih.
References DGtal::NumberTraits< T >::castToDouble().
|
inline |
Vector3D | any type T such that T.operator[](int i) returns a reference to a double. i ranges in 0,1,2. |
(updates) | the current unit normal vector |
Definition at line 571 of file COBANaivePlane.ih.
|
inline |
Definition at line 94 of file COBANaivePlane.ih.
References DGtal::COBANaivePlane< TSpace, TInternalInteger >::ic().
Referenced by DGtal::COBANaivePlane< TSpace, TInternalInteger >::ic().
|
inline |
All these parameters cannot be changed during the process. After this call, the object is in a consistent state and can accept new points for recognition. Calls clear so that the object is ready to be extended.
axis | the main axis (0,1,2) for x, y or z. |
diameter | the diameter for the set of points (maximum distance between the given points) |
widthNumerator | the maximal axis-width (x,y,or z) for the plane is defined as the rational number widthNumerator / widthDenominator (default is 1/1, i.e. naive plane). |
widthDenominator | the maximal axis-width (x,y,or z) for the plane is defined as the rational number widthNumerator / widthDenominator (default is 1/1, i.e. naive plane). |
Definition at line 119 of file COBANaivePlane.ih.
bool DGtal::COBANaivePlane< TSpace, TInternalInteger >::isExtendable | ( | const Point & | p | ) | const |
Checks if we have still a digital plane of specified width when adding point p. The object is left unchanged whatever the returned value. The invariant is 'this->isExtendable( p ) == true <=> this->extend( p ) == true'.
p | any 3D point (in the specified diameter). |
Definition at line 303 of file COBANaivePlane.ih.
bool DGtal::COBANaivePlane< TSpace, TInternalInteger >::isExtendable | ( | TInputIterator | it, |
TInputIterator | itE | ||
) | const |
Checks if we have still a digital plane of specified width when adding the range of points [it, itE). The object is left unchanged whatever the returned value. All points pointed by iterators should be in the diameter of this object. The invariant is 'this->isExtendable( it, itE ) == true <=> this->extend( it, itE ) == true'.
TInputIterator | any model of InputIterator on Point. |
it | an iterator on the first element of the range of 3D points. |
itE | an iterator after the last element of the range of 3D points. |
Definition at line 468 of file COBANaivePlane.ih.
|
inline |
Checks the validity/consistency of the object.
Definition at line 651 of file COBANaivePlane.ih.
|
inline |
NB: std version.
Definition at line 158 of file COBANaivePlane.ih.
References DGtal::COBANaivePlane< TSpace, TInternalInteger >::max_size().
Referenced by DGtal::COBANaivePlane< TSpace, TInternalInteger >::max_size().
|
inline |
Definition at line 610 of file COBANaivePlane.ih.
|
inline |
same as max_size
Definition at line 167 of file COBANaivePlane.ih.
|
inline |
Definition at line 600 of file COBANaivePlane.ih.
|
inline |
Checks if the point p is in the current digital plane. Therefore, a COBANaivePlane is a model of CPointPredicate.
p | any 3D point. |
Definition at line 185 of file COBANaivePlane.ih.
|
inline |
Assignment.
other | the object to copy. |
Definition at line 75 of file COBANaivePlane.ih.
References DGtal::COBANaivePlane< TSpace, TInternalInteger >::myAxis, DGtal::COBANaivePlane< TSpace, TInternalInteger >::myCst1, DGtal::COBANaivePlane< TSpace, TInternalInteger >::myCst2, DGtal::COBANaivePlane< TSpace, TInternalInteger >::myG, DGtal::COBANaivePlane< TSpace, TInternalInteger >::myPointSet, DGtal::COBANaivePlane< TSpace, TInternalInteger >::myState, and DGtal::COBANaivePlane< TSpace, TInternalInteger >::myWidth.
|
inline |
Writes/Displays the object on an output stream.
out | the output stream where the object is written. |
Definition at line 628 of file COBANaivePlane.ih.
|
inline |
Definition at line 140 of file COBANaivePlane.ih.
References DGtal::COBANaivePlane< TSpace, TInternalInteger >::size().
Referenced by DGtal::COBANaivePlane< TSpace, TInternalInteger >::complexity(), and DGtal::COBANaivePlane< TSpace, TInternalInteger >::size().
|
private |
Updates the min and max values/arguments of the scalar product between the normal state.N and the points in the range [itB,itE). Do not overwrite state.min, state.max at the start.
TInputIterator | any model of InputIterator. |
state | (modified) the state where the normal N is used in computation and where fields state.min, state.max, state.indMin, state.indMax are updated. |
itB | an input iterator on the first point of the range. |
itE | an input iterator after the last point of the range. |
Definition at line 742 of file COBANaivePlane.ih.
References DGtal::COBANaivePlane< TSpace, TInternalInteger >::State::max, DGtal::COBANaivePlane< TSpace, TInternalInteger >::State::min, DGtal::COBANaivePlane< TSpace, TInternalInteger >::State::N, DGtal::COBANaivePlane< TSpace, TInternalInteger >::State::ptMax, and DGtal::COBANaivePlane< TSpace, TInternalInteger >::State::ptMin.
|
mutableprivate |
temporary variable to store the current gradient.
Definition at line 441 of file COBANaivePlane.h.
|
mutableprivate |
Temporary state used in computations.
Definition at line 440 of file COBANaivePlane.h.
|
mutableprivate |
temporary variable used in computations.
Definition at line 439 of file COBANaivePlane.h.
|
private |
the main axis used in all subsequent computations.
Definition at line 432 of file COBANaivePlane.h.
Referenced by DGtal::COBANaivePlane< TSpace, TInternalInteger >::operator=().
|
private |
( (int) ceil( get_si( myG ) * myWidth ) + 1 ).
Definition at line 437 of file COBANaivePlane.h.
Referenced by DGtal::COBANaivePlane< TSpace, TInternalInteger >::operator=().
|
private |
( (int) floor( get_si( myG ) * myWidth ) - 1 ).
Definition at line 438 of file COBANaivePlane.h.
Referenced by DGtal::COBANaivePlane< TSpace, TInternalInteger >::operator=().
|
private |
the grid step used in all subsequent computations.
Definition at line 433 of file COBANaivePlane.h.
Referenced by DGtal::COBANaivePlane< TSpace, TInternalInteger >::operator=().
|
private |
the set of points within the plane.
Definition at line 435 of file COBANaivePlane.h.
Referenced by DGtal::COBANaivePlane< TSpace, TInternalInteger >::operator=().
|
private |
the current state that defines the plane being recognized.
Definition at line 436 of file COBANaivePlane.h.
Referenced by DGtal::COBANaivePlane< TSpace, TInternalInteger >::operator=().
|
private |
the plane width as a positive rational number myWidth[0]/myWidth[1]
Definition at line 434 of file COBANaivePlane.h.
Referenced by DGtal::COBANaivePlane< TSpace, TInternalInteger >::operator=().