LSSTApplications
19.0.0-14-gb0260a2+72aee35b6e,20.0.0+117106b506,20.0.0+30000fcb7e,20.0.0+3fc9f7ad86,20.0.0+477e9a1faa,20.0.0+76dc209b92,20.0.0+89c8776288,20.0.0+8e4ccb55f2,20.0.0+9457a788fe,20.0.0+95dc160249,20.0.0+99c1012587,20.0.0+b36b3b23ee,20.0.0+c93f448344,20.0.0+e5c4976b0d,20.0.0+eb0b68971d,20.0.0+ef667cdf05,20.0.0+f3c6aa4fa8,20.0.0+f45b7d88f4,20.0.0+f508b7937b,20.0.0-1-g10df615+9535e95112,20.0.0-1-g253301a+d3ed4cc2ab,20.0.0-1-g4d801e7+e2c0db9aca,20.0.0-1-g8a53f90+e0c9560612,20.0.0-1-gc96f8cb+d4044d9368,20.0.0-1-gd1c87d7+54d12611dd,20.0.0-1-gdb27ee5+f68f2de9db,20.0.0-11-gda4966f+6b932940cf,20.0.0-16-g6654009b+9733cd1e28,20.0.0-2-g25c5319+3eadce6b96,20.0.0-2-gec03fae+4d82fa78bb,20.0.0-25-g163437c+4e1a704cd6,20.0.0-3-gd2e950e+f45b7d88f4,20.0.0-4-g4a2362f+f45b7d88f4,20.0.0-4-gde602ef96+1a0e0454d8,20.0.0-4-ge48a6ca+4e088cdcdc,20.0.0-6-g01203fff+1e89328230,20.0.0-6-g9bcb941+a3f076f801,20.0.0-7-g3c4151b+8b45a8c617,20.0.0-7-gb92c176+129626b99a,w.2020.31
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.