Skip to content

About

Explore the world of 3D graphics and visualization with VTK examples in Python.

Topics

Resources

Contributing

Stars

69 stars

Watchers

2 watching

Forks

Repository files navigation

VTK Examples

A collection of Python examples for VTK, covering geometry, data structures, file formats, rendering, interaction, UI integrations, and small CFD demonstrations. The repository also includes a small browser example using VTK.js.

Watch a VTK rendering demo

Many examples follow the VTK rendering flow: source → filter → mapper → actor → renderer.

Getting started

The Python examples require Python 3.10 or newer. From the repository root, create and activate a virtual environment, then install the dependencies:

git clone https://github.com/djeada/VTK-Examples.git
cd VTK-Examples
# Linux or macOS
python3 -m venv .venv
source .venv/bin/activate
# Windows PowerShell:
# py -m venv .venv
# .venv\Scripts\Activate.ps1

python -m pip install -r requirements-core.txt

The core requirements cover VTK, NumPy, Matplotlib, and the CFD examples. Install requirements.txt when you also need the Qt, pandas, Spark, or other integrations.

Run a Python example by its filename or relative path. For example:

python -m src --list
python -m src circle
python -m src 01_basic_shapes/circle
python -m src naca_airfoil_generator -- 0012 --export airfoil.vtp

Run commands from the repository root so examples can find the shared data/ directory. Some examples open an interactive window; close the window to return to the terminal. Examples that read or write external file formats may need sample files in data/ and can create output files there. File-writing examples may overwrite an existing output file.

Example catalog

Use python -m src --list for the runnable catalog, or filter it with a fragment such as python -m src --list heat. Select an example by filename, unique filename fragment, or category/path. The links below point to the source files.

Basic shapes

Procedural geometry and visual effects

Run these standalone, animated VTK scenes through python -m src <name> (close the rendering window to exit):

The gravity well and tornado are illustrative, not physics simulations; the volume scanner uses generated voxels rather than medical imaging data. All examples depend only on the core VTK/NumPy requirements.

Advanced shapes

Structures and datasets

Input and output

Data conversion

Visualization pipeline

Interactive widgets

UI integrations

CFD

See the CFD model and visualization guide for the equations, boundary conditions, checks, and limitations of these teaching examples.

New to CFD? Start with the two beginner time-marching examples:

Educational science reels

Create one vertical video per selected example. The curated CFD stories use numerical adapters for the example solvers; other examples use their original VTK scene with a generic story or a supplied JSON story. By default, reels render at 1080 × 1920 and 30 fps; fast uses 720 × 1280 at 24 fps. Quality also selects different numerical grids for curated models, so fast and studio results can differ slightly; the manifest records the model parameters. The curated obstacle reel uses Re=50, while the standalone example defaults to Re=100.

Install the reel dependencies and system FFmpeg (including ffprobe), then list or render stories:

python -m pip install -r requirements-reels.txt
python -m src.reels --list
python -m src.reels obstacle_flow_simulation
python -m src.reels --all cfd

Each selected example produces its own MP4, thumbnail, contact sheet, JSON manifest, and SRT captions under reels/. Linux systems without a display use Xvfb automatically when installed. See the reel guide for quality, audio, output, and custom-story options.

VTK.js example

The browser example lives in vtk_js/basic. Follow its README to install the Node.js dependencies and start the development server; it prints the local URL to open.

Notes

The notes/ directory contains guides on data types and structures, filters and algorithms, input and output, visualization techniques, interactivity, animations, performance, tool integration, custom filters, and a complete hands-on case study.

Contributing

Bug reports, example fixes, and documentation improvements are welcome. See CONTRIBUTING.md for the local workflow and project conventions.

License

This project is licensed under the MIT License.

About

Explore the world of 3D graphics and visualization with VTK examples in Python.

Topics

Resources

Contributing

Stars

69 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages