24 #ifndef PXR_BASE_GF_RECT2I_H
25 #define PXR_BASE_GF_RECT2I_H
35 #include <hboost/functional/hash.hpp>
70 : _min(min), _max(max)
77 : _min(min), _max(min +
GfVec2i(width-1, height-1))
190 return (_min + _max) / 2;
195 _min += displacement;
196 _max += displacement;
214 return (_max[0] - _min[0]) + 1;
222 return (_max[1] - _min[1]) + 1;
233 GfMax(_min[1], that._min[1])),
235 GfMin(_max[1], that._max[1])));
252 GfMin(_min[1], that._min[1])),
254 GfMax(_max[1], that._max[1])));
265 return ((p[0] >= _min[0]) && (p[0] <= _max[0]) &&
266 (p[1] >= _min[1]) && (p[1] <= _max[1]));
271 hboost::hash_combine(h, r._min);
272 hboost::hash_combine(h, r._max);
278 return r1._min == r2._min && r1._max == r2._max;
void SetMax(const GfVec2i &max)
Sets the max corner of the rectangle.
GfRect2i(const GfVec2i &min, const GfVec2i &max)
Constructs a rectangle with min and max corners.
const GfVec2i & GetMax() const
Returns the max corner of the rectangle.
GfRect2i operator+=(const GfRect2i &that)
unsigned long GetArea() const
Return the area of the rectangle.
friend size_t hash_value(const GfRect2i &r)
friend bool operator!=(const GfRect2i &r1, const GfRect2i &r2)
Returns true if r1 and r2 are different.
void Translate(const GfVec2i &displacement)
Move the rectangle by displ.
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
GfRect2i Intersect(const GfRect2i &that) const
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
GfRect2i()
Constructs an empty rectangle.
GfVec2i GetCenter() const
Returns the center point of the rectangle.
GLint GLsizei GLsizei height
GF_API std::ostream & operator<<(std::ostream &, const GfRect2i &)
GLfloat GLfloat GLfloat GLfloat h
GfRect2i Union(const GfRect2i &that) const
GfVec2i GetSize() const
Returns the size of the rectangle as a vector (width,height).
friend GfRect2i operator+(const GfRect2i r1, const GfRect2i &r2)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
GfRect2i GetUnion(const GfRect2i &that) const
Computes the union of two rectangles.
bool IsValid() const
Return true if the rectangle is valid (equivalently, not empty).
bool Contains(const GfVec2i &p) const
Returns true if the specified point in the rectangle.
void SetMaxX(int x)
Set the X value of the max corner.
#define PXR_NAMESPACE_CLOSE_SCOPE
friend bool operator==(const GfRect2i &r1, const GfRect2i &r2)
Returns true if r1 and r2 are equal.
const GfVec2i & GetMin() const
Returns the min corner of the rectangle.
GfRect2i GetIntersection(const GfRect2i &that) const
Computes the intersection of two rectangles.
void SetMaxY(int y)
Set the Y value of the max corner.
GF_API GfRect2i GetNormalized() const
void SetMin(const GfVec2i &min)
Sets the min corner of the rectangle.
GfRect2i(const GfVec2i &min, int width, int height)
int GetMaxY() const
Return the Y value of the max corner.