25 #include <pybind11/pybind11.h> 26 #include <pybind11/stl.h> 28 #include "lsst/pex/exceptions/Runtime.h" 29 #include "lsst/pex/exceptions/python/Exception.h" 38 namespace py = pybind11;
47 py::module mod(
"_polygon",
"Python wrapper for afw _polygon library");
53 table::io::python::declarePersistableFacade<Polygon>(mod,
"Polygon");
57 clsPolygon(mod,
"Polygon");
59 pex::exceptions::python::declareException<SinglePolygonException, pex::exceptions::RuntimeError>(
60 mod,
"SinglePolygonException",
"RuntimeError");
65 clsPolygon.def(py::init<Polygon::Box const &>());
66 clsPolygon.def(py::init<
Polygon::Box const &, std::shared_ptr<XYTransform const>
const &>());
67 clsPolygon.def(py::init<Polygon::Box const &, AffineTransform const &>());
68 clsPolygon.def(py::init<std::vector<Polygon::Point>
const &>());
71 clsPolygon.def(
"__eq__", [](
Polygon const &
self,
Polygon const &other) {
return self == other; },
73 clsPolygon.def(
"__ne__", [](
Polygon const &
self,
Polygon const &other) {
return self != other; },
77 clsPolygon.def(
"getNumEdges", &Polygon::getNumEdges);
78 clsPolygon.def(
"getBBox", &Polygon::getBBox);
79 clsPolygon.def(
"calculateCenter", &Polygon::calculateCenter);
80 clsPolygon.def(
"calculateArea", &Polygon::calculateArea);
81 clsPolygon.def(
"calculatePerimeter", &Polygon::calculatePerimeter);
82 clsPolygon.def(
"getVertices", &Polygon::getVertices);
83 clsPolygon.def(
"getEdges", &Polygon::getEdges);
84 clsPolygon.def(
"contains", &Polygon::contains);
85 clsPolygon.def(
"overlaps", (
bool (
Polygon::*)(
Polygon const &)
const) & Polygon::overlaps);
86 clsPolygon.def(
"overlaps", (
bool (
Polygon::*)(
Polygon::Box const &)
const) & Polygon::overlaps);
87 clsPolygon.def(
"intersectionSingle", (std::shared_ptr<Polygon> (
Polygon::*)(
Polygon const &)
const) &
88 Polygon::intersectionSingle);
89 clsPolygon.def(
"intersectionSingle", (std::shared_ptr<Polygon> (
Polygon::*)(
Polygon::Box const &)
const) &
90 Polygon::intersectionSingle);
91 clsPolygon.def(
"intersection",
92 (std::vector<std::shared_ptr<Polygon>> (
Polygon::*)(
Polygon const &)
const) &
93 Polygon::intersection);
94 clsPolygon.def(
"intersection",
96 Polygon::intersection);
97 clsPolygon.def(
"unionSingle",
98 (std::shared_ptr<Polygon> (
Polygon::*)(
Polygon const &)
const) & Polygon::unionSingle);
99 clsPolygon.def(
"unionSingle", (std::shared_ptr<Polygon> (
Polygon::*)(
Polygon::Box const &)
const) &
100 Polygon::unionSingle);
103 clsPolygon.def(
"union", (std::vector<std::shared_ptr<Polygon>> (
Polygon::*)(
Polygon const &)
const) &
105 clsPolygon.def(
"union", (std::vector<std::shared_ptr<Polygon>> (
Polygon::*)(
Polygon::Box const &)
const) &
107 clsPolygon.def(
"symDifference",
108 (std::vector<std::shared_ptr<Polygon>> (
Polygon::*)(
Polygon const &)
const) &
109 Polygon::symDifference);
110 clsPolygon.def(
"symDifference",
112 Polygon::symDifference);
114 clsPolygon.def(
"convexHull", &Polygon::convexHull);
115 clsPolygon.def(
"transform",
116 (std::shared_ptr<Polygon> (
Polygon::*)(std::shared_ptr<XYTransform const>
const &)
const) &
120 clsPolygon.def(
"subSample", (std::shared_ptr<Polygon> (
Polygon::*)(
size_t)
const) & Polygon::subSample);
121 clsPolygon.def(
"subSample", (std::shared_ptr<Polygon> (
Polygon::*)(
double)
const) & Polygon::subSample);
122 clsPolygon.def(
"createImage",
124 Polygon::createImage);
125 clsPolygon.def(
"createImage",
127 Polygon::createImage);
An integer coordinate rectangle.
A base class for objects that can be persisted via afw::table::io Archive classes.
A base class for image defects.
PYBIND11_PLUGIN(_polygon)
A floating-point coordinate rectangle geometry.
A class to represent a 2-dimensional array of pixels.