VTK/Examples

From KitwarePublic
< VTK
Revision as of 10:11, 21 November 2009 by Daviddoria (talk | contribs) (→‎Widgets)
Jump to navigationJump to search

Example Usage (C++)

These are fully independent, compilable examples. There is significant overlap in the examples, but they are each intended to illustrate a different concept and be fully stand alone compilable.

Please add examples in your areas of expertise!

System Configuration/General Information

Preliminaries

Wrapping

Simple Operations

Input and Output

Input

Output

Geometric Objects

In this section, the object is created, added to a polydata object, then written to a .vtp file. The file can be opened in Paraview to see the result.

Working with 3D Data (vtkPolyData)

Input/Output (Reading/Writing)

Geometry and Topology - Adding Points and Shapes to Polydata

A big confusion among VTK beginners is "I added points to my file - why are there no points when I visualize it??". VTK strongly divides GEOMETRY from TOPOLOGY. What most users would think of as "points" are actually "points + vertices" in VTK. The geometry is ALWAYS simply a list of coordinates - the topology represents the connectedness of these coordinates. If no topology at all is specified, then, as far as VTK is aware, there is NOTHING to show. If you want to see points, you must tell VTK that each point is independent of the rest by creating a vertex (a 0-D topology) at each point. The following examples use a triangle to demonstrate a step at a time how to add geometry and topology to polydata.

  • Triangle - Geometry only - Create a polydata consisting of the three corners of a triangle. There is nothing to visualize as there is no topology.
  • Triangle - Geometry + Vertices - Create a polydata consisting of the three corners of a triangle. A vertex is added at each point so there is now 3 "points" for the user to see. This is 0-D topology.
  • Triangle - Geometry + Lines - Create a polydata consisting of three corners of a triangle. A line is added between each point. This is 1-D topology.
  • Triangle - Geometry + Polygon - Create a polydata consisting of three corners of a triangle. A polygon (in this case, a triangle) is added on the three points. This is 2-D topology.

Adding Colors to Polydata

Adding Normals to Polydata

Non-standard Data

These examples show how to attach your own, nonstandard fields to every point or cell in a polydata.

Point cloud operations

Miscellaneous (Field) Data

Three types of data can be stored in a polydata object, PointData, CellData, and FieldData. For PointData, there must be a piece of data associated with each point (e.g. a temperature data array with the temperature at each point). For CellData, there must be a piece of data associated with each cell (e.g. the area of each triangle). For data that does not align with either points or cells, FieldData should be used. This is typically data that describes the dataset as a whole. An example could be the name of the dataset, or the center of mass of the points, etc.

Global Operations on PolyData

Working with Stuctured (grid aligned) 3D Data (vtkImageData)

Utilities

Graphs

Data Structures

Filters

Visualization

See [this] for a brief explanation of the VTK terminology of mappers, actors, etc.

User Interaction

Selecting in 3D (Picking)

Working with Images

Working with Meshes

Using VTK Classes as Member Variables

Widgets

Needed/Missing Examples!

  • vtkVolumeRayCastMapper - any example of raycast/volume rendering
  • vtkApplyColors - How is this different from just adding a Colors array to a vtkDataSet?

Example Usage (Python)

Getting Started

Working with PolyData