lsst.astshim  master-gd1207e8857
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
PcdMap.h
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 #ifndef ASTSHIM_PCDMAP_H
23 #define ASTSHIM_PCDMAP_H
24 
25 #include <memory>
26 #include <sstream>
27 #include <stdexcept>
28 #include <vector>
29 
30 #include "astshim/base.h"
31 #include "astshim/detail/utils.h"
32 #include "astshim/Mapping.h"
33 
34 namespace ast {
35 
73 class PcdMap: public Mapping {
74 friend class Object;
75 public:
86  PcdMap(double disco, std::vector<double> const & pcdcen, std::string const & options="") :
87  Mapping(reinterpret_cast<AstMapping *>(_makeRawPcdMap(disco, pcdcen, options)))
88  {}
89 
90  virtual ~PcdMap() {}
91 
92  PcdMap(PcdMap const &) = delete;
93  PcdMap(PcdMap &&) = default;
94  PcdMap & operator=(PcdMap const &) = delete;
95  PcdMap & operator=(PcdMap &&) = default;
96 
98  std::shared_ptr<PcdMap> copy() const {
99  return std::static_pointer_cast<PcdMap>(_copyPolymorphic());
100  }
101 
103  double getDisco() const { return getD("Disco"); };
104 
106  double getPcdCen(int axis) const { return getD(detail::formatAxisAttr("PcdCen", axis)); }
107 
109  std::vector<double> getPcdCen() const {
110  std::vector<double> ctr;
111  for (auto axis = 1; axis < 3; ++axis) {
112  ctr.push_back(getPcdCen(axis));
113  }
114  return ctr;
115  }
116 
117 protected:
118  virtual std::shared_ptr<Object> _copyPolymorphic() const override {
119  return _copyImpl<PcdMap, AstPcdMap>();
120  }
121 
123  explicit PcdMap(AstPcdMap * rawptr) :
124  Mapping(reinterpret_cast<AstMapping *>(rawptr))
125  {
126  if (!astIsAPcdMap(getRawPtr())) {
127  std::ostringstream os;
128  os << "this is a " << getClass() << ", which is not a PcdMap";
129  throw std::invalid_argument(os.str());
130  }
131  }
132 
133 private:
134  AstPcdMap *_makeRawPcdMap(double disco, std::vector<double> const &pcdcen,
135  std::string const &options = "") {
136  if (pcdcen.size() != 2) {
137  std::ostringstream os;
138  os << "pcdcen.size() = " << pcdcen.size() << "; must be 2";
139  throw std::invalid_argument(os.str());
140  }
141  return astPcdMap(disco, pcdcen.data(), options.c_str());
142  }
143 };
144 
145 } // namespace ast
146 
147 #endif
virtual std::shared_ptr< Object > _copyPolymorphic() const override
Definition: PcdMap.h:118
PcdMap(AstPcdMap *rawptr)
Construct a PcdMap from a raw AST pointer.
Definition: PcdMap.h:123
std::vector< double > getPcdCen() const
Get PcdMap_PcdCen PcdCen for both axes: centre coordinates of pincushion/barrel distortion.
Definition: PcdMap.h:109
double getPcdCen(int axis) const
Get PcdMap_PcdCen PcdCen(axis) for one axis: centre coordinates of pincushion/barrel distortion...
Definition: PcdMap.h:106
std::string getClass() const
Definition: Object.h:117
Definition: Mapping.h:59
Definition: Object.h:49
std::shared_ptr< PcdMap > copy() const
Return a deep copy of this object.
Definition: PcdMap.h:98
PcdMap(double disco, std::vector< double > const &pcdcen, std::string const &options="")
Definition: PcdMap.h:86
double getD(std::string const &attrib) const
Definition: Object.h:360
Definition: PcdMap.h:73
double getDisco() const
Get Disco: pincushion/barrel distortion coefficient.
Definition: PcdMap.h:103
AstObject const * getRawPtr() const
Definition: Object.h:260