OpenVDB  8.1.1
Classes | Public Types | Public Member Functions | List of all members
TreeToMerge< TreeT > Struct Template Reference

Convenience class that contains a pointer to a tree to be stolen or deep copied depending on the tag dispatch class used and a subset of methods to retrieve data from the tree. More...

#include <Merge.h>

Classes

struct  MaskPtr
 Wrapper around unique_ptr that deep-copies mask on copy construction. More...
 
struct  MaskUnionOp
 DynamicNodeManager operator used to generate a mask of the input tree, but with dense leaf nodes replaced with active tiles for compactness. More...
 

Public Types

using TreeType = std::remove_const_t< TreeT >
 
using RootNodeType = typename TreeType::RootNodeType
 
using ValueType = typename TreeType::ValueType
 
using MaskTreeType = typename TreeT::template ValueConverter< ValueMask >::Type
 

Public Member Functions

 TreeToMerge ()=delete
 
 TreeToMerge (TreeType &tree, Steal)
 Non-const pointer tree constructor for stealing data. More...
 
 TreeToMerge (typename TreeType::Ptr treePtr, Steal)
 Non-const shared pointer tree constructor for stealing data. More...
 
 TreeToMerge (const TreeType &tree, DeepCopy, bool initialize=true)
 Const tree pointer constructor for deep-copying data. As the tree is not mutable and thus cannot be pruned, a lightweight mask tree with the same topology is created that can be pruned to use as a reference. Initialization of this mask tree can optionally be disabled for delayed construction. More...
 
 TreeToMerge (TreeType &tree, DeepCopy tag, bool initialize=true)
 Non-const tree pointer constructor for deep-copying data. The tree is not intended to be modified so is not pruned, instead a lightweight mask tree with the same topology is created that can be pruned to use as a reference. Initialization of this mask tree can optionally be disabled for delayed construction. More...
 
void reset (typename TreeType::Ptr treePtr, Steal)
 Reset the non-const tree shared pointer. This is primarily used to preserve the order of trees to merge in a container but have the data in the tree be lazily loaded or resampled. More...
 
TreeTypetreeToSteal ()
 Return a pointer to the tree to be stolen. More...
 
const TreeTypetreeToDeepCopy ()
 Return a pointer to the tree to be deep-copied. More...
 
const RootNodeTyperootPtr () const
 Retrieve a const pointer to the root node. More...
 
template<typename NodeT >
const NodeT * probeConstNode (const Coord &ijk) const
 Return a pointer to the node of type NodeT that contains voxel (x, y, z). If no such node exists, return nullptr. More...
 
template<typename NodeT >
std::unique_ptr< NodeT > stealOrDeepCopyNode (const Coord &ijk)
 Return a pointer to the node of type NodeT that contains voxel (x, y, z). If the tree is non-const, steal the node and replace it with an inactive background-value tile. If the tree is const, deep-copy the node and modify the mask tree to prune the node. More...
 
template<typename NodeT >
void addTile (const Coord &ijk, const ValueType &value, bool active)
 Add a tile containing voxel (x, y, z) at the level of NodeT, deleting the existing branch if necessary. More...
 
void initializeMask ()
 
bool hasMask () const
 
MaskTreeTypemask ()
 
const MaskTreeTypemask () const
 

Detailed Description

template<typename TreeT>
struct openvdb::v8_1::tools::TreeToMerge< TreeT >

Convenience class that contains a pointer to a tree to be stolen or deep copied depending on the tag dispatch class used and a subset of methods to retrieve data from the tree.

The primary purpose of this class is to be able to create an array of TreeToMerge objects that each store a tree to be stolen or a tree to be deep-copied in an arbitrary order. Certain operations such as floating-point addition are non-associative so the order in which they are merged is important for the operation to remain deterministic regardless of how the data is being extracted from the tree.

Note
Stealing data requires a non-const tree pointer. There is a constructor to pass in a tree shared pointer for cases where it is desirable for this class to maintain shared ownership.

Member Typedef Documentation

using MaskTreeType = typename TreeT::template ValueConverter<ValueMask>::Type
using RootNodeType = typename TreeType::RootNodeType
using TreeType = std::remove_const_t<TreeT>
using ValueType = typename TreeType::ValueType

Constructor & Destructor Documentation

TreeToMerge ( )
delete
TreeToMerge ( TreeType tree,
Steal   
)
inline

Non-const pointer tree constructor for stealing data.

TreeToMerge ( typename TreeType::Ptr  treePtr,
Steal   
)
inline

Non-const shared pointer tree constructor for stealing data.

TreeToMerge ( const TreeType tree,
DeepCopy  ,
bool  initialize = true 
)
inline

Const tree pointer constructor for deep-copying data. As the tree is not mutable and thus cannot be pruned, a lightweight mask tree with the same topology is created that can be pruned to use as a reference. Initialization of this mask tree can optionally be disabled for delayed construction.

TreeToMerge ( TreeType tree,
DeepCopy  tag,
bool  initialize = true 
)
inline

Non-const tree pointer constructor for deep-copying data. The tree is not intended to be modified so is not pruned, instead a lightweight mask tree with the same topology is created that can be pruned to use as a reference. Initialization of this mask tree can optionally be disabled for delayed construction.

Member Function Documentation

void addTile ( const Coord &  ijk,
const ValueType value,
bool  active 
)

Add a tile containing voxel (x, y, z) at the level of NodeT, deleting the existing branch if necessary.

bool hasMask ( ) const
void initializeMask ( )
MaskTreeType* mask ( )
inline
const MaskTreeType* mask ( ) const
inline
const NodeT * probeConstNode ( const Coord &  ijk) const

Return a pointer to the node of type NodeT that contains voxel (x, y, z). If no such node exists, return nullptr.

void reset ( typename TreeType::Ptr  treePtr,
Steal   
)

Reset the non-const tree shared pointer. This is primarily used to preserve the order of trees to merge in a container but have the data in the tree be lazily loaded or resampled.

const TreeToMerge< TreeT >::RootNodeType * rootPtr ( ) const

Retrieve a const pointer to the root node.

std::unique_ptr< NodeT > stealOrDeepCopyNode ( const Coord &  ijk)

Return a pointer to the node of type NodeT that contains voxel (x, y, z). If the tree is non-const, steal the node and replace it with an inactive background-value tile. If the tree is const, deep-copy the node and modify the mask tree to prune the node.

const TreeType* treeToDeepCopy ( )
inline

Return a pointer to the tree to be deep-copied.

TreeType* treeToSteal ( )
inline

Return a pointer to the tree to be stolen.


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