Loading...
Searching...
No Matches
ValueAccessor.h File Reference
`#include <openvdb/version.h>`
`#include <openvdb/Types.h>`
`#include <tbb/null_mutex.h>`
`#include <tbb/spin_mutex.h>`
`#include <cassert>`
`#include <limits>`
`#include <type_traits>`

Go to the source code of this file.

## Classes

class | ValueAccessorBase< TreeType, IsSafe >
| This base class for ValueAccessors manages registration of an accessor with a tree so that the tree can automatically clear the accessor whenever one of its nodes is deleted. More...
class | ValueAccessor< _TreeType, IsSafe, CacheLevels, MutexType >
class | ValueAccessor< TreeType, IsSafe, 0, tbb::null_mutex >
| Template specialization of the ValueAccessor with no mutex and no cache levels. More...
class | ValueAccessor< TreeType, IsSafe, 1, tbb::null_mutex >
| Template specialization of the ValueAccessor with no mutex and one cache level. More...
class | ValueAccessor< TreeType, IsSafe, 2, tbb::null_mutex >
| Template specialization of the ValueAccessor with no mutex and two cache levels. More...
class | ValueAccessor< TreeType, IsSafe, 3, tbb::null_mutex >
| Template specialization of the ValueAccessor with no mutex and three cache levels. More...
class | ValueAccessorRW< TreeType, IsSafe >
| This accessor is thread-safe (at the cost of speed) for both reading and writing to a tree. That is, multiple threads may safely access a single, shared ValueAccessorRW. More...
class | CacheItem< TreeCacheT, NodeVecT, AtRoot, BypassLeafAPI >
class | CacheItem< TreeCacheT, NodeVecT, false, true >
class | CacheItem< TreeCacheT, NodeVecT, true, false >
| The tail of a compile-time list of cached node pointers, ordered from LeafNode to RootNode. More...
class | ValueAccessor0< _TreeType, IsSafe >
| ValueAccessor with no mutex and no node caching. More...
class | ValueAccessor1< _TreeType, IsSafe, L0 >
| Value accessor with one level of node caching. More...
class | ValueAccessor2< _TreeType, IsSafe, L0, L1 >
| Value accessor with two levels of node caching. More...
class | ValueAccessor3< _TreeType, IsSafe, L0, L1, L2 >
| Value accessor with three levels of node caching. More...

## Namespaces

namespace | openvdb
namespace | openvdb::v10_0
namespace | openvdb::v10_0::tree

## Detailed Description

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.

Example:

FloatGrid grid;
FloatGrid::Accessor acc = grid.getAccessor();
// First access is slow:
acc.setValue(Coord(0, 0, 0), 100);
// Subsequent nearby accesses are fast, since the accessor now holds pointers
// to nodes that contain (0, 0, 0) along the path from the root of the grid's
// tree to the leaf:
acc.setValue(Coord(0, 0, 1), 100);
acc.getValue(Coord(0, 2, 0), 100);
// Slow, because the accessor must be repopulated:
acc.getValue(Coord(-1, -1, -1));
// Fast:
acc.getValue(Coord(-1, -1, -2));
acc.setValue(Coord(-1, -2, 0), -100);
openvdb::v10_0::Grid::getAccessor
Accessor getAccessor()
Return an accessor that provides random read and write access to this grid's voxels.
Definition Grid.h:732