Open derrick-xwp opened 1 year ago
if name == "main":
cache={}
badset=set()
x, y, z = pi*np.mgrid[-1:1:31j, -1:1:31j, -1:1:31j]
vol = cos(x) + cos(y) + cos(z)
iso_val=-2.0
verts,faces=getContourSegments(iso_val,vol)
celltypes = np.empty(faces.shape[0], dtype=np.uint8)
celltypes[:] = vtk.VTK_TRIANGLE
grid = pv.UnstructuredGrid(faces.ravel(), celltypes, verts)
# call itkwidget
view(geometries=grid)
fig = plt.figure(figsize=(10, 10))
ax = fig.add_subplot(111, projection='3d')
verts[faces]
to generate a collection of triangles
mesh = Poly3DCollection(verts[faces])
mesh.set_edgecolor('k')
ax.add_collection3d(mesh)
ax.set_xlabel("x-axis: a = 6 per ellipsoid")
ax.set_ylabel("y-axis: b = 10")
ax.set_zlabel("z-axis: c = 16")
ax.set_xlim(0, 24) # a = 6 (times two for 2nd ellipsoid)
ax.set_ylim(0, 20) # b = 10
ax.set_zlim(0, 32) # c = 16
plt.tight_layout()
plt.show()
Hi,
I tried to visualize the extracted mesh from your code in the notebook, but I got the below figure.