7fd59977 |
1 | // File: Bnd_Box2d.lxx |
2 | // Created: Thu Nov 27 11:12:34 1997 |
3 | // Author: Christophe MARION |
4 | // <cma@partox.paris1.matra-dtv.fr> |
5 | |
6 | #define VoidMask 0x01 |
7 | #define XminMask 0x02 |
8 | #define XmaxMask 0x04 |
9 | #define YminMask 0x08 |
10 | #define YmaxMask 0x10 |
11 | #define WholeMask 0x1e |
12 | |
13 | #include <gp_Pnt2d.hxx> |
14 | |
15 | //======================================================================= |
16 | //function : Bnd_Box2d |
17 | //purpose : |
18 | //======================================================================= |
19 | |
20 | inline Bnd_Box2d::Bnd_Box2d() |
21 | : Xmin(0.), Xmax(0.), Ymin(0.), Ymax(0.), Gap(0.), Flags (VoidMask) |
22 | { |
23 | } |
24 | |
25 | //======================================================================= |
26 | //function : SetWhole |
27 | //purpose : |
28 | //======================================================================= |
29 | |
30 | inline void Bnd_Box2d::SetWhole () |
31 | { Flags = WholeMask; } |
32 | |
33 | //======================================================================= |
34 | //function : SetVoid |
35 | //purpose : |
36 | //======================================================================= |
37 | |
38 | inline void Bnd_Box2d::SetVoid () |
39 | { |
40 | Flags = VoidMask; |
41 | Gap=0.; |
42 | } |
43 | |
44 | //======================================================================= |
45 | //function : Set |
46 | //purpose : |
47 | //======================================================================= |
48 | |
49 | inline void Bnd_Box2d::Set(const gp_Pnt2d& P) |
50 | { |
51 | Flags = VoidMask; |
52 | Gap=0.; |
53 | Add(P); |
54 | } |
55 | |
56 | //======================================================================= |
57 | //function : Set |
58 | //purpose : |
59 | //======================================================================= |
60 | |
61 | inline void Bnd_Box2d::Set(const gp_Pnt2d& P, const gp_Dir2d& D) |
62 | { |
63 | Flags = VoidMask; |
64 | Gap=0.; |
65 | Add(P,D); |
66 | } |
67 | |
68 | //======================================================================= |
69 | //function : GetGap |
70 | //purpose : |
71 | //======================================================================= |
72 | |
73 | inline Standard_Real Bnd_Box2d::GetGap () const |
74 | { |
75 | return Gap; |
76 | } |
77 | |
78 | //======================================================================= |
79 | //function : SetGap |
80 | //purpose : |
81 | //======================================================================= |
82 | |
83 | inline void Bnd_Box2d::SetGap (const Standard_Real Tol) |
84 | { |
85 | Gap = Tol; |
86 | } |
87 | |
88 | //======================================================================= |
89 | //function : Enlarge |
90 | //purpose : |
91 | //======================================================================= |
92 | |
93 | inline void Bnd_Box2d::Enlarge (const Standard_Real Tol) |
94 | { |
95 | Standard_Real t = Tol; |
96 | if (t < 0) t = - t; |
97 | if (Gap < t) Gap = t; |
98 | } |
99 | |
100 | //======================================================================= |
101 | //function : OpenXmin |
102 | //purpose : |
103 | //======================================================================= |
104 | |
105 | inline void Bnd_Box2d::OpenXmin () |
106 | { Flags |= XminMask; } |
107 | |
108 | //======================================================================= |
109 | //function : OpenXmax |
110 | //purpose : |
111 | //======================================================================= |
112 | |
113 | inline void Bnd_Box2d::OpenXmax () |
114 | { Flags |= XmaxMask; } |
115 | |
116 | //======================================================================= |
117 | //function : OpenYmin |
118 | //purpose : |
119 | //======================================================================= |
120 | |
121 | inline void Bnd_Box2d::OpenYmin () |
122 | { Flags |= YminMask; } |
123 | |
124 | //======================================================================= |
125 | //function : OpenYmax |
126 | //purpose : |
127 | //======================================================================= |
128 | |
129 | inline void Bnd_Box2d::OpenYmax () |
130 | { Flags |= YmaxMask; } |
131 | |
132 | //======================================================================= |
133 | //function : IsOpenXmin |
134 | //purpose : |
135 | //======================================================================= |
136 | |
137 | inline Standard_Boolean Bnd_Box2d::IsOpenXmin () const |
138 | { return Flags & XminMask; } |
139 | |
140 | //======================================================================= |
141 | //function : IsOpenXmax |
142 | //purpose : |
143 | //======================================================================= |
144 | |
145 | inline Standard_Boolean Bnd_Box2d::IsOpenXmax () const |
146 | { return Flags & XmaxMask; } |
147 | |
148 | //======================================================================= |
149 | //function : IsOpenYmin |
150 | //purpose : |
151 | //======================================================================= |
152 | |
153 | inline Standard_Boolean Bnd_Box2d::IsOpenYmin () const |
154 | { return Flags & YminMask; } |
155 | |
156 | //======================================================================= |
157 | //function : IsOpenYmax |
158 | //purpose : |
159 | //======================================================================= |
160 | |
161 | inline Standard_Boolean Bnd_Box2d::IsOpenYmax () const |
162 | { return Flags & YmaxMask; } |
163 | |
164 | //======================================================================= |
165 | //function : IsWhole |
166 | //purpose : |
167 | //======================================================================= |
168 | |
169 | inline Standard_Boolean Bnd_Box2d::IsWhole () const |
170 | { return (Flags & WholeMask) == WholeMask; } |
171 | |
172 | //======================================================================= |
173 | //function : IsVoid |
174 | //purpose : |
175 | //======================================================================= |
176 | |
177 | inline Standard_Boolean Bnd_Box2d::IsVoid () const |
178 | { return Flags & VoidMask; } |
179 | |
180 | //======================================================================= |
181 | //function : Add |
182 | //purpose : |
183 | //======================================================================= |
184 | |
185 | inline void Bnd_Box2d::Add (const gp_Pnt2d& P) |
186 | { |
187 | Update(P.X(),P.Y()); |
188 | } |
189 | |
190 | //======================================================================= |
191 | //function : Add |
192 | //purpose : |
193 | //======================================================================= |
194 | |
195 | inline void Bnd_Box2d::Add (const gp_Pnt2d& P, const gp_Dir2d& D) |
196 | { |
197 | Add(P); |
198 | Add(D); |
199 | } |
200 | |
201 | //======================================================================= |
202 | //function : IsOut |
203 | //purpose : |
204 | //======================================================================= |
205 | |
206 | inline Standard_Boolean Bnd_Box2d::IsOut (const Bnd_Box2d& Other, |
207 | const gp_Trsf2d& T) const |
208 | { |
209 | return IsOut(Other.Transformed(T)); |
210 | } |
211 | |
212 | //======================================================================= |
213 | //function : IsOut |
214 | //purpose : |
215 | //======================================================================= |
216 | |
217 | inline Standard_Boolean Bnd_Box2d::IsOut (const gp_Trsf2d& T1, |
218 | const Bnd_Box2d& Other, |
219 | const gp_Trsf2d& T2) const |
220 | { |
221 | return Transformed(T1).IsOut (Other.Transformed(T2)); |
222 | } |
223 | |