-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathpoints_to_implicit.py
More file actions
47 lines (35 loc) · 1.36 KB
/
Copy pathpoints_to_implicit.py
File metadata and controls
47 lines (35 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from pyCubbyFlow import (
AnisotropicPointsToImplicit2,
CellCenteredScalarGrid2,
Logging,
SPHPointsToImplicit2,
SphericalPointsToImplicit2,
ZhuBridsonPointsToImplicit2,
)
import numpy as np
import matplotlib.pyplot as plt
def main():
np.random.seed(0)
points = np.random.rand(100, 2) * 0.6 + 0.2
grid = CellCenteredScalarGrid2((512, 512), (1.0 / 512.0, 1.0 / 512.0))
_, ax = plt.subplots()
ax.set_aspect("equal")
kernel_radius = 0.1
cutoff = 0.5
converter = SphericalPointsToImplicit2(kernel_radius * cutoff)
converter.Convert(points.tolist(), grid)
plt.contour(grid.GetDataAccessor(), levels=[0.0], colors=("g"))
converter = SPHPointsToImplicit2(kernel_radius, cutoff)
converter.Convert(points.tolist(), grid)
plt.contour(grid.GetDataAccessor(), levels=[0.0], colors=("b"))
converter = ZhuBridsonPointsToImplicit2(2.0 * kernel_radius, 0.5 * cutoff)
converter.Convert(points.tolist(), grid)
plt.contour(grid.GetDataAccessor(), levels=[0.0], colors=("purple"))
converter = AnisotropicPointsToImplicit2(kernel_radius, cutoff, 0.0, 8)
converter.Convert(points.tolist(), grid)
plt.contour(grid.GetDataAccessor(), levels=[0.0], colors=("r"))
plt.scatter(points[:, 0] * 512, points[:, 1] * 512, c="black")
plt.show()
if __name__ == "__main__":
Logging.Mute()
main()