29 #ifndef OPENVDB_TOOLS_VALUETRANSFORMER_HAS_BEEN_INCLUDED
30 #define OPENVDB_TOOLS_VALUETRANSFORMER_HAS_BEEN_INCLUDED
33 #include <tbb/parallel_for.h>
34 #include <tbb/parallel_reduce.h>
87 template<
typename IterT,
typename XformOp>
88 inline void foreach(
const IterT& iter, XformOp& op,
89 bool threaded =
true,
bool shareOp =
true);
91 template<
typename IterT,
typename XformOp>
92 inline void foreach(
const IterT& iter,
const XformOp& op,
93 bool threaded =
true,
bool shareOp =
true);
136 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
138 XformOp& op,
bool threaded =
true,
bool shareOp =
true,
142 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
144 const XformOp& op,
bool threaded =
true,
bool shareOp =
true,
193 template<
typename IterT,
typename XformOp>
194 inline void accumulate(
const IterT& iter, XformOp& op,
bool threaded =
true);
202 template<
typename TreeT>
203 inline void setValueOnMin(TreeT& tree,
const Coord& xyz,
const typename TreeT::ValueType& value);
210 template<
typename TreeT>
211 inline void setValueOnMax(TreeT& tree,
const Coord& xyz,
const typename TreeT::ValueType& value);
218 template<
typename TreeT>
219 inline void setValueOnSum(TreeT& tree,
const Coord& xyz,
const typename TreeT::ValueType& value);
226 template<
typename TreeT>
227 inline void setValueOnMult(TreeT& tree,
const Coord& xyz,
const typename TreeT::ValueType& value);
235 template<
typename ValueType>
238 MinOp(
const ValueType& v): val(v) {}
239 inline void operator()(ValueType& v)
const { v = std::min<ValueType>(v, val); }
242 template<
typename ValueType>
245 MaxOp(
const ValueType& v): val(v) {}
246 inline void operator()(ValueType& v)
const { v = std::max<ValueType>(v, val); }
249 template<
typename ValueType>
252 SumOp(
const ValueType& v): val(v) {}
265 template<
typename ValueType>
275 template<
typename TreeT>
283 template<
typename TreeT>
291 template<
typename TreeT>
299 template<
typename TreeT>
312 template<
typename IterT,
typename OpT>
324 tbb::parallel_for(range, *
this);
338 template<
typename IterT,
typename OpT>
349 mIter(other.mIter), mOp(*other.mOrigOp), mOrigOp(other.mOrigOp) {}
355 tbb::parallel_for(range, *
this);
366 OpT
const *
const mOrigOp;
372 template<
typename IterT,
typename XformOp>
374 foreach(
const IterT& iter, XformOp& op,
bool threaded,
bool shared)
381 Processor proc(iter, op);
382 proc.process(threaded);
386 template<
typename IterT,
typename XformOp>
388 foreach(
const IterT& iter,
const XformOp& op,
bool threaded,
bool )
401 template<
typename InIterT,
typename OutTreeT,
typename OpT>
412 mInputTree(inIter.getTree()),
413 mOutputTree(&outTree),
417 if (
static_cast<const void*
>(mInputTree) ==
static_cast<void*
>(mOutputTree)) {
419 " to transform a grid in place");
426 mInputIter(other.mInputIter),
427 mInputTree(other.mInputTree),
430 mMergePolicy(other.mMergePolicy)
439 mOutputTree =
nullptr;
445 if (!mInputTree || !mOutputTree)
return;
452 tbb::parallel_reduce(range, *
this);
461 if (!mOutputTree)
return;
463 for ( ; range; ++range) {
464 mOp(range.iterator(), outAccessor);
470 if (mOutputTree && other.mOutputTree) {
471 mOutputTree->merge(*other.mOutputTree, mMergePolicy);
478 const InTreeT* mInputTree;
479 OutTreeT* mOutputTree;
485 template<
typename InIterT,
typename OutTreeT,
typename OpT>
497 mInputTree(inIter.getTree()),
498 mOutputTree(&outTree),
503 if (
static_cast<const void*
>(mInputTree) ==
static_cast<void*
>(mOutputTree)) {
505 " to transform a grid in place");
513 mInputIter(other.mInputIter),
514 mInputTree(other.mInputTree),
517 mOrigOp(other.mOrigOp),
518 mMergePolicy(other.mMergePolicy)
527 mOutputTree =
nullptr;
533 if (!mInputTree || !mOutputTree)
return;
540 tbb::parallel_reduce(range, *
this);
549 if (!mOutputTree)
return;
551 for ( ; range; ++range) {
552 mOp(range.iterator(), outAccessor);
558 if (mOutputTree && other.mOutputTree) {
559 mOutputTree->merge(*other.mOutputTree, mMergePolicy);
566 const InTreeT* mInputTree;
567 OutTreeT* mOutputTree;
569 OpT
const *
const mOrigOp;
579 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
585 using OutTreeT =
typename Adapter::TreeType;
588 Processor proc(inIter, Adapter::tree(outGrid), op, merge);
589 proc.process(threaded);
592 Processor proc(inIter, Adapter::tree(outGrid), op, merge);
593 proc.process(threaded);
598 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
604 using OutTreeT =
typename Adapter::TreeType;
607 Processor proc(inIter, Adapter::tree(outGrid), op, merge);
608 proc.process(threaded);
618 template<
typename IterT,
typename OpT>
640 mOp(new OpT(*other.mOrigOp)),
641 mOrigOp(other.mOrigOp)
650 tbb::parallel_reduce(range, *
this);
664 OpT
const *
const mOrigOp;
673 template<
typename IterT,
typename XformOp>
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:26
Definition: TreeIterator.h:1303
Definition: ValueAccessor.h:183
#define OPENVDB_LOG_INFO(message)
Log an info message of the form 'someVar << "some text" << ...'.
Definition: logging.h:251
T zeroVal()
Return the value of type T that corresponds to zero.
Definition: Math.h:69
MergePolicy
Definition: openvdb/Types.h:384
@ MERGE_ACTIVE_STATES
Definition: openvdb/Types.h:385
Definition: openvdb/Exceptions.h:13
This adapter allows code that is templated on a Tree type to accept either a Tree type or a Grid type...
Definition: Grid.h:1071
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:116
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:178