Skip to content

Commit c2bc66e

Browse files
committed
Improved formatting, spelling and comments
Signed-off-by: Nick Avramoussis <[email protected]>
1 parent 36b6043 commit c2bc66e

File tree

6 files changed

+59
-66
lines changed

6 files changed

+59
-66
lines changed

openvdb/openvdb/math/Mat3.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,7 @@ pivot(int i, int j, Mat3<T>& S, Vec3<T>& D, Mat3<T>& Q)
716716
S(i,k) = T(cosin_of_theta * temp - sin_of_theta * S(j,k));
717717
S(j,k) = T(sin_of_theta * temp + cosin_of_theta * S(j,k));
718718
}
719-
for (int k = 0; k < n; ++k)
720-
{
719+
for (int k = 0; k < n; ++k) {
721720
temp = Q(k,i);
722721
Q(k,i) = T(cosin_of_theta * temp - sin_of_theta * Q(k,j));
723722
Q(k,j) = T(sin_of_theta * temp + cosin_of_theta * Q(k,j));

openvdb/openvdb/points/PointRasterizeSDF.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,14 @@
2929
/// points which is ideal for generating a more artistically pleasant
3030
/// surface directly from point distributions. It aims to avoid typical
3131
/// post filtering operations used to smooth surface volumes. Note however
32-
/// that this method may not necessarily produce a *symmetrical* narrow
33-
/// band level set; the exterior band may be smaller than desired depending
34-
/// on the search radius - the surface can be rebuilt or resized if
35-
/// necessary. The same closet point algorithm is used to transfer
36-
/// attributes.
32+
/// that this method can be prone to temporal instabilities (that is, given
33+
/// a sequence of frames, consecutive frames may not generate surfaces that
34+
/// transition as smoothly) due to changes in point distributions resulting
35+
/// in more abrupt surface changes. It may also not necessarily produce a
36+
/// *symmetrical* narrow band level set; the exterior band may be smaller
37+
/// than desired depending on the search radius - the surface can be rebuilt
38+
/// or resized if necessary. The same closet point algorithm is used to
39+
/// transfer attributes.
3740
///
3841
/// - Rasterize Ellipsoids.
3942
///
@@ -298,7 +301,8 @@ struct EllipsoidSettings
298301
using BaseT::radius;
299302
using BaseT::radiusScale;
300303

301-
/// @param rotation the attribute containing each points orientation
304+
/// @param rotation the attribute containing each points orthogonal
305+
/// rotation matrix.
302306
/// @details This attribute must exist and represents the rotation of
303307
/// each points ellipse. Must be a Mat3s type.
304308
std::string rotation = "rotation";

openvdb/openvdb/points/PrincipalComponentAnalysis.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ namespace points {
4343
struct PcaSettings;
4444
struct PcaAttributes;
4545

46-
/// @brief Calculate Calculate ellipsoid transformations from the local point
46+
/// @brief Calculate ellipsoid transformations from the local point
4747
/// distributions as described in Yu and Turk's 'Reconstructing Fluid Surfaces
4848
/// with Anisotropic Kernels'. The results are stored on the attributes
4949
/// pointed to by the PcaAttributes. See the PcaSettings and PcaAttributes
@@ -161,8 +161,8 @@ struct PcaAttributes
161161
std::string stretch = "stretch";
162162

163163
/// @brief Settings for the "rotation" attribute, a floating point matrix
164-
/// attribute which represents the rotation of each points ellipse or
165-
/// the identity matrix for isolated points.
164+
/// attribute which represents the orthogonal rotation of each points
165+
/// ellipse or the identity matrix for isolated points.
166166
using RotationT = math::Mat3<float>;
167167
std::string rotation = "rotation";
168168

openvdb/openvdb/points/impl/PointRasterizeEllipsoidsSDFImpl.h

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ calcEllipsoidBoundMax(const math::Mat3s& ellipsoidTransform)
4848
return boundMax;
4949
}
5050

51-
struct EllipsIndicies
51+
struct EllipseIndicies
5252
{
53-
EllipsIndicies(const points::AttributeSet::Descriptor& desc,
53+
EllipseIndicies(const points::AttributeSet::Descriptor& desc,
5454
const std::string& rotation,
5555
const std::string& pws)
56-
: rotation(EllipsIndicies::getAttributeIndex<Mat3s>(desc, rotation, false))
57-
, positionws(EllipsIndicies::getAttributeIndex<Vec3d>(desc, pws, true)) {}
56+
: rotation(EllipseIndicies::getAttributeIndex<Mat3s>(desc, rotation, false))
57+
, positionws(EllipseIndicies::getAttributeIndex<Vec3d>(desc, pws, true)) {}
5858

5959
bool hasWorldSpacePosition() const { return positionws != std::numeric_limits<size_t>::max(); }
6060

@@ -108,7 +108,7 @@ struct EllipsoidTransfer :
108108
const FilterT& filter,
109109
util::NullInterrupter* interrupt,
110110
SdfT& surface,
111-
const EllipsIndicies& indices,
111+
const EllipseIndicies& indices,
112112
Int64Tree* cpg = nullptr,
113113
const std::unordered_map<const PointDataTree::LeafNodeType*, Index>* ids = nullptr)
114114
: BaseT(pidx, width, rt, source, filter, interrupt, surface, cpg, ids)
@@ -253,27 +253,27 @@ struct EllipsoidTransfer :
253253
// the sqrts and projections when outside the half band
254254
len = math::Sqrt(len);
255255
if (OPENVDB_UNLIKELY(len == 0)) {
256-
// The minimum radius of this ellips in world space. Used only to store
256+
// The minimum radius of this ellipse in world space. Used only to store
257257
// a distance when a given voxel's ijk coordinates overlaps exactly with
258-
// the center of an ellips
258+
// the center of an ellipse
259259
d = -ValueT(std::min(radius.x(), std::min(radius.y(), radius.z()))) * ValueT(this->mDx);
260260
}
261261
else {
262-
Vec3d ellipsNormal = (ellipsoidInverse.transpose() * pointOnUnitSphere);
263-
ellipsNormal.normalize();
264-
// Project xyz onto the ellips normal, scale length by
262+
Vec3d ellipseNormal = (ellipsoidInverse.transpose() * pointOnUnitSphere);
263+
ellipseNormal.normalize();
264+
// Project xyz onto the ellipse normal, scale length by
265265
// the offset correction based on the distance from the
266266
// unit sphere surface and finally convert back to
267267
// world space
268268
//
269269
// Invert the length to represent a proportional offset to
270270
// the final distance when the above sphere point is
271-
// projected back onto the ellips. If the length iz zero,
272-
// then this voxel's ijk is the center of the ellips.
271+
// projected back onto the ellipse. If the length iz zero,
272+
// then this voxel's ijk is the center of the ellipse.
273273
d = static_cast<ValueT>(
274-
((x * ellipsNormal.x()) +
275-
(y * ellipsNormal.y()) +
276-
(z * ellipsNormal.z())) // dot product
274+
((x * ellipseNormal.x()) +
275+
(y * ellipseNormal.y()) +
276+
(z * ellipseNormal.z())) // dot product
277277
* (1.0 - (RealT(1.0)/len)) // scale
278278
* this->mDx); // world space
279279
}
@@ -287,9 +287,9 @@ struct EllipsoidTransfer :
287287
#elif OPENVDB_ELLIPSOID_KERNEL_MODE == 2
288288
const RealT k2 = (pointOnUnitSphere * radInv2).length();
289289
if (OPENVDB_UNLIKELY(k2 == 0)) {
290-
// The minimum radius of this ellips in world space. Used only to store
290+
// The minimum radius of this ellipse in world space. Used only to store
291291
// a distance when a given voxel's ijk coordinates overlaps exactly with
292-
// the center of an ellips
292+
// the center of an ellipse
293293
d = -ValueT(std::min(radius.x(), std::min(radius.y(), radius.z()))) * ValueT(this->mDx);
294294
}
295295
else {
@@ -317,14 +317,14 @@ struct EllipsoidTransfer :
317317
}
318318

319319
private:
320-
const EllipsIndicies& mIndices;
320+
const EllipseIndicies& mIndices;
321321
std::unique_ptr<RotationHandleT> mRotationHandle;
322322
std::unique_ptr<PwsHandleT> mPositionWSHandle;
323323
};
324324

325325

326326
template<typename RadiusType, typename MaskTreeT>
327-
struct EllipsSurfaceMaskOp
327+
struct EllipseSurfaceMaskOp
328328
: public rasterize_sdf_internal::SurfaceMaskOp<MaskTreeT>
329329
{
330330
using BaseT = rasterize_sdf_internal::SurfaceMaskOp<MaskTreeT>;
@@ -333,19 +333,19 @@ struct EllipsSurfaceMaskOp
333333
using RadiusT = typename RadiusType::ValueType;
334334
static const Index DIM = points::PointDataTree::LeafNodeType::DIM;
335335

336-
EllipsSurfaceMaskOp(
336+
EllipseSurfaceMaskOp(
337337
const math::Transform& src,
338338
const math::Transform& trg,
339339
const RadiusType& rad,
340340
const Real halfband,
341-
const EllipsIndicies& indices)
341+
const EllipseIndicies& indices)
342342
: BaseT(src, trg, nullptr)
343343
, mRadius(rad)
344344
, mHalfband(halfband)
345345
, mIndices(indices)
346346
, mMaxDist(0) {}
347347

348-
EllipsSurfaceMaskOp(const EllipsSurfaceMaskOp& other, tbb::split)
348+
EllipseSurfaceMaskOp(const EllipseSurfaceMaskOp& other, tbb::split)
349349
: BaseT(other)
350350
, mRadius(other.mRadius)
351351
, mHalfband(other.mHalfband)
@@ -354,7 +354,7 @@ struct EllipsSurfaceMaskOp
354354

355355
Vec3i getMaxDist() const { return mMaxDist; }
356356

357-
void join(EllipsSurfaceMaskOp& other)
357+
void join(EllipseSurfaceMaskOp& other)
358358
{
359359
mMaxDist = math::maxComponent(mMaxDist, other.mMaxDist);
360360
this->BaseT::join(other);
@@ -378,7 +378,7 @@ struct EllipsSurfaceMaskOp
378378
}
379379

380380
// The max stretch coefficient. We can't analyze each xyz component
381-
// individually as we don't take into account the ellips rotation, so
381+
// individually as we don't take into account the ellipse rotation, so
382382
// have to expand the worst case uniformly
383383
const Real maxRadius = std::max(maxr.x(), std::max(maxr.y(), maxr.z()));
384384

@@ -419,9 +419,9 @@ struct EllipsSurfaceMaskOp
419419
}
420420
}
421421

422-
/// @brief Fill activity by analyzing the axis aligned ellips bounding
422+
/// @brief Fill activity by analyzing the axis aligned ellipse bounding
423423
/// boxes on points in this leaf. Slightly slower than just looking at
424-
/// ellips stretches but produces a more accurate/tighter activation
424+
/// ellipse stretches but produces a more accurate/tighter activation
425425
/// result
426426
void fillFromStretchAndRotation(const typename LeafManagerT::LeafNodeType& leaf)
427427
{
@@ -463,7 +463,7 @@ struct EllipsSurfaceMaskOp
463463
}
464464
}
465465

