HDK
|
The Value Accessor Implementation and API methods. The majoirty of the API matches the API of a compatible OpenVDB Tree Node. More...
#include <ValueAccessor.h>
Public Types | |
using | BaseT = ValueAccessorBase< _TreeType, IsSafe > |
using | LockT = ValueAccessorLock< MutexT > |
using | LeafCacheT = ValueAccessorLeafBuffer< _TreeType, IntegerSequence > |
using | TreeType = _TreeType |
using | ValueType = typename TreeType::ValueType |
using | RootNodeT = typename TreeType::RootNodeType |
using | LeafNodeT = typename TreeType::LeafNodeType |
using | NodeChainT = typename RootNodeT::NodeChainType |
using | NodeLevelList = typename value_accessor_internal::NodeListBuilder< NodeChainT, RootNodeT::LEVEL, IntegerSequence >::ListT |
A resolved, flattened TypeList of node types which this accessor is caching. The nodes index in this list does not necessarily correspond to the nodes level in the tree. More... | |
using | NodePtrList = typename NodeLevelList::template Transform< std::add_pointer_t > |
template<size_t Level> | |
using | NodeTypeAtLevel = typename NodeLevelList::template Get< Level > |
Return a node type at a particular cache level in the Value accessor. The node type at a given cache level does not necessarily equal the same node type in the TreeType as this depends entirely on which tree levels this Accessor is caching. For example: More... | |
using | NodeTypeAtLevel = typename std::conditional<(NumCacheLevels > 0), NodeTypeAtLevel< 0 >, void >::type |
using | NodeTypeAtLevel = typename std::conditional<(NumCacheLevels > 1), NodeTypeAtLevel< 1 >, void >::type |
using | NodeTypeAtLevel = typename std::conditional<(NumCacheLevels > 2), NodeTypeAtLevel< 2 >, void >::type |
Public Member Functions | |
ValueAccessorImpl (TreeType &tree) | |
Constructor from a tree. More... | |
~ValueAccessorImpl () overridefinal=default | |
ValueAccessorImpl (const ValueAccessorImpl &)=default | |
ValueAccessorImpl & | operator= (const ValueAccessorImpl &)=default |
bool | isCached (const Coord &xyz) const |
Return true if any of the nodes along the path to the given coordinate have been cached. More... | |
const ValueType & | getValue (const Coord &xyz) const |
Return the value of the voxel at the given coordinates. More... | |
bool | isValueOn (const Coord &xyz) const |
Return the active state of the voxel at the given coordinates. More... | |
bool | probeValue (const Coord &xyz, ValueType &value) const |
Return the active state of the value at a given coordinate as well as its value. More... | |
int | getValueDepth (const Coord &xyz) const |
Return the tree depth (0 = root) at which the value of voxel (x, y, z) resides, or -1 if (x, y, z) isn't explicitly represented in the tree (i.e., if it is implicitly a background voxel). More... | |
bool | isVoxel (const Coord &xyz) const |
Return true if the value of voxel (x, y, z) resides at the leaf level of the tree, i.e., if it is not a tile value. More... | |
void | setValueOnly (const Coord &xyz, const ValueType &value) |
Set a particular value at the given coordinate but preserve its active state. More... | |
void | setValueOff (const Coord &xyz, const ValueType &value) |
Set a particular value at the given coordinate and mark the coordinate as inactive. More... | |
template<typename ModifyOp > | |
void | modifyValue (const Coord &xyz, const ModifyOp &op) |
Apply a functor to the value at the given coordinate and mark mark the coordinate as active. More... | |
template<typename ModifyOp > | |
void | modifyValueAndActiveState (const Coord &xyz, const ModifyOp &op) |
Apply a functor to the voxel at the given coordinates. More... | |
void | setActiveState (const Coord &xyz, bool on=true) |
Set the active state of the voxel at the given coordinates without changing its value. More... | |
void | setValueOn (const Coord &xyz) |
Mark the voxel at the given coordinates as active without changing its value. More... | |
void | setValueOff (const Coord &xyz) |
Mark the voxel at the given coordinates as inactive without changing its value. More... | |
LeafNodeT * | touchLeaf (const Coord &xyz) |
Returns the leaf node that contains voxel (x, y, z) and if it doesn't exist, create it, but preserve the values and active states of the pre-existing branch. More... | |
void | addLeaf (LeafNodeT *leaf) |
Add the specified leaf to this tree, possibly creating a child branch in the process. If the leaf node already exists, replace it. More... | |
void | addTile (Index level, const Coord &xyz, const ValueType &value, bool state) |
Add a tile at the specified tree level that contains the coordinate xyz, possibly deleting existing nodes or creating new nodes in the process. More... | |
template<typename NodeT > | |
NodeT * | getNode () |
Return the node of type NodeT that has been cached on this accessor. If this accessor does not cache this NodeT, or if no node of this type has been cached, returns a nullptr. More... | |
template<typename NodeT > | |
void | insertNode (const Coord &xyz, NodeT &node) |
Explicitly insert a node of the type NodeT into this Value Accessors cache. More... | |
template<typename NodeT > | |
void | eraseNode () |
Explicitly remove this Value Accessors cached node of the given NodeT. If this Value Accessor does not support the caching of the provided NodeT, this method does nothing. More... | |
void | clear () overridefinal |
Remove all the cached nodes and invalidate the corresponding hash-keys. More... | |
void | setValue (const Coord &xyz, const ValueType &value) |
Set a particular value at the given coordinate and mark the coordinate as active. More... | |
void | setValueOn (const Coord &xyz, const ValueType &value) |
Set a particular value at the given coordinate and mark the coordinate as active. More... | |
template<typename NodeT > | |
NodeT * | probeNode (const Coord &xyz) |
Return a pointer to the node of the specified type that contains the value located at xyz. If no node of the given NodeT exists which contains the value, a nullptr is returned. More... | |
template<typename NodeT > | |
const NodeT * | probeConstNode (const Coord &xyz) const |
Return a pointer to the node of the specified type that contains the value located at xyz. If no node of the given NodeT exists which contains the value, a nullptr is returned. More... | |
LeafNodeT * | probeLeaf (const Coord &xyz) |
Return a pointer to the leaf node that contains the voxel coordinate xyz. If no LeafNode exists, returns a nullptr. More... | |
const LeafNodeT * | probeLeaf (const Coord &xyz) const |
Return a pointer to the leaf node that contains the voxel coordinate xyz. If no LeafNode exists, returns a nullptr. More... | |
const LeafNodeT * | probeConstLeaf (const Coord &xyz) const |
Return a pointer to the leaf node that contains the voxel coordinate xyz. If no LeafNode exists, returns a nullptr. More... | |
Public Member Functions inherited from openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessorBase< _TreeType, IsSafe > | |
ValueAccessorBase (_TreeType &tree) | |
Construct from a tree. Should rarely be invoked directly, the drived implementation class calls this. Remains public for backwards compatibility. More... | |
ValueAccessorBase (const ValueAccessorBase &other) | |
Copy constructor - if IsSafe, then the copy also registers itself against the tree it is accessing. More... | |
virtual | ~ValueAccessorBase () |
ValueAccessorBase & | operator= (const ValueAccessorBase &other) |
_TreeType * | getTree () const |
Return a pointer to the tree associated with this accessor. More... | |
_TreeType & | tree () const |
Return a reference to the tree associated with this accessor. More... | |
Public Member Functions inherited from openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessorLeafBuffer< _TreeType, IntegerSequence > | |
const _TreeType::ValueType * | buffer () |
const _TreeType::ValueType * | buffer () const |
void | setBuffer (const typename _TreeType::ValueType *b) const |
Public Member Functions inherited from openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessorLock< MutexT > | |
auto | lock () const |
Static Public Member Functions | |
static constexpr Index | numCacheLevels () |
Return the number of cache levels employed by this ValueAccessor. More... | |
Static Public Member Functions inherited from openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessorBase< _TreeType, IsSafe > | |
static constexpr bool | isSafe () |
Return true if this accessor is safe, i.e. registered by the tree from which it is constructed. Un-registered accessors can in rare cases be faster because it avoids the (small) overhead of registration, but they are unsafe if the tree is modified. So unless you're an expert it is highly recommended to set IsSafe = true (which is the default). More... | |
Static Public Attributes | |
template<typename NodeT > | |
static constexpr bool | IsLeafAndBypassLeafAPI |
Given a node type, return whether this Accessor can perform optimized value buffer accesses. This is only possible for LeafNodes so will always return false for any non LeafNode type. It also depends on the value type - if the value buffer is a contiguous index-able array of values then this returns true. More... | |
static constexpr bool | BypassLeafAPI |
Helper alias which is true if the lowest cached node level is a LeafNode type and has a compatible value type for optimized access. More... | |
static constexpr size_t | NumCacheLevels = NodeLevelList::Size-1 |
The number of node levels that this accessor can cache, excluding the RootNode. More... | |
Static Public Attributes inherited from openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessorBase< _TreeType, IsSafe > | |
static constexpr bool | IsConstTree |
Returns true if this accessor is operating on a const tree type. More... | |
Static Public Attributes inherited from openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessorLeafBuffer< _TreeType, IntegerSequence > | |
static constexpr bool | BypassLeafAPI |
Protected Member Functions | |
void | release () overridefinal |
Release this accessor from the tree, set the tree to null and clear the accessor cache. After calling this method the accessor will be completely invalid. More... | |
template<typename NodeT > | |
OPENVDB_FORCE_INLINE void | insert ([[maybe_unused]] const Coord &xyz, [[maybe_unused]] const NodeT *node) const |
Insert a node into this ValueAccessor's cache. More... | |
template<typename NodeT > | |
OPENVDB_FORCE_INLINE bool | isHashed ([[maybe_unused]] const Coord &xyz) const |
Friends | |
template<typename > | |
class | RootNode |
template<typename , Index > | |
class | InternalNode |
template<typename , Index > | |
class | LeafNode |
template<typename > | |
class | Tree |
Additional Inherited Members | |
Protected Attributes inherited from openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessorBase< _TreeType, IsSafe > | |
_TreeType * | mTree |
The Value Accessor Implementation and API methods. The majoirty of the API matches the API of a compatible OpenVDB Tree Node.
Definition at line 68 of file ValueAccessor.h.
using openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessorImpl< TreeType, IsSafe, MutexT, IndexSequence >::BaseT = ValueAccessorBase<_TreeType, IsSafe> |
Definition at line 371 of file ValueAccessor.h.
using openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessorImpl< TreeType, IsSafe, MutexT, IndexSequence >::LeafCacheT = ValueAccessorLeafBuffer<_TreeType, IntegerSequence> |
Definition at line 373 of file ValueAccessor.h.
using openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessorImpl< TreeType, IsSafe, MutexT, IndexSequence >::LeafNodeT = typename TreeType::LeafNodeType |
Definition at line 378 of file ValueAccessor.h.
using openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessorImpl< TreeType, IsSafe, MutexT, IndexSequence >::LockT = ValueAccessorLock<MutexT> |
Definition at line 372 of file ValueAccessor.h.
using openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessorImpl< TreeType, IsSafe, MutexT, IndexSequence >::NodeChainT = typename RootNodeT::NodeChainType |
Definition at line 379 of file ValueAccessor.h.
using openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessorImpl< TreeType, IsSafe, MutexT, IndexSequence >::NodeLevelList = typename value_accessor_internal::NodeListBuilder <NodeChainT, RootNodeT::LEVEL, IntegerSequence>::ListT |
A resolved, flattened TypeList of node types which this accessor is caching. The nodes index in this list does not necessarily correspond to the nodes level in the tree.
Definition at line 386 of file ValueAccessor.h.
using openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessorImpl< TreeType, IsSafe, MutexT, IndexSequence >::NodePtrList = typename NodeLevelList::template Transform<std::add_pointer_t> |
Definition at line 387 of file ValueAccessor.h.
using openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessorImpl< TreeType, IsSafe, MutexT, IndexSequence >::NodeTypeAtLevel = typename NodeLevelList::template Get<Level> |
Return a node type at a particular cache level in the Value accessor. The node type at a given cache level does not necessarily equal the same node type in the TreeType as this depends entirely on which tree levels this Accessor is caching. For example:
Definition at line 402 of file ValueAccessor.h.
using openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessorImpl< TreeType, IsSafe, MutexT, IndexSequence >::NodeTypeAtLevel = typename std::conditional<(NumCacheLevels > 0), NodeTypeAtLevel<0>, void>::type |
Definition at line 896 of file ValueAccessor.h.
using openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessorImpl< TreeType, IsSafe, MutexT, IndexSequence >::NodeTypeAtLevel = typename std::conditional<(NumCacheLevels > 1), NodeTypeAtLevel<1>, void>::type |
Definition at line 898 of file ValueAccessor.h.
using openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessorImpl< TreeType, IsSafe, MutexT, IndexSequence >::NodeTypeAtLevel = typename std::conditional<(NumCacheLevels > 2), NodeTypeAtLevel<2>, void>::type |
Definition at line 900 of file ValueAccessor.h.
using openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessorImpl< TreeType, IsSafe, MutexT, IndexSequence >::RootNodeT = typename TreeType::RootNodeType |
Definition at line 377 of file ValueAccessor.h.
using openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessorImpl< TreeType, IsSafe, MutexT, IndexSequence >::TreeType = _TreeType |
Definition at line 375 of file ValueAccessor.h.
using openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessorImpl< TreeType, IsSafe, MutexT, IndexSequence >::ValueType = typename TreeType::ValueType |
Definition at line 376 of file ValueAccessor.h.
|
inline |
Constructor from a tree.
Definition at line 425 of file ValueAccessor.h.
|
finaloverridedefault |
|
default |
|
inline |
Add the specified leaf to this tree, possibly creating a child branch in the process. If the leaf node already exists, replace it.
leaf | The LeafNode to insert into the tree. Must not be a nullptr. |
Definition at line 729 of file ValueAccessor.h.
|
inline |
Add a tile at the specified tree level that contains the coordinate xyz, possibly deleting existing nodes or creating new nodes in the process.
level | The level of the tree to add a tile. Level 0 refers to voxels (and is similar to ::setValue, except will always density). |
xyz | The index space coordinate to add a tile |
value | The value of the tile |
state | The active state to set on the new tile |
Definition at line 754 of file ValueAccessor.h.
|
inlinefinaloverridevirtual |
Remove all the cached nodes and invalidate the corresponding hash-keys.
Implements openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessorBase< _TreeType, IsSafe >.
Definition at line 880 of file ValueAccessor.h.
|
inline |
Explicitly remove this Value Accessors cached node of the given NodeT. If this Value Accessor does not support the caching of the provided NodeT, this method does nothing.
Definition at line 869 of file ValueAccessor.h.
|
inline |
Return the node of type NodeT that has been cached on this accessor. If this accessor does not cache this NodeT, or if no node of this type has been cached, returns a nullptr.
Definition at line 848 of file ValueAccessor.h.
|
inline |
Return the value of the voxel at the given coordinates.
xyz | The index space coordinate to query |
Definition at line 455 of file ValueAccessor.h.
|
inline |
Return the tree depth (0 = root) at which the value of voxel (x, y, z) resides, or -1 if (x, y, z) isn't explicitly represented in the tree (i.e., if it is implicitly a background voxel).
xyz | The index space coordinate to query |
Definition at line 516 of file ValueAccessor.h.
|
inlineprotected |
Insert a node into this ValueAccessor's cache.
******************************* WARNING ******************************* Methods here must be force inline otherwise compilers do not optimize out the function call due to recursive templates and performance degradation is significant.
Definition at line 930 of file ValueAccessor.h.
|
inline |
Explicitly insert a node of the type NodeT into this Value Accessors cache.
Definition at line 860 of file ValueAccessor.h.
|
inline |
Return true
if any of the nodes along the path to the given coordinate have been cached.
xyz | The index space coordinate to query |
Definition at line 441 of file ValueAccessor.h.
|
inlineprotected |
Definition at line 949 of file ValueAccessor.h.
|
inline |
Return the active state of the voxel at the given coordinates.
xyz | The index space coordinate to query |
Definition at line 480 of file ValueAccessor.h.
|
inline |
Return true
if the value of voxel (x, y, z) resides at the leaf level of the tree, i.e., if it is not a tile value.
xyz | The index space coordinate to query |
Definition at line 535 of file ValueAccessor.h.
|
inline |
Apply a functor to the value at the given coordinate and mark mark the coordinate as active.
See Tree::modifyValue() for details.
xyz | The index space coordinate to modify |
op | The modify operation |
Definition at line 632 of file ValueAccessor.h.
|
inline |
Apply a functor to the voxel at the given coordinates.
See Tree::modifyValueAndActiveState() for details.
xyz | The index space coordinate to modify |
op | The modify operation |
Definition at line 656 of file ValueAccessor.h.
|
inlinestatic |
Return the number of cache levels employed by this ValueAccessor.
Definition at line 903 of file ValueAccessor.h.
|
default |
|
inline |
Return a pointer to the leaf node that contains the voxel coordinate xyz. If no LeafNode exists, returns a nullptr.
xyz | The index space coordinate to query |
Definition at line 838 of file ValueAccessor.h.
|
inline |
Return a pointer to the node of the specified type that contains the value located at xyz. If no node of the given NodeT exists which contains the value, a nullptr is returned.
This function may return a nullptr even if the coordinate xyz is represented in tree, as it depends on the type NodeT provided. For example, the value may exist as a tile in an InternalNode but note as a LeafNode.
xyz | The index space coordinate to query |
Definition at line 805 of file ValueAccessor.h.
|
inline |
Return a pointer to the leaf node that contains the voxel coordinate xyz. If no LeafNode exists, returns a nullptr.
xyz | The index space coordinate to query |
Definition at line 836 of file ValueAccessor.h.
|
inline |
Return a pointer to the leaf node that contains the voxel coordinate xyz. If no LeafNode exists, returns a nullptr.
xyz | The index space coordinate to query |
Definition at line 837 of file ValueAccessor.h.
|
inline |
Return a pointer to the node of the specified type that contains the value located at xyz. If no node of the given NodeT exists which contains the value, a nullptr is returned.
This function may return a nullptr even if the coordinate xyz is represented in tree, as it depends on the type NodeT provided. For example, the value may exist as a tile in an InternalNode but note as a LeafNode.
xyz | The index space coordinate to query |
Definition at line 777 of file ValueAccessor.h.
|
inline |
Return the active state of the value at a given coordinate as well as its value.
xyz | The index space coordinate to query |
value | The value to get |
Definition at line 492 of file ValueAccessor.h.
|
inlinefinaloverrideprotectedvirtual |
Release this accessor from the tree, set the tree to null and clear the accessor cache. After calling this method the accessor will be completely invalid.
Reimplemented from openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessorBase< _TreeType, IsSafe >.
Definition at line 916 of file ValueAccessor.h.
|
inline |
Set the active state of the voxel at the given coordinates without changing its value.
xyz | The index space coordinate to modify |
on | Whether to set the active state to on (true) or off (false) |
Definition at line 683 of file ValueAccessor.h.
|
inline |
Set a particular value at the given coordinate and mark the coordinate as active.
xyz | The index space coordinate to set |
value | The value to set |
Definition at line 550 of file ValueAccessor.h.
|
inline |
Set a particular value at the given coordinate and mark the coordinate as inactive.
xyz | The index space coordinate to set |
value | The value to set |
Definition at line 607 of file ValueAccessor.h.
|
inline |
Mark the voxel at the given coordinates as inactive without changing its value.
xyz | The index space coordinate to modify |
Definition at line 704 of file ValueAccessor.h.
|
inline |
Set a particular value at the given coordinate and mark the coordinate as active.
xyz | The index space coordinate to set |
value | The value to set |
Definition at line 569 of file ValueAccessor.h.
|
inline |
Mark the voxel at the given coordinates as active without changing its value.
xyz | The index space coordinate to modify |
Definition at line 698 of file ValueAccessor.h.
|
inline |
Set a particular value at the given coordinate but preserve its active state.
xyz | The index space coordinate to set |
value | The value to set |
Definition at line 578 of file ValueAccessor.h.
|
inline |
Returns the leaf node that contains voxel (x, y, z) and if it doesn't exist, create it, but preserve the values and active states of the pre-existing branch.
xyz | The index space coordinate at which to create a LeafNode. Note that if this coordinate is not a LeafNode origin then the LeafNode that would otherwise contain this coordinate is created and returned. |
Definition at line 715 of file ValueAccessor.h.
|
friend |
Definition at line 908 of file ValueAccessor.h.
|
friend |
Definition at line 909 of file ValueAccessor.h.
|
friend |
Definition at line 907 of file ValueAccessor.h.
|
friend |
Definition at line 911 of file ValueAccessor.h.
|
static |
Helper alias which is true if the lowest cached node level is a LeafNode type and has a compatible value type for optimized access.
Definition at line 415 of file ValueAccessor.h.
|
static |
Given a node type, return whether this Accessor can perform optimized value buffer accesses. This is only possible for LeafNodes so will always return false for any non LeafNode type. It also depends on the value type - if the value buffer is a contiguous index-able array of values then this returns true.
Definition at line 410 of file ValueAccessor.h.
|
static |
The number of node levels that this accessor can cache, excluding the RootNode.
Definition at line 420 of file ValueAccessor.h.