45 #ifndef OPENVDB_TREE_VALUEACCESSOR_HAS_BEEN_INCLUDED 46 #define OPENVDB_TREE_VALUEACCESSOR_HAS_BEEN_INCLUDED 48 #include <openvdb/version.h> 52 #include <tbb/spin_mutex.h> 55 #include <type_traits> 64 template<
typename TreeType,
66 typename MutexT = void,
84 template<
typename TreeType,
bool IsSafe =
true,
85 size_t CacheLevels =
std::max(
Index(1),TreeType::DEPTH)-1,
typename MutexType =
void>
92 template <
typename TreeType,
bool IsSafe>
98 template <
typename TreeType,
bool IsSafe,
size_t L0 = 0>
106 template <
typename TreeType,
bool IsSafe,
size_t L0 = 0,
size_t L1 = 1>
114 template <
typename TreeType,
bool IsSafe,
size_t L0 = 0,
size_t L1 = 1,
size_t L2 = 2>
119 template<
typename TreeType,
bool IsSafe =
true,
150 template<
typename TreeType,
bool IsSafe>
155 static constexpr
bool IsConstTree = std::is_const<TreeType>::value;
163 static constexpr
bool isSafe() {
return IsSafe; }
171 if (IsSafe) tree.attachAccessor(*
this);
181 if (IsSafe && mTree) mTree->attachAccessor(*
this);
186 if (&other !=
this) {
187 if (IsSafe && mTree) mTree->releaseAccessor(*
this);
189 if (IsSafe && mTree) mTree->attachAccessor(*
this);
204 virtual void clear() = 0;
208 template<
typename>
friend class Tree;
217 namespace value_accessor_internal
220 template<
typename ListT,
size_t... Ts>
struct NodeListBuilderImpl;
222 template <
typename NodeChainT>
223 struct NodeListBuilderImpl<NodeChainT>
228 template <
typename NodeChainT,
size_t Idx>
229 struct NodeListBuilderImpl<NodeChainT, Idx>
231 using NodeT =
typename NodeChainT::template Get<Idx>;
235 template <
typename NodeChainT,
size_t ThisIdx,
size_t NextIdx,
size_t... Idxs>
236 struct NodeListBuilderImpl<NodeChainT, ThisIdx, NextIdx, Idxs...>
238 static_assert(ThisIdx < NextIdx,
239 "Invalid cache level - Cache levels must be in increasing ascending order");
240 static_assert(ThisIdx < NodeChainT::Size,
241 "Invalid cache level - Cache level is larger than the number of tree nodes");
242 static_assert(ThisIdx < NodeChainT::Back::LEVEL,
243 "Invalid cache level - Cache level is larger than the number of tree nodes");
245 using NodeT =
typename NodeChainT::template Get<ThisIdx>;
247 typename NodeListBuilderImpl<NodeChainT, NextIdx, Idxs...>::ListT>;
250 template<
typename NodeChainT,
size_t RootLevel,
typename IntegerSequence>
251 struct NodeListBuilder;
253 template<
typename NodeChainT,
size_t RootLevel,
size_t... Is>
254 struct NodeListBuilder<NodeChainT, RootLevel, std::integer_sequence<size_t, Is...>>
256 using ListT =
typename NodeListBuilderImpl<NodeChainT, Is..., RootLevel>::ListT;
259 template<
typename NodeChainT,
size_t RootLevel,
size_t... Is>
260 struct NodeListBuilder<NodeChainT, RootLevel, openvdb::
index_sequence<Is...>>
262 using ListT =
typename NodeListBuilderImpl<NodeChainT, Is..., RootLevel>::ListT;
266 template<
typename TreeTypeT,
typename NodeT>
267 struct EnableLeafBuffer
269 using LeafNodeT =
typename TreeTypeT::LeafNodeType;
270 static constexpr
bool value =
271 std::is_same<NodeT, LeafNodeT>::value &&
272 std::is_same<
typename LeafNodeT::Buffer::StorageType,
273 typename LeafNodeT::ValueType>::value;
276 template<
typename TreeTypeT,
size_t... Is>
277 struct EnableLeafBuffer<TreeTypeT, openvdb::
index_sequence<Is...>>
280 static constexpr
bool value =
false;
283 template<
typename TreeTypeT,
size_t First,
size_t... Is>
284 struct EnableLeafBuffer<TreeTypeT, openvdb::
index_sequence<First, Is...>>
287 using NodeChainT =
typename TreeTypeT::RootNodeType::NodeChainType;
288 using FirstNodeT =
typename NodeChainT::template Get<First>;
290 static constexpr
bool value = EnableLeafBuffer<TreeTypeT, FirstNodeT>::value;
310 template <
typename MutexT>
313 inline auto lock()
const {
return std::scoped_lock(m); }
322 inline constexpr
auto lock()
const {
return 0; }
331 template<
typename TreeTypeT,
typename IntegerSequence,
typename Enable =
void>
334 template <
typename NodeT>
335 static constexpr
bool BypassLeafAPI =
336 std::is_same<NodeT, typename TreeTypeT::LeafNodeType>::value;
339 inline void setBuffer(
const typename TreeTypeT::ValueType* b)
const { mBuffer = b; }
341 mutable const typename TreeTypeT::ValueType* mBuffer;
346 template<
typename TreeTypeT,
typename IntegerSequence>
348 typename
std::enable_if<
349 !value_accessor_internal::EnableLeafBuffer<TreeTypeT, IntegerSequence>::value
352 template <
typename>
static constexpr
bool BypassLeafAPI =
false;
362 template<
typename _TreeType,
bool IsSafe,
typename MutexT,
typename IntegerSequence>
375 using TreeType = _TreeType;
385 typename value_accessor_internal::NodeListBuilder
387 using NodePtrList =
typename NodeLevelList::template Transform<std::add_pointer_t>;
401 template <
size_t Level>
409 template <
typename NodeT>
410 static constexpr
bool IsLeafAndBypassLeafAPI =
411 LeafCacheT::template BypassLeafAPI<NodeT>;
415 static constexpr
bool BypassLeafAPI =
416 IsLeafAndBypassLeafAPI<NodeTypeAtLevel<0>>;
420 static constexpr
size_t NumCacheLevels = NodeLevelList::Size-1;
421 static_assert(TreeType::DEPTH >= NodeLevelList::Size-1,
"cache size exceeds tree depth");
422 static_assert(NodeLevelList::Size > 0,
"unexpected cache size");
445 using NodeType =
typename NodeLevelList::template Get<Idx>;
447 constexpr
bool IsRoot = std::is_same<RootNodeT, NodeType>::value;
448 if constexpr(IsRoot)
return false;
449 else return (this->isHashed<NodeType>(xyz));
461 using NodeType =
typename NodeLevelList::template Get<Idx>;
465 if (!this->isHashed<NodeType>(xyz))
return nullptr;
467 if constexpr(IsLeafAndBypassLeafAPI<NodeType>) {
468 return &(LeafCacheT::buffer()[LeafNodeT::coordToOffset(xyz)]);
471 auto node = mNodes.template get<Idx>();
473 return &(node->getValueAndCache(xyz, *
this));
482 return this->evalFirstCached(xyz, [&](
const auto node) ->
bool {
484 return node->isValueOnAndCache(xyz, *
this);
494 return this->evalFirstCached(xyz, [&](
const auto node) ->
bool 496 using NodeType = std::remove_pointer_t<decltype(node)>;
499 if constexpr(IsLeafAndBypassLeafAPI<NodeType>) {
500 const auto offset = LeafNodeT::coordToOffset(xyz);
501 value = LeafCacheT::buffer()[offset];
502 return node->isValueOn(offset);
505 return node->probeValueAndCache(xyz, value, *
this);
518 return this->evalFirstCached(xyz, [&](
const auto node) ->
int 520 using NodeType = std::remove_pointer_t<decltype(node)>;
523 if constexpr(std::is_same<RootNodeT, NodeType>::value) {
524 return node->getValueDepthAndCache(xyz, *
this);
527 return int(RootNodeT::LEVEL - node->getValueLevelAndCache(xyz, *
this));
538 return this->getValueDepth(xyz) ==
539 static_cast<int>(RootNodeT::LEVEL);
552 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
553 this->evalFirstCached(xyz, [&](
const auto node) ->
void 555 using NodeType = std::remove_pointer_t<decltype(node)>;
558 if constexpr(IsLeafAndBypassLeafAPI<NodeType>) {
559 const auto offset = LeafNodeT::coordToOffset(xyz);
560 const_cast<ValueType&
>(LeafCacheT::buffer()[offset]) = value;
561 const_cast<NodeType*
>(node)->setValueOn(offset);
564 const_cast<NodeType*
>(node)->setValueAndCache(xyz, value, *
this);
580 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
585 using NodeType =
typename NodeLevelList::template Get<Idx>;
586 if (!this->isHashed<NodeType>(xyz))
return false;
588 if constexpr(IsLeafAndBypassLeafAPI<NodeType>) {
589 const_cast<ValueType&
>(LeafCacheT::buffer()[LeafNodeT::coordToOffset(xyz)]) = value;
592 auto node = mNodes.template get<Idx>();
594 const_cast<NodeType*
>(node)->setValueOnlyAndCache(xyz, value, *
this);
609 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
610 this->evalFirstCached(xyz, [&](
const auto node) ->
void 612 using NodeType = std::remove_pointer_t<decltype(node)>;
615 if constexpr(IsLeafAndBypassLeafAPI<NodeType>) {
616 const auto offset = LeafNodeT::coordToOffset(xyz);
617 const_cast<ValueType&
>(LeafCacheT::buffer()[offset]) = value;
618 const_cast<NodeType*
>(node)->setValueOff(offset);
621 const_cast<NodeType*
>(node)->setValueOffAndCache(xyz, value, *
this);
631 template<
typename ModifyOp>
634 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
635 this->evalFirstCached(xyz, [&](
const auto node) ->
void 637 using NodeType = std::remove_pointer_t<decltype(node)>;
640 if constexpr(IsLeafAndBypassLeafAPI<NodeType>) {
641 const auto offset = LeafNodeT::coordToOffset(xyz);
642 op(const_cast<ValueType&>(LeafCacheT::buffer()[offset]));
643 const_cast<NodeType*
>(node)->setActiveState(offset,
true);
646 const_cast<NodeType*
>(node)->modifyValueAndCache(xyz, op, *
this);
655 template<
typename ModifyOp>
658 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
659 this->evalFirstCached(xyz, [&](
const auto node) ->
void 661 using NodeType = std::remove_pointer_t<decltype(node)>;
664 if constexpr(IsLeafAndBypassLeafAPI<NodeType>) {
665 const auto offset = LeafNodeT::coordToOffset(xyz);
666 bool state = node->isValueOn(offset);
667 op(const_cast<ValueType&>(LeafCacheT::buffer()[offset]), state);
668 const_cast<NodeType*
>(node)->setActiveState(offset, state);
671 const_cast<NodeType*
>(node)->modifyValueAndActiveStateAndCache(xyz, op, *
this);
685 static_assert(!BaseT::IsConstTree,
"can't modify a const tree's values");
686 this->evalFirstCached(xyz, [&](
const auto node) ->
void 688 using NodeType = std::remove_pointer_t<decltype(node)>;
690 const_cast<NodeType*
>(node)->setActiveStateAndCache(xyz, on, *
this);
698 void setValueOn(
const Coord& xyz) { this->setActiveState(xyz,
true); }
704 void setValueOff(
const Coord& xyz) { this->setActiveState(xyz,
false); }
717 static_assert(!BaseT::IsConstTree,
"can't get a non-const node from a const tree");
718 return this->evalFirstCached(xyz, [&](
const auto node) ->
LeafNodeT*
720 using NodeType = std::remove_pointer_t<decltype(node)>;
722 return const_cast<NodeType*
>(node)->touchLeafAndCache(xyz, *
this);
732 static_assert(!BaseT::IsConstTree,
"can't add a node to a const tree");
733 static_assert(Start >= 0);
735 this->evalFirstCached<Start>(leaf->origin(), [&](
const auto node) ->
void 737 using NodeType = std::remove_pointer_t<decltype(node)>;
739 const_cast<NodeType*
>(node)->addLeafAndCache(leaf, *
this);
757 static_assert(!BaseT::IsConstTree,
"can't add a tile to a const tree");
758 static_assert(Start >= 0);
759 this->evalFirstCached<Start>(xyz, [&](
const auto node) ->
void 761 using NodeType = std::remove_pointer_t<decltype(node)>;
763 const_cast<NodeType*
>(node)->addTileAndCache(level, xyz, value, state, *
this);
776 template<
typename NodeT>
779 static_assert(!BaseT::IsConstTree,
"can't get a non-const node from a const tree");
780 return this->evalFirstPred([&](
const auto Idx) ->
bool 782 using NodeType =
typename NodeLevelList::template Get<Idx>;
784 constexpr
bool NodeMayBeCached =
785 std::is_same<NodeT, NodeType>::value || NodeT::LEVEL < NodeType::LEVEL;
787 if constexpr(NodeMayBeCached)
return this->isHashed<NodeType>(xyz);
790 [&](
const auto node) -> NodeT*
792 using NodeType = std::remove_pointer_t<decltype(node)>;
794 if constexpr(std::is_same<NodeT, NodeType>::value) {
795 return const_cast<NodeT*
>(node);
799 return const_cast<NodeType*
>(node)->
template probeNodeAndCache<NodeT>(xyz, *
this);
804 template<
typename NodeT>
807 return this->evalFirstPred([&](
const auto Idx) ->
bool 809 using NodeType =
typename NodeLevelList::template Get<Idx>;
811 constexpr
bool NodeMayBeCached =
812 std::is_same<NodeT, NodeType>::value || NodeT::LEVEL < NodeType::LEVEL;
814 if constexpr(NodeMayBeCached)
return this->isHashed<NodeType>(xyz);
817 [&](
const auto node) ->
const NodeT*
819 using NodeType = std::remove_pointer_t<decltype(node)>;
821 if constexpr(std::is_same<NodeT, NodeType>::value) {
826 return const_cast<NodeType*
>(node)->
template probeConstNodeAndCache<NodeT>(xyz, *
this);
840 return this->
template probeConstNode<LeafNodeT>(xyz);
847 template<
typename NodeT>
850 using NodeType =
typename std::decay<NodeT>::type;
851 static constexpr int64_t Idx = NodeLevelList::template
Index<NodeType>;
852 if constexpr (Idx >= 0)
return mNodes.template get<Idx>();
859 template<
typename NodeT>
862 this->insert(xyz, &node);
868 template<
typename NodeT>
871 static constexpr int64_t Idx = NodeLevelList::template
Index<NodeT>;
872 if constexpr (Idx >= 0) {
874 mNodes.template get<Idx>() =
nullptr;
883 mNodes.foreach([](
auto& node) { node =
nullptr; });
884 if constexpr (BypassLeafAPI) {
885 LeafCacheT::setBuffer(
nullptr);
889 mNodes.template get<Idx>() = const_cast<RootNodeT*>(&(BaseT::mTree->root()));
903 static constexpr
Index numCacheLevels() {
return NumCacheLevels; }
911 template<
typename>
friend class Tree;
918 this->BaseT::release();
929 template<
typename NodeT>
931 [[maybe_unused]]
const Coord& xyz,
932 [[maybe_unused]]
const NodeT* node)
const 935 if constexpr(!NodeLevelList::template Contains<NodeT>)
return;
937 constexpr uint64_t Idx = uint64_t(NodeLevelList::template
Index<NodeT>);
938 static_assert(NodeLevelList::template Contains<NodeT>);
939 static_assert(Idx < NumCacheLevels);
940 mKeys[Idx] = xyz & ~(NodeT::DIM-1);
941 mNodes.template get<Idx>() = const_cast<NodeT*>(node);
942 if constexpr(IsLeafAndBypassLeafAPI<NodeT>) {
943 LeafCacheT::setBuffer(node->buffer().data());
948 template<
typename NodeT>
951 if constexpr(!NodeLevelList::template Contains<NodeT>)
return false;
952 if constexpr(std::is_same<NodeT, RootNodeT>::value) {
956 constexpr uint64_t Idx = uint64_t(NodeLevelList::template
Index<NodeT>);
957 static_assert(NodeLevelList::template Contains<NodeT>);
958 static_assert(Idx < NumCacheLevels + 1);
959 return (xyz[0] & ~Coord::ValueType(NodeT::DIM-1)) == mKeys[Idx][0]
960 && (xyz[1] & ~Coord
::ValueType(NodeT::DIM-1)) == mKeys[Idx][1]
961 && (xyz[2] & ~Coord::ValueType(NodeT::DIM-1)) == mKeys[Idx][2];
969 template <
typename OpT>
974 [[maybe_unused]]
const auto lock = this->lock();
976 using IndexT = std::integral_constant<std::size_t, 0>;
977 using RetT =
typename std::invoke_result<OpT, IndexT>::type;
978 return openvdb::evalFirstIndex<0, NumCacheLevels+1>(
op, RetT(NULL));
986 template <
typename PredT,
typename OpT>
991 [[maybe_unused]]
const auto lock = this->lock();
992 using RetT =
typename std::invoke_result<OpT, RootNodeT*>::type;
993 if constexpr(!std::is_same<RetT, void>::value) {
994 return mNodes.evalFirstPred(pred,
op, RetT(
false));
997 return mNodes.evalFirstPred(pred,
op);
1006 template <
size_t Start = 0,
typename OpT =
void>
1009 return this->evalFirstPred([&](
const auto Idx) ->
bool 1011 if constexpr(Idx < Start)
return false;
1012 if constexpr(Idx > NumCacheLevels+1)
return false;
1013 using NodeType =
typename NodeLevelList::template Get<Idx>;
1014 return this->isHashed<NodeType>(xyz);
1019 mutable std::array<Coord, NumCacheLevels> mKeys;
1020 mutable typename NodePtrList::AsTupleList mNodes;
1027 #endif // OPENVDB_TREE_VALUEACCESSOR_HAS_BEEN_INCLUDED void eraseNode()
Explicitly remove this Value Accessors cached node of the given NodeT. If this Value Accessor does no...
Definition: ValueAccessor.h:869
OPENVDB_FORCE_INLINE bool isHashed([[maybe_unused]] const Coord &xyz) const
Definition: ValueAccessor.h:949
typename RootNodeT::NodeChainType NodeChainT
Definition: ValueAccessor.h:379
void setValueOn(const Coord &xyz, const ValueType &value)
Set a particular value at the given coordinate and mark the coordinate as active. ...
Definition: ValueAccessor.h:569
void modifyValue(const Coord &xyz, const ModifyOp &op)
Apply a functor to the value at the given coordinate and mark mark the coordinate as active...
Definition: ValueAccessor.h:632
virtual ~ValueAccessorBase()
Definition: ValueAccessor.h:174
void setValueOff(const Coord &xyz, const ValueType &value)
Set a particular value at the given coordinate and mark the coordinate as inactive.
Definition: ValueAccessor.h:607
A small class that contains a Mutex which is derived from by the internal Value Accessor Implementati...
Definition: ValueAccessor.h:311
The Value Accessor Implementation and API methods. The majoirty of the API matches the API of a compa...
Definition: ValueAccessor.h:68
typename std::conditional<(NumCacheLevels > 1), NodeTypeAtLevel< 1 >, void >::type NodeT1
Definition: ValueAccessor.h:898
OPENVDB_FORCE_INLINE void insert([[maybe_unused]] const Coord &xyz, [[maybe_unused]] const NodeT *node) const
Insert a node into this ValueAccessor's cache.
Definition: ValueAccessor.h:930
typename NodeLevelList::template Get< Level > NodeTypeAtLevel
Return a node type at a particular cache level in the Value accessor. The node type at a given cache ...
Definition: ValueAccessor.h:402
const TreeTypeT::ValueType * buffer() const
Definition: ValueAccessor.h:338
TreeType * mTree
Definition: ValueAccessor.h:210
int getValueDepth(const Coord &xyz) const
Return the tree depth (0 = root) at which the value of voxel (x, y, z) resides, or -1 if (x...
Definition: ValueAccessor.h:516
const NodeT * probeConstNode(const Coord &xyz) const
Return a pointer to the node of the specified type that contains the value located at xyz...
Definition: ValueAccessor.h:805
ValueAccessorBase(TreeType &tree)
Construct from a tree. Should rarely be invoked directly, the drived implementation class calls this...
Definition: ValueAccessor.h:168
A list of types (not necessarily unique)
Definition: TypeList.h:577
void setBuffer(const typename TreeTypeT::ValueType *b) const
Definition: ValueAccessor.h:339
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active without changing its value.
Definition: ValueAccessor.h:698
typename value_accessor_internal::NodeListBuilder< NodeChainT, RootNodeT::LEVEL, IntegerSequence >::ListT NodeLevelList
A resolved, flattened TypeList of node types which this accessor is caching. The nodes index in this ...
Definition: ValueAccessor.h:386
OPENVDB_FORCE_INLINE RetT evalFirstIndex(OpT op, const RetT def=RetT())
Definition: TypeList.h:566
friend class LeafNode
Definition: ValueAccessor.h:909
constexpr TreeTypeT::ValueType * buffer() const
Definition: ValueAccessor.h:354
void setActiveState(const Coord &xyz, bool on=true)
Set the active state of the voxel at the given coordinates without changing its value.
Definition: ValueAccessor.h:683
This base class for ValueAccessors manages registration of an accessor with a tree so that the tree c...
Definition: ValueAccessor.h:151
void setValueOnly(const Coord &xyz, const ValueType &value)
Set a particular value at the given coordinate but preserve its active state.
Definition: ValueAccessor.h:578
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: ValueAccessor.h:656
Index32 Index
Definition: Types.h:54
static constexpr bool isSafe()
Return true if this accessor is safe, i.e. registered by the tree from which it is constructed...
Definition: ValueAccessor.h:163
friend class Tree
Definition: ValueAccessor.h:911
constexpr void setBuffer(const typename TreeTypeT::ValueType *) const
Definition: ValueAccessor.h:355
bool isCached(const Coord &xyz) const
Return true if any of the nodes along the path to the given coordinate have been cached.
Definition: ValueAccessor.h:441
LeafNodeT * touchLeaf(const Coord &xyz)
Returns the leaf node that contains voxel (x, y, z) and if it doesn't exist, create it...
Definition: ValueAccessor.h:715
const TreeTypeT::ValueType * buffer()
Definition: ValueAccessor.h:337
void clear() override final
Remove all the cached nodes and invalidate the corresponding hash-keys.
Definition: ValueAccessor.h:880
TreeType * getTree() const
Return a pointer to the tree associated with this accessor.
Definition: ValueAccessor.h:198
bool probeValue(const Coord &xyz, ValueType &value) const
Return the active state of the value at a given coordinate as well as its value.
Definition: ValueAccessor.h:492
A small class that contains a cached pointer to a LeafNode data buffer which is derived from by the i...
Definition: ValueAccessor.h:332
TreeType & tree() const
Return a reference to the tree associated with this accessor.
Definition: ValueAccessor.h:201
#define OPENVDB_ASSERT(X)
Definition: Assert.h:41
NodeT * probeNode(const Coord &xyz)
Return a pointer to the node of the specified type that contains the value located at xyz...
Definition: ValueAccessor.h:777
Re-implementation of C++17's index_sequence and the helper alias make_index_sequence. This was introduced to fix an issue with clang's builtin implementation which treats template specializations of builtin templates differently when a subsequent parameter is dependent. The result is a resolution failure during partial specialization selection. For example, the following will fail to specialize:
Definition: Types.h:223
const LeafNodeT * probeLeaf(const Coord &xyz) const
Return a pointer to the leaf node that contains the voxel coordinate xyz. If no LeafNode exists...
Definition: ValueAccessor.h:837
typename std::conditional<(NumCacheLevels > 0), NodeTypeAtLevel< 0 >, void >::type NodeT0
Definition: ValueAccessor.h:896
const LeafNodeT * probeConstLeaf(const Coord &xyz) const
Return a pointer to the leaf node that contains the voxel coordinate xyz. If no LeafNode exists...
Definition: ValueAccessor.h:838
bool isVoxel(const Coord &xyz) const
Return true if the value of voxel (x, y, z) resides at the leaf level of the tree, i.e., if it is not a tile value.
Definition: ValueAccessor.h:535
Definition: Exceptions.h:13
void insertNode(const Coord &xyz, NodeT &node)
Explicitly insert a node of the type NodeT into this Value Accessors cache.
Definition: ValueAccessor.h:860
constexpr auto lock() const
Definition: ValueAccessor.h:322
void addLeaf(LeafNodeT *leaf)
Add the specified leaf to this tree, possibly creating a child branch in the process. If the leaf node already exists, replace it.
Definition: ValueAccessor.h:729
typename TreeType::RootNodeType RootNodeT
Definition: ValueAccessor.h:377
typename NodeLevelList::template Transform< std::add_pointer_t > NodePtrList
Definition: ValueAccessor.h:387
void addTile(Index level, const Coord &xyz, const ValueType &value, bool state)
Add a tile at the specified tree level that contains the coordinate xyz, possibly deleting existing n...
Definition: ValueAccessor.h:754
constexpr TreeTypeT::ValueType * buffer()
Definition: ValueAccessor.h:353
void release() override final
Release this accessor from the tree, set the tree to null and clear the accessor cache. After calling this method the accessor will be completely invalid.
Definition: ValueAccessor.h:916
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: ValueAccessor.h:455
typename TreeType::LeafNodeType LeafNodeT
Definition: ValueAccessor.h:378
typename TreeType::ValueType ValueType
Definition: ValueAccessor.h:376
friend class InternalNode
Definition: ValueAccessor.h:908
typename std::conditional<(NumCacheLevels > 2), NodeTypeAtLevel< 2 >, void >::type NodeT2
Definition: ValueAccessor.h:900
auto lock() const
Definition: ValueAccessor.h:313
ValueAccessorBase(const ValueAccessorBase &other)
Copy constructor - if IsSafe, then the copy also registers itself against the tree it is accessing...
Definition: ValueAccessor.h:178
virtual void release()
Definition: ValueAccessor.h:209
LeafNodeT * probeLeaf(const Coord &xyz)
Return a pointer to the leaf node that contains the voxel coordinate xyz. If no LeafNode exists...
Definition: ValueAccessor.h:836
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:121
friend class RootNode
Definition: ValueAccessor.h:907
ValueAccessorBase & operator=(const ValueAccessorBase &other)
Definition: ValueAccessor.h:184
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive without changing its value.
Definition: ValueAccessor.h:704
void setValue(const Coord &xyz, const ValueType &value)
Set a particular value at the given coordinate and mark the coordinate as active. ...
Definition: ValueAccessor.h:550
NodeT * getNode()
Return the node of type NodeT that has been cached on this accessor. If this accessor does not cache ...
Definition: ValueAccessor.h:848
bool isValueOn(const Coord &xyz) const
Return the active state of the voxel at the given coordinates.
Definition: ValueAccessor.h:480
ValueAccessorImpl(TreeType &tree)
Constructor from a tree.
Definition: ValueAccessor.h:425
std::decay_t< decltype(make_index_sequence_impl< N >())> make_index_sequence
Definition: Types.h:234
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:218