lsst.afw  14.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
transformFactory.cc
Go to the documentation of this file.
1 /*
2 * LSST Data Management System
3 * See COPYRIGHT file at the top of the source tree.
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 <http://www.lsstcorp.org/LegalNotices/>.
21 */
22 #include "pybind11/pybind11.h"
23 #include "pybind11/stl.h" // Needed because some Endpoints are vectors
24 
25 #include "numpy/arrayobject.h"
26 #include "ndarray/pybind11.h"
27 
28 #include "lsst/afw/geom/Endpoint.h"
30 
31 namespace py = pybind11;
32 using namespace py::literals;
33 
34 namespace lsst {
35 namespace afw {
36 namespace geom {
37 namespace {
38 
39 // Declare methods on Transform<FromEndpoint, ToEndpoint>
40 template <class FromEndpoint, class ToEndpoint>
41 void declareFunctionTemplates(py::module &mod) {
42  using Class = Transform<FromEndpoint, ToEndpoint>;
43 
44  mod.def("linearizeTransform",
45  (Class(*)(Class const &, typename Class::FromPoint const &)) & linearizeTransform);
46 }
47 
48 PYBIND11_PLUGIN(transformFactory) {
49  py::module mod("transformFactory");
50 
51  py::module::import("lsst.afw.geom.transform");
52 
53  // Need to import numpy for ndarray and eigen conversions
54  if (_import_array() < 0) {
55  PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import");
56  return nullptr;
57  }
58 
59  declareFunctionTemplates<GenericEndpoint, GenericEndpoint>(mod);
60  declareFunctionTemplates<GenericEndpoint, Point2Endpoint>(mod);
61  declareFunctionTemplates<Point2Endpoint, GenericEndpoint>(mod);
62  declareFunctionTemplates<Point2Endpoint, Point2Endpoint>(mod);
63 
64  return mod.ptr();
65 }
66 
67 } // <anonymous>
68 } // geom
69 } // afw
70 } // lsst
PYBIND11_PLUGIN(_cameraPoint)
Definition: cameraPoint.cc:35
Transform< FromEndpoint, ToEndpoint > linearizeTransform(Transform< FromEndpoint, ToEndpoint > const &original, typename Transform< FromEndpoint, ToEndpoint >::FromPoint const &point)
Approximate a Transform by its local linearization.