31 #if defined(CubicalComplex_RECURSES) 32 #error Recursive header files inclusion detected in CubicalComplex.h 33 #else // defined(CubicalComplex_RECURSES) 35 #define CubicalComplex_RECURSES 37 #if !defined CubicalComplex_h 39 #define CubicalComplex_h 47 #include <boost/type_traits.hpp> 48 #include <boost/iterator/iterator_facade.hpp> 49 #include "DGtal/base/Common.h" 50 #include "DGtal/base/ConstAlias.h" 51 #include "DGtal/base/Alias.h" 52 #include "DGtal/base/ContainerTraits.h" 53 #include "DGtal/base/CSTLAssociativeContainer.h" 54 #include "DGtal/topology/CCellularGridSpaceND.h" 83 template <
typename TKSpace,
typename TCellContainer >
87 template <
typename TKSpace,
typename TCellContainer >
91 template <
typename TKSpace,
typename TCellContainer >
95 template <
typename TKSpace,
typename TCellContainer >
99 template <
typename TKSpace,
typename TCellContainer >
103 template <
typename TKSpace,
typename TCellContainer >
107 template <
typename TKSpace,
typename TCellContainer >
111 template <
typename TKSpace,
typename TCellContainer >
115 template <
typename TKSpace,
typename TCellContainer >
120 template <
typename TKSpace,
typename TCellContainer >
123 template <
typename TKSpace,
typename TCellContainer >
127 template <
typename TKSpace,
typename TCellContainer >
131 template <
typename TKSpace,
typename TCellContainer >
135 template <
typename TKSpace,
typename TCellContainer >
137 operator<=( const CubicalComplex< TKSpace, TCellContainer >&,
139 template <
typename TKSpace,
typename TCellContainer >
175 template <
typename TKSpace,
192 friend Self& DGtal::functions::operator|=<>( Self&,
const Self& );
193 friend Self& DGtal::functions::operator&=<>( Self&,
const Self& );
194 friend Self& DGtal::functions::operator^=<>( Self&,
const Self& );
195 friend Self& DGtal::functions::operator-=<>( Self&,
const Self& );
196 friend Self DGtal::functions::operator| <>(
const Self&,
const Self& );
197 friend Self DGtal::functions::operator& <>(
const Self&,
const Self& );
198 friend Self DGtal::functions::operator^ <>(
const Self&,
const Self& );
199 friend Self DGtal::functions::operator- <>(
const Self&,
const Self& );
200 friend Self DGtal::functions::operator~ <>(
const Self& );
201 friend Self DGtal::functions::operator* <>(
const Self& );
202 friend bool DGtal::functions::operator==<>(
const Self&,
const Self& );
203 friend bool DGtal::functions::operator!=<>(
const Self&,
const Self& );
204 friend bool DGtal::functions::operator<=<>(
const Self&,
const Self& );
205 friend bool DGtal::functions::operator>=<>(
const Self&,
const Self& );
209 typedef typename CellContainer::mapped_type
Data;
211 BOOST_STATIC_ASSERT (( boost::is_base_of< CubicalCellData, Data >::value ));
212 BOOST_STATIC_ASSERT (( boost::is_same< typename TKSpace::Cell, typename CellContainer::key_type >::value ));
219 typedef typename KSpace::Cells
Cells;
221 typedef typename KSpace::Size
Size;
237 BOOST_STATIC_CONSTANT(
uint32_t, REMOVED = 0x10000000 );
239 BOOST_STATIC_CONSTANT(
uint32_t, COLLAPSIBLE = 0x20000000 );
241 BOOST_STATIC_CONSTANT(
uint32_t, FIXED = 0x40000000 );
243 BOOST_STATIC_CONSTANT(
uint32_t, USER1 = 0x80000000 );
245 BOOST_STATIC_CONSTANT(
uint32_t, VALUE = 0x0fffffff );
266 bool operator()(
const CellMapIterator& it1,
const CellMapIterator& it2 )
const 268 uint32_t v1 = it1->second.data & VALUE;
269 uint32_t v2 = it2->second.data & VALUE;
271 || ( ( v1 == v2 ) && ( it1->first < it2->first ) );
280 :
public boost::iterator_facade< ConstIterator, Cell const,
281 std::forward_iterator_tag >
286 std::forward_iterator_tag >
Base;
288 typedef typename Base::value_type
Value;
305 : myCC( &cc ), myD( d )
307 if ( myD <= myCC->dimension )
309 myIt = myCC->begin( myD );
310 myItEnd = myCC->end( myD );
315 myD = myCC->dimension + 1;
316 myIt = myCC->end( myCC->dimension );
317 myItEnd = myCC->end( myCC->dimension );
329 CellMapConstIterator it )
330 : myCC( &cc ), myD( d ), myIt( it )
332 ASSERT( d <= myCC->dimension );
333 myItEnd = myCC->end( d );
338 friend class boost::iterator_core_access;
342 while ( myIt == myItEnd )
344 if ( ++myD > myCC->dimension )
break;
345 myIt = myCC->begin( myD );
346 myItEnd = myCC->end( myD );
357 bool equal(
const ConstIterator& other )
const 359 return ( myD == other.
myD ) && ( myIt == other.
myIt );
385 :
public boost::iterator_facade< Iterator, Cell const,
386 std::forward_iterator_tag >
390 typedef boost::iterator_facade<
Iterator, Cell
const,
391 std::forward_iterator_tag >
Base;
393 typedef typename Base::value_type
Value;
409 : myCC( &cc ), myD( d )
411 if ( myD <= myCC->dimension )
413 myIt = myCC->begin( myD );
414 myItEnd = myCC->end( myD );
419 myD = myCC->dimension + 1;
420 myIt = myCC->end( myCC->dimension );
421 myItEnd = myCC->end( myCC->dimension );
434 : myCC( &cc ), myD( d ), myIt( it )
436 ASSERT( d <= myCC->dimension );
437 myItEnd = myCC->end( d );
442 friend class boost::iterator_core_access;
446 while ( myIt == myItEnd )
448 if ( ++myD > myCC->dimension )
break;
449 myIt = myCC->begin( myD );
450 myItEnd = myCC->end( myD );
461 bool equal(
const Iterator& other )
const 463 return ( myD == other.
myD ) && ( myIt == other.
myIt );
534 template <
typename TDigitalSet >
535 void construct (
const TDigitalSet &
set );
562 void fillData( Data data = Data() );
572 void fillData(
Dimension d, Data data = Data() );
599 Integer euler()
const;
604 const KSpace& space()
const;
629 Size count(
const Cell& aCell )
const;
636 Size max_size()
const;
651 std::pair< ConstIterator, ConstIterator > equal_range(
const Cell& aCell )
const;
663 std::pair< Iterator, Iterator > equal_range(
const Cell& aCell );
676 Size
erase(
const Cell& aCell );
706 std::pair< Iterator, bool >
insert(
const Cell& aCell );
724 template <
class InputIterator>
725 void insert( InputIterator first, InputIterator last );
746 Data& operator[](
const Cell& aCell );
755 bool operator()(
const Cell& aCell )
const;
763 void insertCell(
const Cell& aCell,
const Data& data = Data() );
773 void insertCell(
Dimension d,
const Cell& aCell,
const Data& data = Data() );
785 template <
typename CellConstIterator>
786 void insertCells( CellConstIterator it, CellConstIterator itE,
const Data& data = Data() );
799 template <
typename CellConstIterator>
800 void insertCells(
Dimension d, CellConstIterator it, CellConstIterator itE,
const Data& data = Data() );
806 bool belongs(
const Cell& aCell )
const;
813 bool belongs(
Dimension d,
const Cell& aCell )
const;
820 Size eraseCell(
const Cell& aCell );
828 Size eraseCell(
Dimension d,
const Cell& aCell );
834 void eraseCell( CellMapIterator it );
841 void eraseCells( CellMapIterator it, CellMapIterator itE );
852 template <
typename CellConstIterator>
853 Size eraseCells( CellConstIterator it, CellConstIterator itE );
865 template <
typename CellConstIterator>
866 Size eraseCells(
Dimension d, CellConstIterator it, CellConstIterator itE );
882 template <
typename CellOutputIterator>
883 void faces( CellOutputIterator& outIt,
const Cell& aCell,
884 bool hintClosed =
false )
const;
902 template <
typename CellOutputIterator>
903 void directFaces( CellOutputIterator& outIt,
const Cell& aCell,
904 bool hintClosed =
false )
const;
919 template <
typename CellMapIteratorOutputIterator>
920 void directFacesIterators( CellMapIteratorOutputIterator& outIt,
const Cell& aCell );
937 template <
typename CellOutputIterator>
938 void coFaces( CellOutputIterator& outIt,
const Cell& aCell,
939 bool hintOpen =
false )
const;
957 template <
typename CellOutputIterator>
958 void directCoFaces( CellOutputIterator& outIt,
const Cell& aCell,
959 bool hintOpen =
false )
const;
974 template <
typename CellMapIteratorOutputIterator>
975 void directCoFacesIterators( CellMapIteratorOutputIterator& outIt,
const Cell& aCell );
981 CellMapConstIterator begin(
Dimension d )
const;
987 CellMapConstIterator end(
Dimension d )
const;
1005 CellMapConstIterator findCell(
const Cell& aCell )
const;
1012 CellMapConstIterator findCell(
Dimension d,
const Cell& aCell )
const;
1018 CellMapIterator findCell(
const Cell& aCell );
1025 CellMapIterator findCell(
Dimension d,
const Cell& aCell );
1047 Cells cellBoundary(
const Cell& aCell,
bool hintClosed =
false )
const;
1065 Cells cellCoBoundary(
const Cell& aCell,
bool hintOpen =
false )
const;
1077 bool isCellInterior(
const Cell& aCell )
const;
1086 bool isCellBoundary(
const Cell& aCell )
const;
1111 CellType computeCellType(
const Cell& c, CellMapIterator& it_cell_up,
1151 bool hintClosed =
false )
const;
1226 void selfDisplay ( std::ostream & out )
const;
1232 bool isValid()
const;
1239 std::string className()
const;
1274 template <
typename TKSpace,
1275 typename TCellContainer >
1289 template <
typename TKSpace,
typename TCellContainer>
1299 #include "DGtal/topology/CubicalComplex.ih" 1304 #endif // !defined CubicalComplex_h 1306 #undef CubicalComplex_RECURSES 1307 #endif // else defined(CubicalComplex_RECURSES) bool equal(const Iterator &other) const
Cell const & const_reference
Dimension dimension() const
CellMap::iterator CellMapIterator
Iterator for visiting type CellMap.
bool operator()(const CellMapIterator &it1, const CellMapIterator &it2) const
boost::uint32_t uint32_t
unsigned 32-bit integer.
CellContainer::difference_type difference_type
KSpace::Integer Integer
Type for integers in the space.
MyDigitalSurface::ConstIterator ConstIterator
Cell const & dereference() const
Base::reference Reference
ConstIterator(ConstAlias< CubicalComplex > cc, Dimension d)
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
CellContainer::mapped_type Data
Type of data associated to each cell.
DGtal::uint32_t Dimension
const KSpace * myKSpace
The Khalimsky space in which lives the cubical complex.
CubicalCellData(uint32_t d)
boost::iterator_facade< ConstIterator, Cell const, std::forward_iterator_tag > Base
Cell const & dereference() const
TKSpace KSpace
Type of the cellular grid space.
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
CellMap::const_iterator CellMapConstIterator
Const iterator for visiting type CellMap.
KSpace::Cell Cell
Type for a cell in the space.
CellType
Possible cell types within a complex.
KForm< Calculus, order, duality > operator-(const KForm< Calculus, order, duality > &form_a, const KForm< Calculus, order, duality > &form_b)
CellContainer::size_type size_type
CubicalComplex< TKSpace, TCellContainer > Self
void insert(VContainer1 &c1, LContainer2 &c2, unsigned int idx, double v)
bool equal(const ConstIterator &other) const
Iterator()
Default iterator. Invalid.
TCellContainer CellContainer
Type for storing cells, an associative container Cell -> Data.
Base::reference Reference
Dimension dimension() const
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
const CubicalComplex * myCC
ConstIterator()
Default iterator. Invalid.
ConstIterator const_iterator
Base::difference_type DifferenceType
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.
Iterator(Alias< CubicalComplex > cc, Dimension d)
KSpace::DirIterator DirIterator
Type for iterating over cell directions.
DGtal is the top-level namespace which contains all DGtal functions and types.
CellMapConstIterator myItEnd
Aim: Defines the concept describing an Associative Container of the STL (https://www.sgi.com/tech/stl/AssociativeContainer.html).
unsigned int dim(const Vector &z)
Iterator(Alias< CubicalComplex > cc, Dimension d, CellMapIterator it)
SequenceCategory Category
KSpace::Point Point
Type for a point in the digital space.
ConstIterator(ConstAlias< CubicalComplex > cc, Dimension d, CellMapConstIterator it)
std::vector< CellMap > myCells
Base::difference_type DifferenceType
Aim: This concept describes a cellular grid space in nD. In these spaces obtained by cartesian produc...
KSpace::Cells Cells
Type for a sequence of cells in the space.
Cell const * const_pointer
void erase(VContainer1 &c1, LContainer2 &c2, unsigned int idx)
KSpace::Size Size
Type for a number of elements.
KForm< Calculus, order, duality > operator*(const typename Calculus::Scalar &scalar, const KForm< Calculus, order, duality > &form)
CellContainer CellMap
Type for storing cells, an associative container Cell -> Data.
boost::iterator_facade< Iterator, Cell const, std::forward_iterator_tag > Base
Defines default container traits for arbitrary types.
CellMapConstIterator myIt
KSpace::Space Space
Type of the digital space.