31 #include "pxr/base/gf/math.h"
32 #include "pxr/base/gf/vec2i.h"
33 #include "pxr/base/gf/api.h"
35 #include <boost/functional/hash.hpp>
39 PXR_NAMESPACE_OPEN_SCOPE
75 : _lower(topLeft), _higher(bottomRight)
82 : _lower(topLeft), _higher(topLeft +
GfVec2i(width-1, height-1))
189 return (_lower + _higher) / 2;
194 _lower += displacement;
195 _higher += displacement;
212 return (_higher[0] - _lower[0]) + 1;
219 return (_higher[1] - _lower[1]) + 1;
230 GfMax(_lower[1], that._lower[1])),
232 GfMin(_higher[1], that._higher[1])));
249 GfMin(_lower[1], that._lower[1])),
251 GfMax(_higher[1], that._higher[1])));
262 return ((p[0] >= _lower[0]) && (p[0] <= _higher[0]) &&
263 (p[1] >= _lower[1]) && (p[1] <= _higher[1]));
266 friend inline size_t hash_value(
const GfRect2i &r) {
268 boost::hash_combine(h, r._lower);
269 boost::hash_combine(h, r._higher);
275 return r1._lower == r2._lower && r1._higher == r2._higher;
304 PXR_NAMESPACE_CLOSE_SCOPE
Basic type for a vector of 2 int components.
A 2D rectangle with integer coordinates for windowing operations.
GfRect2i()
Constructs an empty rectangle.
void SetLower(const GfVec2i &lower)
Sets the lower corner of the rectangle.
int GetLeft() const
Return the X value of the left edge.
GF_API GfRect2i GetNormalized() const
Returns a normalized rectangle, i.e.
bool IsValid() const
Return true if the rectangle is valid (equivalently, not empty).
unsigned long GetArea() const
Return the area of the rectangle.
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.
int GetTop() const
Return the Y value of the top edge.
GfRect2i GetUnion(const GfRect2i &that) const
Computes the union of two rectangles.
bool IsEmpty() const
Returns true if the rectangle is empty.
GfRect2i(const GfVec2i &topLeft, int width, int height)
Constructs a rectangle with topLeft as the top left corner and with the indicated width and height...
GfRect2i Intersect(const GfRect2i &that) const
Computes the intersection of two rectangles.
int GetBottom() const
Return the Y value of the bottom edge.
void SetLeft(int x)
Set the X value of the left edge.
int GetHeight() const
Returns the height of the rectangle.
GfRect2i GetIntersection(const GfRect2i &that) const
Computes the intersection of two rectangles.
GfRect2i operator+=(const GfRect2i &that)
Computes the union of two rectangles.
bool Contains(const GfVec2i &p) const
Returns true if the specified point in the rectangle.
T GfMax(T a1, T a2)
Returns the largest of the given values.
void SetRight(int x)
Set the X value of the right edge.
const GfVec2i & GetHigher() const
Returns the upper corner of the rectangle.
bool IsNull() const
Returns true if the rectangle is a null rectangle.
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
void SetBottom(int y)
Set the Y value of the bottom edge.
GfVec2i GetCenter() const
Returns the center point of the rectangle.
GfRect2i Union(const GfRect2i &that) const
Computes the union of two rectangles.
GfVec2i GetSize() const
Returns the size of the rectangle as a vector (width,height).
friend bool operator==(const GfRect2i &r1, const GfRect2i &r2)
Returns true if r1 and r2 are equal.
void SetTop(int y)
Set the Y value of the top edge.
const GfVec2i & GetLower() const
Returns the lower corner of the rectangle.
void SetHigher(const GfVec2i &higher)
Sets the upper corner of the rectangle.
void Translate(const GfVec2i &displacement)
Move the rectangle by displ.
int GetWidth() const
Returns the width of the rectangle.
int GetRight() const
Return the X value of the right edge.
GfRect2i(const GfVec2i &topLeft, const GfVec2i &bottomRight)
Constructs a rectangle with topLeft as the top left corner and bottomRight as the bottom right corner...