Commit | Line | Data |
---|---|---|
7fd59977 | 1 | // File: Geom_ToroidalSurface.cxx |
2 | // Created: Wed Mar 10 10:57:46 1993 | |
3 | // Author: JCV | |
4 | // <fid@phylox> | |
5 | // Copyright: Matra Datavision 1993 | |
6 | ||
7 | //File Geom_ToroidalSurface.cxx, JCV 17/01/91 | |
8 | ||
9 | ||
10 | #include <Geom_ToroidalSurface.ixx> | |
11 | ||
12 | #include <GeomAbs_UVSense.hxx> | |
13 | #include <Geom_Circle.hxx> | |
14 | #include <gp.hxx> | |
15 | #include <gp_Circ.hxx> | |
16 | #include <gp_Dir.hxx> | |
17 | #include <gp_XYZ.hxx> | |
18 | #include <ElSLib.hxx> | |
19 | ||
20 | #include <Standard_ConstructionError.hxx> | |
21 | #include <Standard_RangeError.hxx> | |
22 | ||
23 | typedef Geom_ToroidalSurface ToroidalSurface; | |
24 | typedef Handle(Geom_ToroidalSurface) Handle(ToroidalSurface); | |
25 | typedef TColStd_Array1OfReal Array1OfReal; | |
26 | typedef gp_Ax1 Ax1; | |
27 | typedef gp_Ax2 Ax2; | |
28 | typedef gp_Ax3 Ax3; | |
29 | typedef gp_Circ Circ; | |
30 | typedef gp_Dir Dir; | |
31 | typedef gp_Pnt Pnt; | |
32 | typedef gp_Trsf Trsf; | |
33 | typedef gp_Vec Vec; | |
34 | typedef gp_XYZ XYZ; | |
35 | ||
36 | ||
37 | ||
38 | //======================================================================= | |
39 | //function : Copy | |
40 | //purpose : | |
41 | //======================================================================= | |
42 | ||
43 | Handle(Geom_Geometry) Geom_ToroidalSurface::Copy () const { | |
44 | ||
45 | Handle(ToroidalSurface) Cs; | |
46 | Cs = new ToroidalSurface (pos, majorRadius, minorRadius); | |
47 | return Cs; | |
48 | } | |
49 | ||
50 | ||
51 | ||
52 | //======================================================================= | |
53 | //function : Geom_ToroidalSurface | |
54 | //purpose : | |
55 | //======================================================================= | |
56 | ||
57 | Geom_ToroidalSurface::Geom_ToroidalSurface | |
58 | ( const Ax3& A3, | |
59 | const Standard_Real MajorRadius, | |
60 | const Standard_Real MinorRadius ) | |
61 | ||
62 | : majorRadius (MajorRadius), minorRadius (MinorRadius) { | |
63 | ||
64 | if (MinorRadius < 0.0 || MajorRadius < 0.0) { | |
65 | Standard_ConstructionError::Raise(); | |
66 | } | |
67 | else { | |
68 | pos = A3; | |
69 | } | |
70 | } | |
71 | ||
72 | ||
73 | //======================================================================= | |
74 | //function : Geom_ToroidalSurface | |
75 | //purpose : | |
76 | //======================================================================= | |
77 | ||
78 | Geom_ToroidalSurface::Geom_ToroidalSurface (const gp_Torus& T) | |
79 | : majorRadius (T.MajorRadius()), minorRadius (T.MinorRadius()) { | |
80 | ||
81 | pos = T.Position(); | |
82 | } | |
83 | ||
84 | ||
85 | ||
86 | //======================================================================= | |
87 | //function : MajorRadius | |
88 | //purpose : | |
89 | //======================================================================= | |
90 | ||
91 | Standard_Real Geom_ToroidalSurface::MajorRadius () const { | |
92 | ||
93 | return majorRadius; | |
94 | } | |
95 | ||
96 | //======================================================================= | |
97 | ||
98 | //function : MinorRadius | |
99 | //purpose : | |
100 | //======================================================================= | |
101 | ||
102 | Standard_Real Geom_ToroidalSurface::MinorRadius () const { | |
103 | ||
104 | return minorRadius; | |
105 | } | |
106 | ||
107 | ||
108 | //======================================================================= | |
109 | //function : UReversedParameter | |
110 | //purpose : | |
111 | //======================================================================= | |
112 | ||
113 | Standard_Real Geom_ToroidalSurface::UReversedParameter( const Standard_Real U) const { | |
114 | ||
c6541a0c | 115 | return (2.*M_PI - U); |
7fd59977 | 116 | } |
117 | ||
118 | ||
119 | //======================================================================= | |
120 | //function : VReversedParameter | |
121 | //purpose : | |
122 | //======================================================================= | |
123 | ||
124 | Standard_Real Geom_ToroidalSurface::VReversedParameter( const Standard_Real V) const { | |
125 | ||
c6541a0c | 126 | return (2.*M_PI - V); |
7fd59977 | 127 | } |
128 | ||
129 | ||
130 | //======================================================================= | |
131 | //function : IsUClosed | |
132 | //purpose : | |
133 | //======================================================================= | |
134 | ||
135 | Standard_Boolean Geom_ToroidalSurface::IsUClosed () const { | |
136 | ||
137 | return Standard_True; | |
138 | } | |
139 | ||
140 | //======================================================================= | |
141 | //function : IsVClosed | |
142 | //purpose : | |
143 | //======================================================================= | |
144 | ||
145 | Standard_Boolean Geom_ToroidalSurface::IsVClosed () const { | |
146 | ||
147 | return Standard_True; | |
148 | } | |
149 | ||
150 | //======================================================================= | |
151 | //function : IsUPeriodic | |
152 | //purpose : | |
153 | //======================================================================= | |
154 | ||
155 | Standard_Boolean Geom_ToroidalSurface::IsUPeriodic () const { | |
156 | ||
157 | return Standard_True; | |
158 | } | |
159 | ||
160 | //======================================================================= | |
161 | //function : IsVPeriodic | |
162 | //purpose : | |
163 | //======================================================================= | |
164 | ||
165 | Standard_Boolean Geom_ToroidalSurface::IsVPeriodic () const { | |
166 | ||
167 | return Standard_True; | |
168 | } | |
169 | ||
170 | ||
171 | //======================================================================= | |
172 | //function : SetMajorRadius | |
173 | //purpose : | |
174 | //======================================================================= | |
175 | ||
176 | void Geom_ToroidalSurface::SetMajorRadius (const Standard_Real MajorRadius) { | |
177 | ||
178 | if (MajorRadius - minorRadius <= gp::Resolution()) | |
179 | Standard_ConstructionError::Raise(); | |
180 | else | |
181 | majorRadius = MajorRadius; | |
182 | } | |
183 | ||
184 | ||
185 | //======================================================================= | |
186 | //function : SetMinorRadius | |
187 | //purpose : | |
188 | //======================================================================= | |
189 | ||
190 | void Geom_ToroidalSurface::SetMinorRadius (const Standard_Real MinorRadius) { | |
191 | ||
192 | if (MinorRadius < 0.0 || majorRadius - MinorRadius <= gp::Resolution()) | |
193 | Standard_ConstructionError::Raise(); | |
194 | else | |
195 | minorRadius = MinorRadius; | |
196 | } | |
197 | ||
198 | ||
199 | //======================================================================= | |
200 | //function : SetTorus | |
201 | //purpose : | |
202 | //======================================================================= | |
203 | ||
204 | void Geom_ToroidalSurface::SetTorus (const gp_Torus& T) { | |
205 | ||
206 | minorRadius = T.MinorRadius(); | |
207 | majorRadius = T.MajorRadius(); | |
208 | pos = T.Position(); | |
209 | } | |
210 | ||
211 | ||
212 | //======================================================================= | |
213 | //function : Area | |
214 | //purpose : | |
215 | //======================================================================= | |
216 | ||
217 | Standard_Real Geom_ToroidalSurface::Area () const { | |
c6541a0c | 218 | return 4.0 * M_PI * M_PI * minorRadius * majorRadius; |
7fd59977 | 219 | } |
220 | ||
221 | ||
222 | //======================================================================= | |
223 | //function : Bounds | |
224 | //purpose : | |
225 | //======================================================================= | |
226 | ||
227 | void Geom_ToroidalSurface::Bounds (Standard_Real& U1, | |
228 | Standard_Real& U2, | |
229 | Standard_Real& V1, | |
230 | Standard_Real& V2 ) const { | |
231 | ||
232 | U1 = 0.0; | |
233 | V1 = 0.0; | |
c6541a0c D |
234 | U2 = 2*M_PI; |
235 | V2 = 2*M_PI; | |
7fd59977 | 236 | } |
237 | ||
238 | ||
239 | //======================================================================= | |
240 | //function : Coefficients | |
241 | //purpose : | |
242 | //======================================================================= | |
243 | ||
244 | void Geom_ToroidalSurface::Coefficients (Array1OfReal& Coef) const { | |
245 | ||
246 | gp_Torus Tor (pos, majorRadius, minorRadius); | |
247 | Tor.Coefficients (Coef); | |
248 | } | |
249 | ||
250 | ||
251 | //======================================================================= | |
252 | //function : D0 | |
253 | //purpose : | |
254 | //======================================================================= | |
255 | ||
256 | void Geom_ToroidalSurface::D0 (const Standard_Real U, const Standard_Real V, Pnt& P) const | |
257 | { | |
258 | ||
259 | ElSLib::TorusD0 (U, V, pos, majorRadius, minorRadius,P); | |
260 | } | |
261 | ||
262 | ||
263 | //======================================================================= | |
264 | //function : D1 | |
265 | //purpose : | |
266 | //======================================================================= | |
267 | ||
268 | void Geom_ToroidalSurface::D1 | |
269 | (const Standard_Real U, const Standard_Real V, | |
270 | Pnt& P, | |
271 | Vec& D1U, Vec& D1V) const | |
272 | { | |
273 | ElSLib::TorusD1 (U, V, pos, majorRadius, minorRadius, P, D1U, D1V); | |
274 | } | |
275 | ||
276 | ||
277 | //======================================================================= | |
278 | //function : D2 | |
279 | //purpose : | |
280 | //======================================================================= | |
281 | ||
282 | void Geom_ToroidalSurface::D2 | |
283 | (const Standard_Real U , const Standard_Real V, | |
284 | Pnt& P , | |
285 | Vec& D1U, Vec& D1V, | |
286 | Vec& D2U, Vec& D2V, Vec& D2UV ) const | |
287 | { | |
288 | ElSLib::TorusD2 (U, V, pos, majorRadius, minorRadius, P, D1U, D1V, | |
289 | D2U, D2V, D2UV); | |
290 | } | |
291 | ||
292 | ||
293 | //======================================================================= | |
294 | //function : D3 | |
295 | //purpose : | |
296 | //======================================================================= | |
297 | ||
298 | void Geom_ToroidalSurface::D3 | |
299 | (const Standard_Real U, const Standard_Real V, | |
300 | Pnt& P, | |
301 | Vec& D1U, Vec& D1V, | |
302 | Vec& D2U, Vec& D2V, Vec& D2UV, | |
303 | Vec& D3U, Vec& D3V, Vec& D3UUV, Vec& D3UVV ) const | |
304 | { | |
305 | ||
306 | ElSLib::TorusD3 (U, V, pos, majorRadius, minorRadius, P, D1U, D1V, | |
307 | D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV); | |
308 | } | |
309 | ||
310 | ||
311 | //======================================================================= | |
312 | //function : DN | |
313 | //purpose : | |
314 | //======================================================================= | |
315 | ||
316 | Vec Geom_ToroidalSurface::DN | |
317 | (const Standard_Real U , const Standard_Real V, | |
318 | const Standard_Integer Nu, const Standard_Integer Nv ) const { | |
319 | ||
320 | Standard_RangeError_Raise_if (Nu + Nv < 1 || Nu < 0 || Nv <0, " "); | |
321 | return ElSLib::TorusDN (U, V, pos, majorRadius, minorRadius, Nu, Nv); | |
322 | } | |
323 | ||
324 | ||
325 | //======================================================================= | |
326 | //function : Torus | |
327 | //purpose : | |
328 | //======================================================================= | |
329 | ||
330 | gp_Torus Geom_ToroidalSurface::Torus () const { | |
331 | ||
332 | return gp_Torus (pos, majorRadius, minorRadius); | |
333 | } | |
334 | ||
335 | ||
336 | //======================================================================= | |
337 | //function : UIso | |
338 | //purpose : | |
339 | //======================================================================= | |
340 | ||
341 | Handle(Geom_Curve) Geom_ToroidalSurface::UIso (const Standard_Real U) const | |
342 | { | |
343 | Handle(Geom_Circle) | |
344 | GC = new Geom_Circle(ElSLib::TorusUIso(pos,majorRadius,minorRadius,U)); | |
345 | return GC; | |
346 | } | |
347 | ||
348 | ||
349 | //======================================================================= | |
350 | //function : VIso | |
351 | //purpose : | |
352 | //======================================================================= | |
353 | ||
354 | Handle(Geom_Curve) Geom_ToroidalSurface::VIso (const Standard_Real V) const | |
355 | { | |
356 | Handle(Geom_Circle) GC = | |
357 | new Geom_Circle(ElSLib::TorusVIso(pos,majorRadius,minorRadius,V)); | |
358 | return GC; | |
359 | } | |
360 | ||
361 | ||
362 | //======================================================================= | |
363 | //function : Volume | |
364 | //purpose : | |
365 | //======================================================================= | |
366 | ||
367 | Standard_Real Geom_ToroidalSurface::Volume () const { | |
368 | ||
c6541a0c | 369 | return (M_PI * minorRadius * minorRadius) * (2.0 * M_PI * majorRadius); |
7fd59977 | 370 | } |
371 | ||
372 | ||
373 | //======================================================================= | |
374 | //function : Transform | |
375 | //purpose : | |
376 | //======================================================================= | |
377 | ||
378 | void Geom_ToroidalSurface::Transform (const Trsf& T) { | |
379 | ||
380 | majorRadius = majorRadius * Abs(T.ScaleFactor()); | |
381 | minorRadius = minorRadius * Abs(T.ScaleFactor()); | |
382 | pos.Transform (T); | |
383 | } |