28 #ifndef PXR_BASE_GF_RANGE3D_H 29 #define PXR_BASE_GF_RANGE3D_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 = GfVec3d::dimension;
76 _min[0] = _min[1] = _min[2] = FLT_MAX;
77 _max[0] = _max[1] = _max[2] = -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] || _min[2] > _max[2];
135 return (point[0] >= _min[0] && point[0] <= _max[0]
136 && point[1] >= _min[1] && point[1] <= _max[1]
137 && point[2] >= _min[2] && point[2] <= _max[2]);
166 return ((range._max[0] < _min[0] || range._min[0] > _max[0])
167 || (range._max[1] < _min[1] || range._min[1] > _max[1])
168 || (range._max[2] < _min[2] || range._min[2] > _max[2]));
174 _FindMin(res._min,b._min);
175 _FindMax(res._max,b._max);
181 _FindMin(_min,b._min);
182 _FindMax(_max,b._max);
214 _FindMax(res._min,b._min);
215 _FindMin(res._max,b._max);
228 _FindMax(_min,b._min);
229 _FindMin(_max,b._max);
269 return *
this *= (1.0 / m);
274 return GfRange3d(_min + b._min, _max + b._max);
280 return GfRange3d(_min - b._max, _max - b._min);
299 return r * (1.0 / m);
309 return (_min == b._min && _max == b._max);
312 bool operator !=(
const GfRange3d &b)
const {
313 return !(*
this == b);
321 GF_API
inline bool operator !=(
const GfRange3f& other)
const;
349 if (point[0] < dest[0]) dest[0] = point[0];
350 if (point[1] < dest[1]) dest[1] = point[1];
351 if (point[2] < dest[2]) dest[2] = point[2];
356 if (point[0] > dest[0]) dest[0] = point[0];
357 if (point[1] > dest[1]) dest[1] = point[1];
358 if (point[2] > dest[2]) dest[2] = point[2];
366 PXR_NAMESPACE_CLOSE_SCOPE
368 PXR_NAMESPACE_OPEN_SCOPE
377 GfRange3d::operator !=(
const GfRange3f& other)
const {
378 return !(*
this == other);
382 PXR_NAMESPACE_CLOSE_SCOPE
384 #endif // PXR_BASE_GF_RANGE3D_H const GfRange3d & Union(const GfRange3d &b)
Extend this to include b.
Basic type: 3-dimensional floating point range.
bool IsEmpty() const
Returns whether the range is empty (max < min).
GfVec3d GetMidpoint() const
Returns the midpoint of the range, that is, 0.5*(min+max).
bool operator==(const GfRange3d &b) const
The min and max points must match exactly for equality.
const GfVec3d & GetMax() const
Returns the maximum value of the range.
GfRange3d & operator/=(double m)
unary division.
bool IsOutside(const GfRange3d &range) const
Returns true if the range is located entirely outside the range.
const GfVec3f & GetMin() const
Returns the minimum value of the range.
double ScalarType
Scalar element type and dimension.
static GfRange3d GetUnion(const GfRange3d &a, const GfRange3d &b)
Returns the smallest GfRange3d which contains both a and b.
const GfVec3f & GetMax() const
Returns the maximum value of the range.
GfVec3d GetSize() const
Returns the size of the range.
const GfRange3d & UnionWith(const GfRange3d &b)
Extend this to include b.
A metafunction with a static const bool member 'value' that is true for GfRange types and false for a...
GfRange3d operator -(const GfRange3d &b) const
binary difference.
GfRange3d(const GfVec3d &min, const GfVec3d &max)
This constructor initializes the minimum and maximum points.
static GfRange3d Union(const GfRange3d &a, const GfRange3d &b)
Returns the smallest GfRange3d which contains both a and b.
void SetMin(const GfVec3d &min)
Sets the minimum value of the range.
GfRange3d & operator+=(const GfRange3d &b)
unary sum.
void SetEmpty()
Sets the range to an empty interval.
GfVec3d MinMaxType
Helper typedef.
static GF_API const GfRange3d UnitCube
The unit cube.
friend GfRange3d operator/(const GfRange3d &r, double m)
scalar divide.
const GfVec3d & GetMin() const
Returns the minimum value of the range.
GF_API GfRange3d GetOctant(size_t i) const
Returns the ith octant of the range, in the following order: LDB, RDB, LUB, RUB, LDF,...
static size_t Combine(Args &&... args)
Produce a hash code by combining the hash codes of several objects.
bool IsInside(const GfVec3d &point) const
Returns true if the point is located inside the range.
const GfRange3d & UnionWith(const GfVec3d &b)
Extend this to include b.
Basic type: 3-dimensional floating point range.
GF_API std::ostream & operator<<(std::ostream &, GfRange3d const &)
Output a GfRange3d.
GF_API double GetDistanceSquared(const GfVec3d &p) const
Compute the squared distance from a point to the range.
GfRange3d operator+(const GfRange3d &b) const
binary sum.
GF_API GfVec3d GetCorner(size_t i) const
Returns the ith corner of the range, in the following order: LDB, RDB, LUB, RUB, LDF,...
friend GfRange3d operator *(double m, const GfRange3d &r)
scalar multiply.
bool IsInside(const GfRange3d &range) const
Returns true if the range is located entirely inside the range.
const GfRange3d & Union(const GfVec3d &b)
Extend this to include b.
const GfRange3d & Intersection(const GfRange3d &b)
Modifies this range to hold its intersection with b and returns the result.
void ExtendBy(const GfVec3d &point)
Modifies the range if necessary to surround the given value.
static GfRange3d Intersection(const GfRange3d &a, const GfRange3d &b)
Returns a GfRange3d that describes the intersection of a and b.
Basic type for a vector of 3 double components.
bool Contains(const GfVec3d &point) const
Returns true if the point is located inside the range.
GfRange3d()
The default constructor creates an empty range.
friend size_t hash_value(const GfRange3d &r)
hash.
bool Contains(const GfRange3d &range) const
Returns true if the range is located entirely inside the range.
GfRange3d & operator *=(double m)
unary multiply.
friend GfRange3d operator *(const GfRange3d &r, double m)
scalar multiply.
GfRange3d & operator -=(const GfRange3d &b)
unary difference.
static GfRange3d GetIntersection(const GfRange3d &a, const GfRange3d &b)
Returns a GfRange3d that describes the intersection of a and b.
void SetMax(const GfVec3d &max)
Sets the maximum value of the range.
const GfRange3d & IntersectWith(const GfRange3d &b)
Modifies this range to hold its intersection with b and returns the result.
void ExtendBy(const GfRange3d &range)
Modifies the range if necessary to surround the given range.