DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions
DGtal::Shapes< TDomain > Class Template Reference

#include <Shapes.h>

Public Types

typedef TDomain Domain
typedef Domain::Space Space
typedef Domain::Space::RealPoint RealPoint
typedef Domain::Point Point
typedef Domain::Vector Vector
typedef Domain::Predicate Predicate
typedef Domain::ConstIterator ConstIterator
typedef Space::Integer Integer
typedef Space::UnsignedInteger UnsignedInteger

Public Member Functions

 ~Shapes ()
void selfDisplay (std::ostream &out) const
bool isValid () const
template<typename TDigitalSet , typename ShapeFunctor >
void digitalShaper (TDigitalSet &aSet, const ShapeFunctor &aFunctor)
template<typename TDigitalSet , typename ShapeFunctor >
void euclideanShaper (TDigitalSet &aSet, const ShapeFunctor &aFunctor, const double h)

Static Public Member Functions

template<typename TDigitalSet , typename TShapeFunctor >
static void digitalShaper (TDigitalSet &aSet, const TShapeFunctor &aFunctor)
template<typename TDigitalSet , typename TShapeFunctor >
static void euclideanShaper (TDigitalSet &aSet, const TShapeFunctor &aFunctor, const double h=1.0)
template<typename DigitalSet , typename PointPredicate >
static void makeSetFromPointPredicate (DigitalSet &aSet, const PointPredicate &aPP)
template<typename TDigitalSet >
static void addNorm1Ball (TDigitalSet &aSet, const Point &aCenter, UnsignedInteger aRadius)
template<typename TDigitalSet >
static void addNorm2Ball (TDigitalSet &aSet, const Point &aCenter, UnsignedInteger aRadius)
template<typename TDigitalSet >
static void removeNorm1Ball (TDigitalSet &aSet, const Point &aCenter, UnsignedInteger aRadius)
template<typename TDigitalSet >
static void removeNorm2Ball (TDigitalSet &aSet, const Point &aCenter, UnsignedInteger aRadius)

Protected Member Functions

 Shapes ()

Private Member Functions

 BOOST_CONCEPT_ASSERT ((CDomain< TDomain >))
 Shapes (const Shapes &other)
Shapesoperator= (const Shapes &other)

Detailed Description

template<typename TDomain>
class DGtal::Shapes< TDomain >

Aim: A utility class for constructing different shapes (balls, diamonds, and others).

Description of template class 'Shapes'

Template Parameters:
TDomainthe type of the domain in which shapes are created.
Examples:
arithmetic/lower-integer-convex-hull.cpp, io/boards/dgtalBoard2D-2-sets.cpp, io/boards/dgtalBoard2D-4-colormaps.cpp, io/boards/dgtalBoard3DTo2D-2-sets.cpp, io/boards/dgtalBoard3DTo2D-2bis-sets.cpp, io/boards/dgtalBoard3DTo2D-3-objects.cpp, io/boards/dgtalBoard3DTo2D-6.cpp, io/viewers/viewer3D-2-sets.cpp, io/viewers/viewer3D-3-objects.cpp, and io/viewers/viewer3D-6-clipping.cpp.

Definition at line 71 of file DGtal/shapes/Shapes.h.


Member Typedef Documentation

template<typename TDomain>
typedef Domain::ConstIterator DGtal::Shapes< TDomain >::ConstIterator

Definition at line 84 of file DGtal/shapes/Shapes.h.

template<typename TDomain>
typedef TDomain DGtal::Shapes< TDomain >::Domain

Definition at line 78 of file DGtal/shapes/Shapes.h.

template<typename TDomain>
typedef Space::Integer DGtal::Shapes< TDomain >::Integer

Definition at line 86 of file DGtal/shapes/Shapes.h.

template<typename TDomain>
typedef Domain::Point DGtal::Shapes< TDomain >::Point

Definition at line 81 of file DGtal/shapes/Shapes.h.

template<typename TDomain>
typedef Domain::Predicate DGtal::Shapes< TDomain >::Predicate

Definition at line 83 of file DGtal/shapes/Shapes.h.

template<typename TDomain>
typedef Domain::Space::RealPoint DGtal::Shapes< TDomain >::RealPoint

Definition at line 80 of file DGtal/shapes/Shapes.h.

