NetVtk

The Visualization Toolkit (VTK) 9.7.1 for .NET: C# bindings generated from VTK's headers, VTK's class and method names unchanged, in one namespace, Vtk. For simulation results: fields on meshes, isosurfaces, cuts, warps, scalar bars. One AnyCPU package for .NET Framework 3.5 and 4.5+, .NET 6, 8 and 10, and netstandard2.0, with natives for win-x64, win-x86, linux-x64 and osx-arm64.

dotnet add package NetVtk

A program

A sphere's height as a field on its surface, cut into nine rings, written as a .vtp file:

using System;
using Vtk;

namespace Contours;

// a sphere's height as a field on its surface, cut into rings of equal height, written as .vtp
internal static class Program
{
  private static void Main()
  {
    using var sphere = new vtkSphereSource();
    sphere.SetThetaResolution(64);
    sphere.SetPhiResolution(32);

    // each point's height as the field "Elevation": 0 at the bottom, 1 at the top
    using var elevation = new vtkElevationFilter();
    elevation.SetLowPoint(0, 0, -0.5);
    elevation.SetHighPoint(0, 0, 0.5);
    using var spherePort = sphere.GetOutputPort();
    elevation.SetInputConnection(spherePort);

    // nine rings, where the field is 0.1, 0.2, ..., 0.9
    using var contours = new vtkContourFilter();
    using var elevationPort = elevation.GetOutputPort();
    contours.SetInputConnection(elevationPort);
    contours.GenerateValues(9, 0.1, 0.9);

    // Update runs the pipeline up to the contours
    contours.Update();
    using var rings = contours.GetOutput();
    Console.WriteLine($"{rings.GetNumberOfPoints()} points, {rings.GetNumberOfLines()} segments");

    using var writer = new vtkXMLPolyDataWriter();
    writer.SetFileName("rings.vtp");
    writer.SetInputData(rings);
    writer.Write();
  }
}

VTK's pipeline, call for call. How C++ signatures look in C#: From C++ to C#.

Covered

25 of VTK's modules: data sets and arrays, the pipeline, the core, general, geometry, modeling and source filters, VTK's XML and legacy files, Exodus II and CGNS, OpenGL rendering with annotations, text and volumes, interaction styles and widgets. See Modules.

NetVtk at a glance NetVtk at a glance

Where to go

Start Introduction: VTK's parts, classes by task. Getting started: install, a first picture.
Guide Pipelines, Data and arrays, Results, Rendering and hosting, Observers and messages
Concepts From C++ to C#, Object lifetimes, Native interop
Reference Class index: every type, linked to VTK's reference. Platforms, Modules, Building from source, Troubleshooting
Development Design decisions, Licensing

Every example on this site is a test, compiled against the NetVtk package and run; those that need a window compile only.