DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Data Structures | Public Types | Public Member Functions | Private Attributes
DGtal::Object< TDigitalTopology, TDigitalSet > Class Template Reference

#include <Object.h>

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

Data Structures

struct  Edge
struct  VertexMap

Public Types

typedef TDigitalSet DigitalSet
typedef TDigitalTopology DigitalTopology
typedef
DigitalTopology::ReverseTopology 
ReverseTopology
typedef DigitalSet::Size Size
typedef DigitalSet::Point Point
typedef DigitalTopology::Point DTPoint
typedef DigitalSet::Domain 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
typedef TDigitalSet VertexSet
typedef DigitalSet::Point Vertex
typedef DigitalSet::ConstIterator ConstIterator

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 OutputObjectIterator >
Size writeComponents (OutputObjectIterator &it) const
Connectedness connectedness () const
Connectedness computeConnectedness () const
ConstIterator begin () const
ConstIterator end () const
Size degree (const Vertex &v) const
Size bestCapacity () const
template<typename OutputIterator >
void writeNeighbors (OutputIterator &it, const Vertex &v) const
template<typename OutputIterator , typename VertexPredicate >
void writeNeighbors (OutputIterator &it, const Vertex &v, const VertexPredicate &pred) 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
std::string className () 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 CDrawableWithBoard2D. It may be displayed with a Board2D, 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.

Model of CUndirectedSimpleLocalGraph and CUndirectedSimpleGraph.

Template Parameters:
TDigitalTopologyany realization of DigitalTopology.
TDigitalSetany model of CDigitalSet.*
See also:
testObject.cpp
testObject-benchmark.cpp
Examples:
topology/3dBorderExtraction.cpp, and topology/3dBorderExtractionImg.cpp.

Definition at line 88 of file Object.h.


Member Typedef Documentation

template<typename TDigitalTopology, typename TDigitalSet>
typedef DigitalTopology::BackgroundAdjacency DGtal::Object< TDigitalTopology, TDigitalSet >::BackgroundAdjacency

Definition at line 106 of file Object.h.

template<typename TDigitalTopology, typename TDigitalSet>
typedef Object<ReverseTopology, DigitalSet> DGtal::Object< TDigitalTopology, TDigitalSet >::ComplementObject

Definition at line 107 of file Object.h.

template<typename TDigitalTopology, typename TDigitalSet>
typedef DigitalSet::ConstIterator DGtal::Object< TDigitalTopology, TDigitalSet >::ConstIterator

Definition at line 117 of file Object.h.

template<typename TDigitalTopology, typename TDigitalSet>
typedef TDigitalSet DGtal::Object< TDigitalTopology, TDigitalSet >::DigitalSet

Definition at line 92 of file Object.h.

template<typename TDigitalTopology, typename TDigitalSet>
typedef TDigitalTopology DGtal::Object< TDigitalTopology, TDigitalSet >::DigitalTopology

Definition at line 93 of file Object.h.

template<typename TDigitalTopology, typename TDigitalSet>
typedef DigitalSet::Domain DGtal::Object< TDigitalTopology, TDigitalSet >::Domain

Definition at line 100 of file Object.h.

template<typename TDigitalTopology, typename TDigitalSet>
typedef DigitalTopology::Point DGtal::Object< TDigitalTopology, TDigitalSet >::DTPoint

Definition at line 98 of file Object.h.

template<typename TDigitalTopology, typename TDigitalSet>
typedef DigitalTopology::ForegroundAdjacency DGtal::Object< TDigitalTopology, TDigitalSet >::ForegroundAdjacency

Definition at line 105 of file Object.h.

template<typename TDigitalTopology, typename TDigitalSet>
typedef DigitalSet::Point DGtal::Object< TDigitalTopology, TDigitalSet >::Point

Definition at line 96 of file Object.h.

template<typename TDigitalTopology, typename TDigitalSet>
typedef DigitalTopology::ReverseTopology DGtal::Object< TDigitalTopology, TDigitalSet >::ReverseTopology

Definition at line 94 of file Object.h.

template<typename TDigitalTopology, typename TDigitalSet>
typedef DigitalSet::Size DGtal::Object< TDigitalTopology, TDigitalSet >::Size

Definition at line 95 of file Object.h.

template<typename TDigitalTopology, typename TDigitalSet>
typedef Object<ReverseTopology, SmallSet> DGtal::Object< TDigitalTopology, TDigitalSet >::SmallComplementObject

Definition at line 109 of file Object.h.

template<typename TDigitalTopology, typename TDigitalSet>
typedef Object<DigitalTopology, SmallSet> DGtal::Object< TDigitalTopology, TDigitalSet >::SmallObject