template<typename TDomain>
typedef Domain::Space DGtal::Shapes< TDomain >::Space

Definition at line 79 of file DGtal/shapes/Shapes.h.

template<typename TDomain>
typedef Space::UnsignedInteger DGtal::Shapes< TDomain >::UnsignedInteger

Definition at line 87 of file DGtal/shapes/Shapes.h.

template<typename TDomain>
typedef Domain::Vector DGtal::Shapes< TDomain >::Vector

Definition at line 82 of file DGtal/shapes/Shapes.h.


Constructor & Destructor Documentation

template<typename TDomain >
DGtal::Shapes< TDomain >::~Shapes ( )
inline

Destructor.

Definition at line 46 of file DGtal/shapes/Shapes.ih.

{
}
template<typename TDomain>
DGtal::Shapes< TDomain >::Shapes ( )
protected

Constructor. Forbidden by default (protected to avoid g++ warnings).

template<typename TDomain>
DGtal::Shapes< TDomain >::Shapes ( const Shapes< TDomain > &  other)
private

Copy constructor.

Parameters:
otherthe object to clone. Forbidden by default.

Member Function Documentation

template<typename TDomain >
template<typename TDigitalSet >
void DGtal::Shapes< TDomain >::addNorm1Ball ( TDigitalSet &  aSet,
const Point aCenter,
UnsignedInteger  aRadius 
)
inlinestatic

Adds the discrete ball (norm-1) of center [aCenter] and radius [aRadius] to the (perhaps non empty) set [aSet].

Warning:
deprecated Use implicitShaper instead.
Template Parameters:
TDigitalSetthe type chosen for the digital set.
Parameters:
aSetthe set (modified) which will contain the discrete ball.
aCenterthe center of the ball.
aRadiusthe radius of the ball.

Adds the discrete ball (norm-1) of center [aCenter] and radius [aRadius] to the (perhaps non empty) set [aSet].

Template Parameters:
TDigitalSetthe type chosen for the digital set.
Parameters:
aSetthe set (modified) which will contain the discrete ball.
aCenterthe center of the ball.
aRadiusthe radius of the ball.

Definition at line 100 of file DGtal/shapes/Shapes.ih.

{
Point v1( aCenter.diagonal( aRadius ) );
Point p1( aCenter );
Point p2( p1 );
p1 -= v1;
p2 += v1;
const Domain & domain = aSet.domain();
typedef DGtal::HyperRectDomain<Space> LocalSpace;
LocalSpace ballDomain( p1, p2 );
for ( typename LocalSpace::ConstIterator it = ballDomain.begin();
it != ballDomain.end();
++it )
{
if ( domain.isInside( *it )
&& ( (*it - aCenter ).norm1() <= aRadius ) )
aSet.insert( *it );
}
}
template<typename TDomain >
template<typename TDigitalSet >
void DGtal::Shapes< TDomain >::addNorm2Ball ( TDigitalSet &  aSet,
const Point aCenter,
UnsignedInteger  aRadius 
)
inlinestatic

Adds the discrete ball (norm-2) of center [aCenter] and radius [aRadius] to the (perhaps non empty) set [aSet].

Warning:
deprecated Use implicitShaper instead.
Template Parameters:
TDigitalSetthe type chosen for the digital set.
Parameters:
aSetthe set (modified) which will contain the discrete ball.
aCenterthe center of the ball.
aRadiusthe radius of the ball.

Adds the discrete ball (norm-2) of center [aCenter] and radius [aRadius] to the (perhaps non empty) set [aSet].

Template Parameters:
TDigitalSetthe type chosen for the digital set.
Parameters:
aSetthe set (modified) which will contain the discrete ball.
aCenterthe center of the ball.
aRadiusthe radius of the ball.

Definition at line 174 of file DGtal/shapes/Shapes.ih.

