Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
GeometryHelpers.h File Reference
#include <mitkBaseGeometry.h>
#include <mitkTimeGeometry.h>
#include <pybind11/numpy.h>
#include <array>
#include <tuple>

Go to the source code of this file.

Functions

mitk::BaseGeometry::Pointer GetGeometryForTimeStep (mitk::TimeGeometry *tg, mitk::TimeStepType timeStep)
 Returns the mutable BaseGeometry for the given time step. More...
 
mitk::BaseGeometry::ConstPointer GetConstGeometryForTimeStep (const mitk::TimeGeometry *tg, mitk::TimeStepType timeStep)
 Returns the const BaseGeometry for the given time step. More...
 
std::tuple< double, double, double > GetSpacing (const mitk::TimeGeometry *tg, mitk::TimeStepType t)
 Returns the voxel spacing (x, y, z) at the given time step. More...
 
void SetSpacing (mitk::TimeGeometry *tg, const std::array< double, 3 > &spacing, mitk::TimeStepType t)
 Sets the voxel spacing at the given time step. More...
 
std::tuple< double, double, double > GetOrigin (const mitk::TimeGeometry *tg, mitk::TimeStepType t)
 Returns the origin (x, y, z) at the given time step. More...
 
void SetOrigin (mitk::TimeGeometry *tg, const std::array< double, 3 > &origin, mitk::TimeStepType t)
 Sets the origin at the given time step. More...
 
py::array_t< double > ExtractDirection (const mitk::BaseGeometry &geom)
 Extracts the direction cosine matrix (3x3) from a BaseGeometry. More...
 
py::array_t< double > GetDirection (const mitk::TimeGeometry *tg, mitk::TimeStepType t)
 Returns the direction cosine matrix (3x3) at the given time step. More...
 
void SetDirection (mitk::TimeGeometry *tg, py::array_t< double, py::array::c_style|py::array::forcecast > direction, mitk::TimeStepType t)
 Sets the direction cosine matrix at the given time step. More...
 
std::array< double, 9 > GetDirectionCosines (const mitk::TimeGeometry *tg, mitk::TimeStepType t)
 Returns the direction cosines as a flat 9-element array at the given time step. More...
 
template<typename PyClass , typename CppClass , bool BindNdim = true>
void BindGeometryAccessors (PyClass &cls)
 Binds geometry accessors (per-time-step methods and convenience properties) onto an existing pybind11 class that has a GetTimeGeometry() method. More...
 

Function Documentation

◆ BindGeometryAccessors()

template<typename PyClass , typename CppClass , bool BindNdim = true>
void BindGeometryAccessors ( PyClass &  cls)

Binds geometry accessors (per-time-step methods and convenience properties) onto an existing pybind11 class that has a GetTimeGeometry() method.

Template Parameters
PyClasspybind11::class_<...> type
CppClassThe C++ class being bound (must provide GetTimeGeometry() and GetDimension())
BindNdimIf false, skips the ndim property (for classes that bind it themselves)

Definition at line 90 of file GeometryHelpers.h.

References GetDirection(), GetDirectionCosines(), GetGeometryForTimeStep(), GetOrigin(), GetSpacing(), SetDirection(), SetOrigin(), and SetSpacing().

◆ ExtractDirection()

py::array_t<double> ExtractDirection ( const mitk::BaseGeometry &  geom)

Extracts the direction cosine matrix (3x3) from a BaseGeometry.

Precondition
geom must be a valid, initialized BaseGeometry with a non-null index-to-world transform

◆ GetConstGeometryForTimeStep()

mitk::BaseGeometry::ConstPointer GetConstGeometryForTimeStep ( const mitk::TimeGeometry *  tg,
mitk::TimeStepType  timeStep 
)

Returns the const BaseGeometry for the given time step.

Precondition
tg != nullptr
timeStep is a valid time step of tg

◆ GetDirection()

py::array_t<double> GetDirection ( const mitk::TimeGeometry *  tg,
mitk::TimeStepType  t 
)

Returns the direction cosine matrix (3x3) at the given time step.

Precondition
tg != nullptr
t is a valid time step of tg

Referenced by BindGeometryAccessors().

◆ GetDirectionCosines()

std::array<double, 9> GetDirectionCosines ( const mitk::TimeGeometry *  tg,
mitk::TimeStepType  t 
)

Returns the direction cosines as a flat 9-element array at the given time step.

Precondition
tg != nullptr
t is a valid time step of tg

Referenced by BindGeometryAccessors().

◆ GetGeometryForTimeStep()

mitk::BaseGeometry::Pointer GetGeometryForTimeStep ( mitk::TimeGeometry *  tg,
mitk::TimeStepType  timeStep 
)

Returns the mutable BaseGeometry for the given time step.

Precondition
tg != nullptr
timeStep is a valid time step of tg

Referenced by BindGeometryAccessors().

◆ GetOrigin()

std::tuple<double, double, double> GetOrigin ( const mitk::TimeGeometry *  tg,
mitk::TimeStepType  t 
)

Returns the origin (x, y, z) at the given time step.

Precondition
tg != nullptr
t is a valid time step of tg

Referenced by BindGeometryAccessors(), and mitk::PlaneGeometry::SignedDistanceFromPlane().

◆ GetSpacing()

std::tuple<double, double, double> GetSpacing ( const mitk::TimeGeometry *  tg,
mitk::TimeStepType  t 
)

Returns the voxel spacing (x, y, z) at the given time step.

Precondition
tg != nullptr
t is a valid time step of tg

Referenced by BindGeometryAccessors().

◆ SetDirection()

void SetDirection ( mitk::TimeGeometry *  tg,
py::array_t< double, py::array::c_style|py::array::forcecast >  direction,
mitk::TimeStepType  t 
)

Sets the direction cosine matrix at the given time step.

Precondition
tg != nullptr
t is a valid time step of tg
direction must be a 3x3 matrix

Referenced by BindGeometryAccessors().

◆ SetOrigin()

void SetOrigin ( mitk::TimeGeometry *  tg,
const std::array< double, 3 > &  origin,
mitk::TimeStepType  t 
)

Sets the origin at the given time step.

Precondition
tg != nullptr
t is a valid time step of tg

Referenced by BindGeometryAccessors().

◆ SetSpacing()

void SetSpacing ( mitk::TimeGeometry *  tg,
const std::array< double, 3 > &  spacing,
mitk::TimeStepType  t 
)

Sets the voxel spacing at the given time step.

Precondition
tg != nullptr
t is a valid time step of tg
all elements of spacing must be positive

Referenced by BindGeometryAccessors().