|
lsst.afw gba399f52f3+9b61cfce8e
|
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. | |
| 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. | |
| Polygon (Box const &box, lsst::geom::AffineTransform const &transform) | |
| Construct a 4-sided Polygon from a transformed box. | |
| Polygon (std::vector< Point > const &vertices) | |
| Construct a Polygon from a list of vertices. | |
| void | swap (Polygon &other) noexcept |
| Swap two polygons. | |
| size_t | getNumEdges () const |
| Return number of edges. | |
| Box | getBBox () const |
| Return bounding box. | |
| Point | calculateCenter () const |
| double | calculateArea () const |
| double | calculatePerimeter () const |
| std::vector< Point > | getVertices () const |
| Get vector of vertices. | |
| std::vector< Point >::const_iterator | begin () const |
| Iterator for vertices. | |
| std::vector< Point >::const_iterator | end () const |
| std::vector< std::pair< Point, Point > > | getEdges () const |
| Get vector of edges. | |
| 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. | |
| bool | contains (Point const &point) const |
| Returns whether the polygon contains the point. | |
| std::vector< bool > | contains (std::vector< Point > const &points) const |
| Returns whether the polygon contains the vector of points. | |
| std::vector< bool > | contains (std::vector< lsst::geom::Point2I > const &points) const |
| template<typename Xtype, typename Ytype> | |
| bool | contains (Xtype x, Ytype y) const |
| Returns whether the polygon contains the x, y pair. | |
| bool | overlaps (Polygon const &other) const |
| Returns whether the polygons overlap each other. | |
| bool | overlaps (Box const &box) const |
| std::shared_ptr< Polygon > | intersectionSingle (Polygon const &other) const |
| Returns the intersection of two polygons. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| std::vector< std::shared_ptr< Polygon > > | symDifference (Box const &box) const |
| std::shared_ptr< Polygon > | simplify (double const distance) const |
| Return a simplified polygon. | |
| std::vector< std::shared_ptr< Polygon > > | operator& (Polygon const &rhs) const |
| Operators for syntactic sugar. | |
| 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. | |
| std::shared_ptr< Polygon > | transform (TransformPoint2ToPoint2 const &transform) const |
| Transform the polygon. | |
| std::shared_ptr< Polygon > | transform (lsst::geom::AffineTransform const &transform) const |
| std::shared_ptr< Polygon > | subSample (size_t num) const |
| Sub-sample each edge. | |
| 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. | |
| 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. | |
| std::shared_ptr< typehandling::Storable > | cloneStorable () const override |
| Create a new Polygon that is a copy of this one. | |
| std::string | toString () const override |
| Create a string representation of this object. | |
| bool | equals (typehandling::Storable const &other) const noexcept override |
| Compare this object to another Storable. | |
| __repr__ (self) | |
| __reduce__ (self) | |
| __iter__ (self) | |
| __getitem__ (self, i) | |
| __len__ (self) | |
| __contains__ (self, point) | |
| display (self, xy0=None, frame=1, ctype=None) | |
| plot (self, axes=None, **kwargs) | |
Static Public Member Functions | |
| static std::shared_ptr< Polygon > | readFits (fits::Fits &fitsfile) |
| Read an object from an already open FITS object. | |
| static std::shared_ptr< Polygon > | dynamicCast (std::shared_ptr< Persistable > const &ptr) |
| Dynamically cast a shared_ptr. | |
Protected Member Functions | |
| std::string | getPersistenceName () const override |
| void | write (OutputArchiveHandle &handle) const override |
Cartesian polygons.
Polygons are defined by a set of vertices
|
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 |
Construct a Polygon from a list of vertices.
Definition at line 290 of file Polygon.cc.
| lsst.afw.geom.polygon.Polygon.__contains__ | ( | self, | |
| point ) |
point in polygon?
Definition at line 47 of file polygon.py.
| lsst.afw.geom.polygon.Polygon.__getitem__ | ( | self, | |
| i ) |
Definition at line 41 of file polygon.py.
| lsst.afw.geom.polygon.Polygon.__iter__ | ( | self | ) |
Iterator over vertices
Definition at line 36 of file polygon.py.
| lsst.afw.geom.polygon.Polygon.__len__ | ( | self | ) |
Definition at line 44 of file polygon.py.
| lsst.afw.geom.polygon.Polygon.__reduce__ | ( | self | ) |
Definition at line 33 of file polygon.py.
| 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.
|
override |
Create a new Polygon that is a copy of this one.
Definition at line 609 of file Polygon.cc.
| bool lsst::afw::geom::polygon::Polygon::contains | ( | Point const & | point | ) | const |
Returns whether the polygon contains the point.
Definition at line 356 of file Polygon.cc.
| std::vector< bool > lsst::afw::geom::polygon::Polygon::contains | ( | std::vector< lsst::geom::Point2I > const & | points | ) | const |
Definition at line 366 of file Polygon.cc.
| std::vector< bool > lsst::afw::geom::polygon::Polygon::contains | ( | std::vector< Point > const & | points | ) | const |
Returns whether the polygon contains the vector of points.
Definition at line 358 of file Polygon.cc.
|
inline |
| std::shared_ptr< Polygon > lsst::afw::geom::polygon::Polygon::convexHull | ( | ) | const |
Produce a polygon from the convex hull.
Definition at line 420 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 462 of file Polygon.cc.
|
inline |
| 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.
|
overridenoexcept |
Compare this object to another Storable.
Definition at line 619 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.
|
overrideprotected |
Definition at line 594 of file Polygon.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.
|
overridenoexcept |
Return a hash of this object.
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 390 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 386 of file Polygon.cc.
| std::shared_ptr< Polygon > lsst::afw::geom::polygon::Polygon::intersectionSingle | ( | Box const & | box | ) | const |
Definition at line 382 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 378 of file Polygon.cc.
|
inlineoverridenoexcept |
|
inline |
|
inline |
|
inline |
| bool lsst::afw::geom::polygon::Polygon::operator== | ( | Polygon const & | other | ) | const |
Definition at line 345 of file Polygon.cc.
|
inline |
|
inline |
|
inline |
|
inline |
| bool lsst::afw::geom::polygon::Polygon::overlaps | ( | Box const & | box | ) | const |
Definition at line 376 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 374 of file Polygon.cc.
| 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.
| 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 414 of file Polygon.cc.
| std::shared_ptr< Polygon > lsst::afw::geom::polygon::Polygon::subSample | ( | double | maxLength | ) | const |
Definition at line 450 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 440 of file Polygon.cc.
|
inlinenoexcept |
| std::vector< std::shared_ptr< Polygon > > lsst::afw::geom::polygon::Polygon::symDifference | ( | Box const & | box | ) | const |
Definition at line 410 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 406 of file Polygon.cc.
|
override |
Create a string representation of this object.
Definition at line 613 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 431 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 426 of file Polygon.cc.
| std::vector< std::shared_ptr< Polygon > > lsst::afw::geom::polygon::Polygon::union_ | ( | Box const & | box | ) | const |
Definition at line 404 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 400 of file Polygon.cc.
| std::shared_ptr< Polygon > lsst::afw::geom::polygon::Polygon::unionSingle | ( | Box const & | box | ) | const |
Definition at line 398 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 394 of file Polygon.cc.
|
overrideprotected |
Definition at line 596 of file Polygon.cc.