b311480e |
1 | // Copyright (c) 1995-1999 Matra Datavision |
973c2be1 |
2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
3 | // |
973c2be1 |
4 | // This file is part of Open CASCADE Technology software library. |
b311480e |
5 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
11 | // |
973c2be1 |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
7fd59977 |
14 | |
15 | #include <Standard_ConstructionError.hxx> |
16 | |
c1609fbe |
17 | inline gp_Parab2d::gp_Parab2d () :focalLength(RealLast()){ } |
18 | |
19 | inline gp_Parab2d::gp_Parab2d(const gp_Ax22d& theMirrorAxis, |
20 | const Standard_Real theFocalLength) : |
21 | pos (theMirrorAxis), |
22 | focalLength (theFocalLength) |
7fd59977 |
23 | { |
c1609fbe |
24 | Standard_ConstructionError_Raise_if(theFocalLength < 0.0,""); |
25 | } |
26 | |
27 | inline gp_Parab2d::gp_Parab2d(const gp_Ax2d& theMirrorAxis, |
28 | const Standard_Real theFocalLength, |
29 | const Standard_Boolean theSense) : |
30 | focalLength (theFocalLength) |
31 | { |
32 | pos = gp_Ax22d(theMirrorAxis,theSense); |
33 | Standard_ConstructionError_Raise_if(theFocalLength < 0.0,""); |
7fd59977 |
34 | } |
35 | |
36 | inline void gp_Parab2d::SetFocal (const Standard_Real Focal) |
37 | { |
38 | Standard_ConstructionError_Raise_if(Focal < 0.0,""); |
39 | focalLength = Focal; |
40 | } |
41 | |
42 | inline void gp_Parab2d::SetLocation (const gp_Pnt2d& P) |
43 | { pos.SetLocation(P); } |
44 | |
45 | inline void gp_Parab2d::SetMirrorAxis (const gp_Ax2d& A) |
46 | { pos.SetXAxis(A); } |
47 | |
48 | inline void gp_Parab2d::SetAxis (const gp_Ax22d& A) |
49 | { pos.SetAxis(A); } |
50 | |
51 | inline gp_Ax2d gp_Parab2d::Directrix() const |
52 | { |
53 | gp_Pnt2d P (pos.Location().X() - focalLength * pos.XDirection().X(), |
54 | pos.Location().Y() - focalLength * pos.XDirection().Y() ); |
c1609fbe |
55 | gp_Dir2d V (pos.YDirection()); |
56 | return gp_Ax2d(P, V); |
7fd59977 |
57 | } |
58 | |
59 | inline Standard_Real gp_Parab2d::Focal() const |
60 | { return focalLength; } |
61 | |
62 | inline gp_Pnt2d gp_Parab2d::Focus() const |
63 | { |
64 | return gp_Pnt2d (pos.Location().X() + focalLength * pos.XDirection().X(), |
65 | pos.Location().Y() + focalLength * pos.XDirection().Y()); |
66 | } |
67 | |
68 | inline gp_Pnt2d gp_Parab2d::Location () const |
69 | { return pos.Location(); } |
70 | |
71 | inline gp_Ax2d gp_Parab2d::MirrorAxis () const |
72 | { return pos.XAxis(); } |
73 | |
74 | inline gp_Ax22d gp_Parab2d::Axis () const |
75 | { return pos; } |
76 | |
77 | inline Standard_Real gp_Parab2d::Parameter() const |
78 | { return 2.0 * focalLength; } |
79 | |
80 | inline void gp_Parab2d::Reverse() |
81 | { |
82 | gp_Dir2d Temp = pos.YDirection (); |
83 | Temp.Reverse (); |
84 | pos.SetAxis(gp_Ax22d(pos.Location(),pos.XDirection(),Temp)); |
85 | } |
86 | |
87 | inline gp_Parab2d gp_Parab2d::Reversed() const |
88 | { |
89 | gp_Parab2d P = *this; |
90 | gp_Dir2d Temp = pos.YDirection (); |
91 | Temp.Reverse (); |
92 | P.pos.SetAxis(gp_Ax22d(pos.Location(),pos.XDirection(),Temp)); |
93 | return P; |
94 | } |
95 | |
96 | inline Standard_Boolean gp_Parab2d::IsDirect() const |
97 | { return (pos.XDirection().Crossed(pos.YDirection())) >= 0.0; } |
98 | |
99 | inline void gp_Parab2d::Rotate (const gp_Pnt2d& P, |
100 | const Standard_Real Ang) |
101 | {pos.Rotate (P, Ang);} |
102 | |
103 | inline gp_Parab2d gp_Parab2d::Rotated (const gp_Pnt2d& P, |
104 | const Standard_Real Ang) const |
105 | { |
106 | gp_Parab2d Prb = *this; |
107 | Prb.pos.Rotate (P, Ang); |
108 | return Prb; |
109 | } |
110 | |
111 | inline void gp_Parab2d::Scale (const gp_Pnt2d& P, |
112 | const Standard_Real S) |
113 | { |
114 | focalLength *= S; |
115 | if (focalLength < 0) focalLength = - focalLength; |
116 | pos.Scale (P, S); |
117 | } |
118 | |
119 | inline gp_Parab2d gp_Parab2d::Scaled (const gp_Pnt2d& P, |
120 | const Standard_Real S) const |
121 | { |
122 | gp_Parab2d Prb = *this; |
123 | Prb.focalLength *= S; |
124 | if (Prb.focalLength < 0) Prb.focalLength = - Prb.focalLength; |
125 | Prb.pos.Scale (P, S); |
126 | return Prb; |
127 | } |
128 | |
129 | inline void gp_Parab2d::Transform (const gp_Trsf2d& T) |
130 | { |
131 | focalLength *= T.ScaleFactor(); |
132 | if (focalLength < 0) focalLength = - focalLength; |
133 | pos.Transform (T); |
134 | } |
135 | |
136 | inline gp_Parab2d gp_Parab2d::Transformed (const gp_Trsf2d& T) const |
137 | { |
138 | gp_Parab2d Prb = *this; |
139 | Prb.focalLength *= T.ScaleFactor(); |
140 | if (Prb.focalLength < 0) Prb.focalLength = - Prb.focalLength; |
141 | Prb.pos.Transform (T); |
142 | return Prb; |
143 | } |
144 | |
145 | inline void gp_Parab2d::Translate (const gp_Vec2d& V) |
146 | { pos.Translate (V); } |
147 | |
148 | inline gp_Parab2d gp_Parab2d::Translated (const gp_Vec2d& V) const |
149 | { |
150 | gp_Parab2d Prb = *this; |
151 | Prb.pos.Translate(V); |
152 | return Prb; |
153 | } |
154 | |
155 | inline void gp_Parab2d::Translate (const gp_Pnt2d& P1, |
156 | const gp_Pnt2d& P2) |
157 | { pos.Translate (P1, P2); } |
158 | |
159 | inline gp_Parab2d gp_Parab2d::Translated (const gp_Pnt2d& P1, |
160 | const gp_Pnt2d& P2) const |
161 | { |
162 | gp_Parab2d Prb = *this; |
163 | Prb.pos.Translate (P1, P2); |
164 | return Prb; |
165 | } |
166 | |