djeada
Vtk-Examples
Python

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

Last updated Jun 29, 2026
66
Stars
13
Forks
0
Issues
+1
Stars/day
Attention Score
70
Language breakdown
No language data available.
โ–ธ Files click to expand
README

๐ŸŽจ VTK Examples - Master 3D Visualization with Python

A comprehensive collection of VTK (Visualization Toolkit) examples showcasing 3D graphics, scientific visualization, and computational fluid dynamics

License: MIT Python 3.8+ VTK 9.4 Contributions Welcome

๐Ÿ“– Documentation โ€ข ๐Ÿš€ Quick Start โ€ข ๐Ÿ’ก Examples โ€ข ๐Ÿค Contributing


VTK Visualization Demo

๐ŸŽฌ See VTK in Action

Experience the power of VTK through these interactive demonstrations. Click on any thumbnail to watch the video on YouTube:

| Visualization Demo | Animation Showcase | |:------------------:|:------------------:| | Watch Demo 1 | Watch Demo 2 | | 3D Rendering & Interaction | VTK Short Demo |


๐Ÿ“‹ Table of Contents

- ๐Ÿ”ท Basic Shapes - ๐Ÿ”ถ Advanced Shapes - ๐Ÿ“Š Structures and Datasets - ๐Ÿ“ฅ Input and Output - ๐Ÿ”„ Data Conversion - ๐ŸŽฏ Visualization Pipeline - ๐ŸŽ›๏ธ Interactive Widgets - ๐Ÿ”— Integrations - ๐ŸŒŠ Computational Fluid Dynamics

โœจ Why This Repository?

| ๐ŸŽ“ Learn by Example | ๐Ÿ› ๏ธ Production Ready | ๐Ÿ“ˆ Comprehensive Coverage | |:-----------------------:|:------------------------:|:-----------------------------:| | 50+ working examples with clear explanations | Well-structured, reusable code patterns | From basics to advanced CFD simulations |

| ๐Ÿ”ฌ Scientific Focus | ๐ŸŒ Web & Desktop | ๐Ÿ“š Rich Documentation | |:-----------------------:|:--------------------:|:-------------------------:| | Perfect for research and engineering | Python + VTK.js examples | In-depth notes and tutorials |

Whether you're a student learning visualization concepts, a researcher analyzing scientific data, or an engineer building professional applications, this repository provides the building blocks you need.

๐ŸŽฏ What You'll Learn

  • Create stunning 3D visualizations from simple shapes to complex scientific data
  • Master the VTK pipeline architecture for efficient rendering
  • Handle various file formats (STL, OBJ, VTK, VTU, VTM, and more)
  • Build interactive applications with widgets and UI integration
  • Implement CFD simulations for heat transfer and fluid flow
  • Deploy web visualizations using VTK.js

๐Ÿ” What is VTK?

The Visualization Toolkit (VTK) is the gold standard for 3D computer graphics, image processing, and scientific visualization.

๐Ÿ† Features

  • Extensive Algorithm Library โ€” Hundreds of visualization algorithms for any use case
  • Cross-Platform โ€” Windows, Linux, macOS support
  • Multi-Language โ€” C++, Python, Java, Tcl bindings
  • Open Source โ€” BSD license, free for commercial use
  • Active Community โ€” 30+ years of development by Kitware

๐Ÿ”ง Core Capabilities

  • 3D surface and volume rendering
  • Scalar, vector, and tensor visualization
  • Image processing and analysis
  • Mesh generation and manipulation
  • Scientific data formats I/O
  • Interactive 3D widgets

๐Ÿ“Š VTK Pipeline Architecture

