1 // Created on: 1993-03-24
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
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>
29 #include <Precision.hxx>
30 #include <Standard_ConstructionError.hxx>
31 #include <Standard_RangeError.hxx>
32 #include <Standard_Type.hxx>
34 IMPLEMENT_STANDARD_RTTIEXT(Geom2d_Parabola,Geom2d_Conic)
36 typedef Geom2d_Parabola Parabola;
38 typedef gp_Dir2d Dir2d;
39 typedef gp_Pnt2d Pnt2d;
40 typedef gp_Vec2d Vec2d;
41 typedef gp_Trsf2d Trsf2d;
44 //=======================================================================
47 //=======================================================================
49 Handle(Geom2d_Geometry) Geom2d_Parabola::Copy() const
51 Handle(Geom2d_Parabola) Prb;
52 Prb = new Parabola (pos, focalLength);
58 //=======================================================================
59 //function : Geom2d_Parabola
61 //=======================================================================
63 Geom2d_Parabola::Geom2d_Parabola (const gp_Parab2d& Prb)
65 focalLength = Prb.Focal ();
70 //=======================================================================
71 //function : Geom2d_Parabola
73 //=======================================================================
75 Geom2d_Parabola::Geom2d_Parabola (const Ax2d& MirrorAxis,
76 const Standard_Real Focal,
77 const Standard_Boolean Sense)
80 if (Focal < 0.0) { Standard_ConstructionError::Raise(); }
81 pos = gp_Ax22d(MirrorAxis, Sense);
85 //=======================================================================
86 //function : Geom2d_Parabola
88 //=======================================================================
90 Geom2d_Parabola::Geom2d_Parabola (const gp_Ax22d& Axis, const Standard_Real Focal)
93 if (Focal < 0.0) { Standard_ConstructionError::Raise(); }
98 //=======================================================================
99 //function : Geom2d_Parabola
101 //=======================================================================
103 Geom2d_Parabola::Geom2d_Parabola (const Ax2d& D, const Pnt2d& F) {
105 gp_Parab2d Prb (D, F);
107 focalLength = Prb.Focal();
110 //=======================================================================
111 //function : SetFocal
113 //=======================================================================
115 void Geom2d_Parabola::SetFocal (const Standard_Real Focal)
117 if (Focal < 0.0) Standard_ConstructionError::Raise();
122 //=======================================================================
123 //function : SetParab2d
125 //=======================================================================
127 void Geom2d_Parabola::SetParab2d (const gp_Parab2d& Prb)
129 focalLength = Prb.Focal ();
133 //=======================================================================
136 //=======================================================================
138 gp_Parab2d Geom2d_Parabola::Parab2d () const
140 return gp_Parab2d (pos, focalLength);
143 //=======================================================================
144 //function : ReversedParameter
146 //=======================================================================
148 Standard_Real Geom2d_Parabola::ReversedParameter( const Standard_Real U) const
153 //=======================================================================
154 //function : FirstParameter
156 //=======================================================================
158 Standard_Real Geom2d_Parabola::FirstParameter () const
160 return -Precision::Infinite();
163 //=======================================================================
164 //function : LastParameter
166 //=======================================================================
168 Standard_Real Geom2d_Parabola::LastParameter () const
170 return Precision::Infinite();
173 //=======================================================================
174 //function : IsClosed
176 //=======================================================================
178 Standard_Boolean Geom2d_Parabola::IsClosed () const
180 return Standard_False;
183 //=======================================================================
184 //function : IsPeriodic
186 //=======================================================================
188 Standard_Boolean Geom2d_Parabola::IsPeriodic () const
190 return Standard_False;
193 //=======================================================================
194 //function : Directrix
196 //=======================================================================
198 Ax2d Geom2d_Parabola::Directrix () const
200 gp_Parab2d Prb (pos, focalLength);
201 return Prb.Directrix();
204 //=======================================================================
205 //function : Eccentricity
207 //=======================================================================
209 Standard_Real Geom2d_Parabola::Eccentricity () const
214 //=======================================================================
217 //=======================================================================
219 Pnt2d Geom2d_Parabola::Focus () const
221 XY Pxy = pos.XDirection().XY();
222 Pxy.Multiply (focalLength);
223 Pxy.Add (pos.Location().XY());
227 //=======================================================================
230 //=======================================================================
232 Standard_Real Geom2d_Parabola::Focal () const
237 //=======================================================================
238 //function : Parameter
240 //=======================================================================
242 Standard_Real Geom2d_Parabola::Parameter () const
244 return 2.0 * focalLength;
247 //=======================================================================
250 //=======================================================================
252 void Geom2d_Parabola::D0 (const Standard_Real U,
255 P = ElCLib::ParabolaValue (U, pos, focalLength);
258 //=======================================================================
261 //=======================================================================
263 void Geom2d_Parabola::D1 (const Standard_Real U, Pnt2d& P, Vec2d& V1) const
265 ElCLib::ParabolaD1 (U, pos, focalLength, P, V1);
268 //=======================================================================
271 //=======================================================================
273 void Geom2d_Parabola::D2 (const Standard_Real U,
275 Vec2d& V1, Vec2d& V2) const
277 ElCLib::ParabolaD2 (U, pos, focalLength, P, V1, V2);
280 //=======================================================================
283 //=======================================================================
285 void Geom2d_Parabola::D3 (const Standard_Real U,
287 Vec2d& V1, Vec2d& V2, Vec2d& V3) const
289 ElCLib::ParabolaD2 (U, pos, focalLength, P, V1, V2);
290 V3.SetCoord (0.0, 0.0);
293 //=======================================================================
296 //=======================================================================
298 Vec2d Geom2d_Parabola::DN (const Standard_Real U, const Standard_Integer N) const
300 Standard_RangeError_Raise_if (N < 1, " ");
301 return ElCLib::ParabolaDN (U, pos, focalLength, N);
305 //=======================================================================
306 //function : Transform
308 //=======================================================================
310 void Geom2d_Parabola::Transform (const Trsf2d& T)
312 focalLength *= Abs(T.ScaleFactor());
316 //=======================================================================
317 //function : TransformedParameter
319 //=======================================================================
321 Standard_Real Geom2d_Parabola::TransformedParameter(const Standard_Real U,
322 const gp_Trsf2d& T) const
324 if (Precision::IsInfinite(U)) return U;
325 return U * Abs(T.ScaleFactor());
328 //=======================================================================
329 //function : ParametricTransformation
331 //=======================================================================
333 Standard_Real Geom2d_Parabola::ParametricTransformation(const gp_Trsf2d& T) const
335 return Abs(T.ScaleFactor());