Skip to content

CSharp Examples

VTK Classes Summary

This Python script, SelectExamples, will let you select examples based on a VTK Class and language. It requires Python 3.7 or later. The following tables will produce similar information.

Simple Operations

Example Name Description Image
DistanceBetweenPoints Computes the distance between two point Distance between two points
DistancePointToLine Distance between a point and a line
GaussianRandomNumber Generates Gaussian random number Random number (Gaussian distribution)
PerspectiveTransform Apply a perspective transformation to a point
ProjectPointPlane Project a point onto a plan Project a point onto a plane
RandomSequence This is the preferred way to generate random numbers Random sequence
UniformRandomNumber Generates uniform random number Random number (uniform distribution)

Input and Output

Graph Formats

3D File Formats

Example Name Description Image
ConvertFile Convert a file from one type to another
XGMLReader Read a .gml file

Standard Formats

Input
Example Name Description Image
DEMReader Read DEM (elevation map) files
ReadDICOMSeries This example demonstates how to read a series of DICOM images and scroll through slice Convert a series of DICOM files into a VTI File
ReadPDB Read Protein Data Bank Files Read Protein Data Bank files (.pdb) files
ReadPLOT3D Read CFD (computational fluid dynamics) data produced by PLOT3D Read PLOT3D (.bin) files
ReadPLY Read PLY (.ply) files
ReadSTL Read stereo lithography STL (.stl) files
SimplePointsReader Read a simple "xyz" file of points
VRML Read a VRML (WRL) file

VTK Formats

Input
Example Name Description Image
ParticleReader Read an ASCII file
ReadImageData Read a image data (.vti) file
ReadOBJ Read a Wavefront OBJ file
ReadPlainText Read a plain text file
ReadPolyData Read a polygonal data (.vtp) file
ReadRectilinearGrid Read a rectilinear grid (.vtr) file
ReadStructuredGrid Read a structured grid (.vts) file
ReadUnknownTypeXMLFile Read an XML file and later decide what kind it is
ReadUnstructuredGrid Demonstrates how to read a .vtu fil Read an unstructured grid (.vtu) file
Output
Example Name Description Image
WriteVTI VTI is an "ImageData" Write a .vti file
WriteVTP VTP is a "PolyData". This format allows for the most complex geometric objects to be stored Write a .vtp file
WriteVTU VTU is an "Unstructured Grid". This format allows for 3D data to be stored Write a .vtu file
XMLStructuredGridWriter Write a .vts file from a vtkStructuredGrid

Image Formats

Input

Example Name Description Image
ImageReader2Factory 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 Read most standard image formats.
JPEGReader Read a JPG image
MetaImageReader Read .mha files
PNGReader Read a PNG image
ReadBMP Read BMP (.bmp) files
ReadPNM Read PNM (.pnm) files
ReadTIFF Read TIFF (.tif) files

Output

Example Name Description Image
JPEGWriter Write a JPEG (.jpg) file
MetaImageWriter Write a .mha/.mhd + .raw file
WriteBMP Write a BMP (.bmp) file
WritePNG Write a PNG (.png) file
WritePNM Write a PNM (.pnm) file
WriteTIFF Write a TIFF (.tif) file

Geometric Objects

