DGtal  0.9.4beta
Namespaces | Functions
DGtal::functions Namespace Reference

Namespaces

 Hull2D
 
 setops
 

Functions

template<typename Container , bool ordered>
bool isEqual (const Container &S1, const Container &S2)
 
template<typename Container >
bool isEqual (const Container &S1, const Container &S2)
 
template<typename Container , bool ordered>
bool isSubset (const Container &S1, const Container &S2)
 
template<typename Container >
bool isSubset (const Container &S1, const Container &S2)
 
template<typename Container , bool ordered>
Container & assignDifference (Container &S1, const Container &S2)
 
template<typename Container >
Container & assignDifference (Container &S1, const Container &S2)
 
template<typename Container , bool ordered>
Container makeDifference (const Container &S1, const Container &S2)
 
template<typename Container >
Container makeDifference (const Container &S1, const Container &S2)
 
template<typename Container , bool ordered>
Container & assignUnion (Container &S1, const Container &S2)
 
template<typename Container >
Container & assignUnion (Container &S1, const Container &S2)
 
template<typename Container , bool ordered>
Container makeUnion (const Container &S1, const Container &S2)
 
template<typename Container >
Container makeUnion (const Container &S1, const Container &S2)
 
template<typename Container , bool ordered>
Container & assignIntersection (Container &S1, const Container &S2)
 
template<typename Container >
Container & assignIntersection (Container &S1, const Container &S2)
 
template<typename Container , bool ordered>
Container makeIntersection (const Container &S1, const Container &S2)
 
template<typename Container >
Container makeIntersection (const Container &S1, const Container &S2)
 
template<typename Container , bool ordered>
Container & assignSymmetricDifference (Container &S1, const Container &S2)
 
template<typename Container >
Container & assignSymmetricDifference (Container &S1, const Container &S2)
 
template<typename Container , bool ordered>
Container makeSymmetricDifference (const Container &S1, const Container &S2)
 
template<typename Container >
Container makeSymmetricDifference (const Container &S1, const Container &S2)
 
template<typename TCoordinate , typename TInteger , unsigned short adjacency>
bool checkOnePoint (const ArithmeticalDSS< TCoordinate, TInteger, adjacency > &aDSS)
 
template<typename TCoordinate , typename TInteger , unsigned short adjacency>
bool checkPointsPosition (const ArithmeticalDSS< TCoordinate, TInteger, adjacency > &aDSS)
 
template<typename TCoordinate , typename TInteger , unsigned short adjacency>
bool checkPointsRemainder (const ArithmeticalDSS< TCoordinate, TInteger, adjacency > &aDSS)
 
template<typename TCoordinate , typename TInteger , unsigned short adjacency>
bool checkAll (const ArithmeticalDSS< TCoordinate, TInteger, adjacency > &aDSS)
 
template<typename Position , typename Coordinate , typename PointVector , typename OutputIterator , typename PositionFunctor , typename TruncationFunctor1 , typename TruncationFunctor2 >
bool smartCHNextVertex (const Position &positionBound, const Coordinate &remainderBound, PointVector &X, Coordinate &rX, const PointVector &Y, const Coordinate &rY, PointVector &V, Coordinate &rV, OutputIterator ito, const PositionFunctor &pos, const TruncationFunctor1 &f1, const TruncationFunctor2 &f2)
 
template<typename PointVector , typename Coordinate , typename Position , typename PositionFunctor , typename OutputIterator >
PointVector smartCH (const PointVector &aFirstPoint, const Coordinate &aRemainderBound, const Position &aPositionBound, const PointVector &aStep, const Coordinate &aRStep, const PointVector &aShift, const Coordinate &aRShift, const PositionFunctor &aPositionFunctor, OutputIterator uIto, OutputIterator lIto)
 
template<typename DSL , typename OutputIterator >
DSL::Vector smartCH (const DSL &aDSL, const typename DSL::Point &aFirstPoint, const typename DSL::Position &aLength, OutputIterator uIto, OutputIterator lIto)
 
template<typename PointVector , typename Position , typename OutputIterator , typename TruncationFunctor1 , typename TruncationFunctor2 , typename PositionFunctor >
bool smartCHPreviousVertex (PointVector &X, const PointVector &Y, PointVector &V, const Position &aFirstPosition, const Position &aLastPosition, OutputIterator ito, const PositionFunctor &pos, const TruncationFunctor1 &f1, const TruncationFunctor2 &f2)
 
template<typename PointVector , typename Position , typename PositionFunctor , typename OutputIterator >
PointVector reversedSmartCH (PointVector U, PointVector L, PointVector V, const Position &aFirstPosition, const Position &aLastPosition, const PositionFunctor &aPositionFunctor, OutputIterator uIto, OutputIterator lIto)
 
template<typename DSS , typename OutputIterator >
DSS::Vector reversedSmartCH (const DSS &aDSS, const typename DSS::Position &aPositionBound, OutputIterator uIto, OutputIterator lIto)
 
template<typename T >
power (const T &aVal, const unsigned int exponent)
 
template<typename T >
roundToUpperPowerOfTwo (const T &n)
 
template<typename T >
abs (const T &a)
 
template<typename T >
square (T x)
 
template<typename T >
cube (T x)
 
template<typename TKSpace , typename TCellContainer >
CubicalComplex< TKSpace, TCellContainer > & operator|= (CubicalComplex< TKSpace, TCellContainer > &, const CubicalComplex< TKSpace, TCellContainer > &)
 
template<typename TKSpace , typename TCellContainer >
CubicalComplex< TKSpace, TCellContainer > & operator&= (CubicalComplex< TKSpace, TCellContainer > &, const CubicalComplex< TKSpace, TCellContainer > &)
 
template<typename TKSpace , typename TCellContainer >
CubicalComplex< TKSpace, TCellContainer > & operator^= (CubicalComplex< TKSpace, TCellContainer > &, const CubicalComplex< TKSpace, TCellContainer > &)
 
template<typename TKSpace , typename TCellContainer >
CubicalComplex< TKSpace, TCellContainer > & operator-= (CubicalComplex< TKSpace, TCellContainer > &, const CubicalComplex< TKSpace, TCellContainer > &)
 
template<typename TKSpace , typename TCellContainer >
CubicalComplex< TKSpace, TCellContainer > operator| (const CubicalComplex< TKSpace, TCellContainer > &, const CubicalComplex< TKSpace, TCellContainer > &)
 
template<typename TKSpace , typename TCellContainer >
CubicalComplex< TKSpace, TCellContainer > operator& (const CubicalComplex< TKSpace, TCellContainer > &, const CubicalComplex< TKSpace, TCellContainer > &)
 
template<typename TKSpace , typename TCellContainer >
CubicalComplex< TKSpace, TCellContainer > operator^ (const CubicalComplex< TKSpace, TCellContainer > &, const CubicalComplex< TKSpace, TCellContainer > &)
 
template<typename TKSpace , typename TCellContainer >
CubicalComplex< TKSpace, TCellContainer > operator- (const CubicalComplex< TKSpace, TCellContainer > &, const CubicalComplex< TKSpace, TCellContainer > &)
 
template<typename TKSpace , typename TCellContainer >
CubicalComplex< TKSpace, TCellContainer > operator~ (const CubicalComplex< TKSpace, TCellContainer > &)
 
template<typename TKSpace , typename TCellContainer >
CubicalComplex< TKSpace, TCellContainer > operator* (const CubicalComplex< TKSpace, TCellContainer > &)
 
template<typename TKSpace , typename TCellContainer >
bool operator== (const CubicalComplex< TKSpace, TCellContainer > &, const CubicalComplex< TKSpace, TCellContainer > &)
 
template<typename TKSpace , typename TCellContainer >
bool operator!= (const CubicalComplex< TKSpace, TCellContainer > &, const CubicalComplex< TKSpace, TCellContainer > &)
 
template<typename TKSpace , typename TCellContainer >
bool operator<= (const CubicalComplex< TKSpace, TCellContainer > &, const CubicalComplex< TKSpace, TCellContainer > &)
 
template<typename TKSpace , typename TCellContainer >
bool operator>= (const CubicalComplex< TKSpace, TCellContainer > &, const CubicalComplex< TKSpace, TCellContainer > &)
 
template<typename TKSpace , typename TCellContainer , typename CellConstIterator , typename CellMapIteratorPriority >
uint64_t collapse (CubicalComplex< TKSpace, TCellContainer > &K, CellConstIterator S_itB, CellConstIterator S_itE, const CellMapIteratorPriority &priority, bool hintIsSClosed=false, bool hintIsKClosed=false, bool verbose=false)
 
template<typename TKSpace , typename TCellContainer , typename BdryCellOutputIterator , typename InnerCellOutputIterator >
void filterCellsWithinBounds (const CubicalComplex< TKSpace, TCellContainer > &K, const typename TKSpace::Point &kLow, const typename TKSpace::Point &kUp, BdryCellOutputIterator itBdry, InnerCellOutputIterator itInner)
 
