OpenVDB: FindActiveValues.h Source File

OpenVDB 8.0.0

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