LSSTApplications
19.0.0-14-gb0260a2+9346bf5579,20.0.0+34a42eae2c,20.0.0+4d97b31663,20.0.0+5a87225079,20.0.0+8558dd3f48,20.0.0+9180b0bcc6,20.0.0+b290a576ab,20.0.0+b2ea66fa67,20.0.0+bba7c37fb9,20.0.0+cd847060a9,20.0.0+d138450326,20.0.0+d8493377e7,20.0.0+dcf29472a8,20.0.0+ef162136e0,20.0.0+f45b7d88f4,20.0.0-1-g10df615+6305e2b088,20.0.0-1-g253301a+dcf29472a8,20.0.0-1-g498fb60+ff88705a28,20.0.0-1-g4d801e7+d83096fe1b,20.0.0-1-g8a53f90+2817c06967,20.0.0-1-gc96f8cb+bba7c37fb9,20.0.0-1-gd1c87d7+2817c06967,20.0.0-1-gdb27ee5+52b05b0b7e,20.0.0-12-ga81c59a+61094d0bf4,20.0.0-18-g08fba245+aea2d85f7a,20.0.0-2-gec03fae+3bc057fb2a,20.0.0-28-gb33ccd1+1ae6d82017,20.0.0-3-gd2e950e+f45b7d88f4,20.0.0-3-gdd5c15c+990b4320db,20.0.0-4-g4a2362f+f45b7d88f4,20.0.0-5-gac0d578b1+6c871ee35c,20.0.0-5-gfcebe35+988ee452db,20.0.0-6-g01203fff+883dccf1c0,20.0.0-7-g3c4151b+a8ac49de8d,20.0.0-8-gc2abeef+bba7c37fb9,20.0.0-9-gabd0d4c+52b05b0b7e,w.2020.33
LSSTDataManagementBasePackage
|
Go to the documentation of this file.
22 #ifndef LSST_GEOM_BOX_H
23 #define LSST_GEOM_BOX_H
27 #include "boost/format.hpp"
66 Box2I() noexcept : _minimum(0), _dimensions(0) {}
157 int getMinX() const noexcept {
return _minimum.getX(); }
158 int getMinY() const noexcept {
return _minimum.getY(); }
161 int getMaxX() const noexcept {
return _minimum.getX() + _dimensions.getX() - 1; }
162 int getMaxY() const noexcept {
return _minimum.getY() + _dimensions.getY() - 1; }
172 int getBeginX() const noexcept {
return _minimum.getX(); }
173 int getBeginY() const noexcept {
return _minimum.getY(); }
176 int getEndX() const noexcept {
return _minimum.getX() + _dimensions.getX(); }
177 int getEndY() const noexcept {
return _minimum.getY() + _dimensions.getY(); }
187 int getWidth() const noexcept {
return _dimensions.getX(); }
188 int getHeight() const noexcept {
return _dimensions.getY(); }
210 ndarray::View<boost::fusion::vector2<ndarray::index::Range, ndarray::index::Range> >
getSlices()
const;
213 bool isEmpty() const noexcept {
return _dimensions.getX() == 0 && _dimensions.getY() == 0; }
386 return (
boost::format(
"Box2I(%s,%s)") % _minimum.toString() % _dimensions.toString()).str();
514 double getMinX() const noexcept {
return _minimum.getX(); }
515 double getMinY() const noexcept {
return _minimum.getY(); }
518 double getMaxX() const noexcept {
return _maximum.getX(); }
519 double getMaxY() const noexcept {
return _maximum.getY(); }
529 double getWidth() const noexcept {
return isEmpty() ? 0 : _maximum.getX() - _minimum.getX(); }
530 double getHeight() const noexcept {
return isEmpty() ? 0 : _maximum.getY() - _minimum.getY(); }
533 return dim.getX() * dim.getY();
550 return Point2D((_minimum.asEigen() + _maximum.asEigen()) * 0.5);
552 double getCenterX() const noexcept {
return (_minimum.getX() + _maximum.getX()) * 0.5; }
553 double getCenterY() const noexcept {
return (_minimum.getY() + _maximum.getY()) * 0.5; }
557 bool isEmpty() const noexcept {
return _minimum.getX() != _minimum.getX(); }
608 void flipLR(
float xExtent);
611 void flipTB(
float yExtent);
762 return (
boost::format(
"Box2D(%s,%s)") % _minimum.toString() % _maximum.toString()).str();
766 void _tweakMax(
int n) noexcept {
767 if (_maximum[n] < 0.0) {
768 _maximum[n] *= (1.0 -
EPSILON);
769 }
else if (_maximum[n] > 0.0) {
770 _maximum[n] *= (1.0 +
EPSILON);
void flipTB(int yExtent)
Flip a bounding box about the x-axis given a parent box of extent (yExtent).
Point2D const getMin() const noexcept
void swap(Box2I &other) noexcept
A 1-d integer coordinate range.
Box2I reflectedAboutY(Element y) const
Reflect the box about a horizontal line (returning a new object).
bool operator==(Box2I const &other) const noexcept
Compare two boxes for equality.
bool intersects(Box2I const &other) const noexcept
1-d interval accessors
void flipLR(int xExtent)
Flip a bounding box about the y-axis given a parent box of extent (xExtent).
Box2I erodedBy(Element buffer) const
1-d interval accessors
Point2I const getMax() const noexcept
void shift(Extent2D const &offset)
Shift the position of the box by the given offset.
Box2I reflectedAboutX(Element x) const
Reflect the box about a vertical line (returning a new object).
Point2I const getBegin() const noexcept
Box2I & operator=(Box2I const &) noexcept=default
Standard assignment operator.
Box2D erodedBy(Extent const &buffer) const
Decrease the size of the box by the given amount(s) on all sides (returning a new object).
ndarray::View< boost::fusion::vector2< ndarray::index::Range, ndarray::index::Range > > getSlices() const
Return slices to extract the box's region from an ndarray::Array.
bool intersects(Box2D const &other) const noexcept
Return true if the box contains no points.
Box2I erodedBy(Extent const &buffer) const
Decrease the size of the box by the given amount(s) on all sides (returning a new object).
Interval getX() const
1-d interval accessors
int getHeight() const noexcept
Extent2I const getDimensions() const noexcept
Box2I(Box2I &&) noexcept=default
bool operator==(Box2D const &other) const noexcept
Compare two boxes for equality.
static Box2I makeCenteredBox(Point2D const ¢er, Extent const &size)
Create a box centered as closely as possible on a particular point.
bool contains(Point2D const &point) const noexcept
Return true if the box contains the point.
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
bool overlaps(Box2D const &other) const noexcept
Return true if any points in other are also in this.
Extent2D const getDimensions() const noexcept
1-d interval accessors
Point2I const getMin() const noexcept
double getCenterY() const noexcept
Return true if the box contains no points.
Point< double, 2 > Point2D
Box2I(Box2I const &) noexcept=default
Standard copy constructor.
Box2I dilatedBy(Element buffer) const
1-d interval accessors
void swap(Point &other) noexcept
size_t operator()(argument_type const &x) const noexcept
bool isEmpty() const noexcept
Return true if the box contains no points.
double getCenterX() const noexcept
Return true if the box contains no points.
Box2D clippedTo(Box2D const &other) const
Shrink a box to ensure that it is contained by other (returning a new object).
std::vector< Point2D > getCorners() const
Get the corner points.
Box2D() noexcept
Construct an empty box.
int getEndY() const noexcept
Box2D dilatedBy(Extent const &buffer) const
Increase the size of the box by the given amount(s) on all sides (returning a new object).
double getHeight() const noexcept
1-d interval accessors
Box2I shiftedBy(Extent const &offset) const
Shift the position of the box by the given offset (returning a new object).
Interval getY() const
1-d interval accessors
std::string toString() const
Return true if the box contains no points.
Box2D & operator=(Box2D &&) noexcept=default
void shift(Extent2I const &offset)
Shift the position of the box by the given offset.
double getMinY() const noexcept
int getBeginY() const noexcept
static Box2D makeCenteredBox(Point2D const ¢er, Extent const &size) noexcept
Create a box centered on a particular point.
double getCenterY() const noexcept
1-d interval accessors
size_t operator()(argument_type const &x) const noexcept
int getWidth() const noexcept
void swap(Box2D &other) noexcept
bool contains(Element x, Element y) const noexcept
1-d interval accessors
double getCenterX() const noexcept
1-d interval accessors
void grow(int buffer)
Increase the size of the box by the given buffer amount in all directions.
double getMaxX() const noexcept
void include(Point2I const &point)
Expand this to ensure that this->contains(point).
Box2I() noexcept
Construct an empty box.
double getWidth() const noexcept
1-d interval accessors
Point2I const getEnd() const noexcept
double getMinX() const noexcept
ItemVariant const * other
int getBeginX() const noexcept
bool contains(Point2I const &point) const noexcept
Return true if the box contains the point.
Point2D const getMax() const noexcept
Interval getY() const
1-d interval accessors
Box2I clippedTo(Box2I const &other) const noexcept
Shrink an interval to ensure that it is contained by other (returning a new object).
Box2D dilatedBy(Element buffer) const
Return true if the box contains no points.
static IntervalI fromMinSize(Element min, Element size)
Construct an interval from its lower bound and size.
Box2I dilatedBy(Extent const &buffer) const
Increase the size of the box by the given amount(s) on all sides (returning a new object).
afw::table::PointKey< int > dimensions
void clip(Box2D const &other) noexcept
Shrink this to ensure that other.contains(*this).
bool isDisjointFrom(Box2D const &other) const noexcept
Return true if there are no points in both this and other.
A base class for image defects.
std::ostream & operator<<(std::ostream &os, lsst::geom::AffineTransform const &transform)
Box2D erodedBy(Element buffer) const
Return true if the box contains no points.
Point2D const getCenter() const noexcept
1-d interval accessors
A floating-point coordinate rectangle geometry.
Box2D expandedTo(Point const &other) const
Expand a box to ensure that contains(other) is true (returning a new object).
std::size_t hash_value() const noexcept
Return a hash of this object.
int getEndX() const noexcept
bool operator!=(Box2D const &other) const noexcept
Compare two boxes for equality.
Interval getX() const
1-d interval accessors
bool overlaps(Box2I const &other) const noexcept
Return true if any points in other are also in this.
Box2D & operator=(Box2D const &) noexcept=default
Standard assignment operator.
void flipLR(float xExtent)
Flip a bounding box about the y-axis given a parent box of extent (xExtent).
Box2D shiftedBy(Extent const &offset) const
Shift the position of the box by the given offset (returning a new object).
void clip(Box2I const &other) noexcept
Shrink this to ensure that other.contains(*this).
int getMaxY() const noexcept
bool isEmpty() const noexcept
Return true if the box contains no points.
Box2I & operator=(Box2I &&) noexcept=default
int getMaxX() const noexcept
Extent< int, 2 > Extent2I
A coordinate class intended to represent absolute positions.
double getMaxY() const noexcept
An integer coordinate rectangle.
int getMinX() const noexcept
void include(Point2D const &point) noexcept
Expand this to ensure that this->contains(point).
Extent< double, 2 > Extent2D
Point2D const getCenter() const noexcept
Return true if the box contains no points.
std::string toString() const
1-d interval accessors
Box2I expandedTo(Point const &other) const
Expand the box to ensure that contains(other) is true (returning a new object).
Box2D reflectedAboutY(Element y) const
Reflect the box about a horizontal line (returning a new object).
A floating-point coordinate rectangle geometry.
double getArea() const noexcept
1-d interval accessors
Box2D(Box2D &&) noexcept=default
std::size_t hash_value() const noexcept
Return a hash of this object.
void swap(Extent &other) noexcept
bool operator!=(Box2I const &other) const noexcept
Compare two boxes for equality.
static double const INVALID
Value used to specify undefined coordinate values.
A coordinate class intended to represent offsets and dimensions.
void grow(double buffer)
Increase the size of the box by the given buffer amount in all directions.
Box2D(Box2D const &) noexcept=default
Standard copy constructor.
Box2D reflectedAboutX(Element x) const
Reflect the box about a vertical line (returning a new object).
void flipTB(float yExtent)
Flip a bounding box about the x-axis given a parent box of extent (yExtent).
bool contains(Element x, Element y) const noexcept
Return true if the box contains no points.
static IntervalD fromMinMax(Element min, Element max)
Construct an interval from its lower and upper bounds.
Box2I(Interval const &x, Interval const &y)
Construct a box from a pair of intervals.
Relationship invert(Relationship r)
Given the relationship between two sets A and B (i.e.
int getMinY() const noexcept
static double const EPSILON
Value the maximum coordinate is multiplied by to increase it by the smallest possible amount.
std::vector< Point2I > getCorners() const
Get the corner points.
bool isDisjointFrom(Box2I const &other) const noexcept
Return true if there are no points in both this and other.