LSSTApplications  18.0.0+106,18.0.0+50,19.0.0,19.0.0+1,19.0.0+10,19.0.0+11,19.0.0+13,19.0.0+17,19.0.0+2,19.0.0-1-g20d9b18+6,19.0.0-1-g425ff20,19.0.0-1-g5549ca4,19.0.0-1-g580fafe+6,19.0.0-1-g6fe20d0+1,19.0.0-1-g7011481+9,19.0.0-1-g8c57eb9+6,19.0.0-1-gb5175dc+11,19.0.0-1-gdc0e4a7+9,19.0.0-1-ge272bc4+6,19.0.0-1-ge3aa853,19.0.0-10-g448f008b,19.0.0-12-g6990b2c,19.0.0-2-g0d9f9cd+11,19.0.0-2-g3d9e4fb2+11,19.0.0-2-g5037de4,19.0.0-2-gb96a1c4+3,19.0.0-2-gd955cfd+15,19.0.0-3-g2d13df8,19.0.0-3-g6f3c7dc,19.0.0-4-g725f80e+11,19.0.0-4-ga671dab3b+1,19.0.0-4-gad373c5+3,19.0.0-5-ga2acb9c+2,19.0.0-5-gfe96e6c+2,w.2020.01
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
lsst::afw::geom::Point2Endpoint Class Referenceabstract

An endpoint for lsst::geom::Point2D. More...

#include <Endpoint.h>

Inheritance diagram for lsst::afw::geom::Point2Endpoint:
lsst::afw::geom::BaseVectorEndpoint< lsst::geom::Point2D > lsst::afw::geom::BaseEndpoint< lsst::geom::Point2D, std::vector< lsst::geom::Point2D > >

Public Types

using Array = std::vector< lsst::geom::Point2D >
 
using Point = lsst::geom::Point2D
 

Public Member Functions

 Point2Endpoint (Point2Endpoint const &)=default
 
 Point2Endpoint (Point2Endpoint &&)=default
 
Point2Endpointoperator= (Point2Endpoint const &)=delete
 
Point2Endpointoperator= (Point2Endpoint &&)=delete
 
 Point2Endpoint ()
 Construct a Point2Endpoint. More...
 
 Point2Endpoint (int nAxes)
 Construct a Point2Endpoint with nAxes specified; nAxes must equal template parameter N. More...
 
 ~Point2Endpoint () override=default
 
std::vector< double > dataFromPoint (Point const &point) const override
 
ndarray::Array< double, 2, 2 > dataFromArray (Array const &arr) const override
 
Point pointFromData (std::vector< double > const &data) const override
 Get a single point from raw data. More...
 
Array arrayFromData (ndarray::Array< double, 2, 2 > const &data) const override
 Get an array of points from raw data. More...
 
void normalizeFrame (std::shared_ptr< ast::Frame > framePtr) const override
 Check that framePtr points to a Frame, not a subclass. More...
 
int getNPoints (Array const &arr) const override
 Return the number of points in an array. More...
 
int getNAxes () const
 
virtual bool operator== (BaseEndpoint const &other) const noexcept
 Determine whether two endpoints represent the same conversion. More...
 
bool operator!= (BaseEndpoint const &other) const noexcept
 Determine whether two endpoints do not represent the same conversion. More...
 
virtual std::vector< double > dataFromPoint (Point const &point) const=0
 Get raw data from a single point. More...
 
virtual ndarray::Array< double, 2, 2 > dataFromArray (Array const &arr) const=0
 Get raw data from an array of points. More...
 
virtual std::shared_ptr< ast::FramemakeFrame () const
 Create a Frame that can be used with this end point in a Transform. More...
 

Static Public Member Functions

static std::string getClassPrefix ()
 Get the class name prefix, e.g. "Point2" for "Point2Endpoint". More...
 

Protected Member Functions

void _assertNAxes (int nAxes) const
 
int _getNAxes (ndarray::Array< double, 2, 2 > const &data) const
 
int _getNAxes (ndarray::Array< double, 1, 1 > const &data) const
 
int _getNAxes (std::vector< double > const &data) const
 
int _getNPoints (ndarray::Array< double, 2, 2 > const &data) const
 

Detailed Description

