# CSharp

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: [http://www.vtk.org/Wiki/VTK/CSharp/ActiViz.NET Setup a Windows Forms Application to use ActiViz.NET]

## Simple Operations

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

## Input and Output

### Graph Formats

### 3D File Formats

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

#### Standard Formats

##### Input

Example Name | Classes Demonstrated | Description |  |
--- | --- | --- | --- | ---
SimplePointsReader | vtkSimplePointsReader | Read a simple "xyz" file of points |  |
ParticleReader | 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 forma Read an "xyza" file |  |
ReadPlainText | vtkPolyData | Manually read a file using a streamreade Read a plain text file into a polydata |  |
ReadOBJ | vtkOBJReader | Read an OBJ (.obj) File |  |
ReadDICOMSeries | vtkDICOMImageReader | 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 |  |
VRML | vtkVRMLImporter | Read a VRML (WRL) file |  |
DEMReader | vtkDEMReader | Read DEM (elevation map) files |  |
ReadSTL | vtkSTLReader | Read stereo lithography STL (.stl) files |  |
ReadPLY | vtkPLYReader | Read PLY (.ply) files |  |
ReadPLOT3D | vtkPLOT3DReader | Read CFD (computational fluid dynamics) data produced by PLOT3D Read PLOT3D (.bin) files |  |
ReadPDB | vtkPDBReader | Read Protein Data Bank Files Read Protein Data Bank files (.pdb) files |  |

#### VTK Formats

##### Input

Example Name | Classes Demonstrated | Description |  |
--- | --- | --- | --- | ---
ReadUnstructuredGrid | vtkXMLUnstructuredGridReader | Demonstrates how to read a .vtu fil Read an unstructured grid (.vtu) file |  |
ReadPolyData | vtkXMLPolyDataReader | Read a polygonal data (.vtp) file |  |
ReadImageData | vtkXMLImageDataReader | Read a image data (.vti) file |  |
ReadStructuredGrid | vtkXMLStructuredGridReader | Read a structured grid (.vts) file |  |
ReadRectilinearGrid | vtkXMLRectilinearGridReader | Read a rectilinear grid (.vtr) file |  |
ReadUnknownTypeXMLFile | vtkXMLGenericDataObjectReader | Read an XML file and later decide what kind it is |  |

##### Output

Example Name | Classes Demonstrated | Description |  |
--- | --- | --- | --- | ---
WriteVTU | vtkXMLUnstructuredGridWriter | VTU is an "Unstructured Grid". This format allows for 3D data to be stored Write a .vtu file |  |
WriteVTP | vtkXMLPolyDataWriter | VTP is a "PolyData". This format allows for the most complex geometric objects to be stored Write a .vtp file |  |
WriteVTI | vtkXMLImageDataWriter | VTI is an "ImageData" Write a .vti file |  |
XMLStructuredGridWriter | vtkXMLStructuredGridWriter | Write a .vts file from a vtkStructuredGrid |  |

### Image Formats

#### Input

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

#### Output

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

## Geometric Objects

Example Name | Classes Demonstrated | Description |  |
--- | --- | --- | --- | ---
PolygonIntersection | vtkPolygon | IntersectWithLine( Compute the intersection of a line segment with a polygon |  |
GeometricObjectsDemo |  | A demonstration of all geometric objects that work the same way |  |
Arrow | vtkArrowSource | Arrow |  |
Axes | vtkAxesActor | Axes |  |
ColoredLines | vtkCellData vtkLine | Colored Lines |  |
Cone | vtkConeSource | Cone |  |
Cube | vtkCubeSource | Cube |  |
Cylinder | vtkCylinderSource | Cylinder |  |
Disk | vtkDiskSource | A circle with a hole in it Disk |  |
Frustum | vtkFrustumSource | Frustum |  |
Line | vtkLineSource | Line |  |
LongLine | vtkLine | Manually create a polyline |  |
Hexahedron | vtkHexahedron | Hexahedron |  |
OrientedArrow | vtkArrowSource | Oriented Arrow |  |
Plane | vtkPlaneSource | Plane |  |
Planes | vtkPlanes | Planes |  |
PlanesIntersection | vtkPlanesIntersection | PlanesIntersection |  |
PlatonicSolid | vtkPlatonicSolidSource | PlatonicSolid |  |
Point | vtkPoints | Point |  |
Polygon | vtkPolygon | Polygon |  |
Pyramid | vtkPyramid | Pyramid |  |
PolyLine | vtkPolyLine | PolyLine |  |
Quad | vtkQuad | Quad |  |
RegularPolygonSource | vtkRegularPolygonSource | Regular Polygon |  |
Sphere | vtkSphereSource | Sphere |  |
Triangle | vtkTriangle | Triangle |  |
TriangleStrip | vtkTriangleStrip | Triangle strip |  |
Tetrahedron | vtkTetra | Tetrahedron |  |
Vertex | vtkVertex | 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 | Classes Demonstrated | Description |  |
--- | --- | --- | --- | ---
ParametricObjects | vtkParametricBoy, vtkParametricConicSpiral, vtkParametricCrossCap, vtkParametricDini, vtkParametricEllipsoid, vtkParametricEnneper, vtkParametricFigure8Klein, vtkParametricKlein, vtkParametricMobius, vtkParametricRandomHills, vtkParametricRoman, vtkParametricSpline, vtkParametricSuperEllipsoid, vtkParametricSuperToroid, vtkParametricTorus | Create and display a parametric object |  |
ParametricObjectsDemo |  | Demonstration of all of the vtkParametric* classes |  |

## Implicit Functions and Iso-surfaces

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

## Working with 3D Data

Example Name | Classes Demonstrated | Description |  |
--- | --- | --- | --- | ---
ShrinkPolyData | vtkShrinkPolyData | Move all items in a PolyData towards their centroid |  |
VectorFieldNonZeroExtraction | vtkExtractSelectedThresholds | 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 |  |
MultiBlockMergeFilter | vtkMultiBlockMergeFilter, vtkMultiBlockDataSet | Combine MultiBlockDataSets |  |
IterateOverLines | vtkCellArray | Iterate through the lines of a PolyData |  |
AlignFrames | vtkLandmarkTransform | Align coordinate frames |  |
WarpVector | vtkWarpVector | vtkWarpVector |  |
FindAllArrayNames | vtkPolyData | Get the names of all of the data arrays |  |
PolyDataGetPoint | vtkPolyData | Get point locations/coordinates from a vtkPolyData |  |
NullPoint | vtkPointData | Set everything in PointData at a specified index to NUL NullPoint |  |
ContoursFromPolyData | vtkCutter | Create contours from PolyData |  |
ImplicitBoolean | vtkImplicitBoolean | Operations include intersection and union. | OperationsOnImplicitFunctions |

### Working with Meshes

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

### 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.