LSSTApplications  17.0+10,17.0+51,17.0+87,18.0.0+10,18.0.0+15,18.0.0+33,18.0.0+4,18.0.0+6,18.0.0-2-ge43143a+6,18.1.0-1-g0001055+2,18.1.0-1-g0896a44+9,18.1.0-1-g1349e88+8,18.1.0-1-g2505f39+6,18.1.0-1-g380d4d4+8,18.1.0-1-g5e4b7ea+2,18.1.0-1-g7e8fceb,18.1.0-1-g85f8cd4+6,18.1.0-1-g9a6769a+3,18.1.0-1-ga1a4c1a+5,18.1.0-1-gc037db8+2,18.1.0-1-gd55f500+3,18.1.0-1-ge10677a+6,18.1.0-10-g73b8679e+11,18.1.0-11-g311e899+7,18.1.0-12-gc95f69a+7,18.1.0-13-g451e75588,18.1.0-2-g31c43f9+6,18.1.0-2-g9c63283+8,18.1.0-2-gdf0b915+8,18.1.0-2-gf03bb23+2,18.1.0-3-g2e29e3d+9,18.1.0-3-g52aa583+3,18.1.0-3-g8f4a2b1,18.1.0-3-g9cb968e+7,18.1.0-4-gd2e8982+9,18.1.0-5-g510c42a+7,18.1.0-5-gaeab27e+8,18.1.0-6-gdda7f3e+10,18.1.0-8-g4084bf03,w.2019.33
LSSTDataManagementBasePackage
Namespaces | Classes | Functions
lsst::afw::geom::polygon Namespace Reference

Namespaces

 polygonContinued
 

Classes

class  Polygon
 Cartesian polygons. More...
 
class  SinglePolygonException
 An exception that indicates the single-polygon assumption has been violated. More...
 

Functions

std::ostreamoperator<< (std::ostream &os, Polygon const &poly)
 Stream polygon. More...
 
 PYBIND11_MODULE (polygon, mod)
 
std::ostreamoperator<< (std::ostream &os, std::vector< LsstPoint > const &vertices)
 
std::ostreamoperator<< (std::ostream &os, BoostPolygon const &poly)
 

Function Documentation

◆ operator<<() [1/3]

std::ostream& lsst::afw::geom::polygon::operator<< ( std::ostream os,
std::vector< LsstPoint > const &  vertices 
)

Definition at line 157 of file Polygon.cc.

157  {
158  os << "[";
159  size_t num = vertices.size();
160  for (size_t i = 0; i < num - 1; ++i) {
161  os << vertices[i] << ",";
162  }
163  os << vertices[vertices.size() - 1] << "]";
164  return os;
165 }
T size(T... args)
std::ostream * os
Definition: Schema.cc:746

◆ operator<<() [2/3]

std::ostream& lsst::afw::geom::polygon::operator<< ( std::ostream os,
BoostPolygon const &  poly 
)

Definition at line 168 of file Polygon.cc.

168  {
169  return os << "BoostPolygon(" << poly.outer() << ")";
170 }
Low-level polynomials (including special polynomials) in C++.
Definition: Basis1d.h:26

◆ operator<<() [3/3]

std::ostream & lsst::afw::geom::polygon::operator<< ( std::ostream os,
Polygon const &  poly 
)

Stream polygon.

Definition at line 172 of file Polygon.cc.

172  {
173  os << poly.toString();
174  return os;
175 }
Low-level polynomials (including special polynomials) in C++.
Definition: Basis1d.h:26
std::ostream * os
Definition: Schema.cc:746

◆ PYBIND11_MODULE()

lsst::afw::geom::polygon::PYBIND11_MODULE ( polygon  ,
mod   
)

Definition at line 46 of file polygon.cc.

