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>
242 template<
typename ValueType>
249 template<
typename ValueType>
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>
338 template<
typename IterT,
typename OpT>
349 mIter(other.mIter), mOp(*other.mOrigOp), mOrigOp(other.mOrigOp) {}
366 OpT
const *
const mOrigOp;
372 template<
typename IterT,
typename XformOp>
374 foreach(
const IterT& iter, XformOp& op,
bool threaded,
bool shared)
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;
464 mOp(range.iterator(), outAccessor);
470 if (mOutputTree && other.mOutputTree) {
471 mOutputTree->merge(*other.mOutputTree, mMergePolicy);
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;
552 mOp(range.iterator(), outAccessor);
558 if (mOutputTree && other.mOutputTree) {
559 mOutputTree->merge(*other.mOutputTree, mMergePolicy);
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>
685 #endif // OPENVDB_TOOLS_VALUETRANSFORMER_HAS_BEEN_INCLUDED
void parallel_for(int64_t start, int64_t end, std::function< void(int64_t index)> &&task, parallel_options opt=parallel_options(0, Split_Y, 1))
#define OPENVDB_USE_VERSION_NAMESPACE
This adapter allows code that is templated on a Tree type to accept either a Tree type or a Grid type...
void OIIO_API split(string_view str, std::vector< string_view > &result, string_view sep=string_view(), int maxsplit=-1)
class OCIOEXPORT Processor
#define OPENVDB_LOG_INFO(mesg)
GLsizei const GLfloat * value
T zeroVal()
Return the value of type T that corresponds to zero.
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.