VTK/Examples/Python

From KitwarePublic
Jump to navigationJump to search

It would be appreciated if there are any Python VTK experts who could convert any of the c++ examples to Python!

Simple Operations

Example Name VTK Classes Demonstrated Description
Distance between two points vtkMath::Distance2BetweenPoints
Random numbers n/a Random numbers can be generated with Python's random module

Input and Output

Output

Input

Example Name VTK Classes Demonstrated Description
Using STLReader to read an STL file vtkSTLReader
Using vtkVTPReader to read a VTP file vtkXMLPolyDataReader
UnstructuredGridReader.py vtkUnstructuredGridReader

Using vtkUnstructuredGridReader to read a (legacy) *.vtk file

Using vtkFLUENTReader to read a Fluent case file vtkFLUENTReader

Using vtkFLUENTReader to read a Fluent case file and extract the unstructured grid.

Working with Arrays

Example Name VTK Classes Demonstrated Description
Get a value from an array GetTuple3
Rename an array SetName

Geometric Objects

Display

Example Name VTK Classes Demonstrated Description
Compute the intersection of a line segment with a polygon vtkPolygon IntersectWithLine()
A demonstration of all geometric objects that work the same way
Arrow vtkArrowSource
Axes vtkAxesActor
Colored Lines vtkCellData vtkLine
Cone vtkConeSource
Cube vtkCubeSource
Cylinder vtkCylinderSource
Disk vtkDiskSource A circle with a hole in it.
Frustum vtkFrustumSource
Line vtkLineSource
Manually create a polyline vtkLine
Hexahedron vtkHexahedron
Oriented Arrow vtkArrowSource
Plane vtkPlaneSource
Planes vtkPlanes, vtkHull We create a convex hull of the planes for display purposes.
PlanesIntersection vtkPlanesIntersection
PlatonicSolid vtkPlatonicSolidSource All five platonic solids are displayed.
Point vtkPoints
Polygon vtkPolygon
Pyramid vtkPyramid
PolyLine vtkPolyLine This example demonstrates how to create a polygon through several ordered points.
Quad vtkQuad
Regular Polygon vtkRegularPolygonSource
Sphere vtkSphereSource
Triangle vtkTriangle
Triangle strip vtkTriangleStrip
Tetrahedron vtkTetra
Vertex vtkVertex
Display vtkPointSource vtkPointSource
Display text with vtkTextActor vtkTextActor 2D "HUD-type" text
vtkDataSetSurfaceFilter vtkDataSetSurfaceFilter

Parametric Objects

Example Name VTK Classes Demonstrated Description
Create and display a parametric object vtkParametricBoy, vtkParametricConicSpiral, vtkParametricCrossCap, vtkParametricDini, vtkParametricEllipsoid, vtkParametricEnneper, vtkParametricFigure8Klein, vtkParametricKlein, vtkParametricMobius, vtkParametricRandomHills, vtkParametricRoman, vtkParametricSpline, vtkParametricSuperEllipsoid, vtkParametricSuperToroid, vtkParametricTorus

Working with PolyData

Example Name VTK Classes Demonstrated Description
A demonstration of curvatures on a surface vtkCurvatures, vtkColorTransferFunction

Demonstrates how to get the Gaussian and Mean curvatures of a surface.

Draw an outline box around an object vtkOutlineFilter
Rotation around a line with RotateWXYZ vtkTransformPolyDataFilter
Write the corners of a triangle to a file vtkXMLPolyDataWriter
Write the corners of a triangle to a file (+vertices) vtkCellArray
Write a triangle with colored points vtkUnsignedCharArray
Write a colored triangle vtkTriangle
Write a solid colored triangle vtkTriangle
Write a triangle to a file vtkTriangle
Iterative Closest Points (ICP) vtkIterativeClosestPointTransform
Mesh a label image and write cell info to file vtkDiscreteMarchingCubes
Mesh a label image, smooth it and colour it according to the smoothing error vtkDiscreteMarchingCubes
Get a filled polygon from vtkCutter vtkCutter
Create a dotted line vtkActor::GetProperty::SetLineStipplePattern

