24 #ifndef PXR_BASE_GF_RECT2I_H 25 #define PXR_BASE_GF_RECT2I_H 33 #include "pxr/base/gf/api.h" 38 PXR_NAMESPACE_OPEN_SCOPE
69 : _min(min), _max(max)
76 : _min(min), _max(min +
GfVec2i(width-1, height-1))
189 return (_min + _max) / 2;
194 _min += displacement;
195 _max += displacement;
213 return (_max[0] - _min[0]) + 1;
221 return (_max[1] - _min[1]) + 1;
232 GfMax(_min[1], that._min[1])),
234 GfMin(_max[1], that._max[1])));
251 GfMin(_min[1], that._min[1])),
253 GfMax(_max[1], that._max[1])));
264 return ((p[0] >= _min[0]) && (p[0] <= _max[0]) &&
265 (p[1] >= _min[1]) && (p[1] <= _max[1]));
268 friend inline size_t hash_value(
const GfRect2i &r) {
274 return r1._min == r2._min && r1._max == r2._max;
303 PXR_NAMESPACE_CLOSE_SCOPE
GfRect2i(const GfVec2i &min, const GfVec2i &max)
Constructs a rectangle with min and max corners.
void SetMax(const GfVec2i &max)
Sets the max corner of the rectangle.
Basic type for a vector of 2 int components.
int GetWidth() const
Returns the width of the rectangle.
bool IsValid() const
Return true if the rectangle is valid (equivalently, not empty).
int GetMinX() const
Return the X value of min corner.
Assorted mathematical utility functions.
const GfVec2i & GetMax() const
Returns the max corner of the rectangle.
A 2D rectangle with integer coordinates.
int GetMaxY() const
Return the Y value of the max corner.
void SetMaxX(int x)
Set the X value of the max corner.
GfRect2i()
Constructs an empty rectangle.
GF_API GfRect2i GetNormalized() const
Returns a normalized rectangle, i.e.
friend bool operator!=(const GfRect2i &r1, const GfRect2i &r2)
Returns true if r1 and r2 are different.
T GfMin(T a1, T a2)
Returns the smallest of the given values.
void SetMaxY(int y)
Set the Y value of the max corner.
void SetMin(const GfVec2i &min)
Sets the min corner of the rectangle.
int GetMaxX() const
Return the X value of the max corner.
static size_t Combine(Args &&... args)
Produce a hash code by combining the hash codes of several objects.
GfRect2i(const GfVec2i &min, int width, int height)
Constructs a rectangle with min corner and the indicated width and height.
const GfVec2i & GetMin() const
Returns the min corner of the rectangle.
bool IsNull() const
Returns true if the rectangle is a null rectangle.
int GetMinY() const
Return the Y value of the min corner.
GfRect2i operator+=(const GfRect2i &that)
Computes the union of two rectangles.
T GfMax(T a1, T a2)
Returns the largest of the given values.
GfVec2i GetSize() const
Returns the size of the rectangle as a vector (width,height).
void SetMinY(int y)
Set the Y value of the min corner.
GF_API std::ostream & operator<<(std::ostream &, const GfRect2i &)
Output a GfRect2i using the format [(x y):(x y)].
unsigned long GetArea() const
Return the area of the rectangle.
GfRect2i Union(const GfRect2i &that) const
Computes the union of two rectangles.
friend bool operator==(const GfRect2i &r1, const GfRect2i &r2)
Returns true if r1 and r2 are equal.
void SetMinX(int x)
Set the X value of the min corner.
bool IsEmpty() const
Returns true if the rectangle is empty.
void Translate(const GfVec2i &displacement)
Move the rectangle by displ.
GfRect2i GetIntersection(const GfRect2i &that) const
Computes the intersection of two rectangles.
GfRect2i GetUnion(const GfRect2i &that) const
Computes the union of two rectangles.
GfRect2i Intersect(const GfRect2i &that) const
Computes the intersection of two rectangles.
GfVec2i GetCenter() const
Returns the center point of the rectangle.
int GetHeight() const
Returns the height of the rectangle.
bool Contains(const GfVec2i &p) const
Returns true if the specified point in the rectangle.