{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Picking elements of a mesh {#element_picking_example}\n\nThis example demonstrates how to pick different elements on meshes using\n`enable_element_picking() <pyvista.Plotter.enable_element_picking>`{.interpreted-text\nrole=\"func\"}.\n\nThe different elements of a mesh are:\n\n-   Mesh: pick the entire mesh (equivalent to\n    `enable_mesh_picking() <pyvista.Plotter.enable_mesh_picking>`{.interpreted-text\n    role=\"func\"}.)\n-   Cell: pick a cell of the mesh (equivalent to\n    `enable_cell_picking() <pyvista.Plotter.enable_cell_picking>`{.interpreted-text\n    role=\"func\"}.)\n-   Face: pick a single face of a cell on the mesh\n-   Edge: pick a single edge of a cell on the mesh\n-   Point: pick a single point on the mesh\n\nThese types are captured in the\n`pyvista.plotting.opts.ElementType`{.interpreted-text role=\"class\"} enum\nclass.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import pyvista as pv\nfrom pyvista.plotting.opts import ElementType"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Pick Face on Voxel Cell\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "mesh = pv.Wavelet()\n\npl = pv.Plotter()\npl.add_mesh(mesh, show_edges=True, pickable=True)\npl.enable_element_picking(mode=ElementType.FACE)\n\npl.camera_position = [\n    (13.523728057554308, 9.910583926360937, 11.827103195167833),\n    (2.229008884793069, -2.782397236304676, 6.84282248642347),\n    (-0.17641568583704878, -0.21978122178947299, 0.9594653304520027),\n]\n\npl.show(auto_close=False)\n\n# Programmatically pick a face to make example look nice\ntry:\n    width, height = pl.window_size\n    pl.iren._mouse_right_button_press(419, 263)\n    pl.iren._mouse_right_button_release()\nexcept AttributeError:\n    # ignore this section when manually closing the window\n    pass"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Pick an Edge of a Cell\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "sphere = pv.Sphere()\n\npl = pv.Plotter()\npl.add_mesh(sphere, show_edges=True, pickable=True)\npl.enable_element_picking(mode=ElementType.EDGE)\n\npl.camera_position = [\n    (0.7896646029990011, 0.7520805261169909, 0.5148524767495051),\n    (-0.014748048334009667, -0.0257133671899262, 0.07194025085895145),\n    (-0.26016740957025775, -0.2603941863919363, 0.9297891087180916),\n]\n\npl.show(auto_close=False)\n\n# Programmatically pick a face to make example look nice\ntry:\n    width, height = pl.window_size\n    pl.iren._mouse_right_button_press(480, 300)\n    pl.iren._mouse_right_button_release()\nexcept AttributeError:\n    # ignore this section when manually closing the window\n    pass"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.12.2"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}