From KitwarePublic
< VTK‎ | Examples
Jump to navigationJump to search

I just started to maintain this page. So stay tuned. In the near future you will find useful examples here from time to time.
A tutorial on how to setup a Windows Forms Application utilizing ActiViz.NET can be found here: Setup a Windows Forms Application to use ActiViz.NET

Simple Operations

Example Name VTK Classes Demonstrated Description
DistancePointToLine Distance between a point and a line vtkLine
DistanceBetweenPoints Distance between two points vtkMath::Distance2BetweenPoints Computes the distance between two points
UniformRandomNumber Random number (uniform distribution) vtkMath Generates uniform random numbers
GaussianRandomNumber Random number (Gaussian distribution) vtkMath Generates Gaussian random numbers
RandomSequence Random sequence vtkMinimalStandardRandomSequence This is the preferred way to generate random numbers.
ProjectPointPlane Project a point onto a plane vtkPlane Project a point onto a plane
PerspectiveTransform Apply a perspective transformation to a point vtkPerspectiveTransform

Input and Output

Graph Formats

3D File Formats

Example Name VTK Classes Demonstrated Description
ConvertFile Convert a file from one type to another
XGMLReader Read a .gml file vtkXGMLReader

Standard Formats

Example Name VTK Classes Demonstrated Description
SimplePointsReader Read a simple "xyz" file of points vtkSimplePointsReader
ParticleReader Read an "xyza" file vtkParticleReader This example reads ascii files where each line consists of points with its position (x,y,z) and (optionally) one scalar or binary files in RAW 3d file format
ReadPlainText Read a plain text file into a polydata vtkPolyData Manually read a file using a streamreader
ReadOBJ Read an OBJ (.obj) File vtkOBJReader
ReadDICOMSeries Convert a series of DICOM files into a VTI File vtkDICOMImageReader This example demonstates how to read a series of DICOM images and scroll through slices
VRML Read a VRML (WRL) file vtkVRMLImporter
DumpXMLFile Report the contents of a VTK XML or legacy file vtkDataSetReader
DEMReader Read DEM (elevation map) files vtkDEMReader
ReadSTL Read stereo lithography STL (.stl) files vtkSTLReader
ReadPLY Read PLY (.ply) files vtkPLYReader
ReadPLOT3D Read PLOT3D (.bin) files vtkPLOT3DReader Read CFD (computational fluid dynamics) data produced by PLOT3D.
ReadPDB Read Protein Data Bank files (.pdb) files vtkPDBReader Read Protein Data Bank Files.
Example Name VTK Classes Demonstrated Description
SimplePointsWriter Write a simple ".xyz" file vtkSimplePointsWriter
WriteSTL Write stereo lithography STL (.stl) files vtkSTLWriter
WritePLY Write PLY (.ply) files vtkPLYWriter
DelimitedTextWriter Write data to a delimited file vtkDelimitedTextWriter

VTK Formats

Example Name VTK Classes Demonstrated Description
ReadUnstructuredGrid Read an unstructured grid (.vtu) file vtkXMLUnstructuredGridReader Demonstrates how to read a .vtu file
ReadPolyData Read a polygonal data (.vtp) file vtkXMLPolyDataReader
ReadImageData Read a image data (.vti) file vtkXMLImageDataReader
ReadStructuredGrid Read a structured grid (.vts) file vtkXMLStructuredGridReader
ReadRectilinearGrid Read a rectilinear grid (.vtr) file vtkXMLRectilinearGridReader
ReadUnknownTypeXMLFile Read an XML file and later decide what kind it is vtkXMLGenericDataObjectReader
Example Name VTK Classes Demonstrated Description
WriteVTU Write a .vtu file vtkXMLUnstructuredGridWriter VTU is an "Unstructured Grid". This format allows for 3D data to be stored.
WriteVTP Write a .vtp file vtkXMLPolyDataWriter VTP is a "PolyData". This format allows for the most complex geometric objects to be stored.
WriteVTI Write a .vti file vtkXMLImageDataWriter VTI is an "ImageData".
XMLStructuredGridWriter Write a .vts file from a vtkStructuredGrid vtkXMLStructuredGridWriter

Legacy VTK Formats

Example Name VTK Classes Demonstrated Description

Image Formats


