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>
202 void setValueOnMin(TreeT& tree,
const Coord& xyz,
const typename TreeT::ValueType&
value);
209 template<
typename TreeT>
210 void setValueOnMax(TreeT& tree,
const Coord& xyz,
const typename TreeT::ValueType&
value);
217 template<
typename TreeT>
218 void setValueOnSum(TreeT& tree,
const Coord& xyz,
const typename TreeT::ValueType&
value);
225 template<
typename TreeT>
226 void setValueOnMult(TreeT& tree,
const Coord& xyz,
const typename TreeT::ValueType&
value);
234 template<
typename ValueType>
237 MinOp(
const ValueType& v): val(v) {}
238 inline void operator()(ValueType& v)
const { v = std::min<ValueType>(v, val); }
241 template<
typename ValueType>
244 MaxOp(
const ValueType& v): val(v) {}
245 inline void operator()(ValueType& v)
const { v = std::max<ValueType>(v, val); }
248 template<
typename ValueType>
251 SumOp(
const ValueType& v): val(v) {}
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>
330 tbb::parallel_for(range, *
this);
344 template<
typename IterT,
typename OpT>
355 mIter(other.mIter), mOp(*other.mOrigOp), mOrigOp(other.mOrigOp) {}
361 tbb::parallel_for(range, *
this);
372 OpT
const *
const mOrigOp;
378 template<
typename IterT,
typename XformOp>
380 foreach(
const IterT& iter, XformOp& op,
bool threaded,
bool shared)
387 Processor proc(iter, op);
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;
469 for ( ; range; ++range) {
470 mOp(range.iterator(), outAccessor);
476 if (mOutputTree && other.mOutputTree) {
477 mOutputTree->merge(*other.mOutputTree, mMergePolicy);
485 OutTreeT* mOutputTree;
491 template<
typename InIterT,
typename OutTreeT,
typename OpT>
503 mInputTree(inIter.getTree()),
504 mOutputTree(&outTree),
509 if (static_cast<const void*>(mInputTree) == static_cast<void*>(mOutputTree)) {
511 " to transform a grid in place");
519 mInputIter(other.mInputIter),
520 mInputTree(other.mInputTree),
523 mOrigOp(other.mOrigOp),
524 mMergePolicy(other.mMergePolicy)
533 mOutputTree =
nullptr;
539 if (!mInputTree || !mOutputTree)
return;
546 tbb::parallel_reduce(range, *
this);
555 if (!mOutputTree)
return;
557 for ( ; range; ++range) {
558 mOp(range.iterator(), outAccessor);
564 if (mOutputTree && other.mOutputTree) {
565 mOutputTree->merge(*other.mOutputTree, mMergePolicy);
573 OutTreeT* mOutputTree;
575 OpT
const *
const mOrigOp;
585 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
591 using OutTreeT =
typename Adapter::TreeType;
594 Processor proc(inIter, Adapter::tree(outGrid), op, merge);
595 proc.process(threaded);
598 Processor proc(inIter, Adapter::tree(outGrid), op, merge);
599 proc.process(threaded);
603 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
609 using OutTreeT =
typename Adapter::TreeType;
612 Processor proc(inIter, Adapter::tree(outGrid), op, merge);
613 proc.process(threaded);
622 template<
typename IterT,
typename OpT>
644 mOp(new OpT(*other.mOrigOp)),
645 mOrigOp(other.mOrigOp)
654 tbb::parallel_reduce(range, *
this);
668 OpT
const *
const mOrigOp;
677 template<
typename IterT,
typename XformOp>
691 #ifdef OPENVDB_USE_EXPLICIT_INSTANTIATION 693 #ifdef OPENVDB_INSTANTIATE_VALUETRANSFORMER 697 #define _FUNCTION(TreeT) \ 698 void setValueOnMin(TreeT&, const Coord&, const TreeT::ValueType&) 702 #define _FUNCTION(TreeT) \ 703 void setValueOnMax(TreeT&, const Coord&, const TreeT::ValueType&) 707 #define _FUNCTION(TreeT) \ 708 void setValueOnSum(TreeT&, const Coord&, const TreeT::ValueType&) 712 #define _FUNCTION(TreeT) \ 713 void setValueOnMult(TreeT&, const Coord&, const TreeT::ValueType&) 717 #endif // OPENVDB_USE_EXPLICIT_INSTANTIATION 724 #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:160
Definition: Exceptions.h:13
ValueT value
Definition: GridBuilder.h:1290
MergePolicy
Definition: Types.h:467
Definition: ValueAccessor.h:190
Definition: TreeIterator.h:1302
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:121
T zeroVal()
Return the value of type T that corresponds to zero.
Definition: Math.h:70
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
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:212