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(minimum), _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];
95 ndarray::View<boost::fusion::vector2<ndarray::index::Range, ndarray::index::Range> >
Box2I::getSlices()
101 return all(point.
ge(this->getMin())) &&
all(point.
le(this->getMax()));
117 _dimensions += buffer * 2;
129 _minimum[0] = xextent - (_minimum[0] + _dimensions[0]);
136 _minimum[1] = yextent - (_minimum[1] + _dimensions[1]);
147 for (
int n = 0; n < 2; ++n) {
148 if (point[n] < _minimum[n]) {
149 _minimum[n] = point[n];
150 }
else if (point[n] > maximum[n]) {
151 maximum[n] = point[n];
154 _dimensions =
Extent2I(1) + maximum - _minimum;
166 for (
int n = 0; n < 2; ++n) {
167 if (otherMin[n] < _minimum[n]) {
168 _minimum[n] = otherMin[n];
170 if (otherMax[n] > maximum[n]) {
171 maximum[n] = otherMax[n];
174 _dimensions =
Extent2I(1) + maximum - _minimum;
186 for (
int n = 0; n < 2; ++n) {
187 if (otherMin[n] > _minimum[n]) {
188 _minimum[n] = otherMin[n];
190 if (otherMax[n] < maximum[n]) {
191 maximum[n] = otherMax[n];
194 if (
any(maximum.
lt(_minimum))) {
198 _dimensions =
Extent2I(1) + maximum - _minimum;
202 return other._minimum == this->_minimum && other._dimensions == this->_dimensions;
206 return other._minimum != this->_minimum || other._dimensions != this->_dimensions;
225 : _minimum(minimum), _maximum(maximum) {
226 for (
int n = 0; n < 2; ++n) {
227 if (_minimum[n] == _maximum[n]) {
230 }
else if (_minimum[n] > _maximum[n]) {
242 : _minimum(minimum), _maximum(minimum + dimensions) {
243 for (
int n = 0; n < 2; ++n) {
244 if (_minimum[n] == _maximum[n]) {
247 }
else if (_minimum[n] > _maximum[n]) {
265 return all(point.
ge(this->getMin())) &&
all(point.
lt(this->getMax()));
282 if (
any(_minimum.
ge(_maximum))) *
this =
Box2D();
294 _minimum[0] += _maximum[0];
295 _maximum[0] = _minimum[0] - _maximum[0];
296 _minimum[0] -= _maximum[0];
298 _minimum[0] = xextent - _minimum[0];
299 _maximum[0] = xextent - _maximum[0];
306 _minimum[1] += _maximum[1];
307 _maximum[1] = _minimum[1] - _maximum[1];
308 _minimum[1] -= _maximum[1];
310 _minimum[1] = yextent - _minimum[1];
311 _maximum[1] = yextent - _maximum[1];
323 for (
int n = 0; n < 2; ++n) {
324 if (point[n] < _minimum[n]) {
325 _minimum[n] = point[n];
326 }
else if (point[n] >= _maximum[n]) {
327 _maximum[n] = point[n];
341 for (
int n = 0; n < 2; ++n) {
342 if (otherMin[n] < _minimum[n]) {
343 _minimum[n] = otherMin[n];
345 if (otherMax[n] > _maximum[n]) {
346 _maximum[n] = otherMax[n];
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];
367 if (
any(_maximum.
le(_minimum))) {
375 (other._minimum == this->_minimum && other._maximum == this->_maximum);
380 (other._minimum != this->_minimum || other._maximum != this->_maximum);
393 if (box.
isEmpty())
return os <<
"Box2I()";
394 return os <<
"Box2I(Point2I" << box.
getMin() <<
", Extent2I" << box.
getDimensions() <<
")";
398 if (box.
isEmpty())
return os <<
"Box2D()";
399 return os <<
"Box2D(Point2D" << box.
getMin() <<
", Extent2D" << box.
getDimensions() <<
")";
std::vector< Point2D > getCorners() const
Get the corner points.
Box2I()
Construct an empty box.
afw::table::PointKey< int > dimensions
Extent2I const getDimensions() const
void flipLR(int xExtent)
Flip a bounding box about the y-axis given a parent box of extent (xExtent).
CoordinateExpr< N > gt(Point< T, N > const &other) const
bool isEmpty() const
Return true if the box contains no points.
void clip(Box2D const &other)
Shrink this to ensure that other.contains(*this).
A floating-point coordinate rectangle geometry.
Point2I const getMin() const
A coordinate class intended to represent absolute positions.
Box2D()
Construct an empty box.
Extent2D const getDimensions() const
Point2D const getMin() const
bool operator!=(Box2D const &other) const
Compare two boxes for equality.
Relationship invert(Relationship r)
Given the relationship between two sets A and B (i.e.
bool overlaps(Box2D const &other) const
Return true if any points in other are also in this.
void shift(Extent2D const &offset)
Shift the position of the box by the given offset.
std::vector< Point2I > getCorners() const
Get the corner points.
Point2I const getMax() const
Point< double, 2 > Point2D
static double const EPSILON
Value the maximum coordinate is multiplied by to increase it by the smallest possible amount...
bool contains(Point2D const &point) const
Return true if the box contains the point.
void flipLR(float xExtent)
Flip a bounding box about the y-axis given a parent box of extent (xExtent).
CoordinateExpr< N > le(Extent< T, N > const &other) const
bool all(CoordinateExpr< N > const &expr)
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...
void grow(int buffer)
Increase the size of the box by the given buffer amount in all directions.
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.
Point2D const getMax() const
std::ostream & operator<<(std::ostream &os, lsst::geom::AffineTransform const &transform)
A coordinate class intended to represent offsets and dimensions.
CoordinateExpr< N > ge(Point< T, N > const &other) const
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Extent< int, 2 > Extent2I
bool contains(Point2I const &point) const
Return true if the box contains the point.
bool isEmpty() const
Return true if the box contains no points.
void flipTB(float yExtent)
Flip a bounding box about the x-axis given a parent box of extent (yExtent).
void include(Point2I const &point)
Expand this to ensure that this->contains(point).
bool operator==(Box2D const &other) const
Compare two boxes for equality.
CoordinateExpr< N > le(Point< T, N > const &other) const
void shift(Extent2I const &offset)
Shift the position of the box by the given offset.
bool overlaps(Box2I const &other) const
Return true if any points in other are also in 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
Extent< double, 2 > Extent2D
void include(Point2D const &point)
Expand this to ensure that this->contains(point).
bool operator==(Box2I const &other) const
Compare two boxes for equality.
void clip(Box2I const &other)
Shrink this to ensure that other.contains(*this).
bool operator!=(Box2I const &other) const
Compare two boxes for equality.
CoordinateExpr< N > lt(Point< T, N > const &other) const
An integer coordinate rectangle.
void flipTB(int yExtent)
Flip a bounding box about the x-axis given a parent box of extent (yExtent).
bool any(CoordinateExpr< N > const &expr)
Return true if any elements are true.