24 #ifndef PXR_BASE_GF_INTERVAL_H
25 #define PXR_BASE_GF_INTERVAL_H
69 bool minClosed=
true,
bool maxClosed=
true) :
78 return _min == rhs._min && _max == rhs._max;
83 return !(*
this == rhs);
90 return _min < rhs._min;
94 return _max < rhs._max;
109 double GetMin()
const {
return _min.value; }
112 double GetMax()
const {
return _max.value; }
116 _min = _Bound(v, _min.closed);
121 _min = _Bound(v, minClosed);
126 _max = _Bound(v, _max.closed);
131 _max = _Bound(v, maxClosed);
148 return (_max.value != -std::numeric_limits<double>::infinity()
149 && _max.value != std::numeric_limits<double>::infinity());
154 return (_min.value != -std::numeric_limits<double>::infinity()
155 && _min.value != std::numeric_limits<double>::infinity());
165 return (_min.value > _max.value) ||
166 ((_min.value == _max.value)
167 && (! _min.closed || !_max.closed));
173 return GfMax( 0.0, _max.value - _min.value );
182 return ((d > _min.value) || (d == _min.value && _min.closed))
183 && ((d < _max.value) || (d == _max.value && _max.closed));
193 return (*
this & i) == i;
213 if (_min.value < rhs._min.value)
215 else if (_min.value == rhs._min.value)
216 _min.closed &= rhs._min.closed;
219 if (_max.value > rhs._max.value)
221 else if (_max.value == rhs._max.value)
222 _max.closed &= rhs._max.closed;
235 if (_min.value > rhs._min.value)
237 else if (_min.value == rhs._min.value)
238 _min.closed |= rhs._min.closed;
241 if (_max.value < rhs._max.value)
243 else if (_max.value == rhs._max.value)
244 _max.closed |= rhs._max.closed;
252 _min.value += rhs._min.value;
253 _max.value += rhs._max.value;
254 _min.closed &= rhs._min.closed;
255 _max.closed &= rhs._max.closed;
262 return *
this += -rhs;
267 return GfInterval(-_max.value, -_min.value, _max.closed, _min.closed);
272 const _Bound
a = _min * rhs._min;
273 const _Bound
b = _min * rhs._max;
274 const _Bound
c = _max * rhs._min;
275 const _Bound d = _max * rhs._max;
276 _max = _Max( _Max(a,b), _Max(c,d) );
277 _min = _Min( _Min(a,b), _Min(c,d) );
290 return !(rhs < *
this);
296 return !(*
this < rhs);
343 return GfInterval( -std::numeric_limits<double>::infinity(),
344 std::numeric_limits<double>::infinity(),
357 _Bound(
double val,
bool isClosed) :
363 if (
value == -std::numeric_limits<double>::infinity() ||
364 value == std::numeric_limits<double>::infinity()) {
370 return value == rhs.value && closed == rhs.closed;
374 return !(*
this == rhs);
377 bool operator<(
const _Bound &rhs)
const {
378 return value < rhs.value || (
value == rhs.value && closed && !rhs.closed);
386 _Bound
operator*(
const _Bound &rhs)
const {
387 return _Bound(
value * rhs.value, closed & rhs.closed );
395 inline static const _Bound &
396 _Min(
const _Bound &
a,
const _Bound &
b ) {
397 return (a.value < b.value
398 || ((a.value == b.value) && a.closed && !b.closed)) ?
403 inline static const _Bound &
404 _Max(
const _Bound &a,
const _Bound &b ) {
405 return (a.value < b.value
406 || ((a.value == b.value) && !a.closed && b.closed)) ?
420 #endif // PXR_BASE_GF_INTERVAL_H
GfInterval & operator-=(const GfInterval &rhs)
Interval subtraction.
GF_API std::ostream & operator<<(std::ostream &, const GfInterval &)
void SetMin(double v)
Set minimum value.
bool IsMinClosed() const
Minimum boundary condition.
bool IsMinFinite() const
Returns true if the minimum value is finite.
bool operator>(const GfInterval &rhs)
Greater than operator.
bool Contains(double d) const
GLsizei const GLfloat * value
GfInterval & operator&=(const GfInterval &rhs)
Boolean intersection.
double GetMin() const
Minimum value.
GLboolean GLboolean GLboolean GLboolean a
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
static GfInterval GetFullInterval()
Returns the full interval (-inf, inf).
bool IsMaxClosed() const
Maximum boundary condition.
GfInterval(double min, double max, bool minClosed=true, bool maxClosed=true)
Construct an interval with the given arguments.
bool operator>=(const GfInterval &rhs)
Greater than or equal operator.
GfInterval operator+(const GfInterval &rhs) const
Addition operator.
bool IsMaxOpen() const
Maximum boundary condition.
GfInterval operator|(const GfInterval &rhs) const
Union operator.
bool operator<=(const GfInterval &rhs)
Less than or equal operator.
bool operator<(const GfInterval &rhs) const
Less-than operator.
bool IsFinite() const
Returns true if both the maximum and minimum value are finite.
GfInterval()
Construct an empty open interval, (0,0).
GfInterval operator&(const GfInterval &rhs) const
Intersection operator.
void SetMax(double v)
Set maximum value.
GfInterval operator-(const GfInterval &rhs) const
Subtraction operator.
GfInterval(double val)
Construct a closed interval representing the single point, as [val,val].
void SetMin(double v, bool minClosed)
Set minimum value and boundary condition.
GLboolean GLboolean GLboolean b
GfInterval & operator*=(const GfInterval &rhs)
Interval multiplication.
friend size_t hash_value(GfInterval const &i)
GfInterval & operator|=(const GfInterval &rhs)
Returns the interval that bounds the union of this interval and rhs.
static size_t Combine(Args &&...args)
Produce a hash code by combining the hash codes of several objects.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
bool Intersects(const GfInterval &i) const
Return true iff the given interval i intersects this interval.
GfInterval operator*(const GfInterval &rhs) const
Multiplication operator.
LeafData & operator=(const LeafData &)=delete
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
#define PXR_NAMESPACE_CLOSE_SCOPE
bool IsEmpty() const
Return true iff the interval is empty.
void SetMax(double v, bool maxClosed)
Set maximum value and boundary condition.
GfInterval & operator+=(const GfInterval &rhs)
Interval addition.
bool IsMaxFinite() const
Returns true if the maximum value is finite.
double GetMax() const
Maximum value.
bool Contains(const GfInterval &i) const
bool operator==(const GfInterval &rhs) const
Equality operator.
GfInterval operator-() const
Interval unary minus.
bool operator!=(const GfInterval &rhs) const
Inequality operator.
bool IsMinOpen() const
Minimum boundary condition.