
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "gallery/scene/isocurve_for_trisurface.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_gallery_scene_isocurve_for_trisurface.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_gallery_scene_isocurve_for_trisurface.py:


Isocurve for Triangular Mesh 
============================

This example demonstrates isocurve for triangular mesh with vertex data.

.. GENERATED FROM PYTHON SOURCE LINES 13-49



.. image-sg:: /gallery/scene/images/sphx_glr_isocurve_for_trisurface_001.png
   :alt: isocurve for trisurface
   :srcset: /gallery/scene/images/sphx_glr_isocurve_for_trisurface_001.png
   :class: sphx-glr-single-img





.. code-block:: Python


    import numpy as np

    from vispy import app, scene

    from vispy.geometry.generation import create_sphere

    import sys

    # Create a canvas with a 3D viewport
    canvas = scene.SceneCanvas(keys='interactive',
                               title='Isocurve for Triangular Mesh Example')
    canvas.show()
    view = canvas.central_widget.add_view()

    cols = 10
    rows = 10
    radius = 2
    nbr_level = 20
    mesh = create_sphere(cols, rows, radius=radius)
    vertices = mesh.get_vertices()
    tris = mesh.get_faces()

    cl = np.linspace(-radius, radius, nbr_level+2)[1:-1]

    scene.visuals.Isoline(vertices=vertices, tris=tris, data=vertices[:, 2],
                          levels=cl, color_lev='winter', parent=view.scene)

    # Add a 3D axis to keep us oriented
    scene.visuals.XYZAxis(parent=view.scene)

    view.camera = scene.TurntableCamera()
    view.camera.set_range((-1, 1), (-1, 1), (-1, 1))

    if __name__ == '__main__' and sys.flags.interactive == 0:
        app.run()


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 0.466 seconds)


.. _sphx_glr_download_gallery_scene_isocurve_for_trisurface.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: isocurve_for_trisurface.ipynb <isocurve_for_trisurface.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: isocurve_for_trisurface.py <isocurve_for_trisurface.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: isocurve_for_trisurface.zip <isocurve_for_trisurface.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
