lsst.afw  13.0-98-g5a654715e+2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
transformMap.cc
Go to the documentation of this file.
1 /*
2  * LSST Data Management System
3  * Copyright 2016 AURA/LSST.
4  *
5  * This product includes software developed by the
6  * LSST Project (http://www.lsst.org/).
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the LSST License Statement and
19  * the GNU General Public License along with this program. If not,
20  * see <https://www.lsstcorp.org/LegalNotices/>.
21  */
22 #include "pybind11/pybind11.h"
23 #include "pybind11/stl.h"
24 
25 #include <vector>
26 
27 #include "lsst/afw/geom/Point.h"
30 
31 namespace py = pybind11;
32 using namespace py::literals;
33 
34 namespace lsst {
35 namespace afw {
36 namespace cameraGeom {
37 
38 PYBIND11_PLUGIN(_transformMap) {
39  py::module mod("_transformMap");
40 
41  /* Module level */
42  py::class_<TransformMap, std::shared_ptr<TransformMap>> cls(mod, "TransformMap");
43 
44  /* Member types and enums */
45 
46  /* Constructors */
47  cls.def(pybind11::init<
48  CameraSys const &,
49  std::unordered_map<CameraSys, std::shared_ptr<geom::TransformPoint2ToPoint2>> const &>(),
50  "reference"_a, "transforms"_a);
51 
52  /* Operators */
53  cls.def("__len__", &TransformMap::size);
54  cls.def("__contains__", &TransformMap::contains);
55  cls.def("__iter__", [](const TransformMap &self) { return py::make_iterator(self.begin(), self.end()); },
56  py::keep_alive<0, 1>()); /* Essential: keep object alive while iterator exists */
57 
58  /* Members */
59  cls.def("transform",
60  (geom::Point2D(TransformMap::*)(geom::Point2D const &, CameraSys const &, CameraSys const &)
61  const) &
62  TransformMap::transform,
63  "point"_a, "fromSys"_a, "toSys"_a);
64  cls.def("transform",
65  (std::vector<geom::Point2D>(TransformMap::*)(std::vector<geom::Point2D> const &,
66  CameraSys const &, CameraSys const &) const) &
67  TransformMap::transform,
68  "pointList"_a, "fromSys"_a, "toSys"_a);
69  cls.def("getTransform", &TransformMap::getTransform, "fromSys"_a, "toSys"_a);
70 
71  return mod.ptr();
72 }
73 
74 } // namespace cameraGeom
75 } // namespace afw
76 } // namespace lsst
A registry of 2-dimensional coordinate transforms for a specific camera.
Definition: TransformMap.h:57
Camera coordinate system; used as a key in in TransformMap.
Definition: CameraSys.h:77
PYBIND11_PLUGIN(_cameraPoint)
Definition: cameraPoint.cc:35
double const _a
Definition: RandomImage.cc:77
int end