usdrt::GfRect2i

Defined in usdrt/gf/rect.h

struct usdrt::GfRect2i

Public Types

using MinMaxType = GfVec2i

Helper typedef.

using ScalarType = MinMaxType::ScalarType

Public Functions

GfRect2i() = default
constexpr GfRect2i(const GfRect2i&) = default
inline constexpr GfRect2i(const GfVec2i &min, const GfVec2i &max)

Constructs a rectangle with min and max corners.

inline GfRect2i(const GfVec2i &min, int width, int height)

Constructs a rectangle with min corner and the indicated width and height.

inline bool IsNull() const

Returns true if the rectangle is a null rectangle.

A null rectangle has both the width and the height set to 0, that is

GetMaxX() == GetMinX() - 1
and
GetMaxY() == GetMinY() - 1
Remember that if GetMinX() and GetMaxX() return the same value then the rectangle has width 1, and similarly for the height.

A null rectangle is both empty, and not valid.

inline bool IsEmpty() const

Returns true if the rectangle is empty.

An empty rectangle has one or both of its min coordinates strictly greater than the corresponding max coordinate.

An empty rectangle is not valid.

inline bool IsValid() const

Return true if the rectangle is valid (equivalently, not empty).

inline GfRect2i GetNormalized() const

Returns a normalized rectangle, i.e. one that has a non-negative width and height.

GetNormalized() swaps the min and max x-coordinates to ensure a non-negative width, and similarly for the y-coordinates.

inline const GfVec2i &GetMin() const

Returns the min corner of the rectangle.

inline const GfVec2i &GetMax() const

Returns the max corner of the rectangle.

inline int GetMinX() const

Return the X value of min corner.

inline void SetMinX(int x)

Set the X value of the min corner.

inline int GetMaxX() const

Return the X value of the max corner.

inline void SetMaxX(int x)

Set the X value of the max corner.

inline int GetMinY() const

Return the Y value of the min corner.

inline void SetMinY(int y)

Set the Y value of the min corner.

inline int GetMaxY() const

Return the Y value of the max corner.

inline void SetMaxY(int y)

Set the Y value of the max corner.

inline void SetMin(const GfVec2i &min)

Sets the min corner of the rectangle.

inline void SetMax(const GfVec2i &max)

Sets the max corner of the rectangle.

inline GfVec2i GetCenter() const

Returns the center point of the rectangle.

inline void Translate(const GfVec2i &displacement)

Move the rectangle by displ.

inline unsigned long GetArea() const

Return the area of the rectangle.

inline GfVec2i GetSize() const

Returns the size of the rectangle as a vector (width,height).

inline int GetWidth() const

Returns the width of the rectangle.

Note

If the min and max x-coordinates are coincident, the width is one.

inline int GetHeight() const

Returns the height of the rectangle.

Note

If the min and max y-coordinates are coincident, the height is one.

inline GfRect2i GetIntersection(const GfRect2i &that) const

Computes the intersection of two rectangles.

inline GfRect2i Intersect(const GfRect2i &that) const

Computes the intersection of two rectangles.

Deprecated:

Use GetIntersection() instead

inline GfRect2i GetUnion(const GfRect2i &that) const

Computes the union of two rectangles.

inline GfRect2i Union(const GfRect2i &that) const

Computes the union of two rectangles.

Deprecated:

Use GetUnion() instead.

inline bool Contains(const GfVec2i &p) const

Returns true if the specified point in the rectangle.

inline GfRect2i operator+=(const GfRect2i &that)

Computes the union of two rectangles.

See also

GetUnion()

Public Static Attributes

static const size_t dimension = MinMaxType::dimension

Friends

inline friend bool operator==(const GfRect2i &r1, const GfRect2i &r2)

Returns true if r1 and r2 are equal.

inline friend bool operator!=(const GfRect2i &r1, const GfRect2i &r2)

Returns true if r1 and r2 are different.

inline friend GfRect2i operator+(const GfRect2i r1, const GfRect2i &r2)