b311480e |
1 | // Copyright (c) 1995-1999 Matra Datavision |
2 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
3 | // |
4 | // The content of this file is subject to the Open CASCADE Technology Public |
5 | // License Version 6.5 (the "License"). You may not use the content of this file |
6 | // except in compliance with the License. Please obtain a copy of the License |
7 | // at http://www.opencascade.org and read it completely before using this file. |
8 | // |
9 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
10 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
11 | // |
12 | // The Original Code and all software distributed under the License is |
13 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
14 | // Initial Developer hereby disclaims all such warranties, including without |
15 | // limitation, any warranties of merchantability, fitness for a particular |
16 | // purpose or non-infringement. Please see the License for the specific terms |
17 | // and conditions governing the rights and limitations under the License. |
18 | |
7fd59977 |
19 | |
20 | #include <gp.hxx> |
21 | #include <Standard_ConstructionError.hxx> |
22 | |
23 | inline gp_Cone::gp_Cone () : |
24 | radius (RealLast()), |
c6541a0c |
25 | semiAngle (M_PI * 0.25) |
7fd59977 |
26 | { } |
27 | |
28 | inline gp_Cone::gp_Cone (const gp_Ax3& A3, |
29 | const Standard_Real Ang, |
30 | const Standard_Real Radius) : |
31 | pos(A3), |
32 | radius (Radius), |
33 | semiAngle (Ang) |
34 | { |
35 | Standard_Real val = Ang; |
36 | if (val < 0) val = - val; |
37 | Standard_ConstructionError_Raise_if |
38 | (radius < 0. || |
39 | val <= gp::Resolution() || |
c6541a0c |
40 | M_PI * 0.5 - val <= gp::Resolution(), ""); |
7fd59977 |
41 | } |
42 | |
43 | inline void gp_Cone::SetAxis (const gp_Ax1& A1) |
44 | { pos.SetAxis (A1); } |
45 | |
46 | inline void gp_Cone::SetLocation (const gp_Pnt& Loc) |
47 | { pos.SetLocation (Loc); } |
48 | |
49 | inline void gp_Cone::SetPosition (const gp_Ax3& A3) |
50 | { pos = A3; } |
51 | |
52 | inline void gp_Cone::SetRadius (const Standard_Real R) |
53 | { |
54 | Standard_ConstructionError_Raise_if |
55 | (R < 0.0,""); |
56 | radius = R; |
57 | } |
58 | |
59 | inline void gp_Cone::SetSemiAngle (const Standard_Real Ang) |
60 | { |
61 | Standard_Real val = Ang; |
62 | if (val < 0) val = - val; |
63 | Standard_ConstructionError_Raise_if |
64 | (val <= gp::Resolution() || |
c6541a0c |
65 | M_PI * 0.5 - val <= gp::Resolution(),""); |
7fd59977 |
66 | semiAngle = Ang; |
67 | } |
68 | |
69 | inline gp_Pnt gp_Cone::Apex () const |
70 | { |
71 | gp_XYZ Coord = pos.Direction ().XYZ (); |
72 | Coord.Multiply (-radius / Tan (semiAngle)); |
73 | Coord.Add (pos.Location ().XYZ()); |
74 | return gp_Pnt (Coord); |
75 | } |
76 | |
77 | inline void gp_Cone::UReverse() |
78 | { pos.YReverse(); } |
79 | |
80 | inline void gp_Cone::VReverse() |
81 | { pos.ZReverse(); semiAngle = -semiAngle; } |
82 | |
83 | inline Standard_Boolean gp_Cone::Direct() const |
84 | { return pos.Direct(); } |
85 | |
86 | inline const gp_Ax1& gp_Cone::Axis () const |
87 | { return pos.Axis(); } |
88 | |
89 | inline const gp_Pnt& gp_Cone::Location () const |
90 | { return pos.Location(); } |
91 | |
92 | inline const gp_Ax3& gp_Cone::Position () const |
93 | { return pos; } |
94 | |
95 | inline Standard_Real gp_Cone::RefRadius () const |
96 | { return radius; } |
97 | |
98 | inline Standard_Real gp_Cone::SemiAngle () const |
99 | { return semiAngle; } |
100 | |
101 | inline gp_Ax1 gp_Cone::XAxis () const |
102 | { return gp_Ax1 (pos.Location(), pos.XDirection()); } |
103 | |
104 | inline gp_Ax1 gp_Cone::YAxis () const |
105 | { return gp_Ax1 (pos.Location(), pos.YDirection()); } |
106 | |
107 | inline void gp_Cone::Rotate (const gp_Ax1& A1, |
108 | const Standard_Real Ang) |
109 | {pos.Rotate (A1, Ang);} |
110 | |
111 | inline gp_Cone gp_Cone::Rotated (const gp_Ax1& A1, |
112 | const Standard_Real Ang) const |
113 | { |
114 | gp_Cone C = *this; |
115 | C.pos.Rotate (A1, Ang); |
116 | return C; |
117 | } |
118 | |
119 | inline void gp_Cone::Scale (const gp_Pnt& P, |
120 | const Standard_Real S) |
121 | { |
122 | pos.Scale (P, S); |
123 | radius *= S; |
124 | if (radius < 0) radius = - radius; |
125 | } |
126 | |
127 | inline gp_Cone gp_Cone::Scaled (const gp_Pnt& P, |
128 | const Standard_Real S) const |
129 | { |
130 | gp_Cone C = *this; |
131 | C.pos.Scale (P, S); |
132 | C.radius *= S; |
133 | if (C.radius < 0) C.radius = - C.radius; |
134 | return C; |
135 | } |
136 | |
137 | inline void gp_Cone::Transform (const gp_Trsf& T) |
138 | { |
139 | pos.Transform (T); |
140 | radius *= T.ScaleFactor(); |
141 | if (radius < 0) radius = - radius; |
142 | } |
143 | |
144 | inline gp_Cone gp_Cone::Transformed (const gp_Trsf& T) const |
145 | { |
146 | gp_Cone C = *this; |
147 | C.pos.Transform (T); |
148 | C.radius *= T.ScaleFactor(); |
149 | if (C.radius < 0) C.radius = - C.radius; |
150 | return C; |
151 | } |
152 | |
153 | inline void gp_Cone::Translate (const gp_Vec& V) |
154 | { pos.Translate (V); } |
155 | |
156 | inline gp_Cone gp_Cone::Translated (const gp_Vec& V) const |
157 | { |
158 | gp_Cone C = *this; |
159 | C.pos.Translate (V); |
160 | return C; |
161 | } |
162 | |
163 | inline void gp_Cone::Translate (const gp_Pnt& P1, |
164 | const gp_Pnt& P2) |
165 | { pos.Translate (P1, P2); } |
166 | |
167 | inline gp_Cone gp_Cone::Translated (const gp_Pnt& P1, |
168 | const gp_Pnt& P2) const |
169 | { |
170 | gp_Cone C = *this; |
171 | C.pos.Translate (P1, P2); |
172 | return C; |
173 | } |
174 | |