Skip to content

Commit 96d32de

Browse files
authored
More options for particles2obj app (#113)
* Adding more reconstruction methods to the example * FMM as an option * Minor fixes
1 parent 7eb3b89 commit 96d32de

22 files changed

Lines changed: 222 additions & 143 deletions

include/jet/anisotropic_points_to_implicit2.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ class AnisotropicPointsToImplicit2 final : public PointsToImplicit2 {
3737
AnisotropicPointsToImplicit2(double kernelRadius = 1.0,
3838
double cutOffDensity = 0.5,
3939
double positionSmoothingFactor = 0.0,
40-
size_t minNumNeighbors = 8);
40+
size_t minNumNeighbors = 8,
41+
bool isOutputSdf = true);
4142

4243
//! Converts the given points to implicit surface scalar field.
4344
void convert(const ConstArrayAccessor1<Vector2D>& points,
@@ -48,6 +49,7 @@ class AnisotropicPointsToImplicit2 final : public PointsToImplicit2 {
4849
double _cutOffDensity = 0.5;
4950
double _positionSmoothingFactor = 0.0;
5051
size_t _minNumNeighbors = 8;
52+
bool _isOutputSdf = true;
5153
};
5254

5355
//! Shared pointer for the AnisotropicPointsToImplicit2 type.

include/jet/anisotropic_points_to_implicit3.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ class AnisotropicPointsToImplicit3 final : public PointsToImplicit3 {
3737
AnisotropicPointsToImplicit3(double kernelRadius = 1.0,
3838
double cutOffDensity = 0.5,
3939
double positionSmoothingFactor = 0.0,
40-
size_t minNumNeighbors = 25);
40+
size_t minNumNeighbors = 25,
41+
bool isOutputSdf = true);
4142

4243
//! Converts the given points to implicit surface scalar field.
4344
void convert(const ConstArrayAccessor1<Vector3D>& points,
@@ -48,6 +49,7 @@ class AnisotropicPointsToImplicit3 final : public PointsToImplicit3 {
4849
double _cutOffDensity = 0.5;
4950
double _positionSmoothingFactor = 0.0;
5051
size_t _minNumNeighbors = 25;
52+
bool _isOutputSdf = true;
5153
};
5254

5355
//! Shared pointer for the AnisotropicPointsToImplicit3 type.

include/jet/sph_points_to_implicit2.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ namespace jet {
2222
class SphPointsToImplicit2 final : public PointsToImplicit2 {
2323
public:
2424
//! Constructs the converter with given kernel radius and cut-off density.
25-
SphPointsToImplicit2(double kernelRadius = 1.0, double cutOffDensity = 0.5);
25+
SphPointsToImplicit2(double kernelRadius = 1.0, double cutOffDensity = 0.5,
26+
bool isOutputSdf = true);
2627

2728
//! Converts the given points to implicit surface scalar field.
2829
void convert(const ConstArrayAccessor1<Vector2D>& points,
@@ -31,6 +32,7 @@ class SphPointsToImplicit2 final : public PointsToImplicit2 {
3132
private:
3233
double _kernelRadius = 1.0;
3334
double _cutOffDensity = 0.5;
35+
bool _isOutputSdf = true;
3436
};
3537

3638
//! Shared pointer type for SphPointsToImplicit2 class.

include/jet/sph_points_to_implicit3.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ namespace jet {
2222
class SphPointsToImplicit3 final : public PointsToImplicit3 {
2323
public:
2424
//! Constructs the converter with given kernel radius and cut-off density.
25-
SphPointsToImplicit3(double kernelRadius = 1.0, double cutOffDensity = 0.5);
25+
SphPointsToImplicit3(double kernelRadius = 1.0, double cutOffDensity = 0.5,
26+
bool isOutputSdf = true);
2627

2728
//! Converts the given points to implicit surface scalar field.
2829
void convert(const ConstArrayAccessor1<Vector3D>& points,
@@ -31,6 +32,7 @@ class SphPointsToImplicit3 final : public PointsToImplicit3 {
3132
private:
3233
double _kernelRadius = 1.0;
3334
double _cutOffDensity = 0.5;
35+
bool _isOutputSdf = true;
3436
};
3537

3638
//! Shared pointer type for SphPointsToImplicit3 class.

include/jet/spherical_points_to_implicit2.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ namespace jet {
1717
class SphericalPointsToImplicit2 final : public PointsToImplicit2 {
1818
public:
1919
//! Constructs the converter with given sphere radius.
20-
SphericalPointsToImplicit2(double radius = 1.0);
20+
SphericalPointsToImplicit2(double radius = 1.0, bool isOutputSdf = true);
2121

2222
//! Converts the given points to implicit surface scalar field.
2323
void convert(const ConstArrayAccessor1<Vector2D>& points,
2424
ScalarGrid2* output) const override;
2525

2626
private:
2727
double _radius = 1.0;
28+
bool _isOutputSdf = true;
2829
};
2930

3031
//! Shared pointer type for SphericalPointsToImplicit2.

include/jet/spherical_points_to_implicit3.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ namespace jet {
1717
class SphericalPointsToImplicit3 final : public PointsToImplicit3 {
1818
public:
1919
//! Constructs the converter with given sphere radius.
20-
SphericalPointsToImplicit3(double radius = 1.0);
20+
SphericalPointsToImplicit3(double radius = 1.0, bool isOutputSdf = true);
2121

2222
//! Converts the given points to implicit surface scalar field.
2323
void convert(const ConstArrayAccessor1<Vector3D>& points,
2424
ScalarGrid3* output) const override;
2525

2626
private:
2727
double _radius = 1.0;
28+
bool _isOutputSdf = true;
2829
};
2930

3031
//! Shared pointer type for SphericalPointsToImplicit3.

include/jet/zhu_bridson_points_to_implicit2.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ class ZhuBridsonPointsToImplicit2 final : public PointsToImplicit2 {
2121
public:
2222
//! Constructs the converter with given kernel radius and cut-off threshold.
2323
ZhuBridsonPointsToImplicit2(double kernelRadius = 1.0,
24-
double cutOffThreshold = 0.25);
24+
double cutOffThreshold = 0.25,
25+
bool isOutputSdf = true);
2526

2627
//! Converts the given points to implicit surface scalar field.
2728
void convert(const ConstArrayAccessor1<Vector2D>& points,
@@ -30,6 +31,7 @@ class ZhuBridsonPointsToImplicit2 final : public PointsToImplicit2 {
3031
private:
3132
double _kernelRadius = 1.0;
3233
double _cutOffThreshold = 0.25;
34+
bool _isOutputSdf = true;
3335
};
3436

3537
//! Shared pointer type for ZhuBridsonPointsToImplicit2 class

include/jet/zhu_bridson_points_to_implicit3.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ class ZhuBridsonPointsToImplicit3 final : public PointsToImplicit3 {
2121
public:
2222
//! Constructs the converter with given kernel radius and cut-off threshold.
2323
ZhuBridsonPointsToImplicit3(double kernelRadius = 1.0,
24-
double cutOffThreshold = 0.25);
24+
double cutOffThreshold = 0.25,
25+
bool isOutputSdf = true);
2526

2627
//! Converts the given points to implicit surface scalar field.
2728
void convert(const ConstArrayAccessor1<Vector3D>& points,
@@ -30,6 +31,7 @@ class ZhuBridsonPointsToImplicit3 final : public PointsToImplicit3 {
3031
private:
3132
double _kernelRadius = 1.0;
3233
double _cutOffThreshold = 0.25;
34+
bool _isOutputSdf = true;
3335
};
3436

3537
//! Shared pointer type for ZhuBridsonPointsToImplicit3 class

src/examples/hybrid_liquid_sim/main.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void printUsage() {
7373
" -o, --output: output directory name "
7474
"(default is " APP_NAME
7575
"_output)\n"
76-
" -e, --example: example number (between 1 and 5, default is 1)\n"
76+
" -e, --example: example number (between 1 and 6, default is 1)\n"
7777
" -m, --format: particle output format (xyz or pos. default is xyz)\n"
7878
" -h, --help: print this message\n");
7979
}
@@ -476,13 +476,20 @@ void runExample6(const std::string& rootDir, size_t resolutionX,
476476

477477
// Manually emit particles
478478
std::mt19937 rng;
479-
std::uniform_real_distribution<> dist(0, 1);
480-
for (size_t i = 0; i < 8 * resolutionX * resolutionX * resolutionX; ++i) {
481-
Vector3D pt{dist(rng), dist(rng), dist(rng)};
482-
if ((pt - sphere->center).length() < sphere->radius && pt.x > 0.5) {
483-
solver->particleSystemData()->addParticle(pt);
484-
}
485-
}
479+
std::uniform_real_distribution<> dist(-0.1 * solver->gridSpacing().x,
480+
0.1 * solver->gridSpacing().x);
481+
BccLatticePointGenerator pointGenerator;
482+
pointGenerator.forEachPoint(
483+
BoundingBox3D({0.75, 0, 0}, {1, 1, 1}), 0.5 * solver->gridSpacing().x,
484+
[&](const Vector3D& pt) -> bool {
485+
Vector3D newPos = pt + Vector3D{dist(rng), dist(rng), dist(rng)};
486+
if ((pt - Vector3D{0.5, 0.5, 0.5}).length() < 0.4) {
487+
solver->particleSystemData()->addParticle(newPos);
488+
}
489+
return true;
490+
});
491+
printf("Number of particles: %zu\n",
492+
solver->particleSystemData()->numberOfParticles());
486493

487494
// Print simulation info
488495
printf("Running example 6 (sphere boundary with APIC)\n");

0 commit comments

Comments
 (0)