28 #ifndef PXR_BASE_GF_RANGE1D_H 29 #define PXR_BASE_GF_RANGE1D_H 36 #include "pxr/base/gf/api.h" 37 #include "pxr/base/gf/traits.h" 44 PXR_NAMESPACE_OPEN_SCOPE
68 static const size_t dimension = 1;
85 : _min(min), _max(max)
95 double GetMin()
const {
return _min; }
98 double GetMax()
const {
return _max; }
101 double GetSize()
const {
return _max - _min; }
107 return static_cast<ScalarType>(0.5) * _min
108 + static_cast<ScalarType>(0.5) * _max;
133 return (point >= _min && point <= _max);
162 return (range._max < _min || range._min > _max);
168 _FindMin(res._min,b._min);
169 _FindMax(res._max,b._max);
175 _FindMin(_min,b._min);
176 _FindMax(_max,b._max);
208 _FindMax(res._min,b._min);
209 _FindMin(res._max,b._max);
222 _FindMax(_min,b._min);
223 _FindMin(_max,b._max);
263 return *
this *= (1.0 / m);
268 return GfRange1d(_min + b._min, _max + b._max);
274 return GfRange1d(_min - b._max, _max - b._min);
293 return r * (1.0 / m);
303 return (_min == b._min && _max == b._max);
306 bool operator !=(
const GfRange1d &b)
const {
307 return !(*
this == b);
315 GF_API
inline bool operator !=(
const GfRange1f& other)
const;
327 static void _FindMin(
double &dest,
double point) {
328 if (point < dest) dest = point;
332 static void _FindMax(
double &dest,
double point) {
333 if (point > dest) dest = point;
341 PXR_NAMESPACE_CLOSE_SCOPE
343 PXR_NAMESPACE_OPEN_SCOPE
347 return _min == double(other.
GetMin()) &&
348 _max ==
double(other.
GetMax());
352 GfRange1d::operator !=(
const GfRange1f& other)
const {
353 return !(*
this == other);
357 PXR_NAMESPACE_CLOSE_SCOPE
359 #endif // PXR_BASE_GF_RANGE1D_H void SetEmpty()
Sets the range to an empty interval.
GfRange1d & operator/=(double m)
unary division.
const GfRange1d & Union(const GfRange1d &b)
Extend this to include b.
double MinMaxType
Helper typedef.
const GfRange1d & UnionWith(const GfRange1d &b)
Extend this to include b.
bool Contains(double point) const
Returns true if the point is located inside the range.
double GetSize() const
Returns the size of the range.
friend size_t hash_value(const GfRange1d &r)
hash.
friend GfRange1d operator *(double m, const GfRange1d &r)
scalar multiply.
Basic type: 1-dimensional floating point range.
bool IsEmpty() const
Returns whether the range is empty (max < min).
GF_API std::ostream & operator<<(std::ostream &, GfRange1d const &)
Output a GfRange1d.
const GfRange1d & IntersectWith(const GfRange1d &b)
Modifies this range to hold its intersection with b and returns the result.
A metafunction with a static const bool member 'value' that is true for GfRange types and false for a...
bool Contains(const GfRange1d &range) const
Returns true if the range is located entirely inside the range.
GfRange1d & operator *=(double m)
unary multiply.
void ExtendBy(const GfRange1d &range)
Modifies the range if necessary to surround the given range.
float GetMax() const
Returns the maximum value of the range.
float GetMin() const
Returns the minimum value of the range.
static size_t Combine(Args &&... args)
Produce a hash code by combining the hash codes of several objects.
GfRange1d operator+(const GfRange1d &b) const
binary sum.
const GfRange1d & Intersection(const GfRange1d &b)
Modifies this range to hold its intersection with b and returns the result.
bool IsOutside(const GfRange1d &range) const
Returns true if the range is located entirely outside the range.
GF_API double GetDistanceSquared(double p) const
Compute the squared distance from a point to the range.
Basic type: 1-dimensional floating point range.
bool operator==(const GfRange1d &b) const
The min and max points must match exactly for equality.
static GfRange1d Union(const GfRange1d &a, const GfRange1d &b)
Returns the smallest GfRange1d which contains both a and b.
friend GfRange1d operator *(const GfRange1d &r, double m)
scalar multiply.
void ExtendBy(double point)
Modifies the range if necessary to surround the given value.
double GetMax() const
Returns the maximum value of the range.
double GetMidpoint() const
Returns the midpoint of the range, that is, 0.5*(min+max).
double GetMin() const
Returns the minimum value of the range.
GfRange1d operator -(const GfRange1d &b) const
binary difference.
static GfRange1d GetUnion(const GfRange1d &a, const GfRange1d &b)
Returns the smallest GfRange1d which contains both a and b.
static GfRange1d Intersection(const GfRange1d &a, const GfRange1d &b)
Returns a GfRange1d that describes the intersection of a and b.
friend GfRange1d operator/(const GfRange1d &r, double m)
scalar divide.
void SetMax(double max)
Sets the maximum value of the range.
static GfRange1d GetIntersection(const GfRange1d &a, const GfRange1d &b)
Returns a GfRange1d that describes the intersection of a and b.
GfRange1d & operator -=(const GfRange1d &b)
unary difference.
GfRange1d & operator+=(const GfRange1d &b)
unary sum.
bool IsInside(const GfRange1d &range) const
Returns true if the range is located entirely inside the range.
const GfRange1d & UnionWith(double b)
Extend this to include b.
bool IsInside(double point) const
Returns true if the point is located inside the range.
GfRange1d(double min, double max)
This constructor initializes the minimum and maximum points.
const GfRange1d & Union(double b)
Extend this to include b.
void SetMin(double min)
Sets the minimum value of the range.
GfRange1d()
The default constructor creates an empty range.