Understanding VTK's pipeline is essential for effective visualization:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                         VTK VISUALIZATION PIPELINE                      โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                         โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”           โ”‚
โ”‚  โ”‚  SOURCE  โ”‚โ”€โ”€โ”€โ–ถโ”‚  FILTER  โ”‚โ”€โ”€โ”€โ–ถโ”‚  MAPPER  โ”‚โ”€โ”€โ”€โ–ถโ”‚  ACTOR   โ”‚           โ”‚
โ”‚  โ”‚          โ”‚    โ”‚          โ”‚    โ”‚          โ”‚    โ”‚          โ”‚           โ”‚
โ”‚  โ”‚ Generate โ”‚    โ”‚ Process  โ”‚    โ”‚ Convert  โ”‚    โ”‚ Render   โ”‚           โ”‚
โ”‚  โ”‚   Data   โ”‚    โ”‚   Data   โ”‚    โ”‚ to Geo   โ”‚    โ”‚  Object  โ”‚           โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜           โ”‚
โ”‚                                                       โ”‚                 โ”‚
โ”‚                                                       โ–ผ                 โ”‚
โ”‚                                               โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”          โ”‚
โ”‚                                               โ”‚   RENDERER   โ”‚          โ”‚
โ”‚                                               โ”‚              โ”‚          โ”‚
โ”‚                                               โ”‚   Display    โ”‚          โ”‚
โ”‚                                               โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿš€ Quick Start

Get up and running in minutes with these simple steps:

Prerequisites

  • Python 3.8 or higher
  • pip package manager

Installation

# 1. Clone the repository
git clone https://github.com/djeada/VTK-Examples.git
cd VTK-Examples

2. Create a virtual environment (recommended)

python -m venv venv

3. Activate the virtual environment

On Linux/macOS:

source venv/bin/activate

On Windows:

venv\Scripts\activate

4. Install dependencies

pip install -r requirements.txt

Run Your First Example

# Navigate to the examples directory and run a script
cd src/01basicshapes
python circle.py

๐ŸŽ‰ Congratulations! You should see a window displaying circles rendered with VTK.

๐Ÿ’ป IDE Setup (Optional)

For an enhanced development experience with VS Code or PyCharm:

  • Open the project folder in your IDE
  • Configure the Python interpreter to use your virtual environment
  • Run any script using the built-in run button or debugger
  • Debug with breakpoints for step-through analysis

๐Ÿ“ Project Structure

VTK-Examples/
โ”œโ”€โ”€ ๐Ÿ“‚ src/                          # Source code examples
โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ 01basicshapes/          # Fundamental geometric primitives
โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ 02advancedshapes/       # Complex geometries & techniques
โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ 03structuresand_datasets/ # VTK data structures
โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ 04inputoutput/          # File format handling
โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ 05dataconversion/       # Format conversion utilities
โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ 06visualizationpipeline/ # Rendering pipeline examples
โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ 07interactivewidgets/   # UI widgets & interaction
โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ 08integrationwith_ui/   # Qt, Matplotlib integration
โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ 09_cfd/                   # Computational Fluid Dynamics
โ”‚   โ””โ”€โ”€ ๐Ÿ“‚ common/                   # Shared utilities & helpers
โ”‚
โ”œโ”€โ”€ ๐Ÿ“‚ notes/                        # In-depth documentation & tutorials
โ”œโ”€โ”€ ๐Ÿ“‚ vtk_js/                       # VTK.js web visualization examples
โ”œโ”€โ”€ ๐Ÿ“‚ data/                         # Sample data files
โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ stls/                     # STL mesh files
โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ objs/                     # OBJ model files
โ”‚   โ”œโ”€โ”€ ๐Ÿ“‚ vtks/                     # VTK data files
โ”‚   โ””โ”€โ”€ ๐Ÿ“‚ ...                       # Other format samples
โ”‚
โ”œโ”€โ”€ ๐Ÿ“„ requirements.txt              # Python dependencies
โ”œโ”€โ”€ ๐Ÿ“„ LICENSE                       # MIT License
โ””โ”€โ”€ ๐Ÿ“„ README.md                     # This file

๐Ÿ’ก Examples Gallery

๐Ÿ”ท Basic Shapes

Start your VTK journey with fundamental geometric primitives. These examples demonstrate the core concepts of creating and rendering 3D objects.

| # | Example | Description | Link | |:-:|:--------|:------------|:----:| | 1 | Circle | Create perfectly round 2D circles with customizable radius and resolution | ๐Ÿ“„ Code | | 2 | Cone | Generate 3D cones with adjustable height, radius, and resolution | ๐Ÿ“„ Code | | 3 | Cube | Build solid cubes and boxes in 3D space | ๐Ÿ“„ Code | | 4 | Cylinder | Create cylindrical shapes with height and radius parameters | ๐Ÿ“„ Code | | 5 | Glyph | Introduction to glyph-based visualization for representing data points | ๐Ÿ“„ Code | | 6 | Square | Render 2D squares and rectangles | ๐Ÿ“„ Code | | 7 | Triangle | Create triangular primitives, the building blocks of 3D meshes | ๐Ÿ“„ Code |

๐Ÿ”ถ Advanced Shapes

Take your visualization skills to the next level with complex geometries, volume rendering, and multi-object scenes.

| # | Example | Description | Link | |:-:|:--------|:------------|:----:| | 1 | Enclosing Box | Create bounding boxes that enclose other objectsโ€”useful for spatial analysis | ๐Ÿ“„ Code | | 2 | Isosurface | Extract surfaces of constant value from volumetric data | ๐Ÿ“„ Code | | 3 | Multiple Dependent Objects | Build scenes with hierarchically linked objects | ๐Ÿ“„ Code | | 4 | Multiple Independent Objects | Create complex scenes with multiple standalone objects | ๐Ÿ“„ Code | | 5 | Streamlines | Visualize flow fields and vector data with streamline rendering | ๐Ÿ“„ Code | | 6 | Triangulation | Apply triangulation techniques for mesh generation | ๐Ÿ“„ Code | | 7 | Volume Rendering | Render volumetric data with customizable transfer functions | ๐Ÿ“„ Code | | 8 | Visualization Comparison | Compare different visualization techniques side-by-side | ๐Ÿ“„ Code | | 9 | Flow Simulation | Visualize computational fluid dynamics data | ๐Ÿ“„ Code |

๐Ÿ“Š Structures and Datasets

Master VTK's data structuresโ€”the foundation of all visualization operations.

| # | Example | Description | Link | |:-:|:--------|:------------|:----:| | 1 | Points | Work with vtkPointsโ€”the fundamental spatial data structure | ๐Ÿ“„ Code | | 2 | Cells | Understand cells and their role in defining mesh topology | ๐Ÿ“„ Code | | 3 | Fields | Handle scalar, vector, and tensor field data | ๐Ÿ“„ Code | | 4 | Multiblock Dataset | Organize complex data with hierarchical multiblock structures | ๐Ÿ“„ Code | | 5 | PolyData | Work with polygonal surfacesโ€”the most common VTK data type | ๐Ÿ“„ Code | | 6 | Structured Grid | Handle regularly spaced 3D grid data | ๐Ÿ“„ Code | | 7 | Unstructured Grid | Work with arbitrary cell types and connectivity | ๐Ÿ“„ Code | | 8 | Structured Mesh | Create and manipulate structured mesh geometries | ๐Ÿ“„ Code | | 9 | Unstructured Mesh | Build and process unstructured mesh geometries | ๐Ÿ“„ Code | | 10 | Cell Types Demo | Interactive demo of all VTK cell types with combo box selection | ๐Ÿ“„ Code | | 11 | Topology vs Geometry | Interactive demo showing the difference between mesh connectivity and point positions | ๐Ÿ“„ Code | | 12 | Connectivity Demo | Interactive demo of VTK's connectivity filter with multiple extraction modes for identifying and extracting connected regions | ๐Ÿ“„ Code | | 13 | Data Types Demo | Interactive demo of VTK dataset types (ImageData, RectilinearGrid, StructuredGrid, PolyData, UnstructuredGrid) with combo box selection | ๐Ÿ“„ Code |

๐Ÿ“ฅ Input and Output

Learn to read and write various 3D file formats commonly used in engineering and scientific applications.