46  {
47  py::module::import("lsst.pex.exceptions");
48  py::module::import("lsst.afw.typehandling");
49 
50  // TODO: Commented-out code is waiting until needed and is untested.
51  // Add tests for it and enable it or remove it before the final pybind11 merge.
52 
53  /* Module level */
54  py::class_<Polygon, std::shared_ptr<Polygon>, typehandling::Storable> clsPolygon(mod, "Polygon");
55 
56  pex::exceptions::python::declareException<SinglePolygonException, pex::exceptions::RuntimeError>(
57  mod, "SinglePolygonException", "RuntimeError");
58 
59  /* Member types and enums */
60 
61  /* Constructors */
62  clsPolygon.def(py::init<Polygon::Box const &>());
63  clsPolygon.def(py::init<Polygon::Box const &, TransformPoint2ToPoint2 const &>());
64  clsPolygon.def(py::init<Polygon::Box const &, lsst::geom::AffineTransform const &>());
65  clsPolygon.def(py::init<std::vector<Polygon::Point> const &>());
66 
67  table::io::python::addPersistableMethods<Polygon>(clsPolygon);
68 
69  /* Operators */
70  clsPolygon.def("__eq__", [](Polygon const &self, Polygon const &other) { return self == other; },
71  py::is_operator());
72  clsPolygon.def("__ne__", [](Polygon const &self, Polygon const &other) { return self != other; },
73  py::is_operator());
74 
75  /* Members */
76  clsPolygon.def("getNumEdges", &Polygon::getNumEdges);
77  clsPolygon.def("getBBox", &Polygon::getBBox);
78  clsPolygon.def("calculateCenter", &Polygon::calculateCenter);
79  clsPolygon.def("calculateArea", &Polygon::calculateArea);
80  clsPolygon.def("calculatePerimeter", &Polygon::calculatePerimeter);
81  clsPolygon.def("getVertices", &Polygon::getVertices);
82  clsPolygon.def("getEdges", &Polygon::getEdges);
83  clsPolygon.def("contains", &Polygon::contains);
84  clsPolygon.def("overlaps", (bool (Polygon::*)(Polygon const &) const) & Polygon::overlaps);
85  clsPolygon.def("overlaps", (bool (Polygon::*)(Polygon::Box const &) const) & Polygon::overlaps);
86  clsPolygon.def("intersectionSingle", (std::shared_ptr<Polygon>(Polygon::*)(Polygon const &) const) &
87  Polygon::intersectionSingle);
88  clsPolygon.def("intersectionSingle", (std::shared_ptr<Polygon>(Polygon::*)(Polygon::Box const &) const) &
89  Polygon::intersectionSingle);
90  clsPolygon.def("intersection",
91  (std::vector<std::shared_ptr<Polygon>>(Polygon::*)(Polygon const &) const) &
92  Polygon::intersection);
93  clsPolygon.def("intersection",
94  (std::vector<std::shared_ptr<Polygon>>(Polygon::*)(Polygon::Box const &) const) &
95  Polygon::intersection);
96  clsPolygon.def("unionSingle",
97  (std::shared_ptr<Polygon>(Polygon::*)(Polygon const &) const) & Polygon::unionSingle);
98  clsPolygon.def("unionSingle",
99  (std::shared_ptr<Polygon>(Polygon::*)(Polygon::Box const &) const) & Polygon::unionSingle);
100 
101  // Wrap Polygon::union_ (C++) as Polygon.union (Python)
102  clsPolygon.def("union", (std::vector<std::shared_ptr<Polygon>>(Polygon::*)(Polygon const &) const) &
103  Polygon::union_);
104  clsPolygon.def("union", (std::vector<std::shared_ptr<Polygon>>(Polygon::*)(Polygon::Box const &) const) &
105  Polygon::union_);
106  clsPolygon.def("symDifference",
107  (std::vector<std::shared_ptr<Polygon>>(Polygon::*)(Polygon const &) const) &
108  Polygon::symDifference);
109  clsPolygon.def("symDifference",
110  (std::vector<std::shared_ptr<Polygon>>(Polygon::*)(Polygon::Box const &) const) &
111  Polygon::symDifference);
112  // clsPolygon.def("simplify", &Polygon::simplify);
113  clsPolygon.def("convexHull", &Polygon::convexHull);
114  clsPolygon.def("transform",
115  (std::shared_ptr<Polygon>(Polygon::*)(TransformPoint2ToPoint2 const &) const) &
117  clsPolygon.def("transform",
118  (std::shared_ptr<Polygon>(Polygon::*)(lsst::geom::AffineTransform const &) const) &
119  Polygon::transform);
120  clsPolygon.def("subSample", (std::shared_ptr<Polygon>(Polygon::*)(size_t) const) & Polygon::subSample);
121  clsPolygon.def("subSample", (std::shared_ptr<Polygon>(Polygon::*)(double) const) & Polygon::subSample);
122  clsPolygon.def("createImage",
123  (std::shared_ptr<afw::image::Image<float>>(Polygon::*)(lsst::geom::Box2I const &) const) &
124  Polygon::createImage);
125  clsPolygon.def(
126  "createImage",
127  (std::shared_ptr<afw::image::Image<float>>(Polygon::*)(lsst::geom::Extent2I const &) const) &
128  Polygon::createImage);
129  // clsPolygon.def("isPersistable", &Polygon::isPersistable);
130 }
bool contains(VertexIterator const begin, VertexIterator const end, UnitVector3d const &v)
An affine coordinate transformation consisting of a linear transformation and an offset.
def init()
Definition: tests.py:64
ItemVariant const * other
Definition: Schema.cc:56
Transform< Point2Endpoint, Point2Endpoint > TransformPoint2ToPoint2
Definition: Transform.h:300
STL class.
table::Key< int > transform
An integer coordinate rectangle.
Definition: Box.h:54