OpenVDB  1.2.0
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
ValueAccessorRW< TreeType > Struct Template Reference

#include <ValueAccessor.h>

Inherits ValueAccessor< TreeType, TreeType::DEPTH-1, tbb::spin_mutex >.

Public Types

typedef TreeType TreeType
 
typedef TreeType::RootNodeType RootNodeT
 
typedef TreeType::LeafNodeType LeafNodeT
 
typedef RootNodeT::ValueType ValueType
 
typedef ValueAccessorBase
< TreeType
BaseT
 
typedef
tbb::spin_mutex::scoped_lock 
LockT
 

Public Member Functions

 ValueAccessorRW (TreeType &tree)
 
 BOOST_STATIC_ASSERT (CacheLevels<=TreeType::DEPTH-1)
 
bool isCached (const Coord &xyz) const
 Return true if nodes along the path to the given voxel have been cached. More...
 
const ValueTypegetValue (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 setValueOn (const Coord &xyz)
 Mark the voxel at the given coordinates as active without changing its value. More...
 
void setValueOnly (const Coord &xyz, const ValueType &value)
 Set the value of the voxel at the given coordinate but preserves its active state. More...
 
void newSetValue (const Coord &xyz, const ValueType &value)
 
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...
 
void setValueOff (const Coord &xyz)
 Mark the voxel at the given coordinates as inactive without changing its value. More...
 
void setValueOnSum (const Coord &xyz, const ValueType &value)
 
void setActiveState (const Coord &xyz, bool on=true)
 Set the active state of the voxel at the given coordinates without changing its value. More...
 
NodeType * getNode ()
 Return the cached node of type NodeType. [Mainly for internal use]. More...
 
void insertNode (const Coord &xyz, NodeType &node)
 
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 xyz, possibly creating a child branch in the process. If a Node that contains xyz already exists it is replaced by a tile. More...
 
LeafNodeTtouchLeaf (const Coord &xyz)
 
LeafNodeTprobeLeaf (const Coord &xyz)
 
const LeafNodeTprobeLeaf (const Coord &xyz) const
 
const LeafNodeTprobeConstLeaf (const Coord &xyz) const
 
virtual void clear ()
 Remove all nodes from this cache, then reinsert the root node. More...
 
TreeTypegetTree () const
 
TreeTypetree () 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. 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...
 

Static Public Member Functions

static Index numCacheLevels ()
 Return the number of cache levels employed by this ValueAccessor. More...
 

Static Public Attributes

static const bool IsConstTree = boost::is_const<TreeType>::value
 

Protected Attributes

TreeTypemTree
 

Detailed Description

template<typename TreeType>
struct openvdb::v1_2_0::tree::ValueAccessorRW< TreeType >

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. For better performance, however, it is recommended that, instead, each thread be assigned its own (non-mutex protected) accessor.

Member Typedef Documentation

typedef ValueAccessorBase<TreeType> BaseT
inherited
typedef TreeType::LeafNodeType LeafNodeT
inherited
typedef tbb::spin_mutex ::scoped_lock LockT
inherited
typedef TreeType::RootNodeType RootNodeT
inherited
typedef TreeType TreeType
inherited
typedef RootNodeT::ValueType ValueType
inherited

Constructor & Destructor Documentation

ValueAccessorRW ( TreeType tree)
inline

Member Function Documentation

void addLeaf ( LeafNodeT leaf)
inlineinherited

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 
)
inlineinherited

Add a tile at the specified tree level that contains xyz, possibly creating a child branch in the process. If a Node that contains xyz already exists it is replaced by a tile.

BOOST_STATIC_ASSERT ( CacheLevels<=TreeType ::DEPTH-  1)
inherited
virtual void clear ( )
inlinevirtualinherited

Remove all nodes from this cache, then reinsert the root node.

Implements ValueAccessorBase< TreeType >.

void eraseNode ( )
inlineinherited

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]

NodeType* getNode ( )
inlineinherited

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

TreeType* getTree ( ) const
inlineinherited
Returns
a pointer to the tree associated by this ValueAccessor
Note
The only circumstance under which the return value can be NULL is if the tree from which the ValueAccessor is constructed was subsequently deleted - which generally leaves the ValueAccessor in an unsafe state!
const ValueType& getValue ( const Coord xyz) const
inlineinherited

Return the value of the voxel at the given coordinates.

int getValueDepth ( const Coord xyz) const
inlineinherited

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).

void insertNode ( const Coord xyz,
NodeType &  node 
)
inlineinherited

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]

bool isCached ( const Coord xyz) const
inlineinherited

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

bool isValueOn ( const Coord xyz) const
inlineinherited

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

bool isVoxel ( const Coord xyz) const
inlineinherited

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.

void newSetValue ( const Coord xyz,
const ValueType value 
)
inlineinherited

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

static Index numCacheLevels ( )
inlinestaticinherited

Return the number of cache levels employed by this ValueAccessor.

const LeafNodeT* probeConstLeaf ( const Coord xyz) const
inlineinherited
Returns
a const pointer to the leaf node that contains voxel (x, y, z) and if it doesn't exist, return NULL.
LeafNodeT* probeLeaf ( const Coord xyz)
inlineinherited
Returns
a pointer to the leaf node that contains voxel (x, y, z) and if it doesn't exist, return NULL.
const LeafNodeT* probeLeaf ( const Coord xyz) const
inlineinherited
bool probeValue ( const Coord xyz,
ValueType value 
) const
inlineinherited

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

void setActiveState ( const Coord xyz,
bool  on = true 
)
inlineinherited

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

void setValue ( const Coord xyz,
const ValueType value 
)
inlineinherited

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

void setValueOff ( const Coord xyz,
const ValueType value 
)
inlineinherited

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

void setValueOff ( const Coord xyz)
inlineinherited

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

void setValueOn ( const Coord xyz,
const ValueType value 
)
inlineinherited

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

void setValueOn ( const Coord xyz)
inlineinherited

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

void setValueOnly ( const Coord xyz,
const ValueType value 
)
inlineinherited

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

void setValueOnSum ( const Coord xyz,
const ValueType value 
)
inlineinherited

Set the value of the voxel at the given coordinates to the sum of its current value and the given value, and mark the voxel as active.

LeafNodeT* touchLeaf ( const Coord xyz)
inlineinherited
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.

TreeType& tree ( ) const
inlineinherited
Returns
a reference to the tree associated by this ValueAccessor

Member Data Documentation

const bool IsConstTree = boost::is_const<TreeType>::value
staticinherited
TreeType* mTree
protectedinherited

The documentation for this struct was generated from the following file: