LSSTApplications  18.0.0+46,18.0.0+93,19.0.0,19.0.0+1,19.0.0+2,19.0.0+3,19.0.0+4,19.0.0-1-g20d9b18+2,19.0.0-1-g3dc8cbe+2,19.0.0-1-g425ff20,19.0.0-1-g5549ca4,19.0.0-1-g580fafe+2,19.0.0-1-g5db401e+3,19.0.0-1-g6fe20d0+1,19.0.0-1-g7011481+2,19.0.0-1-g8c57eb9+2,19.0.0-1-g9828021+2,19.0.0-1-gb5175dc+2,19.0.0-1-gd7f3e1b+2,19.0.0-1-gdc0e4a7+2,19.0.0-1-ge272bc4+2,19.0.0-2-g0d9f9cd+2,19.0.0-2-g1c703f9ef+1,19.0.0-2-g3d9e4fb2+2,19.0.0-2-gd955cfd+2,19.0.0-3-g2d13df8,19.0.0-3-g63079e6+2,19.0.0-7-g8a434f2+1,19.0.0-7-gf796fef9+3,w.2019.49
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 }
An affine coordinate transformation consisting of a linear transformation and an offset.
def init()
Definition: tests.py:65
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:55