37 #ifndef OPENVDB_TOOLS_PRUNE_HAS_BEEN_INCLUDED
38 #define OPENVDB_TOOLS_PRUNE_HAS_BEEN_INCLUDED
40 #include <boost/utility/enable_if.hpp>
41 #include <openvdb/math/Math.h>
42 #include <openvdb/Types.h>
43 #include <boost/static_assert.hpp>
44 #include <openvdb/Types.h>
45 #include <openvdb/tree/NodeManager.h>
60 template<
typename TreeT>
63 typename TreeT::ValueType tolerance = zeroVal<typename TreeT::ValueType>(),
65 size_t grainSize = 1);
76 template<
typename TreeT>
79 typename TreeT::ValueType tolerance = zeroVal<typename TreeT::ValueType>(),
81 size_t grainSize = 1);
90 template<
typename TreeT>
92 pruneInactive(TreeT& tree,
bool threaded =
true,
size_t grainSize = 1);
102 template<
typename TreeT>
106 const typename TreeT::ValueType& value,
107 bool threaded =
true,
108 size_t grainSize = 1);
123 template<
typename TreeT>
126 bool threaded =
true,
127 size_t grainSize = 1);
146 template<
typename TreeT>
149 const typename TreeT::ValueType& outsideWidth,
150 const typename TreeT::ValueType& insideWidth,
151 bool threaded =
true,
152 size_t grainSize = 1);
158 template<
typename TreeT, Index TerminationLevel = 0>
162 typedef typename TreeT::ValueType
ValueT;
163 typedef typename TreeT::RootNodeType
RootT;
164 typedef typename TreeT::LeafNodeType
LeafT;
165 BOOST_STATIC_ASSERT(RootT::LEVEL > TerminationLevel);
169 tree.clearAllAccessors();
174 tree.clearAllAccessors();
180 template<
typename NodeT>
183 if (NodeT::LEVEL > TerminationLevel) {
184 for (
typename NodeT::ChildOnIter it=node.beginChildOn(); it; ++it) {
185 if (it->isInactive()) node.addTile(it.pos(), mValue,
false);
192 for (
typename RootT::ChildOnIter it = root.beginChildOn(); it; ++it) {
193 if (it->isInactive()) root.addTile(it.getCoord(), mValue,
false);
195 root.eraseBackgroundTiles();
203 template<
typename TreeT, Index TerminationLevel = 0>
207 typedef typename TreeT::ValueType
ValueT;
208 typedef typename TreeT::RootNodeType
RootT;
209 typedef typename TreeT::LeafNodeType
LeafT;
210 BOOST_STATIC_ASSERT(RootT::LEVEL > TerminationLevel);
214 tree.clearAllAccessors();
220 template<
typename NodeT>
223 if (NodeT::LEVEL > TerminationLevel) {
226 for (
typename NodeT::ChildOnIter it=node.beginChildOn(); it; ++it) {
227 if (it->isConstant(value, state, mTolerance)) node.addTile(it.pos(), value, state);
236 for (
typename RootT::ChildOnIter it = root.beginChildOn(); it; ++it) {
237 if (it->isConstant(value, state, mTolerance)) root.addTile(it.getCoord(), value, state);
239 root.eraseBackgroundTiles();
243 const ValueT mTolerance;
247 template<
typename TreeT, Index TerminationLevel = 0>
251 typedef typename TreeT::ValueType
ValueT;
252 typedef typename TreeT::RootNodeType
RootT;
253 typedef typename TreeT::LeafNodeType
LeafT;
254 BOOST_STATIC_ASSERT(RootT::LEVEL > TerminationLevel);
257 : mOutside(tree.background())
262 "LevelSetPruneOp: the background value cannot be negative!");
264 tree.clearAllAccessors();
272 "LevelSetPruneOp: the outside value cannot be negative!");
276 "LevelSetPruneOp: the inside value must be negative!");
278 tree.clearAllAccessors();
283 template<
typename NodeT>
286 if (NodeT::LEVEL > TerminationLevel) {
287 for (
typename NodeT::ChildOnIter it=node.beginChildOn(); it; ++it) {
288 if (it->isInactive()) node.addTile(it.pos(), this->getTileValue(it),
false);
295 for (
typename RootT::ChildOnIter it = root.beginChildOn(); it; ++it) {
296 if (it->isInactive()) root.addTile(it.getCoord(), this->getTileValue(it),
false);
298 root.eraseBackgroundTiles();
302 template <
typename IterT>
303 inline ValueT getTileValue(
const IterT& iter)
const
308 const ValueT mOutside, mInside;
312 template<
typename TreeT>
314 prune(TreeT& tree,
typename TreeT::ValueType tol,
bool threaded,
size_t grainSize)
318 nodes.processBottomUp(op, threaded, grainSize);
322 template<
typename TreeT>
324 pruneTiles(TreeT& tree,
typename TreeT::ValueType tol,
bool threaded,
size_t grainSize)
328 nodes.processBottomUp(op, threaded, grainSize);
332 template<
typename TreeT>
338 nodes.processBottomUp(op, threaded, grainSize);
342 template<
typename TreeT>
345 bool threaded,
size_t grainSize)
349 nodes.processBottomUp(op, threaded, grainSize);
353 template<
typename TreeT>
356 const typename TreeT::ValueType& outside,
357 const typename TreeT::ValueType& inside,
363 nodes.processBottomUp(op, threaded, grainSize);
367 template<
typename TreeT>
373 nodes.processBottomUp(op, threaded, grainSize);
380 #endif // OPENVDB_TOOLS_PRUNE_HAS_BEEN_INCLUDED
bool isNegative(const Type &x)
Return true if x is less than zero.
Definition: Math.h:344
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:97
#define OPENVDB_VERSION_NAME
Definition: version.h:43
Definition: Exceptions.h:39
T negative(const T &val)
Return the unary negation of the given value.
Definition: Math.h:107
Definition: Exceptions.h:88
To facilitate threading over the nodes of a tree, cache node pointers in linear arrays, one for each level of the tree.
Definition: NodeManager.h:56
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71