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>
88 template<
typename IterT,
typename XformOp>
89 inline void foreach(
const IterT& iter, XformOp& op,
90 bool threaded =
true,
bool shareOp =
true);
92 template<
typename IterT,
typename XformOp>
93 inline void foreach(
const IterT& iter,
const XformOp& op,
94 bool threaded =
true,
bool shareOp =
true);
137 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
139 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,
192 template<
typename IterT,
typename XformOp>
193 inline void accumulate(
const IterT& iter, XformOp& op,
bool threaded =
true);
201 template<
typename TreeT>
209 template<
typename TreeT>
217 template<
typename TreeT>
225 template<
typename TreeT>
234 template<
typename ValueType>
241 template<
typename ValueType>
248 template<
typename ValueType>
263 template<
typename ValueType>
281 template<
typename TreeT>
289 template<
typename TreeT>
297 template<
typename TreeT>
305 template<
typename TreeT>
318 template<
typename IterT,
typename OpT>
344 template<
typename IterT,
typename OpT>
355 mIter(other.mIter), mOp(*other.mOrigOp), mOrigOp(other.mOrigOp) {}
372 OpT
const *
const mOrigOp;
378 template<
typename IterT,
typename XformOp>
380 foreach(
const IterT& iter, XformOp& op,
bool threaded,
bool shared)
388 proc.process(threaded);
392 template<
typename IterT,
typename XformOp>
394 foreach(
const IterT& iter,
const XformOp& op,
bool threaded,
bool )
407 template<
typename InIterT,
typename OutTreeT,
typename OpT>
418 mInputTree(inIter.getTree()),
419 mOutputTree(&outTree),
423 if (static_cast<const void*>(mInputTree) == static_cast<void*>(mOutputTree)) {
425 " to transform a grid in place");
432 mInputIter(other.mInputIter),
433 mInputTree(other.mInputTree),
436 mMergePolicy(other.mMergePolicy)
445 mOutputTree =
nullptr;
451 if (!mInputTree || !mOutputTree)
return;
458 tbb::parallel_reduce(range, *
this);
467 if (!mOutputTree)
return;
471 mOp(r.iterator(), outAccessor);
477 if (mOutputTree && other.mOutputTree) {
478 mOutputTree->merge(*other.mOutputTree, mMergePolicy);
486 OutTreeT* mOutputTree;
492 template<
typename InIterT,
typename OutTreeT,
typename OpT>
504 mInputTree(inIter.getTree()),
505 mOutputTree(&outTree),
510 if (static_cast<const void*>(mInputTree) == static_cast<void*>(mOutputTree)) {
512 " to transform a grid in place");
520 mInputIter(other.mInputIter),
521 mInputTree(other.mInputTree),
524 mOrigOp(other.mOrigOp),
525 mMergePolicy(other.mMergePolicy)
534 mOutputTree =
nullptr;
540 if (!mInputTree || !mOutputTree)
return;
547 tbb::parallel_reduce(range, *
this);
556 if (!mOutputTree)
return;
560 mOp(r.iterator(), outAccessor);
566 if (mOutputTree && other.mOutputTree) {
567 mOutputTree->merge(*other.mOutputTree, mMergePolicy);
575 OutTreeT* mOutputTree;
577 OpT
const *
const mOrigOp;
587 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
593 using OutTreeT =
typename Adapter::TreeType;
596 Processor proc(inIter, Adapter::tree(outGrid), op, merge);
597 proc.process(threaded);
600 Processor proc(inIter, Adapter::tree(outGrid), op, merge);
601 proc.process(threaded);
605 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
611 using OutTreeT =
typename Adapter::TreeType;
614 Processor proc(inIter, Adapter::tree(outGrid), op, merge);
615 proc.process(threaded);
624 template<
typename IterT,
typename OpT>
646 mOp(new OpT(*other.mOrigOp)),
647 mOrigOp(other.mOrigOp)
656 tbb::parallel_reduce(range, *
this);
670 OpT
const *
const mOrigOp;
679 template<
typename IterT,
typename XformOp>
693 #ifdef OPENVDB_USE_EXPLICIT_INSTANTIATION
695 #ifdef OPENVDB_INSTANTIATE_VALUETRANSFORMER
699 #define _FUNCTION(TreeT) \
700 void setValueOnMin(TreeT&, const Coord&, const TreeT::ValueType&)
704 #define _FUNCTION(TreeT) \
705 void setValueOnMax(TreeT&, const Coord&, const TreeT::ValueType&)
709 #define _FUNCTION(TreeT) \
710 void setValueOnSum(TreeT&, const Coord&, const TreeT::ValueType&)
714 #define _FUNCTION(TreeT) \
715 void setValueOnMult(TreeT&, const Coord&, const TreeT::ValueType&)
719 #endif // OPENVDB_USE_EXPLICIT_INSTANTIATION
726 #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
The Value Accessor Implementation and API methods. The majoirty of the API matches the API of a compa...
This adapter allows code that is templated on a Tree type to accept either a Tree type or a Grid type...
constexpr T zeroVal()
Return the value of type T that corresponds to zero.
#define OPENVDB_VOLUME_TREE_INSTANTIATE(Function)
#define OPENVDB_LOG_INFO(mesg)
class OCIOEXPORT Processor
void OIIO_UTIL_API split(string_view str, std::vector< string_view > &result, string_view sep=string_view(), int maxsplit=-1)
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.