LSSTApplications
19.0.0-10-g920eed2,19.0.0-11-g48a0200+2,19.0.0-18-gfc4e62b+17,19.0.0-2-g3b2f90d+2,19.0.0-2-gd671419+5,19.0.0-20-g5a5a17ab+15,19.0.0-21-g2644856+18,19.0.0-23-g84eeccb+6,19.0.0-24-g878c510+5,19.0.0-25-g6c8df7140,19.0.0-25-gb330496+5,19.0.0-3-g2b32d65+5,19.0.0-3-g8227491+16,19.0.0-3-g9c54d0d+16,19.0.0-3-gca68e65+12,19.0.0-3-gcfc5f51+5,19.0.0-3-ge110943+15,19.0.0-3-ge74d124,19.0.0-3-gfe04aa6+16,19.0.0-30-g9c3fd16+6,19.0.0-4-g06f5963+5,19.0.0-4-g3d16501+18,19.0.0-4-g4a9c019+5,19.0.0-4-g5a8b323,19.0.0-4-g66397f0+1,19.0.0-4-g8278b9b+1,19.0.0-4-g8557e14,19.0.0-4-g8964aba+17,19.0.0-4-ge404a01+16,19.0.0-5-g40f3a5a,19.0.0-5-g4db63b3,19.0.0-5-gfb03ce7+17,19.0.0-6-gbaebbfb+16,19.0.0-61-gec4c6e08+6,19.0.0-7-g039c0b5+16,19.0.0-7-gbea9075+4,19.0.0-7-gc567de5+17,19.0.0-70-g334bf3e+1,19.0.0-9-g463f923+16,b.20.0.x-g5487ab2134,v20.0.0.rc1
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.