.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/3Doperations/voronoi_gyroid.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_3Doperations_voronoi_gyroid.py: Voronoi gyroid ============== Intersect each cell of a Voronoi tessellation with a gyroid sheet, then mesh the resulting phases with gmsh. Requires the CAD backend: ``pip install microgen[cad]``. .. GENERATED FROM PYTHON SOURCE LINES 10-43 .. code-block:: Python from microgen import Neper, Phase, Tpms, mesh from microgen.cad import make_compound from microgen.shape import surface_functions tess_file = "voronoi.tess" polyhedra = Neper.voronoi_from_tess_file(tess_file) gyroid = Tpms( center=(0.5, 0.5, 0.5), surface_function=surface_functions.gyroid, offset=0.2, ) gyroid = gyroid.generate_cad(type_part="sheet") phases = [] for polyhedron in polyhedra: shape = polyhedron.generate_cad() phases.append(Phase.from_cad(shape.intersect(gyroid))) compound = make_compound([phase.cad for phase in phases]) step_file = "voronoi_gyroid.step" compound.export_step(step_file) vtk_file = "voronoi_gyroid.vtk" mesh( mesh_file=step_file, list_phases=phases, size=0.05, order=1, output_file=vtk_file, ) .. GENERATED FROM PYTHON SOURCE LINES 44-47 .. image:: /_static/examples/Gyroid-voro.png sphinx_gallery_thumbnail_path = "_static/examples/Gyroid-voro.png" .. _sphx_glr_download_examples_3Doperations_voronoi_gyroid.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: voronoi_gyroid.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: voronoi_gyroid.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: voronoi_gyroid.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_