11#ifndef PXR_BASE_GF_RANGE3F_H
12#define PXR_BASE_GF_RANGE3F_H
19#include "pxr/base/gf/api.h"
22#include "pxr/base/gf/traits.h"
29PXR_NAMESPACE_OPEN_SCOPE
53 static const size_t dimension = GfVec3f::dimension;
59 _min[0] = _min[1] = _min[2] = FLT_MAX;
60 _max[0] = _max[1] = _max[2] = -FLT_MAX;
70 : _min(min), _max(max)
92 return static_cast<ScalarType
>(0.5) * _min
93 +
static_cast<ScalarType
>(0.5) * _max;
104 return _min[0] > _max[0] || _min[1] > _max[1] || _min[2] > _max[2];
118 return (point[0] >= _min[0] && point[0] <= _max[0]
119 && point[1] >= _min[1] && point[1] <= _max[1]
120 && point[2] >= _min[2] && point[2] <= _max[2]);
149 return ((range._max[0] < _min[0] || range._min[0] > _max[0])
150 || (range._max[1] < _min[1] || range._min[1] > _max[1])
151 || (range._max[2] < _min[2] || range._min[2] > _max[2]));
157 _FindMin(res._min,b._min);
158 _FindMax(res._max,b._max);
164 _FindMin(_min,b._min);
165 _FindMax(_max,b._max);
197 _FindMax(res._min,b._min);
198 _FindMin(res._max,b._max);
211 _FindMax(_min,b._min);
212 _FindMin(_max,b._max);
252 return *
this *= (1.0 / m);
257 return GfRange3f(_min + b._min, _max + b._max);
263 return GfRange3f(_min - b._max, _max - b._min);
282 return r * (1.0 / m);
292 return (_min == b._min && _max == b._max);
295 bool operator !=(
const GfRange3f &b)
const {
296 return !(*
this == b);
304 GF_API
inline bool operator !=(
const GfRange3d& other)
const;
332 if (point[0] < dest[0]) dest[0] = point[0];
333 if (point[1] < dest[1]) dest[1] = point[1];
334 if (point[2] < dest[2]) dest[2] = point[2];
339 if (point[0] > dest[0]) dest[0] = point[0];
340 if (point[1] > dest[1]) dest[1] = point[1];
341 if (point[2] > dest[2]) dest[2] = point[2];
349PXR_NAMESPACE_CLOSE_SCOPE
351PXR_NAMESPACE_OPEN_SCOPE
360GfRange3f::operator !=(
const GfRange3d& other)
const {
361 return !(*
this == other);
365PXR_NAMESPACE_CLOSE_SCOPE
Basic type: 3-dimensional floating point range.
const GfVec3d & GetMin() const
Returns the minimum value of the range.
const GfVec3d & GetMax() const
Returns the maximum value of the range.
Basic type: 3-dimensional floating point range.
const GfRange3f & Union(const GfVec3f &b)
Extend this to include b.
GfVec3f GetSize() const
Returns the size of the range.
friend size_t hash_value(const GfRange3f &r)
hash.
void ExtendBy(const GfRange3f &range)
Modifies the range if necessary to surround the given range.
void SetMin(const GfVec3f &min)
Sets the minimum value of the range.
static GfRange3f GetUnion(const GfRange3f &a, const GfRange3f &b)
Returns the smallest GfRange3f which contains both a and b.
GF_API GfVec3f GetCorner(size_t i) const
Returns the ith corner of the range, in the following order: LDB, RDB, LUB, RUB, LDF,...
static GfRange3f GetIntersection(const GfRange3f &a, const GfRange3f &b)
Returns a GfRange3f that describes the intersection of a and b.
static GF_API const GfRange3f UnitCube
The unit cube.
static GfRange3f Union(const GfRange3f &a, const GfRange3f &b)
Returns the smallest GfRange3f which contains both a and b.
GfRange3f operator-(const GfRange3f &b) const
binary difference.
friend GfRange3f operator/(const GfRange3f &r, double m)
scalar divide.
const GfRange3f & IntersectWith(const GfRange3f &b)
Modifies this range to hold its intersection with b and returns the result.
const GfRange3f & Intersection(const GfRange3f &b)
Modifies this range to hold its intersection with b and returns the result.
GF_API GfRange3f(class GfRange3d const &other)
Construct from GfRange3d.
GfRange3f(const GfVec3f &min, const GfVec3f &max)
This constructor initializes the minimum and maximum points.
static GfRange3f Intersection(const GfRange3f &a, const GfRange3f &b)
Returns a GfRange3f that describes the intersection of a and b.
GF_API double GetDistanceSquared(const GfVec3f &p) const
Compute the squared distance from a point to the range.
GF_API GfRange3f GetOctant(size_t i) const
Returns the ith octant of the range, in the following order: LDB, RDB, LUB, RUB, LDF,...
void SetMax(const GfVec3f &max)
Sets the maximum value of the range.
bool Contains(const GfVec3f &point) const
Returns true if the point is located inside the range.
GfRange3f()
The default constructor creates an empty range.
GfRange3f & operator*=(double m)
unary multiply.
const GfVec3f & GetMin() const
Returns the minimum value of the range.
void ExtendBy(const GfVec3f &point)
Modifies the range if necessary to surround the given value.
bool IsEmpty() const
Returns whether the range is empty (max < min).
const GfRange3f & UnionWith(const GfRange3f &b)
Extend this to include b.
const GfRange3f & Union(const GfRange3f &b)
Extend this to include b.
GfVec3f GetMidpoint() const
Returns the midpoint of the range, that is, 0.5*(min+max).
GfRange3f & operator+=(const GfRange3f &b)
unary sum.
bool Contains(const GfRange3f &range) const
Returns true if the range is located entirely inside the range.
void SetEmpty()
Sets the range to an empty interval.
bool IsInside(const GfVec3f &point) const
Returns true if the point is located inside the range.
GfVec3f MinMaxType
Helper typedef.
bool IsOutside(const GfRange3f &range) const
Returns true if the range is located entirely outside the range.
bool IsInside(const GfRange3f &range) const
Returns true if the range is located entirely inside the range.
const GfVec3f & GetMax() const
Returns the maximum value of the range.
const GfRange3f & UnionWith(const GfVec3f &b)
Extend this to include b.
GfRange3f & operator-=(const GfRange3f &b)
unary difference.
bool operator==(const GfRange3f &b) const
The min and max points must match exactly for equality.
friend GfRange3f operator*(double m, const GfRange3f &r)
scalar multiply.
GfRange3f & operator/=(double m)
unary division.
GfRange3f operator+(const GfRange3f &b) const
binary sum.
Basic type for a vector of 3 float components.
float ScalarType
Scalar element type and dimension.
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...