11 #ifndef OPENVDB_TOOLS_ChangeBACKGROUND_HAS_BEEN_INCLUDED
12 #define OPENVDB_TOOLS_ChangeBACKGROUND_HAS_BEEN_INCLUDED
36 template<
typename TreeOrLeafManagerT>
39 TreeOrLeafManagerT& tree,
42 size_t grainSize = 32);
62 template<
typename TreeOrLeafManagerT>
65 TreeOrLeafManagerT& tree,
68 size_t grainSize = 32);
90 template<
typename TreeOrLeafManagerT>
93 TreeOrLeafManagerT& tree,
97 size_t grainSize = 32);
104 template<
typename TreeOrLeafManagerT>
109 typedef typename TreeOrLeafManagerT::RootNodeType
RootT;
110 typedef typename TreeOrLeafManagerT::LeafNodeType
LeafT;
114 : mOldValue(tree.root().background())
115 , mNewValue(newValue)
120 for (
typename RootT::ValueOffIter it = root.beginValueOff(); it; ++it) this->set(it);
121 root.setBackground(mNewValue,
false);
125 for (
typename LeafT::ValueOffIter it = node.beginValueOff(); it; ++it) this->set(it);
127 template<
typename NodeT>
130 typename NodeT::NodeMaskType
mask = node.getValueOffMask();
131 for (
typename NodeT::ValueOnIter it(mask.beginOn(), &node); it; ++it) this->set(it);
135 template<
typename IterT>
136 inline void set(IterT& iter)
const
139 iter.setValue(mNewValue);
144 const ValueT mOldValue, mNewValue;
152 template<
typename TreeOrLeafManagerT>
157 typedef typename TreeOrLeafManagerT::RootNodeType
RootT;
158 typedef typename TreeOrLeafManagerT::LeafNodeType
LeafT;
167 "ChangeLevelSetBackgroundOp: the outside value cannot be negative!");
171 "ChangeLevelSetBackgroundOp: the inside value must be negative!");
176 for (
typename RootT::ValueOffIter it = root.beginValueOff(); it; ++it) this->set(it);
177 root.setBackground(mOutside,
false);
181 for(
typename LeafT::ValueOffIter it = node.beginValueOff(); it; ++it) this->set(it);
183 template<
typename NodeT>
186 typedef typename NodeT::ValueOffIter IterT;
187 for (IterT it(node.getChildMask().beginOff(), &node); it; ++it) this->set(it);
191 template<
typename IterT>
192 inline void set(IterT& iter)
const
196 v = v < 0 ? mInside : mOutside;
198 const ValueT mOutside, mInside;
202 template<
typename TreeOrLeafManagerT>
205 TreeOrLeafManagerT& tree,
216 template<
typename TreeOrLeafManagerT>
219 TreeOrLeafManagerT& tree,
232 template<
typename TreeOrLeafManagerT>
235 TreeOrLeafManagerT& tree,
241 tree, background,
math::negative(background), threaded, grainSize);
250 #ifdef OPENVDB_USE_EXPLICIT_INSTANTIATION
252 #ifdef OPENVDB_INSTANTIATE_CHANGEBACKGROUND
256 #define _FUNCTION(TreeT) \
257 void changeBackground(TreeT&, const TreeT::ValueType&, bool, size_t)
261 #define _FUNCTION(TreeT) \
262 void changeBackground(tree::LeafManager<TreeT>&, const TreeT::ValueType&, bool, size_t)
266 #define _FUNCTION(TreeT) \
267 void changeLevelSetBackground(TreeT&, const TreeT::ValueType&, bool, size_t)
271 #define _FUNCTION(TreeT) \
272 void changeLevelSetBackground(tree::LeafManager<TreeT>&, const TreeT::ValueType&, bool, size_t)
276 #define _FUNCTION(TreeT) \
277 void changeAsymmetricLevelSetBackground(TreeT&, const TreeT::ValueType&, const TreeT::ValueType&, bool, size_t)
281 #define _FUNCTION(TreeT) \
282 void changeAsymmetricLevelSetBackground(tree::LeafManager<TreeT>&, const TreeT::ValueType&, const TreeT::ValueType&, bool, size_t)
286 #endif // OPENVDB_USE_EXPLICIT_INSTANTIATION
293 #endif // OPENVDB_TOOLS_CHANGEBACKGROUND_HAS_BEEN_INCLUDED
T negative(const T &val)
Return the unary negation of the given value.
#define OPENVDB_REAL_TREE_INSTANTIATE(Function)
#define OPENVDB_USE_VERSION_NAMESPACE
NodeManager produces linear arrays of all tree nodes allowing for efficient threading and bottom-up p...
bool isNegative(const Type &x)
Return true if x is less than zero.
To facilitate threading over the nodes of a tree, cache node pointers in linear arrays, one for each level of the tree.
bool isApproxEqual(const Type &a, const Type &b, const Type &tolerance)
Return true if a is equal to b to within the given tolerance.
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
#define OPENVDB_VOLUME_TREE_INSTANTIATE(Function)
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
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.
#define OPENVDB_THROW(exception, message)