DGtal  1.1.0
VoxelComplex.h
1 
17 #pragma once
18 
30 #if defined(VoxelComplex_RECURSES)
31 #error Recursive header files inclusion detected in VoxelComplex.h
32 #else // defined(VoxelComplex_RECURSES)
33 
34 #define VoxelComplex_RECURSES
35 
36 #if !defined VoxelComplex_h
37 
38 #define VoxelComplex_h
39 
41 // Inclusions
42 #include "boost/dynamic_bitset.hpp"
43 #include <DGtal/kernel/sets/DigitalSetBySTLSet.h>
44 #include <DGtal/topology/CubicalComplex.h>
45 #include <DGtal/topology/DigitalTopology.h>
46 #include <DGtal/topology/Object.h>
47 
48 namespace DGtal {
49 
50 // Forward definitions.
51 template <typename TKSpace, typename TCellContainer>
52 class VoxelComplex;
53 
54 template <typename TKSpace, typename TCellContainer>
55 VoxelComplex<TKSpace, TCellContainer> &
56 operator-=(VoxelComplex<TKSpace, TCellContainer> &,
57  const VoxelComplex<TKSpace, TCellContainer> &);
58 template <typename TKSpace, typename TCellContainer>
59 VoxelComplex<TKSpace, TCellContainer>
60 operator-(const VoxelComplex<TKSpace, TCellContainer> &,
61  const VoxelComplex<TKSpace, TCellContainer> &);
62 
64  // template class VoxelComplex
89 template <typename TKSpace,
90  typename TCellContainer = typename TKSpace::template CellMap< CubicalCellData >::Type >
91 class VoxelComplex : public CubicalComplex<TKSpace, TCellContainer> {
92  public:
95 
96  friend Self &DGtal::operator-=<>(Self &, const Self &);
97  friend Self DGtal::operator-<>(const Self &, const Self &);
98  // ----------------------- associated types ------------------------------
102  using KSpace = TKSpace;
104  using CellContainer = TCellContainer;
106  using Data = typename CellContainer::mapped_type;
107 
110 
112  using Integer = typename KSpace::Integer;
114  using Cell = typename KSpace::Cell;
116  using PreCell = typename Cell::PreCell;
118  using Cells = typename KSpace::Cells;
120  using Space = typename KSpace::Space;
122  using Size = typename KSpace::Size;
124  using Point = typename KSpace::Point;
130  using CellMapConstIterator = typename CellMap::const_iterator;
132  using CellMapIterator = typename CellMap::iterator;
133 
134  // Clique alias
135  using Clique = Parent;
136  using CliqueContainer = std::vector<Clique>;
137 
138  // Tables
139  using ConfigMap = boost::dynamic_bitset<>;
140  using PointToMaskMap = std::unordered_map<Point, unsigned int>;
141 
142  protected:
149  public:
152 
158  VoxelComplex( const VoxelComplex & other );
159 
165  Self &operator=(const Self &other);
166 
173  template < typename TDigitalSet >
174  void construct(const TDigitalSet &input_set);
175 
190  template < typename TDigitalSet >
191  void construct(const TDigitalSet &input_set,
192  const Alias<ConfigMap> input_table);
193 
201  void setSimplicityTable(const Alias<ConfigMap> input_table);
202 
209  void copySimplicityTable(const Self & other);
210 
216  const ConfigMap &table() const;
217 
223  const bool &isTableLoaded() const;
224 
232  void voxelClose(const Cell &kcell);
233 
240  void cellsClose(Dimension k_d, const Cells &cells);
241 
249  void insertVoxelCell(const Cell &kcell, const bool &close_it = true,
250  const Data &data = Data());
251 
258  void insertVoxelCell(const std::pair<Cell, Data> &data_pair,
259  const bool &close_it = true) {
260  insertVoxelCell(data_pair.first, close_it, data_pair.second);
261  }
262 
271  void insertVoxelPoint(const Point &dig_point, const bool &close_it = true,
272  const Data &data = Data());
273 
281  template<typename TDigitalSet>
282  void dumpVoxels(TDigitalSet & in_out_set);
283 
288  void clear();
289 
294  void clear( Dimension d );
295 
300  void erase( typename Parent::Iterator position );
301 
307  Size erase( const Cell& aCell );
308 
314  void erase( typename Parent::Iterator first, typename Parent::Iterator last );
315 
316  //------ Spels ------//
327  void pointelsFromCell(std::set<Cell> &pointels_out,
328  const Cell &input_cell) const;
339  void spelsFromCell(std::set<Cell> &spels_out, const Cell &input_cell) const;
340 
348  std::set<Cell> neighborhoodVoxels(const Cell &input_cell) const;
349 
360  std::set<Cell> properNeighborhoodVoxels(const Cell &input_cell) const;
361 
372  Clique Kneighborhood(const Cell &input_cell) const;
373 
386  bool isSimpleByThinning(const Cell &input_spel) const;
400  bool isSimple(const Cell &input_spel) const;
401 
402  //------ Cliques ------//
403  // Cliques, union of adjacent spels.
404  // The intersection of all spels of the clique define the type.
405  // 0-clique, 1-clique, 2-clique. 3-clique are isolated spels.
406  public:
415  std::pair<bool, Clique>
417  const CellMapConstIterator &cellMapIterator) const;
418 
428  std::array<CliqueContainer, dimension + 1>
429  criticalCliques(const Parent &cubical, bool verbose = false) const {
430  ASSERT((dimension + 1) == 4);
431  std::array<CliqueContainer, dimension + 1> criticals;
432  if (verbose) {
433  trace.beginBlock("criticalCliques of CubicalComplex");
434  trace.info() << cubical << std::endl;
435  }
436  for (size_t d = 0; d != dimension + 1; ++d)
437  criticals[d] = criticalCliquesForD(d, cubical, verbose);
438 
439  if (verbose) {
440  trace.info() << std::endl;
441  trace.endBlock();
442  }
443  return criticals;
444  }
452  std::array<CliqueContainer, dimension + 1>
453  criticalCliques(bool verbose = false) const {
454  return criticalCliques(*this, verbose);
455  }
456 
471  const Parent &cubical,
472  bool verbose = false) const;
473 
485  std::pair<bool, Clique> K_2(const Cell &A, const Cell &B,
486  bool verbose = false) const;
497  std::pair<bool, Clique> K_2(const typename KSpace::Point &A,
498  const typename KSpace::Point &B,
499  bool verbose = false) const;
500 
510  std::pair<bool, Clique> K_2(const Cell &face2, bool verbose = false) const;
511 
520  std::pair<bool, Clique> K_1(const Cell &face1, bool verbose = false) const;
521 
530  std::pair<bool, Clique> K_0(const Cell &face0, bool verbose = false) const;
531 
543  std::pair<bool, Clique> K_3(const Cell &input_spel,
544  bool verbose = false) const;
552  bool isSpel(const Cell &c) const;
553 
562  Cell surfelBetweenAdjacentSpels(const Cell &A, const Cell &B) const;
563 
564  /*------------- Data --------------*/
565  protected:
570  bool myIsTableLoaded{false};
571 
572  /*------------- Internal Methods --------------*/
581  const PointToMaskMap &pointToMask() const;
582 
583  // ----------------------- Interface --------------------------------------
584  public:
589  void selfDisplay(std::ostream &out) const;
590 
595  bool isValid() const;
596 
597  // --------------- CDrawableWithBoard2D realization ------------------
598  public:
602  std::string className() const;
603 
604 }; // end of class CubicalComplex
605 
612 template <typename TKSpace, typename TCellContainer>
613 std::ostream &
614 operator<<(std::ostream &out,
616 
617 } // namespace DGtal
618 
620 // Includes inline functions.
621 #include "DGtal/topology/VoxelComplex.ih"
622 
623 // //
625 
626 #endif // !defined VoxelComplex_h
627 
628 #undef VoxelComplex_RECURSES
629 #endif // else defined(VoxelComplex_RECURSES)
DGtal::VoxelComplex< KSpace >::KSpace
KSpace KSpace
Definition: VoxelComplex.h:102
DGtal::CubicalComplex::Iterator
Definition: CubicalComplex.h:414
DGtal::VoxelComplex::isTableLoaded
const bool & isTableLoaded() const
DGtal::VoxelComplex::properNeighborhoodVoxels
std::set< Cell > properNeighborhoodVoxels(const Cell &input_cell) const
DGtal::KhalimskySpaceND::dimension
static constexpr const Dimension dimension
Definition: KhalimskySpaceND.h:430
DGtal::operator-
KForm< Calculus, order, duality > operator-(const KForm< Calculus, order, duality > &form_a, const KForm< Calculus, order, duality > &form_b)
DGtal::Trace::endBlock
double endBlock()
DGtal::VoxelComplex< KSpace >::CliqueContainer
std::vector< Clique > CliqueContainer
Definition: VoxelComplex.h:136
DGtal::VoxelComplex< KSpace >::Size
typename KSpace::Size Size
Definition: VoxelComplex.h:122
DGtal::KhalimskySpaceND::Cells
AnyCellCollection< Cell > Cells
Definition: KhalimskySpaceND.h:439
DGtal::trace
Trace trace
Definition: Common.h:150
DGtal::VoxelComplex::neighborhoodVoxels
std::set< Cell > neighborhoodVoxels(const Cell &input_cell) const
DGtal::Dimension
DGtal::uint32_t Dimension
Definition: Common.h:133
DGtal::VoxelComplex::clear
void clear()
DGtal::VoxelComplex< KSpace >::PreCell
typename Cell::PreCell PreCell
Definition: VoxelComplex.h:116
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::VoxelComplex::clear
void clear(Dimension d)
DGtal::VoxelComplex< KSpace >::DirIterator
typename KSpace::DirIterator DirIterator
Definition: VoxelComplex.h:126
DGtal::VoxelComplex
This class represents a voxel complex living in some Khalimsky space. Voxel complexes are derived fro...
Definition: VoxelComplex.h:91
DGtal::VoxelComplex::myPointToMaskPtr
CountedPtrOrPtr< PointToMaskMap > myPointToMaskPtr
Definition: VoxelComplex.h:569
DGtal::VoxelComplex::Parent
CubicalComplex< TKSpace, TCellContainer > Parent
Definition: VoxelComplex.h:100
DGtal::VoxelComplex::myIsTableLoaded
bool myIsTableLoaded
Flag if using a LUT for simplicity.
Definition: VoxelComplex.h:570
DGtal::VoxelComplex::dumpVoxels
void dumpVoxels(TDigitalSet &in_out_set)
DGtal::VoxelComplex::insertVoxelPoint
void insertVoxelPoint(const Point &dig_point, const bool &close_it=true, const Data &data=Data())
DGtal::VoxelComplex::criticalCliques
std::array< CliqueContainer, dimension+1 > criticalCliques(const Parent &cubical, bool verbose=false) const
Definition: VoxelComplex.h:429
DGtal::KhalimskyCell< dim, Integer >::PreCell
KhalimskyPreCell< dim, Integer > PreCell
Definition: KhalimskySpaceND.h:94
DGtal::VoxelComplex< KSpace >::CellMap
CellContainer CellMap
Definition: VoxelComplex.h:128
DGtal::KhalimskySpaceND::Cell
KhalimskyCell< dim, Integer > Cell
Definition: KhalimskySpaceND.h:415
DGtal::operator-=
CubicalComplex< TKSpace, TCellContainer > & operator-=(CubicalComplex< TKSpace, TCellContainer > &, const CubicalComplex< TKSpace, TCellContainer > &)
Definition: CubicalComplexFunctions.h:97
DGtal::KhalimskySpaceND::Point
PointVector< dim, Integer > Point
Definition: KhalimskySpaceND.h:425
DGtal::Trace::info
std::ostream & info()
DGtal::VoxelComplex< KSpace >::Space
typename KSpace::Space Space
Definition: VoxelComplex.h:120
DGtal::VoxelComplex::construct
void construct(const TDigitalSet &input_set, const Alias< ConfigMap > input_table)
DGtal::VoxelComplex::insertVoxelCell
void insertVoxelCell(const std::pair< Cell, Data > &data_pair, const bool &close_it=true)
Definition: VoxelComplex.h:258
DGtal::VoxelComplex::pointToMask
const PointToMaskMap & pointToMask() const
DGtal::KhalimskySpaceND::Size
NumberTraits< Integer >::UnsignedVersion Size
Type used to represent sizes in the digital space.
Definition: KhalimskySpaceND.h:407
DGtal::VoxelComplex::isSimpleByThinning
bool isSimpleByThinning(const Cell &input_spel) const
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
DGtal::VoxelComplex::erase
Size erase(const Cell &aCell)
DGtal::VoxelComplex< KSpace >::CellContainer
typename TKSpace::template CellMap< CubicalCellData >::Type CellContainer
Definition: VoxelComplex.h:104
DGtal::KhalimskySpaceND::Space
SpaceND< dim, Integer > Space
Definition: KhalimskySpaceND.h:410
DGtal::CountedPtrOrPtr< ConfigMap >
DGtal::VoxelComplex::criticalCliquesForD
CliqueContainer criticalCliquesForD(const Dimension d, const Parent &cubical, bool verbose=false) const
DGtal::VoxelComplex::dimension
static const Dimension dimension
The dimension of the embedding space.
Definition: VoxelComplex.h:109
DGtal::VoxelComplex::erase
void erase(typename Parent::Iterator position)
DGtal::VoxelComplex::voxelClose
void voxelClose(const Cell &kcell)
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
DGtal::VoxelComplex::K_3
std::pair< bool, Clique > K_3(const Cell &input_spel, bool verbose=false) const
DGtal::VoxelComplex::cellsClose
void cellsClose(Dimension k_d, const Cells &cells)
DGtal::VoxelComplex::Kneighborhood
Clique Kneighborhood(const Cell &input_cell) const
DGtal::VoxelComplex::table
const ConfigMap & table() const
DGtal::VoxelComplex::erase
void erase(typename Parent::Iterator first, typename Parent::Iterator last)
DGtal::VoxelComplex::myTablePtr
CountedPtrOrPtr< ConfigMap > myTablePtr
Definition: VoxelComplex.h:567
DGtal::VoxelComplex< KSpace >::Cells
typename KSpace::Cells Cells
Definition: VoxelComplex.h:118
DGtal::VoxelComplex::criticalCliques
std::array< CliqueContainer, dimension+1 > criticalCliques(bool verbose=false) const
Definition: VoxelComplex.h:453
DGtal::KhalimskySpaceND::DirIterator
typename PreCellularGridSpace::DirIterator DirIterator
Definition: KhalimskySpaceND.h:422
DGtal::VoxelComplex::K_0
std::pair< bool, Clique > K_0(const Cell &face0, bool verbose=false) const
DGtal::VoxelComplex::K_2
std::pair< bool, Clique > K_2(const typename KSpace::Point &A, const typename KSpace::Point &B, bool verbose=false) const
DGtal::VoxelComplex::isSpel
bool isSpel(const Cell &c) const
DGtal::VoxelComplex::VoxelComplex
VoxelComplex(const VoxelComplex &other)
DGtal::VoxelComplex::K_2
std::pair< bool, Clique > K_2(const Cell &face2, bool verbose=false) const
DGtal::VoxelComplex::operator=
Self & operator=(const Self &other)
DGtal::VoxelComplex::isValid
bool isValid() const
DGtal::VoxelComplex::construct
void construct(const TDigitalSet &input_set)
DGtal::VoxelComplex::K_1
std::pair< bool, Clique > K_1(const Cell &face1, bool verbose=false) const
DGtal::VoxelComplex< KSpace >::Integer
typename KSpace::Integer Integer
Definition: VoxelComplex.h:112
DGtal::VoxelComplex< KSpace >::Data
typename CellContainer::mapped_type Data
Definition: VoxelComplex.h:106
DGtal::PointVector< dim, Integer >
DGtal::VoxelComplex::insertVoxelCell
void insertVoxelCell(const Cell &kcell, const bool &close_it=true, const Data &data=Data())
DGtal::VoxelComplex::spelsFromCell
void spelsFromCell(std::set< Cell > &spels_out, const Cell &input_cell) const
DGtal::Alias
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: Alias.h:183
DGtal::VoxelComplex::criticalCliquePair
std::pair< bool, Clique > criticalCliquePair(const Dimension d, const CellMapConstIterator &cellMapIterator) const
DGtal::VoxelComplex::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::KhalimskySpaceND::Integer
TInteger Integer
Arithmetic ring induced by (+,-,*) and Integer numbers.
Definition: KhalimskySpaceND.h:404
DGtal::VoxelComplex::setSimplicityTable
void setSimplicityTable(const Alias< ConfigMap > input_table)
DGtal::VoxelComplex< KSpace >::ConfigMap
boost::dynamic_bitset<> ConfigMap
Definition: VoxelComplex.h:139
DGtal::VoxelComplex::pointelsFromCell
void pointelsFromCell(std::set< Cell > &pointels_out, const Cell &input_cell) const
DGtal::VoxelComplex::copySimplicityTable
void copySimplicityTable(const Self &other)
DGtal::VoxelComplex< KSpace >::Point
typename KSpace::Point Point
Definition: VoxelComplex.h:124
DGtal::VoxelComplex::isSimple
bool isSimple(const Cell &input_spel) const
DGtal::CubicalComplex
Aim: This class represents an arbitrary cubical complex living in some Khalimsky space....
Definition: CubicalComplex.h:176
DGtal::VoxelComplex::surfelBetweenAdjacentSpels
Cell surfelBetweenAdjacentSpels(const Cell &A, const Cell &B) const
DGtal::VoxelComplex< KSpace >::CellMapConstIterator
typename CellMap::const_iterator CellMapConstIterator
Definition: VoxelComplex.h:130
DGtal::VoxelComplex< KSpace >::Cell
typename KSpace::Cell Cell
Definition: VoxelComplex.h:114
DGtal::VoxelComplex::VoxelComplex
VoxelComplex()
DGtal::VoxelComplex::K_2
std::pair< bool, Clique > K_2(const Cell &A, const Cell &B, bool verbose=false) const
DGtal::VoxelComplex< KSpace >::PointToMaskMap
std::unordered_map< Point, unsigned int > PointToMaskMap
Definition: VoxelComplex.h:140
DGtal::VoxelComplex::className
std::string className() const
DGtal::VoxelComplex< KSpace >::CellMapIterator
typename CellMap::iterator CellMapIterator
Definition: VoxelComplex.h:132