OpenVDB  6.2.0
PointSample.h
Go to the documentation of this file.
1 //
3 // Copyright (c) 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 
36 
37 #ifndef OPENVDB_POINTS_POINT_SAMPLE_HAS_BEEN_INCLUDED
38 #define OPENVDB_POINTS_POINT_SAMPLE_HAS_BEEN_INCLUDED
39 
42 
43 #include "PointDataGrid.h"
44 #include "PointAttribute.h"
45 
46 #include <sstream>
47 #include <type_traits>
48 
49 
50 namespace openvdb {
52 namespace OPENVDB_VERSION_NAME {
53 namespace points {
54 
55 
65 template<typename PointDataGridT, typename SourceGridT,
66  typename FilterT = NullFilter, typename InterrupterT = util::NullInterrupter>
67 inline void pointSample(PointDataGridT& points,
68  const SourceGridT& sourceGrid,
69  const Name& targetAttribute = "",
70  const FilterT& filter = NullFilter(),
71  InterrupterT* const interrupter = nullptr);
72 
73 
83 template<typename PointDataGridT, typename SourceGridT,
84  typename FilterT = NullFilter, typename InterrupterT = util::NullInterrupter>
85 inline void boxSample( PointDataGridT& points,
86  const SourceGridT& sourceGrid,
87  const Name& targetAttribute = "",
88  const FilterT& filter = NullFilter(),
89  InterrupterT* const interrupter = nullptr);
90 
91 
101 template<typename PointDataGridT, typename SourceGridT,
102  typename FilterT = NullFilter, typename InterrupterT = util::NullInterrupter>
103 inline void quadraticSample(PointDataGridT& points,
104  const SourceGridT& sourceGrid,
105  const Name& targetAttribute = "",
106  const FilterT& filter = NullFilter(),
107  InterrupterT* const interrupter = nullptr);
108 
109 
110 // This struct samples the source grid accessor using the world-space position supplied,
111 // with SamplerT providing the sampling scheme. In the case where ValueT does not match
112 // the value type of the source grid, the sample() method will also convert the sampled
113 // value into a ValueT value, using round-to-nearest for float-to-integer conversion.
115 {
116  template<typename ValueT, typename SamplerT, typename AccessorT>
117  inline ValueT sample(const AccessorT& accessor, const Vec3d& position) const;
118 };
119 
120 
121 // A dummy struct that is used to mean that the sampled attribute should either match the type
122 // of the existing attribute or the type of the source grid (if the attribute doesn't exist yet)
123 struct DummySampleType { };
124 
125 
139 template<typename PointDataGridT, typename SourceGridT, typename TargetValueT = DummySampleType,
140  typename SamplerT = SampleWithRounding, typename FilterT = NullFilter,
141  typename InterrupterT = util::NullInterrupter>
142 inline void sampleGrid( size_t order,
143  PointDataGridT& points,
144  const SourceGridT& sourceGrid,
145  const Name& targetAttribute,
146  const FilterT& filter = NullFilter(),
147  const SamplerT& sampler = SampleWithRounding(),
148  InterrupterT* const interrupter = nullptr,
149  const bool threaded = true);
150 
151 
153 
154 
155 namespace point_sample_internal {
156 
157 
158 template<typename FromType, typename ToType>
159 struct CompatibleTypes { enum { value = std::is_constructible<ToType, FromType>::value }; };
160 
161 // Specializations for types that can be converted from source grid to target attribute
162 template<typename T> struct CompatibleTypes<
163  T, T> { enum { value = true }; };
164 template<typename T> struct CompatibleTypes<
165  T, math::Vec2<T>> { enum { value = true }; };
166 template<typename T> struct CompatibleTypes<
167  T, math::Vec3<T>> { enum { value = true }; };
168 template<typename T> struct CompatibleTypes<
169  T, math::Vec4<T>> { enum { value = true }; };
170 template<typename T> struct CompatibleTypes<
171  math::Vec2<T>, math::Vec2<T>> { enum { value = true }; };
172 template<typename T> struct CompatibleTypes<
173  math::Vec3<T>, math::Vec3<T>> { enum { value = true }; };
174 template<typename T> struct CompatibleTypes<
175  math::Vec4<T>, math::Vec4<T>> { enum { value = true }; };
176 template<typename T0, typename T1> struct CompatibleTypes<
177  math::Vec2<T0>, math::Vec2<T1>> { enum { value = CompatibleTypes<T0, T1>::value }; };
178 template<typename T0, typename T1> struct CompatibleTypes<
179  math::Vec3<T0>, math::Vec3<T1>> { enum { value = CompatibleTypes<T0, T1>::value }; };
180 template<typename T0, typename T1> struct CompatibleTypes<
181  math::Vec4<T0>, math::Vec4<T1>> { enum { value = CompatibleTypes<T0, T1>::value }; };
182 template<typename T> struct CompatibleTypes<
183  ValueMask, T> { enum { value = CompatibleTypes<bool, T>::value }; };
184 
185 
186 // Ability to access the Staggered template parameter from tools::Sampler<Order, Staggered>
187 template <typename T> struct SamplerTraits {
188  static const bool Staggered = false;
189 };
190 template <size_t T0, bool T1> struct SamplerTraits<tools::Sampler<T0, T1>> {
191  static const bool Staggered = T1;
192 };
193 
194 
195 // default sampling is incompatible, so throw an error
196 template <typename ValueT, typename SamplerT, typename AccessorT, bool Round, bool Compatible = false>
198 {
199  static inline void sample(ValueT&, const AccessorT&, const Vec3d&)
200  {
201  std::ostringstream ostr;
202  ostr << "Cannot sample a " << typeNameAsString<typename AccessorT::ValueType>()
203  << " grid on to a " << typeNameAsString<ValueT>() << " attribute";
204  OPENVDB_THROW(TypeError, ostr.str());
205  }
206 };
207 // partial specialization to handle sampling and rounding of compatible conversion
208 template <typename ValueT, typename SamplerT, typename AccessorT>
209 struct SampleWithRoundingOp<ValueT, SamplerT, AccessorT, /*Round=*/true, /*Compatible=*/true>
210 {
211  static inline void sample(ValueT& value, const AccessorT& accessor, const Vec3d& position)
212  {
213  value = ValueT(math::Round(SamplerT::sample(accessor, position)));
214  }
215 };
216 // partial specialization to handle sampling and simple casting of compatible conversion
217 template <typename ValueT, typename SamplerT, typename AccessorT>
218 struct SampleWithRoundingOp<ValueT, SamplerT, AccessorT, /*Round=*/false, /*Compatible=*/true>
219 {
220  static inline void sample(ValueT& value, const AccessorT& accessor, const Vec3d& position)
221  {
222  value = ValueT(SamplerT::sample(accessor, position));
223  }
224 };
225 
226 
227 template <typename PointDataGridT, typename SamplerT, typename FilterT, typename InterrupterT>
229 {
230 public:
231  PointDataSampler(size_t order,
232  PointDataGridT& points,
233  const SamplerT& sampler,
234  const FilterT& filter,
235  InterrupterT* const interrupter,
236  const bool threaded)
237  : mOrder(order)
238  , mPoints(points)
239  , mSampler(sampler)
240  , mFilter(filter)
241  , mInterrupter(interrupter)
242  , mThreaded(threaded) { }
243 
244 private:
245  // No-op transformation
246  struct AlignedTransform
247  {
248  inline Vec3d transform(const Vec3d& position) const { return position; }
249  }; // struct AlignedTransform
250 
251  // Re-sample world-space position from source to target transforms
252  struct NonAlignedTransform
253  {
254  NonAlignedTransform(const math::Transform& source, const math::Transform& target)
255  : mSource(source)
256  , mTarget(target) { }
257 
258  inline Vec3d transform(const Vec3d& position) const
259  {
260  return mSource.worldToIndex(mTarget.indexToWorld(position));
261  }
262 
263  private:
264  const math::Transform& mSource;
265  const math::Transform& mTarget;
266  }; // struct NonAlignedTransform
267 
268  // A simple convenience wrapper that contains the source grid accessor and the sampler
269  template <typename ValueT, typename SourceGridT, typename GridSamplerT>
270  struct SamplerWrapper
271  {
272  using ValueType = ValueT;
273  using SourceAccessorT = typename SourceGridT::ConstAccessor;
274 
275  SamplerWrapper(const SourceGridT& sourceGrid, const SamplerT& sampler)
276  : mAccessor(sourceGrid.getConstAccessor())
277  , mSampler(sampler) { }
278 
279  // note that creating a new accessor from the underlying tree is faster than
280  // copying an existing accessor
281  SamplerWrapper(const SamplerWrapper& other)
282  : mAccessor(other.mAccessor.tree())
283  , mSampler(other.mSampler) { }
284 
285  inline ValueT sample(const Vec3d& position) const {
286  return mSampler.template sample<ValueT, GridSamplerT, SourceAccessorT>(
287  mAccessor, position);
288  }
289 
290  private:
291  SourceAccessorT mAccessor;
292  const SamplerT& mSampler;
293  }; // struct SamplerWrapper
294 
295  template <typename SamplerWrapperT, typename TransformerT>
296  inline void doSample(const SamplerWrapperT& sampleWrapper, const Index targetIndex,
297  const TransformerT& transformer)
298  {
299  using PointDataTreeT = typename PointDataGridT::TreeType;
300  using LeafT = typename PointDataTreeT::LeafNodeType;
301  using LeafManagerT = typename tree::LeafManager<PointDataTreeT>;
302 
303  const auto& filter(mFilter);
304  const auto& interrupter(mInterrupter);
305 
306  auto sampleLambda = [targetIndex, &sampleWrapper, &transformer, &filter, &interrupter](
307  LeafT& leaf, size_t /*idx*/)
308  {
310 
311  if (util::wasInterrupted(interrupter)) {
312  tbb::task::self().cancel_group_execution();
313  return;
314  }
315 
316  SamplerWrapperT newSampleWrapper(sampleWrapper);
317  auto positionHandle = AttributeHandle<Vec3f>::create(leaf.constAttributeArray("P"));
318  auto targetHandle = TargetHandleT::create(leaf.attributeArray(targetIndex));
319  for (auto iter = leaf.beginIndexOn(filter); iter; ++iter) {
320  const Vec3d position = transformer.transform(
321  positionHandle->get(*iter) + iter.getCoord().asVec3d());
322  targetHandle->set(*iter, newSampleWrapper.sample(position));
323  }
324  };
325 
326  LeafManagerT leafManager(mPoints.tree());
327 
328  if (mInterrupter) mInterrupter->start();
329 
330  leafManager.foreach(sampleLambda, mThreaded);
331 
332  if (mInterrupter) mInterrupter->end();
333  }
334 
335  template <typename SourceGridT, typename SamplerWrapperT>
336  inline void resolveTransform(const SourceGridT& sourceGrid, const SamplerWrapperT& sampleWrapper,
337  const Index targetIndex)
338  {
339  const auto& sourceTransform = sourceGrid.constTransform();
340  const auto& pointsTransform = mPoints.constTransform();
341 
342  if (sourceTransform == pointsTransform) {
343  AlignedTransform transformer;
344  doSample(sampleWrapper, targetIndex, transformer);
345  } else {
346  NonAlignedTransform transformer(sourceTransform, pointsTransform);
347  doSample(sampleWrapper, targetIndex, transformer);
348  }
349  }
350 
351  template <typename SourceGridT, typename TargetValueT, size_t Order>
352  inline void resolveStaggered(const SourceGridT& sourceGrid, const Index targetIndex)
353  {
354  using SamplerWrapperT = SamplerWrapper<TargetValueT, SourceGridT, tools::Sampler<Order, false>>;
355  using StaggeredSamplerWrapperT = SamplerWrapper<TargetValueT, SourceGridT, tools::Sampler<Order, true>>;
356 
357  using SourceValueType = typename SourceGridT::ValueType;
358  if (VecTraits<SourceValueType>::Size == 3 && sourceGrid.getGridClass() == GRID_STAGGERED) {
359  StaggeredSamplerWrapperT sampleWrapper(sourceGrid, mSampler);
360  resolveTransform(sourceGrid, sampleWrapper, targetIndex);
361  } else {
362  SamplerWrapperT sampleWrapper(sourceGrid, mSampler);
363  resolveTransform(sourceGrid, sampleWrapper, targetIndex);
364  }
365  }
366 
367 public:
368  template <typename SourceGridT, typename TargetValueT = typename SourceGridT::ValueType>
369  inline void sample(const SourceGridT& sourceGrid, Index targetIndex)
370  {
371  if (mOrder == 0) {
372  resolveStaggered<SourceGridT, TargetValueT, 0>(sourceGrid, targetIndex);
373  } else if (mOrder == 1) {
374  resolveStaggered<SourceGridT, TargetValueT, 1>(sourceGrid, targetIndex);
375  } else if (mOrder == 2) {
376  resolveStaggered<SourceGridT, TargetValueT, 2>(sourceGrid, targetIndex);
377  }
378  }
379 
380 private:
381  size_t mOrder;
382  PointDataGridT& mPoints;
383  const SamplerT& mSampler;
384  const FilterT& mFilter;
385  InterrupterT* const mInterrupter;
386  const bool mThreaded;
387 }; // class PointDataSampler
388 
389 
390 template <typename PointDataGridT, typename ValueT>
392 {
393  static void append(PointDataGridT& points, const Name& attribute)
394  {
395  appendAttribute<ValueT>(points.tree(), attribute);
396  }
397 };
398 // partial specialization to disable attempts to append attribute type of DummySampleType
399 template <typename PointDataGridT>
400 struct AppendAttributeOp<PointDataGridT, DummySampleType>
401 {
402  static void append(PointDataGridT&, const Name&) { }
403 };
404 
405 } // namespace point_sample_internal
406 
407 
409 
410 
411 template<typename ValueT, typename SamplerT, typename AccessorT>
412 ValueT SampleWithRounding::sample(const AccessorT& accessor, const Vec3d& position) const
413 {
414  using namespace point_sample_internal;
415  using SourceValueT = typename AccessorT::ValueType;
416  static const bool staggered = SamplerTraits<SamplerT>::Staggered;
417  static const bool compatible = CompatibleTypes</*from=*/SourceValueT, /*to=*/ValueT>::value &&
418  (!staggered || (staggered && VecTraits<SourceValueT>::Size == 3));
419  static const bool round = std::is_floating_point<SourceValueT>::value &&
420  std::is_integral<ValueT>::value;
421  ValueT value;
422  SampleWithRoundingOp<ValueT, SamplerT, AccessorT, round, compatible>::sample(
423  value, accessor, position);
424  return value;
425 }
426 
427 
429 
430 
431 template<typename PointDataGridT, typename SourceGridT, typename TargetValueT,
432  typename SamplerT, typename FilterT, typename InterrupterT>
433 inline void sampleGrid( size_t order,
434  PointDataGridT& points,
435  const SourceGridT& sourceGrid,
436  const Name& targetAttribute,
437  const FilterT& filter,
438  const SamplerT& sampler,
439  InterrupterT* const interrupter,
440  const bool threaded)
441 {
444 
445  // use the name of the grid if no target attribute name supplied
446  Name attribute(targetAttribute);
447  if (targetAttribute.empty()) {
448  attribute = sourceGrid.getName();
449  }
450 
451  // we do not allow sampling onto the "P" attribute
452  if (attribute == "P") {
453  OPENVDB_THROW(RuntimeError, "Cannot sample onto the \"P\" attribute");
454  }
455 
456  auto leaf = points.tree().cbeginLeaf();
457  if (!leaf) return;
458 
459  PointDataSampler<PointDataGridT, SamplerT, FilterT, InterrupterT> pointDataSampler(
460  order, points, sampler, filter, interrupter, threaded);
461 
462  const auto& descriptor = leaf->attributeSet().descriptor();
463  size_t targetIndex = descriptor.find(attribute);
464  const bool attributeExists = targetIndex != AttributeSet::INVALID_POS;
465 
466  if (std::is_same<TargetValueT, DummySampleType>::value) {
467  if (!attributeExists) {
468  // append attribute of source grid value type
469  appendAttribute<typename SourceGridT::ValueType>(points.tree(), attribute);
470  targetIndex = leaf->attributeSet().descriptor().find(attribute);
471  assert(targetIndex != AttributeSet::INVALID_POS);
472 
473  // sample using same type as source grid
474  pointDataSampler.template sample<SourceGridT>(sourceGrid, Index(targetIndex));
475  } else {
476  auto targetIdx = static_cast<Index>(targetIndex);
477  // attempt to explicitly sample using type of existing attribute
478  const Name& targetType = descriptor.valueType(targetIndex);
479  if (targetType == typeNameAsString<Vec3f>()) {
480  pointDataSampler.template sample<SourceGridT, Vec3f>(sourceGrid, targetIdx);
481  } else if (targetType == typeNameAsString<Vec3d>()) {
482  pointDataSampler.template sample<SourceGridT, Vec3d>(sourceGrid, targetIdx);
483  } else if (targetType == typeNameAsString<Vec3i>()) {
484  pointDataSampler.template sample<SourceGridT, Vec3i>(sourceGrid, targetIdx);
485  } else if (targetType == typeNameAsString<int8_t>()) {
486  pointDataSampler.template sample<SourceGridT, int8_t>(sourceGrid, targetIdx);
487  } else if (targetType == typeNameAsString<int16_t>()) {
488  pointDataSampler.template sample<SourceGridT, int16_t>(sourceGrid, targetIdx);
489  } else if (targetType == typeNameAsString<int32_t>()) {
490  pointDataSampler.template sample<SourceGridT, int32_t>(sourceGrid, targetIdx);
491  } else if (targetType == typeNameAsString<int64_t>()) {
492  pointDataSampler.template sample<SourceGridT, int64_t>(sourceGrid, targetIdx);
493  } else if (targetType == typeNameAsString<float>()) {
494  pointDataSampler.template sample<SourceGridT, float>(sourceGrid, targetIdx);
495  } else if (targetType == typeNameAsString<double>()) {
496  pointDataSampler.template sample<SourceGridT, double>(sourceGrid, targetIdx);
497  } else if (targetType == typeNameAsString<bool>()) {
498  pointDataSampler.template sample<SourceGridT, bool>(sourceGrid, targetIdx);
499  } else {
500  std::ostringstream ostr;
501  ostr << "Cannot sample attribute of type - " << targetType;
502  OPENVDB_THROW(TypeError, ostr.str());
503  }
504  }
505  } else {
506  if (!attributeExists) {
507  // append attribute of target value type
508  // (point_sample_internal wrapper disables the ability to use DummySampleType)
509  AppendAttributeOp<PointDataGridT, TargetValueT>::append(points, attribute);
510  targetIndex = leaf->attributeSet().descriptor().find(attribute);
511  assert(targetIndex != AttributeSet::INVALID_POS);
512  }
513  else {
514  const Name targetType = typeNameAsString<TargetValueT>();
515  const Name attributeType = descriptor.valueType(targetIndex);
516  if (targetType != attributeType) {
517  std::ostringstream ostr;
518  ostr << "Requested attribute type " << targetType << " for sampling "
519  << " does not match existing attribute type " << attributeType;
520  OPENVDB_THROW(TypeError, ostr.str());
521  }
522  }
523 
524  // sample using target value type
525  pointDataSampler.template sample<SourceGridT, TargetValueT>(
526  sourceGrid, static_cast<Index>(targetIndex));
527  }
528 }
529 
530 template<typename PointDataGridT, typename SourceGridT, typename FilterT, typename InterrupterT>
531 inline void pointSample(PointDataGridT& points,
532  const SourceGridT& sourceGrid,
533  const Name& targetAttribute,
534  const FilterT& filter,
535  InterrupterT* const interrupter)
536 {
537  SampleWithRounding sampler;
538  sampleGrid(/*order=*/0, points, sourceGrid, targetAttribute, filter, sampler, interrupter);
539 }
540 
541 template<typename PointDataGridT, typename SourceGridT, typename FilterT, typename InterrupterT>
542 inline void boxSample( PointDataGridT& points,
543  const SourceGridT& sourceGrid,
544  const Name& targetAttribute,
545  const FilterT& filter,
546  InterrupterT* const interrupter)
547 {
548  SampleWithRounding sampler;
549  sampleGrid(/*order=*/1, points, sourceGrid, targetAttribute, filter, sampler, interrupter);
550 }
551 
552 template<typename PointDataGridT, typename SourceGridT, typename FilterT, typename InterrupterT>
553 inline void quadraticSample(PointDataGridT& points,
554  const SourceGridT& sourceGrid,
555  const Name& targetAttribute,
556  const FilterT& filter,
557  InterrupterT* const interrupter)
558 {
559  SampleWithRounding sampler;
560  sampleGrid(/*order=*/2, points, sourceGrid, targetAttribute, filter, sampler, interrupter);
561 }
562 
563 
565 
566 
567 } // namespace points
568 } // namespace OPENVDB_VERSION_NAME
569 } // namespace openvdb
570 
571 #endif // OPENVDB_POINTS_POINT_SAMPLE_HAS_BEEN_INCLUDED
572 
573 // Copyright (c) DreamWorks Animation LLC
574 // All rights reserved. This software is distributed under the
575 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
const char * typeNameAsString< Vec3d >()
Definition: Types.h:585
void pointSample(PointDataGridT &points, const SourceGridT &sourceGrid, const Name &targetAttribute="", const FilterT &filter=NullFilter(), InterrupterT *const interrupter=nullptr)
Performs closest point sampling from a VDB grid onto a VDB Points attribute.
Definition: PointSample.h:531
static void append(PointDataGridT &, const Name &)
Definition: PointSample.h:402
const char * typeNameAsString< int16_t >()
Definition: Types.h:573
Definition: Mat4.h:51
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:109
static void sample(ValueT &value, const AccessorT &accessor, const Vec3d &position)
Definition: PointSample.h:211
Definition: Exceptions.h:90
const char * typeNameAsString< bool >()
Definition: Types.h:566
float Round(float x)
Return x rounded to the nearest integer.
Definition: Math.h:793
Index32 Index
Definition: Types.h:61
const char * typeNameAsString< int32_t >()
Definition: Types.h:575
const char * typeNameAsString< int8_t >()
Definition: Types.h:571
const char * typeNameAsString< double >()
Definition: Types.h:570
const char * typeNameAsString< Vec3i >()
Definition: Types.h:583
Write-able version of AttributeHandle.
Definition: AttributeArray.h:944
const char * typeNameAsString< int64_t >()
Definition: Types.h:577
Definition: Types.h:231
void boxSample(PointDataGridT &points, const SourceGridT &sourceGrid, const Name &targetAttribute="", const FilterT &filter=NullFilter(), InterrupterT *const interrupter=nullptr)
Performs tri-linear sampling from a VDB grid onto a VDB Points attribute.
Definition: PointSample.h:542
const char * typeNameAsString< Vec3f >()
Definition: Types.h:584
Vec3< double > Vec3d
Definition: Vec3.h:689
Point attribute manipulation in a VDB Point Grid.
Definition: Mat.h:197
Definition: PointSample.h:123
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:128
Definition: Exceptions.h:91
std::string Name
Definition: Name.h:44
A no-op filter that can be used when iterating over all indices.
Definition: IndexIterator.h:77
static void append(PointDataGridT &points, const Name &attribute)
Definition: PointSample.h:393
const char * typeNameAsString< float >()
Definition: Types.h:569
Definition: Exceptions.h:40
Dummy NOOP interrupter class defining interface.
Definition: NullInterrupter.h:52
Definition: AttributeArray.h:873
void quadraticSample(PointDataGridT &points, const SourceGridT &sourceGrid, const Name &targetAttribute="", const FilterT &filter=NullFilter(), InterrupterT *const interrupter=nullptr)
Performs tri-quadratic sampling from a VDB grid onto a VDB Points attribute.
Definition: PointSample.h:553
static void sample(ValueT &, const AccessorT &, const Vec3d &)
Definition: PointSample.h:199
This class manages a linear array of pointers to a given tree&#39;s leaf nodes, as well as optional auxil...
Definition: LeafManager.h:109
static void sample(ValueT &value, const AccessorT &accessor, const Vec3d &position)
Definition: PointSample.h:220
Definition: Transform.h:66
Attribute-owned data structure for points. Point attributes are stored in leaf nodes and ordered by v...
Definition: Types.h:118
void sampleGrid(size_t order, PointDataGridT &points, const SourceGridT &sourceGrid, const Name &targetAttribute, const FilterT &filter=NullFilter(), const SamplerT &sampler=SampleWithRounding(), InterrupterT *const interrupter=nullptr, const bool threaded=true)
Performs sampling and conversion from a VDB grid onto a VDB Points attribute.
Definition: PointSample.h:433
Definition: PointSample.h:114
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:180
Definition: Vec2.h:50
PointDataSampler(size_t order, PointDataGridT &points, const SamplerT &sampler, const FilterT &filter, InterrupterT *const interrupter, const bool threaded)
Definition: PointSample.h:231
Definition: Types.h:506
void sample(const SourceGridT &sourceGrid, Index targetIndex)
Definition: PointSample.h:369
bool wasInterrupted(T *i, int percent=-1)
Definition: NullInterrupter.h:76