LSSTApplications  1.1.2+25,10.0+13,10.0+132,10.0+133,10.0+224,10.0+41,10.0+8,10.0-1-g0f53050+14,10.0-1-g4b7b172+19,10.0-1-g61a5bae+98,10.0-1-g7408a83+3,10.0-1-gc1e0f5a+19,10.0-1-gdb4482e+14,10.0-11-g3947115+2,10.0-12-g8719d8b+2,10.0-15-ga3f480f+1,10.0-2-g4f67435,10.0-2-gcb4bc6c+26,10.0-28-gf7f57a9+1,10.0-3-g1bbe32c+14,10.0-3-g5b46d21,10.0-4-g027f45f+5,10.0-4-g86f66b5+2,10.0-4-gc4fccf3+24,10.0-40-g4349866+2,10.0-5-g766159b,10.0-5-gca2295e+25,10.0-6-g462a451+1
LSSTDataManagementBasePackage
Public Types | Public Member Functions | List of all members
lsst.afw.geom::Polygon Class Reference

#include <Polygon.h>

Public Types

typedef Box2D Box
 
typedef Point2D Point
 

Public Member Functions

void swap (Polygon &other)
 Swap two polygons. More...
 
size_t getNumEdges () const
 
Box getBBox () const
 Return bounding box. More...
 
Point calculateCenter () const
 
double calculateArea () const
 
double calculatePerimeter () const
 
std::vector< PointgetVertices () const
 
std::vector< std::pair< Point,
Point > > 
getEdges () const
 
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...
 
Polygon convexHull () const
 Produce a polygon from the convex hull. More...
 
 Polygon (Box const &box)
 Constructors. More...
 
 Polygon (Box const &box, boost::shared_ptr< XYTransform const > const &transform)
 Constructors. More...
 
 Polygon (Box const &box, AffineTransform const &transform)
 Constructors. More...
 
 Polygon (std::vector< Point > const &vertices)
 Constructors. More...
 
std::vector< Point >
::const_iterator 
begin () const
 
std::vector< Point >
::const_iterator 
end () const
 
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...
 
Polygon intersectionSingle (Polygon const &other) const
 
Polygon intersectionSingle (Box const &box) const
 
std::vector< Polygonintersection (Polygon const &other) const
 
std::vector< Polygonintersection (Box const &box) const
 
Polygon unionSingle (Polygon const &other) const
 
Polygon unionSingle (Box const &box) const
 
std::vector< Polygonunion_ (Polygon const &other) const
 
std::vector< Polygonunion_ (Box const &box) const
 
std::vector< Polygonoperator& (Polygon const &rhs) const
 Operators for syntactic sugar. More...
 
std::vector< Polygonoperator& (Box const &rhs) const
 Operators for syntactic sugar. More...
 
std::vector< Polygonoperator| (Polygon const &rhs) const
 Operators for syntactic sugar. More...
 
std::vector< Polygonoperator| (Box const &rhs) const
 Operators for syntactic sugar. More...
 
Polygon transform (boost::shared_ptr< XYTransform const > const &transform) const
 
Polygon transform (AffineTransform const &transform) const
 
Polygon subSample (size_t num) const
 
Polygon subSample (double maxLength) const
 
boost::shared_ptr
< afw::image::Image< float > > 
createImage (Box2I const &bbox) const
 
boost::shared_ptr
< afw::image::Image< float > > 
createImage (Extent2I const &extent) const
 
boost::shared_ptr< Impl > _impl
 
 Polygon (boost::shared_ptr< Impl > impl)
 

Detailed Description

Cartesian polygons

Polygons are defined by a set of vertices

Definition at line 54 of file Polygon.h.

Member Typedef Documentation

Definition at line 56 of file Polygon.h.

Definition at line 57 of file Polygon.h.

Constructor & Destructor Documentation

lsst.afw.geom::Polygon::Polygon ( Box const &  box)
explicit

Constructors.

lsst.afw.geom::Polygon::Polygon ( Box const &  box,
boost::shared_ptr< XYTransform const > const &  transform 
)

Constructors.

Parameters
boxBox to convert to polygon
transformTransform from original to target frame
lsst.afw.geom::Polygon::Polygon ( Box const &  box,
AffineTransform const &  transform 
)

Constructors.

Parameters
boxBox to convert to polygon
transformTransform from original to target frame
lsst.afw.geom::Polygon::Polygon ( std::vector< Point > const &  vertices)
explicit

Constructors.

lsst.afw.geom::Polygon::Polygon ( boost::shared_ptr< Impl >  impl)
inlineprivate

Definition at line 211 of file Polygon.h.

211 : _impl(impl) {}
boost::shared_ptr< Impl > _impl
Definition: Polygon.h:209

Member Function Documentation

std::vector<Point>::const_iterator lsst.afw.geom::Polygon::begin ( ) const

Iterator for vertices

Iterates only over the "open" polygon vertices (i.e., same number as returned by "getNumEdges").

