32#include "DGtal/base/Common.h"
33#include "DGtal/kernel/domains/HyperRectDomain.h"
68 template <
class Space>
98 std::array<std::array<DimIndex, D>,
CELL_COUNT> sides_from_index{};
104 sides_from_index[i][d] = coord % 2;
109 return sides_from_index;
212 std::vector<TraversalMemory>& memory)
241 return !(*
this == other);
368 count +=
myNodes[i].capacity() *
sizeof(Node);
448 for (
auto it = other.
begin(); it != other.
end(); ++it)
461 template<
typename It>
467 if (!this->
operator()(*it))
510 for (
auto it =
begin(); it !=
end(); ++it)
515 lb[d] = std::min(lb[d], p[d]);
516 ub[d] = std::max(ub[d], p[d]);
605#include "DigitalSetByOctree.ih"
Aim: Copy on write shared pointer.
void insert(const Point &p)
Inserts a new point in the octree.
Iterator begin()
Returns an iterator to the begining of the octree.
auto computeFunction(OctreeIterator start, OctreeIterator end, CellIndex range, const Func &f)
size_t erase(const Iterator &it)
Remove a voxel from the octree.
CowPtr< Domain > myAdmissibleDomain
DigitalSetByOctree & operator+=(const DigitalSetByOctree &other)
Appends an octree to another.
size_t erase(Iterator begin, Iterator end)
Removes a range of voxels.
static constexpr CellIndex CELL_COUNT
bool operator()(const Point &p) const
Check if a voxel is set or not.
void clear()
Removes all nodes from the octree.
std::vector< std::vector< Node > > myNodes
Iterator end() const
Returns an iterator to the end of the octree.
Iterator find(const Point &p) const
Finds a point within the Octree.
bool empty() const
Check if the octree is empty or not.
size_t size() const
Returns the number of voxel in the set.
static Domain splitDomain(const Domain &domain, const DimIndex *sides)
Helper function to split and select among 2^D subdomains.
CowPtr< Domain > domainPointer() const
Returns the domain of the voxels.
static constexpr std::array< std::array< DimIndex, D >, CELL_COUNT > SIDES_FROM_INDEX
void computeComplement(It out) const
Computes the complement of the octree.
State
The state the container is in.
HyperRectDomain< Space > Domain
void dumpOctree() const
Dumps the octree to std out.
void insertNew(const Point &p)
Inserts a new point in the octree.
CowPtr< Domain > myDomain
void shrinkToFit()
Shrinks storage to reduce memory usage.
DigitalSetByOctree(const Domain &d)
Constructor from a domain.
void convertToDAG()
Converts the octree to DAG.
static constexpr CellIndex INVALID_IDX
static constexpr DGtal::Dimension D
OctreeIterator ConstIterator
typename Space::UnsignedInteger CellIndex
Iterator end()
Returns an iterator to the end of the octree.
size_t memoryFootprint() const
Returns the memory occupied by node storage in bytes.
const Domain & domain() const
Returns the domain of the digital set.
void computeBoundingBox(Point &lb, Point &ub) const
Computes the bounding box of stored points.
typename Domain::Point Point
size_t erase(const Point &p)
Removes a voxel from the octree.
void assignFromComplement(const DSet &other)
Assigns the octree as the complement of another set.
static constexpr DGtal::Dimension dimension
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
const Point & lowerBound() const
NumberTraits< Integer >::UnsignedVersion UnsignedInteger
static const Dimension dimension
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::uint32_t Dimension
Helper struct for computing local estimators.
std::vector< DimIndex > code
bool operator<(const ComputationCacheKey &other) const
CellIndex children[CELL_COUNT]
Iterator over the octree.
std::ptrdiff_t difference_type
std::forward_iterator_tag iterator_category
OctreeIterator(const DigitalSetByOctree *container, std::vector< TraversalMemory > &memory)
Constructor from an entire traversal.
bool operator==(const OctreeIterator &other) const
Compares two iterator.
OctreeIterator & operator++()
Prefix increment.
void findNextLeaf()
Finds the next leaf, if any.
OctreeIterator(const DigitalSetByOctree *container, TraversalMemory init)
Constructor from any node to explore subtree.
bool operator!=(const OctreeIterator &other) const
Not equal comparison operator.
std::vector< TraversalMemory > myMemory
const DigitalSetByOctree * myContainer
friend class DigitalSetByOctree
OctreeIterator(const DigitalSetByOctree *container)
Constuctor to end of an octree.
OctreeIterator operator++(int)
Postfix increment.
Point operator*() const
Dereference operator.
Helper struct to store traversal and go to next leaf.
CellIndex currentChildIdx
bool operator==(const TraversalMemory &other) const
K init(Point(0, 0, 0), Point(512, 512, 512), true)