Skip to content

C++ How To

Often you just need a "pointer" to an example that shows you how to do something.

Here are some snippets and examples that highlight interesting features that may help you:


Example Name Comments Image
CallBack Setting up a callback with client data. Two different methods are demonstrated.


Example Name Comments Image
CameraModel1 Illustrate camera movement around the focal point.
CameraModel2 camera movement centered at the camera position.
CameraPosition Get the camera position while moving the image.
MergeSelections Use the same camera for all renderers.
ShareCamera Use the same camera for all renderers.


Example Name Comments Image
BackgroundGradient Background gradient.
KochanekSplineDemo How to color the slider components.
MergeSelections A nifty way to get a "harmonious" set of window colors, using vtkNamedColors and vtkColorSeries.
ShareCamera Store background colors in a vector for later extraction of the red, green and blue components.


Example Name Comments Image
PointToGlyph How to represent points as glyphs.
QuantizePolyDataPoints Represent a point by a glyph.


Example Name Comments Image
WriteImage Write out an image of various types.


Example Name Comments Image
ReadPolyData This snippet works for most PolyData.


If you want to ensure that the same random points/colors are used in C++ and other languages then it is best to use vtkMinimalStandardRandomSequence.

Example Name Comments Image
ColorDisconnectedRegionsDemo A vtkLookupTable is filled with random colors.
HighlightWithSilhouette Here we use randomly positioned spheres with random colors. A vtkLookupTable is filled with random colors.

Render Windows

Example Name Comments Image
Model Multiple render windows.


How to visualise the information in a structured dataset. All these examples use the combustor dataset.

Example Name Comments Image
ColorIsosurface Color an isosurface with a data array.
CombustorIsosurface Generate an isosurface of constant flow density.
CutStructuredGrid Cut through structured grid with plane. The cut plane is shown solid shaded. A computational plane of constant k value is shown in wireframe for comparison. The colors correspond to flow density. Cutting surfaces are not necessarily planes: implicit functions such as spheres, cylinders, and quadrics can also be used.
ProbeCombustor Probing data in a combustor. Probes are regular arrays of 50 by 50 points that are then passed through a contouring filter.
PseudoVolumeRendering Here we use 100 cut planes, each with an opacity of 0.05. They are then rendered back-to-front to simulate volume rendering.
Rainbow Using different vtkLookupTables.
StreamLines Seed streamlines with vectors from a structured grid.
StreamlinesWithLineWidget Interact with the streamlines in the combustor dataset.
VelocityProfile Warping the geometry of three planes to show flow momentum.
WarpCombustor Carpet plots of combustor flow energy in a structured grid. Colors and plane displacement represent energy values.
XYPlot Display line probes.