blob: f43af0c37974ea75f416ca0b9d440ad11af268cb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
// File: Bnd_B3x.lxx
// Created: 08.09.05 20:55:36
// Author: Alexander GRIGORIEV
// Copyright: Open Cascade 2005
#include <gp_Pnt.hxx>
#ifndef Bnd_B3x_RealLast
#define Bnd_B3x_RealLast RealType(1e30);
#endif
/**
* Empty constructor
*/
inline Bnd_B3x::Bnd_B3x ()
{
Clear();
}
/**
* Constructor.
* @param theCenter
* Center of the created box
* @param theHSize
* Half-diagonal of the box, both X and Y should be non-negative
*/
inline Bnd_B3x::Bnd_B3x (const gp_XYZ& theCenter,
const gp_XYZ& theHSize)
{
myCenter[0] = RealType(theCenter.X());
myCenter[1] = RealType(theCenter.Y());
myCenter[2] = RealType(theCenter.Z());
myHSize[0] = RealType(theHSize.X());
myHSize[1] = RealType(theHSize.Y());
myHSize[2] = RealType(theHSize.Z());
}
/**
* Reset the box data.
*/
inline void Bnd_B3x::Clear ()
{
myCenter[0] = Bnd_B3x_RealLast;
myCenter[1] = Bnd_B3x_RealLast;
myCenter[2] = Bnd_B3x_RealLast;
myHSize[0] = -Bnd_B3x_RealLast;
myHSize[1] = -Bnd_B3x_RealLast;
myHSize[2] = -Bnd_B3x_RealLast;
}
/**
* Check if the box is empty.
*/
inline Standard_Boolean Bnd_B3x::IsVoid () const
{
return (myHSize[0] < -1e-5);
}
/**
* Update the box by point.
*/
inline void Bnd_B3x::Add (const gp_Pnt& thePnt)
{
Add (thePnt.XYZ());
}
/**
* Update the box by another box.
*/
inline void Bnd_B3x::Add (const Bnd_B3x& theBox)
{
if (theBox.IsVoid() == Standard_False) {
Add (theBox.CornerMin());
Add (theBox.CornerMax());
}
}
/**
* Query a box corner.
*/
inline gp_XYZ Bnd_B3x::CornerMin () const
{
return gp_XYZ (myCenter[0] - myHSize[0],
myCenter[1] - myHSize[1],
myCenter[2] - myHSize[2]);
}
/**
* Query a box corner.
*/
inline gp_XYZ Bnd_B3x::CornerMax () const
{
return gp_XYZ (myCenter[0] + myHSize[0],
myCenter[1] + myHSize[1],
myCenter[2] + myHSize[2]);
}
/**
* Query the square diagonal.
*/
inline Standard_Real Bnd_B3x::SquareExtent () const
{
return 4 * (myHSize[0] * myHSize[0] +
myHSize[1] * myHSize[1] +
myHSize[2] * myHSize[2]);
}
/**
* Set the Center coordinates.
*/
inline void Bnd_B3x::SetCenter (const gp_XYZ& theCenter)
{
myCenter[0] = RealType(theCenter.X());
myCenter[1] = RealType(theCenter.Y());
myCenter[2] = RealType(theCenter.Z());
}
/**
* Set the Center coordinates.
*/
inline void Bnd_B3x::SetHSize (const gp_XYZ& theHSize)
{
myHSize[0] = RealType(theHSize.X());
myHSize[1] = RealType(theHSize.Y());
myHSize[2] = RealType(theHSize.Z());
}
/**
* Increase the box.
* @param aDiff
* absolute value of this parameter is added to the box size in all dimensions.
*/
inline void Bnd_B3x::Enlarge (const Standard_Real aDiff)
{
const Standard_Real aD = Abs(aDiff);
myHSize[0] += RealType(aD);
myHSize[1] += RealType(aD);
myHSize[2] += RealType(aD);
}
/**
* Intersection Box - Point
*/
inline Standard_Boolean Bnd_B3x::IsOut (const gp_XYZ& thePnt) const
{
return (Abs(RealType(thePnt.X()) - myCenter[0]) > myHSize[0] ||
Abs(RealType(thePnt.Y()) - myCenter[1]) > myHSize[1] ||
Abs(RealType(thePnt.Z()) - myCenter[2]) > myHSize[2]);
}
/**
* Intersection Box-Box.
*/
inline Standard_Boolean Bnd_B3x::IsOut (const Bnd_B3x& theBox) const
{
return (Abs(theBox.myCenter[0]-myCenter[0]) > theBox.myHSize[0]+myHSize[0] ||
Abs(theBox.myCenter[1]-myCenter[1]) > theBox.myHSize[1]+myHSize[1] ||
Abs(theBox.myCenter[2]-myCenter[2]) > theBox.myHSize[2]+myHSize[2]);
}
/**
* Test the complete inclusion of this box in theBox.
*/
inline Standard_Boolean Bnd_B3x::IsIn (const Bnd_B3x& theBox) const
{
return (Abs(theBox.myCenter[0]-myCenter[0]) < theBox.myHSize[0]-myHSize[0] &&
Abs(theBox.myCenter[1]-myCenter[1]) < theBox.myHSize[1]-myHSize[1] &&
Abs(theBox.myCenter[2]-myCenter[2]) < theBox.myHSize[2]-myHSize[2]);
}
|