DGtal  0.9.3beta
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes
DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger > Class Template Reference

#include <DGtal/geometry/surfaces/COBAGenericNaivePlaneComputer.h>

Collaboration diagram for DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >:
[legend]

Public Types

typedef TSpace Space
 
typedef Space::Point Point
 
typedef std::set< PointPointSet
 
typedef PointSet::size_type Size
 
typedef PointSet::const_iterator ConstIterator
 
typedef PointSet::iterator Iterator
 
typedef TInternalInteger InternalInteger
 
typedef IntegerComputer< InternalIntegerMyIntegerComputer
 
typedef COBANaivePlaneComputer< Space, InternalIntegerCOBAComputer
 
typedef COBAComputer::Primitive Primitive
 
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

 ~COBAGenericNaivePlaneComputer ()
 
 COBAGenericNaivePlaneComputer ()
 
 COBAGenericNaivePlaneComputer (const COBAGenericNaivePlaneComputer &other)
 
COBAGenericNaivePlaneComputeroperator= (const COBAGenericNaivePlaneComputer &other)
 
MyIntegerComputeric () const
 
Dimension active () const
 
void clear ()
 
void init (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
 
Primitive primitive () 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 PointminimalPoint () const
 
const PointmaximalPoint () const
 
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 

Private Types

typedef std::vector< Dimension >::iterator AxisIterator
 
typedef std::vector< Dimension >::const_iterator AxisConstIterator
 

Private Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CSpace< TSpace >))
 
 BOOST_CONCEPT_ASSERT ((concepts::CInteger< TInternalInteger >))
 
 BOOST_STATIC_ASSERT ((TSpace::dimension==3))
 

Private Attributes

std::vector< DimensionmyAxes
 
COBAComputer myComputers [3]
 
std::vector< Dimension_axesToErase
 

Detailed Description

template<typename TSpace, typename TInternalInteger>
class DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >

Aim: A class that recognizes pieces of digital planes of given axis width. When the width is 1, it corresponds to naive planes. Contrary to COBANaivePlaneComputer, the axis is not specified at initialization of the object. This class uses three instances of COBANaivePlaneComputer, one per axis.

Description of template class 'COBAGenericNaivePlaneComputer'

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()). You may clear() it. 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 concepts::CPointPredicate (returns 'true' iff a point is within the current bounds).

Note on complexity: See COBANaivePlaneComputer. Although it uses three instances of COBANaivePlaneComputer, the recognition is not three times slower. Indeed, recognition stops quickly on bad axes.

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).

Template Parameters
TSpacespecifies the type of digital space in which lies input digital points. A model of CSpace.
TInternalIntegerspecifies 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.

typedef SpaceND<3,int> Z3;
typedef COBAGenericNaivePlaneComputer< Z3, int64_t > NaivePlaneComputer;
plane.init( 100, 1, 1 ); // diameter is 100, width is 1/1 => naive
plane.extend( Point( 10, 0, 0 ) ); // return 'true'
plane.extend( Point( 0, 8, 0 ) ); // return 'true'
plane.extend( Point( 0, 0, 6 ) ); // return 'true'
plane.extend( Point( 5, 5, 5 ) ); // return 'false'
// There is no naive plane going through the 3 first points and the last one.

Model of boost::DefaultConstructible, boost::CopyConstructible, boost::Assignable, boost::ForwardContainer, concepts::CAdditivePrimitiveComputer, concepts::CPointPredicate.

Definition at line 121 of file COBAGenericNaivePlaneComputer.h.

Member Typedef Documentation

template<typename TSpace , typename TInternalInteger >
typedef std::vector<Dimension>::const_iterator DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::AxisConstIterator
private

Definition at line 153 of file COBAGenericNaivePlaneComputer.h.

template<typename TSpace , typename TInternalInteger >
typedef std::vector<Dimension>::iterator DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::AxisIterator
private

Definition at line 152 of file COBAGenericNaivePlaneComputer.h.

template<typename TSpace , typename TInternalInteger >
typedef COBANaivePlaneComputer< Space, InternalInteger > DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::COBAComputer

Definition at line 138 of file COBAGenericNaivePlaneComputer.h.

template<typename TSpace , typename TInternalInteger >
typedef PointSet::const_iterator DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::const_iterator

Definition at line 143 of file COBAGenericNaivePlaneComputer.h.

template<typename TSpace , typename TInternalInteger >
typedef PointSet::const_pointer DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::const_pointer

Definition at line 144 of file COBAGenericNaivePlaneComputer.h.

template<typename TSpace , typename TInternalInteger >
typedef PointSet::const_reference DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::const_reference

Definition at line 145 of file COBAGenericNaivePlaneComputer.h.

template<typename TSpace , typename TInternalInteger >
typedef PointSet::const_iterator DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::ConstIterator

Definition at line 134 of file COBAGenericNaivePlaneComputer.h.

template<typename TSpace , typename TInternalInteger >
typedef PointSet::difference_type DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::difference_type

