58 #ifndef OPENVDB_TREE_VALUEACCESSOR_HAS_BEEN_INCLUDED 59 #define OPENVDB_TREE_VALUEACCESSOR_HAS_BEEN_INCLUDED 61 #include <boost/mpl/front.hpp> 62 #include <boost/mpl/pop_front.hpp> 63 #include <boost/mpl/push_back.hpp> 64 #include <boost/mpl/size.hpp> 65 #include <boost/mpl/at.hpp> 66 #include <boost/mpl/equal_to.hpp> 67 #include <boost/mpl/comparison.hpp> 68 #include <boost/mpl/vector.hpp> 69 #include <boost/mpl/assert.hpp> 70 #include <boost/mpl/erase.hpp> 71 #include <boost/mpl/find.hpp> 72 #include <tbb/null_mutex.h> 73 #include <tbb/spin_mutex.h> 74 #include <openvdb/version.h> 75 #include <openvdb/Types.h> 78 #include <type_traits> 87 template<
typename TreeType,
bool IsSafe = true>
89 template<
typename TreeType,
bool IsSafe = true, Index L0 = 0>
91 template<
typename TreeType,
bool IsSafe = true, Index L0 = 0, Index L1 = 1>
93 template<
typename TreeType,
bool IsSafe = true, Index L0 = 0, Index L1 = 1, Index L2 = 2>
95 template<
typename TreeCacheT,
typename NodeVecT,
bool AtRoot>
class CacheItem;
121 template<
typename TreeType,
bool IsSafe>
125 static const bool IsConstTree = std::is_const<TreeType>::value;
137 if (IsSafe) tree.attachAccessor(*
this);
148 TreeType&
tree()
const { assert(mTree);
return *mTree; }
152 if (IsSafe && mTree) mTree->attachAccessor(*
this);
157 if (&other !=
this) {
158 if (IsSafe && mTree) mTree->releaseAccessor(*
this);
160 if (IsSafe && mTree) mTree->attachAccessor(*
this);
165 virtual void clear() = 0;
169 template<
typename>
friend class Tree;
216 template<
typename _TreeType,
218 Index CacheLevels = _TreeType::DEPTH-1,
219 typename MutexType = tbb::null_mutex>
223 static_assert(CacheLevels < _TreeType::DEPTH,
"cache size exceeds tree depth");
230 using LockT =
typename MutexType::scoped_lock;
231 using BaseT::IsConstTree;
235 mCache.insert(
Coord(), &tree.root());
242 if (&other !=
this) {
243 this->BaseT::operator=(other);
244 mCache.copy(*
this, other.mCache);
260 return mCache.getValue(xyz);
270 return mCache.probeValue(xyz,value);
279 return mCache.getValueDepth(xyz);
291 mCache.setValue(xyz, value);
300 mCache.setValueOnly(xyz, value);
308 mCache.newSetValue(xyz, value);
315 mCache.setValueOff(xyz, value);
321 template<
typename ModifyOp>
325 mCache.modifyValue(xyz, op);
330 template<
typename ModifyOp>
334 mCache.modifyValueAndActiveState(xyz, op);
341 mCache.setActiveState(xyz, on);
349 template<
typename NodeType>
353 NodeType* node =
nullptr;
354 mCache.getNode(node);
360 template<
typename NodeType>
364 mCache.insert(xyz, &node);
370 template<
typename NodeType>
371 void eraseNode() {
LockT lock(mMutex); NodeType* node =
nullptr; mCache.erase(node); }
378 mCache.addLeaf(leaf);
386 mCache.addTile(level, xyz, value, state);
397 return mCache.touchLeaf(xyz);
401 template<
typename NodeT>
407 return mCache.template probeNode<NodeT>(xyz);
409 template<
typename NodeT>
413 return mCache.template probeConstNode<NodeT>(xyz);
415 template<
typename NodeT>
418 return this->
template probeConstNode<NodeT>(xyz);
428 return mCache.probeLeaf(xyz);
433 return mCache.probeConstLeaf(xyz);
443 if (this->mTree) mCache.insert(
Coord(), &(this->mTree->root()));
452 template<
typename>
friend class Tree;
456 void release()
override 459 this->BaseT::release();
467 template<
typename NodeType>
468 void insert(
const Coord& xyz, NodeType* node) { mCache.insert(xyz, node); }
471 using InvTreeT =
typename RootNodeT::NodeChainType;
473 using BeginT =
typename boost::mpl::begin<InvTreeT>::type;
474 using FirstT =
typename boost::mpl::advance<BeginT, boost::mpl::int_<CacheLevels>>::type;
475 using LastT =
typename boost::mpl::find<InvTreeT, RootNodeT>::type;
476 using SubtreeT =
typename boost::mpl::erase<InvTreeT, FirstT, LastT>::type;
481 mutable MutexType mMutex;
489 template<
typename TreeType,
bool IsSafe>
501 template<
typename TreeType,
bool IsSafe>
513 template<
typename TreeType,
bool IsSafe>
525 template<
typename TreeType,
bool IsSafe>
547 template<
typename TreeType,
bool IsSafe = true>
566 template<
typename TreeCacheT,
typename NodeVecT,
bool AtRoot>
570 using NodeType =
typename boost::mpl::front<NodeVecT>::type;
589 mNext(parent, other.mNext)
598 mNext.copy(parent, other.mNext);
605 return (this->isHashed(xyz) || mNext.isCached(xyz));
611 mHash = (node !=
nullptr) ? xyz & ~(NodeType::DIM-1) :
Coord::max();
615 template<
typename OtherNodeType>
616 void insert(
const Coord& xyz,
const OtherNodeType* node) { mNext.insert(xyz, node); }
621 template<
typename OtherNodeType>
622 void erase(
const OtherNodeType* node) { mNext.erase(node); }
634 static_assert(!TreeCacheT::IsConstTree,
"can't get a non-const node from a const tree");
635 node =
const_cast<NodeType*
>(mNode);
638 template<
typename OtherNodeType>
639 void getNode(OtherNodeType*& node) { mNext.getNode(node); }
644 if (this->isHashed(xyz)) {
646 return mNode->getValueAndCache(xyz, *mParent);
648 return mNext.getValue(xyz);
653 static_assert(!TreeCacheT::IsConstTree,
"can't add a node to a const tree");
654 if (NodeType::LEVEL == 0)
return;
655 if (this->isHashed(leaf->origin())) {
657 return const_cast<NodeType*
>(mNode)->addLeafAndCache(leaf, *mParent);
664 static_assert(!TreeCacheT::IsConstTree,
"can't add a tile to a const tree");
665 if (NodeType::LEVEL < level)
return;
666 if (this->isHashed(xyz)) {
668 return const_cast<NodeType*
>(mNode)->addTileAndCache(
669 level, xyz, value, state, *mParent);
671 mNext.addTile(level, xyz, value, state);
676 static_assert(!TreeCacheT::IsConstTree,
"can't get a non-const node from a const tree");
677 if (this->isHashed(xyz)) {
679 return const_cast<NodeType*
>(mNode)->touchLeafAndCache(xyz, *mParent);
681 return mNext.touchLeaf(xyz);
686 static_assert(!TreeCacheT::IsConstTree,
"can't get a non-const node from a const tree");
687 if (this->isHashed(xyz)) {
689 return const_cast<NodeType*
>(mNode)->probeLeafAndCache(xyz, *mParent);
691 return mNext.probeLeaf(xyz);
696 if (this->isHashed(xyz)) {
698 return mNode->probeConstLeafAndCache(xyz, *mParent);
700 return mNext.probeConstLeaf(xyz);
703 template<
typename NodeT>
706 static_assert(!TreeCacheT::IsConstTree,
"can't get a non-const node from a const tree");
708 if (this->isHashed(xyz)) {
709 if ((std::is_same<NodeT, NodeType>::value)) {
711 return reinterpret_cast<NodeT*
>(
const_cast<NodeType*
>(mNode));
713 return const_cast<NodeType*
>(mNode)->
template probeNodeAndCache<NodeT>(xyz, *mParent);
715 return mNext.template probeNode<NodeT>(xyz);
719 template<
typename NodeT>
723 if (this->isHashed(xyz)) {
724 if ((std::is_same<NodeT, NodeType>::value)) {
726 return reinterpret_cast<const NodeT*
>(mNode);
728 return mNode->template probeConstNodeAndCache<NodeT>(xyz, *mParent);
730 return mNext.template probeConstNode<NodeT>(xyz);
737 if (this->isHashed(xyz)) {
739 return mNode->isValueOnAndCache(xyz, *mParent);
741 return mNext.isValueOn(xyz);
747 if (this->isHashed(xyz)) {
749 return mNode->probeValueAndCache(xyz, value, *mParent);
751 return mNext.probeValue(xyz, value);
756 if (this->isHashed(xyz)) {
758 return static_cast<int>(TreeCacheT::RootNodeT::LEVEL) -
759 static_cast<int>(mNode->getValueLevelAndCache(xyz, *mParent));
761 return mNext.getValueDepth(xyz);
767 if (this->isHashed(xyz)) {
769 return mNode->getValueLevelAndCache(xyz, *mParent)==0;
771 return mNext.isVoxel(xyz);
778 if (this->isHashed(xyz)) {
780 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
781 const_cast<NodeType*
>(mNode)->setValueAndCache(xyz, value, *mParent);
783 mNext.setValue(xyz, value);
788 if (this->isHashed(xyz)) {
790 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
791 const_cast<NodeType*
>(mNode)->setValueOnlyAndCache(xyz, value, *mParent);
793 mNext.setValueOnly(xyz, value);
801 template<
typename ModifyOp>
804 if (this->isHashed(xyz)) {
806 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
807 const_cast<NodeType*
>(mNode)->modifyValueAndCache(xyz, op, *mParent);
809 mNext.modifyValue(xyz, op);
815 template<
typename ModifyOp>
818 if (this->isHashed(xyz)) {
820 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
821 const_cast<NodeType*
>(mNode)->modifyValueAndActiveStateAndCache(xyz, op, *mParent);
823 mNext.modifyValueAndActiveState(xyz, op);
830 if (this->isHashed(xyz)) {
832 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
833 const_cast<NodeType*
>(mNode)->setValueOffAndCache(xyz, value, *mParent);
835 mNext.setValueOff(xyz, value);
842 if (this->isHashed(xyz)) {
844 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
845 const_cast<NodeType*
>(mNode)->setActiveStateAndCache(xyz, on, *mParent);
847 mNext.setActiveState(xyz, on);
855 bool isHashed(
const Coord& xyz)
const 865 using RestT =
typename boost::mpl::pop_front<NodeVecT>::type;
866 CacheItem<TreeCacheT, RestT, boost::mpl::size<RestT>::value == 1> mNext;
871 template<
typename TreeCacheT,
typename NodeVecT>
879 CacheItem(TreeCacheT& parent): mParent(&parent), mRoot(nullptr) {}
894 template<
typename OtherNodeType>
903 static_assert(!TreeCacheT::IsConstTree,
"can't get a non-const node from a const tree");
911 static_assert(!TreeCacheT::IsConstTree,
"can't add a node to a const tree");
912 const_cast<RootNodeType*
>(mRoot)->addLeafAndCache(leaf, *mParent);
918 static_assert(!TreeCacheT::IsConstTree,
"can't add a tile to a const tree");
919 const_cast<RootNodeType*
>(mRoot)->addTileAndCache(level, xyz, value, state, *mParent);
925 static_assert(!TreeCacheT::IsConstTree,
"can't get a non-const node from a const tree");
926 return const_cast<RootNodeType*
>(mRoot)->touchLeafAndCache(xyz, *mParent);
932 static_assert(!TreeCacheT::IsConstTree,
"can't get a non-const node from a const tree");
933 return const_cast<RootNodeType*
>(mRoot)->probeLeafAndCache(xyz, *mParent);
939 return mRoot->probeConstLeafAndCache(xyz, *mParent);
942 template<
typename NodeType>
946 static_assert(!TreeCacheT::IsConstTree,
"can't get a non-const node from a const tree");
948 template probeNodeAndCache<NodeType>(xyz, *mParent);
951 template<
typename NodeType>
955 return mRoot->template probeConstNodeAndCache<NodeType>(xyz, *mParent);
961 return mRoot->getValueDepthAndCache(xyz, *mParent);
966 return mRoot->isValueOnAndCache(xyz, *mParent);
972 return mRoot->probeValueAndCache(xyz, value, *mParent);
977 return mRoot->getValueDepthAndCache(xyz, *mParent) ==
978 static_cast<int>(RootNodeType::LEVEL);
983 return mRoot->getValueAndCache(xyz, *mParent);
989 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
990 const_cast<RootNodeType*
>(mRoot)->setValueAndCache(xyz, value, *mParent);
995 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
996 const_cast<RootNodeType*
>(mRoot)->setValueOnlyAndCache(xyz, value, *mParent);
1000 template<
typename ModifyOp>
1004 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
1005 const_cast<RootNodeType*
>(mRoot)->modifyValueAndCache(xyz, op, *mParent);
1008 template<
typename ModifyOp>
1012 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
1013 const_cast<RootNodeType*
>(mRoot)->modifyValueAndActiveStateAndCache(xyz, op, *mParent);
1019 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
1020 const_cast<RootNodeType*
>(mRoot)->setValueOffAndCache(xyz, value, *mParent);
1026 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
1027 const_cast<RootNodeType*
>(mRoot)->setActiveStateAndCache(xyz, on, *mParent);
1034 bool isHashed(
const Coord&)
const {
return false; }
1036 TreeCacheT* mParent;
1047 template<
typename _TreeType,
bool IsSafe>
1066 if (&other !=
this) this->BaseT::operator=(other);
1078 assert(BaseT::mTree);
1079 return BaseT::mTree->getValue(xyz);
1085 assert(BaseT::mTree);
1086 return BaseT::mTree->isValueOn(xyz);
1092 assert(BaseT::mTree);
1093 return BaseT::mTree->probeValue(xyz, value);
1101 assert(BaseT::mTree);
1102 return BaseT::mTree->getValueDepth(xyz);
1109 assert(BaseT::mTree);
1110 return BaseT::mTree->getValueDepth(xyz) ==
static_cast<int>(RootNodeT::LEVEL);
1117 assert(BaseT::mTree);
1118 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1119 BaseT::mTree->setValue(xyz, value);
1127 assert(BaseT::mTree);
1128 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1129 BaseT::mTree->setValueOnly(xyz, value);
1135 assert(BaseT::mTree);
1136 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1137 BaseT::mTree->root().setValueOff(xyz, value);
1143 template<
typename ModifyOp>
1146 assert(BaseT::mTree);
1147 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1148 BaseT::mTree->modifyValue(xyz, op);
1153 template<
typename ModifyOp>
1156 assert(BaseT::mTree);
1157 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1158 BaseT::mTree->modifyValueAndActiveState(xyz, op);
1164 assert(BaseT::mTree);
1165 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1166 BaseT::mTree->setActiveState(xyz, on);
1174 template<
typename NodeT> NodeT*
getNode() {
return nullptr; }
1184 assert(BaseT::mTree);
1185 static_assert(!BaseT::IsConstTree,
"can't add a node to a const tree");
1186 BaseT::mTree->root().addLeaf(leaf);
1193 assert(BaseT::mTree);
1194 static_assert(!BaseT::IsConstTree,
"can't add a tile to a const tree");
1195 BaseT::mTree->root().addTile(level, xyz, value, state);
1205 assert(BaseT::mTree);
1206 static_assert(!BaseT::IsConstTree,
"can't get a non-const node from a const tree");
1207 return BaseT::mTree->touchLeaf(xyz);
1210 template<
typename NodeT>
1213 assert(BaseT::mTree);
1214 static_assert(!BaseT::IsConstTree,
"can't get a non-const node from a const tree");
1215 return BaseT::mTree->template probeNode<NodeT>(xyz);
1218 template<
typename NodeT>
1221 assert(BaseT::mTree);
1222 return BaseT::mTree->template probeConstNode<NodeT>(xyz);
1227 return this->
template probeNode<LeafNodeT>(xyz);
1232 return this->
template probeConstNode<LeafNodeT>(xyz);
1237 return this->probeConstLeaf(xyz);
1245 template<
typename>
friend class Tree;
1249 void release()
override { this->BaseT::release(); }
1260 template<
typename _TreeType,
bool IsSafe, Index L0>
1264 static_assert(_TreeType::DEPTH >= 2,
"cache size exceeds tree depth");
1265 static_assert(L0 < _TreeType::RootNodeType::LEVEL,
"invalid cache level");
1272 using NodeT0 =
typename boost::mpl::at<InvTreeT, boost::mpl::int_<L0> >::type;
1288 if (&other !=
this) {
1289 this->BaseT::operator=(other);
1302 assert(BaseT::mTree);
1303 return this->isHashed(xyz);
1309 assert(BaseT::mTree);
1310 if (this->isHashed(xyz)) {
1312 return mNode0->getValueAndCache(xyz, this->
self());
1314 return BaseT::mTree->root().getValueAndCache(xyz, this->
self());
1320 assert(BaseT::mTree);
1321 if (this->isHashed(xyz)) {
1323 return mNode0->isValueOnAndCache(xyz, this->
self());
1325 return BaseT::mTree->root().isValueOnAndCache(xyz, this->
self());
1331 assert(BaseT::mTree);
1332 if (this->isHashed(xyz)) {
1334 return mNode0->probeValueAndCache(xyz, value, this->
self());
1336 return BaseT::mTree->root().probeValueAndCache(xyz, value, this->
self());
1344 assert(BaseT::mTree);
1345 if (this->isHashed(xyz)) {
1347 return RootNodeT::LEVEL - mNode0->getValueLevelAndCache(xyz, this->
self());
1349 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->
self());
1356 assert(BaseT::mTree);
1357 if (this->isHashed(xyz)) {
1359 return mNode0->getValueLevelAndCache(xyz, this->
self()) == 0;
1361 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->
self()) ==
1362 static_cast<int>(RootNodeT::LEVEL);
1369 assert(BaseT::mTree);
1370 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1371 if (this->isHashed(xyz)) {
1373 const_cast<NodeT0*
>(mNode0)->setValueAndCache(xyz, value, *
this);
1375 BaseT::mTree->root().setValueAndCache(xyz, value, *
this);
1384 assert(BaseT::mTree);
1385 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1386 if (this->isHashed(xyz)) {
1388 const_cast<NodeT0*
>(mNode0)->setValueOnlyAndCache(xyz, value, *
this);
1390 BaseT::mTree->root().setValueOnlyAndCache(xyz, value, *
this);
1397 assert(BaseT::mTree);
1398 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1399 if (this->isHashed(xyz)) {
1401 const_cast<NodeT0*
>(mNode0)->setValueOffAndCache(xyz, value, *
this);
1403 BaseT::mTree->root().setValueOffAndCache(xyz, value, *
this);
1410 template<
typename ModifyOp>
1413 assert(BaseT::mTree);
1414 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1415 if (this->isHashed(xyz)) {
1417 const_cast<NodeT0*
>(mNode0)->modifyValueAndCache(xyz, op, *
this);
1419 BaseT::mTree->root().modifyValueAndCache(xyz, op, *
this);
1425 template<
typename ModifyOp>
1428 assert(BaseT::mTree);
1429 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1430 if (this->isHashed(xyz)) {
1432 const_cast<NodeT0*
>(mNode0)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
1434 BaseT::mTree->root().modifyValueAndActiveStateAndCache(xyz, op, *
this);
1441 assert(BaseT::mTree);
1442 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1443 if (this->isHashed(xyz)) {
1445 const_cast<NodeT0*
>(mNode0)->setActiveStateAndCache(xyz, on, *
this);
1447 BaseT::mTree->root().setActiveStateAndCache(xyz, on, *
this);
1456 template<
typename NodeT>
1459 const NodeT* node =
nullptr;
1460 this->getNode(node);
1461 return const_cast<NodeT*
>(node);
1466 template<
typename NodeT>
1472 template<
typename NodeT>
1475 const NodeT* node =
nullptr;
1476 this->eraseNode(node);
1483 assert(BaseT::mTree);
1484 static_assert(!BaseT::IsConstTree,
"can't add a node to a const tree");
1485 BaseT::mTree->root().addLeaf(leaf);
1492 assert(BaseT::mTree);
1493 static_assert(!BaseT::IsConstTree,
"can't add a tile to a const tree");
1494 BaseT::mTree->root().addTile(level, xyz, value, state);
1505 assert(BaseT::mTree);
1506 static_assert(!BaseT::IsConstTree,
"can't get a non-const node from a const tree");
1507 if (this->isHashed(xyz)) {
1509 return const_cast<NodeT0*
>(mNode0)->touchLeafAndCache(xyz, *
this);
1511 return BaseT::mTree->root().touchLeafAndCache(xyz, *
this);
1516 template<
typename NodeT>
1519 assert(BaseT::mTree);
1520 static_assert(!BaseT::IsConstTree,
"can't get a non-const node from a const tree");
1522 if ((std::is_same<NodeT, NodeT0>::value)) {
1523 if (this->isHashed(xyz)) {
1525 return reinterpret_cast<NodeT*
>(
const_cast<NodeT0*
>(mNode0));
1527 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
1534 return this->
template probeNode<LeafNodeT>(xyz);
1539 template<
typename NodeT>
1542 assert(BaseT::mTree);
1544 if ((std::is_same<NodeT, NodeT0>::value)) {
1545 if (this->isHashed(xyz)) {
1547 return reinterpret_cast<const NodeT*
>(mNode0);
1549 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
1556 return this->
template probeConstNode<LeafNodeT>(xyz);
1573 template<
typename>
friend class Tree;
1578 void getNode(
const NodeT0*& node) { node = mNode0; }
1581 node = (BaseT::mTree ? &BaseT::mTree->root() :
nullptr);
1583 template<
typename OtherNodeType>
void getNode(
const OtherNodeType*& node) { node =
nullptr; }
1585 template<
typename OtherNodeType>
void eraseNode(
const OtherNodeType*) {}
1590 mKey0 = other.mKey0;
1591 mNode0 = other.mNode0;
1596 void release()
override 1598 this->BaseT::release();
1605 inline void insert(
const Coord& xyz,
const NodeT0* node)
1608 mKey0 = xyz & ~(NodeT0::DIM-1);
1614 template<
typename OtherNodeType>
inline void insert(
const Coord&,
const OtherNodeType*) {}
1616 inline bool isHashed(
const Coord& xyz)
const 1622 mutable Coord mKey0;
1623 mutable const NodeT0* mNode0;
1634 template<
typename _TreeType,
bool IsSafe, Index L0, Index L1>
1638 static_assert(_TreeType::DEPTH >= 3,
"cache size exceeds tree depth");
1639 static_assert(L0 < L1,
"invalid cache level");
1640 static_assert(L1 < _TreeType::RootNodeType::LEVEL,
"invalid cache level");
1648 using NodeT0 =
typename boost::mpl::at<InvTreeT, boost::mpl::int_<L0>>::type;
1649 using NodeT1 =
typename boost::mpl::at<InvTreeT, boost::mpl::int_<L1>>::type;
1653 mKey0(
Coord::
max()), mNode0(nullptr),
1654 mKey1(
Coord::
max()), mNode1(nullptr) {}
1665 if (&other !=
this) {
1666 this->BaseT::operator=(other);
1679 assert(BaseT::mTree);
1680 return this->isHashed1(xyz) || this->isHashed0(xyz);
1686 assert(BaseT::mTree);
1687 if (this->isHashed0(xyz)) {
1689 return mNode0->getValueAndCache(xyz, this->
self());
1690 }
else if (this->isHashed1(xyz)) {
1692 return mNode1->getValueAndCache(xyz, this->
self());
1694 return BaseT::mTree->root().getValueAndCache(xyz, this->
self());
1700 assert(BaseT::mTree);
1701 if (this->isHashed0(xyz)) {
1703 return mNode0->isValueOnAndCache(xyz, this->
self());
1704 }
else if (this->isHashed1(xyz)) {
1706 return mNode1->isValueOnAndCache(xyz, this->
self());
1708 return BaseT::mTree->root().isValueOnAndCache(xyz, this->
self());
1714 assert(BaseT::mTree);
1715 if (this->isHashed0(xyz)) {
1717 return mNode0->probeValueAndCache(xyz, value, this->
self());
1718 }
else if (this->isHashed1(xyz)) {
1720 return mNode1->probeValueAndCache(xyz, value, this->
self());
1722 return BaseT::mTree->root().probeValueAndCache(xyz, value, this->
self());
1730 assert(BaseT::mTree);
1731 if (this->isHashed0(xyz)) {
1733 return RootNodeT::LEVEL - mNode0->getValueLevelAndCache(xyz, this->
self());
1734 }
else if (this->isHashed1(xyz)) {
1736 return RootNodeT::LEVEL - mNode1->getValueLevelAndCache(xyz, this->
self());
1738 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->
self());
1745 assert(BaseT::mTree);
1746 if (this->isHashed0(xyz)) {
1748 return mNode0->getValueLevelAndCache(xyz, this->
self())==0;
1749 }
else if (this->isHashed1(xyz)) {
1751 return mNode1->getValueLevelAndCache(xyz, this->
self())==0;
1753 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->
self()) ==
1754 static_cast<int>(RootNodeT::LEVEL);
1761 assert(BaseT::mTree);
1762 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1763 if (this->isHashed0(xyz)) {
1765 const_cast<NodeT0*
>(mNode0)->setValueAndCache(xyz, value, *
this);
1766 }
else if (this->isHashed1(xyz)) {
1768 const_cast<NodeT1*
>(mNode1)->setValueAndCache(xyz, value, *
this);
1770 BaseT::mTree->root().setValueAndCache(xyz, value, *
this);
1779 assert(BaseT::mTree);
1780 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1781 if (this->isHashed0(xyz)) {
1783 const_cast<NodeT0*
>(mNode0)->setValueOnlyAndCache(xyz, value, *
this);
1784 }
else if (this->isHashed1(xyz)) {
1786 const_cast<NodeT1*
>(mNode1)->setValueOnlyAndCache(xyz, value, *
this);
1788 BaseT::mTree->root().setValueOnlyAndCache(xyz, value, *
this);
1795 assert(BaseT::mTree);
1796 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1797 if (this->isHashed0(xyz)) {
1799 const_cast<NodeT0*
>(mNode0)->setValueOffAndCache(xyz, value, *
this);
1800 }
else if (this->isHashed1(xyz)) {
1802 const_cast<NodeT1*
>(mNode1)->setValueOffAndCache(xyz, value, *
this);
1804 BaseT::mTree->root().setValueOffAndCache(xyz, value, *
this);
1811 template<
typename ModifyOp>
1814 assert(BaseT::mTree);
1815 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1816 if (this->isHashed0(xyz)) {
1818 const_cast<NodeT0*
>(mNode0)->modifyValueAndCache(xyz, op, *
this);
1819 }
else if (this->isHashed1(xyz)) {
1821 const_cast<NodeT1*
>(mNode1)->modifyValueAndCache(xyz, op, *
this);
1823 BaseT::mTree->root().modifyValueAndCache(xyz, op, *
this);
1829 template<
typename ModifyOp>
1832 assert(BaseT::mTree);
1833 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1834 if (this->isHashed0(xyz)) {
1836 const_cast<NodeT0*
>(mNode0)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
1837 }
else if (this->isHashed1(xyz)) {
1839 const_cast<NodeT1*
>(mNode1)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
1841 BaseT::mTree->root().modifyValueAndActiveStateAndCache(xyz, op, *
this);
1848 assert(BaseT::mTree);
1849 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1850 if (this->isHashed0(xyz)) {
1852 const_cast<NodeT0*
>(mNode0)->setActiveStateAndCache(xyz, on, *
this);
1853 }
else if (this->isHashed1(xyz)) {
1855 const_cast<NodeT1*
>(mNode1)->setActiveStateAndCache(xyz, on, *
this);
1857 BaseT::mTree->root().setActiveStateAndCache(xyz, on, *
this);
1866 template<
typename NodeT>
1869 const NodeT* node =
nullptr;
1870 this->getNode(node);
1871 return const_cast<NodeT*
>(node);
1876 template<
typename NodeT>
1882 template<
typename NodeT>
1885 const NodeT* node =
nullptr;
1886 this->eraseNode(node);
1893 assert(BaseT::mTree);
1894 static_assert(!BaseT::IsConstTree,
"can't add a node to a const tree");
1895 if (this->isHashed1(leaf->origin())) {
1897 return const_cast<NodeT1*
>(mNode1)->addLeafAndCache(leaf, *
this);
1899 BaseT::mTree->root().addLeafAndCache(leaf, *
this);
1906 assert(BaseT::mTree);
1907 static_assert(!BaseT::IsConstTree,
"can't add a tile to a const tree");
1908 if (this->isHashed1(xyz)) {
1910 return const_cast<NodeT1*
>(mNode1)->addTileAndCache(level, xyz, value, state, *
this);
1912 BaseT::mTree->root().addTileAndCache(level, xyz, value, state, *
this);
1923 assert(BaseT::mTree);
1924 static_assert(!BaseT::IsConstTree,
"can't get a non-const node from a const tree");
1925 if (this->isHashed0(xyz)) {
1927 return const_cast<NodeT0*
>(mNode0)->touchLeafAndCache(xyz, *
this);
1928 }
else if (this->isHashed1(xyz)) {
1930 return const_cast<NodeT1*
>(mNode1)->touchLeafAndCache(xyz, *
this);
1932 return BaseT::mTree->root().touchLeafAndCache(xyz, *
this);
1936 template<
typename NodeT>
1939 assert(BaseT::mTree);
1940 static_assert(!BaseT::IsConstTree,
"can't get a non-const node from a const tree");
1942 if ((std::is_same<NodeT, NodeT0>::value)) {
1943 if (this->isHashed0(xyz)) {
1945 return reinterpret_cast<NodeT*
>(
const_cast<NodeT0*
>(mNode0));
1946 }
else if (this->isHashed1(xyz)) {
1948 return const_cast<NodeT1*
>(mNode1)->
template probeNodeAndCache<NodeT>(xyz, *
this);
1950 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
1951 }
else if ((std::is_same<NodeT, NodeT1>::value)) {
1952 if (this->isHashed1(xyz)) {
1954 return reinterpret_cast<NodeT*
>(
const_cast<NodeT1*
>(mNode1));
1956 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
1967 template<
typename NodeT>
1971 if ((std::is_same<NodeT, NodeT0>::value)) {
1972 if (this->isHashed0(xyz)) {
1974 return reinterpret_cast<const NodeT*
>(mNode0);
1975 }
else if (this->isHashed1(xyz)) {
1977 return mNode1->template probeConstNodeAndCache<NodeT>(xyz, this->
self());
1979 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
1980 }
else if ((std::is_same<NodeT, NodeT1>::value)) {
1981 if (this->isHashed1(xyz)) {
1983 return reinterpret_cast<const NodeT*
>(mNode1);
1985 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
1994 return this->
template probeConstNode<LeafNodeT>(xyz);
2000 template<
typename NodeT>
2003 assert(BaseT::mTree);
2005 if ((std::is_same<NodeT, NodeT0>::value)) {
2006 if (this->isHashed0(xyz)) {
2008 return reinterpret_cast<const NodeT*
>(mNode0);
2009 }
else if (this->isHashed1(xyz)) {
2011 return mNode1->template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2013 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2014 }
else if ((std::is_same<NodeT, NodeT1>::value)) {
2015 if (this->isHashed1(xyz)) {
2017 return reinterpret_cast<const NodeT*
>(mNode1);
2019 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2040 template<
typename>
friend class Tree;
2045 void getNode(
const NodeT0*& node) { node = mNode0; }
2046 void getNode(
const NodeT1*& node) { node = mNode1; }
2049 node = (BaseT::mTree ? &BaseT::mTree->root() :
nullptr);
2051 template<
typename OtherNodeType>
void getNode(
const OtherNodeType*& node) { node =
nullptr; }
2054 void eraseNode(
const NodeT1*) { mKey1 =
Coord::max(); mNode1 =
nullptr; }
2055 template<
typename OtherNodeType>
void eraseNode(
const OtherNodeType*) {}
2060 mKey0 = other.mKey0;
2061 mNode0 = other.mNode0;
2062 mKey1 = other.mKey1;
2063 mNode1 = other.mNode1;
2068 void release()
override 2070 this->BaseT::release();
2078 inline void insert(
const Coord& xyz,
const NodeT0* node)
2081 mKey0 = xyz & ~(NodeT0::DIM-1);
2084 inline void insert(
const Coord& xyz,
const NodeT1* node)
2087 mKey1 = xyz & ~(NodeT1::DIM-1);
2092 template<
typename NodeT>
inline void insert(
const Coord&,
const NodeT*) {}
2094 inline bool isHashed0(
const Coord& xyz)
const 2100 inline bool isHashed1(
const Coord& xyz)
const 2106 mutable Coord mKey0;
2107 mutable const NodeT0* mNode0;
2108 mutable Coord mKey1;
2109 mutable const NodeT1* mNode1;
2123 template<
typename _TreeType,
bool IsSafe, Index L0, Index L1, Index L2>
2127 static_assert(_TreeType::DEPTH >= 4,
"cache size exceeds tree depth");
2128 static_assert(L0 < L1,
"invalid cache level");
2129 static_assert(L1 < L2,
"invalid cache level");
2130 static_assert(L2 < _TreeType::RootNodeType::LEVEL,
"invalid cache level");
2138 using NodeT0 =
typename boost::mpl::at<InvTreeT, boost::mpl::int_<L0> >::type;
2139 using NodeT1 =
typename boost::mpl::at<InvTreeT, boost::mpl::int_<L1> >::type;
2140 using NodeT2 =
typename boost::mpl::at<InvTreeT, boost::mpl::int_<L2> >::type;
2144 mKey0(
Coord::
max()), mNode0(nullptr),
2145 mKey1(
Coord::
max()), mNode1(nullptr),
2146 mKey2(
Coord::
max()), mNode2(nullptr) {}
2154 if (&other !=
this) {
2155 this->BaseT::operator=(other);
2171 assert(BaseT::mTree);
2172 return this->isHashed2(xyz) || this->isHashed1(xyz) || this->isHashed0(xyz);
2178 assert(BaseT::mTree);
2179 if (this->isHashed0(xyz)) {
2181 return mNode0->getValueAndCache(xyz, this->
self());
2182 }
else if (this->isHashed1(xyz)) {
2184 return mNode1->getValueAndCache(xyz, this->
self());
2185 }
else if (this->isHashed2(xyz)) {
2187 return mNode2->getValueAndCache(xyz, this->
self());
2189 return BaseT::mTree->root().getValueAndCache(xyz, this->
self());
2195 assert(BaseT::mTree);
2196 if (this->isHashed0(xyz)) {
2198 return mNode0->isValueOnAndCache(xyz, this->
self());
2199 }
else if (this->isHashed1(xyz)) {
2201 return mNode1->isValueOnAndCache(xyz, this->
self());
2202 }
else if (this->isHashed2(xyz)) {
2204 return mNode2->isValueOnAndCache(xyz, this->
self());
2206 return BaseT::mTree->root().isValueOnAndCache(xyz, this->
self());
2212 assert(BaseT::mTree);
2213 if (this->isHashed0(xyz)) {
2215 return mNode0->probeValueAndCache(xyz, value, this->
self());
2216 }
else if (this->isHashed1(xyz)) {
2218 return mNode1->probeValueAndCache(xyz, value, this->
self());
2219 }
else if (this->isHashed2(xyz)) {
2221 return mNode2->probeValueAndCache(xyz, value, this->
self());
2223 return BaseT::mTree->root().probeValueAndCache(xyz, value, this->
self());
2231 assert(BaseT::mTree);
2232 if (this->isHashed0(xyz)) {
2234 return RootNodeT::LEVEL - mNode0->getValueLevelAndCache(xyz, this->
self());
2235 }
else if (this->isHashed1(xyz)) {
2237 return RootNodeT::LEVEL - mNode1->getValueLevelAndCache(xyz, this->
self());
2238 }
else if (this->isHashed2(xyz)) {
2240 return RootNodeT::LEVEL - mNode2->getValueLevelAndCache(xyz, this->
self());
2242 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->
self());
2249 assert(BaseT::mTree);
2250 if (this->isHashed0(xyz)) {
2252 return mNode0->getValueLevelAndCache(xyz, this->
self())==0;
2253 }
else if (this->isHashed1(xyz)) {
2255 return mNode1->getValueLevelAndCache(xyz, this->
self())==0;
2256 }
else if (this->isHashed2(xyz)) {
2258 return mNode2->getValueLevelAndCache(xyz, this->
self())==0;
2260 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->
self()) ==
2261 static_cast<int>(RootNodeT::LEVEL);
2268 assert(BaseT::mTree);
2269 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
2270 if (this->isHashed0(xyz)) {
2272 const_cast<NodeT0*
>(mNode0)->setValueAndCache(xyz, value, *
this);
2273 }
else if (this->isHashed1(xyz)) {
2275 const_cast<NodeT1*
>(mNode1)->setValueAndCache(xyz, value, *
this);
2276 }
else if (this->isHashed2(xyz)) {
2278 const_cast<NodeT2*
>(mNode2)->setValueAndCache(xyz, value, *
this);
2280 BaseT::mTree->root().setValueAndCache(xyz, value, *
this);
2289 assert(BaseT::mTree);
2290 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
2291 if (this->isHashed0(xyz)) {
2293 const_cast<NodeT0*
>(mNode0)->setValueOnlyAndCache(xyz, value, *
this);
2294 }
else if (this->isHashed1(xyz)) {
2296 const_cast<NodeT1*
>(mNode1)->setValueOnlyAndCache(xyz, value, *
this);
2297 }
else if (this->isHashed2(xyz)) {
2299 const_cast<NodeT2*
>(mNode2)->setValueOnlyAndCache(xyz, value, *
this);
2301 BaseT::mTree->root().setValueOnlyAndCache(xyz, value, *
this);
2308 assert(BaseT::mTree);
2309 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
2310 if (this->isHashed0(xyz)) {
2312 const_cast<NodeT0*
>(mNode0)->setValueOffAndCache(xyz, value, *
this);
2313 }
else if (this->isHashed1(xyz)) {
2315 const_cast<NodeT1*
>(mNode1)->setValueOffAndCache(xyz, value, *
this);
2316 }
else if (this->isHashed2(xyz)) {
2318 const_cast<NodeT2*
>(mNode2)->setValueOffAndCache(xyz, value, *
this);
2320 BaseT::mTree->root().setValueOffAndCache(xyz, value, *
this);
2327 template<
typename ModifyOp>
2330 assert(BaseT::mTree);
2331 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
2332 if (this->isHashed0(xyz)) {
2334 const_cast<NodeT0*
>(mNode0)->modifyValueAndCache(xyz, op, *
this);
2335 }
else if (this->isHashed1(xyz)) {
2337 const_cast<NodeT1*
>(mNode1)->modifyValueAndCache(xyz, op, *
this);
2338 }
else if (this->isHashed2(xyz)) {
2340 const_cast<NodeT2*
>(mNode2)->modifyValueAndCache(xyz, op, *
this);
2342 BaseT::mTree->root().modifyValueAndCache(xyz, op, *
this);
2348 template<
typename ModifyOp>
2351 assert(BaseT::mTree);
2352 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
2353 if (this->isHashed0(xyz)) {
2355 const_cast<NodeT0*
>(mNode0)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
2356 }
else if (this->isHashed1(xyz)) {
2358 const_cast<NodeT1*
>(mNode1)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
2359 }
else if (this->isHashed2(xyz)) {
2361 const_cast<NodeT2*
>(mNode2)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
2363 BaseT::mTree->root().modifyValueAndActiveStateAndCache(xyz, op, *
this);
2370 assert(BaseT::mTree);
2371 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
2372 if (this->isHashed0(xyz)) {
2374 const_cast<NodeT0*
>(mNode0)->setActiveStateAndCache(xyz, on, *
this);
2375 }
else if (this->isHashed1(xyz)) {
2377 const_cast<NodeT1*
>(mNode1)->setActiveStateAndCache(xyz, on, *
this);
2378 }
else if (this->isHashed2(xyz)) {
2380 const_cast<NodeT2*
>(mNode2)->setActiveStateAndCache(xyz, on, *
this);
2382 BaseT::mTree->root().setActiveStateAndCache(xyz, on, *
this);
2391 template<
typename NodeT>
2394 const NodeT* node =
nullptr;
2395 this->getNode(node);
2396 return const_cast<NodeT*
>(node);
2401 template<
typename NodeT>
2407 template<
typename NodeT>
2410 const NodeT* node =
nullptr;
2411 this->eraseNode(node);
2418 assert(BaseT::mTree);
2419 static_assert(!BaseT::IsConstTree,
"can't add a node to a const tree");
2420 if (this->isHashed1(leaf->origin())) {
2422 return const_cast<NodeT1*
>(mNode1)->addLeafAndCache(leaf, *
this);
2423 }
else if (this->isHashed2(leaf->origin())) {
2425 return const_cast<NodeT2*
>(mNode2)->addLeafAndCache(leaf, *
this);
2427 BaseT::mTree->root().addLeafAndCache(leaf, *
this);
2434 assert(BaseT::mTree);
2435 static_assert(!BaseT::IsConstTree,
"can't add a tile to a const tree");
2436 if (this->isHashed1(xyz)) {
2438 return const_cast<NodeT1*
>(mNode1)->addTileAndCache(level, xyz, value, state, *
this);
2439 }
if (this->isHashed2(xyz)) {
2441 return const_cast<NodeT2*
>(mNode2)->addTileAndCache(level, xyz, value, state, *
this);
2443 BaseT::mTree->root().addTileAndCache(level, xyz, value, state, *
this);
2454 assert(BaseT::mTree);
2455 static_assert(!BaseT::IsConstTree,
"can't get a non-const node from a const tree");
2456 if (this->isHashed0(xyz)) {
2458 return const_cast<NodeT0*
>(mNode0);
2459 }
else if (this->isHashed1(xyz)) {
2461 return const_cast<NodeT1*
>(mNode1)->touchLeafAndCache(xyz, *
this);
2462 }
else if (this->isHashed2(xyz)) {
2464 return const_cast<NodeT2*
>(mNode2)->touchLeafAndCache(xyz, *
this);
2466 return BaseT::mTree->root().touchLeafAndCache(xyz, *
this);
2470 template<
typename NodeT>
2473 assert(BaseT::mTree);
2474 static_assert(!BaseT::IsConstTree,
"can't get a non-const node from a const tree");
2476 if ((std::is_same<NodeT, NodeT0>::value)) {
2477 if (this->isHashed0(xyz)) {
2479 return reinterpret_cast<NodeT*
>(
const_cast<NodeT0*
>(mNode0));
2480 }
else if (this->isHashed1(xyz)) {
2482 return const_cast<NodeT1*
>(mNode1)->
template probeNodeAndCache<NodeT>(xyz, *
this);
2483 }
else if (this->isHashed2(xyz)) {
2485 return const_cast<NodeT2*
>(mNode2)->
template probeNodeAndCache<NodeT>(xyz, *
this);
2487 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
2488 }
else if ((std::is_same<NodeT, NodeT1>::value)) {
2489 if (this->isHashed1(xyz)) {
2491 return reinterpret_cast<NodeT*
>(
const_cast<NodeT1*
>(mNode1));
2492 }
else if (this->isHashed2(xyz)) {
2494 return const_cast<NodeT2*
>(mNode2)->
template probeNodeAndCache<NodeT>(xyz, *
this);
2496 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
2497 }
else if ((std::is_same<NodeT, NodeT2>::value)) {
2498 if (this->isHashed2(xyz)) {
2500 return reinterpret_cast<NodeT*
>(
const_cast<NodeT2*
>(mNode2));
2502 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
2513 template<
typename NodeT>
2516 assert(BaseT::mTree);
2518 if ((std::is_same<NodeT, NodeT0>::value)) {
2519 if (this->isHashed0(xyz)) {
2521 return reinterpret_cast<const NodeT*
>(mNode0);
2522 }
else if (this->isHashed1(xyz)) {
2524 return mNode1->template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2525 }
else if (this->isHashed2(xyz)) {
2527 return mNode2->template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2529 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2530 }
else if ((std::is_same<NodeT, NodeT1>::value)) {
2531 if (this->isHashed1(xyz)) {
2533 return reinterpret_cast<const NodeT*
>(mNode1);
2534 }
else if (this->isHashed2(xyz)) {
2536 return mNode2->template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2538 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2539 }
else if ((std::is_same<NodeT, NodeT2>::value)) {
2540 if (this->isHashed2(xyz)) {
2542 return reinterpret_cast<const NodeT*
>(mNode2);
2544 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2553 return this->
template probeConstNode<LeafNodeT>(xyz);
2574 template<
typename>
friend class Tree;
2582 mKey0 = other.mKey0;
2583 mNode0 = other.mNode0;
2584 mKey1 = other.mKey1;
2585 mNode1 = other.mNode1;
2586 mKey2 = other.mKey2;
2587 mNode2 = other.mNode2;
2592 void release()
override 2594 this->BaseT::release();
2597 void getNode(
const NodeT0*& node) { node = mNode0; }
2598 void getNode(
const NodeT1*& node) { node = mNode1; }
2599 void getNode(
const NodeT2*& node) { node = mNode2; }
2602 node = (BaseT::mTree ? &BaseT::mTree->root() :
nullptr);
2604 template<
typename OtherNodeType>
void getNode(
const OtherNodeType*& node) { node =
nullptr; }
2606 void eraseNode(
const NodeT0*) { mKey0 =
Coord::max(); mNode0 =
nullptr; }
2607 void eraseNode(
const NodeT1*) { mKey1 =
Coord::max(); mNode1 =
nullptr; }
2609 template<
typename OtherNodeType>
void eraseNode(
const OtherNodeType*) {}
2615 inline void insert(
const Coord& xyz,
const NodeT0* node)
2618 mKey0 = xyz & ~(NodeT0::DIM-1);
2621 inline void insert(
const Coord& xyz,
const NodeT1* node)
2624 mKey1 = xyz & ~(NodeT1::DIM-1);
2627 inline void insert(
const Coord& xyz,
const NodeT2* node)
2630 mKey2 = xyz & ~(NodeT2::DIM-1);
2635 template<
typename OtherNodeType>
2636 inline void insert(
const Coord&,
const OtherNodeType*)
2639 inline bool isHashed0(
const Coord& xyz)
const 2645 inline bool isHashed1(
const Coord& xyz)
const 2651 inline bool isHashed2(
const Coord& xyz)
const 2657 mutable Coord mKey0;
2658 mutable const NodeT0* mNode0;
2659 mutable Coord mKey1;
2660 mutable const NodeT1* mNode1;
2661 mutable Coord mKey2;
2662 mutable const NodeT2* mNode2;
2669 #endif // OPENVDB_TREE_VALUEACCESSOR_HAS_BEEN_INCLUDED CacheItem & copy(TreeCacheT &parent, const CacheItem &other)
Copy another CacheItem's node pointers and hash keys, but not its parent pointer. ...
Definition: ValueAccessor.h:593
typename boost::mpl::at< InvTreeT, boost::mpl::int_< L0 > >::type NodeT0
Definition: ValueAccessor.h:1272
void insert(const Coord &, const RootNodeType *root)
Definition: ValueAccessor.h:891
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:1307
Value accessor with two levels of node caching.
Definition: ValueAccessor.h:92
friend class Tree
Definition: ValueAccessor.h:452
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:1395
friend class InternalNode
Definition: ValueAccessor.h:2571
void setValueOn(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:998
typename TreeType::RootNodeType RootNodeT
Definition: ValueAccessor.h:1053
CacheItem(TreeCacheT &parent, const CacheItem &other)
Definition: ValueAccessor.h:880
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: ValueAccessor.h:1453
typename NodeType::ValueType ValueType
Definition: ValueAccessor.h:571
NodeT * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:2471
const NodeT * probeConstLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1968
friend class Tree
Definition: ValueAccessor.h:2040
void setValueOn(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:1773
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active without changing its value.
Definition: ValueAccessor.h:1861
bool isValueOn(const Coord &xyz) const
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:1083
typename TreeType::RootNodeType RootNodeT
Definition: ValueAccessor.h:226
Value accessor with three levels of node caching.
Definition: ValueAccessor.h:94
TreeType TreeType
Definition: ValueAccessor.h:1266
const ValueType & getValue(const Coord &xyz)
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:642
bool isCached(const Coord &xyz) const
Definition: ValueAccessor.h:1677
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:1490
const LeafNodeT * probeConstLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1230
bool isCached(const Coord &xyz) const
Return true if nodes along the path to the given voxel have been cached.
Definition: ValueAccessor.h:254
NodeT * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:1211
ValueAccessor & operator=(const ValueAccessor &other)
Definition: ValueAccessor.h:240
const NodeType * probeConstNode(const Coord &xyz)
Definition: ValueAccessor.h:952
const NodeT * probeConstNode(const Coord &xyz) const
Definition: ValueAccessor.h:1219
ValueAccessor3 & operator=(const ValueAccessor3 &other)
Asignment operator.
Definition: ValueAccessor.h:2152
const LeafNodeT * probeConstLeaf(const Coord &xyz) const
Return a pointer to the leaf node that contains voxel (x, y, z), or nullptr if no such node exists...
Definition: ValueAccessor.h:430
ValueAccessor2(TreeType &tree)
Constructor from a tree.
Definition: ValueAccessor.h:1652
bool isVoxel(const Coord &xyz) const
Definition: ValueAccessor.h:1354
void clear()
Definition: ValueAccessor.h:899
bool isVoxel(const Coord &xyz) const
Definition: ValueAccessor.h:284
typename TreeType::LeafNodeType LeafNodeT
Definition: ValueAccessor.h:2135
ValueAccessor(TreeType &tree)
Definition: ValueAccessor.h:518
This accessor is thread-safe (at the cost of speed) for both reading and writing to a tree...
Definition: ValueAccessor.h:548
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:1793
void addLeaf(LeafNodeT *leaf)
Add the specified leaf to this tree, possibly creating a child branch in the process. If the leaf node already exists, replace it.
Definition: ValueAccessor.h:375
bool isValueOn(const Coord &xyz)
Definition: ValueAccessor.h:963
void insertNode(const Coord &xyz, NodeT &node)
Definition: ValueAccessor.h:1877
void erase(const NodeType *)
Erase the node at this level.
Definition: ValueAccessor.h:619
typename NodeType::LeafNodeType LeafNodeType
Definition: ValueAccessor.h:572
NodeT * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:704
void addLeaf(LeafNodeType *leaf)
Definition: ValueAccessor.h:651
NodeT * getNode()
Return the cached node of type NodeType. [Mainly for internal use].
Definition: ValueAccessor.h:1174
void setValueOnly(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:786
friend class Tree
Definition: ValueAccessor.h:2574
static Coord max()
Return the largest possible coordinate.
Definition: Coord.h:73
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:1162
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: ValueAccessor.h:1451
void setValueOnly(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:992
int getValueDepth(const Coord &xyz) const
Definition: ValueAccessor.h:1728
Int32 ValueType
Definition: Coord.h:59
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:51
typename RootNodeType::ValueType ValueType
Definition: ValueAccessor.h:876
void insertNode(const Coord &xyz, NodeT &node)
Definition: ValueAccessor.h:1467
CacheItem(TreeCacheT &parent)
Definition: ValueAccessor.h:575
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:1154
LeafNodeT * touchLeaf(const Coord &xyz)
Return a pointer to the leaf node that contains voxel (x, y, z). If no such node exists, create one, but preserve the values and active states of all voxels.
Definition: ValueAccessor.h:394
int getValueDepth(const Coord &xyz) const
Definition: ValueAccessor.h:276
Value accessor with one level of node caching.
Definition: ValueAccessor.h:90
void newSetValue(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:305
const NodeT * probeConstNode(const Coord &xyz)
Definition: ValueAccessor.h:720
void setValueOn(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:293
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:383
const LeafNodeT * probeLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:2555
typename RootNodeT::NodeChainType InvTreeT
Definition: ValueAccessor.h:2137
int getValueDepth(const Coord &xyz) const
Definition: ValueAccessor.h:1342
static Index numCacheLevels()
Return the number of cache levels employed by this accessor.
Definition: ValueAccessor.h:251
LeafNodeT * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1532
const LeafNodeType * probeConstLeaf(const Coord &xyz)
Definition: ValueAccessor.h:936
bool isVoxel(const Coord &xyz) const
Definition: ValueAccessor.h:1743
const ValueType & getValue(const Coord &xyz)
Definition: ValueAccessor.h:980
TreeType & tree() const
Return a reference to the tree associated with this accessor.
Definition: ValueAccessor.h:148
const LeafNodeT * probeConstLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1992
friend class Tree
Definition: ValueAccessor.h:1573
LeafNodeT * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1203
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:2306
void addLeaf(LeafNodeT *leaf)
Add the specified leaf to this tree, possibly creating a child branch in the process. If the leaf node already exists, replace it.
Definition: ValueAccessor.h:1182
friend class InternalNode
Definition: ValueAccessor.h:449
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:1144
const NodeT * probeConstNode(const Coord &xyz) const
Definition: ValueAccessor.h:2001
bool isValueOn(const Coord &xyz) const
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:2193
void eraseNode()
Definition: ValueAccessor.h:1473
bool isCached(const Coord &xyz) const
Definition: ValueAccessor.h:889
static Index numCacheLevels()
Return the number of cache levels employed by this ValueAccessor.
Definition: ValueAccessor.h:1283
ValueAccessor3(TreeType &tree)
Constructor from a tree.
Definition: ValueAccessor.h:2143
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: ValueAccessor.h:346
void getNode(OtherNodeType *&node)
Forward the request to another level of the cache.
Definition: ValueAccessor.h:639
friend class InternalNode
Definition: ValueAccessor.h:2037
const LeafNodeT * probeLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1558
typename TreeType::RootNodeType RootNodeT
Definition: ValueAccessor.h:2134
void getNode(const RootNodeType *&node) const
Definition: ValueAccessor.h:906
LeafNodeType * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:922
Definition: ValueAccessor.h:220
typename TreeType::ValueType ValueType
Definition: ValueAccessor.h:1052
NodeT * getNode()
Return the cached node of type NodeType. [Mainly for internal use].
Definition: ValueAccessor.h:1867
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:1090
void setValueOn(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:2283
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active without changing its value.
Definition: ValueAccessor.h:2386
void insert(const Coord &xyz, const NodeType *node)
Cache the given node at this level.
Definition: ValueAccessor.h:609
void eraseNode()
Definition: ValueAccessor.h:2408
friend class LeafNode
Definition: ValueAccessor.h:2572
const NodeT * probeNode(const Coord &xyz) const
Return a pointer to the node of the specified type that contains voxel (x, y, z), or nullptr if no su...
Definition: ValueAccessor.h:416
virtual void release()
Definition: ValueAccessor.h:171
static Index numCacheLevels()
Return the number of cache levels employed by this ValueAccessor.
Definition: ValueAccessor.h:2162
typename TreeType::LeafNodeType LeafNodeT
Definition: ValueAccessor.h:1269
ValueAccessor(TreeType &tree)
Definition: ValueAccessor.h:233
void erase(const RootNodeType *)
Definition: ValueAccessor.h:897
void clear() override
Remove all the cached nodes and invalidate the corresponding hash-keys.
Definition: ValueAccessor.h:1561
const LeafNodeT * probeConstLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:2551
friend class RootNode
Definition: ValueAccessor.h:2036
TreeType * mTree
Definition: ValueAccessor.h:173
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:1076
ValueAccessor1 & operator=(const ValueAccessor1 &other)
Asignment operator.
Definition: ValueAccessor.h:1286
ValueAccessor(const ValueAccessor &other)
Definition: ValueAccessor.h:519
void addLeaf(LeafNodeT *leaf)
Add the specified leaf to this tree, possibly creating a child branch in the process. If the leaf node already exists, replace it.
Definition: ValueAccessor.h:2416
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:2328
int getValueDepth(const Coord &xyz)
Definition: ValueAccessor.h:958
ValueAccessor1(TreeType &tree)
Constructor from a tree.
Definition: ValueAccessor.h:1275
ValueAccessor with no mutex and no node caching.
Definition: ValueAccessor.h:88
ValueAccessor(const ValueAccessor &other)
Definition: ValueAccessor.h:238
LeafNodeType * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:684
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive without changing its value.
Definition: ValueAccessor.h:1863
ValueAccessor(const ValueAccessor &other)
Definition: ValueAccessor.h:507
typename TreeType::LeafNodeType LeafNodeT
Definition: ValueAccessor.h:1645
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:136
friend class RootNode
Definition: ValueAccessor.h:1569
ValueAccessorRW(TreeType &tree)
Definition: ValueAccessor.h:551
typename boost::mpl::front< SubtreeT >::type NodeType
Definition: ValueAccessor.h:570
void getNode(NodeType *&node)
Definition: ValueAccessor.h:630
LeafNodeT * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1921
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:2176
void setValueOn(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:1378
void clear()
Erase the nodes at this and lower levels of the cache.
Definition: ValueAccessor.h:625
void addLeaf(LeafNodeType *leaf)
Definition: ValueAccessor.h:908
bool isValueOn(const Coord &xyz) const
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:1318
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:802
bool isValueOn(const Coord &xyz) const
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:264
void insertNode(const Coord &xyz, NodeT &node)
Definition: ValueAccessor.h:2402
typename TreeType::RootNodeType RootNodeT
Definition: ValueAccessor.h:1644
bool isCached(const Coord &xyz) const
Definition: ValueAccessor.h:603
TreeType TreeType
Definition: ValueAccessor.h:1051
LeafNodeT * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1963
bool isCached(const Coord &xyz) const
Definition: ValueAccessor.h:1300
NodeT * getNode()
Return the cached node of type NodeType. [Mainly for internal use].
Definition: ValueAccessor.h:2392
void addTile(Index level, const Coord &xyz, const ValueType &value, bool state)
Definition: ValueAccessor.h:915
const LeafNodeT * probeConstLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1554
bool probeValue(const Coord &xyz, ValueType &value) const
Return the active state of the voxel as well as its value.
Definition: ValueAccessor.h:2210
typename RootNodeType::LeafNodeType LeafNodeType
Definition: ValueAccessor.h:877
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:331
NodeT * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:1517
typename boost::mpl::at< InvTreeT, boost::mpl::int_< L2 > >::type NodeT2
Definition: ValueAccessor.h:2140
ValueAccessor2 & operator=(const ValueAccessor2 &other)
Asignment operator.
Definition: ValueAccessor.h:1663
const LeafNodeT * probeLeaf(const Coord &xyz) const
Return a pointer to the leaf node that contains voxel (x, y, z), or nullptr if no such node exists...
Definition: ValueAccessor.h:435
int getValueDepth(const Coord &xyz) const
Definition: ValueAccessor.h:2229
virtual ~ValueAccessorBase()
Definition: ValueAccessor.h:140
friend class LeafNode
Definition: ValueAccessor.h:2038
TreeType TreeType
Definition: ValueAccessor.h:2132
static Index numCacheLevels()
Return the number of cache levels employed by this ValueAccessor.
Definition: ValueAccessor.h:1660
void clear() override
Remove all the cached nodes and invalidate the corresponding hash-keys.
Definition: ValueAccessor.h:2026
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:1777
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:2432
void setValue(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:986
ValueAccessorBase(const ValueAccessorBase &other)
Definition: ValueAccessor.h:150
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:312
typename RootNodeT::NodeChainType InvTreeT
Definition: ValueAccessor.h:1647
Definition: Exceptions.h:40
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:297
friend class InternalNode
Definition: ValueAccessor.h:1570
void erase(const OtherNodeType *node)
Erase the node at another level of the cache.
Definition: ValueAccessor.h:622
Definition: ValueAccessor.h:95
friend class RootNode
Definition: ValueAccessor.h:448
ValueAccessor(const ValueAccessor &other)
Definition: ValueAccessor.h:495
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive without changing its value.
Definition: ValueAccessor.h:2388
bool isVoxel(const Coord &xyz)
Definition: ValueAccessor.h:765
ValueAccessorBase(TreeType &tree)
Definition: ValueAccessor.h:135
This base class for ValueAccessors manages registration of an accessor with a tree so that the tree c...
Definition: ValueAccessor.h:122
NodeT * getNode()
Return the cached node of type NodeType. [Mainly for internal use].
Definition: ValueAccessor.h:1457
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:1382
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:1684
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:322
bool probeValue(const Coord &xyz, ValueType &value)
Return the active state and value of the voxel at the given coordinates.
Definition: ValueAccessor.h:745
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: ValueAccessor.h:1169
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:1133
const NodeT * probeConstNode(const Coord &xyz) const
Definition: ValueAccessor.h:2514
bool isValueOn(const Coord &xyz) const
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:1698
typename TreeType::RootNodeType RootNodeT
Definition: ValueAccessor.h:1268
void addTile(Index level, const Coord &xyz, const ValueType &value, bool state)
Definition: ValueAccessor.h:662
TreeType * getTree() const
Return a pointer to the tree associated with this accessor.
Definition: ValueAccessor.h:146
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:2349
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: ValueAccessor.h:1171
Index32 Index
Definition: Types.h:61
ValueAccessorBase & operator=(const ValueAccessorBase &other)
Definition: ValueAccessor.h:155
void insertNode(const Coord &, NodeT &)
Definition: ValueAccessor.h:1178
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: ValueAccessor.h:344
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:1846
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:338
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:257
int getValueDepth(const Coord &xyz) const
Definition: ValueAccessor.h:1099
TreeType TreeType
Definition: ValueAccessor.h:1642
LeafNodeT * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1225
NodeType * getNode()
Return the cached node of type NodeType. [Mainly for internal use].
Definition: ValueAccessor.h:350
ValueAccessor0 & operator=(const ValueAccessor0 &other)
Definition: ValueAccessor.h:1064
void clear() override
Remove all the cached nodes and invalidate the corresponding hash-keys.
Definition: ValueAccessor.h:2558
std::numeric_limits< Int32 > CoordLimits
Definition: ValueAccessor.h:573
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:1191
void eraseNode()
Definition: ValueAccessor.h:371
TreeType TreeType
Definition: ValueAccessor.h:225
static bool isSafe()
Return true if this accessor is safe, i.e. registered by the tree from which it is constructed...
Definition: ValueAccessor.h:133
bool probeValue(const Coord &xyz, ValueType &value) const
Return the active state of the voxel as well as its value.
Definition: ValueAccessor.h:267
void addLeaf(LeafNodeT *leaf)
Add the specified leaf to this tree, possibly creating a child branch in the process. If the leaf node already exists, replace it.
Definition: ValueAccessor.h:1481
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:1411
const NodeT * probeConstNode(const Coord &xyz) const
Definition: ValueAccessor.h:1540
bool probeValue(const Coord &xyz, ValueType &value)
Definition: ValueAccessor.h:969
void modifyValue(const Coord &xyz, const ModifyOp &op)
Definition: ValueAccessor.h:1001
void eraseNode()
Definition: ValueAccessor.h:1883
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:816
bool isCached(const Coord &) const
Return true if nodes along the path to the given voxel have been cached.
Definition: ValueAccessor.h:1073
static Index numCacheLevels()
Return the number of cache levels employed by this accessor.
Definition: ValueAccessor.h:1062
bool isVoxel(const Coord &xyz) const
Definition: ValueAccessor.h:1107
typename RootNodeT::ValueType ValueType
Definition: ValueAccessor.h:228
friend class RootNode
Definition: ValueAccessor.h:2570
ValueAccessor0(TreeType &tree)
Definition: ValueAccessor.h:1057
void addLeaf(LeafNodeT *leaf)
Add the specified leaf to this tree, possibly creating a child branch in the process. If the leaf node already exists, replace it.
Definition: ValueAccessor.h:1891
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:1812
const LeafNodeT * probeLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1235
void insert(const Coord &, const OtherNodeType *)
Definition: ValueAccessor.h:895
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:1830
typename TreeType::ValueType ValueType
Definition: ValueAccessor.h:2133
void getNode(RootNodeType *&node)
Definition: ValueAccessor.h:901
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Definition: ValueAccessor.h:1009
bool probeValue(const Coord &xyz, ValueType &value) const
Return the active state of the voxel as well as its value.
Definition: ValueAccessor.h:1329
void getNode(const NodeType *&node)
Definition: ValueAccessor.h:629
LeafNodeT * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:2452
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:1439
CacheItem & copy(TreeCacheT &parent, const CacheItem &other)
Definition: ValueAccessor.h:882
typename RootNodeT::NodeChainType InvTreeT
Definition: ValueAccessor.h:1271
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:776
bool isValueOn(const Coord &xyz)
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:735
LeafNodeT * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:2509
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:1426
ValueAccessor(TreeType &tree)
Definition: ValueAccessor.h:506
LeafNodeType * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:674
bool probeValue(const Coord &xyz, ValueType &value) const
Return the active state of the voxel as well as its value.
Definition: ValueAccessor.h:1712
ValueAccessor1(const ValueAccessor1 &other)
Copy constructor.
Definition: ValueAccessor.h:1280
NodeType * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:943
void insertNode(const Coord &xyz, NodeType &node)
Definition: ValueAccessor.h:361
LeafNodeType * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:929
void setValueOff(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:1016
ValueAccessor0(const ValueAccessor0 &other)
Definition: ValueAccessor.h:1059
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:2287
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:1904
ValueAccessor(TreeType &tree)
Definition: ValueAccessor.h:529
typename tbb::null_mutex ::scoped_lock LockT
Definition: ValueAccessor.h:230
typename TreeType::LeafNodeType LeafNodeT
Definition: ValueAccessor.h:227
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:188
typename boost::mpl::at< InvTreeT, boost::mpl::int_< L0 > >::type NodeT0
Definition: ValueAccessor.h:1648
friend class Tree
Definition: ValueAccessor.h:1245
LeafNodeT * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1503
void setActiveState(const Coord &xyz, bool on)
Set the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:840
void setValueOn(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:1121
const NodeT * probeConstNode(const Coord &xyz) const
Return a pointer to the node of the specified type that contains voxel (x, y, z), or nullptr if no su...
Definition: ValueAccessor.h:410
void eraseNode()
Definition: ValueAccessor.h:1201
bool isVoxel(const Coord &xyz)
Definition: ValueAccessor.h:974
ValueAccessor(TreeType &tree)
Definition: ValueAccessor.h:494
typename boost::mpl::front< NodeVecT >::type RootNodeType
Definition: ValueAccessor.h:875
void setValueOn(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:796
typename TreeType::ValueType ValueType
Definition: ValueAccessor.h:1643
const LeafNodeType * probeConstLeaf(const Coord &xyz)
Definition: ValueAccessor.h:694
void setActiveState(const Coord &xyz, bool on)
Definition: ValueAccessor.h:1023
ValueAccessor3(const ValueAccessor3 &other)
Copy constructor.
Definition: ValueAccessor.h:2149
CacheItem(TreeCacheT &parent)
Definition: ValueAccessor.h:879
NodeT * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:1937
void getNode(const NodeType *&node) const
Return the cached node (if any) at this level.
Definition: ValueAccessor.h:628
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:404
const LeafNodeT * probeLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1996
int getValueDepth(const Coord &xyz)
Definition: ValueAccessor.h:754
friend class LeafNode
Definition: ValueAccessor.h:1571
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:828
bool isCached(const Coord &xyz) const
Definition: ValueAccessor.h:2169
typename TreeType::ValueType ValueType
Definition: ValueAccessor.h:1267
bool isVoxel(const Coord &xyz) const
Definition: ValueAccessor.h:2247
void clear() override
Remove all nodes from this cache, then reinsert the root node.
Definition: ValueAccessor.h:439
friend class LeafNode
Definition: ValueAccessor.h:450
void insert(const Coord &xyz, const OtherNodeType *node)
Forward the given node to another level of the cache.
Definition: ValueAccessor.h:616
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:2368
ValueAccessor2(const ValueAccessor2 &other)
Copy constructor.
Definition: ValueAccessor.h:1657
typename TreeType::LeafNodeType LeafNodeT
Definition: ValueAccessor.h:1054
void clear() override
Remove all nodes from this cache, then reinsert the root node.
Definition: ValueAccessor.h:1241
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:1125