42 #ifndef OPENVDB_TOOLS_VALUETRANSFORMER_HAS_BEEN_INCLUDED
43 #define OPENVDB_TOOLS_VALUETRANSFORMER_HAS_BEEN_INCLUDED
45 #include <tbb/parallel_for.h>
46 #include <tbb/parallel_reduce.h>
47 #include <openvdb/Types.h>
48 #include <openvdb/Grid.h>
99 template<
typename IterT,
typename XformOp>
100 inline void foreach(
const IterT& iter, XformOp& op,
101 bool threaded =
true,
bool shareOp =
true);
103 template<
typename IterT,
typename XformOp>
104 inline void foreach(
const IterT& iter,
const XformOp& op,
105 bool threaded =
true,
bool shareOp =
true);
147 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
149 XformOp& op,
bool threaded =
true,
bool shareOp =
true);
152 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
154 const XformOp& op,
bool threaded =
true,
bool shareOp =
true);
163 template<
typename IterT,
typename OpT>
171 void process(
bool threaded =
true)
175 tbb::parallel_for(range, *
this);
189 template<
typename IterT,
typename OpT>
200 mIter(other.mIter), mOp(*other.mOrigOp), mOrigOp(other.mOrigOp) {}
202 void process(
bool threaded =
true)
206 tbb::parallel_for(range, *
this);
217 OpT
const *
const mOrigOp;
223 template<
typename IterT,
typename XformOp>
225 foreach(
const IterT& iter, XformOp& op,
bool threaded,
bool shared)
232 Processor proc(iter, op);
233 proc.process(threaded);
237 template<
typename IterT,
typename XformOp>
239 foreach(
const IterT& iter,
const XformOp& op,
bool threaded,
bool )
252 template<
typename InIterT,
typename OutTreeT,
typename OpT>
263 mInputTree(inIter.getTree()),
264 mOutputTree(&outTree),
267 if (static_cast<const void*>(mInputTree) == static_cast<void*>(mOutputTree)) {
269 " to transform a grid in place");
276 mInputIter(other.mInputIter),
277 mInputTree(other.mInputTree),
292 void process(
bool threaded =
true)
294 if (!mInputTree || !mOutputTree)
return;
301 tbb::parallel_reduce(range, *
this);
310 if (!mOutputTree)
return;
312 for ( ; range; ++range) {
319 if (mOutputTree && other.mOutputTree) {
320 mOutputTree->merge(*other.mOutputTree);
327 const InTreeT* mInputTree;
328 OutTreeT* mOutputTree;
333 template<
typename InIterT,
typename OutTreeT,
typename OpT>
344 mInputTree(inIter.getTree()),
345 mOutputTree(&outTree),
349 if (static_cast<const void*>(mInputTree) == static_cast<void*>(mOutputTree)) {
351 " to transform a grid in place");
359 mInputIter(other.mInputIter),
360 mInputTree(other.mInputTree),
363 mOrigOp(other.mOrigOp)
376 void process(
bool threaded =
true)
378 if (!mInputTree || !mOutputTree)
return;
385 tbb::parallel_reduce(range, *
this);
394 if (!mOutputTree)
return;
396 for ( ; range; ++range) {
403 if (mOutputTree && other.mOutputTree) {
404 mOutputTree->merge(*other.mOutputTree);
411 const InTreeT* mInputTree;
412 OutTreeT* mOutputTree;
414 OpT
const *
const mOrigOp;
423 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
426 bool threaded,
bool shared)
429 typedef typename Adapter::TreeType OutTreeT;
432 Processor proc(inIter, Adapter::tree(outGrid), op);
433 proc.process(threaded);
436 Processor proc(inIter, Adapter::tree(outGrid), op);
437 proc.process(threaded);
442 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
445 bool threaded,
bool )
448 typedef typename Adapter::TreeType OutTreeT;
451 Processor proc(inIter, Adapter::tree(outGrid), op);
452 proc.process(threaded);
460 #endif // OPENVDB_TOOLS_VALUETRANSFORMER_HAS_BEEN_INCLUDED