<jupyter_start><jupyter_text>How to crop meshesThis notebook shows how a 2D and 3D mesh can be cropped.  2D triangle meshGenerate a 2D sample mesh using the data module.<jupyter_code>from nanomesh.data import blob_mesh2d
mesh = blob_mesh2d(seed=2)
triangles = mesh.get('triangle')
triangles.plot()<jupyter_output>{1, 2}<jupyter_text>Crop the mesh using the `crop()` method. Note that it is not necessary to specify all parameters.<jupyter_code>cropped_triangles = triangles.crop(
    xmin=20,
    xmax=45,
    ymin=12,
    ymax=42,
)
cropped_triangles.plot()<jupyter_output>{1, 2}<jupyter_text>To include partial triangles (i.e. those which lie on the cropping boundaries), use the `include_partial` argument.<jupyter_code>cropped_triangles2 = triangles.crop(
    xmin=20,
    xmax=45,
    ymin=12,
    ymax=42,
    include_partial=True,
)
cropped_triangles2.plot()<jupyter_output>{1, 2}<jupyter_text>3D tetrahedral meshUsing the data submodule, a 3D sample mesh can be generated.<jupyter_code>from nanomesh.data import blob_mesh3d
mesh = blob_mesh3d(opts='-pq1.2Aa', length=10, seed=2)
tetras = mesh.get('tetra')
tetras<jupyter_output><empty_output><jupyter_text>3D meshes can be cropped using the same interface.<jupyter_code>new = tetras.crop(
    xmin=2,
    xmax=8,
    ymin=2,
    ymax=7,
    zmin=2,
    zmax=7
)
new.plot_pyvista(
    jupyter_backend='static',
    show_edges=True,
    cmap=['violet', 'yellow'],
)<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup