b311480e |
1 | // Created on: 1993-05-14 |
2 | // Created by: Joelle CHAUVET |
3 | // Copyright (c) 1993-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | // Modified: Thu Nov 26 16:37:18 1998 |
7fd59977 |
23 | // correction in NbUIntervals for SurfaceOfLinearExtrusion |
24 | // (PRO16346) |
25 | |
26 | #define No_Standard_RangeError |
27 | #define No_Standard_OutOfRange |
28 | #define PosTol (Precision::PConfusion()*0.5) |
29 | |
30 | #include <GeomAdaptor_Surface.ixx> |
31 | |
32 | #include <GeomAdaptor_HSurface.hxx> |
33 | #include <GeomAdaptor_HCurve.hxx> |
34 | #include <GeomAdaptor_Curve.hxx> |
35 | #include <Adaptor3d_HSurface.hxx> |
36 | #include <Standard_OutOfRange.hxx> |
37 | #include <Geom_RectangularTrimmedSurface.hxx> |
38 | #include <Geom_BSplineSurface.hxx> |
39 | #include <Geom_BezierSurface.hxx> |
40 | #include <Geom_OffsetSurface.hxx> |
41 | //#include <GeomConvert_BSplineSurfaceKnotSplitting.hxx> |
42 | #include <Standard_OutOfRange.hxx> |
43 | #include <TColStd_HArray1OfInteger.hxx> |
44 | #include <TColStd_Array1OfReal.hxx> |
45 | #include <TColStd_Array1OfInteger.hxx> |
46 | #include <Geom_Plane.hxx> |
47 | #include <Geom_CylindricalSurface.hxx> |
48 | #include <Geom_SphericalSurface.hxx> |
49 | #include <Geom_ToroidalSurface.hxx> |
50 | #include <Geom_ConicalSurface.hxx> |
51 | #include <Geom_SurfaceOfRevolution.hxx> |
52 | #include <Geom_SurfaceOfLinearExtrusion.hxx> |
53 | #include <Geom_Curve.hxx> |
54 | #include <Geom_Circle.hxx> |
55 | #include <gp_Circ.hxx> |
56 | #include <gp_Lin.hxx> |
57 | #include <gp_Trsf.hxx> |
58 | #include <BSplCLib.hxx> |
59 | #include <Precision.hxx> |
60 | #include <Standard_NoSuchObject.hxx> |
041bfce9 |
61 | #include <Standard_NullObject.hxx> |
7fd59977 |
62 | |
63 | #define myBspl (*((Handle(Geom_BSplineSurface)*)&mySurface)) |
64 | #define myExtSurf (*((Handle(Geom_SurfaceOfLinearExtrusion)*)&mySurface)) |
65 | #define myRevSurf (*((Handle(Geom_SurfaceOfRevolution)*)&mySurface)) |
66 | #define myOffSurf (*((Handle(Geom_OffsetSurface)*)&mySurface)) |
67 | |
68 | //======================================================================= |
69 | //function : LocalContinuity |
70 | //purpose : |
71 | //======================================================================= |
72 | |
73 | GeomAbs_Shape LocalContinuity(Standard_Integer Degree, |
74 | Standard_Integer Nb, |
75 | TColStd_Array1OfReal& TK, |
76 | TColStd_Array1OfInteger& TM, |
77 | Standard_Real PFirst, |
78 | Standard_Real PLast, |
79 | Standard_Boolean IsPeriodic) |
80 | { |
81 | Standard_DomainError_Raise_if( (TK.Length()!=Nb || TM.Length()!=Nb )," "); |
82 | Standard_Integer Index1 = 0; |
83 | Standard_Integer Index2 = 0; |
84 | Standard_Real newFirst, newLast; |
85 | BSplCLib::LocateParameter(Degree,TK,TM,PFirst,IsPeriodic,1,Nb,Index1,newFirst); |
86 | BSplCLib::LocateParameter(Degree,TK,TM,PLast, IsPeriodic,1,Nb,Index2,newLast ); |
87 | const Standard_Real EpsKnot = Precision::PConfusion(); |
88 | if (Abs(newFirst-TK(Index1+1))< EpsKnot) Index1++; |
89 | if (Abs(newLast -TK(Index2 ))< EpsKnot) Index2--; |
90 | // attention aux courbes peridiques. |
91 | if ( (IsPeriodic) && (Index1 == Nb) ) |
92 | Index1 = 1; |
93 | |
94 | if (Index2!=Index1) |
95 | { |
96 | Standard_Integer i, Multmax = TM(Index1+1); |
97 | for (i = Index1+1; i<=Index2; i++) { |
98 | if (TM(i)>Multmax) Multmax=TM(i); |
99 | } |
100 | Multmax = Degree - Multmax; |
101 | if (Multmax <= 0) return GeomAbs_C0; |
102 | switch (Multmax) { |
103 | case 1: return GeomAbs_C1; |
104 | case 2: return GeomAbs_C2; |
105 | case 3: return GeomAbs_C3; |
106 | } |
107 | } |
108 | return GeomAbs_CN; |
109 | } |
110 | |
111 | //======================================================================= |
112 | //function : Load |
113 | //purpose : |
114 | //======================================================================= |
115 | |
041bfce9 |
116 | void GeomAdaptor_Surface::load(const Handle(Geom_Surface)& S, |
7fd59977 |
117 | const Standard_Real UFirst, |
118 | const Standard_Real ULast, |
119 | const Standard_Real VFirst, |
120 | const Standard_Real VLast, |
121 | const Standard_Real TolU, |
122 | const Standard_Real TolV) |
123 | { |
7fd59977 |
124 | myTolU = TolU; |
125 | myTolV = TolV; |
126 | myUFirst = UFirst; |
127 | myULast = ULast; |
128 | myVFirst = VFirst; |
129 | myVLast = VLast; |
130 | |
131 | if ( mySurface != S) { |
132 | mySurface = S; |
133 | |
134 | const Handle(Standard_Type)& TheType = S->DynamicType(); |
135 | if ( TheType == STANDARD_TYPE(Geom_BezierSurface)) |
136 | mySurfaceType = GeomAbs_BezierSurface; |
137 | else if (TheType == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) { |
138 | Load((*((Handle(Geom_RectangularTrimmedSurface)*)&S))->BasisSurface(), |
139 | UFirst,ULast,VFirst,VLast); |
140 | } |
141 | else if ( TheType == STANDARD_TYPE(Geom_Plane)) |
142 | mySurfaceType = GeomAbs_Plane; |
143 | else if ( TheType == STANDARD_TYPE(Geom_CylindricalSurface)) |
144 | mySurfaceType = GeomAbs_Cylinder; |
145 | else if ( TheType == STANDARD_TYPE(Geom_ConicalSurface)) |
146 | mySurfaceType = GeomAbs_Cone; |
147 | else if ( TheType == STANDARD_TYPE(Geom_SphericalSurface)) |
148 | mySurfaceType = GeomAbs_Sphere; |
149 | else if ( TheType == STANDARD_TYPE(Geom_ToroidalSurface)) |
150 | mySurfaceType = GeomAbs_Torus; |
151 | else if ( TheType == STANDARD_TYPE(Geom_SurfaceOfRevolution)) |
152 | mySurfaceType = GeomAbs_SurfaceOfRevolution; |
153 | else if ( TheType == STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion)) |
154 | mySurfaceType = GeomAbs_SurfaceOfExtrusion; |
155 | else if ( TheType == STANDARD_TYPE(Geom_BSplineSurface)) { |
156 | mySurfaceType = GeomAbs_BSplineSurface; |
157 | myBspl = *((Handle(Geom_BSplineSurface)*)&S); |
158 | } |
159 | else if ( TheType == STANDARD_TYPE(Geom_OffsetSurface)) |
160 | mySurfaceType = GeomAbs_OffsetSurface; |
161 | else |
162 | mySurfaceType = GeomAbs_OtherSurface; |
163 | } |
164 | } |
165 | |
166 | // -- |
167 | // -- Global methods - Apply to the whole Surface. |
168 | // -- |
169 | |
170 | |
171 | //======================================================================= |
172 | //function : UContinuity |
173 | //purpose : |
174 | //======================================================================= |
175 | |
176 | GeomAbs_Shape GeomAdaptor_Surface::UContinuity() const |
177 | { |
178 | switch (mySurfaceType) |
179 | { |
180 | case GeomAbs_BSplineSurface: |
181 | { |
182 | const Standard_Integer N = myBspl->NbUKnots(); |
183 | TColStd_Array1OfReal TK(1,N); |
184 | TColStd_Array1OfInteger TM(1,N); |
185 | myBspl->UKnots(TK); |
186 | myBspl->UMultiplicities(TM); |
187 | return LocalContinuity(myBspl->UDegree(), myBspl->NbUKnots(), TK, TM, |
188 | myUFirst, myULast, IsUPeriodic()); |
189 | } |
566f8441 |
190 | case GeomAbs_OffsetSurface: |
7fd59977 |
191 | { |
192 | switch(BasisSurface()->UContinuity()) |
193 | { |
566f8441 |
194 | case GeomAbs_CN : |
195 | case GeomAbs_C3 : return GeomAbs_CN; |
196 | case GeomAbs_G2 : |
197 | case GeomAbs_C2 : return GeomAbs_C1; |
198 | case GeomAbs_G1 : |
199 | case GeomAbs_C1 : return GeomAbs_C0; |
200 | case GeomAbs_C0 : break; |
7fd59977 |
201 | } |
202 | Standard_NoSuchObject::Raise("GeomAdaptor_Surface::UContinuity"); |
566f8441 |
203 | break; |
7fd59977 |
204 | } |
566f8441 |
205 | case GeomAbs_SurfaceOfExtrusion: |
7fd59977 |
206 | { |
207 | GeomAdaptor_Curve GC |
208 | ((*((Handle(Geom_SurfaceOfLinearExtrusion)*)&mySurface))->BasisCurve(),myUFirst,myULast); |
209 | return GC.Continuity(); |
210 | } |
566f8441 |
211 | case GeomAbs_OtherSurface: |
212 | Standard_NoSuchObject::Raise("GeomAdaptor_Surface::UContinuity"); |
213 | case GeomAbs_Plane: |
214 | case GeomAbs_Cylinder: |
215 | case GeomAbs_Cone: |
216 | case GeomAbs_Sphere: |
217 | case GeomAbs_Torus: |
218 | case GeomAbs_BezierSurface: |
219 | case GeomAbs_SurfaceOfRevolution: break; |
7fd59977 |
220 | } |
221 | return GeomAbs_CN; |
222 | } |
223 | |
224 | //======================================================================= |
225 | //function : VContinuity |
226 | //purpose : |
227 | //======================================================================= |
228 | |
229 | GeomAbs_Shape GeomAdaptor_Surface::VContinuity() const |
230 | { |
231 | switch (mySurfaceType) |
232 | { |
233 | case GeomAbs_BSplineSurface: |
234 | { |
235 | const Standard_Integer N = myBspl->NbVKnots(); |
236 | TColStd_Array1OfReal TK(1,N); |
237 | TColStd_Array1OfInteger TM(1,N); |
238 | myBspl->VKnots(TK); |
239 | myBspl->VMultiplicities(TM); |
240 | return LocalContinuity(myBspl->VDegree(), myBspl->NbVKnots(), TK, TM, |
241 | myVFirst, myVLast, IsVPeriodic()); |
242 | } |
566f8441 |
243 | case GeomAbs_OffsetSurface: |
7fd59977 |
244 | { |
245 | switch(BasisSurface()->VContinuity()) |
246 | { |
566f8441 |
247 | case GeomAbs_CN : |
248 | case GeomAbs_C3 : return GeomAbs_CN; |
249 | case GeomAbs_G2 : |
250 | case GeomAbs_C2 : return GeomAbs_C1; |
251 | case GeomAbs_G1 : |
252 | case GeomAbs_C1 : return GeomAbs_C0; |
253 | case GeomAbs_C0 : break; |
7fd59977 |
254 | } |
255 | Standard_NoSuchObject::Raise("GeomAdaptor_Surface::VContinuity"); |
256 | break; |
257 | } |
566f8441 |
258 | case GeomAbs_SurfaceOfRevolution: |
7fd59977 |
259 | { |
260 | GeomAdaptor_Curve GC |
261 | ((*((Handle(Geom_SurfaceOfRevolution)*)&mySurface))->BasisCurve(),myVFirst,myVLast); |
262 | return GC.Continuity(); |
263 | } |
566f8441 |
264 | case GeomAbs_OtherSurface: |
265 | Standard_NoSuchObject::Raise("GeomAdaptor_Surface::VContinuity"); |
266 | case GeomAbs_Plane: |
267 | case GeomAbs_Cylinder: |
268 | case GeomAbs_Cone: |
269 | case GeomAbs_Sphere: |
270 | case GeomAbs_Torus: |
271 | case GeomAbs_BezierSurface: |
272 | case GeomAbs_SurfaceOfExtrusion: break; |
7fd59977 |
273 | } |
274 | return GeomAbs_CN; |
275 | } |
276 | |
277 | //======================================================================= |
278 | //function : NbUIntervals |
279 | //purpose : |
280 | //======================================================================= |
281 | |
282 | Standard_Integer GeomAdaptor_Surface::NbUIntervals(const GeomAbs_Shape S) const |
283 | { |
284 | switch (mySurfaceType) |
285 | { |
286 | case GeomAbs_BSplineSurface: |
287 | { |
288 | GeomAdaptor_Curve myBasisCurve |
289 | (myBspl->VIso(myBspl->VKnot(myBspl->FirstVKnotIndex())),myUFirst,myULast); |
290 | return myBasisCurve.NbIntervals(S); |
291 | } |
566f8441 |
292 | case GeomAbs_SurfaceOfExtrusion: |
7fd59977 |
293 | { |
294 | GeomAdaptor_Curve myBasisCurve |
295 | ((*((Handle(Geom_SurfaceOfLinearExtrusion)*)&mySurface))->BasisCurve(),myUFirst,myULast); |
296 | if (myBasisCurve.GetType() == GeomAbs_BSplineCurve) |
297 | return myBasisCurve.NbIntervals(S); |
298 | break; |
299 | } |
566f8441 |
300 | case GeomAbs_OffsetSurface: |
7fd59977 |
301 | { |
302 | GeomAbs_Shape BaseS = GeomAbs_CN; |
303 | switch(S) |
304 | { |
305 | case GeomAbs_G1: |
306 | case GeomAbs_G2: Standard_DomainError::Raise("GeomAdaptor_Curve::NbUIntervals"); |
307 | case GeomAbs_C0: BaseS = GeomAbs_C1; break; |
308 | case GeomAbs_C1: BaseS = GeomAbs_C2; break; |
309 | case GeomAbs_C2: BaseS = GeomAbs_C3; break; |
566f8441 |
310 | case GeomAbs_C3: |
311 | case GeomAbs_CN: break; |
7fd59977 |
312 | } |
313 | GeomAdaptor_Surface Sur((*((Handle(Geom_OffsetSurface)*)&mySurface))->BasisSurface()); |
314 | return Sur.NbUIntervals(BaseS); |
315 | } |
566f8441 |
316 | case GeomAbs_Plane: |
317 | case GeomAbs_Cylinder: |
318 | case GeomAbs_Cone: |
319 | case GeomAbs_Sphere: |
320 | case GeomAbs_Torus: |
321 | case GeomAbs_BezierSurface: |
322 | case GeomAbs_OtherSurface: |
323 | case GeomAbs_SurfaceOfRevolution: break; |
7fd59977 |
324 | } |
325 | return 1; |
326 | } |
327 | |
328 | //======================================================================= |
329 | //function : NbVIntervals |
330 | //purpose : |
331 | //======================================================================= |
332 | |
333 | Standard_Integer GeomAdaptor_Surface::NbVIntervals(const GeomAbs_Shape S) const |
334 | { |
335 | switch (mySurfaceType) |
336 | { |
337 | case GeomAbs_BSplineSurface: |
338 | { |
339 | GeomAdaptor_Curve myBasisCurve |
340 | (myBspl->UIso(myBspl->UKnot(myBspl->FirstUKnotIndex())),myVFirst,myVLast); |
341 | return myBasisCurve.NbIntervals(S); |
342 | } |
566f8441 |
343 | case GeomAbs_SurfaceOfRevolution: |
7fd59977 |
344 | { |
345 | GeomAdaptor_Curve myBasisCurve |
346 | ((*((Handle(Geom_SurfaceOfRevolution)*)&mySurface))->BasisCurve(),myVFirst,myVLast); |
347 | if (myBasisCurve.GetType() == GeomAbs_BSplineCurve) |
348 | return myBasisCurve.NbIntervals(S); |
349 | break; |
350 | } |
566f8441 |
351 | case GeomAbs_OffsetSurface: |
7fd59977 |
352 | { |
353 | GeomAbs_Shape BaseS = GeomAbs_CN; |
354 | switch(S) |
355 | { |
356 | case GeomAbs_G1: |
357 | case GeomAbs_G2: Standard_DomainError::Raise("GeomAdaptor_Curve::NbVIntervals"); |
358 | case GeomAbs_C0: BaseS = GeomAbs_C1; break; |
359 | case GeomAbs_C1: BaseS = GeomAbs_C2; break; |
360 | case GeomAbs_C2: BaseS = GeomAbs_C3; break; |
566f8441 |
361 | case GeomAbs_C3: |
362 | case GeomAbs_CN: break; |
7fd59977 |
363 | } |
364 | GeomAdaptor_Surface Sur((*((Handle(Geom_OffsetSurface)*)&mySurface))->BasisSurface()); |
365 | return Sur.NbVIntervals(BaseS); |
566f8441 |
366 | } |
367 | case GeomAbs_Plane: |
368 | case GeomAbs_Cylinder: |
369 | case GeomAbs_Cone: |
370 | case GeomAbs_Sphere: |
371 | case GeomAbs_Torus: |
372 | case GeomAbs_BezierSurface: |
373 | case GeomAbs_OtherSurface: |
374 | case GeomAbs_SurfaceOfExtrusion: break; |
7fd59977 |
375 | } |
376 | return 1; |
377 | } |
378 | |
379 | //======================================================================= |
380 | //function : UIntervals |
381 | //purpose : |
382 | //======================================================================= |
383 | |
384 | void GeomAdaptor_Surface::UIntervals(TColStd_Array1OfReal& T, const GeomAbs_Shape S) const |
385 | { |
386 | Standard_Integer myNbUIntervals = 1; |
387 | |
388 | switch (mySurfaceType) |
389 | { |
390 | case GeomAbs_BSplineSurface: |
391 | { |
392 | GeomAdaptor_Curve myBasisCurve |
393 | (myBspl->VIso(myBspl->VKnot(myBspl->FirstVKnotIndex())),myUFirst,myULast); |
394 | myNbUIntervals = myBasisCurve.NbIntervals(S); |
395 | myBasisCurve.Intervals(T,S); |
396 | break; |
397 | } |
566f8441 |
398 | case GeomAbs_SurfaceOfExtrusion: |
7fd59977 |
399 | { |
400 | GeomAdaptor_Curve myBasisCurve |
401 | ((*((Handle(Geom_SurfaceOfLinearExtrusion)*)&mySurface))->BasisCurve(),myUFirst,myULast); |
402 | if (myBasisCurve.GetType() == GeomAbs_BSplineCurve) |
403 | { |
404 | myNbUIntervals = myBasisCurve.NbIntervals(S); |
405 | myBasisCurve.Intervals(T,S); |
406 | } |
407 | break; |
408 | } |
566f8441 |
409 | case GeomAbs_OffsetSurface: |
7fd59977 |
410 | { |
411 | GeomAbs_Shape BaseS = GeomAbs_CN; |
412 | switch(S) |
413 | { |
414 | case GeomAbs_G1: |
415 | case GeomAbs_G2: Standard_DomainError::Raise("GeomAdaptor_Curve::UIntervals"); |
416 | case GeomAbs_C0: BaseS = GeomAbs_C1; break; |
417 | case GeomAbs_C1: BaseS = GeomAbs_C2; break; |
418 | case GeomAbs_C2: BaseS = GeomAbs_C3; break; |
566f8441 |
419 | case GeomAbs_C3: |
420 | case GeomAbs_CN: break; |
7fd59977 |
421 | } |
422 | GeomAdaptor_Surface Sur((*((Handle(Geom_OffsetSurface)*)&mySurface))->BasisSurface()); |
423 | myNbUIntervals = Sur.NbUIntervals(BaseS); |
424 | Sur.UIntervals(T, BaseS); |
425 | } |
566f8441 |
426 | case GeomAbs_Plane: |
427 | case GeomAbs_Cylinder: |
428 | case GeomAbs_Cone: |
429 | case GeomAbs_Sphere: |
430 | case GeomAbs_Torus: |
431 | case GeomAbs_BezierSurface: |
432 | case GeomAbs_OtherSurface: |
433 | case GeomAbs_SurfaceOfRevolution: break; |
7fd59977 |
434 | } |
435 | |
436 | T(T.Lower()) = myUFirst; |
437 | T(T.Lower() + myNbUIntervals) = myULast; |
438 | } |
439 | |
440 | //======================================================================= |
441 | //function : VIntervals |
442 | //purpose : |
443 | //======================================================================= |
444 | |
445 | void GeomAdaptor_Surface::VIntervals(TColStd_Array1OfReal& T, const GeomAbs_Shape S) const |
446 | { |
447 | Standard_Integer myNbVIntervals = 1; |
448 | |
449 | switch (mySurfaceType) |
450 | { |
451 | case GeomAbs_BSplineSurface: |
452 | { |
453 | GeomAdaptor_Curve myBasisCurve |
454 | (myBspl->UIso(myBspl->UKnot(myBspl->FirstUKnotIndex())),myVFirst,myVLast); |
455 | myNbVIntervals = myBasisCurve.NbIntervals(S); |
456 | myBasisCurve.Intervals(T,S); |
457 | break; |
458 | } |
566f8441 |
459 | case GeomAbs_SurfaceOfRevolution: |
7fd59977 |
460 | { |
461 | GeomAdaptor_Curve myBasisCurve |
462 | ((*((Handle(Geom_SurfaceOfRevolution)*)&mySurface))->BasisCurve(),myVFirst,myVLast); |
463 | if (myBasisCurve.GetType() == GeomAbs_BSplineCurve) |
464 | { |
465 | myNbVIntervals = myBasisCurve.NbIntervals(S); |
466 | myBasisCurve.Intervals(T,S); |
467 | } |
468 | break; |
469 | } |
566f8441 |
470 | case GeomAbs_OffsetSurface: |
7fd59977 |
471 | { |
472 | GeomAbs_Shape BaseS = GeomAbs_CN; |
473 | switch(S) |
474 | { |
475 | case GeomAbs_G1: |
476 | case GeomAbs_G2: Standard_DomainError::Raise("GeomAdaptor_Curve::VIntervals"); |
477 | case GeomAbs_C0: BaseS = GeomAbs_C1; break; |
478 | case GeomAbs_C1: BaseS = GeomAbs_C2; break; |
479 | case GeomAbs_C2: BaseS = GeomAbs_C3; break; |
566f8441 |
480 | case GeomAbs_C3: |
481 | case GeomAbs_CN: break; |
7fd59977 |
482 | } |
483 | GeomAdaptor_Surface Sur((*((Handle(Geom_OffsetSurface)*)&mySurface))->BasisSurface()); |
484 | myNbVIntervals = Sur.NbVIntervals(BaseS); |
485 | Sur.VIntervals(T, BaseS); |
486 | } |
566f8441 |
487 | case GeomAbs_Plane: |
488 | case GeomAbs_Cylinder: |
489 | case GeomAbs_Cone: |
490 | case GeomAbs_Sphere: |
491 | case GeomAbs_Torus: |
492 | case GeomAbs_BezierSurface: |
493 | case GeomAbs_OtherSurface: |
494 | case GeomAbs_SurfaceOfExtrusion: break; |
7fd59977 |
495 | } |
496 | |
497 | T(T.Lower()) = myVFirst; |
498 | T(T.Lower() + myNbVIntervals) = myVLast; |
499 | } |
500 | |
501 | //======================================================================= |
502 | //function : UTrim |
503 | //purpose : |
504 | //======================================================================= |
505 | |
506 | Handle(Adaptor3d_HSurface) GeomAdaptor_Surface::UTrim(const Standard_Real First, |
507 | const Standard_Real Last , |
508 | const Standard_Real Tol ) const |
509 | { |
510 | return Handle(GeomAdaptor_HSurface) |
511 | (new GeomAdaptor_HSurface(mySurface,First,Last,myVFirst,myVLast,Tol,myTolV)); |
512 | } |
513 | |
514 | //======================================================================= |
515 | //function : VTrim |
516 | //purpose : |
517 | //======================================================================= |
518 | |
519 | Handle(Adaptor3d_HSurface) GeomAdaptor_Surface::VTrim(const Standard_Real First, |
520 | const Standard_Real Last , |
521 | const Standard_Real Tol ) const |
522 | { |
523 | return Handle(GeomAdaptor_HSurface) |
524 | (new GeomAdaptor_HSurface(mySurface,myUFirst,myULast,First,Last,myTolU,Tol)); |
525 | } |
526 | |
527 | //======================================================================= |
528 | //function : IsUClosed |
529 | //purpose : |
530 | //======================================================================= |
531 | |
532 | Standard_Boolean GeomAdaptor_Surface::IsUClosed() const |
533 | { |
534 | if (!mySurface->IsUClosed()) |
535 | return Standard_False; |
536 | |
537 | Standard_Real U1,U2,V1,V2; |
538 | mySurface->Bounds(U1,U2,V1,V2); |
539 | if (mySurface->IsUPeriodic()) |
540 | return (Abs(Abs(U1-U2)-Abs(myUFirst-myULast))<Precision::PConfusion()); |
541 | |
542 | return ( Abs(U1-myUFirst)<Precision::PConfusion() |
543 | && Abs(U2-myULast )<Precision::PConfusion() ); |
544 | } |
545 | |
546 | //======================================================================= |
547 | //function : IsVClosed |
548 | //purpose : |
549 | //======================================================================= |
550 | |
551 | Standard_Boolean GeomAdaptor_Surface::IsVClosed() const |
552 | { |
553 | if (!mySurface->IsVClosed()) |
554 | return Standard_False; |
555 | |
556 | Standard_Real U1,U2,V1,V2; |
557 | mySurface->Bounds(U1,U2,V1,V2); |
558 | if (mySurface->IsVPeriodic()) |
559 | return (Abs(Abs(V1-V2)-Abs(myVFirst-myVLast))<Precision::PConfusion()); |
560 | |
561 | return ( Abs(V1-myVFirst)<Precision::PConfusion() |
562 | && Abs(V2-myVLast )<Precision::PConfusion() ); |
563 | } |
564 | |
565 | //======================================================================= |
566 | //function : IsUPeriodic |
567 | //purpose : |
568 | //======================================================================= |
569 | |
570 | Standard_Boolean GeomAdaptor_Surface::IsUPeriodic() const |
571 | { |
572 | return (mySurface->IsUPeriodic()); |
573 | } |
574 | |
575 | //======================================================================= |
576 | //function : UPeriod |
577 | //purpose : |
578 | //======================================================================= |
579 | |
580 | Standard_Real GeomAdaptor_Surface::UPeriod() const |
581 | { |
582 | Standard_NoSuchObject_Raise_if(!IsUPeriodic()," "); |
583 | return mySurface->UPeriod(); |
584 | } |
585 | |
586 | //======================================================================= |
587 | //function : IsVPeriodic |
588 | //purpose : |
589 | //======================================================================= |
590 | |
591 | Standard_Boolean GeomAdaptor_Surface::IsVPeriodic() const |
592 | { |
593 | return (mySurface->IsVPeriodic()); |
594 | } |
595 | |
596 | //======================================================================= |
597 | //function : VPeriod |
598 | //purpose : |
599 | //======================================================================= |
600 | |
601 | Standard_Real GeomAdaptor_Surface::VPeriod() const |
602 | { |
603 | Standard_NoSuchObject_Raise_if(!IsVPeriodic()," "); |
604 | return mySurface->VPeriod(); |
605 | } |
606 | |
607 | //======================================================================= |
608 | //function : Value |
609 | //purpose : |
610 | //======================================================================= |
611 | |
612 | gp_Pnt GeomAdaptor_Surface::Value(const Standard_Real U, |
613 | const Standard_Real V) const |
614 | { |
615 | return mySurface->Value(U,V); |
616 | } |
617 | |
618 | //======================================================================= |
619 | //function : D0 |
620 | //purpose : |
621 | //======================================================================= |
622 | |
623 | void GeomAdaptor_Surface::D0(const Standard_Real U, |
624 | const Standard_Real V, gp_Pnt& P) const |
625 | { |
626 | mySurface->D0(U,V,P); |
627 | } |
628 | |
629 | |
630 | //======================================================================= |
631 | //function : D1 |
632 | //purpose : |
633 | //======================================================================= |
634 | |
635 | void GeomAdaptor_Surface::D1(const Standard_Real U, |
636 | const Standard_Real V, |
637 | gp_Pnt& P, |
638 | gp_Vec& D1U, |
639 | gp_Vec& D1V ) const |
640 | { |
641 | Standard_Integer Ideb,Ifin,IVdeb,IVfin,USide=0,VSide=0; |
642 | Standard_Real u = U, v = V; |
643 | if (Abs(U-myUFirst) <= myTolU) {USide= 1; u = myUFirst;} |
644 | else if (Abs(U-myULast) <= myTolU) {USide= -1; u = myULast;} |
645 | if (Abs(V-myVFirst) <= myTolV) {VSide= 1; v = myVFirst;} |
646 | else if (Abs(V-myVLast) <= myTolV) {VSide= -1; v = myVLast;} |
647 | |
648 | switch(mySurfaceType) { |
649 | case GeomAbs_BSplineSurface: |
650 | { |
651 | if((USide==0)&&(VSide==0)){ |
652 | myBspl->D1(u,v,P,D1U,D1V); |
653 | } |
654 | else { |
655 | if(IfUVBound(u,v,Ideb,Ifin,IVdeb,IVfin,USide,VSide)) |
656 | myBspl->LocalD1 (u, v, Ideb, Ifin,IVdeb ,IVfin ,P ,D1U,D1V); |
657 | else myBspl->D1(u,v,P,D1U,D1V); |
658 | } |
659 | break; |
660 | } |
661 | |
662 | case GeomAbs_SurfaceOfExtrusion : |
663 | |
664 | if(USide==0) myExtSurf->D1(u,v,P,D1U,D1V); |
665 | else myExtSurf->LocalD1(u,v,USide,P,D1U,D1V); |
666 | break; |
667 | |
668 | case GeomAbs_SurfaceOfRevolution : |
669 | |
670 | if(VSide==0) myRevSurf->D1 (u, v, P,D1U,D1V ); |
671 | else myRevSurf->LocalD1 (u, v, VSide, P,D1U,D1V ); |
672 | break; |
673 | |
674 | case GeomAbs_OffsetSurface : |
675 | { |
676 | if((USide==0)&&(VSide==0)) myOffSurf->D1 (u, v,P,D1U,D1V ); |
677 | else myOffSurf->LocalD1 (u, v, USide, VSide ,P,D1U,D1V ); |
678 | break; |
679 | } |
680 | default : |
681 | mySurface->D1(u,v,P,D1U,D1V); |
682 | } |
683 | } |
684 | |
685 | //======================================================================= |
686 | //function : D2 |
687 | //purpose : |
688 | //======================================================================= |
689 | |
690 | void GeomAdaptor_Surface::D2(const Standard_Real U, |
691 | const Standard_Real V, gp_Pnt& P, |
692 | gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, |
693 | gp_Vec& D2V, gp_Vec& D2UV) const |
694 | { |
695 | Standard_Integer Ideb,Ifin,IVdeb,IVfin,USide=0,VSide=0; |
696 | Standard_Real u = U, v = V; |
697 | if (Abs(U-myUFirst) <= myTolU) {USide= 1; u = myUFirst;} |
698 | else if (Abs(U-myULast) <= myTolU) {USide= -1; u = myULast;} |
699 | if (Abs(V-myVFirst) <= myTolV) {VSide= 1; v = myVFirst;} |
700 | else if (Abs(V-myVLast) <= myTolV) {VSide= -1; v = myVLast;} |
701 | |
702 | switch(mySurfaceType) |
703 | { |
704 | case GeomAbs_BSplineSurface: |
705 | |
706 | if((USide==0)&&(VSide==0)) myBspl->D2(u,v,P,D1U,D1V,D2U,D2V,D2UV); |
707 | else{ |
708 | if(IfUVBound(u,v,Ideb,Ifin,IVdeb,IVfin,USide,VSide)) |
709 | myBspl->LocalD2 (u, v, Ideb, Ifin,IVdeb ,IVfin ,P ,D1U,D1V,D2U,D2V,D2UV); |
710 | else myBspl->D2(u,v,P,D1U,D1V,D2U,D2V,D2UV); |
711 | } |
712 | break; |
713 | |
714 | case GeomAbs_SurfaceOfExtrusion : |
715 | |
716 | if(USide==0) myExtSurf->D2(u,v,P,D1U,D1V,D2U,D2V,D2UV); |
717 | else myExtSurf->LocalD2(u,v,USide,P,D1U,D1V,D2U,D2V,D2UV); |
718 | break; |
719 | |
720 | case GeomAbs_SurfaceOfRevolution : |
721 | |
722 | if(VSide==0) myRevSurf->D2 (u, v, P,D1U,D1V,D2U,D2V,D2UV ); |
723 | else myRevSurf->LocalD2 (u, v, VSide, P,D1U,D1V,D2U,D2V,D2UV ); |
724 | break; |
725 | |
726 | case GeomAbs_OffsetSurface : |
727 | { |
728 | if((USide==0)&&(VSide==0)) myOffSurf->D2 (u, v,P,D1U,D1V,D2U,D2V,D2UV ); |
729 | else myOffSurf->LocalD2 (u, v, USide, VSide ,P,D1U,D1V,D2U,D2V,D2UV ); |
730 | break; |
731 | } |
732 | default : { mySurface->D2(u,v,P,D1U,D1V,D2U,D2V,D2UV); |
733 | break;} |
734 | } |
735 | } |
736 | |
737 | |
738 | //======================================================================= |
739 | //function : D3 |
740 | //purpose : |
741 | //======================================================================= |
742 | |
743 | void GeomAdaptor_Surface::D3(const Standard_Real U, const Standard_Real V, |
744 | gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, |
745 | gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV, |
746 | gp_Vec& D3U, gp_Vec& D3V, gp_Vec& D3UUV, |
747 | gp_Vec& D3UVV) const |
748 | { |
749 | Standard_Integer Ideb,Ifin,IVdeb,IVfin,USide=0,VSide=0; |
750 | Standard_Real u = U, v = V; |
751 | if (Abs(U-myUFirst) <= myTolU) {USide= 1; u = myUFirst;} |
752 | else if (Abs(U-myULast) <= myTolU) {USide= -1; u = myULast;} |
753 | if (Abs(V-myVFirst) <= myTolV) {VSide= 1; v = myVFirst;} |
754 | else if (Abs(V-myVLast) <= myTolV) {VSide= -1; v = myVLast;} |
755 | |
756 | switch(mySurfaceType) { |
757 | case GeomAbs_BSplineSurface: |
758 | |
759 | if((USide==0)&&(VSide==0)) |
760 | myBspl->D3(u,v,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); |
761 | else { |
762 | if(IfUVBound(u,v,Ideb,Ifin,IVdeb,IVfin,USide,VSide)) |
763 | myBspl-> LocalD3 (u, v, Ideb, Ifin,IVdeb ,IVfin , |
764 | P ,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); |
765 | else |
766 | myBspl->D3(u,v,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); |
767 | } |
768 | break; |
769 | |
770 | case GeomAbs_SurfaceOfExtrusion : |
771 | |
772 | if(USide==0) myExtSurf->D3(u,v,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); |
773 | else myExtSurf->LocalD3(u,v,USide,P,D1U,D1V,D2U,D2V,D2UV, |
774 | D3U,D3V,D3UUV,D3UVV); |
775 | break; |
776 | |
777 | case GeomAbs_SurfaceOfRevolution : |
778 | |
779 | if(VSide==0) myRevSurf->D3 (u, v, P ,D1U,D1V,D2U,D2V,D2UV, |
780 | D3U,D3V,D3UUV,D3UVV); |
781 | else myRevSurf->LocalD3 (u, v, VSide, P,D1U,D1V,D2U,D2V,D2UV, |
782 | D3U,D3V,D3UUV,D3UVV ); |
783 | break; |
784 | |
785 | case GeomAbs_OffsetSurface : |
786 | { |
787 | if((USide==0)&&(VSide==0)) myOffSurf->D3 (u, v,P ,D1U,D1V,D2U,D2V,D2UV, |
788 | D3U,D3V,D3UUV,D3UVV); |
789 | else myOffSurf->LocalD3 (u, v, USide, VSide ,P ,D1U,D1V,D2U,D2V,D2UV, |
790 | D3U,D3V,D3UUV,D3UVV); |
791 | break; |
792 | } |
793 | default : { mySurface->D3(u,v,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); |
794 | break;} |
795 | } |
796 | } |
797 | |
798 | //======================================================================= |
799 | //function : DN |
800 | //purpose : |
801 | //======================================================================= |
802 | |
803 | gp_Vec GeomAdaptor_Surface::DN(const Standard_Real U, |
804 | const Standard_Real V, |
805 | const Standard_Integer Nu, |
806 | const Standard_Integer Nv) const |
807 | { |
808 | Standard_Integer Ideb,Ifin,IVdeb,IVfin,USide=0,VSide=0; |
809 | Standard_Real u = U, v = V; |
810 | if (Abs(U-myUFirst) <= myTolU) {USide= 1; u = myUFirst;} |
811 | else if (Abs(U-myULast) <= myTolU) {USide= -1; u = myULast;} |
812 | if (Abs(V-myVFirst) <= myTolV) {VSide= 1; v = myVFirst;} |
813 | else if (Abs(V-myVLast) <= myTolV) {VSide= -1; v = myVLast;} |
814 | |
815 | switch(mySurfaceType) |
816 | { |
817 | case GeomAbs_BSplineSurface: |
818 | |
819 | if((USide==0)&&(VSide==0)) return myBspl->DN(u,v,Nu,Nv); |
820 | else { |
821 | if(IfUVBound(u,v,Ideb,Ifin,IVdeb,IVfin,USide,VSide)) |
822 | return myBspl->LocalDN (u, v, Ideb, Ifin,IVdeb ,IVfin ,Nu,Nv ); |
823 | else |
824 | return myBspl->DN(u,v,Nu,Nv); |
825 | } |
826 | |
827 | case GeomAbs_SurfaceOfExtrusion: |
828 | |
829 | if(USide==0) return myExtSurf-> DN (u, v,Nu,Nv ); |
830 | else return myExtSurf->LocalDN (u, v, USide,Nu,Nv ); |
831 | |
832 | case GeomAbs_SurfaceOfRevolution: |
833 | |
834 | if(VSide==0) return myRevSurf->DN (u, v, Nu, Nv ); |
835 | else return myRevSurf->LocalDN (u, v,VSide, Nu, Nv ); |
836 | |
837 | case GeomAbs_OffsetSurface: |
838 | |
839 | if((USide==0)&&(VSide==0)) return myOffSurf->DN (u, v, Nu, Nv ); |
840 | else return myOffSurf->LocalDN (u, v, USide, VSide, Nu, Nv ); |
841 | |
842 | case GeomAbs_Plane: |
843 | case GeomAbs_Cylinder: |
844 | case GeomAbs_Cone: |
845 | case GeomAbs_Sphere: |
846 | case GeomAbs_Torus: |
847 | case GeomAbs_BezierSurface: |
848 | case GeomAbs_OtherSurface: |
849 | default: |
850 | break; |
851 | } |
852 | |
853 | return mySurface->DN(u,v, Nu, Nv); |
854 | } |
855 | |
856 | |
857 | //======================================================================= |
858 | //function : UResolution |
859 | //purpose : |
860 | //======================================================================= |
861 | |
862 | Standard_Real GeomAdaptor_Surface::UResolution(const Standard_Real R3d) const |
863 | { |
864 | Standard_Real Res = 0.; |
865 | |
866 | switch (mySurfaceType) |
867 | { |
868 | case GeomAbs_SurfaceOfExtrusion: |
869 | { |
870 | GeomAdaptor_Curve myBasisCurve |
871 | ((*((Handle(Geom_SurfaceOfLinearExtrusion)*)&mySurface))->BasisCurve(),myUFirst,myULast); |
872 | return myBasisCurve.Resolution(R3d); |
873 | } |
874 | case GeomAbs_Torus: |
875 | { |
876 | Handle(Geom_ToroidalSurface)& S = *((Handle(Geom_ToroidalSurface)*)&mySurface); |
877 | const Standard_Real R = S->MajorRadius() + S->MinorRadius(); |
878 | if(R>Precision::Confusion()) |
879 | Res = R3d/(2.*R); |
880 | break; |
881 | } |
882 | case GeomAbs_Sphere: |
883 | { |
884 | Handle(Geom_SphericalSurface)& S = *((Handle(Geom_SphericalSurface)*)&mySurface); |
885 | const Standard_Real R = S->Radius(); |
886 | if(R>Precision::Confusion()) |
887 | Res = R3d/(2.*R); |
888 | break; |
889 | } |
890 | case GeomAbs_Cylinder: |
891 | { |
892 | Handle(Geom_CylindricalSurface)& S = *((Handle(Geom_CylindricalSurface)*)&mySurface); |
893 | const Standard_Real R = S->Radius(); |
894 | if(R>Precision::Confusion()) |
895 | Res = R3d/(2.*R); |
896 | break; |
897 | } |
898 | case GeomAbs_Cone: |
899 | { |
900 | if (myVLast - myVFirst > 1.e10) { |
901 | // Pas vraiment borne => resolution inconnue |
902 | return Precision::Parametric(R3d); |
903 | } |
904 | Handle(Geom_ConicalSurface)& S = *((Handle(Geom_ConicalSurface)*)&mySurface); |
905 | Handle(Geom_Curve) C = S->VIso(myVLast); |
906 | const Standard_Real Rayon1 = (*((Handle(Geom_Circle)*)&C))->Radius(); |
907 | C = S->VIso(myVFirst); |
908 | const Standard_Real Rayon2 = (*((Handle(Geom_Circle)*)&C))->Radius(); |
909 | const Standard_Real R = (Rayon1 > Rayon2)? Rayon1 : Rayon2; |
910 | return (R>Precision::Confusion()? (R3d / R) : 0.); |
911 | } |
912 | case GeomAbs_Plane: |
913 | { |
914 | return R3d; |
915 | } |
916 | case GeomAbs_BezierSurface: |
917 | { |
918 | Standard_Real Ures,Vres; |
919 | (*((Handle(Geom_BezierSurface)*)&mySurface))->Resolution(R3d,Ures,Vres); |
920 | return Ures; |
921 | } |
922 | case GeomAbs_BSplineSurface: |
923 | { |
924 | Standard_Real Ures,Vres; |
925 | (*((Handle(Geom_BSplineSurface)*)&mySurface))->Resolution(R3d,Ures,Vres); |
926 | return Ures; |
927 | } |
928 | case GeomAbs_OffsetSurface: |
929 | { |
930 | Handle(Geom_Surface) base = (*((Handle(Geom_OffsetSurface)*)&mySurface))->BasisSurface(); |
931 | GeomAdaptor_Surface gabase(base,myUFirst,myULast,myVFirst,myVLast); |
932 | return gabase.UResolution(R3d); |
933 | } |
934 | default: return Precision::Parametric(R3d); |
935 | } |
936 | |
937 | if ( Res <= 1.) |
938 | return 2.*ASin(Res); |
939 | |
c6541a0c |
940 | return 2.*M_PI; |
7fd59977 |
941 | } |
942 | |
943 | //======================================================================= |
944 | //function : VResolution |
945 | //purpose : |
946 | //======================================================================= |
947 | |
948 | Standard_Real GeomAdaptor_Surface::VResolution(const Standard_Real R3d) const |
949 | { |
950 | Standard_Real Res = 0.; |
951 | |
952 | switch (mySurfaceType) |
953 | { |
954 | case GeomAbs_SurfaceOfRevolution: |
955 | { |
956 | GeomAdaptor_Curve myBasisCurve |
957 | ((*((Handle(Geom_SurfaceOfRevolution)*)&mySurface))->BasisCurve(),myUFirst,myULast); |
958 | return myBasisCurve.Resolution(R3d); |
959 | } |
960 | case GeomAbs_Torus: |
961 | { |
962 | Handle(Geom_ToroidalSurface)& S = *((Handle(Geom_ToroidalSurface)*)&mySurface); |
963 | const Standard_Real R = S->MinorRadius(); |
964 | if(R>Precision::Confusion()) |
965 | Res = R3d/(2.*R); |
966 | break; |
967 | } |
968 | case GeomAbs_Sphere: |
969 | { |
970 | Handle(Geom_SphericalSurface)& S = *((Handle(Geom_SphericalSurface)*)&mySurface); |
971 | const Standard_Real R = S->Radius(); |
972 | if(R>Precision::Confusion()) |
973 | Res = R3d/(2.*R); |
974 | break; |
975 | } |
976 | case GeomAbs_SurfaceOfExtrusion: |
977 | case GeomAbs_Cylinder: |
978 | case GeomAbs_Cone: |
979 | case GeomAbs_Plane: |
980 | { |
981 | return R3d; |
982 | } |
983 | case GeomAbs_BezierSurface: |
984 | { |
985 | Standard_Real Ures,Vres; |
986 | (*((Handle(Geom_BezierSurface)*)&mySurface))->Resolution(R3d,Ures,Vres); |
987 | return Vres; |
988 | } |
989 | case GeomAbs_BSplineSurface: |
990 | { |
991 | Standard_Real Ures,Vres; |
992 | (*((Handle(Geom_BSplineSurface)*)&mySurface))->Resolution(R3d,Ures,Vres); |
993 | return Vres; |
994 | } |
995 | case GeomAbs_OffsetSurface: |
996 | { |
997 | Handle(Geom_Surface) base = (*((Handle(Geom_OffsetSurface)*)&mySurface))->BasisSurface(); |
998 | GeomAdaptor_Surface gabase(base,myUFirst,myULast,myVFirst,myVLast); |
999 | return gabase.VResolution(R3d); |
1000 | } |
1001 | default: return Precision::Parametric(R3d); |
1002 | } |
1003 | |
1004 | if ( Res <= 1.) |
1005 | return 2.*ASin(Res); |
1006 | |
c6541a0c |
1007 | return 2.*M_PI; |
7fd59977 |
1008 | } |
1009 | |
1010 | //======================================================================= |
1011 | //function : Plane |
1012 | //purpose : |
1013 | //======================================================================= |
1014 | |
1015 | gp_Pln GeomAdaptor_Surface::Plane() const |
1016 | { |
1017 | if (mySurfaceType != GeomAbs_Plane) |
1018 | Standard_NoSuchObject::Raise("GeomAdaptor_Surface::Plane"); |
1019 | return (*((Handle(Geom_Plane)*)&mySurface))->Pln(); |
1020 | } |
1021 | |
1022 | //======================================================================= |
1023 | //function : Cylinder |
1024 | //purpose : |
1025 | //======================================================================= |
1026 | |
1027 | gp_Cylinder GeomAdaptor_Surface::Cylinder() const |
1028 | { |
1029 | if (mySurfaceType != GeomAbs_Cylinder) |
1030 | Standard_NoSuchObject::Raise("GeomAdaptor_Surface::Cylinder"); |
1031 | return (*((Handle(Geom_CylindricalSurface)*)&mySurface))->Cylinder(); |
1032 | } |
1033 | |
1034 | //======================================================================= |
1035 | //function : Cone |
1036 | //purpose : |
1037 | //======================================================================= |
1038 | |
1039 | gp_Cone GeomAdaptor_Surface::Cone() const |
1040 | { |
1041 | if (mySurfaceType != GeomAbs_Cone) |
1042 | Standard_NoSuchObject::Raise("GeomAdaptor_Surface::Cone"); |
1043 | return (*((Handle(Geom_ConicalSurface)*)&mySurface))->Cone(); |
1044 | } |
1045 | |
1046 | //======================================================================= |
1047 | //function : Sphere |
1048 | //purpose : |
1049 | //======================================================================= |
1050 | |
1051 | gp_Sphere GeomAdaptor_Surface::Sphere() const |
1052 | { |
1053 | if (mySurfaceType != GeomAbs_Sphere) |
1054 | Standard_NoSuchObject::Raise("GeomAdaptor_Surface::Sphere"); |
1055 | return (*((Handle(Geom_SphericalSurface)*)&mySurface))->Sphere(); |
1056 | } |
1057 | |
1058 | //======================================================================= |
1059 | //function : Torus |
1060 | //purpose : |
1061 | //======================================================================= |
1062 | |
1063 | gp_Torus GeomAdaptor_Surface::Torus() const |
1064 | { |
1065 | if (mySurfaceType != GeomAbs_Torus) |
1066 | Standard_NoSuchObject::Raise("GeomAdaptor_Surface::Torus"); |
1067 | return (*((Handle(Geom_ToroidalSurface)*)&mySurface))->Torus(); |
1068 | } |
1069 | |
1070 | //======================================================================= |
1071 | //function : UDegree |
1072 | //purpose : |
1073 | //======================================================================= |
1074 | |
1075 | Standard_Integer GeomAdaptor_Surface::UDegree() const |
1076 | { |
1077 | if (mySurfaceType == GeomAbs_BSplineSurface) |
1078 | return (*((Handle(Geom_BSplineSurface)*)&mySurface))->UDegree(); |
1079 | if ( mySurfaceType == GeomAbs_BezierSurface) |
1080 | return (*((Handle(Geom_BezierSurface)*)&mySurface))->UDegree(); |
1081 | if ( mySurfaceType == GeomAbs_SurfaceOfExtrusion) |
1082 | { |
1083 | GeomAdaptor_Curve myBasisCurve |
1084 | ((*((Handle(Geom_SurfaceOfLinearExtrusion)*)&mySurface))->BasisCurve(),myUFirst,myULast); |
1085 | return myBasisCurve.Degree(); |
1086 | } |
1087 | Standard_NoSuchObject::Raise("GeomAdaptor_Surface::UDegree"); |
1088 | return 0; |
1089 | } |
1090 | |
1091 | //======================================================================= |
1092 | //function : NbUPoles |
1093 | //purpose : |
1094 | //======================================================================= |
1095 | |
1096 | Standard_Integer GeomAdaptor_Surface::NbUPoles() const |
1097 | { |
1098 | if (mySurfaceType == GeomAbs_BSplineSurface) |
1099 | return (*((Handle(Geom_BSplineSurface)*)&mySurface))->NbUPoles(); |
1100 | if ( mySurfaceType == GeomAbs_BezierSurface) |
1101 | return (*((Handle(Geom_BezierSurface)*)&mySurface))->NbUPoles(); |
1102 | if ( mySurfaceType == GeomAbs_SurfaceOfExtrusion) |
1103 | { |
1104 | GeomAdaptor_Curve myBasisCurve |
1105 | ((*((Handle(Geom_SurfaceOfLinearExtrusion)*)&mySurface))->BasisCurve(),myUFirst,myULast); |
1106 | return myBasisCurve.NbPoles(); |
1107 | } |
1108 | Standard_NoSuchObject::Raise("GeomAdaptor_Surface::NbUPoles"); |
1109 | return 0; |
1110 | } |
1111 | |
1112 | //======================================================================= |
1113 | //function : VDegree |
1114 | //purpose : |
1115 | //======================================================================= |
1116 | |
1117 | Standard_Integer GeomAdaptor_Surface::VDegree() const |
1118 | { |
1119 | if (mySurfaceType == GeomAbs_BSplineSurface) |
1120 | return (*((Handle(Geom_BSplineSurface)*)&mySurface))->VDegree(); |
1121 | if ( mySurfaceType == GeomAbs_BezierSurface) |
1122 | return (*((Handle(Geom_BezierSurface)*)&mySurface))->VDegree(); |
1123 | if ( mySurfaceType == GeomAbs_SurfaceOfRevolution) |
1124 | { |
1125 | GeomAdaptor_Curve myBasisCurve |
1126 | ((*((Handle(Geom_SurfaceOfRevolution)*)&mySurface))->BasisCurve(),myUFirst,myULast); |
1127 | return myBasisCurve.Degree(); |
1128 | } |
1129 | Standard_NoSuchObject::Raise("GeomAdaptor_Surface::VDegree"); |
1130 | return 0; |
1131 | } |
1132 | |
1133 | //======================================================================= |
1134 | //function : NbVPoles |
1135 | //purpose : |
1136 | //======================================================================= |
1137 | |
1138 | Standard_Integer GeomAdaptor_Surface::NbVPoles() const |
1139 | { |
1140 | if (mySurfaceType == GeomAbs_BSplineSurface) |
1141 | return (*((Handle(Geom_BSplineSurface)*)&mySurface))->NbVPoles(); |
1142 | if ( mySurfaceType == GeomAbs_BezierSurface) |
1143 | return (*((Handle(Geom_BezierSurface)*)&mySurface))->NbVPoles(); |
1144 | if ( mySurfaceType == GeomAbs_SurfaceOfRevolution) |
1145 | { |
1146 | GeomAdaptor_Curve myBasisCurve |
1147 | ((*((Handle(Geom_SurfaceOfRevolution)*)&mySurface))->BasisCurve(),myUFirst,myULast); |
1148 | return myBasisCurve.NbPoles(); |
1149 | } |
1150 | Standard_NoSuchObject::Raise("GeomAdaptor_Surface::NbVPoles"); |
1151 | return 0; |
1152 | } |
1153 | |
1154 | //======================================================================= |
1155 | //function : NbUKnots |
1156 | //purpose : |
1157 | //======================================================================= |
1158 | |
1159 | Standard_Integer GeomAdaptor_Surface::NbUKnots() const |
1160 | { |
1161 | if (mySurfaceType == GeomAbs_BSplineSurface) |
1162 | return (*((Handle(Geom_BSplineSurface)*)&mySurface))->NbUKnots(); |
1163 | if ( mySurfaceType == GeomAbs_SurfaceOfExtrusion) |
1164 | { |
1165 | GeomAdaptor_Curve myBasisCurve |
1166 | ((*((Handle(Geom_SurfaceOfLinearExtrusion)*)&mySurface))->BasisCurve(),myUFirst,myULast); |
1167 | return myBasisCurve.NbKnots(); |
1168 | } |
1169 | Standard_NoSuchObject::Raise("GeomAdaptor_Surface::NbUKnots"); |
1170 | return 0; |
1171 | } |
1172 | |
1173 | //======================================================================= |
1174 | //function : NbVKnots |
1175 | //purpose : |
1176 | //======================================================================= |
1177 | |
1178 | Standard_Integer GeomAdaptor_Surface::NbVKnots() const |
1179 | { |
1180 | if (mySurfaceType == GeomAbs_BSplineSurface) |
1181 | return (*((Handle(Geom_BSplineSurface)*)&mySurface))->NbVKnots(); |
1182 | Standard_NoSuchObject::Raise("GeomAdaptor_Surface::NbVKnots"); |
1183 | return 0; |
1184 | } |
1185 | //======================================================================= |
1186 | //function : IsURational |
1187 | //purpose : |
1188 | //======================================================================= |
1189 | |
1190 | Standard_Boolean GeomAdaptor_Surface::IsURational() const |
1191 | { |
1192 | if (mySurfaceType == GeomAbs_BSplineSurface) |
1193 | return (*((Handle(Geom_BSplineSurface)*)&mySurface))->IsURational(); |
1194 | if (mySurfaceType == GeomAbs_BezierSurface) |
1195 | return (*((Handle(Geom_BezierSurface)*)&mySurface))->IsURational(); |
1196 | return Standard_False; |
1197 | } |
1198 | |
1199 | //======================================================================= |
1200 | //function : IsVRational |
1201 | //purpose : |
1202 | //======================================================================= |
1203 | |
1204 | Standard_Boolean GeomAdaptor_Surface::IsVRational() const |
1205 | { |
1206 | if (mySurfaceType == GeomAbs_BSplineSurface) |
1207 | return (*((Handle(Geom_BSplineSurface)*)&mySurface))->IsVRational(); |
1208 | if (mySurfaceType == GeomAbs_BezierSurface) |
1209 | return (*((Handle(Geom_BezierSurface)*)&mySurface))->IsVRational(); |
1210 | return Standard_False; |
1211 | } |
1212 | |
1213 | //======================================================================= |
1214 | //function : Bezier |
1215 | //purpose : |
1216 | //======================================================================= |
1217 | |
1218 | Handle(Geom_BezierSurface) GeomAdaptor_Surface::Bezier() const |
1219 | { |
1220 | if (mySurfaceType != GeomAbs_BezierSurface) |
1221 | Standard_NoSuchObject::Raise("GeomAdaptor_Surface::Bezier"); |
1222 | return *((Handle(Geom_BezierSurface)*)&mySurface); |
1223 | } |
1224 | |
1225 | //======================================================================= |
1226 | //function : BSpline |
1227 | //purpose : |
1228 | //======================================================================= |
1229 | |
1230 | Handle(Geom_BSplineSurface) GeomAdaptor_Surface::BSpline() const |
1231 | { |
1232 | if (mySurfaceType != GeomAbs_BSplineSurface) |
1233 | Standard_NoSuchObject::Raise("GeomAdaptor_Surface::BSpline"); |
1234 | return *((Handle(Geom_BSplineSurface)*)&mySurface); |
1235 | } |
1236 | |
1237 | //======================================================================= |
1238 | //function : AxeOfRevolution |
1239 | //purpose : |
1240 | //======================================================================= |
1241 | |
1242 | gp_Ax1 GeomAdaptor_Surface::AxeOfRevolution() const |
1243 | { |
1244 | if (mySurfaceType != GeomAbs_SurfaceOfRevolution) |
1245 | Standard_NoSuchObject::Raise("GeomAdaptor_Surface::AxeOfRevolution"); |
1246 | return (*((Handle(Geom_SurfaceOfRevolution)*)&mySurface))->Axis(); |
1247 | } |
1248 | |
1249 | //======================================================================= |
1250 | //function : Direction |
1251 | //purpose : |
1252 | //======================================================================= |
1253 | |
1254 | gp_Dir GeomAdaptor_Surface::Direction() const |
1255 | { |
1256 | if (mySurfaceType != GeomAbs_SurfaceOfExtrusion) |
1257 | Standard_NoSuchObject::Raise("GeomAdaptor_Surface::Direction"); |
1258 | return (*((Handle(Geom_SurfaceOfLinearExtrusion)*)&mySurface))->Direction(); |
1259 | } |
1260 | |
1261 | //======================================================================= |
1262 | //function : BasisCurve |
1263 | //purpose : |
1264 | //======================================================================= |
1265 | |
1266 | Handle(Adaptor3d_HCurve) GeomAdaptor_Surface::BasisCurve() const |
1267 | { |
1268 | Handle(Geom_Curve) C; |
1269 | if (mySurfaceType == GeomAbs_SurfaceOfExtrusion) |
1270 | C = (*((Handle(Geom_SurfaceOfLinearExtrusion)*)&mySurface))->BasisCurve(); |
1271 | else if (mySurfaceType == GeomAbs_SurfaceOfRevolution) |
1272 | C = (*((Handle(Geom_SurfaceOfRevolution)*)&mySurface))->BasisCurve(); |
1273 | else |
1274 | Standard_NoSuchObject::Raise("GeomAdaptor_Surface::BasisCurve"); |
1275 | return Handle(GeomAdaptor_HCurve)(new GeomAdaptor_HCurve(C)); |
1276 | } |
1277 | |
1278 | //======================================================================= |
1279 | //function : BasisSurface |
1280 | //purpose : |
1281 | //======================================================================= |
1282 | |
1283 | Handle(Adaptor3d_HSurface) GeomAdaptor_Surface::BasisSurface() const |
1284 | { |
1285 | if (mySurfaceType != GeomAbs_OffsetSurface) |
1286 | Standard_NoSuchObject::Raise("GeomAdaptor_Surface::BasisSurface"); |
1287 | return new GeomAdaptor_HSurface |
1288 | ((*((Handle(Geom_OffsetSurface)*)&mySurface))->BasisSurface(), |
1289 | myUFirst,myULast,myVFirst,myVLast); |
1290 | } |
1291 | |
1292 | //======================================================================= |
1293 | //function : OffsetValue |
1294 | //purpose : |
1295 | //======================================================================= |
1296 | |
1297 | Standard_Real GeomAdaptor_Surface::OffsetValue() const |
1298 | { |
1299 | if (mySurfaceType != GeomAbs_OffsetSurface) |
1300 | Standard_NoSuchObject::Raise("GeomAdaptor_Surface::BasisSurface"); |
1301 | return (*((Handle(Geom_OffsetSurface)*)&mySurface))->Offset(); |
1302 | } |
1303 | |
1304 | //======================================================================= |
1305 | //function : IfUVBound <private> |
1306 | //purpose : locates U,V parameters if U,V =First, Last, |
1307 | // processes the finding span and returns the |
1308 | // parameters for LocalDi |
1309 | //======================================================================= |
1310 | |
1311 | Standard_Boolean GeomAdaptor_Surface::IfUVBound(const Standard_Real U, |
1312 | const Standard_Real V, |
1313 | Standard_Integer& IOutDeb, |
1314 | Standard_Integer& IOutFin, |
1315 | Standard_Integer& IOutVDeb, |
1316 | Standard_Integer& IOutVFin, |
1317 | const Standard_Integer USide, |
1318 | const Standard_Integer VSide) const |
1319 | { |
1320 | Standard_Integer Ideb,Ifin; |
470ebb43 |
1321 | Standard_Integer anUFKIndx = myBspl->FirstUKnotIndex(), |
1322 | anULKIndx = myBspl->LastUKnotIndex(), |
1323 | aVFKIndx = myBspl->FirstVKnotIndex(), aVLKIndx = myBspl->LastVKnotIndex(); |
7fd59977 |
1324 | myBspl->LocateU(U, PosTol, Ideb, Ifin, Standard_False); |
1325 | Standard_Boolean Local = (Ideb == Ifin); |
470ebb43 |
1326 | Span(USide,Ideb,Ifin,Ideb,Ifin,anUFKIndx,anULKIndx); |
7fd59977 |
1327 | Standard_Integer IVdeb,IVfin; |
1328 | myBspl->LocateV(V, PosTol, IVdeb, IVfin, Standard_False); |
1329 | if(IVdeb == IVfin) Local = Standard_True; |
470ebb43 |
1330 | Span(VSide,IVdeb,IVfin,IVdeb,IVfin,aVFKIndx,aVLKIndx); |
7fd59977 |
1331 | |
1332 | IOutDeb=Ideb; IOutFin=Ifin; |
1333 | IOutVDeb=IVdeb; IOutVFin=IVfin; |
1334 | |
1335 | return Local; |
1336 | } |
7fd59977 |
1337 | //======================================================================= |
1338 | //function : Span <private> |
1339 | //purpose : locates U,V parameters if U=UFirst or U=ULast, |
1340 | // processes the finding span and returns the |
1341 | // parameters for LocalDi |
1342 | //======================================================================= |
1343 | |
1344 | void GeomAdaptor_Surface::Span(const Standard_Integer Side, |
1345 | const Standard_Integer Ideb, |
1346 | const Standard_Integer Ifin, |
1347 | Standard_Integer& OutIdeb, |
1348 | Standard_Integer& OutIfin, |
470ebb43 |
1349 | const Standard_Integer theFKIndx, |
1350 | const Standard_Integer theLKIndx) const |
7fd59977 |
1351 | { |
1352 | if(Ideb!=Ifin)//not a knot |
1353 | { |
470ebb43 |
1354 | if(Ideb<theFKIndx) { OutIdeb=theFKIndx; OutIfin=theFKIndx+1; } |
1355 | else if(Ifin>theLKIndx) { OutIdeb=theLKIndx-1; OutIfin=theLKIndx; } |
1356 | else if(Ideb>=(theLKIndx-1)) { OutIdeb=theLKIndx-1; OutIfin=theLKIndx; } |
1357 | else if(Ifin<=theFKIndx+1) { OutIdeb=theFKIndx; OutIfin=theFKIndx+1; } |
7fd59977 |
1358 | else if(Ideb>Ifin) { OutIdeb=Ifin-1; OutIfin=Ifin; } |
1359 | else { OutIdeb=Ideb; OutIfin=Ifin; } |
1360 | } |
1361 | else |
1362 | { |
470ebb43 |
1363 | if(Ideb<=theFKIndx){ OutIdeb=theFKIndx; OutIfin=theFKIndx+1;}//first knot |
1364 | else if(Ifin>=theLKIndx) { OutIdeb=theLKIndx-1;OutIfin=theLKIndx;}//last knot |
7fd59977 |
1365 | else |
1366 | { |
1367 | if(Side==-1){OutIdeb=Ideb-1; OutIfin=Ifin;} |
1368 | else {OutIdeb=Ideb; OutIfin=Ifin+1;} |
1369 | } |
1370 | } |
1371 | } |