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