Data Structures | Public Types | Public Member Functions | Private Attributes

DGtal::Object< TDigitalTopology, TDigitalSet > Class Template Reference

Aim: An object (or digital object) represents a set in some digital space associated with a digital topology. More...

#include <Object.h>

Collaboration diagram for DGtal::Object< TDigitalTopology, TDigitalSet >:
Collaboration graph
[legend]

Data Structures

struct  DefaultDrawStyle

Public Types

enum  Connectedness { DISCONNECTED = 0, CONNECTED = 1, UNKNOWN = 2 }
typedef TDigitalSet DigitalSet
typedef TDigitalTopology DigitalTopology
typedef
DigitalTopology::ReverseTopology 
ReverseTopology
typedef DigitalSet::Size Size
typedef DigitalSet::Point Point
typedef DigitalTopology::Point DTPoint
typedef DigitalSet::DomainType Domain
typedef Domain::Space Space
typedef DigitalSetSelector
< Domain, SMALL_DS+HIGH_ITER_DS >
::Type 
SmallSet
typedef
DigitalTopology::ForegroundAdjacency 
ForegroundAdjacency
typedef
DigitalTopology::BackgroundAdjacency 
BackgroundAdjacency
typedef Object
< ReverseTopology, DigitalSet
ComplementObject
typedef Object
< DigitalTopology, SmallSet
SmallObject
typedef Object
< ReverseTopology, SmallSet
SmallComplementObject

Public Member Functions

 Object ()
 Object (const DigitalTopology &aTopology, const DigitalSet &aPointSet, Connectedness cxn=UNKNOWN)
 Object (const CowPtr< DigitalTopology > &aTopology, const DigitalSet &aPointSet, Connectedness cxn=UNKNOWN)
 Object (const DigitalTopology &aTopology, const CowPtr< DigitalSet > &aPointSet, Connectedness cxn=UNKNOWN)
 Object (const DigitalTopology &aTopology, DigitalSet *aPointSetPtr, Connectedness cxn=UNKNOWN)
 Object (const DigitalTopology &aTopology, const Domain &domain)
 Object (const CowPtr< DigitalTopology > &aTopology, const Domain &aDomain)
 Object (const Object &other)
 ~Object ()
Objectoperator= (const Object &other)
Size size () const
const Domaindomain () const
const DigitalSetpointSet () const
DigitalSetpointSet ()
const DigitalTopologytopology () const
const ForegroundAdjacencyadjacency () const
SmallObject neighborhood (const Point &p) const
Size neighborhoodSize (const Point &p) const
SmallObject properNeighborhood (const Point &p) const
Size properNeighborhoodSize (const Point &p) const
Object border () const
template<typename TOutputObjectIterator >
Size writeComponents (TOutputObjectIterator &it) const
Connectedness connectedness () const
Connectedness computeConnectedness () const
template<typename TAdjacency >
SmallObject geodesicNeighborhood (const TAdjacency &adj, const Point &p, unsigned int k) const
template<typename TAdjacency >
SmallComplementObject geodesicNeighborhoodInComplement (const TAdjacency &adj, const Point &p, unsigned int k) const
bool isSimple (const Point &v) const
void selfDisplay (std::ostream &out) const
bool isValid () const
DrawableWithDGtalBoarddefaultStyle (std::string mode="") const
std::string styleName () const
void selfDraw (DGtalBoard &board) const
template<typename Functor >
void selfDrawWithAdjacencies (DGtalBoard &board) const
void selfDrawWithAdjacencies (DGtalBoard &board) const

Private Attributes

CowPtr< DigitalTopologymyTopo
CowPtr< DigitalSetmyPointSet
Connectedness myConnectedness

Detailed Description

template<typename TDigitalTopology, typename TDigitalSet>
class DGtal::Object< TDigitalTopology, TDigitalSet >

Aim: An object (or digital object) represents a set in some digital space associated with a digital topology.

Description of template class 'Object'

The digital topology induces a connectedness relation on the object (transitive closure of the foreground adjacency) and a connectedness relation on the complement of the set (transitive closure of the background adjacency).

Objects may be connected or not. The connectedness is stored with the object, if it is known. Objects have a border, which are the points which touch the complement in the sense of background adjacency.

