11 #ifndef OPENVDB_TOOLS_ACTIVATE_HAS_BEEN_INCLUDED
12 #define OPENVDB_TOOLS_ACTIVATE_HAS_BEEN_INCLUDED
27 template<
typename Gr
idOrTree>
30 const typename GridOrTree::ValueType& value,
31 const typename GridOrTree::ValueType& tolerance = zeroVal<typename GridOrTree::ValueType>(),
32 const bool threaded =
true
38 template<
typename Gr
idOrTree>
41 const typename GridOrTree::ValueType& value,
42 const typename GridOrTree::ValueType& tolerance = zeroVal<typename GridOrTree::ValueType>(),
43 const bool threaded =
true
50 namespace activate_internal {
52 template<
typename TreeT,
bool IgnoreTolerance = false>
56 using RootT =
typename TreeT::RootNodeType;
57 using LeafT =
typename TreeT::LeafNodeType;
58 using ValueT =
typename TreeT::ValueType;
61 const ValueT& tolerance = zeroVal<ValueT>())
63 , mTolerance(tolerance) { }
68 if (IgnoreTolerance)
return value == mValue;
74 for (
auto it = root.beginValueOff(); it; ++it) {
75 if (check(*it)) it.setValueOn(
true);
80 template<
typename NodeT>
84 if (!node.isValueMaskOn()) {
85 for (
auto it = node.beginValueOff(); it; ++it) {
86 if (check(*it)) it.setValueOn(
true);
90 return !node.isChildMaskOff();
96 if (leaf.isValueMaskOn())
return true;
97 for (
auto it = leaf.beginValueOff(); it; ++it) {
98 if (check(*it)) it.setValueOn(
true);
105 const ValueT mTolerance;
108 template<
typename TreeT,
bool IgnoreTolerance = false>
112 using RootT =
typename TreeT::RootNodeType;
113 using LeafT =
typename TreeT::LeafNodeType;
114 using ValueT =
typename TreeT::ValueType;
117 const ValueT& tolerance = zeroVal<ValueT>())
119 , mTolerance(tolerance) { }
122 if (IgnoreTolerance)
return value == mValue;
128 for (
auto it = root.beginValueOn(); it; ++it) {
129 if (check(*it)) it.setValueOn(
false);
134 template<
typename NodeT>
138 if (!node.isValueMaskOff()) {
139 for (
auto it = node.beginValueOn(); it; ++it) {
140 if (check(*it)) it.setValueOn(
false);
144 return !node.isChildMaskOff();
150 if (leaf.isValueMaskOff())
return true;
151 for (
auto it = leaf.beginValueOn(); it; ++it) {
152 if (check(*it)) it.setValueOn(
false);
159 const ValueT mTolerance;
168 template<
typename Gr
idOrTree>
170 activate(GridOrTree& gridOrTree,
const typename GridOrTree::ValueType& value,
171 const typename GridOrTree::ValueType& tolerance,
175 using TreeType =
typename Adapter::TreeType;
176 using ValueType =
typename TreeType::ValueType;
178 TreeType& tree = Adapter::tree(gridOrTree);
182 if (tolerance == zeroVal<ValueType>()) {
192 template<
typename Gr
idOrTree>
194 deactivate(GridOrTree& gridOrTree,
const typename GridOrTree::ValueType& value,
195 const typename GridOrTree::ValueType& tolerance,
199 using TreeType =
typename Adapter::TreeType;
200 using ValueType =
typename TreeType::ValueType;
202 TreeType& tree = Adapter::tree(gridOrTree);
206 if (tolerance == zeroVal<ValueType>()) {
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
NodeManager produces linear arrays of all tree nodes allowing for efficient threading and bottom-up p...
Definition: NodeManager.h:884
void foreachTopDown(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Threaded method that applies a user-supplied functor to all the nodes in the tree.
Definition: NodeManager.h:968
bool isApproxEqual(const Type &a, const Type &b, const Type &tolerance)
Return true if a is equal to b to within the given tolerance.
Definition: Math.h:407
Definition: openvdb/Exceptions.h:13
This adapter allows code that is templated on a Tree type to accept either a Tree type or a Grid type...
Definition: Grid.h:1071
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:116
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:178