Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
PropertyConversionUtils.h File Reference

Centralized property conversion utilities for Python bindings. More...

#include <mitkBaseProperty.h>
#include <mitkColorProperty.h>
#include <mitkProperties.h>
#include <mitkStringProperty.h>
#include <pybind11/pybind11.h>

Go to the source code of this file.

Namespaces

 mitk
 Find image slices visible on a given plane.
 
 mitk::python
 

Functions

py::object mitk::python::propertyToPythonValue (const mitk::BaseProperty &prop)
 Converts a BaseProperty to its Python native value. More...
 
py::dict mitk::python::propertyToDict (const mitk::BaseProperty &prop)
 
mitk::BaseProperty::Pointer mitk::python::dictToProperty (const py::dict &d)
 

Detailed Description

Centralized property conversion utilities for Python bindings.

DESIGN RATIONALE: Header-only implementation

This file uses a header-only approach for several important reasons:

  1. TEMPLATE COMPATIBILITY: These utilities are used across multiple compilation units with pybind11 templates. Header-only ensures consistent instantiation.
  2. RUNTIME ROBUSTNESS: Eliminates potential linking issues and ensures all compilation units use identical conversion logic.
  3. INLINING BENEFITS: Property conversions are performance-sensitive in Python bindings. Header-only allows compiler inlining optimization.
  4. PYTHON BINDINGS LAYER: While MITK typically prefers header/cpp separation, the Python bindings layer has different constraints and performance profiles.

Trade-off: Slightly increased compile times, but this is acceptable for the runtime robustness and maintainability benefits in this specific context.

Definition in file PropertyConversionUtils.h.