template<typename TComplex >
NeighborhoodConfiguration getSpelNeighborhoodConfigurationOccupancy (const TComplex &input_complex, const typename TComplex::Point &center, const std::unordered_map< typename TComplex::Point, NeighborhoodConfiguration > &mapPointToMask)
 
DGtal::CountedPtr< boost::dynamic_bitset<> > loadTable (const std::string &input_filename, const unsigned int known_size, const bool compressed=true)
 
template<unsigned int dimension = 3>
DGtal::CountedPtr< boost::dynamic_bitset<> > loadTable (const std::string &input_filename, const bool compressed=true)
 
template<typename TPoint >
DGtal::CountedPtr< std::unordered_map< TPoint, NeighborhoodConfiguration > > mapZeroPointNeighborhoodToConfigurationMask ()
 
template<typename TObject , typename TMap >
void generateSimplicityTable (const typename TObject::DigitalTopology &dt, TMap &map)
 

Detailed Description

functions namespace gathers all DGtal functionsxs.

Function Documentation

template<typename T >
T DGtal::functions::abs ( const T &  a)

Return the absolute value of an instance of type T.

Template Parameters
Tthe type of elements to compare (model of boost::LessThanComparable).
Parameters
afirst value
Returns
the absolute value |a|.

Definition at line 116 of file BasicMathFunctions.h.

117  {
118  BOOST_CONCEPT_ASSERT((boost::LessThanComparable<T>));
119  if (a<0)
120  return -a;
121  else
122  return a;
123  }
Go to http://www.sgi.com/tech/stl/LessThanComparable.html.
Definition: Boost.dox:48
template<typename Container , bool ordered>
Container& DGtal::functions::assignDifference ( Container &  S1,
const Container &  S2 
)

Set difference operation. Updates the set S1 as S1 - S2.

Parameters
[in,out]S1an input set, S1 - S2 as output.
[in]S2another input set.
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).
orderedwhen 'true', the user indicates that values are ordered (e.g. a sorted vector), otherwise, depending on the container type, the compiler may still determine that values are ordered.

Definition at line 896 of file SetFunctions.h.

Referenced by makeDifference(), and DGtal::functions::setops::operator-=().

897  {
898  BOOST_STATIC_ASSERT( IsContainer< Container >::value );
899  BOOST_STATIC_CONSTANT
900  ( bool, isAssociative = IsAssociativeContainer< Container >::value );
901  BOOST_STATIC_CONSTANT
902  ( bool, isOrdered = ordered
903  || ( isAssociative && IsOrderedAssociativeContainer< Container >::value ) );
904 
906  ::assignDifference( S1, S2 );
907  }
Aim: Specialize set operations (union, intersection, difference, symmetric_difference) according to t...
Definition: SetFunctions.h:234
template<typename Container >
Container& DGtal::functions::assignDifference ( Container &  S1,
const Container &  S2 
)

Set difference operation. Updates the set S1 as S1 - S2.

Parameters
[in,out]S1an input set, S1 - S2 as output.
[in]S2another input set.
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).

Definition at line 918 of file SetFunctions.h.

919  {
920  BOOST_STATIC_ASSERT( IsContainer< Container >::value );
921  BOOST_STATIC_CONSTANT
922  ( bool, isAssociative = IsAssociativeContainer< Container >::value );
923  BOOST_STATIC_CONSTANT
924  ( bool, isOrdered = isAssociative && IsOrderedAssociativeContainer< Container >::value );
925 
927  ::assignDifference( S1, S2 );
928  }
Aim: Specialize set operations (union, intersection, difference, symmetric_difference) according to t...
Definition: SetFunctions.h:234
template<typename Container , bool ordered>
Container& DGtal::functions::assignIntersection ( Container &  S1,
const Container &  S2 
)

Set intersection operation. Updates the set S1 as \( S1 \cap S2 \).

Parameters
[in,out]S1an input set, \( S1 \cap S2 \) as output.
[in]S2another input set.
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).
orderedwhen 'true', the user indicates that values are ordered (e.g. a sorted vector), otherwise, depending on the container type, the compiler may still determine that values are ordered.

Definition at line 1082 of file SetFunctions.h.

Referenced by makeIntersection(), and DGtal::functions::setops::operator&=().

1083  {
1084  BOOST_STATIC_ASSERT( IsContainer< Container >::value );
1085  BOOST_STATIC_CONSTANT
1086  ( bool, isAssociative = IsAssociativeContainer< Container >::value );
1087  BOOST_STATIC_CONSTANT
1088  ( bool, isOrdered = ordered
1089  || ( isAssociative && IsOrderedAssociativeContainer< Container >::value ) );
1090 
1092  ::assignIntersection( S1, S2 );
1093  }
Aim: Specialize set operations (union, intersection, difference, symmetric_difference) according to t...
Definition: SetFunctions.h:234
template<typename Container >
Container& DGtal::functions::assignIntersection ( Container &  S1,
const Container &  S2 
)

Set intersection operation. Updates the set S1 as \( S1 \cap S2 \).

Parameters
[in,out]S1an input set, \( S1 \cap S2 \) as output.
[in]S2another input set.
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).

Definition at line 1104 of file SetFunctions.h.

1105  {
1106  BOOST_STATIC_ASSERT( IsContainer< Container >::value );
1107  BOOST_STATIC_CONSTANT
1108  ( bool, isAssociative = IsAssociativeContainer< Container >::value );
1109  BOOST_STATIC_CONSTANT
1110  ( bool, isOrdered = isAssociative && IsOrderedAssociativeContainer< Container >::value );
1111 
1113  ::assignIntersection( S1, S2 );
1114  }
Aim: Specialize set operations (union, intersection, difference, symmetric_difference) according to t...
Definition: SetFunctions.h:234
template<typename Container , bool ordered>
Container& DGtal::functions::assignSymmetricDifference ( Container &  S1,
const Container &  S2 
)

Set symmetric difference operation. Updates the set S1 as \( S1 \Delta S2 \).

Parameters
[in,out]S1an input set, \( S1 \Delta S2 \) as output.
[in]S2another input set.
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).
orderedwhen 'true', the user indicates that values are ordered (e.g. a sorted vector), otherwise, depending on the container type, the compiler may still determine that values are ordered.

Definition at line 1176 of file SetFunctions.h.

Referenced by makeSymmetricDifference(), and DGtal::functions::setops::operator^=().

1177  {
1178  BOOST_STATIC_ASSERT( IsContainer< Container >::value );
1179  BOOST_STATIC_CONSTANT
1180  ( bool, isAssociative = IsAssociativeContainer< Container >::value );
1181  BOOST_STATIC_CONSTANT
1182  ( bool, isOrdered = ordered
1183  || ( isAssociative && IsOrderedAssociativeContainer< Container >::value ) );
1184 
1187  }
Aim: Specialize set operations (union, intersection, difference, symmetric_difference) according to t...
Definition: SetFunctions.h:234
template<typename Container >
Container& DGtal::functions::assignSymmetricDifference ( Container &  S1,
const Container &  S2 
)

Set symmetric difference operation. Updates the set S1 as \( S1 \Delta S2 \).

Parameters
[in,out]S1an input set, \( S1 \Delta S2 \) as output.
[in]S2another input set.
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).

Definition at line 1198 of file SetFunctions.h.

1199  {
1200  BOOST_STATIC_ASSERT( IsContainer< Container >::value );
1201  BOOST_STATIC_CONSTANT
1202  ( bool, isAssociative = IsAssociativeContainer< Container >::value );
1203  BOOST_STATIC_CONSTANT
1204  ( bool, isOrdered = isAssociative && IsOrderedAssociativeContainer< Container >::value );
1205 
1208  }
Aim: Specialize set operations (union, intersection, difference, symmetric_difference) according to t...
Definition: SetFunctions.h:234
template<typename Container , bool ordered>
Container& DGtal::functions::assignUnion ( Container &  S1,
const Container &  S2 
)

Set union operation. Updates the set S1 as \( S1 \cup S2 \).

Parameters
[in,out]S1an input set, \( S1 \cup S2 \) as output.
[in]S2another input set.
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).
orderedwhen 'true', the user indicates that values are ordered (e.g. a sorted vector), otherwise, depending on the container type, the compiler may still determine that values are ordered.

Definition at line 990 of file SetFunctions.h.

Referenced by makeUnion(), and DGtal::functions::setops::operator|=().

