Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::MultiLabelSurfaceNetsExtractor Class Reference

Extracts label-boundary polygonal surfaces from a multi-label segmentation group image using vtkSurfaceNets3D. More...

#include <mitkMultiLabelSurfaceNetsExtractor.h>

Public Types

using LabelValueType = MultiLabelSegmentation::LabelValueType
 

Public Member Functions

 MultiLabelSurfaceNetsExtractor ()
 
 ~MultiLabelSurfaceNetsExtractor ()
 
 MultiLabelSurfaceNetsExtractor (const MultiLabelSurfaceNetsExtractor &)=delete
 
MultiLabelSurfaceNetsExtractor & operator= (const MultiLabelSurfaceNetsExtractor &)=delete
 
void SetSmoothing (bool smoothing)
 Set whether constrained smoothing is applied. More...
 
bool GetSmoothing () const
 
vtkSmartPointer< vtkPolyData > Extract (vtkImageData *groupImage, const std::vector< LabelValueType > &labelValues)
 Extract the boundary surface for the given labels of a single group image. More...
 
std::map< LabelValueType, vtkSmartPointer< vtkPolyData > > ExtractPerLabel (vtkImageData *groupImage, const std::vector< LabelValueType > &labelValues)
 Per-label variant. Returns one polydata per label, restricted to that label's exterior faces (vtkSurfaceNets3D OUTPUT_STYLE_SELECTED). More...
 

Static Public Member Functions

static vtkSmartPointer< vtkMatrix4x4 > GetImageToWorldMatrix (const BaseGeometry *geometry)
 Build the image-local-frame to world-frame transform for the polydata produced by Extract. More...
 

Detailed Description

Extracts label-boundary polygonal surfaces from a multi-label segmentation group image using vtkSurfaceNets3D.

Used by MultiLabelSegmentationVtkMapper3D for live 3D rendering and by the "Convert to polygon model" action for one-shot mitk::Surface generation. vtkSurfaceNets3D extracts all labels in a single threaded pass and shares cells between adjacent regions, producing gap-free, label-aware meshes.

Output cells carry a 2-component "BoundaryLabels" cell-data array that vtkSurfaceNets3D writes; component 0 holds the foreground label of each face (background or higher labels go to component 1).

The class also encapsulates a workaround for a vtkSurfaceNets3D bug in VTK 9.5.2, where the boundary cache may be reused without populating the local newScalars, causing TransformMeshType to dereference null in the smoothed path.

Definition at line 50 of file mitkMultiLabelSurfaceNetsExtractor.h.

Member Typedef Documentation

◆ LabelValueType

Constructor & Destructor Documentation

◆ MultiLabelSurfaceNetsExtractor() [1/2]

mitk::MultiLabelSurfaceNetsExtractor::MultiLabelSurfaceNetsExtractor ( )

◆ ~MultiLabelSurfaceNetsExtractor()

mitk::MultiLabelSurfaceNetsExtractor::~MultiLabelSurfaceNetsExtractor ( )

◆ MultiLabelSurfaceNetsExtractor() [2/2]

mitk::MultiLabelSurfaceNetsExtractor::MultiLabelSurfaceNetsExtractor ( const MultiLabelSurfaceNetsExtractor &  )
delete

Member Function Documentation

◆ Extract()

vtkSmartPointer<vtkPolyData> mitk::MultiLabelSurfaceNetsExtractor::Extract ( vtkImageData *  groupImage,
const std::vector< LabelValueType > &  labelValues 
)

Extract the boundary surface for the given labels of a single group image.

Parameters
groupImagevtkImageData of one group of a MultiLabelSegmentation (typically obtained via Image::GetVtkImageData(timeStep)).
labelValuesThe labels to include. An empty list returns an empty mesh.
Returns
A fresh polydata; safe to retain.

◆ ExtractPerLabel()

std::map<LabelValueType, vtkSmartPointer<vtkPolyData> > mitk::MultiLabelSurfaceNetsExtractor::ExtractPerLabel ( vtkImageData *  groupImage,
const std::vector< LabelValueType > &  labelValues 
)

Per-label variant. Returns one polydata per label, restricted to that label's exterior faces (vtkSurfaceNets3D OUTPUT_STYLE_SELECTED).

Smoothing is applied across all labels in the input list, so the per-label output keeps consistent boundaries with adjacent labels. Labels with no boundary in the group are absent from the returned map.

◆ GetImageToWorldMatrix()

static vtkSmartPointer<vtkMatrix4x4> mitk::MultiLabelSurfaceNetsExtractor::GetImageToWorldMatrix ( const BaseGeometry *  geometry)
static

Build the image-local-frame to world-frame transform for the polydata produced by Extract.

vtkSurfaceNets3D operates on the raw vtkImageData (origin (0,0,0), identity direction, image spacing already applied) and returns polydata in that local frame. The returned 4x4 matrix is the [direction | origin] transform that places those coordinates back into world space. The live 3D mapper applies it as the actor's UserMatrix; consumers of the polydata that bypass the rendering pipeline (e.g. the convert-to-surface action) should bake it into the polydata via vtkTransformPolyDataFilter.

◆ GetSmoothing()

bool mitk::MultiLabelSurfaceNetsExtractor::GetSmoothing ( ) const

◆ operator=()

MultiLabelSurfaceNetsExtractor& mitk::MultiLabelSurfaceNetsExtractor::operator= ( const MultiLabelSurfaceNetsExtractor &  )
delete

◆ SetSmoothing()

void mitk::MultiLabelSurfaceNetsExtractor::SetSmoothing ( bool  smoothing)

Set whether constrained smoothing is applied.

When on (default) the output is smoothed triangles; when off the output is the raw axis-aligned voxel-boundary quads.


The documentation for this class was generated from the following file: