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