Skip to content
Snippets Groups Projects

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:

Camera

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.

Coloring

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.

Glyphing

Example Name Comments Image
QuantizePolyDataPoints Represent a point by a glyph.

Image

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

Polydata

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

Random

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.