An endpoint for lsst::geom::Point2D.

Definition at line 261 of file Endpoint.h.

Member Typedef Documentation

◆ Array

Definition at line 197 of file Endpoint.h.

◆ Point

Definition at line 198 of file Endpoint.h.

Constructor & Destructor Documentation

◆ Point2Endpoint() [1/4]

lsst::afw::geom::Point2Endpoint::Point2Endpoint ( Point2Endpoint const &  )
default

◆ Point2Endpoint() [2/4]

lsst::afw::geom::Point2Endpoint::Point2Endpoint ( Point2Endpoint &&  )
default

◆ Point2Endpoint() [3/4]

lsst::afw::geom::Point2Endpoint::Point2Endpoint ( )
inlineexplicit

Construct a Point2Endpoint.

Definition at line 271 of file Endpoint.h.

271 : BaseVectorEndpoint<lsst::geom::Point2D>(2) {}

◆ Point2Endpoint() [4/4]

lsst::afw::geom::Point2Endpoint::Point2Endpoint ( int  nAxes)
explicit

Construct a Point2Endpoint with nAxes specified; nAxes must equal template parameter N.

This constructor is primarily used by Transform; other users are encouraged to use the default constructor.

Parameters
[in]nAxesThe number of axes in a point; must equal template parameter N
Exceptions
lsst.pex.exceptions.InvalidParameterErrorif nAxes != N

Definition at line 107 of file Endpoint.cc.

107  : BaseVectorEndpoint<lsst::geom::Point2D>(2) {
108  if (nAxes != 2) {
110  os << "nAxes = " << nAxes << " != 2";
112  }
113 }
T str(T... args)
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
Reports invalid arguments.
Definition: Runtime.h:66
std::ostream * os
Definition: Schema.cc:746

◆ ~Point2Endpoint()

lsst::afw::geom::Point2Endpoint::~Point2Endpoint ( )
overridedefault

Member Function Documentation

◆ _assertNAxes()

void lsst::afw::geom::BaseEndpoint< Point, Array >::_assertNAxes ( int  nAxes) const
protectedinherited

Definition at line 74 of file Endpoint.cc.

74  {
75  if (nAxes != this->getNAxes()) {
77  os << "number of axes provided " << nAxes << " != " << this->getNAxes() << " required";
78  throw std::invalid_argument(os.str());
79  }
80 }
T str(T... args)
std::ostream * os
Definition: Schema.cc:746

◆ _getNAxes() [1/3]

int lsst::afw::geom::BaseEndpoint< lsst::geom::Point2D , std::vector< lsst::geom::Point2D > >::_getNAxes ( ndarray::Array< double, 2, 2 > const &  data) const
inlineprotectedinherited

Definition at line 177 of file Endpoint.h.

177 { return data.getSize<0>(); }
char * data
Definition: BaseRecord.cc:62

◆ _getNAxes() [2/3]

int lsst::afw::geom::BaseEndpoint< lsst::geom::Point2D , std::vector< lsst::geom::Point2D > >::_getNAxes ( ndarray::Array< double, 1, 1 > const &  data) const
inlineprotectedinherited

Definition at line 179 of file Endpoint.h.

179 { return data.getSize<0>(); }
char * data
Definition: BaseRecord.cc:62

◆ _getNAxes() [3/3]

int lsst::afw::geom::BaseEndpoint< lsst::geom::Point2D , std::vector< lsst::geom::Point2D > >::_getNAxes ( std::vector< double > const &  data) const
inlineprotectedinherited

Definition at line 181 of file Endpoint.h.

181 { return data.size(); }
T size(T... args)

◆ _getNPoints()

int lsst::afw::geom::BaseEndpoint< lsst::geom::Point2D , std::vector< lsst::geom::Point2D > >::_getNPoints ( ndarray::Array< double, 2, 2 > const &  data) const
inlineprotectedinherited

Definition at line 183 of file Endpoint.h.

183 { return data.getSize<1>(); }
char * data
Definition: BaseRecord.cc:62

◆ arrayFromData()

std::vector< lsst::geom::Point2D > lsst::afw::geom::Point2Endpoint::arrayFromData ( ndarray::Array< double, 2, 2 > const &  data) const
overridevirtual

