OpenVDB 10.0.1
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | Friends | List of all members
ValueAccessor3< _TreeType, IsSafe, L0, L1, L2 > Class Template Reference

Value accessor with three levels of node caching. More...

#include <openvdb/tree/ValueAccessor.h>

Inheritance diagram for ValueAccessor3< _TreeType, IsSafe, L0, L1, L2 >:
ValueAccessorBase< _TreeType, IsSafe >

Public Types

using TreeType = _TreeType
 
using ValueType = typename TreeType::ValueType
 
using RootNodeT = typename TreeType::RootNodeType
 
using LeafNodeT = typename TreeType::LeafNodeType
 
using BaseT = ValueAccessorBase< TreeType, IsSafe >
 
using InvTreeT = typename RootNodeT::NodeChainType
 
using NodeT0 = typename InvTreeT::template Get< L0 >
 
using NodeT1 = typename InvTreeT::template Get< L1 >
 
using NodeT2 = typename InvTreeT::template Get< L2 >
 

Public Member Functions

 ValueAccessor3 (TreeType &tree)
 Constructor from a tree.
 
 ValueAccessor3 (const ValueAccessor3 &other)
 Copy constructor.
 
ValueAccessor3operator= (const ValueAccessor3 &other)
 Assignment operator.
 
 ~ValueAccessor3 () override=default
 Virtual destructor.
 
bool isCached (const Coord &xyz) const
 
const ValueTypegetValue (const Coord &xyz) const
 Return the value of the voxel at the given coordinates.
 
bool isValueOn (const Coord &xyz) const
 Return the active state of the voxel at the given coordinates.
 
bool probeValue (const Coord &xyz, ValueType &value) const
 Return the active state of the voxel as well as its value.
 
int getValueDepth (const Coord &xyz) const
 
bool isVoxel (const Coord &xyz) const
 
void setValue (const Coord &xyz, const ValueType &value)
 Set the value of the voxel at the given coordinates and mark the voxel as active.
 
void setValueOn (const Coord &xyz, const ValueType &value)
 
void setValueOnly (const Coord &xyz, const ValueType &value)
 Set the value of the voxel at the given coordinate but preserves its active state.
 
void setValueOff (const Coord &xyz, const ValueType &value)
 Set the value of the voxel at the given coordinates and mark the voxel as inactive.
 
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.
 
template<typename ModifyOp >
void modifyValueAndActiveState (const Coord &xyz, const ModifyOp &op)
 Apply a functor to the voxel at the given coordinates.
 
void setActiveState (const Coord &xyz, bool on=true)
 Set the active state of the voxel at the given coordinates without changing its value.
 
void setValueOn (const Coord &xyz)
 Mark the voxel at the given coordinates as active without changing its value.
 
void setValueOff (const Coord &xyz)
 Mark the voxel at the given coordinates as inactive without changing its value.
 
template<typename NodeT >
NodeT * getNode ()
 Return the cached node of type NodeType. [Mainly for internal use].
 
template<typename NodeT >
void insertNode (const Coord &xyz, NodeT &node)
 
template<typename NodeT >
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.
 
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.
 
LeafNodeTtouchLeaf (const Coord &xyz)
 
template<typename NodeT >
NodeT * probeNode (const Coord &xyz)
 
LeafNodeTprobeLeaf (const Coord &xyz)
 
template<typename NodeT >
const NodeT * probeConstNode (const Coord &xyz) const
 
const LeafNodeTprobeConstLeaf (const Coord &xyz) const
 
const LeafNodeTprobeLeaf (const Coord &xyz) const
 
void clear () override
 Remove all the cached nodes and invalidate the corresponding hash-keys.
 
_TreeType * getTree () const
 Return a pointer to the tree associated with this accessor.
 
_TreeType & tree () const
 Return a reference to the tree associated with this accessor.
 

Static Public Member Functions

static Index numCacheLevels ()
 Return the number of cache levels employed by this ValueAccessor.
 
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).
 

Static Public Attributes

static constexpr bool BypassLeafAPI
 