991  {
992  BOOST_STATIC_ASSERT( IsContainer< Container >::value );
993  BOOST_STATIC_CONSTANT
994  ( bool, isAssociative = IsAssociativeContainer< Container >::value );
995  BOOST_STATIC_CONSTANT
996  ( bool, isOrdered = ordered
997  || ( isAssociative && IsOrderedAssociativeContainer< Container >::value ) );
998 
1000  ::assignUnion( S1, S2 );
1001  }
Aim: Specialize set operations (union, intersection, difference, symmetric_difference) according to t...
Definition: SetFunctions.h:234
template<typename Container >
Container& DGtal::functions::assignUnion ( Container &  S1,
const Container &  S2 
)

Set union operation. Updates the set S1 as \( S1 \cup S2 \).

Parameters
[in,out]S1an input set, \( S1 \cup S2 \) as output.
[in]S2another input set.
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).

Definition at line 1012 of file SetFunctions.h.

1013  {
1014  BOOST_STATIC_ASSERT( IsContainer< Container >::value );
1015  BOOST_STATIC_CONSTANT
1016  ( bool, isAssociative = IsAssociativeContainer< Container >::value );
1017  BOOST_STATIC_CONSTANT
1018  ( bool, isOrdered = isAssociative && IsOrderedAssociativeContainer< Container >::value );
1019 
1021  ::assignUnion( S1, S2 );
1022  }
Aim: Specialize set operations (union, intersection, difference, symmetric_difference) according to t...
Definition: SetFunctions.h:234
template<typename TCoordinate , typename TInteger , unsigned short adjacency>
bool DGtal::functions::checkAll ( const ArithmeticalDSS< TCoordinate, TInteger, adjacency > &  aDSS)

Checks whether a DSS is valid or not. NB: in logarithmic time (in order to check that a and b are relatively prime)

Parameters
aDSSany DSS
Returns
'true' if valid, 'false' otherwise.
template<typename TCoordinate , typename TInteger , unsigned short adjacency>
bool DGtal::functions::checkOnePoint ( const ArithmeticalDSS< TCoordinate, TInteger, adjacency > &  aDSS)

Checks the validity of the DSS when it contains only one point.

Parameters
aDSSany DSS
Precondition
the DSS contains only one point
Returns
'true' if the DSS is valid, 'false' otherwise.
template<typename TCoordinate , typename TInteger , unsigned short adjacency>
bool DGtal::functions::checkPointsPosition ( const ArithmeticalDSS< TCoordinate, TInteger, adjacency > &  aDSS)

Checks that the difference between two extremal upper (resp. lower) leaning points is equal to the direction vector (a,b) scaled by an integer. Checks that there is no pattern between end points and extremal leaning points.

Parameters
aDSSany DSS
Precondition
the DSS contains more than one point, ie a and b are not both null.
Returns
'true' if ok, 'false' otherwise.
template<typename TCoordinate , typename TInteger , unsigned short adjacency>
bool DGtal::functions::checkPointsRemainder ( const ArithmeticalDSS< TCoordinate, TInteger, adjacency > &  aDSS)

Checks the consistency between the parameters and the leaning points: first and last upper leaning points should have a remainder equal to mu while firsta and last lower leaning points should have a remainder equal to mu + omega - 1. Moreover, front and back points should have a remainder lying within the range [mu, mu+omega[.

Parameters
aDSSany DSS
Precondition
the DSS contains more than one point, ie a and b are not both null.
Returns
'true' if this property is fulfilled, 'false' otherwise.
template<typename TKSpace , typename TCellContainer , typename CellConstIterator , typename CellMapIteratorPriority >
uint64_t DGtal::functions::collapse ( CubicalComplex< TKSpace, TCellContainer > &  K,
CellConstIterator  S_itB,
CellConstIterator  S_itE,
const CellMapIteratorPriority &  priority,
bool  hintIsSClosed = false,
bool  hintIsKClosed = false,
bool  verbose = false 
)

Collapse a user-specified part of complex K, collapsing cells following priority [priority], in a decreasing sequence until no more collapse is feasible. The range [S_itb,S_itE) provides the starting cells, generally (but not compulsory) maximal cells. The resulting complex is guaranteed to keep the same homotopy type (a kind of topology equivalence).

Note
Cells whose data has been marked as FIXED are not removed.
Only cells that are in the closure of [S_itb,S_itE) may be removed, and only if they are not marked as FIXED.
Advanced:
If you use a DefaultCellMapIteratorPriority object as priority, then the VALUE part of each cell data defines the priority (the highest value the soonest are these cells collapsed). You may thus fill these cell values before calling this method.
Template Parameters
TKSpacethe digital space in which lives the cubical complex.
TCellContainerthe associative container used to store cells within the cubical complex.
CellConstIteratorany forward const iterator on Cell.
CellMapIteratorPriorityany type defining a method 'bool operator()( const Cell&, const Cell&) const'. Defines the order in which cells are collapsed.
See also
DefaultCellMapIteratorPriority
Parameters
[in,out]Kthe complex that is collapsed.
S_itBthe start of a range of cells which is included in [K].
S_itEthe end of a range of cells which is included in [K].
prioritythe object that assign a priority to each cell.
hintIsSClosedindicates if [S_itb,S_ite) is a closed set (faster in this case).
hintIsKClosedindicates that complex K is closed.
verboseoutputs some information during processing when 'true'.
Returns
the number of cells removed from complex K.
See also
topology/cubical-complex-collapse.cpp
template<typename T >
T DGtal::functions::cube ( x)
inline

Returns the value x * x * x

Template Parameters
Ta type with the multiply operator.
Parameters
xany value
Returns
the value x * x * x

Definition at line 144 of file BasicMathFunctions.h.

145  { return x * x * x; }
template<typename TKSpace , typename TCellContainer , typename BdryCellOutputIterator , typename InnerCellOutputIterator >
void DGtal::functions::filterCellsWithinBounds ( const CubicalComplex< TKSpace, TCellContainer > &  K,
const typename TKSpace::Point &  kLow,
const typename TKSpace::Point &  kUp,
BdryCellOutputIterator  itBdry,
InnerCellOutputIterator  itInner 
)

Computes the cells of the given complex K that lies on the boundary or inside the parallelepiped specified by bounds kLow and kUp.

Template Parameters
TKSpacethe digital space in which lives the cubical complex.
TCellContainerthe associative container used to store cells within the cubical complex.
BdryCellOutputIteratorany output iterator on TCubicalComplex::Cell.
InnerCellOutputIteratorany output iterator on TCubicalComplex::Cell.
Parameters
[in]Kany cubical complex.
[in]kLowany Khalimsky coordinate representing the lowest possible cell.
[in]kUpany Khalimsky coordinate representing the uppermost possible cell.
[in,out]itBdryAn output iterator on Cell that outputs all the cells of K that lie on the boundary of the parallelepiped specified by bounds kLow and kUp.
[in,out]itInnerAn output iterator on Cell that outputs all the cells of K that lie in the interior of the parallelepiped specified by bounds kLow and kUp.
Note
Complexity is linear in the number of cells of K (but the constant is also linear in the dimension of K).
template<typename TObject , typename TMap >
void DGtal::functions::generateSimplicityTable ( const typename TObject::DigitalTopology &  dt,
TMap &  map 
)

Given a digital topology dt, generates tables that tells if the central point is simple for the specified configuration. The configuration is determined by a sequence of bits, the first bit for the point in the neighborhood, the second bit for the second point, etc. When set to one, the point is in the neighborhood.

Template Parameters
TObjectthe type of object whose simpleness we wish to precompute. Includes the topology.
TMapthe type used to store the mapping configuration -> bool.
Parameters
dtan instance of the digital topology.
map(modified) the mapping configuration -> bool.

Definition at line 70 of file NeighborhoodTablesGenerators.h.

References DGtal::HyperRectDomain< TSpace >::begin(), DGtal::HyperRectDomain< TSpace >::end(), DGtal::Trace::progressBar(), and DGtal::trace.

73  {
74  typedef typename TObject::DigitalSet DigitalSet;
75  typedef typename TObject::Point Point;
76  typedef typename DigitalSet::Domain Domain;
77  typedef typename Domain::ConstIterator DomainConstIterator;
78 
79  Point p1 = Point::diagonal( -1 );
80  Point p2 = Point::diagonal( 1 );
81  Point c = Point::diagonal( 0 );
82  Domain domain( p1, p2 );
83  DigitalSet shapeSet( domain );
84  TObject shape( dt, shapeSet );
85  unsigned int k = 0;
86  for ( DomainConstIterator it = domain.begin(); it != domain.end(); ++it )
87  if ( *it != c ) ++k;
88  ASSERT( ( k < 32 )
89  && "[generateSimplicityTable] number of configurations is too high." );
90  unsigned int nbCfg = 1 << k;
91  for ( NeighborhoodConfiguration cfg = 0; cfg < nbCfg; ++cfg )
92  {
93  if ( ( cfg % 1000 ) == 0 )
94  {
95  trace.progressBar( (double) cfg, (double) nbCfg );
96  }
97  shape.pointSet().clear();
98  shape.pointSet().insert( c );
100  for ( DomainConstIterator it = domain.begin(); it != domain.end(); ++it )
101  {
102  if ( *it != c )
103  {
104  if ( cfg & mask ) shape.pointSet().insert( *it );
105  mask <<= 1;
106  }
107  }
108  bool simple = shape.isSimple( c );
109  map[ cfg ] = simple;
110  }
111  }
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
Definition: StdDefs.h:100
void progressBar(const double currentValue, const double maximalValue)
Trace trace
Definition: Common.h:137
uint32_t NeighborhoodConfiguration
template<typename TComplex >
NeighborhoodConfiguration DGtal::functions::getSpelNeighborhoodConfigurationOccupancy ( const TComplex &  input_complex,
const typename TComplex::Point &  center,
const std::unordered_map< typename TComplex::Point, NeighborhoodConfiguration > &  mapPointToMask 
)

Get the occupancy configuration of the neighborhood of a point in a cubical complex. The neighborhood size is considered 3^D for dimension D of the point (ie 3x3x3 cube for 3D point).

Template Parameters
TComplexComplex type.
Parameters
input_complexinput complex. Used to check what points are occupied.
centerof the neighborhood. It doesn't matter if center belongs or not to input_complex.
mapPointToMaskmap[Point]->configuration, where Point is inside a DxD cube centered in {0,0,..} in ND.
Note
This doesn't work with KSpace coordinates, these must be converted to digital coordinates before:
See also
KhalimskySpaceND::uCoords(3,cell)
mapPointToBitMask
Returns
bit configuration
template<typename Container , bool ordered>
bool DGtal::functions::isEqual ( const Container &  S1,
const Container &  S2 
)

Equality test.

Parameters
[in]S1an input set.
[in]S2another input set.
Returns
true iff S1 is equal to S2 (i.e. S1 is a subset of S2 and S2 is a subset of S1).
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).
orderedwhen 'true', the user indicates that values are ordered (e.g. a sorted vector), otherwise, depending on the container type, the compiler may still determine that values are ordered.

Definition at line 789 of file SetFunctions.h.

Referenced by operator!=(), and operator==().

790  {
791  BOOST_STATIC_ASSERT( IsContainer< Container >::value );
792  BOOST_STATIC_CONSTANT
793  ( bool, isAssociative = IsAssociativeContainer< Container >::value );
794  BOOST_STATIC_CONSTANT
795  ( bool, isOrdered = ordered
796  || ( isAssociative && IsOrderedAssociativeContainer< Container >::value ) );
797 
799  ::isEqual( S1, S2 );
800  }
Aim: Specialize set operations (union, intersection, difference, symmetric_difference) according to t...
Definition: SetFunctions.h:234
template<typename Container >
bool DGtal::functions::isEqual ( const Container &  S1,
const Container &  S2 
)

Equality test.

Parameters
[in]S1an input set.
[in]S2another input set.
Returns
true iff S1 is equal to S2 (i.e. S1 is a subset of S2 and S2 is a subset of S1).
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).

