.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/Lattices/preset_lattices.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_Lattices_preset_lattices.py: Preset strut lattices ===================== The twelve preset strut-based lattices of :mod:`microgen.shape.strut_lattice`, with a strut radius of 0.1. Each lattice is turned into one implicit shape with :meth:`~microgen.AbstractLattice.generate_implicit` (union of the struts and joints, clipped by the unit cell) and meshed by marching cubes, without the CAD backend. .. GENERATED FROM PYTHON SOURCE LINES 13-46 .. code-block:: Python import pyvista as pv from microgen import ( BodyCenteredCubic, Cubic, Cuboctahedron, Diamond, FaceCenteredCubic, Octahedron, OctetTruss, RhombicCuboctahedron, RhombicDodecahedron, TruncatedCube, TruncatedCuboctahedron, TruncatedOctahedron, ) preset_lattice_list = [ BodyCenteredCubic(strut_radius=0.1), Cubic(strut_radius=0.1), Cuboctahedron(strut_radius=0.1), Diamond(strut_radius=0.1), FaceCenteredCubic(strut_radius=0.1), Octahedron(strut_radius=0.1), OctetTruss(strut_radius=0.1), RhombicCuboctahedron(strut_radius=0.1), RhombicDodecahedron(strut_radius=0.1), TruncatedCube(strut_radius=0.1), TruncatedCuboctahedron(strut_radius=0.1), TruncatedOctahedron(strut_radius=0.1), ] .. GENERATED FROM PYTHON SOURCE LINES 47-48 One subplot per lattice, on a 3 x 4 grid. .. GENERATED FROM PYTHON SOURCE LINES 48-60 .. code-block:: Python bounds = (-0.5, 0.5, -0.5, 0.5, -0.5, 0.5) N_COL = 4 pl = pv.Plotter(shape=(3, N_COL), window_size=(1200, 900), border=False) for i, lattice in enumerate(preset_lattice_list): mesh = lattice.generate_implicit().generate_surface_mesh( bounds=bounds, resolution=80 ) pl.subplot(i // N_COL, i % N_COL) pl.add_text(type(lattice).__name__, font_size=8) pl.add_mesh(mesh, color="#ef7d2d", smooth_shading=True) pl.link_views() pl.show() .. image-sg:: /examples/Lattices/images/sphx_glr_preset_lattices_001.png :alt: preset lattices :srcset: /examples/Lattices/images/sphx_glr_preset_lattices_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 6.057 seconds) .. _sphx_glr_download_examples_Lattices_preset_lattices.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: preset_lattices.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: preset_lattices.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: preset_lattices.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_