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