Difference between revisions of "VTK/Examples"

From KitwarePublic
< VTK
Jump to navigationJump to search
(Undo revision 62870 by Lorensen (talk))
 
Line 1: Line 1:
==Example Usage (C++)==
+
[[Category:VTK/Examples]]
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 try the new [https://lorensen.github.io/VTKExamples/site VTKExamples website].''' =
 
 
Please add examples in your areas of expertise!
 
 
 
===System Configuration/General Information===
 
* [[Which Libraries Do I Link To?]]
 
* [[Which Header Files Do I Include?]]
 
* [[Typical CMakeLists.txt file]]
 
* [[Environment Setup]]
 
* [[http://scv.bu.edu/documentation/tutorials/VTK/#INTRO A nice tutorial]]
 
 
 
===Preliminaries===
 
* [[Smart Pointers]]
 
* [[vtkIdType]]
 
* [[Casting VTK objects]]
 
 
 
===Wrapping===
 
* [[VTK/Java Wrapping|Java]]
 
* [[Python Wrapping FAQ|Python]]
 
 
 
===Simple Operations===
 
* [[Distance between two points]]
 
* [[Random number (uniform distribution)]]
 
* [[Random number (Gaussian distribution)]]
 
 
 
===Input and Output===
 
====Input====
 
* [[Read a simple "xyz" file of points]]
 
* [[Read a plain text file into a polydata]]
 
* [[Read a delimited file into a polydata]]
 
* [[Read a VTU file]]
 
* [[Read an OBJ File]]
 
* [[Convert a series of DICOM files into a VTI File]]
 
* [[VRML (WRL)]]
 
* [[Read DICOM file]]
 
 
 
====Output====
 
* [[Write a VTU file]]
 
 
 
=== 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.
 
 
 
* [[Point]]
 
* [[Line]]
 
* [[Add colored lines to a Polydata]]
 
* [[Plane]]
 
* [[Triangle (on large point array)]]
 
* [[Triangle (self contained)]]
 
* [[Sphere]]
 
* [[Cube]]
 
* [[Polygon]]
 
 
 
=== Working with 3D Data (vtkPolyData) ===
 
* [[Convex hull]]
 
* [[Check if a point is inside an object]]
 
* [[Check if a point is inside an object (alternate method)]] - this uses a Delaunay triangulation to compute a volume. This gives more of an "is inside convex hull" effect than an "is inside object"
 
 
 
==== Input/Output (Reading/Writing) ====
 
* [[Read a .vtp file]]
 
* [[Write a .vtp file]]
 
 
 
==== 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 ====
 
* [[Colored Points]] - Add three points to a polydata and associate a color with each of them.
 
* [[Triangle - Colored Points]] - Set the color of each point of a triangle. You will be able to interpolate the colors across the triangle.
 
* [[Triangle - Solid Color]] - Create a solid colored triangle.
 
 
 
==== Adding Normals to Polydata ====
 
* [[Add/Get Normals to/from a Cells in a Polydata]]
 
* [[Add/Get Normals to/from a Points in a Polydata]]
 
 
 
==== Non-standard Data ====
 
These examples show how to attach your own, nonstandard fields to every point or cell in a polydata.
 
 
 
* [[Add Miscellaneous Data to Points in a Polydata]]
 
* [[Get Miscellaneous Data from Points in a Polydata]]
 
* [[Add Miscellaneous Data to Cells in a Polydata]]
 
* [[Get Miscellaneous Data from Cells in a Polydata]]
 
 
 
==== Point cloud operations ====
 
* [[Downsample a point cloud]] - remove points so that there are no points within a tolerance of any point.
 
 
 
==== 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.
 
 
 
* Using FieldData [[Add Global Miscellaneous Data to a Polydata]]
 
 
 
==== Global Operations on PolyData ====
 
* [[Extract Normals from a Polydata]]
 
* [[Get the names of all of the data arrays]]
 
* [[Determine data types of arrays]]
 
* [[Embed points into a volume]]
 
 
 
=== Working with Stuctured (grid aligned) 3D Data (vtkImageData) ===
 
* [[Iterating over a vtkImageData]]
 
* [[Structured Grid]]
 
 
 
===Utilities===
 
* [[Color Lookup Table]]
 
* [[Construct a Table]] - A table is a 2D array of any type of elements. They do not all have to be the same type. This is achieved using vtkVariant.
 
* [[Delaunay Triangulation (2D)]] - Perform a 2D Delaunay triangulation on a point set.
 
* [[Constrained Delaunay Triangulation (2D)]] - Perform a 2D Delaunay triangulation on a point set respecting a specified boundary.
 
* [[Compute eigenvalues and eigenvectors of a symmetric matrix]]
 
* [[Known Length Array]]
 
* [[Unknown Length Array]]
 
* [[Array of Vectors (Known Length)]]
 
* [[Array of Vectors (Unknown Length)]]
 
* [[2D Array]]
 
* [[Custom type 2D Array]]
 
* [[Determine the type of a VTK variable]]
 
* [[Screenshot]]
 
* [[Least Squares]]
 
* [[Homogeneous Least Squares]]
 
* [[Quadric Surface Fitting]]
 
 
 
===Graphs===
 
* [[Construct a graph]]
 
* [[Minimum spanning tree of a graph]]
 
* [[Depth First Search iterator]]
 
* [[Visualize a graph]]
 
* [[Label vertices and edges]]
 
* [[Find Connected Components]]
 
* [[Convert a graph to a PolyData]]
 
 
 
===Data Structures===
 
* [[KDTree]]
 
* [[Create a KDTree]]
 
* [[KDTree - Closest Point]]
 
* [[KDTree - Closest Point (vtkKDTreePointLocator)]]
 
* [[KDTree - Closest N Points]]
 
* [[OBBTree]] - Oriented Bounding Box Tree
 
* [[Generate a mesh of each level of a KDTree]]
 
* [[Generate a mesh of each level of an OBBTree]]
 
 
 
===Filters===
 
* [[Apply a Transformation to Points]]
 
* [[Landmark Transform]]
 
* [[Iterative Closest Points (ICP) Transform]]
 
* [[Triangulate a Terrain Map]]
 
* [[Create a surface from Unorganized Points]]
 
* [[Create a surface from Unorganized Points (Gaussian Splat)]]
 
* [[Create models from labeled volume data (Discrete MarchingCubes)]]
 
* [[Create cubes from labeled volume data]]
 
 
 
===Visualization===
 
See [[http://www.cs.uic.edu/~jbell/CS526/Tutorial/Mappers.html this]] for a brief explanation of the VTK terminology of mappers, actors, etc.
 
 
 
* [[Visualize a Sphere]]
 
* [[Visualize a VTP File]]
 
* [[Visualize a 2D Set of Points]]
 
* [[Display coordinate axes]]
 
* [["Trackball" mode]]
 
* [[Display text]]
 
* [[Texture map a plane]]
 
* [[Texture map a quad]]
 
* [[Moving an Actor]]
 
* [[Moving the Camera]]
 
* [[Multiple Actors]]
 
* [[A little bit easier rendering]]
 
* [[Hide an actor]]
 
* [[Hide all actors]]
 
 
 
===User Interaction===
 
* [[Handle keypress events]]
 
* [[Handle mouse events]]
 
 
 
===Selecting in 3D (Picking)===
 
* [[Plane Picking]]
 
 
 
===Working with Images===
 
* [[Read/Write JPG]]
 
* [[Read/Write PNG]]
 
* [[Display a static image]] - this will display the image, but not allow you to interact with it.
 
* [[Visualize and interact with an image]]
 
* [[Select a region of the window]]
 
 
 
===Working with Meshes===
 
* [[Decimation]] - Reduce the number of triangles in a mesh.
 
* [[Subdivision]] - Increase the number of triangles in a mesh.
 
* [[Finding Boundary Edges]] - Find the edges that are used by only one face.
 
 
 
===Using VTK Classes as Member Variables===
 
* [[Non-SmartPointer Member Variable]]
 
* [[Non-SmartPointer Template Member Variable]]
 
* [[SmartPointer Member Variable]]
 
 
 
===Widgets===
 
* [[Slider]]
 
 
 
===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===
 
* [[How do I setup my environment? (python)]]
 
 
 
===Working with PolyData===
 
* [[Write the corners of a triangle to a file (python)]]
 
* [[Write the corners of a triangle to a file (+vertices) (python)]]
 
* [[Write a triangle with colored points (python)]]
 
* [[Write a colored triangle (python)]]
 
* [[Write a solid colored triangle (python)]]
 
* [[Write a triangle to a file (python)]]
 
* [[Iterative Closest Points (ICP) (python)]]
 

Latest revision as of 20:20, 6 August 2018

Please try the new VTKExamples website.