46 #ifndef OPENVDB_TOOLS_POINTSTOMASK_HAS_BEEN_INCLUDED 
   47 #define OPENVDB_TOOLS_POINTSTOMASK_HAS_BEEN_INCLUDED 
   56 #include <tbb/enumerable_thread_specific.h> 
   57 #include <tbb/parallel_for.h> 
   58 #include <tbb/parallel_reduce.h> 
   59 #include <tbb/blocked_range.h> 
   70 template<
typename Gr
idT = MaskGr
id, 
typename InterrupterT = util::NullInterrupter>
 
   77 template<
typename Po
intListT, 
typename Gr
idT>
 
   92 template<
typename Po
intListT>
 
   97     grid->setTransform( xform.
copy() );
 
  105 template<
typename Gr
idT, 
typename InterrupterT>
 
  115     explicit PointsToMask(GridT& grid, InterrupterT* interrupter = 
nullptr)
 
  117         , mInterrupter(interrupter)
 
  126     template<
typename Po
intListT, 
typename VecT = Vec3R>
 
  129         if (mInterrupter) mInterrupter->start(
"PointsToMask: adding points");
 
  131             typename GridT::Ptr examplar = mGrid->copyWithNewTree();
 
  132             PoolType 
pool( *examplar );
 
  133             AddPoints<PointListT, VecT> tmp(points, pool, grainSize, *
this );
 
  134             if ( this->interrupt() ) 
return;
 
  135             ReducePool reducePool(pool, mGrid, 
size_t(0));
 
  138             typename GridT::Accessor acc = mGrid->getAccessor();
 
  140             for (
size_t i = 0, 
n = points.size(); i < 
n; ++i) {
 
  141                 if ( this->interrupt() ) 
break;
 
  142                 points.getPos(i, wPos);
 
  146         if (mInterrupter) mInterrupter->end();
 
  154     bool interrupt()
 const 
  157             thread::cancelGroupExecution();
 
  165     using PoolType = tbb::enumerable_thread_specific<GridT>;
 
  166     template<
typename Po
intListT, 
typename VecT = Vec3R> 
struct AddPoints;
 
  172     InterrupterT* mInterrupter;
 
  177 template<
typename Gr
idT, 
typename InterrupterT>
 
  178 template<
typename Po
intListT, 
typename VecT>
 
  179 struct PointsToMask<GridT, InterrupterT>::AddPoints
 
  181     AddPoints(
const PointListT& 
points,
 
  189         tbb::parallel_for(tbb::blocked_range<size_t>(0, mPoints->size(), grainSize), *
this);
 
  191     void operator()(
const tbb::blocked_range<size_t>& 
range)
 const 
  193         if (mParent->interrupt()) 
return;
 
  194         GridT& grid = mPool->local();
 
  195         const math::Transform& xform = grid.transform();
 
  196         typename GridT::Accessor acc = grid.getAccessor();
 
  198         for (
size_t i=range.begin(), 
n=range.end(); i!=
n; ++i) {
 
  199             mPoints->getPos(i, wPos);
 
  200             acc.setValueOn( xform.worldToIndexCellCentered( wPos ) );
 
  203     const PointListT*    mPoints;
 
  210 template<
typename Gr
idT, 
typename InterrupterT>
 
  213     using VecT = std::vector<GridT*>;
 
  214     using IterT = 
typename VecT::iterator;
 
  215     using RangeT = tbb::blocked_range<IterT>;
 
  217     ReducePool(PoolType& pool, GridT* grid, 
size_t grainSize = 1)
 
  221         if (grainSize == 0) {
 
  222             for (
typename PoolType::const_iterator i = pool.begin(); i != pool.end(); ++i) {
 
  223                 mGrid->topologyUnion(*i);
 
  226             VecT grids( pool.size() );
 
  227             typename PoolType::iterator i = pool.begin();
 
  228             for (
size_t j=0; 
j != pool.size(); ++i, ++
j) grids[
j] = &(*i);
 
  229             tbb::parallel_reduce( 
RangeT( grids.begin(), grids.end(), grainSize ), *
this );
 
  243         for (
IterT i=r.begin(); i!=r.end(); ++i) mGrid->topologyUnion( *(*i) );
 
  256 #endif // OPENVDB_TOOLS_POINTSTOMASK_HAS_BEEN_INCLUDED 
GLdouble GLdouble GLint GLint const GLdouble * points
 
#define OPENVDB_USE_VERSION_NAMESPACE
 
OIIO_UTIL_API void parallel_for(int32_t begin, int32_t end, function_view< void(int32_t)> task, paropt opt=0)
 
void OIIO_UTIL_API split(string_view str, std::vector< string_view > &result, string_view sep=string_view(), int maxsplit=-1)
 
bool wasInterrupted(T *i, int percent=-1)
 
#define OPENVDB_VERSION_NAME
The version namespace name for this library version. 
 
**Note that the tasks the is the thread number *for the pool