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>
139 void transformValues(const InIterT& inIter, OutGridT&
outGrid,
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>
204 void setValueOnMin(TreeT& tree, const Coord& xyz, const typename TreeT::ValueType& value);
211 template<typename TreeT>
212 void setValueOnMax(TreeT& tree, const Coord& xyz, const typename TreeT::ValueType& value);
219 template<typename TreeT>
220 void setValueOnSum(TreeT& tree, const Coord& xyz, const typename TreeT::ValueType& value);
227 template<typename TreeT>
228 void setValueOnMult(TreeT& tree, const Coord& xyz, const typename TreeT::ValueType& value);
236 template<
typename ValueType>
239 MinOp(
const ValueType& v): val(v) {}
240 inline void operator()(ValueType& v)
const { v = std::min<ValueType>(v, val); }
243 template<
typename ValueType>
246 MaxOp(
const ValueType& v): val(v) {}
247 inline void operator()(ValueType& v)
const { v = std::max<ValueType>(v, val); }
250 template<
typename ValueType>
253 SumOp(
const ValueType& v): val(v) {}
265 template<
typename ValueType>
283 template<
typename TreeT>
285 setValueOnMin(TreeT& tree,
const Coord& xyz,
const typename TreeT::ValueType& value)
291 template<
typename TreeT>
293 setValueOnMax(TreeT& tree,
const Coord& xyz,
const typename TreeT::ValueType& value)
299 template<
typename TreeT>
301 setValueOnSum(TreeT& tree,
const Coord& xyz,
const typename TreeT::ValueType& value)
307 template<
typename TreeT>
309 setValueOnMult(TreeT& tree,
const Coord& xyz,
const typename TreeT::ValueType& value)
320 template<
typename IterT,
typename OpT>
332 tbb::parallel_for(range, *
this);
346 template<
typename IterT,
typename OpT>
357 mIter(other.mIter), mOp(*other.mOrigOp), mOrigOp(other.mOrigOp) {}
363 tbb::parallel_for(range, *
this);
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);
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 #define OPENVDB_LOG_INFO(message)
Log an info message of the form 'someVar << "some text" << ...'.
Definition: logging.h:254
#define OPENVDB_VOLUME_TREE_INSTANTIATE(Function)
Definition: version.h.in:165
The Value Accessor Implementation and API methods. The majoirty of the API matches the API of a compa...
Definition: ValueAccessor.h:68
Definition: TreeIterator.h:1303
void split(ContainerT &out, const std::string &in, const char delim)
Definition: Name.h:43
This adapter allows code that is templated on a Tree type to accept either a Tree type or a Grid type...
Definition: Grid.h:1059
Definition: Exceptions.h:13
constexpr T zeroVal()
Return the value of type T that corresponds to zero.
Definition: Math.h:70
MergePolicy
Definition: Types.h:506
#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:218