25 #if !defined(LSST_AFW_GEOM_POLYGON_POLYGON_H)
26 #define LSST_AFW_GEOM_POLYGON_POLYGON_H
33 #include "lsst/base.h"
34 #include "lsst/pex/exceptions.h"
67 std::shared_ptr<XYTransform const>
const&
transform
72 explicit Polygon(std::vector<Point>
const& vertices);
98 std::vector<Point>::const_iterator
begin()
const;
103 std::vector<Point>::const_iterator
end()
const;
109 std::vector<std::pair<Point, Point>>
getEdges()
const;
141 std::vector<std::shared_ptr<Polygon>>
intersection(
Box const& box)
const;
154 std::vector<std::shared_ptr<Polygon>>
union_(
Polygon const& other)
const;
160 std::vector<std::shared_ptr<Polygon>>
union_(
Box const& box)
const;
194 std::shared_ptr<XYTransform const>
const&
transform
202 std::shared_ptr<Polygon>
subSample(
size_t num)
const;
206 std::shared_ptr<Polygon>
subSample(
double maxLength)
const;
210 std::shared_ptr<afw::image::Image<float>>
createImage(
Box2I const& bbox)
const;
237 std::shared_ptr<Impl> _impl;
238 Polygon(std::shared_ptr<Impl> impl) : _impl(impl) {}
243 std::ostream&
operator<<(std::ostream& os, Polygon
const& poly);
double calculatePerimeter() const
double calculateArea() const
std::shared_ptr< Polygon > simplify(double const distance) const
Return a simplified polygon.
std::shared_ptr< afw::image::Image< float > > createImage(Box2I const &bbox) const
Create image of polygon.
size_t getNumEdges() const
Return number of edges.
void swap(ImageBase< PixelT > &a, ImageBase< PixelT > &b)
std::vector< std::pair< Point, Point > > getEdges() const
Get vector of edges.
std::shared_ptr< afw::image::Image< float > > createImage(Extent2I const &extent) const
Create image of polygon.
std::shared_ptr< Polygon > unionSingle(Polygon const &other) const
Returns the union of two polygons.
bool operator!=(Polygon const &other) const
std::vector< Point > getVertices() const
Get vector of vertices.
Polygon(Box const &box)
Constructors.
std::vector< std::shared_ptr< Polygon > > operator^(Polygon const &rhs) const
Operators for syntactic sugar.
std::vector< std::shared_ptr< Polygon > > union_(Polygon const &other) const
Returns the union of two polygons.
Box getBBox() const
Return bounding box.
bool contains(Point const &point) const
Returns whether the polygon contains the point.
An integer coordinate rectangle.
A base class for objects that can be persisted via afw::table::io Archive classes.
std::vector< std::shared_ptr< Polygon > > operator&(Polygon const &rhs) const
Operators for syntactic sugar.
std::ostream & operator<<(std::ostream &os, Polygon const &poly)
Stream polygon.
std::vector< std::shared_ptr< Polygon > > operator&(Box const &rhs) const
Operators for syntactic sugar.
bool operator==(Polygon const &other) const
virtual void write(OutputArchiveHandle &handle) const
Whether Polygon is persistable which is always true.
virtual bool isPersistable() const
Whether Polygon is persistable which is always true.
An exception that indicates the single-polygon assumption has been violated.
std::shared_ptr< Polygon > convexHull() const
Produce a polygon from the convex hull.
std::vector< Point >::const_iterator begin() const
Iterator for vertices.
std::vector< Point >::const_iterator end() const
Iterator for vertices.
bool overlaps(Polygon const &other) const
Returns whether the polygons overlap each other.
std::shared_ptr< Polygon > transform(std::shared_ptr< XYTransform const > const &transform) const
Transform the polygon.
std::shared_ptr< Polygon > subSample(size_t num) const
Sub-sample each edge.
std::vector< std::shared_ptr< Polygon > > symDifference(Polygon const &other) const
Return the symmetric difference of two polygons.
virtual std::string getPersistenceName() const
Whether Polygon is persistable which is always true.
io::OutputArchiveHandle OutputArchiveHandle
std::vector< std::shared_ptr< Polygon > > intersection(Polygon const &other) const
Returns the intersection of two polygons.
std::shared_ptr< Polygon > intersectionSingle(Polygon const &other) const
Returns the intersection of two polygons.
std::vector< std::shared_ptr< Polygon > > operator|(Polygon const &rhs) const
Operators for syntactic sugar.
A floating-point coordinate rectangle geometry.
void swap(Polygon &other)
Swap two polygons.
A CRTP facade class for subclasses of Persistable.
std::vector< std::shared_ptr< Polygon > > operator^(Box const &rhs) const
Operators for syntactic sugar.
std::vector< std::shared_ptr< Polygon > > operator|(Box const &rhs) const
Operators for syntactic sugar.
Point calculateCenter() const