49 #ifndef OPENVDB_TOOLS_VALUETRANSFORMER_HAS_BEEN_INCLUDED
50 #define OPENVDB_TOOLS_VALUETRANSFORMER_HAS_BEEN_INCLUDED
52 #include <tbb/parallel_for.h>
53 #include <tbb/parallel_reduce.h>
54 #include <openvdb/Types.h>
55 #include <openvdb/Grid.h>
106 template<
typename IterT,
typename XformOp>
107 inline void foreach(
const IterT& iter, XformOp& op,
108 bool threaded =
true,
bool shareOp =
true);
110 template<
typename IterT,
typename XformOp>
111 inline void foreach(
const IterT& iter,
const XformOp& op,
112 bool threaded =
true,
bool shareOp =
true);
154 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
156 XformOp& op,
bool threaded =
true,
bool shareOp =
true);
159 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
161 const XformOp& op,
bool threaded =
true,
bool shareOp =
true);
209 template<
typename IterT,
typename XformOp>
210 inline void accumulate(
const IterT& iter, XformOp& op,
bool threaded =
true);
218 template<
typename IterT,
typename OpT>
230 tbb::parallel_for(range, *
this);
244 template<
typename IterT,
typename OpT>
255 mIter(other.mIter), mOp(*other.mOrigOp), mOrigOp(other.mOrigOp) {}
261 tbb::parallel_for(range, *
this);
272 OpT
const *
const mOrigOp;
278 template<
typename IterT,
typename XformOp>
280 foreach(
const IterT& iter, XformOp& op,
bool threaded,
bool shared)
287 Processor proc(iter, op);
288 proc.process(threaded);
292 template<
typename IterT,
typename XformOp>
294 foreach(
const IterT& iter,
const XformOp& op,
bool threaded,
bool )
307 template<
typename InIterT,
typename OutTreeT,
typename OpT>
318 mInputTree(inIter.getTree()),
319 mOutputTree(&outTree),
322 if (static_cast<const void*>(mInputTree) == static_cast<void*>(mOutputTree)) {
324 " to transform a grid in place");
331 mInputIter(other.mInputIter),
332 mInputTree(other.mInputTree),
349 if (!mInputTree || !mOutputTree)
return;
356 tbb::parallel_reduce(range, *
this);
365 if (!mOutputTree)
return;
367 for ( ; range; ++range) {
374 if (mOutputTree && other.mOutputTree) {
375 mOutputTree->merge(*other.mOutputTree);
382 const InTreeT* mInputTree;
383 OutTreeT* mOutputTree;
388 template<
typename InIterT,
typename OutTreeT,
typename OpT>
399 mInputTree(inIter.getTree()),
400 mOutputTree(&outTree),
404 if (static_cast<const void*>(mInputTree) == static_cast<void*>(mOutputTree)) {
406 " to transform a grid in place");
414 mInputIter(other.mInputIter),
415 mInputTree(other.mInputTree),
418 mOrigOp(other.mOrigOp)
433 if (!mInputTree || !mOutputTree)
return;
440 tbb::parallel_reduce(range, *
this);
449 if (!mOutputTree)
return;
451 for ( ; range; ++range) {
458 if (mOutputTree && other.mOutputTree) {
459 mOutputTree->merge(*other.mOutputTree);
466 const InTreeT* mInputTree;
467 OutTreeT* mOutputTree;
469 OpT
const *
const mOrigOp;
478 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
481 bool threaded,
bool shared)
484 typedef typename Adapter::TreeType OutTreeT;
487 Processor proc(inIter, Adapter::tree(outGrid), op);
488 proc.process(threaded);
491 Processor proc(inIter, Adapter::tree(outGrid), op);
492 proc.process(threaded);
497 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
500 bool threaded,
bool )
503 typedef typename Adapter::TreeType OutTreeT;
506 Processor proc(inIter, Adapter::tree(outGrid), op);
507 proc.process(threaded);
517 template<
typename IterT,
typename OpT>
539 mOp(new OpT(*other.mOrigOp)),
540 mOrigOp(other.mOrigOp)
549 tbb::parallel_reduce(range, *
this);
563 OpT
const *
const mOrigOp;
572 template<
typename IterT,
typename XformOp>
584 #endif // OPENVDB_TOOLS_VALUETRANSFORMER_HAS_BEEN_INCLUDED