11 #ifndef OPENVDB_TOOLS_ChangeBACKGROUND_HAS_BEEN_INCLUDED
12 #define OPENVDB_TOOLS_ChangeBACKGROUND_HAS_BEEN_INCLUDED
35 template<
typename TreeOrLeafManagerT>
38 TreeOrLeafManagerT& tree,
39 const typename TreeOrLeafManagerT::ValueType& background,
41 size_t grainSize = 32);
61 template<
typename TreeOrLeafManagerT>
64 TreeOrLeafManagerT& tree,
65 const typename TreeOrLeafManagerT::ValueType& halfWidth,
67 size_t grainSize = 32);
89 template<
typename TreeOrLeafManagerT>
92 TreeOrLeafManagerT& tree,
93 const typename TreeOrLeafManagerT::ValueType& outsideWidth,
94 const typename TreeOrLeafManagerT::ValueType& insideWidth,
96 size_t grainSize = 32);
103 template<
typename TreeOrLeafManagerT>
107 typedef typename TreeOrLeafManagerT::ValueType
ValueT;
108 typedef typename TreeOrLeafManagerT::RootNodeType
RootT;
109 typedef typename TreeOrLeafManagerT::LeafNodeType
LeafT;
113 : mOldValue(tree.root().background())
114 , mNewValue(newValue)
119 for (
typename RootT::ValueOffIter it = root.beginValueOff(); it; ++it) this->set(it);
120 root.setBackground(mNewValue,
false);
124 for (
typename LeafT::ValueOffIter it = node.beginValueOff(); it; ++it) this->set(it);
126 template<
typename NodeT>
129 typename NodeT::NodeMaskType mask = node.getValueOffMask();
130 for (
typename NodeT::ValueOnIter it(mask.beginOn(), &node); it; ++it) this->set(it);
134 template<
typename IterT>
135 inline void set(IterT& iter)
const
138 iter.setValue(mNewValue);
143 const ValueT mOldValue, mNewValue;
151 template<
typename TreeOrLeafManagerT>
155 typedef typename TreeOrLeafManagerT::ValueType
ValueT;
156 typedef typename TreeOrLeafManagerT::RootNodeType
RootT;
157 typedef typename TreeOrLeafManagerT::LeafNodeType
LeafT;
166 "ChangeLevelSetBackgroundOp: the outside value cannot be negative!");
170 "ChangeLevelSetBackgroundOp: the inside value must be negative!");
175 for (
typename RootT::ValueOffIter it = root.beginValueOff(); it; ++it) this->set(it);
176 root.setBackground(mOutside,
false);
180 for(
typename LeafT::ValueOffIter it = node.beginValueOff(); it; ++it) this->set(it);
182 template<
typename NodeT>
185 typedef typename NodeT::ValueOffIter IterT;
186 for (IterT it(node.getChildMask().beginOff(), &node); it; ++it) this->set(it);
190 template<
typename IterT>
191 inline void set(IterT& iter)
const
194 ValueT& v =
const_cast<ValueT&
>(*iter);
195 v = v < 0 ? mInside : mOutside;
197 const ValueT mOutside, mInside;
201 template<
typename TreeOrLeafManagerT>
204 TreeOrLeafManagerT& tree,
205 const typename TreeOrLeafManagerT::ValueType& background,
215 template<
typename TreeOrLeafManagerT>
218 TreeOrLeafManagerT& tree,
219 const typename TreeOrLeafManagerT::ValueType& outsideValue,
220 const typename TreeOrLeafManagerT::ValueType& insideValue,
231 template<
typename TreeOrLeafManagerT>
234 TreeOrLeafManagerT& tree,
235 const typename TreeOrLeafManagerT::ValueType& background,
240 tree, background,
math::negative(background), threaded, grainSize);
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: openvdb/Exceptions.h:65
To facilitate threading over the nodes of a tree, cache node pointers in linear arrays,...
Definition: NodeManager.h:510
void foreachTopDown(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:610
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
bool isNegative(const Type &x)
Return true if x is less than zero.
Definition: Math.h:368
T negative(const T &val)
Return the unary negation of the given value.
Definition: Math.h:127
Definition: openvdb/Exceptions.h:13
#define OPENVDB_THROW(exception, message)
Definition: openvdb/Exceptions.h:74
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:101
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:153