Miscellaneous

Example Name VTK Classes Demonstrated Description
Screenshot vtkWindowToImageFilter
check VTK version vtkVersion
vtkCutter vtkCutter
vtkImplicitDataSet vtkImplicitDataSet Clip one data set with another
vtkIdType n/a This is just a typedef, so in Python, you can use a python "int" or "long" for vtkIdType.
Using Numpy n/a
vtkVariant vtkVariant

Visualization

Example Name VTK Classes Demonstrated Description
Get a list of the visible triangles vtkHardwareSelector
Display a quadratic surface vtkQuadric
PointSize vtkActor::GetProperty()::SetPointSize
Color an Actor vtkActor::GetProperty()::SetColor
Unstructured Transient Volume Rendering vtkUnstructuredGridVolumeRayCastMapper
Change the title of the render window vtkRenderWindow::SetWindowName
Animation vtkTimerCallback
Create a single render window with muliple viewports vtkRenderer::SetViewport
InteractorStyleTrackBallCamera vtkInteractorStyleTrackBallCamera
InteractorStyleTrackBallActor vtkInteractorStyleTrackBallActor
Camera vtkCamera
Create Text vtkTextSource
Clamp glyph sizes vtkGlyph3D Use vtkGlyph3D with ClampingOn to limit glyph sizes
Use a glyph table vtkGlyph3D Vary the shapes of glyphed points using a glyph table
Named colors vtkNamedColors Demonstrates how to use the vtkNamedColor class
Programmable glyphs vtkProgrammableGlyphFilter Vary the shapes of glyphed points using a programmable glyph filter
Apply a texture to a sphere vtkTextureMapToSphere Apply an ImageData texture to an sphere

Working with vtkImageData

Example Name VTK Classes Demonstrated Description
Summing images vtkImageWeightedSum

Graphs

Example Name VTK Classes Demonstrated Description
Create and visualize a graph vtkMutableDirectedGraph, vtkGraphLayoutView
Add edge weights to a graph vtkMutableDirectedGraph, vtkGraphLayoutView
Get a list of the selected vertices and edges vtkAnnotationLink, vtkGraphLayoutView

User Interaction

Example Name VTK Classes Demonstrated Description
Handle mouse events vtkInteractorStyleTrackballCamera Subclass the interactor style.
Handle mouse events (light weight) vtkCallbackCommand Use an observer.


Infovis

Example Name VTK Classes Demonstrated Description
View Selected Graph IDs vtkRandomGraphSource, vtkGraphLayoutView Callback on vtkAnnotationLink in a Graph Layout View when selection is changed
Parallel Coordinates View vtkParallelCoordinatesView Plotting data attributes in a Parallel Coordinates View
Parallel Coordinates Extraction vtkExtractSelection Extract data based on a selection in a Parallel Coordinates View

Geovis

Example Name VTK Classes Demonstrated Description
vtkGeoAssignCoordinates vtkGeoAssignCoordinates

Widgets

Example Name VTK Classes Demonstrated Description
Balloon Widget vtkBaloonWidget
Annotated cube with vtkOrientationWidget vtkAnnotatedCubeActor vtkOrientationWidget
vtkCompassWidget vtkCompassWidget
Contour widget vtkCotourWidget
TextWidget vtkTextWidget Annotate a VTK image with movable text
ScalarBarWidget vtkScalarBarWidget The ScalarBarWidget displays a scalar bar that is movable and changes orienation automatically when close to the borders of the image. It needs a ScalarBarActor

Utilities

Example Name VTK Classes Demonstrated Description
vtkDelaunay2D vtkDelaunay2D

Broken/Missing Examples

Broken/Missing Python Functionality

Example Name VTK Classes Demonstrated Description
vtkFrustumSource not available in Python ?? It is available, see: Frustum
PointInPolygon not available in Python ?
method FindClosestPoint (and others) of vtkCellLocator not available in Python