|
| 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...
|
|
_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...
|
|
|
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...
|
|
template<typename _TreeType, bool IsSafe = true, Index CacheLevels = _TreeType::DEPTH-1, typename MutexType = tbb::null_mutex>
class openvdb::v9_0::tree::ValueAccessor< _TreeType, IsSafe, CacheLevels, MutexType >
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.
- Parameters
-
_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 constructed (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) |
- Warning
- If IsSafe = false then the ValueAccessor will not register itself with the tree from which it is constructed. While in some rare cases this can lead to better performance (since it avoids the small overhead of insertion on creation and deletion on destruction) it is also unsafe if the tree is modified. So unless you're an expert it is highly recommended to set IsSafe = true, which is the default. However if you know that the tree is no being modifed for the lifespan of the ValueAccessor AND the work performed per ValueAccessor is small relative to overhead of registering it you should consider setting IsSafe = false. If this improves performance you should really rewrite your code so as to better amortize the construction of the ValueAccessor, i.e. reuse it as much as possible!
- Note
- If
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.