export: An Object realizes the concept CDrawableWithDGtalBoard. It may be displayed with a DGtalBoard, and is by default displayed as a set of digital points. An Object reacts to the mode "DrawAdjacencies". In this case the set of points and the adjacency relations are displayed.

Template Parameters:
TDigitalTopology any realization of DigitalTopology.
TDigitalSet any model of CDigitalSet.

Member Typedef Documentation

template<typename TDigitalTopology, typename TDigitalSet>
typedef DigitalTopology::BackgroundAdjacency DGtal::Object< TDigitalTopology, TDigitalSet >::BackgroundAdjacency
template<typename TDigitalTopology, typename TDigitalSet>
typedef Object<ReverseTopology, DigitalSet> DGtal::Object< TDigitalTopology, TDigitalSet >::ComplementObject
template<typename TDigitalTopology, typename TDigitalSet>
typedef TDigitalSet DGtal::Object< TDigitalTopology, TDigitalSet >::DigitalSet
template<typename TDigitalTopology, typename TDigitalSet>
typedef TDigitalTopology DGtal::Object< TDigitalTopology, TDigitalSet >::DigitalTopology
template<typename TDigitalTopology, typename TDigitalSet>
typedef DigitalSet::DomainType DGtal::Object< TDigitalTopology, TDigitalSet >::Domain
template<typename TDigitalTopology, typename TDigitalSet>
typedef DigitalTopology::Point DGtal::Object< TDigitalTopology, TDigitalSet >::DTPoint
template<typename TDigitalTopology, typename TDigitalSet>
typedef DigitalTopology::ForegroundAdjacency DGtal::Object< TDigitalTopology, TDigitalSet >::ForegroundAdjacency
template<typename TDigitalTopology, typename TDigitalSet>
typedef DigitalSet::Point DGtal::Object< TDigitalTopology, TDigitalSet >::Point
template<typename TDigitalTopology, typename TDigitalSet>
typedef DigitalTopology::ReverseTopology DGtal::Object< TDigitalTopology, TDigitalSet >::ReverseTopology
template<typename TDigitalTopology, typename TDigitalSet>
typedef DigitalSet::Size DGtal::Object< TDigitalTopology, TDigitalSet >::Size
template<typename TDigitalTopology, typename TDigitalSet>
typedef Object<ReverseTopology, SmallSet> DGtal::Object< TDigitalTopology, TDigitalSet >::SmallComplementObject
template<typename TDigitalTopology, typename TDigitalSet>
typedef Object<DigitalTopology, SmallSet> DGtal::Object< TDigitalTopology, TDigitalSet >::SmallObject
template<typename TDigitalTopology, typename TDigitalSet>
typedef DigitalSetSelector< Domain, SMALL_DS + HIGH_ITER_DS >::Type DGtal::Object< TDigitalTopology, TDigitalSet >::SmallSet
template<typename TDigitalTopology, typename TDigitalSet>
typedef Domain::Space DGtal::Object< TDigitalTopology, TDigitalSet >::Space

Member Enumeration Documentation

template<typename TDigitalTopology, typename TDigitalSet>
enum DGtal::Object::Connectedness

Kind of connectedness of this object.

Enumerator:
DISCONNECTED 
CONNECTED 
UNKNOWN 

Constructor & Destructor Documentation

template<typename TDigitalTopology, typename TDigitalSet>
DGtal::Object< TDigitalTopology, TDigitalSet >::Object (  ) 

Constructor. The object is not valid.

template<typename TDigitalTopology, typename TDigitalSet>
DGtal::Object< TDigitalTopology, TDigitalSet >::Object ( const DigitalTopology aTopology,
const DigitalSet aPointSet,
Connectedness  cxn = UNKNOWN 
)

Constructor.

Parameters:
aTopology the digital topology chosen for this set, a copy of which is stored in the object.
aPointSet the set of points of the object. It is copied in the object.
cxn the connectedness (default is UNKNOWN).
template<typename TDigitalTopology, typename TDigitalSet>
DGtal::Object< TDigitalTopology, TDigitalSet >::Object ( const CowPtr< DigitalTopology > &  aTopology,
const DigitalSet aPointSet,
Connectedness  cxn = UNKNOWN 
)