static const bool IsConstTree
 

Protected Attributes

_TreeType * mTree
 

Friends

template<typename >
class RootNode
 
template<typename , Index >
class InternalNode
 
template<typename , Index >
class LeafNode
 
template<typename >
class Tree
 

Detailed Description

template<typename _TreeType, bool IsSafe, Index L0, Index L1, Index L2>
class openvdb::v10_0::tree::ValueAccessor3< _TreeType, IsSafe, L0, L1, L2 >

Value accessor with three levels of node caching.

The node cache levels are specified by L0, L1, and L2 with the default values 0, 1 and 2 (defined in the forward declaration) corresponding to a LeafNode, its parent InternalNode, and its parent InternalNode. Since the default configuration of all typed trees and grids, e.g., FloatTree or FloatGrid, has a depth of four, this value accessor is the one used by default.

Note
This class is for experts only and should rarely be used directly. Instead use ValueAccessor with its default template arguments

Member Typedef Documentation

◆ BaseT

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
using BaseT = ValueAccessorBase<TreeType, IsSafe>

◆ InvTreeT

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
using InvTreeT = typename RootNodeT::NodeChainType

◆ LeafNodeT

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
using LeafNodeT = typename TreeType::LeafNodeType

◆ NodeT0

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
using NodeT0 = typename InvTreeT::template Get<L0>

◆ NodeT1

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
using NodeT1 = typename InvTreeT::template Get<L1>

◆ NodeT2

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
using NodeT2 = typename InvTreeT::template Get<L2>

◆ RootNodeT

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
using RootNodeT = typename TreeType::RootNodeType

◆ TreeType

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
using TreeType = _TreeType

◆ ValueType

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
using ValueType = typename TreeType::ValueType

Constructor & Destructor Documentation

◆ ValueAccessor3() [1/2]

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
ValueAccessor3 ( TreeType tree)
inline

Constructor from a tree.

◆ ValueAccessor3() [2/2]

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
ValueAccessor3 ( const ValueAccessor3< _TreeType, IsSafe, L0, L1, L2 > &  other)
inline

Copy constructor.

◆ ~ValueAccessor3()

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
~ValueAccessor3 ( )
overridedefault

Virtual destructor.

Member Function Documentation

◆ addLeaf()

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
void addLeaf ( LeafNodeT leaf)
inline

Add the specified leaf to this tree, possibly creating a child branch in the process. If the leaf node already exists, replace it.

◆ addTile()

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
void addTile ( Index  level,
const Coord xyz,
const ValueType value,
bool  state 
)
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.

◆ clear()

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
void clear ( )
inlineoverridevirtual

Remove all the cached nodes and invalidate the corresponding hash-keys.

Implements ValueAccessorBase< _TreeType, IsSafe >.

◆ eraseNode()

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
template<typename NodeT >
void eraseNode ( )
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]

◆ getNode()

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
template<typename NodeT >
NodeT * getNode ( )
inline

Return the cached node of type NodeType. [Mainly for internal use].

◆ getTree()

_TreeType * getTree ( ) const
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).

◆ getValue()

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
const ValueType & getValue ( const Coord xyz) const
inline

Return the value of the voxel at the given coordinates.

◆ getValueDepth()

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
int getValueDepth ( const Coord xyz) const
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).

◆ insertNode()

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
template<typename NodeT >
void insertNode ( const Coord xyz,
NodeT &  node 
)
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]

◆ isCached()

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
bool isCached ( const Coord xyz) const
inline

Return true if any of the nodes along the path to the given voxel have been cached.

◆ isSafe()

static bool isSafe ( )
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).

◆ isValueOn()

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
bool isValueOn ( const Coord xyz) const
inline

Return the active state of the voxel at the given coordinates.

◆ isVoxel()

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
bool isVoxel ( const Coord xyz) const
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.

◆ modifyValue()

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
template<typename ModifyOp >
void modifyValue ( const Coord xyz,
const ModifyOp &  op 
)
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.

