Loading...
Searching...
No Matches
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 <openvdb/tools/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.
| TreeToMerge (typename TreeType::Ptr treePtr, Steal)
| Non-const shared pointer tree constructor for stealing data.
| 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.
| 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.
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.
TreeType * | treeToSteal ()
| Return a pointer to the tree to be stolen.
const TreeType * | treeToDeepCopy ()
| Return a pointer to the tree to be deep-copied.
const RootNodeType * | rootPtr () const
| Retrieve a const pointer to the root node.
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`.
void | pruneMask (Index level, const Coord &ijk)
| Prune the mask and remove the node associated with this coord.
template<typename NodeT>
std::unique_ptr< NodeT > | stealOrDeepCopyNode (const Coord &ijk, const ValueType &value)
| 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 the value provided. If the tree is const, deep-copy the node and modify the mask tree to prune the node.
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.
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.
void | initializeMask ()
bool | hasMask () const
MaskTreeType * | mask ()
const MaskTreeType * | mask () const

## Detailed Description

template<typename TreeT>
struct openvdb::v11_0::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

## MaskTreeType

template<typename TreeT>

using MaskTreeType = typename TreeT::template ValueConverter<ValueMask>::Type

## RootNodeType

template<typename TreeT>

using RootNodeType = typename TreeType::RootNodeType

## TreeType

template<typename TreeT>

using TreeType = std::remove_const_t<TreeT>

## ValueType

template<typename TreeT>

using ValueType = typename TreeType::ValueType

## Constructor & Destructor Documentation

## TreeToMerge() [1/5]

template<typename TreeT>

TreeToMerge | ( |  | ) |

delete

## TreeToMerge() [2/5]

template<typename TreeT>

TreeToMerge | ( | TreeType & | tree,
|  | Steal | )

inline

Non-const pointer tree constructor for stealing data.

## TreeToMerge() [3/5]

template<typename TreeT>

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

inline

Non-const shared pointer tree constructor for stealing data.

## TreeToMerge() [4/5]

template<typename TreeT>

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() [5/5]

template<typename TreeT>

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

## addTile()

template<typename TreeT>
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.

## hasMask()

template<typename TreeT>

bool hasMask | ( |  | ) | const

## initializeMask()

template<typename TreeT>

void initializeMask | ( |  | ) |

## mask() [1/2]

template<typename TreeT>

MaskTreeType * mask | ( |  | ) |

inline

## mask() [2/2]

template<typename TreeT>

const MaskTreeType * mask | ( |  | ) | const

inline

## probeConstNode()

template<typename TreeT>
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`.

## pruneMask()

template<typename TreeT>

void pruneMask | ( | Index | level,
|  | const Coord & | ijk )

Prune the mask and remove the node associated with this coord.

## reset()

template<typename TreeT>

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.

## rootPtr()

template<typename TreeT>

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

Retrieve a const pointer to the root node.

## stealOrDeepCopyNode() [1/2]

template<typename TreeT>
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.

## stealOrDeepCopyNode() [2/2]

template<typename TreeT>
template<typename NodeT>

std::unique_ptr< NodeT > stealOrDeepCopyNode | ( | const Coord & | ijk,
|  | const ValueType & | value )

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 the value provided. If the tree is const, deep-copy the node and modify the mask tree to prune the node.

## treeToDeepCopy()

template<typename TreeT>

const TreeType * treeToDeepCopy | ( |  | ) |

inline

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

## treeToSteal()

template<typename TreeT>

TreeType * treeToSteal | ( |  | ) |

inline

Return a pointer to the tree to be stolen.