Constructor.

Parameters:
aTopology the digital topology chosen for this set, smartly copied.
aPointSet the set of points of the object. It is copied in the object.
cxn the connectedness (default is UNKNOWN).
template<typename TDigitalTopology, typename TDigitalSet>
DGtal::Object< TDigitalTopology, TDigitalSet >::Object ( const DigitalTopology aTopology,
const CowPtr< DigitalSet > &  aPointSet,
Connectedness  cxn = UNKNOWN 
)

Constructor.

Parameters:
aTopology the digital topology chosen for this set, a copy of which is stored in the object.
aPointSet the set of points of the object. It is smartly reference in the object.
cxn the connectedness (default is UNKNOWN).
template<typename TDigitalTopology, typename TDigitalSet>
DGtal::Object< TDigitalTopology, TDigitalSet >::Object ( const DigitalTopology aTopology,
DigitalSet aPointSetPtr,
Connectedness  cxn = UNKNOWN 
)

Constructor by attachment of a dynamically allocated point set.

Parameters:
aTopology the digital topology chosen for this set, a copy of which is stored in the object.
aPointSetPtr a dynamically allocated pointer on a set of points which is afterwards handled by this (which will take care of its deletion).
cxn the connectedness (default is UNKNOWN).
template<typename TDigitalTopology, typename TDigitalSet>
DGtal::Object< TDigitalTopology, TDigitalSet >::Object ( const DigitalTopology aTopology,
const Domain domain 
)

Constructor of an empty object by providing a domain.

Parameters:
aTopology the digital topology chosen for this set, a copy of which is stored in the object.
aDomain any domain related to the given topology.
template<typename TDigitalTopology, typename TDigitalSet>
DGtal::Object< TDigitalTopology, TDigitalSet >::Object ( const CowPtr< DigitalTopology > &  aTopology,
const Domain aDomain 
)

Constructor of an empty object by providing a domain.

Parameters:
aTopology the digital topology chosen for this set, smartly copied.
aDomain any domain related to the given topology.
template<typename TDigitalTopology, typename TDigitalSet>
DGtal::Object< TDigitalTopology, TDigitalSet >::Object ( const Object< TDigitalTopology, TDigitalSet > &  other  ) 

Copy constructor.

Parameters:
other the object to clone.

The copy is smart in the sense that the digital set is referenced, and will be copied only if the set is changed.

template<typename TDigitalTopology, typename TDigitalSet>
DGtal::Object< TDigitalTopology, TDigitalSet >::~Object (  ) 

Destructor.


Member Function Documentation

template<typename TDigitalTopology, typename TDigitalSet>
const ForegroundAdjacency& DGtal::Object< TDigitalTopology, TDigitalSet >::adjacency (  )  const
Returns:
a const reference to the adjacency of this object.
template<typename TDigitalTopology, typename TDigitalSet>
Object DGtal::Object< TDigitalTopology, TDigitalSet >::border (  )  const
Returns:
the border of this object (the set of points of this which is lambda()-adjacent with some point of the background).

NB : the background adjacency should be a symmetric relation.

template<typename TDigitalTopology, typename TDigitalSet>
Connectedness DGtal::Object< TDigitalTopology, TDigitalSet >::computeConnectedness (  )  const

If 'connectedness() == UNKNOWN', computes the connectedness of this object. After that, the connectedness of 'this' is either CONNECTED or DISCONNECTED.

Returns:
the connectedness of this object. Either CONNECTED or DISCONNECTED.
See also:
connectedness
template<typename TDigitalTopology, typename TDigitalSet>
Connectedness DGtal::Object< TDigitalTopology, TDigitalSet >::connectedness (  )  const
Returns:
the connectedness of this object. Either CONNECTED, DISCONNECTED, or UNKNOWN.
See also:
computeConnectedness
template<typename TDigitalTopology, typename TDigitalSet>
DrawableWithDGtalBoard* DGtal::Object< TDigitalTopology, TDigitalSet >::defaultStyle ( std::string  mode = ""  )  const

Default drawing style object.

