lsst.geom  15.0-1-g417ea41+4
Public Types | Public Member Functions | List of all members
lsst::geom::Box2I Class Reference

An integer coordinate rectangle. More...

#include <Box.h>

Public Types

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

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 &)=default
 Standard copy constructor. More...
 
 Box2I (Box2I &&)=default
 
 ~Box2I ()=default
 
void swap (Box2I &other)
 
Box2Ioperator= (Box2I const &)=default
 Standard assignment operator. More...
 
Box2Ioperator= (Box2I &&)=default
 
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
 Get the corner points. More...
 
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
 

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).

Definition at line 54 of file Box.h.

Member Typedef Documentation

◆ Element

Definition at line 58 of file Box.h.

◆ Extent

Definition at line 57 of file Box.h.

◆ Point

Definition at line 56 of file Box.h.

Member Enumeration Documentation

◆ EdgeHandlingEnum

Enumerator
EXPAND 
SHRINK 

Definition at line 60 of file Box.h.

Constructor & Destructor Documentation

◆ Box2I() [1/6]

lsst::geom::Box2I::Box2I ( )
inline

Construct an empty box.

Definition at line 63 of file Box.h.

◆ Box2I() [2/6]

lsst::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.

Definition at line 30 of file Box.cc.

◆ Box2I() [3/6]

lsst::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.

Definition at line 46 of file Box.cc.

◆ Box2I() [4/6]

lsst::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.

Definition at line 68 of file Box.cc.

◆ Box2I() [5/6]

lsst::geom::Box2I::Box2I ( Box2I const &  )
default

Standard copy constructor.

◆ Box2I() [6/6]

lsst::geom::Box2I::Box2I ( Box2I &&  )
default

◆ ~Box2I()

lsst::geom::Box2I::~Box2I ( )
default

Member Function Documentation

◆ clip()

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

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

Definition at line 177 of file Box.cc.

◆ contains() [1/2]

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

Return true if the box contains the point.

Definition at line 100 of file Box.cc.

◆ contains() [2/2]

bool lsst::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.

Definition at line 104 of file Box.cc.

◆ flipLR()

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

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

Definition at line 126 of file Box.cc.

◆ flipTB()

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

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

Definition at line 133 of file Box.cc.

◆ getArea()

int lsst::geom::Box2I::getArea ( ) const
inline

Definition at line 155 of file Box.h.

◆ getBegin()

Point2I const lsst::geom::Box2I::getBegin ( ) const
inline

Definition at line 137 of file Box.h.

◆ getBeginX()

int lsst::geom::Box2I::getBeginX ( ) const
inline

Definition at line 138 of file Box.h.

◆ getBeginY()

int lsst::geom::Box2I::getBeginY ( ) const
inline

Definition at line 139 of file Box.h.

◆ getCorners()

std::vector< Point2I > lsst::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)

Definition at line 209 of file Box.cc.

◆ getDimensions()

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

Definition at line 152 of file Box.h.

◆ getEnd()

Point2I const lsst::geom::Box2I::getEnd ( ) const
inline

Definition at line 141 of file Box.h.

◆ getEndX()

int lsst::geom::Box2I::getEndX ( ) const
inline

Definition at line 142 of file Box.h.

◆ getEndY()

int lsst::geom::Box2I::getEndY ( ) const
inline

Definition at line 143 of file Box.h.

◆ getHeight()

int lsst::geom::Box2I::getHeight ( ) const
inline

Definition at line 154 of file Box.h.

◆ getMax()

Point2I const lsst::geom::Box2I::getMax ( ) const
inline

Definition at line 126 of file Box.h.

◆ getMaxX()

int lsst::geom::Box2I::getMaxX ( ) const
inline

Definition at line 127 of file Box.h.

◆ getMaxY()

int lsst::geom::Box2I::getMaxY ( ) const
inline

Definition at line 128 of file Box.h.

◆ getMin()

Point2I const lsst::geom::Box2I::getMin ( ) const
inline

Definition at line 122 of file Box.h.

◆ getMinX()

int lsst::geom::Box2I::getMinX ( ) const
inline

Definition at line 123 of file Box.h.

◆ getMinY()

int lsst::geom::Box2I::getMinY ( ) const
inline

Definition at line 124 of file Box.h.

◆ getSlices()

ndarray::View< boost::fusion::vector2< ndarray::index::Range, ndarray::index::Range > > lsst::geom::Box2I::getSlices ( ) const

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

Definition at line 95 of file Box.cc.

◆ getWidth()

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

Definition at line 153 of file Box.h.

◆ grow() [1/2]

void lsst::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 187 of file Box.h.

◆ grow() [2/2]

void lsst::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.

Definition at line 114 of file Box.cc.

◆ include() [1/2]

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

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

Definition at line 140 of file Box.cc.

◆ include() [2/2]

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

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

Definition at line 157 of file Box.cc.

◆ isEmpty()

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

Return true if the box contains no points.

Definition at line 162 of file Box.h.

◆ operator!=()

bool lsst::geom::Box2I::operator!= ( Box2I const &  other) const

Compare two boxes for equality.

All empty boxes are equal.

Definition at line 205 of file Box.cc.

◆ operator=() [1/2]

Box2I& lsst::geom::Box2I::operator= ( Box2I const &  )
default

Standard assignment operator.

◆ operator=() [2/2]

Box2I& lsst::geom::Box2I::operator= ( Box2I &&  )
default

◆ operator==()

bool lsst::geom::Box2I::operator== ( Box2I const &  other) const

Compare two boxes for equality.

All empty boxes are equal.

Definition at line 201 of file Box.cc.

◆ overlaps()

bool lsst::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.

Definition at line 109 of file Box.cc.

◆ shift()

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

Shift the position of the box by the given offset.

Definition at line 121 of file Box.cc.

◆ swap()

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

Definition at line 107 of file Box.h.

◆ toString()

std::string lsst::geom::Box2I::toString ( ) const
inline

Definition at line 237 of file Box.h.


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