Example Name Description Image
Arrow Arrow
Axes Axes
ColoredLines Colored Lines
Cone Cone
Cube Cube
Cylinder Cylinder
Disk A circle with a hole in it Disk
Frustum Frustum
GeometricObjectsDemo A demonstration of all geometric objects that work the same way
Hexahedron Hexahedron
Line Line
LongLine Manually create a polyline
OrientedArrow Oriented Arrow
Plane Plane
Planes Planes
PlanesIntersection PlanesIntersection
PlatonicSolid PlatonicSolid
Point Point
PolyLine PolyLine
Polygon Polygon
PolygonIntersection IntersectWithLine( Compute the intersection of a line segment with a polygon
Pyramid Pyramid
Quad Quad
RegularPolygonSource Regular Polygon
Sphere Sphere
Tetrahedron Tetrahedron
Triangle Triangle
TriangleStrip Triangle strip
Vertex Vertex

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 Description Image
ParametricObjects Create and display a parametric object
ParametricObjectsDemo Demonstration of all of the vtkParametric* classes

Implicit Functions and Iso-surfaces

Example Name Description Image
BandedPolyDataContourFilter BandedPolyDataContourFilter
ExtractLargestIsosurface Extract largest isosurface
FilledContours Create filled contours (vtkClipPolyData)
ImplicitSphere An implicit representation of a sphere
IsoContours Visualize different isocontours using a slider
MarchingCubes Create a voxelized spher Marching cubes
MarchingSquares Create a contour from a structured point set (image Marching squares)
SampleFunction Sample and visualize an implicit function

Working with 3D Data

Example Name Description Image
AlignFrames Align coordinate frames
ContoursFromPolyData Create contours from PolyData
FindAllArrayNames Get the names of all of the data arrays
ImplicitBoolean Operations include intersection and union.
IterateOverLines Iterate through the lines of a PolyData
MultiBlockMergeFilter Combine MultiBlockDataSets
NullPoint Set everything in PointData at a specified index to NUL NullPoint
PolyDataGetPoint Get point locations/coordinates from a vtkPolyData
ShrinkPolyData Move all items in a PolyData towards their centroid
VectorFieldNonZeroExtraction This example shows how to create an imagedata object, associate scalar data with some points and visualize only nonzero scalar value Extract non-zero vectors from a vtkImageData
WarpVector vtkWarpVector

Working with Meshes

Example Name Description Image
BoundaryEdges Find the edges that are used by only one face Finding Boundary Edges
CapClip Cap a clipped polydata with a polygon
CellEdges Get edges of cells
ClosedSurface Check if a surface is closed
ColorDisconnectedRegions Color each disconnected region of a vtkPolyData a different color
ColoredElevationMap Colormap, color ma Color a mesh by height
Curvature Compute Gaussian, Mean, Min, and Max Curvatures
Decimate Reduce the number of triangles in a mesh Decimation
DijkstraGraphGeodesicPath Find the shortest path between two points on a mesh
ElevationFilter Color a mesh by height
ExtractEdges Extract Edges
FillHoles Close holes in a mesh Fill Holes
GreedyTerrainDecimation Create a mesh from an ImageData
HighlightBadCells Highlight Bad Cells
LargestRegion Extract the largest connected region in a polydata
MatrixMathFilter Compute various quantities on cell and points in a mesh Matrix math filter
OBBDicer Breakup a mesh into pieces OBBDicer
PolygonalSurfaceContourLineInterpolator Interactively find the shortest path between two points on a mesh
QuadricClustering Reduce the number of triangles in a mesh Decimation (quadric clustering)
QuadricDecimation Reduce the number of triangles in a mesh Decimation (quadric decimation)
SelectPolyData Select a region of a mesh
SimpleElevationFilter Color a mesh by dotting a vector from the origin to each point with a specified vector
SolidClip Create a "solid" clip
SpecifiedRegion Extract a specific (specified) connected region in a polydata
Subdivision Increase the number of triangles in a mesh Subdivision
Triangulate Convert all polygons in a mesh to triangles Triangulate a mesh
WeightedTransformFilter vtkWeightedTransformFilter
WindowedSincPolyDataFilter Smooth a mesh.

Working with Structured 3D Data

This section includes vtkImageData, vtkStructuredGrid, and vtkRectilinearGrid.

"ImageData" is not the traditional "flat, 2D image" you are used to. It is a special VTK data structure in the collection of 3D data structures provided by VTK. Here is an overview of these data structures: [http://vtk.org/Wiki/VTK/Tutorials/3DDataTypes]. Image data can represent at typical 2D image, but also, a 3D volume.