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

Function InitPoint2D

Wrapping/Python/mitk/Points.cpp:19–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17using namespace mitk;
18
19void InitPoint2D(py::module_& m)
20{
21 py::class_<Point2D>(m, "Point2D",
22 R"(2D point in world coordinates.
23
24A pair of double-precision scalars accessible by index or by ``x`` / ``y``
25attributes.
26
27Examples:
28 >>> p = mitk.Point2D(1.0, 2.0)
29 >>> p.x, p.y
30 (1.0, 2.0)
31 >>> p[0]
32 1.0
33)")
34 .def(py::init<>(),
35 "Construct a point at the origin (0, 0).")
36 .def(py::init<ScalarType, ScalarType>(), py::arg("x"), py::arg("y"),
37 R"(Construct a point at the given coordinates.
38
39Args:
40 x: X coordinate.
41 y: Y coordinate.
42)")
43 .def("__getitem__", [](const Point2D& p, size_t i) { return p[i]; },
44 "Return the i-th coordinate (0 = x, 1 = y).")
45 .def("__setitem__", [](Point2D& p, size_t i, ScalarType v) { p[i] = v; },
46 "Set the i-th coordinate.")
47 .def_property("x",
48 [](const Point2D& p) { return p[0]; },
49 [](Point2D& p, ScalarType v) { p[0] = v; },
50 "X coordinate.")
51 .def_property("y",
52 [](const Point2D& p) { return p[1]; },
53 [](Point2D& p, ScalarType v) { p[1] = v; },
54 "Y coordinate.")
55 .def("__repr__",
56 [](const Point2D& p) {
57 return "<Point2D ["
58 + std::to_string(p[0]) + ", "
59 + std::to_string(p[1]) + "]>";
60 });
61}
62
63void InitPoint3D(py::module_& m)
64{

Callers 1

InitPointsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected