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) {}
104 Box2I(
Box2I const& other) : _minimum(other._minimum), _dimensions(other._dimensions) {}
107 _minimum.
swap(other._minimum);
108 _dimensions.
swap(other._dimensions);
113 _minimum = other._minimum;
114 _dimensions = other._dimensions;
125 int getMinX()
const {
return _minimum.getX(); }
126 int getMinY()
const {
return _minimum.getY(); }
129 int getMaxX()
const {
return _minimum.getX() + _dimensions.getX() - 1; }
130 int getMaxY()
const {
return _minimum.getY() + _dimensions.getY() - 1; }
144 int getEndX()
const {
return _minimum.getX() + _dimensions.getX(); }
145 int getEndY()
const {
return _minimum.getY() + _dimensions.getY(); }
155 int getWidth()
const {
return _dimensions.getX(); }
161 ndarray::View<boost::fusion::vector2<ndarray::index::Range, ndarray::index::Range> >
getSlices()
const;
164 bool isEmpty()
const {
return _dimensions.getX() == 0 && _dimensions.getY() == 0; }
240 return (boost::format(
"Box2I(%s,%s)") % _minimum.
toString() % _dimensions.
toString()).str();
319 Box2D(
Box2D const& other) : _minimum(other._minimum), _maximum(other._maximum) {}
322 _minimum.swap(other._minimum);
323 _maximum.swap(other._maximum);
328 _minimum = other._minimum;
329 _maximum = other._maximum;
340 double getMinX()
const {
return _minimum.getX(); }
341 double getMinY()
const {
return _minimum.getY(); }
344 double getMaxX()
const {
return _maximum.getX(); }
345 double getMaxY()
const {
return _maximum.getY(); }
359 return dim.getX() * dim.getY();
370 double getCenterX()
const {
return (_minimum.getX() + _maximum.getX()) * 0.5; }
371 double getCenterY()
const {
return (_minimum.getY() + _maximum.getY()) * 0.5; }
375 bool isEmpty()
const {
return _minimum.getX() != _minimum.getX(); }
414 void flipLR(
float xExtent);
417 void flipTB(
float yExtent);
457 return (boost::format(
"Box2D(%s,%s)") % _minimum.toString() % _maximum.toString()).str();
461 void _tweakMax(
int n) {
462 if (_maximum[n] < 0.0) {
463 _maximum[n] *= (1.0 - EPSILON);
464 }
else if (_maximum[n] > 0.0) {
465 _maximum[n] *= (1.0 + EPSILON);
467 _maximum[n] = EPSILON;
void grow(double buffer)
Increase the size of the box by the given buffer amount in all directions.
std::vector< Point2I > getCorners() const
Get the corner points.
Point2I const getMin() const
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.
Box2I(Box2I const &other)
Standard copy constructor.
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.
Extent< double, 2 > Extent2D
Box2I()
Construct an empty box.
std::ostream & operator<<(std::ostream &os, lsst::afw::geom::AffineTransform const &transform)
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).
Box2D(Box2D const &other)
Standard copy constructor.
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.
Box2D & operator=(Box2D const &other)
Standard assignment operator.
An integer coordinate rectangle.
Extent2D const getDimensions() const
Point2I const getMax() const
afw::table::PointKey< int > dimensions
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
Box2I & operator=(Box2I const &other)
Standard assignment operator.
Point2D const getCenter() const
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).
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).
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