LSSTApplications  19.0.0+10,19.0.0+80,19.0.0-1-g20d9b18+31,19.0.0-1-g49a97f9+4,19.0.0-1-g8c57eb9+31,19.0.0-1-g9a028c0+13,19.0.0-1-ga72da6b+3,19.0.0-1-gb77924a+15,19.0.0-1-gbfe0924+66,19.0.0-1-gc3516c3,19.0.0-1-gefe1d0d+49,19.0.0-1-gf8cb8b4+3,19.0.0-14-g7511ce4+6,19.0.0-16-g3dc1a33c+6,19.0.0-17-g59f0e8a+4,19.0.0-17-g9c22e3c+9,19.0.0-18-g35bb99870+2,19.0.0-19-g2772d4a+9,19.0.0-2-g260436e+53,19.0.0-2-g31cdcee,19.0.0-2-g9675b69+3,19.0.0-2-gaa2795f,19.0.0-2-gbcc4de1,19.0.0-2-gd6f004e+6,19.0.0-2-gde8e5e3+5,19.0.0-2-gff6972b+15,19.0.0-21-ge306cd8,19.0.0-21-gf122e69+2,19.0.0-3-g2d43a51+2,19.0.0-3-gf3b1435+6,19.0.0-4-g56feb96,19.0.0-4-gac56cce+17,19.0.0-49-gce872c1+1,19.0.0-5-g66946eb+6,19.0.0-5-gd8897ba+6,19.0.0-51-gfc4a647e,19.0.0-7-g686a884+5,19.0.0-7-g886f805+5,19.0.0-8-g305ff64,w.2020.17
LSSTDataManagementBasePackage
Box.cc
Go to the documentation of this file.
1 /*
2  * Developed for the LSST Data Management System.
3  * This product includes software developed by the LSST Project
4  * (https://www.lsst.org).
5  * See the COPYRIGHT file at the top-level directory of this distribution
6  * for details of code ownership.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
22 #include <cmath>
23 #include <limits>
24 
25 #include "lsst/utils/hashCombine.h"
26 #include "lsst/geom/Box.h"
27 
28 namespace lsst {
29 namespace geom {
30 
31 Box2I::Box2I(Point2I const& minimum, Point2I const& maximum, bool invert)
32  : _minimum(minimum), _dimensions(maximum - minimum) {
33  for (int n = 0; n < 2; ++n) {
34  if (_dimensions[n] < 0) {
35  if (invert) {
36  _minimum[n] += _dimensions[n];
37  _dimensions[n] = -_dimensions[n];
38  } else {
39  *this = Box2I();
40  return;
41  }
42  }
43  }
44  _dimensions += Extent2I(1);
45 }
46 
47 Box2I::Box2I(Point2I const& corner, Extent2I const& dimensions, bool invert)
48  : _minimum(corner), _dimensions(dimensions) {
49  for (int n = 0; n < 2; ++n) {
50  if (_dimensions[n] == 0) {
51  *this = Box2I();
52  return;
53  } else if (_dimensions[n] < 0) {
54  if (invert) {
55  _minimum[n] += (_dimensions[n] + 1);
56  _dimensions[n] = -_dimensions[n];
57  } else {
58  *this = Box2I();
59  return;
60  }
61  }
62  }
63  if (!isEmpty() && any(getMin().gt(getMax()))) {
65  "Box dimensions too large; integer overflow detected.");
66  }
67 }
68 
69 namespace {
70 
71 // Translate a Box2I enum value to the corresponding IntervalI one. Box2I
72 // can't just use the IntervalI one because Box2I's is for historical reasons
73 // an old-style enum and IntervalI's is a class enum, and we don't want to
74 // break any Box-dependent code right now.
75 IntervalI::EdgeHandlingEnum translateEdgeHandling(Box2I::EdgeHandlingEnum input) {
76  switch (input) {
77  case Box2I::EXPAND:
79  case Box2I::SHRINK:
81  default:
82  throw pex::exceptions::LogicError("Invalid enum value.");
83  }
84 }
85 
86 }
87 
88 Box2I::Box2I(Box2D const& other, EdgeHandlingEnum edgeHandling) :
89  Box2I(IntervalI(other.getX(), translateEdgeHandling(edgeHandling)),
90  IntervalI(other.getY(), translateEdgeHandling(edgeHandling)))
91 {}
92 
93 Point2D const Box2I::getCenter() const noexcept {
94  return Box2D(*this).getCenter();
95 }
96 
97 Box2I Box2I::makeCenteredBox(Point2D const& center, Box2I::Extent const& size) {
98  if (!std::isfinite(center[0]) || !std::isfinite(center[1])) {
99  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "Cannot make Box2I with non-finite center");
100  }
101 
102  lsst::geom::Point2D corner(center);
103  corner.shift(-0.5 * lsst::geom::Extent2D(size));
104  // compensate for Box2I's coordinate conventions (where max = min + size - 1)
105  corner.shift(lsst::geom::Extent2D(0.5, 0.5));
106  return lsst::geom::Box2I(lsst::geom::Point2I(corner), size, false);
107 }
108 
109 ndarray::View<boost::fusion::vector2<ndarray::index::Range, ndarray::index::Range> > Box2I::getSlices()
110  const {
111  return ndarray::view(getBeginY(), getEndY())(getBeginX(), getEndX());
112 }
113 
114 bool Box2I::contains(Point2I const& point) const noexcept {
115  return getX().contains(point.getX()) && getY().contains(point.getY());
116 }
117 
118 bool Box2I::contains(Box2I const& other) const noexcept {
119  return getX().contains(other.getX()) && getY().contains(other.getY());
120 }
121 
122 bool Box2I::overlaps(Box2I const& other) const noexcept {
123  return !isDisjointFrom(other);
124 }
125 
126 bool Box2I::isDisjointFrom(Box2I const& other) const noexcept {
127  return getX().isDisjointFrom(other.getX()) || getY().isDisjointFrom(other.getY());
128 }
129 
130 void Box2I::grow(Extent2I const& buffer) {
131  *this = dilatedBy(buffer);
132 }
133 
134 void Box2I::shift(Extent2I const& offset) {
135  *this = shiftedBy(offset);
136 }
137 
138 void Box2I::flipLR(int xextent) {
139  if (isEmpty()) return; // should we throw an exception here instead of a no-op?
140  // Apply flip about y-axis assumine parent coordinate system
141  _minimum[0] = xextent - (_minimum[0] + _dimensions[0]);
142  // _dimensions should remain unchanged
143 }
144 
145 void Box2I::flipTB(int yextent) {
146  if (isEmpty()) return; // should we throw an exception here instead of a no-op?
147  // Apply flip about y-axis assumine parent coordinate system
148  _minimum[1] = yextent - (_minimum[1] + _dimensions[1]);
149  // _dimensions should remain unchanged
150 }
151 
152 void Box2I::include(Point2I const& point) {
153  if (isEmpty()) {
154  _minimum = point;
155  _dimensions = Extent2I(1);
156  return;
157  }
158  Point2I maximum(getMax());
159  for (int n = 0; n < 2; ++n) {
160  if (point[n] < _minimum[n]) {
161  _minimum[n] = point[n];
162  } else if (point[n] > maximum[n]) {
163  maximum[n] = point[n];
164  }
165  }
166  _dimensions = Extent2I(1) + maximum - _minimum;
167 }
168 
169 void Box2I::include(Box2I const& other) {
170  if (other.isEmpty()) return;
171  if (this->isEmpty()) {
172  *this = other;
173  return;
174  }
175  Point2I maximum(getMax());
176  Point2I const& otherMin = other.getMin();
177  Point2I const otherMax = other.getMax();
178  for (int n = 0; n < 2; ++n) {
179  if (otherMin[n] < _minimum[n]) {
180  _minimum[n] = otherMin[n];
181  }
182  if (otherMax[n] > maximum[n]) {
183  maximum[n] = otherMax[n];
184  }
185  }
186  _dimensions = Extent2I(1) + maximum - _minimum;
187 }
188 
189 void Box2I::clip(Box2I const& other) noexcept {
190  if (isEmpty()) return;
191  if (other.isEmpty()) {
192  *this = Box2I();
193  return;
194  }
195  Point2I maximum(getMax());
196  Point2I const& otherMin = other.getMin();
197  Point2I const otherMax = other.getMax();
198  for (int n = 0; n < 2; ++n) {
199  if (otherMin[n] > _minimum[n]) {
200  _minimum[n] = otherMin[n];
201  }
202  if (otherMax[n] < maximum[n]) {
203  maximum[n] = otherMax[n];
204  }
205  }
206  if (any(maximum.lt(_minimum))) {
207  *this = Box2I();
208  return;
209  }
210  _dimensions = Extent2I(1) + maximum - _minimum;
211 }
212 
213 Box2I Box2I::dilatedBy(Extent const& buffer) const {
214  return Box2I(getX().dilatedBy(buffer.getX()),
215  getY().dilatedBy(buffer.getY()));
216 }
217 
218 Box2I Box2I::shiftedBy(Extent const& offset) const {
219  return Box2I(getX().shiftedBy(offset.getX()),
220  getY().shiftedBy(offset.getY()));
221 }
222 
224  return Box2I(getX().reflectedAbout(x),
225  getY());
226 }
227 
229  return Box2I(getX(),
230  getY().reflectedAbout(y));
231 }
232 
234  return Box2I(getX().expandedTo(other.getX()),
235  getY().expandedTo(other.getY()));
236 }
237 
239  return Box2I(getX().expandedTo(other.getX()),
240  getY().expandedTo(other.getY()));
241 }
242 
243 Box2I Box2I::clippedTo(Box2I const& other) const noexcept {
244  return Box2I(getX().clippedTo(other.getX()),
245  getY().clippedTo(other.getY()));
246 }
247 
248 bool Box2I::operator==(Box2I const& other) const noexcept {
249  return other._minimum == this->_minimum && other._dimensions == this->_dimensions;
250 }
251 
252 bool Box2I::operator!=(Box2I const& other) const noexcept {
253  return other._minimum != this->_minimum || other._dimensions != this->_dimensions;
254 }
255 
256 std::size_t Box2I::hash_value() const noexcept {
257  // Completely arbitrary seed
258  return utils::hashCombine(17, _minimum, _dimensions);
259 }
260 
262  std::vector<Point2I> retVec;
263  retVec.push_back(getMin());
264  retVec.push_back(Point2I(getMaxX(), getMinY()));
265  retVec.push_back(getMax());
266  retVec.push_back(Point2I(getMinX(), getMaxY()));
267  return retVec;
268 }
269 
271 
273 
274 Box2D::Box2D() noexcept : _minimum(INVALID), _maximum(INVALID) {}
275 
276 Box2D::Box2D(Point2D const& minimum, Point2D const& maximum, bool invert) noexcept
277  : _minimum(minimum), _maximum(maximum) {
278  for (int n = 0; n < 2; ++n) {
279  if (_minimum[n] == _maximum[n]) {
280  *this = Box2D();
281  return;
282  } else if (_minimum[n] > _maximum[n]) {
283  if (invert) {
284  std::swap(_minimum[n], _maximum[n]);
285  } else {
286  *this = Box2D();
287  return;
288  }
289  }
290  }
291 }
292 
293 Box2D::Box2D(Point2D const& corner, Extent2D const& dimensions, bool invert) noexcept
294  : _minimum(corner), _maximum(corner + dimensions) {
295  for (int n = 0; n < 2; ++n) {
296  if (_minimum[n] == _maximum[n]) {
297  *this = Box2D();
298  return;
299  } else if (_minimum[n] > _maximum[n]) {
300  if (invert) {
301  std::swap(_minimum[n], _maximum[n]);
302  } else {
303  *this = Box2D();
304  return;
305  }
306  }
307  }
308 }
309 
310 Box2D::Box2D(Box2I const& other) noexcept
311  : _minimum(Point2D(other.getMin()) - Extent2D(0.5)),
312  _maximum(Point2D(other.getMax()) + Extent2D(0.5)) {
313  if (other.isEmpty()) *this = Box2D();
314 }
315 
316 Box2D Box2D::makeCenteredBox(Point2D const& center, Box2D::Extent const& size) noexcept {
317  lsst::geom::Point2D corner(center);
318  corner.shift(-0.5 * size);
319  return lsst::geom::Box2D(corner, size, false);
320 }
321 
322 bool Box2D::contains(Point2D const& point) const noexcept {
323  // Can't delegate to IntervalD here because IntervalID is closed while
324  // Box2D is half-open.
325  return all(point.ge(this->getMin())) && all(point.lt(this->getMax()));
326 }
327 
328 bool Box2D::contains(Box2D const& other) const {
329  return getX().contains(other.getX()) && getY().contains(other.getY());
330 }
331 
332 bool Box2D::overlaps(Box2D const& other) const noexcept {
333  // Can't delegate to IntervalD here because IntervalID is closed while
334  // Box2D is half-open.
335  return !(other.isEmpty() || this->isEmpty() || any(other.getMax().le(this->getMin())) ||
336  any(other.getMin().ge(this->getMax())));
337 }
338 
339 bool Box2D::isDisjointFrom(Box2D const& other) const noexcept {
340  return !overlaps(other);
341 }
342 
343 void Box2D::grow(Extent2D const& buffer) {
344  if (isEmpty()) return; // should we throw an exception here instead of a no-op?
345  _minimum -= buffer;
346  _maximum += buffer;
347  if (any(_minimum.ge(_maximum))) *this = Box2D();
348 }
349 
350 void Box2D::shift(Extent2D const& offset) {
351  if (isEmpty()) return; // should we throw an exception here instead of a no-op?
352  _minimum += offset;
353  _maximum += offset;
354 }
355 
356 void Box2D::flipLR(float xextent) {
357  if (isEmpty()) return; // should we throw an exception here instead of a no-op?
358  // Swap min and max values for x dimension
359  _minimum[0] += _maximum[0];
360  _maximum[0] = _minimum[0] - _maximum[0];
361  _minimum[0] -= _maximum[0];
362  // Apply flip assuming coordinate system of parent.
363  _minimum[0] = xextent - _minimum[0];
364  _maximum[0] = xextent - _maximum[0];
365  // _dimensions should remain unchanged
366 }
367 
368 void Box2D::flipTB(float yextent) {
369  if (isEmpty()) return; // should we throw an exception here instead of a no-op?
370  // Swap min and max values for y dimension
371  _minimum[1] += _maximum[1];
372  _maximum[1] = _minimum[1] - _maximum[1];
373  _minimum[1] -= _maximum[1];
374  // Apply flip assuming coordinate system of parent.
375  _minimum[1] = yextent - _minimum[1];
376  _maximum[1] = yextent - _maximum[1];
377  // _dimensions should remain unchanged
378 }
379 
380 void Box2D::include(Point2D const& point) noexcept {
381  if (isEmpty()) {
382  _minimum = point;
383  _maximum = point;
384  _tweakMax(0);
385  _tweakMax(1);
386  return;
387  }
388  for (int n = 0; n < 2; ++n) {
389  if (point[n] < _minimum[n]) {
390  _minimum[n] = point[n];
391  } else if (point[n] >= _maximum[n]) {
392  _maximum[n] = point[n];
393  _tweakMax(n);
394  }
395  }
396 }
397 
398 void Box2D::include(Box2D const& other) noexcept {
399  if (other.isEmpty()) return;
400  if (this->isEmpty()) {
401  *this = other;
402  return;
403  }
404  Point2D const& otherMin = other.getMin();
405  Point2D const& otherMax = other.getMax();
406  for (int n = 0; n < 2; ++n) {
407  if (otherMin[n] < _minimum[n]) {
408  _minimum[n] = otherMin[n];
409  }
410  if (otherMax[n] > _maximum[n]) {
411  _maximum[n] = otherMax[n];
412  }
413  }
414 }
415 
416 void Box2D::clip(Box2D const& other) noexcept {
417  if (isEmpty()) return;
418  if (other.isEmpty()) {
419  *this = Box2D();
420  return;
421  }
422  Point2D const& otherMin = other.getMin();
423  Point2D const& otherMax = other.getMax();
424  for (int n = 0; n < 2; ++n) {
425  if (otherMin[n] > _minimum[n]) {
426  _minimum[n] = otherMin[n];
427  }
428  if (otherMax[n] < _maximum[n]) {
429  _maximum[n] = otherMax[n];
430  }
431  }
432  if (any(_maximum.le(_minimum))) {
433  *this = Box2D();
434  return;
435  }
436 }
437 
438 Box2D Box2D::dilatedBy(Extent const & buffer) const {
439  return Box2D(getX().dilatedBy(buffer.getX()),
440  getY().dilatedBy(buffer.getY()));
441 }
442 
443 Box2D Box2D::shiftedBy(Extent const & offset) const {
444  return Box2D(getX().shiftedBy(offset.getX()),
445  getY().shiftedBy(offset.getY()));
446 }
447 
449  return Box2D(getX().reflectedAbout(x),
450  getY());
451 }
452 
454  return Box2D(getX(),
455  getY().reflectedAbout(y));
456 }
457 
459  // Can't delegate to IntervalD here because IntervalID is closed while
460  // Box2D is still half-open.
461  Box2D copy(*this);
462  copy.include(other);
463  return copy;
464 }
465 
467  return Box2D(getX().expandedTo(other.getX()),
468  getY().expandedTo(other.getY()));
469 }
470 
472  return Box2D(getX().clippedTo(other.getX()),
473  getY().clippedTo(other.getY()));
474 }
475 
476 bool Box2D::operator==(Box2D const& other) const noexcept {
477  return (other.isEmpty() && this->isEmpty()) ||
478  (other._minimum == this->_minimum && other._maximum == this->_maximum);
479 }
480 
481 bool Box2D::operator!=(Box2D const& other) const noexcept {
482  return !(other.isEmpty() && other.isEmpty()) &&
483  (other._minimum != this->_minimum || other._maximum != this->_maximum);
484 }
485 
486 std::size_t Box2D::hash_value() const noexcept {
487  if (isEmpty()) {
488  // All empty boxes are equal and must have equal hashes
489  return 179;
490  } else {
491  // Completely arbitrary seed
492  return utils::hashCombine(17, _minimum, _maximum);
493  }
494 }
495 
497  std::vector<Point2D> retVec;
498  retVec.push_back(getMin());
499  retVec.push_back(Point2D(getMaxX(), getMinY()));
500  retVec.push_back(getMax());
501  retVec.push_back(Point2D(getMinX(), getMaxY()));
502  return retVec;
503 }
504 
506  if (box.isEmpty()) return os << "Box2I()";
507  return os << "Box2I(Point2I" << box.getMin() << ", Extent2I" << box.getDimensions() << ")";
508 }
509 
511  if (box.isEmpty()) return os << "Box2D()";
512  return os << "Box2D(Point2D" << box.getMin() << ", Extent2D" << box.getDimensions() << ")";
513 }
514 
515 } // namespace geom
516 } // namespace lsst
bool operator==(Box2I const &other) const noexcept
Compare two boxes for equality.
Definition: Box.cc:248
std::vector< Point2D > getCorners() const
Get the corner points.
Definition: Box.cc:496
Extent2I const getDimensions() const noexcept
Definition: Box.h:186
bool isDisjointFrom(Box2I const &other) const noexcept
Return true if there are no points in both this and other.
Definition: Box.cc:126
EdgeHandlingEnum
Enum used to indicate how to handle conversions from floating-point to integer intervals.
Definition: Interval.h:64
Point2I const getMax() const noexcept
Definition: Box.h:160
Box2I reflectedAboutY(Element y) const
Reflect the box about a horizontal line (returning a new object).
Definition: Box.cc:228
Box2I expandedTo(Point const &other) const
Expand the box to ensure that contains(other) is true (returning a new object).
Definition: Box.cc:233
void flipLR(int xExtent)
Flip a bounding box about the y-axis given a parent box of extent (xExtent).
Definition: Box.cc:138
void shift(Extent< T, N > const &offset) noexcept(Super::IS_ELEMENT_NOTHROW_COPYABLE)
Shift the point by the given offset.
Definition: Point.h:132
A floating-point coordinate rectangle geometry.
Definition: Box.h:413
Point2D const getCenter() const noexcept
Definition: Box.h:549
T swap(T... args)
T epsilon(T... args)
A coordinate class intended to represent absolute positions.
void include(Point2D const &point) noexcept
Expand this to ensure that this->contains(point).
Definition: Box.cc:380
bool isEmpty() const noexcept
Return true if the box contains no points.
Definition: Box.h:213
Box2I reflectedAboutX(Element x) const
Reflect the box about a vertical line (returning a new object).
Definition: Box.cc:223
int y
Definition: SpanSet.cc:49
IntervalI clippedTo(IntervalI const &other) const noexcept
Shrink an interval to ensure that it is contained by other (returning a new)
Definition: Interval.cc:186
Extent2D const getDimensions() const noexcept
1-d interval accessors
Definition: Box.h:528
std::size_t hash_value() const noexcept
Return a hash of this object.
Definition: Box.cc:486
bool contains(Element point) const noexcept
Return true if the interval contains the point.
Definition: Interval.cc:116
IntervalI expandedTo(Element other) const
Expand an interval to ensure that contains(other) is true (returning a new object).
Definition: Interval.cc:166
Relationship invert(Relationship r)
Given the relationship between two sets A and B (i.e.
Definition: Relationship.h:55
ItemVariant const * other
Definition: Schema.cc:56
Point2D const getMin() const noexcept
Definition: Box.h:513
void shift(Extent2D const &offset)
Shift the position of the box by the given offset.
Definition: Box.cc:350
std::vector< Point2I > getCorners() const
Get the corner points.
Definition: Box.cc:261
int getEndY() const noexcept
Definition: Box.h:177
IntervalI dilatedBy(Element buffer) const
Increase the size of the interval by the given amount in both directions (returning a new object)...
Definition: Interval.cc:137
Box2D shiftedBy(Extent const &offset) const
Shift the position of the box by the given offset (returning a new object).
Definition: Box.cc:443
Box2I shiftedBy(Extent const &offset) const
Shift the position of the box by the given offset (returning a new object).
Definition: Box.cc:218
bool isDisjointFrom(IntervalI const &other) const noexcept
Return true if there are no points in both this and other.
Definition: Interval.cc:130
Interval getY() const
1-d interval accessors
Definition: Box.h:206
void clip(Box2D const &other) noexcept
Shrink this to ensure that other.contains(*this).
Definition: Box.cc:416
Point< double, 2 > Point2D
Definition: Point.h:324
static double const EPSILON
Value the maximum coordinate is multiplied by to increase it by the smallest possible amount...
Definition: Box.h:425
Include all pixels that overlap the floating-point interval at all.
bool any(CoordinateExpr< N > const &expr) noexcept
Return true if any elements are true.
int getBeginY() const noexcept
Definition: Box.h:173
void flipLR(float xExtent)
Flip a bounding box about the y-axis given a parent box of extent (xExtent).
Definition: Box.cc:356
Point2I const getMin() const noexcept
Definition: Box.h:156
bool isEmpty() const noexcept
Return true if the box contains no points.
Definition: Box.h:557
IntervalI shiftedBy(Element offset) const
Shift the position of the interval by the given offset (returning a new object).) ...
Definition: Interval.cc:146
T push_back(T... args)
afw::table::PointKey< int > dimensions
Definition: GaussianPsf.cc:49
bool all(CoordinateExpr< N > const &expr) noexcept
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...
Definition: Runtime.h:124
CoordinateExpr< N > ge(Point< T, N > const &other) const noexcept
Definition: Point.cc:111
void grow(int buffer)
Increase the size of the box by the given buffer amount in all directions.
Definition: Box.h:249
int getMaxY() const noexcept
Definition: Box.h:162
bool contains(Point2D const &point) const noexcept
Return true if the box contains the point.
Definition: Box.cc:322
static double const INVALID
Value used to specify undefined coordinate values.
Definition: Box.h:428
void grow(double buffer)
Increase the size of the box by the given buffer amount in all directions.
Definition: Box.h:594
int getBeginX() const noexcept
Definition: Box.h:172
static Box2D makeCenteredBox(Point2D const &center, Extent const &size) noexcept
Create a box centered on a particular point.
Definition: Box.cc:316
Box2D reflectedAboutY(Element y) const
Reflect the box about a horizontal line (returning a new object).
Definition: Box.cc:453
T isfinite(T... args)
bool isDisjointFrom(Box2D const &other) const noexcept
Return true if there are no points in both this and other.
Definition: Box.cc:339
Box2I clippedTo(Box2I const &other) const noexcept
Shrink an interval to ensure that it is contained by other (returning a new object).
Definition: Box.cc:243
std::ostream & operator<<(std::ostream &os, lsst::geom::AffineTransform const &transform)
int Element
Definition: Box.h:59
Reports errors in the logical structure of the program.
Definition: Runtime.h:46
Box2D reflectedAboutX(Element x) const
Reflect the box about a vertical line (returning a new object).
Definition: Box.cc:448
A coordinate class intended to represent offsets and dimensions.
Point< int, 2 > Point2I
Definition: Point.h:321
int getMaxX() const noexcept
Definition: Box.h:161
Include only pixels that are wholly contained by the floating-point interval.
double x
Box2D clippedTo(Box2D const &other) const
Shrink a box to ensure that it is contained by other (returning a new object).
Definition: Box.cc:471
std::size_t hash_value() const noexcept
Return a hash of this object.
Definition: Box.cc:256
bool operator!=(Box2I const &other) const noexcept
Compare two boxes for equality.
Definition: Box.cc:252
int getMinX() const noexcept
Definition: Box.h:157
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
Extent< int, 2 > Extent2I
Definition: Extent.h:397
STL class.
Box2D dilatedBy(Extent const &buffer) const
Increase the size of the box by the given amount(s) on all sides (returning a new object)...
Definition: Box.cc:438
CoordinateExpr< N > lt(Point< T, N > const &other) const noexcept
Definition: Point.cc:90
void flipTB(float yExtent)
Flip a bounding box about the x-axis given a parent box of extent (yExtent).
Definition: Box.cc:368
int getEndX() const noexcept
Definition: Box.h:176
void include(Point2I const &point)
Expand this to ensure that this->contains(point).
Definition: Box.cc:152
A 1-d integer coordinate range.
Definition: Interval.h:50
bool overlaps(Box2D const &other) const noexcept
Return true if any points in other are also in this.
Definition: Box.cc:332
double Element
Definition: Box.h:417
void shift(Extent2I const &offset)
Shift the position of the box by the given offset.
Definition: Box.cc:134
bool overlaps(Box2I const &other) const noexcept
Return true if any points in other are also in this.
Definition: Box.cc:122
bool contains(Point2I const &point) const noexcept
Return true if the box contains the point.
Definition: Box.cc:114
void clip(Box2I const &other) noexcept
Shrink this to ensure that other.contains(*this).
Definition: Box.cc:189
Point2D const getCenter() const noexcept
Definition: Box.cc:93
ndarray::View< boost::fusion::vector2< ndarray::index::Range, ndarray::index::Range > > getSlices() const
Return slices to extract the box&#39;s region from an ndarray::Array.
Definition: Box.cc:109
Reports invalid arguments.
Definition: Runtime.h:66
Interval getX() const
1-d interval accessors
Definition: Box.h:539
static Box2I makeCenteredBox(Point2D const &center, Extent const &size)
Create a box centered as closely as possible on a particular point.
Definition: Box.cc:97
Box2I() noexcept
Construct an empty box.
Definition: Box.h:66
T quiet_NaN(T... args)
Interval getX() const
1-d interval accessors
Definition: Box.h:205
Box2D() noexcept
Construct an empty box.
Definition: Box.cc:274
bool operator==(Box2D const &other) const noexcept
Compare two boxes for equality.
Definition: Box.cc:476
Extent< double, 2 > Extent2D
Definition: Extent.h:400
std::size_t hashCombine(std::size_t seed) noexcept
Combine hashes.
Definition: hashCombine.h:35
std::ostream * os
Definition: Schema.cc:746
Box2I dilatedBy(Extent const &buffer) const
Increase the size of the box by the given amount(s) on all sides (returning a new object)...
Definition: Box.cc:213
Box2D expandedTo(Point const &other) const
Expand a box to ensure that contains(other) is true (returning a new object).
Definition: Box.cc:458
An integer coordinate rectangle.
Definition: Box.h:55
STL class.
Interval getY() const
1-d interval accessors
Definition: Box.h:540
int getMinY() const noexcept
Definition: Box.h:158
void flipTB(int yExtent)
Flip a bounding box about the x-axis given a parent box of extent (yExtent).
Definition: Box.cc:145
bool operator!=(Box2D const &other) const noexcept
Compare two boxes for equality.
Definition: Box.cc:481