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);
149 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
151 XformOp& op,
bool threaded =
true,
bool shareOp =
true);
154 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
156 const XformOp& op,
bool threaded =
true,
bool shareOp =
true);
166 template<
typename IterT,
typename OpT>
174 void process(
bool threaded =
true)
178 tbb::parallel_for(range, *
this);
192 template<
typename IterT,
typename OpT>
203 mIter(other.mIter), mOp(*other.mOrigOp), mOrigOp(other.mOrigOp) {}
205 void process(
bool threaded =
true)
209 tbb::parallel_for(range, *
this);
226 template<
typename IterT,
typename XformOp>
228 foreach(
const IterT& iter, XformOp& op,
bool threaded,
bool shared)
235 Processor proc(iter, op);
236 proc.process(threaded);
240 template<
typename IterT,
typename XformOp>
242 foreach(
const IterT& iter,
const XformOp& op,
bool threaded,
bool )
255 template<
typename InIterT,
typename OutTreeT,
typename OpT>
266 mInputTree(inIter.getTree()),
267 mOutputTree(&outTree),
270 if (static_cast<const void*>(mInputTree) == static_cast<void*>(mOutputTree)) {
272 " to transform a grid in place");
279 mInputIter(other.mInputIter),
280 mInputTree(other.mInputTree),
295 void process(
bool threaded =
true)
297 if (!mInputTree || !mOutputTree)
return;
304 tbb::parallel_reduce(range, *
this);
313 if (!mOutputTree)
return;
315 for ( ; range; ++range) {
322 if (mOutputTree && other.mOutputTree) {
323 mOutputTree->merge(*other.mOutputTree);
330 const InTreeT* mInputTree;
331 OutTreeT* mOutputTree;
341 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
344 bool threaded,
bool )
349 typedef typename Adapter::TreeType OutTreeT;
351 Processor proc(inIter, Adapter::tree(outGrid), op);
352 proc.process(threaded);
356 template<
typename InIterT,
typename OutGr
idT,
typename XformOp>
359 bool threaded,
bool )
362 typedef typename Adapter::TreeType OutTreeT;
364 Processor proc(inIter, Adapter::tree(outGrid), op);
365 proc.process(threaded);
373 #endif // OPENVDB_TOOLS_VALUETRANSFORMER_HAS_BEEN_INCLUDED