22 #include "pybind11/pybind11.h"
37 using namespace pybind11::literals;
44 uint8_t
const *buffer =
reinterpret_cast<uint8_t
const *
>(
45 PYBIND11_BYTES_AS_STRING(
bytes.ptr()));
46 size_t n =
static_cast<size_t>(PYBIND11_BYTES_SIZE(
bytes.ptr()));
47 return Circle::decode(buffer, n);
51 py::module::import(
"lsst.sphgeom.region");
53 py::class_<Circle, std::unique_ptr<Circle>, Region>
cls(mod,
"Circle");
55 cls.attr(
"TYPE_CODE") = py::int_(Circle::TYPE_CODE);
57 cls.def_static(
"empty", &Circle::empty);
58 cls.def_static(
"full", &Circle::full);
59 cls.def_static(
"squaredChordLengthFor", &Circle::squaredChordLengthFor,
61 cls.def_static(
"openingAngleFor", &Circle::openingAngleFor,
62 "squaredChordLength"_a);
64 cls.def(py::init<>());
65 cls.def(py::init<UnitVector3d const &>(),
"center"_a);
66 cls.def(py::init<UnitVector3d const &, Angle>(),
"center"_a,
"angle"_a);
67 cls.def(py::init<UnitVector3d const &, double>(),
"center"_a,
68 "squaredChordLength"_a);
69 cls.def(py::init<Circle const &>(),
"circle"_a);
71 cls.def(
"__eq__", &Circle::operator==, py::is_operator());
72 cls.def(
"__ne__", &Circle::operator!=, py::is_operator());
73 cls.def(
"__contains__",
77 cls.def(
"__contains__",
81 cls.def(
"isEmpty", &Circle::isEmpty);
82 cls.def(
"isFull", &Circle::isFull);
83 cls.def(
"getCenter", &Circle::getCenter);
84 cls.def(
"getSquaredChordLength", &Circle::getSquaredChordLength);
85 cls.def(
"getOpeningAngle", &Circle::getOpeningAngle);
92 cls.def(
"isDisjointFrom",
93 (
bool (Circle::*)(UnitVector3d
const &)
const) &
94 Circle::isDisjointFrom);
95 cls.def(
"isDisjointFrom",
96 (
bool (Circle::*)(Circle
const &)
const) & Circle::isDisjointFrom);
98 (
bool (Circle::*)(UnitVector3d
const &)
const) &
100 cls.def(
"intersects",
101 (
bool (Circle::*)(Circle
const &)
const) & Circle::intersects);
103 (
bool (Circle::*)(UnitVector3d
const &)
const) & Circle::isWithin);
105 (
bool (Circle::*)(Circle
const &)
const) & Circle::isWithin);
107 (Circle & (Circle::*)(UnitVector3d
const &)) & Circle::clipTo);
108 cls.def(
"clipTo", (Circle & (Circle::*)(Circle
const &)) & Circle::clipTo);
110 (Circle(Circle::*)(UnitVector3d
const &)
const) &
113 (Circle(Circle::*)(Circle
const &)
const) & Circle::clippedTo);
115 (Circle & (Circle::*)(UnitVector3d
const &)) & Circle::expandTo);
117 (Circle & (Circle::*)(Circle
const &)) & Circle::expandTo);
118 cls.def(
"expandedTo",
119 (Circle(Circle::*)(UnitVector3d
const &)
const) &
121 cls.def(
"expandedTo",
122 (Circle(Circle::*)(Circle
const &)
const) & Circle::expandedTo);
123 cls.def(
"dilateBy", &Circle::dilateBy,
"radius"_a);
124 cls.def(
"dilatedBy", &Circle::dilatedBy,
"radius"_a);
125 cls.def(
"erodeBy", &Circle::erodeBy,
"radius"_a);
126 cls.def(
"erodedBy", &Circle::erodedBy,
"radius"_a);
127 cls.def(
"getArea", &Circle::getArea);
128 cls.def(
"complement", &Circle::complement);
129 cls.def(
"complemented", &Circle::complemented);
135 cls.def_static(
"decode",
139 cls.def(
"__str__", [](Circle
const &
self) {
140 return py::str(
"Circle({!s}, {!s})")
141 .format(
self.getCenter(),
self.getOpeningAngle());
143 cls.def(
"__repr__", [](Circle
const &
self) {
144 return py::str(
"Circle({!r}, {!r})")
145 .format(
self.getCenter(),
self.getOpeningAngle());
148 [](
const Circle &
self) {
return python::encode(
self); },