Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1993-04-21 |
2 | // Created by: Bruno DUMORTIER | |
3 | // Copyright (c) 1993-1999 Matra Datavision | |
973c2be1 | 4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 5 | // |
973c2be1 | 6 | // This file is part of Open CASCADE Technology software library. |
b311480e | 7 | // |
d5f74e42 | 8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published | |
973c2be1 | 10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT | |
12 | // distribution for complete text of the license and disclaimer of any warranty. | |
b311480e | 13 | // |
973c2be1 | 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. | |
7fd59977 | 16 | |
6b84c3f7 | 17 | #include <GeomAdaptor_SurfaceOfRevolution.hxx> |
7fd59977 | 18 | |
c22b52d6 | 19 | #include <Adaptor3d_Curve.hxx> |
7fd59977 | 20 | #include <ElCLib.hxx> |
c22b52d6 | 21 | #include <GeomAdaptor_SurfaceOfRevolution.hxx> |
6b84c3f7 | 22 | #include <GeomEvaluator_SurfaceOfRevolution.hxx> |
42cf5bc1 | 23 | #include <Standard_NoSuchObject.hxx> |
7fd59977 | 24 | |
c22b52d6 | 25 | IMPLEMENT_STANDARD_RTTIEXT(GeomAdaptor_SurfaceOfRevolution, GeomAdaptor_Surface) |
26 | ||
7fd59977 | 27 | //======================================================================= |
6b84c3f7 | 28 | //function : GeomAdaptor_SurfaceOfRevolution |
7fd59977 | 29 | //purpose : |
30 | //======================================================================= | |
6b84c3f7 | 31 | GeomAdaptor_SurfaceOfRevolution::GeomAdaptor_SurfaceOfRevolution() |
32 | : myHaveAxis(Standard_False) | |
7fd59977 | 33 | {} |
34 | ||
35 | //======================================================================= | |
6b84c3f7 | 36 | //function : GeomAdaptor_SurfaceOfRevolution |
7fd59977 | 37 | //purpose : |
38 | //======================================================================= | |
39 | ||
6b84c3f7 | 40 | GeomAdaptor_SurfaceOfRevolution::GeomAdaptor_SurfaceOfRevolution( |
c22b52d6 | 41 | const Handle(Adaptor3d_Curve)& C) |
6b84c3f7 | 42 | : myHaveAxis(Standard_False) |
7fd59977 | 43 | { |
6b84c3f7 | 44 | Load(C); |
7fd59977 | 45 | } |
46 | ||
47 | //======================================================================= | |
6b84c3f7 | 48 | //function : GeomAdaptor_SurfaceOfRevolution |
7fd59977 | 49 | //purpose : |
50 | //======================================================================= | |
51 | ||
6b84c3f7 | 52 | GeomAdaptor_SurfaceOfRevolution::GeomAdaptor_SurfaceOfRevolution( |
c22b52d6 | 53 | const Handle(Adaptor3d_Curve)& C, |
6b84c3f7 | 54 | const gp_Ax1& V) |
55 | : myHaveAxis(Standard_False) | |
7fd59977 | 56 | { |
6b84c3f7 | 57 | Load(C); |
58 | Load(V); | |
7fd59977 | 59 | } |
60 | ||
872a7e3a | 61 | //======================================================================= |
62 | //function : ShallowCopy | |
63 | //purpose : | |
64 | //======================================================================= | |
65 | ||
66 | Handle(Adaptor3d_Surface) GeomAdaptor_SurfaceOfRevolution::ShallowCopy() const | |
67 | { | |
68 | Handle(GeomAdaptor_SurfaceOfRevolution) aCopy = new GeomAdaptor_SurfaceOfRevolution(); | |
69 | ||
70 | if (!myBasisCurve.IsNull()) | |
71 | { | |
72 | aCopy->myBasisCurve = myBasisCurve->ShallowCopy(); | |
73 | } | |
74 | aCopy->myAxis = myAxis; | |
75 | aCopy->myHaveAxis = myHaveAxis; | |
76 | aCopy->myAxeRev = myAxeRev; | |
77 | ||
78 | aCopy->mySurface = mySurface; | |
79 | aCopy->myUFirst = myUFirst; | |
80 | aCopy->myULast = myULast; | |
81 | aCopy->myVFirst = myVFirst; | |
82 | aCopy->myVLast = myVLast; | |
83 | aCopy->myTolU = myTolU; | |
84 | aCopy->myTolV = myTolV; | |
85 | aCopy->myBSplineSurface = myBSplineSurface; | |
86 | ||
87 | aCopy->mySurfaceType = mySurfaceType; | |
88 | if (!myNestedEvaluator.IsNull()) | |
89 | { | |
90 | aCopy->myNestedEvaluator = myNestedEvaluator->ShallowCopy(); | |
91 | } | |
92 | ||
93 | return aCopy; | |
94 | } | |
95 | ||
7fd59977 | 96 | //======================================================================= |
97 | //function : Load | |
98 | //purpose : | |
99 | //======================================================================= | |
100 | ||
c22b52d6 | 101 | void GeomAdaptor_SurfaceOfRevolution::Load(const Handle(Adaptor3d_Curve)& C) |
7fd59977 | 102 | { |
103 | myBasisCurve = C; | |
6b84c3f7 | 104 | if (myHaveAxis) |
105 | Load(myAxis); // to evaluate the new myAxeRev. | |
7fd59977 | 106 | } |
107 | ||
108 | //======================================================================= | |
109 | //function : Load | |
110 | //purpose : | |
111 | //======================================================================= | |
112 | ||
6b84c3f7 | 113 | void GeomAdaptor_SurfaceOfRevolution::Load(const gp_Ax1& V) |
7fd59977 | 114 | { |
115 | myHaveAxis = Standard_True; | |
116 | myAxis = V; | |
6b84c3f7 | 117 | |
118 | mySurfaceType = GeomAbs_SurfaceOfRevolution; | |
119 | myNestedEvaluator = new GeomEvaluator_SurfaceOfRevolution(myBasisCurve, | |
120 | myAxis.Direction(), myAxis.Location()); | |
121 | ||
7fd59977 | 122 | // Eval myAxeRev : axe of revolution ( Determination de Ox). |
123 | gp_Pnt P,Q; | |
124 | gp_Pnt O = myAxis.Location(); | |
125 | gp_Dir Ox; | |
126 | gp_Dir Oz = myAxis.Direction(); | |
127 | Standard_Boolean yrev = Standard_False; | |
128 | if (myBasisCurve->GetType() == GeomAbs_Line) { | |
129 | if((myBasisCurve->Line().Direction()).Dot(Oz) < 0.){ | |
130 | yrev = Standard_True; | |
131 | Oz.Reverse(); | |
132 | } | |
133 | } | |
134 | ||
135 | if (myBasisCurve->GetType() == GeomAbs_Circle) { | |
136 | Q = P = (myBasisCurve->Circle()).Location(); | |
137 | } | |
138 | else { | |
139 | Standard_Real First = myBasisCurve->FirstParameter(); | |
140 | P = Value( 0., 0.);// ce qui ne veut pas dire grand chose | |
141 | if ( GetType() == GeomAbs_Cone) { | |
142 | if ( gp_Lin(myAxis).Distance(P) <= Precision::Confusion()) | |
6b84c3f7 | 143 | Q = ElCLib::Value(1.,myBasisCurve->Line()); |
7fd59977 | 144 | else |
6b84c3f7 | 145 | Q = P; |
7fd59977 | 146 | } |
147 | else if (Precision::IsInfinite(First)) | |
148 | Q = P; | |
149 | else | |
150 | Q = Value( 0., First); | |
151 | } | |
152 | ||
153 | gp_Dir DZ = myAxis.Direction(); | |
154 | O.SetXYZ( O.XYZ() + ( gp_Vec(O,P) * DZ) * DZ.XYZ()); | |
155 | if ( gp_Lin(myAxis).Distance(Q) > Precision::Confusion()) { | |
156 | Ox = gp_Dir(Q.XYZ() - O.XYZ()); | |
157 | } | |
158 | else { | |
159 | Standard_Real First = myBasisCurve->FirstParameter(); | |
160 | Standard_Real Last = myBasisCurve->LastParameter(); | |
161 | Standard_Integer Ratio = 1; | |
162 | Standard_Real Dist; | |
163 | gp_Pnt PP; | |
164 | do { | |
165 | PP = myBasisCurve->Value(First+(Last-First)/Ratio); | |
166 | Dist = gp_Lin(myAxis).Distance(PP); | |
167 | Ratio++; | |
168 | } | |
169 | while ( Dist < Precision::Confusion() && Ratio < 100); | |
170 | ||
171 | if ( Ratio >= 100 ) { | |
9775fa61 | 172 | throw Standard_ConstructionError("Adaptor3d_SurfaceOfRevolution : Axe and meridian are confused"); |
7fd59977 | 173 | } |
174 | Ox = ( (Oz^gp_Vec(PP.XYZ()-O.XYZ()))^Oz); | |
175 | } | |
176 | ||
177 | myAxeRev = gp_Ax3(O,Oz,Ox); | |
178 | ||
179 | if (yrev) { | |
180 | myAxeRev.YReverse(); | |
181 | } | |
182 | else if (myBasisCurve->GetType() == GeomAbs_Circle) { | |
183 | gp_Dir DC = (myBasisCurve->Circle()).Axis().Direction(); | |
184 | if ((Ox.Crossed(Oz)).Dot(DC) < 0.) myAxeRev.ZReverse(); | |
185 | } | |
186 | } | |
187 | ||
188 | //======================================================================= | |
189 | //function : AxeOfRevolution | |
190 | //purpose : | |
191 | //======================================================================= | |
192 | ||
6b84c3f7 | 193 | gp_Ax1 GeomAdaptor_SurfaceOfRevolution::AxeOfRevolution() const |
7fd59977 | 194 | { |
195 | return myAxis; | |
196 | } | |
197 | ||
198 | //======================================================================= | |
199 | //function : FirstUParameter | |
200 | //purpose : | |
201 | //======================================================================= | |
202 | ||
6b84c3f7 | 203 | Standard_Real GeomAdaptor_SurfaceOfRevolution::FirstUParameter() const |
7fd59977 | 204 | { |
205 | return 0.; | |
206 | } | |
207 | ||
208 | //======================================================================= | |
209 | //function : LastUParameter | |
210 | //purpose : | |
211 | //======================================================================= | |
212 | ||
6b84c3f7 | 213 | Standard_Real GeomAdaptor_SurfaceOfRevolution::LastUParameter() const |
7fd59977 | 214 | { |
c6541a0c | 215 | return 2*M_PI; |
7fd59977 | 216 | } |
217 | ||
218 | //======================================================================= | |
219 | //function : FirstVParameter | |
220 | //purpose : | |
221 | //======================================================================= | |
222 | ||
6b84c3f7 | 223 | Standard_Real GeomAdaptor_SurfaceOfRevolution::FirstVParameter() const |
7fd59977 | 224 | { |
225 | return myBasisCurve->FirstParameter(); | |
226 | } | |
227 | ||
228 | //======================================================================= | |
229 | //function : LastVParameter | |
230 | //purpose : | |
231 | //======================================================================= | |
232 | ||
6b84c3f7 | 233 | Standard_Real GeomAdaptor_SurfaceOfRevolution::LastVParameter() const |
7fd59977 | 234 | { |
235 | return myBasisCurve->LastParameter(); | |
236 | } | |
237 | ||
238 | //======================================================================= | |
239 | //function : UContinuity | |
240 | //purpose : | |
241 | //======================================================================= | |
242 | ||
6b84c3f7 | 243 | GeomAbs_Shape GeomAdaptor_SurfaceOfRevolution::UContinuity() const |
7fd59977 | 244 | { |
245 | return GeomAbs_CN; | |
246 | } | |
247 | ||
248 | //======================================================================= | |
249 | //function : VContinuity | |
250 | //purpose : | |
251 | //======================================================================= | |
252 | ||
6b84c3f7 | 253 | GeomAbs_Shape GeomAdaptor_SurfaceOfRevolution::VContinuity() const |
7fd59977 | 254 | { |
255 | return myBasisCurve->Continuity(); | |
256 | } | |
257 | ||
258 | //======================================================================= | |
259 | //function : NbUIntervals | |
260 | //purpose : | |
261 | //======================================================================= | |
262 | ||
6b84c3f7 | 263 | Standard_Integer GeomAdaptor_SurfaceOfRevolution::NbUIntervals(const GeomAbs_Shape ) const |
7fd59977 | 264 | { |
265 | return 1; | |
266 | } | |
267 | ||
268 | //======================================================================= | |
269 | //function : NbVIntervals | |
270 | //purpose : | |
271 | //======================================================================= | |
272 | ||
6b84c3f7 | 273 | Standard_Integer GeomAdaptor_SurfaceOfRevolution::NbVIntervals(const GeomAbs_Shape S) const |
7fd59977 | 274 | { |
275 | return myBasisCurve->NbIntervals(S); | |
276 | } | |
277 | ||
278 | //======================================================================= | |
279 | //function : UIntervals | |
280 | //purpose : | |
281 | //======================================================================= | |
282 | ||
6b84c3f7 | 283 | void GeomAdaptor_SurfaceOfRevolution::UIntervals(TColStd_Array1OfReal& T, |
284 | const GeomAbs_Shape ) const | |
7fd59977 | 285 | { |
286 | T(T.Lower() ) = 0.; | |
c6541a0c | 287 | T(T.Lower()+1) = 2*M_PI; |
7fd59977 | 288 | } |
289 | ||
290 | ||
291 | //======================================================================= | |
292 | //function : VIntervals | |
293 | //purpose : | |
294 | //======================================================================= | |
295 | ||
6b84c3f7 | 296 | void GeomAdaptor_SurfaceOfRevolution::VIntervals(TColStd_Array1OfReal& T, |
297 | const GeomAbs_Shape S) const | |
7fd59977 | 298 | { |
299 | myBasisCurve->Intervals(T,S); | |
300 | } | |
301 | ||
302 | ||
303 | //======================================================================= | |
304 | //function : UTrim | |
305 | //purpose : | |
306 | //======================================================================= | |
307 | ||
c22b52d6 | 308 | Handle(Adaptor3d_Surface) GeomAdaptor_SurfaceOfRevolution::UTrim (const Standard_Real First, const Standard_Real Last, const Standard_Real Tol) const |
7fd59977 | 309 | { |
aff73fd5 | 310 | const Standard_Real Eps = Precision::PConfusion(); |
311 | (void )Eps; (void )First; (void )Last; (void )Tol; | |
7fd59977 | 312 | Standard_OutOfRange_Raise_if |
c6541a0c | 313 | ( Abs(First) > Eps || Abs(Last - 2.*M_PI) > Eps, |
6b84c3f7 | 314 | "GeomAdaptor_SurfaceOfRevolution : UTrim : Parameters out of range"); |
7fd59977 | 315 | |
c22b52d6 | 316 | Handle(GeomAdaptor_SurfaceOfRevolution) HR = new GeomAdaptor_SurfaceOfRevolution( |
6b84c3f7 | 317 | GeomAdaptor_SurfaceOfRevolution(myBasisCurve, myAxis)); |
7fd59977 | 318 | return HR; |
319 | } | |
320 | ||
321 | ||
322 | //======================================================================= | |
323 | //function : VTrim | |
324 | //purpose : | |
325 | //======================================================================= | |
326 | ||
c22b52d6 | 327 | Handle(Adaptor3d_Surface) GeomAdaptor_SurfaceOfRevolution::VTrim |
7fd59977 | 328 | (const Standard_Real First, |
329 | const Standard_Real Last, | |
330 | const Standard_Real Tol) const | |
331 | { | |
c22b52d6 | 332 | Handle(Adaptor3d_Curve) HC = BasisCurve()->Trim(First,Last,Tol); |
333 | Handle(GeomAdaptor_SurfaceOfRevolution) HR = new GeomAdaptor_SurfaceOfRevolution( | |
6b84c3f7 | 334 | GeomAdaptor_SurfaceOfRevolution(HC, myAxis)); |
7fd59977 | 335 | return HR; |
336 | } | |
337 | ||
338 | ||
339 | //======================================================================= | |
340 | //function : IsUClosed | |
341 | //purpose : | |
342 | //======================================================================= | |
343 | ||
6b84c3f7 | 344 | Standard_Boolean GeomAdaptor_SurfaceOfRevolution::IsUClosed() const |
7fd59977 | 345 | { |
346 | return Standard_True; | |
347 | } | |
348 | ||
349 | //======================================================================= | |
350 | //function : IsVClosed | |
351 | //purpose : | |
352 | //======================================================================= | |
353 | ||
6b84c3f7 | 354 | Standard_Boolean GeomAdaptor_SurfaceOfRevolution::IsVClosed() const |
7fd59977 | 355 | { |
356 | return myBasisCurve->IsClosed(); | |
357 | } | |
358 | ||
359 | //======================================================================= | |
360 | //function : IsUPeriodic | |
361 | //purpose : | |
362 | //======================================================================= | |
363 | ||
6b84c3f7 | 364 | Standard_Boolean GeomAdaptor_SurfaceOfRevolution::IsUPeriodic() const |
7fd59977 | 365 | { |
366 | return Standard_True; | |
367 | } | |
368 | ||
369 | //======================================================================= | |
370 | //function : UPeriod | |
371 | //purpose : | |
372 | //======================================================================= | |
373 | ||
6b84c3f7 | 374 | Standard_Real GeomAdaptor_SurfaceOfRevolution::UPeriod() const |
7fd59977 | 375 | { |
c6541a0c | 376 | return 2*M_PI; |
7fd59977 | 377 | } |
378 | ||
379 | //======================================================================= | |
380 | //function : IsVPeriodic | |
381 | //purpose : | |
382 | //======================================================================= | |
383 | ||
6b84c3f7 | 384 | Standard_Boolean GeomAdaptor_SurfaceOfRevolution::IsVPeriodic() const |
7fd59977 | 385 | { |
386 | return myBasisCurve->IsPeriodic(); | |
387 | } | |
388 | ||
389 | //======================================================================= | |
390 | //function : VPeriod | |
391 | //purpose : | |
392 | //======================================================================= | |
393 | ||
6b84c3f7 | 394 | Standard_Real GeomAdaptor_SurfaceOfRevolution::VPeriod() const |
7fd59977 | 395 | { |
396 | return myBasisCurve->Period(); | |
397 | } | |
398 | ||
7fd59977 | 399 | //======================================================================= |
400 | //function : UResolution | |
401 | //purpose : | |
402 | //======================================================================= | |
403 | ||
6b84c3f7 | 404 | Standard_Real GeomAdaptor_SurfaceOfRevolution::UResolution |
7fd59977 | 405 | (const Standard_Real R3d) const |
406 | { | |
407 | return Precision::Parametric(R3d); | |
408 | } | |
409 | ||
410 | //======================================================================= | |
411 | //function : VResolution | |
412 | //purpose : | |
413 | //======================================================================= | |
414 | ||
6b84c3f7 | 415 | Standard_Real GeomAdaptor_SurfaceOfRevolution::VResolution |
7fd59977 | 416 | (const Standard_Real R3d) const |
417 | { | |
418 | return myBasisCurve->Resolution(R3d); | |
419 | } | |
420 | ||
421 | //======================================================================= | |
422 | //function : GetType | |
423 | //purpose : | |
424 | //======================================================================= | |
425 | ||
6b84c3f7 | 426 | GeomAbs_SurfaceType GeomAdaptor_SurfaceOfRevolution::GetType() const |
7fd59977 | 427 | { |
6b84c3f7 | 428 | Standard_Real TolConf = Precision::Confusion(); |
429 | Standard_Real TolAng = Precision::Angular(); | |
9f2d9736 | 430 | Standard_Real TolConeSemiAng = Precision::Confusion(); |
6b84c3f7 | 431 | |
432 | switch (myBasisCurve->GetType()) { | |
bd05fabf | 433 | case GeomAbs_Line: { |
53dda4e9 | 434 | gp_Ax1 Axe = myBasisCurve->Line().Position(); |
7fd59977 | 435 | |
6b84c3f7 | 436 | if (myAxis.IsParallel(Axe, TolAng)) |
9f2d9736 | 437 | { |
438 | gp_Pnt P = Value(0., 0.); | |
439 | Standard_Real R = gp_Vec(myAxeRev.Location(), P) * myAxeRev.XDirection(); | |
440 | if (R > TolConf) | |
441 | { | |
442 | return GeomAbs_Cylinder; | |
443 | } | |
444 | } | |
6b84c3f7 | 445 | else if (myAxis.IsNormal(Axe, TolAng)) |
446 | return GeomAbs_Plane; | |
447 | else | |
448 | { | |
bd05fabf S |
449 | Standard_Real uf = myBasisCurve->FirstParameter(); |
450 | Standard_Real ul = myBasisCurve->LastParameter(); | |
451 | Standard_Boolean istrim = (!Precision::IsInfinite(uf) && | |
6b84c3f7 | 452 | !Precision::IsInfinite(ul)); |
453 | if(istrim) | |
454 | { | |
455 | gp_Pnt pf = myBasisCurve->Value(uf); | |
456 | gp_Pnt pl = myBasisCurve->Value(ul); | |
457 | Standard_Real len = pf.Distance(pl); | |
458 | //on calcule la distance projetee sur l axe. | |
459 | gp_Vec vlin(pf,pl); | |
460 | gp_Vec vaxe(myAxis.Direction()); | |
461 | Standard_Real projlen = Abs(vaxe.Dot(vlin)); | |
9f2d9736 | 462 | if ((len - projlen) <= TolConf) |
463 | { | |
464 | gp_Pnt P = Value(0., 0.); | |
465 | Standard_Real R = gp_Vec(myAxeRev.Location(), P) * myAxeRev.XDirection(); | |
466 | if (R > TolConf) | |
467 | { | |
468 | return GeomAbs_Cylinder; | |
469 | } | |
470 | } | |
471 | else if (projlen <= TolConf) | |
6b84c3f7 | 472 | return GeomAbs_Plane; |
7fd59977 | 473 | } |
6b84c3f7 | 474 | gp_Vec V(myAxis.Location(), myBasisCurve->Line().Location()); |
bd05fabf | 475 | gp_Vec W(Axe.Direction()); |
9f2d9736 | 476 | gp_Vec AxisDir(myAxis.Direction()); |
477 | Standard_Real proj = Abs(W.Dot(AxisDir)); | |
478 | if (Abs(V.DotCross(AxisDir, W)) <= TolConf && | |
479 | (proj >= TolConeSemiAng && proj <= 1. - TolConeSemiAng)) | |
480 | { | |
6b84c3f7 | 481 | return GeomAbs_Cone; |
9f2d9736 | 482 | } |
7fd59977 | 483 | } |
6b84c3f7 | 484 | break; |
bd05fabf | 485 | }//case GeomAbs_Line: |
6b84c3f7 | 486 | // |
bd05fabf | 487 | case GeomAbs_Circle: { |
bd05fabf S |
488 | Standard_Real MajorRadius, aR; |
489 | gp_Lin aLin(myAxis); | |
490 | // | |
53dda4e9 | 491 | gp_Circ C = myBasisCurve->Circle(); |
492 | const gp_Pnt& aLC = C.Location(); | |
bd05fabf S |
493 | aR=C.Radius(); |
494 | // | |
495 | ||
6b84c3f7 | 496 | if (!C.Position().IsCoplanar(myAxis, TolConf, TolAng)) |
497 | return GeomAbs_SurfaceOfRevolution; | |
498 | else if(aLin.Distance(aLC) <= TolConf) | |
499 | return GeomAbs_Sphere; | |
500 | else | |
501 | { | |
bd05fabf | 502 | MajorRadius = aLin.Distance(aLC); |
6b84c3f7 | 503 | if(MajorRadius > aR) |
504 | { | |
259b9303 | 505 | return GeomAbs_Torus; |
bd05fabf | 506 | } |
bd05fabf | 507 | } |
6b84c3f7 | 508 | break; |
bd05fabf S |
509 | } |
510 | // | |
7fd59977 | 511 | default: |
bd05fabf | 512 | break; |
7fd59977 | 513 | } |
514 | ||
6b84c3f7 | 515 | return GeomAbs_SurfaceOfRevolution; |
7fd59977 | 516 | } |
517 | ||
518 | //======================================================================= | |
519 | //function : Plane | |
520 | //purpose : | |
521 | //======================================================================= | |
522 | ||
6b84c3f7 | 523 | gp_Pln GeomAdaptor_SurfaceOfRevolution::Plane() const |
7fd59977 | 524 | { |
525 | Standard_NoSuchObject_Raise_if | |
6b84c3f7 | 526 | (GetType() != GeomAbs_Plane, "GeomAdaptor_SurfaceOfRevolution:Plane"); |
7fd59977 | 527 | |
528 | gp_Ax3 Axe = myAxeRev; | |
6b84c3f7 | 529 | gp_Pnt aPonCurve = Value(0., 0.); |
530 | Standard_Real aDot = (aPonCurve.XYZ() - myAxis.Location().XYZ()).Dot(myAxis.Direction().XYZ()); | |
531 | ||
532 | gp_Pnt P(myAxis.Location().XYZ() + aDot * myAxis.Direction().XYZ()); | |
533 | Axe.SetLocation(P); | |
534 | if (Axe.XDirection().Dot(myBasisCurve->Line().Direction()) >= -Precision::Confusion()) | |
7fd59977 | 535 | Axe.XReverse(); |
7fd59977 | 536 | |
537 | return gp_Pln( Axe); | |
538 | } | |
539 | ||
540 | //======================================================================= | |
541 | //function : Cylinder | |
542 | //purpose : | |
543 | //======================================================================= | |
544 | ||
6b84c3f7 | 545 | gp_Cylinder GeomAdaptor_SurfaceOfRevolution::Cylinder() const |
7fd59977 | 546 | { |
547 | Standard_NoSuchObject_Raise_if | |
6b84c3f7 | 548 | (GetType() != GeomAbs_Cylinder, "GeomAdaptor_SurfaceOfRevolution::Cylinder"); |
7fd59977 | 549 | |
6b84c3f7 | 550 | gp_Pnt P = Value(0., 0.); |
551 | Standard_Real R = gp_Vec(myAxeRev.Location(), P) * myAxeRev.XDirection(); | |
552 | return gp_Cylinder(myAxeRev, R); | |
7fd59977 | 553 | } |
554 | ||
555 | //======================================================================= | |
556 | //function : Cone | |
557 | //purpose : | |
558 | //======================================================================= | |
559 | ||
6b84c3f7 | 560 | gp_Cone GeomAdaptor_SurfaceOfRevolution::Cone() const |
7fd59977 | 561 | { |
562 | Standard_NoSuchObject_Raise_if | |
6b84c3f7 | 563 | ( GetType() != GeomAbs_Cone, "GeomAdaptor_SurfaceOfRevolution:Cone"); |
7fd59977 | 564 | |
565 | gp_Ax3 Axe = myAxeRev; | |
566 | gp_Dir ldir = (myBasisCurve->Line()).Direction(); | |
567 | Standard_Real Angle = (Axe.Direction()).Angle(ldir); | |
568 | gp_Pnt P0 = Value(0., 0.); | |
569 | Standard_Real R = (Axe.Location()).Distance(P0); | |
570 | if ( R >= Precision::Confusion()) { | |
571 | gp_Pnt O = Axe.Location(); | |
572 | gp_Vec OP0(O,P0); | |
573 | Standard_Real t = OP0.Dot(Axe.XDirection()); | |
574 | t /= ldir.Dot(Axe.XDirection()); | |
575 | OP0.Add(-t * gp_Vec(ldir)); | |
576 | if ( OP0.Dot(Axe.Direction()) > 0.) Angle = -Angle; | |
577 | } | |
578 | return gp_Cone( Axe, Angle, R); | |
579 | } | |
580 | ||
581 | ||
582 | //======================================================================= | |
583 | //function : Sphere | |
584 | //purpose : | |
585 | //======================================================================= | |
586 | ||
6b84c3f7 | 587 | gp_Sphere GeomAdaptor_SurfaceOfRevolution::Sphere() const |
7fd59977 | 588 | { |
589 | Standard_NoSuchObject_Raise_if | |
6b84c3f7 | 590 | ( GetType() != GeomAbs_Sphere, "GeomAdaptor_SurfaceOfRevolution:Sphere"); |
7fd59977 | 591 | |
592 | gp_Circ C = myBasisCurve->Circle(); | |
593 | gp_Ax3 Axe = myAxeRev; | |
6b84c3f7 | 594 | Axe.SetLocation(C.Location()); |
595 | return gp_Sphere(Axe, C.Radius()); | |
7fd59977 | 596 | } |
597 | ||
598 | ||
599 | //======================================================================= | |
600 | //function : Torus | |
601 | //purpose : | |
602 | //======================================================================= | |
603 | ||
6b84c3f7 | 604 | gp_Torus GeomAdaptor_SurfaceOfRevolution::Torus() const |
7fd59977 | 605 | { |
606 | Standard_NoSuchObject_Raise_if | |
6b84c3f7 | 607 | (GetType() != GeomAbs_Torus, "GeomAdaptor_SurfaceOfRevolution:Torus"); |
7fd59977 | 608 | |
609 | gp_Circ C = myBasisCurve->Circle(); | |
610 | Standard_Real MajorRadius = gp_Lin(myAxis).Distance(C.Location()); | |
6b84c3f7 | 611 | return gp_Torus(myAxeRev, MajorRadius, C.Radius()); |
7fd59977 | 612 | } |
613 | ||
614 | //======================================================================= | |
615 | //function : VDegree | |
616 | //purpose : | |
617 | //======================================================================= | |
618 | ||
6b84c3f7 | 619 | Standard_Integer GeomAdaptor_SurfaceOfRevolution::VDegree() const |
7fd59977 | 620 | { |
621 | return myBasisCurve->Degree(); | |
622 | } | |
623 | ||
624 | //======================================================================= | |
625 | //function : NbVPoles | |
626 | //purpose : | |
627 | //======================================================================= | |
628 | ||
6b84c3f7 | 629 | Standard_Integer GeomAdaptor_SurfaceOfRevolution::NbVPoles() const |
7fd59977 | 630 | { |
6b84c3f7 | 631 | return myBasisCurve->NbPoles(); |
7fd59977 | 632 | } |
633 | ||
7fd59977 | 634 | //======================================================================= |
635 | //function : NbVKnots | |
636 | //purpose : | |
637 | //======================================================================= | |
638 | ||
6b84c3f7 | 639 | Standard_Integer GeomAdaptor_SurfaceOfRevolution::NbVKnots() const |
7fd59977 | 640 | { |
9775fa61 | 641 | throw Standard_NoSuchObject("GeomAdaptor_SurfaceOfRevolution::NbVKnots"); |
7fd59977 | 642 | } |
643 | ||
644 | ||
645 | ||
646 | //======================================================================= | |
647 | //function : IsURational | |
648 | //purpose : | |
649 | //======================================================================= | |
650 | ||
6b84c3f7 | 651 | Standard_Boolean GeomAdaptor_SurfaceOfRevolution::IsURational() const |
7fd59977 | 652 | { |
9775fa61 | 653 | throw Standard_NoSuchObject("GeomAdaptor_SurfaceOfRevolution::IsURational"); |
7fd59977 | 654 | } |
655 | ||
656 | //======================================================================= | |
657 | //function : IsVRational | |
658 | //purpose : | |
659 | //======================================================================= | |
660 | ||
6b84c3f7 | 661 | Standard_Boolean GeomAdaptor_SurfaceOfRevolution::IsVRational() const |
7fd59977 | 662 | { |
9775fa61 | 663 | throw Standard_NoSuchObject("GeomAdaptor_SurfaceOfRevolution::IsVRational"); |
7fd59977 | 664 | } |
665 | ||
666 | ||
667 | //======================================================================= | |
668 | //function : Bezier | |
669 | //purpose : | |
670 | //======================================================================= | |
671 | ||
6b84c3f7 | 672 | Handle(Geom_BezierSurface) GeomAdaptor_SurfaceOfRevolution::Bezier() const |
7fd59977 | 673 | { |
9775fa61 | 674 | throw Standard_NoSuchObject("GeomAdaptor_SurfaceOfRevolution::Bezier"); |
7fd59977 | 675 | } |
676 | ||
677 | ||
678 | //======================================================================= | |
679 | //function : BSpline | |
680 | //purpose : | |
681 | //======================================================================= | |
682 | ||
6b84c3f7 | 683 | Handle(Geom_BSplineSurface) GeomAdaptor_SurfaceOfRevolution::BSpline() const |
7fd59977 | 684 | { |
9775fa61 | 685 | throw Standard_NoSuchObject("GeomAdaptor_SurfaceOfRevolution::BSpline"); |
7fd59977 | 686 | } |
687 | ||
7fd59977 | 688 | //======================================================================= |
689 | //function : Axis | |
690 | //purpose : | |
691 | //======================================================================= | |
692 | ||
6b84c3f7 | 693 | const gp_Ax3& GeomAdaptor_SurfaceOfRevolution::Axis() const |
7fd59977 | 694 | { |
695 | return myAxeRev; | |
696 | } | |
697 | ||
7fd59977 | 698 | //======================================================================= |
699 | //function : BasisCurve | |
700 | //purpose : | |
701 | //======================================================================= | |
702 | ||
c22b52d6 | 703 | Handle(Adaptor3d_Curve) GeomAdaptor_SurfaceOfRevolution::BasisCurve() const |
7fd59977 | 704 | { |
705 | return myBasisCurve; | |
706 | } |