Loading...
Searching...
No Matches
range3f.h
Go to the documentation of this file.
1
//
2
// Copyright 2016 Pixar
3
//
4
// Licensed under the terms set forth in the LICENSE.txt file available at
5
// https://openusd.org/license.
6
//
8
// This file is generated by a script. Do not edit directly. Edit the
9
// range.template.h file to make changes.
10
11
#ifndef PXR_BASE_GF_RANGE3F_H
12
#define PXR_BASE_GF_RANGE3F_H
13
16
17
#include "
pxr/pxr.h
"
18
19
#include "pxr/base/gf/api.h"
20
#include "
pxr/base/gf/vec3d.h
"
21
#include "
pxr/base/gf/vec3f.h
"
22
#include "pxr/base/gf/traits.h"
23
#include "
pxr/base/tf/hash.h
"
24
25
#include <cfloat>
26
#include <cstddef>
27
#include <iosfwd>
28
29
PXR_NAMESPACE_OPEN_SCOPE
30
31
class
GfRange3d
;
32
class
GfRange3f
;
33
34
template
<>
35
struct
GfIsGfRange
<class
GfRange3f
> {
static
const
bool
value =
true
; };
36
46
class
GfRange3f
47
{
48
public
:
49
51
typedef
GfVec3f
MinMaxType
;
52
53
static
const
size_t
dimension = GfVec3f::dimension;
54
typedef
GfVec3f::ScalarType
ScalarType;
55
57
// TODO check whether this can be deprecated.
58
void
inline
SetEmpty
() {
59
_min[0] = _min[1] = _min[2] = FLT_MAX;
60
_max[0] = _max[1] = _max[2] = -FLT_MAX;
61
}
62
64
GfRange3f
() {
65
SetEmpty
();
66
}
67
69
GfRange3f
(
const
GfVec3f
&min,
const
GfVec3f
&max)
70
: _min(min), _max(max)
71
{
72
}
73
74
76
GF_API
77
explicit
GfRange3f
(
class
GfRange3d
const
&other);
78
80
const
GfVec3f
&
GetMin
()
const
{
return
_min; }
81
83
const
GfVec3f
&
GetMax
()
const
{
return
_max; }
84
86
GfVec3f
GetSize
()
const
{
return
_max - _min; }
87
91
GfVec3f
GetMidpoint
()
const
{
92
return
static_cast<
ScalarType
>
(0.5) * _min
93
+
static_cast<
ScalarType
>
(0.5) * _max;
94
}
95
97
void
SetMin
(
const
GfVec3f
&min) { _min = min; }
98
100
void
SetMax
(
const
GfVec3f
&max) { _max = max; }
101
103
bool
IsEmpty
()
const
{
104
return
_min[0] > _max[0] || _min[1] > _max[1] || _min[2] > _max[2];
105
}
106
109
void
ExtendBy
(
const
GfVec3f
&point) {
UnionWith
(point); }
110
113
void
ExtendBy
(
const
GfRange3f
&range) {
UnionWith
(range); }
114
117
bool
Contains
(
const
GfVec3f
&point)
const
{
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]);
121
}
122
126
bool
Contains
(
const
GfRange3f
&range)
const
{
127
return
Contains
(range._min) &&
Contains
(range._max);
128
}
129
133
bool
IsInside
(
const
GfVec3f
&point)
const
{
134
return
Contains
(point);
135
}
136
141
bool
IsInside
(
const
GfRange3f
&range)
const
{
142
return
Contains
(range);
143
}
144
148
bool
IsOutside
(
const
GfRange3f
&range)
const
{
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]));
152
}
153
155
static
GfRange3f
GetUnion
(
const
GfRange3f
&a,
const
GfRange3f
&b) {
156
GfRange3f
res = a;
157
_FindMin(res._min,b._min);
158
_FindMax(res._max,b._max);
159
return
res;
160
}
161
163
const
GfRange3f
&
UnionWith
(
const
GfRange3f
&b) {
164
_FindMin(_min,b._min);
165
_FindMax(_max,b._max);
166
return
*
this
;
167
}
168
170
const
GfRange3f
&
UnionWith
(
const
GfVec3f
&b) {
171
_FindMin(_min,b);
172
_FindMax(_max,b);
173
return
*
this
;
174
}
175
178
static
GfRange3f
Union
(
const
GfRange3f
&a,
const
GfRange3f
&b) {
179
return
GetUnion
(a, b);
180
}
181
184
const
GfRange3f
&
Union
(
const
GfRange3f
&b) {
185
return
UnionWith
(b);
186
}
187
190
const
GfRange3f
&
Union
(
const
GfVec3f
&b) {
191
return
UnionWith
(b);
192
}
193
195
static
GfRange3f
GetIntersection
(
const
GfRange3f
&a,
const
GfRange3f
&b) {
196
GfRange3f
res = a;
197
_FindMax(res._min,b._min);
198
_FindMin(res._max,b._max);
199
return
res;
200
}
201
204
static
GfRange3f
Intersection
(
const