OpenVDB
12.0.0
|
The Value Accessor Implementation and API methods. The majoirty of the API matches the API of a compatible OpenVDB Tree Node. More...
#include <openvdb/tree/ValueAccessor.h>
Inherits ValueAccessorBase< _TreeType, IsSafe >, ValueAccessorLeafBuffer< _TreeType, IntegerSequence >, and ValueAccessorLock< MutexT >.
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 | NodeT0 = typename std::conditional<(NumCacheLevels > 0), NodeTypeAtLevel< 0 >, void >::type |
using | NodeT1 = typename std::conditional<(NumCacheLevels > 1), NodeTypeAtLevel< 1 >, void >::type |
using | NodeT2 = typename std::conditional<(NumCacheLevels > 2), NodeTypeAtLevel< 2 >, void >::type |
Public Member Functions | |
ValueAccessorImpl (TreeType &tree) | |
Constructor from a tree. More... | |
~ValueAccessorImpl () override final=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 () override final |
Remove all the cached nodes and invalidate the corresponding hash-keys. More... | |
_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... | |
const _TreeType::ValueType * | buffer () |
const _TreeType::ValueType * | buffer () const |
void | setBuffer (const typename _TreeType::ValueType *b) const |
auto | lock () const |
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... | |
Static Public Member Functions | |
static constexpr Index | numCacheLevels () |
Return the number of cache levels employed by this ValueAccessor. More... | |
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 constexpr bool | IsConstTree |
Returns true if this accessor is operating on a const tree type. More... | |
Protected Member Functions | |
void | release () override final |
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 |
Protected Attributes | |
_TreeType * | mTree |
Friends | |
template<typename > | |
class | RootNode |
template<typename , Index > | |
class | InternalNode |
template<typename , Index > | |
class | LeafNode |
template<typename > | |
class | Tree |
The Value Accessor Implementation and API methods. The majoirty of the API matches the API of a compatible OpenVDB Tree Node.
using BaseT = ValueAccessorBase<_TreeType, IsSafe> |
using LeafCacheT = ValueAccessorLeafBuffer<_TreeType, IntegerSequence> |
using LeafNodeT = typename TreeType::LeafNodeType |
using LockT = ValueAccessorLock<MutexT> |
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.
using NodePtrList = typename NodeLevelList::template Transform<std::add_pointer_t> |
using NodeT0 = typename std::conditional<(NumCacheLevels > 0), NodeTypeAtLevel<0>, void>::type |
using NodeT1 = typename std::conditional<(NumCacheLevels > 1), NodeTypeAtLevel<1>, void>::type |
using NodeT2 = typename std::conditional<(NumCacheLevels > 2), NodeTypeAtLevel<2>, void>::type |
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:
using RootNodeT = typename TreeType::RootNodeType |
using TreeType = _TreeType |
using ValueType = typename TreeType::ValueType |
|
inline |
Constructor from a tree.
|
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. |
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 |
|
inlineinherited |
|
inlineinherited |
|
inlinefinaloverridevirtual |
Remove all the cached nodes and invalidate the corresponding hash-keys.
Implements ValueAccessorBase< _TreeType, IsSafe >.
|
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.
|
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.
|
inlineinherited |
Return a pointer to the tree associated with this accessor.
The pointer will be null only if the tree from which this accessor was constructed was subsequently deleted (which generally leaves the accessor in an unsafe state).
|
inline |
Return the value of the voxel at the given coordinates.
xyz | The index space coordinate to query |
|
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 |
|
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.
|
inline |
Explicitly insert a node of the type NodeT into this Value Accessors cache.
|
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 |
|
inlineprotected |
|
inlinestaticinherited |
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).
|
inline |
Return the active state of the voxel at the given coordinates.
xyz | The index space coordinate to query |
|
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 |
|
inlineinherited |
|
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 |
|
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 |
|
inlinestatic |
Return the number of cache levels employed by this ValueAccessor.
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 ValueAccessorBase< _TreeType, IsSafe >.
|
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) |
|
inlineinherited |
|
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 |
|
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 |
|
inline |
Mark the voxel at the given coordinates as inactive without changing its value.
xyz | The index space coordinate to modify |
|
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 |
|
inline |
Mark the voxel at the given coordinates as active without changing its value.
xyz | The index space coordinate to modify |
|
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 |
|
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.
|
inlineinherited |
Return a reference to the tree associated with this accessor.
|
friend |
|
friend |
|
friend |
|
friend |
|
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.
|
staticinherited |
Returns true if this accessor is operating on a const tree type.
|
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.
|
protectedinherited |
|
static |
The number of node levels that this accessor can cache, excluding the RootNode.