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

1k Views Asked by At

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:

my generated iso-surface

How it should look like:

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

There are 1 best solutions below

3
On

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)

enter image description here

(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)

enter image description here