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

#include <DigitalSetBySTLSet.h>

Collaboration diagram for DGtal::DigitalSetBySTLSet< TDomain >:
Collaboration graph
[legend]

Public Types

typedef TDomain Domain
typedef DigitalSetBySTLSet
< Domain
Self
typedef Domain::Space Space
typedef Domain::Point Point
typedef Domain::Size Size
typedef std::set< Point >::iterator Iterator
typedef std::set< Point >
::const_iterator 
ConstIterator

Public Member Functions

 ~DigitalSetBySTLSet ()
 DigitalSetBySTLSet (const Domain &d)
 DigitalSetBySTLSet (const DigitalSetBySTLSet &other)
DigitalSetBySTLSetoperator= (const DigitalSetBySTLSet &other)
const Domaindomain () const
Size size () const
bool empty () const
void insert (const Point &p)
template<typename PointInputIterator >
void insert (PointInputIterator first, PointInputIterator last)
void insertNew (const Point &p)
template<typename PointInputIterator >
void insertNew (PointInputIterator first, PointInputIterator last)
Size erase (const Point &p)
void erase (Iterator it)
void erase (Iterator first, Iterator last)
void clear ()
ConstIterator find (const Point &p) const
Iterator find (const Point &p)
ConstIterator begin () const
ConstIterator end () const
Iterator begin ()
Iterator end ()
DigitalSetBySTLSet< Domain > & operator+= (const DigitalSetBySTLSet< Domain > &aSet)
template<typename TOutputIterator >
void computeComplement (TOutputIterator &ito) const
void assignFromComplement (const DigitalSetBySTLSet< Domain > &other_set)
void computeBoundingBox (Point &lower, Point &upper) const
void selfDisplay (std::ostream &out) const
bool isValid () const
std::string className () const

Protected Member Functions

 DigitalSetBySTLSet ()

Protected Attributes

const DomainmyDomain
std::set< PointmySet

Detailed Description

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

Aim: A container class for storing sets of digital points within some given domain.

Description of template class 'DigitalSetBySTLSet'

This is the most versatile implementation for a set of point, and is essentially a wrapper to std::set<Point>. It added the notion of domain.

Model of CDigitalSet.

Examples:
io/digitalSetFromVol.cpp, io/display3DToOFF.cpp, topology/3dBorderExtraction.cpp, topology/3dBorderExtractionImg.cpp, topology/ctopo-2-3d.cpp, and topology/ctopo-2.cpp.

Definition at line 74 of file DigitalSetBySTLSet.h.


Member Typedef Documentation

template<typename TDomain>
typedef std::set<Point>::const_iterator DGtal::DigitalSetBySTLSet< TDomain >::ConstIterator

Definition at line 83 of file DigitalSetBySTLSet.h.

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

Definition at line 77 of file DigitalSetBySTLSet.h.

template<typename TDomain>
typedef std::set<Point>::iterator DGtal::DigitalSetBySTLSet< TDomain >::Iterator

Definition at line 82 of file DigitalSetBySTLSet.h.

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

Definition at line 80 of file DigitalSetBySTLSet.h.

template<typename TDomain>
typedef DigitalSetBySTLSet<Domain> DGtal::DigitalSetBySTLSet< TDomain >::Self

Definition at line 78 of file DigitalSetBySTLSet.h.

template<typename TDomain>
typedef Domain::Size DGtal::DigitalSetBySTLSet< TDomain >::Size

Definition at line 81 of file DigitalSetBySTLSet.h.

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

Definition at line 79 of file DigitalSetBySTLSet.h.


Constructor & Destructor Documentation

template<typename Domain >
DGtal::DigitalSetBySTLSet< Domain >::~DigitalSetBySTLSet ( )
inline

Destructor.

Definition at line 50 of file DigitalSetBySTLSet.ih.

{
}
template<typename Domain >
DGtal::DigitalSetBySTLSet< Domain >::DigitalSetBySTLSet ( const Domain d)
inline

Constructor. Creates the empty set in the domain [d].

Parameters:
dany domain.

Definition at line 62 of file DigitalSetBySTLSet.ih.

: myDomain( d ), mySet()
{
}
template<typename Domain >
DGtal::DigitalSetBySTLSet< Domain >::DigitalSetBySTLSet ( const DigitalSetBySTLSet< TDomain > &  other)
inline

Copy constructor.

Parameters:
otherthe object to clone.

