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 typedef Geom2d_Parabola Parabola;
36 typedef gp_Dir2d Dir2d;
37 typedef gp_Pnt2d Pnt2d;
38 typedef gp_Vec2d Vec2d;
39 typedef gp_Trsf2d Trsf2d;
42 //=======================================================================
45 //=======================================================================
47 Handle(Geom2d_Geometry) Geom2d_Parabola::Copy() const
49 Handle(Geom2d_Parabola) Prb;
50 Prb = new Parabola (pos, focalLength);
56 //=======================================================================
57 //function : Geom2d_Parabola
59 //=======================================================================
61 Geom2d_Parabola::Geom2d_Parabola (const gp_Parab2d& Prb)
63 focalLength = Prb.Focal ();
68 //=======================================================================
69 //function : Geom2d_Parabola
71 //=======================================================================
73 Geom2d_Parabola::Geom2d_Parabola (const Ax2d& MirrorAxis,
74 const Standard_Real Focal,
75 const Standard_Boolean Sense)
78 if (Focal < 0.0) { Standard_ConstructionError::Raise(); }
79 pos = gp_Ax22d(MirrorAxis, Sense);
83 //=======================================================================
84 //function : Geom2d_Parabola
86 //=======================================================================
88 Geom2d_Parabola::Geom2d_Parabola (const gp_Ax22d& Axis, const Standard_Real Focal)
91 if (Focal < 0.0) { Standard_ConstructionError::Raise(); }
96 //=======================================================================
97 //function : Geom2d_Parabola
99 //=======================================================================
101 Geom2d_Parabola::Geom2d_Parabola (const Ax2d& D, const Pnt2d& F) {
103 gp_Parab2d Prb (D, F);
105 focalLength = Prb.Focal();
108 //=======================================================================
109 //function : SetFocal
111 //=======================================================================
113 void Geom2d_Parabola::SetFocal (const Standard_Real Focal)
115 if (Focal < 0.0) Standard_ConstructionError::Raise();
120 //=======================================================================
121 //function : SetParab2d
123 //=======================================================================
125 void Geom2d_Parabola::SetParab2d (const gp_Parab2d& Prb)
127 focalLength = Prb.Focal ();
131 //=======================================================================
134 //=======================================================================
136 gp_Parab2d Geom2d_Parabola::Parab2d () const
138 return gp_Parab2d (pos, focalLength);
141 //=======================================================================
142 //function : ReversedParameter
144 //=======================================================================
146 Standard_Real Geom2d_Parabola::ReversedParameter( const Standard_Real U) const
151 //=======================================================================
152 //function : FirstParameter
154 //=======================================================================
156 Standard_Real Geom2d_Parabola::FirstParameter () const
158 return -Precision::Infinite();
161 //=======================================================================
162 //function : LastParameter
164 //=======================================================================
166 Standard_Real Geom2d_Parabola::LastParameter () const
168 return Precision::Infinite();
171 //=======================================================================
172 //function : IsClosed
174 //=======================================================================
176 Standard_Boolean Geom2d_Parabola::IsClosed () const
178 return Standard_False;
181 //=======================================================================
182 //function : IsPeriodic
184 //=======================================================================
186 Standard_Boolean Geom2d_Parabola::IsPeriodic () const
188 return Standard_False;
191 //=======================================================================
192 //function : Directrix
194 //=======================================================================
196 Ax2d Geom2d_Parabola::Directrix () const
198 gp_Parab2d Prb (pos, focalLength);
199 return Prb.Directrix();
202 //=======================================================================
203 //function : Eccentricity
205 //=======================================================================
207 Standard_Real Geom2d_Parabola::Eccentricity () const
212 //=======================================================================
215 //=======================================================================
217 Pnt2d Geom2d_Parabola::Focus () const
219 XY Pxy = pos.XDirection().XY();
220 Pxy.Multiply (focalLength);
221 Pxy.Add (pos.Location().XY());
225 //=======================================================================
228 //=======================================================================
230 Standard_Real Geom2d_Parabola::Focal () const
235 //=======================================================================
236 //function : Parameter
238 //=======================================================================
240 Standard_Real Geom2d_Parabola::Parameter () const
242 return 2.0 * focalLength;
245 //=======================================================================
248 //=======================================================================
250 void Geom2d_Parabola::D0 (const Standard_Real U,
253 P = ElCLib::ParabolaValue (U, pos, focalLength);
256 //=======================================================================
259 //=======================================================================
261 void Geom2d_Parabola::D1 (const Standard_Real U, Pnt2d& P, Vec2d& V1) const
263 ElCLib::ParabolaD1 (U, pos, focalLength, P, V1);
266 //=======================================================================
269 //=======================================================================
271 void Geom2d_Parabola::D2 (const Standard_Real U,
273 Vec2d& V1, Vec2d& V2) const
275 ElCLib::ParabolaD2 (U, pos, focalLength, P, V1, V2);
278 //=======================================================================
281 //=======================================================================
283 void Geom2d_Parabola::D3 (const Standard_Real U,
285 Vec2d& V1, Vec2d& V2, Vec2d& V3) const
287 ElCLib::ParabolaD2 (U, pos, focalLength, P, V1, V2);
288 V3.SetCoord (0.0, 0.0);
291 //=======================================================================
294 //=======================================================================
296 Vec2d Geom2d_Parabola::DN (const Standard_Real U, const Standard_Integer N) const
298 Standard_RangeError_Raise_if (N < 1, " ");
299 return ElCLib::ParabolaDN (U, pos, focalLength, N);
303 //=======================================================================
304 //function : Transform
306 //=======================================================================
308 void Geom2d_Parabola::Transform (const Trsf2d& T)
310 focalLength *= Abs(T.ScaleFactor());
314 //=======================================================================
315 //function : TransformedParameter
317 //=======================================================================
319 Standard_Real Geom2d_Parabola::TransformedParameter(const Standard_Real U,
320 const gp_Trsf2d& T) const
322 if (Precision::IsInfinite(U)) return U;
323 return U * Abs(T.ScaleFactor());
326 //=======================================================================
327 //function : ParametricTransformation
329 //=======================================================================
331 Standard_Real Geom2d_Parabola::ParametricTransformation(const gp_Trsf2d& T) const
333 return Abs(T.ScaleFactor());