Definition at line 815 of file SetFunctions.h.

816  {
817  BOOST_STATIC_ASSERT( IsContainer< Container >::value );
818  BOOST_STATIC_CONSTANT
819  ( bool, isAssociative = IsAssociativeContainer< Container >::value );
820  BOOST_STATIC_CONSTANT
821  ( bool, isOrdered = isAssociative && IsOrderedAssociativeContainer< Container >::value );
822 
824  ::isEqual( S1, S2 );
825  }
Aim: Specialize set operations (union, intersection, difference, symmetric_difference) according to t...
Definition: SetFunctions.h:234
template<typename Container , bool ordered>
bool DGtal::functions::isSubset ( const Container &  S1,
const Container &  S2 
)

Inclusion test.

Parameters
[in]S1an input set.
[in]S2another input set.
Returns
true iff S1 is a subset of S2.
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).
orderedwhen 'true', the user indicates that values are ordered (e.g. a sorted vector), otherwise, depending on the container type, the compiler may still determine that values are ordered.

Definition at line 845 of file SetFunctions.h.

Referenced by operator<=(), and operator>=().

846  {
847  BOOST_STATIC_ASSERT( IsContainer< Container >::value );
848  BOOST_STATIC_CONSTANT
849  ( bool, isAssociative = IsAssociativeContainer< Container >::value );
850  BOOST_STATIC_CONSTANT
851  ( bool, isOrdered = ordered
852  || ( isAssociative && IsOrderedAssociativeContainer< Container >::value ) );
853 
855  ::isSubset( S1, S2 );
856  }
Aim: Specialize set operations (union, intersection, difference, symmetric_difference) according to t...
Definition: SetFunctions.h:234
template<typename Container >
bool DGtal::functions::isSubset ( const Container &  S1,
const Container &  S2 
)

Inclusion test.

Parameters
[in]S1an input set.
[in]S2another input set.
Returns
true iff S1 is a subset of S2.
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).

Definition at line 869 of file SetFunctions.h.

870  {
871  BOOST_STATIC_ASSERT( IsContainer< Container >::value );
872  BOOST_STATIC_CONSTANT
873  ( bool, isAssociative = IsAssociativeContainer< Container >::value );
874  BOOST_STATIC_CONSTANT
875  ( bool, isOrdered = isAssociative && IsOrderedAssociativeContainer< Container >::value );
876 
878  ::isSubset( S1, S2 );
879  }
Aim: Specialize set operations (union, intersection, difference, symmetric_difference) according to t...
Definition: SetFunctions.h:234
DGtal::CountedPtr< boost::dynamic_bitset<> > DGtal::functions::loadTable ( const std::string &  input_filename,
const unsigned int  known_size,
const bool  compressed = true 
)
inline

Load existing look up table existing in file_name, precalculated tables can be accessed including the header: "DGtal/topology/tables/ConfigTables.h"

Parameters
input_filenameplain text containing the bool table.
known_sizeof the bitset, for 2D = 256 (2^8), 3D = 67108864 (2^26)
compressedtrue if table to read has been compressed with zlib.
Returns
smart ptr of map[neighbor_configuration] -> bool
Note
The tables were calculated using the generateTableXXX examples. Compressed files of the tables are distributed in the source code. At build or install time, the header "DGtal/topology/tables/ConfigTables.h" is generated. It has const strings variables with the file names of the tables.
template<unsigned int dimension = 3>
DGtal::CountedPtr< boost::dynamic_bitset<> > DGtal::functions::loadTable ( const std::string &  input_filename,
const bool  compressed = true 
)
inline

Load existing look up table existing in file_name, precalculated tables can be accessed including the header: "DGtal/topology/tables/ConfigTables.h"

Template Parameters
dimensionof the space input_filename table refers. 2 or 3
Parameters
input_filenameplain text containing the bool table.
compressedtrue if table to read has been compressed with zlib.
Returns
smart ptr of map[neighbor_configuration] -> bool
See also
NeighborhoodConfigurations::loadTable
template<typename Container , bool ordered>
Container DGtal::functions::makeDifference ( const Container &  S1,
const Container &  S2 
)

Set difference operation. Returns the difference of S1 - S2.

Parameters
[in]S1an input set
[in]S2another input set.
Returns
the set S1 - S2.
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).
orderedwhen 'true', the user indicates that values are ordered (e.g. a sorted vector), otherwise, depending on the container type, the compiler may still determine that values are ordered.

Definition at line 946 of file SetFunctions.h.

Referenced by DGtal::functions::setops::operator-().

947  {
948  BOOST_STATIC_ASSERT( IsContainer< Container >::value );
949  Container S( S1 );
950  assignDifference<Container, ordered>( S, S2 );
951  return S;
952  }
template<typename Container >
Container DGtal::functions::makeDifference ( const Container &  S1,
const Container &  S2 
)

Set difference operation. Returns the difference of S1 - S2.

Parameters
[in]S1an input set
[in]S2another input set.
Returns
the set S1 - S2.
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).

Definition at line 965 of file SetFunctions.h.

References assignDifference().

966  {
967  BOOST_STATIC_ASSERT( IsContainer< Container >::value );
968  Container S( S1 );
969  assignDifference( S, S2 );
970  return S;
971  }
Container & assignDifference(Container &S1, const Container &S2)
Definition: SetFunctions.h:896
template<typename Container , bool ordered>
Container DGtal::functions::makeIntersection ( const Container &  S1,
const Container &  S2 
)

Set intersection operation. Returns the set \( S1 \cap S2 \).

Parameters
[in]S1an input set.
[in]S2another input set.
Returns
the set \( S1 \cap S2 \).
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).
orderedwhen 'true', the user indicates that values are ordered (e.g. a sorted vector), otherwise, depending on the container type, the compiler may still determine that values are ordered.