Returns:
the dyn. alloc. default style for this object.
template<typename TDigitalTopology, typename TDigitalSet>
const Domain& DGtal::Object< TDigitalTopology, TDigitalSet >::domain (  )  const

A const reference to the embedding domain.

template<typename TDigitalTopology, typename TDigitalSet>
template<typename TAdjacency >
SmallObject DGtal::Object< TDigitalTopology, TDigitalSet >::geodesicNeighborhood ( const TAdjacency &  adj,
const Point p,
unsigned int  k 
) const

Geodesic neighborhood of point [p] and order [k] in the object for the given metric adjacency.

template<typename TDigitalTopology, typename TDigitalSet>
template<typename TAdjacency >
SmallComplementObject DGtal::Object< TDigitalTopology, TDigitalSet >::geodesicNeighborhoodInComplement ( const TAdjacency &  adj,
const Point p,
unsigned int  k 
) const

Geodesic neighborhood of point [p] and order [k] in the complemented object for the given metric adjacency.

template<typename TDigitalTopology, typename TDigitalSet>
bool DGtal::Object< TDigitalTopology, TDigitalSet >::isSimple ( const Point v  )  const

[Bertrand, 1994] A voxel v is simple for a set X if C6 [G6 (v, X)] = C18[G18(v, X^c)] = 1, where Ck [Y] denotes the number of k-connected components of a set Y.

We adapt this definition to (kappa,lambda) connectednesses. Be careful, such a definition is valid only for Jordan couples in dimension 2 and 3.

Returns:
'true' if this point is simple.

Referenced by testSimplePoints2D().

template<typename TDigitalTopology, typename TDigitalSet>
bool DGtal::Object< TDigitalTopology, TDigitalSet >::isValid (  )  const

Checks the validity/consistency of the object.

Returns:
'true' if the object is valid, 'false' otherwise.
template<typename TDigitalTopology, typename TDigitalSet>
SmallObject DGtal::Object< TDigitalTopology, TDigitalSet >::neighborhood ( const Point p  )  const

Let A be this object with foreground adjacency k and N_k(p) the k-neighborhood of p. Returns the set A intersected with N_k(p).

Parameters:
p any point (in the domain of the digital object, not necessarily in the object).
Returns:
the kappa-neighborhood of [p] in this object.
See also:
neighborhoodSize

NB: if you need only the size of neighborhood, use neighborhoodSize.

Referenced by testObject().

template<typename TDigitalTopology, typename TDigitalSet>
Size DGtal::Object< TDigitalTopology, TDigitalSet >::neighborhoodSize ( const Point p  )  const
Parameters:
p any point (in the domain of the digital object, not necessarily in the object).
Returns:
the cardinal of the kappa-neighborhood of [p] in this object.
See also:
neighborhood

NB: faster than computing the neighborhood then computing its cardinal.

template<typename TDigitalTopology, typename TDigitalSet>
Object& DGtal::Object< TDigitalTopology, TDigitalSet >::operator= ( const Object< TDigitalTopology, TDigitalSet > &  other  ) 

Assignment.

Parameters:
other the object to copy.
Returns:
a reference on 'this'.
template<typename TDigitalTopology, typename TDigitalSet>
const DigitalSet& DGtal::Object< TDigitalTopology, TDigitalSet >::pointSet (  )  const

A const reference on the point set defining the points of the digital object.

Referenced by testObject(), and testSimplePoints2D().

template<typename TDigitalTopology, typename TDigitalSet>
DigitalSet& DGtal::Object< TDigitalTopology, TDigitalSet >::pointSet (  ) 

A reference on the point set defining the points of the digital object (may duplicate the set).

template<typename TDigitalTopology, typename TDigitalSet>
SmallObject DGtal::Object< TDigitalTopology, TDigitalSet >::properNeighborhood ( const Point p  )  const

Let A be this object with foreground adjacency k and N*_k(p) the proper k-neighborhood of p. Returns the set A intersected with N*_k(p).

Parameters:
p any point (in the domain of the digital object, not necessarily in the object).
Returns:
the kappa-neighborhood of [p] in this object, without p.
See also:
properNeighborhoodSize

NB: if you need only the size of the proper neighborhood, use properNeighborhoodSize.

Referenced by testObject().

