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];
103 ndarray::View<boost::fusion::vector2<ndarray::index::Range, ndarray::index::Range> >
Box2I::getSlices()
109 return all(point.
ge(this->getMin())) &&
all(point.
le(this->getMax()));
125 _dimensions += buffer * 2;
137 _minimum[0] = xextent - (_minimum[0] + _dimensions[0]);
144 _minimum[1] = yextent - (_minimum[1] + _dimensions[1]);
155 for (
int n = 0; n < 2; ++n) {
156 if (point[n] < _minimum[n]) {
157 _minimum[n] = point[n];
158 }
else if (point[n] > maximum[n]) {
159 maximum[n] = point[n];
162 _dimensions =
Extent2I(1) + maximum - _minimum;
174 for (
int n = 0; n < 2; ++n) {
175 if (otherMin[n] < _minimum[n]) {
176 _minimum[n] = otherMin[n];
178 if (otherMax[n] > maximum[n]) {
179 maximum[n] = otherMax[n];
182 _dimensions =
Extent2I(1) + maximum - _minimum;
194 for (
int n = 0; n < 2; ++n) {
195 if (otherMin[n] > _minimum[n]) {
196 _minimum[n] = otherMin[n];
198 if (otherMax[n] < maximum[n]) {
199 maximum[n] = otherMax[n];
202 if (
any(maximum.
lt(_minimum))) {
206 _dimensions =
Extent2I(1) + maximum - _minimum;
210 return other._minimum == this->_minimum && other._dimensions == this->_dimensions;
214 return other._minimum != this->_minimum || other._dimensions != this->_dimensions;
233 : _minimum(minimum), _maximum(maximum) {
234 for (
int n = 0; n < 2; ++n) {
235 if (_minimum[n] == _maximum[n]) {
238 }
else if (_minimum[n] > _maximum[n]) {
250 : _minimum(corner), _maximum(corner + dimensions) {
251 for (
int n = 0; n < 2; ++n) {
252 if (_minimum[n] == _maximum[n]) {
255 }
else if (_minimum[n] > _maximum[n]) {
274 corner.
shift(-0.5 * size);
279 return all(point.
ge(this->getMin())) &&
all(point.
lt(this->getMax()));
296 if (
any(_minimum.
ge(_maximum))) *
this =
Box2D();
308 _minimum[0] += _maximum[0];
309 _maximum[0] = _minimum[0] - _maximum[0];
310 _minimum[0] -= _maximum[0];
312 _minimum[0] = xextent - _minimum[0];
313 _maximum[0] = xextent - _maximum[0];
320 _minimum[1] += _maximum[1];
321 _maximum[1] = _minimum[1] - _maximum[1];
322 _minimum[1] -= _maximum[1];
324 _minimum[1] = yextent - _minimum[1];
325 _maximum[1] = yextent - _maximum[1];
337 for (
int n = 0; n < 2; ++n) {
338 if (point[n] < _minimum[n]) {
339 _minimum[n] = point[n];
340 }
else if (point[n] >= _maximum[n]) {
341 _maximum[n] = point[n];
355 for (
int n = 0; n < 2; ++n) {
356 if (otherMin[n] < _minimum[n]) {
357 _minimum[n] = otherMin[n];
359 if (otherMax[n] > _maximum[n]) {
360 _maximum[n] = otherMax[n];
373 for (
int n = 0; n < 2; ++n) {
374 if (otherMin[n] > _minimum[n]) {
375 _minimum[n] = otherMin[n];
377 if (otherMax[n] < _maximum[n]) {
378 _maximum[n] = otherMax[n];
381 if (
any(_maximum.
le(_minimum))) {
389 (other._minimum == this->_minimum && other._maximum == this->_maximum);
394 (other._minimum != this->_minimum || other._maximum != this->_maximum);
407 if (box.
isEmpty())
return os <<
"Box2I()";
408 return os <<
"Box2I(Point2I" << box.
getMin() <<
", Extent2I" << box.
getDimensions() <<
")";
412 if (box.
isEmpty())
return os <<
"Box2D()";
413 return os <<
"Box2D(Point2D" << box.
getMin() <<
", Extent2D" << box.
getDimensions() <<
")";
std::vector< Point2D > getCorners() const
Get the corner points.
Box2I()
Construct an empty box.
Extent2I const getDimensions() const
void shift(Extent< T, N > const &offset)
Shift the point by the given offset.
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.
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.
void grow(int buffer)
Increase the size of the box by the given buffer amount in all directions.
static Box2D makeCenteredBox(Point2D const ¢er, Extent const &size)
Create a box centered on a particular 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.
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,...)
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.
static Box2I makeCenteredBox(Point2D const ¢er, Extent const &size)
Create a box centered as closely as possible on a particular point.
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.