Definition at line 1131 of file SetFunctions.h.

Referenced by DGtal::functions::setops::operator&().

1132  {
1133  BOOST_STATIC_ASSERT( IsContainer< Container >::value );
1134  Container S( S1 );
1135  assignIntersection<Container, ordered>( S, S2 );
1136  return S;
1137  }
template<typename Container >
Container DGtal::functions::makeIntersection ( const Container &  S1,
const Container &  S2 
)

Set intersection operation. Returns the set \( S1 \cap S2 \).

Parameters
[in]S1an input set.
[in]S2another input set.
Returns
the set \( S1 \cap S2 \).
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).

Definition at line 1149 of file SetFunctions.h.

References assignIntersection().

1150  {
1151  BOOST_STATIC_ASSERT( IsContainer< Container >::value );
1152  Container S( S1 );
1153  assignIntersection( S, S2 );
1154  return S;
1155  }
Container & assignIntersection(Container &S1, const Container &S2)
template<typename Container , bool ordered>
Container DGtal::functions::makeSymmetricDifference ( const Container &  S1,
const Container &  S2 
)

Set symmetric difference operation. Returns the set \( S1 \Delta S2 \).

Parameters
[in]S1an input set.
[in]S2another input set.
Returns
the set \( S1 \Delta S2 \).
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).
orderedwhen 'true', the user indicates that values are ordered (e.g. a sorted vector), otherwise, depending on the container type, the compiler may still determine that values are ordered.

Definition at line 1225 of file SetFunctions.h.

Referenced by DGtal::functions::setops::operator^().

1226  {
1227  BOOST_STATIC_ASSERT( IsContainer< Container >::value );
1228  Container S( S1 );
1229  assignSymmetricDifference<Container, ordered>( S, S2 );
1230  return S;
1231  }
template<typename Container >
Container DGtal::functions::makeSymmetricDifference ( const Container &  S1,
const Container &  S2 
)

Set symmetric difference operation. Returns the set \( S1 \Delta S2 \).

Parameters
[in]S1an input set.
[in]S2another input set.
Returns
the set \( S1 \Delta S2 \).
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).

Definition at line 1243 of file SetFunctions.h.

References assignSymmetricDifference().

1244  {
1245  BOOST_STATIC_ASSERT( IsContainer< Container >::value );
1246  Container S( S1 );
1247  assignSymmetricDifference( S, S2 );
1248  return S;
1249  }
Container & assignSymmetricDifference(Container &S1, const Container &S2)
template<typename Container , bool ordered>
Container DGtal::functions::makeUnion ( const Container &  S1,
const Container &  S2 
)

Set union operation. Returns the set \( S1 \cup S2 \).

Parameters
[in]S1an input set.
[in]S2another input set.
Returns
the set \( S1 \cup S2 \).
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).
orderedwhen 'true', the user indicates that values are ordered (e.g. a sorted vector), otherwise, depending on the container type, the compiler may still determine that values are ordered.

Definition at line 1039 of file SetFunctions.h.

Referenced by DGtal::functions::setops::operator|().

1040  {
1041  BOOST_STATIC_ASSERT( IsContainer< Container >::value );
1042  Container S( S1 );
1043  assignUnion<Container, ordered>( S, S2 );
1044  return S;
1045  }
template<typename Container >
Container DGtal::functions::makeUnion ( const Container &  S1,
const Container &  S2 
)

Set union operation. Returns the set \( S1 \cup S2 \).

Parameters
[in]S1an input set.
[in]S2another input set.
Returns
the set \( S1 \cup S2 \).
Template Parameters
Containerany type of container (even a sequence, a set, an unordered_set, a map, etc).

Definition at line 1057 of file SetFunctions.h.

References assignUnion().

1058  {
1059  BOOST_STATIC_ASSERT( IsContainer< Container >::value );
1060  Container S( S1 );
1061  assignUnion( S, S2 );
1062  return S;
1063  }
Container & assignUnion(Container &S1, const Container &S2)
Definition: SetFunctions.h:990
template<typename TPoint >
DGtal::CountedPtr< std::unordered_map<TPoint, NeighborhoodConfiguration > > DGtal::functions::mapZeroPointNeighborhoodToConfigurationMask ( )
inline

Maps any point in the neighborhood of point Zero (0,..,0) to its corresponding configuration bit mask. This is a helper to use with tables. The order of the configuration is lexicographic, starting in {-1, -1, ...}.

Note
the neighborhood is considered to be all points p which ||p-zero|| <= 1

Example: Point{ -1, -1, -1 } = 1; // corresponding to mask x x 0000 0001 Point{ 0, -1, -1 } = 2; // corresponding to mask x x 0000 0010 Point{ 1, 1, 1 } = 2^26; // x 0010 x x x x x x

Note
NeighborhoodConfiguration is type uint 32 bits, so the max dimension supported is 3.
See also
HyperRectDomain_Iterator::nextLexicographicOrder
testNeighborhoodConfigurations.cpp shows the complete mapping.
Template Parameters
TPointtype of point to create map and input the desired dimension.
Returns
map[Point]->configuration smart pointer.
template<typename TKSpace , typename TCellContainer >
bool DGtal::functions::operator!= ( const CubicalComplex< TKSpace, TCellContainer > &  S1,
const CubicalComplex< TKSpace, TCellContainer > &  S2 
)

Difference test.

Template Parameters
TKSpacethe digital space in which lives the cubical complex.
TCellContainerthe associative container used to store cells within the cubical complex.
Parameters
[in]S1an input cubical complex.
[in]S2another input cubical complex.
Returns
true iff S1 is not equal to S2 (i.e. either S1 is not a subcomplex of S2 or S2 is not a subcomplex of S1).

Definition at line 295 of file CubicalComplexFunctions.h.

References DGtal::CubicalComplex< TKSpace, TCellContainer >::dimension, isEqual(), DGtal::CubicalComplex< TKSpace, TCellContainer >::myCells, and DGtal::CubicalComplex< TKSpace, TCellContainer >::space().

297  {
298  typedef CubicalComplex< TKSpace, TCellContainer > CC;
299  ASSERT( &(S1.space()) == &(S2.space()) );
300  for ( Dimension i = 0; i <= CC::dimension; ++i )
301  if ( ! isEqual( S1.myCells[ i ], S2.myCells[ i ] ) )
302  return true;
303  return false;
304  }
Aim: This class represents an arbitrary cubical complex living in some Khalimsky space. Cubical complexes are sets of cells of different dimensions related together with incidence relations. Two cells in a cubical complex are incident if and only if they are incident in the surrounding Khalimsky space. In other words, cubical complexes are defined here as subsets of Khalimsky spaces.
bool isEqual(const Container &S1, const Container &S2)
Definition: SetFunctions.h:789
static const Dimension dimension
The dimension of the embedding space.
template<typename TKSpace , typename TCellContainer >
CubicalComplex< TKSpace, TCellContainer > DGtal::functions::operator& ( const CubicalComplex< TKSpace, TCellContainer > &  S1,
const CubicalComplex< TKSpace, TCellContainer > &  S2 
)
inline

Cubical Complex intersection operation. Returns the cubical complex \( S1 \cap S2 \).

Template Parameters
TKSpacethe digital space in which lives the cubical complex.
TCellContainerthe associative container used to store cells within the cubical complex.
Parameters
[in]S1an input cubical complex.
[in]S2another input cubical complex.
Returns
the cubical complex \( S1 \cap S2 \).

Definition at line 182 of file CubicalComplexFunctions.h.

References DGtal::CubicalComplex< TKSpace, TCellContainer >::dimension, and DGtal::CubicalComplex< TKSpace, TCellContainer >::myCells.

184  {
185  typedef CubicalComplex< TKSpace, TCellContainer > CC;
186  CC S( S1 );
187  for ( Dimension i = 0; i <= CC::dimension; ++i )
188  setops::operator&=( S.myCells[ i ], S2.myCells[ i ] );
189  return S;
190  }
Aim: This class represents an arbitrary cubical complex living in some Khalimsky space. Cubical complexes are sets of cells of different dimensions related together with incidence relations. Two cells in a cubical complex are incident if and only if they are incident in the surrounding Khalimsky space. In other words, cubical complexes are defined here as subsets of Khalimsky spaces.
static const Dimension dimension
The dimension of the embedding space.
template<typename TKSpace , typename TCellContainer >
CubicalComplex< TKSpace, TCellContainer > & DGtal::functions::operator&= ( CubicalComplex< TKSpace, TCellContainer > &  S1,
const CubicalComplex< TKSpace, TCellContainer > &  S2 
)
inline

Cubical Complex intersection operation. Updates the cubical complex S1 as \( S1 \cap S2 \).

