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.");
80 switch (edgeHandling) {
82 for (
int n = 0; n < 2; ++n) {
83 _minimum[n] =
static_cast<int>(
std::floor(fpMin[n]));
84 _dimensions[n] =
static_cast<int>(
std::ceil(fpMax[n])) + 1 - _minimum[n];
88 for (
int n = 0; n < 2; ++n) {
89 _minimum[n] =
static_cast<int>(
std::ceil(fpMin[n]));
90 _dimensions[n] =
static_cast<int>(
std::floor(fpMax[n])) + 1 - _minimum[n];
108 ndarray::View<boost::fusion::vector2<ndarray::index::Range, ndarray::index::Range> >
Box2I::getSlices()
114 return all(point.ge(this->getMin())) &&
all(point.le(this->getMax()));
118 return other.isEmpty() ||
130 _dimensions += buffer * 2;
142 _minimum[0] = xextent - (_minimum[0] + _dimensions[0]);
149 _minimum[1] = yextent - (_minimum[1] + _dimensions[1]);
160 for (
int n = 0; n < 2; ++n) {
161 if (point[n] < _minimum[n]) {
162 _minimum[n] = point[n];
163 }
else if (point[n] > maximum[n]) {
164 maximum[n] = point[n];
167 _dimensions =
Extent2I(1) + maximum - _minimum;
179 for (
int n = 0; n < 2; ++n) {
180 if (otherMin[n] < _minimum[n]) {
181 _minimum[n] = otherMin[n];
183 if (otherMax[n] > maximum[n]) {
184 maximum[n] = otherMax[n];
187 _dimensions =
Extent2I(1) + maximum - _minimum;
192 if (
other.isEmpty()) {
199 for (
int n = 0; n < 2; ++n) {
200 if (otherMin[n] > _minimum[n]) {
201 _minimum[n] = otherMin[n];
203 if (otherMax[n] < maximum[n]) {
204 maximum[n] = otherMax[n];
207 if (
any(maximum.
lt(_minimum))) {
211 _dimensions =
Extent2I(1) + maximum - _minimum;
215 return other._minimum == this->_minimum &&
other._dimensions == this->_dimensions;
219 return other._minimum != this->_minimum ||
other._dimensions != this->_dimensions;
243 : _minimum(
minimum), _maximum(maximum) {
244 for (
int n = 0; n < 2; ++n) {
245 if (_minimum[n] == _maximum[n]) {
248 }
else if (_minimum[n] > _maximum[n]) {
260 : _minimum(corner), _maximum(corner +
dimensions) {
261 for (
int n = 0; n < 2; ++n) {
262 if (_minimum[n] == _maximum[n]) {
265 }
else if (_minimum[n] > _maximum[n]) {
284 corner.
shift(-0.5 * size);
289 return all(point.ge(this->getMin())) &&
all(point.lt(this->getMax()));
293 return other.isEmpty() ||
306 if (
any(_minimum.
ge(_maximum))) *
this =
Box2D();
318 _minimum[0] += _maximum[0];
319 _maximum[0] = _minimum[0] - _maximum[0];
320 _minimum[0] -= _maximum[0];
322 _minimum[0] = xextent - _minimum[0];
323 _maximum[0] = xextent - _maximum[0];
330 _minimum[1] += _maximum[1];
331 _maximum[1] = _minimum[1] - _maximum[1];
332 _minimum[1] -= _maximum[1];
334 _minimum[1] = yextent - _minimum[1];
335 _maximum[1] = yextent - _maximum[1];
347 for (
int n = 0; n < 2; ++n) {
348 if (point[n] < _minimum[n]) {
349 _minimum[n] = point[n];
350 }
else if (point[n] >= _maximum[n]) {
351 _maximum[n] = point[n];
358 if (
other.isEmpty())
return;
365 for (
int n = 0; n < 2; ++n) {
366 if (otherMin[n] < _minimum[n]) {
367 _minimum[n] = otherMin[n];
369 if (otherMax[n] > _maximum[n]) {
370 _maximum[n] = otherMax[n];
377 if (
other.isEmpty()) {
383 for (
int n = 0; n < 2; ++n) {
384 if (otherMin[n] > _minimum[n]) {
385 _minimum[n] = otherMin[n];
387 if (otherMax[n] < _maximum[n]) {
388 _maximum[n] = otherMax[n];
391 if (
any(_maximum.le(_minimum))) {
399 (
other._minimum == this->_minimum &&
other._maximum == this->_maximum);
403 return !(
other.isEmpty() &&
other.isEmpty()) &&
404 (
other._minimum != this->_minimum ||
other._maximum != this->_maximum);
427 if (box.
isEmpty())
return os <<
"Box2I()";
428 return os <<
"Box2I(Point2I" << box.
getMin() <<
", Extent2I" << box.
getDimensions() <<
")";
432 if (box.
isEmpty())
return os <<
"Box2D()";
433 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
std::size_t hash_value() const noexcept
Return a hash of this object.
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
std::size_t hash_value() const noexcept
Return a hash of this object.
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
std::size_t hashCombine(std::size_t seed) noexcept
Combine hashes.
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.