◆ modifyValueAndActiveState()

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
template<typename ModifyOp >
void modifyValueAndActiveState ( const Coord xyz,
const ModifyOp &  op 
)
inline

Apply a functor to the voxel at the given coordinates.

See Tree::modifyValueAndActiveState() for details.

◆ numCacheLevels()

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
static Index numCacheLevels ( )
inlinestatic

Return the number of cache levels employed by this ValueAccessor.

◆ operator=()

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
ValueAccessor3 & operator= ( const ValueAccessor3< _TreeType, IsSafe, L0, L1, L2 > &  other)
inline

Assignment operator.

◆ probeConstLeaf()

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
const LeafNodeT * probeConstLeaf ( const Coord xyz) const
inline
Returns
a const pointer to the leaf node that contains voxel (x, y, z) and if it doesn't exist, return nullptr.

◆ probeConstNode()

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
template<typename NodeT >
const NodeT * probeConstNode ( const Coord xyz) const
inline
Returns
a const pointer to the node of the specified type that contains voxel (x, y, z) and if it doesn't exist, return nullptr.

◆ probeLeaf() [1/2]

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
LeafNodeT * probeLeaf ( const Coord xyz)
inline
Returns
a pointer to the leaf node that contains voxel (x, y, z) and if it doesn't exist, return nullptr.

◆ probeLeaf() [2/2]

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
const LeafNodeT * probeLeaf ( const Coord xyz) const
inline

◆ probeNode()

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
template<typename NodeT >
NodeT * probeNode ( const Coord xyz)
inline
Returns
a pointer to the node of the specified type that contains voxel (x, y, z) and if it doesn't exist, return nullptr.

◆ probeValue()

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
bool probeValue ( const Coord xyz,
ValueType value 
) const
inline

Return the active state of the voxel as well as its value.

◆ setActiveState()

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
void setActiveState ( const Coord xyz,
bool  on = true 
)
inline

Set the active state of the voxel at the given coordinates without changing its value.

◆ setValue()

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
void setValue ( const Coord xyz,
const ValueType value 
)
inline

Set the value of the voxel at the given coordinates and mark the voxel as active.

◆ setValueOff() [1/2]

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
void setValueOff ( const Coord xyz)
inline

Mark the voxel at the given coordinates as inactive without changing its value.

◆ setValueOff() [2/2]

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
void setValueOff ( const Coord xyz,
const ValueType value 
)
inline

Set the value of the voxel at the given coordinates and mark the voxel as inactive.

◆ setValueOn() [1/2]

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
void setValueOn ( const Coord xyz)
inline

Mark the voxel at the given coordinates as active without changing its value.

◆ setValueOn() [2/2]

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
void setValueOn ( const Coord xyz,
const ValueType value 
)
inline

◆ setValueOnly()

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
void setValueOnly ( const Coord xyz,
const ValueType value 
)
inline

Set the value of the voxel at the given coordinate but preserves its active state.

◆ touchLeaf()

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
LeafNodeT * touchLeaf ( const Coord xyz)
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 all voxels.

Use this method to preallocate a static tree topology over which to safely perform multithreaded processing.

◆ tree()

_TreeType & tree ( ) const
inlineinherited

Return a reference to the tree associated with this accessor.

Friends And Related Symbol Documentation

◆ InternalNode

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
template<typename , Index >
friend class InternalNode
friend

◆ LeafNode

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
template<typename , Index >
friend class LeafNode
friend

◆ RootNode

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
template<typename >
friend class RootNode
friend

◆ Tree

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
template<typename >
friend class Tree
friend

Member Data Documentation

◆ BypassLeafAPI

template<typename _TreeType , bool IsSafe, Index L0, Index L1, Index L2>
constexpr bool BypassLeafAPI
staticconstexpr
Initial value:
=
std::is_same<NodeT0, LeafNodeT>::value &&
std::is_same<typename LeafNodeT::Buffer::StorageType, ValueType>::value

◆ IsConstTree

const bool IsConstTree
staticinherited

◆ mTree

_TreeType * mTree
protectedinherited