Definition at line 108 of file Object.h.

template<typename TDigitalTopology, typename TDigitalSet>
typedef DigitalSetSelector< Domain, SMALL_DS + HIGH_ITER_DS >::Type DGtal::Object< TDigitalTopology, TDigitalSet >::SmallSet

Definition at line 104 of file Object.h.

template<typename TDigitalTopology, typename TDigitalSet>
typedef Domain::Space DGtal::Object< TDigitalTopology, TDigitalSet >::Space

Definition at line 101 of file Object.h.

template<typename TDigitalTopology, typename TDigitalSet>
typedef DigitalSet::Point DGtal::Object< TDigitalTopology, TDigitalSet >::Vertex

Definition at line 113 of file Object.h.

template<typename TDigitalTopology, typename TDigitalSet>
typedef TDigitalSet DGtal::Object< TDigitalTopology, TDigitalSet >::VertexSet

Definition at line 112 of file Object.h.


Constructor & Destructor Documentation

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

Constructor. The object is not valid.

Constructor.

Parameters:
aTopologythe digital topology chosen for this set, a copy of which is stored in the object.
aPointSetthe set of points of the object. It is copied in the object.

Definition at line 57 of file Object.ih.

References DGtal::UNKNOWN.

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

Constructor.

Parameters:
aTopologythe digital topology chosen for this set, a copy of which is stored in the object.
aPointSetthe set of points of the object. It is copied in the object.
cxnthe connectedness (default is UNKNOWN).

Constructor.

Parameters:
aTopologythe digital topology chosen for this set, a copy of which is stored in the object.
aPointSetthe set of points of the object. It is copied in the object.

Definition at line 74 of file Object.ih.

: myTopo( new DigitalTopology( aTopology ) ),
myPointSet( new DigitalSet( aPointSet ) ),
{
}
template<typename TDigitalTopology , typename TDigitalSet >
DGtal::Object< TDigitalTopology, TDigitalSet >::Object ( const CowPtr< DigitalTopology > &  aTopology,
const DigitalSet aPointSet,
Connectedness  cxn = UNKNOWN 
)
inline

Constructor.

Parameters:
aTopologythe digital topology chosen for this set, smartly copied.
aPointSetthe set of points of the object. It is copied in the object.
cxnthe connectedness (default is UNKNOWN).

Constructor.

Parameters:
aTopologythe digital topology chosen for this set, smartly copied.
aPointSetthe set of points of the object. It is copied in the object.

Definition at line 95 of file Object.ih.

: myTopo( aTopology ),
myPointSet( new DigitalSet( aPointSet ) ),
{
}
template<typename TDigitalTopology , typename TDigitalSet >
DGtal::Object< TDigitalTopology, TDigitalSet >::Object ( const DigitalTopology aTopology,
const CowPtr< DigitalSet > &  aPointSet,
Connectedness  cxn = UNKNOWN 
)
inline

Constructor.

Parameters:
aTopologythe digital topology chosen for this set, a copy of which is stored in the object.
aPointSetthe set of points of the object. It is smartly reference in the object.
cxnthe connectedness (default is UNKNOWN).

Constructor.

Parameters:
aTopologythe digital topology chosen for this set, a copy of which is stored in the object.
aPointSetthe set of points of the object. It is smartly reference in the object.

Definition at line 116 of file Object.ih.

: myTopo( new DigitalTopology( aTopology ) ),
myPointSet( aPointSet ),
{
}
template<typename TDigitalTopology , typename TDigitalSet >
DGtal::Object< TDigitalTopology, TDigitalSet >::Object ( const DigitalTopology aTopology,
DigitalSet aPointSetPtr,
Connectedness  cxn = UNKNOWN 
)
inline

Constructor by attachment of a dynamically allocated point set.

Parameters:
aTopologythe digital topology chosen for this set, a copy of which is stored in the object.
aPointSetPtra dynamically allocated pointer on a set of points which is afterwards handled by this (which will take care of its deletion).
cxnthe connectedness (default is UNKNOWN).

Constructor by attachment of a dynamically allocated point set.

Parameters:
aTopologythe digital topology chosen for this set, a copy of which is stored in the object.
aPointSetPtra dynamically allocated pointer on a set of points which is afterwards handled by this (which will take care of its deletion).

Definition at line 138 of file Object.ih.

: myTopo( new DigitalTopology( aTopology ) ),
{
}
template<typename TDigitalTopology , typename TDigitalSet >
DGtal::Object< TDigitalTopology, TDigitalSet >::Object ( const DigitalTopology aTopology,
const Domain aDomain 
)
inline

