OpenVDB  2.3.0
Interpolation.h
Go to the documentation of this file.
1 //
3 // Copyright (c) 2012-2013 DreamWorks Animation LLC
4 //
5 // All rights reserved. This software is distributed under the
6 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
7 //
8 // Redistributions of source code must retain the above copyright
9 // and license notice and the following restrictions and disclaimer.
10 //
11 // * Neither the name of DreamWorks Animation nor the names of
12 // its contributors may be used to endorse or promote products derived
13 // from this software without specific prior written permission.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
20 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 // IN NO EVENT SHALL THE COPYRIGHT HOLDERS' AND CONTRIBUTORS' AGGREGATE
27 // LIABILITY FOR ALL CLAIMS REGARDLESS OF THEIR BASIS EXCEED US$250.00.
28 //
30 //
66 
67 #ifndef OPENVDB_TOOLS_INTERPOLATION_HAS_BEEN_INCLUDED
68 #define OPENVDB_TOOLS_INTERPOLATION_HAS_BEEN_INCLUDED
69 
70 #include <cmath>
71 #include <boost/shared_ptr.hpp>
72 #include <openvdb/version.h> // for OPENVDB_VERSION_NAME
73 #include <openvdb/Platform.h> // for round()
74 #include <openvdb/math/Transform.h> // for Transform
75 #include <openvdb/Grid.h>
76 #include <openvdb/tree/ValueAccessor.h>
77 
78 namespace openvdb {
80 namespace OPENVDB_VERSION_NAME {
81 namespace tools {
82 
83 // The following samplers operate in voxel space.
84 // When the samplers are applied to grids holding vector or other non-scalar data,
85 // the data is assumed to be collocated. For example, using the BoxSampler on a grid
86 // with ValueType Vec3f assumes that all three elements in a vector can be assigned
87 // the same physical location. Consider using the GridSampler below instead.
88 
90 {
91  static const char* name() { return "point"; }
92  static int radius() { return 0; }
93  static bool mipmap() { return false; }
94  static bool consistent() { return true; }
95 
99  template<class TreeT>
100  static bool sample(const TreeT& inTree, const Vec3R& inCoord,
101  typename TreeT::ValueType& result);
102 };
103 
104 
106 {
107  static const char* name() { return "box"; }
108  static int radius() { return 1; }
109  static bool mipmap() { return true; }
110  static bool consistent() { return true; }
111 
115  template<class TreeT>
116  static bool sample(const TreeT& inTree, const Vec3R& inCoord,
117  typename TreeT::ValueType& result);
118 
121  template<class TreeT>
122  static typename TreeT::ValueType sample(const TreeT& inTree, const Vec3R& inCoord);
123 
124 private:
125  template<class ValueT, size_t N>
126  static inline ValueT trilinearInterpolation(ValueT (& data)[N][N][N], const Vec3R& uvw);
127 };
128 
129 
131 {
132  static const char* name() { return "quadratic"; }
133  static int radius() { return 1; }
134  static bool mipmap() { return true; }
135  static bool consistent() { return false; }
136 
140  template<class TreeT>
141  static bool sample(const TreeT& inTree, const Vec3R& inCoord,
142  typename TreeT::ValueType& result);
143 };
144 
145 
147 
148 
149 // The following samplers operate in voxel space and are designed for Vec3
150 // staggered grid data (e.g., fluid simulations using the Marker-and-Cell approach
151 // associate elements of the velocity vector with different physical locations:
152 // the faces of a cube).
153 
155 {
156  static const char* name() { return "point"; }
157  static int radius() { return 0; }
158  static bool mipmap() { return false; }
159  static bool consistent() { return false; }
160 
164  template<class TreeT>
165  static bool sample(const TreeT& inTree, const Vec3R& inCoord,
166  typename TreeT::ValueType& result);
167 };
168 
169 
171 {
172  static const char* name() { return "box"; }
173  static int radius() { return 1; }
174  static bool mipmap() { return true; }
175  static bool consistent() { return false; }
176 
180  template<class TreeT>
181  static bool sample(const TreeT& inTree, const Vec3R& inCoord,
182  typename TreeT::ValueType& result);
183 };
184 
185 
187 {
188  static const char* name() { return "quadratic"; }
189  static int radius() { return 1; }
190  static bool mipmap() { return true; }
191  static bool consistent() { return false; }
192 
196  template<class TreeT>
197  static bool sample(const TreeT& inTree, const Vec3R& inCoord,
198  typename TreeT::ValueType& result);
199 };
200 
201 
203 
204 
219 template<typename GridOrTreeType, typename SamplerType>
221 {
222 public:
223  typedef boost::shared_ptr<GridSampler> Ptr;
224  typedef typename GridOrTreeType::ValueType ValueType;
228 
230  explicit GridSampler(const GridType& grid)
231  : mTree(&(grid.tree())), mTransform(&(grid.transform())) {}
232 
235  GridSampler(const TreeType& tree, const math::Transform& transform)
236  : mTree(&tree), mTransform(&transform) {}
237 
238  const math::Transform& transform() const { return *mTransform; }
239 
244  template<typename RealType>
245  ValueType sampleVoxel(const RealType& x, const RealType& y, const RealType& z) const
246  {
247  return this->isSample(Vec3d(x,y,z));
248  }
249 
254  ValueType sampleVoxel(typename Coord::ValueType i,
255  typename Coord::ValueType j,
256  typename Coord::ValueType k) const
257  {
258  return this->isSample(Coord(i,j,k));
259  }
260 
263  ValueType isSample(const Coord& ijk) const { return mTree->getValue(ijk); }
264 
267  ValueType isSample(const Vec3d& ispoint) const
268  {
269  ValueType result = zeroVal<ValueType>();
270  SamplerType::sample(*mTree, ispoint, result);
271  return result;
272  }
273 
276  ValueType wsSample(const Vec3d& wspoint) const
277  {
278  ValueType result = zeroVal<ValueType>();
279  SamplerType::sample(*mTree, mTransform->worldToIndex(wspoint), result);
280  return result;
281  }
282 
283 private:
284  const TreeType* mTree;
285  const math::Transform* mTransform;
286 }; // class GridSampler
287 
288 
301 template<typename TreeT, typename SamplerType>
302 class GridSampler<tree::ValueAccessor<TreeT>, SamplerType>
303 {
304 public:
305  typedef boost::shared_ptr<GridSampler> Ptr;
306  typedef typename TreeT::ValueType ValueType;
307  typedef TreeT TreeType;
310 
314  const math::Transform& transform)
315  : mAccessor(&acc), mTransform(&transform) {}
316 
317  const math::Transform& transform() const { return *mTransform; }
318 
323  template<typename RealType>
324  ValueType sampleVoxel(const RealType& x, const RealType& y, const RealType& z) const
325  {
326  return this->isSample(Vec3d(x,y,z));
327  }
328 
333  ValueType sampleVoxel(typename Coord::ValueType i,
334  typename Coord::ValueType j,
335  typename Coord::ValueType k) const
336  {
337  return this->isSample(Coord(i,j,k));
338  }
339 
342  ValueType isSample(const Coord& ijk) const { return mAccessor->getValue(ijk); }
343 
346  ValueType isSample(const Vec3d& ispoint) const
347  {
348  ValueType result = zeroVal<ValueType>();
349  SamplerType::sample(*mAccessor, ispoint, result);
350  return result;
351  }
352 
355  ValueType wsSample(const Vec3d& wspoint) const
356  {
357  ValueType result = zeroVal<ValueType>();
358  SamplerType::sample(*mAccessor, mTransform->worldToIndex(wspoint), result);
359  return result;
360  }
361 
362 private:
363  const AccessorType* mAccessor;//not thread-safe!
364  const math::Transform* mTransform;
365 };//Specialization of GridSampler
366 
367 
369 
370 
380 template<typename GridOrTreeT,
381  typename SamplerT>
383 {
384 public:
385  typedef typename GridOrTreeT::ValueType ValueType;
389 
393  DualGridSampler(const GridType& sourceGrid,
394  const math::Transform& targetXform)
395  : mSourceTree(&(sourceGrid.tree()))
396  , mSourceXform(&(sourceGrid.transform()))
397  , mTargetXform(&targetXform)
398  , mAligned(targetXform == *mSourceXform)
399  {
400  }
405  DualGridSampler(const TreeType& sourceTree,
406  const math::Transform& sourceXform,
407  const math::Transform& targetXform)
408  : mSourceTree(&sourceTree)
409  , mSourceXform(&sourceXform)
410  , mTargetXform(&targetXform)
411  , mAligned(targetXform == sourceXform)
412  {
413  }
416  inline ValueType operator()(const Coord& ijk) const
417  {
418  if (mAligned) return mSourceTree->getValue(ijk);
419  const Vec3R world = mTargetXform->indexToWorld(ijk);
420  return SamplerT::sample(*mSourceTree, mSourceXform->worldToIndex(world));
421  }
423  inline bool isAligned() const { return mAligned; }
424 private:
425  const TreeType* mSourceTree;
426  const math::Transform* mSourceXform;
427  const math::Transform* mTargetXform;
428  const bool mAligned;
429 };// DualGridSampler
430 
432 template<typename TreeT,
433  typename SamplerT>
434 class DualGridSampler<tree::ValueAccessor<TreeT>, SamplerT>
435 {
436  public:
437  typedef typename TreeT::ValueType ValueType;
438  typedef TreeT TreeType;
441 
446  DualGridSampler(const AccessorType& sourceAccessor,
447  const math::Transform& sourceXform,
448  const math::Transform& targetXform)
449  : mSourceAcc(&sourceAccessor)
450  , mSourceXform(&sourceXform)
451  , mTargetXform(&targetXform)
452  , mAligned(targetXform == sourceXform)
453  {
454  }
457  inline ValueType operator()(const Coord& ijk) const
458  {
459  if (mAligned) return mSourceAcc->getValue(ijk);
460  const Vec3R world = mTargetXform->indexToWorld(ijk);
461  return SamplerT::sample(*mSourceAcc, mSourceXform->worldToIndex(world));
462  }
464  inline bool isAligned() const { return mAligned; }
465 private:
466  const AccessorType* mSourceAcc;
467  const math::Transform* mSourceXform;
468  const math::Transform* mTargetXform;
469  const bool mAligned;
470 };//Specialization of DualGridSampler
471 
473 
474 
475 namespace local_util {
476 
477 inline Vec3i
478 floorVec3(const Vec3R& v)
479 {
480  return Vec3i(int(std::floor(v(0))), int(std::floor(v(1))), int(std::floor(v(2))));
481 }
482 
483 
484 inline Vec3i
485 ceilVec3(const Vec3R& v)
486 {
487  return Vec3i(int(std::ceil(v(0))), int(std::ceil(v(1))), int(std::ceil(v(2))));
488 }
489 
490 
491 inline Vec3i
492 roundVec3(const Vec3R& v)
493 {
494  return Vec3i(int(::round(v(0))), int(::round(v(1))), int(::round(v(2))));
495 }
496 
497 } // namespace local_util
498 
499 
501 
502 
503 template<class TreeT>
504 inline bool
505 PointSampler::sample(const TreeT& inTree, const Vec3R& inCoord,
506  typename TreeT::ValueType& result)
507 {
508  Vec3i inIdx = local_util::roundVec3(inCoord);
509  return inTree.probeValue(Coord(inIdx), result);
510 }
511 
512 
514 
515 
516 template<class ValueT, size_t N>
517 inline ValueT
518 BoxSampler::trilinearInterpolation(ValueT (& data)[N][N][N], const Vec3R& uvw)
519 {
520  // Trilinear interpolation:
521  // The eight surrounding latice values are used to construct the result. \n
522  // result(x,y,z) =
523  // v000 (1-x)(1-y)(1-z) + v001 (1-x)(1-y)z + v010 (1-x)y(1-z) + v011 (1-x)yz
524  // + v100 x(1-y)(1-z) + v101 x(1-y)z + v110 xy(1-z) + v111 xyz
525 
526  ValueT resultA, resultB;
527 
528  resultA = data[0][0][0] + ValueT((data[0][0][1] - data[0][0][0]) * uvw[2]);
529  resultB = data[0][1][0] + ValueT((data[0][1][1] - data[0][1][0]) * uvw[2]);
530  ValueT result1 = resultA + ValueT((resultB-resultA) * uvw[1]);
531 
532  resultA = data[1][0][0] + ValueT((data[1][0][1] - data[1][0][0]) * uvw[2]);
533  resultB = data[1][1][0] + ValueT((data[1][1][1] - data[1][1][0]) * uvw[2]);
534  ValueT result2 = resultA + ValueT((resultB - resultA) * uvw[1]);
535 
536  return result1 + ValueT(uvw[0] * (result2 - result1));
537 }
538 
539 
540 template<class TreeT>
541 inline bool
542 BoxSampler::sample(const TreeT& inTree, const Vec3R& inCoord,
543  typename TreeT::ValueType& result)
544 {
545  typedef typename TreeT::ValueType ValueT;
546 
547  Vec3i inIdx = local_util::floorVec3(inCoord);
548  Vec3R uvw = inCoord - inIdx;
549 
550  // Retrieve the values of the eight voxels surrounding the
551  // fractional source coordinates.
552  ValueT data[2][2][2];
553 
554  bool hasActiveValues = false;
555  Coord ijk(inIdx);
556  hasActiveValues |= inTree.probeValue(ijk, data[0][0][0]); // i, j, k
557  ijk[2] += 1;
558  hasActiveValues |= inTree.probeValue(ijk, data[0][0][1]); // i, j, k + 1
559  ijk[1] += 1;
560  hasActiveValues |= inTree.probeValue(ijk, data[0][1][1]); // i, j+1, k + 1
561  ijk[2] = inIdx[2];
562  hasActiveValues |= inTree.probeValue(ijk, data[0][1][0]); // i, j+1, k
563  ijk[0] += 1;
564  ijk[1] = inIdx[1];
565  hasActiveValues |= inTree.probeValue(ijk, data[1][0][0]); // i+1, j, k
566  ijk[2] += 1;
567  hasActiveValues |= inTree.probeValue(ijk, data[1][0][1]); // i+1, j, k + 1
568  ijk[1] += 1;
569  hasActiveValues |= inTree.probeValue(ijk, data[1][1][1]); // i+1, j+1, k + 1
570  ijk[2] = inIdx[2];
571  hasActiveValues |= inTree.probeValue(ijk, data[1][1][0]); // i+1, j+1, k
572 
573  result = trilinearInterpolation(data, uvw);
574  return hasActiveValues;
575 }
576 
577 
578 template<class TreeT>
579 inline typename TreeT::ValueType
580 BoxSampler::sample(const TreeT& inTree, const Vec3R& inCoord)
581 {
582  typedef typename TreeT::ValueType ValueT;
583 
584  Vec3i inIdx = local_util::floorVec3(inCoord);
585  Vec3R uvw = inCoord - inIdx;
586 
587  // Retrieve the values of the eight voxels surrounding the
588  // fractional source coordinates.
589  ValueT data[2][2][2];
590 
591  Coord ijk(inIdx);
592  data[0][0][0] = inTree.getValue(ijk); // i, j, k
593  ijk[2] += 1;
594  data[0][0][1] = inTree.getValue(ijk); // i, j, k + 1
595  ijk[1] += 1;
596  data[0][1][1] = inTree.getValue(ijk); // i, j+1, k + 1
597  ijk[2] = inIdx[2];
598  data[0][1][0] = inTree.getValue(ijk); // i, j+1, k
599  ijk[0] += 1;
600  ijk[1] = inIdx[1];
601  data[1][0][0] = inTree.getValue(ijk); // i+1, j, k
602  ijk[2] += 1;
603  data[1][0][1] = inTree.getValue(ijk); // i+1, j, k + 1
604  ijk[1] += 1;
605  data[1][1][1] = inTree.getValue(ijk); // i+1, j+1, k + 1
606  ijk[2] = inIdx[2];
607  data[1][1][0] = inTree.getValue(ijk); // i+1, j+1, k
608 
609  return trilinearInterpolation(data, uvw);
610 }
611 
612 
614 
615 
616 template<class TreeT>
617 inline bool
618 QuadraticSampler::sample(const TreeT& inTree, const Vec3R& inCoord,
619  typename TreeT::ValueType& result)
620 {
621  typedef typename TreeT::ValueType ValueT;
622 
623  Vec3i
624  inIdx = local_util::floorVec3(inCoord),
625  inLoIdx = inIdx - Vec3i(1, 1, 1);
626  Vec3R frac = inCoord - inIdx;
627 
628  // Retrieve the values of the 27 voxels surrounding the
629  // fractional source coordinates.
630  bool active = false;
631  ValueT v[3][3][3];
632  for (int dx = 0, ix = inLoIdx.x(); dx < 3; ++dx, ++ix) {
633  for (int dy = 0, iy = inLoIdx.y(); dy < 3; ++dy, ++iy) {
634  for (int dz = 0, iz = inLoIdx.z(); dz < 3; ++dz, ++iz) {
635  if (inTree.probeValue(Coord(ix, iy, iz), v[dx][dy][dz])) {
636  active = true;
637  }
638  }
639  }
640  }
641 
643  ValueT vx[3];
644  for (int dx = 0; dx < 3; ++dx) {
645  ValueT vy[3];
646  for (int dy = 0; dy < 3; ++dy) {
647  // Fit a parabola to three contiguous samples in z
648  // (at z=-1, z=0 and z=1), then evaluate the parabola at z',
649  // where z' is the fractional part of inCoord.z, i.e.,
650  // inCoord.z - inIdx.z. The coefficients come from solving
651  //
652  // | (-1)^2 -1 1 || a | | v0 |
653  // | 0 0 1 || b | = | v1 |
654  // | 1^2 1 1 || c | | v2 |
655  //
656  // for a, b and c.
657  const ValueT* vz = &v[dx][dy][0];
658  const ValueT
659  az = static_cast<ValueT>(0.5 * (vz[0] + vz[2]) - vz[1]),
660  bz = static_cast<ValueT>(0.5 * (vz[2] - vz[0])),
661  cz = static_cast<ValueT>(vz[1]);
662  vy[dy] = static_cast<ValueT>(frac.z() * (frac.z() * az + bz) + cz);
663  }
664  // Fit a parabola to three interpolated samples in y, then
665  // evaluate the parabola at y', where y' is the fractional
666  // part of inCoord.y.
667  const ValueT
668  ay = static_cast<ValueT>(0.5 * (vy[0] + vy[2]) - vy[1]),
669  by = static_cast<ValueT>(0.5 * (vy[2] - vy[0])),
670  cy = static_cast<ValueT>(vy[1]);
671  vx[dx] = static_cast<ValueT>(frac.y() * (frac.y() * ay + by) + cy);
672  }
673  // Fit a parabola to three interpolated samples in x, then
674  // evaluate the parabola at the fractional part of inCoord.x.
675  const ValueT
676  ax = static_cast<ValueT>(0.5 * (vx[0] + vx[2]) - vx[1]),
677  bx = static_cast<ValueT>(0.5 * (vx[2] - vx[0])),
678  cx = static_cast<ValueT>(vx[1]);
679  result = static_cast<ValueT>(frac.x() * (frac.x() * ax + bx) + cx);
680 
681  return active;
682 }
683 
684 
686 
687 
688 template<class TreeT>
689 inline bool
690 StaggeredPointSampler::sample(const TreeT& inTree, const Vec3R& inCoord,
691  typename TreeT::ValueType& result)
692 {
693  typedef typename TreeT::ValueType ValueType;
694 
695  ValueType tempX, tempY, tempZ;
696  bool active = false;
697 
698  active = PointSampler::sample<TreeT>(inTree, inCoord + Vec3R(0.5, 0, 0), tempX) || active;
699  active = PointSampler::sample<TreeT>(inTree, inCoord + Vec3R(0, 0.5, 0), tempY) || active;
700  active = PointSampler::sample<TreeT>(inTree, inCoord + Vec3R(0, 0, 0.5), tempZ) || active;
701 
702  result.x() = tempX.x();
703  result.y() = tempY.y();
704  result.z() = tempZ.z();
705 
706  return active;
707 }
708 
709 
711 
712 
713 template<class TreeT>
714 inline bool
715 StaggeredBoxSampler::sample(const TreeT& inTree, const Vec3R& inCoord,
716  typename TreeT::ValueType& result)
717 {
718  typedef typename TreeT::ValueType ValueType;
719 
720  ValueType tempX, tempY, tempZ;
721  tempX = tempY = tempZ = zeroVal<ValueType>();
722  bool active = false;
723 
724  active = BoxSampler::sample<TreeT>(inTree, inCoord + Vec3R(0.5, 0, 0), tempX) || active;
725  active = BoxSampler::sample<TreeT>(inTree, inCoord + Vec3R(0, 0.5, 0), tempY) || active;
726  active = BoxSampler::sample<TreeT>(inTree, inCoord + Vec3R(0, 0, 0.5), tempZ) || active;
727 
728  result.x() = tempX.x();
729  result.y() = tempY.y();
730  result.z() = tempZ.z();
731 
732  return active;
733 }
734 
735 
737 
738 
739 template<class TreeT>
740 inline bool
741 StaggeredQuadraticSampler::sample(const TreeT& inTree, const Vec3R& inCoord,
742  typename TreeT::ValueType& result)
743 {
744  typedef typename TreeT::ValueType ValueType;
745 
746  ValueType tempX, tempY, tempZ;
747  bool active = false;
748 
749  active = QuadraticSampler::sample<TreeT>(inTree, inCoord + Vec3R(0.5, 0, 0), tempX) || active;
750  active = QuadraticSampler::sample<TreeT>(inTree, inCoord + Vec3R(0, 0.5, 0), tempY) || active;
751  active = QuadraticSampler::sample<TreeT>(inTree, inCoord + Vec3R(0, 0, 0.5), tempZ) || active;
752 
753  result.x() = tempX.x();
754  result.y() = tempY.y();
755  result.z() = tempZ.z();
756 
757  return active;
758 }
759 
760 } // namespace tools
761 } // namespace OPENVDB_VERSION_NAME
762 } // namespace openvdb
763 
764 #endif // OPENVDB_TOOLS_INTERPOLATION_HAS_BEEN_INCLUDED
765 
766 // Copyright (c) 2012-2013 DreamWorks Animation LLC
767 // All rights reserved. This software is distributed under the
768 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
TreeAdapter< GridOrTreeType >::GridType GridType
Definition: Interpolation.h:225
TreeAdapter< GridOrTreeType >::AccessorType AccessorType
Definition: Interpolation.h:227
ValueType wsSample(const Vec3d &wspoint) const
Sample in world space.
Definition: Interpolation.h:355
math::Vec3< Real > Vec3R
Definition: Types.h:75
static bool mipmap()
Definition: Interpolation.h:174
static int radius()
Definition: Interpolation.h:157
tree::ValueAccessor< TreeT > AccessorType
Definition: Interpolation.h:440
static const char * name()
Definition: Interpolation.h:156
bool isAligned() const
Return true if the two grids are aligned.
Definition: Interpolation.h:464
boost::shared_ptr< GridSampler > Ptr
Definition: Interpolation.h:223
Vec3i roundVec3(const Vec3R &v)
Definition: Interpolation.h:492
GridSampler(const GridType &grid)
Definition: Interpolation.h:230
Definition: Interpolation.h:170
static bool mipmap()
Definition: Interpolation.h:93
T & z()
Definition: Vec3.h:96
static bool mipmap()
Definition: Interpolation.h:158
TreeAdapter< GridOrTreeType >::TreeType TreeType
Definition: Interpolation.h:226
Vec3i floorVec3(const Vec3R &v)
Definition: Interpolation.h:478
static bool consistent()
Definition: Interpolation.h:135
DualGridSampler(const AccessorType &sourceAccessor, const math::Transform &sourceXform, const math::Transform &targetXform)
ValueAccessor and transform constructor.
Definition: Interpolation.h:446
static bool consistent()
Definition: Interpolation.h:110
T & y()
Definition: Vec3.h:95
ValueType isSample(const Coord &ijk) const
Sample value in integer index space.
Definition: Interpolation.h:342
static const char * name()
Definition: Interpolation.h:132
static const char * name()
Definition: Interpolation.h:107
GridOrTreeT::ValueType ValueType
Definition: Interpolation.h:385
static int radius()
Definition: Interpolation.h:92
static bool consistent()
Definition: Interpolation.h:159
static bool mipmap()
Definition: Interpolation.h:190
ValueType isSample(const Vec3d &ispoint) const
Sample in fractional index space.
Definition: Interpolation.h:267
This is a simple convenience class that allows for sampling from a source grid into the index space o...
Definition: Interpolation.h:382
Container class that associates a tree with a transform and metadata.
Definition: Grid.h:54
Definition: Interpolation.h:154
const math::Transform & transform() const
Definition: Interpolation.h:238
Definition: Interpolation.h:130
TreeAdapter< GridType >::AccessorType AccessorType
Definition: Interpolation.h:388
#define OPENVDB_VERSION_NAME
Definition: version.h:45
static bool mipmap()
Definition: Interpolation.h:134
TreeAdapter< GridOrTreeT >::TreeType TreeType
Definition: Interpolation.h:387
Definition: Interpolation.h:89
static const char * name()
Definition: Interpolation.h:188
ValueType operator()(const Coord &ijk) const
Return the value of the source grid at the index coordinates, ijk, relative to the target grid...
Definition: Interpolation.h:457
GridSampler(const TreeType &tree, const math::Transform &transform)
Definition: Interpolation.h:235
Vec3< int32_t > Vec3i
Definition: Vec3.h:622
GridSampler(const AccessorType &acc, const math::Transform &transform)
Definition: Interpolation.h:313
static int radius()
Definition: Interpolation.h:173
const math::Transform & transform() const
Definition: Interpolation.h:317
static bool mipmap()
Definition: Interpolation.h:109
static bool consistent()
Definition: Interpolation.h:191
Class that provides the interface for continuous sampling of values in a tree.
Definition: Interpolation.h:220
Vec3< double > Vec3d
Definition: Vec3.h:625
GridOrTreeType::ValueType ValueType
Definition: Interpolation.h:224
static const char * name()
Definition: Interpolation.h:172
ValueType wsSample(const Vec3d &wspoint) const
Sample in world space.
Definition: Interpolation.h:276
boost::shared_ptr< GridSampler > Ptr
Definition: Interpolation.h:305
bool isAligned() const
Return true if the two grids are aligned.
Definition: Interpolation.h:423
static bool consistent()
Definition: Interpolation.h:94
static int radius()
Definition: Interpolation.h:133
static const char * name()
Definition: Interpolation.h:91
Vec3i ceilVec3(const Vec3R &v)
Definition: Interpolation.h:485
ValueType sampleVoxel(typename Coord::ValueType i, typename Coord::ValueType j, typename Coord::ValueType k) const
Sample value in integer index space.
Definition: Interpolation.h:254
DualGridSampler(const GridType &sourceGrid, const math::Transform &targetXform)
Grid and transform constructor.
Definition: Interpolation.h:393
ValueType operator()(const Coord &ijk) const
Return the value of the source grid at the index coordinates, ijk, relative to the target grid (or it...
Definition: Interpolation.h:416
tree::ValueAccessor< TreeT > AccessorType
Definition: Interpolation.h:309
TreeAdapter< GridOrTreeT >::GridType GridType
Definition: Interpolation.h:386
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:67
Definition: Interpolation.h:105
ValueType isSample(const Vec3d &ispoint) const
Sample in fractional index space.
Definition: Interpolation.h:346
T & x()
Reference to the component, e.g. v.x() = 4.5f;.
Definition: Vec3.h:94
ValueType sampleVoxel(const RealType &x, const RealType &y, const RealType &z) const
Sample a point in index space in the grid.
Definition: Interpolation.h:245
static bool consistent()
Definition: Interpolation.h:175
ValueType sampleVoxel(const RealType &x, const RealType &y, const RealType &z) const
Sample a point in index space in the grid.
Definition: Interpolation.h:324
static int radius()
Definition: Interpolation.h:189
ValueType isSample(const Coord &ijk) const
Sample value in integer index space.
Definition: Interpolation.h:263
DualGridSampler(const TreeType &sourceTree, const math::Transform &sourceXform, const math::Transform &targetXform)
Tree and transform constructor.
Definition: Interpolation.h:405
ValueType sampleVoxel(typename Coord::ValueType i, typename Coord::ValueType j, typename Coord::ValueType k) const
Sample value in integer index space.
Definition: Interpolation.h:333
Calculate an axis-aligned bounding box in index space from a bounding sphere in world space...
Definition: Transform.h:65
_TreeType TreeType
Definition: Grid.h:839
static int radius()
Definition: Interpolation.h:108