22 #include "pybind11/pybind11.h"
23 #include "pybind11/stl.h"
39 using namespace pybind11::literals;
46 uint8_t
const *buffer =
reinterpret_cast<uint8_t
const *
>(
47 PYBIND11_BYTES_AS_STRING(
bytes.ptr()));
48 size_t n =
static_cast<size_t>(PYBIND11_BYTES_SIZE(
bytes.ptr()));
49 return ConvexPolygon::decode(buffer, n);
53 py::module::import(
"lsst.sphgeom.region");
55 py::class_<ConvexPolygon, std::unique_ptr<ConvexPolygon>, Region>
cls(
56 mod,
"ConvexPolygon");
58 cls.attr(
"TYPE_CODE") = py::int_(ConvexPolygon::TYPE_CODE);
60 cls.def_static(
"convexHull", &ConvexPolygon::convexHull,
"points"_a);
64 cls.def(py::init<ConvexPolygon const &>(),
"convexPolygon"_a);
66 cls.def(
"__eq__", &ConvexPolygon::operator==, py::is_operator());
67 cls.def(
"__ne__", &ConvexPolygon::operator!=, py::is_operator());
69 cls.def(
"getVertices", &ConvexPolygon::getVertices);
70 cls.def(
"getCentroid", &ConvexPolygon::getCentroid);
75 cls.def(
"isDisjointFrom", &ConvexPolygon::isDisjointFrom);
76 cls.def(
"intersects", &ConvexPolygon::intersects);
77 cls.def(
"isWithin", &ConvexPolygon::isWithin);
81 cls.def_static(
"decode",
85 cls.def(
"__repr__", [](ConvexPolygon
const &
self) {
86 return py::str(
"ConvexPolygon({!r})").format(
self.getVertices());
89 [](
const ConvexPolygon &
self) {
return python::encode(
self); },