Is there a way to fill one side of the gyroid surface by using Mayavi?

心不动则不痛 提交于 2021-02-05 09:22:31

问题


I'm using Mayavi to plot an iso-surface of a gyroid. My problem is that I need a more solid structure by filling one side of the two generated areas. In the following pictures, you can see how my generated iso-surface looks like and how it should look like after filling one side.

My generated iso-surface:

How it should look like:

The iso-surface can be generated by the following equation:

U = sin(2*pi * x/a) * cos(2*pi * y/a) + sin(2*pi * y/a) * cos(2*pi * z/a) \
    + sin(2*pi * z/a) * cos(2*pi * x/a)

I plotted the iso-surface = 0 by using this: mlab.contour3d(U, contours=[0])

I hope somebody can help me out.


回答1:


Using vedo:

from vedo import *
import numpy as np

a = 15
pi = np.pi
x, y, z = np.mgrid[:30, :30, :30]/a
U =   sin(2*pi* x) * cos(2*pi* y) + sin(2*pi* y) * cos(2*pi* z) \
    + sin(2*pi* z) * cos(2*pi* x)
iso = Volume(U).isosurface(0)
plane = Grid(sx=29,sy=29, pos=(14.5,14.5,0), resx=200, resy=200)
cpln = plane.cutWithMesh(iso).wireframe(0).c('tomato').lw(0)
show(iso, cpln, axes=1)

(note that the red-tomato "cap" is effectively a different mesh)

PS: you can also use CubicGrid(n=(29,29,29), spacing=(1,1,1), alpha=1) (instead of 6 planes). E.g.:

iso = Volume(U).isosurface(0).smoothLaplacian().c('silver').lw(1)
cube = CubicGrid(n=(29,29,29), spacing=(1,1,1))
cube.cutWithMesh(iso).c('silver').alpha(1)
show(iso, cube)



来源:https://stackoverflow.com/questions/64480835/is-there-a-way-to-fill-one-side-of-the-gyroid-surface-by-using-mayavi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!