OpenVDB  8.1.1
FindActiveValues.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3 
5 //
21 
22 #ifndef OPENVDB_TOOLS_FINDACTIVEVALUES_HAS_BEEN_INCLUDED
23 #define OPENVDB_TOOLS_FINDACTIVEVALUES_HAS_BEEN_INCLUDED
24 
25 #include <vector>
26 #include <openvdb/version.h> // for OPENVDB_VERSION_NAME
27 #include <openvdb/Types.h>
29 
30 #include "Count.h" // tools::countActiveVoxels()
31 
32 #include <tbb/blocked_range.h>
33 #include <tbb/parallel_for.h>
34 #include <tbb/parallel_reduce.h>
35 
36 namespace openvdb {
38 namespace OPENVDB_VERSION_NAME {
39 namespace tools {
40 
45 template<typename ValueType>
46 struct TileData;
47 
57 template<typename TreeT>
58 inline bool
59 anyActiveValues(const TreeT& tree, const CoordBBox &bbox);
60 
73 template<typename TreeT>
74 inline bool
75 anyActiveVoxels(const TreeT& tree, const CoordBBox &bbox);
76 
86 template<typename TreeT>
87 inline bool
88 anyActiveTiles(const TreeT& tree, const CoordBBox &bbox);
89 
99 template<typename TreeT>
100 inline bool
101 noActiveValues(const TreeT& tree, const CoordBBox &bbox);
102 
112 template<typename TreeT>
113 inline Index64
114 countActiveValues(const TreeT& tree, const CoordBBox &bbox);
115 
125 template<typename TreeT>
126 inline std::vector<TileData<typename TreeT::ValueType>>
127 activeTiles(const TreeT& tree, const CoordBBox &bbox);
128 
130 
138 template<typename TreeT>
140 {
141 public:
142 
144 
146  FindActiveValues(const TreeT& tree);
147 
149  ~FindActiveValues();
150 
152  void update(const TreeT& tree);
153 
159  bool anyActiveValues(const CoordBBox &bbox, bool useAccessor = false) const;
160 
162  bool anyActiveVoxels(const CoordBBox &bbox) const;
163 
165  bool anyActiveTiles(const CoordBBox &bbox) const;
166 
172  bool noActiveValues(const CoordBBox &bbox, bool useAccessor = false) const { return !this->anyActiveValues(bbox, useAccessor); }
173 
175  Index64 count(const CoordBBox &bbox) const;
176 
179  std::vector<TileDataT> activeTiles(const CoordBBox &bbox) const;
180 
181  OPENVDB_DEPRECATED_MESSAGE("Use anyActiveValues() instead") inline bool any(const CoordBBox &bbox, bool useAccessor = false) const
182  {
183  return this->anyActiveValues(bbox, useAccessor);
184  }
185  OPENVDB_DEPRECATED_MESSAGE("Use noActiveValues() instead") inline bool none(const CoordBBox &bbox, bool useAccessor = false) const
186  {
187  return this->noActiveValues(bbox, useAccessor);
188  }
189 
190 private:
191 
192  // Cleans up internal data structures
193  void clear();
194 
195  // builds internal data structures
196  void init(const TreeT &tree);
197 
198  template<typename NodeT>
199  typename NodeT::NodeMaskType getBBoxMask(const CoordBBox &bbox, const NodeT* node) const;
200 
201  // process leaf nodes
202  inline bool anyActiveValues(const typename TreeT::LeafNodeType* leaf, const CoordBBox &bbox ) const { return this->anyActiveVoxels(leaf, bbox); }
203  inline bool anyActiveVoxels(const typename TreeT::LeafNodeType* leaf, const CoordBBox &bbox ) const;
204  static bool anyActiveTiles( const typename TreeT::LeafNodeType*, const CoordBBox& ) {return false;}
205  void activeTiles(const typename TreeT::LeafNodeType*, const CoordBBox&, std::vector<TileDataT>&) const {;}// no-op
206  inline Index64 count(const typename TreeT::LeafNodeType* leaf, const CoordBBox &bbox ) const;
207 
208  // process internal nodes
209  template<typename NodeT>
210  bool anyActiveValues(const NodeT* node, const CoordBBox &bbox) const;
211  template<typename NodeT>
212  bool anyActiveVoxels(const NodeT* node, const CoordBBox &bbox) const;
213  template<typename NodeT>
214  bool anyActiveTiles(const NodeT* node, const CoordBBox &bbox) const;
215  template<typename NodeT>
216  void activeTiles(const NodeT* node, const CoordBBox &bbox, std::vector<TileDataT> &tiles) const;
217  template<typename NodeT>
218  Index64 count(const NodeT* node, const CoordBBox &bbox) const;
219 
220  using AccT = tree::ValueAccessor<const TreeT, false/* IsSafe */>;
221  using RootChildType = typename TreeT::RootNodeType::ChildNodeType;
222 
223  struct RootChild;
224 
225  AccT mAcc;
226  std::vector<TileDataT> mRootTiles;// cache bbox of child nodes (faster to cache than access RootNode)
227  std::vector<RootChild> mRootNodes;// cache bbox of acive tiles (faster to cache than access RootNode)
228 
229 };// FindActiveValues class
230 
232 
233 template<typename TreeT>
234 FindActiveValues<TreeT>::FindActiveValues(const TreeT& tree) : mAcc(tree), mRootTiles(), mRootNodes()
235 {
236  this->init(tree);
237 }
238 
239 template<typename TreeT>
241 {
242  this->clear();
243 }
244 
245 template<typename TreeT>
246 void FindActiveValues<TreeT>::update(const TreeT& tree)
247 {
248  this->clear();
249  mAcc = AccT(tree);
250  this->init(tree);
251 }
252 
253 template<typename TreeT>
255 {
256  mRootNodes.clear();
257  mRootTiles.clear();
258 }
259 
260 template<typename TreeT>
261 void FindActiveValues<TreeT>::init(const TreeT& tree)
262 {
263  const auto &root = tree.root();
264  for (auto i = root.cbeginChildOn(); i; ++i) {
265  mRootNodes.emplace_back(i.getCoord(), &*i);
266  }
267  for (auto i = root.cbeginValueOn(); i; ++i) {
268  mRootTiles.emplace_back(root, i.getCoord(), *i);
269  }
270 }
271 
272 template<typename TreeT>
273 bool FindActiveValues<TreeT>::anyActiveValues(const CoordBBox &bbox, bool useAccessor) const
274 {
275  // test early-out: the center of the bbox is active
276  if (useAccessor) {
277  if (mAcc.isValueOn( (bbox.min() + bbox.max())>>1 )) return true;
278  } else {
279  if (mAcc.tree().isValueOn( (bbox.min() + bbox.max())>>1 )) return true;
280  }
281 
282  for (auto& tile : mRootTiles) {
283  if (tile.bbox.hasOverlap(bbox)) return true;
284  }
285  for (auto& node : mRootNodes) {
286  if (!node.bbox.hasOverlap(bbox)) {// no overlap
287  continue;
288  } else if (node.bbox.isInside(bbox)) {// bbox is inside the child node
289  return this->anyActiveValues(node.child, bbox);
290  } else if (this->anyActiveValues(node.child, bbox)) {// bbox overlaps the child node
291  return true;
292  }
293  }
294  return false;
295 }
296 
297 template<typename TreeT>
298 bool FindActiveValues<TreeT>::anyActiveVoxels(const CoordBBox &bbox) const
299 {
300  for (auto& node : mRootNodes) {
301  if (!node.bbox.hasOverlap(bbox)) {// no overlap
302  continue;
303  } else if (node.bbox.isInside(bbox)) {// bbox is inside the child node
304  return this->anyActiveVoxels(node.child, bbox);
305  } else if (this->anyActiveVoxels(node.child, bbox)) {// bbox overlaps the child node
306  return true;
307  }
308  }
309  return false;
310 }
311 
312 template<typename TreeT>
313 bool FindActiveValues<TreeT>::anyActiveTiles(const CoordBBox &bbox) const
314 {
315  for (auto& tile : mRootTiles) {
316  if (tile.bbox.hasOverlap(bbox)) return true;
317  }
318  for (auto& node : mRootNodes) {
319  if (!node.bbox.hasOverlap(bbox)) {// no overlap
320  continue;
321  } else if (node.bbox.isInside(bbox)) {// bbox is inside the child node
322  return this->anyActiveTiles(node.child, bbox);
323  } else if (this->anyActiveTiles(node.child, bbox)) {// bbox overlaps the child node
324  return true;
325  }
326  }
327  return false;
328 }
329 
330 template<typename TreeT>
331 Index64 FindActiveValues<TreeT>::count(const CoordBBox &bbox) const
332 {
333  Index64 count = 0;
334  for (auto& tile : mRootTiles) {//loop over active tiles only
335  if (!tile.bbox.hasOverlap(bbox)) {
336  continue;//ignore non-overlapping tiles
337  } else if (tile.bbox.isInside(bbox)) {
338  return bbox.volume();// bbox is completely inside the active tile
339  } else if (bbox.isInside(tile.bbox)) {
340  count += RootChildType::NUM_VOXELS;
341  } else {// partial overlap between tile and bbox
342  auto tmp = tile.bbox;
343  tmp.intersect(bbox);
344  count += tmp.volume();
345  }
346  }
347  for (auto &node : mRootNodes) {//loop over child nodes of the root node only
348  if ( !node.bbox.hasOverlap(bbox) ) {
349  continue;//ignore non-overlapping child nodes
350  } else if ( node.bbox.isInside(bbox) ) {
351  return this->count(node.child, bbox);// bbox is completely inside the child node
352  } else {
353  count += this->count(node.child, bbox);
354  }
355  }
356  return count;
357 }
358 
359 template<typename TreeT>
360 std::vector<TileData<typename TreeT::ValueType> >
361 FindActiveValues<TreeT>::activeTiles(const CoordBBox &bbox) const
362 {
363  std::vector<TileDataT> tiles;
364  for (auto& tile : mRootTiles) {//loop over active tiles only
365  if (!tile.bbox.hasOverlap(bbox)) {
366  continue;//ignore non-overlapping tiles
367  } else if (tile.bbox.isInside(bbox)) {// bbox is completely inside the active tile
368  tiles.emplace_back(bbox, tile.value, tile.level);
369  return tiles;
370  } else if (bbox.isInside(tile.bbox)) {// active tile is completely inside the bbox
371  tiles.push_back(tile);
372  } else {// partial overlap between tile and bbox
373  auto tmp = tile.bbox;
374  tmp.intersect(bbox);
375  tiles.emplace_back(tmp, tile.value, tile.level);
376  }
377  }
378  for (auto &node : mRootNodes) {//loop over child nodes of the root node only
379  if ( !node.bbox.hasOverlap(bbox) ) {
380  continue;//ignore non-overlapping child nodes
381  } else if ( node.bbox.isInside(bbox) ) {// bbox is completely inside the child node
382  this->activeTiles(node.child, bbox, tiles);
383  return tiles;
384  } else {// partial overlap between tile and child node
385  this->activeTiles(node.child, bbox, tiles);
386  }
387  }
388  return tiles;
389 }
390 
391 template<typename TreeT>
392 template<typename NodeT>
393 typename NodeT::NodeMaskType FindActiveValues<TreeT>::getBBoxMask(const CoordBBox &bbox, const NodeT* node) const
394 {
395  typename NodeT::NodeMaskType mask;// typically 32^3 or 16^3 bit mask
396  auto b = node->getNodeBoundingBox();
397  assert( bbox.hasOverlap(b) );
398  if ( bbox.isInside(b) ) {
399  mask.setOn();//node is completely inside the bbox so early out
400  } else {
401  b.intersect(bbox);// trim bounding box
402  // transform bounding box from global to local coordinates
403  b.min() &= NodeT::DIM-1u;
404  b.min() >>= NodeT::ChildNodeType::TOTAL;
405  b.max() &= NodeT::DIM-1u;
406  b.max() >>= NodeT::ChildNodeType::TOTAL;
407  assert( b.hasVolume() );
408  auto it = b.begin();// iterates over all the child nodes or tiles that intersects bbox
409  for (const Coord& ijk = *it; it; ++it) {
410  mask.setOn(ijk[2] + (ijk[1] << NodeT::LOG2DIM) + (ijk[0] << 2*NodeT::LOG2DIM));
411  }
412  }
413  return mask;
414 }
415 
416 template<typename TreeT>
417 template<typename NodeT>
418 bool FindActiveValues<TreeT>::anyActiveValues(const NodeT* node, const CoordBBox &bbox) const
419 {
420  // Generate a bit mask of the bbox coverage
421  auto mask = this->getBBoxMask(bbox, node);
422 
423  // Check active tiles
424  const auto tmp = mask & node->getValueMask();// prune active the tile mask with the bbox mask
425  if (!tmp.isOff()) return true;
426 
427  // Check child nodes
428  mask &= node->getChildMask();// prune the child mask with the bbox mask
429  const auto* table = node->getTable();
430  bool active = false;
431  for (auto i = mask.beginOn(); !active && i; ++i) {
432  active = this->anyActiveValues(table[i.pos()].getChild(), bbox);
433  }
434  return active;
435 }
436 
437 template<typename TreeT>
438 template<typename NodeT>
439 bool FindActiveValues<TreeT>::anyActiveVoxels(const NodeT* node, const CoordBBox &bbox) const
440 {
441  // Generate a bit mask of the bbox coverage
442  auto mask = this->getBBoxMask(bbox, node);
443 
444  // Check child nodes
445  mask &= node->getChildMask();// prune the child mask with the bbox mask
446  const auto* table = node->getTable();
447  bool active = false;
448  for (auto i = mask.beginOn(); !active && i; ++i) {
449  active = this->anyActiveVoxels(table[i.pos()].getChild(), bbox);
450  }
451  return active;
452 }
453 
454 template<typename TreeT>
455 inline bool FindActiveValues<TreeT>::anyActiveVoxels(const typename TreeT::LeafNodeType* leaf, const CoordBBox &bbox ) const
456 {
457  const auto &mask = leaf->getValueMask();
458 
459  // check for two common cases that leads to early-out
460  if (bbox.isInside(leaf->getNodeBoundingBox())) return !mask.isOff();// leaf in inside the bbox
461  if (mask.isOn()) return true;// all values are active
462 
463  bool active = false;
464  for (auto i = leaf->cbeginValueOn(); !active && i; ++i) {
465  active = bbox.isInside(i.getCoord());
466  }
467  return active;
468 }
469 
470 template<typename TreeT>
471 template<typename NodeT>
472 bool FindActiveValues<TreeT>::anyActiveTiles(const NodeT* node, const CoordBBox &bbox) const
473 {
474  // Generate a bit mask of the bbox coverage
475  auto mask = this->getBBoxMask(bbox, node);
476 
477  // Check active tiles
478  const auto tmp = mask & node->getValueMask();// prune active the tile mask with the bbox mask
479  if (!tmp.isOff()) return true;
480 
481  bool active = false;
482  if (NodeT::LEVEL>1) {// Only check child nodes if they are NOT leaf nodes
483  mask &= node->getChildMask();// prune the child mask with the bbox mask
484  const auto* table = node->getTable();
485  for (auto i = mask.beginOn(); !active && i; ++i) {
486  active = this->anyActiveTiles(table[i.pos()].getChild(), bbox);
487  }
488  }
489  return active;
490 }
491 
492 template<typename TreeT>
493 inline Index64 FindActiveValues<TreeT>::count(const typename TreeT::LeafNodeType* leaf, const CoordBBox &bbox ) const
494 {
495  Index64 count = 0;
496  auto b = leaf->getNodeBoundingBox();
497  if (b.isInside(bbox)) { // leaf node is completely inside bbox
498  count = leaf->onVoxelCount();
499  } else if (leaf->isDense()) {
500  b.intersect(bbox);
501  count = b.volume();
502  } else if (b.hasOverlap(bbox)) {
503  for (auto i = leaf->cbeginValueOn(); i; ++i) {
504  if (bbox.isInside(i.getCoord())) ++count;
505  }
506  }
507  return count;
508 }
509 
510 template<typename TreeT>
511 template<typename NodeT>
512 Index64 FindActiveValues<TreeT>::count(const NodeT* node, const CoordBBox &bbox) const
513 {
514  Index64 count = 0;
515 
516  // Generate a bit masks
517  auto mask = this->getBBoxMask(bbox, node);
518  const auto childMask = mask & node->getChildMask();// prune the child mask with the bbox mask
519  mask &= node->getValueMask();// prune active tile mask with the bbox mask
520  const auto* table = node->getTable();
521 
522  {// Check child nodes
523  using ChildT = typename NodeT::ChildNodeType;
524  using RangeT = tbb::blocked_range<typename std::vector<const ChildT*>::iterator>;
525  std::vector<const ChildT*> childNodes(childMask.countOn());
526  int j=0;
527  for (auto i = childMask.beginOn(); i; ++i, ++j) childNodes[j] = table[i.pos()].getChild();
528  count += tbb::parallel_reduce( RangeT(childNodes.begin(), childNodes.end()), 0,
529  [&](const RangeT& r, Index64 sum)->Index64 {
530  for ( auto i = r.begin(); i != r.end(); ++i ) sum += this->count(*i, bbox);
531  return sum;
532  }, []( Index64 a, Index64 b )->Index64 { return a+b; }
533  );
534  }
535 
536  {// Check active tiles
537  std::vector<Coord> coords(mask.countOn());
538  using RangeT = tbb::blocked_range<typename std::vector<Coord>::iterator>;
539  int j=0;
540  for (auto i = mask.beginOn(); i; ++i, ++j) coords[j] = node->offsetToGlobalCoord(i.pos());
541  count += tbb::parallel_reduce( RangeT(coords.begin(), coords.end()), 0,
542  [&bbox](const RangeT& r, Index64 sum)->Index64 {
543  for ( auto i = r.begin(); i != r.end(); ++i ) {
544  auto b = CoordBBox::createCube(*i, NodeT::ChildNodeType::DIM);
545  b.intersect(bbox);
546  sum += b.volume();
547  }
548  return sum;
549  }, []( Index64 a, Index64 b )->Index64 { return a+b; }
550  );
551  }
552 
553  return count;
554 }
555 
556 // process internal node
557 template<typename TreeT>
558 template<typename NodeT>
559 void FindActiveValues<TreeT>::activeTiles(const NodeT* node, const CoordBBox &bbox, std::vector<TileDataT> &tiles) const
560 {
561  // Generate a bit masks
562  auto mask = this->getBBoxMask(bbox, node);
563  const auto childMask = mask & node->getChildMask();// prune the child mask with the bbox mask
564  mask &= node->getValueMask();// prune active tile mask with the bbox mask
565 
566  if (NodeT::LEVEL > 1) {// Only check child nodes if they are NOT leaf nodes
567  const auto* table = node->getTable();
568  for (auto i = childMask.beginOn(); i; ++i) this->activeTiles(table[i.pos()].getChild(), bbox, tiles);
569  }
570 
571  const size_t tileCount = mask.countOn();
572  if (tileCount < 8) {// Serial processing of active tiles
573  for (auto iter = mask.beginOn(); iter; ++iter) {
574  tiles.emplace_back(*node, iter.pos());
575  tiles.back().bbox.intersect(bbox);
576  }
577  } else {// Parallel processing of active tiles
578  std::vector<TileDataT> tmp( tileCount );// for temporary thread-safe processing
579  int n = 0;
580  for (auto iter = mask.beginOn(); iter; ++iter) tmp[n++].level = iter.pos();// placeholder to support multi-threading
581  tbb::parallel_for(tbb::blocked_range<size_t>(0, tileCount, 8), [&](const tbb::blocked_range<size_t>& r) {
582  for ( size_t i = r.begin(); i != r.end(); ++i ) {
583  tmp[i] = TileDataT(*node, tmp[i].level);
584  tmp[i].bbox.intersect(bbox);
585  }
586  });
587  tiles.insert(tiles.end(), tmp.begin(), tmp.end());
588  }
589 }
590 
591 template<typename TreeT>
593 {
594  const CoordBBox bbox;
596  RootChild(const Coord& ijk = Coord(), const RootChildType* ptr = nullptr)
597  : bbox(CoordBBox::createCube(ijk, RootChildType::DIM)), child(ptr)
598  {
599  }
600 };// RootChild struct
601 
603 
604 template<typename ValueType>
605 struct TileData
606 {
607  CoordBBox bbox;
608  ValueType value;
610  bool state;
611 
613  TileData() = default;
614 
616  TileData(const CoordBBox &b, const ValueType &v, Index l, bool active = true)
617  : bbox(b), value(v), level(l), state(active) {}
618 
624  template <typename ParentNodeT>
625  TileData(const ParentNodeT &parent, Index childIdx)
626  : bbox(CoordBBox::createCube(parent.offsetToGlobalCoord(childIdx), parent.getChildDim()))
627  , level(parent.getLevel())
628  , state(true)
629  {
630  assert(childIdx < ParentNodeT::NUM_VALUES);
631  assert(parent.isChildMaskOff(childIdx));
632  assert(parent.isValueMaskOn(childIdx));
633  value = parent.getTable()[childIdx].getValue();
634  }
635 
638  template <typename ParentNodeT>
639  TileData(const ParentNodeT &parent, const Coord &ijk, const ValueType &v)
640  : bbox(CoordBBox::createCube(ijk, parent.getChildDim()))
641  , value(v)
642  , level(parent.getLevel())
643  , state(true)
644  {
645  }
646 };// TileData struct
647 
649 
650 // Implementation of stand-alone function
651 template<typename TreeT>
652 inline bool
653 anyActiveValues(const TreeT& tree, const CoordBBox &bbox)
654 {
655  FindActiveValues<TreeT> op(tree);
656  return op.anyActiveValues(bbox);
657 }
658 
659 // Implementation of stand-alone function
660 template<typename TreeT>
661 inline bool
662 anyActiveVoxels(const TreeT& tree, const CoordBBox &bbox)
663 {
664  FindActiveValues<TreeT> op(tree);
665  return op.anyActiveVoxels(bbox);
666 }
667 
668 // Implementation of stand-alone function
669 template<typename TreeT>
670 inline bool
671 anyActiveTiles(const TreeT& tree, const CoordBBox &bbox)
672 {
673  FindActiveValues<TreeT> op(tree);
674  return op.anyActiveTiles(bbox);
675 }
676 
677 // Implementation of stand-alone function
678 template<typename TreeT>
679 inline bool
680 noActiveValues(const TreeT& tree, const CoordBBox &bbox)
681 {
682  FindActiveValues<TreeT> op(tree);
683  return op.noActiveValues(bbox);
684 }
685 
686 // Implementation of stand-alone function
687 template<typename TreeT>
688 inline Index64
689 countActiveValues(const TreeT& tree, const CoordBBox &bbox)
690 {
691  return tools::countActiveVoxels(tree, bbox);
692 }
693 
694 // Implementation of stand-alone function
695 template<typename TreeT>
696 inline std::vector<TileData<typename TreeT::ValueType>>
697 activeTiles(const TreeT& tree, const CoordBBox &bbox)
698 {
699  FindActiveValues<TreeT> op(tree);
700  return op.activeTiles(bbox);
701 }
702 
703 } // namespace tools
704 } // namespace OPENVDB_VERSION_NAME
705 } // namespace openvdb
706 
707 #endif // OPENVDB_TOOLS_FINDACTIVEVALUES_HAS_BEEN_INCLUDED
Definition: FindActiveValues.h:592
typename TreeT::RootNodeType::ChildNodeType RootChildType
Definition: FindActiveValues.h:221
bool useAccessor
Definition: FindActiveValues.h:181
std::vector< TileData< typename TreeT::ValueType > > activeTiles(const TreeT &tree, const CoordBBox &bbox)
Return a vector with bounding boxes that represents all the intersections between active tiles in the...
Definition: FindActiveValues.h:697
bool anyActiveValues(const CoordBBox &bbox, bool useAccessor=false) const
Returns true if the specified bounding box intersects any active values.
Definition: FindActiveValues.h:273
Finds the active values in a tree which intersects a bounding box.
Definition: FindActiveValues.h:139
Level getLevel()
Return the current logging level.
Definition: logging.h:138
TileData(const CoordBBox &b, const ValueType &v, Index l, bool active=true)
Member data constructor.
Definition: FindActiveValues.h:616
bool noActiveValues(const CoordBBox &bbox, bool useAccessor=false) const
Returns true if the specified bounding box does not intersect any active values.
Definition: FindActiveValues.h:172
Index level
Definition: FindActiveValues.h:609
CoordBBox bbox
Definition: FindActiveValues.h:607
void init(const TreeT &tree)
Definition: FindActiveValues.h:261
TileData(const ParentNodeT &parent, const Coord &ijk, const ValueType &v)
Constructor form a parent node, the coordinate of the origin of one of its tiles, and said tiles valu...
Definition: FindActiveValues.h:639
void activeTiles(const typename TreeT::LeafNodeType *, const CoordBBox &, std::vector< TileDataT > &) const
Definition: FindActiveValues.h:205
Index64 count(const CoordBBox &bbox) const
Returns the number of active voxels intersected by the specified bounding box.
Definition: FindActiveValues.h:331
bool anyActiveTiles(const TreeT &tree, const CoordBBox &bbox)
Returns true if the bounding box intersects any of the active tiles in a tree, i.e. ignores active leaf values.
Definition: FindActiveValues.h:671
bool anyActiveValues(const TreeT &tree, const CoordBBox &bbox)
Returns true if the bounding box intersects any of the active values in a tree, i.e. either active voxels or active tiles.
Definition: FindActiveValues.h:653
bool anyActiveVoxels(const CoordBBox &bbox) const
Returns true if the specified bounding box intersects any active tiles only.
Definition: FindActiveValues.h:298
std::vector< TileDataT > activeTiles(const CoordBBox &bbox) const
Return a vector with bounding boxes that represents all the intersections between active tiles in the...
Definition: FindActiveValues.h:361
void update(const TreeT &tree)
Initiate this class with a new (or modified) tree.
Definition: FindActiveValues.h:246
TileData(const ParentNodeT &parent, Index childIdx)
Constructor from a parent node and the linear offset to one of its tiles.
Definition: FindActiveValues.h:625
Index32 Index
Definition: openvdb/Types.h:50
RootChild(const Coord &ijk=Coord(), const RootChildType *ptr=nullptr)
Definition: FindActiveValues.h:596
const CoordBBox bbox
Definition: FindActiveValues.h:594
TileData< typename TreeT::ValueType > TileDataT
Definition: FindActiveValues.h:143
bool anyActiveValues(const typename TreeT::LeafNodeType *leaf, const CoordBBox &bbox) const
Definition: FindActiveValues.h:202
Definition: openvdb/Exceptions.h:13
static bool anyActiveTiles(const typename TreeT::LeafNodeType *, const CoordBBox &)
Definition: FindActiveValues.h:204
uint64_t Index64
Definition: openvdb/Types.h:49
Index64 countActiveVoxels(const TreeT &tree, bool threaded=true)
Return the total number of active voxels in the tree.
Definition: Count.h:210
bool anyActiveVoxels(const TreeT &tree, const CoordBBox &bbox)
Returns true if the bounding box intersects any of the active voxels in a tree, i.e. ignores active tile values.
Definition: FindActiveValues.h:662
Struct that encodes a bounding box, value and level of a tile.
Definition: FindActiveValues.h:46
NodeT::NodeMaskType getBBoxMask(const CoordBBox &bbox, const NodeT *node) const
Definition: FindActiveValues.h:393
bool state
Definition: FindActiveValues.h:610
std::vector< TileDataT > mRootTiles
Definition: FindActiveValues.h:226
bool isValueOn(const Coord &xyz) const
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:226
tree::ValueAccessor< const TreeT, false > AccT
Definition: FindActiveValues.h:220
Functions to count tiles, nodes or voxels in a grid.
AccT mAcc
Definition: FindActiveValues.h:223
ValueType value
Definition: FindActiveValues.h:608
TreeType & tree() const
Return a reference to the tree associated with this accessor.
Definition: ValueAccessor.h:110
std::vector< RootChild > mRootNodes
Definition: FindActiveValues.h:227
~FindActiveValues()
Default destructor.
Definition: FindActiveValues.h:240
Index64 countActiveValues(const TreeT &tree, const CoordBBox &bbox)
Returns the number of active values that intersects a bounding box intersects, i.e. the count includes both active voxels and virtual voxels in active tiles.
Definition: FindActiveValues.h:689
bool noActiveValues(const TreeT &tree, const CoordBBox &bbox)
Returns true if the bounding box intersects none of the active values in a tree, i.e. neither active voxels or active tiles.
Definition: FindActiveValues.h:680
const RootChildType * child
Definition: FindActiveValues.h:595
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:116
bool anyActiveTiles(const CoordBBox &bbox) const
Returns true if the specified bounding box intersects any active tiles only.
Definition: FindActiveValues.h:313
#define OPENVDB_DEPRECATED_MESSAGE(msg)
Definition: Platform.h:123
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:178