10#ifndef OPENVDB_TOOLS_PRUNE_HAS_BEEN_INCLUDED 
   11#define OPENVDB_TOOLS_PRUNE_HAS_BEEN_INCLUDED 
   37template<
typename TreeT>
 
   40      typename TreeT::ValueType tolerance = zeroVal<typename TreeT::ValueType>(),
 
   42      size_t grainSize = 1);
 
   53template<
typename TreeT>
 
   56           typename TreeT::ValueType tolerance = zeroVal<typename TreeT::ValueType>(),
 
   58           size_t grainSize = 1);
 
   67template<
typename TreeT>
 
   69pruneInactive(TreeT& tree, 
bool threaded = 
true, 
size_t grainSize = 1);
 
   79template<
typename TreeT>
 
   83    const typename TreeT::ValueType& value,
 
   85    size_t grainSize = 1);
 
  100template<
typename TreeT>
 
  103              bool threaded = 
true,
 
  104              size_t grainSize = 1);
 
  123template<
typename TreeT>
 
  126              const typename TreeT::ValueType& outsideWidth,
 
  127              const typename TreeT::ValueType& insideWidth,
 
  128              bool threaded = 
true,
 
  129              size_t grainSize = 1);
 
  135template<
typename TreeT, Index TerminationLevel = 0>
 
  139    using ValueT = 
typename TreeT::ValueType;
 
  140    using RootT = 
typename TreeT::RootNodeType;
 
  141    using LeafT = 
typename TreeT::LeafNodeType;
 
  142    static_assert(RootT::LEVEL > TerminationLevel, 
"TerminationLevel out of range");
 
  146        tree.clearAllAccessors();
 
 
  151        tree.clearAllAccessors();
 
 
  158    template<
