10 #ifndef OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED    11 #define OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED    18 #include "openvdb/thread/Threading.h"    22 #include <tbb/blocked_range.h>                 23 #include <tbb/parallel_for.h>                  37 template<
typename CptGr
idT = Vec3fGr
id>
    51         mCptAccessor(cptGrid.getAccessor()),
    56         mCptGrid(other.mCptGrid),
    57         mCptAccessor(mCptGrid->getAccessor()),
    58         mCptIterations(other.mCptIterations)
    65     template <
typename LocationType>
    73         for (
unsigned int i = 0; i < mCptIterations; ++i) {
    74             const Vec3R location = mCptGrid->worldToIndex(
Vec3R(result[0], result[1], result[2]));
    75             BoxSampler::sample<CptAccessor>(mCptAccessor, location, result);
    85     unsigned int        mCptIterations;
   113          typename PointListT = std::vector<typename GridT::ValueType>,
   114          bool StaggeredVelocity = 
false,
   124     PointAdvect(
const GridT& velGrid, InterrupterType* interrupter = 
nullptr):
   127         mIntegrationOrder(1),
   129         mInterrupter(interrupter)
   133         mVelGrid(other.mVelGrid),
   134         mPoints(other.mPoints),
   136         mAdvIterations(other.mAdvIterations),
   137         mIntegrationOrder(other.mIntegrationOrder),
   138         mThreaded(other.mThreaded),
   139         mInterrupter(other.mInterrupter)
   146     bool earlyOut()
 const { 
return (mIntegrationOrder==0);}
   153     void advect(PointListT& points, 
float dt, 
unsigned int advIterations = 1)
   155         if (this->earlyOut()) 
return; 
   158         mAdvIterations = advIterations;
   160         if (mInterrupter) mInterrupter->start(
"Advecting points by OpenVDB velocity field: ");
   162             tbb::parallel_for(tbb::blocked_range<size_t>(0, mPoints->size()), *
this);
   164             (*this)(tbb::blocked_range<size_t>(0, mPoints->size()));
   166         if (mInterrupter) mInterrupter->end();
   170     void operator() (
const tbb::blocked_range<size_t> &range)
 const   172         if (mInterrupter && mInterrupter->wasInterrupted()) {
   173             thread::cancelGroupExecution();
   177         switch (mIntegrationOrder) {
   180                 for (
size_t n = range.begin(); n != range.end(); ++n) {
   183                     for (
unsigned int i = 0; i < mAdvIterations; ++i) {
   184                         velField.template rungeKutta<1>(mDt, X0);
   191                 for (
size_t n = range.begin(); n != range.end(); ++n) {
   194                     for (
unsigned int i = 0; i < mAdvIterations; ++i) {
   195                         velField.template rungeKutta<2>(mDt, X0);
   202                 for (
size_t n = range.begin(); n != range.end(); ++n) {
   205                     for (
unsigned int i = 0; i < mAdvIterations; ++i) {
   206                         velField.template rungeKutta<3>(mDt, X0);
   213                 for (
size_t n = range.begin(); n != range.end(); ++n) {
   216                     for (
unsigned int i = 0; i < mAdvIterations; ++i) {
   217                         velField.template rungeKutta<4>(mDt, X0);
   234     unsigned int           mAdvIterations;     
   235     unsigned int           mIntegrationOrder;
   239     InterrupterType*       mInterrupter;
   245          typename PointListT = std::vector<typename GridT::ValueType>,
   246          bool StaggeredVelocity = 
false,
   247          typename CptGridType = GridT,
   259         const GridType& cptGrid, 
int cptn, InterrupterType* interrupter = 
nullptr):
   263         mInterrupter(interrupter)
   267         mVelGrid(other.mVelGrid),
   268         mCptGrid(other.mCptGrid),
   269         mCptIter(other.mCptIter),
   270         mPoints(other.mPoints),
   272         mAdvIterations(other.mAdvIterations),
   273         mIntegrationOrder(other.mIntegrationOrder),
   274         mThreaded(other.mThreaded),
   275         mInterrupter(other.mInterrupter)
   287     void advect(PointListT& points, 
float dt, 
unsigned int advIterations = 1)
   292         if (mIntegrationOrder==0 && mCptIter == 0) {
   295         (mIntegrationOrder>0) ? mAdvIterations = advIterations : mAdvIterations = 1;
   297         if (mInterrupter) mInterrupter->start(
"Advecting points by OpenVDB velocity field: ");
   298         const size_t N = mPoints->size();
   301             tbb::parallel_for(tbb::blocked_range<size_t>(0, N), *
this);
   303             (*this)(tbb::blocked_range<size_t>(0, N));
   305         if (mInterrupter) mInterrupter->end();
   310     void operator() (
const tbb::blocked_range<size_t> &range)
 const   312         if (mInterrupter && mInterrupter->wasInterrupted()) {
   313             thread::cancelGroupExecution();
   318         switch (mIntegrationOrder) {
   321                 for (
size_t n = range.begin(); n != range.end(); ++n) {
   323                     for (
unsigned int i = 0; i < mAdvIterations; ++i) {
   331                 for (
size_t n = range.begin(); n != range.end(); ++n) {
   333                     for (
unsigned int i = 0; i < mAdvIterations; ++i) {
   334                         velField.template rungeKutta<1>(mDt, X0);
   342                 for (
size_t n = range.begin(); n != range.end(); ++n) {
   344                     for (
unsigned int i = 0; i < mAdvIterations; ++i) {
   345                         velField.template rungeKutta<2>(mDt, X0);
   354                 for (
size_t n = range.begin(); n != range.end(); ++n) {
   356                     for (
unsigned int i = 0; i < mAdvIterations; ++i) {
   357                         velField.template rungeKutta<3>(mDt, X0);
   365                 for (
size_t n = range.begin(); n != range.end(); ++n) {
   367                     for (
unsigned int i = 0; i < mAdvIterations; ++i) {
   368                         velField.template rungeKutta<4>(mDt, X0);
   385     unsigned int            mAdvIterations;     
   386     unsigned int            mIntegrationOrder;  
   389     InterrupterType*        mInterrupter;
   396 #endif // OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED 
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
Defines two simple wrapper classes for advection velocity fields as well as VelocitySampler and Veloc...
Base class for interrupters. 
Definition: NullInterrupter.h:25
Vec3SGrid Vec3fGrid
Definition: openvdb.h:54
math::Vec3< Real > Vec3R
Definition: Types.h:72
Definition: Exceptions.h:13
#define OPENVDB_VERSION_NAME
The version namespace name for this library version. 
Definition: version.h.in:116
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:202