| 61 | } |
| 62 | |
| 63 | void InitPoint3D(py::module_& m) |
| 64 | { |
| 65 | py::class_<Point3D>(m, "Point3D", |
| 66 | R"(3D point in world coordinates. |
| 67 | |
| 68 | A triple of double-precision scalars accessible by index or by ``x`` / |
| 69 | ``y`` / ``z`` attributes. |
| 70 | |
| 71 | Examples: |
| 72 | >>> p = mitk.Point3D(1.0, 2.0, 3.0) |
| 73 | >>> p.x, p.y, p.z |
| 74 | (1.0, 2.0, 3.0) |
| 75 | )") |
| 76 | .def(py::init<>(), |
| 77 | "Construct a point at the origin (0, 0, 0).") |
| 78 | .def(py::init<ScalarType, ScalarType, ScalarType>(), py::arg("x"), py::arg("y"), py::arg("z"), |
| 79 | R"(Construct a point at the given coordinates. |
| 80 | |
| 81 | Args: |
| 82 | x: X coordinate. |
| 83 | y: Y coordinate. |
| 84 | z: Z coordinate. |
| 85 | )") |
| 86 | .def("__getitem__", [](const Point3D& p, size_t i) { return p[i]; }, |
| 87 | "Return the i-th coordinate (0 = x, 1 = y, 2 = z).") |
| 88 | .def("__setitem__", [](Point3D& p, size_t i, ScalarType v) { p[i] = v; }, |
| 89 | "Set the i-th coordinate.") |
| 90 | .def_property("x", |
| 91 | [](const Point3D& p) { return p[0]; }, |
| 92 | [](Point3D& p, ScalarType v) { p[0] = v; }, |
| 93 | "X coordinate.") |
| 94 | .def_property("y", |
| 95 | [](const Point3D& p) { return p[1]; }, |
| 96 | [](Point3D& p, ScalarType v) { p[1] = v; }, |
| 97 | "Y coordinate.") |
| 98 | .def_property("z", |
| 99 | [](const Point3D& p) { return p[2]; }, |
| 100 | [](Point3D& p, ScalarType v) { p[2] = v; }, |
| 101 | "Z coordinate.") |
| 102 | .def("__repr__", |
| 103 | [](const Point3D& p) { |
| 104 | return "<Point3D [" |
| 105 | + std::to_string(p[0]) + ", " |
| 106 | + std::to_string(p[1]) + ", " |
| 107 | + std::to_string(p[2]) + "]>"; |
| 108 | }); |
| 109 | } |
| 110 | |
| 111 | void InitPoints(py::module_& m) |
| 112 | { |