<jupyter_start><jupyter_text>Subdivide Cells===============Increase the number of triangles in a single, connected triangular mesh.The `pyvista.PolyDataFilters.subdivide`{.interpreted-text role="func"}filter utilizes three different subdivision algorithms to subdivide amesh\'s cells: [butterfly]{.title-ref}, [loop]{.title-ref}, or[linear]{.title-ref}.<jupyter_code>from pyvista import examples
import pyvista as pv<jupyter_output><empty_output><jupyter_text>First, let\'s load a **triangulated** mesh to subdivide. We can use the`pyvista.DataSetFilters.triangulate`{.interpreted-text role="func"}filter to ensure the mesh we are using is purely triangles.<jupyter_code>mesh = examples.download_bunny_coarse().triangulate()

cpos = [(-0.02788175062966399, 0.19293295656233056, 0.4334449972621349),
 (-0.053260899930287015, 0.08881197167521734, -9.016948161029588e-05),
 (-0.10170607813337212, 0.9686438023715356, -0.22668272496584665)]<jupyter_output><empty_output><jupyter_text>Now, lets do a few subdivisions with the mesh and compare the results.Below is a helper function to make a comparison plot of thee differentsubdivisions.<jupyter_code>def plot_subdivisions(mesh, a, b):
    display_args = dict(show_edges=True, color=True)
    p = pv.Plotter(shape=(3,3))

    for i in range(3):
        p.subplot(i,0)
        p.add_mesh(mesh, **display_args)
        p.add_text("Original Mesh")

    def row_plot(row, subfilter):
        subs = [a, b]
        for i in range(2):
            p.subplot(row, i+1)
            p.add_mesh(mesh.subdivide(subs[i], subfilter=subfilter), **display_args)
            p.add_text(f"{subfilter} subdivision of {subs[i]}")
    row_plot(0, "linear")
    row_plot(1, "butterfly")
    row_plot(2, "loop")

    p.link_views()
    p.view_isometric()
    return p<jupyter_output><empty_output><jupyter_text>Run the subdivisions for 1 and 3 levels.<jupyter_code>plotter = plot_subdivisions(mesh, 1, 3)
plotter.camera_position = cpos
plotter.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12830753869196207, 'fraction_numerical': 0.08686969545681478, 'mean_word_length': 5.072727272727272, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '328202', 'license': 'MIT', 'n_tokens_mistral': 829, 'n_tokens_neox': 709, 'n_words': 149, 'path': 'examples/01-filter/subdivide.ipynb', 'repo_name': 'pyvista/pyvista-examples', 'size': '2003'}