.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/holes.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_holes.py: Holes ~~~~~~~~~~~~ Example of using TetGen to create a tetrahedral mesh with holes. .. GENERATED FROM PYTHON SOURCE LINES 8-32 .. image-sg:: /examples/images/sphx_glr_holes_001.png :alt: holes :srcset: /examples/images/sphx_glr_holes_001.png :class: sphx-glr-single-img .. code-block:: Python import pyvista as pv import tetgen # create a cube with two spheres inside it cube = pv.Cube(x_length=2).triangulate() sphere1 = pv.Sphere(center=[-0.5, 0.0, 0.0], theta_resolution=16, phi_resolution=16, radius=0.25) sphere2 = pv.Sphere(center=[0.5, 0.0, 0.0], theta_resolution=16, phi_resolution=16, radius=0.1) # merge the geometries mesh = pv.merge([cube, sphere1, sphere2]) tgen = tetgen.TetGen(mesh) # add the center of the spheres as holes tgen.add_hole([-0.5, 0.0, 0.0]) tgen.add_hole([0.5, 0.0, 0.0]) # tetrahedralize the mesh using TetGen nodes, elem = tgen.tetrahedralize(switches="pzq1.4") grid = tgen.grid # plot a slice to see the holes grid.clip(normal="z").plot(show_edges=True) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.756 seconds) .. _sphx_glr_download_examples_holes.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: holes.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: holes.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: holes.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_