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];
48 : _minimum(corner), _dimensions(dimensions) {
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()
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;
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;
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));
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()));
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;
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];
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));
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()";
507 return os <<
"Box2I(Point2I" << box.
getMin() <<
", Extent2I" << box.
getDimensions() <<
")";
511 if (box.
isEmpty())
return os <<
"Box2D()";
512 return os <<
"Box2D(Point2D" << box.
getMin() <<
", Extent2D" << box.
getDimensions() <<
")";
bool operator==(Box2I const &other) const noexcept
Compare two boxes for equality.
std::vector< Point2D > getCorners() const
Get the corner points.
Extent2I const getDimensions() const noexcept
bool isDisjointFrom(Box2I const &other) const noexcept
Return true if there are no points in both this and other.
EdgeHandlingEnum
Enum used to indicate how to handle conversions from floating-point to integer intervals.
Point2I const getMax() const noexcept
Box2I reflectedAboutY(Element y) const
Reflect the box about a horizontal line (returning a new object).
Box2I expandedTo(Point const &other) const
Expand the box to ensure that contains(other) is true (returning a new object).
void flipLR(int xExtent)
Flip a bounding box about the y-axis given a parent box of extent (xExtent).
void shift(Extent< T, N > const &offset) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Shift the point by the given offset.
A floating-point coordinate rectangle geometry.
Point2D const getCenter() const noexcept
A coordinate class intended to represent absolute positions.
void include(Point2D const &point) noexcept
Expand this to ensure that this->contains(point).
bool isEmpty() const noexcept
Return true if the box contains no points.
Box2I reflectedAboutX(Element x) const
Reflect the box about a vertical line (returning a new object).
IntervalI clippedTo(IntervalI const &other) const noexcept
Shrink an interval to ensure that it is contained by other (returning a new)
Extent2D const getDimensions() const noexcept
1-d interval accessors
std::size_t hash_value() const noexcept
Return a hash of this object.
bool contains(Element point) const noexcept
Return true if the interval contains the point.
IntervalI expandedTo(Element other) const
Expand an interval to ensure that contains(other) is true (returning a new object).
Relationship invert(Relationship r)
Given the relationship between two sets A and B (i.e.
ItemVariant const * other
Point2D const getMin() const noexcept
void shift(Extent2D const &offset)
Shift the position of the box by the given offset.
std::vector< Point2I > getCorners() const
Get the corner points.
int getEndY() const noexcept
IntervalI dilatedBy(Element buffer) const
Increase the size of the interval by the given amount in both directions (returning a new object)...
Box2D shiftedBy(Extent const &offset) const
Shift the position of the box by the given offset (returning a new object).
Box2I shiftedBy(Extent const &offset) const
Shift the position of the box by the given offset (returning a new object).
bool isDisjointFrom(IntervalI const &other) const noexcept
Return true if there are no points in both this and other.
Interval getY() const
1-d interval accessors
void clip(Box2D const &other) noexcept
Shrink this to ensure that other.contains(*this).
Point< double, 2 > Point2D
static double const EPSILON
Value the maximum coordinate is multiplied by to increase it by the smallest possible amount...
Include all pixels that overlap the floating-point interval at all.
bool any(CoordinateExpr< N > const &expr) noexcept
Return true if any elements are true.
int getBeginY() const noexcept
void flipLR(float xExtent)
Flip a bounding box about the y-axis given a parent box of extent (xExtent).
Point2I const getMin() const noexcept
bool isEmpty() const noexcept
Return true if the box contains no points.
IntervalI shiftedBy(Element offset) const
Shift the position of the interval by the given offset (returning a new object).) ...
afw::table::PointKey< int > dimensions
bool all(CoordinateExpr< N > const &expr) noexcept
Return true if all elements are true.
A base class for image defects.
Reports when the result of an arithmetic operation is too large for the destination type...
CoordinateExpr< N > ge(Point< T, N > const &other) const noexcept
void grow(int buffer)
Increase the size of the box by the given buffer amount in all directions.
int getMaxY() const noexcept
bool contains(Point2D const &point) const noexcept
Return true if the box contains the point.
static double const INVALID
Value used to specify undefined coordinate values.
void grow(double buffer)
Increase the size of the box by the given buffer amount in all directions.
int getBeginX() const noexcept
static Box2D makeCenteredBox(Point2D const ¢er, Extent const &size) noexcept
Create a box centered on a particular point.
Box2D reflectedAboutY(Element y) const
Reflect the box about a horizontal line (returning a new object).
bool isDisjointFrom(Box2D const &other) const noexcept
Return true if there are no points in both this and other.
Box2I clippedTo(Box2I const &other) const noexcept
Shrink an interval to ensure that it is contained by other (returning a new object).
std::ostream & operator<<(std::ostream &os, lsst::geom::AffineTransform const &transform)
Reports errors in the logical structure of the program.
Box2D reflectedAboutX(Element x) const
Reflect the box about a vertical line (returning a new object).
A coordinate class intended to represent offsets and dimensions.
int getMaxX() const noexcept
Include only pixels that are wholly contained by the floating-point interval.
Box2D clippedTo(Box2D const &other) const
Shrink a box to ensure that it is contained by other (returning a new object).
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.
int getMinX() const noexcept
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Extent< int, 2 > Extent2I
Box2D dilatedBy(Extent const &buffer) const
Increase the size of the box by the given amount(s) on all sides (returning a new object)...
CoordinateExpr< N > lt(Point< T, N > const &other) const noexcept
void flipTB(float yExtent)
Flip a bounding box about the x-axis given a parent box of extent (yExtent).
int getEndX() const noexcept
void include(Point2I const &point)
Expand this to ensure that this->contains(point).
A 1-d integer coordinate range.
bool overlaps(Box2D const &other) const noexcept
Return true if any points in other are also in this.
void shift(Extent2I const &offset)
Shift the position of the box by the given offset.
bool overlaps(Box2I const &other) const noexcept
Return true if any points in other are also in this.
bool contains(Point2I const &point) const noexcept
Return true if the box contains the point.
void clip(Box2I const &other) noexcept
Shrink this to ensure that other.contains(*this).
Point2D const getCenter() const noexcept
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.
Reports invalid arguments.
Interval getX() const
1-d interval accessors
static Box2I makeCenteredBox(Point2D const ¢er, Extent const &size)
Create a box centered as closely as possible on a particular point.
Box2I() noexcept
Construct an empty box.
Interval getX() const
1-d interval accessors
Box2D() noexcept
Construct an empty box.
bool operator==(Box2D const &other) const noexcept
Compare two boxes for equality.
Extent< double, 2 > Extent2D
std::size_t hashCombine(std::size_t seed) noexcept
Combine hashes.
Box2I dilatedBy(Extent const &buffer) const
Increase the size of the box by the given amount(s) on all sides (returning a new object)...
Box2D expandedTo(Point const &other) const
Expand a box to ensure that contains(other) is true (returning a new object).
An integer coordinate rectangle.
Interval getY() const
1-d interval accessors
int getMinY() const noexcept
void flipTB(int yExtent)
Flip a bounding box about the x-axis given a parent box of extent (yExtent).
bool operator!=(Box2D const &other) const noexcept
Compare two boxes for equality.