38 #ifndef OPENVDB_TOOLS_ChangeBACKGROUND_HAS_BEEN_INCLUDED 39 #define OPENVDB_TOOLS_ChangeBACKGROUND_HAS_BEEN_INCLUDED 62 template<
typename TreeOrLeafManagerT>
65 TreeOrLeafManagerT& tree,
66 const typename TreeOrLeafManagerT::ValueType& background,
68 size_t grainSize = 32);
88 template<
typename TreeOrLeafManagerT>
91 TreeOrLeafManagerT& tree,
92 const typename TreeOrLeafManagerT::ValueType& halfWidth,
94 size_t grainSize = 32);
116 template<
typename TreeOrLeafManagerT>
119 TreeOrLeafManagerT& tree,
120 const typename TreeOrLeafManagerT::ValueType& outsideWidth,
121 const typename TreeOrLeafManagerT::ValueType& insideWidth,
122 bool threaded =
true,
123 size_t grainSize = 32);
130 template<
typename TreeOrLeafManagerT>
134 typedef typename TreeOrLeafManagerT::ValueType
ValueT;
135 typedef typename TreeOrLeafManagerT::RootNodeType
RootT;
136 typedef typename TreeOrLeafManagerT::LeafNodeType
LeafT;
140 : mOldValue(tree.root().background())
141 , mNewValue(newValue)
146 for (
typename RootT::ValueOffIter it = root.beginValueOff(); it; ++it) this->set(it);
147 root.setBackground(mNewValue,
false);
151 for (
typename LeafT::ValueOffIter it = node.beginValueOff(); it; ++it) this->set(it);
153 template<
typename NodeT>
156 typename NodeT::NodeMaskType mask = node.getValueOffMask();
157 for (
typename NodeT::ValueOnIter it(mask.beginOn(), &node); it; ++it) this->set(it);
161 template<
typename IterT>
162 inline void set(IterT& iter)
const 165 iter.setValue(mNewValue);
170 const ValueT mOldValue, mNewValue;
178 template<
typename TreeOrLeafManagerT>
182 typedef typename TreeOrLeafManagerT::ValueType
ValueT;
183 typedef typename TreeOrLeafManagerT::RootNodeType
RootT;
184 typedef typename TreeOrLeafManagerT::LeafNodeType
LeafT;
193 "ChangeLevelSetBackgroundOp: the outside value cannot be negative!");
197 "ChangeLevelSetBackgroundOp: the inside value must be negative!");
202 for (
typename RootT::ValueOffIter it = root.beginValueOff(); it; ++it) this->set(it);
203 root.setBackground(mOutside,
false);
207 for(
typename LeafT::ValueOffIter it = node.beginValueOff(); it; ++it) this->set(it);
209 template<
typename NodeT>
212 typedef typename NodeT::ValueOffIter IterT;
213 for (IterT it(node.getChildMask().beginOff(), &node); it; ++it) this->set(it);
217 template<
typename IterT>
218 inline void set(IterT& iter)
const 221 ValueT& v = const_cast<ValueT&>(*iter);
222 v = v < 0 ? mInside : mOutside;
224 const ValueT mOutside, mInside;
228 template<
typename TreeOrLeafManagerT>
231 TreeOrLeafManagerT& tree,
232 const typename TreeOrLeafManagerT::ValueType& background,
242 template<
typename TreeOrLeafManagerT>
245 TreeOrLeafManagerT& tree,
246 const typename TreeOrLeafManagerT::ValueType& outsideValue,
247 const typename TreeOrLeafManagerT::ValueType& insideValue,
258 template<
typename TreeOrLeafManagerT>
261 TreeOrLeafManagerT& tree,
262 const typename TreeOrLeafManagerT::ValueType& background,
267 tree, background,
math::negative(background), threaded, grainSize);
274 #endif // OPENVDB_TOOLS_CHANGEBACKGROUND_HAS_BEEN_INCLUDED
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:109
NodeManager produces linear arrays of all tree nodes allowing for efficient threading and bottom-up p...
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:136
T negative(const T &val)
Return the unary negation of the given value.
Definition: Math.h:108
To facilitate threading over the nodes of a tree, cache node pointers in linear arrays,...
Definition: NodeManager.h:58
Definition: Exceptions.h:40
bool isApproxEqual(const Type &a, const Type &b)
Return true if a is equal to b to within the default floating-point comparison tolerance.
Definition: Math.h:358
Definition: Exceptions.h:92
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:188
bool isNegative(const Type &x)
Return true if x is less than zero.
Definition: Math.h:338
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:477