.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/cow.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_cow.py: Holey Cow --------- Repair a holey cow .. GENERATED FROM PYTHON SOURCE LINES 7-16 .. code-block:: Python import numpy as np # sphinx_gallery_thumbnail_number = 1 import pyvista as pv from pyvista import examples import pymeshfix as mf .. GENERATED FROM PYTHON SOURCE LINES 17-24 .. code-block:: Python cow = examples.download_cow() # Add holes and cast to triangulated PolyData cow["random"] = np.random.rand(cow.n_cells) holy_cow = cow.threshold(0.9, invert=True).extract_geometry().triangulate() print(holy_cow) .. rst-class:: sphx-glr-script-out .. code-block:: none PolyData (0x7fd5474cee00) N Cells: 5185 N Points: 2903 N Strips: 0 X Bounds: -4.446e+00, 5.998e+00 Y Bounds: -3.637e+00, 2.760e+00 Z Bounds: -1.701e+00, 1.701e+00 N Arrays: 1 .. GENERATED FROM PYTHON SOURCE LINES 25-41 .. code-block:: Python # A nice camera location of the cow cpos = [(6.56, 8.73, 22.03), (0.77, -0.44, 0.0), (-0.13, 0.93, -0.35)] meshfix = mf.MeshFix(holy_cow) holes = meshfix.extract_holes() # Render the mesh and outline the holes p = pv.Plotter() p.add_mesh(holy_cow, color=True) p.add_mesh(holes, color="r", line_width=8) p.camera_position = cpos p.enable_eye_dome_lighting() # helps depth perception p.show() .. image-sg:: /examples/images/sphx_glr_cow_001.png :alt: cow :srcset: /examples/images/sphx_glr_cow_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 42-43 Repair the holey cow .. GENERATED FROM PYTHON SOURCE LINES 43-46 .. code-block:: Python meshfix.repair(verbose=True) .. rst-class:: sphx-glr-script-out .. code-block:: none Removed 2 small components Patching holes... Patched 204 holes Fixing degeneracies and intersections .. GENERATED FROM PYTHON SOURCE LINES 47-48 Show the repaired result .. GENERATED FROM PYTHON SOURCE LINES 48-52 .. code-block:: Python repaired = meshfix.mesh print(repaired) .. rst-class:: sphx-glr-script-out .. code-block:: none PolyData (0x7fd5475cd3c0) N Cells: 5422 N Points: 2713 N Strips: 0 X Bounds: -3.696e+00, 5.998e+00 Y Bounds: -3.637e+00, 2.760e+00 Z Bounds: -1.701e+00, 1.701e+00 N Arrays: 0 .. GENERATED FROM PYTHON SOURCE LINES 53-54 .. code-block:: Python repaired.plot(cpos=cpos) .. image-sg:: /examples/images/sphx_glr_cow_002.png :alt: cow :srcset: /examples/images/sphx_glr_cow_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.923 seconds) .. _sphx_glr_download_examples_cow.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: cow.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: cow.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_