OpenVDB: PointSample.h Source File

OpenVDB 7.0.0

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