|
DGtal 2.1.0
|
A DigitalSet that stores voxels as an octree, or a DAG. More...
#include <DGtal/kernel/sets/DigitalSetByOctree.h>
Data Structures | |
| struct | Node |
| Node for octree. More... | |
| struct | ComputationCacheKey |
| Helper struct for computing local estimators. More... | |
| struct | TraversalMemory |
| Helper struct to store traversal and go to next leaf. More... | |
| struct | OctreeIterator |
| Iterator over the octree. More... | |
Public Types | |
| using | DimIndex = std::uint8_t |
| using | CellIndex = typename Space::UnsignedInteger |
| using | Size = size_t |
| using | Domain = HyperRectDomain<Space> |
| using | Point = typename Domain::Point |
| using | Value = void |
| using | Iterator = OctreeIterator |
| using | ConstIterator = OctreeIterator |
Public Member Functions | |
| DigitalSetByOctree (const Domain &d) | |
| Constructor from a domain. | |
| const Domain & | domain () const |
| Returns the domain of the digital set. | |
| CowPtr< Domain > | domainPointer () const |
| Returns the domain of the voxels. | |
| void | insert (const Point &p) |
| Inserts a new point in the octree. | |
| void | insertNew (const Point &p) |
| Inserts a new point in the octree. | |
| bool | operator() (const Point &p) const |
| Check if a voxel is set or not. | |
| Iterator | find (const Point &p) const |
| Finds a point within the Octree. | |
| size_t | size () const |
| Returns the number of voxel in the set. | |
| bool | empty () const |
| Check if the octree is empty or not. | |
| size_t | memoryFootprint () const |
| Returns the memory occupied by node storage in bytes. | |
| void | clear () |
| Removes all nodes from the octree. | |
| size_t | erase (const Iterator &it) |
| Remove a voxel from the octree. | |
| size_t | erase (Iterator begin, Iterator end) |
| Removes a range of voxels. | |
| size_t | erase (const Point &p) |
| Removes a voxel from the octree. | |
| void | shrinkToFit () |
| Shrinks storage to reduce memory usage. | |
| DigitalSetByOctree & | operator+= (const DigitalSetByOctree &other) |
| Appends an octree to another. | |
| template<typename It> | |
| void | computeComplement (It out) const |
| Computes the complement of the octree. | |
| template<class DSet> | |
| void | assignFromComplement (const DSet &other) |
| Assigns the octree as the complement of another set. | |
| void | computeBoundingBox (Point &lb, Point &ub) const |
| Computes the bounding box of stored points. | |
| Iterator | begin () const |
| Returns an iterator to the begining of the octree. | |
| Iterator | begin () |
| Returns an iterator to the begining of the octree. | |
| Iterator | end () |
| Returns an iterator to the end of the octree. | |
| Iterator | end () const |
| Returns an iterator to the end of the octree. | |
| void | convertToDAG () |
| Converts the octree to DAG. | |
| template<class Func> | |
| auto | computeFunction (OctreeIterator start, OctreeIterator end, CellIndex range, const Func &f) |
| void | dumpOctree () const |
| Dumps the octree to std out. | |
Static Public Attributes | |
| static constexpr DGtal::Dimension | D = Space::dimension |
| static constexpr DGtal::Dimension | dimension = Space::dimension |
| static constexpr CellIndex | CELL_COUNT = (1 << D) |
| static constexpr CellIndex | INVALID_IDX = std::numeric_limits<CellIndex>::max() |
| static constexpr std::array< std::array< DimIndex, D >, CELL_COUNT > | SIDES_FROM_INDEX |
Private Types | |
| enum class | State { OCTREE = 1 , DAG = 2 } |
| The state the container is in. More... | |
Static Private Member Functions | |
| static Domain | splitDomain (const Domain &domain, const DimIndex *sides) |
| Helper function to split and select among 2^D subdomains. | |
Private Attributes | |
| CowPtr< Domain > | myAdmissibleDomain |
| CowPtr< Domain > | myDomain |
| State | myState = State::OCTREE |
| size_t | mySize |
| std::vector< std::vector< Node > > | myNodes |
Friends | |
| template<class> | |
| class | SVOWriter |
| template<class> | |
| class | SVOReader |
A DigitalSet that stores voxels as an octree, or a DAG.
This class allows for a compact representation of voxel as a sparse voxel octree (SVO). Optionally, this can be further compressed as a Sparse Voxel Directed Acyclic Graph where nodes are shared when they share a common structure.
Leaves are never explicitly stored to further reduce memory usage.
Common operation complexity: (L = depth of the tree computed with domain size, N = number of voxels)
When converted to a DAG, the digital set can not be modified anymore (neither insertion, or erase).
Definition at line 69 of file DigitalSetByOctree.h.
| using DGtal::DigitalSetByOctree< Space >::CellIndex = typename Space::UnsignedInteger |
Definition at line 78 of file DigitalSetByOctree.h.
| using DGtal::DigitalSetByOctree< Space >::ConstIterator = OctreeIterator |
Definition at line 282 of file DigitalSetByOctree.h.
| using DGtal::DigitalSetByOctree< Space >::DimIndex = std::uint8_t |
Definition at line 77 of file DigitalSetByOctree.h.
| using DGtal::DigitalSetByOctree< Space >::Domain = HyperRectDomain<Space> |
Definition at line 82 of file DigitalSetByOctree.h.
| using DGtal::DigitalSetByOctree< Space >::Iterator = OctreeIterator |
Definition at line 281 of file DigitalSetByOctree.h.
| using DGtal::DigitalSetByOctree< Space >::Point = typename Domain::Point |
Definition at line 83 of file DigitalSetByOctree.h.
| using DGtal::DigitalSetByOctree< Space >::Size = size_t |
Definition at line 79 of file DigitalSetByOctree.h.
| using DGtal::DigitalSetByOctree< Space >::Value = void |
Definition at line 87 of file DigitalSetByOctree.h.
|
strongprivate |
The state the container is in.
After the octree is converted to a DAG, it is not possible to insert or remove nodes.
| Enumerator | |
|---|---|
| OCTREE | |
| DAG | |
Definition at line 581 of file DigitalSetByOctree.h.
| DGtal::DigitalSetByOctree< Space >::DigitalSetByOctree | ( | const Domain & | d | ) |
Constructor from a domain.
Only HyperRectDomains are supported for octrees.
The given domain will be extended to ensure it is an hyper cube with sides that is a power of 2
| d | The domain |
|
inline |
Assigns the octree as the complement of another set.
This is equivalent to looping through a set and inserting every node
| other | The digital set to compute complement of |
Definition at line 484 of file DigitalSetByOctree.h.
|
inline |
Returns an iterator to the begining of the octree.
Definition at line 538 of file DigitalSetByOctree.h.
|
inline |
Returns an iterator to the begining of the octree.
Definition at line 524 of file DigitalSetByOctree.h.
Referenced by DGtal::DigitalSetByOctree< Z3i::Space >::computeBoundingBox(), DGtal::DigitalSetByOctree< Z3i::Space >::operator+=(), and TEST_CASE_METHOD().
|
inline |
Removes all nodes from the octree.
Note: if the octree has been converted to a dag, this function reset the flag and insertion is available afterwards.
Definition at line 379 of file DigitalSetByOctree.h.
Referenced by DGtal::DigitalSetByOctree< Z3i::Space >::assignFromComplement().
|
inline |
Computes the bounding box of stored points.
This functions runs in O(N log(L)).
| lb | Output lower bound |
| ub | Output upper bound |
Definition at line 505 of file DigitalSetByOctree.h.
|
inline |
Computes the complement of the octree.
This is equivalent to looping through an octree and inserting
| out | The output iterator |
Definition at line 462 of file DigitalSetByOctree.h.
| auto DGtal::DigitalSetByOctree< Space >::computeFunction | ( | OctreeIterator | start, |
| OctreeIterator | end, | ||
| CellIndex | range, | ||
| const Func & | f ) |
| void DGtal::DigitalSetByOctree< Space >::convertToDAG | ( | ) |
Converts the octree to DAG.
Referenced by TEST_CASE_METHOD().
|
inline |
Returns the domain of the digital set.
Definition at line 299 of file DigitalSetByOctree.h.
Referenced by TEST_CASE_METHOD().
|
inline |
| void DGtal::DigitalSetByOctree< Space >::dumpOctree | ( | ) | const |
Dumps the octree to std out.
Note: This function is meant for debug purposes only
|
inline |
Check if the octree is empty or not.
Definition at line 357 of file DigitalSetByOctree.h.
|
inline |
Returns an iterator to the end of the octree.
Definition at line 543 of file DigitalSetByOctree.h.
Referenced by DGtal::DigitalSetByOctree< Z3i::Space >::computeBoundingBox(), DGtal::DigitalSetByOctree< Z3i::Space >::operator()(), DGtal::DigitalSetByOctree< Z3i::Space >::operator+=(), and TEST_CASE_METHOD().
|
inline |
| size_t DGtal::DigitalSetByOctree< Space >::erase | ( | const Iterator & | it | ) |
Remove a voxel from the octree.
This functions is undefined behavior if the Iterator is invalid.
| it | The iterator pointing to the voxel to remove |
Referenced by DGtal::DigitalSetByOctree< Z3i::Space >::erase(), DGtal::DigitalSetByOctree< Z3i::Space >::erase(), and TEST_CASE_METHOD().
|
inline |
Removes a voxel from the octree.
| p | The point to remove |
Definition at line 414 of file DigitalSetByOctree.h.
|
inline |
| Iterator DGtal::DigitalSetByOctree< Space >::find | ( | const Point & | p | ) | const |
Finds a point within the Octree.
| p | The point to find |
Referenced by DGtal::DigitalSetByOctree< Z3i::Space >::erase(), and DGtal::DigitalSetByOctree< Z3i::Space >::operator()().
| void DGtal::DigitalSetByOctree< Space >::insert | ( | const Point & | p | ) |
Inserts a new point in the octree.
This function can be called multiple times with the same point without any risk.
If the point is not in bounds or the octree has been converted to a DAG, this function does nothing.
| p | The point to insert |
Referenced by DGtal::DigitalSetByOctree< Z3i::Space >::assignFromComplement(), DGtal::DigitalSetByOctree< Z3i::Space >::insertNew(), DGtal::DigitalSetByOctree< Z3i::Space >::operator+=(), and TEST_CASE_METHOD().
|
inline |
Inserts a new point in the octree.
This function can be called multiple times with the same point without any risk.
If the point is not in bounds or the octree has been converted to a DAG, this function does nothing.
| p | The point to insert |
Definition at line 331 of file DigitalSetByOctree.h.
|
inline |
Returns the memory occupied by node storage in bytes.
Definition at line 364 of file DigitalSetByOctree.h.
|
inline |
|
inline |
Appends an octree to another.
This is equivalent to looping through an octree and inserting every node into another
| other | The octree to append |
Definition at line 444 of file DigitalSetByOctree.h.
|
inline |
Shrinks storage to reduce memory usage.
This function removes extra capacity added for faster insertion with vector and can free some memory once insertion phase is over.
This function is called automatically by convertToDAG.
Definition at line 430 of file DigitalSetByOctree.h.
|
inline |
Returns the number of voxel in the set.
Definition at line 352 of file DigitalSetByOctree.h.
Referenced by DGtal::DigitalSetByOctree< Z3i::Space >::empty(), and TEST_CASE_METHOD().
|
staticprivate |
Helper function to split and select among 2^D subdomains.
| domain | The domain to split |
| sides | Selection between left or right subdomain for each dimension |
Referenced by DGtal::DigitalSetByOctree< Space >::OctreeIterator::operator*().
Definition at line 75 of file DigitalSetByOctree.h.
Definition at line 73 of file DigitalSetByOctree.h.
|
staticconstexpr |
Definition at line 92 of file DigitalSetByOctree.h.
Referenced by DGtal::DigitalSetByOctree< Space >::Node::Node().
|
staticconstexpr |
Definition at line 89 of file DigitalSetByOctree.h.
|
staticconstexpr |
Definition at line 90 of file DigitalSetByOctree.h.
|
staticconstexpr |
Definition at line 93 of file DigitalSetByOctree.h.
Referenced by DGtal::DigitalSetByOctree< Space >::Node::Node().
|
private |
Definition at line 596 of file DigitalSetByOctree.h.
|
private |
Definition at line 597 of file DigitalSetByOctree.h.
|
private |
Definition at line 601 of file DigitalSetByOctree.h.
|
private |
Definition at line 600 of file DigitalSetByOctree.h.
|
private |
Definition at line 598 of file DigitalSetByOctree.h.
|
staticconstexpr |
Definition at line 96 of file DigitalSetByOctree.h.
Referenced by DGtal::DigitalSetByOctree< Space >::OctreeIterator::operator*().