LSST Applications  21.0.0-147-g0e635eb1+1acddb5be5,22.0.0+052faf71bd,22.0.0+1ea9a8b2b2,22.0.0+6312710a6c,22.0.0+729191ecac,22.0.0+7589c3a021,22.0.0+9f079a9461,22.0.1-1-g7d6de66+b8044ec9de,22.0.1-1-g87000a6+536b1ee016,22.0.1-1-g8e32f31+6312710a6c,22.0.1-10-gd060f87+016f7cdc03,22.0.1-12-g9c3108e+df145f6f68,22.0.1-16-g314fa6d+c825727ab8,22.0.1-19-g93a5c75+d23f2fb6d8,22.0.1-19-gb93eaa13+aab3ef7709,22.0.1-2-g8ef0a89+b8044ec9de,22.0.1-2-g92698f7+9f079a9461,22.0.1-2-ga9b0f51+052faf71bd,22.0.1-2-gac51dbf+052faf71bd,22.0.1-2-gb66926d+6312710a6c,22.0.1-2-gcb770ba+09e3807989,22.0.1-20-g32debb5+b8044ec9de,22.0.1-23-gc2439a9a+fb0756638e,22.0.1-3-g496fd5d+09117f784f,22.0.1-3-g59f966b+1e6ba2c031,22.0.1-3-g849a1b8+f8b568069f,22.0.1-3-gaaec9c0+c5c846a8b1,22.0.1-32-g5ddfab5d3+60ce4897b0,22.0.1-4-g037fbe1+64e601228d,22.0.1-4-g8623105+b8044ec9de,22.0.1-5-g096abc9+d18c45d440,22.0.1-5-g15c806e+57f5c03693,22.0.1-7-gba73697+57f5c03693,master-g6e05de7fdc+c1283a92b8,master-g72cdda8301+729191ecac,w.2021.39
LSST Data Management Base Package
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
lsst::afw::geom::polygon::Polygon::Impl Struct Reference

Public Member Functions

 Impl ()
 
 Impl (Polygon::Box const &box)
 
 Impl (std::vector< LsstPoint > const &vertices)
 
 Impl (BoostPolygon const &_poly)
 
void check ()
 
template<class PolyT >
bool overlaps (PolyT const &other) const
 
template<class PolyT >
std::shared_ptr< PolygonintersectionSingle (PolyT const &other) const
 
template<class PolyT >
std::vector< std::shared_ptr< Polygon > > intersection (PolyT const &other) const
 
template<class PolyT >
std::shared_ptr< PolygonunionSingle (PolyT const &other) const
 
template<class PolyT >
std::vector< std::shared_ptr< Polygon > > union_ (PolyT const &other) const
 
template<class PolyT >
std::vector< std::shared_ptr< Polygon > > symDifference (PolyT const &other) const
 

Static Public Member Functions

static std::vector< std::shared_ptr< Polygon > > convertBoostPolygons (std::vector< BoostPolygon > const &boostPolygons)
 

Public Attributes

BoostPolygon poly
 

Detailed Description

Definition at line 176 of file Polygon.cc.

Constructor & Destructor Documentation

◆ Impl() [1/4]

lsst::afw::geom::polygon::Polygon::Impl::Impl ( )
inline

Definition at line 177 of file Polygon.cc.

177 : poly() {}

◆ Impl() [2/4]

lsst::afw::geom::polygon::Polygon::Impl::Impl ( Polygon::Box const &  box)
inlineexplicit

Definition at line 178 of file Polygon.cc.

178  : poly() {
179  boost::geometry::assign(poly, box);
180  // Assignment from a box is correctly handled by BoostPolygon, so doesn't need a "check()"
181  }
Low-level polynomials (including special polynomials) in C++.
Definition: Basis1d.h:26

◆ Impl() [3/4]

lsst::afw::geom::polygon::Polygon::Impl::Impl ( std::vector< LsstPoint > const &  vertices)
inlineexplicit

Definition at line 182 of file Polygon.cc.

182  : poly() {
183  boost::geometry::assign(poly, vertices);
184  check(); // because the vertices might not have the correct orientation (CW vs CCW) or be open
185  }
afw::table::PointKey< double > vertices
Definition: Polygon.cc:525

◆ Impl() [4/4]

lsst::afw::geom::polygon::Polygon::Impl::Impl ( BoostPolygon const &  _poly)
inlineexplicit

Definition at line 186 of file Polygon.cc.

