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 <boost/static_assert.hpp>
73 #include <boost/type_traits/is_const.hpp>
74 #include <tbb/null_mutex.h>
75 #include <tbb/spin_mutex.h>
76 #include <openvdb/version.h>
77 #include <openvdb/Types.h>
87 template<
typename TreeType, Index L0 = 0, Index L1 = 1>
class ValueAccessor2;
88 template<
typename TreeType, Index L0 = 0, Index L1 = 1, Index L2 = 2>
class ValueAccessor3;
89 template<
typename TreeCacheT,
typename NodeVecT,
bool AtRoot>
class CacheItem;
101 template<
typename TreeType>
105 static const bool IsConstTree = boost::is_const<TreeType>::value;
117 TreeType&
tree()
const { assert(mTree);
return *mTree; }
121 if (mTree) mTree->attachAccessor(*
this);
126 if (&other !=
this) {
127 if (mTree) mTree->releaseAccessor(*
this);
129 if (mTree) mTree->attachAccessor(*
this);
134 virtual void clear() = 0;
138 template<
typename>
friend class Tree;
170 template<
typename _TreeType,
171 Index CacheLevels = _TreeType::DEPTH-1,
172 typename MutexType = tbb::null_mutex>
176 BOOST_STATIC_ASSERT(CacheLevels < _TreeType::DEPTH);
183 typedef typename MutexType::scoped_lock
LockT;
184 using BaseT::IsConstTree;
188 mCache.insert(Coord(), &tree.root());
195 if (&other !=
this) {
196 this->BaseT::operator=(other);
197 mCache.copy(*
this, other.mCache);
207 bool isCached(
const Coord& xyz)
const {
LockT lock(mMutex);
return mCache.isCached(xyz); }
213 return mCache.getValue(xyz);
217 bool isValueOn(
const Coord& xyz)
const {
LockT lock(mMutex);
return mCache.isValueOn(xyz); }
223 return mCache.probeValue(xyz,value);
232 return mCache.getValueDepth(xyz);
237 bool isVoxel(
const Coord& xyz)
const {
LockT lock(mMutex);
return mCache.isVoxel(xyz); }
240 void setValue(
const Coord& xyz,
const ValueType& value)
244 mCache.setValue(xyz, value);
253 mCache.setValueOnly(xyz, value);
261 mCache.newSetValue(xyz, value);
268 mCache.setValueOff(xyz, value);
274 template<
typename ModifyOp>
278 mCache.modifyValue(xyz, op);
283 template<
typename ModifyOp>
287 mCache.modifyValueAndActiveState(xyz, op);
294 mCache.setActiveState(xyz, on);
297 void setValueOn(
const Coord& xyz) { this->setActiveState(xyz,
true); }
299 void setValueOff(
const Coord& xyz) { this->setActiveState(xyz,
false); }
302 template<
typename NodeType>
306 NodeType* node = NULL;
307 mCache.getNode(node);
313 template<
typename NodeType>
317 mCache.insert(xyz, &node);
323 template<
typename NodeType>
324 void eraseNode() {
LockT lock(mMutex); NodeType* node = NULL; mCache.erase(node); }
331 mCache.addLeaf(leaf);
339 mCache.addTile(level, xyz, value, state);
350 return mCache.touchLeaf(xyz);
354 template<
typename NodeT>
360 return mCache.template probeNode<NodeT>(xyz);
362 template<
typename NodeT>
366 return mCache.template probeConstNode<NodeT>(xyz);
368 template<
typename NodeT>
371 return this->
template probeConstNode<NodeT>(xyz);
376 LeafNodeT* probeLeaf(
const Coord& xyz)
381 return mCache.probeLeaf(xyz);
386 return mCache.probeConstLeaf(xyz);
396 if (this->mTree) mCache.insert(Coord(), &(this->mTree->root()));
405 template<
typename>
friend class Tree;
409 virtual void release()
412 this->BaseT::release();
420 template<
typename NodeType>
421 void insert(
const Coord& xyz, NodeType* node) { mCache.insert(xyz, node); }
424 typedef typename RootNodeT::NodeChainType InvTreeT;
426 typedef typename boost::mpl::begin<InvTreeT>::type BeginT;
427 typedef typename boost::mpl::advance<BeginT,boost::mpl::int_<CacheLevels> >::type FirstT;
428 typedef typename boost::mpl::find<InvTreeT, RootNodeT>::type LastT;
429 typedef typename boost::mpl::erase<InvTreeT,FirstT,LastT>::type SubtreeT;
430 typedef CacheItem<ValueAccessor, SubtreeT, boost::mpl::size<SubtreeT>::value==1> CacheItemT;
433 mutable CacheItemT mCache;
434 mutable MutexType mMutex;
442 template<
typename TreeType>
452 template<
typename TreeType>
462 template<
typename TreeType>
472 template<
typename TreeType>
492 template<
typename TreeType>
510 template<
typename TreeCacheT,
typename NodeVecT,
bool AtRoot>
514 typedef typename boost::mpl::front<NodeVecT>::type
NodeType;
533 mNext(parent, other.mNext)
542 mNext.copy(parent, other.mNext);
549 return (this->isHashed(xyz) || mNext.isCached(xyz));
553 void insert(
const Coord& xyz,
const NodeType* node)
555 mHash = (node != NULL) ? xyz & ~(NodeType::DIM-1) :
Coord::max();
559 template<
typename OtherNodeType>
560 void insert(
const Coord& xyz,
const OtherNodeType* node) { mNext.insert(xyz, node); }
565 template<
typename OtherNodeType>
566 void erase(
const OtherNodeType* node) { mNext.erase(node); }
572 void getNode(
const NodeType*& node)
const { node = mNode; }
573 void getNode(
const NodeType*& node) { node = mNode; }
578 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
579 node =
const_cast<NodeType*
>(mNode);
582 template<
typename OtherNodeType>
583 void getNode(OtherNodeType*& node) { mNext.getNode(node); }
588 if (this->isHashed(xyz)) {
590 return mNode->getValueAndCache(xyz, *mParent);
592 return mNext.getValue(xyz);
597 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
598 if (NodeType::LEVEL == 0)
return;
599 if (this->isHashed(leaf->origin())) {
601 return const_cast<NodeType*
>(mNode)->addLeafAndCache(leaf, *mParent);
608 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
609 if (NodeType::LEVEL < level)
return;
610 if (this->isHashed(xyz)) {
612 return const_cast<NodeType*
>(mNode)->addTileAndCache(
613 level, xyz, value, state, *mParent);
615 mNext.addTile(level, xyz, value, state);
620 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
621 if (this->isHashed(xyz)) {
623 return const_cast<NodeType*
>(mNode)->touchLeafAndCache(xyz, *mParent);
625 return mNext.touchLeaf(xyz);
630 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
631 if (this->isHashed(xyz)) {
633 return const_cast<NodeType*
>(mNode)->probeLeafAndCache(xyz, *mParent);
635 return mNext.probeLeaf(xyz);
640 if (this->isHashed(xyz)) {
642 return mNode->probeConstLeafAndCache(xyz, *mParent);
644 return mNext.probeConstLeaf(xyz);
647 template<
typename NodeT>
650 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
652 if (this->isHashed(xyz)) {
653 if ((boost::is_same<NodeT, NodeType>::value)) {
655 return reinterpret_cast<NodeT*
>(
const_cast<NodeType*
>(mNode));
657 return const_cast<NodeType*
>(mNode)->
template probeNodeAndCache<NodeT>(xyz, *mParent);
659 return mNext.template probeNode<NodeT>(xyz);
663 template<
typename NodeT>
667 if (this->isHashed(xyz)) {
668 if ((boost::is_same<NodeT, NodeType>::value)) {
670 return reinterpret_cast<const NodeT*
>(mNode);
672 return mNode->template probeConstNodeAndCache<NodeT>(xyz, *mParent);
674 return mNext.template probeConstNode<NodeT>(xyz);
681 if (this->isHashed(xyz)) {
683 return mNode->isValueOnAndCache(xyz, *mParent);
685 return mNext.isValueOn(xyz);
691 if (this->isHashed(xyz)) {
693 return mNode->probeValueAndCache(xyz, value, *mParent);
695 return mNext.probeValue(xyz, value);
700 if (this->isHashed(xyz)) {
702 return static_cast<int>(TreeCacheT::RootNodeT::LEVEL) -
703 static_cast<int>(mNode->getValueLevelAndCache(xyz, *mParent));
705 return mNext.getValueDepth(xyz);
711 if (this->isHashed(xyz)) {
713 return mNode->getValueLevelAndCache(xyz, *mParent)==0;
715 return mNext.isVoxel(xyz);
722 if (this->isHashed(xyz)) {
724 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
725 const_cast<NodeType*
>(mNode)->setValueAndCache(xyz, value, *mParent);
727 mNext.setValue(xyz, value);
732 if (this->isHashed(xyz)) {
734 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
735 const_cast<NodeType*
>(mNode)->setValueOnlyAndCache(xyz, value, *mParent);
737 mNext.setValueOnly(xyz, value);
745 template<
typename ModifyOp>
748 if (this->isHashed(xyz)) {
750 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
751 const_cast<NodeType*
>(mNode)->modifyValueAndCache(xyz, op, *mParent);
753 mNext.modifyValue(xyz, op);
759 template<
typename ModifyOp>
762 if (this->isHashed(xyz)) {
764 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
765 const_cast<NodeType*
>(mNode)->modifyValueAndActiveStateAndCache(xyz, op, *mParent);
767 mNext.modifyValueAndActiveState(xyz, op);
774 if (this->isHashed(xyz)) {
776 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
777 const_cast<NodeType*
>(mNode)->setValueOffAndCache(xyz, value, *mParent);
779 mNext.setValueOff(xyz, value);
786 if (this->isHashed(xyz)) {
788 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
789 const_cast<NodeType*
>(mNode)->setActiveStateAndCache(xyz, on, *mParent);
791 mNext.setActiveState(xyz, on);
799 bool isHashed(
const Coord& xyz)
const
801 return (xyz[0] & ~Coord::ValueType(NodeType::DIM-1)) == mHash[0]
802 && (xyz[1] & ~Coord::ValueType(NodeType::DIM-1)) == mHash[1]
803 && (xyz[2] & ~Coord::ValueType(NodeType::DIM-1)) == mHash[2];
808 const NodeType* mNode;
809 typedef typename boost::mpl::pop_front<NodeVecT>::type RestT;
810 CacheItem<TreeCacheT, RestT, boost::mpl::size<RestT>::value == 1> mNext;
815 template<
typename TreeCacheT,
typename NodeVecT>
823 CacheItem(TreeCacheT& parent): mParent(&parent), mRoot(NULL) {}
833 bool isCached(
const Coord& xyz)
const {
return this->isHashed(xyz); }
838 template <
typename OtherNodeType>
839 void insert(
const Coord&,
const OtherNodeType*) {}
847 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
855 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
856 const_cast<RootNodeType*
>(mRoot)->addLeafAndCache(leaf, *mParent);
862 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
863 const_cast<RootNodeType*
>(mRoot)->addTileAndCache(level, xyz, value, state, *mParent);
869 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
870 return const_cast<RootNodeType*
>(mRoot)->touchLeafAndCache(xyz, *mParent);
876 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
877 return const_cast<RootNodeType*
>(mRoot)->probeLeafAndCache(xyz, *mParent);
883 return mRoot->probeConstLeafAndCache(xyz, *mParent);
886 template<
typename NodeType>
890 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
891 return const_cast<RootNodeType*
>(mRoot)->
template probeNodeAndCache<NodeType>(xyz, *mParent);
894 template<
typename NodeType>
898 return mRoot->template probeConstNodeAndCache<NodeType>(xyz, *mParent);
904 return mRoot->getValueDepthAndCache(xyz, *mParent);
909 return mRoot->isValueOnAndCache(xyz, *mParent);
915 return mRoot->probeValueAndCache(xyz, value, *mParent);
920 return mRoot->getValueDepthAndCache(xyz, *mParent) ==
921 static_cast<int>(RootNodeType::LEVEL);
926 return mRoot->getValueAndCache(xyz, *mParent);
932 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
933 const_cast<RootNodeType*
>(mRoot)->setValueAndCache(xyz, value, *mParent);
938 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
939 const_cast<RootNodeType*
>(mRoot)->setValueOnlyAndCache(xyz, value, *mParent);
943 template<
typename ModifyOp>
947 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
948 const_cast<RootNodeType*
>(mRoot)->modifyValueAndCache(xyz, op, *mParent);
951 template<
typename ModifyOp>
955 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
956 const_cast<RootNodeType*
>(mRoot)->modifyValueAndActiveStateAndCache(xyz, op, *mParent);
962 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
963 const_cast<RootNodeType*
>(mRoot)->setValueOffAndCache(xyz, value, *mParent);
969 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
970 const_cast<RootNodeType*
>(mRoot)->setActiveStateAndCache(xyz, on, *mParent);
977 bool isHashed(
const Coord&)
const {
return false; }
980 const RootNodeType* mRoot;
990 template<
typename _TreeType>
991 class ValueAccessor0:
public ValueAccessorBase<_TreeType>
1009 if (&other !=
this) this->BaseT::operator=(other);
1021 assert(BaseT::mTree);
1022 return BaseT::mTree->getValue(xyz);
1028 assert(BaseT::mTree);
1029 return BaseT::mTree->isValueOn(xyz);
1035 assert(BaseT::mTree);
1036 return BaseT::mTree->probeValue(xyz, value);
1044 assert(BaseT::mTree);
1045 return BaseT::mTree->getValueDepth(xyz);
1052 assert(BaseT::mTree);
1053 return BaseT::mTree->getValueDepth(xyz) ==
static_cast<int>(RootNodeT::LEVEL);
1057 void setValue(
const Coord& xyz,
const ValueType& value)
1060 assert(BaseT::mTree);
1061 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1062 BaseT::mTree->setValue(xyz, value);
1070 assert(BaseT::mTree);
1071 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1072 BaseT::mTree->setValueOnly(xyz, value);
1078 assert(BaseT::mTree);
1079 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1080 BaseT::mTree->root().setValueOff(xyz, value);
1086 template<
typename ModifyOp>
1089 assert(BaseT::mTree);
1090 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1091 BaseT::mTree->modifyValue(xyz, op);
1096 template<
typename ModifyOp>
1099 assert(BaseT::mTree);
1100 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1101 BaseT::mTree->modifyValueAndActiveState(xyz, op);
1107 assert(BaseT::mTree);
1108 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1109 BaseT::mTree->setActiveState(xyz, on);
1112 void setValueOn(
const Coord& xyz) { this->setActiveState(xyz,
true); }
1114 void setValueOff(
const Coord& xyz) { this->setActiveState(xyz,
false); }
1117 template<
typename NodeT> NodeT*
getNode() {
return NULL; }
1121 template<
typename NodeT>
void insertNode(
const Coord&, NodeT&) {}
1127 assert(BaseT::mTree);
1128 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1129 BaseT::mTree->root().addLeaf(leaf);
1136 assert(BaseT::mTree);
1137 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1138 BaseT::mTree->root().addTile(level, xyz, value, state);
1148 assert(BaseT::mTree);
1149 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1150 return BaseT::mTree->touchLeaf(xyz);
1153 template <
typename NodeT>
1156 assert(BaseT::mTree);
1157 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1158 return BaseT::mTree->template probeNode<NodeT>(xyz);
1161 template <
typename NodeT>
1164 assert(BaseT::mTree);
1165 return BaseT::mTree->template probeConstNode<NodeT>(xyz);
1170 return this->
template probeNode<LeafNodeT>(xyz);
1175 return this->
template probeConstNode<LeafNodeT>(xyz);
1180 return this->probeConstLeaf(xyz);
1188 template<
typename>
friend class Tree;
1192 virtual void release() { this->BaseT::release(); }
1203 template<
typename _TreeType, Index L0>
1204 class ValueAccessor1 :
public ValueAccessorBase<_TreeType>
1207 BOOST_STATIC_ASSERT(_TreeType::DEPTH >= 2);
1208 BOOST_STATIC_ASSERT( L0 < _TreeType::RootNodeType::LEVEL );
1215 typedef typename boost::mpl::at<InvTreeT, boost::mpl::int_<L0> >::type
NodeT0;
1231 if (&other !=
this) {
1232 this->BaseT::operator=(other);
1245 assert(BaseT::mTree);
1246 return this->isHashed(xyz);
1252 assert(BaseT::mTree);
1253 if (this->isHashed(xyz)) {
1255 return mNode0->getValueAndCache(xyz, this->
self());
1257 return BaseT::mTree->root().getValueAndCache(xyz, this->
self());
1263 assert(BaseT::mTree);
1264 if (this->isHashed(xyz)) {
1266 return mNode0->isValueOnAndCache(xyz, this->
self());
1268 return BaseT::mTree->root().isValueOnAndCache(xyz, this->
self());
1274 assert(BaseT::mTree);
1275 if (this->isHashed(xyz)) {
1277 return mNode0->probeValueAndCache(xyz, value, this->
self());
1279 return BaseT::mTree->root().probeValueAndCache(xyz, value, this->
self());
1287 assert(BaseT::mTree);
1288 if (this->isHashed(xyz)) {
1290 return RootNodeT::LEVEL - mNode0->getValueLevelAndCache(xyz, this->
self());
1292 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->
self());
1299 assert(BaseT::mTree);
1300 if (this->isHashed(xyz)) {
1302 return mNode0->getValueLevelAndCache(xyz, this->
self()) == 0;
1304 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->
self()) ==
1305 static_cast<int>(RootNodeT::LEVEL);
1309 void setValue(
const Coord& xyz,
const ValueType& value)
1312 assert(BaseT::mTree);
1313 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1314 if (this->isHashed(xyz)) {
1316 const_cast<NodeT0*
>(mNode0)->setValueAndCache(xyz, value, *
this);
1318 BaseT::mTree->root().setValueAndCache(xyz, value, *
this);
1321 void setValueOn(
const Coord& xyz,
const ValueType& value) { this->setValue(xyz, value); }
1327 assert(BaseT::mTree);
1328 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1329 if (this->isHashed(xyz)) {
1331 const_cast<NodeT0*
>(mNode0)->setValueOnlyAndCache(xyz, value, *
this);
1333 BaseT::mTree->root().setValueOnlyAndCache(xyz, value, *
this);
1340 assert(BaseT::mTree);
1341 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1342 if (this->isHashed(xyz)) {
1344 const_cast<NodeT0*
>(mNode0)->setValueOffAndCache(xyz, value, *
this);
1346 BaseT::mTree->root().setValueOffAndCache(xyz, value, *
this);
1353 template<
typename ModifyOp>
1356 assert(BaseT::mTree);
1357 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1358 if (this->isHashed(xyz)) {
1360 const_cast<NodeT0*
>(mNode0)->modifyValueAndCache(xyz, op, *
this);
1362 BaseT::mTree->root().modifyValueAndCache(xyz, op, *
this);
1368 template<
typename ModifyOp>
1371 assert(BaseT::mTree);
1372 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1373 if (this->isHashed(xyz)) {
1375 const_cast<NodeT0*
>(mNode0)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
1377 BaseT::mTree->root().modifyValueAndActiveStateAndCache(xyz, op, *
this);
1384 assert(BaseT::mTree);
1385 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1386 if (this->isHashed(xyz)) {
1388 const_cast<NodeT0*
>(mNode0)->setActiveStateAndCache(xyz, on, *
this);
1390 BaseT::mTree->root().setActiveStateAndCache(xyz, on, *
this);
1394 void setValueOn(
const Coord& xyz) { this->setActiveState(xyz,
true); }
1396 void setValueOff(
const Coord& xyz) { this->setActiveState(xyz,
false); }
1399 template<
typename NodeT>
1402 const NodeT* node = NULL;
1403 this->getNode(node);
1404 return const_cast<NodeT*
>(node);
1409 template<
typename NodeT>
1410 void insertNode(
const Coord& xyz, NodeT& node) { this->insert(xyz, &node); }
1415 template<
typename NodeT>
1418 const NodeT* node = NULL;
1419 this->eraseNode(node);
1426 assert(BaseT::mTree);
1427 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1428 BaseT::mTree->root().addLeaf(leaf);
1433 void addTile(
Index level,
const Coord& xyz,
const ValueType& value,
bool state)
1435 assert(BaseT::mTree);
1436 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1437 BaseT::mTree->root().addTile(level, xyz, value, state);
1448 assert(BaseT::mTree);
1449 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1450 if (this->isHashed(xyz)) {
1452 return const_cast<NodeT0*
>(mNode0)->touchLeafAndCache(xyz, *
this);
1454 return BaseT::mTree->root().touchLeafAndCache(xyz, *
this);
1459 template <
typename NodeT>
1462 assert(BaseT::mTree);
1463 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1465 if ((boost::is_same<NodeT, NodeT0>::value)) {
1466 if (this->isHashed(xyz)) {
1468 return reinterpret_cast<NodeT*
>(
const_cast<NodeT0*
>(mNode0));
1470 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
1477 return this->
template probeNode<LeafNodeT>(xyz);
1482 template <
typename NodeT>
1485 assert(BaseT::mTree);
1487 if ((boost::is_same<NodeT, NodeT0>::value)) {
1488 if (this->isHashed(xyz)) {
1490 return reinterpret_cast<const NodeT*
>(mNode0);
1492 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
1499 return this->
template probeConstNode<LeafNodeT>(xyz);
1501 const LeafNodeT*
probeLeaf(
const Coord& xyz)
const {
return this->probeConstLeaf(xyz); }
1516 template<
typename>
friend class Tree;
1521 void getNode(
const NodeT0*& node) { node = mNode0; }
1522 void getNode(
const RootNodeT*& node)
1524 node = (BaseT::mTree ? &BaseT::mTree->root() : NULL);
1526 template <
typename OtherNodeType>
void getNode(
const OtherNodeType*& node) { node = NULL; }
1527 void eraseNode(
const NodeT0*) { mKey0 =
Coord::max(); mNode0 = NULL; }
1528 template <
typename OtherNodeType>
void eraseNode(
const OtherNodeType*) {}
1531 inline void copy(
const ValueAccessor1& other)
1533 mKey0 = other.mKey0;
1534 mNode0 = other.mNode0;
1539 virtual void release()
1541 this->BaseT::release();
1548 inline void insert(
const Coord& xyz,
const NodeT0* node)
1551 mKey0 = xyz & ~(NodeT0::DIM-1);
1557 template<
typename OtherNodeType>
inline void insert(
const Coord&,
const OtherNodeType*) {}
1559 inline bool isHashed(
const Coord& xyz)
const
1561 return (xyz[0] & ~Coord::ValueType(NodeT0::DIM-1)) == mKey0[0]
1562 && (xyz[1] & ~Coord::ValueType(NodeT0::DIM-1)) == mKey0[1]
1563 && (xyz[2] & ~Coord::ValueType(NodeT0::DIM-1)) == mKey0[2];
1565 mutable Coord mKey0;
1566 mutable const NodeT0* mNode0;
1577 template<
typename _TreeType, Index L0, Index L1>
1578 class ValueAccessor2 :
public ValueAccessorBase<_TreeType>
1581 BOOST_STATIC_ASSERT(_TreeType::DEPTH >= 3);
1582 BOOST_STATIC_ASSERT( L0 < L1 && L1 < _TreeType::RootNodeType::LEVEL );
1589 typedef typename boost::mpl::at<InvTreeT, boost::mpl::int_<L0> >::type
NodeT0;
1590 typedef typename boost::mpl::at<InvTreeT, boost::mpl::int_<L1> >::type
NodeT1;
1594 mKey0(Coord::
max()), mNode0(NULL),
1595 mKey1(Coord::
max()), mNode1(NULL) {}
1606 if (&other !=
this) {
1607 this->BaseT::operator=(other);
1620 assert(BaseT::mTree);
1621 return this->isHashed1(xyz) || this->isHashed0(xyz);
1627 assert(BaseT::mTree);
1628 if (this->isHashed0(xyz)) {
1630 return mNode0->getValueAndCache(xyz, this->
self());
1631 }
else if (this->isHashed1(xyz)) {
1633 return mNode1->getValueAndCache(xyz, this->
self());
1635 return BaseT::mTree->root().getValueAndCache(xyz, this->
self());
1641 assert(BaseT::mTree);
1642 if (this->isHashed0(xyz)) {
1644 return mNode0->isValueOnAndCache(xyz, this->
self());
1645 }
else if (this->isHashed1(xyz)) {
1647 return mNode1->isValueOnAndCache(xyz, this->
self());
1649 return BaseT::mTree->root().isValueOnAndCache(xyz, this->
self());
1655 assert(BaseT::mTree);
1656 if (this->isHashed0(xyz)) {
1658 return mNode0->probeValueAndCache(xyz, value, this->
self());
1659 }
else if (this->isHashed1(xyz)) {
1661 return mNode1->probeValueAndCache(xyz, value, this->
self());
1663 return BaseT::mTree->root().probeValueAndCache(xyz, value, this->
self());
1671 assert(BaseT::mTree);
1672 if (this->isHashed0(xyz)) {
1674 return RootNodeT::LEVEL - mNode0->getValueLevelAndCache(xyz, this->
self());
1675 }
else if (this->isHashed1(xyz)) {
1677 return RootNodeT::LEVEL - mNode1->getValueLevelAndCache(xyz, this->
self());
1679 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->
self());
1686 assert(BaseT::mTree);
1687 if (this->isHashed0(xyz)) {
1689 return mNode0->getValueLevelAndCache(xyz, this->
self())==0;
1690 }
else if (this->isHashed1(xyz)) {
1692 return mNode1->getValueLevelAndCache(xyz, this->
self())==0;
1694 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->
self()) ==
1695 static_cast<int>(RootNodeT::LEVEL);
1699 void setValue(
const Coord& xyz,
const ValueType& value)
1702 assert(BaseT::mTree);
1703 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1704 if (this->isHashed0(xyz)) {
1706 const_cast<NodeT0*
>(mNode0)->setValueAndCache(xyz, value, *
this);
1707 }
else if (this->isHashed1(xyz)) {
1709 const_cast<NodeT1*
>(mNode1)->setValueAndCache(xyz, value, *
this);
1711 BaseT::mTree->root().setValueAndCache(xyz, value, *
this);
1714 void setValueOn(
const Coord& xyz,
const ValueType& value) { this->setValue(xyz, value); }
1720 assert(BaseT::mTree);
1721 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1722 if (this->isHashed0(xyz)) {
1724 const_cast<NodeT0*
>(mNode0)->setValueOnlyAndCache(xyz, value, *
this);
1725 }
else if (this->isHashed1(xyz)) {
1727 const_cast<NodeT1*
>(mNode1)->setValueOnlyAndCache(xyz, value, *
this);
1729 BaseT::mTree->root().setValueOnlyAndCache(xyz, value, *
this);
1736 assert(BaseT::mTree);
1737 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1738 if (this->isHashed0(xyz)) {
1740 const_cast<NodeT0*
>(mNode0)->setValueOffAndCache(xyz, value, *
this);
1741 }
else if (this->isHashed1(xyz)) {
1743 const_cast<NodeT1*
>(mNode1)->setValueOffAndCache(xyz, value, *
this);
1745 BaseT::mTree->root().setValueOffAndCache(xyz, value, *
this);
1752 template<
typename ModifyOp>
1755 assert(BaseT::mTree);
1756 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1757 if (this->isHashed0(xyz)) {
1759 const_cast<NodeT0*
>(mNode0)->modifyValueAndCache(xyz, op, *
this);
1760 }
else if (this->isHashed1(xyz)) {
1762 const_cast<NodeT1*
>(mNode1)->modifyValueAndCache(xyz, op, *
this);
1764 BaseT::mTree->root().modifyValueAndCache(xyz, op, *
this);
1770 template<
typename ModifyOp>
1773 assert(BaseT::mTree);
1774 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1775 if (this->isHashed0(xyz)) {
1777 const_cast<NodeT0*
>(mNode0)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
1778 }
else if (this->isHashed1(xyz)) {
1780 const_cast<NodeT1*
>(mNode1)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
1782 BaseT::mTree->root().modifyValueAndActiveStateAndCache(xyz, op, *
this);
1789 assert(BaseT::mTree);
1790 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1791 if (this->isHashed0(xyz)) {
1793 const_cast<NodeT0*
>(mNode0)->setActiveStateAndCache(xyz, on, *
this);
1794 }
else if (this->isHashed1(xyz)) {
1796 const_cast<NodeT1*
>(mNode1)->setActiveStateAndCache(xyz, on, *
this);
1798 BaseT::mTree->root().setActiveStateAndCache(xyz, on, *
this);
1802 void setValueOn(
const Coord& xyz) { this->setActiveState(xyz,
true); }
1804 void setValueOff(
const Coord& xyz) { this->setActiveState(xyz,
false); }
1807 template<
typename NodeT>
1810 const NodeT* node = NULL;
1811 this->getNode(node);
1812 return const_cast<NodeT*
>(node);
1817 template<
typename NodeT>
1818 void insertNode(
const Coord& xyz, NodeT& node) { this->insert(xyz, &node); }
1823 template<
typename NodeT>
1826 const NodeT* node = NULL;
1827 this->eraseNode(node);
1834 assert(BaseT::mTree);
1835 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1836 if (this->isHashed1(leaf->origin())) {
1838 return const_cast<NodeT1*
>(mNode1)->addLeafAndCache(leaf, *
this);
1840 BaseT::mTree->root().addLeafAndCache(leaf, *
this);
1845 void addTile(
Index level,
const Coord& xyz,
const ValueType& value,
bool state)
1847 assert(BaseT::mTree);
1848 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1849 if (this->isHashed1(xyz)) {
1851 return const_cast<NodeT1*
>(mNode1)->addTileAndCache(level, xyz, value, state, *
this);
1853 BaseT::mTree->root().addTileAndCache(level, xyz, value, state, *
this);
1864 assert(BaseT::mTree);
1865 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1866 if (this->isHashed0(xyz)) {
1868 return const_cast<NodeT0*
>(mNode0)->touchLeafAndCache(xyz, *
this);
1869 }
else if (this->isHashed1(xyz)) {
1871 return const_cast<NodeT1*
>(mNode1)->touchLeafAndCache(xyz, *
this);
1873 return BaseT::mTree->root().touchLeafAndCache(xyz, *
this);
1877 template <
typename NodeT>
1880 assert(BaseT::mTree);
1881 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1883 if ((boost::is_same<NodeT, NodeT0>::value)) {
1884 if (this->isHashed0(xyz)) {
1886 return reinterpret_cast<NodeT*
>(
const_cast<NodeT0*
>(mNode0));
1887 }
else if (this->isHashed1(xyz)) {
1889 return const_cast<NodeT1*
>(mNode1)->
template probeNodeAndCache<NodeT>(xyz, *
this);
1891 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
1892 }
else if ((boost::is_same<NodeT, NodeT1>::value)) {
1893 if (this->isHashed1(xyz)) {
1895 return reinterpret_cast<NodeT*
>(
const_cast<NodeT1*
>(mNode1));
1897 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
1904 LeafNodeT*
probeLeaf(
const Coord& xyz) {
return this->
template probeNode<LeafNodeT>(xyz); }
1908 template <
typename NodeT>
1912 if ((boost::is_same<NodeT, NodeT0>::value)) {
1913 if (this->isHashed0(xyz)) {
1915 return reinterpret_cast<const NodeT*
>(mNode0);
1916 }
else if (this->isHashed1(xyz)) {
1918 return mNode1->template probeConstNodeAndCache<NodeT>(xyz, this->
self());
1920 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
1921 }
else if ((boost::is_same<NodeT, NodeT1>::value)) {
1922 if (this->isHashed1(xyz)) {
1924 return reinterpret_cast<const NodeT*
>(mNode1);
1926 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
1935 return this->
template probeConstNode<LeafNodeT>(xyz);
1937 const LeafNodeT*
probeLeaf(
const Coord& xyz)
const {
return this->probeConstLeaf(xyz); }
1941 template <
typename NodeT>
1944 assert(BaseT::mTree);
1946 if ((boost::is_same<NodeT, NodeT0>::value)) {
1947 if (this->isHashed0(xyz)) {
1949 return reinterpret_cast<const NodeT*
>(mNode0);
1950 }
else if (this->isHashed1(xyz)) {
1952 return mNode1->template probeConstNodeAndCache<NodeT>(xyz, this->
self());
1954 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
1955 }
else if ((boost::is_same<NodeT, NodeT1>::value)) {
1956 if (this->isHashed1(xyz)) {
1958 return reinterpret_cast<const NodeT*
>(mNode1);
1960 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
1981 template<
typename>
friend class Tree;
1986 void getNode(
const NodeT0*& node) { node = mNode0; }
1987 void getNode(
const NodeT1*& node) { node = mNode1; }
1988 void getNode(
const RootNodeT*& node)
1990 node = (BaseT::mTree ? &BaseT::mTree->root() : NULL);
1992 template <
typename OtherNodeType>
void getNode(
const OtherNodeType*& node) { node = NULL; }
1994 void eraseNode(
const NodeT0*) { mKey0 =
Coord::max(); mNode0 = NULL; }
1995 void eraseNode(
const NodeT1*) { mKey1 =
Coord::max(); mNode1 = NULL; }
1996 template <
typename OtherNodeType>
void eraseNode(
const OtherNodeType*) {}
1999 inline void copy(
const ValueAccessor2& other)
2001 mKey0 = other.mKey0;
2002 mNode0 = other.mNode0;
2003 mKey1 = other.mKey1;
2004 mNode1 = other.mNode1;
2009 virtual void release()
2011 this->BaseT::release();
2019 inline void insert(
const Coord& xyz,
const NodeT0* node)
2022 mKey0 = xyz & ~(NodeT0::DIM-1);
2025 inline void insert(
const Coord& xyz,
const NodeT1* node)
2028 mKey1 = xyz & ~(NodeT1::DIM-1);
2033 template<
typename NodeT>
inline void insert(
const Coord&,
const NodeT*) {}
2035 inline bool isHashed0(
const Coord& xyz)
const
2037 return (xyz[0] & ~Coord::ValueType(NodeT0::DIM-1)) == mKey0[0]
2038 && (xyz[1] & ~Coord::ValueType(NodeT0::DIM-1)) == mKey0[1]
2039 && (xyz[2] & ~Coord::ValueType(NodeT0::DIM-1)) == mKey0[2];
2041 inline bool isHashed1(
const Coord& xyz)
const
2043 return (xyz[0] & ~Coord::ValueType(NodeT1::DIM-1)) == mKey1[0]
2044 && (xyz[1] & ~Coord::ValueType(NodeT1::DIM-1)) == mKey1[1]
2045 && (xyz[2] & ~Coord::ValueType(NodeT1::DIM-1)) == mKey1[2];
2047 mutable Coord mKey0;
2048 mutable const NodeT0* mNode0;
2049 mutable Coord mKey1;
2050 mutable const NodeT1* mNode1;
2064 template<
typename _TreeType, Index L0, Index L1, Index L2>
2065 class ValueAccessor3 :
public ValueAccessorBase<_TreeType>
2068 BOOST_STATIC_ASSERT(_TreeType::DEPTH >= 4);
2069 BOOST_STATIC_ASSERT(L0 < L1 && L1 < L2 && L2 < _TreeType::RootNodeType::LEVEL);
2076 typedef typename boost::mpl::at<InvTreeT, boost::mpl::int_<L0> >::type
NodeT0;
2077 typedef typename boost::mpl::at<InvTreeT, boost::mpl::int_<L1> >::type
NodeT1;
2078 typedef typename boost::mpl::at<InvTreeT, boost::mpl::int_<L2> >::type
NodeT2;
2082 mKey0(Coord::
max()), mNode0(NULL),
2083 mKey1(Coord::
max()), mNode1(NULL),
2084 mKey2(Coord::
max()), mNode2(NULL) {}
2092 if (&other !=
this) {
2093 this->BaseT::operator=(other);
2109 assert(BaseT::mTree);
2110 return this->isHashed2(xyz) || this->isHashed1(xyz) || this->isHashed0(xyz);
2116 assert(BaseT::mTree);
2117 if (this->isHashed0(xyz)) {
2119 return mNode0->getValueAndCache(xyz, this->
self());
2120 }
else if (this->isHashed1(xyz)) {
2122 return mNode1->getValueAndCache(xyz, this->
self());
2123 }
else if (this->isHashed2(xyz)) {
2125 return mNode2->getValueAndCache(xyz, this->
self());
2127 return BaseT::mTree->root().getValueAndCache(xyz, this->
self());
2133 assert(BaseT::mTree);
2134 if (this->isHashed0(xyz)) {
2136 return mNode0->isValueOnAndCache(xyz, this->
self());
2137 }
else if (this->isHashed1(xyz)) {
2139 return mNode1->isValueOnAndCache(xyz, this->
self());
2140 }
else if (this->isHashed2(xyz)) {
2142 return mNode2->isValueOnAndCache(xyz, this->
self());
2144 return BaseT::mTree->root().isValueOnAndCache(xyz, this->
self());
2150 assert(BaseT::mTree);
2151 if (this->isHashed0(xyz)) {
2153 return mNode0->probeValueAndCache(xyz, value, this->
self());
2154 }
else if (this->isHashed1(xyz)) {
2156 return mNode1->probeValueAndCache(xyz, value, this->
self());
2157 }
else if (this->isHashed2(xyz)) {
2159 return mNode2->probeValueAndCache(xyz, value, this->
self());
2161 return BaseT::mTree->root().probeValueAndCache(xyz, value, this->
self());
2169 assert(BaseT::mTree);
2170 if (this->isHashed0(xyz)) {
2172 return RootNodeT::LEVEL - mNode0->getValueLevelAndCache(xyz, this->
self());
2173 }
else if (this->isHashed1(xyz)) {
2175 return RootNodeT::LEVEL - mNode1->getValueLevelAndCache(xyz, this->
self());
2176 }
else if (this->isHashed2(xyz)) {
2178 return RootNodeT::LEVEL - mNode2->getValueLevelAndCache(xyz, this->
self());
2180 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->
self());
2187 assert(BaseT::mTree);
2188 if (this->isHashed0(xyz)) {
2190 return mNode0->getValueLevelAndCache(xyz, this->
self())==0;
2191 }
else if (this->isHashed1(xyz)) {
2193 return mNode1->getValueLevelAndCache(xyz, this->
self())==0;
2194 }
else if (this->isHashed2(xyz)) {
2196 return mNode2->getValueLevelAndCache(xyz, this->
self())==0;
2198 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->
self()) ==
2199 static_cast<int>(RootNodeT::LEVEL);
2203 void setValue(
const Coord& xyz,
const ValueType& value)
2206 assert(BaseT::mTree);
2207 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
2208 if (this->isHashed0(xyz)) {
2210 const_cast<NodeT0*
>(mNode0)->setValueAndCache(xyz, value, *
this);
2211 }
else if (this->isHashed1(xyz)) {
2213 const_cast<NodeT1*
>(mNode1)->setValueAndCache(xyz, value, *
this);
2214 }
else if (this->isHashed2(xyz)) {
2216 const_cast<NodeT2*
>(mNode2)->setValueAndCache(xyz, value, *
this);
2218 BaseT::mTree->root().setValueAndCache(xyz, value, *
this);
2221 void setValueOn(
const Coord& xyz,
const ValueType& value) { this->setValue(xyz, value); }
2227 assert(BaseT::mTree);
2228 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
2229 if (this->isHashed0(xyz)) {
2231 const_cast<NodeT0*
>(mNode0)->setValueOnlyAndCache(xyz, value, *
this);
2232 }
else if (this->isHashed1(xyz)) {
2234 const_cast<NodeT1*
>(mNode1)->setValueOnlyAndCache(xyz, value, *
this);
2235 }
else if (this->isHashed2(xyz)) {
2237 const_cast<NodeT2*
>(mNode2)->setValueOnlyAndCache(xyz, value, *
this);
2239 BaseT::mTree->root().setValueOnlyAndCache(xyz, value, *
this);
2246 assert(BaseT::mTree);
2247 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
2248 if (this->isHashed0(xyz)) {
2250 const_cast<NodeT0*
>(mNode0)->setValueOffAndCache(xyz, value, *
this);
2251 }
else if (this->isHashed1(xyz)) {
2253 const_cast<NodeT1*
>(mNode1)->setValueOffAndCache(xyz, value, *
this);
2254 }
else if (this->isHashed2(xyz)) {
2256 const_cast<NodeT2*
>(mNode2)->setValueOffAndCache(xyz, value, *
this);
2258 BaseT::mTree->root().setValueOffAndCache(xyz, value, *
this);
2265 template<
typename ModifyOp>
2268 assert(BaseT::mTree);
2269 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
2270 if (this->isHashed0(xyz)) {
2272 const_cast<NodeT0*
>(mNode0)->modifyValueAndCache(xyz, op, *
this);
2273 }
else if (this->isHashed1(xyz)) {
2275 const_cast<NodeT1*
>(mNode1)->modifyValueAndCache(xyz, op, *
this);
2276 }
else if (this->isHashed2(xyz)) {
2278 const_cast<NodeT2*
>(mNode2)->modifyValueAndCache(xyz, op, *
this);
2280 BaseT::mTree->root().modifyValueAndCache(xyz, op, *
this);
2286 template<
typename ModifyOp>
2289 assert(BaseT::mTree);
2290 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
2291 if (this->isHashed0(xyz)) {
2293 const_cast<NodeT0*
>(mNode0)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
2294 }
else if (this->isHashed1(xyz)) {
2296 const_cast<NodeT1*
>(mNode1)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
2297 }
else if (this->isHashed2(xyz)) {
2299 const_cast<NodeT2*
>(mNode2)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
2301 BaseT::mTree->root().modifyValueAndActiveStateAndCache(xyz, op, *
this);
2308 assert(BaseT::mTree);
2309 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
2310 if (this->isHashed0(xyz)) {
2312 const_cast<NodeT0*
>(mNode0)->setActiveStateAndCache(xyz, on, *
this);
2313 }
else if (this->isHashed1(xyz)) {
2315 const_cast<NodeT1*
>(mNode1)->setActiveStateAndCache(xyz, on, *
this);
2316 }
else if (this->isHashed2(xyz)) {
2318 const_cast<NodeT2*
>(mNode2)->setActiveStateAndCache(xyz, on, *
this);
2320 BaseT::mTree->root().setActiveStateAndCache(xyz, on, *
this);
2324 void setValueOn(
const Coord& xyz) { this->setActiveState(xyz,
true); }
2326 void setValueOff(
const Coord& xyz) { this->setActiveState(xyz,
false); }
2329 template<
typename NodeT>
2332 const NodeT* node = NULL;
2333 this->getNode(node);
2334 return const_cast<NodeT*
>(node);
2339 template<
typename NodeT>
2340 void insertNode(
const Coord& xyz, NodeT& node) { this->insert(xyz, &node); }
2345 template<
typename NodeT>
2348 const NodeT* node = NULL;
2349 this->eraseNode(node);
2356 assert(BaseT::mTree);
2357 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
2358 if (this->isHashed1(leaf->origin())) {
2360 return const_cast<NodeT1*
>(mNode1)->addLeafAndCache(leaf, *
this);
2361 }
else if (this->isHashed2(leaf->origin())) {
2363 return const_cast<NodeT2*
>(mNode2)->addLeafAndCache(leaf, *
this);
2365 BaseT::mTree->root().addLeafAndCache(leaf, *
this);
2370 void addTile(
Index level,
const Coord& xyz,
const ValueType& value,
bool state)
2372 assert(BaseT::mTree);
2373 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
2374 if (this->isHashed1(xyz)) {
2376 return const_cast<NodeT1*
>(mNode1)->addTileAndCache(level, xyz, value, state, *
this);
2377 }
if (this->isHashed2(xyz)) {
2379 return const_cast<NodeT2*
>(mNode2)->addTileAndCache(level, xyz, value, state, *
this);
2381 BaseT::mTree->root().addTileAndCache(level, xyz, value, state, *
this);
2392 assert(BaseT::mTree);
2393 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
2394 if (this->isHashed0(xyz)) {
2396 return const_cast<NodeT0*
>(mNode0);
2397 }
else if (this->isHashed1(xyz)) {
2399 return const_cast<NodeT1*
>(mNode1)->touchLeafAndCache(xyz, *
this);
2400 }
else if (this->isHashed2(xyz)) {
2402 return const_cast<NodeT2*
>(mNode2)->touchLeafAndCache(xyz, *
this);
2404 return BaseT::mTree->root().touchLeafAndCache(xyz, *
this);
2408 template <
typename NodeT>
2411 assert(BaseT::mTree);
2412 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
2414 if ((boost::is_same<NodeT, NodeT0>::value)) {
2415 if (this->isHashed0(xyz)) {
2417 return reinterpret_cast<NodeT*
>(
const_cast<NodeT0*
>(mNode0));
2418 }
else if (this->isHashed1(xyz)) {
2420 return const_cast<NodeT1*
>(mNode1)->
template probeNodeAndCache<NodeT>(xyz, *
this);
2421 }
else if (this->isHashed2(xyz)) {
2423 return const_cast<NodeT2*
>(mNode2)->
template probeNodeAndCache<NodeT>(xyz, *
this);
2425 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
2426 }
else if ((boost::is_same<NodeT, NodeT1>::value)) {
2427 if (this->isHashed1(xyz)) {
2429 return reinterpret_cast<NodeT*
>(
const_cast<NodeT1*
>(mNode1));
2430 }
else if (this->isHashed2(xyz)) {
2432 return const_cast<NodeT2*
>(mNode2)->
template probeNodeAndCache<NodeT>(xyz, *
this);
2434 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
2435 }
else if ((boost::is_same<NodeT, NodeT2>::value)) {
2436 if (this->isHashed2(xyz)) {
2438 return reinterpret_cast<NodeT*
>(
const_cast<NodeT2*
>(mNode2));
2440 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
2447 LeafNodeT*
probeLeaf(
const Coord& xyz) {
return this->
template probeNode<LeafNodeT>(xyz); }
2451 template <
typename NodeT>
2454 assert(BaseT::mTree);
2456 if ((boost::is_same<NodeT, NodeT0>::value)) {
2457 if (this->isHashed0(xyz)) {
2459 return reinterpret_cast<const NodeT*
>(mNode0);
2460 }
else if (this->isHashed1(xyz)) {
2462 return mNode1->template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2463 }
else if (this->isHashed2(xyz)) {
2465 return mNode2->template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2467 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2468 }
else if ((boost::is_same<NodeT, NodeT1>::value)) {
2469 if (this->isHashed1(xyz)) {
2471 return reinterpret_cast<const NodeT*
>(mNode1);
2472 }
else if (this->isHashed2(xyz)) {
2474 return mNode2->template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2476 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2477 }
else if ((boost::is_same<NodeT, NodeT2>::value)) {
2478 if (this->isHashed2(xyz)) {
2480 return reinterpret_cast<const NodeT*
>(mNode2);
2482 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2491 return this->
template probeConstNode<LeafNodeT>(xyz);
2493 const LeafNodeT*
probeLeaf(
const Coord& xyz)
const {
return this->probeConstLeaf(xyz); }
2512 template<
typename>
friend class Tree;
2520 mKey0 = other.mKey0;
2521 mNode0 = other.mNode0;
2522 mKey1 = other.mKey1;
2523 mNode1 = other.mNode1;
2524 mKey2 = other.mKey2;
2525 mNode2 = other.mNode2;
2530 virtual void release()
2532 this->BaseT::release();
2535 void getNode(
const NodeT0*& node) { node = mNode0; }
2536 void getNode(
const NodeT1*& node) { node = mNode1; }
2537 void getNode(
const NodeT2*& node) { node = mNode2; }
2538 void getNode(
const RootNodeT*& node)
2540 node = (BaseT::mTree ? &BaseT::mTree->root() : NULL);
2542 template <
typename OtherNodeType>
void getNode(
const OtherNodeType*& node) { node = NULL; }
2544 void eraseNode(
const NodeT0*) { mKey0 =
Coord::max(); mNode0 = NULL; }
2545 void eraseNode(
const NodeT1*) { mKey1 =
Coord::max(); mNode1 = NULL; }
2546 void eraseNode(
const NodeT2*) { mKey2 =
Coord::max(); mNode2 = NULL; }
2547 template <
typename OtherNodeType>
void eraseNode(
const OtherNodeType*) {}
2553 inline void insert(
const Coord& xyz,
const NodeT0* node)
2556 mKey0 = xyz & ~(NodeT0::DIM-1);
2559 inline void insert(
const Coord& xyz,
const NodeT1* node)
2562 mKey1 = xyz & ~(NodeT1::DIM-1);
2565 inline void insert(
const Coord& xyz,
const NodeT2* node)
2568 mKey2 = xyz & ~(NodeT2::DIM-1);
2573 template<
typename OtherNodeType>
2574 inline void insert(
const Coord&,
const OtherNodeType*)
2577 inline bool isHashed0(
const Coord& xyz)
const
2579 return (xyz[0] & ~Coord::ValueType(NodeT0::DIM-1)) == mKey0[0]
2580 && (xyz[1] & ~Coord::ValueType(NodeT0::DIM-1)) == mKey0[1]
2581 && (xyz[2] & ~Coord::ValueType(NodeT0::DIM-1)) == mKey0[2];
2583 inline bool isHashed1(
const Coord& xyz)
const
2585 return (xyz[0] & ~Coord::ValueType(NodeT1::DIM-1)) == mKey1[0]
2586 && (xyz[1] & ~Coord::ValueType(NodeT1::DIM-1)) == mKey1[1]
2587 && (xyz[2] & ~Coord::ValueType(NodeT1::DIM-1)) == mKey1[2];
2589 inline bool isHashed2(
const Coord& xyz)
const
2591 return (xyz[0] & ~Coord::ValueType(NodeT2::DIM-1)) == mKey2[0]
2592 && (xyz[1] & ~Coord::ValueType(NodeT2::DIM-1)) == mKey2[1]
2593 && (xyz[2] & ~Coord::ValueType(NodeT2::DIM-1)) == mKey2[2];
2595 mutable Coord mKey0;
2596 mutable const NodeT0* mNode0;
2597 mutable Coord mKey1;
2598 mutable const NodeT1* mNode1;
2599 mutable Coord mKey2;
2600 mutable const NodeT2* mNode2;
2607 #endif // OPENVDB_TREE_VALUEACCESSOR_HAS_BEEN_INCLUDED
friend class RootNode
Definition: ValueAccessor.h:401
friend class InternalNode
Definition: ValueAccessor.h:402
void eraseNode()
Definition: ValueAccessor.h:1416
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:746
friend class InternalNode
Definition: ValueAccessor.h:1513
ValueAccessor with no mutex and no node caching.
Definition: ValueAccessor.h:85
const ValueType & getValue(const Coord &xyz)
Definition: ValueAccessor.h:923
virtual ~ValueAccessor()
Definition: ValueAccessor.h:467
TreeType::ValueType ValueType
Definition: ValueAccessor.h:995
NodeT * getNode()
Return the cached node of type NodeType. [Mainly for internal use].
Definition: ValueAccessor.h:1400
bool isCached(const Coord &xyz) const
Definition: ValueAccessor.h:547
NodeT * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:2409
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:328
static Index numCacheLevels()
Return the number of cache levels employed by this ValueAccessor.
Definition: ValueAccessor.h:2100
ValueAccessorBase & operator=(const ValueAccessorBase &other)
Definition: ValueAccessor.h:124
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:1753
bool isVoxel(const Coord &xyz) const
Definition: ValueAccessor.h:2185
virtual ~ValueAccessorBase()
Definition: ValueAccessor.h:109
const NodeT * probeConstNode(const Coord &xyz)
Definition: ValueAccessor.h:664
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:1097
virtual void clear()
Remove all the cached nodes and invalidate the corresponding hash-keys.
Definition: ValueAccessor.h:1967
NodeType * getNode()
Return the cached node of type NodeType. [Mainly for internal use].
Definition: ValueAccessor.h:303
CacheItem(TreeCacheT &parent)
Definition: ValueAccessor.h:823
void getNode(NodeType *&node)
Definition: ValueAccessor.h:574
void erase(const RootNodeType *)
Definition: ValueAccessor.h:841
friend class RootNode
Definition: ValueAccessor.h:1512
int getValueDepth(const Coord &xyz) const
Definition: ValueAccessor.h:1285
ValueAccessor3 & operator=(const ValueAccessor3 &other)
Asignment operator.
Definition: ValueAccessor.h:2090
bool probeValue(const Coord &xyz, ValueType &value)
Return the active state and value of the voxel at the given coordinates.
Definition: ValueAccessor.h:689
void newSetValue(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:258
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: ValueAccessor.h:1394
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:1734
ValueAccessor0 & operator=(const ValueAccessor0 &other)
Definition: ValueAccessor.h:1007
friend class Tree
Definition: ValueAccessor.h:1188
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:1718
static Index numCacheLevels()
Return the number of cache levels employed by this ValueAccessor.
Definition: ValueAccessor.h:1601
_TreeType TreeType
Definition: ValueAccessor.h:178
void setActiveState(const Coord &xyz, bool on)
Definition: ValueAccessor.h:966
friend class LeafNode
Definition: ValueAccessor.h:1979
Value accessor with three levels of node caching.
Definition: ValueAccessor.h:88
virtual ~ValueAccessor()
Definition: ValueAccessor.h:447
LeafNodeT * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1862
virtual ~ValueAccessor()
Definition: ValueAccessor.h:457
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:772
friend class LeafNode
Definition: ValueAccessor.h:403
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:720
boost::mpl::front< NodeVecT >::type NodeType
Definition: ValueAccessor.h:514
void setActiveState(const Coord &xyz, bool on)
Set the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:784
int getValueDepth(const Coord &xyz) const
Definition: ValueAccessor.h:1042
ValueAccessor & operator=(const ValueAccessor &other)
Definition: ValueAccessor.h:193
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:2114
void insertNode(const Coord &xyz, NodeT &node)
Definition: ValueAccessor.h:1410
const NodeT * probeNode(const Coord &xyz) const
Return a pointer to the node of the specified type that contains voxel (x, y, z), or NULL if no such ...
Definition: ValueAccessor.h:369
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: ValueAccessor.h:1112
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:2244
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:2354
friend class Tree
Definition: ValueAccessor.h:1516
TreeType * mTree
Definition: ValueAccessor.h:142
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: ValueAccessor.h:1114
ValueAccessor(TreeType &tree)
Definition: ValueAccessor.h:475
void setValueOnly(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:935
virtual void clear()
Remove all nodes from this cache, then reinsert the root node.
Definition: ValueAccessor.h:392
const NodeT * probeConstLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1909
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active without changing its value.
Definition: ValueAccessor.h:2324
virtual ~ValueAccessor1()
Virtual destructor.
Definition: ValueAccessor.h:1239
const LeafNodeT * probeConstLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1173
void eraseNode()
Definition: ValueAccessor.h:2346
boost::mpl::at< InvTreeT, boost::mpl::int_< L0 > >::type NodeT0
Definition: ValueAccessor.h:1215
const LeafNodeT * probeLeaf(const Coord &xyz) const
Return a pointer to the leaf node that contains voxel (x, y, z), or NULL if no such node exists...
Definition: ValueAccessor.h:388
NodeT * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:648
Definition: ValueAccessor.h:173
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:2287
LeafNodeT * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1475
ValueAccessor1(const ValueAccessor1 &other)
Copy constructor.
Definition: ValueAccessor.h:1223
const LeafNodeT * probeConstLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1497
std::numeric_limits< Int32 > CoordLimits
Definition: ValueAccessor.h:517
void eraseNode()
Definition: ValueAccessor.h:1144
const NodeT * probeConstNode(const Coord &xyz) const
Return a pointer to the node of the specified type that contains voxel (x, y, z), or NULL if no such ...
Definition: ValueAccessor.h:363
const NodeType * probeConstNode(const Coord &xyz)
Definition: ValueAccessor.h:895
RootNodeT::ValueType ValueType
Definition: ValueAccessor.h:181
Index32 Index
Definition: Types.h:56
int getValueDepth(const Coord &xyz) const
Definition: ValueAccessor.h:2167
LeafNodeT * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1168
const NodeT * probeConstNode(const Coord &xyz) const
Definition: ValueAccessor.h:1483
int getValueDepth(const Coord &xyz)
Definition: ValueAccessor.h:901
NodeType::ValueType ValueType
Definition: ValueAccessor.h:515
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:1354
LeafNodeT * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1146
friend class InternalNode
Definition: ValueAccessor.h:2509
void insertNode(const Coord &, NodeT &)
Definition: ValueAccessor.h:1121
ValueAccessor(const ValueAccessor &other)
Definition: ValueAccessor.h:446
TreeType::LeafNodeType LeafNodeT
Definition: ValueAccessor.h:997
RootNodeT::NodeChainType InvTreeT
Definition: ValueAccessor.h:2075
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:1369
const ValueType & getValue(const Coord &xyz)
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:586
bool probeValue(const Coord &xyz, ValueType &value) const
Return the active state of the voxel as well as its value.
Definition: ValueAccessor.h:1272
friend class RootNode
Definition: ValueAccessor.h:1977
int getValueDepth(const Coord &xyz) const
Definition: ValueAccessor.h:1669
void addTile(Index level, const Coord &xyz, const ValueType &value, bool state)
Definition: ValueAccessor.h:606
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:1787
const NodeT * probeConstNode(const Coord &xyz) const
Definition: ValueAccessor.h:1162
const LeafNodeType * probeConstLeaf(const Coord &xyz)
Definition: ValueAccessor.h:638
NodeT * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:1460
NodeT * probeNode(const Coord &xyz)
Return a pointer to the node of the specified type that contains voxel (x, y, z), or NULL if no such ...
Definition: ValueAccessor.h:357
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:2225
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive without changing its value.
Definition: ValueAccessor.h:1804
LeafNodeT * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:2390
int getValueDepth(const Coord &xyz)
Definition: ValueAccessor.h:698
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:291
ValueAccessor(TreeType &tree)
Definition: ValueAccessor.h:465
ValueAccessor1 & operator=(const ValueAccessor1 &other)
Asignment operator.
Definition: ValueAccessor.h:1229
TreeType::LeafNodeType LeafNodeT
Definition: ValueAccessor.h:1212
bool isValueOn(const Coord &xyz) const
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:1261
void setValueOn(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:740
ValueAccessorBase< TreeType > BaseT
Definition: ValueAccessor.h:182
RootNodeType::LeafNodeType LeafNodeType
Definition: ValueAccessor.h:821
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:1033
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:1845
bool isValueOn(const Coord &xyz)
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:679
void insertNode(const Coord &xyz, NodeT &node)
Definition: ValueAccessor.h:1818
ValueAccessor2 & operator=(const ValueAccessor2 &other)
Asignment operator.
Definition: ValueAccessor.h:1604
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:1832
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:210
bool probeValue(const Coord &xyz, ValueType &value)
Definition: ValueAccessor.h:912
bool isVoxel(const Coord &xyz) const
Definition: ValueAccessor.h:1050
CacheItem & copy(TreeCacheT &parent, const CacheItem &other)
Copy another CacheItem's node pointers and hash keys, but not its parent pointer. ...
Definition: ValueAccessor.h:537
bool isValueOn(const Coord &xyz) const
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:1026
ValueAccessor0(const ValueAccessor0 &other)
Definition: ValueAccessor.h:1002
RootNodeT::NodeChainType InvTreeT
Definition: ValueAccessor.h:1214
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:250
virtual void clear()
Remove all the cached nodes and invalidate the corresponding hash-keys.
Definition: ValueAccessor.h:2496
This base class for ValueAccessors manages registration of an accessor with a tree so that the tree c...
Definition: ValueAccessor.h:102
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:1250
void setValue(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:929
ValueAccessor(TreeType &tree)
Definition: ValueAccessor.h:455
bool isCached(const Coord &xyz) const
Definition: ValueAccessor.h:2107
bool isCached(const Coord &xyz) const
Return true if nodes along the path to the given voxel have been cached.
Definition: ValueAccessor.h:207
void eraseNode()
Definition: ValueAccessor.h:1824
boost::mpl::at< InvTreeT, boost::mpl::int_< L0 > >::type NodeT0
Definition: ValueAccessor.h:1589
virtual ~ValueAccessor()
Definition: ValueAccessor.h:201
LeafNodeType * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:628
void insert(const Coord &, const OtherNodeType *)
Definition: ValueAccessor.h:839
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:336
bool isValueOn(const Coord &xyz) const
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:2131
#define OPENVDB_VERSION_NAME
Definition: version.h:45
LeafNodeT * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1904
ValueAccessor3(const ValueAccessor3 &other)
Copy constructor.
Definition: ValueAccessor.h:2087
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:1019
Value accessor with two levels of node caching.
Definition: ValueAccessor.h:87
boost::mpl::at< InvTreeT, boost::mpl::int_< L1 > >::type NodeT1
Definition: ValueAccessor.h:2077
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:1714
virtual ~ValueAccessor3()
Virtual destructor.
Definition: ValueAccessor.h:2103
bool probeValue(const Coord &xyz, ValueType &value) const
Return the active state of the voxel as well as its value.
Definition: ValueAccessor.h:220
TreeType::RootNodeType RootNodeT
Definition: ValueAccessor.h:2072
bool probeValue(const Coord &xyz, ValueType &value) const
Return the active state of the voxel as well as its value.
Definition: ValueAccessor.h:2148
bool isCached(const Coord &) const
Return true if nodes along the path to the given voxel have been cached.
Definition: ValueAccessor.h:1016
TreeType * getTree() const
Return a pointer to the tree associated with this accessor.
Definition: ValueAccessor.h:115
void setValueOnly(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:730
friend class LeafNode
Definition: ValueAccessor.h:1514
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:1087
LeafNodeT * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1446
ValueAccessorBase< TreeType > BaseT
Definition: ValueAccessor.h:1587
const LeafNodeT * probeConstLeaf(const Coord &xyz) const
Return a pointer to the leaf node that contains voxel (x, y, z), or NULL if no such node exists...
Definition: ValueAccessor.h:383
void getNode(const NodeType *&node)
Definition: ValueAccessor.h:573
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:1771
TreeType::LeafNodeType LeafNodeT
Definition: ValueAccessor.h:180
void getNode(const RootNodeType *&node) const
Definition: ValueAccessor.h:850
LeafNodeType * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:873
bool probeValue(const Coord &xyz, ValueType &value) const
Return the active state of the voxel as well as its value.
Definition: ValueAccessor.h:1653
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:1134
friend class RootNode
Definition: ValueAccessor.h:2508
void clear()
Definition: ValueAccessor.h:843
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: ValueAccessor.h:297
NodeT * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:1154
void insert(const Coord &xyz, const OtherNodeType *node)
Forward the given node to another level of the cache.
Definition: ValueAccessor.h:560
bool isVoxel(const Coord &xyz)
Definition: ValueAccessor.h:709
const LeafNodeT * probeLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1501
ValueAccessor2(TreeType &tree)
Constructor from a tree.
Definition: ValueAccessor.h:1593
TreeType::ValueType ValueType
Definition: ValueAccessor.h:1584
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: ValueAccessor.h:299
bool isCached(const Coord &xyz) const
Definition: ValueAccessor.h:833
boost::mpl::front< NodeVecT >::type RootNodeType
Definition: ValueAccessor.h:819
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:1433
void addTile(Index level, const Coord &xyz, const ValueType &value, bool state)
Definition: ValueAccessor.h:859
void insertNode(const Coord &xyz, NodeT &node)
Definition: ValueAccessor.h:2340
ValueAccessor(const ValueAccessor &other)
Definition: ValueAccessor.h:191
virtual void release()
Definition: ValueAccessor.h:140
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:1424
bool isVoxel(const Coord &xyz) const
Definition: ValueAccessor.h:1297
OPENVDB_API Hermite max(const Hermite &, const Hermite &)
min and max operations done directly on the compressed data.
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:284
void addLeaf(LeafNodeType *leaf)
Definition: ValueAccessor.h:595
const LeafNodeT * probeLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1178
RootNodeType::ValueType ValueType
Definition: ValueAccessor.h:820
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:1625
friend class Tree
Definition: ValueAccessor.h:405
CacheItem(TreeCacheT &parent, const CacheItem &other)
Definition: ValueAccessor.h:824
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:1076
ValueAccessor1(TreeType &tree)
Constructor from a tree.
Definition: ValueAccessor.h:1218
const LeafNodeT * probeConstLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1933
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:1068
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:1064
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive without changing its value.
Definition: ValueAccessor.h:2326
void addLeaf(LeafNodeType *leaf)
Definition: ValueAccessor.h:852
void getNode(RootNodeType *&node)
Definition: ValueAccessor.h:845
virtual void clear()
Remove all the cached nodes and invalidate the corresponding hash-keys.
Definition: ValueAccessor.h:1504
TreeType::RootNodeType RootNodeT
Definition: ValueAccessor.h:179
Value accessor with one level of node caching.
Definition: ValueAccessor.h:86
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active without changing its value.
Definition: ValueAccessor.h:1802
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:1338
bool isCached(const Coord &xyz) const
Definition: ValueAccessor.h:1243
CacheItem(TreeCacheT &parent)
Definition: ValueAccessor.h:519
ValueAccessor2(const ValueAccessor2 &other)
Copy constructor.
Definition: ValueAccessor.h:1598
const LeafNodeT * probeConstLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:2489
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:2221
virtual ~ValueAccessor2()
Virtual destructor.
Definition: ValueAccessor.h:1614
_TreeType TreeType
Definition: ValueAccessor.h:1209
ValueAccessorBase< TreeType > BaseT
Definition: ValueAccessor.h:998
void getNode(OtherNodeType *&node)
Forward the request to another level of the cache.
Definition: ValueAccessor.h:583
bool isVoxel(const Coord &xyz) const
Definition: ValueAccessor.h:237
ValueAccessor(TreeType &tree)
Definition: ValueAccessor.h:186
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:1382
NodeT * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:1878
void insert(const Coord &, const RootNodeType *root)
Definition: ValueAccessor.h:835
int getValueDepth(const Coord &xyz) const
Definition: ValueAccessor.h:229
ValueAccessor3(TreeType &tree)
Constructor from a tree.
Definition: ValueAccessor.h:2081
_TreeType TreeType
Definition: ValueAccessor.h:994
ValueAccessorBase< TreeType > BaseT
Definition: ValueAccessor.h:2074
const LeafNodeT * probeLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:2493
TreeType::RootNodeType RootNodeT
Definition: ValueAccessor.h:1211
TreeType::LeafNodeType LeafNodeT
Definition: ValueAccessor.h:1586
void erase(const OtherNodeType *node)
Erase the node at another level of the cache.
Definition: ValueAccessor.h:566
LeafNodeType * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:866
NodeType * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:887
const LeafNodeType * probeConstLeaf(const Coord &xyz)
Definition: ValueAccessor.h:880
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:1105
boost::mpl::at< InvTreeT, boost::mpl::int_< L1 > >::type NodeT1
Definition: ValueAccessor.h:1590
friend class LeafNode
Definition: ValueAccessor.h:2510
friend class InternalNode
Definition: ValueAccessor.h:1978
void getNode(const NodeType *&node) const
Return the cached node (if any) at this level.
Definition: ValueAccessor.h:572
const LeafNodeT * probeLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1937
TreeType::RootNodeType RootNodeT
Definition: ValueAccessor.h:996
TreeType::LeafNodeType LeafNodeT
Definition: ValueAccessor.h:2073
MutexType::scoped_lock LockT
Definition: ValueAccessor.h:183
RootNodeT::NodeChainType InvTreeT
Definition: ValueAccessor.h:1588
TreeType::ValueType ValueType
Definition: ValueAccessor.h:1210
NodeT * getNode()
Return the cached node of type NodeType. [Mainly for internal use].
Definition: ValueAccessor.h:1808
ValueAccessor(const ValueAccessor &other)
Definition: ValueAccessor.h:466
virtual ~ValueAccessor0()
Definition: ValueAccessor.h:1013
const NodeT * probeConstNode(const Coord &xyz) const
Definition: ValueAccessor.h:2452
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:2306
NodeType::LeafNodeType LeafNodeType
Definition: ValueAccessor.h:516
bool isValueOn(const Coord &xyz)
Definition: ValueAccessor.h:906
void modifyValue(const Coord &xyz, const ModifyOp &op)
Definition: ValueAccessor.h:944
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:2266
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:1125
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:265
void insertNode(const Coord &xyz, NodeType &node)
Definition: ValueAccessor.h:314
void eraseNode()
Definition: ValueAccessor.h:324
ValueAccessor(const ValueAccessor &other)
Definition: ValueAccessor.h:456
void erase(const NodeType *)
Erase the node at this level.
Definition: ValueAccessor.h:563
bool isVoxel(const Coord &xyz) const
Definition: ValueAccessor.h:1684
ValueAccessorRW(TreeType &tree)
Definition: ValueAccessor.h:495
This accessor is thread-safe (at the cost of speed) for both reading and writing to a tree...
Definition: ValueAccessor.h:493
void setValueOn(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:941
void clear()
Erase the nodes at this and lower levels of the cache.
Definition: ValueAccessor.h:569
virtual ~ValueAccessor()
Definition: ValueAccessor.h:477
CacheItem & copy(TreeCacheT &parent, const CacheItem &other)
Definition: ValueAccessor.h:826
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:2370
NodeT * getNode()
Return the cached node of type NodeType. [Mainly for internal use].
Definition: ValueAccessor.h:2330
bool isValueOn(const Coord &xyz) const
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:217
const NodeT * probeConstNode(const Coord &xyz) const
Definition: ValueAccessor.h:1942
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:67
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:275
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:1325
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:1321
static Index numCacheLevels()
Return the number of cache levels employed by this ValueAccessor.
Definition: ValueAccessor.h:1226
_TreeType TreeType
Definition: ValueAccessor.h:2070
Definition: ValueAccessor.h:89
virtual void clear()
Remove all nodes from this cache, then reinsert the root node.
Definition: ValueAccessor.h:1184
TreeType::ValueType ValueType
Definition: ValueAccessor.h:2071
LeafNodeType * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:618
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:246
bool isCached(const Coord &xyz) const
Definition: ValueAccessor.h:1618
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:760
bool isVoxel(const Coord &xyz)
Definition: ValueAccessor.h:917
friend class Tree
Definition: ValueAccessor.h:1981
static Index numCacheLevels()
Return the number of cache levels employed by this accessor.
Definition: ValueAccessor.h:1005
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: ValueAccessor.h:1396
boost::mpl::at< InvTreeT, boost::mpl::int_< L0 > >::type NodeT0
Definition: ValueAccessor.h:2076
ValueAccessorBase(const ValueAccessorBase &other)
Definition: ValueAccessor.h:119
_TreeType TreeType
Definition: ValueAccessor.h:1583
ValueAccessorBase< TreeType > BaseT
Definition: ValueAccessor.h:1213
TreeType & tree() const
Return a reference to the tree associated with this accessor.
Definition: ValueAccessor.h:117
bool isValueOn(const Coord &xyz) const
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:1639
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Definition: ValueAccessor.h:952
static Index numCacheLevels()
Return the number of cache levels employed by this accessor.
Definition: ValueAccessor.h:204
LeafNodeT * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:2447
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:347
ValueAccessor(TreeType &tree)
Definition: ValueAccessor.h:445
friend class Tree
Definition: ValueAccessor.h:2512
boost::mpl::at< InvTreeT, boost::mpl::int_< L2 > >::type NodeT2
Definition: ValueAccessor.h:2078
ValueAccessor0(TreeType &tree)
Definition: ValueAccessor.h:1000
TreeType::RootNodeType RootNodeT
Definition: ValueAccessor.h:1585
NodeT * getNode()
Return the cached node of type NodeType. [Mainly for internal use].
Definition: ValueAccessor.h:1117
ValueAccessor(const ValueAccessor &other)
Definition: ValueAccessor.h:476
ValueAccessorBase(TreeType &tree)
Definition: ValueAccessor.h:107
void setValueOff(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:959
void insert(const Coord &xyz, const NodeType *node)
Cache the given node at this level.
Definition: ValueAccessor.h:553