Constructor of an empty object by providing a domain.

Parameters:
aTopologythe digital topology chosen for this set, a copy of which is stored in the object.
aDomainany domain related to the given topology.

Definition at line 175 of file Object.ih.

: myTopo( new DigitalTopology( aTopology ) ),
myPointSet( new DigitalSet( aDomain ) ),
{
}
template<typename TDigitalTopology , typename TDigitalSet >
DGtal::Object< TDigitalTopology, TDigitalSet >::Object ( const CowPtr< DigitalTopology > &  aTopology,
const Domain aDomain 
)
inline

Constructor of an empty object by providing a domain.

Parameters:
aTopologythe digital topology chosen for this set, smartly copied.
aDomainany domain related to the given topology.

Definition at line 193 of file Object.ih.

: myTopo( aTopology ),
myPointSet( new DigitalSet( aDomain ) ),
{
}
template<typename TDigitalTopology , typename TDigitalSet >
DGtal::Object< TDigitalTopology, TDigitalSet >::Object ( const Object< TDigitalTopology, TDigitalSet > &  other)
inline

Copy constructor.

Parameters:
otherthe 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.

Definition at line 157 of file Object.ih.

: myTopo( other.myTopo ),
{
}
template<typename TDigitalTopology , typename TDigitalSet >
DGtal::Object< TDigitalTopology, TDigitalSet >::~Object ( )
inline

Destructor.

Definition at line 206 of file Object.ih.

{
}

Member Function Documentation

template<typename TDigitalTopology , typename TDigitalSet >
const TDigitalTopology::ForegroundAdjacency & DGtal::Object< TDigitalTopology, TDigitalSet >::adjacency ( ) const
inline
Returns:
a const reference to the adjacency of this object.

Definition at line 295 of file Object.ih.

{
return myTopo->kappa();
}
template<typename TDigitalTopology , typename TDigitalSet >
DGtal::Object< TDigitalTopology, TDigitalSet >::ConstIterator DGtal::Object< TDigitalTopology, TDigitalSet >::begin ( ) const
inline
template<typename TDigitalTopology , typename TDigitalSet >
DGtal::Object< TDigitalTopology, TDigitalSet >::Size DGtal::Object< TDigitalTopology, TDigitalSet >::bestCapacity ( ) const
inline
Returns:
the maximum number of neighbors for a vertex of this object

Definition at line 683 of file Object.ih.

References DGtal::Object< TDigitalTopology, TDigitalSet >::bestCapacity().

Referenced by DGtal::Object< TDigitalTopology, TDigitalSet >::bestCapacity().

{
return myTopo->kappa().bestCapacity();
}
template<typename TDigitalTopology , typename TDigitalSet >
DGtal::Object< TDigitalTopology, TDigitalSet > DGtal::Object< TDigitalTopology, TDigitalSet >::border ( ) const
inline
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.

Returns:
the border of this object (the set of points of this which is lambda()-adjacent with some point of the background).
Examples:
topology/3dBorderExtractionImg.cpp.

Definition at line 467 of file Object.ih.

References DGtal::Object< TDigitalTopology, TDigitalSet >::pointSet().

{
typedef std::vector<Vertex> Container;
typedef typename Container::const_iterator ContainerConstIterator;
typedef typename DigitalSet::ConstIterator DigitalSetConstIterator;
typedef typename DigitalSet::ConstIterator DigitalSetConstIterator;
//typedef typename Domain::Predicate Predicate;
// Intermediate container that is fast writable.
const DigitalSet & mySet = pointSet();
domain() );
DigitalSet & outputSet = output.pointSet();
// Loop on all points of the set.
Container tmp_local_points;
const DigitalSetConstIterator it_end = mySet.end();
for ( DigitalSetConstIterator it = mySet.begin();
it != it_end;
++it )
{
std::back_insert_iterator< Container > back_ins_it( tmp_local_points );
// Computing neighborhood within domain.
topology().lambda().writeNeighbors
( back_ins_it, *it, domain().predicate() );
// Checks if any point is not in the object.
const ContainerConstIterator itc_end( tmp_local_points.end() );
for ( ContainerConstIterator itc = tmp_local_points.begin();
itc != itc_end;
++itc )
if ( pointSet().find( *itc ) == it_end )
{
outputSet.insertNew( *it );
break;
}
tmp_local_points.clear();
}
return output;
}
template<typename TDigitalTopology , typename TDigitalSet >
std::string DGtal::Object< TDigitalTopology, TDigitalSet >::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 992 of file Object.ih.

Referenced by DGtal::Display3DFactory::draw(), and DGtal::Display2DFactory::draw().