template<typename TDigitalTopology, typename TDigitalSet>
Size DGtal::Object< TDigitalTopology, TDigitalSet >::properNeighborhoodSize ( const Point p  )  const
Parameters:
p any point (in the domain of the digital object, not necessarily in the object).
Returns:
the cardinal of the kappa-neighborhood of [p] in this object.
See also:
properNeighborhood

NB: faster than computing the proper neighborhood then computing its cardinal.

template<typename TDigitalTopology, typename TDigitalSet>
void DGtal::Object< TDigitalTopology, TDigitalSet >::selfDisplay ( std::ostream &  out  )  const

Writes/Displays the object on an output stream.

Parameters:
out the output stream where the object is written.
template<typename TDigitalTopology, typename TDigitalSet>
void DGtal::Object< TDigitalTopology, TDigitalSet >::selfDraw ( DGtalBoard board  )  const

Draw the object on a DGtalBoard board.

Parameters:
board the output board where the object is drawn.
template<typename TDigitalTopology, typename TDigitalSet>
void DGtal::Object< TDigitalTopology, TDigitalSet >::selfDrawWithAdjacencies ( DGtalBoard board  )  const

Draw the object (with Adjacency relationships) on a LiBoard board.

Parameters:
board the output board where the object is drawn.
template<typename TDigitalTopology, typename TDigitalSet>
template<typename Functor >
void DGtal::Object< TDigitalTopology, TDigitalSet >::selfDrawWithAdjacencies ( DGtalBoard board  )  const

Draw the object (with Adjacency relationships) on a LiBoard board.

Parameters:
board the output board where the object is drawn.
Template Parameters:
Functor a Functor to specialize the Board style
template<typename TDigitalTopology, typename TDigitalSet>
Size DGtal::Object< TDigitalTopology, TDigitalSet >::size (  )  const
Returns:
the number of elements in the set.

Referenced by testObject().

template<typename TDigitalTopology, typename TDigitalSet>
std::string DGtal::Object< TDigitalTopology, TDigitalSet >::styleName (  )  const
Returns:
the style name used for drawing this object.

Referenced by testSimplePoints2D().

template<typename TDigitalTopology, typename TDigitalSet>
const DigitalTopology& DGtal::Object< TDigitalTopology, TDigitalSet >::topology (  )  const
Returns:
a const reference to the topology of this object.
template<typename TDigitalTopology, typename TDigitalSet>
template<typename TOutputObjectIterator >
Size DGtal::Object< TDigitalTopology, TDigitalSet >::writeComponents ( TOutputObjectIterator &  it  )  const

Computes the connected components of the object and writes them on the output iterator [it].

Template Parameters:
TOutputObjectIterator the type of an output iterator in a container of Object s.
Parameters:
it the output iterator. *it is an Object.
Returns:
the number of components.

NB: Be careful that the [it] should not be an output iterator pointing in the same container containing 'this'. The following example might make a 'bus error' because the vector might be resized() during insertion.

 vector<ObjectType> objects;
 objects[ 0 ] = ... some object;
 ...
 back_insert_iterator< vector<ObjectType> > it( objects );
 objects[ 0 ].writeComponents( it ); // it points in same container as this.
 // might 'bus error'.

If you wish to use an output iterator (like a std::back_insert_iterator) in the same container containing your object, you can write:

 ObjectType( objects[ 0 ] ).writeComponents( it );

It is nearly as efficient (the clone uses smart copy on write pointers) and works in any case. You might even overwrite your object while doing this.


Field Documentation

template<typename TDigitalTopology, typename TDigitalSet>
Connectedness DGtal::Object< TDigitalTopology, TDigitalSet >::myConnectedness [mutable, private]

Connectedness of this object. Either CONNECTED, DISCONNECTED, or UNKNOWN.

template<typename TDigitalTopology, typename TDigitalSet>
CowPtr<DigitalSet> DGtal::Object< TDigitalTopology, TDigitalSet >::myPointSet [private]

A copy on write pointer on the associated (owned or not) point set

template<typename TDigitalTopology, typename TDigitalSet>
CowPtr<DigitalTopology> DGtal::Object< TDigitalTopology, TDigitalSet >::myTopo [private]

the digital topology of the object.


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