11#ifndef PXR_BASE_GF_RANGE1F_H
12#define PXR_BASE_GF_RANGE1F_H
19#include "pxr/base/gf/api.h"
20#include "pxr/base/gf/traits.h"
27PXR_NAMESPACE_OPEN_SCOPE
51 static const size_t dimension = 1;
68 : _min(min), _max(max)
78 float GetMin()
const {
return _min; }
81 float GetMax()
const {
return _max; }
84 float GetSize()
const {
return _max - _min; }
90 return static_cast<ScalarType
>(0.5) * _min
91 +
static_cast<ScalarType
>(0.5) * _max;
95 void SetMin(
float min) { _min = min; }
98 void SetMax(
float max) { _max = max; }
116 return (point >= _min && point <= _max);
145 return (range._max < _min || range._min > _max);
151 _FindMin(res._min,b._min);
152 _FindMax(res._max,b._max);
158 _FindMin(_min,b._min);
159 _FindMax(_max,b._max);
191 _FindMax(res._min,b._min);
192 _FindMin(res._max,b._max);
205 _FindMax(_min,b._min);
206 _FindMin(_max,b._max);
246 return *
this *= (1.0 / m);
251 return GfRange1f(_min + b._min, _max + b._max);
257 return GfRange1f(_min - b._max, _max - b._min);
276 return r * (1.0 / m);
286 return (_min == b._min && _max == b._max);
289 bool operator !=(
const GfRange1f &b)
const {
290 return !(*
this == b);
298 GF_API
inline bool operator !=(
const GfRange1d& other)
const;
310 static void _FindMin(
float &dest,
float point) {
311 if (point < dest) dest = point;
315 static void _FindMax(
float &dest,
float point) {
316 if (point > dest) dest = point;
324PXR_NAMESPACE_CLOSE_SCOPE
326PXR_NAMESPACE_OPEN_SCOPE
330 return _min == float(other.
GetMin()) &&
331 _max == float(other.
GetMax());
335GfRange1f::operator !=(
const GfRange1d& other)
const {
336 return !(*
this == other);
340PXR_NAMESPACE_CLOSE_SCOPE
Basic type: 1-dimensional floating point range.
double GetMax() const
Returns the maximum value of the range.
double GetMin() const
Returns the minimum value of the range.
Basic type: 1-dimensional floating point range.
friend GfRange1f operator*(double m, const GfRange1f &r)
scalar multiply.
GfRange1f operator-(const GfRange1f &b) const
binary difference.
const GfRange1f & Intersection(const GfRange1f &b)
Modifies this range to hold its intersection with b and returns the result.
bool IsInside(float point) const
Returns true if the point is located inside the range.
void ExtendBy(const GfRange1f &range)
Modifies the range if necessary to surround the given range.
GfRange1f()
The default constructor creates an empty range.
GfRange1f & operator/=(double m)
unary division.
GF_API double GetDistanceSquared(float p) const
Compute the squared distance from a point to the range.
GfRange1f & operator+=(const GfRange1f &b)
unary sum.
const GfRange1f & Union(const GfRange1f &b)
Extend this to include b.
bool Contains(const GfRange1f &range) const
Returns true if the range is located entirely inside the range.
float GetMidpoint() const
Returns the midpoint of the range, that is, 0.5*(min+max).
bool IsInside(const GfRange1f &range) const
Returns true if the range is located entirely inside the range.
float MinMaxType
Helper typedef.
const GfRange1f & UnionWith(const GfRange1f &b)
Extend this to include b.
void SetMax(float max)
Sets the maximum value of the range.
GfRange1f & operator*=(double m)
unary multiply.
void SetMin(float min)
Sets the minimum value of the range.
static GfRange1f Union(const GfRange1f &a, const GfRange1f &b)
Returns the smallest GfRange1f which contains both a and b.
float GetMax() const
Returns the maximum value of the range.
friend size_t hash_value(const GfRange1f &r)
hash.
bool Contains(float point) const
Returns true if the point is located inside the range.
bool IsEmpty() const
Returns whether the range is empty (max < min).
float GetMin() const
Returns the minimum value of the range.
GfRange1f & operator-=(const GfRange1f &b)
unary difference.
bool IsOutside(const GfRange1f &range) const
Returns true if the range is located entirely outside the range.
void SetEmpty()
Sets the range to an empty interval.
GF_API GfRange1f(class GfRange1d const &other)
Construct from GfRange1d.
bool operator==(const GfRange1f &b) const
The min and max points must match exactly for equality.
static GfRange1f GetIntersection(const GfRange1f &a, const GfRange1f &b)
Returns a GfRange1f that describes the intersection of a and b.
GfRange1f(float min, float max)
This constructor initializes the minimum and maximum points.
const GfRange1f & Union(float b)
Extend this to include b.
GfRange1f operator+(const GfRange1f &b) const
binary sum.
const GfRange1f & IntersectWith(const GfRange1f &b)
Modifies this range to hold its intersection with b and returns the result.
const GfRange1f & UnionWith(float b)
Extend this to include b.
float GetSize() const
Returns the size of the range.
static GfRange1f GetUnion(const GfRange1f &a, const GfRange1f &b)
Returns the smallest GfRange1f which contains both a and b.
friend GfRange1f operator/(const GfRange1f &r, double m)
scalar divide.
static GfRange1f Intersection(const GfRange1f &a, const GfRange1f &b)
Returns a GfRange1f that describes the intersection of a and b.
void ExtendBy(float point)
Modifies the range if necessary to surround the given value.
static size_t Combine(Args &&... args)
Produce a hash code by combining the hash codes of several objects.
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
A metafunction with a static const bool member 'value' that is true for GfRange types and false for a...