b311480e |
1 | // Created on: 1993-03-10 |
2 | // Created by: JCV |
3 | // Copyright (c) 1993-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
7fd59977 |
22 | |
23 | #include <Geom_Plane.ixx> |
24 | |
25 | #include <Precision.hxx> |
26 | #include <Standard_RangeError.hxx> |
27 | |
28 | #include <gp_XYZ.hxx> |
29 | #include <gp.hxx> |
30 | #include <gp_Lin.hxx> |
31 | #include <gp_Trsf2d.hxx> |
32 | #include <ElSLib.hxx> |
33 | #include <Geom_Line.hxx> |
34 | #include <GeomAbs_UVSense.hxx> |
35 | |
36 | typedef Geom_Plane Plane; |
37 | typedef Handle(Geom_Plane) Handle(Plane); |
38 | typedef Handle(Geom_Line) Handle(Line); |
39 | |
40 | typedef gp_Ax1 Ax1; |
41 | typedef gp_Ax2 Ax2; |
42 | typedef gp_Ax3 Ax3; |
43 | typedef gp_Dir Dir; |
44 | typedef gp_Lin Lin; |
45 | typedef gp_Pln Pln; |
46 | typedef gp_Pnt Pnt; |
47 | typedef gp_Trsf Trsf; |
48 | typedef gp_Vec Vec; |
49 | typedef gp_XYZ XYZ; |
50 | |
51 | |
52 | |
53 | //======================================================================= |
54 | //function : Copy |
55 | //purpose : |
56 | //======================================================================= |
57 | |
58 | Handle(Geom_Geometry) Geom_Plane::Copy () const { |
59 | |
60 | Handle(Plane) Pl = new Plane ( pos); |
61 | return Pl; |
62 | } |
63 | |
64 | |
65 | |
66 | |
67 | //======================================================================= |
68 | //function : Geom_Plane |
69 | //purpose : |
70 | //======================================================================= |
71 | |
72 | Geom_Plane::Geom_Plane (const gp_Ax3& A3) { |
73 | |
74 | pos = A3; |
75 | } |
76 | |
77 | |
78 | //======================================================================= |
79 | //function : Geom_Plane |
80 | //purpose : |
81 | //======================================================================= |
82 | |
83 | Geom_Plane::Geom_Plane (const gp_Pln& Pl) { |
84 | |
85 | pos = Pl.Position(); |
86 | } |
87 | |
88 | |
89 | //======================================================================= |
90 | //function : Geom_Plane |
91 | //purpose : |
92 | //======================================================================= |
93 | |
94 | Geom_Plane::Geom_Plane (const Pnt& P, const Dir& V) { |
95 | |
96 | gp_Pln Pl (P, V); |
97 | pos = Pl.Position(); |
98 | } |
99 | |
100 | |
101 | //======================================================================= |
102 | //function : Geom_Plane |
103 | //purpose : |
104 | //======================================================================= |
105 | |
106 | Geom_Plane::Geom_Plane ( const Standard_Real A, |
107 | const Standard_Real B, |
108 | const Standard_Real C, |
109 | const Standard_Real D) { |
110 | |
111 | gp_Pln Pl (A, B, C, D); |
112 | pos = Pl.Position (); |
113 | } |
114 | |
115 | |
116 | //======================================================================= |
117 | //function : SetPln |
118 | //purpose : |
119 | //======================================================================= |
120 | |
121 | void Geom_Plane::SetPln (const gp_Pln& Pl) |
122 | { pos = Pl.Position(); } |
123 | |
124 | //======================================================================= |
125 | //function : Pln |
126 | //purpose : |
127 | //======================================================================= |
128 | |
129 | gp_Pln Geom_Plane::Pln () const { |
130 | |
131 | return gp_Pln (Position()); |
132 | } |
133 | |
134 | |
135 | //======================================================================= |
136 | //function : UReverse |
137 | //purpose : |
138 | //======================================================================= |
139 | |
140 | void Geom_Plane::UReverse() { |
141 | pos.XReverse(); |
142 | } |
143 | |
144 | //======================================================================= |
145 | //function : UReversedParameter |
146 | //purpose : |
147 | //======================================================================= |
148 | |
149 | Standard_Real Geom_Plane::UReversedParameter( const Standard_Real U) const { |
150 | |
151 | return (-U); |
152 | } |
153 | |
154 | |
155 | //======================================================================= |
156 | //function : VReverse |
157 | //purpose : |
158 | //======================================================================= |
159 | |
160 | void Geom_Plane::VReverse() { |
161 | |
162 | pos.YReverse(); |
163 | } |
164 | |
165 | |
166 | //======================================================================= |
167 | //function : VReversedParameter |
168 | //purpose : |
169 | //======================================================================= |
170 | |
171 | Standard_Real Geom_Plane::VReversedParameter( const Standard_Real V) const { |
172 | |
173 | return (-V); |
174 | } |
175 | |
176 | //======================================================================= |
177 | //function : Transform |
178 | //purpose : |
179 | //======================================================================= |
180 | |
181 | void Geom_Plane::Transform (const Trsf& T) |
182 | { pos.Transform (T); } |
183 | |
184 | //======================================================================= |
185 | //function : IsUClosed |
186 | //purpose : |
187 | //======================================================================= |
188 | |
189 | Standard_Boolean Geom_Plane::IsUClosed () const { |
190 | |
191 | return Standard_False; |
192 | } |
193 | |
194 | //======================================================================= |
195 | //function : IsVClosed |
196 | //purpose : |
197 | //======================================================================= |
198 | |
199 | Standard_Boolean Geom_Plane::IsVClosed () const { |
200 | |
201 | return Standard_False; |
202 | } |
203 | |
204 | //======================================================================= |
205 | //function : IsUPeriodic |
206 | //purpose : |
207 | //======================================================================= |
208 | |
209 | Standard_Boolean Geom_Plane::IsUPeriodic () const { |
210 | |
211 | return Standard_False; |
212 | } |
213 | |
214 | //======================================================================= |
215 | //function : IsVPeriodic |
216 | //purpose : |
217 | //======================================================================= |
218 | |
219 | Standard_Boolean Geom_Plane::IsVPeriodic () const { |
220 | |
221 | return Standard_False; |
222 | } |
223 | |
224 | //======================================================================= |
225 | //function : Bounds |
226 | //purpose : |
227 | //======================================================================= |
228 | |
229 | void Geom_Plane::Bounds (Standard_Real& U1, Standard_Real& U2, Standard_Real& V1, Standard_Real& V2) const { |
230 | |
231 | U1 = -Precision::Infinite(); |
232 | U2 = Precision::Infinite(); |
233 | V1 = -Precision::Infinite(); |
234 | V2 = Precision::Infinite(); |
235 | } |
236 | |
237 | |
238 | //======================================================================= |
239 | //function : Coefficients |
240 | //purpose : |
241 | //======================================================================= |
242 | |
243 | void Geom_Plane::Coefficients (Standard_Real& A, Standard_Real& B, Standard_Real& C, Standard_Real& D) const { |
244 | |
245 | gp_Pln Pl (Position()); |
246 | Pl.Coefficients (A, B, C, D); |
247 | } |
248 | |
249 | |
250 | //======================================================================= |
251 | //function : D0 |
252 | //purpose : |
253 | //======================================================================= |
254 | |
255 | void Geom_Plane::D0 (const Standard_Real U, const Standard_Real V, Pnt& P) const { |
256 | |
257 | P = ElSLib::PlaneValue (U, V, pos); |
258 | } |
259 | |
260 | |
261 | |
262 | //======================================================================= |
263 | //function : D1 |
264 | //purpose : |
265 | //======================================================================= |
266 | |
267 | void Geom_Plane::D1 ( const Standard_Real U, const Standard_Real V, |
268 | Pnt& P, Vec& D1U, Vec& D1V) const |
269 | { |
270 | |
271 | ElSLib::PlaneD1 (U, V, pos, P, D1U, D1V); |
272 | } |
273 | |
274 | |
275 | //======================================================================= |
276 | //function : D2 |
277 | //purpose : |
278 | //======================================================================= |
279 | |
280 | void Geom_Plane::D2 ( const Standard_Real U , const Standard_Real V, |
281 | Pnt& P , |
282 | Vec& D1U, Vec& D1V, |
283 | Vec& D2U, Vec& D2V, Vec& D2UV) const |
284 | { |
285 | |
286 | ElSLib::PlaneD1 (U, V, pos, P, D1U, D1V); |
287 | D2U.SetCoord (0.0, 0.0, 0.0); |
288 | D2V.SetCoord (0.0, 0.0, 0.0); |
289 | D2UV.SetCoord (0.0, 0.0, 0.0); |
290 | } |
291 | |
292 | |
293 | //======================================================================= |
294 | //function : D3 |
295 | //purpose : |
296 | //======================================================================= |
297 | |
298 | void Geom_Plane::D3 ( const Standard_Real U, const Standard_Real V, |
299 | Pnt& P, |
300 | Vec& D1U, Vec& D1V, |
301 | Vec& D2U, Vec& D2V, Vec& D2UV, |
302 | Vec& D3U, Vec& D3V, Vec& D3UUV, Vec& D3UVV) const |
303 | { |
304 | ElSLib::PlaneD1 (U, V, pos, P, D1U, D1V); |
305 | D2U.SetCoord (0.0, 0.0, 0.0); |
306 | D2V.SetCoord (0.0, 0.0, 0.0); |
307 | D2UV.SetCoord (0.0, 0.0, 0.0); |
308 | D3U.SetCoord (0.0, 0.0, 0.0); |
309 | D3V.SetCoord (0.0, 0.0, 0.0); |
310 | D3UUV.SetCoord (0.0, 0.0, 0.0); |
311 | D3UVV.SetCoord (0.0, 0.0, 0.0); |
312 | } |
313 | |
314 | |
315 | |
316 | //======================================================================= |
317 | //function : DN |
318 | //purpose : |
319 | //======================================================================= |
320 | |
321 | Vec Geom_Plane::DN ( const Standard_Real , const Standard_Real , |
322 | const Standard_Integer Nu, const Standard_Integer Nv ) const { |
323 | |
324 | Standard_RangeError_Raise_if (Nu < 0 || Nv < 0 || Nu + Nv < 1, " "); |
325 | if (Nu == 0 && Nv == 1) { |
326 | return Vec (pos.YDirection()); |
327 | } |
328 | else if (Nu == 1 && Nv == 0) { |
329 | return Vec (pos.XDirection()); |
330 | } |
331 | return Vec (0.0, 0.0, 0.0); |
332 | } |
333 | |
334 | |
335 | //======================================================================= |
336 | //function : UIso |
337 | //purpose : |
338 | //======================================================================= |
339 | |
340 | Handle(Geom_Curve) Geom_Plane::UIso (const Standard_Real U) const |
341 | { |
342 | Handle(Geom_Line) GL = new Geom_Line (ElSLib::PlaneUIso(pos,U)); |
343 | return GL; |
344 | } |
345 | |
346 | |
347 | //======================================================================= |
348 | //function : VIso |
349 | //purpose : |
350 | //======================================================================= |
351 | |
352 | Handle(Geom_Curve) Geom_Plane::VIso (const Standard_Real V) const |
353 | { |
354 | Handle(Geom_Line) GL = new Geom_Line (ElSLib::PlaneVIso(pos,V)); |
355 | return GL; |
356 | } |
357 | |
358 | //======================================================================= |
359 | //function : TransformParameters |
360 | //purpose : |
361 | //======================================================================= |
362 | |
363 | void Geom_Plane::TransformParameters(Standard_Real& U, |
364 | Standard_Real& V, |
365 | const gp_Trsf& T) |
366 | const |
367 | { |
368 | if (!Precision::IsInfinite(U)) U *= Abs(T.ScaleFactor()); |
369 | if (!Precision::IsInfinite(V)) V *= Abs(T.ScaleFactor()); |
370 | } |
371 | |
372 | //======================================================================= |
373 | //function : ParametricTransformation |
374 | //purpose : |
375 | //======================================================================= |
376 | |
377 | gp_GTrsf2d Geom_Plane::ParametricTransformation(const gp_Trsf& T) const |
378 | { |
379 | gp_Trsf2d T2; |
380 | T2.SetScale(gp::Origin2d(), Abs(T.ScaleFactor())); |
381 | return gp_GTrsf2d(T2); |
382 | } |