Definition at line 73 of file DigitalSetBySTLSet.ih.

: myDomain( other.myDomain ), mySet( other.mySet )
{
}
template<typename TDomain>
DGtal::DigitalSetBySTLSet< TDomain >::DigitalSetBySTLSet ( )
protected

Default Constructor. Forbidden since a Domain is necessary for defining a set.


Member Function Documentation

template<typename Domain >
void DGtal::DigitalSetBySTLSet< Domain >::assignFromComplement ( const DigitalSetBySTLSet< Domain > &  other_set)
inline

Builds the complement in the domain of the set [other_set] in this.

Parameters:
other_setdefines the set whose complement is assigned to 'this'.

Definition at line 369 of file DigitalSetBySTLSet.ih.

References DGtal::DigitalSetBySTLSet< TDomain >::end(), and DGtal::DigitalSetBySTLSet< TDomain >::find().

{
clear();
typename Domain::ConstIterator itPoint = myDomain.begin();
typename Domain::ConstIterator itEnd = myDomain.end();
while ( itPoint != itEnd ) {
if ( other_set.find( *itPoint ) == other_set.end() ) {
insert( *itPoint );
}
++itPoint;
}
}
template<typename Domain >
DGtal::DigitalSetBySTLSet< Domain >::ConstIterator DGtal::DigitalSetBySTLSet< Domain >::begin ( ) const
inline
template<typename Domain >
DGtal::DigitalSetBySTLSet< Domain >::Iterator DGtal::DigitalSetBySTLSet< Domain >::begin ( )
inline
Returns:
an iterator on the first element in this set.

Definition at line 298 of file DigitalSetBySTLSet.ih.

References DGtal::DigitalSetBySTLSet< TDomain >::begin().

{
return mySet.begin();
}
template<typename Domain >
std::string DGtal::DigitalSetBySTLSet< Domain >::className ( ) const
inline

Default drawing style object.

Returns:
the dyn. alloc. default style for this object.
the style name used for drawing this object.

Definition at line 448 of file DigitalSetBySTLSet.ih.

Referenced by DGtal::Display3DFactory::draw().

{
return "DigitalSetBySTLSet";
}
template<typename Domain >
void DGtal::DigitalSetBySTLSet< Domain >::clear ( )
inline

Clears the set.

Postcondition:
this set is empty.

Definition at line 241 of file DigitalSetBySTLSet.ih.

References DGtal::DigitalSetBySTLSet< TDomain >::clear().

Referenced by DGtal::DigitalSetBySTLSet< TDomain >::clear().

{
mySet.clear();
}
template<typename Domain >
void DGtal::DigitalSetBySTLSet< Domain >::computeBoundingBox ( Point lower,
Point upper 
) const
inline

Computes the bounding box of this set.

Parameters:
lowerthe first point of the bounding box (lowest in all directions).
upperthe last point of the bounding box (highest in all directions).

Definition at line 394 of file DigitalSetBySTLSet.ih.

{
lower = myDomain.upperBound();
upper = myDomain.lowerBound();
ConstIterator it = begin();
ConstIterator itEnd = end();
while ( it != itEnd ) {
lower = lower.inf( *it );
upper = upper.sup( *it );
++it;
}
}
template<typename Domain >
template<typename TOutputIterator >
void DGtal::DigitalSetBySTLSet< Domain >::computeComplement ( TOutputIterator &  ito) const
inline

Computes the complement in the domain of this set

Parameters:
itoan output iterator
Template Parameters:
TOutputIteratora model of output iterator

Definition at line 347 of file DigitalSetBySTLSet.ih.

References DGtal::DigitalSetBySTLSet< TDomain >::begin().

{
typename Domain::ConstIterator itPoint = myDomain.begin();
typename Domain::ConstIterator itEnd = myDomain.end();
while ( itPoint != itEnd ) {
if ( find( *itPoint ) == end() ) {
*ito++ = *itPoint;
}
++itPoint;
}
}
template<typename Domain >
const Domain & DGtal::DigitalSetBySTLSet< Domain >::domain ( ) const
inline
Returns:
the embedding domain.

Definition at line 102 of file DigitalSetBySTLSet.ih.

{
return myDomain;
}
template<typename Domain >
bool DGtal::DigitalSetBySTLSet< Domain >::empty ( ) const
inline
Returns:
'true' iff the set is empty (no element).

