31 : _minimum(minimum), _dimensions(maximum - minimum) {
32 for (
int n = 0; n < 2; ++n) {
33 if (_dimensions[n] < 0) {
35 _minimum[n] += _dimensions[n];
36 _dimensions[n] = -_dimensions[n];
47 : _minimum(corner), _dimensions(dimensions) {
48 for (
int n = 0; n < 2; ++n) {
49 if (_dimensions[n] == 0) {
52 }
else if (_dimensions[n] < 0) {
54 _minimum[n] += (_dimensions[n] + 1);
55 _dimensions[n] = -_dimensions[n];
64 "Box dimensions too large; integer overflow detected.");
79 switch (edgeHandling) {
81 for (
int n = 0; n < 2; ++n) {
82 _minimum[n] =
static_cast<int>(
std::floor(fpMin[n]));
83 _dimensions[n] =
static_cast<int>(
std::ceil(fpMax[n])) + 1 - _minimum[n];
87 for (
int n = 0; n < 2; ++n) {
88 _minimum[n] =
static_cast<int>(
std::ceil(fpMin[n]));
89 _dimensions[n] =
static_cast<int>(
std::floor(fpMax[n])) + 1 - _minimum[n];
107 ndarray::View<boost::fusion::vector2<ndarray::index::Range, ndarray::index::Range> >
Box2I::getSlices()
113 return all(point.ge(this->getMin())) &&
all(point.le(this->getMax()));
117 return other.isEmpty() ||
129 _dimensions += buffer * 2;
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;
214 return other._minimum == this->_minimum &&
other._dimensions == this->_dimensions;
218 return other._minimum != this->_minimum ||
other._dimensions != this->_dimensions;
237 : _minimum(
minimum), _maximum(maximum) {
238 for (
int n = 0; n < 2; ++n) {
239 if (_minimum[n] == _maximum[n]) {
242 }
else if (_minimum[n] > _maximum[n]) {
254 : _minimum(corner), _maximum(corner +
dimensions) {
255 for (
int n = 0; n < 2; ++n) {
256 if (_minimum[n] == _maximum[n]) {
259 }
else if (_minimum[n] > _maximum[n]) {
278 corner.
shift(-0.5 * size);
283 return all(point.ge(this->getMin())) &&
all(point.lt(this->getMax()));
287 return other.isEmpty() ||
300 if (
any(_minimum.
ge(_maximum))) *
this =
Box2D();
312 _minimum[0] += _maximum[0];
313 _maximum[0] = _minimum[0] - _maximum[0];
314 _minimum[0] -= _maximum[0];
316 _minimum[0] = xextent - _minimum[0];
317 _maximum[0] = xextent - _maximum[0];
324 _minimum[1] += _maximum[1];
325 _maximum[1] = _minimum[1] - _maximum[1];
326 _minimum[1] -= _maximum[1];
328 _minimum[1] = yextent - _minimum[1];
329 _maximum[1] = yextent - _maximum[1];
341 for (
int n = 0; n < 2; ++n) {
342 if (point[n] < _minimum[n]) {
343 _minimum[n] = point[n];
344 }
else if (point[n] >= _maximum[n]) {
345 _maximum[n] = point[n];
352 if (
other.isEmpty())
return;
359 for (
int n = 0; n < 2; ++n) {
360 if (otherMin[n] < _minimum[n]) {
361 _minimum[n] = otherMin[n];
363 if (otherMax[n] > _maximum[n]) {
364 _maximum[n] = otherMax[n];
371 if (
other.isEmpty()) {
377 for (
int n = 0; n < 2; ++n) {
378 if (otherMin[n] > _minimum[n]) {
379 _minimum[n] = otherMin[n];
381 if (otherMax[n] < _maximum[n]) {
382 _maximum[n] = otherMax[n];
385 if (
any(_maximum.le(_minimum))) {
393 (
other._minimum == this->_minimum &&
other._maximum == this->_maximum);
397 return !(
other.isEmpty() &&
other.isEmpty()) &&
398 (
other._minimum != this->_minimum ||
other._maximum != this->_maximum);
411 if (box.
isEmpty())
return os <<
"Box2I()";
412 return os <<
"Box2I(Point2I" << box.
getMin() <<
", Extent2I" << box.
getDimensions() <<
")";
416 if (box.
isEmpty())
return os <<
"Box2D()";
417 return os <<
"Box2D(Point2D" << box.
getMin() <<
", Extent2D" << box.
getDimensions() <<
")";
bool operator==(Box2I const &other) const noexcept
Compare two boxes for equality.
double getMinY() const noexcept
std::vector< Point2D > getCorners() const
Get the corner points.
Extent2I const getDimensions() const noexcept
afw::table::PointKey< int > dimensions
Point2I const getMax() const noexcept
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.
double getMinX() const noexcept
A coordinate class intended to represent absolute positions.
CoordinateExpr< N > le(Extent< T, N > const &other) const noexcept
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.
double getMaxX() const noexcept
Extent2D const getDimensions() const noexcept
Relationship invert(Relationship r)
Given the relationship between two sets A and B (i.e.
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
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...
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.
bool all(CoordinateExpr< N > const &expr) noexcept
Return true if all elements are true.
double getMaxY() const noexcept
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.
std::ostream & operator<<(std::ostream &os, lsst::geom::AffineTransform const &transform)
A coordinate class intended to represent offsets and dimensions.
int getMaxX() const noexcept
Point2D const getMax() const noexcept
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
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).
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).
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.
ItemVariant const * other
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.
Box2D() noexcept
Construct an empty box.
bool operator==(Box2D const &other) const noexcept
Compare two boxes for equality.
Extent< double, 2 > Extent2D
An integer coordinate rectangle.
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.