Example Name VTK Classes Demonstrated Description
ReadBMP Read BMP (.bmp) files vtkBMPReader
JPEGReader Read a JPG image vtkJPEGReader
PNGReader Read a PNG image vtkPNGReader
ReadPNM Read PNM (.pnm) files vtkPNMReader
ReadTIFF Read TIFF (.tif) files vtkTIFFReader
MetaImageReader Read .mha files vtkMetaImageReader
ImageReader2Factory Read most standard image formats. vtkImageReader2Factory This class tries to find an appropriate reader. It is very convenient to use this when you don't know what kind of file to expect.


Example Name VTK Classes Demonstrated Description
WriteBMP Write a BMP (.bmp) file vtkBMPWriter
JPEGWriter Write a JPEG (.jpg) file vtkJPEGWriter
WritePNG Write a PNG (.png) file vtkPNGWriter
WritePNM Write a PNM (.pnm) file vtkPNMWriter
WriteTIFF Write a TIFF (.tif) file vtkTIFFWriter
MetaImageWriter Write a .mha/.mhd + .raw file vtkMetaImageWriter

Geometric Objects

Example Name VTK Classes Demonstrated Description
PolygonIntersection Compute the intersection of a line segment with a polygon vtkPolygon IntersectWithLine()
GeometricObjectsDemo A demonstration of all geometric objects that work the same way
Arrow Arrow vtkArrowSource
Axes Axes vtkAxesActor
|Colored Lines vtkCellData vtkLine
Cone Cone vtkConeSource
Cube Cube vtkCubeSource
Cylinder Cylinder vtkCylinderSource
Disk Disk vtkDiskSource A circle with a hole in it.
Frustum Frustum vtkFrustumSource
Line Line vtkLineSource
LongLine Manually create a polyline vtkLine
Hexahedron Hexahedron vtkHexahedron
OrientedArrow Oriented Arrow vtkArrowSource
Plane Plane vtkPlaneSource
Planes Planes vtkPlanes
PlanesIntersection PlanesIntersection vtkPlanesIntersection
PlatonicSolid PlatonicSolid vtkPlatonicSolidSource
Point Point vtkPoints
Polygon Polygon vtkPolygon
Pyramid Pyramid vtkPyramid
PolyLine PolyLine vtkPolyLine
Quad Quad vtkQuad
RegularPolygonSource Regular Polygon vtkRegularPolygonSource
Sphere Sphere vtkSphereSource
Triangle Triangle vtkTriangle
TriangleStrip Triangle strip vtkTriangleStrip
Tetrahedron Tetrahedron vtkTetra
Vertex Vertex vtkVertex

Parametric Objects

These examples demonstrate how to create an display one of the many vtkParametric* objects. All of the classes listed can be used in an identical fashion.

Example Name VTK Classes Demonstrated Description
ParametricObjects Create and display a parametric object vtkParametricBoy, vtkParametricConicSpiral, vtkParametricCrossCap, vtkParametricDini, vtkParametricEllipsoid, vtkParametricEnneper, vtkParametricFigure8Klein, vtkParametricKlein, vtkParametricMobius, vtkParametricRandomHills, vtkParametricRoman, vtkParametricSpline, vtkParametricSuperEllipsoid, vtkParametricSuperToroid, vtkParametricTorus
ParametricObjectsDemo Demonstration of all of the vtkParametric* classes

Implicit Functions and Iso-surfaces

Example Name VTK Classes Demonstrated Description
IsoContours Visualize different isocontours using a slider vtkContourFunction
SampleFunction Sample and visualize an implicit function vtkSampleFunction
ExtractLargestIsosurface Extract largest isosurface vtkPolyDataConnectivityFilter
BandedPolyDataContourFilter BandedPolyDataContourFilter vtkBandedPolyDataContourFilter
FilledContours Create filled contours (vtkClipPolyData) vtkContourFilter
ImplicitSphere An implicit representation of a sphere vtkSphere
MarchingCubes Marching cubes vtkMarchingCubes Create a voxelized sphere
MarchingSquares Marching squares vtkMarchingSquares Create a contour from a structured point set (image)

Working with 3D Data

