LSST Applications
21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
|
Cartesian polygons. More...
#include <Polygon.h>
Classes | |
struct | Impl |
Public Types | |
using | Box = lsst::geom::Box2D |
using | Point = lsst::geom::Point2D |
Public Member Functions | |
Polygon (Box const &box) | |
Construct a rectangular Polygon whose vertices are the corners of a box. More... | |
Polygon (Polygon const &) | |
Polygon (Polygon &&) | |
Polygon & | operator= (Polygon const &) |
Polygon & | operator= (Polygon &&) |
~Polygon () override | |
Polygon (Box const &box, TransformPoint2ToPoint2 const &transform) | |
Construct a 4-sided Polygon from a transformed box. More... | |
Polygon (Box const &box, lsst::geom::AffineTransform const &transform) | |
Construct a 4-sided Polygon from a transformed box. More... | |
Polygon (std::vector< Point > const &vertices) | |
Construct a Polygon from a list of vertices. More... | |
void | swap (Polygon &other) noexcept |
Swap two polygons. More... | |
size_t | getNumEdges () const |
Return number of edges. More... | |
Box | getBBox () const |
Return bounding box. More... | |
Point | calculateCenter () const |
double | calculateArea () const |
double | calculatePerimeter () const |
std::vector< Point > | getVertices () const |
Get vector of vertices. More... | |
std::vector< Point >::const_iterator | begin () const |
Iterator for vertices. More... | |
std::vector< Point >::const_iterator | end () const |
std::vector< std::pair< Point, Point > > | getEdges () const |
Get vector of edges. More... | |
bool | operator== (Polygon const &other) const |
bool | operator!= (Polygon const &other) const |
std::size_t | hash_value () const noexcept override |
Return a hash of this object. More... | |
bool | contains (Point const &point) const |
Returns whether the polygon contains the point. More... | |
bool | overlaps (Polygon const &other) const |
Returns whether the polygons overlap each other. More... | |
bool | overlaps (Box const &box) const |
std::shared_ptr< Polygon > | intersectionSingle (Polygon const &other) const |
Returns the intersection of two polygons. More... | |
std::shared_ptr< Polygon > | intersectionSingle (Box const &box) const |
std::vector< std::shared_ptr< Polygon > > | intersection (Polygon const &other) const |
Returns the intersection of two polygons. More... | |
std::vector< std::shared_ptr< Polygon > > | intersection (Box const &box) const |
std::shared_ptr< Polygon > | unionSingle (Polygon const &other) const |
Returns the union of two polygons. More... | |
std::shared_ptr< Polygon > | unionSingle (Box const &box) const |
std::vector< std::shared_ptr< Polygon > > | union_ (Polygon const &other) const |
Returns the union of two polygons. More... | |
std::vector< std::shared_ptr< Polygon > > | union_ (Box const &box) const |
std::vector< std::shared_ptr< Polygon > > | symDifference (Polygon const &other) const |
Return the symmetric difference of two polygons. More... | |
std::vector< std::shared_ptr< Polygon > > | symDifference (Box const &box) const |
std::shared_ptr< Polygon > | simplify (double const distance) const |
Return a simplified polygon. More... | |
std::vector< std::shared_ptr< Polygon > > | operator& (Polygon const &rhs) const |
Operators for syntactic sugar. More... | |
std::vector< std::shared_ptr< Polygon > > | operator& (Box const &rhs) const |
std::vector< std::shared_ptr< Polygon > > | operator| (Polygon const &rhs) const |
std::vector< std::shared_ptr< Polygon > > | operator| (Box const &rhs) const |
std::vector< std::shared_ptr< Polygon > > | operator^ (Polygon const &rhs) const |
std::vector< std::shared_ptr< Polygon > > | operator^ (Box const &rhs) const |
std::shared_ptr< Polygon > | convexHull () const |
Produce a polygon from the convex hull. More... | |
std::shared_ptr< Polygon > | transform (TransformPoint2ToPoint2 const &transform) const |
Transform the polygon. More... | |
std::shared_ptr< Polygon > | transform (lsst::geom::AffineTransform const &transform) const |
std::shared_ptr< Polygon > | subSample (size_t num) const |
Sub-sample each edge. More... | |
std::shared_ptr< Polygon > | subSample (double maxLength) const |
std::shared_ptr< afw::image::Image< float > > | createImage (lsst::geom::Box2I const &bbox) const |
Create image of polygon. More... | |
std::shared_ptr< afw::image::Image< float > > | createImage (lsst::geom::Extent2I const &extent) const |
bool | isPersistable () const noexcept override |
Whether Polygon is persistable which is always true. More... | |
std::shared_ptr< typehandling::Storable > | cloneStorable () const override |
Create a new Polygon that is a copy of this one. More... | |
std::string | toString () const override |
Create a string representation of this object. More... | |
bool | equals (typehandling::Storable const &other) const noexcept override |
Compare this object to another Storable. More... | |
def | __repr__ (self) |
def | __reduce__ (self) |
def | __iter__ (self) |
def | __getitem__ (self, i) |
def | __len__ (self) |
def | __contains__ (self, point) |
def | display (self, xy0=None, frame=1, ctype=None) |
def | plot (self, axes=None, **kwargs) |
void | writeFits (std::string const &fileName, std::string const &mode="w") const |
Write the object to a regular FITS file. More... | |
void | writeFits (fits::MemFileManager &manager, std::string const &mode="w") const |
Write the object to a FITS image in memory. More... | |
void | writeFits (fits::Fits &fitsfile) const |
Write the object to an already-open FITS object. More... | |
Static Public Member Functions | |
static std::shared_ptr< Polygon > | readFits (fits::Fits &fitsfile) |
Read an object from an already open FITS object. More... | |
static std::shared_ptr< Polygon > | readFits (std::string const &fileName, int hdu=fits::DEFAULT_HDU) |
Read an object from a regular FITS file. More... | |
static std::shared_ptr< Polygon > | readFits (fits::MemFileManager &manager, int hdu=fits::DEFAULT_HDU) |
Read an object from a FITS file in memory. More... | |
static std::shared_ptr< Polygon > | dynamicCast (std::shared_ptr< Persistable > const &ptr) |
Dynamically cast a shared_ptr. More... | |
Protected Types | |
using | OutputArchiveHandle = io::OutputArchiveHandle |
Protected Member Functions | |
std::string | getPersistenceName () const override |
Return the unique name used to persist this object and look up its factory. More... | |
void | write (OutputArchiveHandle &handle) const override |
Write the object to one or more catalogs. More... | |
virtual std::string | getPythonModule () const |
Return the fully-qualified Python module that should be imported to guarantee that its factory is registered. More... | |
Static Protected Member Functions | |
template<class T > | |
static bool | singleClassEquals (T const &lhs, Storable const &rhs) |
Test if a Storable is of a particular class and equal to another object. More... | |
Related Functions | |
(Note that these are not member functions.) | |
std::ostream & | operator<< (std::ostream &os, Storable const &storable) |
Output operator for Storable. More... | |
Cartesian polygons.
Polygons are defined by a set of vertices
|
protectedinherited |
Definition at line 108 of file Persistable.h.
|
explicit |
Construct a rectangular Polygon whose vertices are the corners of a box.
Definition at line 288 of file Polygon.cc.
|
default |
|
default |
|
overridedefault |
lsst::afw::geom::polygon::Polygon::Polygon | ( | Polygon::Box const & | box, |
TransformPoint2ToPoint2 const & | transform | ||
) |
Construct a 4-sided Polygon from a transformed box.
The resulting polygon has 4 vertices: transform.applyForward(bbox.getCorners())
[in] | box | Initial box |
[in] | transform | Coordinate transform |
Definition at line 292 of file Polygon.cc.
lsst::afw::geom::polygon::Polygon::Polygon | ( | Polygon::Box const & | box, |
lsst::geom::AffineTransform const & | transform | ||
) |
Construct a 4-sided Polygon from a transformed box.
The resulting polygon has 4 vertices: the corners of the box transformed by transform
[in] | box | Initial box |
[in] | transform | Coordinate transform |
Definition at line 299 of file Polygon.cc.
|
explicit |
def lsst.afw.geom.polygon.Polygon.__contains__ | ( | self, | |
point | |||
) |
point in polygon?
Definition at line 47 of file polygon.py.
def lsst.afw.geom.polygon.Polygon.__getitem__ | ( | self, | |
i | |||
) |
Definition at line 41 of file polygon.py.
def lsst.afw.geom.polygon.Polygon.__iter__ | ( | self | ) |
def lsst.afw.geom.polygon.Polygon.__len__ | ( | self | ) |
Definition at line 44 of file polygon.py.
def lsst.afw.geom.polygon.Polygon.__reduce__ | ( | self | ) |
Definition at line 33 of file polygon.py.
def lsst.afw.geom.polygon.Polygon.__repr__ | ( | self | ) |
Definition at line 30 of file polygon.py.
std::vector< LsstPoint >::const_iterator lsst::afw::geom::polygon::Polygon::begin | ( | ) | const |
Iterator for vertices.
Iterates only over the "open" polygon vertices (i.e., same number as returned by "getNumEdges").
Definition at line 339 of file Polygon.cc.
double lsst::afw::geom::polygon::Polygon::calculateArea | ( | ) | const |
Definition at line 322 of file Polygon.cc.
LsstPoint lsst::afw::geom::polygon::Polygon::calculateCenter | ( | ) | const |
Definition at line 318 of file Polygon.cc.
double lsst::afw::geom::polygon::Polygon::calculatePerimeter | ( | ) | const |
Definition at line 324 of file Polygon.cc.
|
overridevirtual |
Create a new Polygon that is a copy of this one.
Reimplemented from lsst::afw::typehandling::Storable.
Definition at line 593 of file Polygon.cc.
bool lsst::afw::geom::polygon::Polygon::contains | ( | Point const & | point | ) | const |
std::shared_ptr< Polygon > lsst::afw::geom::polygon::Polygon::convexHull | ( | ) | const |
Produce a polygon from the convex hull.
Definition at line 404 of file Polygon.cc.
std::shared_ptr< afw::image::Image< float > > lsst::afw::geom::polygon::Polygon::createImage | ( | lsst::geom::Box2I const & | bbox | ) | const |
Create image of polygon.
Pixels entirely contained within the polygon receive value unity, pixels entirely outside the polygon receive value zero, and pixels on the border receive a value equal to the fraction of the pixel within the polygon.
Note that the center of the lower-left pixel is 0,0.
Definition at line 446 of file Polygon.cc.
|
inline |
Definition at line 248 of file Polygon.h.
def lsst.afw.geom.polygon.Polygon.display | ( | self, | |
xy0 = None , |
|||
frame = 1 , |
|||
ctype = None |
|||
) |
Display polygon on existing frame
Definition at line 51 of file polygon.py.
|
staticinherited |
Dynamically cast a shared_ptr.
Dynamically cast a shared pointer and raise on failure.
You must provide an explicit template instantiation in the .cc file for each class that inherits from PersistableFacade. Designed to work around RTTI issues on macOS with hidden symbols;
lsst::pex::exceptions::LogicError | if the cast fails |
param[in] ptr The pointer to be cast.
lsst::pex::exceptions::TypeError | If the dynamic cast fails. |
Definition at line 218 of file Persistable.cc.
std::vector< LsstPoint >::const_iterator lsst::afw::geom::polygon::Polygon::end | ( | ) | const |
Definition at line 341 of file Polygon.cc.
|
overridevirtualnoexcept |
Compare this object to another Storable.
*this == other
if other
is a Polygon; otherwise false
. Reimplemented from lsst::afw::typehandling::Storable.
Definition at line 603 of file Polygon.cc.
Polygon::Box lsst::afw::geom::polygon::Polygon::getBBox | ( | ) | const |
Return bounding box.
Definition at line 314 of file Polygon.cc.
std::vector< std::pair< LsstPoint, LsstPoint > > lsst::afw::geom::polygon::Polygon::getEdges | ( | ) | const |
Get vector of edges.
Returns edges, as pairs of vertices.
Definition at line 326 of file Polygon.cc.
size_t lsst::afw::geom::polygon::Polygon::getNumEdges | ( | ) | const |
Return number of edges.
Identical with the number of points
Definition at line 309 of file Polygon.cc.
|
overrideprotectedvirtual |
Return the unique name used to persist this object and look up its factory.
Must be less than ArchiveIndexSchema::MAX_NAME_LENGTH characters.
Reimplemented from lsst::afw::table::io::Persistable.
Definition at line 578 of file Polygon.cc.
|
protectedvirtualinherited |
Return the fully-qualified Python module that should be imported to guarantee that its factory is registered.
Must be less than ArchiveIndexSchema::MAX_MODULE_LENGTH characters.
Will be ignored if empty.
Reimplemented in lsst::meas::modelfit::Mixture, lsst::meas::algorithms::WarpedPsf, lsst::meas::algorithms::KernelPsf, lsst::meas::algorithms::CoaddPsf, lsst::meas::algorithms::CoaddBoundedField, lsst::afw::typehandling::StorableHelper< Base >, lsst::afw::math::WarpingControl, lsst::afw::math::NearestWarpingKernel, lsst::afw::math::BilinearWarpingKernel, lsst::afw::math::LanczosWarpingKernel, lsst::afw::math::TransformBoundedField, lsst::afw::math::ProductBoundedField, lsst::afw::math::PixelAreaBoundedField, lsst::afw::math::Kernel, lsst::afw::math::Function< ReturnT >, lsst::afw::math::ChebyshevBoundedField, lsst::afw::image::TransmissionCurve, lsst::afw::image::CoaddInputs, lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >, lsst::afw::geom::Transform< afw::geom::Point2Endpoint, afw::geom::GenericEndpoint >, lsst::afw::geom::SkyWcs, lsst::afw::detection::GaussianPsf, lsst::afw::detection::Footprint, lsst::afw::cameraGeom::DetectorCollection, and lsst::afw::image::FilterLabel.
Definition at line 36 of file Persistable.cc.
std::vector< LsstPoint > lsst::afw::geom::polygon::Polygon::getVertices | ( | ) | const |
Get vector of vertices.
Note that the "closed" polygon vertices are returned, so the first and last vertex are identical and there is one more vertex than otherwise expected.
Definition at line 337 of file Polygon.cc.
|
overridevirtualnoexcept |
Return a hash of this object.
Reimplemented from lsst::afw::typehandling::Storable.
Definition at line 349 of file Polygon.cc.
std::vector< std::shared_ptr< Polygon > > lsst::afw::geom::polygon::Polygon::intersection | ( | Box const & | box | ) | const |
Definition at line 374 of file Polygon.cc.
std::vector< std::shared_ptr< Polygon > > lsst::afw::geom::polygon::Polygon::intersection | ( | Polygon const & | other | ) | const |
Returns the intersection of two polygons.
Handles the full range of possibilities.
Definition at line 370 of file Polygon.cc.
std::shared_ptr< Polygon > lsst::afw::geom::polygon::Polygon::intersectionSingle | ( | Box const & | box | ) | const |
Definition at line 366 of file Polygon.cc.
std::shared_ptr< Polygon > lsst::afw::geom::polygon::Polygon::intersectionSingle | ( | Polygon const & | other | ) | const |
Returns the intersection of two polygons.
Does not handle non-convex polygons (which might have multiple independent intersections), and is provided as a convenience for when the polygons are known to be convex (e.g., image borders) and overlapping.
Definition at line 362 of file Polygon.cc.
|
inlineoverridevirtualnoexcept |
Whether Polygon is persistable which is always true.
Reimplemented from lsst::afw::table::io::Persistable.
|
inline |
|
inline |
|
inline |
bool lsst::afw::geom::polygon::Polygon::operator== | ( | Polygon const & | other | ) | const |
Definition at line 345 of file Polygon.cc.
|
inline |
Definition at line 210 of file Polygon.h.
|
inline |
|
inline |
Definition at line 208 of file Polygon.h.
|
inline |
bool lsst::afw::geom::polygon::Polygon::overlaps | ( | Box const & | box | ) | const |
Definition at line 360 of file Polygon.cc.
bool lsst::afw::geom::polygon::Polygon::overlaps | ( | Polygon const & | other | ) | const |
Returns whether the polygons overlap each other.
Note that there may be no intersection if the polygons only share a boundary.
Definition at line 358 of file Polygon.cc.
def lsst.afw.geom.polygon.Polygon.plot | ( | self, | |
axes = None , |
|||
** | kwargs | ||
) |
Plot polygon with matplotlib Parameters ---------- axes : `matplotlib.axes.Axes` Matplotlib axes to use, or None kwargs : any Additional arguments to `matplotlib.axes.Axes.plot` or `matplotlib.axes.Axes.scatter`. Returns ------- axes : `matplotlib.axes.Axes` The axes used to make the plot (same as ``axes``, if provided).
Definition at line 61 of file polygon.py.
|
inlinestaticinherited |
Read an object from an already open FITS object.
[in] | fitsfile | FITS object to read from, already positioned at the desired HDU. |
Definition at line 183 of file Persistable.h.
|
inlinestaticinherited |
Read an object from a FITS file in memory.
[in] | manager | Manager for the memory to read from. |
[in] | hdu | HDU to read, where 0 is the primary. The special value of afw::fits::DEFAULT_HDU skips the primary HDU if it is empty. |
Definition at line 205 of file Persistable.h.
|
inlinestaticinherited |
Read an object from a regular FITS file.
[in] | fileName | Name of the file to read. |
[in] | hdu | HDU to read, where 0 is the primary. The special value of afw::fits::DEFAULT_HDU skips the primary HDU if it is empty. |
Definition at line 194 of file Persistable.h.
std::shared_ptr< Polygon > lsst::afw::geom::polygon::Polygon::simplify | ( | double const | distance | ) | const |
Return a simplified polygon.
Removes unnecessary points (using the Douglas-Peucker algorithm).
Definition at line 398 of file Polygon.cc.
|
inlinestaticprotectedinherited |
Test if a Storable is of a particular class and equal to another object.
This method template simplifies implementations of equals that delegate to operator==
without supporting cross-class comparisons.
T | The class expected of the two objects to be compared. |
lhs,rhs | The objects to compare. Note that rhs need not be a T , while lhs must be. |
true
if rhs
is a T
and lhs == rhs
; false
otherwise.operator==
. Most implementations of operator==
do not throw.operator==
with both arguments of compile-time type T const&
. Its use is not recommended if there would be any ambiguity as to which operator==
gets picked by overload resolution.This method template is typically called from equals as:
bool MyType::equals(Storable const& other) const noexcept { return singleClassEquals(*this, other); }
Definition at line 151 of file Storable.h.
std::shared_ptr< Polygon > lsst::afw::geom::polygon::Polygon::subSample | ( | double | maxLength | ) | const |
Definition at line 434 of file Polygon.cc.
std::shared_ptr< Polygon > lsst::afw::geom::polygon::Polygon::subSample | ( | size_t | num | ) | const |
Sub-sample each edge.
This should provide greater fidelity when transforming with a non-linear transform.
Definition at line 424 of file Polygon.cc.
|
inlinenoexcept |
std::vector< std::shared_ptr< Polygon > > lsst::afw::geom::polygon::Polygon::symDifference | ( | Box const & | box | ) | const |
Definition at line 394 of file Polygon.cc.
std::vector< std::shared_ptr< Polygon > > lsst::afw::geom::polygon::Polygon::symDifference | ( | Polygon const & | other | ) | const |
Return the symmetric difference of two polygons.
Definition at line 390 of file Polygon.cc.
|
overridevirtual |
Create a string representation of this object.
Reimplemented from lsst::afw::typehandling::Storable.
Definition at line 597 of file Polygon.cc.
std::shared_ptr< Polygon > lsst::afw::geom::polygon::Polygon::transform | ( | lsst::geom::AffineTransform const & | transform | ) | const |
transform | Transform from original to target frame |
Definition at line 415 of file Polygon.cc.
std::shared_ptr< Polygon > lsst::afw::geom::polygon::Polygon::transform | ( | TransformPoint2ToPoint2 const & | transform | ) | const |
Transform the polygon.
The transformation is only applied to the vertices. If the transformation is non-linear, the edges will not reflect that, but simply join the vertices. Greater fidelity might be achieved by using "subSample" before transforming.
transform | Transform from original to target frame |
Definition at line 410 of file Polygon.cc.
std::vector< std::shared_ptr< Polygon > > lsst::afw::geom::polygon::Polygon::union_ | ( | Box const & | box | ) | const |
Definition at line 388 of file Polygon.cc.
std::vector< std::shared_ptr< Polygon > > lsst::afw::geom::polygon::Polygon::union_ | ( | Polygon const & | other | ) | const |
Returns the union of two polygons.
Handles the full range of possibilities.
Note the trailing underscore in C++, due to "union" being a reserved word.
Definition at line 384 of file Polygon.cc.
std::shared_ptr< Polygon > lsst::afw::geom::polygon::Polygon::unionSingle | ( | Box const & | box | ) | const |
Definition at line 382 of file Polygon.cc.
std::shared_ptr< Polygon > lsst::afw::geom::polygon::Polygon::unionSingle | ( | Polygon const & | other | ) | const |
Returns the union of two polygons.
Does not handle non-overlapping polygons, the union of which would be disjoint.
Definition at line 378 of file Polygon.cc.
|
overrideprotectedvirtual |
Write the object to one or more catalogs.
The handle object passed to this function provides an interface for adding new catalogs and adding nested objects to the same archive (while checking for duplicates). See OutputArchiveHandle for more information.
Reimplemented from lsst::afw::table::io::Persistable.
Definition at line 580 of file Polygon.cc.
|
inherited |
Write the object to an already-open FITS object.
[in] | fitsfile | Open FITS object to write to. |
Definition at line 18 of file Persistable.cc.
|
inherited |
Write the object to a FITS image in memory.
[in] | manager | Name of the file to write to. |
[in] | mode | If "w", any existing file with the given name will be overwritten. If "a", new HDUs will be appended to an existing file. |
Definition at line 29 of file Persistable.cc.
|
inherited |
Write the object to a regular FITS file.
[in] | fileName | Name of the file to write to. |
[in] | mode | If "w", any existing file with the given name will be overwritten. If "a", new HDUs will be appended to an existing file. |
Definition at line 24 of file Persistable.cc.
|
related |
Output operator for Storable.
os | the desired output stream |
storable | the object to print |
os
UnsupportedOperationException | Thrown if storable does not have an implementation of Storable::toString. |
Definition at line 174 of file Storable.h.