HDK
|
#include <ValueAccessor.h>
Public Types | |
using | TreeType = _TreeType |
using | RootNodeT = typename TreeType::RootNodeType |
using | LeafNodeT = typename TreeType::LeafNodeType |
using | ValueType = typename RootNodeT::ValueType |
using | BaseT = ValueAccessorBase< TreeType, IsSafe > |
using | LockT = typename MutexType::scoped_lock |
Public Member Functions | |
ValueAccessor (TreeType &tree) | |
ValueAccessor (const ValueAccessor &other) | |
ValueAccessor & | operator= (const ValueAccessor &other) |
~ValueAccessor () override=default | |
bool | isCached (const Coord &xyz) const |
Return true if nodes along the path to the given voxel 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 voxel as well as its value. More... | |
int | getValueDepth (const Coord &xyz) const |
bool | isVoxel (const Coord &xyz) const |
void | setValueOnly (const Coord &xyz, const ValueType &value) |
Set the value of the voxel at the given coordinate but don't change its active state. More... | |
void | setValueOff (const Coord &xyz, const ValueType &value) |
Set the value of the voxel at the given coordinates and mark the voxel as inactive. More... | |
template<typename ModifyOp > | |
void | modifyValue (const Coord &xyz, const ModifyOp &op) |
Apply a functor to the value of the voxel at the given coordinates and mark the voxel 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 but don't change its value. More... | |
void | setValueOn (const Coord &xyz) |
Mark the voxel at the given coordinates as active but don't change its value. More... | |
void | setValueOff (const Coord &xyz) |
Mark the voxel at the given coordinates as inactive but don't change its value. More... | |
template<typename NodeType > | |
NodeType * | getNode () |
Return the cached node of type NodeType. [Mainly for internal use]. More... | |
template<typename NodeType > | |
void | insertNode (const Coord &xyz, NodeType &node) |
template<typename NodeType > | |
void | eraseNode () |
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 voxel (x, y, z), possibly deleting existing nodes or creating new nodes in the process. More... | |
LeafNodeT * | touchLeaf (const Coord &xyz) |
Return a pointer to the leaf node that contains voxel (x, y, z). If no such node exists, create one, but preserve the values and active states of all voxels. More... | |
void | clear () override |
Remove all nodes from this cache, then reinsert the root node. More... | |
void | setValue (const Coord &xyz, const ValueType &value) |
Set the value of the voxel at the given coordinates and mark the voxel as active. More... | |
void | setValueOn (const Coord &xyz, const ValueType &value) |
Set the value of the voxel at the given coordinates and mark the voxel as active. More... | |
template<typename NodeT > | |
NodeT * | probeNode (const Coord &xyz) |
Return a pointer to the node of the specified type that contains voxel (x, y, z), or nullptr if no such node exists. More... | |
template<typename NodeT > | |
const NodeT * | probeConstNode (const Coord &xyz) const |
Return a pointer to the node of the specified type that contains voxel (x, y, z), or nullptr if no such node exists. More... | |
template<typename NodeT > | |
const NodeT * | probeNode (const Coord &xyz) const |
Return a pointer to the node of the specified type that contains voxel (x, y, z), or nullptr if no such node exists. More... | |
LeafNodeT * | probeLeaf (const Coord &xyz) |
Return a pointer to the leaf node that contains voxel (x, y, z), or nullptr if no such node exists. More... | |
const LeafNodeT * | probeConstLeaf (const Coord &xyz) const |
Return a pointer to the leaf node that contains voxel (x, y, z), or nullptr if no such node exists. More... | |
const LeafNodeT * | probeLeaf (const Coord &xyz) const |
Return a pointer to the leaf node that contains voxel (x, y, z), or nullptr if no such node exists. More... | |
![]() | |
ValueAccessorBase (_TreeType &tree) | |
ValueAccessorBase (const ValueAccessorBase &other) | |
virtual | ~ValueAccessorBase () |
_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... | |
ValueAccessorBase & | operator= (const ValueAccessorBase &other) |
Static Public Member Functions | |
static Index | numCacheLevels () |
Return the number of cache levels employed by this accessor. More... | |
![]() | |
static 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... | |
Friends | |
template<typename > | |
class | RootNode |
template<typename , Index > | |
class | InternalNode |
template<typename , Index > | |
class | LeafNode |
template<typename > | |
class | Tree |
Additional Inherited Members | |
![]() | |
static const bool | IsConstTree |
![]() | |
_TreeType * | mTree |
When traversing a grid in a spatially coherent pattern (e.g., iterating over neighboring voxels), request a ValueAccessor
from the grid (with Grid::getAccessor()) and use the accessor's getValue()
and setValue()
methods. These will typically be significantly faster than accessing voxels directly in the grid's tree.
A ValueAccessor caches pointers to tree nodes along the path to a voxel (x, y, z). A subsequent access to voxel (x', y', z') starts from the cached leaf node and moves up until a cached node that encloses (x', y', z') is found, then traverses down the tree from that node to a leaf, updating the cache with the new path. This leads to significant acceleration of spatially-coherent accesses.
_TreeType | the type of the tree to be accessed [required] |
IsSafe | if IsSafe = false then the ValueAccessor will not register itself with the tree from which it is consturcted (see warning). |
CacheLevels | the number of nodes to be cached, starting from the leaf level and not including the root (i.e., CacheLevels < DEPTH), and defaulting to all non-root nodes |
MutexType | the type of mutex to use (see note) |
MutexType
is a TBB-compatible mutex, then multiple threads may safely access a single, shared accessor. However, it is highly recommended that, instead, each thread be assigned its own, non-mutex-protected accessor. Definition at line 182 of file ValueAccessor.h.
using openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessor< _TreeType, IsSafe, CacheLevels, MutexType >::BaseT = ValueAccessorBase<TreeType, IsSafe> |
Definition at line 191 of file ValueAccessor.h.
using openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessor< _TreeType, IsSafe, CacheLevels, MutexType >::LeafNodeT = typename TreeType::LeafNodeType |
Definition at line 189 of file ValueAccessor.h.
using openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessor< _TreeType, IsSafe, CacheLevels, MutexType >::LockT = typename MutexType::scoped_lock |
Definition at line 192 of file ValueAccessor.h.
using openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessor< _TreeType, IsSafe, CacheLevels, MutexType >::RootNodeT = typename TreeType::RootNodeType |
Definition at line 188 of file ValueAccessor.h.
using openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessor< _TreeType, IsSafe, CacheLevels, MutexType >::TreeType = _TreeType |
Definition at line 187 of file ValueAccessor.h.
using openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessor< _TreeType, IsSafe, CacheLevels, MutexType >::ValueType = typename RootNodeT::ValueType |
Definition at line 190 of file ValueAccessor.h.
|
inline |
Definition at line 195 of file ValueAccessor.h.
|
inline |
Definition at line 200 of file ValueAccessor.h.
|
overridedefault |
|
inline |
Add the specified leaf to this tree, possibly creating a child branch in the process. If the leaf node already exists, replace it.
Definition at line 329 of file ValueAccessor.h.
|
inline |
Add a tile at the specified tree level that contains voxel (x, y, z), possibly deleting existing nodes or creating new nodes in the process.
Definition at line 337 of file ValueAccessor.h.
|
inlineoverridevirtual |
Remove all nodes from this cache, then reinsert the root node.
Implements openvdb::OPENVDB_VERSION_NAME::tree::ValueAccessorBase< _TreeType, IsSafe >.
Definition at line 393 of file ValueAccessor.h.
|
inline |
If a node of the given type exists in the cache, remove it, so that isCached(xyz) returns false
for any voxel (x, y, z) contained in that node. [Mainly for internal use]
Definition at line 325 of file ValueAccessor.h.
|
inline |
Return the cached node of type NodeType. [Mainly for internal use].
Definition at line 304 of file ValueAccessor.h.
|
inline |
Return the value of the voxel at the given coordinates.
Definition at line 219 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).
Definition at line 238 of file ValueAccessor.h.
|
inline |
Cache the given node, which should lie along the path from the root node to the node containing voxel (x, y, z). [Mainly for internal use]
Definition at line 315 of file ValueAccessor.h.
|
inline |
Return true
if nodes along the path to the given voxel have been cached.
Definition at line 216 of file ValueAccessor.h.
|
inline |
Return the active state of the voxel at the given coordinates.
Definition at line 226 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.
Definition at line 246 of file ValueAccessor.h.
|
inline |
Apply a functor to the value of the voxel at the given coordinates and mark the voxel as active.
See Tree::modifyValue() for details.
Definition at line 276 of file ValueAccessor.h.
|
inline |
Apply a functor to the voxel at the given coordinates.
See Tree::modifyValueAndActiveState() for details.
Definition at line 285 of file ValueAccessor.h.
|
inlinestatic |
Return the number of cache levels employed by this accessor.
Definition at line 213 of file ValueAccessor.h.
|
inline |
Definition at line 202 of file ValueAccessor.h.
|
inline |
Return a pointer to the leaf node that contains voxel (x, y, z), or nullptr
if no such node exists.
Definition at line 384 of file ValueAccessor.h.
|
inline |
Return a pointer to the node of the specified type that contains voxel (x, y, z), or nullptr
if no such node exists.
Definition at line 364 of file ValueAccessor.h.
|
inline |
Return a pointer to the leaf node that contains voxel (x, y, z), or nullptr
if no such node exists.
Definition at line 379 of file ValueAccessor.h.
|
inline |
Return a pointer to the leaf node that contains voxel (x, y, z), or nullptr
if no such node exists.
Definition at line 389 of file ValueAccessor.h.
|
inline |
Return a pointer to the node of the specified type that contains voxel (x, y, z), or nullptr
if no such node exists.
Definition at line 358 of file ValueAccessor.h.
|
inline |
Return a pointer to the node of the specified type that contains voxel (x, y, z), or nullptr
if no such node exists.
Definition at line 370 of file ValueAccessor.h.
|
inline |
Return the active state of the voxel as well as its value.
Definition at line 229 of file ValueAccessor.h.
|
inline |
Set the active state of the voxel at the given coordinates but don't change its value.
Definition at line 292 of file ValueAccessor.h.
|
inline |
Set the value of the voxel at the given coordinates and mark the voxel as active.
Definition at line 250 of file ValueAccessor.h.
|
inline |
Set the value of the voxel at the given coordinates and mark the voxel as inactive.
Definition at line 266 of file ValueAccessor.h.
|
inline |
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition at line 300 of file ValueAccessor.h.
|
inline |
Set the value of the voxel at the given coordinates and mark the voxel as active.
Definition at line 255 of file ValueAccessor.h.
|
inline |
Mark the voxel at the given coordinates as active but don't change its value.
Definition at line 298 of file ValueAccessor.h.
|
inline |
Set the value of the voxel at the given coordinate but don't change its active state.
Definition at line 259 of file ValueAccessor.h.
|
inline |
Return a pointer to the leaf node that contains voxel (x, y, z). If no such node exists, create one, but preserve the values and active states of all voxels.
Use this method to preallocate a static tree topology over which to safely perform multithreaded processing.
Definition at line 348 of file ValueAccessor.h.
|
friend |
Definition at line 403 of file ValueAccessor.h.
|
friend |
Definition at line 404 of file ValueAccessor.h.
|
friend |
Definition at line 402 of file ValueAccessor.h.
|
friend |
Definition at line 406 of file ValueAccessor.h.