33 : _minimum(minimum), _dimensions(maximum - minimum) {
34 for (
int n = 0; n < 2; ++n) {
35 if (_dimensions[n] < 0) {
37 _minimum[n] += _dimensions[n];
38 _dimensions[n] = -_dimensions[n];
49 : _minimum(minimum), _dimensions(dimensions) {
50 for (
int n = 0; n < 2; ++n) {
51 if (_dimensions[n] == 0) {
54 }
else if (_dimensions[n] < 0) {
56 _minimum[n] += (_dimensions[n] + 1);
57 _dimensions[n] = -_dimensions[n];
66 "Box dimensions too large; integer overflow detected.");
81 switch (edgeHandling) {
83 for (
int n = 0; n < 2; ++n) {
84 _minimum[n] =
static_cast<int>(
std::floor(fpMin[n]));
85 _dimensions[n] =
static_cast<int>(
std::ceil(fpMax[n])) + 1 - _minimum[n];
89 for (
int n = 0; n < 2; ++n) {
90 _minimum[n] =
static_cast<int>(
std::ceil(fpMin[n]));
91 _dimensions[n] =
static_cast<int>(
std::floor(fpMax[n])) + 1 - _minimum[n];
97 ndarray::View<boost::fusion::vector2<ndarray::index::Range, ndarray::index::Range> >
Box2I::getSlices()
103 return all(point.
ge(this->getMin())) &&
all(point.
le(this->getMax()));
119 _dimensions += buffer * 2;
131 _minimum[0] = xextent - (_minimum[0] + _dimensions[0]);
138 _minimum[1] = yextent - (_minimum[1] + _dimensions[1]);
149 for (
int n = 0; n < 2; ++n) {
150 if (point[n] < _minimum[n]) {
151 _minimum[n] = point[n];
152 }
else if (point[n] > maximum[n]) {
153 maximum[n] = point[n];
156 _dimensions =
Extent2I(1) + maximum - _minimum;
168 for (
int n = 0; n < 2; ++n) {
169 if (otherMin[n] < _minimum[n]) {
170 _minimum[n] = otherMin[n];
172 if (otherMax[n] > maximum[n]) {
173 maximum[n] = otherMax[n];
176 _dimensions =
Extent2I(1) + maximum - _minimum;
188 for (
int n = 0; n < 2; ++n) {
189 if (otherMin[n] > _minimum[n]) {
190 _minimum[n] = otherMin[n];
192 if (otherMax[n] < maximum[n]) {
193 maximum[n] = otherMax[n];
196 if (
any(maximum.
lt(_minimum))) {
200 _dimensions =
Extent2I(1) + maximum - _minimum;
204 return other._minimum == this->_minimum && other._dimensions == this->_dimensions;
208 return other._minimum != this->_minimum || other._dimensions != this->_dimensions;
227 : _minimum(minimum), _maximum(maximum) {
228 for (
int n = 0; n < 2; ++n) {
229 if (_minimum[n] == _maximum[n]) {
232 }
else if (_minimum[n] > _maximum[n]) {
244 : _minimum(minimum), _maximum(minimum + dimensions) {
245 for (
int n = 0; n < 2; ++n) {
246 if (_minimum[n] == _maximum[n]) {
249 }
else if (_minimum[n] > _maximum[n]) {
267 return all(point.
ge(this->getMin())) &&
all(point.
lt(this->getMax()));
284 if (
any(_minimum.
ge(_maximum))) *
this =
Box2D();
296 _minimum[0] += _maximum[0];
297 _maximum[0] = _minimum[0] - _maximum[0];
298 _minimum[0] -= _maximum[0];
300 _minimum[0] = xextent - _minimum[0];
301 _maximum[0] = xextent - _maximum[0];
308 _minimum[1] += _maximum[1];
309 _maximum[1] = _minimum[1] - _maximum[1];
310 _minimum[1] -= _maximum[1];
312 _minimum[1] = yextent - _minimum[1];
313 _maximum[1] = yextent - _maximum[1];
325 for (
int n = 0; n < 2; ++n) {
326 if (point[n] < _minimum[n]) {
327 _minimum[n] = point[n];
328 }
else if (point[n] >= _maximum[n]) {
329 _maximum[n] = point[n];
343 for (
int n = 0; n < 2; ++n) {
344 if (otherMin[n] < _minimum[n]) {
345 _minimum[n] = otherMin[n];
347 if (otherMax[n] > _maximum[n]) {
348 _maximum[n] = otherMax[n];
361 for (
int n = 0; n < 2; ++n) {
362 if (otherMin[n] > _minimum[n]) {
363 _minimum[n] = otherMin[n];
365 if (otherMax[n] < _maximum[n]) {
366 _maximum[n] = otherMax[n];
369 if (
any(_maximum.
le(_minimum))) {
377 (other._minimum == this->_minimum && other._maximum == this->_maximum);
382 (other._minimum != this->_minimum || other._maximum != this->_maximum);
395 if (box.
isEmpty())
return os <<
"Box2I()";
396 return os <<
"Box2I(Point2I" << box.
getMin() <<
", Extent2I" << box.
getDimensions() <<
")";
400 if (box.
isEmpty())
return os <<
"Box2D()";
401 return os <<
"Box2D(Point2D" << box.
getMin() <<
", Extent2D" << box.
getDimensions() <<
")";
bool overlaps(Box2D const &other) const
Return true if any points in other are also in this.
void grow(double buffer)
Increase the size of the box by the given buffer amount in all directions.
Point2I const getMin() const
afw::table::PointKey< int > dimensions
bool isEmpty() const
Return true if the box contains no points.
bool all(CoordinateExpr< N > const &expr)
Return true if all elements are true.
void shift(Extent2I const &offset)
Shift the position of the box by the given offset.
CoordinateExpr< N > gt(Point< T, N > const &other) const
bool contains(Point2D const &point) const
Return true if the box contains the point.
Extent< double, 2 > Extent2D
std::ostream & operator<<(std::ostream &os, lsst::afw::geom::AffineTransform const &transform)
Box2I()
Construct an empty box.
static double const INVALID
Value used to specify undefined coordinate values.
A coordinate class intended to represent offsets and dimensions.
void include(Point2I const &point)
Expand this to ensure that this->contains(point).
bool operator!=(Box2D const &other) const
Compare two boxes for equality.
Extent< int, 2 > Extent2I
Relationship invert(Relationship r)
Given the relationship between two sets A and B (i.e.
bool isEmpty() const
Return true if the box contains no points.
A coordinate class intended to represent absolute positions.
An integer coordinate rectangle.
Extent2D const getDimensions() const
Point2I const getMax() const
void clip(Box2D const &other)
Shrink this to ensure that other.contains(*this).
CoordinateExpr< N > ge(Point< T, N > const &other) const
CoordinateExpr< N > le(Extent< T, N > const &other) const
bool any(CoordinateExpr< N > const &expr)
Return true if any elements are true.
bool overlaps(Box2I const &other) const
Return true if any points in other are also in this.
A base class for image defects.
Reports when the result of an arithmetic operation is too large for the destination type...
Point< double, 2 > Point2D
void flipTB(float yExtent)
Flip a bounding box about the x-axis given a parent box of extent (yExtent).
void include(Point2D const &point)
Expand this to ensure that this->contains(point).
bool operator==(Box2D const &other) const
Compare two boxes for equality.
bool operator==(Box2I const &other) const
Compare two boxes for equality.
static double const EPSILON
Value the maximum coordinate is multiplied by to increase it by the smallest possible amount...
bool contains(Point2I const &point) const
Return true if the box contains the point.
void flipLR(int xExtent)
Flip a bounding box about the y-axis given a parent box of extent (xExtent).
CoordinateExpr< N > le(Point< T, N > const &other) const
std::vector< Point2D > getCorners() const
Get the corner points.
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.
Box2D()
Construct an empty box.
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
void flipLR(float xExtent)
Flip a bounding box about the y-axis given a parent box of extent (xExtent).
std::vector< Point2I > getCorners() const
Get the corner points.
void grow(int buffer)
Increase the size of the box by the given buffer amount in all directions.
Extent2I const getDimensions() const
void flipTB(int yExtent)
Flip a bounding box about the x-axis given a parent box of extent (yExtent).
void shift(Extent2D const &offset)
Shift the position of the box by the given offset.
Reports invalid arguments.
ItemVariant const * other
bool operator!=(Box2I const &other) const
Compare two boxes for equality.
void clip(Box2I const &other)
Shrink this to ensure that other.contains(*this).
A floating-point coordinate rectangle geometry.
CoordinateExpr< N > lt(Point< T, N > const &other) const
Point2D const getMax() const
Point2D const getMin() const