24 #ifndef LSST_AFW_GEOM_BOX_H 25 #define LSST_AFW_GEOM_BOX_H 28 #include "boost/format.hpp" 64 Box2I() : _minimum(0), _dimensions(0) {}
109 _minimum.
swap(other._minimum);
110 _dimensions.
swap(other._dimensions);
124 int getMinX()
const {
return _minimum.getX(); }
125 int getMinY()
const {
return _minimum.getY(); }
128 int getMaxX()
const {
return _minimum.getX() + _dimensions.getX() - 1; }
129 int getMaxY()
const {
return _minimum.getY() + _dimensions.getY() - 1; }
143 int getEndX()
const {
return _minimum.getX() + _dimensions.getX(); }
144 int getEndY()
const {
return _minimum.getY() + _dimensions.getY(); }
154 int getWidth()
const {
return _dimensions.getX(); }
160 ndarray::View<boost::fusion::vector2<ndarray::index::Range, ndarray::index::Range> >
getSlices()
const;
163 bool isEmpty()
const {
return _dimensions.getX() == 0 && _dimensions.getY() == 0; }
324 _minimum.swap(other._minimum);
325 _maximum.swap(other._maximum);
339 double getMinX()
const {
return _minimum.getX(); }
340 double getMinY()
const {
return _minimum.getY(); }
343 double getMaxX()
const {
return _maximum.getX(); }
344 double getMaxY()
const {
return _maximum.getY(); }
358 return dim.getX() * dim.getY();
369 double getCenterX()
const {
return (_minimum.getX() + _maximum.getX()) * 0.5; }
370 double getCenterY()
const {
return (_minimum.getY() + _maximum.getY()) * 0.5; }
374 bool isEmpty()
const {
return _minimum.getX() != _minimum.getX(); }
413 void flipLR(
float xExtent);
416 void flipTB(
float yExtent);
456 return (
boost::format(
"Box2D(%s,%s)") % _minimum.toString() % _maximum.toString()).str();
460 void _tweakMax(
int n) {
461 if (_maximum[n] < 0.0) {
462 _maximum[n] *= (1.0 -
EPSILON);
463 }
else if (_maximum[n] > 0.0) {
464 _maximum[n] *= (1.0 +
EPSILON);
void grow(double buffer)
Increase the size of the box by the given buffer amount in all directions.
Point2I const getMin() const
afw::table::PointKey< int > dimensions
std::string toString() const
bool isEmpty() const
Return true if the box contains no points.
Point2I const getBegin() const
Point2I const getEnd() const
void shift(Extent2I const &offset)
Shift the position of the box by the given offset.
Extent< double, 2 > Extent2D
std::ostream & operator<<(std::ostream &os, lsst::afw::geom::AffineTransform const &transform)
Box2I()
Construct an empty box.
static double const INVALID
Value used to specify undefined coordinate values.
A coordinate class intended to represent offsets and dimensions.
void include(Point2I const &point)
Expand this to ensure that this->contains(point).
Extent< int, 2 > Extent2I
std::string toString() const
std::string toString() const
bool isEmpty() const
Return true if the box contains no points.
A coordinate class intended to represent absolute positions.
An integer coordinate rectangle.
Extent2D const getDimensions() const
Point2I const getMax() const
Box2I & operator=(Box2I const &)=default
Standard assignment operator.
bool overlaps(Box2I const &other) const
Return true if any points in other are also in this.
A base class for image defects.
std::string toString() const
double getCenterX() const
Point< double, 2 > Point2D
Point2D const getCenter() const
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
bool operator==(Box2I const &other) const
Compare two boxes for equality.
static double const EPSILON
Value the maximum coordinate is multiplied by to increase it by the smallest possible amount...
bool contains(Point2I const &point) const
Return true if the box contains the point.
void flipLR(int xExtent)
Flip a bounding box about the y-axis given a parent box of extent (xExtent).
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.
std::vector< Point2I > getCorners() const
Get the corner points.
void grow(int buffer)
Increase the size of the box by the given buffer amount in all directions.
Extent2I const getDimensions() const
void flipTB(int yExtent)
Flip a bounding box about the x-axis given a parent box of extent (yExtent).
ItemVariant const * other
double getCenterY() const
bool operator!=(Box2I const &other) const
Compare two boxes for equality.
void clip(Box2I const &other)
Shrink this to ensure that other.contains(*this).
A floating-point coordinate rectangle geometry.
Point2D const getMax() const
Point2D const getMin() const