1 // Created on: 1993-03-10
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 <Geom_Geometry.hxx>
20 #include <Geom_Parabola.hxx>
23 #include <gp_Parab.hxx>
25 #include <gp_Trsf.hxx>
28 #include <Precision.hxx>
29 #include <Standard_ConstructionError.hxx>
30 #include <Standard_RangeError.hxx>
31 #include <Standard_Type.hxx>
33 IMPLEMENT_STANDARD_RTTIEXT(Geom_Parabola,Geom_Conic)
35 typedef Geom_Parabola Parabola;
43 //=======================================================================
46 //=======================================================================
48 Handle(Geom_Geometry) Geom_Parabola::Copy() const {
50 Handle(Geom_Parabola) Prb;
51 Prb = new Parabola (pos, focalLength);
57 //=======================================================================
58 //function : Geom_Parabola
60 //=======================================================================
62 Geom_Parabola::Geom_Parabola (const gp_Parab& Prb)
63 : focalLength (Prb.Focal())
64 { pos = Prb.Position(); }
67 //=======================================================================
68 //function : Geom_Parabola
70 //=======================================================================
72 Geom_Parabola::Geom_Parabola (const Ax2& A2, const Standard_Real Focal)
73 : focalLength (Focal) {
75 if(Focal < 0.0) throw Standard_ConstructionError();
80 //=======================================================================
81 //function : Geom_Parabola
83 //=======================================================================
85 Geom_Parabola::Geom_Parabola (const Ax1& D, const Pnt& F) {
89 focalLength = Prb.Focal();
92 //=======================================================================
93 //function : ReversedParameter
95 //=======================================================================
97 Standard_Real Geom_Parabola::ReversedParameter( const Standard_Real U) const
103 //=======================================================================
104 //function : IsClosed
106 //=======================================================================
108 Standard_Boolean Geom_Parabola::IsClosed () const { return Standard_False; }
110 //=======================================================================
111 //function : IsPeriodic
113 //=======================================================================
115 Standard_Boolean Geom_Parabola::IsPeriodic () const { return Standard_False; }
117 //=======================================================================
118 //function : Eccentricity
120 //=======================================================================
122 Standard_Real Geom_Parabola::Eccentricity () const { return 1.0; }
124 //=======================================================================
125 //function : FirstParameter
127 //=======================================================================
129 Standard_Real Geom_Parabola::FirstParameter () const
130 { return -Precision::Infinite(); }
132 //=======================================================================
135 //=======================================================================
137 Standard_Real Geom_Parabola::Focal () const { return focalLength; }
139 //=======================================================================
140 //function : LastParameter
142 //=======================================================================
144 Standard_Real Geom_Parabola::LastParameter () const
145 { return Precision::Infinite(); }
147 //=======================================================================
148 //function : Parameter
150 //=======================================================================
152 Standard_Real Geom_Parabola::Parameter () const { return 2.0 * focalLength; }
154 //=======================================================================
155 //function : SetFocal
157 //=======================================================================
159 void Geom_Parabola::SetFocal (const Standard_Real Focal) {
161 if (Focal < 0.0) throw Standard_ConstructionError();
166 //=======================================================================
167 //function : SetParab
169 //=======================================================================
171 void Geom_Parabola::SetParab (const gp_Parab& Prb) {
173 focalLength = Prb.Focal ();
174 pos = Prb.Position ();
178 //=======================================================================
179 //function : Directrix
181 //=======================================================================
183 Ax1 Geom_Parabola::Directrix () const {
185 gp_Parab Prb (pos, focalLength);
186 return Prb.Directrix();
190 //=======================================================================
193 //=======================================================================
195 void Geom_Parabola::D0 (const Standard_Real U, Pnt& P) const {
197 P = ElCLib::ParabolaValue (U, pos, focalLength);
201 //=======================================================================
204 //=======================================================================
206 void Geom_Parabola::D1 (const Standard_Real U, Pnt& P, Vec& V1) const {
208 ElCLib::ParabolaD1 (U, pos, focalLength, P, V1);
212 //=======================================================================
215 //=======================================================================
217 void Geom_Parabola::D2 (const Standard_Real U, Pnt& P, Vec& V1, Vec& V2) const {
219 ElCLib::ParabolaD2 (U, pos, focalLength, P, V1, V2);
223 //=======================================================================
226 //=======================================================================
228 void Geom_Parabola::D3 (const Standard_Real U,
229 Pnt& P, Vec& V1, Vec& V2, Vec& V3) const {
231 ElCLib::ParabolaD2 (U, pos, focalLength, P, V1, V2);
232 V3.SetCoord (0.0, 0.0, 0.0);
236 //=======================================================================
239 //=======================================================================
241 Vec Geom_Parabola::DN (const Standard_Real U, const Standard_Integer N) const {
243 Standard_RangeError_Raise_if (N < 1, " ");
244 return ElCLib::ParabolaDN (U, pos, focalLength, N);
248 //=======================================================================
251 //=======================================================================
253 Pnt Geom_Parabola::Focus () const {
255 Standard_Real Xp, Yp, Zp, Xd, Yd, Zd;
256 pos.Location().Coord (Xp, Yp, Zp);
257 pos.XDirection().Coord (Xd, Yd, Zd);
258 return Pnt (Xp + focalLength*Xd, Yp + focalLength*Yd, Zp + focalLength*Zd);
262 //=======================================================================
265 //=======================================================================
267 gp_Parab Geom_Parabola::Parab () const {
269 return gp_Parab (pos, focalLength);
273 //=======================================================================
274 //function : Transform
276 //=======================================================================
278 void Geom_Parabola::Transform (const Trsf& T) {
280 focalLength *= Abs(T.ScaleFactor());
286 //=======================================================================
287 //function : TransformedParameter
289 //=======================================================================
291 Standard_Real Geom_Parabola::TransformedParameter(const Standard_Real U,
292 const gp_Trsf& T) const
294 if (Precision::IsInfinite(U)) return U;
295 return U * Abs(T.ScaleFactor());
299 //=======================================================================
300 //function : TransformedParameter
302 //=======================================================================
304 Standard_Real Geom_Parabola::ParametricTransformation(const gp_Trsf& T) const
306 return Abs(T.ScaleFactor());