28 #ifndef PXR_BASE_GF_RANGE2D_H 29 #define PXR_BASE_GF_RANGE2D_H 36 #include "pxr/base/gf/api.h" 39 #include "pxr/base/gf/traits.h" 46 PXR_NAMESPACE_OPEN_SCOPE
70 static const size_t dimension = GfVec2d::dimension;
76 _min[0] = _min[1] = FLT_MAX;
77 _max[0] = _max[1] = -FLT_MAX;
87 : _min(min), _max(max)
109 return static_cast<ScalarType>(0.5) * _min
110 + static_cast<ScalarType>(0.5) * _max;
121 return _min[0] > _max[0] || _min[1] > _max[1];
135 return (point[0] >= _min[0] && point[0] <= _max[0]
136 && point[1] >= _min[1] && point[1] <= _max[1]);
165 return ((range._max[0] < _min[0] || range._min[0] > _max[0])
166 || (range._max[1] < _min[1] || range._min[1] > _max[1]));
172 _FindMin(res._min,b._min);
173 _FindMax(res._max,b._max);
179 _FindMin(_min,b._min);
180 _FindMax(_max,b._max);
212 _FindMax(res._min,b._min);
213 _FindMin(res._max,b._max);
226 _FindMax(_min,b._min);
227 _FindMin(_max,b._max);
267 return *
this *= (1.0 / m);
272 return GfRange2d(_min + b._min, _max + b._max);
278 return GfRange2d(_min - b._max, _max - b._min);
297 return r * (1.0 / m);
307 return (_min == b._min && _max == b._max);
310 bool operator !=(
const GfRange2d &b)
const {
311 return !(*
this == b);
319 GF_API
inline bool operator !=(
const GfRange2f& other)
const;
345 if (point[0] < dest[0]) dest[0] = point[0];
346 if (point[1] < dest[1]) dest[1] = point[1];
351 if (point[0] > dest[0]) dest[0] = point[0];
352 if (point[1] > dest[1]) dest[1] = point[1];
360 PXR_NAMESPACE_CLOSE_SCOPE
362 PXR_NAMESPACE_OPEN_SCOPE
371 GfRange2d::operator !=(
const GfRange2f& other)
const {
372 return !(*
this == other);
376 PXR_NAMESPACE_CLOSE_SCOPE
378 #endif // PXR_BASE_GF_RANGE2D_H bool Contains(const GfVec2d &point) const
Returns true if the point is located inside the range.
GfRange2d()
The default constructor creates an empty range.
static GF_API const GfRange2d UnitSquare
The unit square.
const GfRange2d & UnionWith(const GfRange2d &b)
Extend this to include b.
void ExtendBy(const GfVec2d &point)
Modifies the range if necessary to surround the given value.
static GfRange2d GetUnion(const GfRange2d &a, const GfRange2d &b)
Returns the smallest GfRange2d which contains both a and b.
const GfVec2d & GetMax() const
Returns the maximum value of the range.
GfVec2d GetSize() const
Returns the size of the range.
const GfRange2d & UnionWith(const GfVec2d &b)
Extend this to include b.
friend GfRange2d operator *(const GfRange2d &r, double m)
scalar multiply.
A metafunction with a static const bool member 'value' that is true for GfRange types and false for a...
GF_API std::ostream & operator<<(std::ostream &, GfRange2d const &)
Output a GfRange2d.
bool Contains(const GfRange2d &range) const
Returns true if the range is located entirely inside the range.
GfVec2d GetMidpoint() const
Returns the midpoint of the range, that is, 0.5*(min+max).
GfRange2d & operator/=(double m)
unary division.
GF_API double GetDistanceSquared(const GfVec2d &p) const
Compute the squared distance from a point to the range.
GF_API GfVec2d GetCorner(size_t i) const
Returns the ith corner of the range, in the following order: SW, SE, NW, NE.
Basic type for a vector of 2 double components.
GfVec2d MinMaxType
Helper typedef.
static size_t Combine(Args &&... args)
Produce a hash code by combining the hash codes of several objects.
const GfVec2f & GetMin() const
Returns the minimum value of the range.
Basic type: 2-dimensional floating point range.
const GfVec2d & GetMin() const
Returns the minimum value of the range.
void SetEmpty()
Sets the range to an empty interval.
friend GfRange2d operator *(double m, const GfRange2d &r)
scalar multiply.
friend size_t hash_value(const GfRange2d &r)
hash.
GfRange2d & operator *=(double m)
unary multiply.
bool IsEmpty() const
Returns whether the range is empty (max < min).
static GfRange2d GetIntersection(const GfRange2d &a, const GfRange2d &b)
Returns a GfRange2d that describes the intersection of a and b.
GfRange2d operator -(const GfRange2d &b) const
binary difference.
GfRange2d & operator -=(const GfRange2d &b)
unary difference.
const GfRange2d & Union(const GfRange2d &b)
Extend this to include b.
bool IsOutside(const GfRange2d &range) const
Returns true if the range is located entirely outside the range.
GfRange2d(const GfVec2d &min, const GfVec2d &max)
This constructor initializes the minimum and maximum points.
GF_API GfRange2d GetQuadrant(size_t i) const
Returns the ith quadrant of the range, in the following order: SW, SE, NW, NE.
bool IsInside(const GfVec2d &point) const
Returns true if the point is located inside the range.
void ExtendBy(const GfRange2d &range)
Modifies the range if necessary to surround the given range.
const GfRange2d & IntersectWith(const GfRange2d &b)
Modifies this range to hold its intersection with b and returns the result.
GfRange2d operator+(const GfRange2d &b) const
binary sum.
void SetMin(const GfVec2d &min)
Sets the minimum value of the range.
bool IsInside(const GfRange2d &range) const
Returns true if the range is located entirely inside the range.
const GfVec2f & GetMax() const
Returns the maximum value of the range.
const GfRange2d & Union(const GfVec2d &b)
Extend this to include b.
double ScalarType
Scalar element type and dimension.
Basic type: 2-dimensional floating point range.
static GfRange2d Union(const GfRange2d &a, const GfRange2d &b)
Returns the smallest GfRange2d which contains both a and b.
static GfRange2d Intersection(const GfRange2d &a, const GfRange2d &b)
Returns a GfRange2d that describes the intersection of a and b.
void SetMax(const GfVec2d &max)
Sets the maximum value of the range.
friend GfRange2d operator/(const GfRange2d &r, double m)
scalar divide.
bool operator==(const GfRange2d &b) const
The min and max points must match exactly for equality.
GfRange2d & operator+=(const GfRange2d &b)
unary sum.
const GfRange2d & Intersection(const GfRange2d &b)
Modifies this range to hold its intersection with b and returns the result.