466-
// Compute max ellips bounds
466+
// Compute max ellipse bounds
467467
points::AttributeHandle<math::Mat3s> rotHandle(leaf.constAttributeArray(mIndices.rotation));
468468
float maxUniformRadius(0);
469469
Vec3f r(radius0);
@@ -484,7 +484,7 @@ struct EllipsSurfaceMaskOp
484484
}
485485
}
486486

487-
// compute AABB of ellips
487+
// compute AABB of ellipse
488488
const math::Mat3s rotation = rotHandle.get(i);
489489
const math::Mat3s ellipsoidTransform = rotation.timesDiagonal(r);
490490
const Vec3d bounds = calcUnitEllipsoidBoundMaxSq(ellipsoidTransform);
@@ -494,7 +494,7 @@ struct EllipsSurfaceMaskOp
494494
for (size_t i = 0; i < 3; ++i) {
495495
// We don't do the sqrt per point so resolve the actual maxBounds now
496496
maxBounds[i] = std::sqrt(maxBounds[i]);
497-
// Account for uniform stretch values - compare the ellips to isolated
497+
// Account for uniform stretch values - compare the ellipse to isolated
498498
// points and choose the largest radius of the two
499499
maxBounds[i] = std::max(double(maxUniformRadius), maxBounds[i]);
500500
}
@@ -571,7 +571,7 @@ struct EllipsSurfaceMaskOp
571571
private:
572572
const RadiusType& mRadius;
573573
const Real mHalfband;
574-
const EllipsIndicies& mIndices;
574+
const EllipseIndicies& mIndices;
575575
Vec3i mMaxDist;
576576
};
577577

