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,
92 template<
typename IterT,
typename XformOp>
93 inline void foreach(
const IterT& iter,
const XformOp& op,
137 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
143 template<typename InIterT, typename OutGridT, typename XformOp>
145 void transformValues(const InIterT& inIter, OutGridT& outGrid,
194 template<typename IterT, typename XformOp>
203 template<typename TreeT>
211 template<typename TreeT>
219 template<typename TreeT>
227 template<typename TreeT>
236 template<
typename ValueType>
243 template<
typename ValueType>
250 template<
typename ValueType>
265 template<
typename ValueType>
283 template<
typename TreeT>
291 template<
typename TreeT>
299 template<
typename TreeT>
307 template<
typename TreeT>
320 template<
typename IterT,
typename OpT>
346 template<
typename IterT,
typename OpT>
357 mIter(other.mIter), mOp(*other.mOrigOp), mOrigOp(other.mOrigOp) {}
374 OpT
const *
const mOrigOp;
380 template<
typename IterT,
typename XformOp>
390 proc.process(threaded);
394 template<
typename IterT,
typename XformOp>
396 foreach(
const IterT& iter,
const XformOp& op,
bool threaded,
bool )
409 template<
typename InIterT,
typename OutTreeT,
typename OpT>
420 mInputTree(inIter.getTree()),
421 mOutputTree(&outTree),
425 if (static_cast<const void*>(mInputTree) == static_cast<void*>(mOutputTree)) {
427 " to transform a grid in place");
434 mInputIter(other.mInputIter),
435 mInputTree(other.mInputTree),
438 mMergePolicy(other.mMergePolicy)
447 mOutputTree =
nullptr;
453 if (!mInputTree || !mOutputTree)
return;
460 tbb::parallel_reduce(range, *
this);
469 if (!mOutputTree)
return;
473 mOp(r.iterator(), outAccessor);
479 if (mOutputTree && other.mOutputTree) {
480 mOutputTree->merge(*other.mOutputTree, mMergePolicy);
494 template<
typename InIterT,
typename OutTreeT,
typename OpT>
506 mInputTree(inIter.getTree()),
507 mOutputTree(&outTree),
512 if (static_cast<const void*>(mInputTree) == static_cast<void*>(mOutputTree)) {
514 " to transform a grid in place");
522 mInputIter(other.mInputIter),
523 mInputTree(other.mInputTree),
526 mOrigOp(other.mOrigOp),
527 mMergePolicy(other.mMergePolicy)
536 mOutputTree =
nullptr;
542 if (!mInputTree || !mOutputTree)
return;
549 tbb::parallel_reduce(range, *
this);
558 if (!mOutputTree)
return;
562 mOp(r.iterator(), outAccessor);
568 if (mOutputTree && other.mOutputTree) {
569 mOutputTree->merge(*other.mOutputTree, mMergePolicy);
579 OpT
const *
const mOrigOp;
589 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
591 void transformValues(const InIterT& inIter, OutGridT&
outGrid, XformOp& op,
599 proc.process(threaded);
601 using Processor =
typename valxform::CopyableOpTransformer<InIterT, OutTreeT, XformOp>;
603 proc.process(threaded);
607 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
609 void transformValues(const InIterT& inIter, OutGridT& outGrid, const XformOp& op,
613 using OutTreeT =
typename Adapter::TreeType;
617 proc.process(threaded);
626 template<
typename IterT,
typename OpT>
648 mOp(new OpT(*other.mOrigOp)),
649 mOrigOp(other.mOrigOp)
658 tbb::parallel_reduce(range, *
this);
672 OpT
const *
const mOrigOp;
681 template<
typename IterT,
typename XformOp>
695 #ifdef OPENVDB_USE_EXPLICIT_INSTANTIATION
697 #ifdef OPENVDB_INSTANTIATE_VALUETRANSFORMER
701 #define _FUNCTION(TreeT) \
702 void setValueOnMin(TreeT&, const Coord&, const TreeT::ValueType&)
706 #define _FUNCTION(TreeT) \
707 void setValueOnMax(TreeT&, const Coord&, const TreeT::ValueType&)
711 #define _FUNCTION(TreeT) \
712 void setValueOnSum(TreeT&, const Coord&, const TreeT::ValueType&)
716 #define _FUNCTION(TreeT) \
717 void setValueOnMult(TreeT&, const Coord&, const TreeT::ValueType&)
721 #endif // OPENVDB_USE_EXPLICIT_INSTANTIATION
728 #endif // OPENVDB_TOOLS_VALUETRANSFORMER_HAS_BEEN_INCLUDED
GLsizei const GLfloat * value
#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.
OIIO_UTIL_API void parallel_for(int32_t begin, int32_t end, function_view< void(int32_t)> task, paropt opt=0)
#define OPENVDB_VOLUME_TREE_INSTANTIATE(Function)
#define OPENVDB_LOG_INFO(mesg)
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.