{
return "Object";
}
template<typename TDigitalTopology , typename TDigitalSet >
DGtal::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

Definition at line 612 of file Object.ih.

References DGtal::CONNECTED, DGtal::DISCONNECTED, DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::expand(), DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::finished(), DGtal::UNKNOWN, and DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::visitedVertices().

Referenced by DGtal::Object< TDigitalTopology, TDigitalSet >::isSimple().

{
{
if ( pointSet().empty() )
else
{
// Take first point
Vertex p = *( pointSet().begin() );
while ( ! visitor.finished() )
{
visitor.expand();
}
myConnectedness = ( visitor.visitedVertices().size() == pointSet().size() )
// JOL: 2012/11/16 There is apparently now a bug in expander !
// Very weird considering this was working in 2012/05. Perhaps
// this is related to some manipulations in predicates.
//
// Expander<Object> expander( *this, p );
// // and expand.
// while ( expander.nextLayer() )
// ;
// myConnectedness = ( expander.core().size() == pointSet().size() )
// ? CONNECTED : DISCONNECTED;
}
}
}
template<typename TDigitalTopology , typename TDigitalSet >
DGtal::Connectedness DGtal::Object< TDigitalTopology, TDigitalSet >::connectedness ( ) const
Returns:
the connectedness of this object. Either CONNECTED, DISCONNECTED, or UNKNOWN.
See also:
computeConnectedness

Definition at line 595 of file Object.ih.

{
}
template<typename TDigitalTopology , typename TDigitalSet >
DGtal::Object< TDigitalTopology, TDigitalSet >::Size DGtal::Object< TDigitalTopology, TDigitalSet >::degree ( const Vertex v) const
inline
Parameters:
vany vertex of the object
Returns:
the number of neighbors of this vertex

Definition at line 672 of file Object.ih.

{
return neighborhoodSize( v );
}
template<typename TDigitalTopology , typename TDigitalSet >
const DGtal::Object< TDigitalTopology, TDigitalSet >::Domain & DGtal::Object< TDigitalTopology, TDigitalSet >::domain ( ) const
inline

A const reference to the embedding domain.

Definition at line 247 of file Object.ih.

References DGtal::Object< TDigitalTopology, TDigitalSet >::domain().

Referenced by DGtal::Object< TDigitalTopology, TDigitalSet >::domain().

{
return myPointSet->domain();
}
template<typename TDigitalTopology , typename TDigitalSet >
DGtal::Object< TDigitalTopology, TDigitalSet >::ConstIterator DGtal::Object< TDigitalTopology, TDigitalSet >::end ( ) const
inline
template<typename TDigitalTopology , typename TDigitalSet >
template<typename TAdjacency >
DGtal::Object< TDigitalTopology, TDigitalSet >::SmallObject DGtal::Object< TDigitalTopology, TDigitalSet >::geodesicNeighborhood ( const TAdjacency &  adj,
const Point p,
unsigned int  k 
) const
inline

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

Definition at line 782 of file Object.ih.

References DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::expand(), DGtal::Object< TDigitalTopology, TDigitalSet >::pointSet(), and DGtal::DigitalSetDomain< TDigitalSet >::predicate().

{
// Local types.
typedef std::vector<Vertex> Container;
typedef MetricAdjacency<Space, 1> OmegaAdjacency;
typedef typename Container::const_iterator ContainerConstIterator;
typedef typename DigitalSet::ConstIterator DigitalSetConstIterator;
typedef Object<LocalTopology, SmallSet> LocalObject;
typedef HyperRectDomain<Space> LocalDomain;
AlphaAdjacency alpha;
OmegaAdjacency omega;
// Intermediate container that is fast writable.
Container tmp_local_points;
std::back_insert_iterator< Container > back_ins_it( tmp_local_points );
alpha.writeNeighbors( back_ins_it, p, limitedX.predicate() );
// Construct local domain.
Point p1( p );
for ( typename Point::Iterator it = p1.begin(); it != p1.end(); ++it )
--(*it);
Point p2( p );
for ( typename Point::Iterator it = p2.begin(); it != p2.end(); ++it )
++(*it);
LocalDomain aDomain( p1, p2 );
// Construct local X.
LocalTopology aTopology( adj, omega );
LocalObject X( aTopology, aDomain );
X.pointSet().insertNew( tmp_local_points.begin(), tmp_local_points.end() );
// A neighborhood is small, so is defined the digital object.
typename LocalObject::SmallObject neighAdj = X.properNeighborhood( p );
( X, neighAdj.pointSet().begin(),
neighAdj.pointSet().end() );
while ( ! visitor.finished() )
visitor.expand();
SmallObject geodesicN( this->topology(), aDomain );
geodesicN.pointSet().insertNew( visitor.markedVertices().begin(),
visitor.markedVertices().end() );
// JOL: 2012/11/16 There is apparently now a bug in expander !
// Very weird considering this was working in 2012/05. Perhaps
// this is related to some manipulations in predicates.
// Expander<LocalObject> expander( X,
// neighAdj.pointSet().begin(),
// neighAdj.pointSet().end() );
// for ( unsigned int i = 1; ( i < k ) && ( ! expander.finished() ); ++i )
// expander.nextLayer();
// SmallObject geodesicN( this->topology(), expander.core() );
return geodesicN;
}
template<typename TDigitalTopology , typename TDigitalSet >
template<typename TAdjacency >
DGtal::Object< TDigitalTopology, TDigitalSet >::SmallComplementObject DGtal::Object< TDigitalTopology, TDigitalSet >::geodesicNeighborhoodInComplement ( const TAdjacency &  adj,
const Point p,
unsigned int  k 
) const
inline

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