typename NodeT>
 
  161        if (NodeT::LEVEL > TerminationLevel) {
 
  162            for (
typename NodeT::ChildOnIter it=node.beginChildOn(); it; ++it) {
 
  163                if (it->isInactive()) node.addTile(it.pos(), mValue, 
false);
 
 
  171        for (
typename RootT::ChildOnIter it = root.beginChildOn(); it; ++it) {
 
  172            if (it->isInactive()) root.addTile(it.getCoord(), mValue, 
false);
 
  174        root.eraseBackgroundTiles();
 
 
 
  182template<
typename TreeT, Index TerminationLevel = 0>
 
  186    using ValueT = 
typename TreeT::ValueType;
 
  187    using RootT = 
typename TreeT::RootNodeType;
 
  188    using LeafT = 
typename TreeT::LeafNodeType;
 
  189    static_assert(RootT::LEVEL > TerminationLevel, 
"TerminationLevel out of range");
 
  193        tree.clearAllAccessors();
 
 
  201        for (
typename RootT::ChildOnIter it = root.beginChildOn(); it; ++it) {
 
  202            if (this->isConstant(*it, value, state)) root.addTile(it.getCoord(), value, state);
 
  204        root.eraseBackgroundTiles();
 
 
  208    template<
typename NodeT>
 
  211        if (NodeT::LEVEL > TerminationLevel) {
 
  214            for (
typename NodeT::ChildOnIter it=node.beginChildOn(); it; ++it) {
 
  215                if (this->isConstant(*it, value, state)) node.addTile(it.pos(), value, state);
 
 
  225    inline ValueT median(LeafT& leaf)
 const {
return leaf.medianAll(leaf.buffer().data());}
 
  228    template<
typename NodeT>
 
  229    inline typename NodeT::ValueType median(NodeT& node)
 const 
  231        using UnionT = 
typename NodeT::UnionType;
 
  232        UnionT* data = 
const_cast<UnionT*
>(node.getTable());
 
  233        static const size_t midpoint = (NodeT::NUM_VALUES - 1) >> 1;
 
  234        auto op = [](
const UnionT& a, 
const UnionT& b){
return a.getValue() < b.getValue();};
 
  235        std::nth_element(data, data + midpoint, data + NodeT::NUM_VALUES, op);
 
  236        return data[midpoint].getValue();
 
  240    template<
typename NodeT>
 
  242    typename std::enable_if<std::is_same<bool, typename NodeT::ValueType>::value, 
bool>::type
 
  243    isConstant(NodeT& node, 
bool& value, 
bool& state)
 const 
  245        return node.isConstant(value, state, mTolerance);
 
  249    template<
typename NodeT>
 
  251    typename std::enable_if<!std::is_same<bool, typename NodeT::ValueType>::value, 
bool>::type
 
  252    isConstant(NodeT& node, ValueT& value, 
bool& state)
 const 
  255        const bool test = node.isConstant(value, tmp, state, mTolerance);
 
  256        if (test) value = this->median(node);
 
  260    const ValueT mTolerance;
 
 
  264template<
typename TreeT, Index TerminationLevel = 0>
 
  268    using ValueT = 
typename TreeT::ValueType;
 
  269    using RootT = 
typename TreeT::RootNodeType;
 
  270    using LeafT = 
typename TreeT::LeafNodeType;
 
  271    static_assert(RootT::LEVEL > TerminationLevel, 
"TerminationLevel out of range");
 
  274        : mOutside(
tree.background())
 
  275        , mInside(
math::negative(mOutside))
 
  279                          "LevelSetPruneOp: the background value cannot be negative!");
 
  281        tree.clearAllAccessors();
 
 
  290                          "LevelSetPruneOp: the outside value cannot be negative!");
 
  294                          "LevelSetPruneOp: the inside value must be negative!");
 
  296        tree.clearAllAccessors();
 
 
  303    template<
typename NodeT>
 
  306        if (NodeT::LEVEL > TerminationLevel) {
 
  307            for (
typename NodeT::ChildOnIter it=node.beginChildOn(); it; ++it) {
 
  308                if (it->isInactive()) node.addTile(it.pos(), this->getTileValue(it), 
false);
 
 
  316        for (
typename RootT::ChildOnIter it = root.beginChildOn(); it; ++it) {
 
  317            if (it->isInactive()) root.addTile(it.getCoord(), this->getTileValue(it), 
false);
 
  319        root.eraseBackgroundTiles();
 
 
  323    template <
typename IterT>
 
  324    inline ValueT getTileValue(
const IterT& iter)
 const 
  329    const ValueT mOutside, mInside;
 
 
  333template<
typename TreeT>
 
  339    nodes.foreachBottomUp(
op, 
threaded, grainSize);
 
 
  343template<
typename TreeT>
 
  349    nodes.foreachBottomUp(
op, 
threaded, grainSize);
 
 
  353template<
typename TreeT>
 
  359    nodes.foreachBottomUp(
op, 
threaded, grainSize);
 
 
  363template<
typename TreeT>
 
  370    nodes.foreachBottomUp(
op, 
threaded, grainSize);
 
 
  374template<
typename TreeT>
 
  377              const typename TreeT::ValueType& outside,
 
  378              const typename TreeT::ValueType& inside,
 
  384    nodes.foreachBottomUp(
op, 
threaded, grainSize);
 
 
  388template<
typename TreeT>
 
  394    nodes.foreachBottomUp(
op, 
threaded, grainSize);
 
 
  403#ifdef OPENVDB_USE_EXPLICIT_INSTANTIATION 
  405#ifdef OPENVDB_INSTANTIATE_PRUNE 
  409#define _FUNCTION(TreeT) \ 
  410    void prune(TreeT&, TreeT::ValueType, bool, size_t) 
  414#define _FUNCTION(TreeT) \ 
  415    void pruneTiles(TreeT&, TreeT::ValueType, bool, size_t) 
  419#define _FUNCTION(TreeT) \ 
  420    void pruneInactive(TreeT&, bool, size_t) 
  424#define _FUNCTION(TreeT) \ 
  425    void pruneInactiveWithValue(TreeT&, const TreeT::ValueType&, bool, size_t) 
  429#define _FUNCTION(TreeT) \ 
  430    void pruneLevelSet(TreeT&, bool, size_t) 
  434#define _FUNCTION(TreeT) \ 
  435    void pruneLevelSet(TreeT&, const TreeT::ValueType&, const TreeT::ValueType&, bool, size_t) 
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
Definition Exceptions.h:65
To facilitate threading over the nodes of a tree, cache node pointers in linear arrays,...
Definition NodeManager.h:532
bool isNegative(const Type &x)
Return true if x is less than zero.
Definition Math.h:367
Definition PointDataGrid.h:170
Definition Exceptions.h:13
#define OPENVDB_THROW(exception, message)
Definition Exceptions.h:74
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.in:121
#define OPENVDB_USE_VERSION_NAMESPACE
Definition version.h.in:218
#define OPENVDB_REAL_TREE_INSTANTIATE(Function)
Definition version.h.in:162
#define OPENVDB_VOLUME_TREE_INSTANTIATE(Function)
Definition version.h.in:165