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>
88template<
typename IterT,
typename XformOp>
89inline void foreach(
const IterT& iter, XformOp& op,
90 bool threaded =
true,
bool shareOp =
true);
92template<
typename IterT,
typename XformOp>
93inline void foreach(
const IterT& iter,
const XformOp& op,
94 bool threaded =
true,
bool shareOp =
true);
137template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
139void transformValues(const InIterT& inIter, OutGridT& outGrid,
140 XformOp& op,
bool threaded = true,
bool shareOp = true,
141 MergePolicy merge = MERGE_ACTIVE_STATES);
143template<typename InIterT, typename OutGridT, typename XformOp>
145void transformValues(const InIterT& inIter, OutGridT& outGrid,
146 const XformOp& op,
bool threaded = true,
bool shareOp = true,
147 MergePolicy merge = MERGE_ACTIVE_STATES);
194template<typename IterT, typename XformOp>
195inline
void accumulate(const IterT& iter, XformOp& op,
bool threaded = true);
203template<typename TreeT>
204void setValueOnMin(TreeT& tree, const Coord& xyz, const typename TreeT::ValueType& value);
211template<typename TreeT>
212void setValueOnMax(TreeT& tree, const Coord& xyz, const typename TreeT::ValueType& value);
219template<typename TreeT>
220void setValueOnSum(TreeT& tree, const Coord& xyz, const typename TreeT::ValueType& value);
227template<typename TreeT>
228void setValueOnMult(TreeT& tree, const Coord& xyz, const typename TreeT::ValueType& value);
236template<
typename ValueType>
245template<
typename ValueType>
254template<
typename ValueType>
269template<
typename ValueType>
287template<
typename TreeT>
295template<
typename TreeT>
303template<
typename TreeT>
311template<
typename TreeT>
324template<
typename IterT,
typename OpT>
336 tbb::parallel_for(range, *
this);
350template<
typename IterT,
typename OpT>
361 mIter(other.mIter), mOp(*other.mOrigOp), mOrigOp(other.mOrigOp) {}
367 tbb::parallel_for(range, *
this);
378 OpT
const *
const mOrigOp;
384template<
typename IterT,
typename XformOp>
386foreach(
const IterT& iter, XformOp& op,
bool threaded,
bool shared)
393 Processor proc(iter, op);
394 proc.process(threaded);
398template<
typename IterT,
typename XformOp>
400foreach(
const IterT& iter,
const XformOp& op,
bool threaded,
bool )
413template<
typename InIterT,
typename OutTreeT,
typename OpT>
424 mInputTree(inIter.getTree()),
425 mOutputTree(&outTree),
429 if (
static_cast<const void*
>(mInputTree) ==
static_cast<void*
>(mOutputTree)) {
431 " to transform a grid in place");
438 mInputIter(other.mInputIter),
439 mInputTree(other.mInputTree),
442 mMergePolicy(other.mMergePolicy)
451 mOutputTree =
nullptr;
457 if (!mInputTree || !mOutputTree)
return;
464 tbb::parallel_reduce(range, *
this);
473 if (!mOutputTree)
return;
477 mOp(r.iterator(), outAccessor);
483 if (mOutputTree && other.mOutputTree) {
484 mOutputTree->merge(*other.mOutputTree, mMergePolicy);
491 const InTreeT* mInputTree;
492 OutTreeT* mOutputTree;
498template<
typename InIterT,
typename OutTreeT,
typename OpT>
510 mInputTree(inIter.getTree()),
511 mOutputTree(&outTree),
516 if (
static_cast<const void*
>(mInputTree) ==
static_cast<void*
>(mOutputTree)) {
518 " to transform a grid in place");
526 mInputIter(other.mInputIter),
527 mInputTree(other.mInputTree),
530 mOrigOp(other.mOrigOp),
531 mMergePolicy(other.mMergePolicy)
540 mOutputTree =
nullptr;
546 if (!mInputTree || !mOutputTree)
return;
553 tbb::parallel_reduce(range, *
this);
562 if (!mOutputTree)
return;
566 mOp(r.iterator(), outAccessor);
572 if (mOutputTree && other.mOutputTree) {
573 mOutputTree->merge(*other.mOutputTree, mMergePolicy);
580 const InTreeT* mInputTree;
581 OutTreeT* mOutputTree;
583 OpT
const *
const mOrigOp;
593template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
599 using OutTreeT =
typename Adapter::TreeType;
602 Processor proc(inIter, Adapter::tree(outGrid), op, merge);
603 proc.process(threaded);
606 Processor proc(inIter, Adapter::tree(outGrid), op, merge);
607 proc.process(threaded);
611template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
617 using OutTreeT =
typename Adapter::TreeType;
620 Processor proc(inIter, Adapter::tree(outGrid), op, merge);
621 proc.process(threaded);
630template<
typename IterT,
typename OpT>
652 mOp(new OpT(*other.mOrigOp)),
653 mOrigOp(other.mOrigOp)
662 tbb::parallel_reduce(range, *
this);
676 OpT
const *
const mOrigOp;
685template<
typename IterT,
typename XformOp>
699#ifdef OPENVDB_USE_EXPLICIT_INSTANTIATION
701#ifdef OPENVDB_INSTANTIATE_VALUETRANSFORMER
705#define _FUNCTION(TreeT) \
706 void setValueOnMin(TreeT&, const Coord&, const TreeT::ValueType&)
710#define _FUNCTION(TreeT) \
711 void setValueOnMax(TreeT&, const Coord&, const TreeT::ValueType&)
715#define _FUNCTION(TreeT) \
716 void setValueOnSum(TreeT&, const Coord&, const TreeT::ValueType&)
720#define _FUNCTION(TreeT) \
721 void setValueOnMult(TreeT&, const Coord&, const TreeT::ValueType&)
Signed (x, y, z) 32-bit integer coordinates.
Definition Coord.h:26
Definition TreeIterator.h:1304
#define OPENVDB_LOG_INFO(message)
Log an info message of the form 'someVar << "some text" << ...'.
Definition logging.h:254
bool cwiseLessThan(const Mat< SIZE, T > &m0, const Mat< SIZE, T > &m1)
Definition Mat.h:1015
bool cwiseGreaterThan(const Mat< SIZE, T > &m0, const Mat< SIZE, T > &m1)
Definition Mat.h:1029
Definition PointDataGrid.h:170
ValueAccessorImpl< TreeType, IsSafe, MutexType, openvdb::make_index_sequence< CacheLevels > > ValueAccessor
Default alias for a ValueAccessor. This is simply a helper alias for the generic definition but takes...
Definition ValueAccessor.h:86
constexpr T zeroVal()
Return the value of type T that corresponds to zero.
Definition Math.h:71
MergePolicy
Definition Types.h:577
Definition 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:1058
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition version.h.in:121
#define OPENVDB_USE_VERSION_NAMESPACE
Definition version.h.in:284
#define OPENVDB_VOLUME_TREE_INSTANTIATE(Function)
Definition version.h.in:231