186 : poly(_poly) {}

Member Function Documentation

◆ check()

void lsst::afw::geom::polygon::Polygon::Impl::check ( )
inline

Definition at line 188 of file Polygon.cc.

188 { boost::geometry::correct(poly); }

◆ convertBoostPolygons()

std::vector< std::shared_ptr< Polygon > > lsst::afw::geom::polygon::Polygon::Impl::convertBoostPolygons ( std::vector< BoostPolygon > const &  boostPolygons)
static

Definition at line 217 of file Polygon.cc.

218  {
220  lsstPolygons.reserve(boostPolygons.size());
221  for (auto const &boostPolygon : boostPolygons) {
222  std::shared_ptr<Polygon> tmp(new Polygon(std::make_shared<Polygon::Impl>(boostPolygon)));
223  lsstPolygons.push_back(tmp);
224  }
225  return lsstPolygons;
226 }
Polygon(Box const &box)
Construct a rectangular Polygon whose vertices are the corners of a box.
Definition: Polygon.cc:283
T push_back(T... args)
T reserve(T... args)
T size(T... args)

◆ intersection()

template<class PolyT >
std::vector< std::shared_ptr< Polygon > > lsst::afw::geom::polygon::Polygon::Impl::intersection ( PolyT const &  other) const

Definition at line 244 of file Polygon.cc.

244  {
245  std::vector<BoostPolygon> boostResult;
246  boost::geometry::intersection(poly, other, boostResult);
247  return convertBoostPolygons(boostResult);
248 }
static std::vector< std::shared_ptr< Polygon > > convertBoostPolygons(std::vector< BoostPolygon > const &boostPolygons)
Definition: Polygon.cc:217

◆ intersectionSingle()

template<class PolyT >
std::shared_ptr< Polygon > lsst::afw::geom::polygon::Polygon::Impl::intersectionSingle ( PolyT const &  other) const

Definition at line 229 of file Polygon.cc.

229  {
231  boost::geometry::intersection(poly, other, result);
232  if (result.size() == 0) {
233  throw LSST_EXCEPT(SinglePolygonException, "Polygons have no intersection");
234  }
235  if (result.size() > 1) {
236  throw LSST_EXCEPT(
237  SinglePolygonException,
238  (boost::format("Multiple polygons (%d) created by intersection()") % result.size()).str());
239  }
240  return std::shared_ptr<Polygon>(new Polygon(std::make_shared<Impl>(result[0])));
241 }
py::object result
Definition: _schema.cc:429
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174

◆ overlaps()

template<class PolyT >
bool lsst::afw::geom::polygon::Polygon::Impl::overlaps ( PolyT const &  other) const
inline

Definition at line 195 of file Polygon.cc.

195  {
196  return !boost::geometry::disjoint(poly, other);
197  }

◆ symDifference()

template<class PolyT >
std::vector< std::shared_ptr< Polygon > > lsst::afw::geom::polygon::Polygon::Impl::symDifference ( PolyT const &  other) const

Definition at line 270 of file Polygon.cc.

270  {
271  std::vector<BoostPolygon> boostResult;
272  boost::geometry::sym_difference(poly, other, boostResult);
273  return convertBoostPolygons(boostResult);
274 }

◆ union_()

template<class PolyT >
std::vector< std::shared_ptr< Polygon > > lsst::afw::geom::polygon::Polygon::Impl::union_ ( PolyT const &  other) const

Definition at line 263 of file Polygon.cc.

263  {
264  std::vector<BoostPolygon> boostResult;
265  boost::geometry::union_(poly, other, boostResult);
266  return convertBoostPolygons(boostResult);
267 }

◆ unionSingle()

template<class PolyT >
std::shared_ptr< Polygon > lsst::afw::geom::polygon::Polygon::Impl::unionSingle ( PolyT const &  other) const

Definition at line 251 of file Polygon.cc.

251  {
253  boost::geometry::union_(poly, other, result);
254  if (result.size() != 1) {
255  throw LSST_EXCEPT(
256  SinglePolygonException,
257  (boost::format("Multiple polygons (%d) created by union_()") % result.size()).str());
258  }
259  return std::shared_ptr<Polygon>(new Polygon(std::make_shared<Impl>(result[0])));
260 }

Member Data Documentation

◆ poly

BoostPolygon lsst::afw::geom::polygon::Polygon::Impl::poly

Definition at line 214 of file Polygon.cc.


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