OpenVDB  1.2.0
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | Friends | List of all members
ValueAccessor1< TreeType, L0 > Class Template Reference

Value accessor with one level of node caching. More...

#include <ValueAccessor.h>

Inherits ValueAccessorBase< _TreeType >.

Public Types

typedef _TreeType TreeType
 
typedef TreeType::ValueType ValueType
 
typedef TreeType::RootNodeType RootNodeT
 
typedef TreeType::LeafNodeType LeafNodeT
 
typedef ValueAccessorBase
< TreeType
BaseT
 
typedef InvertedTree
< RootNodeT, RootNodeT::LEVEL >
::Type 
InvTreeT
 
typedef boost::mpl::at
< InvTreeT, boost::mpl::int_
< L0 > >::type 
NodeT0
 

Public Member Functions

 BOOST_STATIC_ASSERT (_TreeType::DEPTH >=2)
 
 BOOST_STATIC_ASSERT (L0< _TreeType::RootNodeType::LEVEL)
 
 ValueAccessor1 (TreeType &tree)
 Constructor from a tree. More...
 
 ValueAccessor1 (const ValueAccessor1 &other)
 Copy constructor. More...
 
ValueAccessor1operator= (const ValueAccessor1 &other)
 Asignment operator. More...
 
virtual ~ValueAccessor1 ()
 Virtual destructor. More...
 
bool isCached (const Coord &xyz) const
 
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 setValueOnly (const Coord &xyz, const ValueType &value)
 Set the value of the voxel at the given coordinate but preserves 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...
 
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...
 
void setValueOn (const Coord &xyz)
 Mark the voxel at the given coordinates as active without changing its value. More...
 
void setValueOff (const Coord &xyz)
 Mark the voxel at the given coordinates as inactive without changing its value. More...
 
template<typename NodeT >
NodeT * getNode ()
 Return the cached node of type NodeType. [Mainly for internal use]. More...
 
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. 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)
 
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
 
virtual void clear ()
 Remove all the cached nodes and invalidate the corresponding hash-keys. More...
 
_TreeType * getTree () const
 
_TreeType & tree () 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
 

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, Index L0 = 0>
class openvdb::v1_2_0::tree::ValueAccessor1< TreeType, L0 >

Value accessor with one level of node caching.

The node cache level is specified by L0 with the default value 0 (defined in the forward declaration) corresponding to a LeafNode.

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

Member Typedef Documentation

typedef InvertedTree<RootNodeT, RootNodeT::LEVEL>::Type InvTreeT
typedef TreeType::LeafNodeType LeafNodeT
typedef boost::mpl::at<InvTreeT, boost::mpl::int_<L0> >::type NodeT0
typedef TreeType::RootNodeType RootNodeT
typedef _TreeType TreeType
typedef TreeType::ValueType ValueType

Constructor & Destructor Documentation

ValueAccessor1 ( TreeType tree)
inline

Constructor from a tree.

ValueAccessor1 ( const ValueAccessor1< TreeType, L0 > &  other)
inline

Copy constructor.

virtual ~ValueAccessor1 ( )
inlinevirtual

Virtual destructor.

Member Function Documentation

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.

void addTile ( Index  level,
const Coord xyz,
const ValueType value,
bool  state 
)
inline

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 ( _TreeType::DEPTH >=  2)
BOOST_STATIC_ASSERT ( )
virtual void clear ( )
inlinevirtual

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

Implements ValueAccessorBase< _TreeType >.

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]

NodeT* getNode ( )
inline

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
inline

Return the value of the voxel at the given coordinates.

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

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]

bool isCached ( const Coord xyz) const
inline

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

bool isValueOn ( const Coord xyz) const
inline

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

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.

static Index numCacheLevels ( )
inlinestatic

Return the number of cache levels employed by this ValueAccessor.

ValueAccessor1& operator= ( const ValueAccessor1< TreeType, L0 > &  other)
inline

Asignment operator.

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

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

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

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

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.

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.

void setValueOff ( const Coord xyz)
inline

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

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

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

void setValueOn ( const Coord xyz)
inline

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

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

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

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

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

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

Friends And Related Function Documentation

friend class InternalNode
friend
friend class LeafNode
friend
friend class RootNode
friend
friend class Tree
friend

Member Data Documentation

const bool IsConstTree
staticinherited
_TreeType * mTree
protectedinherited

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