OpenVDB: FilterType Interface Reference

OpenVDB 12.1.0

Loading...
Searching...
No Matches
FilterType Interface Reference

Selectively extract and filter point data using a custom filter operator. More...

`#include <openvdb/tools/PointIndexGrid.h>`

## Detailed Description

Selectively extract and filter point data using a custom filter operator.

FilterType example:

template<typename T>
struct WeightedAverageAccumulator {
using ValueType = T;
WeightedAverageAccumulator(T const * const array, const T radius)
: mValues(array), mInvRadius(1.0/radius), mWeightSum(0.0), mValueSum(0.0) {}
void reset() { mWeightSum = mValueSum = T(0.0); }
// the following method is invoked by the PointIndexFilter
void operator()(const T distSqr, const size_t pointIndex) {
const T weight = T(1.0) - openvdb::math::Sqrt(distSqr) * mInvRadius;
mWeightSum += weight;
mValueSum += weight * mValues[pointIndex];
}
T result() const { return mWeightSum > T(0.0) ? mValueSum / mWeightSum : T(0.0); }
private:
T const * const mValues;
const T mInvRadius;
T mWeightSum, mValueSum;
}; // struct WeightedAverageAccumulator