22 #ifndef LSST_GEOM_BOX_H 23 #define LSST_GEOM_BOX_H 27 #include "boost/format.hpp" 63 Box2I() : _minimum(0), _dimensions(0) {}
108 _minimum.
swap(other._minimum);
109 _dimensions.
swap(other._dimensions);
123 int getMinX()
const {
return _minimum.getX(); }
124 int getMinY()
const {
return _minimum.getY(); }
127 int getMaxX()
const {
return _minimum.getX() + _dimensions.getX() - 1; }
128 int getMaxY()
const {
return _minimum.getY() + _dimensions.getY() - 1; }
142 int getEndX()
const {
return _minimum.getX() + _dimensions.getX(); }
143 int getEndY()
const {
return _minimum.getY() + _dimensions.getY(); }
153 int getWidth()
const {
return _dimensions.getX(); }
159 ndarray::View<boost::fusion::vector2<ndarray::index::Range, ndarray::index::Range> >
getSlices()
const;
162 bool isEmpty()
const {
return _dimensions.getX() == 0 && _dimensions.getY() == 0; }
323 _minimum.swap(other._minimum);
324 _maximum.swap(other._maximum);
338 double getMinX()
const {
return _minimum.getX(); }
339 double getMinY()
const {
return _minimum.getY(); }
342 double getMaxX()
const {
return _maximum.getX(); }
343 double getMaxY()
const {
return _maximum.getY(); }
357 return dim.getX() * dim.getY();
368 double getCenterX()
const {
return (_minimum.getX() + _maximum.getX()) * 0.5; }
369 double getCenterY()
const {
return (_minimum.getY() + _maximum.getY()) * 0.5; }
373 bool isEmpty()
const {
return _minimum.getX() != _minimum.getX(); }
412 void flipLR(
float xExtent);
415 void flipTB(
float yExtent);
455 return (
boost::format(
"Box2D(%s,%s)") % _minimum.toString() % _maximum.toString()).
str();
459 void _tweakMax(
int n) {
460 if (_maximum[n] < 0.0) {
461 _maximum[n] *= (1.0 -
EPSILON);
462 }
else if (_maximum[n] > 0.0) {
463 _maximum[n] *= (1.0 +
EPSILON);
Box2I()
Construct an empty box.
afw::table::PointKey< int > dimensions
double getCenterY() const
Extent2I const getDimensions() const
std::string toString() const
void flipLR(int xExtent)
Flip a bounding box about the y-axis given a parent box of extent (xExtent).
bool isEmpty() const
Return true if the box contains no points.
A floating-point coordinate rectangle geometry.
Point2I const getMin() const
Point2I const getEnd() const
A coordinate class intended to represent absolute positions.
Extent2D const getDimensions() const
Point2D const getMin() const
std::string toString() const
Box2I & operator=(Box2I const &)=default
Standard assignment operator.
Relationship invert(Relationship r)
Given the relationship between two sets A and B (i.e.
std::vector< Point2I > getCorners() const
Get the corner points.
Point2I const getMax() const
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...
Point2D const getCenter() const
double getCenterX() const
A base class for image defects.
void grow(int buffer)
Increase the size of the box by the given buffer amount in all directions.
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.
Point2D const getMax() const
std::ostream & operator<<(std::ostream &os, lsst::geom::AffineTransform const &transform)
A coordinate class intended to represent offsets and dimensions.
Extent< int, 2 > Extent2I
bool contains(Point2I const &point) const
Return true if the box contains the point.
bool isEmpty() const
Return true if the box contains no points.
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
Return true if any points in other are also in 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
Point2I const getBegin() const
Extent< double, 2 > Extent2D
bool operator==(Box2I const &other) const
Compare two boxes for equality.
void clip(Box2I const &other)
Shrink this to ensure that other.contains(*this).
bool operator!=(Box2I const &other) const
Compare two boxes for equality.
An integer coordinate rectangle.
void flipTB(int yExtent)
Flip a bounding box about the x-axis given a parent box of extent (yExtent).