| # | Format | Description | Link | |:-:|:-------|:------------|:----:| | 1 | OBJ | Wavefront OBJโ€”widely used 3D model format | ๐Ÿ“„ Code | | 2 | STL | Stereolithography formatโ€”standard for 3D printing | ๐Ÿ“„ Code | | 3 | VTK | Native VTK format for polygonal data | ๐Ÿ“„ Code | | 4 | VTM | VTK multiblock format for composite datasets | ๐Ÿ“„ Code | | 5 | VTU | VTK unstructured grid format | ๐Ÿ“„ Code | | 6 | Exodus II | SANDIA National Labs format for FEM/CFD results | ๐Ÿ“„ Code | | 7 | OpenFOAM | Read OpenFOAM CFD simulation results | ๐Ÿ“„ Code |

๐Ÿ”„ Data Conversion

Convert between popular 3D file formats with ease.

| # | Conversion | Description | Link | |:-:|:-----------|:------------|:----:| | 1 | Converter Interface | Base interface for building custom converters | ๐Ÿ“„ Code | | 2 | STL โ†” VTK | Convert between STL and VTK formats | ๐Ÿ“„ Code | | 3 | VTK โ†” OBJ | Convert between VTK and OBJ formats | ๐Ÿ“„ Code | | 4 | STL โ†” OBJ | Convert between STL and OBJ formats | ๐Ÿ“„ Code | | 5 | VTK โ†” VTM | Convert between VTK and VTM formats | ๐Ÿ“„ Code | | 6 | VTK โ†” VTU | Convert between VTK and VTU formats | ๐Ÿ“„ Code |

๐ŸŽฏ Visualization Pipeline

Understand and master the VTK rendering pipeline for professional-quality visualizations.

| # | Example | Description | Link | |:-:|:--------|:------------|:----:| | 1 | Actor-Mapper Setup | Handle multiple objects with proper actor-mapper relationships | ๐Ÿ“„ Code | | 2 | Text Labels | Add informative text annotations to your visualizations | ๐Ÿ“„ Code | | 3 | Scalar Color Mapping | Map data values to colors using customizable color maps | ๐Ÿ“„ Code | | 4 | Camera Movement | Control camera position, orientation, and movement paths | ๐Ÿ“„ Code | | 5 | Filters in Action | Apply VTK filters for data processing and transformation | ๐Ÿ“„ Code | | 6 | Lighting & Shadows | Create realistic lighting effects and shadow rendering | ๐Ÿ“„ Code | | 7 | Pipeline Animation | Animate your visualization pipeline over time | ๐Ÿ“„ Code |

๐ŸŽ›๏ธ Interactive Widgets

Build interactive applications with VTK's powerful widget system.

| # | Widget | Description | Link | |:-:|:-------|:------------|:----:| | 1 | Orientation Marker | Add 3D axes indicator for spatial orientation | ๐Ÿ“„ Code | | 2 | Slider | Create interactive sliders for parameter control | ๐Ÿ“„ Code | | 3 | Button | Implement clickable buttons for user interaction | ๐Ÿ“„ Code | | 4 | Planes Intersection | Interactively slice volumes with intersecting planes | ๐Ÿ“„ Code |

๐Ÿ”— Integrations with External Tools

Combine VTK with popular frameworks for enhanced visualization capabilities.

| # | Integration | Description | Link | |:-:|:------------|:------------|:----:| | 1 | Qt Integration | Embed VTK visualizations in Qt desktop applications | ๐Ÿ“„ Code | | 2 | Matplotlib Sphere | Combine VTK 3D rendering with Matplotlib | ๐Ÿ“„ Code | | 3 | Matplotlib Surface | Create surface plots using VTK and Matplotlib together | ๐Ÿ“„ Code |

๐ŸŒŠ Computational Fluid Dynamics (CFD)

Simulate and visualize heat transfer and fluid flow phenomena with these physics-based examples.

