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.hxx> |
16 | #include <Standard_ConstructionError.hxx> |
17 | |
18 | inline gp_Cone::gp_Cone () : |
19 | radius (RealLast()), |
c6541a0c |
20 | semiAngle (M_PI * 0.25) |
7fd59977 |
21 | { } |
22 | |
23 | inline gp_Cone::gp_Cone (const gp_Ax3& A3, |
24 | const Standard_Real Ang, |
25 | const Standard_Real Radius) : |
26 | pos(A3), |
27 | radius (Radius), |
28 | semiAngle (Ang) |
29 | { |
30 | Standard_Real val = Ang; |
31 | if (val < 0) val = - val; |
32 | Standard_ConstructionError_Raise_if |
33 | (radius < 0. || |
34 | val <= gp::Resolution() || |
2d2b3d53 |
35 | M_PI * 0.5 - val <= gp::Resolution(), "gp_Cone() - invalid construction parameters"); |
7fd59977 |
36 | } |
37 | |
38 | inline void gp_Cone::SetAxis (const gp_Ax1& A1) |
39 | { pos.SetAxis (A1); } |
40 | |
41 | inline void gp_Cone::SetLocation (const gp_Pnt& Loc) |
42 | { pos.SetLocation (Loc); } |
43 | |
44 | inline void gp_Cone::SetPosition (const gp_Ax3& A3) |
45 | { pos = A3; } |
46 | |
47 | inline void gp_Cone::SetRadius (const Standard_Real R) |
48 | { |
2d2b3d53 |
49 | Standard_ConstructionError_Raise_if (R < 0.0, "gp_Cone::SetRadius() - radius should be positive number"); |
7fd59977 |
50 | radius = R; |
51 | } |
52 | |
53 | inline void gp_Cone::SetSemiAngle (const Standard_Real Ang) |
54 | { |
55 | Standard_Real val = Ang; |
56 | if (val < 0) val = - val; |
57 | Standard_ConstructionError_Raise_if |
58 | (val <= gp::Resolution() || |
2d2b3d53 |
59 | M_PI * 0.5 - val <= gp::Resolution(), "gp_Cone::SetSemiAngle() - invalid angle range"); |
7fd59977 |
60 | semiAngle = Ang; |
61 | } |
62 | |
63 | inline gp_Pnt gp_Cone::Apex () const |
64 | { |
65 | gp_XYZ Coord = pos.Direction ().XYZ (); |
66 | Coord.Multiply (-radius / Tan (semiAngle)); |
67 | Coord.Add (pos.Location ().XYZ()); |
68 | return gp_Pnt (Coord); |
69 | } |
70 | |
71 | inline void gp_Cone::UReverse() |
72 | { pos.YReverse(); } |
73 | |
74 | inline void gp_Cone::VReverse() |
75 | { pos.ZReverse(); semiAngle = -semiAngle; } |
76 | |
77 | inline Standard_Boolean gp_Cone::Direct() const |
78 | { return pos.Direct(); } |
79 | |
80 | inline const gp_Ax1& gp_Cone::Axis () const |
81 | { return pos.Axis(); } |
82 | |
83 | inline const gp_Pnt& gp_Cone::Location () const |
84 | { return pos.Location(); } |
85 | |
86 | inline const gp_Ax3& gp_Cone::Position () const |
87 | { return pos; } |
88 | |
89 | inline Standard_Real gp_Cone::RefRadius () const |
90 | { return radius; } |
91 | |
92 | inline Standard_Real gp_Cone::SemiAngle () const |
93 | { return semiAngle; } |
94 | |
95 | inline gp_Ax1 gp_Cone::XAxis () const |
96 | { return gp_Ax1 (pos.Location(), pos.XDirection()); } |
97 | |
98 | inline gp_Ax1 gp_Cone::YAxis () const |
99 | { return gp_Ax1 (pos.Location(), pos.YDirection()); } |
100 | |
101 | inline void gp_Cone::Rotate (const gp_Ax1& A1, |
102 | const Standard_Real Ang) |
103 | {pos.Rotate (A1, Ang);} |
104 | |
105 | inline gp_Cone gp_Cone::Rotated (const gp_Ax1& A1, |
106 | const Standard_Real Ang) const |
107 | { |
108 | gp_Cone C = *this; |
109 | C.pos.Rotate (A1, Ang); |
110 | return C; |
111 | } |
112 | |
113 | inline void gp_Cone::Scale (const gp_Pnt& P, |
114 | const Standard_Real S) |
115 | { |
116 | pos.Scale (P, S); |
117 | radius *= S; |
118 | if (radius < 0) radius = - radius; |
119 | } |
120 | |
121 | inline gp_Cone gp_Cone::Scaled (const gp_Pnt& P, |
122 | const Standard_Real S) const |
123 | { |
124 | gp_Cone C = *this; |
125 | C.pos.Scale (P, S); |
126 | C.radius *= S; |
127 | if (C.radius < 0) C.radius = - C.radius; |
128 | return C; |
129 | } |
130 | |
131 | inline void gp_Cone::Transform (const gp_Trsf& T) |
132 | { |
133 | pos.Transform (T); |
134 | radius *= T.ScaleFactor(); |
135 | if (radius < 0) radius = - radius; |
136 | } |
137 | |
138 | inline gp_Cone gp_Cone::Transformed (const gp_Trsf& T) const |
139 | { |
140 | gp_Cone C = *this; |
141 | C.pos.Transform (T); |
142 | C.radius *= T.ScaleFactor(); |
143 | if (C.radius < 0) C.radius = - C.radius; |
144 | return C; |
145 | } |
146 | |
147 | inline void gp_Cone::Translate (const gp_Vec& V) |
148 | { pos.Translate (V); } |
149 | |
150 | inline gp_Cone gp_Cone::Translated (const gp_Vec& V) const |
151 | { |
152 | gp_Cone C = *this; |
153 | C.pos.Translate (V); |
154 | return C; |
155 | } |
156 | |
157 | inline void gp_Cone::Translate (const gp_Pnt& P1, |
158 | const gp_Pnt& P2) |
159 | { pos.Translate (P1, P2); } |
160 | |
161 | inline gp_Cone gp_Cone::Translated (const gp_Pnt& P1, |
162 | const gp_Pnt& P2) const |
163 | { |
164 | gp_Cone C = *this; |
165 | C.pos.Translate (P1, P2); |
166 | return C; |
167 | } |
168 | |