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.
15 #include <Standard_ConstructionError.hxx>
17 inline gp_Parab2d::gp_Parab2d () :focalLength(RealLast()){ }
19 inline gp_Parab2d::gp_Parab2d(const gp_Ax22d& theMirrorAxis,
20 const Standard_Real theFocalLength) :
22 focalLength (theFocalLength)
24 Standard_ConstructionError_Raise_if (theFocalLength < 0.0, "gp_Parab2d() - focal length should be >= 0");
27 inline gp_Parab2d::gp_Parab2d(const gp_Ax2d& theMirrorAxis,
28 const Standard_Real theFocalLength,
29 const Standard_Boolean theSense) :
30 focalLength (theFocalLength)
32 pos = gp_Ax22d(theMirrorAxis,theSense);
33 Standard_ConstructionError_Raise_if (theFocalLength < 0.0, "gp_Parab2d() - focal length should be >= 0");
36 inline void gp_Parab2d::SetFocal (const Standard_Real Focal)
38 Standard_ConstructionError_Raise_if (Focal < 0.0, "gp_Parab2d::SetFocal() - focal length should be >= 0");
42 inline void gp_Parab2d::SetLocation (const gp_Pnt2d& P)
43 { pos.SetLocation(P); }
45 inline void gp_Parab2d::SetMirrorAxis (const gp_Ax2d& A)
48 inline void gp_Parab2d::SetAxis (const gp_Ax22d& A)
51 inline gp_Ax2d gp_Parab2d::Directrix() const
53 gp_Pnt2d P (pos.Location().X() - focalLength * pos.XDirection().X(),
54 pos.Location().Y() - focalLength * pos.XDirection().Y() );
55 gp_Dir2d V (pos.YDirection());
59 inline Standard_Real gp_Parab2d::Focal() const
60 { return focalLength; }
62 inline gp_Pnt2d gp_Parab2d::Focus() const
64 return gp_Pnt2d (pos.Location().X() + focalLength * pos.XDirection().X(),
65 pos.Location().Y() + focalLength * pos.XDirection().Y());
68 inline gp_Pnt2d gp_Parab2d::Location () const
69 { return pos.Location(); }
71 inline gp_Ax2d gp_Parab2d::MirrorAxis () const
72 { return pos.XAxis(); }
74 inline gp_Ax22d gp_Parab2d::Axis () const
77 inline Standard_Real gp_Parab2d::Parameter() const
78 { return 2.0 * focalLength; }
80 inline void gp_Parab2d::Reverse()
82 gp_Dir2d Temp = pos.YDirection ();
84 pos.SetAxis(gp_Ax22d(pos.Location(),pos.XDirection(),Temp));
87 inline gp_Parab2d gp_Parab2d::Reversed() const
90 gp_Dir2d Temp = pos.YDirection ();
92 P.pos.SetAxis(gp_Ax22d(pos.Location(),pos.XDirection(),Temp));
96 inline Standard_Boolean gp_Parab2d::IsDirect() const
97 { return (pos.XDirection().Crossed(pos.YDirection())) >= 0.0; }
99 inline void gp_Parab2d::Rotate (const gp_Pnt2d& P,
100 const Standard_Real Ang)
101 {pos.Rotate (P, Ang);}
103 inline gp_Parab2d gp_Parab2d::Rotated (const gp_Pnt2d& P,
104 const Standard_Real Ang) const
106 gp_Parab2d Prb = *this;
107 Prb.pos.Rotate (P, Ang);
111 inline void gp_Parab2d::Scale (const gp_Pnt2d& P,
112 const Standard_Real S)
115 if (focalLength < 0) focalLength = - focalLength;
119 inline gp_Parab2d gp_Parab2d::Scaled (const gp_Pnt2d& P,
120 const Standard_Real S) const
122 gp_Parab2d Prb = *this;
123 Prb.focalLength *= S;
124 if (Prb.focalLength < 0) Prb.focalLength = - Prb.focalLength;
125 Prb.pos.Scale (P, S);
129 inline void gp_Parab2d::Transform (const gp_Trsf2d& T)
131 focalLength *= T.ScaleFactor();
132 if (focalLength < 0) focalLength = - focalLength;
136 inline gp_Parab2d gp_Parab2d::Transformed (const gp_Trsf2d& T) const
138 gp_Parab2d Prb = *this;
139 Prb.focalLength *= T.ScaleFactor();
140 if (Prb.focalLength < 0) Prb.focalLength = - Prb.focalLength;
141 Prb.pos.Transform (T);
145 inline void gp_Parab2d::Translate (const gp_Vec2d& V)
146 { pos.Translate (V); }
148 inline gp_Parab2d gp_Parab2d::Translated (const gp_Vec2d& V) const
150 gp_Parab2d Prb = *this;
151 Prb.pos.Translate(V);
155 inline void gp_Parab2d::Translate (const gp_Pnt2d& P1,
157 { pos.Translate (P1, P2); }
159 inline gp_Parab2d gp_Parab2d::Translated (const gp_Pnt2d& P1,
160 const gp_Pnt2d& P2) const
162 gp_Parab2d Prb = *this;
163 Prb.pos.Translate (P1, P2);