MCPcopy Create free account
hub / github.com/MITK/MITK / SetDirection

Function SetDirection

Wrapping/Python/mitk/GeometryHelpers.cpp:97–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95}
96
97void SetDirection(mitk::TimeGeometry* tg, py::array_t<double, py::array::c_style | py::array::forcecast> direction, mitk::TimeStepType t)
98{
99 if (direction.ndim() != 2 || direction.shape(0) != 3 || direction.shape(1) != 3)
100 throw py::value_error("direction must be a 3x3 matrix");
101
102 auto geom = GetGeometryForTimeStep(tg, t);
103 auto buf = direction.unchecked<2>();
104 const auto spacing = geom->GetSpacing();
105
106 auto* transform = geom->GetIndexToWorldTransform();
107 auto matrix = transform->GetMatrix();
108
109 for (int row = 0; row < 3; ++row)
110 for (int col = 0; col < 3; ++col)
111 matrix[row][col] = buf(row, col) * spacing[col];
112
113 transform->SetMatrix(matrix);
114 geom->Modified();
115}
116
117std::array<double, 9> GetDirectionCosines(const mitk::TimeGeometry* tg, mitk::TimeStepType t)
118{

Callers 2

BindGeometryAccessorsFunction · 0.85
ImageFromNumpyFunction · 0.85

Calls 6

GetGeometryForTimeStepFunction · 0.85
GetMatrixMethod · 0.80
SetMatrixMethod · 0.80
GetSpacingMethod · 0.45
ModifiedMethod · 0.45

Tested by

no test coverage detected