LSSTApplications  19.0.0-12-gef62271,20.0.0+1,20.0.0+10,20.0.0+11,20.0.0+13,20.0.0+2,20.0.0+3,20.0.0+4,20.0.0+6,20.0.0-1-g10df615+10,20.0.0-1-g253301a+5,20.0.0-1-g596936a+11,20.0.0-1-g8a53f90+1,20.0.0-1-gc96f8cb+12,20.0.0-1-gd1c87d7+1,20.0.0-17-g41c5faf,20.0.0-2-g04cfba9+4,20.0.0-2-gd11eeda,20.0.0-2-gec03fae+3,20.0.0-3-g082faa5+1,20.0.0-3-gbdbfa727+3,20.0.0-3-gc53c7b6,20.0.0-4-gde602ef96+4,20.0.0-4-ge48a6ca+7,20.0.0-4-ge987224+1,20.0.0-8-g7eef53f7+7,20.0.0-9-g8e1b333,w.2020.28
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
y
int y
Definition: SpanSet.cc:49
lsst::geom::Box2I::flipTB
void flipTB(int yExtent)
Flip a bounding box about the x-axis given a parent box of extent (yExtent).
Definition: Box.cc:145
lsst::geom::Box2D::getMin
Point2D const getMin() const noexcept
Definition: Box.h:513
lsst::geom::IntervalI
A 1-d integer coordinate range.
Definition: Interval.h:50
lsst::geom::Box2I::reflectedAboutY
Box2I reflectedAboutY(Element y) const
Reflect the box about a horizontal line (returning a new object).
Definition: Box.cc:228
lsst::geom::Box2I::operator==
bool operator==(Box2I const &other) const noexcept
Compare two boxes for equality.
Definition: Box.cc:248
lsst::geom::Box2I::flipLR
void flipLR(int xExtent)
Flip a bounding box about the y-axis given a parent box of extent (xExtent).
Definition: Box.cc:138
lsst::geom::Box2I::getMax
Point2I const getMax() const noexcept
Definition: Box.h:160
lsst::geom::Box2D::shift
void shift(Extent2D const &offset)
Shift the position of the box by the given offset.
Definition: Box.cc:350
lsst::geom::Box2I::reflectedAboutX
Box2I reflectedAboutX(Element x) const
Reflect the box about a vertical line (returning a new object).
Definition: Box.cc:223
lsst::geom::Box2I::getSlices
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.
Definition: Box.cc:109
lsst::geom::Box2D::getX
Interval getX() const
1-d interval accessors
Definition: Box.h:539
lsst::geom::Box2I::getDimensions
Extent2I const getDimensions() const noexcept
Definition: Box.h:186
std::numeric_limits::quiet_NaN
T quiet_NaN(T... args)
lsst::geom::Box2D::operator==
bool operator==(Box2D const &other) const noexcept
Compare two boxes for equality.
Definition: Box.cc:476
lsst::geom::Box2I::makeCenteredBox
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
std::vector
STL class.
lsst::geom::Box2D::contains
bool contains(Point2D const &point) const noexcept
Return true if the box contains the point.
Definition: Box.cc:322
lsst::geom::Box2D::overlaps
bool overlaps(Box2D const &other) const noexcept
Return true if any points in other are also in this.
Definition: Box.cc:332
lsst::geom::Box2D::getDimensions
Extent2D const getDimensions() const noexcept
1-d interval accessors
Definition: Box.h:528
lsst::geom::Box2I::Element
int Element
Definition: Box.h:59
lsst::geom::Box2I::getMin
Point2I const getMin() const noexcept
Definition: Box.h:156
lsst::geom::Point2D
Point< double, 2 > Point2D
Definition: Point.h:324
lsst::geom::Box2I::isEmpty
bool isEmpty() const noexcept
Return true if the box contains no points.
Definition: Box.h:213
lsst::geom::Box2D::clippedTo
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
lsst::geom::Box2D::getCorners
std::vector< Point2D > getCorners() const
Get the corner points.
Definition: Box.cc:496
lsst::geom::Box2D::Box2D
Box2D() noexcept
Construct an empty box.
Definition: Box.cc:274
lsst::geom::Box2I::getEndY
int getEndY() const noexcept
Definition: Box.h:177
lsst::geom::Box2I::EXPAND
@ EXPAND
Definition: Box.h:63
lsst::geom::IntervalI::EdgeHandlingEnum
EdgeHandlingEnum
Enum used to indicate how to handle conversions from floating-point to integer intervals.
Definition: Interval.h:64
lsst::geom::Box2D::dilatedBy
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
lsst::geom::all
bool all(CoordinateExpr< N > const &expr) noexcept
Return true if all elements are true.
Definition: CoordinateExpr.h:81
std::vector::push_back
T push_back(T... args)
lsst::geom::Box2I::shiftedBy
Box2I shiftedBy(Extent const &offset) const
Shift the position of the box by the given offset (returning a new object).
Definition: Box.cc:218
lsst::geom::Box2I::getY
Interval getY() const
1-d interval accessors
Definition: Box.h:206
lsst::geom::Box2D::Element
double Element
Definition: Box.h:417
hashCombine.h
lsst::geom::Box2I::shift
void shift(Extent2I const &offset)
Shift the position of the box by the given offset.
Definition: Box.cc:134
lsst::geom::Box2D::getMinY
double getMinY() const noexcept
Definition: Box.h:515
lsst::geom::Box2I::getBeginY
int getBeginY() const noexcept
Definition: Box.h:173
lsst::geom::Box2D::makeCenteredBox
static Box2D makeCenteredBox(Point2D const &center, Extent const &size) noexcept
Create a box centered on a particular point.
Definition: Box.cc:316
std::isfinite
T isfinite(T... args)
lsst::geom::Box2I::grow
void grow(int buffer)
Increase the size of the box by the given buffer amount in all directions.
Definition: Box.h:249
std::ostream
STL class.
lsst::geom::Box2D::getMaxX
double getMaxX() const noexcept
Definition: Box.h:518
lsst::geom::Box2I::EdgeHandlingEnum
EdgeHandlingEnum
Definition: Box.h:63
x
double x
Definition: ChebyshevBoundedField.cc:277
lsst::geom::Box2I::include
void include(Point2I const &point)
Expand this to ensure that this->contains(point).
Definition: Box.cc:152
lsst::geom::IntervalI::EdgeHandlingEnum::EXPAND
@ EXPAND
Include all pixels that overlap the floating-point interval at all.
lsst::geom::Box2I::Box2I
Box2I() noexcept
Construct an empty box.
Definition: Box.h:66
lsst::geom::Box2D::getMinX
double getMinX() const noexcept
Definition: Box.h:514
lsst::pex::exceptions::OverflowError
Reports when the result of an arithmetic operation is too large for the destination type.
Definition: Runtime.h:124
other
ItemVariant const * other
Definition: Schema.cc:56
lsst::geom::Box2I::getBeginX
int getBeginX() const noexcept
Definition: Box.h:172
lsst::geom::Box2I::contains
bool contains(Point2I const &point) const noexcept
Return true if the box contains the point.
Definition: Box.cc:114
lsst::pex::exceptions::LogicError
Reports errors in the logical structure of the program.
Definition: Runtime.h:46
lsst::geom::Box2D::getMax
Point2D const getMax() const noexcept
Definition: Box.h:517
lsst::geom::any
bool any(CoordinateExpr< N > const &expr) noexcept
Return true if any elements are true.
Definition: CoordinateExpr.h:89
lsst::geom::Box2D::getY
Interval getY() const
1-d interval accessors
Definition: Box.h:540
lsst::geom::Box2I::clippedTo
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
lsst::geom::Box2I::dilatedBy
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
dimensions
afw::table::PointKey< int > dimensions
Definition: GaussianPsf.cc:49
lsst::geom::Box2D::clip
void clip(Box2D const &other) noexcept
Shrink this to ensure that other.contains(*this).
Definition: Box.cc:416
lsst::geom::Box2I::SHRINK
@ SHRINK
Definition: Box.h:63
lsst::geom::Box2D::isDisjointFrom
bool isDisjointFrom(Box2D const &other) const noexcept
Return true if there are no points in both this and other.
Definition: Box.cc:339
Box.h
std::numeric_limits::epsilon
T epsilon(T... args)
lsst
A base class for image defects.
Definition: imageAlgorithm.dox:1
lsst::geom::operator<<
std::ostream & operator<<(std::ostream &os, lsst::geom::AffineTransform const &transform)
Definition: AffineTransform.cc:72
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
lsst::geom::Box2I::getCenter
Point2D const getCenter() const noexcept
1-d interval accessors
Definition: Box.cc:93
std::swap
T swap(T... args)
lsst::geom::Box2D::expandedTo
Box2D expandedTo(Point const &other) const
Expand a box to ensure that contains(other) is true (returning a new object).
Definition: Box.cc:458
lsst::geom
Definition: AffineTransform.h:36
os
std::ostream * os
Definition: Schema.cc:746
lsst::geom::Box2D::hash_value
std::size_t hash_value() const noexcept
Return a hash of this object.
Definition: Box.cc:486
lsst::geom::IntervalD::contains
bool contains(Element point) const
Return true if the interval contains the point.
Definition: Interval.cc:263
lsst::geom::Box2I::getEndX
int getEndX() const noexcept
Definition: Box.h:176
lsst::utils::hashCombine
std::size_t hashCombine(std::size_t seed) noexcept
Combine hashes.
Definition: hashCombine.h:35
lsst::geom::Box2D::operator!=
bool operator!=(Box2D const &other) const noexcept
Compare two boxes for equality.
Definition: Box.cc:481
lsst::geom::Box2I::getX
Interval getX() const
1-d interval accessors
Definition: Box.h:205
lsst::geom::Box2I::overlaps
bool overlaps(Box2I const &other) const noexcept
Return true if any points in other are also in this.
Definition: Box.cc:122
lsst::geom::Box2D::flipLR
void flipLR(float xExtent)
Flip a bounding box about the y-axis given a parent box of extent (xExtent).
Definition: Box.cc:356
lsst::pex::exceptions::InvalidParameterError
Reports invalid arguments.
Definition: Runtime.h:66
lsst::geom::Box2D::shiftedBy
Box2D shiftedBy(Extent const &offset) const
Shift the position of the box by the given offset (returning a new object).
Definition: Box.cc:443
lsst::geom::Box2I::clip
void clip(Box2I const &other) noexcept
Shrink this to ensure that other.contains(*this).
Definition: Box.cc:189
lsst::geom::Box2I::getMaxY
int getMaxY() const noexcept
Definition: Box.h:162
lsst::geom::Box2D::isEmpty
bool isEmpty() const noexcept
Return true if the box contains no points.
Definition: Box.h:557
lsst::geom::Box2I::getMaxX
int getMaxX() const noexcept
Definition: Box.h:161
lsst::geom::Extent2I
Extent< int, 2 > Extent2I
Definition: Extent.h:397
lsst::geom::IntervalI::EdgeHandlingEnum::SHRINK
@ SHRINK
Include only pixels that are wholly contained by the floating-point interval.
lsst::geom::Point
A coordinate class intended to represent absolute positions.
Definition: CoordinateBase.h:39
lsst::geom::Box2D::getMaxY
double getMaxY() const noexcept
Definition: Box.h:519
lsst::geom::Point2I
Point< int, 2 > Point2I
Definition: Point.h:321
lsst::geom::Box2I
An integer coordinate rectangle.
Definition: Box.h:55
lsst::geom::Box2I::getMinX
int getMinX() const noexcept
Definition: Box.h:157
lsst::geom::Box2D::include
void include(Point2D const &point) noexcept
Expand this to ensure that this->contains(point).
Definition: Box.cc:380
std::size_t
lsst::geom::Box2D::getCenter
Point2D const getCenter() const noexcept
Return true if the box contains no points.
Definition: Box.h:549
lsst::geom::Box2I::expandedTo
Box2I expandedTo(Point const &other) const
Expand the box to ensure that contains(other) is true (returning a new object).
Definition: Box.cc:233
lsst::geom::Box2D::reflectedAboutY
Box2D reflectedAboutY(Element y) const
Reflect the box about a horizontal line (returning a new object).
Definition: Box.cc:453
lsst::geom::Box2D
A floating-point coordinate rectangle geometry.
Definition: Box.h:413
lsst::geom::Box2I::hash_value
std::size_t hash_value() const noexcept
Return a hash of this object.
Definition: Box.cc:256
lsst::geom::Box2I::operator!=
bool operator!=(Box2I const &other) const noexcept
Compare two boxes for equality.
Definition: Box.cc:252
lsst::geom::Box2D::INVALID
static double const INVALID
Value used to specify undefined coordinate values.
Definition: Box.h:428
lsst::geom::Extent
A coordinate class intended to represent offsets and dimensions.
Definition: CoordinateBase.h:41
lsst::geom::Box2D::grow
void grow(double buffer)
Increase the size of the box by the given buffer amount in all directions.
Definition: Box.h:594
lsst::geom::Box2D::reflectedAboutX
Box2D reflectedAboutX(Element x) const
Reflect the box about a vertical line (returning a new object).
Definition: Box.cc:448
lsst::geom::Box2D::flipTB
void flipTB(float yExtent)
Flip a bounding box about the x-axis given a parent box of extent (yExtent).
Definition: Box.cc:368
lsst::sphgeom::invert
Relationship invert(Relationship r)
Given the relationship between two sets A and B (i.e.
Definition: Relationship.h:55
lsst::geom::Box2I::getMinY
int getMinY() const noexcept
Definition: Box.h:158
lsst::geom::Box2D::EPSILON
static double const EPSILON
Value the maximum coordinate is multiplied by to increase it by the smallest possible amount.
Definition: Box.h:425
lsst::geom::Box2I::getCorners
std::vector< Point2I > getCorners() const
Get the corner points.
Definition: Box.cc:261
lsst::geom::Box2I::isDisjointFrom
bool isDisjointFrom(Box2I const &other) const noexcept
Return true if there are no points in both this and other.
Definition: Box.cc:126