LSSTApplications
21.0.0+1b62c9342b,21.0.0+4a36882ba2,21.0.0-1-ga51b5d4+2c88556dba,21.0.0-17-gf9a0284+69dd6c2060,21.0.0-2-g103fe59+d751821c91,21.0.0-2-g1367e85+ad4ce71c09,21.0.0-2-g2909d54+4a36882ba2,21.0.0-2-g45278ab+1b62c9342b,21.0.0-2-g4bc9b9f+56aff0fea6,21.0.0-2-g5242d73+ad4ce71c09,21.0.0-2-g54e2caa+dde81d9b0d,21.0.0-2-g66bcc37+905c13b855,21.0.0-2-g7f82c8f+ae0b31d2cf,21.0.0-2-g8dde007+5461f6ec49,21.0.0-2-g8f08a60+05ed0ab9e4,21.0.0-2-g973f35b+b1744c1cf5,21.0.0-2-ga326454+ae0b31d2cf,21.0.0-2-ga63a54e+c659dddc9d,21.0.0-2-ga885a99+4aa8b35973,21.0.0-2-gc738bc1+96c5b647eb,21.0.0-2-gde069b7+d0bdec52a8,21.0.0-2-ge17e5af+ad4ce71c09,21.0.0-2-ge712728+f9003e3bc5,21.0.0-2-gecfae73+e945072e23,21.0.0-2-gfc62afb+ad4ce71c09,21.0.0-21-g006371a9+8d72e8ff79,21.0.0-3-g4c5b185+b08abf4bf6,21.0.0-3-g5051ac2+1b62c9342b,21.0.0-3-g6d51c4a+905c13b855,21.0.0-3-gaa929c8+2605bebd58,21.0.0-3-gd222c45+21ef063859,21.0.0-3-gd5de2f2+905c13b855,21.0.0-4-g8a80011+3e4520b944,21.0.0-5-gb7080ec+f575c71e2b,21.0.0-5-gcff38f6+b82b996a2d,21.0.0-6-gd3283ba+2605bebd58,21.0.0-8-g19111d86+0648bf24f8,21.0.0-8-gd9c33f4a0+ec3713772a,w.2021.03
LSSTDataManagementBasePackage
|
Go to the documentation of this file.
32 : _minimum(minimum), _dimensions(maximum - minimum) {
33 for (
int n = 0; n < 2; ++n) {
34 if (_dimensions[n] < 0) {
36 _minimum[n] += _dimensions[n];
37 _dimensions[n] = -_dimensions[n];
49 for (
int n = 0; n < 2; ++n) {
50 if (_dimensions[n] == 0) {
53 }
else if (_dimensions[n] < 0) {
55 _minimum[n] += (_dimensions[n] + 1);
56 _dimensions[n] = -_dimensions[n];
65 "Box dimensions too large; integer overflow detected.");
109 ndarray::View<boost::fusion::vector2<ndarray::index::Range, ndarray::index::Range> >
Box2I::getSlices()
115 return getX().contains(point.getX()) && getY().contains(point.getY());
119 return getX().contains(
other.getX()) && getY().contains(
other.getY());
123 return !isDisjointFrom(
other);
127 return getX().isDisjointFrom(
other.getX()) || getY().isDisjointFrom(
other.getY());
141 _minimum[0] = xextent - (_minimum[0] + _dimensions[0]);
148 _minimum[1] = yextent - (_minimum[1] + _dimensions[1]);
159 for (
int n = 0; n < 2; ++n) {
160 if (point[n] < _minimum[n]) {
161 _minimum[n] = point[n];
162 }
else if (point[n] > maximum[n]) {
163 maximum[n] = point[n];
166 _dimensions =
Extent2I(1) + maximum - _minimum;
170 if (
other.isEmpty())
return;
178 for (
int n = 0; n < 2; ++n) {
179 if (otherMin[n] < _minimum[n]) {
180 _minimum[n] = otherMin[n];
182 if (otherMax[n] > maximum[n]) {
183 maximum[n] = otherMax[n];
186 _dimensions =
Extent2I(1) + maximum - _minimum;
190 if (isEmpty())
return;
191 if (
other.isEmpty()) {
198 for (
int n = 0; n < 2; ++n) {
199 if (otherMin[n] > _minimum[n]) {
200 _minimum[n] = otherMin[n];
202 if (otherMax[n] < maximum[n]) {
203 maximum[n] = otherMax[n];
206 if (
any(maximum.lt(_minimum))) {
210 _dimensions =
Extent2I(1) + maximum - _minimum;
230 getY().reflectedAbout(
y));
245 getY().clippedTo(
other.getY()));
249 return other._minimum == this->_minimum &&
other._dimensions == this->_dimensions;
253 return other._minimum != this->_minimum ||
other._dimensions != this->_dimensions;
277 : _minimum(minimum), _maximum(maximum) {
278 for (
int n = 0; n < 2; ++n) {
279 if (_minimum[n] == _maximum[n]) {
282 }
else if (_minimum[n] > _maximum[n]) {
294 : _minimum(corner), _maximum(corner +
dimensions) {
295 for (
int n = 0; n < 2; ++n) {
296 if (_minimum[n] == _maximum[n]) {
299 }
else if (_minimum[n] > _maximum[n]) {
318 corner.shift(-0.5 * size);
325 return all(point.ge(this->getMin())) &&
all(point.lt(this->getMax()));
335 return !(
other.isEmpty() || this->isEmpty() ||
any(
other.getMax().le(this->getMin())) ||
336 any(
other.getMin().ge(this->getMax())));
340 return !overlaps(
other);
347 if (
any(_minimum.ge(_maximum))) *
this =
Box2D();
359 _minimum[0] += _maximum[0];
360 _maximum[0] = _minimum[0] - _maximum[0];
361 _minimum[0] -= _maximum[0];
363 _minimum[0] = xextent - _minimum[0];
364 _maximum[0] = xextent - _maximum[0];
371 _minimum[1] += _maximum[1];
372 _maximum[1] = _minimum[1] - _maximum[1];
373 _minimum[1] -= _maximum[1];
375 _minimum[1] = yextent - _minimum[1];
376 _maximum[1] = yextent - _maximum[1];
388 for (
int n = 0; n < 2; ++n) {
389 if (point[n] < _minimum[n]) {
390 _minimum[n] = point[n];
391 }
else if (point[n] >= _maximum[n]) {
392 _maximum[n] = point[n];
399 if (
other.isEmpty())
return;
400 if (this->isEmpty()) {
406 for (
int n = 0; n < 2; ++n) {
407 if (otherMin[n] < _minimum[n]) {
408 _minimum[n] = otherMin[n];
410 if (otherMax[n] > _maximum[n]) {
411 _maximum[n] = otherMax[n];
417 if (isEmpty())
return;
418 if (
other.isEmpty()) {
424 for (
int n = 0; n < 2; ++n) {
425 if (otherMin[n] > _minimum[n]) {
426 _minimum[n] = otherMin[n];
428 if (otherMax[n] < _maximum[n]) {
429 _maximum[n] = otherMax[n];
432 if (
any(_maximum.le(_minimum))) {
455 getY().reflectedAbout(
y));
477 return (
other.isEmpty() && this->isEmpty()) ||
478 (
other._minimum == this->_minimum &&
other._maximum == this->_maximum);
482 return !(
other.isEmpty() &&
other.isEmpty()) &&
483 (
other._minimum != this->_minimum ||
other._maximum != this->_maximum);
506 if (box.
isEmpty())
return os <<
"Box2I()";
511 if (box.
isEmpty())
return os <<
"Box2D()";
void flipTB(int yExtent)
Flip a bounding box about the x-axis given a parent box of extent (yExtent).
Point2D const getMin() const 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.
void flipLR(int xExtent)
Flip a bounding box about the y-axis given a parent box of extent (xExtent).
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).
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.
Interval getX() const
1-d interval accessors
Extent2I const getDimensions() const noexcept
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.
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
Point< double, 2 > Point2D
bool isEmpty() 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
EdgeHandlingEnum
Enum used to indicate how to handle conversions from floating-point to integer intervals.
Box2D dilatedBy(Extent const &buffer) const
Increase the size of the box by the given amount(s) on all sides (returning a new object).
bool all(CoordinateExpr< N > const &expr) noexcept
Return true if all elements are true.
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
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.
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).
@ EXPAND
Include all pixels that overlap the floating-point interval at all.
Box2I() noexcept
Construct an empty box.
double getMinX() const noexcept
Reports when the result of an arithmetic operation is too large for the destination type.
ItemVariant const * other
int getBeginX() const noexcept
bool contains(Point2I const &point) const noexcept
Return true if the box contains the point.
Reports errors in the logical structure of the program.
Point2D const getMax() const noexcept
bool any(CoordinateExpr< N > const &expr) noexcept
Return true if any elements are true.
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).
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)
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Point2D const getCenter() const noexcept
1-d interval accessors
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.
bool contains(Element point) const
Return true if the interval contains the point.
int getEndX() const noexcept
std::size_t hashCombine(std::size_t seed) noexcept
Combine hashes.
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.
void flipLR(float xExtent)
Flip a bounding box about the y-axis given a parent box of extent (xExtent).
Reports invalid arguments.
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.
int getMaxX() const noexcept
Extent< int, 2 > Extent2I
@ SHRINK
Include only pixels that are wholly contained by the floating-point interval.
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).
Point2D const getCenter() const noexcept
Return true if the box contains no points.
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.
std::size_t hash_value() const noexcept
Return a hash of this object.
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 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).
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.