56 #ifndef OPENVDB_TOOLS_VALUETRANSFORMER_HAS_BEEN_INCLUDED 57 #define OPENVDB_TOOLS_VALUETRANSFORMER_HAS_BEEN_INCLUDED 60 #include <tbb/parallel_for.h> 61 #include <tbb/parallel_reduce.h> 114 template<
typename IterT,
typename XformOp>
115 inline void foreach(
const IterT& iter, XformOp& op,
116 bool threaded =
true,
bool shareOp =
true);
118 template<
typename IterT,
typename XformOp>
119 inline void foreach(
const IterT& iter,
const XformOp& op,
120 bool threaded =
true,
bool shareOp =
true);
163 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
165 XformOp& op,
bool threaded =
true,
bool shareOp =
true,
169 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
171 const XformOp& op,
bool threaded =
true,
bool shareOp =
true,
220 template<
typename IterT,
typename XformOp>
221 inline void accumulate(
const IterT& iter, XformOp& op,
bool threaded =
true);
229 template<
typename TreeT>
230 inline void setValueOnMin(TreeT& tree,
const Coord& xyz,
const typename TreeT::ValueType& value);
237 template<
typename TreeT>
238 inline void setValueOnMax(TreeT& tree,
const Coord& xyz,
const typename TreeT::ValueType& value);
245 template<
typename TreeT>
246 inline void setValueOnSum(TreeT& tree,
const Coord& xyz,
const typename TreeT::ValueType& value);
253 template<
typename TreeT>
254 inline void setValueOnMult(TreeT& tree,
const Coord& xyz,
const typename TreeT::ValueType& value);
262 template<
typename ValueType>
265 MinOp(
const ValueType& v): val(v) {}
266 inline void operator()(ValueType& v)
const { v = std::min<ValueType>(v, val); }
269 template<
typename ValueType>
272 MaxOp(
const ValueType& v): val(v) {}
273 inline void operator()(ValueType& v)
const { v = std::max<ValueType>(v, val); }
276 template<
typename ValueType>
279 SumOp(
const ValueType& v): val(v) {}
292 template<
typename ValueType>
302 template<
typename TreeT>
310 template<
typename TreeT>
318 template<
typename TreeT>
326 template<
typename TreeT>
339 template<
typename IterT,
typename OpT>
351 tbb::parallel_for(range, *
this);
365 template<
typename IterT,
typename OpT>
376 mIter(other.mIter), mOp(*other.mOrigOp), mOrigOp(other.mOrigOp) {}
382 tbb::parallel_for(range, *
this);
393 OpT
const *
const mOrigOp;
399 template<
typename IterT,
typename XformOp>
401 foreach(
const IterT& iter, XformOp& op,
bool threaded,
bool shared)
408 Processor proc(iter, op);
409 proc.process(threaded);
413 template<
typename IterT,
typename XformOp>
415 foreach(
const IterT& iter,
const XformOp& op,
bool threaded,
bool )
428 template<
typename InIterT,
typename OutTreeT,
typename OpT>
439 mInputTree(inIter.getTree()),
440 mOutputTree(&outTree),
444 if (static_cast<const void*>(mInputTree) == static_cast<void*>(mOutputTree)) {
446 " to transform a grid in place");
453 mInputIter(other.mInputIter),
454 mInputTree(other.mInputTree),
457 mMergePolicy(other.mMergePolicy)
466 mOutputTree =
nullptr;
472 if (!mInputTree || !mOutputTree)
return;
479 tbb::parallel_reduce(range, *
this);
488 if (!mOutputTree)
return;
490 for ( ; range; ++range) {
491 mOp(range.iterator(), outAccessor);
497 if (mOutputTree && other.mOutputTree) {
498 mOutputTree->merge(*other.mOutputTree, mMergePolicy);
505 const InTreeT* mInputTree;
506 OutTreeT* mOutputTree;
512 template<
typename InIterT,
typename OutTreeT,
typename OpT>
524 mInputTree(inIter.getTree()),
525 mOutputTree(&outTree),
530 if (static_cast<const void*>(mInputTree) == static_cast<void*>(mOutputTree)) {
532 " to transform a grid in place");
540 mInputIter(other.mInputIter),
541 mInputTree(other.mInputTree),
544 mOrigOp(other.mOrigOp),
545 mMergePolicy(other.mMergePolicy)
554 mOutputTree =
nullptr;
560 if (!mInputTree || !mOutputTree)
return;
567 tbb::parallel_reduce(range, *
this);
576 if (!mOutputTree)
return;
578 for ( ; range; ++range) {
579 mOp(range.iterator(), outAccessor);
585 if (mOutputTree && other.mOutputTree) {
586 mOutputTree->merge(*other.mOutputTree, mMergePolicy);
593 const InTreeT* mInputTree;
594 OutTreeT* mOutputTree;
596 OpT
const *
const mOrigOp;
606 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
612 using OutTreeT =
typename Adapter::TreeType;
615 Processor proc(inIter, Adapter::tree(outGrid), op, merge);
616 proc.process(threaded);
619 Processor proc(inIter, Adapter::tree(outGrid), op, merge);
620 proc.process(threaded);
625 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
631 using OutTreeT =
typename Adapter::TreeType;
634 Processor proc(inIter, Adapter::tree(outGrid), op, merge);
635 proc.process(threaded);
645 template<
typename IterT,
typename OpT>
667 mOp(new OpT(*other.mOrigOp)),
668 mOrigOp(other.mOrigOp)
677 tbb::parallel_reduce(range, *
this);
691 OpT
const *
const mOrigOp;
700 template<
typename IterT,
typename XformOp>
712 #endif // OPENVDB_TOOLS_VALUETRANSFORMER_HAS_BEEN_INCLUDED
Definition: TreeIterator.h:1334
Definition: ValueAccessor.h:220
MergePolicy
Definition: Types.h:555
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:125
T zeroVal()
Return the value of type T that corresponds to zero.
Definition: Math.h:86
Definition: Exceptions.h:40
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:52
#define OPENVDB_LOG_INFO(message)
Log an info message of the form 'someVar << "some text" << ...'.
Definition: logging.h:278
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:177
This adapter allows code that is templated on a Tree type to accept either a Tree type or a Grid type...
Definition: Grid.h:1036