Get an array of points from raw data.

Parameters
[in]dataRaw data for an array of points, as a 2-D ndarray array [nPoints, nAxes] in C order, so the in-memory view is, for example, x0, y0, x1, y1, x2, y2, ...
Returns
an array of points
Exceptions
lsst::pex::exceptions::InvalidParameterErrorif the array has the wrong nAxes dimension

Implements lsst::afw::geom::BaseEndpoint< lsst::geom::Point2D, std::vector< lsst::geom::Point2D > >.

Definition at line 148 of file Endpoint.cc.

149  {
150  this->_assertNAxes(this->_getNAxes(data));
151  int const nPoints = this->_getNPoints(data);
152  Array array;
153  array.reserve(nPoints);
154  for (auto const& dataCol : data.transpose()) {
155  array.emplace_back(dataCol[0], dataCol[1]);
156  }
157  return array;
158 }
int _getNPoints(ndarray::Array< double, 2, 2 > const &data) const
Definition: Endpoint.h:183
char * data
Definition: BaseRecord.cc:62

◆ dataFromArray() [1/2]

virtual ndarray::Array<double, 2, 2> lsst::afw::geom::BaseEndpoint< lsst::geom::Point2D , std::vector< lsst::geom::Point2D > >::dataFromArray ( Array const &  arr) const
pure virtualinherited

Get raw data from an array of points.

Parameters
[in]arrArray of points
Returns
the data as a 2-D ndarray array [nAxes, nPoints] in C order, so the in-memory view is, for example, x0, x1, x2, ..., y0, y1, y2, ...
Exceptions
lsst::pex::exceptions::InvalidParameterErrorif the array has the wrong nAxes dimension

◆ dataFromArray() [2/2]

ndarray::Array< double, 2, 2 > lsst::afw::geom::Point2Endpoint::dataFromArray ( Array const &  arr) const
override

Definition at line 124 of file Endpoint.cc.

124  {
125  const int nAxes = this->getNAxes();
126  const int nPoints = this->getNPoints(arr);
127  ndarray::Array<double, 2, 2> data = ndarray::allocate(ndarray::makeVector(nAxes, nPoints));
128  auto dataColIter = data.transpose().begin();
129  for (auto const& point : arr) {
130  for (int axInd = 0; axInd < nAxes; ++axInd) {
131  (*dataColIter)[axInd] = point[axInd];
132  }
133  ++dataColIter;
134  }
135  return data;
136 }
char * data
Definition: BaseRecord.cc:62
int getNPoints(Array const &arr) const override
Definition: Endpoint.cc:83

◆ dataFromPoint() [1/2]

virtual std::vector<double> lsst::afw::geom::BaseEndpoint< lsst::geom::Point2D , std::vector< lsst::geom::Point2D > >::dataFromPoint ( Point const &  point) const
pure virtualinherited

Get raw data from a single point.

Parameters
[in]pointdata for a single point
Returns
the values in the point as a vector of size NAxess
Exceptions
lsst::pex::exceptions::InvalidParameterErrorif the point has the wrong number of axes

◆ dataFromPoint() [2/2]

std::vector< double > lsst::afw::geom::Point2Endpoint::dataFromPoint ( Point const &  point) const
override

Definition at line 115 of file Endpoint.cc.

115  {
116  const int nAxes = this->getNAxes();
118  for (int axInd = 0; axInd < nAxes; ++axInd) {
119  result[axInd] = point[axInd];
120  }
121  return result;
122 }
py::object result
Definition: _schema.cc:429

◆ getClassPrefix()

static std::string lsst::afw::geom::Point2Endpoint::getClassPrefix ( )
inlinestatic

Get the class name prefix, e.g. "Point2" for "Point2Endpoint".

Definition at line 307 of file Endpoint.h.

307 { return "Point2"; };

◆ getNAxes()

int lsst::afw::geom::BaseEndpoint< lsst::geom::Point2D , std::vector< lsst::geom::Point2D > >::getNAxes ( ) const
inlineinherited

Definition at line 79 of file Endpoint.h.

79 { return _nAxes; }

◆ getNPoints()

int lsst::afw::geom::BaseVectorEndpoint< Point >::getNPoints ( Array const &  arr) const
overridevirtualinherited

Return the number of points in an array.

Implements lsst::afw::geom::BaseEndpoint< lsst::geom::Point2D, std::vector< lsst::geom::Point2D > >.

Definition at line 83 of file Endpoint.cc.

83  {
84  return arr.size();
85 }

◆ makeFrame()

std::shared_ptr< ast::Frame > lsst::afw::geom::BaseEndpoint< Point, Array >::makeFrame ( ) const
virtualinherited

Create a Frame that can be used with this end point in a Transform.

Definition at line 69 of file Endpoint.cc.

69  {
70  return std::make_shared<ast::Frame>(getNAxes());
71 }

◆ normalizeFrame()

void lsst::afw::geom::Point2Endpoint::normalizeFrame ( std::shared_ptr< ast::Frame framePtr) const
overridevirtual

Check that framePtr points to a Frame, not a subclass.

Subclasses are forbidden because lsst::geom::Point2D is assumed to be cartesian and subclasses of Frame are not (e.g. SkyFrame, SpecFrame and TimeFrame). Note that SpecFrame and TimeFrame are 1-dimensional so they cannot be used in any case. A CmpFrame could be cartesian, but we play it safe and reject these (however, a cartesian CmpFrame ought to simplify to a Frame).

Reimplemented from lsst::afw::geom::BaseEndpoint< lsst::geom::Point2D, std::vector< lsst::geom::Point2D > >.

Definition at line 160 of file Endpoint.cc.

160  {
161  // use getCurrentFrame because if framePtr points to a FrameSet we want the name of its current frame
162  std::string className = getCurrentFrame(framePtr)->getClassName();
163  if (className != "Frame") {
165  os << "frame is a " << className << ", not a Frame";
167  }
168 }
STL class.
T str(T... args)
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
Reports invalid arguments.
Definition: Runtime.h:66
std::ostream * os
Definition: Schema.cc:746

◆ operator!=()

Determine whether two endpoints do not represent the same conversion.

Returns
the inverse of operator==. See that operator's documentation for important caveats.

Definition at line 109 of file Endpoint.h.

109 { return !(*this == other); }
ItemVariant const * other
Definition: Schema.cc:56

◆ operator=() [1/2]

Point2Endpoint& lsst::afw::geom::Point2Endpoint::operator= ( Point2Endpoint const &  )
delete

◆ operator=() [2/2]

Point2Endpoint& lsst::afw::geom::Point2Endpoint::operator= ( Point2Endpoint &&  )
delete

◆ operator==()

bool lsst::afw::geom::BaseEndpoint< Point, Array >::operator== ( BaseEndpoint< lsst::geom::Point2D, std::vector< lsst::geom::Point2D > > const &  other) const
virtualnoexceptinherited

Determine whether two endpoints represent the same conversion.

Parameters
otherthe endpoint to compare
Returns
true iff this object and other are of exactly the same class and all visible properties are identical. This implementation requires that the objects have the same number of axes.
Warning
Two endpoints with different implementation classes will never compare equal, even if one class is conceptually equivalent to the other (e.g., a decorator). This may cause unexpected behavior when mixing related concrete endpoint classes.

Definition at line 64 of file Endpoint.cc.

64  {
65  return this->getNAxes() == other.getNAxes() && typeid(*this) == typeid(other);
66 }
ItemVariant const * other
Definition: Schema.cc:56

◆ pointFromData()

lsst::geom::Point2D lsst::afw::geom::Point2Endpoint::pointFromData ( std::vector< double > const &  data) const
overridevirtual

Get a single point from raw data.

Parameters
[in]dataData as a vector of length NAxes
Returns
the corresponding point

Implements lsst::afw::geom::BaseEndpoint< lsst::geom::Point2D, std::vector< lsst::geom::Point2D > >.

Definition at line 138 of file Endpoint.cc.

138  {
139  const int nAxes = this->getNAxes();
140  this->_assertNAxes(this->_getNAxes(data));
141  Point result;
142  for (int axInd = 0; axInd < nAxes; ++axInd) {
143  result[axInd] = data[axInd];
144  }
145  return result;
146 }
py::object result
Definition: _schema.cc:429

The documentation for this class was generated from the following files: