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" 41 #include <boost/functional/hash.hpp> 47 PXR_NAMESPACE_OPEN_SCOPE
71 static const size_t dimension = GfVec3d::dimension;
77 _min[0] = _min[1] = _min[2] = FLT_MAX;
78 _max[0] = _max[1] = _max[2] = -FLT_MAX;
88 : _min(min), _max(max)
105 return static_cast<ScalarType>(0.5) * _min
106 + static_cast<ScalarType>(0.5) * _max;
117 return _min[0] > _max[0] || _min[1] > _max[1] || _min[2] > _max[2];
131 return (point[0] >= _min[0] && point[0] <= _max[0]
132 && point[1] >= _min[1] && point[1] <= _max[1]
133 && point[2] >= _min[2] && point[2] <= _max[2]);
162 return ((range._max[0] < _min[0] || range._min[0] > _max[0])
163 || (range._max[1] < _min[1] || range._min[1] > _max[1])
164 || (range._max[2] < _min[2] || range._min[2] > _max[2]));
170 _FindMin(res._min,b._min);
171 _FindMax(res._max,b._max);
177 _FindMin(_min,b._min);
178 _FindMax(_max,b._max);
210 _FindMax(res._min,b._min);
211 _FindMin(res._max,b._max);
224 _FindMax(_min,b._min);
225 _FindMin(_max,b._max);
265 return *
this *= (1.0 / m);
270 return GfRange3d(_min + b._min, _max + b._max);
276 return GfRange3d(_min - b._max, _max - b._min);
295 return r * (1.0 / m);
301 boost::hash_combine(h, r._min);
302 boost::hash_combine(h, r._max);
308 return (_min == b._min && _max == b._max);
311 bool operator !=(
const GfRange3d &b)
const {
312 return !(*
this == b);
320 GF_API
inline bool operator !=(
const GfRange3f& other)
const;
348 if (point[0] < dest[0]) dest[0] = point[0];
349 if (point[1] < dest[1]) dest[1] = point[1];
350 if (point[2] < dest[2]) dest[2] = point[2];
355 if (point[0] > dest[0]) dest[0] = point[0];
356 if (point[1] > dest[1]) dest[1] = point[1];
357 if (point[2] > dest[2]) dest[2] = point[2];
365 PXR_NAMESPACE_CLOSE_SCOPE
367 PXR_NAMESPACE_OPEN_SCOPE
376 GfRange3d::operator !=(
const GfRange3f& other)
const {
377 return !(*
this == other);
381 PXR_NAMESPACE_CLOSE_SCOPE
383 #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,...
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.