22 #ifndef LSST_GEOM_BOX_H 23 #define LSST_GEOM_BOX_H 27 #include "boost/format.hpp" 63 Box2I() noexcept : _minimum(0), _dimensions(0) {}
111 ~Box2I() noexcept =
default;
129 _minimum.
swap(other._minimum);
130 _dimensions.
swap(other._dimensions);
144 int getMinX() const noexcept {
return _minimum.getX(); }
145 int getMinY() const noexcept {
return _minimum.getY(); }
148 int getMaxX() const noexcept {
return _minimum.getX() + _dimensions.getX() - 1; }
149 int getMaxY() const noexcept {
return _minimum.getY() + _dimensions.getY() - 1; }
159 int getBeginX() const noexcept {
return _minimum.getX(); }
160 int getBeginY() const noexcept {
return _minimum.getY(); }
163 int getEndX() const noexcept {
return _minimum.getX() + _dimensions.getX(); }
164 int getEndY() const noexcept {
return _minimum.getY() + _dimensions.getY(); }
174 int getWidth() const noexcept {
return _dimensions.getX(); }
175 int getHeight() const noexcept {
return _dimensions.getY(); }
180 ndarray::View<boost::fusion::vector2<ndarray::index::Range, ndarray::index::Range> >
getSlices()
const;
183 bool isEmpty() const noexcept {
return _dimensions.getX() == 0 && _dimensions.getY() == 0; }
348 ~
Box2D() noexcept = default;
365 _minimum.swap(
other._minimum);
366 _maximum.swap(
other._maximum);
380 double getMinX() const noexcept {
return _minimum.getX(); }
381 double getMinY() const noexcept {
return _minimum.getY(); }
384 double getMaxX() const noexcept {
return _maximum.getX(); }
385 double getMaxY() const noexcept {
return _maximum.getY(); }
395 double getWidth() const noexcept {
return isEmpty() ? 0 : _maximum.getX() - _minimum.getX(); }
396 double getHeight() const noexcept {
return isEmpty() ? 0 : _maximum.getY() - _minimum.getY(); }
399 return dim.getX() * dim.getY();
410 return Point2D((_minimum.asEigen() + _maximum.asEigen()) * 0.5);
412 double getCenterX() const noexcept {
return (_minimum.getX() + _maximum.getX()) * 0.5; }
413 double getCenterY() const noexcept {
return (_minimum.getY() + _maximum.getY()) * 0.5; }
417 bool isEmpty() const noexcept {
return _minimum.getX() != _minimum.getX(); }
456 void flipLR(
float xExtent);
459 void flipTB(
float yExtent);
504 return (
boost::format(
"Box2D(%s,%s)") % _minimum.toString() % _maximum.toString()).
str();
508 void _tweakMax(
int n) noexcept {
509 if (_maximum[n] < 0.0) {
510 _maximum[n] *= (1.0 -
EPSILON);
511 }
else if (_maximum[n] > 0.0) {
512 _maximum[n] *= (1.0 +
EPSILON);
bool operator==(Box2I const &other) const noexcept
Compare two boxes for equality.
double getMinY() const noexcept
Extent2I const getDimensions() const noexcept
double getHeight() const noexcept
afw::table::PointKey< int > dimensions
Point2I const getMax() const noexcept
std::string toString() const
void flipLR(int xExtent)
Flip a bounding box about the y-axis given a parent box of extent (xExtent).
double getWidth() const noexcept
int getHeight() const noexcept
A floating-point coordinate rectangle geometry.
Point2D const getCenter() const noexcept
double getMinX() const noexcept
A coordinate class intended to represent absolute positions.
bool isEmpty() const noexcept
Return true if the box contains no points.
double getMaxX() const noexcept
Extent2D const getDimensions() const noexcept
std::string toString() const
Relationship invert(Relationship r)
Given the relationship between two sets A and B (i.e.
Point2D const getMin() const noexcept
std::vector< Point2I > getCorners() const
Get the corner points.
int getEndY() const noexcept
std::string toString() const
Point< double, 2 > Point2D
static double const EPSILON
Value the maximum coordinate is multiplied by to increase it by the smallest possible amount...
int getBeginY() const noexcept
Point2I const getMin() const noexcept
bool isEmpty() const noexcept
Return true if the box contains no points.
double getMaxY() const noexcept
double getCenterX() const noexcept
A base class for image defects.
void grow(int buffer)
Increase the size of the box by the given buffer amount in all directions.
int getMaxY() const noexcept
static double const INVALID
Value used to specify undefined coordinate values.
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
void grow(double buffer)
Increase the size of the box by the given buffer amount in all directions.
int getBeginX() const noexcept
int getWidth() const noexcept
std::ostream & operator<<(std::ostream &os, lsst::geom::AffineTransform const &transform)
A coordinate class intended to represent offsets and dimensions.
int getMaxX() const noexcept
Point2I const getEnd() const noexcept
void swap(Point &other) noexcept
double getArea() const noexcept
Point2D const getMax() const noexcept
void swap(Extent &other) noexcept
bool operator!=(Box2I const &other) const noexcept
Compare two boxes for equality.
double getCenterY() const noexcept
int getMinX() const noexcept
Extent< int, 2 > Extent2I
int getEndX() const noexcept
std::string toString() const
void include(Point2I const &point)
Expand this to ensure that this->contains(point).
void shift(Extent2I const &offset)
Shift the position of the box by the given offset.
bool overlaps(Box2I const &other) const noexcept
Return true if any points in other are also in this.
bool contains(Point2I const &point) const noexcept
Return true if the box contains the point.
~Box2I() noexcept=default
void clip(Box2I const &other) noexcept
Shrink this to ensure that other.contains(*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.
ItemVariant const * other
static Box2I makeCenteredBox(Point2D const ¢er, Extent const &size)
Create a box centered as closely as possible on a particular point.
Box2I() noexcept
Construct an empty box.
Extent< double, 2 > Extent2D
Point2I const getBegin() const noexcept
An integer coordinate rectangle.
int getMinY() const noexcept
Box2I & operator=(Box2I const &) noexcept=default
Standard assignment operator.
void flipTB(int yExtent)
Flip a bounding box about the x-axis given a parent box of extent (yExtent).
void swap(Box2I &other) noexcept