10 #ifndef OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED
11 #define OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED
22 #include <tbb/blocked_range.h>
23 #include <tbb/parallel_for.h>
36 template<
typename CptGr
idT = Vec3fGr
id>
50 mCptAccessor(cptGrid.getAccessor()),
55 mCptGrid(other.mCptGrid),
56 mCptAccessor(mCptGrid->getAccessor()),
57 mCptIterations(other.mCptIterations)
64 template <
typename LocationType>
72 for (
unsigned int i = 0; i < mCptIterations; ++i) {
84 unsigned int mCptIterations;
112 typename PointListT = std::vector<typename GridT::ValueType>,
113 bool StaggeredVelocity =
false,
123 PointAdvect(
const GridT& velGrid, InterrupterType* interrupter =
nullptr):
126 mIntegrationOrder(1),
128 mInterrupter(interrupter)
132 mVelGrid(other.mVelGrid),
133 mPoints(other.mPoints),
135 mAdvIterations(other.mAdvIterations),
136 mIntegrationOrder(other.mIntegrationOrder),
137 mThreaded(other.mThreaded),
138 mInterrupter(other.mInterrupter)
145 bool earlyOut()
const {
return (mIntegrationOrder==0);}
152 void advect(PointListT&
points,
float dt,
unsigned int advIterations = 1)
157 mAdvIterations = advIterations;
159 if (mInterrupter) mInterrupter->start(
"Advecting points by OpenVDB velocity field: ");
163 (*this)(tbb::blocked_range<size_t>(0, mPoints->size()));
165 if (mInterrupter) mInterrupter->end();
171 if (mInterrupter && mInterrupter->wasInterrupted()) {
172 thread::cancelGroupExecution();
176 switch (mIntegrationOrder) {
179 for (
size_t n = range.begin();
n != range.end(); ++
n) {
182 for (
unsigned int i = 0; i < mAdvIterations; ++i) {
183 velField.template rungeKutta<1>(mDt, X0);
190 for (
size_t n = range.begin();
n != range.end(); ++
n) {
193 for (
unsigned int i = 0; i < mAdvIterations; ++i) {
194 velField.template rungeKutta<2>(mDt, X0);
201 for (
size_t n = range.begin();
n != range.end(); ++
n) {
204 for (
unsigned int i = 0; i < mAdvIterations; ++i) {
205 velField.template rungeKutta<3>(mDt, X0);
212 for (
size_t n = range.begin();
n != range.end(); ++
n) {
215 for (
unsigned int i = 0; i < mAdvIterations; ++i) {
216 velField.template rungeKutta<4>(mDt, X0);
233 unsigned int mAdvIterations;
234 unsigned int mIntegrationOrder;
238 InterrupterType* mInterrupter;
244 typename PointListT = std::vector<typename GridT::ValueType>,
245 bool StaggeredVelocity =
false,
246 typename CptGridType = GridT,
258 const GridType& cptGrid,
int cptn, InterrupterType* interrupter =
nullptr):
262 mInterrupter(interrupter)
266 mVelGrid(other.mVelGrid),
267 mCptGrid(other.mCptGrid),
268 mCptIter(other.mCptIter),
269 mPoints(other.mPoints),
271 mAdvIterations(other.mAdvIterations),
272 mIntegrationOrder(other.mIntegrationOrder),
273 mThreaded(other.mThreaded),
274 mInterrupter(other.mInterrupter)
286 void advect(PointListT&
points,
float dt,
unsigned int advIterations = 1)
291 if (mIntegrationOrder==0 && mCptIter == 0) {
294 (mIntegrationOrder>0) ? mAdvIterations = advIterations : mAdvIterations = 1;
296 if (mInterrupter) mInterrupter->start(
"Advecting points by OpenVDB velocity field: ");
297 const size_t N = mPoints->size();
302 (*this)(tbb::blocked_range<size_t>(0,
N));
304 if (mInterrupter) mInterrupter->end();
311 if (mInterrupter && mInterrupter->wasInterrupted()) {
312 thread::cancelGroupExecution();
317 switch (mIntegrationOrder) {
320 for (
size_t n = range.begin();
n != range.end(); ++
n) {
322 for (
unsigned int i = 0; i < mAdvIterations; ++i) {
330 for (
size_t n = range.begin();
n != range.end(); ++
n) {
332 for (
unsigned int i = 0; i < mAdvIterations; ++i) {
333 velField.template rungeKutta<1>(mDt, X0);
341 for (
size_t n = range.begin();
n != range.end(); ++
n) {
343 for (
unsigned int i = 0; i < mAdvIterations; ++i) {
344 velField.template rungeKutta<2>(mDt, X0);
353 for (
size_t n = range.begin();
n != range.end(); ++
n) {
355 for (
unsigned int i = 0; i < mAdvIterations; ++i) {
356 velField.template rungeKutta<3>(mDt, X0);
364 for (
size_t n = range.begin();
n != range.end(); ++
n) {
366 for (
unsigned int i = 0; i < mAdvIterations; ++i) {
367 velField.template rungeKutta<4>(mDt, X0);
384 unsigned int mAdvIterations;
385 unsigned int mIntegrationOrder;
388 InterrupterType* mInterrupter;
395 #endif // OPENVDB_TOOLS_POINT_ADVECT_HAS_BEEN_INCLUDED
void parallel_for(int64_t start, int64_t end, std::function< void(int64_t index)> &&task, parallel_options opt=parallel_options(0, Split_Y, 1))
GLdouble GLdouble GLint GLint const GLdouble * points
#define OPENVDB_USE_VERSION_NAMESPACE
**But if you need a result
Base class for interrupters.
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
GLdouble GLdouble GLint GLint order
Defines two simple wrapper classes for advection velocity fields as well as VelocitySampler and Veloc...
GA_API const UT_StringHolder N
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.