Definition at line 851 of file Object.ih.

References DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::expand(), DGtal::Object< TDigitalTopology, TDigitalSet >::pointSet(), and DGtal::DigitalSetDomain< TDigitalSet >::predicate().

{
// Local types.
typedef std::vector<Vertex> Container;
typedef MetricAdjacency<Space, 1> OmegaAdjacency;
typedef typename Container::const_iterator ContainerConstIterator;
typedef typename DigitalSet::ConstIterator DigitalSetConstIterator;
typedef Object<LocalTopology, SmallSet> LocalObject;
typedef HyperRectDomain<Space> LocalDomain;
typedef typename DigitalSetDomain<DigitalSet>::Predicate PredicateIsInX;
AlphaAdjacency alpha;
OmegaAdjacency omega;
// Intermediate container that is fast writable.
Container tmp_local_points;
std::back_insert_iterator< Container > back_ins_it( tmp_local_points );
NotPointPredicate<PredicateIsInX> not_pred_is_in_X( limitedX.predicate() );
alpha.writeNeighbors( back_ins_it, p, not_pred_is_in_X );
// Construct local domain.
Point p1( p );
for ( typename Point::Iterator it = p1.begin(); it != p1.end(); ++it )
--(*it);
Point p2( p );
for ( typename Point::Iterator it = p2.begin(); it != p2.end(); ++it )
++(*it);
LocalDomain aDomain( p1, p2 );
// Construct local Xcomp.
LocalTopology aTopology( adj, omega );
LocalObject Xcomp( aTopology, aDomain );
Xcomp.pointSet().insertNew( tmp_local_points.begin(), tmp_local_points.end() );
// A neighborhood is small, so is defined the digital object.
typename LocalObject::SmallObject neighAdj = Xcomp.properNeighborhood( p );
( Xcomp, neighAdj.pointSet().begin(),
neighAdj.pointSet().end() );
while ( ! visitor.finished() )
visitor.expand();
SmallComplementObject geodesicN( this->topology().reverseTopology(),
aDomain );
geodesicN.pointSet().insertNew( visitor.markedVertices().begin(),
visitor.markedVertices().end() );
// JOL: 2012/11/16 There is apparently now a bug in expander !
// Very weird considering this was working in 2012/05. Perhaps
// this is related to some manipulations in predicates.
// Expander<LocalObject> expander( Xcomp,
// neighAdj.pointSet().begin(),
// neighAdj.pointSet().end() );
// for ( unsigned int i = 1; ( i < k ) && ( ! expander.finished() ); ++i )
// expander.nextLayer();
// SmallComplementObject geodesicN( this->topology().reverseTopology(),
// expander.core() );
return geodesicN;
}
template<typename TDigitalTopology , typename TDigitalSet >
bool DGtal::Object< TDigitalTopology, TDigitalSet >::isSimple ( const Point v) const
inline

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

Definition at line 927 of file Object.ih.

References DGtal::Object< TDigitalTopology, TDigitalSet >::computeConnectedness(), DGtal::CONNECTED, and DGtal::Object< TDigitalTopology, TDigitalSet >::pointSet().

{
SmallObject Gkappa_X
v, Space::dimension );
if ( Gkappa_X.computeConnectedness() == CONNECTED )
{
if ( Gkappa_X.pointSet().empty() )
return false;
SmallComplementObject Glambda_compX
v, Space::dimension );
return ( Glambda_compX.computeConnectedness()
== CONNECTED )
&& ( ! Glambda_compX.pointSet().empty() );
}
return false;
}
template<typename TDigitalTopology , typename TDigitalSet >
bool DGtal::Object< TDigitalTopology, TDigitalSet >::isValid ( ) const
inline

