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