4 #ifndef OPENVDB_POINTS_POINT_PRINCIPAL_COMPONENT_ANALYSIS_IMPL_HAS_BEEN_INCLUDED 5 #define OPENVDB_POINTS_POINT_PRINCIPAL_COMPONENT_ANALYSIS_IMPL_HAS_BEEN_INCLUDED 8 #ifdef OPENVDB_PROFILE_PCA 16 #define OPENVDB_PCA_SELF_CONTRIBUTION 1 23 namespace pca_internal {
25 #ifdef OPENVDB_PROFILE_PCA 29 inline void start(
const char*) {}
39 , mInterrupt(interrupt) {}
40 inline void start(
const char* msg)
43 if (mInterrupt) mInterrupt->start(msg);
48 if (mInterrupt) mInterrupt->end();
55 using GroupIndexT = points::AttributeSet::Descriptor::GroupIndex;
66 template <
typename T,
typename LeafNodeT>
69 auto& array = leaf.attributeArray(idx);
71 OPENVDB_ASSERT(array.codecType() == std::string(NullCodec::name()));
73 const char* data = array.constDataAsByteArray();
74 return reinterpret_cast<T*
>(
const_cast<char*
>(data));
94 template <
typename Po
intDataTreeT>
110 :
BaseT(manager.tree())
113 , mSettings(settings)
117 , mSourcePosition() {
125 , mIndices(other.mIndices)
126 , mSettings(other.mSettings)
127 , mDxInv(other.mDxInv)
128 , mManager(other.mManager)
130 , mSourcePosition() {}
161 auto& leaf = mManager.leaf(idx);
162 mTargetPosition = std::make_unique<PositionHandleT>(leaf.constAttributeArray(mIndices.mPWsIndex));
168 mSourcePosition = std::make_unique<PositionHandleT>(leaf.constAttributeArray(mIndices.mPWsIndex));
169 #if OPENVDB_PCA_SELF_CONTRIBUTION == 0 170 mIsSameLeaf = this->mTargetPosition->array() == this->mSourcePosition->array();
175 bool endPointLeaf(
const typename PointDataTreeT::LeafNodeType&) {
return true; }
184 #if OPENVDB_PCA_SELF_CONTRIBUTION == 0 185 bool mIsSameLeaf {
false};
189 template <
typename Po
intDataTreeT>
195 static const Index DIM = PointDataTreeT::LeafNodeType::DIM;
196 static const Index LOG2DIM = PointDataTreeT::LeafNodeType::LOG2DIM;
203 :
BaseT(indices, settings, vs, manager, interrupt)
205 , mWeightedPositions()
211 , mWeightedPositions()
214 inline void initialize(
const Coord& origin,
const size_t idx,
const CoordBBox& bounds)
217 mWeights = initPcaArrayAttribute<WeightSumT>(leaf, this->mIndices.mWeightSumIndex);
218 mWeightedPositions = initPcaArrayAttribute<WeightedPositionSumT>(leaf, this->mIndices.mPosSumIndex);
220 mCounts.assign(this->mTargetPosition->size(), 0);
227 const auto*
const data = this->
template buffer<0>();
228 const auto& mask = *(this->
template mask<0>());
230 const float searchRadiusInv = 1.0f / this->searchRadius();
232 const Real searchRadiusIS2 =
math::Pow2(this->searchRadius() * this->mDxInv);
238 const Coord& a(bounds.min());
239 const Coord& b(bounds.max());
241 for (
Index srcid = start; srcid < end; srcid += step) {
242 const Vec3d Psrc(this->mSourcePosition->get(srcid));
243 const Vec3d PsrcIS = Psrc * this->mDxInv;
245 for (Coord c = a; c.x() <= b.x(); ++c.x()) {
246 const Real minx = c.
x() - 0.5;
247 const Real maxx = c.x() + 0.5;
249 (PsrcIS[0] < minx ?
math::Pow2(PsrcIS[0] - minx) :
250 (PsrcIS[0] > maxx ?
math::Pow2(PsrcIS[0] - maxx) : 0));
251 if (dminx > searchRadiusIS2)
continue;
252 const Index i = ((c.x() & (DIM-1u)) << 2*LOG2DIM);
253 for (c.y() = a.y(); c.y() <= b.y(); ++c.y()) {
254 const Real miny = c.y() - 0.5;
255 const Real maxy = c.y() + 0.5;
256 const Real dminxy = dminx +
257 (PsrcIS[1] < miny ?
math::Pow2(PsrcIS[1] - miny) :
258 (PsrcIS[1] > maxy ?
math::Pow2(PsrcIS[1] - maxy) : 0));
259 if (dminxy > searchRadiusIS2)
continue;
260 const Index ij = i + ((c.y() & (DIM-1u)) << LOG2DIM);
261 for (c.z() = a.z(); c.z() <= b.z(); ++c.z()) {
262 const Index offset = ij + (c.z() & (DIM-1u));
263 if (!mask.isOn(offset))
continue;
265 const Real minz = c.z() - 0.5;
266 const Real maxz = c.z() + 0.5;
267 const Real dminxyz = dminxy +
268 (PsrcIS[2] < minz ?
math::Pow2(PsrcIS[2] - minz) :
269 (PsrcIS[2] > maxz ?
math::Pow2(PsrcIS[2] - maxz) : 0));
271 if (dminxyz > searchRadiusIS2)
continue;
274 const Index targetEnd = data[offset];
275 const Index targetStart = (offset == 0) ? 0 :
Index(data[offset - 1]);
276 const Index targetStep =
277 std::max(
Index(1),
Index((targetEnd - targetStart) / this->maxTargetPointsPerVoxel()));
283 for (
Index tgtid = targetStart; tgtid < targetEnd; tgtid += targetStep) {
284 #if OPENVDB_PCA_SELF_CONTRIBUTION == 0 287 const Vec3d Ptgt(this->mTargetPosition->get(tgtid));
288 const Real d2 = (Psrc - Ptgt).lengthSqr();
289 if (d2 > searchRadius2)
continue;
295 mWeights[tgtid] += weight;
296 mWeightedPositions[tgtid] += Psrc * weight;
308 auto& leaf = this->mManager.leaf(idx);
313 auto& array = leaf.attributeArray(this->mIndices.mEllipsesGroupIndex.first);
320 const int32_t threshold = int32_t(this->neighbourThreshold());
321 for (
Index i = 0; i < this->mTargetPosition->size(); ++i) {
323 if ((threshold == 0 || (mCounts[i] < threshold)) && group.getUnsafe(i)) {
324 group.setUnsafe(i,
false);
326 if (mCounts[i] <= 0)
continue;
329 mWeights[i] = 1.0 / mWeights[i];
330 mWeightedPositions[i] *= mWeights[i];
338 std::vector<int32_t> mCounts;
341 template <
typename Po
intDataTreeT>
347 static const Index DIM = PointDataTreeT::LeafNodeType::DIM;
348 static const Index LOG2DIM = PointDataTreeT::LeafNodeType::LOG2DIM;
355 :
BaseT(indices, settings, vs, manager, interrupt)
356 , mInclusionGroupHandle()
358 , mWeightedPositions()
363 , mInclusionGroupHandle()
365 , mWeightedPositions()
368 inline void initialize(
const Coord& origin,
const size_t idx,
const CoordBBox& bounds)
371 mInclusionGroupHandle = std::make_unique<points::GroupHandle>(leaf.groupHandle(this->mIndices.mEllipsesGroupIndex));
372 mWeights = initPcaArrayAttribute<WeightSumT>(leaf, this->mIndices.mWeightSumIndex);
373 mWeightedPositions = initPcaArrayAttribute<WeightedPositionSumT>(leaf, this->mIndices.mPosSumIndex);
374 mCovMats = initPcaArrayAttribute<math::Mat3s>(leaf, this->mIndices.mCovMatrixIndex);
381 const auto*
const data = this->
template buffer<0>();
382 const auto& mask = *(this->
template mask<0>());
384 const float searchRadiusInv = 1.0f/this->searchRadius();
386 const Real searchRadiusIS2 =
math::Pow2(this->searchRadius() * this->mDxInv);
392 const Coord& a(bounds.min());
393 const Coord& b(bounds.max());
395 for (
Index srcid = start; srcid < end; srcid += step) {
396 const Vec3d Psrc(this->mSourcePosition->get(srcid));
397 const Vec3d PsrcIS = Psrc * this->mDxInv;
399 for (Coord c = a; c.x() <= b.x(); ++c.x()) {
400 const Real minx = c.
x() - 0.5;
401 const Real maxx = c.x() + 0.5;
403 (PsrcIS[0] < minx ?
math::Pow2(PsrcIS[0] - minx) :
404 (PsrcIS[0] > maxx ?
math::Pow2(PsrcIS[0] - maxx) : 0));
405 if (dminx > searchRadiusIS2)
continue;
406 const Index i = ((c.x() & (DIM-1u)) << 2*LOG2DIM);
407 for (c.y() = a.y(); c.y() <= b.y(); ++c.y()) {
408 const Real miny = c.y() - 0.5;
409 const Real maxy = c.y() + 0.5;
410 const Real dminxy = dminx +
411 (PsrcIS[1] < miny ?
math::Pow2(PsrcIS[1] - miny) :
412 (PsrcIS[1] > maxy ?
math::Pow2(PsrcIS[1] - maxy) : 0));
413 if (dminxy > searchRadiusIS2)
continue;
414 const Index ij = i + ((c.y() & (DIM-1u)) << LOG2DIM);
415 for (c.z() = a.z(); c.z() <= b.z(); ++c.z()) {
416 const Index offset = ij + (c.z() & (DIM-1u));
417 if (!mask.isOn(offset))
continue;
419 const Real minz = c.z() - 0.5;
420 const Real maxz = c.z() + 0.5;
421 const Real dminxyz = dminxy +
422 (PsrcIS[2] < minz ?
math::Pow2(PsrcIS[2] - minz) :
423 (PsrcIS[2] > maxz ?
math::Pow2(PsrcIS[2] - maxz) : 0));
425 if (dminxyz > searchRadiusIS2)
continue;
427 const Index targetEnd = data[offset];
428 const Index targetStart = (offset == 0) ? 0 :
Index(data[offset - 1]);
429 const Index targetStep =
430 std::max(
Index(1),
Index((targetEnd - targetStart) / this->maxTargetPointsPerVoxel()));
432 for (
Index tgtid = targetStart; tgtid < targetEnd; tgtid += targetStep) {
433 if (!mInclusionGroupHandle->get(tgtid))
continue;
434 #if OPENVDB_PCA_SELF_CONTRIBUTION == 0 437 const Vec3d Ptgt(this->mTargetPosition->get(tgtid));
438 const Real d2 = (Psrc - Ptgt).lengthSqr();
439 if (d2 > searchRadius2)
continue;
443 const WeightSumT totalWeightInv = mWeights[tgtid];
459 float*
const m = mCovMats[tgtid].asPointer();
465 m[0] += float(x[0] * posMeanDiff[0]);
466 m[1] += float(x[0] * posMeanDiff[1]);
467 m[2] += float(x[0] * posMeanDiff[2]);
469 m[3] += float(x[1] * posMeanDiff[0]);
470 m[4] += float(x[1] * posMeanDiff[1]);
471 m[5] += float(x[1] * posMeanDiff[2]);
473 m[6] += float(x[2] * posMeanDiff[0]);
474 m[7] += float(x[2] * posMeanDiff[1]);
475 m[8] += float(x[2] * posMeanDiff[2]);
483 bool finalize(
const Coord&,
size_t) {
return true; }
490 std::vector<int32_t> mCounts;
495 template <
typename Scalar>
500 if (vector[0] < vector[1]) {
501 std::swap(vector[0], vector[1]);
502 std::swap(order[0], order[1]);
504 if (vector[1] < vector[2]) {
505 std::swap(vector[1], vector[2]);
506 std::swap(order[1], order[2]);
508 if (vector[0] < vector[1]) {
509 std::swap(vector[0], vector[1]);
510 std::swap(order[0], order[1]);
522 template <
typename Scalar>
531 if (!diagonalized)
return false;
546 template <
typename Po
intDataGr
idT>
548 pca(PointDataGridT& points,
554 using namespace pca_internal;
556 using PointDataTreeT =
typename PointDataGridT::TreeType;
558 using LeafNodeT =
typename PointDataTreeT::LeafNodeType;
560 auto& tree = points.
tree();
561 const auto leaf = tree.cbeginLeaf();
568 const auto initAttribute = [&](
const std::string& name,
const auto val)
570 using ValueT = std::decay_t<decltype(val)>;
571 if (leaf->hasAttribute(name)) {
575 points::appendAttribute<ValueT>(tree, name, val);
576 return leaf->attributeSet().find(name);
581 const size_t pvsIdx = leaf->attributeSet().find(
"P");
582 const auto& xform = points.constTransform();
583 const double vs = xform.voxelSize()[0];
584 LeafManagerT manager(tree);
587 const size_t pwsIdx = initAttribute(attrs.
positionWS, zeroVal<PcaAttributes::PosWsT>());
588 const size_t rotIdx = initAttribute(attrs.
rotation, zeroVal<PcaAttributes::RotationT>());
592 const auto& descriptor = leaf->attributeSet().descriptor();
593 const std::vector<std::string> temps {
594 descriptor.uniqueName(
"_weightedpositionsums"),
595 descriptor.uniqueName(
"_inv_weightssum")
598 const size_t posSumIndex = initAttribute(temps[0], zeroVal<WeightedPositionSumT>());
599 const size_t weightSumIndex = initAttribute(temps[1], zeroVal<WeightSumT>());
602 if (!leaf->attributeSet().descriptor().hasGroup(attrs.
ellipses)) {
610 leaf->attributeSet().descriptor().groupIndex(attrs.
ellipses);
616 timer.start(
"Compute position world spaces");
617 manager.foreach([&](LeafNodeT& leafnode,
size_t)
623 PwsT* Pws = initPcaArrayAttribute<PwsT>(leafnode, pwsIdx,
false);
625 for (
auto voxel = leafnode.cbeginValueOn(); voxel; ++voxel) {
626 const Coord voxelCoord = voxel.getCoord();
627 const Vec3d coordVec = voxelCoord.asVec3d();
628 for (
auto iter = leafnode.beginIndexVoxel(voxelCoord); iter; ++iter) {
629 Pws[*iter] = xform.indexToWorld(Pvs.get(*iter) + coordVec);
638 indices.mPosSumIndex = posSumIndex;
639 indices.mWeightSumIndex = weightSumIndex;
640 indices.mCovMatrixIndex = rotIdx;
641 indices.mPWsIndex = pwsIdx;
642 indices.mEllipsesGroupIndex = ellipsesIdx;
652 timer.start(
"Compute position weights");
654 WeightPosSumsTransfer<PointDataTreeT>
655 transfer(indices, settings,
float(vs), manager, settings.
interrupter);
656 points::rasterize<PointDataGridT, decltype(transfer)> (points, transfer);
665 timer.start(
"Compute covariance matrices");
667 CovarianceTransfer<PointDataTreeT>
668 transfer(indices, settings,
float(vs), manager, settings.
interrupter);
669 points::rasterize<PointDataGridT, decltype(transfer)>(points, transfer);
677 timer.start(
"Decompose covariance matrices");
678 manager.foreach([&](LeafNodeT& leafnode,
size_t)
682 GroupHandle ellipsesGroupHandle(leafnode.groupHandle(ellipsesIdx));
684 for (
Index idx = 0; idx < stretchHandle.size(); ++idx) {
685 if (!ellipsesGroupHandle.get(idx)) {
686 rotHandle.set(idx, math::Mat3s::identity());
697 sigma[1] =
std::max(sigma[1], maxs);
698 sigma[2] =
std::max(sigma[2], maxs);
712 stretchHandle.set(idx, sigma);
713 rotHandle.set(idx, u);
727 timer.start(
"Normalise the principal lengths");
728 manager.foreach([&](LeafNodeT& leafnode,
size_t)
731 filter.
reset(leafnode);
734 for (
Index i = 0; i < stretchHandle.size(); ++i)
736 if (!filter.
valid(&i))
continue;
737 const Vec3f stretch = stretchHandle.get(i);
739 const float stretchScale = 1.0f / std::cbrt(stretch.
product());
740 stretchHandle.set(i, stretchScale * stretch);
752 timer.start(
"Laplacian smooth positions");
755 manager.foreach([&](LeafNodeT& leafnode,
size_t) {
759 for (
Index i = 0; i < Pws.size(); ++i)
769 Pws.set(i, smoothedPosition);
784 #endif // OPENVDB_POINTS_POINT_PRINCIPAL_COMPONENT_ANALYSIS_IMPL_HAS_BEEN_INCLUDED Helper metafunction used to determine if the first template parameter is a specialization of the clas...
Definition: Types.h:263
const AttrIndices & mIndices
Definition: PrincipalComponentAnalysisImpl.h:178
Simple timer for basic profiling.
Definition: CpuTimer.h:66
util::NullInterrupter * interrupter
Definition: PrincipalComponentAnalysis.h:149
Definition: AttributeGroup.h:102
The VolumeTransfer module provides methods to automatically setup and access destination buffers for ...
Definition: PointTransfer.h:296
Definition: Exceptions.h:59
void start(const char *msg)
Definition: PrincipalComponentAnalysisImpl.h:40
void setColumns(const Vec3< T > &v1, const Vec3< T > &v2, const Vec3< T > &v3)
Set the columns of this matrix to the vectors v1, v2, v3.
Definition: Mat3.h:209
Definition: PrincipalComponentAnalysisImpl.h:57
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:74
WeightPosSumsTransfer(const WeightPosSumsTransfer &other)
Definition: PrincipalComponentAnalysisImpl.h:208
void initialize(const Coord &origin, const size_t idx, const CoordBBox &bounds)
Definition: PrincipalComponentAnalysisImpl.h:214
OPENVDB_IMPORT void initialize()
Global registration of native Grid, Transform, Metadata and Point attribute types. Also initializes blosc (if enabled).
void start(const char *)
Definition: PrincipalComponentAnalysisImpl.h:29
float Sqrt(float x)
Return the square root of a floating-point value.
Definition: Math.h:761
const PcaSettings & mSettings
Definition: PrincipalComponentAnalysisImpl.h:179
bool startPointLeaf(const typename PointDataTreeT::LeafNodeType &leaf)
Definition: PrincipalComponentAnalysisImpl.h:166
const Real mDxInv
Definition: PrincipalComponentAnalysisImpl.h:180
std::unique_ptr< PositionHandleT > mTargetPosition
Definition: PrincipalComponentAnalysisImpl.h:182
static Vec3< T > zero()
Predefined constants, e.g. Vec3d v = Vec3d::xNegAxis();.
Definition: Vec3.h:467
Index32 Index
Definition: Types.h:54
void dropAttributes(PointDataTreeT &tree, const std::vector< size_t > &indices)
Drops attributes from the VDB tree.
Definition: PointAttributeImpl.h:238
bool isApproxZero(const Type &x)
Return true if x is equal to zero to within the default floating-point comparison tolerance...
Definition: Math.h:349
void rasterizePoints(const Coord &, const Index start, const Index end, const CoordBBox &bounds)
Definition: PrincipalComponentAnalysisImpl.h:377
Vec3i range(const Coord &, size_t) const
Definition: PrincipalComponentAnalysisImpl.h:155
const tree::LeafManager< PointDataTreeT > & mManager
Definition: PrincipalComponentAnalysisImpl.h:181
size_t mPWsIndex
Definition: PrincipalComponentAnalysisImpl.h:62
float averagePositions
Definition: PrincipalComponentAnalysis.h:147
void rasterizePoints(const Coord &, const Index start, const Index end, const CoordBBox &bounds)
Definition: PrincipalComponentAnalysisImpl.h:223
Index filtering on group membership.
Definition: AttributeGroup.h:135
Write-able version of AttributeHandle.
Definition: AttributeArray.h:831
GroupIndexT mEllipsesGroupIndex
Definition: PrincipalComponentAnalysisImpl.h:63
void appendGroup(PointDataTreeT &tree, const Name &group)
Appends a new empty group to the VDB tree.
Definition: PointGroupImpl.h:209
float nonAnisotropicStretch
Definition: PrincipalComponentAnalysis.h:99
Vec3< int32_t > Vec3i
Definition: Vec3.h:662
PcaTimer(util::NullInterrupter *const interrupt)
Definition: PrincipalComponentAnalysisImpl.h:37
double WeightSumT
Definition: PrincipalComponentAnalysisImpl.h:53
WeightPosSumsTransfer(const AttrIndices &indices, const PcaSettings &settings, const Real vs, tree::LeafManager< PointDataTreeT > &manager, util::NullInterrupter *interrupt)
Definition: PrincipalComponentAnalysisImpl.h:198
Base class for interrupters.
Definition: NullInterrupter.h:25
Definition: PrincipalComponentAnalysisImpl.h:28
float searchRadius() const
Definition: PrincipalComponentAnalysisImpl.h:150
Definition: AttributeArray.h:763
T & x()
Reference to the component, e.g. v.x() = 4.5f;.
Definition: Vec3.h:86
void pca(PointDataGridT &points, const PcaSettings &settings, const PcaAttributes &attrs)
Calculate ellipsoid transformations from the local point distributions as described in Yu and Turk's ...
Definition: PrincipalComponentAnalysisImpl.h:548
Various settings for the neighborhood analysis of point distributions.
Definition: PrincipalComponentAnalysis.h:66
std::unique_ptr< GroupHandle > UniquePtr
Definition: AttributeGroup.h:77
#define OPENVDB_ASSERT(X)
Definition: Assert.h:41
Vec3< T > col(int j) const
Get jth column, e.g. Vec3d v = m.col(0);.
Definition: Mat3.h:168
size_t maxTargetPointsPerVoxel() const
Definition: PrincipalComponentAnalysisImpl.h:153
typename PointDataTreeT::LeafNodeType LeafNodeType
Definition: PrincipalComponentAnalysisImpl.h:100
Definition: AttributeGroup.h:73
size_t mWeightSumIndex
Definition: PrincipalComponentAnalysisImpl.h:60
Vec3i range() const
Definition: PrincipalComponentAnalysisImpl.h:156
Type Pow2(Type x)
Return x2.
Definition: Math.h:548
Tolerance for floating-point comparison.
Definition: Math.h:148
CovarianceTransfer(const CovarianceTransfer &other)
Definition: PrincipalComponentAnalysisImpl.h:361
T * initPcaArrayAttribute(LeafNodeT &leaf, const size_t idx, const bool fill=true)
Definition: PrincipalComponentAnalysisImpl.h:67
Definition: Exceptions.h:13
float Round(float x)
Return x rounded to the nearest integer.
Definition: Math.h:819
points::AttributeSet::Descriptor::GroupIndex GroupIndexT
Definition: PrincipalComponentAnalysisImpl.h:55
size_t mPosSumIndex
Definition: PrincipalComponentAnalysisImpl.h:59
Definition: PrincipalComponentAnalysisImpl.h:342
Vec3i descendingOrder(math::Vec3< Scalar > &vector)
Sort a vector into descending order and output a vector of the resulting order.
Definition: PrincipalComponentAnalysisImpl.h:497
std::string ellipses
A point group to create that represents points which have valid ellipsoidal neighborhood. Points outside of this group will have their stretch and rotation attributes set to describe a canonical sphere. Note however that all points, regardless of this groups membership flag, will still contribute to their neighbours and may have their world space position deformed in relation to their neighboring points.
Definition: PrincipalComponentAnalysis.h:185
Vec3d WeightedPositionSumT
Definition: PrincipalComponentAnalysisImpl.h:54
util::NullInterrupter *const mInterrupt
Definition: PrincipalComponentAnalysisImpl.h:50
PcaTransfer(const AttrIndices &indices, const PcaSettings &settings, const Real vs, tree::LeafManager< PointDataTreeT > &manager, util::NullInterrupter *interrupt)
Definition: PrincipalComponentAnalysisImpl.h:105
bool decomposeSymmetricMatrix(const math::Mat3< Scalar > &mat, math::Mat3< Scalar > &U, math::Vec3< Scalar > &sigma)
Decomposes a symmetric matrix into its eigenvalues and a rotation matrix of eigenvectors. Note that if mat is positive-definite, this will be equivalent to a singular value decomposition where V = U.
Definition: PrincipalComponentAnalysisImpl.h:524
double Real
Definition: Types.h:60
bool wasInterrupted(T *i, int percent=-1)
Definition: NullInterrupter.h:49
void setGroup(PointDataTreeT &tree, const PointIndexTreeT &indexTree, const std::vector< short > &membership, const Name &group, const bool remove=false)
Sets group membership from a PointIndexTree-ordered vector.
Definition: PointGroupImpl.h:438
size_t maxSourcePointsPerVoxel() const
Definition: PrincipalComponentAnalysisImpl.h:152
void stop()
Definition: PrincipalComponentAnalysisImpl.h:45
Definition: PrincipalComponentAnalysisImpl.h:95
PcaTransfer(const PcaTransfer &other)
Definition: PrincipalComponentAnalysisImpl.h:122
InterruptableTransfer module, when derived from allows for schemes to callback into a interrupter...
Definition: PointTransfer.h:230
bool endPointLeaf(const typename PointDataTreeT::LeafNodeType &)
Definition: PrincipalComponentAnalysisImpl.h:175
The persistent attributes created by the PCA methods.
Definition: PrincipalComponentAnalysis.h:155
size_t mCovMatrixIndex
Definition: PrincipalComponentAnalysisImpl.h:61
void reset(const LeafT &leaf)
Definition: AttributeGroup.h:151
LeafNodeType * initialize(const Coord &origin, const size_t idx, const CoordBBox &bounds)
Definition: PrincipalComponentAnalysisImpl.h:158
std::string positionWS
Definition: PrincipalComponentAnalysis.h:176
std::string stretch
Definition: PrincipalComponentAnalysis.h:161
Type Pow3(Type x)
Return x3.
Definition: Math.h:552
bool finalize(const Coord &, size_t idx)
Definition: PrincipalComponentAnalysisImpl.h:305
std::unique_ptr< PositionHandleT > mSourcePosition
Definition: PrincipalComponentAnalysisImpl.h:183
const TreeType & tree() const
Return a const reference to tree associated with this manager.
Definition: LeafManager.h:303
bool diagonalizeSymmetricMatrix(const Mat3< T > &input, Mat3< T > &Q, Vec3< T > &D, unsigned int MAX_ITERATIONS=250)
Use Jacobi iterations to decompose a symmetric 3x3 matrix (diagonalize and compute eigenvectors) ...
Definition: Mat3.h:736
float allowedAnisotropyRatio
Definition: PrincipalComponentAnalysis.h:94
void stop()
Definition: PrincipalComponentAnalysisImpl.h:30
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:121
std::string rotation
Definition: PrincipalComponentAnalysis.h:167
Definition: PrincipalComponentAnalysisImpl.h:35
static Vec3< T > ones()
Definition: Vec3.h:468
size_t neighbourThreshold() const
Definition: PrincipalComponentAnalysisImpl.h:151
CovarianceTransfer(const AttrIndices &indices, const PcaSettings &settings, const Real vs, tree::LeafManager< PointDataTreeT > &manager, util::NullInterrupter *interrupt)
Definition: PrincipalComponentAnalysisImpl.h:350
Definition: PrincipalComponentAnalysisImpl.h:190
Vec3< float > Vec3s
Definition: Vec3.h:664
bool valid(const IterT &iter) const
Definition: AttributeGroup.h:156
bool finalize(const Coord &, size_t)
Definition: PrincipalComponentAnalysisImpl.h:483
3x3 matrix class.
Definition: Mat3.h:28
T product() const
Return the product of all the vector components.
Definition: Vec3.h:357
void initialize(const Coord &origin, const size_t idx, const CoordBBox &bounds)
Definition: PrincipalComponentAnalysisImpl.h:368
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:218