Checks the validity/consistency of the object.

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

Definition at line 975 of file Object.ih.

{
return ( *myPointSet != 0 ) && (*myTopo != 0 );
}
template<typename TDigitalTopology , typename TDigitalSet >
DGtal::Object< TDigitalTopology, TDigitalSet >::SmallObject DGtal::Object< TDigitalTopology, TDigitalSet >::neighborhood ( const Point p) const
inline

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:
pany 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.

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:
pany point (in the domain of the digital object, not necessarily in the object).
Returns:
the kappa-neighborhood of [p] in this object.

Definition at line 317 of file Object.ih.

References DGtal::DigitalSetBySTLSet< TDomain >::insertNew(), and DGtal::Object< TDigitalTopology, TDigitalSet >::pointSet().

{
typedef std::vector<Vertex> Container;
typedef typename Container::const_iterator ContainerConstIterator;
typedef typename DigitalSet::ConstIterator DigitalSetConstIterator;
// Intermediate container that is fast writable.
Container tmp_local_points;
std::back_insert_iterator< Container > back_ins_it( tmp_local_points );
adjacency().writeNeighbors( back_ins_it, p );
tmp_local_points.push_back( p );
// A neighborhood is small, so is defined the digital object.
const ContainerConstIterator it_end( tmp_local_points.end() );
const DigitalSetConstIterator not_found( pointSet().end() );
SmallSet & neighASet = neighA.pointSet();
for ( ContainerConstIterator it = tmp_local_points.begin();
it != it_end;
++it )
if ( pointSet().find( *it ) != not_found )
neighASet.insertNew( *it ); // insertNew is guaranteed by construction.
return neighA;
}
template<typename TDigitalTopology , typename TDigitalSet >
DGtal::Object< TDigitalTopology, TDigitalSet >::Size DGtal::Object< TDigitalTopology, TDigitalSet >::neighborhoodSize ( const Point p) const
inline
Parameters:
pany 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.

Definition at line 356 of file Object.ih.

{
typedef std::vector<Vertex> Container;
typedef typename Container::const_iterator ContainerConstIterator;
typedef typename DigitalSet::ConstIterator DigitalSetConstIterator;
// Intermediate container that is fast writable.
Container tmp_local_points;
std::back_insert_iterator< Container > back_ins_it( tmp_local_points );
adjacency().writeNeighbors( back_ins_it, p );
tmp_local_points.push_back( p );
// A neighborhood is small, so is defined the digital object.
const ContainerConstIterator it_end( tmp_local_points.end() );
const DigitalSetConstIterator not_found( pointSet().end() );
Size nb = 0;
for ( ContainerConstIterator it = tmp_local_points.begin();
it != it_end;
++it )
if ( pointSet().find( *it ) != not_found )
++nb;
return nb;
}
template<typename TDigitalTopology , typename TDigitalSet >
DGtal::Object< TDigitalTopology, TDigitalSet > & DGtal::Object< TDigitalTopology, TDigitalSet >::operator= ( const Object< TDigitalTopology, TDigitalSet > &  other)
inline

Assignment.

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

Definition at line 219 of file Object.ih.

References DGtal::Object< TDigitalTopology, TDigitalSet >::myConnectedness, DGtal::Object< TDigitalTopology, TDigitalSet >::myPointSet, and DGtal::Object< TDigitalTopology, TDigitalSet >::myTopo.

{
if ( this != &other )
{
myTopo = other.myTopo;
}
return *this;
}
template<typename TDigitalTopology , typename TDigitalSet >
const TDigitalSet & DGtal::Object< TDigitalTopology, TDigitalSet >::pointSet ( ) const
inline
template<typename TDigitalTopology , typename TDigitalSet >
TDigitalSet & DGtal::Object< TDigitalTopology, TDigitalSet >::pointSet ( )
inline

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

Definition at line 272 of file Object.ih.

References DGtal::UNKNOWN.

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

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:
pany 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.

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:
pany point (in the domain of the digital object, not necessarily in the object).
Returns:
the kappa-neighborhood of [p] in this object, without p.

Definition at line 395 of file Object.ih.

References DGtal::DigitalSetBySTLSet< TDomain >::insertNew(), and DGtal::Object< TDigitalTopology, TDigitalSet >::pointSet().

Referenced by DGtal::Display3DFactory::drawWithAdjacencies(), and DGtal::Display2DFactory::drawWithAdjacencies().

