DGtal 1.4.0
Loading...
Searching...
No Matches
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)
34#define VoxelComplex_RECURSES
35
36#if !defined VoxelComplex_h
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
48namespace DGtal {
49
50// Forward definitions.
51template <typename TKSpace, typename TCellContainer>
52class VoxelComplex;
53
54template <typename TKSpace, typename TCellContainer>
55VoxelComplex<TKSpace, TCellContainer> &
56operator-=(VoxelComplex<TKSpace, TCellContainer> &,
57 const VoxelComplex<TKSpace, TCellContainer> &);
58template <typename TKSpace, typename TCellContainer>
59VoxelComplex<TKSpace, TCellContainer>
60operator-(const VoxelComplex<TKSpace, TCellContainer> &,
61 const VoxelComplex<TKSpace, TCellContainer> &);
62
64 // template class VoxelComplex
89template <typename TKSpace,
90 typename TCellContainer = typename TKSpace::template CellMap< CubicalCellData >::Type >
91class 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
181 template < typename TDigitalSet >
182 void construct(const TDigitalSet &input_set,
183 const Alias<ConfigMap> input_table);
184 using Parent::construct;
185
193 void setSimplicityTable(const Alias<ConfigMap> input_table);
194
201 void copySimplicityTable(const Self & other);
202
208 const ConfigMap &table() const;
209
215 const bool &isTableLoaded() const;
216
224 void voxelClose(const Cell &kcell);
225
232 void cellsClose(Dimension k_d, const Cells &cells);
233
241 void insertVoxelCell(const Cell &kcell, const bool &close_it = true,
242 const Data &data = Data());
243
250 void insertVoxelCell(const std::pair<Cell, Data> &data_pair,
251 const bool &close_it = true) {
252 insertVoxelCell(data_pair.first, close_it, data_pair.second);
253 }
254
263 void insertVoxelPoint(const Point &dig_point, const bool &close_it = true,
264 const Data &data = Data());
265
273 template<typename TDigitalSet>
274 void dumpVoxels(TDigitalSet & in_out_set) const;
275
276 //------ Spels ------//
287 void pointelsFromCell(std::set<Cell> &pointels_out,
288 const Cell &input_cell) const;
299 void spelsFromCell(std::set<Cell> &spels_out, const Cell &input_cell) const;
300
308 std::set<Cell> neighborhoodVoxels(const Cell &input_cell) const;
309
320 std::set<Cell> properNeighborhoodVoxels(const Cell &input_cell) const;
321
332 Clique Kneighborhood(const Cell &input_cell) const;
333
346 bool isSimpleByThinning(const Cell &input_spel) const;
355 bool isSimple(const Cell &input_spel) const;
356
357 //------ Cliques ------//
358 // Cliques, union of adjacent spels.
359 // The intersection of all spels of the clique define the type.
360 // 0-clique, 1-clique, 2-clique. 3-clique are isolated spels.
361 public:
370 std::pair<bool, Clique>
372 const CellMapConstIterator &cellMapIterator) const;
373
383 std::array<CliqueContainer, dimension + 1>
384 criticalCliques(const Parent &cubical, bool verbose = false) const {
385 ASSERT((dimension + 1) == 4);
386 std::array<CliqueContainer, dimension + 1> criticals;
387 if (verbose) {
388 trace.beginBlock("criticalCliques of CubicalComplex");
389 trace.info() << cubical << std::endl;
390 }
391 for (Dimension d = 0; d != dimension + 1; ++d)
392 criticals[d] = criticalCliquesForD(d, cubical, verbose);
393
394 if (verbose) {
395 trace.info() << std::endl;
396 trace.endBlock();
397 }
398 return criticals;
399 }
407 std::array<CliqueContainer, dimension + 1>
408 criticalCliques(bool verbose = false) const {
409 return criticalCliques(*this, verbose);
410 }
411
426 const Parent &cubical,
427 bool verbose = false) const;
428
440 std::pair<bool, Clique> K_2(const Cell &A, const Cell &B,
441 bool verbose = false) const;
452 std::pair<bool, Clique> K_2(const typename KSpace::Point &A,
453 const typename KSpace::Point &B,
454 bool verbose = false) const;
455
465 std::pair<bool, Clique> K_2(const Cell &face2, bool verbose = false) const;
466
475 std::pair<bool, Clique> K_1(const Cell &face1, bool verbose = false) const;
476
485 std::pair<bool, Clique> K_0(const Cell &face0, bool verbose = false) const;
486
498 std::pair<bool, Clique> K_3(const Cell &input_spel,
499 bool verbose = false) const;
507 bool isSpel(const Cell &c) const;
508
517 Cell surfelBetweenAdjacentSpels(const Cell &A, const Cell &B) const;
518
519 /*------------- Data --------------*/
520 protected:
525 bool myIsTableLoaded{false};
526
527 /*------------- Internal Methods --------------*/
537
538 // ----------------------- Interface --------------------------------------
539 public:
544 void selfDisplay(std::ostream &out) const;
545
550 bool isValid() const;
551
552 // --------------- CDrawableWithBoard2D realization ------------------
553 public:
557 std::string className() const;
558
559}; // end of class CubicalComplex
560
567template <typename TKSpace, typename TCellContainer>
568std::ostream &
569operator<<(std::ostream &out,
571
572} // namespace DGtal
573
575// Includes inline functions.
576#include "DGtal/topology/VoxelComplex.ih"
577
578// //
580
581#endif // !defined VoxelComplex_h
582
583#undef VoxelComplex_RECURSES
584#endif // else defined(VoxelComplex_RECURSES)
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition Alias.h:183
Aim: Smart or simple pointer on T. It can be a smart pointer based on reference counts or a simple po...
Aim: This class represents an arbitrary cubical complex living in some Khalimsky space....
void construct(const TDigitalSet &set)
TInteger Integer
Arithmetic ring induced by (+,-,*) and Integer numbers.
PointVector< dim, Integer > Point
NumberTraits< Integer >::UnsignedVersion Size
Type used to represent sizes in the digital space.
SpaceND< dim, Integer > Space
static const constexpr Dimension dimension
typename PreCellularGridSpace::DirIterator DirIterator
KhalimskyCell< dim, Integer > Cell
AnyCellCollection< Cell > Cells
void beginBlock(const std::string &keyword="")
std::ostream & info()
double endBlock()
This class represents a voxel complex living in some Khalimsky space. Voxel complexes are derived fro...
void dumpVoxels(TDigitalSet &in_out_set) const
typename KSpace::Point Point
typename CellMap::const_iterator CellMapConstIterator
std::pair< bool, Clique > K_2(const Cell &face2, bool verbose=false) const
typename CellContainer::mapped_type Data
std::unordered_map< Point, unsigned int > PointToMaskMap
void insertVoxelCell(const std::pair< Cell, Data > &data_pair, const bool &close_it=true)
std::pair< bool, Clique > K_1(const Cell &face1, bool verbose=false) const
std::pair< bool, Clique > criticalCliquePair(const Dimension d, const CellMapConstIterator &cellMapIterator) const
void cellsClose(Dimension k_d, const Cells &cells)
typename KSpace::Space Space
bool isValid() const
typename KSpace::Integer Integer
void copySimplicityTable(const Self &other)
std::set< Cell > properNeighborhoodVoxels(const Cell &input_cell) const
void setSimplicityTable(const Alias< ConfigMap > input_table)
void voxelClose(const Cell &kcell)
CubicalComplex< TKSpace, TCellContainer > Parent
std::pair< bool, Clique > K_2(const typename KSpace::Point &A, const typename KSpace::Point &B, bool verbose=false) const
const ConfigMap & table() const
const bool & isTableLoaded() const
std::array< CliqueContainer, dimension+1 > criticalCliques(const Parent &cubical, bool verbose=false) const
VoxelComplex(const VoxelComplex &other)
bool myIsTableLoaded
Flag if using a LUT for simplicity.
Clique Kneighborhood(const Cell &input_cell) const
CliqueContainer criticalCliquesForD(const Dimension d, const Parent &cubical, bool verbose=false) const
const PointToMaskMap & pointToMask() const
std::pair< bool, Clique > K_3(const Cell &input_spel, bool verbose=false) const
std::set< Cell > neighborhoodVoxels(const Cell &input_cell) const
std::pair< bool, Clique > K_0(const Cell &face0, bool verbose=false) const
void insertVoxelPoint(const Point &dig_point, const bool &close_it=true, const Data &data=Data())
TCellContainer CellContainer
CountedPtrOrPtr< PointToMaskMap > myPointToMaskPtr
CountedPtrOrPtr< ConfigMap > myTablePtr
void construct(const TDigitalSet &input_set, const Alias< ConfigMap > input_table)
Self & operator=(const Self &other)
typename KSpace::DirIterator DirIterator
std::pair< bool, Clique > K_2(const Cell &A, const Cell &B, bool verbose=false) const
bool isSpel(const Cell &c) const
std::array< CliqueContainer, dimension+1 > criticalCliques(bool verbose=false) const
bool isSimple(const Cell &input_spel) const
static const Dimension dimension
The dimension of the embedding space.
void pointelsFromCell(std::set< Cell > &pointels_out, const Cell &input_cell) const
void spelsFromCell(std::set< Cell > &spels_out, const Cell &input_cell) const
CellContainer CellMap
Cell surfelBetweenAdjacentSpels(const Cell &A, const Cell &B) const
boost::dynamic_bitset<> ConfigMap
void selfDisplay(std::ostream &out) const
bool isSimpleByThinning(const Cell &input_spel) const
void insertVoxelCell(const Cell &kcell, const bool &close_it=true, const Data &data=Data())
typename KSpace::Cell Cell
std::string className() const
typename CellMap::iterator CellMapIterator
typename Cell::PreCell PreCell
std::vector< Clique > CliqueContainer
typename KSpace::Cells Cells
typename KSpace::Size Size
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
DGtal::uint32_t Dimension
Definition Common.h:136
Trace trace
Definition Common.h:153
KForm< Calculus, order, duality > operator-(const KForm< Calculus, order, duality > &form_a, const KForm< Calculus, order, duality > &form_b)
CubicalComplex< TKSpace, TCellContainer > & operator-=(CubicalComplex< TKSpace, TCellContainer > &, const CubicalComplex< TKSpace, TCellContainer > &)
KhalimskyPreCell< dim, Integer > PreCell