0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / Geom2d / Geom2d_Parabola.cxx
1 // Created on: 1993-03-24
2 // Created by: JCV
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <ElCLib.hxx>
19 #include <Geom2d_Geometry.hxx>
20 #include <Geom2d_Parabola.hxx>
21 #include <gp_Ax2d.hxx>
22 #include <gp_Ax22d.hxx>
23 #include <gp_Dir2d.hxx>
24 #include <gp_Parab2d.hxx>
25 #include <gp_Pnt2d.hxx>
26 #include <gp_Trsf2d.hxx>
27 #include <gp_Vec2d.hxx>
28 #include <gp_XY.hxx>
29 #include <Precision.hxx>
30 #include <Standard_ConstructionError.hxx>
31 #include <Standard_RangeError.hxx>
32 #include <Standard_Type.hxx>
33
34 IMPLEMENT_STANDARD_RTTIEXT(Geom2d_Parabola,Geom2d_Conic)
35
36 typedef Geom2d_Parabola         Parabola;
37 typedef gp_Ax2d   Ax2d;
38 typedef gp_Dir2d  Dir2d;
39 typedef gp_Pnt2d  Pnt2d;
40 typedef gp_Vec2d  Vec2d;
41 typedef gp_Trsf2d Trsf2d;
42 typedef gp_XY     XY;
43
44 //=======================================================================
45 //function : Copy
46 //purpose  : 
47 //=======================================================================
48
49 Handle(Geom2d_Geometry) Geom2d_Parabola::Copy() const 
50 {
51   Handle(Geom2d_Parabola) Prb;
52   Prb = new Parabola (pos, focalLength);
53   return Prb;
54 }
55
56
57
58 //=======================================================================
59 //function : Geom2d_Parabola
60 //purpose  : 
61 //=======================================================================
62
63 Geom2d_Parabola::Geom2d_Parabola (const gp_Parab2d& Prb) 
64 {
65   focalLength = Prb.Focal ();
66   pos         = Prb.Axis();
67 }
68
69
70 //=======================================================================
71 //function : Geom2d_Parabola
72 //purpose  : 
73 //=======================================================================
74
75 Geom2d_Parabola::Geom2d_Parabola (const Ax2d& MirrorAxis, 
76                                   const Standard_Real Focal, 
77                                   const Standard_Boolean Sense) 
78 : focalLength (Focal) 
79 {
80   if (Focal < 0.0) { throw Standard_ConstructionError(); }
81   pos = gp_Ax22d(MirrorAxis, Sense);
82 }
83
84
85 //=======================================================================
86 //function : Geom2d_Parabola
87 //purpose  : 
88 //=======================================================================
89
90 Geom2d_Parabola::Geom2d_Parabola (const gp_Ax22d& Axis, const Standard_Real Focal)
91 : focalLength (Focal) 
92 {
93   if (Focal < 0.0) { throw Standard_ConstructionError(); }
94   pos  = Axis;
95 }
96
97
98 //=======================================================================
99 //function : Geom2d_Parabola
100 //purpose  : 
101 //=======================================================================
102
103 Geom2d_Parabola::Geom2d_Parabola (const Ax2d& D, const Pnt2d& F) {
104
105   gp_Parab2d Prb (D, F);
106   pos = Prb.Axis();
107   focalLength = Prb.Focal();
108 }
109
110 //=======================================================================
111 //function : SetFocal
112 //purpose  : 
113 //=======================================================================
114
115 void Geom2d_Parabola::SetFocal (const Standard_Real Focal) 
116 {
117   if (Focal < 0.0) throw Standard_ConstructionError();
118   focalLength = Focal;
119 }
120
121
122 //=======================================================================
123 //function : SetParab2d
124 //purpose  : 
125 //=======================================================================
126
127 void Geom2d_Parabola::SetParab2d (const gp_Parab2d& Prb) 
128 {
129   focalLength = Prb.Focal ();
130   pos = Prb.Axis();
131 }
132
133 //=======================================================================
134 //function : Parab2d
135 //purpose  : 
136 //=======================================================================
137
138 gp_Parab2d Geom2d_Parabola::Parab2d () const 
139 {
140   return gp_Parab2d (pos, focalLength);
141 }
142
143 //=======================================================================
144 //function : ReversedParameter
145 //purpose  : 
146 //=======================================================================
147
148 Standard_Real Geom2d_Parabola::ReversedParameter( const Standard_Real U) const
149 {
150   return ( -U);
151 }
152
153 //=======================================================================
154 //function : FirstParameter
155 //purpose  : 
156 //=======================================================================
157
158 Standard_Real Geom2d_Parabola::FirstParameter () const   
159 {
160   return -Precision::Infinite(); 
161 }
162
163 //=======================================================================
164 //function : LastParameter
165 //purpose  : 
166 //=======================================================================
167
168 Standard_Real Geom2d_Parabola::LastParameter () const    
169 {
170   return Precision::Infinite(); 
171 }
172
173 //=======================================================================
174 //function : IsClosed
175 //purpose  : 
176 //=======================================================================
177
178 Standard_Boolean Geom2d_Parabola::IsClosed ()   const    
179 {
180   return Standard_False; 
181 }
182
183 //=======================================================================
184 //function : IsPeriodic
185 //purpose  : 
186 //=======================================================================
187
188 Standard_Boolean Geom2d_Parabola::IsPeriodic () const    
189 {
190   return Standard_False; 
191 }
192
193 //=======================================================================
194 //function : Directrix
195 //purpose  : 
196 //=======================================================================
197
198 Ax2d Geom2d_Parabola::Directrix () const 
199 {
200   gp_Parab2d Prb (pos, focalLength);
201   return Prb.Directrix();
202 }
203
204 //=======================================================================
205 //function : Eccentricity
206 //purpose  : 
207 //=======================================================================
208
209 Standard_Real Geom2d_Parabola::Eccentricity () const     
210 {
211   return 1.0; 
212 }
213
214 //=======================================================================
215 //function : Focus
216 //purpose  : 
217 //=======================================================================
218
219 Pnt2d Geom2d_Parabola::Focus () const 
220 {
221   XY Pxy = pos.XDirection().XY();
222   Pxy.Multiply (focalLength);
223   Pxy.Add (pos.Location().XY());
224   return Pnt2d (Pxy);
225 }
226
227 //=======================================================================
228 //function : Focal
229 //purpose  : 
230 //=======================================================================
231
232 Standard_Real Geom2d_Parabola::Focal () const            
233 {
234   return focalLength; 
235 }
236
237 //=======================================================================
238 //function : Parameter
239 //purpose  : 
240 //=======================================================================
241
242 Standard_Real Geom2d_Parabola::Parameter () const        
243 {
244   return 2.0 * focalLength; 
245 }
246
247 //=======================================================================
248 //function : D0
249 //purpose  : 
250 //=======================================================================
251
252 void Geom2d_Parabola::D0 (const Standard_Real   U,
253                                 Pnt2d& P) const 
254 {
255   P = ElCLib::ParabolaValue (U, pos, focalLength);
256 }
257
258 //=======================================================================
259 //function : D1
260 //purpose  : 
261 //=======================================================================
262
263 void Geom2d_Parabola::D1 (const Standard_Real U, Pnt2d& P, Vec2d& V1) const 
264 {
265   ElCLib::ParabolaD1 (U, pos, focalLength, P, V1);
266 }
267
268 //=======================================================================
269 //function : D2
270 //purpose  : 
271 //=======================================================================
272
273 void Geom2d_Parabola::D2 (const Standard_Real U, 
274                                 Pnt2d& P, 
275                                 Vec2d& V1, Vec2d& V2) const 
276 {
277   ElCLib::ParabolaD2 (U, pos, focalLength, P, V1, V2);
278 }
279
280 //=======================================================================
281 //function : D3
282 //purpose  : 
283 //=======================================================================
284
285 void Geom2d_Parabola::D3 (const Standard_Real U, 
286                                 Pnt2d& P, 
287                                 Vec2d& V1, Vec2d& V2, Vec2d& V3) const 
288 {
289    ElCLib::ParabolaD2 (U, pos, focalLength, P, V1, V2);
290    V3.SetCoord (0.0, 0.0);
291 }
292
293 //=======================================================================
294 //function : DN
295 //purpose  : 
296 //=======================================================================
297
298 Vec2d Geom2d_Parabola::DN (const Standard_Real U, const Standard_Integer N) const 
299 {
300    Standard_RangeError_Raise_if (N < 1, " ");
301    return ElCLib::ParabolaDN (U, pos, focalLength, N);
302 }
303
304
305 //=======================================================================
306 //function : Transform
307 //purpose  : 
308 //=======================================================================
309
310 void Geom2d_Parabola::Transform (const Trsf2d& T) 
311 {
312   focalLength *= Abs(T.ScaleFactor());
313    pos.Transform (T);
314 }
315
316 //=======================================================================
317 //function : TransformedParameter
318 //purpose  : 
319 //=======================================================================
320
321 Standard_Real Geom2d_Parabola::TransformedParameter(const Standard_Real U,
322                                                     const gp_Trsf2d& T) const
323 {
324   if (Precision::IsInfinite(U)) return U;
325   return U * Abs(T.ScaleFactor());
326 }
327
328 //=======================================================================
329 //function : ParametricTransformation
330 //purpose  : 
331 //=======================================================================
332
333 Standard_Real Geom2d_Parabola::ParametricTransformation(const gp_Trsf2d& T) const
334 {
335   return Abs(T.ScaleFactor());
336 }
337
338