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> 62 #include <openvdb/Types.h> 63 #include <openvdb/Grid.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) {}
283 template<
typename ValueType>
293 template<
typename TreeT>
301 template<
typename TreeT>
309 template<
typename TreeT>
317 template<
typename TreeT>
330 template<
typename IterT,
typename OpT>
340 IterRange range(mIter);
342 tbb::parallel_for(range, *
this);
356 template<
typename IterT,
typename OpT>
367 mIter(other.mIter), mOp(*other.mOrigOp), mOrigOp(other.mOrigOp) {}
371 IterRange range(mIter);
373 tbb::parallel_for(range, *
this);
384 OpT
const *
const mOrigOp;
390 template<
typename IterT,
typename XformOp>
392 foreach(
const IterT& iter, XformOp& op,
bool threaded,
bool shared)
399 Processor proc(iter, op);
400 proc.process(threaded);
404 template<
typename IterT,
typename XformOp>
406 foreach(
const IterT& iter,
const XformOp& op,
bool threaded,
bool )
419 template<
typename InIterT,
typename OutTreeT,
typename OpT>
430 mInputTree(inIter.getTree()),
431 mOutputTree(&outTree),
435 if (static_cast<const void*>(mInputTree) == static_cast<void*>(mOutputTree)) {
437 " to transform a grid in place");
444 mInputIter(other.mInputIter),
445 mInputTree(other.mInputTree),
446 mOutputTree(new OutTreeT(
zeroVal<OutValueT>())),
448 mMergePolicy(other.mMergePolicy)
463 if (!mInputTree || !mOutputTree)
return;
465 IterRange range(mInputIter);
470 tbb::parallel_reduce(range, *
this);
479 if (!mOutputTree)
return;
481 for ( ; range; ++range) {
488 if (mOutputTree && other.mOutputTree) {
489 mOutputTree->merge(*other.mOutputTree, mMergePolicy);
496 const InTreeT* mInputTree;
497 OutTreeT* mOutputTree;
503 template<
typename InIterT,
typename OutTreeT,
typename OpT>
515 mInputTree(inIter.getTree()),
516 mOutputTree(&outTree),
521 if (static_cast<const void*>(mInputTree) == static_cast<void*>(mOutputTree)) {
523 " to transform a grid in place");
531 mInputIter(other.mInputIter),
532 mInputTree(other.mInputTree),
533 mOutputTree(new OutTreeT(
zeroVal<OutValueT>())),
535 mOrigOp(other.mOrigOp),
536 mMergePolicy(other.mMergePolicy)
551 if (!mInputTree || !mOutputTree)
return;
553 IterRange range(mInputIter);
558 tbb::parallel_reduce(range, *
this);
567 if (!mOutputTree)
return;
569 for ( ; range; ++range) {
576 if (mOutputTree && other.mOutputTree) {
577 mOutputTree->merge(*other.mOutputTree, mMergePolicy);
584 const InTreeT* mInputTree;
585 OutTreeT* mOutputTree;
587 OpT
const *
const mOrigOp;
597 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
603 typedef typename Adapter::TreeType OutTreeT;
606 Processor proc(inIter, Adapter::tree(outGrid), op, merge);
607 proc.process(threaded);
610 Processor proc(inIter, Adapter::tree(outGrid), op, merge);
611 proc.process(threaded);
616 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
622 typedef typename Adapter::TreeType OutTreeT;
625 Processor proc(inIter, Adapter::tree(outGrid), op, merge);
626 proc.process(threaded);
636 template<
typename IterT,
typename OpT>
658 mOp(new OpT(*other.mOrigOp)),
659 mOrigOp(other.mOrigOp)
666 IterRange range(mIter);
668 tbb::parallel_reduce(range, *
this);
682 OpT
const *
const mOrigOp;
691 template<
typename IterT,
typename XformOp>
703 #endif // OPENVDB_TOOLS_VALUETRANSFORMER_HAS_BEEN_INCLUDED
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:51
Definition: ValueAccessor.h:220
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:136
Definition: Exceptions.h:40
MergePolicy
Definition: Types.h:328
T zeroVal()
Return the value of type T that corresponds to zero.
Definition: Math.h:86
Definition: TreeIterator.h:1351
#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:188
This adapter allows code that is templated on a Tree type to accept either a Tree type or a Grid type...
Definition: Grid.h:944
const IterT & iterator() const
Return a reference to this range's iterator.
Definition: TreeIterator.h:1372