Definition at line 147 of file COBAGenericNaivePlaneComputer.h.

template<typename TSpace , typename TInternalInteger >
typedef TInternalInteger DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::InternalInteger

Definition at line 136 of file COBAGenericNaivePlaneComputer.h.

template<typename TSpace , typename TInternalInteger >
typedef PointSet::iterator DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::Iterator

Definition at line 135 of file COBAGenericNaivePlaneComputer.h.

template<typename TSpace , typename TInternalInteger >
typedef IntegerComputer< InternalInteger > DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::MyIntegerComputer

Definition at line 137 of file COBAGenericNaivePlaneComputer.h.

template<typename TSpace , typename TInternalInteger >
typedef Space::Point DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::Point

Definition at line 131 of file COBAGenericNaivePlaneComputer.h.

template<typename TSpace , typename TInternalInteger >
typedef std::set< Point > DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::PointSet

Definition at line 132 of file COBAGenericNaivePlaneComputer.h.

template<typename TSpace , typename TInternalInteger >
typedef COBAComputer::Primitive DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::Primitive

Definition at line 139 of file COBAGenericNaivePlaneComputer.h.

template<typename TSpace , typename TInternalInteger >
typedef PointSet::size_type DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::Size

Definition at line 133 of file COBAGenericNaivePlaneComputer.h.

template<typename TSpace , typename TInternalInteger >
typedef PointSet::size_type DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::size_type

Definition at line 148 of file COBAGenericNaivePlaneComputer.h.

template<typename TSpace , typename TInternalInteger >
typedef TSpace DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::Space

Definition at line 130 of file COBAGenericNaivePlaneComputer.h.

template<typename TSpace , typename TInternalInteger >
typedef PointSet::value_type DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::value_type

Definition at line 146 of file COBAGenericNaivePlaneComputer.h.

Constructor & Destructor Documentation

template<typename TSpace , typename TInternalInteger >
DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::~COBAGenericNaivePlaneComputer ( )

Destructor.

template<typename TSpace , typename TInternalInteger >
DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::COBAGenericNaivePlaneComputer ( )

Constructor. The object is not valid and should be initialized.

See also
init
template<typename TSpace , typename TInternalInteger >
DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::COBAGenericNaivePlaneComputer ( const COBAGenericNaivePlaneComputer< TSpace, TInternalInteger > &  other)

Copy constructor.

Parameters
otherthe object to clone.

Member Function Documentation

template<typename TSpace , typename TInternalInteger >
Dimension DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::active ( ) const
Returns
an active axis (or the active axis when there is only one).
template<typename TSpace , typename TInternalInteger >
ConstIterator DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::begin ( ) const
Returns
a const iterator pointing on the first point stored in the current naive plane.
template<typename TSpace , typename TInternalInteger >
DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::BOOST_CONCEPT_ASSERT ( (concepts::CSpace< TSpace >)  )
private
template<typename TSpace , typename TInternalInteger >
DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::BOOST_CONCEPT_ASSERT ( (concepts::CInteger< TInternalInteger >)  )
private
template<typename TSpace , typename TInternalInteger >
DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::BOOST_STATIC_ASSERT ( (TSpace::dimension==3)  )
private
template<typename TSpace , typename TInternalInteger >
void DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::clear ( )

Clear the object, free memory. The plane keeps its main axis, diameter and width, but contains no point.

template<typename TSpace , typename TInternalInteger >
Size DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::complexity ( ) const
Returns
the number of vertices/edges of the convex integer polygon of solutions.
template<typename TSpace , typename TInternalInteger >
bool DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::empty ( ) const
Returns
'true' if and only if this object contains no point.
template<typename TSpace , typename TInternalInteger >
ConstIterator DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::end ( ) const
Returns
a const iterator pointing after the last point stored in the current naive plane.
template<typename TSpace , typename TInternalInteger >
bool DGtal::COBAGenericNaivePlaneComputer< 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.

Parameters
pany 3D point (in the specified diameter).
Returns
'true' if it is still a plane, 'false' otherwise (the object is then in its original state).
template<typename TSpace , typename TInternalInteger >
template<typename TInputIterator >
bool DGtal::COBAGenericNaivePlaneComputer< 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.

Template Parameters
TInputIteratorany model of InputIterator on Point.
Parameters
itan iterator on the first element of the range of 3D points.
itEan iterator after the last element of the range of 3D points.
Returns
'true' if it is still a plane, 'false' otherwise (the object is then in its original state).
template<typename TSpace , typename TInternalInteger >
bool DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::extendAsIs ( const Point p)

Adds the point p to this plane if it is within the current bounds. The plane parameters are not updated.

Parameters
pany 3D point (in the specified diameter).
Returns
'true' if p is in the plane, 'false' otherwise (the object is then in its original state).
template<typename TSpace , typename TInternalInteger >
void DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::getBounds ( double &  min,
double &  max 
) const

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.

