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 <gp_Lin.hxx> |
16 | #include <Standard_ConstructionError.hxx> |
17 | |
18 | inline gp_Parab::gp_Parab () : |
19 | focalLength (RealLast()) |
20 | { } |
21 | |
22 | inline gp_Parab::gp_Parab (const gp_Ax2& A2, |
23 | const Standard_Real Focal) : |
24 | pos(A2), |
25 | focalLength (Focal) |
2d2b3d53 |
26 | { |
27 | Standard_ConstructionError_Raise_if (Focal < 0.0, "gp_Parab() - focal length should be >= 0"); |
28 | } |
7fd59977 |
29 | |
30 | inline gp_Parab::gp_Parab (const gp_Ax1& D, |
31 | const gp_Pnt& F) |
32 | { |
33 | gp_Lin Droite(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()), |
42 | Ax.Direction()); |
43 | } |
44 | |
45 | inline void gp_Parab::SetAxis (const gp_Ax1& A1) |
46 | { pos.SetAxis (A1); } |
47 | |
48 | inline void gp_Parab::SetFocal (const Standard_Real Focal) |
49 | { |
2d2b3d53 |
50 | Standard_ConstructionError_Raise_if (Focal < 0.0, "gp_Parab::SetFocal() - focal length should be >= 0"); |
7fd59977 |
51 | focalLength = Focal; |
52 | } |
53 | |
54 | inline void gp_Parab::SetLocation (const gp_Pnt& P) |
55 | { pos.SetLocation(P); } |
56 | |
57 | inline void gp_Parab::SetPosition (const gp_Ax2& A2) |
58 | { pos = A2; } |
59 | |
60 | inline const gp_Ax1& gp_Parab::Axis () const |
61 | { return pos.Axis(); } |
62 | |
63 | inline gp_Ax1 gp_Parab::Directrix() const |
64 | { |
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()); |
71 | } |
72 | |
73 | inline Standard_Real gp_Parab::Focal() const |
74 | { return focalLength; } |
75 | |
76 | inline gp_Pnt gp_Parab::Focus() const |
77 | { |
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()); |
83 | } |
84 | |
85 | inline const gp_Pnt& gp_Parab::Location () const |
86 | { return pos.Location(); } |
87 | |
88 | inline Standard_Real gp_Parab::Parameter() const |
89 | { return 2.0 * focalLength; } |
90 | |
91 | inline const gp_Ax2& gp_Parab::Position() const |
92 | { return pos; } |
93 | |
94 | inline gp_Ax1 gp_Parab::XAxis () const |
95 | { return gp_Ax1 (pos.Location(), pos.XDirection()); } |
96 | |
97 | inline gp_Ax1 gp_Parab::YAxis () const |
98 | { return gp_Ax1 (pos.Location(), pos.YDirection()); } |
99 | |
100 | inline void gp_Parab::Rotate (const gp_Ax1& A1, |
101 | const Standard_Real Ang) |
102 | { pos.Rotate (A1, Ang); } |
103 | |
104 | inline gp_Parab gp_Parab::Rotated (const gp_Ax1& A1, |
105 | const Standard_Real Ang) const |
106 | { |
107 | gp_Parab Prb = *this; |
108 | Prb.pos.Rotate (A1, Ang); |
109 | return Prb; |
110 | } |
111 | |
112 | inline void gp_Parab::Scale (const gp_Pnt& P, |
113 | const Standard_Real S) |
114 | { |
115 | focalLength *= S; |
116 | if (focalLength < 0) focalLength = - focalLength; |
117 | pos.Scale (P, S); |
118 | } |
119 | |
120 | inline gp_Parab gp_Parab::Scaled (const gp_Pnt& P, |
121 | const Standard_Real S) const |
122 | { |
123 | gp_Parab Prb = *this; |
124 | Prb.focalLength *= S; |
125 | if (Prb.focalLength < 0) Prb.focalLength = - Prb.focalLength; |
126 | Prb.pos.Scale (P, S); |
127 | return Prb; |
128 | } |
129 | |
130 | inline void gp_Parab::Transform (const gp_Trsf& T) |
131 | { |
132 | focalLength *= T.ScaleFactor(); |
133 | if (focalLength < 0) focalLength = - focalLength; |
134 | pos.Transform (T); |
135 | } |
136 | |
137 | inline gp_Parab gp_Parab::Transformed (const gp_Trsf& T) const |
138 | { |
139 | gp_Parab Prb = *this; |
140 | Prb.focalLength *= T.ScaleFactor(); |
141 | if (Prb.focalLength < 0) Prb.focalLength = - Prb.focalLength; |
142 | Prb.pos.Transform (T); |
143 | return Prb; |
144 | } |
145 | |
146 | inline void gp_Parab::Translate (const gp_Vec& V) |
147 | { pos.Translate (V); } |
148 | |
149 | inline gp_Parab gp_Parab::Translated (const gp_Vec& V) const |
150 | { |
151 | gp_Parab Prb = *this; |
152 | Prb.pos.Translate (V); |
153 | return Prb; |
154 | } |
155 | |
156 | inline void gp_Parab::Translate (const gp_Pnt& P1, |
157 | const gp_Pnt& P2) |
158 | { pos.Translate (P1, P2); } |
159 | |
160 | inline gp_Parab gp_Parab::Translated (const gp_Pnt& P1, |
161 | const gp_Pnt& P2) const |
162 | { |
163 | gp_Parab Prb = *this; |
164 | Prb.pos.Translate (P1, P2); |
165 | return Prb; |
166 | } |
167 | |