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

Function InitBaseGeometry

Wrapping/Python/mitk/Geometries.cpp:26–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24using namespace mitk;
25
26void InitBaseGeometry(py::module_& m)
27{
28 py::class_<BaseGeometry, BaseGeometry::Pointer>(m, "BaseGeometry",
29 R"(Spatial geometry of a 3D object.
30
31A ``BaseGeometry`` ties the discrete index space (voxel indices) of an
32image or data object to a continuous world coordinate system. It carries:
33
34- An **origin**: world coordinates of the index ``(0, 0, 0)``.
35- A **spacing**: world distance between adjacent indices along each axis.
36- A **direction cosine matrix**: orientation of the index axes in world
37 space.
38- **Bounds**: the index-space extent of the data.
39
40``BaseGeometry`` is abstract. The concrete subclasses bound here are
41:py:class:`Geometry3D`, :py:class:`PlaneGeometry`, and
42:py:class:`SlicedGeometry3D`.
43)")
44 .def_property("image_geometry", &BaseGeometry::GetImageGeometry, &BaseGeometry::SetImageGeometry,
45 R"(Whether this geometry is interpreted as an image geometry.
46
47When True, world coordinates address voxel centers (corner-based addressing
48shifted by half a voxel); when False, world coordinates address voxel
49corners.
50)")
51 .def_property("origin", &BaseGeometry::GetOrigin, &BaseGeometry::SetOrigin,
52 "World coordinates of the index ``(0, 0, 0)`` as a :py:class:`Point3D`.")
53 .def_property("spacing", &BaseGeometry::GetSpacing, &BaseGeometry::SetSpacing,
54 "Voxel spacing in world units as a :py:class:`Vector3D` ``(sx, sy, sz)``.")
55 .def("enforce_spacing",
56 [](BaseGeometry& g, const Vector3D& s) {
57 g.SetSpacing(s, true);
58 },
59 py::arg("spacing"),
60 R"(Set spacing and rescale the index-to-world transform accordingly.
61
62Equivalent to ``SetSpacing(spacing, enforceSetSpacing=True)``: rather than
63storing the spacing as an independent value, the transform is rebuilt so
64that the requested spacing is preserved exactly when the matrix is
65re-decomposed.
66
67Args:
68 spacing: New spacing as a :py:class:`Vector3D`.
69)")
70 .def_property("frame_of_reference_id", &BaseGeometry::GetFrameOfReferenceID, &BaseGeometry::SetFrameOfReferenceID,
71 "DICOM Frame of Reference ID used to group geometries that share a coordinate system.")
72 .def_property("bounds",
73 [](const BaseGeometry& g) {
74 const auto b = g.GetBounds();
75 return std::vector<ScalarType>(b.begin(), b.end());
76 },
77 [](BaseGeometry& g, const std::vector<ScalarType>& v) {
78 if (v.size() != 6)
79 mitkThrow() << "Bounds must be of length 6";
80
81 BaseGeometry::BoundsArrayType b;
82 std::copy(v.begin(), v.end(), b.begin());
83

Callers 1

InitGeometriesFunction · 0.85

Calls 9

IsIndexInsideMethod · 0.80
SetSpacingMethod · 0.45
GetBoundsMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
SetBoundsMethod · 0.45
WorldToIndexMethod · 0.45
IndexToWorldMethod · 0.45

Tested by

no test coverage detected