{
typedef std::vector<Vertex> Container;
typedef typename Container::const_iterator ContainerConstIterator;
typedef typename DigitalSet::ConstIterator DigitalSetConstIterator;
// Intermediate container that is fast writable.
Container tmp_local_points;
std::back_insert_iterator< Container > back_ins_it( tmp_local_points );
adjacency().writeNeighbors( back_ins_it, p );
// A neighborhood is small, so is defined the digital object.
const ContainerConstIterator it_end( tmp_local_points.end() );
const DigitalSetConstIterator not_found( pointSet().end() );
SmallSet & neighASet = neighA.pointSet();
for ( ContainerConstIterator it = tmp_local_points.begin();
it != it_end;
++it )
if ( pointSet().find( *it ) != not_found )
neighASet.insertNew( *it ); // insertNew is guaranteed by construction.
return neighA;
}
template<typename TDigitalTopology , typename TDigitalSet >
DGtal::Object< TDigitalTopology, TDigitalSet >::Size DGtal::Object< TDigitalTopology, TDigitalSet >::properNeighborhoodSize ( const Point p) const
inline
Parameters:
pany 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.

Definition at line 434 of file Object.ih.

{
typedef std::vector<Vertex> Container;
typedef typename Container::const_iterator ContainerConstIterator;
typedef typename DigitalSet::ConstIterator DigitalSetConstIterator;
// Intermediate container that is fast writable.
Container tmp_local_points;
std::back_insert_iterator< Container > back_ins_it( tmp_local_points );
adjacency().writeNeighbors( back_ins_it, p );
// A neighborhood is small, so is defined the digital object.
const ContainerConstIterator it_end( tmp_local_points.end() );
const DigitalSetConstIterator not_found( pointSet().end() );
Size nb = 0;
for ( ContainerConstIterator it = tmp_local_points.begin();
it != it_end;
++it )
if ( pointSet().find( *it ) != not_found )
++nb;
return nb;
}
template<typename TDigitalTopology , typename TDigitalSet >
void DGtal::Object< TDigitalTopology, TDigitalSet >::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 958 of file Object.ih.

{
out << "[Object"
<< " topology=" << myTopo
<< " counts=" << myPointSet.count()
<< " set=" << *myPointSet
<< " cxn=" << myConnectedness
<< "]";
}
template<typename TDigitalTopology , typename TDigitalSet >
DGtal::Object< TDigitalTopology, TDigitalSet >::Size DGtal::Object< TDigitalTopology, TDigitalSet >::size ( ) const
inline
Returns:
the number of elements in the set.

Definition at line 236 of file Object.ih.

References DGtal::Object< TDigitalTopology, TDigitalSet >::size().

Referenced by DGtal::Object< TDigitalTopology, TDigitalSet >::size().

{
return myPointSet->size();
}
template<typename TDigitalTopology , typename TDigitalSet >
const TDigitalTopology & DGtal::Object< TDigitalTopology, TDigitalSet >::topology ( ) const
inline
Returns:
a const reference to the topology of this object.

Definition at line 284 of file Object.ih.

{
return *myTopo;
}
template<typename TDigitalTopology , typename TDigitalSet >
template<typename OutputObjectIterator >
DGtal::Object< TDigitalTopology, TDigitalSet >::Size DGtal::Object< TDigitalTopology, TDigitalSet >::writeComponents ( OutputObjectIterator &  it) const
inline
  Computes the connected components of the object and writes
  them on the output iterator [it].

  @tparam OutputObjectIterator the type of an output iterator in
  a container of Object s.

  @param it the output iterator. *it is an Object.
  @return 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.

  @code 

typedef ... MyObject; vector<MyObject> objects; objects[ 0 ] = ... some object; ... back_insert_iterator< vector<MyObject> > 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:

MyObject( 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.

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

Template Parameters:
OutputObjectIteratorthe type of an output iterator in a container of Object s.
Parameters:
itthe output iterator. *it is an Object.

Definition at line 521 of file Object.ih.

References DGtal::CONNECTED, DGtal::DISCONNECTED, DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::expand(), DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::finished(), and DGtal::BreadthFirstVisitor< TGraph, TMarkSet >::markedVertices().

{
Size nb_components = 0;
if ( pointSet().empty() )
{
return nb_components;
}
else
{
*it++ = *this;
return 1;
}
typedef typename DigitalSet::ConstIterator DigitalSetConstIterator;
DigitalSetConstIterator it_object = pointSet().begin();
Point p( *it_object++ );
// first component.
while ( ! visitor.finished() ) visitor.expand();
DigitalSet visited( domain() );
visited.insertNew( visitor.markedVertices().begin(),
visitor.markedVertices().end() );
*it++ = Object( myTopo, visited, CONNECTED );
++nb_components;
while ( it_object != pointSet().end() )
{
p = *it_object++;
if ( visited.find( p ) == visited.end() )
{
while ( ! visitor2.finished() ) visitor2.expand();
DigitalSet visited2( domain() );
visited2.insertNew( visitor2.markedVertices().begin(),
visitor2.markedVertices().end() );
*it++ = Object( myTopo, visited2, CONNECTED );
++nb_components;
visited += visited2;
}
}
// Expander<Object> expander( *this, p );
// while ( expander.nextLayer() )
// ;
// Object component( myTopo, expander.core(), CONNECTED );
// *it++ = component;
// ++nb_components;
// DigitalSet visited( expander.core() );
// while ( it_object != pointSet().end() )
// {
// p = *it_object++;
// if ( visited.find( p ) == visited.end() )
// {
// Expander<Object> expander2( *this, p );
// while ( expander2.nextLayer() )
// ;
// Object component2( myTopo, expander2.core(), CONNECTED );
// *it++ = component2;
// ++nb_components;
// visited += expander2.core();
// }
// }
myConnectedness = nb_components == 1 ? CONNECTED : DISCONNECTED;
return nb_components;
}
template<typename TDigitalTopology , typename TDigitalSet >
template<typename OutputIterator >
void DGtal::Object< TDigitalTopology, TDigitalSet >::writeNeighbors ( OutputIterator &  it,
const Vertex v 
) const
inline

Writes the neighbors of a vertex using an output iterator

Template Parameters:
OutputObjectIteratorthe type of an output iterator writing in a container of vertices.
Parameters:
itthe output iterator
vthe vertex whose neighbors will be writeNeighbors

Definition at line 704 of file Object.ih.

{
typedef std::vector<Vertex> Container;
typedef typename Container::const_iterator ContainerConstIterator;
typedef typename DigitalSet::ConstIterator DigitalSetConstIterator;
// Intermediate container that is fast writable.
Container tmp_local_points;
std::back_insert_iterator< Container > back_ins_it( tmp_local_points );
adjacency().writeNeighbors( back_ins_it, v );
// A neighborhood is small, so is defined the digital object.
const ContainerConstIterator it_end( tmp_local_points.end() );
const DigitalSetConstIterator not_found( pointSet().end() );
for ( ContainerConstIterator cit = tmp_local_points.begin();
cit != it_end;
++cit )
if ( pointSet().find( *cit ) != not_found )
*it++ = *cit;
}
template<typename TDigitalTopology , typename TDigitalSet >
template<typename OutputIterator , typename VertexPredicate >
void DGtal::Object< TDigitalTopology, TDigitalSet >::writeNeighbors ( OutputIterator &  it,
const Vertex v,
const VertexPredicate &  pred 
) const
inline

Writes the neighbors of a vertex which satisfy a predicate using an output iterator

Template Parameters:
OutputObjectIteratorthe type of an output iterator writing in a container of vertices.
VertexPredicatethe type of the predicate
Parameters:
itthe output iterator
vthe vertex whose neighbors will be written
predthe predicate that must be satisfied

Definition at line 747 of file Object.ih.

{
typedef std::vector<Vertex> Container;
typedef typename Container::const_iterator ContainerConstIterator;
typedef typename DigitalSet::ConstIterator DigitalSetConstIterator;
// Intermediate container that is fast writable.
Container tmp_local_points;
std::back_insert_iterator< Container > back_ins_it( tmp_local_points );
adjacency().writeNeighbors( back_ins_it, v );
// A neighborhood is small, so is defined the digital object.
const ContainerConstIterator it_end( tmp_local_points.end() );
const DigitalSetConstIterator not_found( pointSet().end() );
for ( ContainerConstIterator cit = tmp_local_points.begin();
cit != it_end;
++cit )
if ( ( pointSet().find( *cit ) != not_found ) && pred(*cit) )
*it++ = *cit;
}

Field Documentation

template<typename TDigitalTopology, typename TDigitalSet>
Connectedness DGtal::Object< TDigitalTopology, TDigitalSet >::myConnectedness
mutableprivate

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

Definition at line 562 of file Object.h.

Referenced by DGtal::Object< TDigitalTopology, TDigitalSet >::operator=().

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

Definition at line 557 of file Object.h.

Referenced by DGtal::Object< TDigitalTopology, TDigitalSet >::operator=().

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

the digital topology of the object.

Definition at line 552 of file Object.h.

Referenced by DGtal::Object< TDigitalTopology, TDigitalSet >::operator=().


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