Hello all,
I'm hoping this is related enough to python to merit being posted here. I'm hoping someone will possibly have a better way of doing it altogether.
I'm using tetgen to try to create a hollow dome. I was using triangle and then just triangulating a circle and raising the z values according to the equation z = sqrt(abs(r^2 - x^2 - y^2)) but I was getting very bad stretching near the edges.
So I would like to just generate a bunch of points of this dome and then mesh it without filling it in. Tetgen basically does this for me by giving the .node and .faces file, but the problem is I'm still getting a bottom and I'm not sure how to get rid of it. I'm pretty new to tetgen and meshpy, so if anyone could give me a work flow for this I would greatly appreciate. The answer might actually be very easy.
For example, I am able to create the points around the bottom of the circle with a simple function:
def gen_pts_on_circle(num_pts, radius):
pnts = []
theta = 360.0 / num_pts
# loop through circle using theta for point placement
for i in np.arange(0, 360, theta):
x = radius * np.cos(np.radians(i))
y = radius * np.sin(np.radians(i))
z = 0.0
pnts.append((x,y,z))
return np.array(pnts)
Then I generate random points on the dome by using the function:
def gen_random_pts(num_pts, radius):
pts = []
for i in xrange(num_pts):
q = np.random.random() * (np.pi * 2.0)
r = np.sqrt(np.random.random())
x = (radius * r) * np.cos(q)
y = (radius * r) * np.sin(q)
# Just the sphere equation with abs value to make a dome
z = np.sqrt(abs(r**2 - x**2 - y**2))
pts.append((x,y,z))
return np.array(pts)
Then I simply just slap the header from a .node file and run tetgen to get the .face file. The only problem with this approach is the bottom is there when I need it to be an open dome.
I would much rather use meshpy, but generating these points and then feeding it into meshpy like so doesn't return anything...
from meshpy.tet import MeshInfo, build
# Generating all of the points using the functions
pts_circ = gen_pts_on_circle(100, 5)
points = np.vstack((pts_circle, gen_random_pts(500, 5)))
# Building with tet
mesh_info = MeshInfo()
mesh_info.set_points(points)
mesh = build(info)
print np.array(mesh.facets) and print np.array(mesh.points) are now just empty arrays.
Does anyone have any ideas on how to use meshpy without also setting all of the facets as well, or using this build method to build the facets like the command line tetgen does? This doesn't really get rid of my problem that the bottom of the dome isn't open though, but something I've been trying to work out. Any help would be greatly appreciated. Thanks!