DGtal  1.5.beta
CubicalComplexFunctions.h
1 
17 #pragma once
18 
31 #if defined(CubicalComplexFunctions_RECURSES)
32 #error Recursive header files inclusion detected in CubicalComplexFunctions.h
33 #else // defined(CubicalComplexFunctions_RECURSES)
35 #define CubicalComplexFunctions_RECURSES
36 
37 #if !defined CubicalComplexFunctions_h
39 #define CubicalComplexFunctions_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
45 #include "DGtal/topology/CubicalComplex.h"
46 #include <DGtal/topology/helpers/NeighborhoodConfigurationsHelper.h>
48 
49 namespace DGtal
50 {
59  template <typename TKSpace, typename TCellContainer>
60  inline CubicalComplex< TKSpace, TCellContainer >
62  {
64  S.close();
65  return S;
66  }
67 
76  template <typename TKSpace, typename TCellContainer>
77  inline CubicalComplex< TKSpace, TCellContainer >
79  {
81  S.open();
82  return S;
83  }
84 
95  template <typename TKSpace, typename TCellContainer>
96  inline CubicalComplex< TKSpace, TCellContainer >&
99  {
101  for ( Dimension i = 0; i <= CC::dimension; ++i )
102  functions::setops::operator-=( S1.myCells[ i ],S2.myCells[ i ] );
103  return S1;
104  }
105 
116  template <typename TKSpace, typename TCellContainer>
117  inline CubicalComplex< TKSpace, TCellContainer >
120  {
122  CC S( S1 );
123  for ( Dimension i = 0; i <= CC::dimension; ++i )
124  functions::setops::operator-=( S.myCells[ i ],S2.myCells[ i ] );
125  return S;
126  }
127 
137  template <typename TKSpace, typename TCellContainer>
138  inline CubicalComplex< TKSpace, TCellContainer >
141  {
143  CC S( S1 );
144  for ( Dimension i = 0; i <= CC::dimension; ++i )
145  functions::setops::operator|=( S.myCells[ i ],S2.myCells[ i ] );
146  return S;
147  }
148 
158  template <typename TKSpace, typename TCellContainer>
159  inline CubicalComplex< TKSpace, TCellContainer >&
162  {
164  for ( Dimension i = 0; i <= CC::dimension; ++i )
165  functions::setops::operator|=( S1.myCells[ i ], S2.myCells[ i ] );
166  return S1;
167  }
168 
178  template <typename TKSpace, typename TCellContainer>
179  inline CubicalComplex< TKSpace, TCellContainer >
182  {
184  CC S( S1 );
185  for ( Dimension i = 0; i <= CC::dimension; ++i )
186  functions::setops::operator&=( S.myCells[ i ], S2.myCells[ i ] );
187  return S;
188  }
189 
199  template <typename TKSpace, typename TCellContainer>
200  inline CubicalComplex< TKSpace, TCellContainer >&
203  {
205  for ( Dimension i = 0; i <= CC::dimension; ++i )
206  functions::setops::operator&=( S1.myCells[ i ], S2.myCells[ i ] );
207  return S1;
208  }
209 
220  template <typename TKSpace, typename TCellContainer>
221  inline CubicalComplex< TKSpace, TCellContainer >
224  {
226  CC S( S1 );
227  for ( Dimension i = 0; i <= CC::dimension; ++i )
228  functions::setops::operator^=( S.myCells[ i ], S2.myCells[ i ] );
229  return S;
230  }
231 
243  template <typename TKSpace, typename TCellContainer>
244  inline CubicalComplex< TKSpace, TCellContainer >&
247  {
249  for ( Dimension i = 0; i <= CC::dimension; ++i )
250  functions::setops::operator^=( S1.myCells[ i ], S2.myCells[ i ] );
251  return S1;
252  }
253 
255 
264  template <typename TKSpace, typename TCellContainer>
265  bool
268  {
270  ASSERT( &(S1.space()) == &(S2.space()) );
271  for ( Dimension i = 0; i <= CC::dimension; ++i )
272  if ( ! functions::isEqual( S1.myCells[ i ], S2.myCells[ i ] ) )
273  return false;
274  return true;
275  }
276 
278 
291  template <typename TKSpace, typename TCellContainer>
292  bool
295  {
297  ASSERT( &(S1.space()) == &(S2.space()) );
298  for ( Dimension i = 0; i <= CC::dimension; ++i )
299  if ( ! functions::isEqual( S1.myCells[ i ], S2.myCells[ i ] ) )
300  return true;
301  return false;
302  }
303 
305 
315  template <typename TKSpace, typename TCellContainer>
316  bool
319  {
321  ASSERT( &(S1.space()) == &(S2.space()) );
322  for ( Dimension i = 0; i <= CC::dimension; ++i )
323  if ( ! functions::isSubset( S1.myCells[ i ], S2.myCells[ i ] ) )
324  return false;
325  return true;
326  }
327 
338  template <typename TKSpace, typename TCellContainer>
339  bool
342  {
344  ASSERT( &(S1.space()) == &(S2.space()) );
345  for ( Dimension i = 0; i <= CC::dimension; ++i )
346  if ( ! functions::isSubset( S2.myCells[ i ], S1.myCells[ i ] ) )
347  return false;
348  return true;
349  }
350 
351  namespace functions {
352 
392  template <typename TKSpace, typename TCellContainer,
393  typename CellConstIterator,
394  typename CellMapIteratorPriority >
396  CellConstIterator S_itB, CellConstIterator S_itE,
397  const CellMapIteratorPriority& priority,
398  bool hintIsSClosed = false, bool hintIsKClosed = false,
399  bool verbose = false );
400 
431  template <typename TKSpace, typename TCellContainer,
432  typename BdryCellOutputIterator,
433  typename InnerCellOutputIterator>
434  void
436  const typename TKSpace::Point& kLow,
437  const typename TKSpace::Point& kUp,
438  BdryCellOutputIterator itBdry,
439  InnerCellOutputIterator itInner );
440 
457  template < typename TObject, typename TKSpace, typename TCellContainer>
458  std::unique_ptr<TObject>
460 
482  template<typename TComplex>
485  const TComplex & input_complex,
486  const typename TComplex::Point & center,
487  const std::unordered_map<
488  typename TComplex::Point, NeighborhoodConfiguration> & mapPointToMask);
489  } // namespace functions
490 
491 } // namespace DGtal
492 
493 
495 // Includes inline functions.
496 #include "DGtal/topology/CubicalComplexFunctions.ih"
497 
498 // //
500 
501 #endif // !defined CubicalComplexFunctions_h
502 
503 #undef CubicalComplexFunctions_RECURSES
504 #endif // else defined(CubicalComplexFunctions_RECURSES)
Aim: This class represents an arbitrary cubical complex living in some Khalimsky space....
const KSpace & space() const
std::vector< CellMap > myCells
NeighborhoodConfiguration getSpelNeighborhoodConfigurationOccupancy(const TComplex &input_complex, const typename TComplex::Point &center, const std::unordered_map< typename TComplex::Point, NeighborhoodConfiguration > &mapPointToMask)
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)
void filterCellsWithinBounds(const CubicalComplex< TKSpace, TCellContainer > &K, const typename TKSpace::Point &kLow, const typename TKSpace::Point &kUp, BdryCellOutputIterator itBdry, InnerCellOutputIterator itInner)
bool isEqual(const Container &S1, const Container &S2)
Definition: SetFunctions.h:789
std::unique_ptr< TObject > objectFromSpels(const CubicalComplex< TKSpace, TCellContainer > &C)
bool isSubset(const Container &S1, const Container &S2)
Definition: SetFunctions.h:845
DGtal is the top-level namespace which contains all DGtal functions and types.
bool operator>=(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Comparison operator on Points/Vectors (GreaterOrEqualThan).
CubicalComplex< TKSpace, TCellContainer > & operator^=(CubicalComplex< TKSpace, TCellContainer > &, const CubicalComplex< TKSpace, TCellContainer > &)
bool operator==(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Equality operator between two Points/Vectors.
uint32_t NeighborhoodConfiguration
CubicalComplex< TKSpace, TCellContainer > & operator&=(CubicalComplex< TKSpace, TCellContainer > &, const CubicalComplex< TKSpace, TCellContainer > &)
bool operator!=(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Difference operator on Points/Vectors.
CubicalComplex< TKSpace, TCellContainer > operator~(const CubicalComplex< TKSpace, TCellContainer > &)
bool operator<=(PointVector< ptDim, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< ptDim, RightEuclideanRing, RightContainer > const &rhs)
Comparison operator on Points/Vectors (LesserOrEqualThan).
DGtal::uint32_t Dimension
Definition: Common.h:136
CubicalComplex< TKSpace, TCellContainer > operator^(const CubicalComplex< TKSpace, TCellContainer > &, const CubicalComplex< TKSpace, TCellContainer > &)
KForm< Calculus, order, duality > operator*(const typename Calculus::Scalar &scalar, const KForm< Calculus, order, duality > &form)
boost::uint64_t uint64_t
unsigned 64-bit integer.
Definition: BasicTypes.h:65
CubicalComplex< TKSpace, TCellContainer > & operator|=(CubicalComplex< TKSpace, TCellContainer > &, const CubicalComplex< TKSpace, TCellContainer > &)
KForm< Calculus, order, duality > operator-(const KForm< Calculus, order, duality > &form_a, const KForm< Calculus, order, duality > &form_b)
CubicalComplex< TKSpace, TCellContainer > operator&(const CubicalComplex< TKSpace, TCellContainer > &, const CubicalComplex< TKSpace, TCellContainer > &)
CubicalComplex< TKSpace, TCellContainer > operator|(const CubicalComplex< TKSpace, TCellContainer > &, const CubicalComplex< TKSpace, TCellContainer > &)
CubicalComplex< TKSpace, TCellContainer > & operator-=(CubicalComplex< TKSpace, TCellContainer > &, const CubicalComplex< TKSpace, TCellContainer > &)
MyPointD Point
Definition: testClone2.cpp:383
KSpace K
CubicalComplex< KSpace, Map > CC