Definition at line 130 of file DigitalSetBySTLSet.ih.

References DGtal::DigitalSetBySTLSet< TDomain >::empty().

Referenced by DGtal::DigitalSetBySTLSet< TDomain >::empty().

{
return mySet.empty();
}
template<typename Domain >
DGtal::DigitalSetBySTLSet< Domain >::ConstIterator DGtal::DigitalSetBySTLSet< Domain >::end ( ) const
inline
template<typename Domain >
DGtal::DigitalSetBySTLSet< Domain >::Iterator DGtal::DigitalSetBySTLSet< Domain >::end ( )
inline
Returns:
a iterator on the element after the last in this set.

Definition at line 309 of file DigitalSetBySTLSet.ih.

References DGtal::DigitalSetBySTLSet< TDomain >::end().

{
return mySet.end();
}
template<typename Domain >
DGtal::DigitalSetBySTLSet< Domain >::Size DGtal::DigitalSetBySTLSet< Domain >::erase ( const Point p)

Removes point [p] from the set.

Parameters:
pthe point to remove.
Returns:
the number of removed elements (0 or 1).

Definition at line 215 of file DigitalSetBySTLSet.ih.

References DGtal::DigitalSetBySTLSet< TDomain >::erase().

Referenced by DGtal::DigitalSetBySTLSet< TDomain >::erase().

{
return (unsigned int)mySet.erase( p );
}
template<typename Domain >
void DGtal::DigitalSetBySTLSet< Domain >::erase ( Iterator  it)
inline

Removes the point pointed by [it] from the set.

Parameters:
itan iterator on this set. Note: generally faster than giving just the point.

Definition at line 229 of file DigitalSetBySTLSet.ih.

References DGtal::DigitalSetBySTLSet< TDomain >::erase().

{
mySet.erase( it );
}
template<typename TDomain>
void DGtal::DigitalSetBySTLSet< TDomain >::erase ( Iterator  first,
Iterator  last 
)

Removes the collection of points specified by the two iterators from this set.

Parameters:
firstthe start point in this set.
lastthe last point in this set.
template<typename Domain >
DGtal::DigitalSetBySTLSet< Domain >::ConstIterator DGtal::DigitalSetBySTLSet< Domain >::find ( const Point p) const
inline
Parameters:
pany digital point.
pany digital point.
Returns:
a const iterator pointing on [p] if found, otherwise end().

Definition at line 253 of file DigitalSetBySTLSet.ih.

References DGtal::DigitalSetBySTLSet< TDomain >::find().

Referenced by DGtal::DigitalSetBySTLSet< TDomain >::assignFromComplement(), and DGtal::DigitalSetBySTLSet< TDomain >::find().

{
return mySet.find( p );
}
template<typename Domain >
DGtal::DigitalSetBySTLSet< Domain >::Iterator DGtal::DigitalSetBySTLSet< Domain >::find ( const Point p)
inline
Parameters:
pany digital point.
Returns:
an iterator pointing on [p] if found, otherwise end().

Definition at line 265 of file DigitalSetBySTLSet.ih.

References DGtal::DigitalSetBySTLSet< TDomain >::find().

{
return mySet.find( p );
}
template<typename Domain >
void DGtal::DigitalSetBySTLSet< Domain >::insert ( const Point p)
inline

Adds point [p] to this set.

Parameters:
pany digital point.
Precondition:
p should belong to the associated domain.

Definition at line 145 of file DigitalSetBySTLSet.ih.

References DGtal::DigitalSetBySTLSet< TDomain >::insert().

Referenced by DGtal::DigitalSetBySTLSet< TDomain >::insert(), and DGtal::DigitalSetBySTLSet< TDomain >::insertNew().

{
// ASSERT( myDomain.isInside( p ) );
mySet.insert( p );
}
template<typename Domain >
template<typename PointInputIterator >
void DGtal::DigitalSetBySTLSet< Domain >::insert ( PointInputIterator  first,
PointInputIterator  last 
)

Adds the collection of points specified by the two iterators to this set.

Parameters:
firstthe start point in the collection of Point.
lastthe last point in the collection of Point.
Precondition:
all points should belong to the associated domain.

Definition at line 163 of file DigitalSetBySTLSet.ih.

References DGtal::DigitalSetBySTLSet< TDomain >::insert().

{
mySet.insert( first, last );
}
template<typename Domain >
void DGtal::DigitalSetBySTLSet< Domain >::insertNew ( const Point p)
inline