double lsst.afw.geom::Polygon::calculateArea ( ) const
Point lsst.afw.geom::Polygon::calculateCenter ( ) const
double lsst.afw.geom::Polygon::calculatePerimeter ( ) const
bool lsst.afw.geom::Polygon::contains ( Point const &  point) const

Returns whether the polygon contains the point.

Polygon lsst.afw.geom::Polygon::convexHull ( ) const

Produce a polygon from the convex hull.

boost::shared_ptr< afw::image::Image<float> > lsst.afw.geom::Polygon::createImage ( 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.

boost::shared_ptr< afw::image::Image<float> > lsst.afw.geom::Polygon::createImage ( Extent2I const &  extent) const
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.

Definition at line 201 of file Polygon.h.

201  {
202  return createImage(Box2I(Point2I(0, 0), extent));
203  }
Point< int, 2 > Point2I
Definition: PSF.h:39
boost::shared_ptr< afw::image::Image< float > > createImage(Box2I const &bbox) const
std::vector<Point>::const_iterator lsst.afw.geom::Polygon::end ( ) const

Iterator for vertices

Iterates only over the "open" polygon vertices (i.e., same number as returned by "getNumEdges").

Box lsst.afw.geom::Polygon::getBBox ( ) const

Return bounding box.

std::vector<std::pair<Point, Point> > lsst.afw.geom::Polygon::getEdges ( ) const

Get vector of edges

Returns edges, as pairs of vertices.

size_t lsst.afw.geom::Polygon::getNumEdges ( ) const

Return number of edges

Identical with the number of points

std::vector<Point> lsst.afw.geom::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.

std::vector<Polygon> lsst.afw.geom::Polygon::intersection ( Polygon const &  other) const

Returns the intersection of two polygons

Handles the full range of possibilities.

std::vector<Polygon> lsst.afw.geom::Polygon::intersection ( Box const &  box) const

Returns the intersection of two polygons

Handles the full range of possibilities.

Polygon lsst.afw.geom::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.

Polygon lsst.afw.geom::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.

bool lsst.afw.geom::Polygon::operator!= ( Polygon const &  other) const
inline

Definition at line 110 of file Polygon.h.

110 { return !(*this == other); }
std::vector<Polygon> lsst.afw.geom::Polygon::operator& ( Polygon const &  rhs) const
inline

Operators for syntactic sugar.

Definition at line 160 of file Polygon.h.

160 { return intersection(rhs); }
std::vector< Polygon > intersection(Polygon const &other) const
std::vector<Polygon> lsst.afw.geom::Polygon::operator& ( Box const &  rhs) const
inline

Operators for syntactic sugar.

Definition at line 161 of file Polygon.h.

161 { return intersection(rhs); }
std::vector< Polygon > intersection(Polygon const &other) const
bool lsst.afw.geom::Polygon::operator== ( Polygon const &  other) const
std::vector<Polygon> lsst.afw.geom::Polygon::operator| ( Polygon const &  rhs) const
inline

Operators for syntactic sugar.

Definition at line 162 of file Polygon.h.

162 { return union_(rhs); }
std::vector< Polygon > union_(Polygon const &other) const
std::vector<Polygon> lsst.afw.geom::Polygon::operator| ( Box const &  rhs) const
inline

Operators for syntactic sugar.

Definition at line 163 of file Polygon.h.

163 { return union_(rhs); }
std::vector< Polygon > union_(Polygon const &other) const
bool lsst.afw.geom::Polygon::overlaps ( Polygon const &  other) const

Returns whether the polygons overlap each other.

bool lsst.afw.geom::Polygon::overlaps ( Box const &  box) const

Returns whether the polygons overlap each other.

Polygon lsst.afw.geom::Polygon::subSample ( size_t  num) const

Sub-sample each edge

This should provide greater fidelity when transforming with a non-linear transform.

Polygon lsst.afw.geom::Polygon::subSample ( double  maxLength) const

Sub-sample each edge

This should provide greater fidelity when transforming with a non-linear transform.

void lsst.afw.geom::Polygon::swap ( Polygon other)
inline

Swap two polygons.

Definition at line 72 of file Polygon.h.

72  {
73  std::swap(this->_impl, other._impl);
74  }
void swap(ImageBase< PixelT > &a, ImageBase< PixelT > &b)
Definition: Image.cc:291
boost::shared_ptr< Impl > _impl
Definition: Polygon.h:209
Polygon lsst.afw.geom::Polygon::transform ( boost::shared_ptr< XYTransform const > 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.

Parameters
transformTransform from original to target frame
Polygon lsst.afw.geom::Polygon::transform ( 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.

Parameters
transformTransform from original to target frame
std::vector<Polygon> lsst.afw.geom::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.

std::vector<Polygon> lsst.afw.geom::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.

Polygon lsst.afw.geom::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.

Polygon lsst.afw.geom::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.

Member Data Documentation

boost::shared_ptr< Impl > lsst.afw.geom::Polygon::_impl
private

Definition at line 209 of file Polygon.h.


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