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> 86 template<
typename TreeType,
bool IsSafe = true>
88 template<
typename TreeType,
bool IsSafe = true, Index L0 = 0>
90 template<
typename TreeType,
bool IsSafe = true, Index L0 = 0, Index L1 = 1>
92 template<
typename TreeType,
bool IsSafe = true, Index L0 = 0, Index L1 = 1, Index L2 = 2>
94 template<
typename TreeCacheT,
typename NodeVecT,
bool AtRoot>
class CacheItem;
120 template<
typename TreeType,
bool IsSafe>
124 static const bool IsConstTree = boost::is_const<TreeType>::value;
136 if (IsSafe) tree.attachAccessor(*
this);
147 TreeType&
tree()
const { assert(mTree);
return *mTree; }
151 if (IsSafe && mTree) mTree->attachAccessor(*
this);
156 if (&other !=
this) {
157 if (IsSafe && mTree) mTree->releaseAccessor(*
this);
159 if (IsSafe && mTree) mTree->attachAccessor(*
this);
164 virtual void clear() = 0;
168 template<
typename>
friend class Tree;
215 template<
typename _TreeType,
217 Index CacheLevels = _TreeType::DEPTH-1,
218 typename MutexType = tbb::null_mutex>
222 BOOST_STATIC_ASSERT(CacheLevels < _TreeType::DEPTH);
229 typedef typename MutexType::scoped_lock
LockT;
230 using BaseT::IsConstTree;
234 mCache.insert(Coord(), &tree.root());
241 if (&other !=
this) {
242 this->BaseT::operator=(other);
243 mCache.copy(*
this, other.mCache);
253 bool isCached(
const Coord& xyz)
const { LockT lock(mMutex);
return mCache.isCached(xyz); }
259 return mCache.getValue(xyz);
263 bool isValueOn(
const Coord& xyz)
const { LockT lock(mMutex);
return mCache.isValueOn(xyz); }
269 return mCache.probeValue(xyz,value);
278 return mCache.getValueDepth(xyz);
283 bool isVoxel(
const Coord& xyz)
const { LockT lock(mMutex);
return mCache.isVoxel(xyz); }
286 void setValue(
const Coord& xyz,
const ValueType& value)
290 mCache.setValue(xyz, value);
292 void setValueOn(
const Coord& xyz,
const ValueType& value) { this->setValue(xyz, value); }
299 mCache.setValueOnly(xyz, value);
307 mCache.newSetValue(xyz, value);
314 mCache.setValueOff(xyz, value);
320 template<
typename ModifyOp>
324 mCache.modifyValue(xyz, op);
329 template<
typename ModifyOp>
333 mCache.modifyValueAndActiveState(xyz, op);
340 mCache.setActiveState(xyz, on);
343 void setValueOn(
const Coord& xyz) { this->setActiveState(xyz,
true); }
345 void setValueOff(
const Coord& xyz) { this->setActiveState(xyz,
false); }
348 template<
typename NodeType>
352 NodeType* node = NULL;
353 mCache.getNode(node);
359 template<
typename NodeType>
363 mCache.insert(xyz, &node);
369 template<
typename NodeType>
370 void eraseNode() { LockT lock(mMutex); NodeType* node = NULL; mCache.erase(node); }
377 mCache.addLeaf(leaf);
382 void addTile(
Index level,
const Coord& xyz,
const ValueType& value,
bool state)
385 mCache.addTile(level, xyz, value, state);
396 return mCache.touchLeaf(xyz);
400 template<
typename NodeT>
406 return mCache.template probeNode<NodeT>(xyz);
408 template<
typename NodeT>
412 return mCache.template probeConstNode<NodeT>(xyz);
414 template<
typename NodeT>
417 return this->
template probeConstNode<NodeT>(xyz);
422 LeafNodeT* probeLeaf(
const Coord& xyz)
427 return mCache.probeLeaf(xyz);
432 return mCache.probeConstLeaf(xyz);
434 const LeafNodeT*
probeLeaf(
const Coord& xyz)
const {
return this->probeConstLeaf(xyz); }
442 if (this->mTree) mCache.insert(Coord(), &(this->mTree->root()));
451 template<
typename>
friend class Tree;
455 virtual void release()
458 this->BaseT::release();
466 template<
typename NodeType>
467 void insert(
const Coord& xyz, NodeType* node) { mCache.insert(xyz, node); }
470 typedef typename RootNodeT::NodeChainType InvTreeT;
472 typedef typename boost::mpl::begin<InvTreeT>::type BeginT;
473 typedef typename boost::mpl::advance<BeginT,boost::mpl::int_<CacheLevels> >::type FirstT;
474 typedef typename boost::mpl::find<InvTreeT, RootNodeT>::type LastT;
475 typedef typename boost::mpl::erase<InvTreeT,FirstT,LastT>::type SubtreeT;
480 mutable MutexType mMutex;
488 template<
typename TreeType,
bool IsSafe>
500 template<
typename TreeType,
bool IsSafe>
512 template<
typename TreeType,
bool IsSafe>
524 template<
typename TreeType,
bool IsSafe>
546 template<
typename TreeType,
bool IsSafe = true>
565 template<
typename TreeCacheT,
typename NodeVecT,
bool AtRoot>
569 typedef typename boost::mpl::front<NodeVecT>::type
NodeType;
576 mHash(CoordLimits::
max()),
588 mNext(parent, other.mNext)
597 mNext.copy(parent, other.mNext);
604 return (this->isHashed(xyz) || mNext.isCached(xyz));
608 void insert(
const Coord& xyz,
const NodeType* node)
610 mHash = (node != NULL) ? xyz & ~(NodeType::DIM-1) :
Coord::max();
614 template<
typename OtherNodeType>
615 void insert(
const Coord& xyz,
const OtherNodeType* node) { mNext.insert(xyz, node); }
620 template<
typename OtherNodeType>
621 void erase(
const OtherNodeType* node) { mNext.erase(node); }
627 void getNode(
const NodeType*& node)
const { node = mNode; }
628 void getNode(
const NodeType*& node) { node = mNode; }
633 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
634 node =
const_cast<NodeType*
>(mNode);
637 template<
typename OtherNodeType>
638 void getNode(OtherNodeType*& node) { mNext.getNode(node); }
643 if (this->isHashed(xyz)) {
645 return mNode->getValueAndCache(xyz, *mParent);
647 return mNext.getValue(xyz);
652 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
653 if (NodeType::LEVEL == 0)
return;
654 if (this->isHashed(leaf->origin())) {
656 return const_cast<NodeType*
>(mNode)->addLeafAndCache(leaf, *mParent);
661 void addTile(
Index level,
const Coord& xyz,
const ValueType& value,
bool state)
663 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
664 if (NodeType::LEVEL < level)
return;
665 if (this->isHashed(xyz)) {
667 return const_cast<NodeType*
>(mNode)->addTileAndCache(
668 level, xyz, value, state, *mParent);
670 mNext.addTile(level, xyz, value, state);
675 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
676 if (this->isHashed(xyz)) {
678 return const_cast<NodeType*
>(mNode)->touchLeafAndCache(xyz, *mParent);
680 return mNext.touchLeaf(xyz);
685 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
686 if (this->isHashed(xyz)) {
688 return const_cast<NodeType*
>(mNode)->probeLeafAndCache(xyz, *mParent);
690 return mNext.probeLeaf(xyz);
695 if (this->isHashed(xyz)) {
697 return mNode->probeConstLeafAndCache(xyz, *mParent);
699 return mNext.probeConstLeaf(xyz);
702 template<
typename NodeT>
705 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
707 if (this->isHashed(xyz)) {
708 if ((boost::is_same<NodeT, NodeType>::value)) {
710 return reinterpret_cast<NodeT*
>(
const_cast<NodeType*
>(mNode));
712 return const_cast<NodeType*
>(mNode)->
template probeNodeAndCache<NodeT>(xyz, *mParent);
714 return mNext.template probeNode<NodeT>(xyz);
718 template<
typename NodeT>
722 if (this->isHashed(xyz)) {
723 if ((boost::is_same<NodeT, NodeType>::value)) {
725 return reinterpret_cast<const NodeT*
>(mNode);
727 return mNode->template probeConstNodeAndCache<NodeT>(xyz, *mParent);
729 return mNext.template probeConstNode<NodeT>(xyz);
736 if (this->isHashed(xyz)) {
738 return mNode->isValueOnAndCache(xyz, *mParent);
740 return mNext.isValueOn(xyz);
746 if (this->isHashed(xyz)) {
748 return mNode->probeValueAndCache(xyz, value, *mParent);
750 return mNext.probeValue(xyz, value);
755 if (this->isHashed(xyz)) {
757 return static_cast<int>(TreeCacheT::RootNodeT::LEVEL) -
758 static_cast<int>(mNode->getValueLevelAndCache(xyz, *mParent));
760 return mNext.getValueDepth(xyz);
766 if (this->isHashed(xyz)) {
768 return mNode->getValueLevelAndCache(xyz, *mParent)==0;
770 return mNext.isVoxel(xyz);
775 void setValue(
const Coord& xyz,
const ValueType& value)
777 if (this->isHashed(xyz)) {
779 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
780 const_cast<NodeType*
>(mNode)->setValueAndCache(xyz, value, *mParent);
782 mNext.setValue(xyz, value);
787 if (this->isHashed(xyz)) {
789 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
790 const_cast<NodeType*
>(mNode)->setValueOnlyAndCache(xyz, value, *mParent);
792 mNext.setValueOnly(xyz, value);
795 void setValueOn(
const Coord& xyz,
const ValueType& value) { this->setValue(xyz, value); }
800 template<
typename ModifyOp>
803 if (this->isHashed(xyz)) {
805 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
806 const_cast<NodeType*
>(mNode)->modifyValueAndCache(xyz, op, *mParent);
808 mNext.modifyValue(xyz, op);
814 template<
typename ModifyOp>
817 if (this->isHashed(xyz)) {
819 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
820 const_cast<NodeType*
>(mNode)->modifyValueAndActiveStateAndCache(xyz, op, *mParent);
822 mNext.modifyValueAndActiveState(xyz, op);
829 if (this->isHashed(xyz)) {
831 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
832 const_cast<NodeType*
>(mNode)->setValueOffAndCache(xyz, value, *mParent);
834 mNext.setValueOff(xyz, value);
841 if (this->isHashed(xyz)) {
843 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
844 const_cast<NodeType*
>(mNode)->setActiveStateAndCache(xyz, on, *mParent);
846 mNext.setActiveState(xyz, on);
854 bool isHashed(
const Coord& xyz)
const 856 return (xyz[0] & ~Coord::ValueType(NodeType::DIM-1)) == mHash[0]
857 && (xyz[1] & ~Coord
::ValueType(NodeType::DIM-1)) == mHash[1]
858 && (xyz[2] & ~Coord::ValueType(NodeType::DIM-1)) == mHash[2];
863 const NodeType* mNode;
864 typedef typename boost::mpl::pop_front<NodeVecT>::type RestT;
865 CacheItem<TreeCacheT, RestT, boost::mpl::size<RestT>::value == 1> mNext;
870 template<
typename TreeCacheT,
typename NodeVecT>
878 CacheItem(TreeCacheT& parent): mParent(&parent), mRoot(NULL) {}
888 bool isCached(
const Coord& xyz)
const {
return this->isHashed(xyz); }
890 void insert(
const Coord&,
const RootNodeType* root) { mRoot = root; }
893 template <
typename OtherNodeType>
894 void insert(
const Coord&,
const OtherNodeType*) {}
896 void erase(
const RootNodeType*) { mRoot = NULL; }
902 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
903 node =
const_cast<RootNodeType*
>(mRoot);
905 void getNode(
const RootNodeType*& node)
const { node = mRoot; }
910 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
911 const_cast<RootNodeType*
>(mRoot)->addLeafAndCache(leaf, *mParent);
914 void addTile(
Index level,
const Coord& xyz,
const ValueType& value,
bool state)
917 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
918 const_cast<RootNodeType*
>(mRoot)->addTileAndCache(level, xyz, value, state, *mParent);
924 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
925 return const_cast<RootNodeType*
>(mRoot)->touchLeafAndCache(xyz, *mParent);
931 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
932 return const_cast<RootNodeType*
>(mRoot)->probeLeafAndCache(xyz, *mParent);
938 return mRoot->probeConstLeafAndCache(xyz, *mParent);
941 template<
typename NodeType>
945 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
946 return const_cast<RootNodeType*
>(mRoot)->
template probeNodeAndCache<NodeType>(xyz, *mParent);
949 template<
typename NodeType>
953 return mRoot->template probeConstNodeAndCache<NodeType>(xyz, *mParent);
959 return mRoot->getValueDepthAndCache(xyz, *mParent);
964 return mRoot->isValueOnAndCache(xyz, *mParent);
970 return mRoot->probeValueAndCache(xyz, value, *mParent);
975 return mRoot->getValueDepthAndCache(xyz, *mParent) ==
976 static_cast<int>(RootNodeType::LEVEL);
981 return mRoot->getValueAndCache(xyz, *mParent);
984 void setValue(
const Coord& xyz,
const ValueType& value)
987 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
988 const_cast<RootNodeType*
>(mRoot)->setValueAndCache(xyz, value, *mParent);
993 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
994 const_cast<RootNodeType*
>(mRoot)->setValueOnlyAndCache(xyz, value, *mParent);
996 void setValueOn(
const Coord& xyz,
const ValueType& value) { this->setValue(xyz, value); }
998 template<
typename ModifyOp>
1002 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
1003 const_cast<RootNodeType*
>(mRoot)->modifyValueAndCache(xyz, op, *mParent);
1006 template<
typename ModifyOp>
1010 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
1011 const_cast<RootNodeType*
>(mRoot)->modifyValueAndActiveStateAndCache(xyz, op, *mParent);
1017 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
1018 const_cast<RootNodeType*
>(mRoot)->setValueOffAndCache(xyz, value, *mParent);
1024 BOOST_STATIC_ASSERT(!TreeCacheT::IsConstTree);
1025 const_cast<RootNodeType*
>(mRoot)->setActiveStateAndCache(xyz, on, *mParent);
1032 bool isHashed(
const Coord&)
const {
return false; }
1034 TreeCacheT* mParent;
1035 const RootNodeType* mRoot;
1045 template<
typename _TreeType,
bool IsSafe>
1064 if (&other !=
this) this->BaseT::operator=(other);
1076 assert(BaseT::mTree);
1077 return BaseT::mTree->getValue(xyz);
1083 assert(BaseT::mTree);
1084 return BaseT::mTree->isValueOn(xyz);
1090 assert(BaseT::mTree);
1091 return BaseT::mTree->probeValue(xyz, value);
1099 assert(BaseT::mTree);
1100 return BaseT::mTree->getValueDepth(xyz);
1107 assert(BaseT::mTree);
1108 return BaseT::mTree->getValueDepth(xyz) ==
static_cast<int>(RootNodeT::LEVEL);
1112 void setValue(
const Coord& xyz,
const ValueType& value)
1115 assert(BaseT::mTree);
1116 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1117 BaseT::mTree->setValue(xyz, value);
1119 void setValueOn(
const Coord& xyz,
const ValueType& value) { this->setValue(xyz, value); }
1125 assert(BaseT::mTree);
1126 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1127 BaseT::mTree->setValueOnly(xyz, value);
1133 assert(BaseT::mTree);
1134 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1135 BaseT::mTree->root().setValueOff(xyz, value);
1141 template<
typename ModifyOp>
1144 assert(BaseT::mTree);
1145 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1146 BaseT::mTree->modifyValue(xyz, op);
1151 template<
typename ModifyOp>
1154 assert(BaseT::mTree);
1155 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1156 BaseT::mTree->modifyValueAndActiveState(xyz, op);
1162 assert(BaseT::mTree);
1163 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1164 BaseT::mTree->setActiveState(xyz, on);
1167 void setValueOn(
const Coord& xyz) { this->setActiveState(xyz,
true); }
1169 void setValueOff(
const Coord& xyz) { this->setActiveState(xyz,
false); }
1172 template<
typename NodeT> NodeT*
getNode() {
return NULL; }
1176 template<
typename NodeT>
void insertNode(
const Coord&, NodeT&) {}
1182 assert(BaseT::mTree);
1183 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1184 BaseT::mTree->root().addLeaf(leaf);
1189 void addTile(
Index level,
const Coord& xyz,
const ValueType& value,
bool state)
1191 assert(BaseT::mTree);
1192 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1193 BaseT::mTree->root().addTile(level, xyz, value, state);
1203 assert(BaseT::mTree);
1204 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1205 return BaseT::mTree->touchLeaf(xyz);
1208 template <
typename NodeT>
1211 assert(BaseT::mTree);
1212 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1213 return BaseT::mTree->template probeNode<NodeT>(xyz);
1216 template <
typename NodeT>
1219 assert(BaseT::mTree);
1220 return BaseT::mTree->template probeConstNode<NodeT>(xyz);
1225 return this->
template probeNode<LeafNodeT>(xyz);
1230 return this->
template probeConstNode<LeafNodeT>(xyz);
1235 return this->probeConstLeaf(xyz);
1243 template<
typename>
friend class Tree;
1247 virtual void release() { this->BaseT::release(); }
1258 template<
typename _TreeType,
bool IsSafe, Index L0>
1262 BOOST_STATIC_ASSERT(_TreeType::DEPTH >= 2);
1263 BOOST_STATIC_ASSERT( L0 < _TreeType::RootNodeType::LEVEL );
1270 typedef typename boost::mpl::at<InvTreeT, boost::mpl::int_<L0> >::type
NodeT0;
1286 if (&other !=
this) {
1287 this->BaseT::operator=(other);
1300 assert(BaseT::mTree);
1301 return this->isHashed(xyz);
1307 assert(BaseT::mTree);
1308 if (this->isHashed(xyz)) {
1310 return mNode0->getValueAndCache(xyz, this->
self());
1312 return BaseT::mTree->root().getValueAndCache(xyz, this->
self());
1318 assert(BaseT::mTree);
1319 if (this->isHashed(xyz)) {
1321 return mNode0->isValueOnAndCache(xyz, this->
self());
1323 return BaseT::mTree->root().isValueOnAndCache(xyz, this->
self());
1329 assert(BaseT::mTree);
1330 if (this->isHashed(xyz)) {
1332 return mNode0->probeValueAndCache(xyz, value, this->
self());
1334 return BaseT::mTree->root().probeValueAndCache(xyz, value, this->
self());
1342 assert(BaseT::mTree);
1343 if (this->isHashed(xyz)) {
1345 return RootNodeT::LEVEL - mNode0->getValueLevelAndCache(xyz, this->
self());
1347 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->
self());
1354 assert(BaseT::mTree);
1355 if (this->isHashed(xyz)) {
1357 return mNode0->getValueLevelAndCache(xyz, this->
self()) == 0;
1359 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->
self()) ==
1360 static_cast<int>(RootNodeT::LEVEL);
1364 void setValue(
const Coord& xyz,
const ValueType& value)
1367 assert(BaseT::mTree);
1368 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1369 if (this->isHashed(xyz)) {
1371 const_cast<NodeT0*
>(mNode0)->setValueAndCache(xyz, value, *
this);
1373 BaseT::mTree->root().setValueAndCache(xyz, value, *
this);
1376 void setValueOn(
const Coord& xyz,
const ValueType& value) { this->setValue(xyz, value); }
1382 assert(BaseT::mTree);
1383 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1384 if (this->isHashed(xyz)) {
1386 const_cast<NodeT0*
>(mNode0)->setValueOnlyAndCache(xyz, value, *
this);
1388 BaseT::mTree->root().setValueOnlyAndCache(xyz, value, *
this);
1395 assert(BaseT::mTree);
1396 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1397 if (this->isHashed(xyz)) {
1399 const_cast<NodeT0*
>(mNode0)->setValueOffAndCache(xyz, value, *
this);
1401 BaseT::mTree->root().setValueOffAndCache(xyz, value, *
this);
1408 template<
typename ModifyOp>
1411 assert(BaseT::mTree);
1412 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1413 if (this->isHashed(xyz)) {
1415 const_cast<NodeT0*
>(mNode0)->modifyValueAndCache(xyz, op, *
this);
1417 BaseT::mTree->root().modifyValueAndCache(xyz, op, *
this);
1423 template<
typename ModifyOp>
1426 assert(BaseT::mTree);
1427 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1428 if (this->isHashed(xyz)) {
1430 const_cast<NodeT0*
>(mNode0)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
1432 BaseT::mTree->root().modifyValueAndActiveStateAndCache(xyz, op, *
this);
1439 assert(BaseT::mTree);
1440 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1441 if (this->isHashed(xyz)) {
1443 const_cast<NodeT0*
>(mNode0)->setActiveStateAndCache(xyz, on, *
this);
1445 BaseT::mTree->root().setActiveStateAndCache(xyz, on, *
this);
1449 void setValueOn(
const Coord& xyz) { this->setActiveState(xyz,
true); }
1451 void setValueOff(
const Coord& xyz) { this->setActiveState(xyz,
false); }
1454 template<
typename NodeT>
1457 const NodeT* node = NULL;
1458 this->getNode(node);
1459 return const_cast<NodeT*
>(node);
1464 template<
typename NodeT>
1465 void insertNode(
const Coord& xyz, NodeT& node) { this->insert(xyz, &node); }
1470 template<
typename NodeT>
1473 const NodeT* node = NULL;
1474 this->eraseNode(node);
1481 assert(BaseT::mTree);
1482 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1483 BaseT::mTree->root().addLeaf(leaf);
1488 void addTile(
Index level,
const Coord& xyz,
const ValueType& value,
bool state)
1490 assert(BaseT::mTree);
1491 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1492 BaseT::mTree->root().addTile(level, xyz, value, state);
1503 assert(BaseT::mTree);
1504 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1505 if (this->isHashed(xyz)) {
1507 return const_cast<NodeT0*
>(mNode0)->touchLeafAndCache(xyz, *
this);
1509 return BaseT::mTree->root().touchLeafAndCache(xyz, *
this);
1514 template <
typename NodeT>
1517 assert(BaseT::mTree);
1518 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1520 if ((boost::is_same<NodeT, NodeT0>::value)) {
1521 if (this->isHashed(xyz)) {
1523 return reinterpret_cast<NodeT*
>(
const_cast<NodeT0*
>(mNode0));
1525 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
1532 return this->
template probeNode<LeafNodeT>(xyz);
1537 template <
typename NodeT>
1540 assert(BaseT::mTree);
1542 if ((boost::is_same<NodeT, NodeT0>::value)) {
1543 if (this->isHashed(xyz)) {
1545 return reinterpret_cast<const NodeT*
>(mNode0);
1547 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
1554 return this->
template probeConstNode<LeafNodeT>(xyz);
1556 const LeafNodeT*
probeLeaf(
const Coord& xyz)
const {
return this->probeConstLeaf(xyz); }
1571 template<
typename>
friend class Tree;
1576 void getNode(
const NodeT0*& node) { node = mNode0; }
1577 void getNode(
const RootNodeT*& node)
1579 node = (BaseT::mTree ? &BaseT::mTree->root() : NULL);
1581 template <
typename OtherNodeType>
void getNode(
const OtherNodeType*& node) { node = NULL; }
1582 void eraseNode(
const NodeT0*) { mKey0 =
Coord::max(); mNode0 = NULL; }
1583 template <
typename OtherNodeType>
void eraseNode(
const OtherNodeType*) {}
1588 mKey0 = other.mKey0;
1589 mNode0 = other.mNode0;
1594 virtual void release()
1596 this->BaseT::release();
1603 inline void insert(
const Coord& xyz,
const NodeT0* node)
1606 mKey0 = xyz & ~(NodeT0::DIM-1);
1612 template<
typename OtherNodeType>
inline void insert(
const Coord&,
const OtherNodeType*) {}
1614 inline bool isHashed(
const Coord& xyz)
const 1616 return (xyz[0] & ~Coord::ValueType(NodeT0::DIM-1)) == mKey0[0]
1617 && (xyz[1] & ~Coord
::ValueType(NodeT0::DIM-1)) == mKey0[1]
1618 && (xyz[2] & ~Coord::ValueType(NodeT0::DIM-1)) == mKey0[2];
1620 mutable Coord mKey0;
1621 mutable const NodeT0* mNode0;
1632 template<
typename _TreeType,
bool IsSafe, Index L0, Index L1>
1636 BOOST_STATIC_ASSERT(_TreeType::DEPTH >= 3);
1637 BOOST_STATIC_ASSERT( L0 < L1 && L1 < _TreeType::RootNodeType::LEVEL );
1644 typedef typename boost::mpl::at<InvTreeT, boost::mpl::int_<L0> >::type
NodeT0;
1645 typedef typename boost::mpl::at<InvTreeT, boost::mpl::int_<L1> >::type
NodeT1;
1649 mKey0(Coord::
max()), mNode0(NULL),
1650 mKey1(Coord::
max()), mNode1(NULL) {}
1661 if (&other !=
this) {
1662 this->BaseT::operator=(other);
1675 assert(BaseT::mTree);
1676 return this->isHashed1(xyz) || this->isHashed0(xyz);
1682 assert(BaseT::mTree);
1683 if (this->isHashed0(xyz)) {
1685 return mNode0->getValueAndCache(xyz, this->
self());
1686 }
else if (this->isHashed1(xyz)) {
1688 return mNode1->getValueAndCache(xyz, this->
self());
1690 return BaseT::mTree->root().getValueAndCache(xyz, this->
self());
1696 assert(BaseT::mTree);
1697 if (this->isHashed0(xyz)) {
1699 return mNode0->isValueOnAndCache(xyz, this->
self());
1700 }
else if (this->isHashed1(xyz)) {
1702 return mNode1->isValueOnAndCache(xyz, this->
self());
1704 return BaseT::mTree->root().isValueOnAndCache(xyz, this->
self());
1710 assert(BaseT::mTree);
1711 if (this->isHashed0(xyz)) {
1713 return mNode0->probeValueAndCache(xyz, value, this->
self());
1714 }
else if (this->isHashed1(xyz)) {
1716 return mNode1->probeValueAndCache(xyz, value, this->
self());
1718 return BaseT::mTree->root().probeValueAndCache(xyz, value, this->
self());
1726 assert(BaseT::mTree);
1727 if (this->isHashed0(xyz)) {
1729 return RootNodeT::LEVEL - mNode0->getValueLevelAndCache(xyz, this->
self());
1730 }
else if (this->isHashed1(xyz)) {
1732 return RootNodeT::LEVEL - mNode1->getValueLevelAndCache(xyz, this->
self());
1734 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->
self());
1741 assert(BaseT::mTree);
1742 if (this->isHashed0(xyz)) {
1744 return mNode0->getValueLevelAndCache(xyz, this->
self())==0;
1745 }
else if (this->isHashed1(xyz)) {
1747 return mNode1->getValueLevelAndCache(xyz, this->
self())==0;
1749 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->
self()) ==
1750 static_cast<int>(RootNodeT::LEVEL);
1754 void setValue(
const Coord& xyz,
const ValueType& value)
1757 assert(BaseT::mTree);
1758 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1759 if (this->isHashed0(xyz)) {
1761 const_cast<NodeT0*
>(mNode0)->setValueAndCache(xyz, value, *
this);
1762 }
else if (this->isHashed1(xyz)) {
1764 const_cast<NodeT1*
>(mNode1)->setValueAndCache(xyz, value, *
this);
1766 BaseT::mTree->root().setValueAndCache(xyz, value, *
this);
1769 void setValueOn(
const Coord& xyz,
const ValueType& value) { this->setValue(xyz, value); }
1775 assert(BaseT::mTree);
1776 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1777 if (this->isHashed0(xyz)) {
1779 const_cast<NodeT0*
>(mNode0)->setValueOnlyAndCache(xyz, value, *
this);
1780 }
else if (this->isHashed1(xyz)) {
1782 const_cast<NodeT1*
>(mNode1)->setValueOnlyAndCache(xyz, value, *
this);
1784 BaseT::mTree->root().setValueOnlyAndCache(xyz, value, *
this);
1791 assert(BaseT::mTree);
1792 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1793 if (this->isHashed0(xyz)) {
1795 const_cast<NodeT0*
>(mNode0)->setValueOffAndCache(xyz, value, *
this);
1796 }
else if (this->isHashed1(xyz)) {
1798 const_cast<NodeT1*
>(mNode1)->setValueOffAndCache(xyz, value, *
this);
1800 BaseT::mTree->root().setValueOffAndCache(xyz, value, *
this);
1807 template<
typename ModifyOp>
1810 assert(BaseT::mTree);
1811 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1812 if (this->isHashed0(xyz)) {
1814 const_cast<NodeT0*
>(mNode0)->modifyValueAndCache(xyz, op, *
this);
1815 }
else if (this->isHashed1(xyz)) {
1817 const_cast<NodeT1*
>(mNode1)->modifyValueAndCache(xyz, op, *
this);
1819 BaseT::mTree->root().modifyValueAndCache(xyz, op, *
this);
1825 template<
typename ModifyOp>
1828 assert(BaseT::mTree);
1829 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1830 if (this->isHashed0(xyz)) {
1832 const_cast<NodeT0*
>(mNode0)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
1833 }
else if (this->isHashed1(xyz)) {
1835 const_cast<NodeT1*
>(mNode1)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
1837 BaseT::mTree->root().modifyValueAndActiveStateAndCache(xyz, op, *
this);
1844 assert(BaseT::mTree);
1845 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1846 if (this->isHashed0(xyz)) {
1848 const_cast<NodeT0*
>(mNode0)->setActiveStateAndCache(xyz, on, *
this);
1849 }
else if (this->isHashed1(xyz)) {
1851 const_cast<NodeT1*
>(mNode1)->setActiveStateAndCache(xyz, on, *
this);
1853 BaseT::mTree->root().setActiveStateAndCache(xyz, on, *
this);
1857 void setValueOn(
const Coord& xyz) { this->setActiveState(xyz,
true); }
1859 void setValueOff(
const Coord& xyz) { this->setActiveState(xyz,
false); }
1862 template<
typename NodeT>
1865 const NodeT* node = NULL;
1866 this->getNode(node);
1867 return const_cast<NodeT*
>(node);
1872 template<
typename NodeT>
1873 void insertNode(
const Coord& xyz, NodeT& node) { this->insert(xyz, &node); }
1878 template<
typename NodeT>
1881 const NodeT* node = NULL;
1882 this->eraseNode(node);
1889 assert(BaseT::mTree);
1890 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1891 if (this->isHashed1(leaf->origin())) {
1893 return const_cast<NodeT1*
>(mNode1)->addLeafAndCache(leaf, *
this);
1895 BaseT::mTree->root().addLeafAndCache(leaf, *
this);
1900 void addTile(
Index level,
const Coord& xyz,
const ValueType& value,
bool state)
1902 assert(BaseT::mTree);
1903 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1904 if (this->isHashed1(xyz)) {
1906 return const_cast<NodeT1*
>(mNode1)->addTileAndCache(level, xyz, value, state, *
this);
1908 BaseT::mTree->root().addTileAndCache(level, xyz, value, state, *
this);
1919 assert(BaseT::mTree);
1920 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1921 if (this->isHashed0(xyz)) {
1923 return const_cast<NodeT0*
>(mNode0)->touchLeafAndCache(xyz, *
this);
1924 }
else if (this->isHashed1(xyz)) {
1926 return const_cast<NodeT1*
>(mNode1)->touchLeafAndCache(xyz, *
this);
1928 return BaseT::mTree->root().touchLeafAndCache(xyz, *
this);
1932 template <
typename NodeT>
1935 assert(BaseT::mTree);
1936 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
1938 if ((boost::is_same<NodeT, NodeT0>::value)) {
1939 if (this->isHashed0(xyz)) {
1941 return reinterpret_cast<NodeT*
>(
const_cast<NodeT0*
>(mNode0));
1942 }
else if (this->isHashed1(xyz)) {
1944 return const_cast<NodeT1*
>(mNode1)->
template probeNodeAndCache<NodeT>(xyz, *
this);
1946 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
1947 }
else if ((boost::is_same<NodeT, NodeT1>::value)) {
1948 if (this->isHashed1(xyz)) {
1950 return reinterpret_cast<NodeT*
>(
const_cast<NodeT1*
>(mNode1));
1952 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
1959 LeafNodeT*
probeLeaf(
const Coord& xyz) {
return this->
template probeNode<LeafNodeT>(xyz); }
1963 template <
typename NodeT>
1967 if ((boost::is_same<NodeT, NodeT0>::value)) {
1968 if (this->isHashed0(xyz)) {
1970 return reinterpret_cast<const NodeT*
>(mNode0);
1971 }
else if (this->isHashed1(xyz)) {
1973 return mNode1->template probeConstNodeAndCache<NodeT>(xyz, this->
self());
1975 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
1976 }
else if ((boost::is_same<NodeT, NodeT1>::value)) {
1977 if (this->isHashed1(xyz)) {
1979 return reinterpret_cast<const NodeT*
>(mNode1);
1981 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
1990 return this->
template probeConstNode<LeafNodeT>(xyz);
1992 const LeafNodeT*
probeLeaf(
const Coord& xyz)
const {
return this->probeConstLeaf(xyz); }
1996 template <
typename NodeT>
1999 assert(BaseT::mTree);
2001 if ((boost::is_same<NodeT, NodeT0>::value)) {
2002 if (this->isHashed0(xyz)) {
2004 return reinterpret_cast<const NodeT*
>(mNode0);
2005 }
else if (this->isHashed1(xyz)) {
2007 return mNode1->template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2009 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2010 }
else if ((boost::is_same<NodeT, NodeT1>::value)) {
2011 if (this->isHashed1(xyz)) {
2013 return reinterpret_cast<const NodeT*
>(mNode1);
2015 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2036 template<
typename>
friend class Tree;
2041 void getNode(
const NodeT0*& node) { node = mNode0; }
2042 void getNode(
const NodeT1*& node) { node = mNode1; }
2043 void getNode(
const RootNodeT*& node)
2045 node = (BaseT::mTree ? &BaseT::mTree->root() : NULL);
2047 template <
typename OtherNodeType>
void getNode(
const OtherNodeType*& node) { node = NULL; }
2049 void eraseNode(
const NodeT0*) { mKey0 =
Coord::max(); mNode0 = NULL; }
2050 void eraseNode(
const NodeT1*) { mKey1 =
Coord::max(); mNode1 = NULL; }
2051 template <
typename OtherNodeType>
void eraseNode(
const OtherNodeType*) {}
2056 mKey0 = other.mKey0;
2057 mNode0 = other.mNode0;
2058 mKey1 = other.mKey1;
2059 mNode1 = other.mNode1;
2064 virtual void release()
2066 this->BaseT::release();
2074 inline void insert(
const Coord& xyz,
const NodeT0* node)
2077 mKey0 = xyz & ~(NodeT0::DIM-1);
2080 inline void insert(
const Coord& xyz,
const NodeT1* node)
2083 mKey1 = xyz & ~(NodeT1::DIM-1);
2088 template<
typename NodeT>
inline void insert(
const Coord&,
const NodeT*) {}
2090 inline bool isHashed0(
const Coord& xyz)
const 2092 return (xyz[0] & ~Coord::ValueType(NodeT0::DIM-1)) == mKey0[0]
2093 && (xyz[1] & ~Coord
::ValueType(NodeT0::DIM-1)) == mKey0[1]
2094 && (xyz[2] & ~Coord::ValueType(NodeT0::DIM-1)) == mKey0[2];
2096 inline bool isHashed1(
const Coord& xyz)
const 2098 return (xyz[0] & ~Coord::ValueType(NodeT1::DIM-1)) == mKey1[0]
2099 && (xyz[1] & ~Coord
::ValueType(NodeT1::DIM-1)) == mKey1[1]
2100 && (xyz[2] & ~Coord::ValueType(NodeT1::DIM-1)) == mKey1[2];
2102 mutable Coord mKey0;
2103 mutable const NodeT0* mNode0;
2104 mutable Coord mKey1;
2105 mutable const NodeT1* mNode1;
2119 template<
typename _TreeType,
bool IsSafe, Index L0, Index L1, Index L2>
2123 BOOST_STATIC_ASSERT(_TreeType::DEPTH >= 4);
2124 BOOST_STATIC_ASSERT(L0 < L1 && L1 < L2 && L2 < _TreeType::RootNodeType::LEVEL);
2131 typedef typename boost::mpl::at<InvTreeT, boost::mpl::int_<L0> >::type
NodeT0;
2132 typedef typename boost::mpl::at<InvTreeT, boost::mpl::int_<L1> >::type
NodeT1;
2133 typedef typename boost::mpl::at<InvTreeT, boost::mpl::int_<L2> >::type
NodeT2;
2137 mKey0(Coord::
max()), mNode0(NULL),
2138 mKey1(Coord::
max()), mNode1(NULL),
2139 mKey2(Coord::
max()), mNode2(NULL) {}
2147 if (&other !=
this) {
2148 this->BaseT::operator=(other);
2164 assert(BaseT::mTree);
2165 return this->isHashed2(xyz) || this->isHashed1(xyz) || this->isHashed0(xyz);
2171 assert(BaseT::mTree);
2172 if (this->isHashed0(xyz)) {
2174 return mNode0->getValueAndCache(xyz, this->
self());
2175 }
else if (this->isHashed1(xyz)) {
2177 return mNode1->getValueAndCache(xyz, this->
self());
2178 }
else if (this->isHashed2(xyz)) {
2180 return mNode2->getValueAndCache(xyz, this->
self());
2182 return BaseT::mTree->root().getValueAndCache(xyz, this->
self());
2188 assert(BaseT::mTree);
2189 if (this->isHashed0(xyz)) {
2191 return mNode0->isValueOnAndCache(xyz, this->
self());
2192 }
else if (this->isHashed1(xyz)) {
2194 return mNode1->isValueOnAndCache(xyz, this->
self());
2195 }
else if (this->isHashed2(xyz)) {
2197 return mNode2->isValueOnAndCache(xyz, this->
self());
2199 return BaseT::mTree->root().isValueOnAndCache(xyz, this->
self());
2205 assert(BaseT::mTree);
2206 if (this->isHashed0(xyz)) {
2208 return mNode0->probeValueAndCache(xyz, value, this->
self());
2209 }
else if (this->isHashed1(xyz)) {
2211 return mNode1->probeValueAndCache(xyz, value, this->
self());
2212 }
else if (this->isHashed2(xyz)) {
2214 return mNode2->probeValueAndCache(xyz, value, this->
self());
2216 return BaseT::mTree->root().probeValueAndCache(xyz, value, this->
self());
2224 assert(BaseT::mTree);
2225 if (this->isHashed0(xyz)) {
2227 return RootNodeT::LEVEL - mNode0->getValueLevelAndCache(xyz, this->
self());
2228 }
else if (this->isHashed1(xyz)) {
2230 return RootNodeT::LEVEL - mNode1->getValueLevelAndCache(xyz, this->
self());
2231 }
else if (this->isHashed2(xyz)) {
2233 return RootNodeT::LEVEL - mNode2->getValueLevelAndCache(xyz, this->
self());
2235 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->
self());
2242 assert(BaseT::mTree);
2243 if (this->isHashed0(xyz)) {
2245 return mNode0->getValueLevelAndCache(xyz, this->
self())==0;
2246 }
else if (this->isHashed1(xyz)) {
2248 return mNode1->getValueLevelAndCache(xyz, this->
self())==0;
2249 }
else if (this->isHashed2(xyz)) {
2251 return mNode2->getValueLevelAndCache(xyz, this->
self())==0;
2253 return BaseT::mTree->root().getValueDepthAndCache(xyz, this->
self()) ==
2254 static_cast<int>(RootNodeT::LEVEL);
2258 void setValue(
const Coord& xyz,
const ValueType& value)
2261 assert(BaseT::mTree);
2262 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
2263 if (this->isHashed0(xyz)) {
2265 const_cast<NodeT0*
>(mNode0)->setValueAndCache(xyz, value, *
this);
2266 }
else if (this->isHashed1(xyz)) {
2268 const_cast<NodeT1*
>(mNode1)->setValueAndCache(xyz, value, *
this);
2269 }
else if (this->isHashed2(xyz)) {
2271 const_cast<NodeT2*
>(mNode2)->setValueAndCache(xyz, value, *
this);
2273 BaseT::mTree->root().setValueAndCache(xyz, value, *
this);
2276 void setValueOn(
const Coord& xyz,
const ValueType& value) { this->setValue(xyz, value); }
2282 assert(BaseT::mTree);
2283 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
2284 if (this->isHashed0(xyz)) {
2286 const_cast<NodeT0*
>(mNode0)->setValueOnlyAndCache(xyz, value, *
this);
2287 }
else if (this->isHashed1(xyz)) {
2289 const_cast<NodeT1*
>(mNode1)->setValueOnlyAndCache(xyz, value, *
this);
2290 }
else if (this->isHashed2(xyz)) {
2292 const_cast<NodeT2*
>(mNode2)->setValueOnlyAndCache(xyz, value, *
this);
2294 BaseT::mTree->root().setValueOnlyAndCache(xyz, value, *
this);
2301 assert(BaseT::mTree);
2302 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
2303 if (this->isHashed0(xyz)) {
2305 const_cast<NodeT0*
>(mNode0)->setValueOffAndCache(xyz, value, *
this);
2306 }
else if (this->isHashed1(xyz)) {
2308 const_cast<NodeT1*
>(mNode1)->setValueOffAndCache(xyz, value, *
this);
2309 }
else if (this->isHashed2(xyz)) {
2311 const_cast<NodeT2*
>(mNode2)->setValueOffAndCache(xyz, value, *
this);
2313 BaseT::mTree->root().setValueOffAndCache(xyz, value, *
this);
2320 template<
typename ModifyOp>
2323 assert(BaseT::mTree);
2324 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
2325 if (this->isHashed0(xyz)) {
2327 const_cast<NodeT0*
>(mNode0)->modifyValueAndCache(xyz, op, *
this);
2328 }
else if (this->isHashed1(xyz)) {
2330 const_cast<NodeT1*
>(mNode1)->modifyValueAndCache(xyz, op, *
this);
2331 }
else if (this->isHashed2(xyz)) {
2333 const_cast<NodeT2*
>(mNode2)->modifyValueAndCache(xyz, op, *
this);
2335 BaseT::mTree->root().modifyValueAndCache(xyz, op, *
this);
2341 template<
typename ModifyOp>
2344 assert(BaseT::mTree);
2345 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
2346 if (this->isHashed0(xyz)) {
2348 const_cast<NodeT0*
>(mNode0)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
2349 }
else if (this->isHashed1(xyz)) {
2351 const_cast<NodeT1*
>(mNode1)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
2352 }
else if (this->isHashed2(xyz)) {
2354 const_cast<NodeT2*
>(mNode2)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
2356 BaseT::mTree->root().modifyValueAndActiveStateAndCache(xyz, op, *
this);
2363 assert(BaseT::mTree);
2364 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
2365 if (this->isHashed0(xyz)) {
2367 const_cast<NodeT0*
>(mNode0)->setActiveStateAndCache(xyz, on, *
this);
2368 }
else if (this->isHashed1(xyz)) {
2370 const_cast<NodeT1*
>(mNode1)->setActiveStateAndCache(xyz, on, *
this);
2371 }
else if (this->isHashed2(xyz)) {
2373 const_cast<NodeT2*
>(mNode2)->setActiveStateAndCache(xyz, on, *
this);
2375 BaseT::mTree->root().setActiveStateAndCache(xyz, on, *
this);
2379 void setValueOn(
const Coord& xyz) { this->setActiveState(xyz,
true); }
2381 void setValueOff(
const Coord& xyz) { this->setActiveState(xyz,
false); }
2384 template<
typename NodeT>
2387 const NodeT* node = NULL;
2388 this->getNode(node);
2389 return const_cast<NodeT*
>(node);
2394 template<
typename NodeT>
2395 void insertNode(
const Coord& xyz, NodeT& node) { this->insert(xyz, &node); }
2400 template<
typename NodeT>
2403 const NodeT* node = NULL;
2404 this->eraseNode(node);
2411 assert(BaseT::mTree);
2412 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
2413 if (this->isHashed1(leaf->origin())) {
2415 return const_cast<NodeT1*
>(mNode1)->addLeafAndCache(leaf, *
this);
2416 }
else if (this->isHashed2(leaf->origin())) {
2418 return const_cast<NodeT2*
>(mNode2)->addLeafAndCache(leaf, *
this);
2420 BaseT::mTree->root().addLeafAndCache(leaf, *
this);
2425 void addTile(
Index level,
const Coord& xyz,
const ValueType& value,
bool state)
2427 assert(BaseT::mTree);
2428 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
2429 if (this->isHashed1(xyz)) {
2431 return const_cast<NodeT1*
>(mNode1)->addTileAndCache(level, xyz, value, state, *
this);
2432 }
if (this->isHashed2(xyz)) {
2434 return const_cast<NodeT2*
>(mNode2)->addTileAndCache(level, xyz, value, state, *
this);
2436 BaseT::mTree->root().addTileAndCache(level, xyz, value, state, *
this);
2447 assert(BaseT::mTree);
2448 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
2449 if (this->isHashed0(xyz)) {
2451 return const_cast<NodeT0*
>(mNode0);
2452 }
else if (this->isHashed1(xyz)) {
2454 return const_cast<NodeT1*
>(mNode1)->touchLeafAndCache(xyz, *
this);
2455 }
else if (this->isHashed2(xyz)) {
2457 return const_cast<NodeT2*
>(mNode2)->touchLeafAndCache(xyz, *
this);
2459 return BaseT::mTree->root().touchLeafAndCache(xyz, *
this);
2463 template <
typename NodeT>
2466 assert(BaseT::mTree);
2467 BOOST_STATIC_ASSERT(!BaseT::IsConstTree);
2469 if ((boost::is_same<NodeT, NodeT0>::value)) {
2470 if (this->isHashed0(xyz)) {
2472 return reinterpret_cast<NodeT*
>(
const_cast<NodeT0*
>(mNode0));
2473 }
else if (this->isHashed1(xyz)) {
2475 return const_cast<NodeT1*
>(mNode1)->
template probeNodeAndCache<NodeT>(xyz, *
this);
2476 }
else if (this->isHashed2(xyz)) {
2478 return const_cast<NodeT2*
>(mNode2)->
template probeNodeAndCache<NodeT>(xyz, *
this);
2480 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
2481 }
else if ((boost::is_same<NodeT, NodeT1>::value)) {
2482 if (this->isHashed1(xyz)) {
2484 return reinterpret_cast<NodeT*
>(
const_cast<NodeT1*
>(mNode1));
2485 }
else if (this->isHashed2(xyz)) {
2487 return const_cast<NodeT2*
>(mNode2)->
template probeNodeAndCache<NodeT>(xyz, *
this);
2489 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
2490 }
else if ((boost::is_same<NodeT, NodeT2>::value)) {
2491 if (this->isHashed2(xyz)) {
2493 return reinterpret_cast<NodeT*
>(
const_cast<NodeT2*
>(mNode2));
2495 return BaseT::mTree->root().template probeNodeAndCache<NodeT>(xyz, *
this);
2502 LeafNodeT*
probeLeaf(
const Coord& xyz) {
return this->
template probeNode<LeafNodeT>(xyz); }
2506 template <
typename NodeT>
2509 assert(BaseT::mTree);
2511 if ((boost::is_same<NodeT, NodeT0>::value)) {
2512 if (this->isHashed0(xyz)) {
2514 return reinterpret_cast<const NodeT*
>(mNode0);
2515 }
else if (this->isHashed1(xyz)) {
2517 return mNode1->template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2518 }
else if (this->isHashed2(xyz)) {
2520 return mNode2->template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2522 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2523 }
else if ((boost::is_same<NodeT, NodeT1>::value)) {
2524 if (this->isHashed1(xyz)) {
2526 return reinterpret_cast<const NodeT*
>(mNode1);
2527 }
else if (this->isHashed2(xyz)) {
2529 return mNode2->template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2531 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2532 }
else if ((boost::is_same<NodeT, NodeT2>::value)) {
2533 if (this->isHashed2(xyz)) {
2535 return reinterpret_cast<const NodeT*
>(mNode2);
2537 return BaseT::mTree->root().template probeConstNodeAndCache<NodeT>(xyz, this->
self());
2546 return this->
template probeConstNode<LeafNodeT>(xyz);
2548 const LeafNodeT*
probeLeaf(
const Coord& xyz)
const {
return this->probeConstLeaf(xyz); }
2567 template<
typename>
friend class Tree;
2575 mKey0 = other.mKey0;
2576 mNode0 = other.mNode0;
2577 mKey1 = other.mKey1;
2578 mNode1 = other.mNode1;
2579 mKey2 = other.mKey2;
2580 mNode2 = other.mNode2;
2585 virtual void release()
2587 this->BaseT::release();
2590 void getNode(
const NodeT0*& node) { node = mNode0; }
2591 void getNode(
const NodeT1*& node) { node = mNode1; }
2592 void getNode(
const NodeT2*& node) { node = mNode2; }
2593 void getNode(
const RootNodeT*& node)
2595 node = (BaseT::mTree ? &BaseT::mTree->root() : NULL);
2597 template <
typename OtherNodeType>
void getNode(
const OtherNodeType*& node) { node = NULL; }
2599 void eraseNode(
const NodeT0*) { mKey0 =
Coord::max(); mNode0 = NULL; }
2600 void eraseNode(
const NodeT1*) { mKey1 =
Coord::max(); mNode1 = NULL; }
2601 void eraseNode(
const NodeT2*) { mKey2 =
Coord::max(); mNode2 = NULL; }
2602 template <
typename OtherNodeType>
void eraseNode(
const OtherNodeType*) {}
2608 inline void insert(
const Coord& xyz,
const NodeT0* node)
2611 mKey0 = xyz & ~(NodeT0::DIM-1);
2614 inline void insert(
const Coord& xyz,
const NodeT1* node)
2617 mKey1 = xyz & ~(NodeT1::DIM-1);
2620 inline void insert(
const Coord& xyz,
const NodeT2* node)
2623 mKey2 = xyz & ~(NodeT2::DIM-1);
2628 template<
typename OtherNodeType>
2629 inline void insert(
const Coord&,
const OtherNodeType*)
2632 inline bool isHashed0(
const Coord& xyz)
const 2634 return (xyz[0] & ~Coord::ValueType(NodeT0::DIM-1)) == mKey0[0]
2635 && (xyz[1] & ~Coord
::ValueType(NodeT0::DIM-1)) == mKey0[1]
2636 && (xyz[2] & ~Coord::ValueType(NodeT0::DIM-1)) == mKey0[2];
2638 inline bool isHashed1(
const Coord& xyz)
const 2640 return (xyz[0] & ~Coord::ValueType(NodeT1::DIM-1)) == mKey1[0]
2641 && (xyz[1] & ~Coord
::ValueType(NodeT1::DIM-1)) == mKey1[1]
2642 && (xyz[2] & ~Coord::ValueType(NodeT1::DIM-1)) == mKey1[2];
2644 inline bool isHashed2(
const Coord& xyz)
const 2646 return (xyz[0] & ~Coord::ValueType(NodeT2::DIM-1)) == mKey2[0]
2647 && (xyz[1] & ~Coord
::ValueType(NodeT2::DIM-1)) == mKey2[1]
2648 && (xyz[2] & ~Coord::ValueType(NodeT2::DIM-1)) == mKey2[2];
2650 mutable Coord mKey0;
2651 mutable const NodeT0* mNode0;
2652 mutable Coord mKey1;
2653 mutable const NodeT1* mNode1;
2654 mutable Coord mKey2;
2655 mutable const NodeT2* mNode2;
2662 #endif // OPENVDB_TREE_VALUEACCESSOR_HAS_BEEN_INCLUDED void setValue(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:984
TreeType::LeafNodeType LeafNodeT
Definition: ValueAccessor.h:226
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:2299
ValueAccessor2(TreeType &tree)
Constructor from a tree.
Definition: ValueAccessor.h:1648
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:2409
friend class InternalNode
Definition: ValueAccessor.h:448
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:374
Index32 Index
Definition: Types.h:58
CacheItem(TreeCacheT &parent)
Definition: ValueAccessor.h:878
LeafNodeT * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1223
const LeafNodeT * probeLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1992
RootNodeType::ValueType ValueType
Definition: ValueAccessor.h:875
NodeT * getNode()
Return the cached node of type NodeType. [Mainly for internal use].
Definition: ValueAccessor.h:1863
const LeafNodeT * probeConstLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1228
ValueAccessor with no mutex and no node caching.
Definition: ValueAccessor.h:87
ValueAccessor(TreeType &tree)
Definition: ValueAccessor.h:517
NodeT * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:1933
ValueAccessor0(const ValueAccessor0 &other)
Definition: ValueAccessor.h:1057
virtual void clear()
Remove all the cached nodes and invalidate the corresponding hash-keys.
Definition: ValueAccessor.h:2551
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: ValueAccessor.h:1451
boost::mpl::at< InvTreeT, boost::mpl::int_< L0 > >::type NodeT0
Definition: ValueAccessor.h:2131
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:2321
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:2342
void addLeaf(LeafNodeType *leaf)
Definition: ValueAccessor.h:907
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:1119
NodeType * getNode()
Return the cached node of type NodeType. [Mainly for internal use].
Definition: ValueAccessor.h:349
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:2425
NodeT * getNode()
Return the cached node of type NodeType. [Mainly for internal use].
Definition: ValueAccessor.h:2385
void insert(const Coord &xyz, const OtherNodeType *node)
Forward the given node to another level of the cache.
Definition: ValueAccessor.h:615
const LeafNodeT * probeConstLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1552
ValueAccessorBase< TreeType, IsSafe > BaseT
Definition: ValueAccessor.h:1053
void setActiveState(const Coord &xyz, bool on)
Definition: ValueAccessor.h:1021
bool isVoxel(const Coord &xyz)
Definition: ValueAccessor.h:764
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:1380
friend class LeafNode
Definition: ValueAccessor.h:449
friend class LeafNode
Definition: ValueAccessor.h:2565
TreeType::RootNodeType RootNodeT
Definition: ValueAccessor.h:1640
TreeType TreeType
Definition: ValueAccessor.h:2125
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:2276
void clear()
Definition: ValueAccessor.h:898
const NodeT * probeConstNode(const Coord &xyz) const
Definition: ValueAccessor.h:1538
Value accessor with three levels of node caching.
Definition: ValueAccessor.h:93
ValueAccessor(const ValueAccessor &other)
Definition: ValueAccessor.h:237
ValueAccessor(TreeType &tree)
Definition: ValueAccessor.h:505
void insertNode(const Coord &xyz, NodeT &node)
Definition: ValueAccessor.h:1873
RootNodeT::NodeChainType InvTreeT
Definition: ValueAccessor.h:1643
friend class RootNode
Definition: ValueAccessor.h:447
ValueAccessor(const ValueAccessor &other)
Definition: ValueAccessor.h:530
virtual ~ValueAccessor0()
Definition: ValueAccessor.h:1068
CacheItem(TreeCacheT &parent)
Definition: ValueAccessor.h:574
LeafNodeT * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1201
TreeType::ValueType ValueType
Definition: ValueAccessor.h:1639
void getNode(OtherNodeType *&node)
Forward the request to another level of the cache.
Definition: ValueAccessor.h:638
void eraseNode()
Definition: ValueAccessor.h:1471
TreeType::LeafNodeType LeafNodeT
Definition: ValueAccessor.h:1052
void addLeaf(LeafNodeType *leaf)
Definition: ValueAccessor.h:650
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:1424
TreeType TreeType
Definition: ValueAccessor.h:1638
ValueAccessor(const ValueAccessor &other)
Definition: ValueAccessor.h:494
NodeType * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:942
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:1842
const NodeT * probeConstNode(const Coord &xyz) const
Definition: ValueAccessor.h:1217
ValueAccessorBase(const ValueAccessorBase &other)
Definition: ValueAccessor.h:149
const LeafNodeType * probeConstLeaf(const Coord &xyz)
Definition: ValueAccessor.h:935
TreeType & tree() const
Return a reference to the tree associated with this accessor.
Definition: ValueAccessor.h:147
LeafNodeT * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:2445
TreeType::LeafNodeType LeafNodeT
Definition: ValueAccessor.h:1267
bool isValueOn(const Coord &xyz) const
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:1316
bool isVoxel(const Coord &xyz) const
Definition: ValueAccessor.h:2240
void setValueOnly(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:990
LeafNodeT * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1959
ValueAccessor3(const ValueAccessor3 &other)
Copy constructor.
Definition: ValueAccessor.h:2142
bool isCached(const Coord &xyz) const
Definition: ValueAccessor.h:888
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:330
NodeT * getNode()
Return the cached node of type NodeType. [Mainly for internal use].
Definition: ValueAccessor.h:1172
int getValueDepth(const Coord &xyz)
Definition: ValueAccessor.h:956
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:1887
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:409
bool isValueOn(const Coord &xyz)
Definition: ValueAccessor.h:961
void modifyValue(const Coord &xyz, const ModifyOp &op)
Definition: ValueAccessor.h:999
const NodeType * probeConstNode(const Coord &xyz)
Definition: ValueAccessor.h:950
void getNode(RootNodeType *&node)
Definition: ValueAccessor.h:900
bool isValueOn(const Coord &xyz) const
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:1081
void setValueOn(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:996
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:321
void eraseNode()
Definition: ValueAccessor.h:370
NodeT * getNode()
Return the cached node of type NodeType. [Mainly for internal use].
Definition: ValueAccessor.h:1455
virtual ~ValueAccessor2()
Virtual destructor.
Definition: ValueAccessor.h:1669
bool isCached(const Coord &xyz) const
Definition: ValueAccessor.h:2162
int getValueDepth(const Coord &xyz) const
Definition: ValueAccessor.h:275
NodeType::LeafNodeType LeafNodeType
Definition: ValueAccessor.h:571
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: ValueAccessor.h:1169
void erase(const OtherNodeType *node)
Erase the node at another level of the cache.
Definition: ValueAccessor.h:621
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:1808
void clear()
Erase the nodes at this and lower levels of the cache.
Definition: ValueAccessor.h:624
bool isValueOn(const Coord &xyz) const
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:2186
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:296
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:1376
void insertNode(const Coord &xyz, NodeType &node)
Definition: ValueAccessor.h:360
friend class RootNode
Definition: ValueAccessor.h:1567
boost::mpl::at< InvTreeT, boost::mpl::int_< L1 > >::type NodeT1
Definition: ValueAccessor.h:2132
ValueAccessorBase< TreeType, IsSafe > BaseT
Definition: ValueAccessor.h:228
bool probeValue(const Coord &xyz, ValueType &value)
Definition: ValueAccessor.h:967
bool isVoxel(const Coord &xyz)
Definition: ValueAccessor.h:972
void eraseNode()
Definition: ValueAccessor.h:2401
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:434
virtual void clear()
Remove all the cached nodes and invalidate the corresponding hash-keys.
Definition: ValueAccessor.h:1559
boost::mpl::at< InvTreeT, boost::mpl::int_< L0 > >::type NodeT0
Definition: ValueAccessor.h:1270
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:1773
void getNode(const NodeType *&node) const
Return the cached node (if any) at this level.
Definition: ValueAccessor.h:627
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:292
ValueAccessorRW(TreeType &tree)
Definition: ValueAccessor.h:550
RootNodeType::LeafNodeType LeafNodeType
Definition: ValueAccessor.h:876
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active without changing its value.
Definition: ValueAccessor.h:1857
void insertNode(const Coord &xyz, NodeT &node)
Definition: ValueAccessor.h:2395
ValueAccessorBase & operator=(const ValueAccessorBase &other)
Definition: ValueAccessor.h:154
MutexType::scoped_lock LockT
Definition: ValueAccessor.h:229
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:2169
ValueAccessorBase(TreeType &tree)
Definition: ValueAccessor.h:134
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:815
LeafNodeT * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1501
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:256
TreeType::ValueType ValueType
Definition: ValueAccessor.h:1265
void erase(const NodeType *)
Erase the node at this level.
Definition: ValueAccessor.h:618
NodeT * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:2464
void eraseNode()
Definition: ValueAccessor.h:1199
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:1826
LeafNodeType * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:921
ValueAccessor3(TreeType &tree)
Constructor from a tree.
Definition: ValueAccessor.h:2136
int getValueDepth(const Coord &xyz) const
Definition: ValueAccessor.h:1340
virtual ~ValueAccessor1()
Virtual destructor.
Definition: ValueAccessor.h:1294
void insert(const Coord &, const OtherNodeType *)
Definition: ValueAccessor.h:894
friend class LeafNode
Definition: ValueAccessor.h:2034
static Index numCacheLevels()
Return the number of cache levels employed by this ValueAccessor.
Definition: ValueAccessor.h:1281
#define OPENVDB_VERSION_NAME
Definition: version.h:43
LeafNodeType * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:673
virtual void release()
Definition: ValueAccessor.h:170
ValueAccessor2(const ValueAccessor2 &other)
Copy constructor.
Definition: ValueAccessor.h:1653
friend class InternalNode
Definition: ValueAccessor.h:2033
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:1479
bool isValueOn(const Coord &xyz) const
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:263
int getValueDepth(const Coord &xyz) const
Definition: ValueAccessor.h:1097
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:403
TreeType::ValueType ValueType
Definition: ValueAccessor.h:2126
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive without changing its value.
Definition: ValueAccessor.h:1859
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:801
Value accessor with two levels of node caching.
Definition: ValueAccessor.h:91
void newSetValue(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:304
static Index numCacheLevels()
Return the number of cache levels employed by this accessor.
Definition: ValueAccessor.h:1060
bool isCached(const Coord &xyz) const
Definition: ValueAccessor.h:602
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:1131
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: ValueAccessor.h:343
const LeafNodeT * probeConstLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1988
bool isCached(const Coord &xyz) const
Return true if nodes along the path to the given voxel have been cached.
Definition: ValueAccessor.h:253
void getNode(NodeType *&node)
Definition: ValueAccessor.h:629
bool isVoxel(const Coord &xyz) const
Definition: ValueAccessor.h:1105
virtual ~ValueAccessor()
Definition: ValueAccessor.h:247
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:1409
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:429
ValueAccessor & operator=(const ValueAccessor &other)
Definition: ValueAccessor.h:239
ValueAccessor0 & operator=(const ValueAccessor0 &other)
Definition: ValueAccessor.h:1062
void getNode(const RootNodeType *&node) const
Definition: ValueAccessor.h:905
_TreeType TreeType
Definition: ValueAccessor.h:224
bool probeValue(const Coord &xyz, ValueType &value)
Return the active state and value of the voxel at the given coordinates.
Definition: ValueAccessor.h:744
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:1393
void insert(const Coord &xyz, const NodeType *node)
Cache the given node at this level.
Definition: ValueAccessor.h:608
bool isCached(const Coord &xyz) const
Definition: ValueAccessor.h:1298
void addTile(Index level, const Coord &xyz, const ValueType &value, bool state)
Definition: ValueAccessor.h:914
friend class RootNode
Definition: ValueAccessor.h:2032
virtual ~ValueAccessor()
Definition: ValueAccessor.h:531
const LeafNodeT * probeConstLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:2544
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:827
Definition: Exceptions.h:39
void eraseNode()
Definition: ValueAccessor.h:1879
virtual void clear()
Remove all nodes from this cache, then reinsert the root node.
Definition: ValueAccessor.h:1239
boost::mpl::at< InvTreeT, boost::mpl::int_< L0 > >::type NodeT0
Definition: ValueAccessor.h:1644
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:2280
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:382
TreeType::RootNodeType RootNodeT
Definition: ValueAccessor.h:225
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: ValueAccessor.h:345
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:1437
virtual ~ValueAccessorBase()
Definition: ValueAccessor.h:139
void setActiveState(const Coord &xyz, bool on)
Set the active state of the voxel at the given coordinates.
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:1900
int getValueDepth(const Coord &xyz) const
Definition: ValueAccessor.h:2222
TreeType::ValueType ValueType
Definition: ValueAccessor.h:1050
ValueAccessor2 & operator=(const ValueAccessor2 &other)
Asignment operator.
Definition: ValueAccessor.h:1659
virtual ~ValueAccessor3()
Virtual destructor.
Definition: ValueAccessor.h:2158
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:415
TreeType::LeafNodeType LeafNodeT
Definition: ValueAccessor.h:1641
TreeType::RootNodeType RootNodeT
Definition: ValueAccessor.h:2127
const NodeT * probeConstNode(const Coord &xyz)
Definition: ValueAccessor.h:719
static Index numCacheLevels()
Return the number of cache levels employed by this ValueAccessor.
Definition: ValueAccessor.h:2155
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:1160
RootNodeT::NodeChainType InvTreeT
Definition: ValueAccessor.h:2130
bool isCached(const Coord &) const
Return true if nodes along the path to the given voxel have been cached.
Definition: ValueAccessor.h:1071
ValueAccessorBase< TreeType, IsSafe > BaseT
Definition: ValueAccessor.h:1642
CacheItem(TreeCacheT &parent, const CacheItem &other)
Definition: ValueAccessor.h:879
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:1305
boost::mpl::at< InvTreeT, boost::mpl::int_< L1 > >::type NodeT1
Definition: ValueAccessor.h:1645
virtual void clear()
Remove all nodes from this cache, then reinsert the root node.
Definition: ValueAccessor.h:438
int getValueDepth(const Coord &xyz) const
Definition: ValueAccessor.h:1724
NodeT * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:1515
TreeType::LeafNodeType LeafNodeT
Definition: ValueAccessor.h:2128
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:393
TreeType * mTree
Definition: ValueAccessor.h:172
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:775
const ValueType & getValue(const Coord &xyz)
Definition: ValueAccessor.h:978
const NodeT * probeConstNode(const Coord &xyz) const
Definition: ValueAccessor.h:2507
ValueAccessor(TreeType &tree)
Definition: ValueAccessor.h:493
static Index numCacheLevels()
Return the number of cache levels employed by this ValueAccessor.
Definition: ValueAccessor.h:1656
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:2361
boost::mpl::front< NodeVecT >::type NodeType
Definition: ValueAccessor.h:569
ValueAccessor(TreeType &tree)
Definition: ValueAccessor.h:232
friend class Tree
Definition: ValueAccessor.h:2036
Definition: ValueAccessor.h:94
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:1074
friend class InternalNode
Definition: ValueAccessor.h:1568
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:1180
Value accessor with one level of node caching.
Definition: ValueAccessor.h:89
LeafNodeT * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:2502
const NodeT * probeConstNode(const Coord &xyz) const
Definition: ValueAccessor.h:1997
void erase(const RootNodeType *)
Definition: ValueAccessor.h:896
virtual ~ValueAccessor()
Definition: ValueAccessor.h:519
RootNodeT::NodeChainType InvTreeT
Definition: ValueAccessor.h:1269
friend class Tree
Definition: ValueAccessor.h:2567
friend class Tree
Definition: ValueAccessor.h:451
bool probeValue(const Coord &xyz, ValueType &value) const
Return the active state of the voxel as well as its value.
Definition: ValueAccessor.h:1327
void insert(const Coord &, const RootNodeType *root)
Definition: ValueAccessor.h:890
boost::mpl::at< InvTreeT, boost::mpl::int_< L2 > >::type NodeT2
Definition: ValueAccessor.h:2133
ValueAccessor0(TreeType &tree)
Definition: ValueAccessor.h:1055
virtual void clear()
Remove all the cached nodes and invalidate the corresponding hash-keys.
Definition: ValueAccessor.h:2022
NodeT * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:703
bool isVoxel(const Coord &xyz) const
Definition: ValueAccessor.h:1352
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:1142
Definition: ValueAccessor.h:219
void addTile(Index level, const Coord &xyz, const ValueType &value, bool state)
Definition: ValueAccessor.h:661
TreeType * getTree() const
Return a pointer to the tree associated with this accessor.
Definition: ValueAccessor.h:145
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: ValueAccessor.h:1449
bool isCached(const Coord &xyz) const
Definition: ValueAccessor.h:1673
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:1189
friend class RootNode
Definition: ValueAccessor.h:2563
const LeafNodeType * probeConstLeaf(const Coord &xyz)
Definition: ValueAccessor.h:693
ValueAccessor1(TreeType &tree)
Constructor from a tree.
Definition: ValueAccessor.h:1273
int getValueDepth(const Coord &xyz)
Definition: ValueAccessor.h:753
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:1088
static bool isSafe()
Return true if this accessor is safe, i.e. registered by the tree from which it is constructed...
Definition: ValueAccessor.h:132
std::numeric_limits< Int32 > CoordLimits
Definition: ValueAccessor.h:572
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:311
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive without changing its value.
Definition: ValueAccessor.h:2381
bool isValueOn(const Coord &xyz) const
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:1694
virtual ~ValueAccessor()
Definition: ValueAccessor.h:495
void setValueOn(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:795
virtual ~ValueAccessor()
Definition: ValueAccessor.h:507
CacheItem & copy(TreeCacheT &parent, const CacheItem &other)
Definition: ValueAccessor.h:881
const LeafNodeT * probeLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1556
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:337
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: ValueAccessor.h:1167
This accessor is thread-safe (at the cost of speed) for both reading and writing to a tree...
Definition: ValueAccessor.h:547
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:1488
CacheItem & copy(TreeCacheT &parent, const CacheItem &other)
Copy another CacheItem's node pointers and hash keys, but not its parent pointer. ...
Definition: ValueAccessor.h:592
This base class for ValueAccessors manages registration of an accessor with a tree so that the tree c...
Definition: ValueAccessor.h:121
NodeType::ValueType ValueType
Definition: ValueAccessor.h:570
bool isVoxel(const Coord &xyz) const
Definition: ValueAccessor.h:283
friend class LeafNode
Definition: ValueAccessor.h:1569
const LeafNodeT * probeLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1233
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active without changing its value.
Definition: ValueAccessor.h:2379
const ValueType & getValue(const Coord &xyz)
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:641
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
friend class Tree
Definition: ValueAccessor.h:1243
RootNodeT::ValueType ValueType
Definition: ValueAccessor.h:227
ValueAccessorBase< TreeType, IsSafe > BaseT
Definition: ValueAccessor.h:1268
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:1680
ValueAccessor(TreeType &tree)
Definition: ValueAccessor.h:529
NodeT * probeNode(const Coord &xyz)
Definition: ValueAccessor.h:1209
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:1123
TreeType::RootNodeType RootNodeT
Definition: ValueAccessor.h:1266
LeafNodeType * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:928
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:1769
void insertNode(const Coord &xyz, NodeT &node)
Definition: ValueAccessor.h:1465
bool probeValue(const Coord &xyz, ValueType &value) const
Return the active state of the voxel as well as its value.
Definition: ValueAccessor.h:266
ValueAccessor1 & operator=(const ValueAccessor1 &other)
Asignment operator.
Definition: ValueAccessor.h:1284
friend class Tree
Definition: ValueAccessor.h:1571
bool isValueOn(const Coord &xyz)
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:734
bool probeValue(const Coord &xyz, ValueType &value) const
Return the active state of the voxel as well as its value.
Definition: ValueAccessor.h:2203
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:1152
TreeType::RootNodeType RootNodeT
Definition: ValueAccessor.h:1051
TreeType TreeType
Definition: ValueAccessor.h:1264
static Index numCacheLevels()
Return the number of cache levels employed by this accessor.
Definition: ValueAccessor.h:250
const NodeT * probeConstLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:1964
ValueAccessor3 & operator=(const ValueAccessor3 &other)
Asignment operator.
Definition: ValueAccessor.h:2145
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:1789
friend class InternalNode
Definition: ValueAccessor.h:2564
void insertNode(const Coord &, NodeT &)
Definition: ValueAccessor.h:1176
void setValueOnly(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:785
ValueAccessorBase< TreeType, IsSafe > BaseT
Definition: ValueAccessor.h:2129
ValueAccessor(const ValueAccessor &other)
Definition: ValueAccessor.h:518
LeafNodeT * touchLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1917
bool probeValue(const Coord &xyz, ValueType &value) const
Return the active state of the voxel as well as its value.
Definition: ValueAccessor.h:1708
void getNode(const NodeType *&node)
Definition: ValueAccessor.h:628
bool isVoxel(const Coord &xyz) const
Definition: ValueAccessor.h:1739
LeafNodeType * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:683
LeafNodeT * probeLeaf(const Coord &xyz)
Definition: ValueAccessor.h:1530
TreeType TreeType
Definition: ValueAccessor.h:1049
void setValueOff(const Coord &xyz, const ValueType &value)
Definition: ValueAccessor.h:1014
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Definition: ValueAccessor.h:1007
const LeafNodeT * probeLeaf(const Coord &xyz) const
Definition: ValueAccessor.h:2548
ValueAccessor(const ValueAccessor &other)
Definition: ValueAccessor.h:506
ValueAccessor1(const ValueAccessor1 &other)
Copy constructor.
Definition: ValueAccessor.h:1278
boost::mpl::front< NodeVecT >::type RootNodeType
Definition: ValueAccessor.h:874