11#ifndef OPENVDB_TOOLS_ACTIVATE_HAS_BEEN_INCLUDED 
   12#define OPENVDB_TOOLS_ACTIVATE_HAS_BEEN_INCLUDED 
   29template<
typename Gr
idOrTree>
 
   32    const typename GridOrTree::ValueType& value,
 
   40template<
typename Gr
idOrTree>
 
   43    const typename GridOrTree::ValueType& value,
 
   54namespace activate_internal {
 
   56template<
typename TreeT, 
bool IgnoreTolerance = false>
 
   60    using RootT = 
typename TreeT::RootNodeType;
 
   61    using LeafT = 
typename TreeT::LeafNodeType;
 
   62    using ValueT = 
typename TreeT::ValueType;
 
   64    explicit ActivateOp(
const ValueT& value,
 
   67        , mTolerance(tolerance) { }
 
   69    inline bool check(
const ValueT& value)
 const {
 
   72        if (IgnoreTolerance)    
return value == mValue;
 
   76    bool operator()(RootT& root, 
size_t)
 const 
   78        for (
auto it = root.beginValueOff(); it; ++it) {
 
   79            if (check(*it))     it.setValueOn(
true);
 
   84    template<
typename NodeT>
 
   85    bool operator()(NodeT& node, 
size_t)
 const 
   88        if (!node.isValueMaskOn()) {
 
   89            for (
auto it = node.beginValueOff(); it; ++it) {
 
   93                if (node.isChildMaskOn(it.pos())) 
continue;
 
   94                if (check(*it))     it.setValueOn(
true);
 
   98        return !node.isChildMaskOff();
 
  101    bool operator()(LeafT& leaf, 
size_t)
 const 
  104        if (leaf.isValueMaskOn())  
return true;
 
  105        for (
auto it = leaf.beginValueOff(); it; ++it) {
 
  106            if (check(*it))     it.setValueOn(
true);
 
  113    const ValueT mTolerance;
 
  116template<
typename TreeT, 
bool IgnoreTolerance = false>
 
  120    using RootT = 
typename TreeT::RootNodeType;
 
  121    using LeafT = 
typename TreeT::LeafNodeType;
 
  122    using ValueT = 
typename TreeT::ValueType;
 
  124    explicit DeactivateOp(
const ValueT& value,
 
  127        , mTolerance(tolerance) { }
 
  129    inline bool check(
const ValueT& value)
 const {
 
  130        if (IgnoreTolerance)    
return value == mValue;
 
  134    bool operator()(RootT& root, 
size_t)
 const 
  136        for (
auto it = root.beginValueOn(); it; ++it) {
 
  137            if (check(*it))     it.setValueOn(
false);
 
  142    template<
typename NodeT>
 
  143    bool operator()(NodeT& node, 
size_t)
 const 
  146        if (!node.isValueMaskOff()) {
 
  147            for (
auto it = node.beginValueOn(); it; ++it) {
 
  148                if (check(*it))     it.setValueOn(
false);
 
  152        return !node.isChildMaskOff();
 
  155    bool operator()(LeafT& leaf, 
size_t)
 const 
  158        if (leaf.isValueMaskOff())  
return true;
 
  159        for (
auto it = leaf.beginValueOn(); it; ++it) {
 
  160            if (check(*it))     it.setValueOn(
false);
 
  167    const ValueT mTolerance;
 
  178template<
typename Gr
idOrTree>
 
  180    const typename GridOrTree::ValueType& value,
 
  181    const typename GridOrTree::ValueType& tolerance,
 
  185    using TreeType = 
typename Adapter::TreeType;
 
  186    using ValueType = 
typename TreeType::ValueType;
 
  188    TreeType& 
tree = Adapter::tree(gridOrTree);
 
  193        activate_internal::ActivateOp<TreeType, 
true> 
op(value);
 
  196        activate_internal::ActivateOp<TreeType> 
op(value, tolerance);
 
 
  202template<
typename Gr
idOrTree>
 
  204    const typename GridOrTree::ValueType& value,
 
  205    const typename GridOrTree::ValueType& tolerance,
 
  209    using TreeType = 
typename Adapter::TreeType;
 
  210    using ValueType = 
typename TreeType::ValueType;
 
  212    TreeType& 
tree = Adapter::tree(gridOrTree);
 
  217        activate_internal::DeactivateOp<TreeType, 
true> 
op(value);
 
  220        activate_internal::DeactivateOp<TreeType> 
op(value, tolerance);
 
 
  231#ifdef OPENVDB_USE_EXPLICIT_INSTANTIATION 
  233#ifdef OPENVDB_INSTANTIATE_ACTIVATE 
  237#define _FUNCTION(TreeT) \ 
  238    void activate(TreeT&, const TreeT::ValueType&, const TreeT::ValueType&, const bool) 
  242#define _FUNCTION(TreeT) \ 
  243    void activate(Grid<TreeT>&, const TreeT::ValueType&, const TreeT::ValueType&, const bool) 
  247#define _FUNCTION(TreeT) \ 
  248    void deactivate(TreeT&, const TreeT::ValueType&, const TreeT::ValueType&, const bool) 
  252#define _FUNCTION(TreeT) \ 
  253    void deactivate(Grid<TreeT>&, const TreeT::ValueType&, const TreeT::ValueType&, const bool) 
 
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
Attribute-owned data structure for points. Point attributes are stored in leaf nodes and ordered by v...
Definition NodeManager.h:891
void foreachTopDown(const NodeOp &op, bool threaded=true, size_t leafGrainSize=1, size_t nonLeafGrainSize=1)
Threaded method that applies a user-supplied functor to all the nodes in the tree.
Definition NodeManager.h:977
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:406
Definition PointDataGrid.h:170
constexpr T zeroVal()
Return the value of type T that corresponds to zero.
Definition Math.h:70
Definition Exceptions.h:13
NodeManager produces linear arrays of all tree nodes allowing for efficient threading and bottom-up p...
This adapter allows code that is templated on a Tree type to accept either a Tree type or a Grid type...
Definition Grid.h:1060
#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_ALL_TREE_INSTANTIATE(Function)
Definition version.h.in:166