@@ -614,20 +614,19 @@ rasterizeEllipsoids(const PointDataGridT& points,
614614
}
615615

616616
// Get attributes
617-
const EllipsIndicies indices(leaf->attributeSet().descriptor(),
617+
const EllipseIndicies indices(leaf->attributeSet().descriptor(),
618618
settings.rotation,
619619
settings.pws); // pws is optional
620620

621621
typename SdfT::Ptr surface;
622622
GridPtrVec grids;
623623

624-
if (settings.radius.empty())
625-
{
624+
if (settings.radius.empty()) {
626625
// Initial Index Space radius
627626
FixedBandRadius<Vec3f> rad(Vec3f(radiusScale / vs), float(halfband));
628627

629628
// pre-compute ellipsoidal transform bounds and surface mask. Points that
630-
// are not in the ellipse ellipses group are treated as spheres and follow
629+
// are not in the ellipses group are treated as spheres and follow
631630
// the same logic as that of the Fixed/VaryingSurfaceMaskOps. Ellipsoids
632631
// instead compute the max axis-aligned bounding boxes. The maximum extents
633632
// of the spheres/ellipses in a leaf is used for the maximum mask/lookup.
@@ -640,7 +639,7 @@ rasterizeEllipsoids(const PointDataGridT& points,
640639
tree::LeafManager<const PointDataTreeT> manager(points.tree());
641640
// pass radius scale as index space
642641

643-
EllipsSurfaceMaskOp<FixedBandRadius<Vec3f>, MaskTreeT>
642+
EllipseSurfaceMaskOp<FixedBandRadius<Vec3f>, MaskTreeT>
644643
op(points.transform(), *transform, rad, halfband, indices);
645644
tbb::parallel_reduce(manager.leafRange(), op);
646645

@@ -658,8 +657,7 @@ rasterizeEllipsoids(const PointDataGridT& points,
658657
(points, attributes, *surface,
659658
width, rad, points.transform(), filter, interrupter, *surface, indices); // args
660659
}
661-
else
662-
{
660+
else {
663661
using RadiusT = typename SettingsT::RadiusAttributeType;
664662

665663
const size_t ridx = leaf->attributeSet().find(settings.radius);
@@ -671,7 +669,7 @@ rasterizeEllipsoids(const PointDataGridT& points,
671669
VaryingBandRadius<RadiusT, Vec3f> rad(ridx, float(halfband), Vec3f(radiusScale / vs));
672670

673671
// pre-compute ellipsoidal transform bounds and surface mask. Points that
674-
// are not in the ellipse ellipses group are treated as spheres and follow
672+
// are not in the ellipse group are treated as spheres and follow
675673
// the same logic as that of the Fixed/VaryingSurfaceMaskOps. Ellipsoids
676674
// instead compute the max axis-aligned bounding boxes. The maximum extents
677675
// of the spheres/ellipses in a leaf is used for the maximum mask/lookup.
@@ -684,7 +682,7 @@ rasterizeEllipsoids(const PointDataGridT& points,
684682
tree::LeafManager<const PointDataTreeT> manager(points.tree());
685683

686684
// pass radius scale as index space
687-
EllipsSurfaceMaskOp<VaryingBandRadius<RadiusT, Vec3f>, MaskTreeT>
685+
EllipseSurfaceMaskOp<VaryingBandRadius<RadiusT, Vec3f>, MaskTreeT>
688686
op(points.transform(), *transform, rad, halfband, indices);
689687
tbb::parallel_reduce(manager.leafRange(), op);
690688

openvdb/openvdb/points/impl/PointRasterizeSDFImpl.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,8 +1311,7 @@ rasterizeSpheres(const PointDataGridT& points,
13111311
typename SdfT::Ptr surface;
13121312
GridPtrVec grids;
13131313

1314-
if (settings.radius.empty())
1315-
{
1314+
if (settings.radius.empty()) {
13161315
// search distance at the SDF transform, including its half band
13171316
const Real radiusIndexSpace = settings.radiusScale / vs;
13181317
const FixedBandRadius<Real> rad(radiusIndexSpace, float(halfband));
@@ -1422,8 +1421,7 @@ rasterizeSmoothSpheres(const PointDataGridT& points,
14221421
typename SdfT::Ptr surface;
14231422
GridPtrVec grids;
14241423

1425-
if (settings.radius.empty())
1426-
{
1424+
if (settings.radius.empty()) {
14271425
// This is the max possible distance we need to activate, but we'll
14281426
// clip this at the edges of the point bounds (as the ZB kernel will
14291427
// only create positions in between points).
@@ -1445,8 +1443,7 @@ rasterizeSmoothSpheres(const PointDataGridT& points,
14451443
(points, attributes, *surface,
14461444
width, rad, indexSpaceSearch, points.transform(), filter, interrupter, *surface); // args
14471445
}
1448-
else
1449-
{
1446+
else {
14501447
using RadiusT = typename SettingsT::RadiusAttributeType;
14511448
using PointDataTreeT = typename PointDataGridT::TreeType;
14521449
using RadTreeT = typename PointDataTreeT::template ValueConverter<RadiusT>::Type;

openvdb/openvdb/points/impl/PrincipalComponentAnalysisImpl.h

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,7 @@ struct WeightPosSumsTransfer
238238
const Coord& a(bounds.min());
239239
const Coord& b(bounds.max());
240240

241-
for (Index srcid = start; srcid < end; srcid += step)
242-
{
241+
for (Index srcid = start; srcid < end; srcid += step) {
243242
const Vec3d Psrc(this->mSourcePosition->get(srcid));
244243
const Vec3d PsrcIS = Psrc * this->mDxInv;
245244

@@ -281,8 +280,7 @@ struct WeightPosSumsTransfer
281280
/// we get a self contribution, could guarantee this
282281
/// by enabling the OPENVDB_PCA_SELF_CONTRIBUTION == 0
283282
/// check and adding it afterwards.
284-
for (Index tgtid = targetStart; tgtid < targetEnd; tgtid += targetStep)
285-
{
283+
for (Index tgtid = targetStart; tgtid < targetEnd; tgtid += targetStep) {
286284
#if OPENVDB_PCA_SELF_CONTRIBUTION == 0
287285
if (OPENVDB_UNLIKELY(this->mIsSameLeaf && tgtid == srcid)) continue;
288286
#endif
@@ -320,8 +318,7 @@ struct WeightPosSumsTransfer
320318
points::GroupWriteHandle group(leaf.groupWriteHandle(this->mIndices.mEllipsesGroupIndex));
321319

322320
const int32_t threshold = int32_t(this->neighbourThreshold());
323-
for (Index i = 0; i < this->mTargetPosition->size(); ++i)
324-
{
321+
for (Index i = 0; i < this->mTargetPosition->size(); ++i) {
325322
// turn points OFF if they are ON and don't meet max neighbour requirements
326323
if ((threshold == 0 || (mCounts[i] < threshold)) && group.getUnsafe(i)) {
327324
group.setUnsafe(i, false);
@@ -395,8 +392,7 @@ struct CovarianceTransfer
395392
const Coord& a(bounds.min());
396393
const Coord& b(bounds.max());
397394

398-
for (Index srcid = start; srcid < end; srcid += step)
399-
{
395+
for (Index srcid = start; srcid < end; srcid += step) {
400396
const Vec3d Psrc(this->mSourcePosition->get(srcid));
401397
const Vec3d PsrcIS = Psrc * this->mDxInv;
402398

@@ -433,8 +429,7 @@ struct CovarianceTransfer
433429
const Index targetStep =
434430
std::max(Index(1), Index((targetEnd - targetStart) / this->maxTargetPointsPerVoxel()));
435431

436-
for (Index tgtid = targetStart; tgtid < targetEnd; tgtid += targetStep)
437-
{
432+
for (Index tgtid = targetStart; tgtid < targetEnd; tgtid += targetStep) {
438433
if (!mInclusionGroupHandle->get(tgtid)) continue;
439434
#if OPENVDB_PCA_SELF_CONTRIBUTION == 0
440435
if (OPENVDB_UNLIKELY(this->mIsSameLeaf && tgtid == srcid)) continue;

0 commit comments

Comments
 (0)