1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
16 #include <Standard_ConstructionError.hxx>
18 inline gp_Parab::gp_Parab () :
19 focalLength (RealLast())
22 inline gp_Parab::gp_Parab (const gp_Ax2& A2,
23 const Standard_Real Focal) :
27 Standard_ConstructionError_Raise_if (Focal < 0.0, "gp_Parab() - focal length should be >= 0");
30 inline gp_Parab::gp_Parab (const gp_Ax1& D,
34 focalLength = Droite.Distance(F) / 2.;
35 gp_Ax1 Ax = Droite.Normal(F).Position();
36 gp_Ax1 Ay = Droite.Position();
37 const gp_Dir& DD = Ax.Direction();
38 pos = gp_Ax2 (gp_Pnt(F.X() - focalLength * DD.X(),
39 F.Y() - focalLength * DD.Y(),
40 F.Z() - focalLength * DD.Z()),
41 Ax.Direction().Crossed(Ay.Direction()),
45 inline void gp_Parab::SetAxis (const gp_Ax1& A1)
48 inline void gp_Parab::SetFocal (const Standard_Real Focal)
50 Standard_ConstructionError_Raise_if (Focal < 0.0, "gp_Parab::SetFocal() - focal length should be >= 0");
54 inline void gp_Parab::SetLocation (const gp_Pnt& P)
55 { pos.SetLocation(P); }
57 inline void gp_Parab::SetPosition (const gp_Ax2& A2)
60 inline const gp_Ax1& gp_Parab::Axis () const
61 { return pos.Axis(); }
63 inline gp_Ax1 gp_Parab::Directrix() const
65 const gp_Pnt& PP = pos.Location ();
66 const gp_Dir& DD = pos.XDirection();
67 gp_Pnt P (PP.X() - focalLength * DD.X(),
68 PP.Y() - focalLength * DD.Y(),
69 PP.Z() - focalLength * DD.Z());
70 return gp_Ax1 (P, pos.YDirection());
73 inline Standard_Real gp_Parab::Focal() const
74 { return focalLength; }
76 inline gp_Pnt gp_Parab::Focus() const
78 const gp_Pnt& PP = pos.Location ();
79 const gp_Dir& DD = pos.XDirection();
80 return gp_Pnt (PP.X() + focalLength * DD.X(),
81 PP.Y() + focalLength * DD.Y(),
82 PP.Z() + focalLength * DD.Z());
85 inline const gp_Pnt& gp_Parab::Location () const
86 { return pos.Location(); }
88 inline Standard_Real gp_Parab::Parameter() const
89 { return 2.0 * focalLength; }
91 inline const gp_Ax2& gp_Parab::Position() const
94 inline gp_Ax1 gp_Parab::XAxis () const
95 { return gp_Ax1 (pos.Location(), pos.XDirection()); }
97 inline gp_Ax1 gp_Parab::YAxis () const
98 { return gp_Ax1 (pos.Location(), pos.YDirection()); }
100 inline void gp_Parab::Rotate (const gp_Ax1& A1,
101 const Standard_Real Ang)
102 { pos.Rotate (A1, Ang); }
104 inline gp_Parab gp_Parab::Rotated (const gp_Ax1& A1,
105 const Standard_Real Ang) const
107 gp_Parab Prb = *this;
108 Prb.pos.Rotate (A1, Ang);
112 inline void gp_Parab::Scale (const gp_Pnt& P,
113 const Standard_Real S)
116 if (focalLength < 0) focalLength = - focalLength;
120 inline gp_Parab gp_Parab::Scaled (const gp_Pnt& P,
121 const Standard_Real S) const
123 gp_Parab Prb = *this;
124 Prb.focalLength *= S;
125 if (Prb.focalLength < 0) Prb.focalLength = - Prb.focalLength;
126 Prb.pos.Scale (P, S);
130 inline void gp_Parab::Transform (const gp_Trsf& T)
132 focalLength *= T.ScaleFactor();
133 if (focalLength < 0) focalLength = - focalLength;
137 inline gp_Parab gp_Parab::Transformed (const gp_Trsf& T) const
139 gp_Parab Prb = *this;
140 Prb.focalLength *= T.ScaleFactor();
141 if (Prb.focalLength < 0) Prb.focalLength = - Prb.focalLength;
142 Prb.pos.Transform (T);
146 inline void gp_Parab::Translate (const gp_Vec& V)
147 { pos.Translate (V); }
149 inline gp_Parab gp_Parab::Translated (const gp_Vec& V) const
151 gp_Parab Prb = *this;
152 Prb.pos.Translate (V);
156 inline void gp_Parab::Translate (const gp_Pnt& P1,
158 { pos.Translate (P1, P2); }
160 inline gp_Parab gp_Parab::Translated (const gp_Pnt& P1,
161 const gp_Pnt& P2) const
163 gp_Parab Prb = *this;
164 Prb.pos.Translate (P1, P2);