30#ifndef LSST_SPHGEOM_PYTHON_INTERVAL_H_
31#define LSST_SPHGEOM_PYTHON_INTERVAL_H_
33#include "pybind11/pybind11.h"
35#include "relationship.h"
37namespace py = pybind11;
38using namespace pybind11::literals;
50template <
typename PyClass,
typename Class,
typename Scalar>
51void defineInterval(PyClass& cls) {
52 cls.def(
"__eq__", [](Class
const& self,
53 Class
const& other) {
return self == other; },
56 [](Class
const& self, Scalar other) {
return self == other; },
58 cls.def(
"__ne__", [](Class
const& self,
59 Class
const& other) {
return self != other; },
62 [](Class
const& self, Scalar other) {
return self != other; },
65 cls.def(
"getA", [](Class
const& self) {
return self.getA(); });
66 cls.def(
"getB", [](Class
const& self) {
return self.getB(); });
67 cls.def(
"isEmpty", [](Class
const& self) {
return self.isEmpty(); });
68 cls.def(
"getCenter", [](Class
const& self) {
return self.getCenter(); });
69 cls.def(
"getSize", [](Class
const& self) {
return self.getSize(); });
71 cls.def(
"__contains__", [](Class
const& self,
72 Scalar other) {
return self.contains(other); },
74 cls.def(
"__contains__",
75 [](Class
const& self, Class
const& other) {
76 return self.contains(other);
80 cls.def(
"contains", [](Class
const& self, Scalar other) {
81 return self.contains(other);
83 cls.def(
"contains", [](Class
const& self, Class
const& other) {
84 return self.contains(other);
86 cls.def(
"isDisjointFrom", [](Class
const& self, Scalar other) {
87 return self.isDisjointFrom(other);
89 cls.def(
"isDisjointFrom", [](Class
const& self, Class
const& other) {
90 return self.isDisjointFrom(other);
92 cls.def(
"intersects", [](Class
const& self, Scalar other) {
93 return self.intersects(other);
95 cls.def(
"intersects", [](Class
const& self, Class
const& other) {
96 return self.intersects(other);
98 cls.def(
"isWithin", [](Class
const& self, Scalar other) {
99 return self.isWithin(other);
101 cls.def(
"isWithin", [](Class
const& self, Class
const& other) {
102 return self.isWithin(other);
104 cls.def(
"relate", [](Class
const& self, Scalar other) {
105 return self.relate(other);
107 cls.def(
"relate", [](Class
const& self, Class
const& other) {
108 return self.relate(other);
117 cls.def(
"clipTo", [](Class& self, Scalar other) -> Class & {
121 cls.def(
"clipTo", [](Class& self, Class
const& other) -> Class & {
125 cls.def(
"clippedTo", [](Class
const& self, Scalar other) {
126 Class instance = self.clippedTo(other);
129 cls.def(
"clippedTo", [](Class
const& self, Class
const& other) {
130 Class instance = self.clippedTo(other);
133 cls.def(
"expandTo", [](Class& self, Scalar other) -> Class & {
134 self.expandTo(other);
137 cls.def(
"expandTo", [](Class& self, Class
const& other) -> Class & {
138 self.expandTo(other);
141 cls.def(
"expandedTo", [](Class
const& self, Scalar other) {
142 Class instance = self.expandedTo(other);
145 cls.def(
"expandedTo", [](Class
const& self, Class
const& other) {
146 Class instance = self.expandedTo(other);
150 cls.def(
"dilateBy", [](Class& self, Scalar other) -> Class & {
151 self.dilateBy(other);
154 cls.def(
"dilatedBy", [](Class
const& self, Scalar other) {
155 Class instance = self.dilatedBy(other);
158 cls.def(
"erodeBy", [](Class& self, Scalar other) -> Class & {
162 cls.def(
"erodedBy", [](Class
const& self, Scalar other) {
163 Class instance = self.erodedBy(other);
167 cls.def(
"__reduce__", [cls](Class
const &self) {
168 return py::make_tuple(cls, py::make_tuple(self.getA(), self.getB()));