35 #ifndef OPENVDB_TREE_TREE_HAS_BEEN_INCLUDED 36 #define OPENVDB_TREE_TREE_HAS_BEEN_INCLUDED 41 #include <boost/shared_ptr.hpp> 42 #include <boost/cstdint.hpp> 43 #include <tbb/atomic.h> 44 #include <tbb/concurrent_hash_map.h> 45 #include <openvdb/Types.h> 46 #include <openvdb/metadata/Metadata.h> 47 #include <openvdb/math/Math.h> 48 #include <openvdb/math/BBox.h> 49 #include <openvdb/util/Formats.h> 50 #include <openvdb/util/logging.h> 51 #include <openvdb/Platform.h> 68 typedef boost::shared_ptr<TreeBase>
Ptr;
69 typedef boost::shared_ptr<const TreeBase>
ConstPtr;
75 virtual const Name& type()
const = 0;
78 virtual Name valueType()
const = 0;
97 virtual bool evalLeafBoundingBox(
CoordBBox& bbox)
const = 0;
102 virtual bool evalLeafDim(
Coord& dim)
const = 0;
111 virtual bool evalActiveVoxelBoundingBox(
CoordBBox& bbox)
const = 0;
116 virtual bool evalActiveVoxelDim(
Coord& dim)
const = 0;
118 virtual void getIndexRange(
CoordBBox& bbox)
const = 0;
120 #ifndef OPENVDB_2_ABI_COMPATIBLE 121 virtual void clipUnallocatedNodes() = 0;
136 virtual Index treeDepth()
const = 0;
138 virtual Index32 leafCount()
const = 0;
140 virtual Index32 nonLeafCount()
const = 0;
142 virtual Index64 activeLeafVoxelCount()
const = 0;
144 virtual Index64 inactiveLeafVoxelCount()
const = 0;
146 virtual Index64 activeVoxelCount()
const = 0;
148 virtual Index64 inactiveVoxelCount()
const = 0;
149 #ifndef OPENVDB_2_ABI_COMPATIBLE 150 virtual Index64 activeTileCount()
const = 0;
164 virtual void readTopology(std::istream&,
bool saveFloatAsHalf =
false);
168 virtual void writeTopology(std::ostream&,
bool saveFloatAsHalf =
false)
const;
171 virtual void readBuffers(std::istream&,
bool saveFloatAsHalf =
false) = 0;
172 #ifndef OPENVDB_2_ABI_COMPATIBLE 173 virtual void readBuffers(std::istream&,
const CoordBBox&,
bool saveFloatAsHalf =
false) = 0;
180 virtual void readNonresidentBuffers()
const = 0;
182 virtual void writeBuffers(std::ostream&,
bool saveFloatAsHalf =
false)
const = 0;
192 virtual void print(std::ostream& os = std::cout,
int verboseLevel = 1)
const;
204 template<
typename _RootNodeType>
208 typedef boost::shared_ptr<Tree>
Ptr;
216 static const Index DEPTH = RootNodeType::LEVEL + 1;
224 template<
typename OtherValueType>
243 template<
typename OtherRootType>
258 template<
typename OtherTreeType>
259 Tree(
const OtherTreeType& other,
260 const ValueType& inactiveValue,
261 const ValueType& activeValue,
264 mRoot(other.root(), inactiveValue, activeValue,
TopologyCopy())
279 template<
typename OtherTreeType>
287 Tree(
const ValueType& background): mRoot(background) {}
289 virtual ~Tree() { this->clear(); releaseAllAccessors(); }
298 static const Name& treeType();
300 virtual const Name&
type()
const {
return this->treeType(); }
306 RootNodeType& root() {
return mRoot; }
308 const RootNodeType&
root()
const {
return mRoot; }
317 template<
typename OtherRootNodeType>
320 virtual bool evalLeafBoundingBox(
CoordBBox& bbox)
const;
321 virtual bool evalActiveVoxelBoundingBox(
CoordBBox& bbox)
const;
322 virtual bool evalActiveVoxelDim(
Coord& dim)
const;
323 virtual bool evalLeafDim(
Coord& dim)
const;
328 static void getNodeLog2Dims(std::vector<Index>& dims);
337 virtual void readTopology(std::istream&,
bool saveFloatAsHalf =
false);
341 virtual void writeTopology(std::ostream&,
bool saveFloatAsHalf =
false)
const;
343 virtual void readBuffers(std::istream&,
bool saveFloatAsHalf =
false);
344 #ifndef OPENVDB_2_ABI_COMPATIBLE 345 virtual void readBuffers(std::istream&,
const CoordBBox&,
bool saveFloatAsHalf =
false);
352 virtual void readNonresidentBuffers()
const;
354 virtual void writeBuffers(std::ostream&,
bool saveFloatAsHalf =
false)
const;
357 virtual void print(std::ostream& os = std::cout,
int verboseLevel = 1)
const;
378 virtual Index64 inactiveVoxelCount()
const;
383 void evalMinMax(ValueType &
min, ValueType &
max)
const;
392 const ValueType& getValue(
const Coord& xyz)
const;
395 template<
typename AccessT>
const ValueType& getValue(
const Coord& xyz, AccessT&)
const;
400 int getValueDepth(
const Coord& xyz)
const;
403 void setActiveState(
const Coord& xyz,
bool on);
405 void setValueOnly(
const Coord& xyz,
const ValueType& value);
407 void setValueOn(
const Coord& xyz);
409 void setValueOn(
const Coord& xyz,
const ValueType& value);
411 void setValue(
const Coord& xyz,
const ValueType& value);
414 template<
typename AccessT>
void setValue(
const Coord& xyz,
const ValueType& value, AccessT&);
416 void setValueOff(
const Coord& xyz);
418 void setValueOff(
const Coord& xyz,
const ValueType& value);
438 template<
typename ModifyOp>
439 void modifyValue(
const Coord& xyz,
const ModifyOp& op);
460 template<
typename ModifyOp>
461 void modifyValueAndActiveState(
const Coord& xyz,
const ModifyOp& op);
465 bool probeValue(
const Coord& xyz, ValueType& value)
const;
477 #ifndef OPENVDB_2_ABI_COMPATIBLE 478 virtual void clipUnallocatedNodes();
487 void sparseFill(
const CoordBBox& bbox,
const ValueType& value,
bool active =
true);
496 void fill(
const CoordBBox& bbox,
const ValueType& value,
bool active =
true)
498 this->sparseFill(bbox, value, active);
511 void denseFill(
const CoordBBox& bbox,
const ValueType& value,
bool active =
true);
517 void prune(
const ValueType& tolerance = zeroVal<ValueType>())
519 this->clearAllAccessors();
520 mRoot.prune(tolerance);
524 void addLeaf(LeafNodeType* leaf) { assert(leaf); mRoot.addLeaf(leaf); }
537 void addTile(
Index level,
const Coord& xyz,
const ValueType& value,
bool active);
543 template<
typename NodeT>
544 NodeT* stealNode(
const Coord& xyz,
const ValueType& value,
bool active);
551 LeafNodeType* touchLeaf(
const Coord& xyz);
554 template<
typename NodeType> NodeType* probeNode(
const Coord& xyz);
557 template<
typename NodeType>
const NodeType* probeConstNode(
const Coord& xyz)
const;
558 template<
typename NodeType>
const NodeType* probeNode(
const Coord& xyz)
const;
562 LeafNodeType* probeLeaf(
const Coord& xyz);
565 const LeafNodeType* probeConstLeaf(
const Coord& xyz)
const;
566 const LeafNodeType*
probeLeaf(
const Coord& xyz)
const {
return this->probeConstLeaf(xyz); }
570 template<
typename ArrayT>
void getNodes(ArrayT& array) { mRoot.getNodes(array); }
593 template<
typename ArrayT>
void getNodes(ArrayT& array)
const { mRoot.getNodes(array); }
619 template<
typename ArrayT>
620 void stealNodes(ArrayT& array) { this->clearAllAccessors(); mRoot.stealNodes(array); }
621 template<
typename ArrayT>
622 void stealNodes(ArrayT& array,
const ValueType& value,
bool state)
624 this->clearAllAccessors();
625 mRoot.stealNodes(array, value, state);
633 bool empty()
const {
return mRoot.empty(); }
639 void clearAllAccessors();
675 const ValueType&
background()
const {
return mRoot.background(); }
686 void voxelizeActiveTiles(
bool threaded =
true);
710 template<
typename OtherRootNodeType>
726 template<
typename OtherRootNodeType>
739 template<
typename OtherRootNodeType>
786 template<
typename CombineOp>
787 void combine(
Tree& other, CombineOp& op,
bool prune =
false);
789 template<
typename CombineOp>
790 void combine(
Tree& other,
const CombineOp& op,
bool prune =
false);
831 template<
typename ExtendedCombineOp>
832 void combineExtended(
Tree& other, ExtendedCombineOp& op,
bool prune =
false);
834 template<
typename ExtendedCombineOp>
835 void combineExtended(
Tree& other,
const ExtendedCombineOp& op,
bool prune =
false);
866 template<
typename CombineOp,
typename OtherTreeType >
867 void combine2(
const Tree& a,
const OtherTreeType& b, CombineOp& op,
bool prune =
false);
869 template<
typename CombineOp,
typename OtherTreeType >
870 void combine2(
const Tree& a,
const OtherTreeType& b,
const CombineOp& op,
bool prune =
false);
946 template<
typename ExtendedCombineOp,
typename OtherTreeType >
947 void combine2Extended(
const Tree& a,
const OtherTreeType& b, ExtendedCombineOp& op,
950 template<
typename ExtendedCombineOp,
typename OtherTreeType >
951 void combine2Extended(
const Tree& a,
const OtherTreeType& b,
const ExtendedCombineOp&,
995 template<
typename BBoxOp>
void visitActiveBBox(BBoxOp& op)
const { mRoot.visitActiveBBox(op); }
1050 template<
typename VisitorOp>
void visit(VisitorOp& op);
1051 template<
typename VisitorOp>
void visit(
const VisitorOp& op);
1057 template<
typename VisitorOp>
void visit(VisitorOp& op)
const;
1058 template<
typename VisitorOp>
void visit(
const VisitorOp& op)
const;
1107 template<
typename OtherTreeType,
typename VisitorOp>
1108 void visit2(OtherTreeType& other, VisitorOp& op);
1109 template<
typename OtherTreeType,
typename VisitorOp>
1110 void visit2(OtherTreeType& other,
const VisitorOp& op);
1122 template<
typename OtherTreeType,
typename VisitorOp>
1123 void visit2(OtherTreeType& other, VisitorOp& op)
const;
1124 template<
typename OtherTreeType,
typename VisitorOp>
1125 void visit2(OtherTreeType& other,
const VisitorOp& op)
const;
1132 typename RootNodeType::ChildOnCIter beginRootChildren()
const {
return mRoot.cbeginChildOn(); }
1139 typename RootNodeType::ChildOffCIter beginRootTiles()
const {
return mRoot.cbeginChildOff(); }
1141 typename RootNodeType::ChildOffCIter
cbeginRootTiles()
const {
return mRoot.cbeginChildOff(); }
1142 typename RootNodeType::ChildOffIter
beginRootTiles() {
return mRoot.beginChildOff(); }
1146 typename RootNodeType::ChildAllCIter beginRootDense()
const {
return mRoot.cbeginChildAll(); }
1148 typename RootNodeType::ChildAllCIter
cbeginRootDense()
const {
return mRoot.cbeginChildAll(); }
1149 typename RootNodeType::ChildAllIter
beginRootDense() {
return mRoot.beginChildAll(); }
1166 NodeIter beginNode() {
return NodeIter(*
this); }
1173 LeafIter beginLeaf() {
return LeafIter(*
this); }
1187 ValueAllIter beginValueAll() {
return ValueAllIter(*
this); }
1193 ValueOnIter beginValueOn() {
return ValueOnIter(*
this); }
1199 ValueOffIter beginValueOff() {
return ValueOffIter(*
this); }
1207 template<
typename IterT> IterT begin();
1210 template<
typename CIterT> CIterT cbegin()
const;
1222 void releaseAllAccessors();
1225 template<
typename NodeType>
1228 : mNodes(nodes.empty() ? NULL : &nodes.front()) { }
1230 for (
size_t n = range.begin(), N = range.end(); n < N; ++n) {
1231 delete mNodes[n]; mNodes[n] = NULL;
1247 template<
typename _RootNodeType>
1255 template<
typename T, Index N1=4, Index N2=3>
1265 template<
typename T, Index N1=5, Index N2=4, Index N3=3>
1274 template<
typename T, Index N1=6, Index N2=5, Index N3=4, Index N4=3>
1287 int32_t bufferCount;
1288 is.read(reinterpret_cast<char*>(&bufferCount),
sizeof(int32_t));
1289 if (bufferCount != 1)
OPENVDB_LOG_WARN(
"multi-buffer trees are no longer supported");
1296 int32_t bufferCount = 1;
1297 os.write(reinterpret_cast<char*>(&bufferCount),
sizeof(int32_t));
1304 os <<
" Tree Type: " << type()
1305 <<
" Active Voxel Count: " << activeVoxelCount() << std::endl
1306 #ifndef OPENVDB_2_ABI_COMPATIBLE 1307 <<
" Active tile Count: " << activeTileCount() << std::endl
1309 <<
" Inactive Voxel Count: " << inactiveVoxelCount() << std::endl
1310 <<
" Leaf Node Count: " << leafCount() << std::endl
1311 <<
" Non-leaf Node Count: " << nonLeafCount() << std::endl;
1326 template<
typename TreeT>
struct TreeIterTraits<TreeT, typename TreeT::RootNodeType::ChildOnIter> {
1327 static typename TreeT::RootNodeType::ChildOnIter
begin(TreeT& tree) {
1328 return tree.beginRootChildren();
1332 template<
typename TreeT>
struct TreeIterTraits<TreeT, typename TreeT::RootNodeType::ChildOnCIter> {
1333 static typename TreeT::RootNodeType::ChildOnCIter
begin(
const TreeT& tree) {
1334 return tree.cbeginRootChildren();
1338 template<
typename TreeT>
struct TreeIterTraits<TreeT, typename TreeT::RootNodeType::ChildOffIter> {
1339 static typename TreeT::RootNodeType::ChildOffIter
begin(TreeT& tree) {
1340 return tree.beginRootTiles();
1344 template<
typename TreeT>
struct TreeIterTraits<TreeT, typename TreeT::RootNodeType::ChildOffCIter> {
1345 static typename TreeT::RootNodeType::ChildOffCIter
begin(
const TreeT& tree) {
1346 return tree.cbeginRootTiles();
1350 template<
typename TreeT>
struct TreeIterTraits<TreeT, typename TreeT::RootNodeType::ChildAllIter> {
1351 static typename TreeT::RootNodeType::ChildAllIter
begin(TreeT& tree) {
1352 return tree.beginRootDense();
1356 template<
typename TreeT>
struct TreeIterTraits<TreeT, typename TreeT::RootNodeType::ChildAllCIter> {
1357 static typename TreeT::RootNodeType::ChildAllCIter
begin(
const TreeT& tree) {
1358 return tree.cbeginRootDense();
1363 static typename TreeT::NodeIter
begin(TreeT& tree) {
return tree.beginNode(); }
1367 static typename TreeT::NodeCIter
begin(
const TreeT& tree) {
return tree.cbeginNode(); }
1371 static typename TreeT::LeafIter
begin(TreeT& tree) {
return tree.beginLeaf(); }
1375 static typename TreeT::LeafCIter
begin(
const TreeT& tree) {
return tree.cbeginLeaf(); }
1379 static typename TreeT::ValueOnIter
begin(TreeT& tree) {
return tree.beginValueOn(); }
1382 template<
typename TreeT>
struct TreeIterTraits<TreeT, typename TreeT::ValueOnCIter> {
1383 static typename TreeT::ValueOnCIter
begin(
const TreeT& tree) {
return tree.cbeginValueOn(); }
1386 template<
typename TreeT>
struct TreeIterTraits<TreeT, typename TreeT::ValueOffIter> {
1387 static typename TreeT::ValueOffIter
begin(TreeT& tree) {
return tree.beginValueOff(); }
1390 template<
typename TreeT>
struct TreeIterTraits<TreeT, typename TreeT::ValueOffCIter> {
1391 static typename TreeT::ValueOffCIter
begin(
const TreeT& tree) {
return tree.cbeginValueOff(); }
1394 template<
typename TreeT>
struct TreeIterTraits<TreeT, typename TreeT::ValueAllIter> {
1395 static typename TreeT::ValueAllIter
begin(TreeT& tree) {
return tree.beginValueAll(); }
1398 template<
typename TreeT>
struct TreeIterTraits<TreeT, typename TreeT::ValueAllCIter> {
1399 static typename TreeT::ValueAllCIter
begin(
const TreeT& tree) {
return tree.cbeginValueAll(); }
1403 template<
typename RootNodeType>
1404 template<
typename IterT>
1412 template<
typename RootNodeType>
1413 template<
typename IterT>
1424 template<
typename RootNodeType>
1428 this->clearAllAccessors();
1430 mRoot.readTopology(is, saveFloatAsHalf);
1434 template<
typename RootNodeType>
1439 mRoot.writeTopology(os, saveFloatAsHalf);
1443 template<
typename RootNodeType>
1447 this->clearAllAccessors();
1448 mRoot.readBuffers(is, saveFloatAsHalf);
1452 #ifndef OPENVDB_2_ABI_COMPATIBLE 1454 template<
typename RootNodeType>
1458 this->clearAllAccessors();
1459 mRoot.readBuffers(is, bbox, saveFloatAsHalf);
1463 template<
typename RootNodeType>
1467 for (
LeafCIter it = this->cbeginLeaf(); it; ++it) {
1473 #endif // !OPENVDB_2_ABI_COMPATIBLE 1476 template<
typename RootNodeType>
1484 template<
typename RootNodeType>
1488 std::vector<LeafNodeType*> leafnodes;
1489 this->stealNodes(leafnodes);
1491 tbb::parallel_for(tbb::blocked_range<size_t>(0, leafnodes.size()),
1494 std::vector<typename RootNodeType::ChildNodeType*> internalNodes;
1495 this->stealNodes(internalNodes);
1497 tbb::parallel_for(tbb::blocked_range<size_t>(0, internalNodes.size()),
1502 this->clearAllAccessors();
1509 template<
typename RootNodeType>
1513 typename AccessorRegistry::accessor a;
1514 mAccessorRegistry.insert(a, &accessor);
1518 template<
typename RootNodeType>
1522 typename ConstAccessorRegistry::accessor a;
1523 mConstAccessorRegistry.insert(a, &accessor);
1527 template<
typename RootNodeType>
1531 mAccessorRegistry.erase(&accessor);
1535 template<
typename RootNodeType>
1539 mConstAccessorRegistry.erase(&accessor);
1543 template<
typename RootNodeType>
1547 for (
typename AccessorRegistry::iterator it = mAccessorRegistry.begin();
1548 it != mAccessorRegistry.end(); ++it)
1550 if (it->first) it->first->
clear();
1553 for (
typename ConstAccessorRegistry::iterator it = mConstAccessorRegistry.begin();
1554 it != mConstAccessorRegistry.end(); ++it)
1556 if (it->first) it->first->clear();
1561 template<
typename RootNodeType>
1565 mAccessorRegistry.erase(NULL);
1566 for (
typename AccessorRegistry::iterator it = mAccessorRegistry.begin();
1567 it != mAccessorRegistry.end(); ++it)
1569 it->first->release();
1571 mAccessorRegistry.
clear();
1573 mAccessorRegistry.erase(NULL);
1574 for (
typename ConstAccessorRegistry::iterator it = mConstAccessorRegistry.begin();
1575 it != mConstAccessorRegistry.end(); ++it)
1577 it->first->release();
1579 mConstAccessorRegistry.clear();
1586 template<
typename RootNodeType>
1587 inline const typename RootNodeType::ValueType&
1594 template<
typename RootNodeType>
1595 template<
typename AccessT>
1596 inline const typename RootNodeType::ValueType&
1603 template<
typename RootNodeType>
1611 template<
typename RootNodeType>
1619 template<
typename RootNodeType>
1627 template<
typename RootNodeType>
1635 template<
typename RootNodeType>
1642 template<
typename RootNodeType>
1649 template<
typename RootNodeType>
1650 template<
typename AccessT>
1658 template<
typename RootNodeType>
1666 template<
typename RootNodeType>
1674 template<
typename RootNodeType>
1675 template<
typename ModifyOp>
1683 template<
typename RootNodeType>
1684 template<
typename ModifyOp>
1692 template<
typename RootNodeType>
1703 template<
typename RootNodeType>
1706 const ValueType& value,
bool active)
1708 mRoot.
addTile(level, xyz, value, active);
1712 template<
typename RootNodeType>
1713 template<
typename NodeT>
1717 this->clearAllAccessors();
1718 return mRoot.template stealNode<NodeT>(xyz, value, active);
1722 template<
typename RootNodeType>
1723 inline typename RootNodeType::LeafNodeType*
1730 template<
typename RootNodeType>
1731 inline typename RootNodeType::LeafNodeType*
1738 template<
typename RootNodeType>
1739 inline const typename RootNodeType::LeafNodeType*
1746 template<
typename RootNodeType>
1747 template<
typename NodeType>
1751 return mRoot.template probeNode<NodeType>(xyz);
1755 template<
typename RootNodeType>
1756 template<
typename NodeType>
1757 inline const NodeType*
1760 return this->
template probeConstNode<NodeType>(xyz);
1764 template<
typename RootNodeType>
1765 template<
typename NodeType>
1766 inline const NodeType*
1769 return mRoot.template probeConstNode<NodeType>(xyz);
1776 template<
typename RootNodeType>
1780 this->clearAllAccessors();
1781 return mRoot.clip(bbox);
1785 #ifndef OPENVDB_2_ABI_COMPATIBLE 1786 template<
typename RootNodeType>
1790 this->clearAllAccessors();
1791 for (
LeafIter it = this->beginLeaf(); it; ) {
1792 const LeafNodeType* leaf = it.getLeaf();
1794 if (!leaf->isAllocated()) {
1795 this->addTile(0, leaf->origin(), this->background(),
false);
1802 template<
typename RootNodeType>
1806 this->clearAllAccessors();
1807 return mRoot.denseFill(bbox, value, active);
1810 template<
typename RootNodeType>
1814 this->clearAllAccessors();
1815 return mRoot.sparseFill(bbox, value, active);
1819 template<
typename RootNodeType>
1827 if (result->typeName() == MetadataT::staticTypeName()) {
1828 MetadataT* m =
static_cast<MetadataT*
>(result.get());
1829 m->value() = mRoot.background();
1839 template<
typename RootNodeType>
1843 this->clearAllAccessors();
1844 mRoot.voxelizeActiveTiles(threaded);
1848 template<
typename RootNodeType>
1852 this->clearAllAccessors();
1856 mRoot.template merge<MERGE_ACTIVE_STATES>(other.
mRoot);
break;
1858 mRoot.template merge<MERGE_NODES>(other.
mRoot);
break;
1860 mRoot.template merge<MERGE_ACTIVE_STATES_AND_NODES>(other.
mRoot);
break;
1865 template<
typename RootNodeType>
1866 template<
typename OtherRootNodeType>
1870 this->clearAllAccessors();
1871 mRoot.topologyUnion(other.
root());
1874 template<
typename RootNodeType>
1875 template<
typename OtherRootNodeType>
1879 this->clearAllAccessors();
1880 mRoot.topologyIntersection(other.
root());
1883 template<
typename RootNodeType>
1884 template<
typename OtherRootNodeType>
1888 this->clearAllAccessors();
1889 mRoot.topologyDifference(other.
root());
1897 template<
typename AValueT,
typename CombineOp,
typename BValueT = AValueT>
1903 op(args.
a(), args.
b(), args.
result());
1910 template<
typename RootNodeType>
1911 template<
typename CombineOp>
1916 this->combineExtended(other, extendedOp, prune);
1923 template<
typename RootNodeType>
1924 template<
typename CombineOp>
1929 this->combineExtended(other, extendedOp, prune);
1934 template<
typename RootNodeType>
1935 template<
typename ExtendedCombineOp>
1939 this->clearAllAccessors();
1947 template<
typename RootNodeType>
1948 template<
typename ExtendedCombineOp>
1952 this->clearAllAccessors();
1953 mRoot.template combine<const ExtendedCombineOp>(other.
mRoot, op,
prune);
1958 template<
typename RootNodeType>
1959 template<
typename CombineOp,
typename OtherTreeType>
1964 this->combine2Extended(a, b, extendedOp, prune);
1971 template<
typename RootNodeType>
1972 template<
typename CombineOp,
typename OtherTreeType>
1977 this->combine2Extended(a, b, extendedOp, prune);
1982 template<
typename RootNodeType>
1983 template<
typename ExtendedCombineOp,
typename OtherTreeType>
1986 ExtendedCombineOp& op,
bool prune)
1988 this->clearAllAccessors();
1989 mRoot.combine2(a.
root(), b.root(), op,
prune);
1997 template<
typename RootNodeType>
1998 template<
typename ExtendedCombineOp,
typename OtherTreeType>
2001 const ExtendedCombineOp& op,
bool prune)
2003 this->clearAllAccessors();
2004 mRoot.template combine2<const ExtendedCombineOp>(a.
root(), b.root(), op,
prune);
2012 template<
typename RootNodeType>
2013 template<
typename VisitorOp>
2017 this->clearAllAccessors();
2018 mRoot.template visit<VisitorOp>(op);
2022 template<
typename RootNodeType>
2023 template<
typename VisitorOp>
2027 mRoot.template visit<VisitorOp>(op);
2033 template<
typename RootNodeType>
2034 template<
typename VisitorOp>
2038 this->clearAllAccessors();
2039 mRoot.template visit<const VisitorOp>(op);
2045 template<
typename RootNodeType>
2046 template<
typename VisitorOp>
2050 mRoot.template visit<const VisitorOp>(op);
2057 template<
typename RootNodeType>
2058 template<
typename OtherTreeType,
typename VisitorOp>
2062 this->clearAllAccessors();
2063 typedef typename OtherTreeType::RootNodeType OtherRootNodeType;
2064 mRoot.template visit2<OtherRootNodeType, VisitorOp>(other.root(), op);
2068 template<
typename RootNodeType>
2069 template<
typename OtherTreeType,
typename VisitorOp>
2073 typedef typename OtherTreeType::RootNodeType OtherRootNodeType;
2074 mRoot.template visit2<OtherRootNodeType, VisitorOp>(other.root(), op);
2080 template<
typename RootNodeType>
2081 template<
typename OtherTreeType,
typename VisitorOp>
2085 this->clearAllAccessors();
2086 typedef typename OtherTreeType::RootNodeType OtherRootNodeType;
2087 mRoot.template visit2<OtherRootNodeType, const VisitorOp>(other.root(), op);
2093 template<
typename RootNodeType>
2094 template<
typename OtherTreeType,
typename VisitorOp>
2098 typedef typename OtherTreeType::RootNodeType OtherRootNodeType;
2099 mRoot.template visit2<OtherRootNodeType, const VisitorOp>(other.root(), op);
2106 template<
typename RootNodeType>
2110 if (sTreeTypeName == NULL) {
2111 std::vector<Index> dims;
2112 Tree::getNodeLog2Dims(dims);
2113 std::ostringstream ostr;
2114 ostr <<
"Tree_" << typeNameAsString<BuildType>();
2115 for (
size_t i = 1, N = dims.size(); i < N; ++i) {
2116 ostr <<
"_" << dims[i];
2119 if (sTreeTypeName.compare_and_swap(s, NULL) != NULL)
delete s;
2121 return *sTreeTypeName;
2125 template<
typename RootNodeType>
2126 template<
typename OtherRootNodeType>
2134 template<
typename RootNodeType>
2139 this->evalActiveVoxelDim(dim);
2141 totalVoxels = dim.
x() * dim.
y() * dim.
z(),
2142 activeVoxels = this->activeVoxelCount();
2143 assert(totalVoxels >= activeVoxels);
2144 return totalVoxels - activeVoxels;
2148 template<
typename RootNodeType>
2154 if (this->empty())
return false;
2156 mRoot.evalActiveBoundingBox(bbox,
false);
2161 template<
typename RootNodeType>
2167 if (this->empty())
return false;
2169 mRoot.evalActiveBoundingBox(bbox,
true);
2175 template<
typename RootNodeType>
2180 bool notEmpty = this->evalActiveVoxelBoundingBox(bbox);
2186 template<
typename RootNodeType>
2191 bool notEmpty = this->evalLeafBoundingBox(bbox);
2197 template<
typename RootNodeType>
2201 minVal = maxVal = zeroVal<ValueType>();
2203 minVal = maxVal = *iter;
2204 for (++iter; iter; ++iter) {
2205 const ValueType& val = *iter;
2206 if (val < minVal) minVal = val;
2207 if (val > maxVal) maxVal = val;
2213 template<
typename RootNodeType>
2218 RootNodeType::getNodeLog2Dims(dims);
2222 template<
typename RootNodeType>
2226 if (verboseLevel <= 0)
return;
2231 std::streamsize savedPrecision;
2232 OnExit(std::ostream& _os): os(_os), savedPrecision(os.precision()) {}
2233 ~OnExit() { os.precision(savedPrecision); }
2235 OnExit restorePrecision(os);
2237 std::vector<Index> dims;
2238 Tree::getNodeLog2Dims(dims);
2240 os <<
"Information about Tree:\n" 2241 <<
" Type: " << this->type() <<
"\n";
2243 os <<
" Configuration:\n";
2245 if (verboseLevel <= 1) {
2247 os <<
" Root(" << mRoot.getTableSize() <<
")";
2248 if (dims.size() > 1) {
2249 for (
size_t i = 1, N = dims.size() - 1; i < N; ++i) {
2250 os <<
", Internal(" << (1 << dims[i]) <<
"^3)";
2252 os <<
", Leaf(" << (1 << *dims.rbegin()) <<
"^3)\n";
2254 os <<
" Background value: " << mRoot.background() <<
"\n";
2260 ValueType minVal = zeroVal<ValueType>(), maxVal = zeroVal<ValueType>();
2261 if (verboseLevel > 3) {
2263 this->evalMinMax(minVal, maxVal);
2266 std::vector<Index64> nodeCount(dims.size());
2267 #ifndef OPENVDB_2_ABI_COMPATIBLE 2268 Index64 unallocatedLeafCount = 0;
2270 for (
NodeCIter it = cbeginNode(); it; ++it) {
2271 ++(nodeCount[it.getDepth()]);
2273 #ifndef OPENVDB_2_ABI_COMPATIBLE 2274 if (it.getLevel() == 0) {
2275 const LeafNodeType* leaf = NULL;
2277 if (leaf && !leaf->isAllocated()) ++unallocatedLeafCount;
2282 for (
size_t i = 0; i < nodeCount.size(); ++i) totalNodeCount += nodeCount[i];
2285 os <<
" Root(1 x " << mRoot.getTableSize() <<
")";
2286 if (dims.size() > 1) {
2287 for (
size_t i = 1, N = dims.size() - 1; i < N; ++i) {
2289 os <<
" x " << (1 << dims[i]) <<
"^3)";
2292 os <<
" x " << (1 << *dims.rbegin()) <<
"^3)\n";
2294 os <<
" Background value: " << mRoot.background() <<
"\n";
2298 if (verboseLevel > 3) {
2299 os <<
" Min value: " << minVal <<
"\n";
2300 os <<
" Max value: " << maxVal <<
"\n";
2304 leafCount = *nodeCount.rbegin(),
2305 numActiveVoxels = this->activeVoxelCount(),
2306 numActiveLeafVoxels = this->activeLeafVoxelCount(),
2307 numActiveTiles = this->activeTileCount();
2313 uint64_t totalVoxels = 0;
2314 if (numActiveVoxels) {
2316 this->evalActiveVoxelBoundingBox(bbox);
2318 totalVoxels = dim.
x() * uint64_t(dim.
y()) * dim.
z();
2320 os <<
" Bounding box of active voxels: " << bbox <<
"\n";
2321 os <<
" Dimensions of active voxels: " 2322 << dim[0] <<
" x " << dim[1] <<
" x " << dim[2] <<
"\n";
2324 const double activeRatio = (100.0 * double(numActiveVoxels)) /
double(totalVoxels);
2325 os <<
" Percentage of active voxels: " << std::setprecision(3) << activeRatio <<
"%\n";
2327 if (leafCount > 0) {
2328 const double fillRatio = (100.0 * double(numActiveLeafVoxels))
2329 / (
double(leafCount) * double(LeafNodeType::NUM_VOXELS));
2330 os <<
" Average leaf node fill ratio: " << fillRatio <<
"%\n";
2333 #ifndef OPENVDB_2_ABI_COMPATIBLE 2334 if (verboseLevel > 2) {
2335 os <<
" Number of unallocated nodes: " 2337 << (100.0 * double(unallocatedLeafCount) / double(totalNodeCount)) <<
"%)\n";
2341 os <<
" Tree is empty!\n";
2345 if (verboseLevel == 2)
return;
2349 actualMem = this->memUsage(),
2350 denseMem =
sizeof(ValueType) * totalVoxels,
2351 voxelsMem =
sizeof(ValueType) * numActiveLeafVoxels;
2354 os <<
"Memory footprint:\n";
2358 if (numActiveVoxels) {
2360 os <<
" Actual footprint is " << (100.0 * double(actualMem) / double(denseMem))
2361 <<
"% of an equivalent dense volume\n";
2362 os <<
" Leaf voxel footprint is " << (100.0 * double(voxelsMem) / double(actualMem))
2363 <<
"% of actual footprint\n";
2371 #endif // OPENVDB_TREE_TREE_HAS_BEEN_INCLUDED Tree5<T, N1, N2, N3, N4>::Type is the type of a five-level tree (Root, Internal, Internal, Internal, Leaf) with value type T and internal and leaf node log dimensions N1, N2, N3 and N4, respectively.
Definition: Tree.h:1275
Base class for typed trees.
Definition: Tree.h:65
bool operator==(const Tree &) const
Definition: Tree.h:302
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: Tree.h:1613
void setValueOnly(const Coord &xyz, const ValueType &value)
Set the value of the voxel at the given coordinates but don't change its active state.
Definition: Tree.h:1644
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: Tree.h:1677
int getValueDepth(const Coord &xyz) const
Return the tree depth (0 = root) at which the value of voxel (x, y, z) resides.
Definition: Tree.h:1605
static TreeT::RootNodeType::ChildAllIter begin(TreeT &tree)
Definition: Tree.h:1351
void getNodes(ArrayT &array) const
Adds all nodes of a certain type to a container with the following API:
Definition: Tree.h:593
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: Tree.h:1686
ValueAllCIter cbeginValueAll() const
Return an iterator over all values (tile and voxel) across all nodes.
Definition: Tree.h:1190
DeallocateNodes(std::vector< NodeType *> &nodes)
Definition: Tree.h:1227
RootNodeType::ValueType ValueType
Definition: Tree.h:212
RootNodeType mRoot
Definition: Tree.h:1240
Tree(const OtherTreeType &other, const ValueType &inactiveValue, const ValueType &activeValue, TopologyCopy)
Topology copy constructor from a tree of a different type.
Definition: Tree.h:259
RootNodeType & root()
Return this tree's root node.
Definition: Tree.h:307
Tree< RootNode< InternalNode< LeafNode< T, N2 >, N1 > > > Type
Definition: Tree.h:1257
virtual void print(std::ostream &os=std::cout, int verboseLevel=1) const
Print statistics, memory usage and other information about this tree.
Definition: Tree.h:1302
virtual Index64 activeVoxelCount() const
Return the total number of active voxels.
Definition: Tree.h:376
boost::shared_ptr< const TreeBase > ConstPtr
Definition: Tree.h:69
Tree< RootNode< InternalNode< InternalNode< InternalNode< LeafNode< T, N4 >, N3 >, N2 >, N1 > > > Type
Definition: Tree.h:1277
void reset()
Definition: Coord.h:338
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: Tree.h:1660
RootNodeType::ChildAllCIter cbeginRootDense() const
Return an iterator over all entries of the root node's table.
Definition: Tree.h:1148
bool isValueOff(const Coord &xyz) const
Return true if the value at the given coordinates is inactive.
Definition: Tree.h:470
ValueAllCIter beginValueAll() const
Return an iterator over all values (tile and voxel) across all nodes.
Definition: Tree.h:1189
static TreeT::RootNodeType::ChildOffIter begin(TreeT &tree)
Definition: Tree.h:1339
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:97
ValueConverter<T>::Type is the type of a tree having the same hierarchy as this tree but a different ...
Definition: Tree.h:225
TreeValueIteratorBase< const Tree, typename RootNodeType::ValueAllCIter > ValueAllCIter
Definition: Tree.h:1180
std::string Name
Definition: Name.h:44
void operator()(const tbb::blocked_range< size_t > &range) const
Definition: Tree.h:1229
ValueOffCIter beginValueOff() const
Return an iterator over inactive values (tile and voxel) across all nodes.
Definition: Tree.h:1201
const LeafNodeType * probeLeaf(const Coord &xyz) const
Return a pointer to the leaf node that contains voxel (x, y, z). If no such node exists, return NULL.
Definition: Tree.h:566
virtual Index64 inactiveLeafVoxelCount() const
Return the number of inactive voxels stored in leaf nodes.
Definition: Tree.h:374
RootNodeType::ChildOffIter beginRootTiles()
Return an iterator over non-child entries of the root node's table.
Definition: Tree.h:1142
Base class for tree-traversal iterators over all nodes.
Definition: TreeIterator.h:977
virtual Index32 nonLeafCount() const
Return the number of non-leaf nodes.
Definition: Tree.h:370
void visitActiveBBox(BBoxOp &op) const
Use sparse traversal to call the given functor with bounding box information for all active tiles and...
Definition: Tree.h:995
ConstAccessorRegistry mConstAccessorRegistry
Definition: Tree.h:1242
void prune(const ValueType &tolerance=zeroVal< ValueType >())
Reduce the memory footprint of this tree by replacing with tiles any nodes whose values are all the s...
Definition: Tree.h:517
NodeIteratorBase< const Tree, typename RootNodeType::ChildOnCIter > NodeCIter
Iterator over all nodes in this tree.
Definition: Tree.h:1156
Tree< typename RootNodeType::template ValueConverter< OtherValueType >::Type > Type
Definition: Tree.h:226
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:47
boost::shared_ptr< TreeBase > Ptr
Definition: Tree.h:68
const RootNodeType & root() const
Return this tree's root node.
Definition: Tree.h:308
virtual Index64 memUsage() const
Return the total amount of memory in bytes occupied by this tree.
Definition: Tree.h:155
FormattedInt< IntT > formattedInt(IntT n)
Definition: Formats.h:130
CombineOpAdapter(CombineOp &_op)
Definition: Tree.h:1900
Base class for tree-traversal iterators over tile and voxel values.
Definition: TreeIterator.h:658
RootNodeType::ChildOffCIter cbeginRootTiles() const
Return an iterator over non-child entries of the root node's table.
Definition: Tree.h:1141
virtual const Name & type() const
Return the name of this type of tree.
Definition: Tree.h:300
Int32 x() const
Definition: Coord.h:146
TreeIterTraits provides, for all tree iterators, a begin(tree) function that returns an iterator over...
Definition: Tree.h:1324
ValueOffCIter cbeginValueOff() const
Return an iterator over inactive values (tile and voxel) across all nodes.
Definition: Tree.h:1202
TreeValueIteratorBase< Tree, typename RootNodeType::ValueOnIter > ValueOnIter
Definition: Tree.h:1181
Tree4<T, N1, N2, N3>::Type is the type of a four-level tree (Root, Internal, Internal, Leaf) with value type T and internal and leaf node log dimensions N1, N2 and N3, respectively.
Definition: Tree.h:1266
Tree(const Tree &other)
Deep copy constructor.
Definition: Tree.h:233
NodeType **const mNodes
Definition: Tree.h:1234
const AValueType & a() const
Get the A input value.
Definition: Types.h:352
TreeValueIteratorBase< const Tree, typename RootNodeType::ValueOnCIter > ValueOnCIter
Definition: Tree.h:1182
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: Tree.h:1637
Index32 Index
Definition: Types.h:58
TreeValueIteratorBase< Tree, typename RootNodeType::ValueOffIter > ValueOffIter
Definition: Tree.h:1183
_RootNodeType RootNodeType
Definition: Tree.h:211
OPENVDB_DEPRECATED void addLeaf(LeafNodeType &leaf)
Add the given leaf node to this tree, creating a new branch if necessary. If a leaf node with the sam...
Definition: Tree.h:530
static TreeT::NodeCIter begin(const TreeT &tree)
Definition: Tree.h:1367
Tree()
Definition: Tree.h:230
Tree(const OtherTreeType &other, const ValueType &background, TopologyCopy)
Topology copy constructor from a tree of a different type.
Definition: Tree.h:280
static TreeT::ValueAllIter begin(TreeT &tree)
Definition: Tree.h:1395
Index64 activeTileCount() const
Return the total number of active tiles.
Definition: Tree.h:380
RootNodeType::ChildOnCIter cbeginRootChildren() const
Return an iterator over children of the root node.
Definition: Tree.h:1134
uint64_t Index64
Definition: Types.h:57
Internal table nodes for OpenVDB trees.
static TreeT::RootNodeType::ChildOnCIter begin(const TreeT &tree)
Definition: Tree.h:1333
#define OPENVDB_VERSION_NAME
Definition: version.h:43
NodeCIter beginNode() const
Return an iterator over all nodes in this tree.
Definition: Tree.h:1168
void attachAccessor(ValueAccessorBase< const Tree, false > &) const
Dummy implementations.
Definition: Tree.h:651
LeafCIter cbeginLeaf() const
Return an iterator over all leaf nodes in this tree.
Definition: Tree.h:1176
void setActiveState(const Coord &xyz, bool on)
Set the active state of the voxel at the given coordinates but don't change its value.
Definition: Tree.h:1629
tbb::concurrent_hash_map< ValueAccessorBase< Tree, true > *, bool > AccessorRegistry
Definition: Tree.h:1214
void clear()
Remove all tiles from this tree and all nodes other than the root node.
Definition: Tree.h:1486
const BValueType & b() const
Get the B input value.
Definition: Types.h:354
static TreeT::NodeIter begin(TreeT &tree)
Definition: Tree.h:1363
ValueOnCIter cbeginValueOn() const
Return an iterator over active values (tile and voxel) across all nodes.
Definition: Tree.h:1196
const AValueType & result() const
Get the output value.
Definition: Types.h:357
TreeValueIteratorBase< Tree, typename RootNodeType::ValueAllIter > ValueAllIter
Definition: Tree.h:1179
#define OPENVDB_LOG_WARN(message)
Log a warning message of the form 'someVar << "some text" << ...'.
Definition: logging.h:39
bool empty() const
Return true if this tree contains no nodes other than the root node and no tiles other than backgroun...
Definition: Tree.h:633
const ValueType & background() const
Return this tree's background value.
Definition: Tree.h:675
Coord extents() const
Definition: Coord.h:365
OPENVDB_API int printBytes(std::ostream &os, uint64_t bytes, const std::string &head="", const std::string &tail="\, bool exact=false, int width=8, int precision=3)
void clearAllAccessors()
Clear all registered accessors.
Definition: Tree.h:1545
virtual ~Tree()
Definition: Tree.h:289
bool isValueOn(const Coord &xyz) const
Return true if the value at the given coordinates is active.
Definition: Tree.h:468
MergePolicy
Definition: Types.h:264
virtual TreeBase::Ptr copy() const
Return a pointer to a deep copy of this tree.
Definition: Tree.h:292
static TreeT::RootNodeType::ChildOnIter begin(TreeT &tree)
Definition: Tree.h:1327
Definition: Exceptions.h:39
const LeafNodeType * probeConstLeaf(const Coord &xyz) const
Return a pointer to the leaf node that contains voxel (x, y, z). If no such node exists, return NULL.
Definition: Tree.h:1740
Tree(const ValueType &background)
Empty tree constructor.
Definition: Tree.h:287
boost::shared_ptr< Tree > Ptr
Definition: Tree.h:208
uint32_t Index32
Definition: Types.h:56
Tree3<T, N1, N2>::Type is the type of a three-level tree (Root, Internal, Leaf) with value type T and...
Definition: Tree.h:1256
static TreeT::ValueAllCIter begin(const TreeT &tree)
Definition: Tree.h:1399
CombineOp & op
Definition: Tree.h:1906
Base class for tree-traversal iterators over all leaf nodes (but not leaf voxels) ...
Definition: TreeIterator.h:1228
TreeValueIteratorBase< const Tree, typename RootNodeType::ValueOffCIter > ValueOffCIter
Definition: Tree.h:1184
virtual Name valueType() const
Return the name of the type of a voxel's value (e.g., "float" or "vec3d")
Definition: Tree.h:295
Int32 z() const
Definition: Coord.h:148
RootNodeType::BuildType BuildType
Definition: Tree.h:213
Helper class to adapt a three-argument (a, b, result) CombineOp functor into a single-argument functo...
Definition: Tree.h:1898
RootNodeType::ChildOnIter beginRootChildren()
Return an iterator over children of the root node.
Definition: Tree.h:1135
virtual Index32 leafCount() const
Return the number of leaf nodes.
Definition: Tree.h:368
bool hasActiveTiles() const
Return true if this tree has any active tiles.
Definition: Tree.h:472
bool operator!=(const Tree &) const
Definition: Tree.h:303
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: Tree.h:1588
bool probeValue(const Coord &xyz, ValueType &value) const
Get the value of the voxel at the given coordinates.
Definition: Tree.h:1694
LeafNodeType * probeLeaf(const Coord &xyz)
Return a pointer to the leaf node that contains voxel (x, y, z). If no such node exists, return NULL.
Definition: Tree.h:1732
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:259
Definition: Exceptions.h:84
The root node of an OpenVDB tree.
void fill(const CoordBBox &bbox, const ValueType &value, bool active=true)
Set all voxels within a given axis-aligned box to a constant value.
Definition: Tree.h:496
NodeCIter cbeginNode() const
Return an iterator over all nodes in this tree.
Definition: Tree.h:1169
virtual Index treeDepth() const
Return the depth of this tree.
Definition: Tree.h:366
Int32 y() const
Definition: Coord.h:147
static TreeT::ValueOnCIter begin(const TreeT &tree)
Definition: Tree.h:1383
static TreeT::LeafCIter begin(const TreeT &tree)
Definition: Tree.h:1375
static TreeT::LeafIter begin(TreeT &tree)
Definition: Tree.h:1371
static tbb::atomic< const Name * > sTreeTypeName
Definition: Tree.h:1244
virtual void writeTopology(std::ostream &, bool saveFloatAsHalf=false) const
Write the tree topology to a stream.
Definition: Tree.h:1294
static TreeT::ValueOnIter begin(TreeT &tree)
Definition: Tree.h:1379
static TreeT::ValueOffCIter begin(const TreeT &tree)
Definition: Tree.h:1391
This base class for ValueAccessors manages registration of an accessor with a tree so that the tree c...
Definition: ValueAccessor.h:121
static TreeT::RootNodeType::ChildOffCIter begin(const TreeT &tree)
Definition: Tree.h:1345
RootNodeType::ChildAllIter beginRootDense()
Return an iterator over all entries of the root node's table.
Definition: Tree.h:1149
virtual void getIndexRange(CoordBBox &bbox) const
Min and max are both inclusive.
Definition: Tree.h:678
Tree(const Tree< OtherRootType > &other)
Value conversion deep copy constructor.
Definition: Tree.h:244
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
virtual void writeBuffers(std::ostream &, bool saveFloatAsHalf=false) const
Write out all data buffers for this tree.
Definition: Tree.h:1478
virtual Index64 activeLeafVoxelCount() const
Return the number of active voxels stored in leaf nodes.
Definition: Tree.h:372
RootNodeType::LeafNodeType LeafNodeType
Definition: Tree.h:214
static TreeT::ValueOffIter begin(TreeT &tree)
Definition: Tree.h:1387
ValueOnCIter beginValueOn() const
Return an iterator over active values (tile and voxel) across all nodes.
Definition: Tree.h:1195
virtual Metadata::Ptr getBackgroundValue() const
Return this tree's background value wrapped as metadata.
Definition: Tree.h:88
tbb::concurrent_hash_map< ValueAccessorBase< const Tree, true > *, bool > ConstAccessorRegistry
Definition: Tree.h:1215
void operator()(CombineArgs< AValueT, BValueT > &args) const
Definition: Tree.h:1902
void releaseAccessor(ValueAccessorBase< const Tree, false > &) const
Dummy implementations.
Definition: Tree.h:663
virtual Index64 memUsage() const
Return the total amount of memory in bytes occupied by this tree.
Definition: Tree.h:385
LeafIteratorBase< const Tree, typename RootNodeType::ChildOnCIter > LeafCIter
Iterator over all leaf nodes in this tree.
Definition: Tree.h:1162
Tree< RootNode< InternalNode< InternalNode< LeafNode< T, N3 >, N2 >, N1 > > > Type
Definition: Tree.h:1267
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
Definition: Types.h:312
LeafCIter beginLeaf() const
Return an iterator over all leaf nodes in this tree.
Definition: Tree.h:1175
virtual ~TreeBase()
Definition: Tree.h:72
void stealNodes(ArrayT &array)
Steals all nodes of a certain type from the tree and adds them to a container with the following API:...
Definition: Tree.h:620
TreeBase()
Definition: Tree.h:71
AccessorRegistry mAccessorRegistry
Definition: Tree.h:1241
void addTile(Index level, const Coord &xyz, const ValueType &value, bool active)
Add a tile containing voxel (x, y, z) at the specified tree level, creating a new branch if necessary...
Definition: Tree.h:1705
virtual void readTopology(std::istream &, bool saveFloatAsHalf=false)
Read the tree topology from a stream.
Definition: Tree.h:1285
bool hasSameTopology(const Tree< OtherRootNodeType > &other) const
Return true if the given tree has the same node and active value topology as this tree...
Definition: Tree.h:2128
static TreeT::RootNodeType::ChildAllCIter begin(const TreeT &tree)
Definition: Tree.h:1357
void stealNodes(ArrayT &array, const ValueType &value, bool state)
Definition: Tree.h:622
boost::shared_ptr< const Tree > ConstPtr
Definition: Tree.h:209
LeafNodeType * touchLeaf(const Coord &xyz)
Return a pointer to the leaf node that contains voxel (x, y, z). If no such node exists, create one that preserves the values and active states of all voxels.
Definition: Tree.h:1724