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