22 #include "pybind11/pybind11.h" 23 #include "pybind11/stl.h" 37 [](
auto & mod,
auto &
cls)
mutable {
39 cls.attr(
"Point") = mod.attr(
"Point2I");
40 cls.attr(
"Extent") = mod.attr(
"Extent2I");
42 py::enum_<Box2I::EdgeHandlingEnum>(cls,
"EdgeHandlingEnum")
43 .value(
"EXPAND", Box2I::EdgeHandlingEnum::EXPAND)
44 .value(
"SHRINK", Box2I::EdgeHandlingEnum::SHRINK)
47 cls.def(py::init<>());
48 cls.def(py::init<Point2I const &, Point2I const &, bool>(),
"minimum"_a,
"maximum"_a,
50 cls.def(py::init<Point2I const &, Extent2I const &, bool>(),
"corner"_a,
"dimensions"_a,
52 cls.def(py::init<Box2D const &, Box2I::EdgeHandlingEnum>(),
"other"_a,
53 "edgeHandling"_a = Box2I::EXPAND);
54 cls.def(py::init<Box2I const &>(),
"other"_a);
56 cls.def(
"__eq__", [](Box2I const &self, Box2I const &other) { return self == other; },
61 cls.def_static(
"makeCenteredBox", &Box2I::makeCenteredBox,
"center"_a,
"size"_a);
63 cls.def(
"getMin", &Box2I::getMin);
64 cls.def(
"getMinX", &Box2I::getMinX);
65 cls.def(
"getMinY", &Box2I::getMinY);
66 cls.def(
"getMax", &Box2I::getMax);
67 cls.def(
"getMaxX", &Box2I::getMaxX);
68 cls.def(
"getMaxY", &Box2I::getMaxY);
69 cls.def(
"getBegin", &Box2I::getBegin);
70 cls.def(
"getBeginX", &Box2I::getBeginX);
71 cls.def(
"getBeginY", &Box2I::getBeginY);
72 cls.def(
"getEnd", &Box2I::getEnd);
73 cls.def(
"getEndX", &Box2I::getEndX);
74 cls.def(
"getEndY", &Box2I::getEndY);
75 cls.def(
"getDimensions", &Box2I::getDimensions);
76 cls.def(
"getWidth", &Box2I::getWidth);
77 cls.def(
"getHeight", &Box2I::getHeight);
78 cls.def(
"getArea", &Box2I::getArea);
79 cls.def(
"getCenter", &Box2I::getCenter);
80 cls.def(
"getCenterX", &Box2I::getCenterX);
81 cls.def(
"getCenterY", &Box2I::getCenterY);
82 cls.def(
"isEmpty", &Box2I::isEmpty);
84 cls.def(
"contains", (
bool (
Box2I::*)(
Box2I const &)
const) & Box2I::contains);
85 cls.def(
"__contains__", (
bool (
Box2I::*)(
Point2I const &)
const) & Box2I::contains);
86 cls.def(
"__contains__", (
bool (
Box2I::*)(
Box2I const &)
const) & Box2I::contains);
87 cls.def(
"overlaps", &Box2I::overlaps);
88 cls.def(
"grow", (
void (
Box2I::*)(
int)) & Box2I::grow);
90 cls.def(
"shift", &Box2I::shift);
91 cls.def(
"flipLR", &Box2I::flipLR);
92 cls.def(
"flipTB", &Box2I::flipTB);
93 cls.def(
"include", (
void (
Box2I::*)(
Point2I const &)) & Box2I::include);
94 cls.def(
"include", (
void (
Box2I::*)(
Box2I const &)) & Box2I::include);
95 cls.def(
"clip", &Box2I::clip);
96 cls.def(
"getCorners", &Box2I::getCorners);
97 cls.def(
"toString", &Box2I::toString);
98 cls.def(
"__repr__", [](
Box2I const &
self) {
99 return py::str(
"Box2I(minimum={}, dimensions={})")
100 .format(py::repr(py::cast(
self.getMin())), py::repr(py::cast(
self.getDimensions())));
102 cls.def(
"__str__", [](
Box2I const &
self) {
103 return py::str(
"(minimum={}, maximum={})")
104 .format(
py::str(py::cast(
self.getMin())),
py::str(py::cast(
self.getMax())));
107 return py::make_tuple(
cls, make_tuple(py::cast(
self.getMin()), py::cast(
self.getMax())));
109 cls.def(
"getSlices", [](
Box2I const &
self) {
110 return py::make_tuple(py::slice(
self.getBeginY(),
self.getEndY(), 1),
111 py::slice(
self.getBeginX(),
self.getEndX(), 1));
114 mod.attr(
"BoxI") =
cls;
120 [](
auto & mod,
auto &
cls)
mutable {
122 cls.attr(
"Point") = mod.attr(
"Point2D");
123 cls.attr(
"Extent") = mod.attr(
"Extent2D");
125 cls.attr(
"EPSILON") = py::float_(Box2D::EPSILON);
126 cls.attr(
"INVALID") = py::float_(Box2D::INVALID);
128 cls.def(py::init<>());
129 cls.def(py::init<Point2D const &, Point2D const &, bool>(),
"minimum"_a,
"maximum"_a,
131 cls.def(py::init<Point2D const &, Extent2D const &, bool>(),
"corner"_a,
"dimensions"_a,
133 cls.def(py::init<Box2I const &>());
134 cls.def(py::init<Box2D const &>());
136 cls.def(
"__eq__", [](Box2D const &self, Box2D const &other) { return self == other; },
141 cls.def_static(
"makeCenteredBox", &Box2D::makeCenteredBox,
"center"_a,
"size"_a);
143 cls.def(
"getMin", &Box2D::getMin);
144 cls.def(
"getMinX", &Box2D::getMinX);
145 cls.def(
"getMinY", &Box2D::getMinY);
146 cls.def(
"getMax", &Box2D::getMax);
147 cls.def(
"getMaxX", &Box2D::getMaxX);
148 cls.def(
"getMaxY", &Box2D::getMaxY);
149 cls.def(
"getDimensions", &Box2D::getDimensions);
150 cls.def(
"getWidth", &Box2D::getWidth);
151 cls.def(
"getHeight", &Box2D::getHeight);
152 cls.def(
"getArea", &Box2D::getArea);
153 cls.def(
"getCenter", &Box2D::getCenter);
154 cls.def(
"getCenterX", &Box2D::getCenterX);
155 cls.def(
"getCenterY", &Box2D::getCenterY);
156 cls.def(
"isEmpty", &Box2D::isEmpty);
158 cls.def(
"contains", (
bool (
Box2D::*)(
Box2D const &)
const) & Box2D::contains);
159 cls.def(
"__contains__", (
bool (
Box2D::*)(
Point2D const &)
const) & Box2D::contains);
160 cls.def(
"__contains__", (
bool (
Box2D::*)(
Box2D const &)
const) & Box2D::contains);
161 cls.def(
"overlaps", &Box2D::overlaps);
162 cls.def(
"grow", (
void (
Box2D::*)(
double)) & Box2D::grow);
165 cls.def(
"shift", &Box2D::shift);
166 cls.def(
"flipLR", &Box2D::flipLR);
167 cls.def(
"flipTB", &Box2D::flipTB);
168 cls.def(
"include", (
void (
Box2D::*)(
Point2D const &)) & Box2D::include);
169 cls.def(
"include", (
void (
Box2D::*)(
Box2D const &)) & Box2D::include);
170 cls.def(
"clip", &Box2D::clip);
171 cls.def(
"getCorners", &Box2D::getCorners);
172 cls.def(
"toString", &Box2D::toString);
173 cls.def(
"__repr__", [](
Box2D const &
self) {
174 return py::str(
"Box2D(minimum={}, dimensions={})")
175 .format(py::repr(py::cast(
self.getMin())), py::repr(py::cast(
self.getDimensions())));
177 cls.def(
"__str__", [](
Box2D const &
self) {
178 return py::str(
"(minimum={}, maximum={})")
179 .format(
py::str(py::cast(
self.getMin())),
py::str(py::cast(
self.getMax())));
182 return py::make_tuple(
cls, make_tuple(py::cast(
self.getMin()), py::cast(
self.getMax())));
185 mod.attr(
"BoxD") =
cls;
bool contains(VertexIterator const begin, VertexIterator const end, UnitVector3d const &v)
A floating-point coordinate rectangle geometry.
pybind11::module module
The module object passed to the PYBIND11_MODULE block that contains this WrapperCollection.
void wrapBox(utils::python::WrapperCollection &wrappers)
A base class for image defects.
void swap(Image< PixelT > &a, Image< PixelT > &b)
ItemVariant const * other
A helper class for subdividing pybind11 module across multiple translation units (i.e.
An integer coordinate rectangle.
PyType wrapType(PyType cls, ClassWrapperCallback function, bool setModuleName=true)
Add a type (class or enum) wrapper, deferring method and other attribute definitions until finish() i...