Given a tree this class defines a linear array of its leafs and optional auxiliary buffers. This is useful for multi-threading computations over leaf values in a static tree, i.e. voxel values, vs topology, is dynamic. The auxiliary buffers can conventiently be used for temporal integration. Efficient methods are provided for multi-threaded swapping and sync'ing (i.e. copying) of these buffers.
More...
#include <LeafManager.h>
|
| LeafManager (TreeType &tree, size_t auxBuffersPerLeaf=0, bool serial=false) |
| Constructor from a tree reference and auxiliary buffers count (default is no auxiliary buffers). More...
|
|
| LeafManager (const LeafManager &other) |
| Shallow copy constructor called by tbb::parallel_for() threads. More...
|
|
virtual | ~LeafManager () |
|
void | rebuild (bool serial=false) |
| Use this method for (re)-initialization. It clears all existing leafs and auxiliary buffers and allocates new ones. New auxiliary buffers are initialized to the corresponding leaf node buffer. More...
|
|
void | rebuild (size_t auxBuffersPerLeaf, bool serial=false) |
| Clears all existing leafs and auxiliary buffers and allocates new ones. More...
|
|
void | rebuild (TreeType &tree, bool serial=false) |
| Clears all existing leafs and auxiliary buffers and allocates new ones. More...
|
|
void | rebuild (TreeType &tree, size_t auxBuffersPerLeaf, bool serial=false) |
| Clears all existing leafs and auxiliary buffers and allocates new ones. More...
|
|
void | rebuildAuxBuffers (size_t auxBuffersPerLeaf, bool serial=false) |
|
void | removeAuxBuffers () |
| Remove the auxiliary buffers (the leafs are unchanged) More...
|
|
void | rebuildLeafs () |
| Remove the auxiliary buffers and rebuild the array of leafs. More...
|
|
size_t | auxBufferCount () const |
| The total number of allocated auxiliary buffers. More...
|
|
size_t | auxBuffersPerLeaf () const |
| The number of auxiliary buffers per LeafNode. More...
|
|
size_t | leafCount () const |
|
TreeType & | tree () |
|
LeafType & | leaf (size_t leafId) |
|
BufferType & | getBuffer (size_t leafId, size_t bufferId) |
|
RangeType | getRange (size_t grainsize=1) |
| Return range of the buffer-array. Needed for multithreading by tbb. More...
|
|
bool | swapLeafBuffer (size_t bufferId, bool serial=false) |
| Swaps the leaf node with the specified auxiliary buffer. More...
|
|
bool | swapBuffer (size_t bufferId1, size_t bufferId2, bool serial=false) |
|
bool | syncAuxBuffer (size_t bufferId, bool serial=false) |
| Syncs up the specified auxiliary buffer with the corresponding leaf node buffer. More...
|
|
bool | syncAllBuffers (bool serial=false) |
| Syncs up all auxiliary buffer with the corresponding leaf node buffer. More...
|
|
void | operator() (const RangeType &r) const |
| Used internally by tbb::parallel_for() - never call it directly! More...
|
|
template<typename TreeT>
class openvdb::v0_104_0::tree::LeafManager< TreeT >
Given a tree this class defines a linear array of its leafs and optional auxiliary buffers. This is useful for multi-threading computations over leaf values in a static tree, i.e. voxel values, vs topology, is dynamic. The auxiliary buffers can conventiently be used for temporal integration. Efficient methods are provided for multi-threaded swapping and sync'ing (i.e. copying) of these buffers.
- Note
- By definition the buffers residing inside LeafNodes correspond to bufferId = 0, and any (optional) auxiliary buffers are indexed starting from one.
Constructor from a tree reference and auxiliary buffers count (default is no auxiliary buffers).
Shallow copy constructor called by tbb::parallel_for() threads.
size_t auxBufferCount |
( |
| ) |
const |
|
inline |
The total number of allocated auxiliary buffers.
size_t auxBuffersPerLeaf |
( |
| ) |
const |
|
inline |
The number of auxiliary buffers per LeafNode.
BufferType& getBuffer |
( |
size_t |
leafId, |
|
|
size_t |
bufferId |
|
) |
| |
|
inline |
- Returns
- The leaf or auxiliary buffer specified by leafId. If bufferId is zero the LeafNode buffer is returned, else the n'th auxiliary buffer where n = bufferId -1.
- Note
- For performance reasons no range checks are performed on the inputs - other than asserts! Since auxiliary buffers, unlike leaf buffers, are likely to not exist, be especially caseful when specifying the bufferId index.
Return range of the buffer-array. Needed for multithreading by tbb.
- Returns
- the leaf specified by leafId.
- Note
- For performance reasons no range check is performed - other than assert!
size_t leafCount |
( |
| ) |
const |
|
inline |
- Returns
- size of the of the LeafManager, corresponding to the number of leaf nodes.
Used internally by tbb::parallel_for() - never call it directly!
All methods below are for internal use only and should never be called directly
void rebuild |
( |
bool |
serial = false | ) |
|
|
inline |
Use this method for (re)-initialization. It clears all existing leafs and auxiliary buffers and allocates new ones. New auxiliary buffers are initialized to the corresponding leaf node buffer.
void rebuild |
( |
size_t |
auxBuffersPerLeaf, |
|
|
bool |
serial = false |
|
) |
| |
|
inline |
Clears all existing leafs and auxiliary buffers and allocates new ones.
void rebuild |
( |
TreeType & |
tree, |
|
|
bool |
serial = false |
|
) |
| |
|
inline |
Clears all existing leafs and auxiliary buffers and allocates new ones.
void rebuild |
( |
TreeType & |
tree, |
|
|
size_t |
auxBuffersPerLeaf, |
|
|
bool |
serial = false |
|
) |
| |
|
inline |
Clears all existing leafs and auxiliary buffers and allocates new ones.
void rebuildAuxBuffers |
( |
size_t |
auxBuffersPerLeaf, |
|
|
bool |
serial = false |
|
) |
| |
|
inline |
Use this method to change to number of auxiliary buffers. If auxBuffersPerLeaf=0 all existing auxiliary buffers are deleted, but the leaf nodes are always unchanged. Also note that new auxiliary buffers are initialized as a copy of the corresponding leaf node buffer.
Remove the auxiliary buffers and rebuild the array of leafs.
void removeAuxBuffers |
( |
| ) |
|
|
inline |
Remove the auxiliary buffers (the leafs are unchanged)
bool swapBuffer |
( |
size_t |
bufferId1, |
|
|
size_t |
bufferId2, |
|
|
bool |
serial = false |
|
) |
| |
|
inline |
bool swapLeafBuffer |
( |
size_t |
bufferId, |
|
|
bool |
serial = false |
|
) |
| |
|
inline |
Swaps the leaf node with the specified auxiliary buffer.
- Returns
- true if swap was successfuly
- Parameters
-
bufferId | Index of the buffer that will be swapped with the corresponding leaf node buffer. |
serial | if false, swap buffers in parallel using multiple threads. |
- Note
- Recall that the indexing of auxiliary buffers is 1-based, since bufferId=0 correponds to the leaf node buffer. So bufferId=1 corresponds to the first auxiliary buffer.
bool syncAllBuffers |
( |
bool |
serial = false | ) |
|
|
inline |
Syncs up all auxiliary buffer with the corresponding leaf node buffer.
- Returns
- true if sync was successfuly
- Parameters
-
serial | if false, sync buffers in parallel using multiple threads. |
bool syncAuxBuffer |
( |
size_t |
bufferId, |
|
|
bool |
serial = false |
|
) |
| |
|
inline |
Syncs up the specified auxiliary buffer with the corresponding leaf node buffer.
- Returns
- true if sync was successfuly
- Parameters
-
bufferId | Index of the buffer that will contain a copy of the corresponding leaf node buffer. |
serial | if false, sync buffers in parallel using multiple threads. |
- Note
- Recall that the indexing of auxiliary buffers is 1-based, since bufferId=0 correponds to the leaf node buffer. So bufferId=1 corresponds to the first auxiliary buffer.
The documentation for this class was generated from the following file: