LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Private Attributes | List of all members
lsst.afw.geom::Box2I Class Reference

An integer coordinate rectangle. More...

#include <Box.h>

Public Types

enum  EdgeHandlingEnum { EXPAND, SHRINK }
 
typedef Point2I Point
 
typedef Extent2I Extent
 

Public Member Functions

 Box2I ()
 Construct an empty box. More...
 
 Box2I (Point2I const &minimum, Point2I const &maximum, bool invert=true)
 Construct a box from its minimum and maximum points. More...
 
 Box2I (Point2I const &minimum, Extent2I const &dimensions, bool invert=true)
 Construct a box from its minimum point and dimensions. More...
 
 Box2I (Box2D const &other, EdgeHandlingEnum edgeHandling=EXPAND)
 Construct an integer box from a floating-point box. More...
 
 Box2I (Box2I const &other)
 Standard copy constructor. More...
 
void swap (Box2I &other)
 
Box2Ioperator= (Box2I const &other)
 Standard assignment operator. More...
 
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. More...
 
bool isEmpty () const
 Return true if the box contains no points. More...
 
bool contains (Point2I const &point) const
 Return true if the box contains the point. More...
 
bool contains (Box2I const &other) const
 Return true if all points contained by other are also contained by this. More...
 
bool overlaps (Box2I const &other) const
 Return true if any points in other are also in this. More...
 
void grow (int buffer)
 Increase the size of the box by the given buffer amount in all directions. More...
 
void grow (Extent2I const &buffer)
 Increase the size of the box by the given buffer amount in each direction. More...
 
void shift (Extent2I const &offset)
 Shift the position of the box by the given offset. More...
 
void flipLR (int xExtent)
 Flip a bounding box about the y-axis given a parent box of extent (xExtent). More...
 
void flipTB (int yExtent)
 Flip a bounding box about the x-axis given a parent box of extent (yExtent). More...
 
void include (Point2I const &point)
 Expand this to ensure that this->contains(point). More...
 
void include (Box2I const &other)
 Expand this to ensure that this->contains(other). More...
 
void clip (Box2I const &other)
 Shrink this to ensure that other.contains(*this). More...
 
bool operator== (Box2I const &other) const
 Compare two boxes for equality. More...
 
bool operator!= (Box2I const &other) const
 Compare two boxes for equality. More...
 
std::vector< Point2IgetCorners () const
 
std::string toString () const
 
Min/Max Accessors

Return the minimum and maximum coordinates of the box (inclusive).

Point2I const getMin () const
 
int getMinX () const
 
int getMinY () const
 
Point2I const getMax () const
 
int getMaxX () const
 
int getMaxY () const
 
Begin/End Accessors

Return STL-style begin (inclusive) and end (exclusive) coordinates for the box.

Point2I const getBegin () const
 
int getBeginX () const
 
int getBeginY () const
 
Point2I const getEnd () const
 
int getEndX () const
 
int getEndY () const
 
Size Accessors

Return the size of the box in pixels.

Extent2I const getDimensions () const
 
int getWidth () const
 
int getHeight () const
 
int getArea () const
 

Private Attributes

Point2I _minimum
 
Extent2I _dimensions
 

Detailed Description

An integer coordinate rectangle.

Box2I is an inclusive box that represents a rectangular region of pixels. A box never has negative dimensions; the empty box is defined to have zero-size dimensions, and is treated as though it does not have a well-defined position (regardless of the return value of getMin() or getMax() for an empty box).

Examples:
image2.cc, maskedImage2.cc, spatialCellExample.cc, testSpatialCell.cc, and testSpatialCell.h.

Definition at line 53 of file Box.h.

Member Typedef Documentation

Definition at line 57 of file Box.h.

Definition at line 56 of file Box.h.

Member Enumeration Documentation

Enumerator
EXPAND 
SHRINK 

Definition at line 59 of file Box.h.

Constructor & Destructor Documentation

lsst.afw.geom::Box2I::Box2I ( )
inline

Construct an empty box.

Definition at line 62 of file Box.h.

62 : _minimum(0), _dimensions(0) {}
Extent2I _dimensions
Definition: Box.h:249
Point2I _minimum
Definition: Box.h:248
lsst.afw.geom::Box2I::Box2I ( Point2I const &  minimum,
Point2I const &  maximum,
bool  invert = true 
)

Construct a box from its minimum and maximum points.

Parameters
[in]minimumMinimum (lower left) coordinate (inclusive).
[in]maximumMaximum (upper right) coordinate (inclusive).
[in]invertIf true (default), swap the minimum and maximum coordinates if minimum > maximum instead of creating an empty box.
lsst.afw.geom::Box2I::Box2I ( Point2I const &  minimum,
Extent2I const &  dimensions,
bool  invert = true 
)

Construct a box from its minimum point and dimensions.

Parameters
[in]minimumMinimum (lower left) coordinate.
[in]dimensionsBox dimensions. If either dimension coordinate is 0, the box will be empty.
[in]invertIf true (default), invert any negative dimensions instead of creating an empty box.
lsst.afw.geom::Box2I::Box2I ( Box2D const &  other,
EdgeHandlingEnum  edgeHandling = EXPAND 
)
explicit

Construct an integer box from a floating-point box.

Floating-point to integer box conversion is based on the concept that a pixel is not an infinitesimal point but rather a square of unit size centered on integer-valued coordinates. Converting a floating-point box to an integer box thus requires a choice on how to handle pixels which are only partially contained by the input floating-point box.

Parameters
[in]otherA floating-point box to convert.
[in]edgeHandlingIf EXPAND, the integer box will contain any pixels that overlap the floating-point box. If SHRINK, the integer box will contain only pixels completely contained by the floating-point box.
lsst.afw.geom::Box2I::Box2I ( Box2I const &  other)
inline

Standard copy constructor.

Definition at line 103 of file Box.h.

103 : _minimum(other._minimum), _dimensions(other._dimensions) {}
Extent2I _dimensions
Definition: Box.h:249
Point2I _minimum
Definition: Box.h:248

Member Function Documentation

void lsst.afw.geom::Box2I::clip ( Box2I const &  other)

Shrink this to ensure that other.contains(*this).

bool lsst.afw.geom::Box2I::contains ( Point2I const &  point) const

Return true if the box contains the point.

bool lsst.afw.geom::Box2I::contains ( Box2I const &  other) const

Return true if all points contained by other are also contained by this.

An empty box is contained by every other box, including other empty boxes.

void lsst.afw.geom::Box2I::flipLR ( int  xExtent)

Flip a bounding box about the y-axis given a parent box of extent (xExtent).

void lsst.afw.geom::Box2I::flipTB ( int  yExtent)

Flip a bounding box about the x-axis given a parent box of extent (yExtent).

int lsst.afw.geom::Box2I::getArea ( ) const
inline
Examples:
spatialCellExample.cc, and testSpatialCell.h.

Definition at line 156 of file Box.h.

156 { return getWidth() * getHeight(); }
int getHeight() const
Definition: Box.h:155
int getWidth() const
Definition: Box.h:154
Point2I const lsst.afw.geom::Box2I::getBegin ( ) const
inline

Definition at line 138 of file Box.h.

138 { return _minimum; }
Point2I _minimum
Definition: Box.h:248
int lsst.afw.geom::Box2I::getBeginX ( ) const
inline

Definition at line 139 of file Box.h.

139 { return _minimum.getX(); }
Point2I _minimum
Definition: Box.h:248
int lsst.afw.geom::Box2I::getBeginY ( ) const
inline

Definition at line 140 of file Box.h.

140 { return _minimum.getY(); }
Point2I _minimum
Definition: Box.h:248
std::vector<Point2I> lsst.afw.geom::Box2I::getCorners ( ) const

Get the corner points

The order is counterclockise, starting from the lower left corner, i.e.: (minX, minY), (maxX, maxY), (maxX, maxX), (minX, maxY)

Extent2I const lsst.afw.geom::Box2I::getDimensions ( ) const
inline

Definition at line 153 of file Box.h.

153 { return _dimensions; }
Extent2I _dimensions
Definition: Box.h:249
Point2I const lsst.afw.geom::Box2I::getEnd ( ) const
inline

Definition at line 142 of file Box.h.

142 { return _minimum + _dimensions; }
Extent2I _dimensions
Definition: Box.h:249
Point2I _minimum
Definition: Box.h:248
int lsst.afw.geom::Box2I::getEndX ( ) const
inline

Definition at line 143 of file Box.h.

143 { return _minimum.getX() + _dimensions.getX(); }
Extent2I _dimensions
Definition: Box.h:249
Point2I _minimum
Definition: Box.h:248
int lsst.afw.geom::Box2I::getEndY ( ) const
inline

Definition at line 144 of file Box.h.

144 { return _minimum.getY() + _dimensions.getY(); }
Extent2I _dimensions
Definition: Box.h:249
Point2I _minimum
Definition: Box.h:248
int lsst.afw.geom::Box2I::getHeight ( ) const
inline

Definition at line 155 of file Box.h.

155 { return _dimensions.getY(); }
Extent2I _dimensions
Definition: Box.h:249
Point2I const lsst.afw.geom::Box2I::getMax ( ) const
inline

Definition at line 127 of file Box.h.

127 { return _minimum + _dimensions - Extent2I(1); }
Extent2I _dimensions
Definition: Box.h:249
Extent< int, 2 > Extent2I
Definition: Extent.h:355
Point2I _minimum
Definition: Box.h:248
int lsst.afw.geom::Box2I::getMaxX ( ) const
inline
Examples:
spatialCellExample.cc.

Definition at line 128 of file Box.h.

128 { return _minimum.getX() + _dimensions.getX() - 1; }
Extent2I _dimensions
Definition: Box.h:249
Point2I _minimum
Definition: Box.h:248
int lsst.afw.geom::Box2I::getMaxY ( ) const
inline
Examples:
spatialCellExample.cc.

Definition at line 129 of file Box.h.

129 { return _minimum.getY() + _dimensions.getY() - 1; }
Extent2I _dimensions
Definition: Box.h:249
Point2I _minimum
Definition: Box.h:248
Point2I const lsst.afw.geom::Box2I::getMin ( ) const
inline

Definition at line 123 of file Box.h.

123 { return _minimum; }
Point2I _minimum
Definition: Box.h:248
int lsst.afw.geom::Box2I::getMinX ( ) const
inline
Examples:
spatialCellExample.cc.

Definition at line 124 of file Box.h.

124 { return _minimum.getX(); }
Point2I _minimum
Definition: Box.h:248
int lsst.afw.geom::Box2I::getMinY ( ) const
inline
Examples:
spatialCellExample.cc.

Definition at line 125 of file Box.h.

125 { return _minimum.getY(); }
Point2I _minimum
Definition: Box.h:248
ndarray::View< boost::fusion::vector2< ndarray::index::Range, ndarray::index::Range > > lsst.afw.geom::Box2I::getSlices ( ) const

Return slices to extract the box's region from an ndarray::Array.

int lsst.afw.geom::Box2I::getWidth ( ) const
inline

Definition at line 154 of file Box.h.

154 { return _dimensions.getX(); }
Extent2I _dimensions
Definition: Box.h:249
void lsst.afw.geom::Box2I::grow ( int  buffer)
inline

Increase the size of the box by the given buffer amount in all directions.

If a negative buffer is passed and the final size of the box is less than or equal to zero, the box will be made empty.

Definition at line 193 of file Box.h.

193 { grow(Extent2I(buffer)); }
void grow(int buffer)
Increase the size of the box by the given buffer amount in all directions.
Definition: Box.h:193
Extent< int, 2 > Extent2I
Definition: Extent.h:355
void lsst.afw.geom::Box2I::grow ( Extent2I const &  buffer)

Increase the size of the box by the given buffer amount in each direction.

If a negative buffer is passed and the final size of the box is less than or equal to zero, the box will be made empty.

void lsst.afw.geom::Box2I::include ( Point2I const &  point)

Expand this to ensure that this->contains(point).

void lsst.afw.geom::Box2I::include ( Box2I const &  other)

Expand this to ensure that this->contains(other).

bool lsst.afw.geom::Box2I::isEmpty ( ) const
inline

Return true if the box contains no points.

Definition at line 166 of file Box.h.

166  {
167  return _dimensions.getX() == 0 && _dimensions.getY() == 0;
168  }
Extent2I _dimensions
Definition: Box.h:249
bool lsst.afw.geom::Box2I::operator!= ( Box2I const &  other) const

Compare two boxes for equality.

All empty boxes are equal.

Box2I& lsst.afw.geom::Box2I::operator= ( Box2I const &  other)
inline

Standard assignment operator.

Definition at line 111 of file Box.h.

111  {
112  _minimum = other._minimum;
113  _dimensions = other._dimensions;
114  return *this;
115  }
Extent2I _dimensions
Definition: Box.h:249
Point2I _minimum
Definition: Box.h:248
bool lsst.afw.geom::Box2I::operator== ( Box2I const &  other) const

Compare two boxes for equality.

All empty boxes are equal.

bool lsst.afw.geom::Box2I::overlaps ( Box2I const &  other) const

Return true if any points in other are also in this.

Any overlap operation involving an empty box returns false.

void lsst.afw.geom::Box2I::shift ( Extent2I const &  offset)

Shift the position of the box by the given offset.

void lsst.afw.geom::Box2I::swap ( Box2I other)
inline

Definition at line 105 of file Box.h.

105  {
106  _minimum.swap(other._minimum);
107  _dimensions.swap(other._dimensions);
108  }
void swap(Point &other)
Definition: Point.h:174
void swap(Extent &other)
Definition: Extent.h:213
Extent2I _dimensions
Definition: Box.h:249
Point2I _minimum
Definition: Box.h:248
std::string lsst.afw.geom::Box2I::toString ( void  ) const
inline

Definition at line 243 of file Box.h.

243  {
244  return (boost::format("Box2I(%s,%s)") % _minimum.toString() % _dimensions.toString()).str();
245  }
Extent2I _dimensions
Definition: Box.h:249
std::string toString() const
Definition: Extent.h:155
Point2I _minimum
Definition: Box.h:248
std::string toString() const
Definition: Point.h:123

Member Data Documentation

Extent2I lsst.afw.geom::Box2I::_dimensions
private

Definition at line 249 of file Box.h.

Point2I lsst.afw.geom::Box2I::_minimum
private

Definition at line 248 of file Box.h.


The documentation for this class was generated from the following file: