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> 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);
287 void setValue(
const Coord& xyz,
const ValueType& value)
291 mCache.setValue(xyz, value);
300 mCache.setValueOnly(xyz, value);
307 mCache.setValueOff(xyz, value);
313 template<
typename ModifyOp>
317 mCache.modifyValue(xyz, op);
322 template<
typename ModifyOp>
326 mCache.modifyValueAndActiveState(xyz, op);
333 mCache.setActiveState(xyz, on);
341 template<
typename NodeType>
345 NodeType* node =
nullptr;
346 mCache.getNode(node);
352 template<
typename NodeType>
356 mCache.insert(xyz, &node);
362 template<
typename NodeType>
363 void eraseNode() {
LockT lock(mMutex); NodeType* node =
nullptr; mCache.erase(node); }
370 mCache.addLeaf(leaf);
378 mCache.addTile(level, xyz, value, state);
389 return mCache.touchLeaf(xyz);
393 template<
typename NodeT>
399 return mCache.template probeNode<NodeT>(xyz);
401 template<
typename NodeT>
405 return mCache.template probeConstNode<NodeT>(xyz);
407 template<
typename NodeT>
410 return this->
template probeConstNode<NodeT>(xyz);
415 LeafNodeT* probeLeaf(
const Coord& xyz)
420 return mCache.probeLeaf(xyz);
425 return mCache.probeConstLeaf(xyz);
435 if (this->mTree) mCache.insert(
Coord(), &(this->mTree->root()));
444 template<
typename>
friend class Tree;
448 void release()
override 451 this->BaseT::release();
459 template<
typename NodeType>
460 void insert(
const Coord& xyz, NodeType* node) { mCache.insert(xyz, node); }
463 using InvTreeT =
typename RootNodeT::NodeChainType;
465 using BeginT =
typename boost::mpl::begin<InvTreeT>::type;
466 using FirstT =
typename boost::mpl::advance<BeginT, boost::mpl::int_<CacheLevels>>::type;
467 using LastT =
typename boost::mpl::find<InvTreeT, RootNodeT>::type;
468 using SubtreeT =
typename boost::mpl::erase<InvTreeT, FirstT, LastT>::type;
469 using CacheItemT = CacheItem<ValueAccessor, SubtreeT, boost::mpl::size<SubtreeT>::value==1>;
472 mutable CacheItemT mCache;
473 mutable MutexType mMutex;
481 template<
typename TreeType,
bool IsSafe>
493 template<
typename TreeType,
bool IsSafe>
505 template<
typename TreeType,
bool IsSafe>
517 template<
typename TreeType,
bool IsSafe>
539 template<
typename TreeType,
bool IsSafe = true>
558 template<
typename TreeCacheT,
typename NodeVecT,
bool AtRoot>
562 using NodeType =
typename boost::mpl::front<NodeVecT>::type;
581 mNext(parent, other.mNext)
590 mNext.copy(parent, other.mNext);
597 return (this->isHashed(xyz) || mNext.isCached(xyz));
603 mHash = (node !=
nullptr) ? xyz & ~(NodeType::DIM-1) :
Coord::max();
607 template<
typename OtherNodeType>
608 void insert(
const Coord& xyz,
const OtherNodeType* node) { mNext.insert(xyz, node); }
613 template<
typename OtherNodeType>
614 void erase(
const OtherNodeType* node) { mNext.erase(node); }
626 static_assert(!TreeCacheT::IsConstTree,
"can't get a non-const node from a const tree");
627 node = const_cast<NodeType*>(mNode);
630 template<
typename OtherNodeType>
631 void getNode(OtherNodeType*& node) { mNext.getNode(node); }
636 if (this->isHashed(xyz)) {
638 return mNode->getValueAndCache(xyz, *mParent);
640 return mNext.getValue(xyz);
645 static_assert(!TreeCacheT::IsConstTree,
"can't add a node to a const tree");
646 if (NodeType::LEVEL == 0)
return;
647 if (this->isHashed(leaf->origin())) {
649 return const_cast<NodeType*>(mNode)->addLeafAndCache(leaf, *mParent);
656 static_assert(!TreeCacheT::IsConstTree,
"can't add a tile to a const tree");
657 if (NodeType::LEVEL < level)
return;
658 if (this->isHashed(xyz)) {
660 return const_cast<NodeType*>(mNode)->addTileAndCache(
661 level, xyz, value, state, *mParent);
663 mNext.addTile(level, xyz, value, state);
668 static_assert(!TreeCacheT::IsConstTree,
"can't get a non-const node from a const tree");
669 if (this->isHashed(xyz)) {
671 return const_cast<NodeType*>(mNode)->touchLeafAndCache(xyz, *mParent);
673 return mNext.touchLeaf(xyz);
678 static_assert(!TreeCacheT::IsConstTree,
"can't get a non-const node from a const tree");
679 if (this->isHashed(xyz)) {
681 return const_cast<NodeType*>(mNode)->probeLeafAndCache(xyz, *mParent);
683 return mNext.probeLeaf(xyz);
688 if (this->isHashed(xyz)) {
690 return mNode->probeConstLeafAndCache(xyz, *mParent);
692 return mNext.probeConstLeaf(xyz);
695 template<
typename NodeT>
698 static_assert(!TreeCacheT::IsConstTree,
"can't get a non-const node from a const tree");
700 if (this->isHashed(xyz)) {
701 if ((std::is_same<NodeT, NodeType>::value)) {
703 return reinterpret_cast<NodeT*>(const_cast<NodeType*>(mNode));
705 return const_cast<NodeType*>(mNode)->template probeNodeAndCache<NodeT>(xyz, *mParent);
707 return mNext.template probeNode<NodeT>(xyz);
711 template<
typename NodeT>
715 if (this->isHashed(xyz)) {
716 if ((std::is_same<NodeT, NodeType>::value)) {
718 return reinterpret_cast<const NodeT*>(mNode);
720 return mNode->template probeConstNodeAndCache<NodeT>(xyz, *mParent);
722 return mNext.template probeConstNode<NodeT>(xyz);
729 if (this->isHashed(xyz)) {
731 return mNode->isValueOnAndCache(xyz, *mParent);
733 return mNext.isValueOn(xyz);
739 if (this->isHashed(xyz)) {
741 return mNode->probeValueAndCache(xyz, value, *mParent);
743 return mNext.probeValue(xyz, value);
748 if (this->isHashed(xyz)) {
750 return static_cast<int>(TreeCacheT::RootNodeT::LEVEL) -
751 static_cast<int>(mNode->getValueLevelAndCache(xyz, *mParent));
753 return mNext.getValueDepth(xyz);
759 if (this->isHashed(xyz)) {
761 return mNode->getValueLevelAndCache(xyz, *mParent)==0;
763 return mNext.isVoxel(xyz);
770 if (this->isHashed(xyz)) {
772 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
773 const_cast<NodeType*>(mNode)->setValueAndCache(xyz, value, *mParent);
775 mNext.setValue(xyz, value);
780 if (this->isHashed(xyz)) {
782 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
783 const_cast<NodeType*>(mNode)->setValueOnlyAndCache(xyz, value, *mParent);
785 mNext.setValueOnly(xyz, value);
793 template<
typename ModifyOp>
796 if (this->isHashed(xyz)) {
798 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
799 const_cast<NodeType*>(mNode)->modifyValueAndCache(xyz, op, *mParent);
801 mNext.modifyValue(xyz, op);
807 template<
typename ModifyOp>
810 if (this->isHashed(xyz)) {
812 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
813 const_cast<NodeType*>(mNode)->modifyValueAndActiveStateAndCache(xyz, op, *mParent);
815 mNext.modifyValueAndActiveState(xyz, op);
822 if (this->isHashed(xyz)) {
824 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
825 const_cast<NodeType*>(mNode)->setValueOffAndCache(xyz, value, *mParent);
827 mNext.setValueOff(xyz, value);
834 if (this->isHashed(xyz)) {
836 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
837 const_cast<NodeType*>(mNode)->setActiveStateAndCache(xyz, on, *mParent);
839 mNext.setActiveState(xyz, on);
847 bool isHashed(
const Coord& xyz)
const 850 && (xyz[1] & ~
Coord::ValueType(NodeType::DIM-1)) == mHash[1]
856 const NodeType* mNode;
857 using RestT =
typename boost::mpl::pop_front<NodeVecT>::type;
858 CacheItem<TreeCacheT, RestT, boost::mpl::size<RestT>::value == 1> mNext;
863 template<
typename TreeCacheT,
typename NodeVecT>
871 CacheItem(TreeCacheT& parent): mParent(&parent), mRoot(nullptr) {}
886 template<
typename OtherNodeType>
895 static_assert(!TreeCacheT::IsConstTree,
"can't get a non-const node from a const tree");
896 node = const_cast<RootNodeType*>(mRoot);
903 static_assert(!TreeCacheT::IsConstTree,
"can't add a node to a const tree");
904 const_cast<RootNodeType*>(mRoot)->addLeafAndCache(leaf, *mParent);
910 static_assert(!TreeCacheT::IsConstTree,
"can't add a tile to a const tree");
911 const_cast<RootNodeType*>(mRoot)->addTileAndCache(level, xyz, value, state, *mParent);
917 static_assert(!TreeCacheT::IsConstTree,
"can't get a non-const node from a const tree");
918 return const_cast<RootNodeType*>(mRoot)->touchLeafAndCache(xyz, *mParent);
924 static_assert(!TreeCacheT::IsConstTree,
"can't get a non-const node from a const tree");
925 return const_cast<RootNodeType*>(mRoot)->probeLeafAndCache(xyz, *mParent);
931 return mRoot->probeConstLeafAndCache(xyz, *mParent);
934 template<
typename NodeType>
938 static_assert(!TreeCacheT::IsConstTree,
"can't get a non-const node from a const tree");
939 return const_cast<RootNodeType*>(mRoot)->
940 template probeNodeAndCache<NodeType>(xyz, *mParent);
943 template<
typename NodeType>
947 return mRoot->template probeConstNodeAndCache<NodeType>(xyz, *mParent);
953 return mRoot->getValueDepthAndCache(xyz, *mParent);
958 return mRoot->isValueOnAndCache(xyz, *mParent);
964 return mRoot->probeValueAndCache(xyz, value, *mParent);
969 return mRoot->getValueDepthAndCache(xyz, *mParent) ==
970 static_cast<int>(RootNodeType::LEVEL);
975 return mRoot->getValueAndCache(xyz, *mParent);
981 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
982 const_cast<RootNodeType*>(mRoot)->setValueAndCache(xyz, value, *mParent);
987 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
988 const_cast<RootNodeType*>(mRoot)->setValueOnlyAndCache(xyz, value, *mParent);
992 template<
typename ModifyOp>
996 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
997 const_cast<RootNodeType*>(mRoot)->modifyValueAndCache(xyz, op, *mParent);
1000 template<
typename ModifyOp>
1004 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
1005 const_cast<RootNodeType*>(mRoot)->modifyValueAndActiveStateAndCache(xyz, op, *mParent);
1011 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
1012 const_cast<RootNodeType*>(mRoot)->setValueOffAndCache(xyz, value, *mParent);
1018 static_assert(!TreeCacheT::IsConstTree,
"can't modify a const tree's values");
1019 const_cast<RootNodeType*>(mRoot)->setActiveStateAndCache(xyz, on, *mParent);
1026 bool isHashed(
const Coord&)
const {
return false; }
1028 TreeCacheT* mParent;
1029 const RootNodeType* mRoot;
1039 template<
typename _TreeType,
bool IsSafe>
1040 class ValueAccessor0:
public ValueAccessorBase<_TreeType, IsSafe>
1058 if (&other !=
this) this->BaseT::operator=(other);
1070 assert(BaseT::mTree);
1071 return BaseT::mTree->getValue(xyz);
1077 assert(BaseT::mTree);
1078 return BaseT::mTree->isValueOn(xyz);
1084 assert(BaseT::mTree);
1085 return BaseT::mTree->probeValue(xyz, value);
1093 assert(BaseT::mTree);
1094 return BaseT::mTree->getValueDepth(xyz);
1101 assert(BaseT::mTree);
1102 return BaseT::mTree->getValueDepth(xyz) == static_cast<int>(RootNodeT::LEVEL);
1106 void setValue(
const Coord& xyz,
const ValueType& value)
1109 assert(BaseT::mTree);
1110 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1111 BaseT::mTree->setValue(xyz, value);
1119 assert(BaseT::mTree);
1120 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1121 BaseT::mTree->setValueOnly(xyz, value);
1127 assert(BaseT::mTree);
1128 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1129 BaseT::mTree->root().setValueOff(xyz, value);
1135 template<
typename ModifyOp>
1138 assert(BaseT::mTree);
1139 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1140 BaseT::mTree->modifyValue(xyz, op);
1145 template<
typename ModifyOp>
1148 assert(BaseT::mTree);
1149 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1150 BaseT::mTree->modifyValueAndActiveState(xyz, op);
1156 assert(BaseT::mTree);
1157 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1158 BaseT::mTree->setActiveState(xyz, on);
1166 template<
typename NodeT> NodeT*
getNode() {
return nullptr; }
1176 assert(BaseT::mTree);
1177 static_assert(!BaseT::IsConstTree,
"can't add a node to a const tree");
1178 BaseT::mTree->root().addLeaf(leaf);
1185 assert(BaseT::mTree);
1186 static_assert(!BaseT::IsConstTree,
"can't add a tile to a const tree");
1187 BaseT::mTree->root().addTile(level, xyz, value, state);
1197 assert(BaseT::mTree);
1198 static_assert(!BaseT::IsConstTree,
"can't get a non-const node from a const tree");
1199 return BaseT::mTree->touchLeaf(xyz);
1202 template<
typename NodeT>
1205 assert(BaseT::mTree);
1206 static_assert(!BaseT::IsConstTree,
"can't get a non-const node from a const tree");
1207 return BaseT::mTree->template probeNode<NodeT>(xyz);
1210 template<
typename NodeT>
1213 assert(BaseT::mTree);
1214 return BaseT::mTree->template probeConstNode<NodeT>(xyz);
1219 return this->
template probeNode<LeafNodeT>(xyz);
1224 return this->
template probeConstNode<LeafNodeT>(xyz);
1229 return this->probeConstLeaf(xyz);
1237 template<
typename>
friend class Tree;
1241 void release()
override { this->BaseT::release(); }
1252 template<
typename _TreeType,
bool IsSafe, Index L0>
1253 class ValueAccessor1 :
public ValueAccessorBase<_TreeType, IsSafe>
1256 static_assert(_TreeType::DEPTH >= 2,
"cache size exceeds tree depth");
1257 static_assert(L0 < _TreeType::RootNodeType::LEVEL,
"invalid cache level");
1264 using NodeT0 =
typename boost::mpl::at<InvTreeT, boost::mpl::int_<L0> >::type;
1280 if (&other !=
this) {
1281 this->BaseT::operator=(other);
1294 assert(BaseT::mTree);
1295 return this->isHashed(xyz);
1301 assert(BaseT::mTree);
1302 if (this->isHashed(xyz)) {
1304 return mNode0->getValueAndCache(xyz, this->
self());
1306 return BaseT::mTree->root().getValueAndCache(xyz, this->
self());
1312 assert(BaseT::mTree);
1313 if (this->isHashed(xyz)) {
1315 return mNode0->isValueOnAndCache(xyz, this->
self());
1317 return BaseT::mTree->root().isValueOnAndCache(xyz, this->
self());
1323 assert(BaseT::mTree);
1324 if (this->isHashed(xyz)) {
1326 return mNode0->probeValueAndCache(xyz, value, this->
self());
1328 return BaseT::mTree->root().probeValueAndCache(xyz, value, this->
self());
1336 assert(BaseT::mTree);
1337 if (this->isHashed(xyz)) {
1339 return RootNodeT::LEVEL - mNode0->getValueLevelAndCache(xyz, this->
self());
1341 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->
self());
1348 assert(BaseT::mTree);
1349 if (this->isHashed(xyz)) {
1351 return mNode0->getValueLevelAndCache(xyz, this->
self()) == 0;
1353 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->
self()) ==
1354 static_cast<int>(RootNodeT::LEVEL);
1358 void setValue(
const Coord& xyz,
const ValueType& value)
1361 assert(BaseT::mTree);
1362 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1363 if (this->isHashed(xyz)) {
1365 const_cast<NodeT0*>(mNode0)->setValueAndCache(xyz, value, *
this);
1367 BaseT::mTree->root().setValueAndCache(xyz, value, *
this);
1376 assert(BaseT::mTree);
1377 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1378 if (this->isHashed(xyz)) {
1380 const_cast<NodeT0*>(mNode0)->setValueOnlyAndCache(xyz, value, *
this);
1382 BaseT::mTree->root().setValueOnlyAndCache(xyz, value, *
this);
1389 assert(BaseT::mTree);
1390 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1391 if (this->isHashed(xyz)) {
1393 const_cast<NodeT0*>(mNode0)->setValueOffAndCache(xyz, value, *
this);
1395 BaseT::mTree->root().setValueOffAndCache(xyz, value, *
this);
1402 template<
typename ModifyOp>
1405 assert(BaseT::mTree);
1406 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1407 if (this->isHashed(xyz)) {
1409 const_cast<NodeT0*>(mNode0)->modifyValueAndCache(xyz, op, *
this);
1411 BaseT::mTree->root().modifyValueAndCache(xyz, op, *
this);
1417 template<
typename ModifyOp>
1420 assert(BaseT::mTree);
1421 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1422 if (this->isHashed(xyz)) {
1424 const_cast<NodeT0*>(mNode0)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
1426 BaseT::mTree->root().modifyValueAndActiveStateAndCache(xyz, op, *
this);
1433 assert(BaseT::mTree);
1434 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1435 if (this->isHashed(xyz)) {
1437 const_cast<NodeT0*>(mNode0)->setActiveStateAndCache(xyz, on, *
this);
1439 BaseT::mTree->root().setActiveStateAndCache(xyz, on, *
this);
1448 template<
typename NodeT>
1451 const NodeT* node =
nullptr;
1452 this->getNode(node);
1453 return const_cast<NodeT*>(node);
1458 template<
typename NodeT>
1464 template<
typename NodeT>
1467 const NodeT* node =
nullptr;
1468 this->eraseNode(node);
1475 assert(BaseT::mTree);
1476 static_assert(!BaseT::IsConstTree,
"can't add a node to a const tree");
1477 BaseT::mTree->root().addLeaf(leaf);
1484 assert(BaseT::mTree);
1485 static_assert(!BaseT::IsConstTree,
"can't add a tile to a const tree");
1486 BaseT::mTree->root().addTile(level, xyz, value, state);
1497 assert(BaseT::mTree);
1498 static_assert(!BaseT::IsConstTree,
"can't get a non-const node from a const tree");
1499 if (this->isHashed(xyz)) {
1501 return const_cast<NodeT0*>(mNode0)->touchLeafAndCache(xyz, *
this);
1503 return BaseT::mTree->root().touchLeafAndCache(xyz, *
this);
1508 template<
typename NodeT>
1511 assert(BaseT::mTree);
1512 static_assert(!BaseT::IsConstTree,
"can't get a non-const node from a const tree");
1514 if ((std::is_same<NodeT, NodeT0>::value)) {
1515 if (this->isHashed(xyz)) {
1517 return reinterpret_cast<NodeT*>(const_cast<NodeT0*>(mNode0));
1519 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
1526 return this->
template probeNode<LeafNodeT>(xyz);
1531 template<
typename NodeT>
1534 assert(BaseT::mTree);
1536 if ((std::is_same<NodeT, NodeT0>::value)) {
1537 if (this->isHashed(xyz)) {
1539 return reinterpret_cast<const NodeT*>(mNode0);
1541 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
1548 return this->
template probeConstNode<LeafNodeT>(xyz);
1565 template<
typename>
friend class Tree;
1568 inline ValueAccessor1&
self()
const {
return const_cast<ValueAccessor1&>(*
this); }
1570 void getNode(
const NodeT0*& node) { node = mNode0; }
1571 void getNode(
const RootNodeT*& node)
1573 node = (BaseT::mTree ? &BaseT::mTree->root() :
nullptr);
1575 template<
typename OtherNodeType>
void getNode(
const OtherNodeType*& node) { node =
nullptr; }
1576 void eraseNode(
const NodeT0*) { mKey0 =
Coord::max(); mNode0 =
nullptr; }
1577 template<
typename OtherNodeType>
void eraseNode(
const OtherNodeType*) {}
1580 inline void copy(
const ValueAccessor1& other)
1582 mKey0 = other.mKey0;
1583 mNode0 = other.mNode0;
1588 void release()
override 1590 this->BaseT::release();
1597 inline void insert(
const Coord& xyz,
const NodeT0* node)
1600 mKey0 = xyz & ~(NodeT0::DIM-1);
1606 template<
typename OtherNodeType>
inline void insert(
const Coord&,
const OtherNodeType*) {}
1608 inline bool isHashed(
const Coord& xyz)
const 1611 && (xyz[1] & ~Coord::ValueType(NodeT0::DIM-1)) == mKey0[1]
1614 mutable Coord mKey0;
1615 mutable const NodeT0* mNode0;
1626 template<
typename _TreeType,
bool IsSafe, Index L0, Index L1>
1627 class ValueAccessor2 :
public ValueAccessorBase<_TreeType, IsSafe>
1630 static_assert(_TreeType::DEPTH >= 3,
"cache size exceeds tree depth");
1631 static_assert(L0 < L1,
"invalid cache level");
1632 static_assert(L1 < _TreeType::RootNodeType::LEVEL,
"invalid cache level");
1640 using NodeT0 =
typename boost::mpl::at<InvTreeT, boost::mpl::int_<L0>>::type;
1641 using NodeT1 =
typename boost::mpl::at<InvTreeT, boost::mpl::int_<L1>>::type;
1645 mKey0(
Coord::
max()), mNode0(nullptr),
1646 mKey1(
Coord::
max()), mNode1(nullptr) {}
1657 if (&other !=
this) {
1658 this->BaseT::operator=(other);
1671 assert(BaseT::mTree);
1672 return this->isHashed1(xyz) || this->isHashed0(xyz);
1678 assert(BaseT::mTree);
1679 if (this->isHashed0(xyz)) {
1681 return mNode0->getValueAndCache(xyz, this->
self());
1682 }
else if (this->isHashed1(xyz)) {
1684 return mNode1->getValueAndCache(xyz, this->
self());
1686 return BaseT::mTree->root().getValueAndCache(xyz, this->
self());
1692 assert(BaseT::mTree);
1693 if (this->isHashed0(xyz)) {
1695 return mNode0->isValueOnAndCache(xyz, this->
self());
1696 }
else if (this->isHashed1(xyz)) {
1698 return mNode1->isValueOnAndCache(xyz, this->
self());
1700 return BaseT::mTree->root().isValueOnAndCache(xyz, this->
self());
1706 assert(BaseT::mTree);
1707 if (this->isHashed0(xyz)) {
1709 return mNode0->probeValueAndCache(xyz, value, this->
self());
1710 }
else if (this->isHashed1(xyz)) {
1712 return mNode1->probeValueAndCache(xyz, value, this->
self());
1714 return BaseT::mTree->root().probeValueAndCache(xyz, value, this->
self());
1722 assert(BaseT::mTree);
1723 if (this->isHashed0(xyz)) {
1725 return RootNodeT::LEVEL - mNode0->getValueLevelAndCache(xyz, this->
self());
1726 }
else if (this->isHashed1(xyz)) {
1728 return RootNodeT::LEVEL - mNode1->getValueLevelAndCache(xyz, this->
self());
1730 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->
self());
1737 assert(BaseT::mTree);
1738 if (this->isHashed0(xyz)) {
1740 return mNode0->getValueLevelAndCache(xyz, this->
self())==0;
1741 }
else if (this->isHashed1(xyz)) {
1743 return mNode1->getValueLevelAndCache(xyz, this->
self())==0;
1745 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->
self()) ==
1746 static_cast<int>(RootNodeT::LEVEL);
1750 void setValue(
const Coord& xyz,
const ValueType& value)
1753 assert(BaseT::mTree);
1754 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1755 if (this->isHashed0(xyz)) {
1757 const_cast<NodeT0*>(mNode0)->setValueAndCache(xyz, value, *
this);
1758 }
else if (this->isHashed1(xyz)) {
1760 const_cast<NodeT1*>(mNode1)->setValueAndCache(xyz, value, *
this);
1762 BaseT::mTree->root().setValueAndCache(xyz, value, *
this);
1771 assert(BaseT::mTree);
1772 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1773 if (this->isHashed0(xyz)) {
1775 const_cast<NodeT0*>(mNode0)->setValueOnlyAndCache(xyz, value, *
this);
1776 }
else if (this->isHashed1(xyz)) {
1778 const_cast<NodeT1*>(mNode1)->setValueOnlyAndCache(xyz, value, *
this);
1780 BaseT::mTree->root().setValueOnlyAndCache(xyz, value, *
this);
1787 assert(BaseT::mTree);
1788 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1789 if (this->isHashed0(xyz)) {
1791 const_cast<NodeT0*>(mNode0)->setValueOffAndCache(xyz, value, *
this);
1792 }
else if (this->isHashed1(xyz)) {
1794 const_cast<NodeT1*>(mNode1)->setValueOffAndCache(xyz, value, *
this);
1796 BaseT::mTree->root().setValueOffAndCache(xyz, value, *
this);
1803 template<
typename ModifyOp>
1806 assert(BaseT::mTree);
1807 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1808 if (this->isHashed0(xyz)) {
1810 const_cast<NodeT0*>(mNode0)->modifyValueAndCache(xyz, op, *
this);
1811 }
else if (this->isHashed1(xyz)) {
1813 const_cast<NodeT1*>(mNode1)->modifyValueAndCache(xyz, op, *
this);
1815 BaseT::mTree->root().modifyValueAndCache(xyz, op, *
this);
1821 template<
typename ModifyOp>
1824 assert(BaseT::mTree);
1825 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1826 if (this->isHashed0(xyz)) {
1828 const_cast<NodeT0*>(mNode0)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
1829 }
else if (this->isHashed1(xyz)) {
1831 const_cast<NodeT1*>(mNode1)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
1833 BaseT::mTree->root().modifyValueAndActiveStateAndCache(xyz, op, *
this);
1840 assert(BaseT::mTree);
1841 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
1842 if (this->isHashed0(xyz)) {
1844 const_cast<NodeT0*>(mNode0)->setActiveStateAndCache(xyz, on, *
this);
1845 }
else if (this->isHashed1(xyz)) {
1847 const_cast<NodeT1*>(mNode1)->setActiveStateAndCache(xyz, on, *
this);
1849 BaseT::mTree->root().setActiveStateAndCache(xyz, on, *
this);
1858 template<
typename NodeT>
1861 const NodeT* node =
nullptr;
1862 this->getNode(node);
1863 return const_cast<NodeT*>(node);
1868 template<
typename NodeT>
1874 template<
typename NodeT>
1877 const NodeT* node =
nullptr;
1878 this->eraseNode(node);
1885 assert(BaseT::mTree);
1886 static_assert(!BaseT::IsConstTree,
"can't add a node to a const tree");
1887 if (this->isHashed1(leaf->origin())) {
1889 return const_cast<NodeT1*>(mNode1)->addLeafAndCache(leaf, *
this);
1891 BaseT::mTree->root().addLeafAndCache(leaf, *
this);
1898 assert(BaseT::mTree);
1899 static_assert(!BaseT::IsConstTree,
"can't add a tile to a const tree");
1900 if (this->isHashed1(xyz)) {
1902 return const_cast<NodeT1*>(mNode1)->addTileAndCache(level, xyz, value, state, *
this);
1904 BaseT::mTree->root().addTileAndCache(level, xyz, value, state, *
this);
1915 assert(BaseT::mTree);
1916 static_assert(!BaseT::IsConstTree,
"can't get a non-const node from a const tree");
1917 if (this->isHashed0(xyz)) {
1919 return const_cast<NodeT0*>(mNode0)->touchLeafAndCache(xyz, *
this);
1920 }
else if (this->isHashed1(xyz)) {
1922 return const_cast<NodeT1*>(mNode1)->touchLeafAndCache(xyz, *
this);
1924 return BaseT::mTree->root().touchLeafAndCache(xyz, *
this);
1928 template<
typename NodeT>
1931 assert(BaseT::mTree);
1932 static_assert(!BaseT::IsConstTree,
"can't get a non-const node from a const tree");
1934 if ((std::is_same<NodeT, NodeT0>::value)) {
1935 if (this->isHashed0(xyz)) {
1937 return reinterpret_cast<NodeT*>(const_cast<NodeT0*>(mNode0));
1938 }
else if (this->isHashed1(xyz)) {
1940 return const_cast<NodeT1*>(mNode1)->template probeNodeAndCache<NodeT>(xyz, *
this);
1942 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
1943 }
else if ((std::is_same<NodeT, NodeT1>::value)) {
1944 if (this->isHashed1(xyz)) {
1946 return reinterpret_cast<NodeT*>(const_cast<NodeT1*>(mNode1));
1948 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
1959 template<
typename NodeT>
1963 if ((std::is_same<NodeT, NodeT0>::value)) {
1964 if (this->isHashed0(xyz)) {
1966 return reinterpret_cast<const NodeT*>(mNode0);
1967 }
else if (this->isHashed1(xyz)) {
1969 return mNode1->template probeConstNodeAndCache<NodeT>(xyz, this->
self());
1971 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
1972 }
else if ((std::is_same<NodeT, NodeT1>::value)) {
1973 if (this->isHashed1(xyz)) {
1975 return reinterpret_cast<const NodeT*>(mNode1);
1977 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
1986 return this->
template probeConstNode<LeafNodeT>(xyz);
1992 template<
typename NodeT>
1995 assert(BaseT::mTree);
1997 if ((std::is_same<NodeT, NodeT0>::value)) {
1998 if (this->isHashed0(xyz)) {
2000 return reinterpret_cast<const NodeT*>(mNode0);
2001 }
else if (this->isHashed1(xyz)) {
2003 return mNode1->template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2005 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2006 }
else if ((std::is_same<NodeT, NodeT1>::value)) {
2007 if (this->isHashed1(xyz)) {
2009 return reinterpret_cast<const NodeT*>(mNode1);
2011 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2032 template<
typename>
friend class Tree;
2035 inline ValueAccessor2&
self()
const {
return const_cast<ValueAccessor2&>(*
this); }
2037 void getNode(
const NodeT0*& node) { node = mNode0; }
2038 void getNode(
const NodeT1*& node) { node = mNode1; }
2039 void getNode(
const RootNodeT*& node)
2041 node = (BaseT::mTree ? &BaseT::mTree->root() :
nullptr);
2043 template<
typename OtherNodeType>
void getNode(
const OtherNodeType*& node) { node =
nullptr; }
2045 void eraseNode(
const NodeT0*) { mKey0 =
Coord::max(); mNode0 =
nullptr; }
2046 void eraseNode(
const NodeT1*) { mKey1 =
Coord::max(); mNode1 =
nullptr; }
2047 template<
typename OtherNodeType>
void eraseNode(
const OtherNodeType*) {}
2050 inline void copy(
const ValueAccessor2& other)
2052 mKey0 = other.mKey0;
2053 mNode0 = other.mNode0;
2054 mKey1 = other.mKey1;
2055 mNode1 = other.mNode1;
2060 void release()
override 2062 this->BaseT::release();
2070 inline void insert(
const Coord& xyz,
const NodeT0* node)
2073 mKey0 = xyz & ~(NodeT0::DIM-1);
2076 inline void insert(
const Coord& xyz,
const NodeT1* node)
2079 mKey1 = xyz & ~(NodeT1::DIM-1);
2084 template<
typename NodeT>
inline void insert(
const Coord&,
const NodeT*) {}
2086 inline bool isHashed0(
const Coord& xyz)
const 2089 && (xyz[1] & ~Coord::ValueType(NodeT0::DIM-1)) == mKey0[1]
2092 inline bool isHashed1(
const Coord& xyz)
const 2095 && (xyz[1] & ~Coord::ValueType(NodeT1::DIM-1)) == mKey1[1]
2098 mutable Coord mKey0;
2099 mutable const NodeT0* mNode0;
2100 mutable Coord mKey1;
2101 mutable const NodeT1* mNode1;
2115 template<
typename _TreeType,
bool IsSafe, Index L0, Index L1, Index L2>
2116 class ValueAccessor3 :
public ValueAccessorBase<_TreeType, IsSafe>
2119 static_assert(_TreeType::DEPTH >= 4,
"cache size exceeds tree depth");
2120 static_assert(L0 < L1,
"invalid cache level");
2121 static_assert(L1 < L2,
"invalid cache level");
2122 static_assert(L2 < _TreeType::RootNodeType::LEVEL,
"invalid cache level");
2130 using NodeT0 =
typename boost::mpl::at<InvTreeT, boost::mpl::int_<L0> >::type;
2131 using NodeT1 =
typename boost::mpl::at<InvTreeT, boost::mpl::int_<L1> >::type;
2132 using NodeT2 =
typename boost::mpl::at<InvTreeT, boost::mpl::int_<L2> >::type;
2136 mKey0(
Coord::
max()), mNode0(nullptr),
2137 mKey1(
Coord::
max()), mNode1(nullptr),
2138 mKey2(
Coord::
max()), mNode2(nullptr) {}
2146 if (&other !=
this) {
2147 this->BaseT::operator=(other);
2163 assert(BaseT::mTree);
2164 return this->isHashed2(xyz) || this->isHashed1(xyz) || this->isHashed0(xyz);
2170 assert(BaseT::mTree);
2171 if (this->isHashed0(xyz)) {
2173 return mNode0->getValueAndCache(xyz, this->
self());
2174 }
else if (this->isHashed1(xyz)) {
2176 return mNode1->getValueAndCache(xyz, this->
self());
2177 }
else if (this->isHashed2(xyz)) {
2179 return mNode2->getValueAndCache(xyz, this->
self());
2181 return BaseT::mTree->root().getValueAndCache(xyz, this->
self());
2187 assert(BaseT::mTree);
2188 if (this->isHashed0(xyz)) {
2190 return mNode0->isValueOnAndCache(xyz, this->
self());
2191 }
else if (this->isHashed1(xyz)) {
2193 return mNode1->isValueOnAndCache(xyz, this->
self());
2194 }
else if (this->isHashed2(xyz)) {
2196 return mNode2->isValueOnAndCache(xyz, this->
self());
2198 return BaseT::mTree->root().isValueOnAndCache(xyz, this->
self());
2204 assert(BaseT::mTree);
2205 if (this->isHashed0(xyz)) {
2207 return mNode0->probeValueAndCache(xyz, value, this->
self());
2208 }
else if (this->isHashed1(xyz)) {
2210 return mNode1->probeValueAndCache(xyz, value, this->
self());
2211 }
else if (this->isHashed2(xyz)) {
2213 return mNode2->probeValueAndCache(xyz, value, this->
self());
2215 return BaseT::mTree->root().probeValueAndCache(xyz, value, this->
self());
2223 assert(BaseT::mTree);
2224 if (this->isHashed0(xyz)) {
2226 return RootNodeT::LEVEL - mNode0->getValueLevelAndCache(xyz, this->
self());
2227 }
else if (this->isHashed1(xyz)) {
2229 return RootNodeT::LEVEL - mNode1->getValueLevelAndCache(xyz, this->
self());
2230 }
else if (this->isHashed2(xyz)) {
2232 return RootNodeT::LEVEL - mNode2->getValueLevelAndCache(xyz, this->
self());
2234 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->
self());
2241 assert(BaseT::mTree);
2242 if (this->isHashed0(xyz)) {
2244 return mNode0->getValueLevelAndCache(xyz, this->
self())==0;
2245 }
else if (this->isHashed1(xyz)) {
2247 return mNode1->getValueLevelAndCache(xyz, this->
self())==0;
2248 }
else if (this->isHashed2(xyz)) {
2250 return mNode2->getValueLevelAndCache(xyz, this->
self())==0;
2252 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->
self()) ==
2253 static_cast<int>(RootNodeT::LEVEL);
2257 void setValue(
const Coord& xyz,
const ValueType& value)
2260 assert(BaseT::mTree);
2261 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
2262 if (this->isHashed0(xyz)) {
2264 const_cast<NodeT0*>(mNode0)->setValueAndCache(xyz, value, *
this);
2265 }
else if (this->isHashed1(xyz)) {
2267 const_cast<NodeT1*>(mNode1)->setValueAndCache(xyz, value, *
this);
2268 }
else if (this->isHashed2(xyz)) {
2270 const_cast<NodeT2*>(mNode2)->setValueAndCache(xyz, value, *
this);
2272 BaseT::mTree->root().setValueAndCache(xyz, value, *
this);
2281 assert(BaseT::mTree);
2282 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
2283 if (this->isHashed0(xyz)) {
2285 const_cast<NodeT0*>(mNode0)->setValueOnlyAndCache(xyz, value, *
this);
2286 }
else if (this->isHashed1(xyz)) {
2288 const_cast<NodeT1*>(mNode1)->setValueOnlyAndCache(xyz, value, *
this);
2289 }
else if (this->isHashed2(xyz)) {
2291 const_cast<NodeT2*>(mNode2)->setValueOnlyAndCache(xyz, value, *
this);
2293 BaseT::mTree->root().setValueOnlyAndCache(xyz, value, *
this);
2300 assert(BaseT::mTree);
2301 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
2302 if (this->isHashed0(xyz)) {
2304 const_cast<NodeT0*>(mNode0)->setValueOffAndCache(xyz, value, *
this);
2305 }
else if (this->isHashed1(xyz)) {
2307 const_cast<NodeT1*>(mNode1)->setValueOffAndCache(xyz, value, *
this);
2308 }
else if (this->isHashed2(xyz)) {
2310 const_cast<NodeT2*>(mNode2)->setValueOffAndCache(xyz, value, *
this);
2312 BaseT::mTree->root().setValueOffAndCache(xyz, value, *
this);
2319 template<
typename ModifyOp>
2322 assert(BaseT::mTree);
2323 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
2324 if (this->isHashed0(xyz)) {
2326 const_cast<NodeT0*>(mNode0)->modifyValueAndCache(xyz, op, *
this);
2327 }
else if (this->isHashed1(xyz)) {
2329 const_cast<NodeT1*>(mNode1)->modifyValueAndCache(xyz, op, *
this);
2330 }
else if (this->isHashed2(xyz)) {
2332 const_cast<NodeT2*>(mNode2)->modifyValueAndCache(xyz, op, *
this);
2334 BaseT::mTree->root().modifyValueAndCache(xyz, op, *
this);
2340 template<
typename ModifyOp>
2343 assert(BaseT::mTree);
2344 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
2345 if (this->isHashed0(xyz)) {
2347 const_cast<NodeT0*>(mNode0)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
2348 }
else if (this->isHashed1(xyz)) {
2350 const_cast<NodeT1*>(mNode1)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
2351 }
else if (this->isHashed2(xyz)) {
2353 const_cast<NodeT2*>(mNode2)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
2355 BaseT::mTree->root().modifyValueAndActiveStateAndCache(xyz, op, *
this);
2362 assert(BaseT::mTree);
2363 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
2364 if (this->isHashed0(xyz)) {
2366 const_cast<NodeT0*>(mNode0)->setActiveStateAndCache(xyz, on, *
this);
2367 }
else if (this->isHashed1(xyz)) {
2369 const_cast<NodeT1*>(mNode1)->setActiveStateAndCache(xyz, on, *
this);
2370 }
else if (this->isHashed2(xyz)) {
2372 const_cast<NodeT2*>(mNode2)->setActiveStateAndCache(xyz, on, *
this);
2374 BaseT::mTree->root().setActiveStateAndCache(xyz, on, *
this);
2383 template<
typename NodeT>
2386 const NodeT* node =
nullptr;
2387 this->getNode(node);
2388 return const_cast<NodeT*>(node);
2393 template<
typename NodeT>
2399 template<
typename NodeT>
2402 const NodeT* node =
nullptr;
2403 this->eraseNode(node);
2410 assert(BaseT::mTree);
2411 static_assert(!BaseT::IsConstTree,
"can't add a node to a const tree");
2412 if (this->isHashed1(leaf->origin())) {
2414 return const_cast<NodeT1*>(mNode1)->addLeafAndCache(leaf, *
this);
2415 }
else if (this->isHashed2(leaf->origin())) {
2417 return const_cast<NodeT2*>(mNode2)->addLeafAndCache(leaf, *
this);
2419 BaseT::mTree->root().addLeafAndCache(leaf, *
this);
2426 assert(BaseT::mTree);
2427 static_assert(!BaseT::IsConstTree,
"can't add a tile to a const tree");
2428 if (this->isHashed1(xyz)) {
2430 return const_cast<NodeT1*>(mNode1)->addTileAndCache(level, xyz, value, state, *
this);
2431 }
if (this->isHashed2(xyz)) {
2433 return const_cast<NodeT2*>(mNode2)->addTileAndCache(level, xyz, value, state, *
this);
2435 BaseT::mTree->root().addTileAndCache(level, xyz, value, state, *
this);
2446 assert(BaseT::mTree);
2447 static_assert(!BaseT::IsConstTree,
"can't get a non-const node from a const tree");
2448 if (this->isHashed0(xyz)) {
2450 return const_cast<NodeT0*>(mNode0);
2451 }
else if (this->isHashed1(xyz)) {
2453 return const_cast<NodeT1*>(mNode1)->touchLeafAndCache(xyz, *
this);
2454 }
else if (this->isHashed2(xyz)) {
2456 return const_cast<NodeT2*>(mNode2)->touchLeafAndCache(xyz, *
this);
2458 return BaseT::mTree->root().touchLeafAndCache(xyz, *
this);
2462 template<
typename NodeT>
2465 assert(BaseT::mTree);
2466 static_assert(!BaseT::IsConstTree,
"can't get a non-const node from a const tree");
2468 if ((std::is_same<NodeT, NodeT0>::value)) {
2469 if (this->isHashed0(xyz)) {
2471 return reinterpret_cast<NodeT*>(const_cast<NodeT0*>(mNode0));
2472 }
else if (this->isHashed1(xyz)) {
2474 return const_cast<NodeT1*>(mNode1)->template probeNodeAndCache<NodeT>(xyz, *
this);
2475 }
else if (this->isHashed2(xyz)) {
2477 return const_cast<NodeT2*>(mNode2)->template probeNodeAndCache<NodeT>(xyz, *
this);
2479 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
2480 }
else if ((std::is_same<NodeT, NodeT1>::value)) {
2481 if (this->isHashed1(xyz)) {
2483 return reinterpret_cast<NodeT*>(const_cast<NodeT1*>(mNode1));
2484 }
else if (this->isHashed2(xyz)) {
2486 return const_cast<NodeT2*>(mNode2)->template probeNodeAndCache<NodeT>(xyz, *
this);
2488 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
2489 }
else if ((std::is_same<NodeT, NodeT2>::value)) {
2490 if (this->isHashed2(xyz)) {
2492 return reinterpret_cast<NodeT*>(const_cast<NodeT2*>(mNode2));
2494 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
2505 template<
typename NodeT>
2508 assert(BaseT::mTree);
2510 if ((std::is_same<NodeT, NodeT0>::value)) {
2511 if (this->isHashed0(xyz)) {
2513 return reinterpret_cast<const NodeT*>(mNode0);
2514 }
else if (this->isHashed1(xyz)) {
2516 return mNode1->template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2517 }
else if (this->isHashed2(xyz)) {
2519 return mNode2->template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2521 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2522 }
else if ((std::is_same<NodeT, NodeT1>::value)) {
2523 if (this->isHashed1(xyz)) {
2525 return reinterpret_cast<const NodeT*>(mNode1);
2526 }
else if (this->isHashed2(xyz)) {
2528 return mNode2->template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2530 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2531 }
else if ((std::is_same<NodeT, NodeT2>::value)) {
2532 if (this->isHashed2(xyz)) {
2534 return reinterpret_cast<const NodeT*>(mNode2);
2536 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2545 return this->
template probeConstNode<LeafNodeT>(xyz);
2566 template<
typename>
friend class Tree;
2569 inline ValueAccessor3&
self()
const {
return const_cast<ValueAccessor3&>(*
this); }
2574 mKey0 = other.mKey0;
2575 mNode0 = other.mNode0;
2576 mKey1 = other.mKey1;
2577 mNode1 = other.mNode1;
2578 mKey2 = other.mKey2;
2579 mNode2 = other.mNode2;
2584 void release()
override 2586 this->BaseT::release();
2589 void getNode(
const NodeT0*& node) { node = mNode0; }
2590 void getNode(
const NodeT1*& node) { node = mNode1; }
2591 void getNode(
const NodeT2*& node) { node = mNode2; }
2592 void getNode(
const RootNodeT*& node)
2594 node = (BaseT::mTree ? &BaseT::mTree->root() :
nullptr);
2596 template<
typename OtherNodeType>
void getNode(
const OtherNodeType*& node) { node =
nullptr; }
2598 void eraseNode(
const NodeT0*) { mKey0 =
Coord::max(); mNode0 =
nullptr; }
2599 void eraseNode(
const NodeT1*) { mKey1 =
Coord::max(); mNode1 =
nullptr; }
2600 void eraseNode(
const NodeT2*) { mKey2 =
Coord::max(); mNode2 =
nullptr; }
2601 template<
typename OtherNodeType>
void eraseNode(
const OtherNodeType*) {}
2607 inline void insert(
const Coord& xyz,
const NodeT0* node)
2610 mKey0 = xyz & ~(NodeT0::DIM-1);
2613 inline void insert(
const Coord& xyz,
const NodeT1* node)
2616 mKey1 = xyz & ~(NodeT1::DIM-1);
2619 inline void insert(
const Coord& xyz,
const NodeT2* node)
2622 mKey2 = xyz & ~(NodeT2::DIM-1);
2627 template<
typename OtherNodeType>
2628 inline void insert(
const Coord&,
const OtherNodeType*)
2631 inline bool isHashed0(
const Coord& xyz)
const 2634 && (xyz[1] & ~Coord::ValueType(NodeT0::DIM-1)) == mKey0[1]
2637 inline bool isHashed1(
const Coord& xyz)
const 2640 && (xyz[1] & ~Coord::ValueType(NodeT1::DIM-1)) == mKey1[1]
2643 inline bool isHashed2(
const Coord& xyz)
const 2646 && (xyz[1] & ~Coord::ValueType(NodeT2::DIM-1)) == mKey2[1]
2649 mutable Coord mKey0;
2650 mutable const NodeT0* mNode0;
2651 mutable Coord mKey1;
2652 mutable const NodeT1* mNode1;
2653 mutable Coord mKey2;
2654 mutable const NodeT2* mNode2;
2661 #endif // OPENVDB_TREE_VALUEACCESSOR_HAS_BEEN_INCLUDED void getNode(OtherNodeType *&node)
Forward the request to another level of the cache.
Definition: ValueAccessor.h:631
Definition: ValueAccessor.h:95
typename boost::mpl::at< InvTreeT, boost::mpl::int_< L1 > >::type NodeT1
Definition: ValueAccessor.h:1641
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:323
void clear() override
Remove all the cached nodes and invalidate the corresponding hash-keys.
Definition: ValueAccessor.h:1553
LeafNodeT * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:2501
void setValueOn(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:990
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:1082
static Index numCacheLevels()
Return the number of cache levels employed by this ValueAccessor.
Definition: ValueAccessor.h:2154
void insertNode(const Coord &xyz, NodeT &node)
Definition: ValueAccessor.h:1869
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:1136
NodeT * getNode()
Return the cached node of type NodeType. [Mainly for internal use].
Definition: ValueAccessor.h:2384
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:1676
CacheItem & copy(TreeCacheT &parent, const CacheItem &other)
Copy another CacheItem's node pointers and hash keys, but not its parent pointer.
Definition: ValueAccessor.h:585
TreeType * getTree() const
Return a pointer to the tree associated with this accessor.
Definition: ValueAccessor.h:146
friend class LeafNode
Definition: ValueAccessor.h:442
NodeT * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:1509
bool isVoxel(const Coord &xyz)
Definition: ValueAccessor.h:757
void insertNode(const Coord &xyz, NodeT &node)
Definition: ValueAccessor.h:1459
Index32 Index
Definition: Types.h:61
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:314
ValueAccessor2(const ValueAccessor2 &other)
Copy constructor.
Definition: ValueAccessor.h:1649
const LeafNodeT * probeLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1227
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:1896
ValueAccessor(TreeType &tree)
Definition: ValueAccessor.h:233
ValueAccessor0(const ValueAccessor0 &other)
Definition: ValueAccessor.h:1051
NodeT * getNode()
Return the cached node of type NodeType. [Mainly for internal use].
Definition: ValueAccessor.h:1449
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: ValueAccessor.h:336
const NodeT * probeConstNode(const Coord &xyz) const
Definition: ValueAccessor.h:2506
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:2341
friend class LeafNode
Definition: ValueAccessor.h:1563
void getNode(NodeType *&node)
Definition: ValueAccessor.h:622
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
ValueAccessor(const ValueAccessor &other)
Definition: ValueAccessor.h:238
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive without changing its value.
Definition: ValueAccessor.h:1855
void setActiveState(const Coord &xyz, bool on)
Definition: ValueAccessor.h:1015
typename boost::mpl::at< InvTreeT, boost::mpl::int_< L1 > >::type NodeT1
Definition: ValueAccessor.h:2131
void clear() override
Remove all the cached nodes and invalidate the corresponding hash-keys.
Definition: ValueAccessor.h:2018
typename TreeType::LeafNodeType LeafNodeT
Definition: ValueAccessor.h:1261
static Index numCacheLevels()
Return the number of cache levels employed by this ValueAccessor.
Definition: ValueAccessor.h:1652
bool probeValue(const Coord &xyz, ValueType &value) const
Return the active state of the voxel as well as its value.
Definition: ValueAccessor.h:2202
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:402
bool isValueOn(const Coord &xyz) const
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:264
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:2320
friend class Tree
Definition: ValueAccessor.h:1237
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:2360
std::numeric_limits< Int32 > CoordLimits
Definition: ValueAccessor.h:565
bool probeValue(const Coord &xyz, ValueType &value) const
Return the active state of the voxel as well as its value.
Definition: ValueAccessor.h:267
ValueAccessor with no mutex and no node caching.
Definition: ValueAccessor.h:88
void addLeaf(LeafNodeType *leaf)
Definition: ValueAccessor.h:900
typename TreeType::LeafNodeType LeafNodeT
Definition: ValueAccessor.h:1637
virtual ~ValueAccessorBase()
Definition: ValueAccessor.h:140
ValueAccessor1(const ValueAccessor1 &other)
Copy constructor.
Definition: ValueAccessor.h:1272
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:808
typename TreeType::RootNodeType RootNodeT
Definition: ValueAccessor.h:1045
ValueAccessor(TreeType &tree)
Definition: ValueAccessor.h:498
typename TreeType::ValueType ValueType
Definition: ValueAccessor.h:2125
typename RootNodeT::NodeChainType InvTreeT
Definition: ValueAccessor.h:1639
const NodeT * probeConstNode(const Coord &xyz) const
Definition: ValueAccessor.h:1532
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:1387
bool isValueOn(const Coord &xyz) const
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:1075
ValueAccessorRW(TreeType &tree)
Definition: ValueAccessor.h:543
void getNode(const NodeType *&node) const
Return the cached node (if any) at this level.
Definition: ValueAccessor.h:620
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:396
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:1769
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:820
LeafNodeT * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1195
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:1822
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:304
friend class InternalNode
Definition: ValueAccessor.h:2563
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive without changing its value.
Definition: ValueAccessor.h:2380
const LeafNodeT * probeLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1988
bool probeValue(const Coord &xyz, ValueType &value)
Definition: ValueAccessor.h:961
void insert(const Coord &, const OtherNodeType *)
Definition: ValueAccessor.h:887
ValueAccessor(TreeType &tree)
Definition: ValueAccessor.h:510
void clear() override
Remove all the cached nodes and invalidate the corresponding hash-keys.
Definition: ValueAccessor.h:2550
friend class RootNode
Definition: ValueAccessor.h:2028
void setValue(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:978
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:51
int getValueDepth(const Coord &xyz) const
Definition: ValueAccessor.h:1720
void insertNode(const Coord &, NodeT &)
Definition: ValueAccessor.h:1170
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:1374
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:1418
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: ValueAccessor.h:1163
void insert(const Coord &, const RootNodeType *root)
Definition: ValueAccessor.h:883
void eraseNode()
Definition: ValueAccessor.h:1465
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:1482
friend class RootNode
Definition: ValueAccessor.h:1561
TreeType TreeType
Definition: ValueAccessor.h:1258
ValueAccessor3(TreeType &tree)
Constructor from a tree.
Definition: ValueAccessor.h:2135
void insertNode(const Coord &xyz, NodeT &node)
Definition: ValueAccessor.h:2394
static Index numCacheLevels()
Return the number of cache levels employed by this accessor.
Definition: ValueAccessor.h:1054
void insertNode(const Coord &xyz, NodeType &node)
Definition: ValueAccessor.h:353
int getValueDepth(const Coord &xyz) const
Definition: ValueAccessor.h:1334
typename TreeType::ValueType ValueType
Definition: ValueAccessor.h:1635
friend class Tree
Definition: ValueAccessor.h:2032
const LeafNodeT * probeConstLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1222
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:1785
void modifyValue(const Coord &xyz, const ModifyOp &op)
Definition: ValueAccessor.h:993
ValueAccessor0 & operator=(const ValueAccessor0 &other)
Definition: ValueAccessor.h:1056
int getValueDepth(const Coord &xyz)
Definition: ValueAccessor.h:950
typename TreeType::LeafNodeType LeafNodeT
Definition: ValueAccessor.h:227
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active without changing its value.
Definition: ValueAccessor.h:1853
void eraseNode()
Definition: ValueAccessor.h:363
typename boost::mpl::at< InvTreeT, boost::mpl::int_< L2 > >::type NodeT2
Definition: ValueAccessor.h:2132
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:1113
ValueAccessor2 & operator=(const ValueAccessor2 &other)
Asignment operator.
Definition: ValueAccessor.h:1655
bool isCached(const Coord &xyz) const
Return true if nodes along the path to the given voxel have been cached.
Definition: ValueAccessor.h:254
typename TreeType::ValueType ValueType
Definition: ValueAccessor.h:1259
virtual void release()
Definition: ValueAccessor.h:171
void erase(const RootNodeType *)
Definition: ValueAccessor.h:889
bool isCached(const Coord &xyz) const
Definition: ValueAccessor.h:1292
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:1154
const LeafNodeType * probeConstLeaf(const Coord &xyz)
Definition: ValueAccessor.h:686
void eraseNode()
Definition: ValueAccessor.h:2400
void setValueOnly(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:778
bool isVoxel(const Coord &xyz) const
Definition: ValueAccessor.h:1099
bool probeValue(const Coord &xyz, ValueType &value) const
Return the active state of the voxel as well as its value.
Definition: ValueAccessor.h:1321
void clear() override
Remove all nodes from this cache, then reinsert the root node.
Definition: ValueAccessor.h:431
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:794
LeafNodeT * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1913
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:1403
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:1299
typename RootNodeT::NodeChainType InvTreeT
Definition: ValueAccessor.h:1263
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:136
void addLeaf(LeafNodeT *leaf)
Add the specified leaf to this tree, possibly creating a child branch in the process....
Definition: ValueAccessor.h:1174
bool isValueOn(const Coord &xyz) const
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:2185
bool isValueOn(const Coord &xyz)
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:727
typename boost::mpl::front< NodeVecT >::type RootNodeType
Definition: ValueAccessor.h:867
This base class for ValueAccessors manages registration of an accessor with a tree so that the tree c...
Definition: ValueAccessor.h:122
LeafNodeT * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1524
NodeT * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:1929
bool probeValue(const Coord &xyz, ValueType &value) const
Return the active state of the voxel as well as its value.
Definition: ValueAccessor.h:1704
LeafNodeType * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:676
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:408
NodeT * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:696
void addLeaf(LeafNodeType *leaf)
Definition: ValueAccessor.h:643
typename RootNodeType::ValueType ValueType
Definition: ValueAccessor.h:868
ValueAccessor3(const ValueAccessor3 &other)
Copy constructor.
Definition: ValueAccessor.h:2141
void setValueOnly(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:984
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:1804
ValueAccessor(const ValueAccessor &other)
Definition: ValueAccessor.h:487
friend class Tree
Definition: ValueAccessor.h:2566
void erase(const NodeType *)
Erase the node at this level.
Definition: ValueAccessor.h:611
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:2298
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: ValueAccessor.h:1443
typename boost::mpl::at< InvTreeT, boost::mpl::int_< L0 > >::type NodeT0
Definition: ValueAccessor.h:2130
ValueAccessorBase & operator=(const ValueAccessorBase &other)
Definition: ValueAccessor.h:155
typename TreeType::RootNodeType RootNodeT
Definition: ValueAccessor.h:2126
ValueAccessor(TreeType &tree)
Definition: ValueAccessor.h:486
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:257
const LeafNodeT * probeConstLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1984
bool isVoxel(const Coord &xyz)
Definition: ValueAccessor.h:966
Definition: Exceptions.h:40
typename tbb::null_mutex ::scoped_lock LockT
Definition: ValueAccessor.h:230
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:375
ValueAccessor(TreeType &tree)
Definition: ValueAccessor.h:521
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:1765
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:2279
typename TreeType::RootNodeType RootNodeT
Definition: ValueAccessor.h:226
const ValueType & getValue(const Coord &xyz)
Definition: ValueAccessor.h:972
ValueAccessor3 & operator=(const ValueAccessor3 &other)
Asignment operator.
Definition: ValueAccessor.h:2144
void addTile(Index level, const Coord &xyz, const ValueType &value, bool state)
Definition: ValueAccessor.h:654
const ValueType & getValue(const Coord &xyz)
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:634
ValueAccessorBase(const ValueAccessorBase &other)
Definition: ValueAccessor.h:150
friend class Tree
Definition: ValueAccessor.h:1565
friend class InternalNode
Definition: ValueAccessor.h:2029
friend class LeafNode
Definition: ValueAccessor.h:2564
void addLeaf(LeafNodeT *leaf)
Add the specified leaf to this tree, possibly creating a child branch in the process....
Definition: ValueAccessor.h:2408
CacheItem(TreeCacheT &parent, const CacheItem &other)
Definition: ValueAccessor.h:872
LeafNodeType * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:666
bool isCached(const Coord &xyz) const
Definition: ValueAccessor.h:881
const LeafNodeT * probeLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:2547
CacheItem(TreeCacheT &parent)
Definition: ValueAccessor.h:567
void clear() override
Remove all nodes from this cache, then reinsert the root node.
Definition: ValueAccessor.h:1233
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:427
friend class RootNode
Definition: ValueAccessor.h:2562
Int32 ValueType
Definition: Coord.h:59
NodeT * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:2463
ValueAccessor0(TreeType &tree)
Definition: ValueAccessor.h:1049
int getValueDepth(const Coord &xyz) const
Definition: ValueAccessor.h:2221
ValueAccessor(const ValueAccessor &other)
Definition: ValueAccessor.h:499
typename RootNodeT::ValueType ValueType
Definition: ValueAccessor.h:228
CacheItem(TreeCacheT &parent)
Definition: ValueAccessor.h:871
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: ValueAccessor.h:338
const NodeT * probeConstNode(const Coord &xyz) const
Definition: ValueAccessor.h:1211
typename NodeType::ValueType ValueType
Definition: ValueAccessor.h:563
bool isValueOn(const Coord &xyz) const
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:1310
void getNode(const NodeType *&node)
Definition: ValueAccessor.h:621
void insert(const Coord &xyz, const OtherNodeType *node)
Forward the given node to another level of the cache.
Definition: ValueAccessor.h:608
ValueAccessor(const ValueAccessor &other)
Definition: ValueAccessor.h:511
typename boost::mpl::at< InvTreeT, boost::mpl::int_< L0 > >::type NodeT0
Definition: ValueAccessor.h:1640
NodeT * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:1203
bool isVoxel(const Coord &xyz) const
Definition: ValueAccessor.h:2239
typename TreeType::RootNodeType RootNodeT
Definition: ValueAccessor.h:1636
Library and file format version numbers.
Definition: ValueAccessor.h:220
friend class RootNode
Definition: ValueAccessor.h:440
const LeafNodeT * probeConstLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:2543
void erase(const OtherNodeType *node)
Erase the node at another level of the cache.
Definition: ValueAccessor.h:614
const LeafNodeType * probeConstLeaf(const Coord &xyz)
Definition: ValueAccessor.h:928
This accessor is thread-safe (at the cost of speed) for both reading and writing to a tree....
Definition: ValueAccessor.h:540
const LeafNodeT * probeLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1550
ValueAccessorBase(TreeType &tree)
Definition: ValueAccessor.h:135
typename boost::mpl::front< SubtreeT >::type NodeType
Definition: ValueAccessor.h:562
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active without changing its value.
Definition: ValueAccessor.h:2378
void insert(const Coord &xyz, const NodeType *node)
Cache the given node at this level.
Definition: ValueAccessor.h:601
LeafNodeT * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1955
TreeType & tree() const
Return a reference to the tree associated with this accessor.
Definition: ValueAccessor.h:148
void clear()
Definition: ValueAccessor.h:891
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:1117
NodeT * getNode()
Return the cached node of type NodeType. [Mainly for internal use].
Definition: ValueAccessor.h:1166
int getValueDepth(const Coord &xyz) const
Definition: ValueAccessor.h:276
friend class Tree
Definition: ValueAccessor.h:444
friend class LeafNode
Definition: ValueAccessor.h:2030
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:1146
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: ValueAccessor.h:1445
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:386
NodeType * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:935
void eraseNode()
Definition: ValueAccessor.h:1875
typename NodeType::LeafNodeType LeafNodeType
Definition: ValueAccessor.h:564
typename TreeType::LeafNodeType LeafNodeT
Definition: ValueAccessor.h:1046
const NodeT * probeConstNode(const Coord &xyz)
Definition: ValueAccessor.h:712
TreeType TreeType
Definition: ValueAccessor.h:1043
int getValueDepth(const Coord &xyz) const
Definition: ValueAccessor.h:1091
Value accessor with two levels of node caching.
Definition: ValueAccessor.h:92
LeafNodeT * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:2444
const LeafNodeT * probeConstLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1546
const NodeType * probeConstNode(const Coord &xyz)
Definition: ValueAccessor.h:944
void getNode(const RootNodeType *&node) const
Definition: ValueAccessor.h:898
bool isValueOn(const Coord &xyz) const
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:1690
ValueAccessor & operator=(const ValueAccessor &other)
Definition: ValueAccessor.h:240
static Coord max()
Return the largest possible coordinate.
Definition: Coord.h:73
typename boost::mpl::at< InvTreeT, boost::mpl::int_< L0 > >::type NodeT0
Definition: ValueAccessor.h:1264
CacheItem & copy(TreeCacheT &parent, const CacheItem &other)
Definition: ValueAccessor.h:874
int getValueDepth(const Coord &xyz)
Definition: ValueAccessor.h:746
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:2424
TreeType TreeType
Definition: ValueAccessor.h:2124
void clear()
Erase the nodes at this and lower levels of the cache.
Definition: ValueAccessor.h:617
typename TreeType::RootNodeType RootNodeT
Definition: ValueAccessor.h:1260
typename TreeType::ValueType ValueType
Definition: ValueAccessor.h:1044
friend class InternalNode
Definition: ValueAccessor.h:1562
const NodeT * probeConstNode(const Coord &xyz) const
Definition: ValueAccessor.h:1993
Value accessor with three levels of node caching.
Definition: ValueAccessor.h:94
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 isVoxel(const Coord &xyz) const
Definition: ValueAccessor.h:284
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:1125
bool probeValue(const Coord &xyz, ValueType &value)
Return the active state and value of the voxel at the given coordinates.
Definition: ValueAccessor.h:737
void getNode(RootNodeType *&node)
Definition: ValueAccessor.h:893
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:768
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:422
const NodeT * probeConstLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1960
bool isVoxel(const Coord &xyz) const
Definition: ValueAccessor.h:1346
LeafNodeT * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1495
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:1068
void addLeaf(LeafNodeT *leaf)
Add the specified leaf to this tree, possibly creating a child branch in the process....
Definition: ValueAccessor.h:367
void addLeaf(LeafNodeT *leaf)
Add the specified leaf to this tree, possibly creating a child branch in the process....
Definition: ValueAccessor.h:1473
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
bool isCached(const Coord &xyz) const
Definition: ValueAccessor.h:2161
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:1838
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:188
bool isValueOn(const Coord &xyz)
Definition: ValueAccessor.h:955
typename TreeType::LeafNodeType LeafNodeT
Definition: ValueAccessor.h:2127
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:2275
void addTile(Index level, const Coord &xyz, const ValueType &value, bool state)
Definition: ValueAccessor.h:907
LeafNodeT * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1217
typename RootNodeType::LeafNodeType LeafNodeType
Definition: ValueAccessor.h:869
void setValueOff(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:1008
NodeT * getNode()
Return the cached node of type NodeType. [Mainly for internal use].
Definition: ValueAccessor.h:1859
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:2168
typename RootNodeT::NodeChainType InvTreeT
Definition: ValueAccessor.h:2129
void addLeaf(LeafNodeT *leaf)
Add the specified leaf to this tree, possibly creating a child branch in the process....
Definition: ValueAccessor.h:1883
void eraseNode()
Definition: ValueAccessor.h:1193
bool isCached(const Coord &) const
Return true if nodes along the path to the given voxel have been cached.
Definition: ValueAccessor.h:1065
LeafNodeType * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:914
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: ValueAccessor.h:1161
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:1183
TreeType TreeType
Definition: ValueAccessor.h:1634
void setValueOn(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:788
LeafNodeType * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:921
static Index numCacheLevels()
Return the number of cache levels employed by this ValueAccessor.
Definition: ValueAccessor.h:1275
static Index numCacheLevels()
Return the number of cache levels employed by this accessor.
Definition: ValueAccessor.h:251
ValueAccessor1 & operator=(const ValueAccessor1 &other)
Asignment operator.
Definition: ValueAccessor.h:1278
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:330
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Definition: ValueAccessor.h:1001
bool isCached(const Coord &xyz) const
Definition: ValueAccessor.h:595
NodeType * getNode()
Return the cached node of type NodeType. [Mainly for internal use].
Definition: ValueAccessor.h:342
Value accessor with one level of node caching.
Definition: ValueAccessor.h:90
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:1370
bool isVoxel(const Coord &xyz) const
Definition: ValueAccessor.h:1735
TreeType * mTree
Definition: ValueAccessor.h:173
Index32TreeType TreeType
Definition: ValueAccessor.h:225
friend class InternalNode
Definition: ValueAccessor.h:441
ValueAccessor1(TreeType &tree)
Constructor from a tree.
Definition: ValueAccessor.h:1267
ValueAccessor2(TreeType &tree)
Constructor from a tree.
Definition: ValueAccessor.h:1644
void setActiveState(const Coord &xyz, bool on)
Set the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:832
bool isCached(const Coord &xyz) const
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:1431