|
lsst.afw
16.0-12-gf08c31002
|
Cartesian polygons. More...
#include <Polygon.h>
Classes | |
| struct | Impl |
Public Types | |
| typedef lsst::geom::Box2D | Box |
| typedef lsst::geom::Point2D | Point |
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 &&) |
| virtual | ~Polygon () |
| 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< std::pair< Point, Point > > | getEdges () const |
| Get vector of edges. More... | |
| bool | operator== (Polygon const &other) const |
| bool | operator!= (Polygon const &other) const |
| bool | contains (Point const &point) const |
| Returns whether the polygon contains the point. More... | |
| std::shared_ptr< Polygon > | simplify (double const distance) const |
| Return a simplified polygon. More... | |
| std::shared_ptr< Polygon > | convexHull () const |
| Produce a polygon from the convex hull. More... | |
| 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... | |
| std::vector< Point >::const_iterator | begin () const |
| Iterator for vertices. More... | |
| std::vector< Point >::const_iterator | end () const |
| Iterator for vertices. More... | |
| bool | overlaps (Polygon const &other) const |
| Returns whether the polygons overlap each other. More... | |
| bool | overlaps (Box const &box) const |
| Returns whether the polygons overlap each other. More... | |
| 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 |
| Returns the intersection of two polygons. More... | |
| 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 |
| Returns the intersection of two polygons. More... | |
| 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 |
| Returns the union of two polygons. More... | |
| 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 |
| Returns the union of two polygons. More... | |
| 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 |
| Return the symmetric difference of two polygons. 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 |
| Operators for syntactic sugar. 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 |
| Operators for syntactic sugar. 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 |
| Operators for syntactic sugar. 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 |
| Transform the polygon. More... | |
| std::shared_ptr< Polygon > | subSample (size_t num) const |
| Sub-sample each edge. More... | |
| std::shared_ptr< Polygon > | subSample (double maxLength) const |
| Sub-sample each edge. More... | |
| 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 |
| Create image of polygon. 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... | |
Protected Types | |
| typedef io::OutputArchiveHandle | OutputArchiveHandle |
Protected Member Functions | |
| virtual std::string | getPythonModule () const |
| Return the fully-qualified Python module that should be imported to guarantee that its factory is registered. More... | |
| virtual bool | isPersistable () const noexcept override |
| Whether Polygon is persistable which is always true. More... | |
| virtual std::string | getPersistenceName () const |
| Whether Polygon is persistable which is always true. More... | |
| virtual void | write (OutputArchiveHandle &handle) const |
| Whether Polygon is persistable which is always true. 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 278 of file Polygon.cc.
|
default |
|
default |
|
virtualdefault |
| 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 282 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 289 of file Polygon.cc.
|
explicit |
Construct a Polygon from a list of vertices.
Definition at line 280 of file Polygon.cc.
| std::vector< LsstPoint >::const_iterator lsst::afw::geom::polygon::Polygon::begin | ( | void | ) | const |
Iterator for vertices.
Iterates only over the "open" polygon vertices (i.e., same number as returned by "getNumEdges").
Definition at line 329 of file Polygon.cc.
| double lsst::afw::geom::polygon::Polygon::calculateArea | ( | ) | const |
Definition at line 312 of file Polygon.cc.
| LsstPoint lsst::afw::geom::polygon::Polygon::calculateCenter | ( | ) | const |
Definition at line 308 of file Polygon.cc.
| double lsst::afw::geom::polygon::Polygon::calculatePerimeter | ( | ) | const |
Definition at line 314 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 339 of file Polygon.cc.
| std::shared_ptr< Polygon > lsst::afw::geom::polygon::Polygon::convexHull | ( | ) | const |
Produce a polygon from the convex hull.
Definition at line 387 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 430 of file Polygon.cc.
|
inline |
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.
| std::vector< LsstPoint >::const_iterator lsst::afw::geom::polygon::Polygon::end | ( | void | ) | const |
Iterator for vertices.
Iterates only over the "open" polygon vertices (i.e., same number as returned by "getNumEdges").
Definition at line 331 of file Polygon.cc.
| Polygon::Box lsst::afw::geom::polygon::Polygon::getBBox | ( | ) | const |
Return bounding box.
Definition at line 304 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 316 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 299 of file Polygon.cc.
|
protectedvirtual |
Whether Polygon is persistable which is always true.
Reimplemented from lsst::afw::table::io::Persistable.
Definition at line 565 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::afw::math::Kernel, lsst::afw::geom::SkyWcs, lsst::afw::detection::Footprint, lsst::afw::geom::Transform< FromEndpoint, ToEndpoint >, lsst::afw::geom::Transform< afw::geom::Point2Endpoint, afw::geom::GenericEndpoint >, lsst::afw::image::TransmissionCurve, lsst::afw::math::ChebyshevBoundedField, lsst::afw::math::Function< ReturnT >, lsst::afw::math::Function< Kernel::Pixel >, lsst::afw::detection::GaussianPsf, lsst::afw::math::TransformBoundedField, and lsst::afw::image::CoaddInputs.
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 327 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 353 of file Polygon.cc.
| std::vector< std::shared_ptr< Polygon > > lsst::afw::geom::polygon::Polygon::intersection | ( | Box const & | box | ) | const |
Returns the intersection of two polygons.
Handles the full range of possibilities.
Definition at line 357 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 345 of file Polygon.cc.
| std::shared_ptr< Polygon > lsst::afw::geom::polygon::Polygon::intersectionSingle | ( | Box const & | box | ) | 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 349 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 335 of file Polygon.cc.
|
inline |
|
inline |
|
inline |
|
inline |
| 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 341 of file Polygon.cc.
| bool lsst::afw::geom::polygon::Polygon::overlaps | ( | Box const & | box | ) | 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 343 of file Polygon.cc.
|
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 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.
|
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.
| 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 381 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 408 of file Polygon.cc.
| std::shared_ptr< Polygon > lsst::afw::geom::polygon::Polygon::subSample | ( | double | maxLength | ) | const |
Sub-sample each edge.
This should provide greater fidelity when transforming with a non-linear transform.
Definition at line 418 of file Polygon.cc.
|
inlinenoexcept |
| 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 373 of file Polygon.cc.
| std::vector< std::shared_ptr< Polygon > > lsst::afw::geom::polygon::Polygon::symDifference | ( | Box const & | box | ) | const |
Return the symmetric difference of two polygons.
Definition at line 377 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 393 of file Polygon.cc.
| std::shared_ptr< Polygon > lsst::afw::geom::polygon::Polygon::transform | ( | lsst::geom::AffineTransform 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 398 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 367 of file Polygon.cc.
| std::vector< std::shared_ptr< Polygon > > lsst::afw::geom::polygon::Polygon::union_ | ( | Box const & | box | ) | 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 371 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 361 of file Polygon.cc.
| std::shared_ptr< Polygon > lsst::afw::geom::polygon::Polygon::unionSingle | ( | Box const & | box | ) | const |
Returns the union of two polygons.
Does not handle non-overlapping polygons, the union of which would be disjoint.
Definition at line 365 of file Polygon.cc.
|
protectedvirtual |
Whether Polygon is persistable which is always true.
Reimplemented from lsst::afw::table::io::Persistable.
Definition at line 567 of file Polygon.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.
|
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 an already-open FITS object.
| [in] | fitsfile | Open FITS object to write to. |
Definition at line 18 of file Persistable.cc.
1.8.13