{
Point v1( aCenter.diagonal( aRadius ) );
Point p1( aCenter );
Point p2( p1 );
p1 -= v1;
p2 += v1;
const Domain & domain = aSet.domain();
typedef DGtal::HyperRectDomain<Space> LocalSpace;
LocalSpace ballDomain( p1, p2 );
for ( typename LocalSpace::ConstIterator it = ballDomain.begin();
it != ballDomain.end();
++it )
{
if ( domain.isInside( *it )
&& ( (*it - aCenter ).norm() <= aRadius ) )
aSet.insert( *it );
}
}
template<typename TDomain>
DGtal::Shapes< TDomain >::BOOST_CONCEPT_ASSERT ( (CDomain< TDomain >)  )
private
template<typename TDomain>
template<typename TDigitalSet , typename TShapeFunctor >
static void DGtal::Shapes< TDomain >::digitalShaper ( TDigitalSet &  aSet,
const TShapeFunctor &  aFunctor 
)
static

Adds to the (perhaps non empty) set [aSet] an shape defined by an instance of ShapeFunctor. The shape functor must be a model of CDigitalOrientedShape and CDigitalBoundedShape.

Parameters:
aSetthe set (modified) which will contain the shape.
aFunctora functor defining the shape.
Template Parameters:
TDigitalSeta model of CDigitalSet.
TShapeFunctora model of CDigitalBoundedShape and CDigitalOrientedShape.
template<typename TDomain>
template<typename TDigitalSet , typename ShapeFunctor >
void DGtal::Shapes< TDomain >::digitalShaper ( TDigitalSet &  aSet,
const ShapeFunctor &  aFunctor 
)

Definition at line 199 of file DGtal/shapes/Shapes.ih.

References DGtal::INSIDE.

{
typedef DGtal::HyperRectDomain<Space> LocalSpace;
BOOST_CONCEPT_ASSERT((CDigitalBoundedShape<ShapeFunctor>));
BOOST_CONCEPT_ASSERT((CDigitalOrientedShape<ShapeFunctor>));
Point pLow = aFunctor.getLowerBound();
Point pUpp = aFunctor.getUpperBound();
LocalSpace implicitDomain( pLow, pUpp );
for ( typename LocalSpace::ConstIterator it = implicitDomain.begin();
it != implicitDomain.end();
++it )
{
if ( aFunctor.orientation( *it ) == INSIDE)
aSet.insert( *it );
}
}
template<typename TDomain>
template<typename TDigitalSet , typename TShapeFunctor >
static void DGtal::Shapes< TDomain >::euclideanShaper ( TDigitalSet &  aSet,
const TShapeFunctor &  aFunctor,
const double  h = 1.0 
)
static

Adds to the (perhaps non empty) set [aSet] an shape defined by an instance of ShapeFunctor.The shape functor must be a model of CEuclideanOrientedShape and CEuclideanBoundedShape. The underlying digitization process is a Gauss Digitizer with grid step h.

Parameters:
aSetthe set (modified) which will contain the shape.
aFunctora functor defining the shape.
hgrid step for the Gauss digitization.
Template Parameters:
TDigitalSeta model of CDigitalSet.
TShapeFunctora model of CEuclideanBoundedShape and CEuclideanOrientedShape.
template<typename TDomain>
template<typename TDigitalSet , typename ShapeFunctor >
void DGtal::Shapes< TDomain >::euclideanShaper ( TDigitalSet &  aSet,
const ShapeFunctor &  aFunctor,
const double  h 
)

Definition at line 225 of file DGtal/shapes/Shapes.ih.

References DGtal::GaussDigitizer< TSpace, TEuclideanShape >::attach(), and DGtal::GaussDigitizer< TSpace, TEuclideanShape >::init().

{
BOOST_CONCEPT_ASSERT((CEuclideanBoundedShape<ShapeFunctor>));
BOOST_CONCEPT_ASSERT((CEuclideanOrientedShape<ShapeFunctor>));
RealPoint pLow = aFunctor.getLowerBound();
RealPoint pUpp = aFunctor.getUpperBound();
GaussDigitizer<Space,ShapeFunctor> dig;
dig.attach( aFunctor ); // attaches the shape.
dig.init( pLow, pUpp, h);
// Creates a set from the digitizer.
}
template<typename TDomain >
bool DGtal::Shapes< TDomain >::isValid ( ) const
inline

Checks the validity/consistency of the object.

Returns:
'true' if the object is valid, 'false' otherwise.

Definition at line 289 of file DGtal/shapes/Shapes.ih.

{
return true;
}
template<typename TDomain >
template<typename DigitalSet , typename PointPredicate >
void DGtal::Shapes< TDomain >::makeSetFromPointPredicate ( DigitalSet &  aSet,
const PointPredicate &  aPP 
)
static

Add to the set aSet the points of the domain that satisfies the predicate aPP.

Parameters:
aSet(modified) the digital set that will contain the points.
aPPa predicate on point.
Template Parameters:
DigitalSeta model of CDigitalSet such that DigitalSet::Domain is Domain.
PointPredicatea model of CPointPredicate such that PointPredicate::Point is Point.

Definition at line 247 of file DGtal/shapes/Shapes.ih.

{
BOOST_CONCEPT_ASSERT(( CDigitalSet< DigitalSet > ));
BOOST_CONCEPT_ASSERT(( CPointPredicate< PointPredicate > ));
BOOST_STATIC_ASSERT
(( ConceptUtils::SameType< Domain, typename DigitalSet::Domain >::value ));
BOOST_STATIC_ASSERT
(( ConceptUtils::SameType< Point, typename PointPredicate::Point >::value ));
typedef typename Domain::ConstIterator ConstIterator;
for ( ConstIterator it = aSet.domain().begin(),
it_end = aSet.domain().end(); it != it_end; ++it )
if ( aPP( *it ) ) aSet.insert( *it );
}
template<typename TDomain>
Shapes& DGtal::Shapes< TDomain >::operator= ( const Shapes< TDomain > &  other)
private

Assignment.

Parameters:
otherthe object to copy.
Returns:
a reference on 'this'. Forbidden by default.
template<typename TDomain >
template<typename TDigitalSet >
void DGtal::Shapes< TDomain >::removeNorm1Ball ( TDigitalSet &  aSet,
const Point aCenter,
UnsignedInteger  aRadius 
)
inlinestatic

Removes the discrete ball (norm-1) of center [aCenter] and radius [aRadius] to the (perhaps non empty) set [aSet].

Template Parameters:
TDigitalSetthe type chosen for the digital set.
Parameters:
aSetthe set (modified) which will contain the discrete ball.
aCenterthe center of the ball.
aRadiusthe radius of the ball.

Definition at line 65 of file DGtal/shapes/Shapes.ih.

{
Point v1( aCenter.diagonal( aRadius ) );
Point p1( aCenter );
Point p2( p1 );
p1 -= v1;
p2 += v1;
const Domain & domain = aSet.domain();
typedef DGtal::HyperRectDomain<Space> LocalSpace;
LocalSpace ballDomain( p1, p2 );
for ( typename LocalSpace::ConstIterator it = ballDomain.begin();
it != ballDomain.end();
++it )
{
if ( domain.isInside( *it )
&& ( (*it - aCenter ).norm1() <= aRadius ) )
aSet.erase( *it );
}
}
template<typename TDomain >
template<typename TDigitalSet >
void DGtal::Shapes< TDomain >::removeNorm2Ball ( TDigitalSet &  aSet,
const Point aCenter,
UnsignedInteger  aRadius 
)
inlinestatic

Removes the discrete ball (norm-2) of center [aCenter] and radius [aRadius] to the (perhaps non empty) set [aSet].

Template Parameters:
TDigitalSetthe type chosen for the digital set.
Parameters:
aSetthe set (modified) which will contain the discrete ball.
aCenterthe center of the ball.
aRadiusthe radius of the ball.

Definition at line 137 of file DGtal/shapes/Shapes.ih.

{
Point v1( aCenter.diagonal( aRadius ) );
Point p1( aCenter );
Point p2( p1 );
p1 -= v1;
p2 += v1;
const Domain & domain = aSet.domain();
typedef DGtal::HyperRectDomain<Space> LocalSpace;
LocalSpace ballDomain( p1, p2 );
for ( typename LocalSpace::ConstIterator it = ballDomain.begin();
it != ballDomain.end();
++it )
{
if ( domain.isInside( *it )
&& ( (*it - aCenter ).norm() <= aRadius ) )
aSet.erase( *it );
}
}
template<typename TDomain >
void DGtal::Shapes< TDomain >::selfDisplay ( std::ostream &  out) const
inline

Writes/Displays the object on an output stream.

Parameters:
outthe output stream where the object is written.

Definition at line 277 of file DGtal/shapes/Shapes.ih.

{
out << "[Shapes]";
}

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