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];
112 ndarray::View<boost::fusion::vector2<ndarray::index::Range, ndarray::index::Range> >
Box2I::getSlices()
118 return all(point.ge(this->getMin())) &&
all(point.le(this->getMax()));
122 return other.isEmpty() ||
134 _dimensions += buffer * 2;
146 _minimum[0] = xextent - (_minimum[0] + _dimensions[0]);
153 _minimum[1] = yextent - (_minimum[1] + _dimensions[1]);
164 for (
int n = 0; n < 2; ++n) {
165 if (point[n] < _minimum[n]) {
166 _minimum[n] = point[n];
167 }
else if (point[n] > maximum[n]) {
168 maximum[n] = point[n];
171 _dimensions =
Extent2I(1) + maximum - _minimum;
183 for (
int n = 0; n < 2; ++n) {
184 if (otherMin[n] < _minimum[n]) {
185 _minimum[n] = otherMin[n];
187 if (otherMax[n] > maximum[n]) {
188 maximum[n] = otherMax[n];
191 _dimensions =
Extent2I(1) + maximum - _minimum;
196 if (
other.isEmpty()) {
203 for (
int n = 0; n < 2; ++n) {
204 if (otherMin[n] > _minimum[n]) {
205 _minimum[n] = otherMin[n];
207 if (otherMax[n] < maximum[n]) {
208 maximum[n] = otherMax[n];
211 if (
any(maximum.
lt(_minimum))) {
215 _dimensions =
Extent2I(1) + maximum - _minimum;
219 return other._minimum == this->_minimum &&
other._dimensions == this->_dimensions;
223 return other._minimum != this->_minimum ||
other._dimensions != this->_dimensions;
247 : _minimum(
minimum), _maximum(maximum) {
248 for (
int n = 0; n < 2; ++n) {
249 if (_minimum[n] == _maximum[n]) {
252 }
else if (_minimum[n] > _maximum[n]) {
264 : _minimum(corner), _maximum(corner +
dimensions) {
265 for (
int n = 0; n < 2; ++n) {
266 if (_minimum[n] == _maximum[n]) {
269 }
else if (_minimum[n] > _maximum[n]) {
288 corner.
shift(-0.5 * size);
293 return all(point.ge(this->getMin())) &&
all(point.lt(this->getMax()));
297 return other.isEmpty() ||
310 if (
any(_minimum.
ge(_maximum))) *
this =
Box2D();
322 _minimum[0] += _maximum[0];
323 _maximum[0] = _minimum[0] - _maximum[0];
324 _minimum[0] -= _maximum[0];
326 _minimum[0] = xextent - _minimum[0];
327 _maximum[0] = xextent - _maximum[0];
334 _minimum[1] += _maximum[1];
335 _maximum[1] = _minimum[1] - _maximum[1];
336 _minimum[1] -= _maximum[1];
338 _minimum[1] = yextent - _minimum[1];
339 _maximum[1] = yextent - _maximum[1];
351 for (
int n = 0; n < 2; ++n) {
352 if (point[n] < _minimum[n]) {
353 _minimum[n] = point[n];
354 }
else if (point[n] >= _maximum[n]) {
355 _maximum[n] = point[n];
362 if (
other.isEmpty())
return;
369 for (
int n = 0; n < 2; ++n) {
370 if (otherMin[n] < _minimum[n]) {
371 _minimum[n] = otherMin[n];
373 if (otherMax[n] > _maximum[n]) {
374 _maximum[n] = otherMax[n];
381 if (
other.isEmpty()) {
387 for (
int n = 0; n < 2; ++n) {
388 if (otherMin[n] > _minimum[n]) {
389 _minimum[n] = otherMin[n];
391 if (otherMax[n] < _maximum[n]) {
392 _maximum[n] = otherMax[n];
395 if (
any(_maximum.le(_minimum))) {
403 (
other._minimum == this->_minimum &&
other._maximum == this->_maximum);
407 return !(
other.isEmpty() &&
other.isEmpty()) &&
408 (
other._minimum != this->_minimum ||
other._maximum != this->_maximum);
431 if (box.
isEmpty())
return os <<
"Box2I()";
432 return os <<
"Box2I(Point2I" << box.
getMin() <<
", Extent2I" << box.
getDimensions() <<
")";
436 if (box.
isEmpty())
return os <<
"Box2D()";
437 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.
Point2D const getCenter() const noexcept
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).
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.
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.