<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>
{'fraction_non_alphanumeric': 0.11164713990351481, 'fraction_numerical': 0.03239145416953825, 'mean_word_length': 5.3406113537117905, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '239277', 'license': 'Apache-2.0', 'n_tokens_mistral': 588, 'n_tokens_neox': 553, 'n_words': 124, 'path': 'notebooks/examples/how_to_crop_meshes.ipynb', 'repo_name': 'hpgem/nanomesher', 'size': '1451'}