-
Notifications
You must be signed in to change notification settings - Fork 0
/
sphere.py
41 lines (29 loc) · 1.25 KB
/
sphere.py
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
import pickle
import pdf
#create an hexagonal mesh
import numpy as np
import matplotlib.pyplot as plt
g=pdf.Grid((-150,-150,-150),(150,150,150))
sppdf=pdf.sphere(r=80.0)
sp_density = g.evaluate(sppdf)
pdf.save_density(sp_density, 1.0, "sphere.mrc", origin=None)
skin=pdf.get_skin(sp_density,0.90,0.1)
pdf.save_density(skin, 1.0, "sphere_median_skin.mrc", origin=None)
radius=15.0
points=pdf.sample_skin(skin,min_distance_beads=radius)
radii=[radius/2]*len(points)
sampled=pdf.get_sparse_grid_from_points(sp_density,points)
pdf.save_density(sampled, 1.0, "sphere_median_skin_points.mrc", origin=None)
pickle.dump((points,radii),open("sphere_median_skin_points.pkl","wb"))
# compute the extrusion
extrude_skin=pdf.extrude(skin)
pdf.save_density(extrude_skin, 1.0, "sphere_extrude_skin.mrc", origin=None)
radius=8.0
points=pdf.sample_skin(extrude_skin,min_distance_beads=radius)
radii=[radius/2]*len(points)
sampled=pdf.get_sparse_grid_from_points(sp_density,points)
pdf.save_density(sampled, 1.0, "sphere_extrude_skin_points.mrc", origin=None)
pickle.dump((points,radii),open("sphere_extrude_skin_points.pkl","wb"))
# compute the dilation difference
dilation_skin=pdf.dilation_difference(skin)
pdf.save_density(dilation_skin, 1.0, "sphere_dilation_skin.mrc", origin=None)