LSST Applications g0d97872fb5+76bdf3f114,g1653933729+34a971ddd9,g28da252d5a+072f89fe25,g2bbee38e9b+a99b0ab4cd,g2bc492864f+a99b0ab4cd,g2ca4be77d2+cae847d7e5,g2cdde0e794+704103fe75,g3156d2b45e+6e87dc994a,g347aa1857d+a99b0ab4cd,g35bb328faa+34a971ddd9,g3a166c0a6a+a99b0ab4cd,g3e281a1b8c+8ec26ec694,g4005a62e65+ba0306790b,g414038480c+9ed5ed841a,g569e0e2b34+cb4faa46ad,g5a97de2502+520531a62c,g717e5f8c0f+29153700a5,g7ede599f99+924b0fe0eb,g80478fca09+17051a22cc,g82479be7b0+061a565528,g858d7b2824+29153700a5,g8b782ad322+29153700a5,g8cd86fa7b1+05420e7f7d,g9125e01d80+34a971ddd9,ga5288a1d22+e7f674aaf3,gae0086650b+34a971ddd9,gae74b0b5c6+45ef5cdc51,gb58c049af0+ace264a4f2,gc28159a63d+a99b0ab4cd,gcf0d15dbbd+8051a81198,gda6a2b7d83+8051a81198,gdaeeff99f8+7774323b41,gdf4d240d4a+34a971ddd9,ge2409df99d+de9c54f8ec,ge33fd446bb+29153700a5,ge79ae78c31+a99b0ab4cd,gf0baf85859+890af219f9,gf5289d68f6+234e029470,w.2024.36
LSST Data Management Base Package
Loading...
Searching...
No Matches
interval.h
Go to the documentation of this file.
1/*
2 * This file is part of sphgeom.
3 *
4 * Developed for the LSST Data Management System.
5 * This product includes software developed by the LSST Project
6 * (http://www.lsst.org).
7 * See the COPYRIGHT file at the top-level directory of this distribution
8 * for details of code ownership.
9 *
10 * This software is dual licensed under the GNU General Public License and also
11 * under a 3-clause BSD license. Recipients may choose which of these licenses
12 * to use; please see the files gpl-3.0.txt and/or bsd_license.txt,
13 * respectively. If you choose the GPL option then the following text applies
14 * (but note that there is still no warranty even if you opt for BSD instead):
15 *
16 * This program is free software: you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation, either version 3 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 */
29
30#ifndef LSST_SPHGEOM_PYTHON_INTERVAL_H_
31#define LSST_SPHGEOM_PYTHON_INTERVAL_H_
32
33#include "pybind11/pybind11.h"
34
35#include "relationship.h"
36
37namespace py = pybind11;
38using namespace pybind11::literals;
39
40namespace lsst {
41namespace sphgeom {
42namespace python {
43namespace {
44
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; },
54 py::is_operator());
55 cls.def("__eq__",
56 [](Class const& self, Scalar other) { return self == other; },
57 py::is_operator());
58 cls.def("__ne__", [](Class const& self,
59 Class const& other) { return self != other; },
60 py::is_operator());
61 cls.def("__ne__",
62 [](Class const& self, Scalar other) { return self != other; },
63 py::is_operator());
64
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(); });
70
71 cls.def("__contains__", [](Class const& self,
72 Scalar other) { return self.contains(other); },
73 py::is_operator());
74 cls.def("__contains__",
75 [](Class const& self, Class const& other) {
76 return self.contains(other);
77 },
78 py::is_operator());
79
80 cls.def("contains", [](Class const& self, Scalar other) {
81 return self.contains(other);
82 });
83 cls.def("contains", [](Class const& self, Class const& other) {
84 return self.contains(other);
85 });
86 cls.def("isDisjointFrom", [](Class const& self, Scalar other) {
87 return self.isDisjointFrom(other);
88 });
89 cls.def("isDisjointFrom", [](Class const& self, Class const& other) {
90 return self.isDisjointFrom(other);
91 });
92 cls.def("intersects", [](Class const& self, Scalar other) {
93 return self.intersects(other);
94 });
95 cls.def("intersects", [](Class const& self, Class const& other) {
96 return self.intersects(other);
97 });
98 cls.def("isWithin", [](Class const& self, Scalar other) {
99 return self.isWithin(other);
100 });
101 cls.def("isWithin", [](Class const& self, Class const& other) {
102 return self.isWithin(other);
103 });
104 cls.def("relate", [](Class const& self, Scalar other) {
105 return self.relate(other);
106 });
107 cls.def("relate", [](Class const& self, Class const& other) {
108 return self.relate(other);
109 });
110
111 // Note that when a reference to *this is returned in C++, it will
112 // have an existing wrapper object which is automatically returned
113 // by pybind11 - no return value policy is needed. The explicit
114 // reference return type for the corresponding lambdas seems to be
115 // required to obtain this behavior.
116
117 cls.def("clipTo", [](Class& self, Scalar other) -> Class & {
118 self.clipTo(other);
119 return self;
120 });
121 cls.def("clipTo", [](Class& self, Class const& other) -> Class & {
122 self.clipTo(other);
123 return self;
124 });
125 cls.def("clippedTo", [](Class const& self, Scalar other) {
126 Class instance = self.clippedTo(other);
127 return instance;
128 });
129 cls.def("clippedTo", [](Class const& self, Class const& other) {
130 Class instance = self.clippedTo(other);
131 return instance;
132 });
133 cls.def("expandTo", [](Class& self, Scalar other) -> Class & {
134 self.expandTo(other);
135 return self;
136 });
137 cls.def("expandTo", [](Class& self, Class const& other) -> Class & {
138 self.expandTo(other);
139 return self;
140 });
141 cls.def("expandedTo", [](Class const& self, Scalar other) {
142 Class instance = self.expandedTo(other);
143 return instance;
144 });
145 cls.def("expandedTo", [](Class const& self, Class const& other) {
146 Class instance = self.expandedTo(other);
147 return instance;
148 });
149
150 cls.def("dilateBy", [](Class& self, Scalar other) -> Class & {
151 self.dilateBy(other);
152 return self;
153 });
154 cls.def("dilatedBy", [](Class const& self, Scalar other) {
155 Class instance = self.dilatedBy(other);
156 return instance;
157 });
158 cls.def("erodeBy", [](Class& self, Scalar other) -> Class & {
159 self.erodeBy(other);
160 return self;
161 });
162 cls.def("erodedBy", [](Class const& self, Scalar other) {
163 Class instance = self.erodedBy(other);
164 return instance;
165 });
166
167 cls.def("__reduce__", [cls](Class const &self) {
168 return py::make_tuple(cls, py::make_tuple(self.getA(), self.getB()));
169 });
170}
171
172} // unnamed
173} // python
174} // sphgeom
175} // lsst
176
177#endif // LSST_SPHGEOM_PYTHON_INTERVAL_H_