LSSTApplications
19.0.0-14-gb0260a2+72efe9b372,20.0.0+7927753e06,20.0.0+8829bf0056,20.0.0+995114c5d2,20.0.0+b6f4b2abd1,20.0.0+bddc4f4cbe,20.0.0-1-g253301a+8829bf0056,20.0.0-1-g2b7511a+0d71a2d77f,20.0.0-1-g5b95a8c+7461dd0434,20.0.0-12-g321c96ea+23efe4bbff,20.0.0-16-gfab17e72e+fdf35455f6,20.0.0-2-g0070d88+ba3ffc8f0b,20.0.0-2-g4dae9ad+ee58a624b3,20.0.0-2-g61b8584+5d3db074ba,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+226a441f5f,20.0.0-2-gf072044+8829bf0056,20.0.0-2-gf1f7952+ee58a624b3,20.0.0-20-geae50cf+e37fec0aee,20.0.0-25-g3dcad98+544a109665,20.0.0-25-g5eafb0f+ee58a624b3,20.0.0-27-g64178ef+f1f297b00a,20.0.0-3-g4cc78c6+e0676b0dc8,20.0.0-3-g8f21e14+4fd2c12c9a,20.0.0-3-gbd60e8c+187b78b4b8,20.0.0-3-gbecbe05+48431fa087,20.0.0-38-ge4adf513+a12e1f8e37,20.0.0-4-g97dc21a+544a109665,20.0.0-4-gb4befbc+087873070b,20.0.0-4-gf910f65+5d3db074ba,20.0.0-5-gdfe0fee+199202a608,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g64f541c+d529cf1a41,20.0.0-6-g9a5b7a1+a1cd37312e,20.0.0-68-ga3f3dda+5fca18c6a4,20.0.0-9-g4aef684+e18322736b,w.2020.45
LSSTDataManagementBasePackage
|
Go to the documentation of this file.
44 template <
class FromEndpo
int,
class ToEndpo
int>
46 : _fromEndpoint(mapping.getNIn()),
47 _mapping(simplify ? mapping.
simplified() : mapping.copy()),
48 _toEndpoint(mapping.getNOut()) {}
50 template <
typename FromEndpo
int,
typename ToEndpo
int>
52 : _fromEndpoint(
frameSet.getNIn()), _mapping(), _toEndpoint(
frameSet.getNOut()) {
61 _toEndpoint.normalizeFrame(frameSetCopy);
65 const int baseIndex = frameSetCopy->getBase();
66 const int currentIndex = frameSetCopy->getCurrent();
67 frameSetCopy->setCurrent(baseIndex);
68 _fromEndpoint.normalizeFrame(frameSetCopy);
69 frameSetCopy->setBase(baseIndex);
70 frameSetCopy->setCurrent(currentIndex);
71 _mapping = simplify ? frameSetCopy->getMapping()->
simplified() : frameSetCopy->getMapping();
74 template <
typename FromEndpo
int,
typename ToEndpo
int>
76 : _fromEndpoint(mapping->getNIn()), _mapping(mapping), _toEndpoint(mapping->getNOut()) {}
78 template <
class FromEndpo
int,
class ToEndpo
int>
80 typename FromEndpoint::Point
const &point)
const {
81 auto const rawFromData = _fromEndpoint.dataFromPoint(point);
82 auto rawToData = _mapping->applyForward(rawFromData);
83 return _toEndpoint.pointFromData(rawToData);
86 template <
class FromEndpo
int,
class ToEndpo
int>
88 typename FromEndpoint::Array
const &array)
const {
89 auto const rawFromData = _fromEndpoint.dataFromArray(array);
90 auto rawToData = _mapping->applyForward(rawFromData);
91 return _toEndpoint.arrayFromData(rawToData);
94 template <
class FromEndpo
int,
class ToEndpo
int>
96 typename ToEndpoint::Point
const &point)
const {
97 auto const rawFromData = _toEndpoint.dataFromPoint(point);
98 auto rawToData = _mapping->applyInverse(rawFromData);
99 return _fromEndpoint.pointFromData(rawToData);
102 template <
class FromEndpo
int,
class ToEndpo
int>
104 typename ToEndpoint::Array
const &array)
const {
105 auto const rawFromData = _toEndpoint.dataFromArray(array);
106 auto rawToData = _mapping->applyInverse(rawFromData);
107 return _fromEndpoint.arrayFromData(rawToData);
110 template <
class FromEndpo
int,
class ToEndpo
int>
112 auto inverse = std::dynamic_pointer_cast<ast::Mapping>(_mapping->inverted());
116 buffer <<
"Mapping.inverted() does not return a Mapping. Called from: " << _mapping;
119 return std::make_shared<Transform<ToEndpoint, FromEndpoint>>(*inverse);
122 template <
class FromEndpo
int,
class ToEndpo
int>
124 int const nIn = _fromEndpoint.getNAxes();
125 int const nOut = _toEndpoint.getNAxes();
128 Eigen::MatrixXd jacobian(nOut, nIn);
129 for (
int i = 0; i < nOut; ++i) {
130 for (
int j = 0; j < nIn; ++j) {
131 jacobian(i, j) = _mapping->rate(point, i + 1, j + 1);
137 template <
class FromEndpo
int,
class ToEndpo
int>
140 os <<
"Transform" << FromEndpoint::getClassPrefix() <<
"To" << ToEndpoint::getClassPrefix();
144 template <
class FromEndpo
int,
class ToEndpo
int>
147 return detail::readStream<Transform<FromEndpoint, ToEndpoint>>(is);
150 template <
class FromEndpo
int,
class ToEndpo
int>
157 template <
class FromEndpo
int,
class ToEndpo
int>
159 detail::writeStream<Transform<FromEndpoint, ToEndpoint>>(*
this,
os);
162 template <
class FromEndpo
int,
class ToEndpo
int>
169 template <
class FromEndpo
int,
class ToEndpo
int>
170 template <
class NextToEndpo
int>
173 if (_toEndpoint.getNAxes() ==
next.getFromEndpoint().getNAxes()) {
174 auto nextMapping =
next.getMapping();
175 auto combinedMapping = getMapping()->then(*
next.getMapping());
177 return std::make_shared<Transform<FromEndpoint, NextToEndpoint>>(*combinedMapping.simplified());
179 return std::make_shared<Transform<FromEndpoint, NextToEndpoint>>(combinedMapping);
182 auto message =
"Cannot match " +
std::to_string(_toEndpoint.getNAxes()) +
"-D to-endpoint to " +
188 template <
class FromEndpo
int,
class ToEndpo
int>
196 class TransformPersistenceHelper {
199 table::Key<table::Array<std::uint8_t>>
bytes;
201 static TransformPersistenceHelper
const &get() {
202 static TransformPersistenceHelper instance;
207 TransformPersistenceHelper(TransformPersistenceHelper
const &) =
delete;
208 TransformPersistenceHelper &operator=(TransformPersistenceHelper
const &) =
delete;
211 TransformPersistenceHelper(TransformPersistenceHelper &&) =
delete;
212 TransformPersistenceHelper &operator=(TransformPersistenceHelper &&) =
delete;
215 TransformPersistenceHelper()
218 "bytes",
"a bytestring containing the output of Transform.writeString",
"")) {}
221 template <
typename FromEndpo
int,
typename ToEndpo
int>
222 class TransformFactory :
public table::io::PersistableFactory {
227 CatalogVector
const &catalogs)
const override {
228 auto const &
keys = TransformPersistenceHelper::get();
232 auto const &record = catalogs.front().front();
240 template <
class FromEndpo
int,
class ToEndpo
int>
242 auto const &
keys = TransformPersistenceHelper::get();
249 #define INSTANTIATE_OVERLOADS(FromEndpoint, ToEndpoint, NextToEndpoint) \
250 template std::shared_ptr<Transform<FromEndpoint, NextToEndpoint>> \
251 Transform<FromEndpoint, ToEndpoint>::then<NextToEndpoint>( \
252 Transform<ToEndpoint, NextToEndpoint> const &next, bool) const;
254 #define INSTANTIATE_TRANSFORM(FromEndpoint, ToEndpoint) \
256 template std::shared_ptr<geom::Transform<geom::FromEndpoint, geom::ToEndpoint>> \
257 table::io::PersistableFacade<geom::Transform<geom::FromEndpoint, geom::ToEndpoint>>::dynamicCast( \
258 std::shared_ptr<table::io::Persistable> const &); \
260 template class Transform<FromEndpoint, ToEndpoint>; \
261 template std::ostream &operator<<<FromEndpoint, ToEndpoint>( \
262 std::ostream &os, Transform<FromEndpoint, ToEndpoint> const &transform); \
264 TransformFactory<FromEndpoint, ToEndpoint> registration##FromEndpoint##ToEndpoint( \
265 Transform<FromEndpoint, ToEndpoint>::getShortClassName()); \
267 INSTANTIATE_OVERLOADS(FromEndpoint, ToEndpoint, GenericEndpoint) \
268 INSTANTIATE_OVERLOADS(FromEndpoint, ToEndpoint, Point2Endpoint) \
269 INSTANTIATE_OVERLOADS(FromEndpoint, ToEndpoint, SpherePointEndpoint)
void writeStream(Transform const &transform, std::ostream &os)
Serialize a Transform to an output stream.
A FrameSet consists of a set of one or more Frames (which describe coordinate systems),...
std::shared_ptr< Mapping > simplified() const
Return a simplied version of the mapping (which may be a compound Mapping such as a CmpMap).
An object passed to Persistable::write to allow it to persist itself.
An abstract base class for objects which transform one set of coordinates to another.
void saveCatalog(BaseCatalog const &catalog)
Save a catalog in the archive.
An endpoint for lsst::geom::Point2D.
BaseCatalog makeCatalog(Schema const &schema)
Return a new, empty catalog with the given schema.
std::ostream & operator<<(std::ostream &os, GenericEndpoint const &endpoint)
Print "GenericEndpoint(_n_)" to the ostream where _n_ is the number of axes, e.g. "GenericAxes(4)".
PolynomialFunction1d simplified(ScaledPolynomialFunction1d const &f)
Calculate the standard polynomial function that is equivalent to a scaled standard polynomial functio...
Reports errors in the logical structure of the program.
A base class for image defects.
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Reports invalid arguments.
#define LSST_ARCHIVE_ASSERT(EXPR)
An assertion macro used to validate the structure of an InputArchive.
A generic endpoint for data in the format used by ast::Mapping.
std::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.
An endpoint for lsst::geom::SpherePoint.