|
1 | 1 | { |
2 | | - "metadata": {}, |
3 | | - "nbformat": 3, |
4 | | - "nbformat_minor": 0, |
5 | | - "worksheets": [ |
| 2 | + "cells": [ |
6 | 3 | { |
7 | | - "cells": [ |
8 | | - { |
9 | | - "cell_type": "markdown", |
10 | | - "metadata": {}, |
11 | | - "source": [ |
12 | | - "Mayavi tvtk\n", |
13 | | - "===========\n", |
14 | | - "\n", |
15 | | - "||\\<\\#80FF80\\> This page is not the main source of documentation. You\n", |
16 | | - "are invited to refer to the [Mayavi2 home\n", |
17 | | - "page](http://enthought.github.com/mayavi/mayavi) for up-to-date\n", |
18 | | - "documentation on TVTK. In particular, bear in mind that if you are\n", |
19 | | - "looking for a high-level Python 3D plotting library, Mayavi also\n", |
20 | | - "provides the right API, and can be embedded (see the [user\n", |
21 | | - "guide](http://enthought.github.com/mayavi/mayavi/building_applications.html)).\n", |
22 | | - "||" |
23 | | - ] |
24 | | - }, |
25 | | - { |
26 | | - "cell_type": "markdown", |
27 | | - "source": [ |
28 | | - "What is tvtk?\n", |
29 | | - "=============\n", |
30 | | - "\n", |
31 | | - "``tvtk`` is a `traits <http://www.enthought.com/traits>`_ \n", |
32 | | - "enabled version of `VTK <http://www.vtk.org>`_\n", |
33 | | - "for 3D graphics and visualization.\n", |
34 | | - "\n", |
35 | | - "It provides an exact match to the VTK objects, but with a Pythonic feel, unlike `Mayavi <http://code.enthought.com/projects/mayavi>`_ which aims to provide new APIs\n", |
36 | | - "\n", |
37 | | - "Most important features are\n", |
38 | | - "\n", |
39 | | - "* All VTK classes are wrapped.\n", |
40 | | - "* Support for traits.\n", |
41 | | - "* Elementary pickle support.\n", |
42 | | - "* Pythonic feel.\n", |
43 | | - "* Handles numpy/Numeric/numarray arrays/Python lists transparently.\n", |
44 | | - "* Support for a pipeline browser, `ivtk` \n", |
45 | | - "* High-level `mlab` module.\n", |
46 | | - "* Envisage plugins for a tvtk scene and the pipeline browser.\n", |
47 | | - "* MayaVi2 is built on top of tvtk\n", |
48 | | - "\n", |
49 | | - "See the `enthought TVTK page <http://www.enthought.com/enthought/wiki/TVTK>`_ for more details,\n", |
50 | | - "in particular the `tvtk introduction <http://www.enthought.com/enthought/wiki/TVTKIntroduction>`_.\n", |
51 | | - "\n", |
52 | | - "tvtk examples\n", |
53 | | - "-------------\n", |
54 | | - "\n", |
55 | | - "cone\n", |
56 | | - "````\n", |
57 | | - "\n", |
58 | | - "The following example displays a cone which can be rotated/scaled/... with the mouse.\n", |
59 | | - "[Simple_tvtk_cone.py](files/attachments/MayaVi_tvtk/Simple_tvtk_cone.py)\n", |
60 | | - "\n", |
61 | | - "quadrics\n", |
62 | | - "````````\n", |
63 | | - "\n", |
64 | | - "A more interesting example is the generation of some contour surfaces of an implicit function.\n", |
65 | | - "#[Vis_quad.py](files/attachments/MayaVi_tvtk/Vis_quad.py)\n", |
66 | | - "\n", |
67 | | - "This displays the following scene on screen and also saves it to a file.\n", |
68 | | - "\n", |
69 | | - "\n", |
70 | | - "\n", |
71 | | - "\n", |
72 | | - "ivtk\n", |
73 | | - "----\n", |
74 | | - "\n", |
75 | | - "The module `tools.ivtk` makes VTK/TVTK easier to use from the Python\n", |
76 | | - "interpreter. \n", |
77 | | - "For example, start IPython with::\n", |
78 | | - "\n", |
79 | | - " ipython -wthread \n", |
80 | | - "\n", |
81 | | - "(if you have both wxPython 2.4 and wxPython 2.6 installed you will need a recent IPython\n", |
82 | | - "and do ``ipython -wthread -wxversion 2.6``)." |
83 | | - ], |
84 | | - "metadata": {} |
85 | | - }, |
86 | | - { |
87 | | - "cell_type": "markdown", |
88 | | - "metadata": {}, |
89 | | - "source": [ |
90 | | - "Then you can paste the following lines:" |
91 | | - ] |
92 | | - }, |
93 | | - { |
94 | | - "cell_type": "code", |
95 | | - "collapsed": false, |
96 | | - "input": [ |
97 | | - " from enthought.tvtk.tools import ivtk\n", |
98 | | - " from enthought.tvtk.api import tvtk\n", |
99 | | - " # Create a cone:\n", |
100 | | - " cs = tvtk.ConeSource(resolution=100)\n", |
101 | | - " mapper = tvtk.PolyDataMapper(input=cs.output)\n", |
102 | | - " actor = tvtk.Actor(mapper=mapper)\n", |
103 | | - "\n", |
104 | | - " # Now create the viewer:\n", |
105 | | - " v = ivtk.IVTKWithCrustAndBrowser(size=(600,600))\n", |
106 | | - " v.open()\n", |
107 | | - " v.scene.add_actors(actor) # or v.scene.add_actor(a)" |
108 | | - ], |
109 | | - "language": "python", |
110 | | - "metadata": {}, |
111 | | - "outputs": [] |
112 | | - }, |
113 | | - { |
114 | | - "cell_type": "markdown", |
115 | | - "collapsed": false, |
116 | | - "source": [ |
117 | | - "You can then explore the visualization pipeline and modify any settings.\n", |
118 | | - "\n", |
119 | | - "\n", |
120 | | - ")\n", |
121 | | - "\n", |
122 | | - "For creating the viewer there are different options:\n", |
123 | | - "\n", |
124 | | - "- ``v = ivtk.viewer()`` - this one does not need the ``v.open()`` and the ``size=(600,600)``\n", |
125 | | - "- ``v = ivtk.IVTK()``\n", |
126 | | - "- ``v = ivtk.IVTKWithCrust()``\n", |
127 | | - "- ``v = ivtk.IVTKWithBrowser()``\n", |
128 | | - "- ``v = ivtk.IVTKWithCrustAndBrowser)``\n", |
129 | | - "\n", |
130 | | - "For viewers with `Crust` you can use the python command line window to modify the pipeline." |
131 | | - ], |
132 | | - "metadata": {} |
133 | | - } |
134 | | - ], |
135 | | - "metadata": {} |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": {}, |
| 6 | + "source": [ |
| 7 | + "Mayavi tvtk\n", |
| 8 | + "===========\n", |
| 9 | + "\n", |
| 10 | + "||\\<\\#80FF80\\> This page is not the main source of documentation. You\n", |
| 11 | + "are invited to refer to the [Mayavi2 home\n", |
| 12 | + "page](http://enthought.github.com/mayavi/mayavi) for up-to-date\n", |
| 13 | + "documentation on TVTK. In particular, bear in mind that if you are\n", |
| 14 | + "looking for a high-level Python 3D plotting library, Mayavi also\n", |
| 15 | + "provides the right API, and can be embedded (see the [user\n", |
| 16 | + "guide](http://enthought.github.com/mayavi/mayavi/building_applications.html)).\n", |
| 17 | + "||" |
| 18 | + ] |
| 19 | + }, |
| 20 | + { |
| 21 | + "cell_type": "markdown", |
| 22 | + "metadata": {}, |
| 23 | + "source": [ |
| 24 | + "What is tvtk?\n", |
| 25 | + "=============\n", |
| 26 | + "\n", |
| 27 | + "``tvtk`` is a `traits <http://www.enthought.com/traits>`_ \n", |
| 28 | + "enabled version of `VTK <http://www.vtk.org>`_\n", |
| 29 | + "for 3D graphics and visualization.\n", |
| 30 | + "\n", |
| 31 | + "It provides an exact match to the VTK objects, but with a Pythonic feel, unlike `Mayavi <http://code.enthought.com/projects/mayavi>`_ which aims to provide new APIs\n", |
| 32 | + "\n", |
| 33 | + "Most important features are\n", |
| 34 | + "\n", |
| 35 | + "* All VTK classes are wrapped.\n", |
| 36 | + "* Support for traits.\n", |
| 37 | + "* Elementary pickle support.\n", |
| 38 | + "* Pythonic feel.\n", |
| 39 | + "* Handles numpy/Numeric/numarray arrays/Python lists transparently.\n", |
| 40 | + "* Support for a pipeline browser, `ivtk` \n", |
| 41 | + "* High-level `mlab` module.\n", |
| 42 | + "* Envisage plugins for a tvtk scene and the pipeline browser.\n", |
| 43 | + "* MayaVi2 is built on top of tvtk\n", |
| 44 | + "\n", |
| 45 | + "See the `enthought TVTK page <http://www.enthought.com/enthought/wiki/TVTK>`_ for more details,\n", |
| 46 | + "in particular the `tvtk introduction <http://www.enthought.com/enthought/wiki/TVTKIntroduction>`_.\n", |
| 47 | + "\n", |
| 48 | + "tvtk examples\n", |
| 49 | + "-------------\n", |
| 50 | + "\n", |
| 51 | + "cone\n", |
| 52 | + "````\n", |
| 53 | + "\n", |
| 54 | + "The following example displays a cone which can be rotated/scaled/... with the mouse.\n", |
| 55 | + "[Simple_tvtk_cone.py](files/attachments/MayaVi_tvtk/Simple_tvtk_cone.py)\n", |
| 56 | + "\n", |
| 57 | + "quadrics\n", |
| 58 | + "````````\n", |
| 59 | + "\n", |
| 60 | + "A more interesting example is the generation of some contour surfaces of an implicit function.\n", |
| 61 | + "#[Vis_quad.py](files/attachments/MayaVi_tvtk/Vis_quad.py)\n", |
| 62 | + "\n", |
| 63 | + "This displays the following scene on screen and also saves it to a file.\n", |
| 64 | + "\n", |
| 65 | + "\n", |
| 66 | + "\n", |
| 67 | + "\n", |
| 68 | + "ivtk\n", |
| 69 | + "----\n", |
| 70 | + "\n", |
| 71 | + "The module `tools.ivtk` makes VTK/TVTK easier to use from the Python\n", |
| 72 | + "interpreter. \n", |
| 73 | + "For example, start IPython with::\n", |
| 74 | + "\n", |
| 75 | + " ipython -wthread \n", |
| 76 | + "\n", |
| 77 | + "(if you have both wxPython 2.4 and wxPython 2.6 installed you will need a recent IPython\n", |
| 78 | + "and do ``ipython -wthread -wxversion 2.6``)." |
| 79 | + ] |
| 80 | + }, |
| 81 | + { |
| 82 | + "cell_type": "markdown", |
| 83 | + "metadata": {}, |
| 84 | + "source": [ |
| 85 | + "Then you can paste the following lines:" |
| 86 | + ] |
| 87 | + }, |
| 88 | + { |
| 89 | + "cell_type": "code", |
| 90 | + "execution_count": null, |
| 91 | + "metadata": { |
| 92 | + "collapsed": false |
| 93 | + }, |
| 94 | + "outputs": [], |
| 95 | + "source": [ |
| 96 | + " from enthought.tvtk.tools import ivtk\n", |
| 97 | + " from enthought.tvtk.api import tvtk\n", |
| 98 | + " # Create a cone:\n", |
| 99 | + " cs = tvtk.ConeSource(resolution=100)\n", |
| 100 | + " mapper = tvtk.PolyDataMapper(input=cs.output)\n", |
| 101 | + " actor = tvtk.Actor(mapper=mapper)\n", |
| 102 | + "\n", |
| 103 | + " # Now create the viewer:\n", |
| 104 | + " v = ivtk.IVTKWithCrustAndBrowser(size=(600,600))\n", |
| 105 | + " v.open()\n", |
| 106 | + " v.scene.add_actors(actor) # or v.scene.add_actor(a)" |
| 107 | + ] |
| 108 | + }, |
| 109 | + { |
| 110 | + "cell_type": "markdown", |
| 111 | + "metadata": {}, |
| 112 | + "source": [ |
| 113 | + "You can then explore the visualization pipeline and modify any settings.\n", |
| 114 | + "\n", |
| 115 | + "\n", |
| 116 | + ")\n", |
| 117 | + "\n", |
| 118 | + "For creating the viewer there are different options:\n", |
| 119 | + "\n", |
| 120 | + "- ``v = ivtk.viewer()`` - this one does not need the ``v.open()`` and the ``size=(600,600)``\n", |
| 121 | + "- ``v = ivtk.IVTK()``\n", |
| 122 | + "- ``v = ivtk.IVTKWithCrust()``\n", |
| 123 | + "- ``v = ivtk.IVTKWithBrowser()``\n", |
| 124 | + "- ``v = ivtk.IVTKWithCrustAndBrowser)``\n", |
| 125 | + "\n", |
| 126 | + "For viewers with `Crust` you can use the python command line window to modify the pipeline." |
| 127 | + ] |
| 128 | + } |
| 129 | + ], |
| 130 | + "metadata": { |
| 131 | + "kernelspec": { |
| 132 | + "display_name": "Python 3", |
| 133 | + "language": "python", |
| 134 | + "name": "python3" |
| 135 | + }, |
| 136 | + "language_info": { |
| 137 | + "codemirror_mode": { |
| 138 | + "name": "ipython", |
| 139 | + "version": 3 |
| 140 | + }, |
| 141 | + "file_extension": ".py", |
| 142 | + "mimetype": "text/x-python", |
| 143 | + "name": "python", |
| 144 | + "nbconvert_exporter": "python", |
| 145 | + "pygments_lexer": "ipython3", |
| 146 | + "version": "3.5.2" |
136 | 147 | } |
137 | | - ] |
| 148 | + }, |
| 149 | + "nbformat": 4, |
| 150 | + "nbformat_minor": 0 |
138 | 151 | } |
0 commit comments