31#ifndef OPENVDB_TREE_VALUEACCESSOR_HAS_BEEN_INCLUDED
32#define OPENVDB_TREE_VALUEACCESSOR_HAS_BEEN_INCLUDED
34#include <openvdb/version.h>
37#include <tbb/null_mutex.h>
38#include <tbb/spin_mutex.h>
51template<
typename TreeType,
bool IsSafe = true>
53template<
typename TreeType,
bool IsSafe = true, Index L0 = 0>
55template<
typename TreeType,
bool IsSafe = true, Index L0 = 0, Index L1 = 1>
57template<
typename TreeType,
bool IsSafe = true, Index L0 = 0, Index L1 = 1, Index L2 = 2>
59template<
typename TreeCacheT,
typename NodeVecT,
bool AtRoot
60#if OPENVDB_ABI_VERSION_NUMBER >= 10
62 std::is_same<typename NodeVecT::Front, typename NodeVecT::Front::LeafNodeType>::value &&
63 std::is_same<typename NodeVecT::Front::LeafNodeType::Buffer::StorageType, typename NodeVecT::Front::ValueType>::value
91template<
typename TreeType,
bool IsSafe>
95 static const bool IsConstTree = std::is_const<TreeType>::value;
107 if (IsSafe) tree.attachAccessor(*
this);
118 TreeType&
tree()
const { assert(mTree);
return *mTree; }
122 if (IsSafe && mTree) mTree->attachAccessor(*
this);
127 if (&other !=
this) {
128 if (IsSafe && mTree) mTree->releaseAccessor(*
this);
130 if (IsSafe && mTree) mTree->attachAccessor(*
this);
139 template<
typename>
friend class Tree;
186template<
typename _TreeType,
188 Index CacheLevels = _TreeType::DEPTH-1,
189 typename MutexType = tbb::null_mutex>
193 static_assert(CacheLevels < _TreeType::DEPTH,
"cache size exceeds tree depth");
200 using LockT =
typename MutexType::scoped_lock;
201 using BaseT::IsConstTree;
203#if OPENVDB_ABI_VERSION_NUMBER >= 10
207 static constexpr bool BypassLeafAPI = CacheLevels >= 1 &&
208 std::is_same<typename LeafNodeT::Buffer::StorageType, ValueType>::value;
213 mCache.insert(
Coord(), &tree.root());
220 if (&other !=
this) {
221 this->BaseT::operator=(other);
222 mCache.copy(*
this, other.mCache);
238 return mCache.getValue(xyz);
248 return mCache.probeValue(xyz,
value);
257 return mCache.getValueDepth(xyz);
269 mCache.setValue(xyz,
value);
278 mCache.setValueOnly(xyz,
value);
285 mCache.setValueOff(xyz,
value);
291 template<
typename ModifyOp>
295 mCache.modifyValue(xyz, op);
300 template<
typename ModifyOp>
304 mCache.modifyValueAndActiveState(xyz, op);
311 mCache.setActiveState(xyz, on);
319 template<
typename NodeType>
323 NodeType* node =
nullptr;
324 mCache.getNode(node);
330 template<
typename NodeType>
334 mCache.insert(xyz, &node);
340 template<
typename NodeType>
341 void eraseNode() {
LockT lock(mMutex); NodeType* node =
nullptr; mCache.erase(node); }
348 mCache.addLeaf(leaf);
356 mCache.addTile(level, xyz,
value, state);
367 return mCache.touchLeaf(xyz);
373 template<
typename NodeT>
377 return mCache.template probeNode<NodeT>(xyz);
379 template<
typename NodeT>
383 return mCache.template probeConstNode<NodeT>(xyz);
385 template<
typename NodeT>
388 return this->
template probeConstNode<NodeT>(xyz);
398 return mCache.probeLeaf(xyz);
403 return mCache.probeConstLeaf(xyz);
413 if (this->mTree) mCache.insert(
Coord(), &(this->mTree->root()));
422 template<
typename>
friend class Tree;
426 void release()
override
429 this->BaseT::release();
437 template<
typename NodeType>
438 void insert(
const Coord& xyz, NodeType* node) { mCache.insert(xyz, node); }
441 using InvTreeT =
typename RootNodeT::NodeChainType;
443 static constexpr int64_t First = CacheLevels;
445 using SubtreeT =
typename InvTreeT::template RemoveByIndex<First, Last-1>;
446 using CacheItemT = CacheItem<ValueAccessor, SubtreeT, SubtreeT::Size==1>;
449 mutable CacheItemT mCache;
450 mutable MutexType mMutex;
458template<
typename TreeType,
bool IsSafe>
470template<
typename TreeType,
bool IsSafe>
482template<
typename TreeType,
bool IsSafe>
494template<
typename TreeType,
bool IsSafe>
516template<
typename TreeType,
bool IsSafe = true>
535template<
typename TreeCacheT,
typename NodeVecT,
bool AtRoot
536#if OPENVDB_ABI_VERSION_NUMBER >= 10
562 , mNext(parent, other.mNext)
571 mNext.copy(parent, other.mNext);
578 return (this->isHashed(xyz) || mNext.isCached(xyz));
584 mHash = (node !=
nullptr) ? xyz & ~(NodeType::DIM-1) : Coord::max();
588 template<
typename OtherNodeType>
589 void insert(
const Coord& xyz,
const OtherNodeType* node) { mNext.insert(xyz, node); }
594 template<
typename OtherNodeType>
595 void erase(
const OtherNodeType* node) { mNext.erase(node); }
598 void clear() { mHash = Coord::max(); mNode =
nullptr; mNext.clear(); }
607 static_assert(!TreeCacheT::IsConstTree,
"can't get a non-const node from a const tree");
608 node =
const_cast<NodeType*
>(mNode);
611 template<
typename OtherNodeType>
612 void getNode(OtherNodeType*& node) { mNext.getNode(node); }
617 if (this->isHashed(xyz)) {
619 return mNode->getValueAndCache(xyz, *mParent);
621 return mNext.getValue(xyz);
626 static_assert(!TreeCacheT::IsConstTree,
"can't add a node to a const tree");
627 if (NodeType::LEVEL == 0) {
632 if (this->isHashed(leaf->origin())) {
634 return const_cast<NodeType*
>(mNode)->addLeafAndCache(leaf, *mParent);
643 static_assert(!TreeCacheT::IsConstTree,
"can't add a tile to a const tree");
644 if (NodeType::LEVEL >= level && this->isHashed(xyz)) {
646 const_cast<NodeType*
>(mNode)->addTileAndCache(level, xyz,
value, state, *mParent);
649 mNext.addTile(level, xyz,
value, state);
654 static_assert(!TreeCacheT::IsConstTree,
"can't get a non-const node from a const tree");
655 if (this->isHashed(xyz)) {
657 return const_cast<NodeType*
>(mNode)->touchLeafAndCache(xyz, *mParent);
659 return mNext.touchLeaf(xyz);
664 static_assert(!TreeCacheT::IsConstTree,
"can't get a non-const node from a const tree");
665 if (this->isHashed(xyz)) {
667 return const_cast<NodeType*
>(mNode)->probeLeafAndCache(xyz, *mParent);
669 return mNext.probeLeaf(xyz);
674 if (this->isHashed(xyz)) {
676 return mNode->probeConstLeafAndCache(xyz, *mParent);
678 return mNext.probeConstLeaf(xyz);
681 template<
typename NodeT>
684 static_assert(!TreeCacheT::IsConstTree,
"can't get a non-const node from a const tree");
685 if constexpr ((std::is_same<NodeT, NodeType>::value)) {
686 if (this->isHashed(xyz)) {
688 return reinterpret_cast<NodeT*
>(
const_cast<NodeType*
>(mNode));
692 if (NodeT::LEVEL < NodeType::LEVEL && mNode) {
694 return const_cast<NodeType*
>(mNode)->
template probeNodeAndCache<NodeT>(xyz, *mParent);
698 return mNext.template probeNode<NodeT>(xyz);
702 template<
typename NodeT>
705 if constexpr ((std::is_same<NodeT, NodeType>::value)) {
706 if (this->isHashed(xyz)) {
708 return reinterpret_cast<const NodeT*
>(mNode);
712 if (NodeT::LEVEL < NodeType::LEVEL && mNode) {
714 return mNode->template probeConstNodeAndCache<NodeT>(xyz, *mParent);
718 return mNext.template probeConstNode<NodeT>(xyz);
725 if (this->isHashed(xyz)) {
727 return mNode->isValueOnAndCache(xyz, *mParent);
729 return mNext.isValueOn(xyz);
735 if (this->isHashed(xyz)) {
737 return mNode->probeValueAndCache(xyz,
value, *mParent);
739 return mNext.probeValue(xyz,
value);
744 if (this->isHashed(xyz)) {
746 return static_cast<int>(TreeCacheT::RootNodeT::LEVEL) -
747 static_cast<int>(mNode->getValueLevelAndCache(xyz, *mParent));
749 return mNext.getValueDepth(xyz);
755 if (this->isHashed(xyz)) {
757 return mNode->getValueLevelAndCache(xyz, *mParent)==0;
759 return mNext.isVoxel(xyz);
766 if (this->isHashed(xyz)) {
768 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
769 const_cast<NodeType*
>(mNode)->setValueAndCache(xyz,
value, *mParent);
771 mNext.setValue(xyz,
value);
776 if (this->isHashed(xyz)) {
778 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
779 const_cast<NodeType*
>(mNode)->setValueOnlyAndCache(xyz,
value, *mParent);
781 mNext.setValueOnly(xyz,
value);
789 template<
typename ModifyOp>
792 if (this->isHashed(xyz)) {
794 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
795 const_cast<NodeType*
>(mNode)->modifyValueAndCache(xyz, op, *mParent);
797 mNext.modifyValue(xyz, op);
803 template<
typename ModifyOp>
806 if (this->isHashed(xyz)) {
808 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
809 const_cast<NodeType*
>(mNode)->modifyValueAndActiveStateAndCache(xyz, op, *mParent);
811 mNext.modifyValueAndActiveState(xyz, op);
818 if (this->isHashed(xyz)) {
820 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
821 const_cast<NodeType*
>(mNode)->setValueOffAndCache(xyz,
value, *mParent);
823 mNext.setValueOff(xyz,
value);
830 if (this->isHashed(xyz)) {
832 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
833 const_cast<NodeType*
>(mNode)->setActiveStateAndCache(xyz, on, *mParent);
835 mNext.setActiveState(xyz, on);
843 bool isHashed(
const Coord& xyz)
const
846 && (xyz[1] &
~Coord::ValueType(NodeType::DIM-1)) == mHash[1]
852 const NodeType* mNode;
853 using RestT =
typename NodeVecT::PopFront;
854#if OPENVDB_ABI_VERSION_NUMBER >= 10
857 CacheItem<TreeCacheT, RestT, RestT::Size == 1,
false> mNext;
859 CacheItem<TreeCacheT, RestT, RestT::Size == 1> mNext;
864#if OPENVDB_ABI_VERSION_NUMBER >= 10
866template<
typename TreeCacheT,
typename NodeVecT>
875 static_assert(std::is_same<NodeType, LeafNodeType>::value);
882 , mBuffer(nullptr) {}
890 , mNext(parent, other.mNext)
891 , mBuffer(other.mBuffer) {}
898 mNext.copy(parent, other.mNext);
899 mBuffer = other.mBuffer;
906 return (this->isHashed(xyz) || mNext.isCached(xyz));
912 mHash = (node !=
nullptr) ? xyz & ~(NodeType::DIM-1) : Coord::max();
914 mBuffer = node ? node->buffer().data() :
nullptr;
917 template<
typename OtherNodeType>
918 void insert(
const Coord& xyz,
const OtherNodeType* node) { mNext.insert(xyz, node); }
923 template<
typename OtherNodeType>
924 void erase(
const OtherNodeType* node) { mNext.erase(node); }
927 void clear() { mHash = Coord::max(); mNode =
nullptr; mNext.clear(); }
936 static_assert(!TreeCacheT::IsConstTree,
"can't get a non-const node from a const tree");
937 node =
const_cast<NodeType*
>(mNode);
940 template<
typename OtherNodeType>
941 void getNode(OtherNodeType*& node) { mNext.getNode(node); }
946 if (this->isHashed(xyz)) {
948 return mBuffer[LeafNodeType::coordToOffset(xyz)];
950 return mNext.getValue(xyz);
960 static_assert(!TreeCacheT::IsConstTree,
"can't add a tile to a const tree");
961 if (NodeType::LEVEL >= level && this->isHashed(xyz)) {
963 const_cast<NodeType*
>(mNode)->addTileAndCache(level, xyz,
value, state, *mParent);
966 mNext.addTile(level, xyz,
value, state);
971 static_assert(!TreeCacheT::IsConstTree,
"can't get a non-const node from a const tree");
972 if (this->isHashed(xyz)) {
974 return const_cast<NodeType*
>(mNode)->touchLeafAndCache(xyz, *mParent);
976 return mNext.touchLeaf(xyz);
981 static_assert(!TreeCacheT::IsConstTree,
"can't get a non-const node from a const tree");
982 if (this->isHashed(xyz)) {
984 return const_cast<NodeType*
>(mNode)->probeLeafAndCache(xyz, *mParent);
986 return mNext.probeLeaf(xyz);
991 if (this->isHashed(xyz)) {
993 return mNode->probeConstLeafAndCache(xyz, *mParent);
995 return mNext.probeConstLeaf(xyz);
998 template<
typename NodeT>
1001 static_assert(!TreeCacheT::IsConstTree,
"can't get a non-const node from a const tree");
1002 if constexpr ((std::is_same<NodeT, NodeType>::value)) {
1003 if (this->isHashed(xyz)) {
1005 return reinterpret_cast<NodeT*
>(
const_cast<NodeType*
>(mNode));
1009 if (NodeT::LEVEL < NodeType::LEVEL && mNode) {
1011 return const_cast<NodeType*
>(mNode)->
template probeNodeAndCache<NodeT>(xyz, *mParent);
1015 return mNext.template probeNode<NodeT>(xyz);
1019 template<
typename NodeT>
1022 if constexpr ((std::is_same<NodeT, NodeType>::value)) {
1023 if (this->isHashed(xyz)) {
1025 return reinterpret_cast<const NodeT*
>(mNode);
1029 if (NodeT::LEVEL < NodeType::LEVEL && mNode) {
1031 return mNode->template probeConstNodeAndCache<NodeT>(xyz, *mParent);
1035 return mNext.template probeConstNode<NodeT>(xyz);
1042 if (this->isHashed(xyz)) {
1044 return mNode->isValueOnAndCache(xyz, *mParent);
1046 return mNext.isValueOn(xyz);
1052 if (this->isHashed(xyz)) {
1055 const auto offset = LeafNodeType::coordToOffset(xyz);
1056 value = mBuffer[offset];
1057 return mNode->isValueOn(offset);
1059 return mNext.probeValue(xyz,
value);
1064 if (this->isHashed(xyz)) {
1066 return static_cast<int>(TreeCacheT::RootNodeT::LEVEL) -
1067 static_cast<int>(mNode->getValueLevelAndCache(xyz, *mParent));
1069 return mNext.getValueDepth(xyz);
1075 if (this->isHashed(xyz)) {
1077 return mNode->getValueLevelAndCache(xyz, *mParent)==0;
1079 return mNext.isVoxel(xyz);
1086 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
1088 if (this->isHashed(xyz)) {
1091 const auto offset = LeafNodeType::coordToOffset(xyz);
1093 const_cast<NodeType*
>(mNode)->setValueOn(offset);
1095 mNext.setValue(xyz,
value);
1100 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
1101 if (this->isHashed(xyz)) {
1104 const auto offset = LeafNodeType::coordToOffset(xyz);
1107 mNext.setValueOnly(xyz,
value);
1115 template<
typename ModifyOp>
1118 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
1119 if (this->isHashed(xyz)) {
1122 const auto offset = LeafNodeType::coordToOffset(xyz);
1123 op(
const_cast<ValueType&
>(mBuffer[offset]));
1124 const_cast<NodeType*
>(mNode)->setActiveState(offset,
true);
1126 mNext.modifyValue(xyz, op);
1132 template<
typename ModifyOp>
1135 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
1136 if (this->isHashed(xyz)) {
1139 const auto offset = LeafNodeType::coordToOffset(xyz);
1140 bool state = mNode->isValueOn(offset);
1141 op(
const_cast<ValueType&
>(mBuffer[offset]), state);
1142 const_cast<NodeType*
>(mNode)->setActiveState(offset, state);
1144 mNext.modifyValueAndActiveState(xyz, op);
1151 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
1152 if (this->isHashed(xyz)) {
1154 const_cast<NodeType*
>(mNode)->setValueOffAndCache(xyz,
value, *mParent);
1156 mNext.setValueOff(xyz,
value);
1163 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
1164 if (this->isHashed(xyz)) {
1166 const_cast<NodeType*
>(mNode)->setActiveStateAndCache(xyz, on, *mParent);
1168 mNext.setActiveState(xyz, on);
1176 bool isHashed(
const Coord& xyz)
const
1179 && (xyz[1] &
~Coord::ValueType(NodeType::DIM-1)) == mHash[1]
1183 TreeCacheT* mParent;
1185 const NodeType* mNode;
1186 using RestT =
typename NodeVecT::PopFront;
1187 CacheItem<TreeCacheT, RestT, RestT::Size == 1> mNext;
1188 const ValueType* mBuffer;
1194template<
typename TreeCacheT,
typename NodeVecT>
1196#if OPENVDB_ABI_VERSION_NUMBER >= 10
1206 CacheItem(TreeCacheT& parent): mParent(&parent), mRoot(nullptr) {}
1212 mRoot = other.mRoot;
1221 template<
typename OtherNodeType>
1230 static_assert(!TreeCacheT::IsConstTree,
"can't get a non-const node from a const tree");
1238 static_assert(!TreeCacheT::IsConstTree,
"can't add a node to a const tree");
1239 const_cast<RootNodeType*
>(mRoot)->addLeafAndCache(leaf, *mParent);
1245 static_assert(!TreeCacheT::IsConstTree,
"can't add a tile to a const tree");
1246 const_cast<RootNodeType*
>(mRoot)->addTileAndCache(level, xyz,
value, state, *mParent);
1252 static_assert(!TreeCacheT::IsConstTree,
"can't get a non-const node from a const tree");
1253 return const_cast<RootNodeType*
>(mRoot)->touchLeafAndCache(xyz, *mParent);
1259 static_assert(!TreeCacheT::IsConstTree,
"can't get a non-const node from a const tree");
1260 return const_cast<RootNodeType*
>(mRoot)->probeLeafAndCache(xyz, *mParent);
1266 return mRoot->probeConstLeafAndCache(xyz, *mParent);
1269 template<
typename NodeType>
1273 static_assert(!TreeCacheT::IsConstTree,
"can't get a non-const node from a const tree");
1275 template probeNodeAndCache<NodeType>(xyz, *mParent);
1278 template<
typename NodeType>
1282 return mRoot->template probeConstNodeAndCache<NodeType>(xyz, *mParent);
1288 return mRoot->getValueDepthAndCache(xyz, *mParent);
1293 return mRoot->isValueOnAndCache(xyz, *mParent);
1299 return mRoot->probeValueAndCache(xyz,
value, *mParent);
1304 return mRoot->getValueDepthAndCache(xyz, *mParent) ==
1305 static_cast<int>(RootNodeType::LEVEL);
1310 return mRoot->getValueAndCache(xyz, *mParent);
1316 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
1322 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
1327 template<
typename ModifyOp>
1331 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
1332 const_cast<RootNodeType*
>(mRoot)->modifyValueAndCache(xyz, op, *mParent);
1335 template<
typename ModifyOp>
1339 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
1340 const_cast<RootNodeType*
>(mRoot)->modifyValueAndActiveStateAndCache(xyz, op, *mParent);
1346 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
1353 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
1354 const_cast<RootNodeType*
>(mRoot)->setActiveStateAndCache(xyz, on, *mParent);
1361 bool isHashed(
const Coord&)
const {
return false; }
1363 TreeCacheT* mParent;
1364 const RootNodeType* mRoot;
1374template<
typename _TreeType,
bool IsSafe>
1384#if OPENVDB_ABI_VERSION_NUMBER >= 10
1386 static constexpr bool BypassLeafAPI =
false;
1398 if (&other !=
this) this->BaseT::operator=(other);
1410 assert(BaseT::mTree);
1411 return BaseT::mTree->getValue(xyz);
1417 assert(BaseT::mTree);
1418 return BaseT::mTree->isValueOn(xyz);
1424 assert(BaseT::mTree);
1425 return BaseT::mTree->probeValue(xyz,
value);
1433 assert(BaseT::mTree);
1434 return BaseT::mTree->getValueDepth(xyz);
1441 assert(BaseT::mTree);
1442 return BaseT::mTree->getValueDepth(xyz) ==
static_cast<int>(RootNodeT::LEVEL);
1449 assert(BaseT::mTree);
1450 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1451 BaseT::mTree->setValue(xyz,
value);
1459 assert(BaseT::mTree);
1460 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1461 BaseT::mTree->setValueOnly(xyz,
value);
1467 assert(BaseT::mTree);
1468 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1469 BaseT::mTree->root().setValueOff(xyz,
value);
1475 template<
typename ModifyOp>
1478 assert(BaseT::mTree);
1479 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1480 BaseT::mTree->modifyValue(xyz, op);
1485 template<
typename ModifyOp>
1488 assert(BaseT::mTree);
1489 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1490 BaseT::mTree->modifyValueAndActiveState(xyz, op);
1496 assert(BaseT::mTree);
1497 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1498 BaseT::mTree->setActiveState(xyz, on);
1506 template<
typename NodeT> NodeT*
getNode() {
return nullptr; }
1516 assert(BaseT::mTree);
1517 static_assert(!BaseT::IsConstTree,
"can't add a node to a const tree");
1518 BaseT::mTree->root().addLeaf(leaf);
1525 assert(BaseT::mTree);
1526 static_assert(!BaseT::IsConstTree,
"can't add a tile to a const tree");
1527 BaseT::mTree->root().addTile(level, xyz,
value, state);
1537 assert(BaseT::mTree);
1538 static_assert(!BaseT::IsConstTree,
"can't get a non-const node from a const tree");
1539 return BaseT::mTree->touchLeaf(xyz);
1542 template<
typename NodeT>
1545 assert(BaseT::mTree);
1546 static_assert(!BaseT::IsConstTree,
"can't get a non-const node from a const tree");
1547 return BaseT::mTree->template probeNode<NodeT>(xyz);
1550 template<
typename NodeT>
1553 assert(BaseT::mTree);
1554 return BaseT::mTree->template probeConstNode<NodeT>(xyz);
1559 return this->
template probeNode<LeafNodeT>(xyz);
1564 return this->
template probeConstNode<LeafNodeT>(xyz);
1569 return this->probeConstLeaf(xyz);
1577 template<
typename>
friend class Tree;
1581 void release()
override { this->BaseT::release(); }
1592template<
typename _TreeType,
bool IsSafe, Index L0>
1596 static_assert(_TreeType::DEPTH >= 2,
"cache size exceeds tree depth");
1597 static_assert(L0 < _TreeType::RootNodeType::LEVEL,
"invalid cache level");
1604 using NodeT0 =
typename InvTreeT::template Get<L0>;
1606#if OPENVDB_ABI_VERSION_NUMBER >= 10
1610 static constexpr bool BypassLeafAPI =
1611 std::is_same<NodeT0, LeafNodeT>::value &&
1612 std::is_same<typename LeafNodeT::Buffer::StorageType, ValueType>::value;
1618 , mKey0(
Coord::max()), mNode0(nullptr)
1619#if OPENVDB_ABI_VERSION_NUMBER >= 10
1633 if (&other !=
this) {
1634 this->BaseT::operator=(other);
1647 assert(BaseT::mTree);
1648 return this->isHashed(xyz);
1654 assert(BaseT::mTree);
1655 if (this->isHashed(xyz)) {
1657#if OPENVDB_ABI_VERSION_NUMBER >= 10
1658 if constexpr(BypassLeafAPI) {
1660 return mBuffer[LeafNodeT::coordToOffset(xyz)];
1663 return mNode0->getValueAndCache(xyz, this->self());
1665 return BaseT::mTree->root().getValueAndCache(xyz, this->self());
1671 assert(BaseT::mTree);
1672 if (this->isHashed(xyz)) {
1674 return mNode0->isValueOnAndCache(xyz, this->self());
1676 return BaseT::mTree->root().isValueOnAndCache(xyz, this->self());
1682 assert(BaseT::mTree);
1683 if (this->isHashed(xyz)) {
1685#if OPENVDB_ABI_VERSION_NUMBER >= 10
1686 if constexpr(BypassLeafAPI) {
1688 const auto offset = LeafNodeT::coordToOffset(xyz);
1689 value = mBuffer[offset];
1690 return mNode0->isValueOn(offset);
1693 return mNode0->probeValueAndCache(xyz,
value, this->self());
1695 return BaseT::mTree->root().probeValueAndCache(xyz,
value, this->self());
1703 assert(BaseT::mTree);
1704 if (this->isHashed(xyz)) {
1706 return RootNodeT::LEVEL - mNode0->getValueLevelAndCache(xyz, this->self());
1708 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->self());
1715 assert(BaseT::mTree);
1716 if (this->isHashed(xyz)) {
1718 return mNode0->getValueLevelAndCache(xyz, this->self()) == 0;
1720 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->self()) ==
1721 static_cast<int>(RootNodeT::LEVEL);
1728 assert(BaseT::mTree);
1729 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1730 if (this->isHashed(xyz)) {
1732#if OPENVDB_ABI_VERSION_NUMBER >= 10
1733 if constexpr(BypassLeafAPI) {
1735 const auto offset = LeafNodeT::coordToOffset(xyz);
1737 const_cast<NodeT0*
>(mNode0)->setValueOn(offset);
1741 const_cast<NodeT0*
>(mNode0)->setValueAndCache(xyz,
value, *
this);
1743 BaseT::mTree->root().setValueAndCache(xyz,
value, *
this);
1752 assert(BaseT::mTree);
1753 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1754 if (this->isHashed(xyz)) {
1756#if OPENVDB_ABI_VERSION_NUMBER >= 10
1757 if constexpr(BypassLeafAPI) {
1759 const auto offset = LeafNodeT::coordToOffset(xyz);
1764 const_cast<NodeT0*
>(mNode0)->setValueOnlyAndCache(xyz,
value, *
this);
1766 BaseT::mTree->root().setValueOnlyAndCache(xyz,
value, *
this);
1773 assert(BaseT::mTree);
1774 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1775 if (this->isHashed(xyz)) {
1777 const_cast<NodeT0*
>(mNode0)->setValueOffAndCache(xyz,
value, *
this);
1779 BaseT::mTree->root().setValueOffAndCache(xyz,
value, *
this);
1786 template<
typename ModifyOp>
1789 assert(BaseT::mTree);
1790 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1791 if (this->isHashed(xyz)) {
1793#if OPENVDB_ABI_VERSION_NUMBER >= 10
1794 if constexpr(BypassLeafAPI) {
1796 const auto offset = LeafNodeT::coordToOffset(xyz);
1797 op(
const_cast<ValueType&
>(mBuffer[offset]));
1798 const_cast<NodeT0*
>(mNode0)->setActiveState(offset,
true);
1802 const_cast<NodeT0*
>(mNode0)->modifyValueAndCache(xyz, op, *
this);
1804 BaseT::mTree->root().modifyValueAndCache(xyz, op, *
this);
1810 template<
typename ModifyOp>
1813 assert(BaseT::mTree);
1814 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1815 if (this->isHashed(xyz)) {
1817#if OPENVDB_ABI_VERSION_NUMBER >= 10
1818 if constexpr(BypassLeafAPI) {
1820 const auto offset = LeafNodeT::coordToOffset(xyz);
1821 bool state = mNode0->isValueOn(offset);
1822 op(
const_cast<ValueType&
>(mBuffer[offset]), state);
1823 const_cast<NodeT0*
>(mNode0)->setActiveState(offset, state);
1827 const_cast<NodeT0*
>(mNode0)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
1829 BaseT::mTree->root().modifyValueAndActiveStateAndCache(xyz, op, *
this);
1836 assert(BaseT::mTree);
1837 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1838 if (this->isHashed(xyz)) {
1840 const_cast<NodeT0*
>(mNode0)->setActiveStateAndCache(xyz, on, *
this);
1842 BaseT::mTree->root().setActiveStateAndCache(xyz, on, *
this);
1851 template<
typename NodeT>
1854 const NodeT* node =
nullptr;
1855 this->getNode(node);
1856 return const_cast<NodeT*
>(node);
1861 template<
typename NodeT>
1867 template<
typename NodeT>
1870 const NodeT* node =
nullptr;
1871 this->eraseNode(node);
1878 assert(BaseT::mTree);
1879 static_assert(!BaseT::IsConstTree,
"can't add a node to a const tree");
1880 BaseT::mTree->root().addLeaf(leaf);
1887 assert(BaseT::mTree);
1888 static_assert(!BaseT::IsConstTree,
"can't add a tile to a const tree");
1889 BaseT::mTree->root().addTile(level, xyz,
value, state);
1900 assert(BaseT::mTree);
1901 static_assert(!BaseT::IsConstTree,
"can't get a non-const node from a const tree");
1902 if (this->isHashed(xyz)) {
1904 return const_cast<NodeT0*
>(mNode0)->touchLeafAndCache(xyz, *
this);
1906 return BaseT::mTree->root().touchLeafAndCache(xyz, *
this);
1911 template<
typename NodeT>
1914 assert(BaseT::mTree);
1915 static_assert(!BaseT::IsConstTree,
"can't get a non-const node from a const tree");
1916 if constexpr ((std::is_same<NodeT, NodeT0>::value)) {
1917 if (this->isHashed(xyz)) {
1919 return reinterpret_cast<NodeT*
>(
const_cast<NodeT0*
>(mNode0));
1921 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
1922 }
else if constexpr (NodeT::LEVEL < NodeT0::LEVEL) {
1925 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
1929 return BaseT::mTree->root().template probeNode<NodeT>(xyz);
1934 return this->
template probeNode<LeafNodeT>(xyz);
1939 template<
typename NodeT>
1942 assert(BaseT::mTree);
1943 if constexpr ((std::is_same<NodeT, NodeT0>::value)) {
1944 if (this->isHashed(xyz)) {
1946 return reinterpret_cast<const NodeT*
>(mNode0);
1948 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->self());
1949 }
else if constexpr (NodeT::LEVEL < NodeT0::LEVEL) {
1952 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->self());
1956 return BaseT::mTree->root().template probeConstNode<NodeT>(xyz);
1961 return this->
template probeConstNode<LeafNodeT>(xyz);
1968 mKey0 = Coord::max();
1970#if OPENVDB_ABI_VERSION_NUMBER >= 10
1981 template<
typename>
friend class Tree;
1986 void getNode(
const NodeT0*& node) { node = mNode0; }
1987 void getNode(
const RootNodeT*& node)
1989 node = (BaseT::mTree ? &BaseT::mTree->root() :
nullptr);
1992 template<
typename OtherNodeType>
void getNode(
const OtherNodeType*& node) { node =
nullptr; }
1994 void eraseNode(
const NodeT0*)
1996 mKey0 = Coord::max();
1998#if OPENVDB_ABI_VERSION_NUMBER >= 10
2003 template<
typename OtherNodeType>
void eraseNode(
const OtherNodeType*) {}
2006 inline void copy(
const ValueAccessor1& other)
2008 mKey0 = other.mKey0;
2009 mNode0 = other.mNode0;
2010#if OPENVDB_ABI_VERSION_NUMBER >= 10
2011 mBuffer = other.mBuffer;
2017 void release()
override
2019 this->BaseT::release();
2026 inline void insert(
const Coord& xyz,
const NodeT0* node)
2029 mKey0 = xyz & ~(NodeT0::DIM-1);
2031#if OPENVDB_ABI_VERSION_NUMBER >= 10
2032 if constexpr(BypassLeafAPI) {
2033 mBuffer = node->buffer().data();
2040 template<
typename OtherNodeType>
inline void insert(
const Coord&,
const OtherNodeType*) {}
2042 inline bool isHashed(
const Coord& xyz)
const
2044 return (xyz[0] & ~Coord::ValueType(NodeT0::DIM-1)) == mKey0[0]
2045 && (xyz[1] & ~Coord::ValueType(NodeT0::DIM-1)) == mKey0[1]
2046 && (xyz[2] & ~Coord::ValueType(NodeT0::DIM-1)) == mKey0[2];
2049 mutable Coord mKey0;
2050 mutable const NodeT0* mNode0;
2051#if OPENVDB_ABI_VERSION_NUMBER >= 10
2052 mutable const ValueType* mBuffer;
2064template<
typename _TreeType,
bool IsSafe, Index L0, Index L1>
2068 static_assert(_TreeType::DEPTH >= 3,
"cache size exceeds tree depth");
2069 static_assert(L0 < L1,
"invalid cache level");
2070 static_assert(L1 < _TreeType::RootNodeType::LEVEL,
"invalid cache level");
2078 using NodeT0 =
typename InvTreeT::template Get<L0>;
2079 using NodeT1 =
typename InvTreeT::template Get<L1>;
2081#if OPENVDB_ABI_VERSION_NUMBER >= 10
2085 static constexpr bool BypassLeafAPI =
2086 std::is_same<NodeT0, LeafNodeT>::value &&
2087 std::is_same<typename LeafNodeT::Buffer::StorageType, ValueType>::value;
2093 , mKey0(
Coord::max()), mNode0(nullptr)
2094 , mKey1(
Coord::max()), mNode1(nullptr)
2095#if OPENVDB_ABI_VERSION_NUMBER >= 10
2109 if (&other !=
this) {
2110 this->BaseT::operator=(other);
2123 assert(BaseT::mTree);
2124 return this->isHashed1(xyz) || this->isHashed0(xyz);
2130 assert(BaseT::mTree);
2131 if (this->isHashed0(xyz)) {
2133#if OPENVDB_ABI_VERSION_NUMBER >= 10
2134 if constexpr(BypassLeafAPI) {
2136 return mBuffer[LeafNodeT::coordToOffset(xyz)];
2139 return mNode0->getValueAndCache(xyz, this->self());
2140 }
else if (this->isHashed1(xyz)) {
2142 return mNode1->getValueAndCache(xyz, this->self());
2144 return BaseT::mTree->root().getValueAndCache(xyz, this->self());
2150 assert(BaseT::mTree);
2151 if (this->isHashed0(xyz)) {
2153 return mNode0->isValueOnAndCache(xyz, this->self());
2154 }
else if (this->isHashed1(xyz)) {
2156 return mNode1->isValueOnAndCache(xyz, this->self());
2158 return BaseT::mTree->root().isValueOnAndCache(xyz, this->self());
2164 assert(BaseT::mTree);
2165 if (this->isHashed0(xyz)) {
2167#if OPENVDB_ABI_VERSION_NUMBER >= 10
2168 if constexpr(BypassLeafAPI) {
2170 const auto offset = LeafNodeT::coordToOffset(xyz);
2171 value = mBuffer[offset];
2172 return mNode0->isValueOn(offset);
2175 return mNode0->probeValueAndCache(xyz,
value, this->self());
2176 }
else if (this->isHashed1(xyz)) {
2178 return mNode1->probeValueAndCache(xyz,
value, this->self());
2180 return BaseT::mTree->root().probeValueAndCache(xyz,
value, this->self());
2188 assert(BaseT::mTree);
2189 if (this->isHashed0(xyz)) {
2191 return RootNodeT::LEVEL - mNode0->getValueLevelAndCache(xyz, this->self());
2192 }
else if (this->isHashed1(xyz)) {
2194 return RootNodeT::LEVEL - mNode1->getValueLevelAndCache(xyz, this->self());
2196 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->self());
2203 assert(BaseT::mTree);
2204 if (this->isHashed0(xyz)) {
2206 return mNode0->getValueLevelAndCache(xyz, this->self())==0;
2207 }
else if (this->isHashed1(xyz)) {
2209 return mNode1->getValueLevelAndCache(xyz, this->self())==0;
2211 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->self()) ==
2212 static_cast<int>(RootNodeT::LEVEL);
2219 assert(BaseT::mTree);
2220 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
2221 if (this->isHashed0(xyz)) {
2223#if OPENVDB_ABI_VERSION_NUMBER >= 10
2224 if constexpr(BypassLeafAPI) {
2226 const auto offset = LeafNodeT::coordToOffset(xyz);
2228 const_cast<NodeT0*
>(mNode0)->setValueOn(offset);
2232 const_cast<NodeT0*
>(mNode0)->setValueAndCache(xyz,
value, *
this);
2233 }
else if (this->isHashed1(xyz)) {
2235 const_cast<NodeT1*
>(mNode1)->setValueAndCache(xyz,
value, *
this);
2237 BaseT::mTree->root().setValueAndCache(xyz,
value, *
this);
2246 assert(BaseT::mTree);
2247 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
2248 if (this->isHashed0(xyz)) {
2250#if OPENVDB_ABI_VERSION_NUMBER >= 10
2251 if constexpr(BypassLeafAPI) {
2253 const auto offset = LeafNodeT::coordToOffset(xyz);
2258 const_cast<NodeT0*
>(mNode0)->setValueOnlyAndCache(xyz,
value, *
this);
2259 }
else if (this->isHashed1(xyz)) {
2261 const_cast<NodeT1*
>(mNode1)->setValueOnlyAndCache(xyz,
value, *
this);
2263 BaseT::mTree->root().setValueOnlyAndCache(xyz,
value, *
this);
2270 assert(BaseT::mTree);
2271 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
2272 if (this->isHashed0(xyz)) {
2274 const_cast<NodeT0*
>(mNode0)->setValueOffAndCache(xyz,
value, *
this);
2275 }
else if (this->isHashed1(xyz)) {
2277 const_cast<NodeT1*
>(mNode1)->setValueOffAndCache(xyz,
value, *
this);
2279 BaseT::mTree->root().setValueOffAndCache(xyz,
value, *
this);
2286 template<
typename ModifyOp>
2289 assert(BaseT::mTree);
2290 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
2291 if (this->isHashed0(xyz)) {
2293#if OPENVDB_ABI_VERSION_NUMBER >= 10
2294 if constexpr(BypassLeafAPI) {
2296 const auto offset = LeafNodeT::coordToOffset(xyz);
2297 op(
const_cast<ValueType&
>(mBuffer[offset]));
2298 const_cast<NodeT0*
>(mNode0)->setActiveState(offset,
true);
2302 const_cast<NodeT0*
>(mNode0)->modifyValueAndCache(xyz, op, *
this);
2303 }
else if (this->isHashed1(xyz)) {
2305 const_cast<NodeT1*
>(mNode1)->modifyValueAndCache(xyz, op, *
this);
2307 BaseT::mTree->root().modifyValueAndCache(xyz, op, *
this);
2313 template<
typename ModifyOp>
2316 assert(BaseT::mTree);
2317 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
2318 if (this->isHashed0(xyz)) {
2320#if OPENVDB_ABI_VERSION_NUMBER >= 10
2321 if constexpr(BypassLeafAPI) {
2323 const auto offset = LeafNodeT::coordToOffset(xyz);
2324 bool state = mNode0->isValueOn(offset);
2325 op(
const_cast<ValueType&
>(mBuffer[offset]), state);
2326 const_cast<NodeT0*
>(mNode0)->setActiveState(offset, state);
2330 const_cast<NodeT0*
>(mNode0)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
2331 }
else if (this->isHashed1(xyz)) {
2333 const_cast<NodeT1*
>(mNode1)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
2335 BaseT::mTree->root().modifyValueAndActiveStateAndCache(xyz, op, *
this);
2342 assert(BaseT::mTree);
2343 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
2344 if (this->isHashed0(xyz)) {
2346 const_cast<NodeT0*
>(mNode0)->setActiveStateAndCache(xyz, on, *
this);
2347 }
else if (this->isHashed1(xyz)) {
2349 const_cast<NodeT1*
>(mNode1)->setActiveStateAndCache(xyz, on, *
this);
2351 BaseT::mTree->root().setActiveStateAndCache(xyz, on, *
this);
2360 template<
typename NodeT>
2363 const NodeT* node =
nullptr;
2364 this->getNode(node);
2365 return const_cast<NodeT*
>(node);
2370 template<
typename NodeT>
2376 template<
typename NodeT>
2379 const NodeT* node =
nullptr;
2380 this->eraseNode(node);
2387 assert(BaseT::mTree);
2388 static_assert(!BaseT::IsConstTree,
"can't add a node to a const tree");
2389 if (this->isHashed1(leaf->origin())) {
2391 return const_cast<NodeT1*
>(mNode1)->addLeafAndCache(leaf, *
this);
2393 BaseT::mTree->root().addLeafAndCache(leaf, *
this);
2400 assert(BaseT::mTree);
2401 static_assert(!BaseT::IsConstTree,
"can't add a tile to a const tree");
2402 if (this->isHashed1(xyz)) {
2404 return const_cast<NodeT1*
>(mNode1)->addTileAndCache(level, xyz,
value, state, *
this);
2406 BaseT::mTree->root().addTileAndCache(level, xyz,
value, state, *
this);
2417 assert(BaseT::mTree);
2418 static_assert(!BaseT::IsConstTree,
"can't get a non-const node from a const tree");
2419 if (this->isHashed0(xyz)) {
2421 return const_cast<NodeT0*
>(mNode0)->touchLeafAndCache(xyz, *
this);
2422 }
else if (this->isHashed1(xyz)) {
2424 return const_cast<NodeT1*
>(mNode1)->touchLeafAndCache(xyz, *
this);
2426 return BaseT::mTree->root().touchLeafAndCache(xyz, *
this);
2431 template<
typename NodeT>
2434 assert(BaseT::mTree);
2435 static_assert(!BaseT::IsConstTree,
"can't get a non-const node from a const tree");
2436 if constexpr ((std::is_same<NodeT, NodeT0>::value)) {
2437 if (this->isHashed0(xyz)) {
2439 return reinterpret_cast<NodeT*
>(
const_cast<NodeT0*
>(mNode0));
2440 }
else if (this->isHashed1(xyz)) {
2442 return const_cast<NodeT1*
>(mNode1)->
template probeNodeAndCache<NodeT>(xyz, *
this);
2444 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
2445 }
else if constexpr ((std::is_same<NodeT, NodeT1>::value)) {
2446 if (this->isHashed1(xyz)) {
2448 return reinterpret_cast<NodeT*
>(
const_cast<NodeT1*
>(mNode1));
2450 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
2451 }
else if constexpr (NodeT::LEVEL < NodeT1::LEVEL) {
2454 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
2458 return BaseT::mTree->root().template probeNode<NodeT>(xyz);
2464 template<
typename NodeT>
2467 assert(BaseT::mTree);
2468 if constexpr ((std::is_same<NodeT, NodeT0>::value)) {
2469 if (this->isHashed0(xyz)) {
2471 return reinterpret_cast<const NodeT*
>(mNode0);
2472 }
else if (this->isHashed1(xyz)) {
2474 return mNode1->template probeConstNodeAndCache<NodeT>(xyz, this->self());
2476 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->self());
2477 }
else if constexpr ((std::is_same<NodeT, NodeT1>::value)) {
2478 if (this->isHashed1(xyz)) {
2480 return reinterpret_cast<const NodeT*
>(mNode1);
2482 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->self());
2483 }
else if constexpr (NodeT::LEVEL < NodeT1::LEVEL) {
2486 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->self());
2490 return BaseT::mTree->root().template probeConstNode<NodeT>(xyz);
2503 return this->
template probeConstNode<LeafNodeT>(xyz);
2509 mKey0 = Coord::max();
2511 mKey1 = Coord::max();
2513#if OPENVDB_ABI_VERSION_NUMBER >= 10
2524 template<
typename>
friend class Tree;
2529 void getNode(
const NodeT0*& node) { node = mNode0; }
2530 void getNode(
const NodeT1*& node) { node = mNode1; }
2531 void getNode(
const RootNodeT*& node)
2533 node = (BaseT::mTree ? &BaseT::mTree->root() :
nullptr);
2535 template<
typename OtherNodeType>
void getNode(
const OtherNodeType*& node) { node =
nullptr; }
2537 void eraseNode(
const NodeT0*)
2539 mKey0 = Coord::max();
2541#if OPENVDB_ABI_VERSION_NUMBER >= 10
2546 void eraseNode(
const NodeT1*) { mKey1 = Coord::max(); mNode1 =
nullptr; }
2547 template<
typename OtherNodeType>
void eraseNode(
const OtherNodeType*) {}
2550 inline void copy(
const ValueAccessor2& other)
2552 mKey0 = other.mKey0;
2553 mNode0 = other.mNode0;
2554 mKey1 = other.mKey1;
2555 mNode1 = other.mNode1;
2556#if OPENVDB_ABI_VERSION_NUMBER >= 10
2557 mBuffer = other.mBuffer;
2563 void release()
override
2565 this->BaseT::release();
2573 inline void insert(
const Coord& xyz,
const NodeT0* node)
2576 mKey0 = xyz & ~(NodeT0::DIM-1);
2578#if OPENVDB_ABI_VERSION_NUMBER >= 10
2579 if constexpr(BypassLeafAPI) {
2580 mBuffer = node->buffer().data();
2584 inline void insert(
const Coord& xyz,
const NodeT1* node)
2587 mKey1 = xyz & ~(NodeT1::DIM-1);
2592 template<
typename NodeT>
inline void insert(
const Coord&,
const NodeT*) {}
2594 inline bool isHashed0(
const Coord& xyz)
const
2596 return (xyz[0] & ~Coord::ValueType(NodeT0::DIM-1)) == mKey0[0]
2597 && (xyz[1] & ~Coord::ValueType(NodeT0::DIM-1)) == mKey0[1]
2598 && (xyz[2] & ~Coord::ValueType(NodeT0::DIM-1)) == mKey0[2];
2600 inline bool isHashed1(
const Coord& xyz)
const
2602 return (xyz[0] & ~Coord::ValueType(NodeT1::DIM-1)) == mKey1[0]
2603 && (xyz[1] & ~Coord::ValueType(NodeT1::DIM-1)) == mKey1[1]
2604 && (xyz[2] & ~Coord::ValueType(NodeT1::DIM-1)) == mKey1[2];
2606 mutable Coord mKey0;
2607 mutable const NodeT0* mNode0;
2608 mutable Coord mKey1;
2609 mutable const NodeT1* mNode1;
2610#if OPENVDB_ABI_VERSION_NUMBER >= 10
2611 mutable const ValueType* mBuffer;
2626template<
typename _TreeType,
bool IsSafe, Index L0, Index L1, Index L2>
2630 static_assert(_TreeType::DEPTH >= 4,
"cache size exceeds tree depth");
2631 static_assert(L0 < L1,
"invalid cache level");
2632 static_assert(L1 < L2,
"invalid cache level");
2633 static_assert(L2 < _TreeType::RootNodeType::LEVEL,
"invalid cache level");
2641 using NodeT0 =
typename InvTreeT::template Get<L0>;
2642 using NodeT1 =
typename InvTreeT::template Get<L1>;
2643 using NodeT2 =
typename InvTreeT::template Get<L2>;
2645#if OPENVDB_ABI_VERSION_NUMBER >= 10
2649 static constexpr bool BypassLeafAPI =
2650 std::is_same<NodeT0, LeafNodeT>::value &&
2651 std::is_same<typename LeafNodeT::Buffer::StorageType, ValueType>::value;
2657 , mKey0(
Coord::max()), mNode0(nullptr)
2658 , mKey1(
Coord::max()), mNode1(nullptr)
2659 , mKey2(
Coord::max()), mNode2(nullptr)
2660#if OPENVDB_ABI_VERSION_NUMBER >= 10
2671 if (&other !=
this) {
2672 this->BaseT::operator=(other);
2688 assert(BaseT::mTree);
2689 return this->isHashed2(xyz) || this->isHashed1(xyz) || this->isHashed0(xyz);
2695 assert(BaseT::mTree);
2696 if (this->isHashed0(xyz)) {
2698#if OPENVDB_ABI_VERSION_NUMBER >= 10
2699 if constexpr(BypassLeafAPI) {
2701 return mBuffer[LeafNodeT::coordToOffset(xyz)];
2704 return mNode0->getValueAndCache(xyz, this->self());
2705 }
else if (this->isHashed1(xyz)) {
2707 return mNode1->getValueAndCache(xyz, this->self());
2708 }
else if (this->isHashed2(xyz)) {
2710 return mNode2->getValueAndCache(xyz, this->self());
2712 return BaseT::mTree->root().getValueAndCache(xyz, this->self());
2718 assert(BaseT::mTree);
2719 if (this->isHashed0(xyz)) {
2721 return mNode0->isValueOnAndCache(xyz, this->self());
2722 }
else if (this->isHashed1(xyz)) {
2724 return mNode1->isValueOnAndCache(xyz, this->self());
2725 }
else if (this->isHashed2(xyz)) {
2727 return mNode2->isValueOnAndCache(xyz, this->self());
2729 return BaseT::mTree->root().isValueOnAndCache(xyz, this->self());
2735 assert(BaseT::mTree);
2736 if (this->isHashed0(xyz)) {
2738#if OPENVDB_ABI_VERSION_NUMBER >= 10
2739 if constexpr(BypassLeafAPI) {
2741 const auto offset = LeafNodeT::coordToOffset(xyz);
2742 value = mBuffer[offset];
2743 return mNode0->isValueOn(offset);
2746 return mNode0->probeValueAndCache(xyz,
value, this->self());
2747 }
else if (this->isHashed1(xyz)) {
2749 return mNode1->probeValueAndCache(xyz,
value, this->self());
2750 }
else if (this->isHashed2(xyz)) {
2752 return mNode2->probeValueAndCache(xyz,
value, this->self());
2754 return BaseT::mTree->root().probeValueAndCache(xyz,
value, this->self());
2762 assert(BaseT::mTree);
2763 if (this->isHashed0(xyz)) {
2765 return RootNodeT::LEVEL - mNode0->getValueLevelAndCache(xyz, this->self());
2766 }
else if (this->isHashed1(xyz)) {
2768 return RootNodeT::LEVEL - mNode1->getValueLevelAndCache(xyz, this->self());
2769 }
else if (this->isHashed2(xyz)) {
2771 return RootNodeT::LEVEL - mNode2->getValueLevelAndCache(xyz, this->self());
2773 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->self());
2780 assert(BaseT::mTree);
2781 if (this->isHashed0(xyz)) {
2783 return mNode0->getValueLevelAndCache(xyz, this->self())==0;
2784 }
else if (this->isHashed1(xyz)) {
2786 return mNode1->getValueLevelAndCache(xyz, this->self())==0;
2787 }
else if (this->isHashed2(xyz)) {
2789 return mNode2->getValueLevelAndCache(xyz, this->self())==0;
2791 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->self()) ==
2792 static_cast<int>(RootNodeT::LEVEL);
2799 assert(BaseT::mTree);
2800 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
2801 if (this->isHashed0(xyz)) {
2803#if OPENVDB_ABI_VERSION_NUMBER >= 10
2804 if constexpr(BypassLeafAPI) {
2806 const auto offset = LeafNodeT::coordToOffset(xyz);
2808 const_cast<NodeT0*
>(mNode0)->setValueOn(offset);
2812 const_cast<NodeT0*
>(mNode0)->setValueAndCache(xyz,
value, *
this);
2813 }
else if (this->isHashed1(xyz)) {
2815 const_cast<NodeT1*
>(mNode1)->setValueAndCache(xyz,
value, *
this);
2816 }
else if (this->isHashed2(xyz)) {
2818 const_cast<NodeT2*
>(mNode2)->setValueAndCache(xyz,
value, *
this);
2820 BaseT::mTree->root().setValueAndCache(xyz,
value, *
this);
2829 assert(BaseT::mTree);
2830 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
2831 if (this->isHashed0(xyz)) {
2833#if OPENVDB_ABI_VERSION_NUMBER >= 10
2834 if constexpr(BypassLeafAPI) {
2836 const auto offset = LeafNodeT::coordToOffset(xyz);
2841 const_cast<NodeT0*
>(mNode0)->setValueOnlyAndCache(xyz,
value, *
this);
2842 }
else if (this->isHashed1(xyz)) {
2844 const_cast<NodeT1*
>(mNode1)->setValueOnlyAndCache(xyz,
value, *
this);
2845 }
else if (this->isHashed2(xyz)) {
2847 const_cast<NodeT2*
>(mNode2)->setValueOnlyAndCache(xyz,
value, *
this);
2849 BaseT::mTree->root().setValueOnlyAndCache(xyz,
value, *
this);
2856 assert(BaseT::mTree);
2857 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
2858 if (this->isHashed0(xyz)) {
2860 const_cast<NodeT0*
>(mNode0)->setValueOffAndCache(xyz,
value, *
this);
2861 }
else if (this->isHashed1(xyz)) {
2863 const_cast<NodeT1*
>(mNode1)->setValueOffAndCache(xyz,
value, *
this);
2864 }
else if (this->isHashed2(xyz)) {
2866 const_cast<NodeT2*
>(mNode2)->setValueOffAndCache(xyz,
value, *
this);
2868 BaseT::mTree->root().setValueOffAndCache(xyz,
value, *
this);
2875 template<
typename ModifyOp>
2878 assert(BaseT::mTree);
2879 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
2880 if (this->isHashed0(xyz)) {
2882#if OPENVDB_ABI_VERSION_NUMBER >= 10
2883 if constexpr(BypassLeafAPI) {
2885 const auto offset = LeafNodeT::coordToOffset(xyz);
2886 op(
const_cast<ValueType&
>(mBuffer[offset]));
2887 const_cast<NodeT0*
>(mNode0)->setActiveState(offset,
true);
2891 const_cast<NodeT0*
>(mNode0)->modifyValueAndCache(xyz, op, *
this);
2892 }
else if (this->isHashed1(xyz)) {
2894 const_cast<NodeT1*
>(mNode1)->modifyValueAndCache(xyz, op, *
this);
2895 }
else if (this->isHashed2(xyz)) {
2897 const_cast<NodeT2*
>(mNode2)->modifyValueAndCache(xyz, op, *
this);
2899 BaseT::mTree->root().modifyValueAndCache(xyz, op, *
this);
2905 template<
typename ModifyOp>
2908 assert(BaseT::mTree);
2909 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
2910 if (this->isHashed0(xyz)) {
2912#if OPENVDB_ABI_VERSION_NUMBER >= 10
2913 if constexpr(BypassLeafAPI) {
2915 const auto offset = LeafNodeT::coordToOffset(xyz);
2916 bool state = mNode0->isValueOn(offset);
2917 op(
const_cast<ValueType&
>(mBuffer[offset]), state);
2918 const_cast<NodeT0*
>(mNode0)->setActiveState(offset, state);
2922 const_cast<NodeT0*
>(mNode0)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
2923 }
else if (this->isHashed1(xyz)) {
2925 const_cast<NodeT1*
>(mNode1)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
2926 }
else if (this->isHashed2(xyz)) {
2928 const_cast<NodeT2*
>(mNode2)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
2930 BaseT::mTree->root().modifyValueAndActiveStateAndCache(xyz, op, *
this);
2937 assert(BaseT::mTree);
2938 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
2939 if (this->isHashed0(xyz)) {
2941 const_cast<NodeT0*
>(mNode0)->setActiveStateAndCache(xyz, on, *
this);
2942 }
else if (this->isHashed1(xyz)) {
2944 const_cast<NodeT1*
>(mNode1)->setActiveStateAndCache(xyz, on, *
this);
2945 }
else if (this->isHashed2(xyz)) {
2947 const_cast<NodeT2*
>(mNode2)->setActiveStateAndCache(xyz, on, *
this);
2949 BaseT::mTree->root().setActiveStateAndCache(xyz, on, *
this);
2958 template<
typename NodeT>
2961 const NodeT* node =
nullptr;
2962 this->getNode(node);
2963 return const_cast<NodeT*
>(node);
2968 template<
typename NodeT>
2974 template<
typename NodeT>
2977 const NodeT* node =
nullptr;
2978 this->eraseNode(node);
2985 assert(BaseT::mTree);
2986 static_assert(!BaseT::IsConstTree,
"can't add a node to a const tree");
2987 if (this->isHashed1(leaf->origin())) {
2989 return const_cast<NodeT1*
>(mNode1)->addLeafAndCache(leaf, *
this);
2990 }
else if (this->isHashed2(leaf->origin())) {
2992 return const_cast<NodeT2*
>(mNode2)->addLeafAndCache(leaf, *
this);
2994 BaseT::mTree->root().addLeafAndCache(leaf, *
this);
3001 assert(BaseT::mTree);
3002 static_assert(!BaseT::IsConstTree,
"can't add a tile to a const tree");
3003 if (this->isHashed1(xyz)) {
3005 return const_cast<NodeT1*
>(mNode1)->addTileAndCache(level, xyz,
value, state, *
this);
3006 }
if (this->isHashed2(xyz)) {
3008 return const_cast<NodeT2*
>(mNode2)->addTileAndCache(level, xyz,
value, state, *
this);
3010 BaseT::mTree->root().addTileAndCache(level, xyz,
value, state, *
this);
3021 assert(BaseT::mTree);
3022 static_assert(!BaseT::IsConstTree,
"can't get a non-const node from a const tree");
3023 if (this->isHashed0(xyz)) {
3025 return const_cast<NodeT0*
>(mNode0);
3026 }
else if (this->isHashed1(xyz)) {
3028 return const_cast<NodeT1*
>(mNode1)->touchLeafAndCache(xyz, *
this);
3029 }
else if (this->isHashed2(xyz)) {
3031 return const_cast<NodeT2*
>(mNode2)->touchLeafAndCache(xyz, *
this);
3033 return BaseT::mTree->root().touchLeafAndCache(xyz, *
this);
3037 template<
typename NodeT>
3040 assert(BaseT::mTree);
3041 static_assert(!BaseT::IsConstTree,
"can't get a non-const node from a const tree");
3042 if constexpr ((std::is_same<NodeT, NodeT0>::value)) {
3043 if (this->isHashed0(xyz)) {
3045 return reinterpret_cast<NodeT*
>(
const_cast<NodeT0*
>(mNode0));
3046 }
else if (this->isHashed1(xyz)) {
3048 return const_cast<NodeT1*
>(mNode1)->
template probeNodeAndCache<NodeT>(xyz, *
this);
3049 }
else if (this->isHashed2(xyz)) {
3051 return const_cast<NodeT2*
>(mNode2)->
template probeNodeAndCache<NodeT>(xyz, *
this);
3053 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
3054 }
else if constexpr ((std::is_same<NodeT, NodeT1>::value)) {
3055 if (this->isHashed1(xyz)) {
3057 return reinterpret_cast<NodeT*
>(
const_cast<NodeT1*
>(mNode1));
3058 }
else if (this->isHashed2(xyz)) {
3060 return const_cast<NodeT2*
>(mNode2)->
template probeNodeAndCache<NodeT>(xyz, *
this);
3062 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
3063 }
else if constexpr ((std::is_same<NodeT, NodeT2>::value)) {
3064 if (this->isHashed2(xyz)) {
3066 return reinterpret_cast<NodeT*
>(
const_cast<NodeT2*
>(mNode2));
3068 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
3069 }
else if constexpr (NodeT::LEVEL < NodeT2::LEVEL) {
3072 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
3076 return BaseT::mTree->root().template probeNode<NodeT>(xyz);
3085 template<
typename NodeT>
3088 assert(BaseT::mTree);
3089 if constexpr ((std::is_same<NodeT, NodeT0>::value)) {
3090 if (this->isHashed0(xyz)) {
3092 return reinterpret_cast<const NodeT*
>(mNode0);
3093 }
else if (this->isHashed1(xyz)) {
3095 return mNode1->template probeConstNodeAndCache<NodeT>(xyz, this->self());
3096 }
else if (this->isHashed2(xyz)) {
3098 return mNode2->template probeConstNodeAndCache<NodeT>(xyz, this->self());
3100 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->self());
3101 }
else if constexpr ((std::is_same<NodeT, NodeT1>::value)) {
3102 if (this->isHashed1(xyz)) {
3104 return reinterpret_cast<const NodeT*
>(mNode1);
3105 }
else if (this->isHashed2(xyz)) {
3107 return mNode2->template probeConstNodeAndCache<NodeT>(xyz, this->self());
3109 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->self());
3110 }
else if constexpr ((std::is_same<NodeT, NodeT2>::value)) {
3111 if (this->isHashed2(xyz)) {
3113 return reinterpret_cast<const NodeT*
>(mNode2);
3115 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->self());
3116 }
else if constexpr (NodeT::LEVEL < NodeT2::LEVEL) {
3119 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->self());
3123 return BaseT::mTree->root().template probeConstNode<NodeT>(xyz);
3130 return this->
template probeConstNode<LeafNodeT>(xyz);
3137 mKey0 = Coord::max();
3139 mKey1 = Coord::max();
3141 mKey2 = Coord::max();
3143#if OPENVDB_ABI_VERSION_NUMBER >= 10
3154 template<
typename>
friend class Tree;
3162 mKey0 = other.mKey0;
3163 mNode0 = other.mNode0;
3164 mKey1 = other.mKey1;
3165 mNode1 = other.mNode1;
3166 mKey2 = other.mKey2;
3167 mNode2 = other.mNode2;
3168#if OPENVDB_ABI_VERSION_NUMBER >= 10
3169 mBuffer = other.mBuffer;
3175 void release()
override
3177 this->BaseT::release();
3180 void getNode(
const NodeT0*& node) { node = mNode0; }
3181 void getNode(
const NodeT1*& node) { node = mNode1; }
3182 void getNode(
const NodeT2*& node) { node = mNode2; }
3183 void getNode(
const RootNodeT*& node)
3185 node = (BaseT::mTree ? &BaseT::mTree->root() :
nullptr);
3187 template<
typename OtherNodeType>
void getNode(
const OtherNodeType*& node) { node =
nullptr; }
3189 void eraseNode(
const NodeT0*)
3191 mKey0 = Coord::max();
3193#if OPENVDB_ABI_VERSION_NUMBER >= 10
3198 void eraseNode(
const NodeT1*) { mKey1 = Coord::max(); mNode1 =
nullptr; }
3199 void eraseNode(
const NodeT2*) { mKey2 = Coord::max(); mNode2 =
nullptr; }
3200 template<
typename OtherNodeType>
void eraseNode(
const OtherNodeType*) {}
3206 inline void insert(
const Coord& xyz,
const NodeT0* node)
3209 mKey0 = xyz & ~(NodeT0::DIM-1);
3211#if OPENVDB_ABI_VERSION_NUMBER >= 10
3212 if constexpr(BypassLeafAPI) {
3213 mBuffer = node->buffer().data();
3217 inline void insert(
const Coord& xyz,
const NodeT1* node)
3220 mKey1 = xyz & ~(NodeT1::DIM-1);
3223 inline void insert(
const Coord& xyz,
const NodeT2* node)
3226 mKey2 = xyz & ~(NodeT2::DIM-1);
3231 template<
typename OtherNodeType>
3232 inline void insert(
const Coord&,
const OtherNodeType*)
3235 inline bool isHashed0(
const Coord& xyz)
const
3237 return (xyz[0] & ~Coord::ValueType(NodeT0::DIM-1)) == mKey0[0]
3238 && (xyz[1] & ~Coord::ValueType(NodeT0::DIM-1)) == mKey0[1]
3239 && (xyz[2] & ~Coord::ValueType(NodeT0::DIM-1)) == mKey0[2];
3241 inline bool isHashed1(
const Coord& xyz)
const
3243 return (xyz[0] & ~Coord::ValueType(NodeT1::DIM-1)) == mKey1[0]
3244 && (xyz[1] & ~Coord::ValueType(NodeT1::DIM-1)) == mKey1[1]
3245 && (xyz[2] & ~Coord::ValueType(NodeT1::DIM-1)) == mKey1[2];
3247 inline bool isHashed2(
const Coord& xyz)
const
3249 return (xyz[0] & ~Coord::ValueType(NodeT2::DIM-1)) == mKey2[0]
3250 && (xyz[1] & ~Coord::ValueType(NodeT2::DIM-1)) == mKey2[1]
3251 && (xyz[2] & ~Coord::ValueType(NodeT2::DIM-1)) == mKey2[2];
3253 mutable Coord mKey0;
3254 mutable const NodeT0* mNode0;
3255 mutable Coord mKey1;
3256 mutable const NodeT1* mNode1;
3257 mutable Coord mKey2;
3258 mutable const NodeT2* mNode2;
3259#if OPENVDB_ABI_VERSION_NUMBER >= 10
3260 mutable const ValueType* mBuffer;
ValueT value
Definition: GridBuilder.h:1290
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:25
Int32 ValueType
Definition: Coord.h:32
LeafNodeType * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:979
std::numeric_limits< Int32 > CoordLimits
Definition: ValueAccessor.h:873
void getNode(const NodeType *&node) const
Return the cached node (if any) at this level.
Definition: ValueAccessor.h:930
void erase(const OtherNodeType *node)
Erase the node at another level of the cache.
Definition: ValueAccessor.h:924
LeafNodeType * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:969
CacheItem(TreeCacheT &parent, const CacheItem &other)
Copy another CacheItem's node pointers and hash keys, but not its parent pointer.
Definition: ValueAccessor.h:886
typename NodeType::LeafNodeType LeafNodeType
Definition: ValueAccessor.h:872
void insert(const Coord &xyz, const NodeType *node)
Cache the given node at this level.
Definition: ValueAccessor.h:910
bool probeValue(const Coord &xyz, ValueType &value)
Return the active state and value of the voxel at the given coordinates.
Definition: ValueAccessor.h:1050
CacheItem & copy(TreeCacheT &parent, const CacheItem &other)
Definition: ValueAccessor.h:893
void getNode(NodeType *&node)
Definition: ValueAccessor.h:932
void addTile(Index level, const Coord &xyz, const ValueType &value, bool state)
Definition: ValueAccessor.h:958
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:1133
void setValueOnly(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:1098
void insert(const Coord &xyz, const OtherNodeType *node)
Forward the given node to another level of the cache.
Definition: ValueAccessor.h:918
const NodeT * probeConstNode(const Coord &xyz)
Definition: ValueAccessor.h:1020
void addLeaf(LeafNodeType *leaf)
Definition: ValueAccessor.h:953
int getValueDepth(const Coord &xyz)
Definition: ValueAccessor.h:1062
void setValueOff(const Coord &xyz, const ValueType &value)
Set the value of the voxel at the given coordinates and mark the voxel as inactive.
Definition: ValueAccessor.h:1149
typename NodeVecT::Front NodeType
Definition: ValueAccessor.h:870
void setActiveState(const Coord &xyz, bool on)
Set the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:1161
void setValue(const Coord &xyz, const ValueType &value)
Set the value of the voxel at the given coordinates and mark the voxel as active.
Definition: ValueAccessor.h:1084
CacheItem(TreeCacheT &parent)
Definition: ValueAccessor.h:877
void getNode(const NodeType *&node)
Definition: ValueAccessor.h:931
void modifyValue(const Coord &xyz, const ModifyOp &op)
Apply a functor to the value of the voxel at the given coordinates and mark the voxel as active.
Definition: ValueAccessor.h:1116
bool isValueOn(const Coord &xyz)
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:1040
const ValueType & getValue(const Coord &xyz)
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:944
void clear()
Erase the nodes at this and lower levels of the cache.
Definition: ValueAccessor.h:927
bool isCached(const Coord &xyz) const
Definition: ValueAccessor.h:904
typename NodeType::ValueType ValueType
Definition: ValueAccessor.h:871
void getNode(OtherNodeType *&node)
Forward the request to another level of the cache.
Definition: ValueAccessor.h:941
const LeafNodeType * probeConstLeaf(const Coord &xyz)
Definition: ValueAccessor.h:989
void setValueOn(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:1110
void erase(const NodeType *)
Erase the node at this level.
Definition: ValueAccessor.h:921
bool isVoxel(const Coord &xyz)
Definition: ValueAccessor.h:1073
NodeT * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:999
LeafNodeType * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1256
void insert(const Coord &, const RootNodeType *root)
Definition: ValueAccessor.h:1218
NodeType * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:1270
void getNode(const RootNodeType *&node) const
Definition: ValueAccessor.h:1233
LeafNodeType * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1249
CacheItem(TreeCacheT &parent, const CacheItem &other)
Definition: ValueAccessor.h:1207
bool probeValue(const Coord &xyz, ValueType &value)
Definition: ValueAccessor.h:1296
CacheItem & copy(TreeCacheT &parent, const CacheItem &other)
Definition: ValueAccessor.h:1209
const NodeType * probeConstNode(const Coord &xyz)
Definition: ValueAccessor.h:1279
typename NodeVecT::Front RootNodeType
Definition: ValueAccessor.h:1202
void addTile(Index level, const Coord &xyz, const ValueType &value, bool state)
Definition: ValueAccessor.h:1242
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Definition: ValueAccessor.h:1336
void setValueOnly(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:1319
void addLeaf(LeafNodeType *leaf)
Definition: ValueAccessor.h:1235
int getValueDepth(const Coord &xyz)
Definition: ValueAccessor.h:1285
void setValueOff(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:1343
void getNode(RootNodeType *&node)
Definition: ValueAccessor.h:1228
void setActiveState(const Coord &xyz, bool on)
Definition: ValueAccessor.h:1350
void setValue(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:1313
void erase(const RootNodeType *)
Definition: ValueAccessor.h:1224
CacheItem(TreeCacheT &parent)
Definition: ValueAccessor.h:1206
typename RootNodeType::ValueType ValueType
Definition: ValueAccessor.h:1203
void insert(const Coord &, const OtherNodeType *)
Definition: ValueAccessor.h:1222
void modifyValue(const Coord &xyz, const ModifyOp &op)
Definition: ValueAccessor.h:1328
bool isValueOn(const Coord &xyz)
Definition: ValueAccessor.h:1290
const ValueType & getValue(const Coord &xyz)
Definition: ValueAccessor.h:1307
void clear()
Definition: ValueAccessor.h:1226
bool isCached(const Coord &xyz) const
Definition: ValueAccessor.h:1216
typename RootNodeType::LeafNodeType LeafNodeType
Definition: ValueAccessor.h:1204
const LeafNodeType * probeConstLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1263
void setValueOn(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:1325
bool isVoxel(const Coord &xyz)
Definition: ValueAccessor.h:1301
Definition: ValueAccessor.h:541
LeafNodeType * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:662
std::numeric_limits< Int32 > CoordLimits
Definition: ValueAccessor.h:546
void getNode(const NodeType *&node) const
Return the cached node (if any) at this level.
Definition: ValueAccessor.h:601
void erase(const OtherNodeType *node)
Erase the node at another level of the cache.
Definition: ValueAccessor.h:595
LeafNodeType * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:652
CacheItem(TreeCacheT &parent, const CacheItem &other)
Copy another CacheItem's node pointers and hash keys, but not its parent pointer.
Definition: ValueAccessor.h:558
typename NodeType::LeafNodeType LeafNodeType
Definition: ValueAccessor.h:545
void insert(const Coord &xyz, const NodeType *node)
Cache the given node at this level.
Definition: ValueAccessor.h:582
bool probeValue(const Coord &xyz, ValueType &value)
Return the active state and value of the voxel at the given coordinates.
Definition: ValueAccessor.h:733
CacheItem & copy(TreeCacheT &parent, const CacheItem &other)
Definition: ValueAccessor.h:566
void getNode(NodeType *&node)
Definition: ValueAccessor.h:603
void addTile(Index level, const Coord &xyz, const ValueType &value, bool state)
Definition: ValueAccessor.h:641
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:804
void setValueOnly(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:774
void insert(const Coord &xyz, const OtherNodeType *node)
Forward the given node to another level of the cache.
Definition: ValueAccessor.h:589
const NodeT * probeConstNode(const Coord &xyz)
Definition: ValueAccessor.h:703
void addLeaf(LeafNodeType *leaf)
Definition: ValueAccessor.h:624
int getValueDepth(const Coord &xyz)
Definition: ValueAccessor.h:742
void setValueOff(const Coord &xyz, const ValueType &value)
Set the value of the voxel at the given coordinates and mark the voxel as inactive.
Definition: ValueAccessor.h:816
typename NodeVecT::Front NodeType
Definition: ValueAccessor.h:543
void setActiveState(const Coord &xyz, bool on)
Set the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:828
void setValue(const Coord &xyz, const ValueType &value)
Set the value of the voxel at the given coordinates and mark the voxel as active.
Definition: ValueAccessor.h:764
CacheItem(TreeCacheT &parent)
Definition: ValueAccessor.h:548
void getNode(const NodeType *&node)
Definition: ValueAccessor.h:602
void modifyValue(const Coord &xyz, const ModifyOp &op)
Apply a functor to the value of the voxel at the given coordinates and mark the voxel as active.
Definition: ValueAccessor.h:790
bool isValueOn(const Coord &xyz)
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:723
const ValueType & getValue(const Coord &xyz)
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:615
void clear()
Erase the nodes at this and lower levels of the cache.
Definition: ValueAccessor.h:598
bool isCached(const Coord &xyz) const
Definition: ValueAccessor.h:576
typename NodeType::ValueType ValueType
Definition: ValueAccessor.h:544
void getNode(OtherNodeType *&node)
Forward the request to another level of the cache.
Definition: ValueAccessor.h:612
const LeafNodeType * probeConstLeaf(const Coord &xyz)
Definition: ValueAccessor.h:672
void setValueOn(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:784
void erase(const NodeType *)
Erase the node at this level.
Definition: ValueAccessor.h:592
bool isVoxel(const Coord &xyz)
Definition: ValueAccessor.h:753
NodeT * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:682
ValueAccessor with no mutex and no node caching.
Definition: ValueAccessor.h:1376
int getValueDepth(const Coord &xyz) const
Definition: ValueAccessor.h:1431
void insertNode(const Coord &, NodeT &)
Definition: ValueAccessor.h:1510
bool isValueOn(const Coord &xyz) const
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:1415
void setActiveState(const Coord &xyz, bool on=true)
Set the active state of the voxel at the given coordinates but don't change its value.
Definition: ValueAccessor.h:1494
bool isVoxel(const Coord &xyz) const
Definition: ValueAccessor.h:1439
LeafNodeT * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1535
ValueAccessor0(const ValueAccessor0 &other)
Definition: ValueAccessor.h:1391
typename TreeType::ValueType ValueType
Definition: ValueAccessor.h:1379
void addLeaf(LeafNodeT *leaf)
Add the specified leaf to this tree, possibly creating a child branch in the process....
Definition: ValueAccessor.h:1514
static Index numCacheLevels()
Return the number of cache levels employed by this accessor.
Definition: ValueAccessor.h:1394
LeafNodeT * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1557
void addTile(Index level, const Coord &xyz, const ValueType &value, bool state)
Add a tile at the specified tree level that contains voxel (x, y, z), possibly deleting existing node...
Definition: ValueAccessor.h:1523
const LeafNodeT * probeConstLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1562
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:1486
ValueAccessor0 & operator=(const ValueAccessor0 &other)
Definition: ValueAccessor.h:1396
void setValueOnly(const Coord &xyz, const ValueType &value)
Set the value of the voxel at the given coordinate but don't change its active state.
Definition: ValueAccessor.h:1457
typename TreeType::RootNodeType RootNodeT
Definition: ValueAccessor.h:1380
bool isCached(const Coord &) const
Return true if nodes along the path to the given voxel have been cached.
Definition: ValueAccessor.h:1405
void setValueOff(const Coord &xyz, const ValueType &value)
Set the value of the voxel at the given coordinates and mark the voxel as inactive.
Definition: ValueAccessor.h:1465
bool probeValue(const Coord &xyz, ValueType &value) const
Return the active state and, in value, the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:1422
typename TreeType::LeafNodeType LeafNodeT
Definition: ValueAccessor.h:1381
void setValue(const Coord &xyz, const ValueType &value)
Set the value of the voxel at the given coordinates and mark the voxel as active.
Definition: ValueAccessor.h:1447
ValueAccessor0(TreeType &tree)
Definition: ValueAccessor.h:1389
void eraseNode()
Definition: ValueAccessor.h:1533
~ValueAccessor0() override=default
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: ValueAccessor.h:1503
NodeT * getNode()
Return the cached node of type NodeType. [Mainly for internal use].
Definition: ValueAccessor.h:1506
friend class Tree
Definition: ValueAccessor.h:1577
void modifyValue(const Coord &xyz, const ModifyOp &op)
Apply a functor to the value of the voxel at the given coordinates and mark the voxel as active.
Definition: ValueAccessor.h:1476
const LeafNodeT * probeLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1567
const NodeT * probeConstNode(const Coord &xyz) const
Definition: ValueAccessor.h:1551
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: ValueAccessor.h:1501
void setValueOn(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:1453
TreeType TreeType
Definition: ValueAccessor.h:1378
void clear() override
Remove all nodes from this cache, then reinsert the root node.
Definition: ValueAccessor.h:1573
NodeT * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:1543
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:1408
Value accessor with one level of node caching.
Definition: ValueAccessor.h:1594
int getValueDepth(const Coord &xyz) const
Definition: ValueAccessor.h:1701
bool isValueOn(const Coord &xyz) const
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:1669
void setActiveState(const Coord &xyz, bool on=true)
Set the active state of the voxel at the given coordinates but don't change its value.
Definition: ValueAccessor.h:1834
bool isVoxel(const Coord &xyz) const
Definition: ValueAccessor.h:1713
LeafNodeT * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1898
typename TreeType::ValueType ValueType
Definition: ValueAccessor.h:1599
void addLeaf(LeafNodeT *leaf)
Add the specified leaf to this tree, possibly creating a child branch in the process....
Definition: ValueAccessor.h:1876
static Index numCacheLevels()
Return the number of cache levels employed by this ValueAccessor.
Definition: ValueAccessor.h:1628
ValueAccessor1(TreeType &tree)
Constructor from a tree.
Definition: ValueAccessor.h:1616
LeafNodeT * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1932
void addTile(Index level, const Coord &xyz, const ValueType &value, bool state)
Add a tile at the specified tree level that contains voxel (x, y, z), possibly deleting existing node...
Definition: ValueAccessor.h:1885
const LeafNodeT * probeConstLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1959
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:1811
friend class InternalNode
Definition: ValueAccessor.h:1978
void setValueOnly(const Coord &xyz, const ValueType &value)
Set the value of the voxel at the given coordinate but preserves its active state.
Definition: ValueAccessor.h:1750
typename TreeType::RootNodeType RootNodeT
Definition: ValueAccessor.h:1600
void setValueOff(const Coord &xyz, const ValueType &value)
Set the value of the voxel at the given coordinates and mark the voxel as inactive.
Definition: ValueAccessor.h:1771
bool probeValue(const Coord &xyz, ValueType &value) const
Return the active state of the voxel as well as its value.
Definition: ValueAccessor.h:1680
ValueAccessor1(const ValueAccessor1 &other)
Copy constructor.
Definition: ValueAccessor.h:1625
typename TreeType::LeafNodeType LeafNodeT
Definition: ValueAccessor.h:1601
void setValue(const Coord &xyz, const ValueType &value)
Set the value of the voxel at the given coordinates and mark the voxel as active.
Definition: ValueAccessor.h:1726
~ValueAccessor1() override=default
Virtual destructor.
void eraseNode()
Definition: ValueAccessor.h:1868
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: ValueAccessor.h:1848
NodeT * getNode()
Return the cached node of type NodeType. [Mainly for internal use].
Definition: ValueAccessor.h:1852
typename RootNodeT::NodeChainType InvTreeT
Definition: ValueAccessor.h:1603
friend class Tree
Definition: ValueAccessor.h:1981
void modifyValue(const Coord &xyz, const ModifyOp &op)
Apply a functor to the value of the voxel at the given coordinates and mark the voxel as active.
Definition: ValueAccessor.h:1787
friend class LeafNode
Definition: ValueAccessor.h:1979
ValueAccessor1 & operator=(const ValueAccessor1 &other)
Assignment operator.
Definition: ValueAccessor.h:1631
const LeafNodeT * probeLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1963
void insertNode(const Coord &xyz, NodeT &node)
Definition: ValueAccessor.h:1862
const NodeT * probeConstNode(const Coord &xyz) const
Definition: ValueAccessor.h:1940
bool isCached(const Coord &xyz) const
Definition: ValueAccessor.h:1645
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: ValueAccessor.h:1846
typename InvTreeT::template Get< L0 > NodeT0
Definition: ValueAccessor.h:1604
void setValueOn(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:1746
TreeType TreeType
Definition: ValueAccessor.h:1598
void clear() override
Remove all the cached nodes and invalidate the corresponding hash-keys.
Definition: ValueAccessor.h:1966
NodeT * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:1912
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:1652
friend class RootNode
Definition: ValueAccessor.h:1977
Value accessor with two levels of node caching.
Definition: ValueAccessor.h:2066
int getValueDepth(const Coord &xyz) const
Definition: ValueAccessor.h:2186
bool isValueOn(const Coord &xyz) const
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:2148
void setActiveState(const Coord &xyz, bool on=true)
Set the active state of the voxel at the given coordinates without changing its value.
Definition: ValueAccessor.h:2340
bool isVoxel(const Coord &xyz) const
Definition: ValueAccessor.h:2201
LeafNodeT * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:2415
typename TreeType::ValueType ValueType
Definition: ValueAccessor.h:2073
void addLeaf(LeafNodeT *leaf)
Add the specified leaf to this tree, possibly creating a child branch in the process....
Definition: ValueAccessor.h:2385
static Index numCacheLevels()
Return the number of cache levels employed by this ValueAccessor.
Definition: ValueAccessor.h:2104
LeafNodeT * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:2496
ValueAccessor2(const ValueAccessor2 &other)
Copy constructor.
Definition: ValueAccessor.h:2101
ValueAccessor2 & operator=(const ValueAccessor2 &other)
Assignment operator.
Definition: ValueAccessor.h:2107
void addTile(Index level, const Coord &xyz, const ValueType &value, bool state)
Add a tile at the specified tree level that contains voxel (x, y, z), possibly deleting existing node...
Definition: ValueAccessor.h:2398
const LeafNodeT * probeConstLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:2501
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:2314
friend class InternalNode
Definition: ValueAccessor.h:2521
void setValueOnly(const Coord &xyz, const ValueType &value)
Set the value of the voxel at the given coordinate but preserves its active state.
Definition: ValueAccessor.h:2244
typename InvTreeT::template Get< L1 > NodeT1
Definition: ValueAccessor.h:2079
typename TreeType::RootNodeType RootNodeT
Definition: ValueAccessor.h:2074
void setValueOff(const Coord &xyz, const ValueType &value)
Set the value of the voxel at the given coordinates and mark the voxel as inactive.
Definition: ValueAccessor.h:2268
bool probeValue(const Coord &xyz, ValueType &value) const
Return the active state of the voxel as well as its value.
Definition: ValueAccessor.h:2162
typename TreeType::LeafNodeType LeafNodeT
Definition: ValueAccessor.h:2075
void setValue(const Coord &xyz, const ValueType &value)
Set the value of the voxel at the given coordinates and mark the voxel as active.
Definition: ValueAccessor.h:2217
void eraseNode()
Definition: ValueAccessor.h:2377
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive without changing its value.
Definition: ValueAccessor.h:2357
NodeT * getNode()
Return the cached node of type NodeType. [Mainly for internal use].
Definition: ValueAccessor.h:2361
typename RootNodeT::NodeChainType InvTreeT
Definition: ValueAccessor.h:2077
ValueAccessor2(TreeType &tree)
Constructor from a tree.
Definition: ValueAccessor.h:2091
friend class Tree
Definition: ValueAccessor.h:2524
void modifyValue(const Coord &xyz, const ModifyOp &op)
Apply a functor to the value of the voxel at the given coordinates and mark the voxel as active.
Definition: ValueAccessor.h:2287
friend class LeafNode
Definition: ValueAccessor.h:2522
const LeafNodeT * probeLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:2497
void insertNode(const Coord &xyz, NodeT &node)
Definition: ValueAccessor.h:2371
const NodeT * probeConstNode(const Coord &xyz) const
Definition: ValueAccessor.h:2465
bool isCached(const Coord &xyz) const
Definition: ValueAccessor.h:2121
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active without changing its value.
Definition: ValueAccessor.h:2355
~ValueAccessor2() override=default
Virtual destructor.
typename InvTreeT::template Get< L0 > NodeT0
Definition: ValueAccessor.h:2078
void setValueOn(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:2240
TreeType TreeType
Definition: ValueAccessor.h:2072
void clear() override
Remove all the cached nodes and invalidate the corresponding hash-keys.
Definition: ValueAccessor.h:2507
NodeT * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:2432
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:2128
friend class RootNode
Definition: ValueAccessor.h:2520
Value accessor with three levels of node caching.
Definition: ValueAccessor.h:2628
int getValueDepth(const Coord &xyz) const
Definition: ValueAccessor.h:2760
ValueAccessor3(const ValueAccessor3 &other)
Copy constructor.
Definition: ValueAccessor.h:2666
bool isValueOn(const Coord &xyz) const
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:2716
void setActiveState(const Coord &xyz, bool on=true)
Set the active state of the voxel at the given coordinates without changing its value.
Definition: ValueAccessor.h:2935
bool isVoxel(const Coord &xyz) const
Definition: ValueAccessor.h:2778
LeafNodeT * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:3019
typename TreeType::ValueType ValueType
Definition: ValueAccessor.h:2636
void addLeaf(LeafNodeT *leaf)
Add the specified leaf to this tree, possibly creating a child branch in the process....
Definition: ValueAccessor.h:2983
static Index numCacheLevels()
Return the number of cache levels employed by this ValueAccessor.
Definition: ValueAccessor.h:2679
typename InvTreeT::template Get< L2 > NodeT2
Definition: ValueAccessor.h:2643
LeafNodeT * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:3081
void addTile(Index level, const Coord &xyz, const ValueType &value, bool state)
Add a tile at the specified tree level that contains voxel (x, y, z), possibly deleting existing node...
Definition: ValueAccessor.h:2999
const LeafNodeT * probeConstLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:3128
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:2906
friend class InternalNode
Definition: ValueAccessor.h:3151
void setValueOnly(const Coord &xyz, const ValueType &value)
Set the value of the voxel at the given coordinate but preserves its active state.
Definition: ValueAccessor.h:2827
typename InvTreeT::template Get< L1 > NodeT1
Definition: ValueAccessor.h:2642
typename TreeType::RootNodeType RootNodeT
Definition: ValueAccessor.h:2637
void setValueOff(const Coord &xyz, const ValueType &value)
Set the value of the voxel at the given coordinates and mark the voxel as inactive.
Definition: ValueAccessor.h:2854
ValueAccessor3 & operator=(const ValueAccessor3 &other)
Assignment operator.
Definition: ValueAccessor.h:2669
bool probeValue(const Coord &xyz, ValueType &value) const
Return the active state of the voxel as well as its value.
Definition: ValueAccessor.h:2733
typename TreeType::LeafNodeType LeafNodeT
Definition: ValueAccessor.h:2638
void setValue(const Coord &xyz, const ValueType &value)
Set the value of the voxel at the given coordinates and mark the voxel as active.
Definition: ValueAccessor.h:2797
~ValueAccessor3() override=default
Virtual destructor.
void eraseNode()
Definition: ValueAccessor.h:2975
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive without changing its value.
Definition: ValueAccessor.h:2955
NodeT * getNode()
Return the cached node of type NodeType. [Mainly for internal use].
Definition: ValueAccessor.h:2959
typename RootNodeT::NodeChainType InvTreeT
Definition: ValueAccessor.h:2640
friend class Tree
Definition: ValueAccessor.h:3154
void modifyValue(const Coord &xyz, const ModifyOp &op)
Apply a functor to the value of the voxel at the given coordinates and mark the voxel as active.
Definition: ValueAccessor.h:2876
friend class LeafNode
Definition: ValueAccessor.h:3152
ValueAccessor3(TreeType &tree)
Constructor from a tree.
Definition: ValueAccessor.h:2655
const LeafNodeT * probeLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:3132
void insertNode(const Coord &xyz, NodeT &node)
Definition: ValueAccessor.h:2969
const NodeT * probeConstNode(const Coord &xyz) const
Definition: ValueAccessor.h:3086
bool isCached(const Coord &xyz) const
Definition: ValueAccessor.h:2686
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active without changing its value.
Definition: ValueAccessor.h:2953
typename InvTreeT::template Get< L0 > NodeT0
Definition: ValueAccessor.h:2641
void setValueOn(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:2823
TreeType TreeType
Definition: ValueAccessor.h:2635
void clear() override
Remove all the cached nodes and invalidate the corresponding hash-keys.
Definition: ValueAccessor.h:3135
NodeT * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:3038
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:2693
friend class RootNode
Definition: ValueAccessor.h:3150
This base class for ValueAccessors manages registration of an accessor with a tree so that the tree c...
Definition: ValueAccessor.h:93
TreeType * getTree() const
Return a pointer to the tree associated with this accessor.
Definition: ValueAccessor.h:116
ValueAccessorBase(const ValueAccessorBase &other)
Definition: ValueAccessor.h:120
ValueAccessorBase & operator=(const ValueAccessorBase &other)
Definition: ValueAccessor.h:125
TreeType * mTree
Definition: ValueAccessor.h:143
virtual ~ValueAccessorBase()
Definition: ValueAccessor.h:110
ValueAccessorBase(TreeType &tree)
Definition: ValueAccessor.h:105
TreeType & tree() const
Return a reference to the tree associated with this accessor.
Definition: ValueAccessor.h:118
static bool isSafe()
Return true if this accessor is safe, i.e. registered by the tree from which it is constructed....
Definition: ValueAccessor.h:103
virtual void release()
Definition: ValueAccessor.h:141
This accessor is thread-safe (at the cost of speed) for both reading and writing to a tree....
Definition: ValueAccessor.h:518
ValueAccessorRW(TreeType &tree)
Definition: ValueAccessor.h:520
~ValueAccessor() override=default
ValueAccessor(TreeType &tree)
Definition: ValueAccessor.h:463
ValueAccessor(const ValueAccessor &other)
Definition: ValueAccessor.h:464
~ValueAccessor() override=default
ValueAccessor(TreeType &tree)
Definition: ValueAccessor.h:475
ValueAccessor(const ValueAccessor &other)
Definition: ValueAccessor.h:476
~ValueAccessor() override=default
ValueAccessor(TreeType &tree)
Definition: ValueAccessor.h:487
ValueAccessor(const ValueAccessor &other)
Definition: ValueAccessor.h:488
~ValueAccessor() override=default
ValueAccessor(TreeType &tree)
Definition: ValueAccessor.h:498
ValueAccessor(const ValueAccessor &)=default
ValueAccessor & operator=(const ValueAccessor &)=default
Definition: ValueAccessor.h:191
int getValueDepth(const Coord &xyz) const
Definition: ValueAccessor.h:254
~ValueAccessor() override=default
ValueAccessor(TreeType &tree)
Definition: ValueAccessor.h:211
bool isValueOn(const Coord &xyz) const
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:242
void setActiveState(const Coord &xyz, bool on=true)
Set the active state of the voxel at the given coordinates but don't change its value.
Definition: ValueAccessor.h:308
bool isVoxel(const Coord &xyz) const
Definition: ValueAccessor.h:262
LeafNodeT * touchLeaf(const Coord &xyz)
Return a pointer to the leaf node that contains voxel (x, y, z). If no such node exists,...
Definition: ValueAccessor.h:364
ValueAccessor & operator=(const ValueAccessor &other)
Definition: ValueAccessor.h:218
void addLeaf(LeafNodeT *leaf)
Add the specified leaf to this tree, possibly creating a child branch in the process....
Definition: ValueAccessor.h:345
static Index numCacheLevels()
Return the number of cache levels employed by this accessor.
Definition: ValueAccessor.h:229
LeafNodeT * probeLeaf(const Coord &xyz)
Return a pointer to the leaf node that contains voxel (x, y, z), or nullptr if no such node exists.
Definition: ValueAccessor.h:395
typename RootNodeT::ValueType ValueType
Definition: ValueAccessor.h:198
void addTile(Index level, const Coord &xyz, const ValueType &value, bool state)
Add a tile at the specified tree level that contains voxel (x, y, z), possibly deleting existing node...
Definition: ValueAccessor.h:353
const LeafNodeT * probeConstLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:400
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:301
friend class InternalNode
Definition: ValueAccessor.h:419
void setValueOnly(const Coord &xyz, const ValueType &value)
Set the value of the voxel at the given coordinate but don't change its active state.
Definition: ValueAccessor.h:275
void insertNode(const Coord &xyz, NodeType &node)
Definition: ValueAccessor.h:331
typename TreeType::RootNodeType RootNodeT
Definition: ValueAccessor.h:196
void setValueOff(const Coord &xyz, const ValueType &value)
Set the value of the voxel at the given coordinates and mark the voxel as inactive.
Definition: ValueAccessor.h:282
bool probeValue(const Coord &xyz, ValueType &value) const
Return the active state of the voxel as well as its value.
Definition: ValueAccessor.h:245
typename TreeType::LeafNodeType LeafNodeT
Definition: ValueAccessor.h:197
void setValue(const Coord &xyz, const ValueType &value)
Set the value of the voxel at the given coordinates and mark the voxel as active.
Definition: ValueAccessor.h:266
typename MutexType::scoped_lock LockT
Definition: ValueAccessor.h:200
void eraseNode()
Definition: ValueAccessor.h:341
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: ValueAccessor.h:316
friend class Tree
Definition: ValueAccessor.h:422
void modifyValue(const Coord &xyz, const ModifyOp &op)
Apply a functor to the value of the voxel at the given coordinates and mark the voxel as active.
Definition: ValueAccessor.h:292
friend class LeafNode
Definition: ValueAccessor.h:420
const NodeT * probeNode(const Coord &xyz) const
Definition: ValueAccessor.h:386
const LeafNodeT * probeLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:405
const NodeT * probeConstNode(const Coord &xyz) const
Definition: ValueAccessor.h:380
bool isCached(const Coord &xyz) const
Return true if nodes along the path to the given voxel have been cached.
Definition: ValueAccessor.h:232
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: ValueAccessor.h:314
NodeType * getNode()
Return the cached node of type NodeType. [Mainly for internal use].
Definition: ValueAccessor.h:320
void setValueOn(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:271
_TreeType TreeType
Definition: ValueAccessor.h:195
ValueAccessor(const ValueAccessor &other)
Definition: ValueAccessor.h:216
void clear() override
Remove all nodes from this cache, then reinsert the root node.
Definition: ValueAccessor.h:409
NodeT * probeNode(const Coord &xyz)
Return a pointer to the node of the specified type that contains voxel (x, y, z), or nullptr if no su...
Definition: ValueAccessor.h:374
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:235
friend class RootNode
Definition: ValueAccessor.h:418
Index32 Index
Definition: Types.h:54
Definition: Exceptions.h:13
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:121
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:212