Template Parameters
TKSpacethe digital space in which lives the cubical complex.
TCellContainerthe associative container used to store cells within the cubical complex.
Parameters
[in,out]S1an input cubical complex, \( S1 \cap S2 \) as output.
[in]S2another input cubical complex.
Returns
a reference to the modified cubical complex S1.

Definition at line 203 of file CubicalComplexFunctions.h.

References DGtal::CubicalComplex< TKSpace, TCellContainer >::dimension, and DGtal::CubicalComplex< TKSpace, TCellContainer >::myCells.

205  {
206  typedef CubicalComplex< TKSpace, TCellContainer > CC;
207  for ( Dimension i = 0; i <= CC::dimension; ++i )
208  setops::operator&=( S1.myCells[ i ], S2.myCells[ i ] );
209  return S1;
210  }
Aim: This class represents an arbitrary cubical complex living in some Khalimsky space. Cubical complexes are sets of cells of different dimensions related together with incidence relations. Two cells in a cubical complex are incident if and only if they are incident in the surrounding Khalimsky space. In other words, cubical complexes are defined here as subsets of Khalimsky spaces.
static const Dimension dimension
The dimension of the embedding space.
template<typename TKSpace , typename TCellContainer >
CubicalComplex< TKSpace, TCellContainer > DGtal::functions::operator* ( const CubicalComplex< TKSpace, TCellContainer > &  S1)
inline

Cubical Complex open operation.

Template Parameters
TKSpacethe digital space in which lives the cubical complex.
TCellContainerthe associative container used to store cells within the cubical complex.
Parameters
[in]S1an input cubical complex
Returns
a new cubical complex that is the opening of S1.

Definition at line 80 of file CubicalComplexFunctions.h.

References DGtal::CubicalComplex< TKSpace, TCellContainer >::open().

81  {
82  CubicalComplex< TKSpace, TCellContainer > S( S1 );
83  S.open();
84  return S;
85  }
template<typename TKSpace , typename TCellContainer >
CubicalComplex< TKSpace, TCellContainer > DGtal::functions::operator- ( const CubicalComplex< TKSpace, TCellContainer > &  S1,
const CubicalComplex< TKSpace, TCellContainer > &  S2 
)
inline

Cubical Complex difference operation. Returns the difference of S1 - S2.

Template Parameters
TKSpacethe digital space in which lives the cubical complex.
TCellContainerthe associative container used to store cells within the cubical complex.
Parameters
[in]S1an input cubical complex
[in]S2another input cubical complex.
Returns
the cubical complex S1 - S2.

Definition at line 120 of file CubicalComplexFunctions.h.

References DGtal::CubicalComplex< TKSpace, TCellContainer >::dimension, and DGtal::CubicalComplex< TKSpace, TCellContainer >::myCells.

122  {
123  typedef CubicalComplex< TKSpace, TCellContainer > CC;
124  CC S( S1 );
125  for ( Dimension i = 0; i <= CC::dimension; ++i )
126  setops::operator-=( S.myCells[ i ],S2.myCells[ i ] );
127  return S;
128  }
Aim: This class represents an arbitrary cubical complex living in some Khalimsky space. Cubical complexes are sets of cells of different dimensions related together with incidence relations. Two cells in a cubical complex are incident if and only if they are incident in the surrounding Khalimsky space. In other words, cubical complexes are defined here as subsets of Khalimsky spaces.
static const Dimension dimension
The dimension of the embedding space.
template<typename TKSpace , typename TCellContainer >
CubicalComplex< TKSpace, TCellContainer > & DGtal::functions::operator-= ( CubicalComplex< TKSpace, TCellContainer > &  S1,
const CubicalComplex< TKSpace, TCellContainer > &  S2 
)
inline

Cubical Complex difference operation. Updates the cubical complex S1 as S1 - S2.

Template Parameters
TKSpacethe digital space in which lives the cubical complex.
TCellContainerthe associative container used to store cells within the cubical complex.
Parameters
[in,out]S1an input cubical complex, S1 - S2 as output.
[in]S2another input cubical complex.
Returns
a reference to the modified cubical complex S1.

Definition at line 99 of file CubicalComplexFunctions.h.

References DGtal::CubicalComplex< TKSpace, TCellContainer >::dimension, and DGtal::CubicalComplex< TKSpace, TCellContainer >::myCells.

101  {
102  typedef CubicalComplex< TKSpace, TCellContainer > CC;
103  for ( Dimension i = 0; i <= CC::dimension; ++i )
104  setops::operator-=( S1.myCells[ i ],S2.myCells[ i ] );
105  return S1;
106  }
Aim: This class represents an arbitrary cubical complex living in some Khalimsky space. Cubical complexes are sets of cells of different dimensions related together with incidence relations. Two cells in a cubical complex are incident if and only if they are incident in the surrounding Khalimsky space. In other words, cubical complexes are defined here as subsets of Khalimsky spaces.
static const Dimension dimension
The dimension of the embedding space.
template<typename TKSpace , typename TCellContainer >
bool DGtal::functions::operator<= ( const CubicalComplex< TKSpace, TCellContainer > &  S1,
const CubicalComplex< TKSpace, TCellContainer > &  S2 
)

Inclusion test (subset of).

Template Parameters
TKSpacethe digital space in which lives the cubical complex.
TCellContainerthe associative container used to store cells within the cubical complex.
Parameters
[in]S1an input cubical complex.
[in]S2another input cubical complex.
Returns
true iff S1 is a subcomplex of S2.

Definition at line 319 of file CubicalComplexFunctions.h.

References DGtal::CubicalComplex< TKSpace, TCellContainer >::dimension, and isSubset().

321  {
322  typedef CubicalComplex< TKSpace, TCellContainer > CC;
323  ASSERT( &(S1.space()) == &(S2.space()) );
324  for ( Dimension i = 0; i <= CC::dimension; ++i )
325  if ( ! isSubset( S1.myCells[ i ], S2.myCells[ i ] ) )
326  return false;
327  return true;
328  }
Aim: This class represents an arbitrary cubical complex living in some Khalimsky space. Cubical complexes are sets of cells of different dimensions related together with incidence relations. Two cells in a cubical complex are incident if and only if they are incident in the surrounding Khalimsky space. In other words, cubical complexes are defined here as subsets of Khalimsky spaces.
bool isSubset(const Container &S1, const Container &S2)
Definition: SetFunctions.h:845
static const Dimension dimension
The dimension of the embedding space.
template<typename TKSpace , typename TCellContainer >
bool DGtal::functions::operator== ( const CubicalComplex< TKSpace, TCellContainer > &  S1,
const CubicalComplex< TKSpace, TCellContainer > &  S2 
)

Equality test.

Parameters
[in]S1an input cubical complex.
[in]S2another input cubical complex.
Returns
true iff S1 is equal to S2 (i.e. S1 is a subcomplex of S2 and S2 is a subcomplex of S1).

Definition at line 268 of file CubicalComplexFunctions.h.

References DGtal::CubicalComplex< TKSpace, TCellContainer >::dimension, isEqual(), DGtal::CubicalComplex< TKSpace, TCellContainer >::myCells, and DGtal::CubicalComplex< TKSpace, TCellContainer >::space().

270  {
271  typedef CubicalComplex< TKSpace, TCellContainer > CC;
272  ASSERT( &(S1.space()) == &(S2.space()) );
273  for ( Dimension i = 0; i <= CC::dimension; ++i )
274  if ( ! isEqual( S1.myCells[ i ], S2.myCells[ i ] ) )
275  return false;
276  return true;
277  }
Aim: This class represents an arbitrary cubical complex living in some Khalimsky space. Cubical complexes are sets of cells of different dimensions related together with incidence relations. Two cells in a cubical complex are incident if and only if they are incident in the surrounding Khalimsky space. In other words, cubical complexes are defined here as subsets of Khalimsky spaces.
bool isEqual(const Container &S1, const Container &S2)
Definition: SetFunctions.h:789
static const Dimension dimension
The dimension of the embedding space.
template<typename TKSpace , typename TCellContainer >
bool DGtal::functions::operator>= ( const CubicalComplex< TKSpace, TCellContainer > &  S1,
const CubicalComplex< TKSpace, TCellContainer > &  S2 
)

Inclusion test (supset of).

Template Parameters
TKSpacethe digital space in which lives the cubical complex.
TCellContainerthe associative container used to store cells within the cubical complex.
Parameters
[in]S1an input cubical complex.
[in]S2another input cubical complex.
Returns
true iff S2 is a subcomplex of S1.

Definition at line 342 of file CubicalComplexFunctions.h.

References DGtal::CubicalComplex< TKSpace, TCellContainer >::dimension, isSubset(), DGtal::CubicalComplex< TKSpace, TCellContainer >::myCells, and DGtal::CubicalComplex< TKSpace, TCellContainer >::space().

344  {
345  typedef CubicalComplex< TKSpace, TCellContainer > CC;
346  ASSERT( &(S1.space()) == &(S2.space()) );
347  for ( Dimension i = 0; i <= CC::dimension; ++i )
348  if ( ! isSubset( S2.myCells[ i ], S1.myCells[ i ] ) )
349  return false;
350  return true;
351  }
Aim: This class represents an arbitrary cubical complex living in some Khalimsky space. Cubical complexes are sets of cells of different dimensions related together with incidence relations. Two cells in a cubical complex are incident if and only if they are incident in the surrounding Khalimsky space. In other words, cubical complexes are defined here as subsets of Khalimsky spaces.
bool isSubset(const Container &S1, const Container &S2)
Definition: SetFunctions.h:845
static const Dimension dimension
The dimension of the embedding space.
template<typename TKSpace , typename TCellContainer >
CubicalComplex< TKSpace, TCellContainer > DGtal::functions::operator^ ( const CubicalComplex< TKSpace, TCellContainer > &  S1,
const CubicalComplex< TKSpace, TCellContainer > &  S2 
)
inline

Cubical Complex symmetric difference operation. Returns the cubical complex \( S1 \Delta S2 \).

Template Parameters
TKSpacethe digital space in which lives the cubical complex.
TCellContainerthe associative container used to store cells within the cubical complex.
Parameters
[in]S1an input cubical complex.
[in]S2another input cubical complex.
Returns
the cubical complex \( S1 \Delta S2 \).

Definition at line 224 of file CubicalComplexFunctions.h.

References DGtal::CubicalComplex< TKSpace, TCellContainer >::dimension, and DGtal::CubicalComplex< TKSpace, TCellContainer >::myCells.

226  {
227  typedef CubicalComplex< TKSpace, TCellContainer > CC;
228  CC S( S1 );
229  for ( Dimension i = 0; i <= CC::dimension; ++i )
230  setops::operator^=( S.myCells[ i ], S2.myCells[ i ] );
231  return S;
232  }
Aim: This class represents an arbitrary cubical complex living in some Khalimsky space. Cubical complexes are sets of cells of different dimensions related together with incidence relations. Two cells in a cubical complex are incident if and only if they are incident in the surrounding Khalimsky space. In other words, cubical complexes are defined here as subsets of Khalimsky spaces.
static const Dimension dimension
The dimension of the embedding space.
template<typename TKSpace , typename TCellContainer >
CubicalComplex< TKSpace, TCellContainer > & DGtal::functions::operator^= ( CubicalComplex< TKSpace, TCellContainer > &  S1,
const CubicalComplex< TKSpace, TCellContainer > &  S2 
)
inline

Cubical Complex symmetric difference operation. Updates the cubical complex S1 as \( S1 \Delta S2 \).

Template Parameters
TKSpacethe digital space in which lives the cubical complex.
TCellContainerthe associative container used to store cells within the cubical complex.
Parameters
[in,out]S1an input cubical complex, \( S1 \Delta S2 \) as output.
[in]S2another input cubical complex.
Returns
a reference to the modified cubical complex S1.

Definition at line 247 of file CubicalComplexFunctions.h.

References DGtal::CubicalComplex< TKSpace, TCellContainer >::dimension, and DGtal::CubicalComplex< TKSpace, TCellContainer >::myCells.

249  {
250  typedef CubicalComplex< TKSpace, TCellContainer > CC;
251  for ( Dimension i = 0; i <= CC::dimension; ++i )
252  setops::operator^=( S1.myCells[ i ], S2.myCells[ i ] );
253  return S1;
254  }
Aim: This class represents an arbitrary cubical complex living in some Khalimsky space. Cubical complexes are sets of cells of different dimensions related together with incidence relations. Two cells in a cubical complex are incident if and only if they are incident in the surrounding Khalimsky space. In other words, cubical complexes are defined here as subsets of Khalimsky spaces.
static const Dimension dimension
The dimension of the embedding space.
template<typename TKSpace , typename TCellContainer >
CubicalComplex< TKSpace, TCellContainer > DGtal::functions::operator| ( const CubicalComplex< TKSpace, TCellContainer > &  S1,
const CubicalComplex< TKSpace, TCellContainer > &  S2 
)
inline

Cubical Complex union operation. Returns the cubical complex \( S1 \cup S2 \).

Template Parameters
TKSpacethe digital space in which lives the cubical complex.
TCellContainerthe associative container used to store cells within the cubical complex.
Parameters
[in]S1an input cubical complex.
[in]S2another input cubical complex.
Returns
the cubical complex \( S1 \cup S2 \).

Definition at line 141 of file CubicalComplexFunctions.h.

References DGtal::CubicalComplex< TKSpace, TCellContainer >::dimension, and DGtal::CubicalComplex< TKSpace, TCellContainer >::myCells.

143  {
144  typedef CubicalComplex< TKSpace, TCellContainer > CC;
145  CC S( S1 );
146  for ( Dimension i = 0; i <= CC::dimension; ++i )
147  setops::operator|=( S.myCells[ i ],S2.myCells[ i ] );
148  return S;
149  }
Aim: This class represents an arbitrary cubical complex living in some Khalimsky space. Cubical complexes are sets of cells of different dimensions related together with incidence relations. Two cells in a cubical complex are incident if and only if they are incident in the surrounding Khalimsky space. In other words, cubical complexes are defined here as subsets of Khalimsky spaces.
static const Dimension dimension
The dimension of the embedding space.
template<typename TKSpace , typename TCellContainer >
CubicalComplex< TKSpace, TCellContainer > & DGtal::functions::operator|= ( CubicalComplex< TKSpace, TCellContainer > &  S1,
const CubicalComplex< TKSpace, TCellContainer > &  S2 
)
inline

Cubical Complex union operation. Updates the cubical complex S1 as \( S1 \cup S2 \).

Template Parameters
TKSpacethe digital space in which lives the cubical complex.
TCellContainerthe associative container used to store cells within the cubical complex.
Parameters
[in,out]S1an input cubical complex, \( S1 \cup S2 \) as output.
[in]S2another input cubical complex.
Returns
a reference to the modified cubical complex S1.

Definition at line 162 of file CubicalComplexFunctions.h.

References DGtal::CubicalComplex< TKSpace, TCellContainer >::dimension, and DGtal::CubicalComplex< TKSpace, TCellContainer >::myCells.

164  {
165  typedef CubicalComplex< TKSpace, TCellContainer > CC;
166  for ( Dimension i = 0; i <= CC::dimension; ++i )
167  setops::operator|=( S1.myCells[ i ], S2.myCells[ i ] );
168  return S1;
169  }
Aim: This class represents an arbitrary cubical complex living in some Khalimsky space. Cubical complexes are sets of cells of different dimensions related together with incidence relations. Two cells in a cubical complex are incident if and only if they are incident in the surrounding Khalimsky space. In other words, cubical complexes are defined here as subsets of Khalimsky spaces.
static const Dimension dimension
The dimension of the embedding space.
template<typename TKSpace , typename TCellContainer >
CubicalComplex< TKSpace, TCellContainer > DGtal::functions::operator~ ( const CubicalComplex< TKSpace, TCellContainer > &  S1)
inline

Cubical Complex close operation.

Template Parameters
TKSpacethe digital space in which lives the cubical complex.
TCellContainerthe associative container used to store cells within the cubical complex.
Parameters
[in]S1an input cubical complex
Returns
a new cubical complex that is the closing of S1.

Definition at line 63 of file CubicalComplexFunctions.h.

References DGtal::CubicalComplex< TKSpace, TCellContainer >::close().

64  {
65  CubicalComplex< TKSpace, TCellContainer > S( S1 );
66  S.close();
67  return S;
68  }
template<typename T >
T DGtal::functions::power ( const T &  aVal,
const unsigned int  exponent 
)

Compute exponentiation by squaring of a scalar aVal of type T by the exponent exponent (unsigned int). The computation is done in \( O(\log(exponent))\) multiplications.

Note
This function is better than std::pow on unsigned int exponents and integer value type since it performs exact computations (no cast to float or doubles).
Parameters
aValthe value
exponentthe exponent
Template Parameters
Tscalar value type (must have '*' operator).
Returns
aVal^exponent
See also
square, cube

Definition at line 73 of file BasicMathFunctions.h.

74  {
75  unsigned int q=exponent;
76  T p(aVal);
77 
78  if (exponent == 0) { return 1; }
79 
80  T result = NumberTraits<T>::ONE;
81  while (q != 0)
82  {
83  if (q % 2 == 1) { // q is odd
84  result *= p;
85  q--;
86  }
87  p *= p;
88  q /= 2;
89  }
90  return result;
91  }
template<typename PointVector , typename Position , typename PositionFunctor , typename OutputIterator >
PointVector DGtal::functions::reversedSmartCH ( PointVector  U,
PointVector  L,
PointVector  V,
const Position &  aFirstPosition,
const Position &  aLastPosition,
const PositionFunctor &  aPositionFunctor,
OutputIterator  uIto,
OutputIterator  lIto 
)
inline

