Skip to content

Commit 7eb3b89

Browse files
authored
Surface reconstruction from points (#112)
This revision includes four different kinds of surface reconstruction algorithms of points such as: * Spherical representation (union of spheres) * SPH blobby (metaball-like) [Müller et al., 2003] * Zhu and Bridson's method [Zhu and Bridson, 2005] * Anisotropic kernel [Yu and Turk, 2010]
1 parent b2d72ac commit 7eb3b89

65 files changed

Lines changed: 3418 additions & 562 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright (c) 2017 Doyub Kim
2+
//
3+
// I am making my contributions/submissions to this project solely in my
4+
// personal capacity and am not conveying any rights to any intellectual
5+
// property of any third parties.
6+
7+
#ifndef INCLUDE_JET_ANISOTROPIC_POINTS_TO_IMPLICIT2_H_
8+
#define INCLUDE_JET_ANISOTROPIC_POINTS_TO_IMPLICIT2_H_
9+
10+
#include <jet/points_to_implicit2.h>
11+
12+
namespace jet {
13+
14+
//!
15+
//! \brief 2-D points-to-implicit converter using Anisotropic kernels.
16+
//!
17+
//! This class converts 2-D points to implicit surface using anisotropic kernels
18+
//! so that the kernels are oriented and stretched to reflect the point
19+
//! distribution more naturally (thus less bumps). The implementation is based
20+
//! on Yu and Turk's 2013 paper with some modifications.
21+
//!
22+
//! \see Yu, Jihun, and Greg Turk. "Reconstructing surfaces of particle-based
23+
//! fluids using anisotropic kernels." ACM Transactions on Graphics (TOG)
24+
//! 32.1 (2013): 5.
25+
//!
26+
class AnisotropicPointsToImplicit2 final : public PointsToImplicit2 {
27+
public:
28+
//!
29+
//! \brief Constructs the converter with given parameters.
30+
//!
31+
//! \param kernelRadius Kernel radius for interpolations.
32+
//! \param cutOffDensity Iso-contour density value.
33+
//! \param positionSmoothingFactor Position smoothing factor.
34+
//! \param minNumNeighbors Minimum number of neighbors to enable anisotropic
35+
//! kernel.
36+
//!
37+
AnisotropicPointsToImplicit2(double kernelRadius = 1.0,
38+
double cutOffDensity = 0.5,
39+
double positionSmoothingFactor = 0.0,
40+
size_t minNumNeighbors = 8);
41+
42+
//! Converts the given points to implicit surface scalar field.
43+
void convert(const ConstArrayAccessor1<Vector2D>& points,
44+
ScalarGrid2* output) const override;
45+
46+
private:
47+
double _kernelRadius = 1.0;
48+
double _cutOffDensity = 0.5;
49+
double _positionSmoothingFactor = 0.0;
50+
size_t _minNumNeighbors = 8;
51+
};
52+
53+
//! Shared pointer for the AnisotropicPointsToImplicit2 type.
54+
typedef std::shared_ptr<AnisotropicPointsToImplicit2>
55+
AnisotropicPointsToImplicit2Ptr;
56+
57+
} // namespace jet
58+
59+
#endif // INCLUDE_JET_ANISOTROPIC_POINTS_TO_IMPLICIT2_H_
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright (c) 2017 Doyub Kim
2+
//
3+
// I am making my contributions/submissions to this project solely in my
4+
// personal capacity and am not conveying any rights to any intellectual
5+
// property of any third parties.
6+
7+
#ifndef INCLUDE_JET_ANISOTROPIC_POINTS_TO_IMPLICIT3_H_
8+
#define INCLUDE_JET_ANISOTROPIC_POINTS_TO_IMPLICIT3_H_
9+
10+
#include <jet/points_to_implicit3.h>
11+
12+
namespace jet {
13+
14+
//!
15+
//! \brief 3-D points-to-implicit converter using Anisotropic kernels.
16+
//!
17+
//! This class converts 3-D points to implicit surface using anisotropic kernels
18+
//! so that the kernels are oriented and stretched to reflect the point
19+
//! distribution more naturally (thus less bumps). The implementation is based
20+
//! on Yu and Turk's 2013 paper with some modifications.
21+
//!
22+
//! \see Yu, Jihun, and Greg Turk. "Reconstructing surfaces of particle-based
23+
//! fluids using anisotropic kernels." ACM Transactions on Graphics (TOG)
24+
//! 32.1 (2013): 5.
25+
//!
26+
class AnisotropicPointsToImplicit3 final : public PointsToImplicit3 {
27+
public:
28+
//!
29+
//! \brief Constructs the converter with given parameters.
30+
//!
31+
//! \param kernelRadius Kernel radius for interpolations.
32+
//! \param cutOffDensity Iso-contour density value.
33+
//! \param positionSmoothingFactor Position smoothing factor.
34+
//! \param minNumNeighbors Minimum number of neighbors to enable anisotropic
35+
//! kernel.
36+
//!
37+
AnisotropicPointsToImplicit3(double kernelRadius = 1.0,
38+
double cutOffDensity = 0.5,
39+
double positionSmoothingFactor = 0.0,
40+
size_t minNumNeighbors = 25);
41+
42+
//! Converts the given points to implicit surface scalar field.
43+
void convert(const ConstArrayAccessor1<Vector3D>& points,
44+
ScalarGrid3* output) const override;
45+
46+
private:
47+
double _kernelRadius = 1.0;
48+
double _cutOffDensity = 0.5;
49+
double _positionSmoothingFactor = 0.0;
50+
size_t _minNumNeighbors = 25;
51+
};
52+
53+
//! Shared pointer for the AnisotropicPointsToImplicit3 type.
54+
typedef std::shared_ptr<AnisotropicPointsToImplicit3>
55+
AnisotropicPointsToImplicit3Ptr;
56+
57+
} // namespace jet
58+
59+
#endif // INCLUDE_JET_ANISOTROPIC_POINTS_TO_IMPLICIT3_H_

include/jet/bounding_box2.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ class BoundingBox<T, 2> {
108108

109109
//! Returns the clamped point.
110110
Vector2<T> clamp(const Vector2<T>& pt) const;
111+
112+
//! Returns true if the box is empty.
113+
bool isEmpty() const;
111114
};
112115

113116
//! Type alias for 2-D BoundingBox.

include/jet/bounding_box3.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ class BoundingBox<T, 3> {
111111

112112
//! Returns the clamped point.
113113
Vector3<T> clamp(const Vector3<T>& point) const;
114+
115+
//! Returns true if the box is empty.
116+
bool isEmpty() const;
114117
};
115118

116119
//! Type alias for 3-D BoundingBox.

include/jet/detail/bounding_box2-inl.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,11 @@ Vector2<T> BoundingBox<T, 2>::clamp(const Vector2<T>& pt) const {
199199
return ::jet::clamp(pt, lowerCorner, upperCorner);
200200
}
201201

202+
template <typename T>
203+
bool BoundingBox<T, 2>::isEmpty() const {
204+
return (lowerCorner.x >= upperCorner.x || lowerCorner.y >= upperCorner.y);
205+
}
206+
202207
} // namespace jet
203208

204209
#endif // INCLUDE_JET_DETAIL_BOUNDING_BOX2_INL_H_

include/jet/detail/bounding_box3-inl.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ Vector3<T> BoundingBox<T, 3>::clamp(const Vector3<T>& pt) const {
212212
return ::jet::clamp(pt, lowerCorner, upperCorner);
213213
}
214214

215+
template <typename T>
216+
bool BoundingBox<T, 3>::isEmpty() const {
217+
return (lowerCorner.x >= upperCorner.x || lowerCorner.y >= upperCorner.y ||
218+
lowerCorner.z >= upperCorner.z);
219+
}
220+
215221
} // namespace jet
216222

217223
#endif // INCLUDE_JET_DETAIL_BOUNDING_BOX3_INL_H_

0 commit comments

Comments
 (0)