0026936: Drawbacks of inlining in new type system in OCCT 7.0 -- automatic
[occt.git] / src / Geom / Geom_Parabola.cxx
CommitLineData
b311480e 1// Created on: 1993-03-10
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 <Geom_Geometry.hxx>
20#include <Geom_Parabola.hxx>
21#include <gp_Ax1.hxx>
22#include <gp_Ax2.hxx>
23#include <gp_Parab.hxx>
24#include <gp_Pnt.hxx>
25#include <gp_Trsf.hxx>
26#include <gp_Vec.hxx>
7fd59977 27#include <gp_XYZ.hxx>
42cf5bc1 28#include <Precision.hxx>
7fd59977 29#include <Standard_ConstructionError.hxx>
30#include <Standard_RangeError.hxx>
42cf5bc1 31#include <Standard_Type.hxx>
7fd59977 32
92efcf78 33IMPLEMENT_STANDARD_RTTIEXT(Geom_Parabola,Geom_Conic)
34
7fd59977 35typedef Geom_Parabola Parabola;
7fd59977 36typedef gp_Ax1 Ax1;
37typedef gp_Ax2 Ax2;
38typedef gp_Pnt Pnt;
39typedef gp_Trsf Trsf;
40typedef gp_Vec Vec;
41typedef gp_XYZ XYZ;
42
7fd59977 43//=======================================================================
44//function : Copy
45//purpose :
46//=======================================================================
47
48Handle(Geom_Geometry) Geom_Parabola::Copy() const {
49
c04c30b3 50 Handle(Geom_Parabola) Prb;
7fd59977 51 Prb = new Parabola (pos, focalLength);
52 return Prb;
53}
54
55
56
57//=======================================================================
58//function : Geom_Parabola
59//purpose :
60//=======================================================================
61
62Geom_Parabola::Geom_Parabola (const gp_Parab& Prb)
63 : focalLength (Prb.Focal())
64{ pos = Prb.Position(); }
65
66
67//=======================================================================
68//function : Geom_Parabola
69//purpose :
70//=======================================================================
71
72Geom_Parabola::Geom_Parabola (const Ax2& A2, const Standard_Real Focal)
73 : focalLength (Focal) {
74
75 if(Focal < 0.0) Standard_ConstructionError::Raise();
76 pos = A2;
77}
78
79
80//=======================================================================
81//function : Geom_Parabola
82//purpose :
83//=======================================================================
84
85Geom_Parabola::Geom_Parabola (const Ax1& D, const Pnt& F) {
86
87 gp_Parab Prb (D, F);
88 pos = Prb.Position();
89 focalLength = Prb.Focal();
90}
91
92//=======================================================================
93//function : ReversedParameter
94//purpose :
95//=======================================================================
96
97Standard_Real Geom_Parabola::ReversedParameter( const Standard_Real U) const
98{
99 return (-U);
100}
101
102
103//=======================================================================
104//function : IsClosed
105//purpose :
106//=======================================================================
107
108Standard_Boolean Geom_Parabola::IsClosed () const { return Standard_False; }
109
110//=======================================================================
111//function : IsPeriodic
112//purpose :
113//=======================================================================
114
115Standard_Boolean Geom_Parabola::IsPeriodic () const { return Standard_False; }
116
117//=======================================================================
118//function : Eccentricity
119//purpose :
120//=======================================================================
121
122Standard_Real Geom_Parabola::Eccentricity () const { return 1.0; }
123
124//=======================================================================
125//function : FirstParameter
126//purpose :
127//=======================================================================
128
129Standard_Real Geom_Parabola::FirstParameter () const
130{ return -Precision::Infinite(); }
131
132//=======================================================================
133//function : Focal
134//purpose :
135//=======================================================================
136
137Standard_Real Geom_Parabola::Focal () const { return focalLength; }
138
139//=======================================================================
140//function : LastParameter
141//purpose :
142//=======================================================================
143
144Standard_Real Geom_Parabola::LastParameter () const
145{ return Precision::Infinite(); }
146
147//=======================================================================
148//function : Parameter
149//purpose :
150//=======================================================================
151
152Standard_Real Geom_Parabola::Parameter () const { return 2.0 * focalLength; }
153
154//=======================================================================
155//function : SetFocal
156//purpose :
157//=======================================================================
158
159void Geom_Parabola::SetFocal (const Standard_Real Focal) {
160
161 if (Focal < 0.0) Standard_ConstructionError::Raise();
162 focalLength = Focal;
163}
164
165
166//=======================================================================
167//function : SetParab
168//purpose :
169//=======================================================================
170
171void Geom_Parabola::SetParab (const gp_Parab& Prb) {
172
173 focalLength = Prb.Focal ();
174 pos = Prb.Position ();
175}
176
177
178//=======================================================================
179//function : Directrix
180//purpose :
181//=======================================================================
182
183Ax1 Geom_Parabola::Directrix () const {
184
185 gp_Parab Prb (pos, focalLength);
186 return Prb.Directrix();
187}
188
189
190//=======================================================================
191//function : D0
192//purpose :
193//=======================================================================
194
195void Geom_Parabola::D0 (const Standard_Real U, Pnt& P) const {
196
197 P = ElCLib::ParabolaValue (U, pos, focalLength);
198}
199
200
201//=======================================================================
202//function : D1
203//purpose :
204//=======================================================================
205
206void Geom_Parabola::D1 (const Standard_Real U, Pnt& P, Vec& V1) const {
207
208 ElCLib::ParabolaD1 (U, pos, focalLength, P, V1);
209}
210
211
212//=======================================================================
213//function : D2
214//purpose :
215//=======================================================================
216
217void Geom_Parabola::D2 (const Standard_Real U, Pnt& P, Vec& V1, Vec& V2) const {
218
219 ElCLib::ParabolaD2 (U, pos, focalLength, P, V1, V2);
220}
221
222
223//=======================================================================
224//function : D3
225//purpose :
226//=======================================================================
227
228void Geom_Parabola::D3 (const Standard_Real U,
229 Pnt& P, Vec& V1, Vec& V2, Vec& V3) const {
230
231 ElCLib::ParabolaD2 (U, pos, focalLength, P, V1, V2);
232 V3.SetCoord (0.0, 0.0, 0.0);
233}
234
235
236//=======================================================================
237//function : DN
238//purpose :
239//=======================================================================
240
241Vec Geom_Parabola::DN (const Standard_Real U, const Standard_Integer N) const {
242
243 Standard_RangeError_Raise_if (N < 1, " ");
244 return ElCLib::ParabolaDN (U, pos, focalLength, N);
245}
246
247
248//=======================================================================
249//function : Focus
250//purpose :
251//=======================================================================
252
253Pnt Geom_Parabola::Focus () const {
254
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);
259}
260
261
262//=======================================================================
263//function : Parab
264//purpose :
265//=======================================================================
266
267gp_Parab Geom_Parabola::Parab () const {
268
269 return gp_Parab (pos, focalLength);
270}
271
272
273//=======================================================================
274//function : Transform
275//purpose :
276//=======================================================================
277
278void Geom_Parabola::Transform (const Trsf& T) {
279
280 focalLength *= Abs(T.ScaleFactor());
281 pos.Transform (T);
282}
283
284
285
286//=======================================================================
287//function : TransformedParameter
288//purpose :
289//=======================================================================
290
291Standard_Real Geom_Parabola::TransformedParameter(const Standard_Real U,
292 const gp_Trsf& T) const
293{
294 if (Precision::IsInfinite(U)) return U;
295 return U * Abs(T.ScaleFactor());
296}
297
298
299//=======================================================================
300//function : TransformedParameter
301//purpose :
302//=======================================================================
303
304Standard_Real Geom_Parabola::ParametricTransformation(const gp_Trsf& T) const
305{
306 return Abs(T.ScaleFactor());
307}
308
309