Procedure that computes the lower and upper left hull of the left subsegment of a greater DSS characterized by the first upper leaning point U, the first positive Bezout point L and its direction vector V. Note that the so-called left subsegment is bounded on the one hand by the first point of the DSS located at aFirstPosition and on the other hand by the point located at position aLastPosition.

Parameters
Ulast upper convex hull vertex
Llast lower convex hull vertex
Vlast valid Bezout vector (main direction vector)
aFirstPositionposition of the first point of the subsegment
aLastPositionposition of the last point of the subsegment
aPositionFunctorposition functor, which returns the position of any given point/vector
uItooutput iterator used to store the vertices of the upper convex hull
lItooutput iterator used to store the vertices of the lower convex hull
Template Parameters
PointVectora model of 2d point/vector
Positiona model of integer for the position of the point in the bounding DSS
PositionFunctora model of unary functor that returns the position of a point/vector
OutputIteratora model of output iterator
Returns
last direction vector, ie. the rational slope of minimal denominator
template<typename DSS , typename OutputIterator >
DSS::Vector DGtal::functions::reversedSmartCH ( const DSS &  aDSS,
const typename DSS::Position &  aPositionBound,
OutputIterator  uIto,
OutputIterator  lIto 
)
inline

Procedure that computes the lower and upper left hull of the left subsegment of a greater DSS aDSS. Note that the so-called left subsegment is bounded on the one hand by the first point of aDSS and on the other hand by the point located at position aPositionBound [Roussillon 2014 : [66]].

Parameters
aDSSbounding DSS
aPositionBoundposition of the last point of the subsegment (should be located after the first point of aDSS).
uItooutput iterator used to store the vertices of the upper convex hull
lItooutput iterator used to store the vertices of the lower convex hull
Template Parameters
DSSa model of arithmetical DSS
OutputIteratora model of output iterator
Returns
last direction vector, ie. the rational slope of minimal denominator
template<typename T >
T DGtal::functions::roundToUpperPowerOfTwo ( const T &  n)

Compute the next higher power of two of the given argument n of type T.

Template Parameters
Tthe type of the element T
Parameters
nan element of type T (casted to unsigned integer).
Returns
the next higher power of two.

Definition at line 102 of file BasicMathFunctions.h.

References DGtal::Bits::mostSignificantBit().

Referenced by DGtal::Viewer3D< TSpace, TKSpace >::GLTextureImage::GLTextureImage().

102  {
103  return (T) 1 << (1+DGtal::Bits::mostSignificantBit( (unsigned int) n-1 ) );
104  }
static unsigned int mostSignificantBit(DGtal::uint8_t n)
Definition: Bits.h:343
template<typename PointVector , typename Coordinate , typename Position , typename PositionFunctor , typename OutputIterator >
PointVector DGtal::functions::smartCH ( const PointVector aFirstPoint,
const Coordinate &  aRemainderBound,
const Position &  aPositionBound,
const PointVector aStep,
const Coordinate &  aRStep,
const PointVector aShift,
const Coordinate &  aRShift,
const PositionFunctor &  aPositionFunctor,
OutputIterator  uIto,
OutputIterator  lIto 
)
inline

Procedure that computes the lower and upper left hull of a DSS of first point aFirstPoint, length aPositionBound, contained in a digital straight line described by aRStep, aRShift and aRemainderBound.

Parameters
aFirstPointfirst point of the DSS
aRemainderBounddifference between the intercept mu of the bounding DSL and the remainder of the first point.
aPositionBound(strictly positive) length of the DSS
aStepfirst step of the DSL
aRStepremainder of the first step, ie. parameter \( a \) of the bounding DSL
aShiftshift vector of the DSL
aRShiftremainder of the shift vector, ie. parameter \( omega \) of the bounding DSL.
aPositionFunctorposition functor, which returns the position of any given point/vector
uItooutput iterator used to store the vertices of the upper convex hull
lItooutput iterator used to store the vertices of the lower convex hull
Returns
last direction vector, ie. the rational slope of minimal denominator of the DSS
Template Parameters
PointVectora model of 2d point/vector
Coordinatea model of integer for the coordinates of the point/vector
Positiona model of integer for locating points in the DSS
PositionFunctora model of unary functor that returns the position of a point/vector
OutputIteratora model of output iterator
template<typename DSL , typename OutputIterator >
DSL::Vector DGtal::functions::smartCH ( const DSL &  aDSL,
const typename DSL::Point &  aFirstPoint,
const typename DSL::Position &  aLength,
OutputIterator  uIto,
OutputIterator  lIto 
)
inline

Procedure that computes the lower and upper left hull of a DSS of first point aFirstPoint, length aLength, contained in a DSL aDSL [Roussillon 2014 : [66]].

Parameters
aDSLbounding DSL
aFirstPointfirst point of the DSS
aLength(strictly positive) length of the DSS
uItooutput iterator used to store the vertices of the upper convex hull
lItooutput iterator used to store the vertices of the lower convex hull
Returns
last direction vector, ie. the rational slope of minimal denominator
Template Parameters
DSLa model of arithmetical DSL
OutputIteratora model of output iterator
template<typename Position , typename Coordinate , typename PointVector , typename OutputIterator , typename PositionFunctor , typename TruncationFunctor1 , typename TruncationFunctor2 >
bool DGtal::functions::smartCHNextVertex ( const Position &  positionBound,
const Coordinate &  remainderBound,
PointVector X,
Coordinate &  rX,
const PointVector Y,
const Coordinate &  rY,
PointVector V,
Coordinate &  rV,
OutputIterator  ito,
const PositionFunctor &  pos,
const TruncationFunctor1 &  f1,
const TruncationFunctor2 &  f2 
)
inline

Procedure that computes the next (lower or upper) vertex of the left hull of a DSS.

Parameters
positionBoundposition of the last point of the DSS
remainderBoundremainder of the lower leaning points contained in the DSS
X(returned) last vertex of the considered side
rX(returned) remainder of X
Ylast vertex of the opposite side
rYremainder of Y
V(returned) last direction vector (unimodular with (X - Y))
rV(returned) remainder of V (not null)
itooutput iterator used to store the new vertex lying on the same side as X
posposition functor, which returns the position of any given point/vector
f1first floor function (for the vertex)
f2second floor function (for the direction vector)
Returns
'true' if the last vertex of the left hull has been reached, 'false' otherwise.
Template Parameters
Positiona model of integer for locating points in the DSS
PointVectora model of 2d point/vector
Coordinatea model of integer for the coordinates of the point/vector
OutputIteratora model of output iterator
PositionFunctora model of unary functor that returns the position of a point/vector
TruncationFunctor1a model of unary functor that implements an integer division
TruncationFunctor2a model of unary functor that implements an integer division
template<typename PointVector , typename Position , typename OutputIterator , typename TruncationFunctor1 , typename TruncationFunctor2 , typename PositionFunctor >
bool DGtal::functions::smartCHPreviousVertex ( PointVector X,
const PointVector Y,
PointVector V,
const Position &  aFirstPosition,
const Position &  aLastPosition,
OutputIterator  ito,
const PositionFunctor &  pos,
const TruncationFunctor1 &  f1,
const TruncationFunctor2 &  f2 
)
inline

Procedure that computes the previous vertex of the left hull of a DSS of main direction vector V , first upper leaning point U and first positive Bezout point L. The computation stops as soon as a computed vertex is located before aLastPosition.

Parameters
X(returned) first vertex of the left hull on the considered side
Yfirst vertex of the left hull on the opposite side
V(returned) previous direction vector
aFirstPositionposition of the first point of the subsegment
aLastPositionposition of the last point of the subsegment
itooutput iterator used to store the vertices of the left hull lying on the same side as X
posposition functor, which returns the position of any given point/vector
f1integer divisor for the direction vector update
f2integer divisor for the vertex update
Template Parameters
PointVectora model of couple of coordinates
Positiona model of integer for the position of the points
OutputIteratora model of output iterator
TruncationFunctor1a model of functor for the integer division
TruncationFunctor2a model of functor for the integer division
PositionFunctora model of functor returning the position of a point
Returns
'true' if the last vertex has been reached, 'false' otherwise
template<typename T >
T DGtal::functions::square ( x)
inline

Returns the value x * x

Template Parameters
Ta type with the multiply operator.
Parameters
xany value
Returns
the value x * x

Definition at line 133 of file BasicMathFunctions.h.

Referenced by DGtal::functors::HatPointFunction< TPoint, TScalar >::operator()(), and DGtal::functors::BallConstantPointFunction< TPoint, TScalar >::operator()().

134  { return x * x; }