DGtal  0.9.4.1
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 TObject, typename TCellContainer>
53 namespace functions {
54 template <typename TKSpace, typename TObject, typename TCellContainer>
58 template <typename TKSpace, typename TObject, typename TCellContainer>
62 
63 } // namespace functions
65  // template class VoxelComplex
90 template <typename TKSpace, typename TObject,
91  typename TCellContainer = typename TKSpace::template CellMap< CubicalCellData >::Type >
92 class VoxelComplex : public CubicalComplex<TKSpace, TCellContainer> {
93  public:
94  // The TObject::DigitalSet::Container must be associative.
96  typename TObject::DigitalSet::Container>));
97 
100 
101  friend Self &DGtal::functions::operator-=<>(Self &, const Self &);
102  friend Self DGtal::functions::operator-<>(const Self &, const Self &);
103  // ----------------------- associated types ------------------------------
107  using KSpace = TKSpace;
109  using CellContainer = TCellContainer;
111  using Data = typename CellContainer::mapped_type;
113  using Object = TObject;
115  using DigitalTopology = typename TObject::DigitalTopology;
116 
119 
121  using Integer = typename KSpace::Integer;
123  using Cell = typename KSpace::Cell;
125  using Cells = typename KSpace::Cells;
127  using Space = typename KSpace::Space;
129  using Size = typename KSpace::Size;
131  using Point = typename KSpace::Point;
137  using CellMapConstIterator = typename CellMap::const_iterator;
139  using CellMapIterator = typename CellMap::iterator;
140 
141  // Clique alias
142  using Clique = Parent;
143  using CliqueContainer = std::vector<Clique>;
144 
145  // Tables
146  using ConfigMap = boost::dynamic_bitset<>;
147  using PointToMaskMap = std::unordered_map<Point, unsigned int>;
148 
149  protected:
155  VoxelComplex();
156  public:
159 
165  VoxelComplex( const VoxelComplex & other );
166 
172  Self &operator=(const Self &other);
173 
180  void construct(const TObject &obj);
181 
196  void construct(const typename Object::DigitalSet &input_set,
197  const Alias<ConfigMap> input_table);
198 
206  void setSimplicityTable(const Alias<ConfigMap> input_table);
207 
213  const ConfigMap &table() const;
214 
220  const bool &isTableLoaded() const;
221 
229  void voxelClose(const Cell &kcell);
230 
237  void cellsClose(Dimension k_d, const Cells &cells);
238 
246  void insertVoxelCell(const Cell &kcell, const bool &close_it = true,
247  const Data &data = Data());
248 
255  void insertVoxelCell(const std::pair<Cell, Data> &data_pair,
256  const bool &close_it = true) {
257  insertVoxelCell(data_pair.first, close_it, data_pair.second);
258  }
259 
268  void insertVoxelPoint(const Point &dig_point, const bool &close_it = true,
269  const Data &data = Data());
270 
275  void clear();
276 
285  const typename Object::Point &objPointFromVoxel(const Cell &voxel) const;
286  //------ Spels ------//
297  void pointelsFromCell(std::set<Cell> &pointels_out,
298  const Cell &input_cell) const;
309  void spelsFromCell(std::set<Cell> &spels_out, const Cell &input_cell) const;
310 
321  Clique Kneighborhood(const Cell &input_cell) const;
322 
330 
344  bool isSimple(const Cell &input_spel) const;
345 
353  bool isConnected() const;
354 
358  Object &object();
362  const Object &object() const;
363 
367  typename Object::DigitalSet &objectSet();
368 
372  const typename Object::DigitalSet &objectSet() const;
373 
374  //------ Cliques ------//
375  // Cliques, union of adjacent spels.
376  // The intersection of all spels of the clique define the type.
377  // 0-clique, 1-clique, 2-clique. 3-clique are isolated spels.
378  public:
387  std::pair<bool, Clique>
389  const CellMapConstIterator &cellMapIterator) const;
390 
400  std::array<CliqueContainer, dimension + 1>
401  criticalCliques(const Parent &cubical, bool verbose = false) const {
402  ASSERT((dimension + 1) == 4);
403  std::array<CliqueContainer, dimension + 1> criticals;
404  if (verbose) {
405  trace.beginBlock("criticalCliques of CubicalComplex");
406  trace.info() << cubical << std::endl;
407  }
408  for (size_t d = 0; d != dimension + 1; ++d)
409  criticals[d] = criticalCliquesForD(d, cubical, verbose);
410 
411  if (verbose) {
412  trace.info() << std::endl;
413  trace.endBlock();
414  }
415  return criticals;
416  }
424  std::array<CliqueContainer, dimension + 1>
425  criticalCliques(bool verbose = false) const {
426  return criticalCliques(*this, verbose);
427  }
428 
443  const Parent &cubical,
444  bool verbose = false) const;
445 
457  std::pair<bool, Clique> K_2(const Cell &A, const Cell &B,
458  bool verbose = false) const;
469  std::pair<bool, Clique> K_2(const typename Object::Point &A,
470  const typename Object::Point &B,
471  bool verbose = false) const;
472 
482  std::pair<bool, Clique> K_2(const Cell &face2, bool verbose = false) const;
483 
492  std::pair<bool, Clique> K_1(const Cell &face1, bool verbose = false) const;
493 
502  std::pair<bool, Clique> K_0(const Cell &face0, bool verbose = false) const;
503 
515  std::pair<bool, Clique> K_3(const Cell &input_spel,
516  bool verbose = false) const;
524  bool isSpel(const Cell &c) const;
525 
534  Cell surfelBetweenAdjacentSpels(const Cell &A, const Cell &B) const;
535 
536  /*------------- Data --------------*/
537  protected:
544  bool myIsTableLoaded{false};
545 
546  /*------------- Internal Methods --------------*/
555  const PointToMaskMap &pointToMask() const;
556 
563  void instantiateEmptyObject(const typename Object::DigitalSet &dig_set);
564 
565  // ----------------------- Interface --------------------------------------
566  public:
571  void selfDisplay(std::ostream &out) const;
572 
577  bool isValid() const;
578 
579  // --------------- CDrawableWithBoard2D realization ------------------
580  public:
584  std::string className() const;
585 
586 }; // end of class CubicalComplex
587 
594 template <typename TKSpace, typename TObject, typename TCellContainer>
595 std::ostream &
596 operator<<(std::ostream &out,
597  const VoxelComplex<TKSpace, TObject, TCellContainer> &object);
598 
599 } // namespace DGtal
600 
602 // Includes inline functions.
603 #include "DGtal/topology/VoxelComplex.ih"
604 
605 // //
607 
608 #endif // !defined VoxelComplex_h
609 
610 #undef VoxelComplex_RECURSES
611 #endif // else defined(VoxelComplex_RECURSES)
Aim: An object (or digital object) represents a set in some digital space associated with a digital t...
Definition: Object.h:119
void beginBlock(const std::string &keyword="")
void insertVoxelCell(const std::pair< Cell, Data > &data_pair, const bool &close_it=true)
Definition: VoxelComplex.h:255
void selfDisplay(std::ostream &out) const
std::array< CliqueContainer, dimension+1 > criticalCliques(bool verbose=false) const
Definition: VoxelComplex.h:425
DigitalSet::Point Point
Definition: Object.h:141
Trace trace
Definition: Common.h:137
typename CellContainer::mapped_type Data
Definition: VoxelComplex.h:111
Aim: SpaceND is a utility class that defines the fundamental structure of a Digital Space in ND...
Definition: SpaceND.h:95
void insertVoxelPoint(const Point &dig_point, const bool &close_it=true, const Data &data=Data())
const Object::Point & objPointFromVoxel(const Cell &voxel) const
CellContainer::mapped_type Data
Type of data associated to each cell.
void setSimplicityTable(const Alias< ConfigMap > input_table)
DGtal::uint32_t Dimension
Definition: Common.h:120
CubicalComplex< TKSpace, TCellContainer > & operator-=(CubicalComplex< TKSpace, TCellContainer > &, const CubicalComplex< TKSpace, TCellContainer > &)
TDigitalSet DigitalSet
Definition: Object.h:123
void insertVoxelCell(const Cell &kcell, const bool &close_it=true, const Data &data=Data())
bool isSpel(const Cell &c) const
const bool & isTableLoaded() const
This class represents a voxel complex living in some Khalimsky space. Voxel complexes are derived fro...
Definition: VoxelComplex.h:52
CountedPtrOrPtr< PointToMaskMap > myPointToMaskPtr
Definition: VoxelComplex.h:543
void construct(const TObject &obj)
double endBlock()
std::pair< bool, Clique > K_0(const Cell &face0, bool verbose=false) const
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: Alias.h:182
void voxelClose(const Cell &kcell)
CellMap::const_iterator CellMapConstIterator
Const iterator for visiting type CellMap.
NumberTraits< Integer >::UnsignedVersion Size
Type used to represent sizes in the digital space.
TCellContainer CellContainer
Definition: VoxelComplex.h:109
bool isConnected() const
std::unordered_map< Point, unsigned int > PointToMaskMap
Definition: VoxelComplex.h:147
typename KSpace ::template CellMap< CubicalCellData >::Type CellContainer
Type for storing cells, an associative container Cell -> Data.
CC::CellMapConstIterator CellMapConstIterator
CountedPtrOrPtr< ConfigMap > myTablePtr
Definition: VoxelComplex.h:541
BOOST_CONCEPT_ASSERT((concepts::CSTLAssociativeContainer< typename TObject::DigitalSet::Container >))
Cell surfelBetweenAdjacentSpels(const Cell &A, const Cell &B) const
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
bool isValid() const
KhalimskyCell< dim, Integer > Cell
std::pair< bool, Clique > K_2(const Cell &A, const Cell &B, bool verbose=false) const
CliqueContainer criticalCliquesForD(const Dimension d, const Parent &cubical, bool verbose=false) const
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.
CubicalComplex< TKSpace, TCellContainer > Parent
Definition: VoxelComplex.h:105
SpaceND< dim, Integer > Space
KSpace::DirIterator DirIterator
Type for iterating over cell directions.
DGtal is the top-level namespace which contains all DGtal functions and types.
MyPointD Point
Definition: testClone2.cpp:383
Object::DigitalSet & objectSet()
Aim: Defines the concept describing an Associative Container of the STL (https://www.sgi.com/tech/stl/AssociativeContainer.html).
std::ostream & info()
const Object & populateObjectFromCells()
bool isSimple(const Cell &input_spel) const
const PointToMaskMap & pointToMask() const
void instantiateEmptyObject(const typename Object::DigitalSet &dig_set)
void cellsClose(Dimension k_d, const Cells &cells)
PointVector< dim, Integer > Point
CubicalComplex< TKSpace, TCellContainer > operator-(const CubicalComplex< TKSpace, TCellContainer > &, const CubicalComplex< TKSpace, TCellContainer > &)
std::string className() const
bool myIsTableLoaded
Flag if using a LUT for simplicity.
Definition: VoxelComplex.h:544
std::pair< bool, Clique > K_1(const Cell &face1, bool verbose=false) const
const ConfigMap & table() const
std::pair< bool, Clique > K_3(const Cell &input_spel, bool verbose=false) const
typename PreCellularGridSpace::DirIterator DirIterator
typename FixtureObject ::DigitalTopology DigitalTopology
Definition: VoxelComplex.h:115
Clique Kneighborhood(const Cell &input_cell) const
static const constexpr Dimension dimension
CellContainer CellMap
Type for storing cells, an associative container Cell -> Data.
void spelsFromCell(std::set< Cell > &spels_out, const Cell &input_cell) const
void pointelsFromCell(std::set< Cell > &pointels_out, const Cell &input_cell) const
Self & operator=(const Self &other)
AnyCellCollection< Cell > Cells
TInteger Integer
Arithmetic ring induced by (+,-,*) and Integer numbers.
std::pair< bool, Clique > criticalCliquePair(const Dimension d, const CellMapConstIterator &cellMapIterator) const
std::array< CliqueContainer, dimension+1 > criticalCliques(const Parent &cubical, bool verbose=false) const
Definition: VoxelComplex.h:401
static const Dimension dimension
The dimension of the embedding space.
Definition: VoxelComplex.h:118