Example Name VTK Classes Demonstrated Description
CenterOfMass Compute the center of mass of the points CenterOfMass vtkCenterOfMass not implemented yet in ActiViz.NET
BooleanOperationPolyDataFilter Perform boolean operations on two vtkPolyData objects BooleanOperationPolyDataFilter vtkBooleanOperationPolyDataFilter not implemented yet in ActiViz.NET
DistancePolyDataFilter Compute the distance function from one vtkPolyData to another DistancePolyDataFilter vtkDistancePolyDataFilter not implemented yet in ActiViz.NET
ImplicitPolyDataDistance Compute the distance function in a space around a vtkPolyData ImplicitPolyDataDistance vtkImplicitPolyDataDistance not implemented yet in ActiViz.NET
IntersectionPolyDataFilter Compute the intersection of two vtkPolyData objects IntersectionPolyDataFilter vtkIntersectionPolyDataFilter not implemented yet in ActiViz.NET
ShrinkPolyData Move all items in a PolyData towards their centroid vtkShrinkPolyData
VectorFieldNonZeroExtraction Extract non-zero vectors from a vtkImageData vtkExtractSelectedThresholds This example shows how to create an imagedata object, associate scalar data with some points and visualize only nonzero scalar values
MultiBlockMergeFilter Combine MultiBlockDataSets vtkMultiBlockMergeFilter, vtkMultiBlockDataSet
IterateOverLines Iterate through the lines of a PolyData vtkCellArray
AlignFrames Align coordinate frames vtkLandmarkTransform
WarpVector vtkWarpVector vtkWarpVector
FindAllArrayNames Get the names of all of the data arrays vtkPolyData
PolyDataGetPoint Get point locations/coordinates from a vtkPolyData vtkPolyData
NullPoint NullPoint vtkPointData Set everything in PointData at a specified index to NULL
ContoursFromPolyData Create contours from PolyData vtkCutter
ImplicitBoolean OperationsOnImplicitFunctions vtkImplicitBoolean Operations include intersection and union.

Point cloud operations

Example Name VTK Classes Demonstrated Description

Working with Meshes

Example Name VTK Classes Demonstrated Description
MatrixMathFilter Matrix math filter vtkMatrixMathFilter Compute various quantities on cell and points in a mesh.
WeightedTransformFilter vtkWeightedTransformFilter vtkWeightedTransformFilter
GreedyTerrainDecimation Create a mesh from an ImageData vtkGreedyTerrainDecimation
LargestRegion Extract the largest connected region in a polydata vtkPolyDataConnectivityFilter
SpecifiedRegion Extract a specific (specified) connected region in a polydata vtkPolyDataConnectivityFilter
ColorDisconnectedRegions Color each disconnected region of a vtkPolyData a different color vtkPolyDataConnectivityFilter
Curvatures Compute Gaussian, Mean, Min, and Max Curvatures vtkCurvatures
MeshQuality Mesh Quality vtkMeshQuality
HighlightBadCells Highlight Bad Cells vtkMeshQuality
PolygonalSurfaceContourLineInterpolator Interactively find the shortest path between two points on a mesh vtkPolygonalSurfaceContourLineInterpolator
DijkstraGraphGeodesicPath Find the shortest path between two points on a mesh vtkDijkstraGraphGeodesicPath
SelectPolyData Select a region of a mesh vtkSelectPolyData
SmoothPolyDataFilter Laplacian smoothing vtkSmoothPolyDataFilter
ClosedSurface Check if a surface is closed vtkFeatureEdges
Decimation Decimation vtkDecimatePro Reduce the number of triangles in a mesh.
QuadricDecimation Decimation (quadric decimation) vtkQuadricDecimation Reduce the number of triangles in a mesh.
QuadricClustering Decimation (quadric clustering) vtkQuadricClustering Reduce the number of triangles in a mesh.
Subdivision Subdivision vtkButterflySubdivisionFilter, vtkLoopSubdivisionFilter, vtkLinearSubdivisionFilter Increase the number of triangles in a mesh.
BoundaryEdges Finding Boundary Edges vtkFeatureEdges Find the edges that are used by only one face.
FillHoles Fill Holes vtkFillHolesFilter Close holes in a mesh.
WindowedSincPolyDataFilter Smooth a mesh (windowed sinc filter) vtkWindowedSincPolyDataFilter Smooth a mesh.
a mesh by height height Color a mesh by height vtkLookupTable Colormap, color map
ElevationFilter Color a mesh by height vtkElevationFilter
SimpleElevationFilter Color a mesh by dotting a vector from the origin to each point with a specified vector vtkSimpleElevationFilter
a mesh mesh Triangulate a mesh vtkTriangleFilter Convert all polygons in a mesh to triangles.
ExtractEdges Extract Edges vtkExtractEdges
CellEdges Get edges of cells vtkCell
SolidClip Create a "solid" clip vtkClipPolyData
CapClip Cap a clipped polydata with a polygon vtkClipPolyData
OBBDicer OBBDicer vtkOBBDicer Breakup a mesh into pieces.