Parameters
minthe lower bound (corresponding to the unit vector).
maxthe upper bound (corresponding to the unit vector).
template<typename TSpace , typename TInternalInteger >
template<typename Vector3D >
void DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::getNormal ( Vector3D &  normal) const
Template Parameters
Vector3Dany type T such that T.operator[](int i) returns a reference to a double. i ranges in 0,1,2.
Parameters
[in,out]normal(updates) the current normal vector
template<typename TSpace , typename TInternalInteger >
template<typename Vector3D >
void DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::getUnitNormal ( Vector3D &  normal) const
Template Parameters
Vector3Dany type T such that T.operator[](int i) returns a reference to a double. i ranges in 0,1,2.
Parameters
normal(updates) the current unit normal vector
template<typename TSpace , typename TInternalInteger >
MyIntegerComputer& DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::ic ( ) const
Returns
the object that performs integer calculation.
template<typename TSpace , typename TInternalInteger >
void DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::init ( InternalInteger  diameter,
InternalInteger  widthNumerator = NumberTraitsInternalInteger >::ONE,
InternalInteger  widthDenominator = NumberTraitsInternalInteger >::ONE 
)

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.

Parameters
diameterthe diameter for the set of points (maximum distance between the given points)
widthNumeratorthe 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).
widthDenominatorthe 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).
template<typename TSpace , typename TInternalInteger >
bool DGtal::COBAGenericNaivePlaneComputer< 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'.

Parameters
pany 3D point (in the specified diameter).
Returns
'true' if this is still a plane, 'false' otherwise.
template<typename TSpace , typename TInternalInteger >
template<typename TInputIterator >
bool DGtal::COBAGenericNaivePlaneComputer< 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'.

Template Parameters
TInputIteratorany model of InputIterator on Point.
Parameters
itan iterator on the first element of the range of 3D points.
itEan iterator after the last element of the range of 3D points.
Returns
'true' if this is still a plane, 'false' otherwise.
template<typename TSpace , typename TInternalInteger >
bool DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::isValid ( ) const

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.
template<typename TSpace , typename TInternalInteger >
Size DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::max_size ( ) const

NB: std version.

Returns
the maximal allowed number of points in the current naive plane.
See also
maxSize
template<typename TSpace , typename TInternalInteger >
const Point& DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::maximalPoint ( ) const
Precondition
! empty()
Returns
the current maximal point of the plane, i.e. the one with the highest scalar product with the current normal vector. Note that other points may also have a maximum value.
template<typename TSpace , typename TInternalInteger >
Size DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::maxSize ( ) const

same as max_size

Returns
the maximal allowed number of points in the current naive plane.
template<typename TSpace , typename TInternalInteger >
const Point& DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::minimalPoint ( ) const
Precondition
! empty()
Returns
the current minimal point of the plane, i.e. the one with the smallest scalar product with the current normal vector. Note that other points may also have a minimum value.
template<typename TSpace , typename TInternalInteger >
bool DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::operator() ( const Point p) const

Checks if the point p is in the current digital plane. Therefore, a COBAGenericNaivePlaneComputer is a model of concepts::CPointPredicate.

Parameters
pany 3D point.
Returns
'true' if it is in the current plane, false otherwise.
template<typename TSpace , typename TInternalInteger >
COBAGenericNaivePlaneComputer& DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::operator= ( const COBAGenericNaivePlaneComputer< TSpace, TInternalInteger > &  other)

Assignment.

Parameters
otherthe object to copy.
Returns
a reference on 'this'.
template<typename TSpace , typename TInternalInteger >
Primitive DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::primitive ( ) const
Returns
the current primitive recognized by this computer, which is a ParallelStrip of axis width smaller than the one specified at instanciation.
Note
The returned primitive has the form \(\mu \le \vec{N} \cdot \vec{X} \le \mu + \epsilon\). It is guaranteed that its axis width is strictly less than the value widthNumerator / widthDenominator specified with method init.
template<typename TSpace , typename TInternalInteger >
void DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::selfDisplay ( std::ostream &  out) const

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.
template<typename TSpace , typename TInternalInteger >
Size DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::size ( ) const
Returns
the number of distinct points in the current naive plane.

Field Documentation

template<typename TSpace , typename TInternalInteger >
std::vector<Dimension> DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::_axesToErase
mutableprivate

Useful when erasing axes.

Definition at line 428 of file COBAGenericNaivePlaneComputer.h.

template<typename TSpace , typename TInternalInteger >
std::vector<Dimension> DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::myAxes
private

The list of active plane axes. Starts with {0,1,2}. At least one.

Definition at line 426 of file COBAGenericNaivePlaneComputer.h.

template<typename TSpace , typename TInternalInteger >
COBAComputer DGtal::COBAGenericNaivePlaneComputer< TSpace, TInternalInteger >::myComputers[3]
private

The three COBA plane computers.

Definition at line 427 of file COBAGenericNaivePlaneComputer.h.


The documentation for this class was generated from the following file: