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(); }
191 ndarray::View<boost::fusion::vector2<ndarray::index::Range, ndarray::index::Range> >
getSlices()
const;
194 bool isEmpty() const noexcept {
return _dimensions.getX() == 0 && _dimensions.getY() == 0; }
362 ~
Box2D() noexcept = default;
379 _minimum.swap(
other._minimum);
380 _maximum.swap(
other._maximum);
394 double getMinX() const noexcept {
return _minimum.getX(); }
395 double getMinY() const noexcept {
return _minimum.getY(); }
398 double getMaxX() const noexcept {
return _maximum.getX(); }
399 double getMaxY() const noexcept {
return _maximum.getY(); }
409 double getWidth() const noexcept {
return isEmpty() ? 0 : _maximum.getX() - _minimum.getX(); }
410 double getHeight() const noexcept {
return isEmpty() ? 0 : _maximum.getY() - _minimum.getY(); }
413 return dim.getX() * dim.getY();
424 return Point2D((_minimum.asEigen() + _maximum.asEigen()) * 0.5);
426 double getCenterX() const noexcept {
return (_minimum.getX() + _maximum.getX()) * 0.5; }
427 double getCenterY() const noexcept {
return (_minimum.getY() + _maximum.getY()) * 0.5; }
431 bool isEmpty() const noexcept {
return _minimum.getX() != _minimum.getX(); }
470 void flipLR(
float xExtent);
473 void flipTB(
float yExtent);
521 return (
boost::format(
"Box2D(%s,%s)") % _minimum.toString() % _maximum.toString()).
str();
525 void _tweakMax(
int n) noexcept {
526 if (_maximum[n] < 0.0) {
527 _maximum[n] *= (1.0 -
EPSILON);
528 }
else if (_maximum[n] > 0.0) {
529 _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
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.
ItemVariant const * other
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.
afw::table::PointKey< int > dimensions
double getMaxY() const noexcept
double getCenterX() 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.
size_t operator()(argument_type const &x) const noexcept
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
std::size_t hash_value() const noexcept
Return a hash of this object.
Point2D const getMax() const noexcept
double getCenterY() 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).
Point2D const getCenter() const noexcept
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.
Box2I() noexcept
Construct an empty box.
size_t operator()(argument_type const &x) const noexcept
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