| # | Simulation | Description | Link | |:-:|:-----------|:------------|:----:| | 1 | 1D Heat Convection | Solve 1D heat convection problems with finite differences | ๐Ÿ“„ Code | | 2 | 1D Fixed-End Heat Transfer | Heat transfer with fixed temperature boundary conditions | ๐Ÿ“„ Code | | 3 | 1D Convective-End Heat Transfer | Heat transfer with convective boundary conditions | ๐Ÿ“„ Code | | 4 | 1D Enhanced Heat Transfer | Advanced 1D heat transfer with enhanced accuracy | ๐Ÿ“„ Code | | 5 | 2D Heat Conduction | Solve 2D steady-state heat conduction problems | ๐Ÿ“„ Code | | 6 | 2D Enhanced Heat Transfer | Advanced 2D heat transfer solver | ๐Ÿ“„ Code | | 7 | Fluid Flow Simulation | Simulate basic fluid flow patterns | ๐Ÿ“„ Code | | 8 | Obstacle Flow | Simulate fluid flow around obstacles | ๐Ÿ“„ Code |


๐ŸŒ VTK.js Web Examples

Take your visualizations to the web with VTK.jsโ€”a JavaScript implementation of VTK for browser-based 3D rendering.

Quick Start with VTK.js

# Navigate to the VTK.js examples
cd vtk_js/basic

Install dependencies

npm install

Build the project

npm run build

Start the development server

npm start

Then open your browser to http://localhost:8080 to see VTK running in the web!

๐Ÿ“‚ Location: vtk_js/basic/


๐Ÿ“– Documentation

Deepen your understanding with our comprehensive documentation covering VTK concepts, techniques, and best practices.

| Topic | Description | Link | |:------|:------------|:----:| | Data Types & Structures | vtkDataObject, points, cells, grids, and datasets | ๐Ÿ“š Read | | Filters & Algorithms | Data processing, transformation, and analysis filters | ๐Ÿ“š Read | | Input & Output | File format handling and data serialization | ๐Ÿ“š Read | | Visualization Techniques | Volume rendering, scalar mapping, vector visualization | ๐Ÿ“š Read | | Interactivity | User interaction, picking, and selection | ๐Ÿ“š Read | | Animations | Creating smooth animations and time-series visualizations | ๐Ÿ“š Read | | Performance Optimization | Parallelism, LOD, and rendering optimization | ๐Ÿ“š Read | | Tool Integration | Integrating VTK with Qt, Matplotlib, and other tools | ๐Ÿ“š Read | | Custom Filters | Building custom filters and algorithms | ๐Ÿ“š Read |


๐Ÿค How to Contribute

We welcome contributions from the community! Whether you're fixing a bug, adding new examples, or improving documentation, your help is appreciated.

Ways to Contribute

  • ๐Ÿ› Report bugs โ€” Found an issue? Open a bug report
  • ๐Ÿ’ก Suggest features โ€” Have an idea? Share it with us
  • ๐Ÿ“ Improve documentation โ€” Help make the docs even better
  • ๐Ÿ”ง Submit code โ€” Add new examples or enhance existing ones

Contribution Workflow

# 1. Fork the repository on GitHub

2. Clone your fork

git clone https://github.com/YOUR_USERNAME/VTK-Examples.git cd VTK-Examples

3. Create a feature branch

git checkout -b feature/AmazingFeature

4. Make your changes and commit

git add . git commit -m "Add AmazingFeature: brief description"

5. Push to your fork

git push origin feature/AmazingFeature

6. Open a Pull Request on GitHub

Code Guidelines

  • Follow existing code style and patterns
  • Add clear comments and docstrings
  • Include example usage in new scripts
  • Test your code before submitting

๐Ÿ“š References

Expand your VTK knowledge with these excellent resources:

Official Resources

Community Resources


๐Ÿ“„ License

This project is licensed under the MIT License โ€” see the LICENSE file for details.

MIT License - Copyright (c) 2021 Adam Djellouli

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software.


โญ Star History

If you find this repository helpful, please consider giving it a star! Your support helps others discover these resources.

Star History Chart


Made with โค๏ธ by Adam Djellouli and contributors

โฌ† Back to Top

๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท djeada/Vtk-Examples ยท Updated daily from GitHub