Adds point [p] to this set if the point is not already in the set.

Parameters:
pany digital point.
Precondition:
p should belong to the associated domain.
p should not belong to this.

Definition at line 181 of file DigitalSetBySTLSet.ih.

References DGtal::DigitalSetBySTLSet< TDomain >::insert().

Referenced by DGtal::Object< TDigitalTopology, TDigitalSet >::neighborhood(), and DGtal::Object< TDigitalTopology, TDigitalSet >::properNeighborhood().

{
// ASSERT( myDomain.isInside( p ) );
mySet.insert( p );
}
template<typename Domain >
template<typename PointInputIterator >
void DGtal::DigitalSetBySTLSet< Domain >::insertNew ( PointInputIterator  first,
PointInputIterator  last 
)
inline

Adds the collection of points specified by the two iterators to this set.

Parameters:
firstthe start point in the collection of Point.
lastthe last point in the collection of Point.
Precondition:
all points should belong to the associated domain.
each point should not belong to this.

Definition at line 202 of file DigitalSetBySTLSet.ih.

References DGtal::DigitalSetBySTLSet< TDomain >::insert().

{
mySet.insert( first, last );
}
template<typename Domain >
bool DGtal::DigitalSetBySTLSet< Domain >::isValid ( ) const
inline

Checks the validity/consistency of the object.

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

Definition at line 429 of file DigitalSetBySTLSet.ih.

{
return true;
}
template<typename Domain >
DGtal::DigitalSetBySTLSet< Domain > & DGtal::DigitalSetBySTLSet< Domain >::operator+= ( const DigitalSetBySTLSet< Domain > &  aSet)
inline

set union to left.

Parameters:
aSetany other set.

Definition at line 322 of file DigitalSetBySTLSet.ih.

References DGtal::DigitalSetBySTLSet< TDomain >::begin(), and DGtal::DigitalSetBySTLSet< TDomain >::end().

{
if ( this != &aSet )
{
Iterator it_dst = end();
for ( ConstIterator it_src = aSet.begin();
it_src != aSet.end();
++it_src )
{
// Use hint it_dst to go faster.
it_dst = mySet.insert( it_dst, *it_src );
}
}
return *this;
}
template<typename Domain >
DGtal::DigitalSetBySTLSet< Domain > & DGtal::DigitalSetBySTLSet< Domain >::operator= ( const DigitalSetBySTLSet< TDomain > &  other)
inline

Assignment.

Parameters:
otherthe object to copy.
Returns:
a reference on 'this'.

Definition at line 86 of file DigitalSetBySTLSet.ih.

References DGtal::DigitalSetBySTLSet< TDomain >::myDomain, and DGtal::DigitalSetBySTLSet< TDomain >::mySet.

{
ASSERT( ( myDomain.lowerBound() <= other.myDomain.lowerBound() )
&& ( myDomain.upperBound() >= other.myDomain.upperBound() )
&& "This domain should include the domain of the other set in case of assignment." );
mySet = other.mySet;
return *this;
}
template<typename Domain >
void DGtal::DigitalSetBySTLSet< Domain >::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 417 of file DigitalSetBySTLSet.ih.

Referenced by DGtal::operator<<().

{
out << "[DigitalSetBySTLSet]" << " size=" << size();
}
template<typename Domain >
DGtal::DigitalSetBySTLSet< Domain >::Size DGtal::DigitalSetBySTLSet< Domain >::size ( ) const
inline
Returns:
the number of elements in the set.

Definition at line 119 of file DigitalSetBySTLSet.ih.

References DGtal::DigitalSetBySTLSet< TDomain >::size().

Referenced by DGtal::DigitalSetBySTLSet< TDomain >::size().

{
return (unsigned int)mySet.size();
}

Field Documentation

template<typename TDomain>
const Domain& DGtal::DigitalSetBySTLSet< TDomain >::myDomain
protected

The associated domain;

Definition at line 295 of file DigitalSetBySTLSet.h.

Referenced by DGtal::DigitalSetBySTLSet< TDomain >::operator=().

template<typename TDomain>
std::set<Point> DGtal::DigitalSetBySTLSet< TDomain >::mySet
protected

The container storing the points of the set.

Definition at line 300 of file DigitalSetBySTLSet.h.

Referenced by DGtal::DigitalSetBySTLSet< TDomain >::operator=().


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