LSST Applications g0265f82a02+0e5473021a,g02d81e74bb+0dd8ce4237,g1470d8bcf6+3ea6592b6f,g2079a07aa2+86d27d4dc4,g2305ad1205+5ca4c0b359,g295015adf3+d10818ec9d,g2a9a014e59+6f9be1b9cd,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g3ddfee87b4+703ba97ebf,g487adcacf7+4fa16da234,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+ffa42b374e,g5a732f18d5+53520f316c,g64a986408d+0dd8ce4237,g858d7b2824+0dd8ce4237,g8a8a8dda67+585e252eca,g99cad8db69+d39438377f,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+f1d96605c8,gb0e22166c9+60f28cb32d,gb6a65358fc+0e5473021a,gba4ed39666+c2a2e4ac27,gbb8dafda3b+e5339d463f,gc120e1dc64+da31e9920e,gc28159a63d+0e5473021a,gcf0d15dbbd+703ba97ebf,gdaeeff99f8+f9a426f77a,ge6526c86ff+889fc9d533,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gf18bd8381d+7268b93478,gff1a9f87cc+0dd8ce4237,w.2024.16
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
lsst::afw::geom::ellipses::PixelRegion Class Referencefinal

A pixelized region containing all pixels whose centers are within an Ellipse. More...

#include <PixelRegion.h>

Public Types

using Iterator = std::vector<Span>::const_iterator
 Iterator type used by begin() and end().
 

Public Member Functions

 PixelRegion (Ellipse const &ellipse)
 Construct a PixelRegion from an Ellipse.
 
 PixelRegion (PixelRegion const &)=default
 PixelRegion is copy and move constructable and assignable.
 
 PixelRegion (PixelRegion &&)=default
 
PixelRegionoperator= (PixelRegion const &)=default
 
PixelRegionoperator= (PixelRegion &&)=default
 
 ~PixelRegion ()=default
 
Iterator begin () const
 Iterator range over Spans whose pixels are within the Ellipse.
 
Iterator end () const
 
lsst::geom::Box2I const & getBBox () const
 Return the bounding box of the pixel region.
 
Span const getSpanAt (int y) const
 Return the span at the given y coordinate value.
 

Detailed Description

A pixelized region containing all pixels whose centers are within an Ellipse.

The pixel region for an ellipse may be larger or smaller in area than the ellipse itself, depending on the details of where pixel centers land, and it may be empty even if the area of the ellipse is nonzero.

Definition at line 46 of file PixelRegion.h.

Member Typedef Documentation

◆ Iterator

Iterator type used by begin() and end().

Definition at line 50 of file PixelRegion.h.

Constructor & Destructor Documentation

◆ PixelRegion() [1/3]

lsst::afw::geom::ellipses::PixelRegion::PixelRegion ( Ellipse const & ellipse)
explicit

Construct a PixelRegion from an Ellipse.

Definition at line 100 of file PixelRegion.cc.

101 : _bbox(ellipse.computeBBox(), lsst::geom::Box2I::EXPAND)
102{
103 // Initial temporary bounding box that may be larger than the final one.
104 lsst::geom::Box2I envelope(ellipse.computeBBox(), lsst::geom::Box2I::EXPAND);
105
106 if (envelope.isEmpty()) {
107 // If the outer bbox is empty, we know there can't be any spans that
108 // contain ellipse pixels.
109 return;
110 }
111
112 // Helper class that does the hard work: compute the boundary points of the
113 // ellipse in x that intersect a horizontal line at some given y.
114 EllipseHorizontalLineIntersection intersection(ellipse);
115
116 // Iterate over pixel rows in the bounding box, computing the intersection
117 // of the ellipse with that y coordinate.
118 int const yEnd = envelope.getEndY();
119 for (int y = envelope.getBeginY(); y != yEnd; ++y) {
120 auto x = intersection.xAt(y);
121 if (x) {
122 int xMin = std::ceil(x->first);
123 int xMax = std::floor(x->second);
124 if (xMax < xMin) continue;
125 _spans.emplace_back(y, xMin, xMax);
126 _bbox.include(lsst::geom::Point2I(xMin, y));
127 _bbox.include(lsst::geom::Point2I(xMax, y));
128 }
129 }
130}
int y
Definition SpanSet.cc:48
T ceil(T... args)
An integer coordinate rectangle.
Definition Box.h:55
void include(Point2I const &point)
Expand this to ensure that this->contains(point).
Definition Box.cc:152
T floor(T... args)

◆ PixelRegion() [2/3]

lsst::afw::geom::ellipses::PixelRegion::PixelRegion ( PixelRegion const & )
default

PixelRegion is copy and move constructable and assignable.

◆ PixelRegion() [3/3]

lsst::afw::geom::ellipses::PixelRegion::PixelRegion ( PixelRegion && )
default

◆ ~PixelRegion()

lsst::afw::geom::ellipses::PixelRegion::~PixelRegion ( )
default

Member Function Documentation

◆ begin()

Iterator lsst::afw::geom::ellipses::PixelRegion::begin ( ) const
inline

Iterator range over Spans whose pixels are within the Ellipse.

Definition at line 68 of file PixelRegion.h.

68{ return _spans.begin(); }

◆ end()

Iterator lsst::afw::geom::ellipses::PixelRegion::end ( ) const
inline

Definition at line 69 of file PixelRegion.h.

69{ return _spans.end(); }

◆ getBBox()

lsst::geom::Box2I const & lsst::afw::geom::ellipses::PixelRegion::getBBox ( ) const
inline

Return the bounding box of the pixel region.

This is guaranteed to be the smallest box that includes all Spans. It has no guaranteed relationship with the Ellipse's direct (floating-point) bounding box as computed by Ellipse::computeBBox(), and may be empty even if the Ellipse's bounding box is not.

Definition at line 80 of file PixelRegion.h.

80{ return _bbox; }

◆ getSpanAt()

Span const lsst::afw::geom::ellipses::PixelRegion::getSpanAt ( int y) const

Return the span at the given y coordinate value.

Exceptions
lsst::pex::exceptions::OutOfRangeErrorThrown if y is not within the y bounds of getBBox().

Definition at line 132 of file PixelRegion.cc.

132 {
133 if (_bbox.isEmpty()) {
134 throw LSST_EXCEPT(
135 pex::exceptions::OutOfRangeError,
136 "PixelRegion is empty."
137 );
138 }
139 if (y < _bbox.getMinY() || y > _bbox.getMaxY()) {
140 throw LSST_EXCEPT(
141 pex::exceptions::OutOfRangeError,
142 (boost::format("No span at y=%s in pixel region with rows between y=%s and y=%s")
143 % y % _bbox.getMinY() % _bbox.getMaxY()).str()
144 );
145 }
146 return _spans[y - _bbox.getBeginY()];
147}
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition Exception.h:48
int getMinY() const noexcept
Definition Box.h:158
bool isEmpty() const noexcept
Return true if the box contains no points.
Definition Box.h:213
int getBeginY() const noexcept
Definition Box.h:173
int getMaxY() const noexcept
Definition Box.h:162

◆ operator=() [1/2]

PixelRegion & lsst::afw::geom::ellipses::PixelRegion::operator= ( PixelRegion && )
default

◆ operator=() [2/2]

PixelRegion & lsst::afw::geom::ellipses::PixelRegion::operator= ( PixelRegion const & )
default

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