0025976: Conversion of an offset face from a spline into a spline face hangs-up the...
authorifv <ifv@opencascade.com>
Thu, 26 Mar 2015 12:42:42 +0000 (15:42 +0300)
committerapn <apn@opencascade.com>
Thu, 26 Mar 2015 15:10:25 +0000 (18:10 +0300)
Tests-case for issue #25976

src/GeomConvert/GeomConvert_1.cxx
tests/bugs/modalg_5/bug25976 [new file with mode: 0644]

index 5c98468..d4cb967 100644 (file)
@@ -86,7 +86,7 @@ typedef Handle(Geom_BSplineSurface)           Handle(BSplineSurface);
 typedef Handle(Geom_SurfaceOfRevolution)      Handle(SurfaceOfRevolution);
 typedef Handle(Geom_SurfaceOfLinearExtrusion) Handle(SurfaceOfLinearExtrusion);
 typedef Handle(Geom_RectangularTrimmedSurface) 
-        Handle(RectangularTrimmedSurface);
+  Handle(RectangularTrimmedSurface);
 
 
 typedef TColStd_Array1OfReal                 Array1OfReal;
@@ -137,9 +137,9 @@ Handle(BSplineSurface) BSplineSurfaceBuilder
     VMults (i) = Convert.VMultiplicity (i);
   }
   TheSurface = new BSplineSurface (Poles, Weights, UKnots, VKnots, 
-                                   UMults, VMults, UDegree, VDegree,
-                                  Convert.IsUPeriodic(),
-                                  Convert.IsVPeriodic());
+    UMults, VMults, UDegree, VDegree,
+    Convert.IsUPeriodic(),
+    Convert.IsVPeriodic());
   return TheSurface;
 }
 
@@ -150,12 +150,12 @@ Handle(BSplineSurface) BSplineSurfaceBuilder
 
 Handle(BSplineSurface) GeomConvert::SplitBSplineSurface 
   (const Handle(BSplineSurface)& S,
-   const Standard_Integer FromUK1, 
-   const Standard_Integer ToUK2,
-   const Standard_Integer FromVK1, 
-   const Standard_Integer ToVK2,
-   const Standard_Boolean SameUOrientation, 
-   const Standard_Boolean SameVOrientation ) 
+  const Standard_Integer FromUK1, 
+  const Standard_Integer ToUK2,
+  const Standard_Integer FromVK1, 
+  const Standard_Integer ToVK2,
+  const Standard_Boolean SameUOrientation, 
+  const Standard_Boolean SameVOrientation ) 
 {
   Standard_Integer FirstU = S->FirstUKnotIndex ();
   Standard_Integer FirstV = S->FirstVKnotIndex ();
@@ -167,12 +167,12 @@ Handle(BSplineSurface) GeomConvert::SplitBSplineSurface
   Standard_Integer FirstVK = Min (FromVK1, ToVK2);
   Standard_Integer LastVK  = Max (FromVK1, ToVK2);
   if (FirstUK < FirstU || LastUK > LastU || 
-      FirstVK < FirstV || LastVK > LastV) { Standard_DomainError::Raise(); }
+    FirstVK < FirstV || LastVK > LastV) { Standard_DomainError::Raise(); }
 
   Handle(BSplineSurface) S1= Handle(BSplineSurface)::DownCast(S->Copy());
-  
+
   S1->Segment(S1->UKnot(FirstUK),S1->UKnot(LastUK),
-             S1->VKnot(FirstVK),S1->VKnot(LastVK));
+    S1->VKnot(FirstVK),S1->VKnot(LastVK));
 
   if (S->IsUPeriodic()) {
     if (!SameUOrientation) S1->UReverse();
@@ -197,10 +197,10 @@ Handle(BSplineSurface) GeomConvert::SplitBSplineSurface
 
 Handle(BSplineSurface) GeomConvert::SplitBSplineSurface 
   (const Handle(BSplineSurface)& S,
-   const Standard_Integer FromK1,
-   const Standard_Integer ToK2,
-   const Standard_Boolean USplit, 
-   const Standard_Boolean SameOrientation )
+  const Standard_Integer FromK1,
+  const Standard_Integer ToK2,
+  const Standard_Boolean USplit, 
+  const Standard_Boolean SameOrientation )
 {
   if (FromK1 == ToK2)   Standard_DomainError::Raise();
 
@@ -216,9 +216,9 @@ Handle(BSplineSurface) GeomConvert::SplitBSplineSurface
     if (FirstUK < FirstU || LastUK > LastU)  Standard_DomainError::Raise();
 
     S1->Segment( S1->UKnot(FirstUK), 
-                S1->UKnot(LastUK),
-                S1->VKnot(S1->FirstVKnotIndex()),
-                S1->VKnot(S1->LastVKnotIndex()));
+      S1->UKnot(LastUK),
+      S1->VKnot(S1->FirstVKnotIndex()),
+      S1->VKnot(S1->LastVKnotIndex()));
 
     if (S->IsUPeriodic()) {
       if (!SameOrientation) S1->UReverse();
@@ -237,9 +237,9 @@ Handle(BSplineSurface) GeomConvert::SplitBSplineSurface
     if (FirstVK < FirstV || LastVK > LastV)  Standard_DomainError::Raise();
 
     S1->Segment( S1->UKnot(S1->FirstUKnotIndex()), 
-                S1->UKnot(S1->LastUKnotIndex()),
-                S1->VKnot(FirstVK),
-                S1->VKnot(LastVK));
+      S1->UKnot(S1->LastUKnotIndex()),
+      S1->VKnot(FirstVK),
+      S1->VKnot(LastVK));
 
 
     if (S->IsVPeriodic()) {
@@ -260,14 +260,14 @@ Handle(BSplineSurface) GeomConvert::SplitBSplineSurface
 
 Handle(BSplineSurface) GeomConvert::SplitBSplineSurface 
   (const Handle(BSplineSurface)& S, 
-   const Standard_Real FromU1, 
-   const Standard_Real ToU2,
-   const Standard_Real FromV1, 
-   const Standard_Real ToV2,
-//   const Standard_Real ParametricTolerance,
-   const Standard_Real ,
-   const Standard_Boolean SameUOrientation, 
-   const Standard_Boolean SameVOrientation )
+  const Standard_Real FromU1, 
+  const Standard_Real ToU2,
+  const Standard_Real FromV1, 
+  const Standard_Real ToV2,
+  //   const Standard_Real ParametricTolerance,
+  const Standard_Real ,
+  const Standard_Boolean SameUOrientation, 
+  const Standard_Boolean SameVOrientation )
 {
   Standard_Real FirstU = Min( FromU1, ToU2);
   Standard_Real LastU  = Max( FromU1, ToU2);
@@ -302,11 +302,11 @@ Handle(BSplineSurface) GeomConvert::SplitBSplineSurface
 
 Handle(BSplineSurface) GeomConvert::SplitBSplineSurface 
   (const Handle(BSplineSurface)& S, 
-   const Standard_Real                    FromParam1, 
-   const Standard_Real                    ToParam2,
-   const Standard_Boolean                 USplit, 
-   const Standard_Real                    ParametricTolerance, 
-   const Standard_Boolean                 SameOrientation  )
+  const Standard_Real                    FromParam1, 
+  const Standard_Real                    ToParam2,
+  const Standard_Boolean                 USplit, 
+  const Standard_Real                    ParametricTolerance, 
+  const Standard_Boolean                 SameOrientation  )
 {
   if (Abs (FromParam1 - ToParam2) <= Abs(ParametricTolerance)) {
     Standard_DomainError::Raise();
@@ -355,7 +355,7 @@ Handle(BSplineSurface) GeomConvert::SplitBSplineSurface
 //purpose  : 
 //=======================================================================
 
- Handle(Geom_BSplineSurface) GeomConvert::SurfaceToBSplineSurface
+Handle(Geom_BSplineSurface) GeomConvert::SurfaceToBSplineSurface
   (const Handle(Surface)& Sr) 
 {
   Standard_Real U1, U2, V1, V2;
@@ -367,12 +367,12 @@ Handle(BSplineSurface) GeomConvert::SplitBSplineSurface
 
   //If the surface Sr is infinite stop the computation
   if (Precision::IsNegativeInfinite(UFirst) || 
-      Precision::IsPositiveInfinite(ULast)  || 
-      Precision::IsNegativeInfinite(VFirst) || 
-      Precision::IsPositiveInfinite(VLast) )   {
-       Standard_DomainError::Raise("");
-       }
-  
+    Precision::IsPositiveInfinite(ULast)  || 
+    Precision::IsNegativeInfinite(VFirst) || 
+    Precision::IsPositiveInfinite(VLast) )   {
+      Standard_DomainError::Raise("");
+  }
+
   Handle(Geom_BSplineSurface) TheSurface;
   Handle(Surface) S; 
   Handle(Geom_OffsetSurface) OffsetSur;
@@ -387,29 +387,29 @@ Handle(BSplineSurface) GeomConvert::SplitBSplineSurface
 
   if (S->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) {
     Handle(Geom_RectangularTrimmedSurface) Strim = 
-       Handle(Geom_RectangularTrimmedSurface)::DownCast(S);
-    
+      Handle(Geom_RectangularTrimmedSurface)::DownCast(S);
+
     Handle(Geom_Surface) Surf = Strim->BasisSurface();
     UFirst = U1;  ULast = U2; VFirst = V1; VLast = V2;
     if (Surf->IsKind(STANDARD_TYPE(Geom_OffsetSurface))) {
       Handle(Geom_OffsetSurface) OffsetSur = 
-      Handle(Geom_OffsetSurface)::DownCast(Surf);
+        Handle(Geom_OffsetSurface)::DownCast(Surf);
 
       S = OffsetSur->Surface();
       if (!S.IsNull()) {
-       Surf = S;
+        Surf = S;
       } 
       else S = Surf;
     }
 
     if  (Surf->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) {
-       Handle(Geom_RectangularTrimmedSurface) Strim = new 
-        (Geom_RectangularTrimmedSurface) (Surf, 
-                                          UFirst, ULast, 
-                                          VFirst, VLast);
-       return SurfaceToBSplineSurface(Strim);
+      Handle(Geom_RectangularTrimmedSurface) Strim = new 
+        (Geom_RectangularTrimmedSurface) (Surf, 
+        UFirst, ULast, 
+        VFirst, VLast);
+      return SurfaceToBSplineSurface(Strim);
     }
-                    
+
     if (Surf->IsKind(STANDARD_TYPE(Geom_Plane))) {
       TColgp_Array2OfPnt Poles (1, 2, 1, 2);
       Poles (1, 1) = Strim->Value (U1, V1);
@@ -431,12 +431,12 @@ Handle(BSplineSurface) GeomConvert::SplitBSplineSurface
       Standard_Integer UDegree = 1;
       Standard_Integer VDegree = 1;
       TheSurface = new Geom_BSplineSurface (Poles, UKnots, VKnots, UMults,
-                                            VMults, UDegree, VDegree);
+        VMults, UDegree, VDegree);
     }
     else if (Surf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) {
       Handle(Geom_CylindricalSurface) TheElSurf= 
-       Handle(Geom_CylindricalSurface)::DownCast(Surf);
-      
+        Handle(Geom_CylindricalSurface)::DownCast(Surf);
+
       gp_Cylinder Cyl = TheElSurf->Cylinder();
       if (Strim->IsUClosed()) {
         Convert_CylinderToBSplineSurface Convert (Cyl, VFirst, VLast);
@@ -444,15 +444,15 @@ Handle(BSplineSurface) GeomConvert::SplitBSplineSurface
       }
       else {
         Convert_CylinderToBSplineSurface 
-         Conv (Cyl, UFirst, ULast, VFirst, VLast);
+          Conv (Cyl, UFirst, ULast, VFirst, VLast);
         TheSurface = BSplineSurfaceBuilder (Conv);
       }
     }
-    
-    
+
+
     else if (Surf->IsKind(STANDARD_TYPE(Geom_ConicalSurface))) {
       Handle(Geom_ConicalSurface) TheElSurf = 
-       Handle(Geom_ConicalSurface)::DownCast(Surf);
+        Handle(Geom_ConicalSurface)::DownCast(Surf);
       gp_Cone Co = TheElSurf->Cone();
       if (Strim->IsUClosed()) {
         Convert_ConeToBSplineSurface Convert (Co, VFirst, VLast);
@@ -460,39 +460,39 @@ Handle(BSplineSurface) GeomConvert::SplitBSplineSurface
       }
       else {
         Convert_ConeToBSplineSurface 
-         Convert (Co, UFirst, ULast, VFirst, VLast);
+          Convert (Co, UFirst, ULast, VFirst, VLast);
         TheSurface = BSplineSurfaceBuilder (Convert);
       }
     }
-    
-    
+
+
     else if (Surf->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) {
       Handle(Geom_SphericalSurface) TheElSurf = 
-       Handle(Geom_SphericalSurface)::DownCast(Surf);
+        Handle(Geom_SphericalSurface)::DownCast(Surf);
       gp_Sphere Sph = TheElSurf->Sphere();
       //OCC217
       if (Strim->IsUClosed()) {
-      //if (Strim->IsVClosed()) {
+        //if (Strim->IsVClosed()) {
         //Convert_SphereToBSplineSurface Convert (Sph, UFirst, ULast);
-       Convert_SphereToBSplineSurface Convert (Sph, VFirst, VLast, Standard_False);
-       TheSurface = BSplineSurfaceBuilder (Convert);
+        Convert_SphereToBSplineSurface Convert (Sph, VFirst, VLast, Standard_False);
+        TheSurface = BSplineSurfaceBuilder (Convert);
       }
       else {
-       Convert_SphereToBSplineSurface 
-         Convert (Sph, UFirst, ULast, VFirst, VLast);
-       TheSurface = BSplineSurfaceBuilder (Convert);
+        Convert_SphereToBSplineSurface 
+          Convert (Sph, UFirst, ULast, VFirst, VLast);
+        TheSurface = BSplineSurfaceBuilder (Convert);
       }
     }
-    
-    
+
+
     else if (Surf->IsKind(STANDARD_TYPE(Geom_ToroidalSurface))) {
       Handle(Geom_ToroidalSurface) TheElSurf = 
-       Handle(Geom_ToroidalSurface)::DownCast(Surf);
-      
+        Handle(Geom_ToroidalSurface)::DownCast(Surf);
+
       gp_Torus Tr = TheElSurf->Torus();
       if (Strim->IsUClosed()) { 
         Convert_TorusToBSplineSurface Convert (Tr, VFirst, VLast, 
-                                              Standard_False);
+          Standard_False);
         TheSurface = BSplineSurfaceBuilder (Convert);
       }
       else if (Strim->IsVClosed()) {
@@ -501,25 +501,25 @@ Handle(BSplineSurface) GeomConvert::SplitBSplineSurface
       }
       else {
         Convert_TorusToBSplineSurface 
-         Convert (Tr, UFirst, ULast, VFirst, VLast);
+          Convert (Tr, UFirst, ULast, VFirst, VLast);
         TheSurface = BSplineSurfaceBuilder (Convert);
       }
     }
-    
-    
+
+
     else if (Surf->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) {
       Handle(Geom_SurfaceOfRevolution) Revol = 
-       Handle(Geom_SurfaceOfRevolution)::DownCast(Surf);
-      
+        Handle(Geom_SurfaceOfRevolution)::DownCast(Surf);
+
       Handle(Geom_Curve) Meridian = Revol->BasisCurve();
       Handle(Geom_BSplineCurve) C; 
       if (Strim->IsVClosed()) {
-       C =  GeomConvert::CurveToBSplineCurve (Meridian);
+        C =  GeomConvert::CurveToBSplineCurve (Meridian);
       }
       else {
-       Handle(Geom_TrimmedCurve) CT = 
-         new Geom_TrimmedCurve( Meridian, VFirst, VLast);
-       C =  GeomConvert::CurveToBSplineCurve (CT);
+        Handle(Geom_TrimmedCurve) CT = 
+          new Geom_TrimmedCurve( Meridian, VFirst, VLast);
+        C =  GeomConvert::CurveToBSplineCurve (CT);
       }
       Standard_Integer NbUPoles, NbUKnots;
       Standard_Integer NbVPoles, NbVKnots;
@@ -536,30 +536,30 @@ Handle(BSplineSurface) GeomConvert::SplitBSplineSurface
       Standard_Integer nbUSpans;
       Standard_Real AlfaU;
       if (Strim->IsUPeriodic()) {
-       NbUKnots = 4;
-       nbUSpans = 3;
-       AlfaU    = M_PI / 3.;
-       NbUPoles = 6;
-       periodic = Standard_True;
+        NbUKnots = 4;
+        nbUSpans = 3;
+        AlfaU    = M_PI / 3.;
+        NbUPoles = 6;
+        periodic = Standard_True;
       }
       else {
-       // Nombre de spans : ouverture maximale = 150 degres ( = PI / 1.2 rds)
-       nbUSpans = 
-         (Standard_Integer)IntegerPart( 1.2 * (ULast - UFirst) / M_PI) + 1;
-       AlfaU = (ULast - UFirst) / ( nbUSpans * 2);
-       NbUPoles = 2 * nbUSpans + 1;
-       NbUKnots = nbUSpans + 1;
+        // Nombre de spans : ouverture maximale = 150 degres ( = PI / 1.2 rds)
+        nbUSpans = 
+          (Standard_Integer)IntegerPart( 1.2 * (ULast - UFirst) / M_PI) + 1;
+        AlfaU = (ULast - UFirst) / ( nbUSpans * 2);
+        NbUPoles = 2 * nbUSpans + 1;
+        NbUKnots = nbUSpans + 1;
       }
       // Compute Knots and Mults
       TColStd_Array1OfReal    UKnots(1, NbUKnots);
       TColStd_Array1OfInteger UMults( 1, NbUKnots);
       Standard_Integer i,j;
       for ( i = 1; i <= NbUKnots; i++) {
-       UKnots(i) = UFirst + (i-1) * 2 * AlfaU;
-       UMults(i) = 2;
+        UKnots(i) = UFirst + (i-1) * 2 * AlfaU;
+        UMults(i) = 2;
       }
       if (!periodic) {
-       UMults(1)++; UMults(NbUKnots)++;
+        UMults(1)++; UMults(NbUKnots)++;
       }
       NbVKnots = C->NbKnots();
       TColStd_Array1OfReal    VKnots(1, NbVKnots);
@@ -573,51 +573,51 @@ Handle(BSplineSurface) GeomConvert::SplitBSplineSurface
       gp_Trsf Trsf;
 
       for ( i = 1; i<= NbUPoles; i+=2) {
-       Trsf.SetRotation( Revol->Axis(), UFirst + (i-1)*AlfaU);
-       for ( j = 1; j <= NbVPoles; j++) {
-         NewPoles(i,j) = Poles(j).Transformed(Trsf);
-         NewWeights(i,j) = Weights(j);
-       }
+        Trsf.SetRotation( Revol->Axis(), UFirst + (i-1)*AlfaU);
+        for ( j = 1; j <= NbVPoles; j++) {
+          NewPoles(i,j) = Poles(j).Transformed(Trsf);
+          NewWeights(i,j) = Weights(j);
+        }
       }
       gp_GTrsf Aff;
       Aff.SetAffinity( Revol->Axis(), 1/Cos(AlfaU));
       gp_XYZ coord;
       for ( j= 1; j<= NbVPoles; j++) {
-       coord = Poles(j).XYZ();
-       Aff.Transforms(coord);
-       Poles(j).SetXYZ(coord);
+        coord = Poles(j).XYZ();
+        Aff.Transforms(coord);
+        Poles(j).SetXYZ(coord);
       }
       for ( i = 2; i<= NbUPoles; i+=2) {
-       Trsf.SetRotation( Revol->Axis(), UFirst + (i-1)*AlfaU);
-       for ( j = 1; j <= NbVPoles; j++) {
-         NewPoles(i,j) = Poles(j).Transformed(Trsf);
-         NewWeights(i,j) = Weights(j) * Cos(AlfaU);
-       }
+        Trsf.SetRotation( Revol->Axis(), UFirst + (i-1)*AlfaU);
+        for ( j = 1; j <= NbVPoles; j++) {
+          NewPoles(i,j) = Poles(j).Transformed(Trsf);
+          NewWeights(i,j) = Weights(j) * Cos(AlfaU);
+        }
       }
 
       TheSurface = new Geom_BSplineSurface(NewPoles, NewWeights, 
-                                          UKnots, VKnots, 
-                                          UMults, VMults,
-                                          2 , C->Degree(),
-                                          periodic, C->IsPeriodic());
+        UKnots, VKnots, 
+        UMults, VMults,
+        2 , C->Degree(),
+        periodic, C->IsPeriodic());
 
 
     }
-    
-    
+
+
     else if (Surf->IsKind(STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion))) {
       Handle(Geom_SurfaceOfLinearExtrusion) Extru = 
-       Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(Surf);
-      
+        Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(Surf);
+
       Handle(Geom_Curve) Meridian = Extru->BasisCurve();
       Handle(Geom_BSplineCurve) C; 
       if (Strim->IsUClosed()) {
-       C =  GeomConvert::CurveToBSplineCurve (Meridian);
+        C =  GeomConvert::CurveToBSplineCurve (Meridian);
       }
       else {
-       Handle(Geom_TrimmedCurve) CT = 
-         new Geom_TrimmedCurve( Meridian, UFirst, ULast);
-       C =  GeomConvert::CurveToBSplineCurve (CT);
+        Handle(Geom_TrimmedCurve) CT = 
+          new Geom_TrimmedCurve( Meridian, UFirst, ULast);
+        C =  GeomConvert::CurveToBSplineCurve (CT);
       }
       TColgp_Array2OfPnt      Poles  ( 1, C->NbPoles(), 1, 2);
       TColStd_Array2OfReal    Weights( 1, C->NbPoles(), 1, 2);
@@ -630,27 +630,27 @@ Handle(BSplineSurface) GeomConvert::SplitBSplineSurface
       VKnots(2) = VLast;
       TColStd_Array1OfInteger VMults ( 1, 2);
       VMults.Init(2);
-      
+
       gp_Vec D( Extru->Direction());
       gp_Vec DV1 = VFirst * D;
       gp_Vec DV2 = VLast  * D;
       for (Standard_Integer i = 1; i <= C->NbPoles(); i++) {
-       Poles(i,1) = C->Pole(i).Translated(DV1);
-       Poles(i,2) = C->Pole(i).Translated(DV2);
-       Weights(i,1) = Weights(i,2) = C->Weight(i);
+        Poles(i,1) = C->Pole(i).Translated(DV1);
+        Poles(i,2) = C->Pole(i).Translated(DV2);
+        Weights(i,1) = Weights(i,2) = C->Weight(i);
       } 
       TheSurface = new Geom_BSplineSurface(Poles, Weights, UKnots, VKnots, 
-                                          UMults, VMults,
-                                          C->Degree(), 1,
-                                          C->IsPeriodic(), Standard_False);
+        UMults, VMults,
+        C->Degree(), 1,
+        C->IsPeriodic(), Standard_False);
     }
 
-    
+
     else if (Surf->IsKind(STANDARD_TYPE(Geom_BezierSurface))) {
-      
+
       Handle(Geom_BezierSurface) SBez = 
-       Handle(Geom_BezierSurface)::DownCast(Surf->Copy());
-      
+        Handle(Geom_BezierSurface)::DownCast(Surf->Copy());
+
       SBez->Segment (U1, U2, V1, V2);
       Standard_Integer NbUPoles = SBez->NbUPoles();
       Standard_Integer NbVPoles = SBez->NbVPoles();
@@ -674,33 +674,33 @@ Handle(BSplineSurface) GeomConvert::SplitBSplineSurface
         TColStd_Array2OfReal Weights (1, NbUPoles, 1, NbVPoles);
         SBez->Weights (Weights);
         TheSurface = new Geom_BSplineSurface (Poles, Weights, UKnots, VKnots,
-                                             UMults, VMults,
-                                             UDegree, VDegree);
+          UMults, VMults,
+          UDegree, VDegree);
       }
       else {
         TheSurface = new Geom_BSplineSurface (Poles, UKnots, VKnots, 
-                                             UMults, VMults,
-                                             UDegree, VDegree);
+          UMults, VMults,
+          UDegree, VDegree);
       }
     }
-    
+
     else if (Surf->IsKind(STANDARD_TYPE(Geom_BSplineSurface))) {
       Handle(Geom_BSplineSurface) BS = 
-       Handle(Geom_BSplineSurface)::DownCast(Surf->Copy());
+        Handle(Geom_BSplineSurface)::DownCast(Surf->Copy());
       Standard_Real umin, umax, vmin, vmax;
       BS->Bounds(umin, umax, vmin, vmax);
       if (!BS->IsUPeriodic()) {
-       if (U1 < umin)
-         U1 = umin;
-       if (U2 > umax) 
-         U2 = umax;
+        if (U1 < umin)
+          U1 = umin;
+        if (U2 > umax) 
+          U2 = umax;
       }
 
       if (!BS->IsVPeriodic()) {
-       if (V1 < vmin)
-         V1 = vmin;
-       if (V2 > vmax)
-         V2 = vmax;
+        if (V1 < vmin)
+          V1 = vmin;
+        if (V2 > vmax)
+          V2 = vmax;
       }
       BS->Segment (U1, U2, V1, V2);
       TheSurface = BS;
@@ -712,46 +712,46 @@ Handle(BSplineSurface) GeomConvert::SplitBSplineSurface
       GeomAbs_Shape cont;
       GeomAdaptor_Surface AS(Sr);
       if (AS.NbUIntervals(GeomAbs_C2) > 1 || AS.NbVIntervals(GeomAbs_C2) > 1 ) 
-         cont=GeomAbs_C1;
+        cont=GeomAbs_C1;
       else
-         cont=GeomAbs_C2;
+        cont=GeomAbs_C2;
       MaxSeg = 4*(AS.NbUIntervals(GeomAbs_CN)+1)*(AS.NbVIntervals(GeomAbs_CN)+1); 
       GeomConvert_ApproxSurface BSpS(Sr, Tol3d, cont, cont,
-                                    MaxDegree, MaxDegree, MaxSeg, 1);
+        MaxDegree, MaxDegree, MaxSeg, 1);
       TheSurface = BSpS.Surface();
     }
   } // Fin du cas Rectangular::TrimmedSurface
-  
+
   else { 
 
     if (S->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) {
       Handle(Geom_SphericalSurface) TheElSurf = 
-       Handle(Geom_SphericalSurface)::DownCast(S);
-      
+        Handle(Geom_SphericalSurface)::DownCast(S);
+
       gp_Sphere Sph = TheElSurf->Sphere();
       Convert_SphereToBSplineSurface Convert(Sph);
       TheSurface = BSplineSurfaceBuilder(Convert);
     }
-    
+
 
     else if (S->IsKind(STANDARD_TYPE(Geom_ToroidalSurface))) {
       Handle(Geom_ToroidalSurface) TheElSurf = 
-       Handle(Geom_ToroidalSurface)::DownCast(S);
-      
+        Handle(Geom_ToroidalSurface)::DownCast(S);
+
       gp_Torus Tr = TheElSurf->Torus();
       Convert_TorusToBSplineSurface Convert(Tr);
       TheSurface = BSplineSurfaceBuilder(Convert);
     }
-    
-    
+
+
     else if (S->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) {
-      
+
       Handle(Geom_SurfaceOfRevolution) Revol = 
         Handle(Geom_SurfaceOfRevolution)::DownCast(S);
-      
+
       Handle(Geom_Curve) Meridian = Revol->BasisCurve();
       Handle(Geom_BSplineCurve) C 
-       = GeomConvert::CurveToBSplineCurve (Meridian);
+        = GeomConvert::CurveToBSplineCurve (Meridian);
 
       Standard_Integer NbUPoles, NbUKnots;
       Standard_Integer NbVPoles, NbVKnots;
@@ -775,8 +775,8 @@ Handle(BSplineSurface) GeomConvert::SplitBSplineSurface
       TColStd_Array1OfInteger UMults( 1, NbUKnots);
       Standard_Integer i,j;
       for ( i = 1; i <= NbUKnots; i++) {
-       UKnots(i) = UFirst + (i-1) * 2 * AlfaU;
-       UMults(i) = 2;
+        UKnots(i) = UFirst + (i-1) * 2 * AlfaU;
+        UMults(i) = 2;
       }
       NbVKnots = C->NbKnots();
       TColStd_Array1OfReal    VKnots(1, NbVKnots);
@@ -790,41 +790,41 @@ Handle(BSplineSurface) GeomConvert::SplitBSplineSurface
       gp_Trsf Trsf;
 
       for ( i = 1; i<= NbUPoles; i+=2) {
-       Trsf.SetRotation( Revol->Axis(), UFirst + (i-1)*AlfaU);
-       for ( j = 1; j <= NbVPoles; j++) {
-         NewPoles(i,j) = Poles(j).Transformed(Trsf);
-         NewWeights(i,j) = Weights(j);
-       }
+        Trsf.SetRotation( Revol->Axis(), UFirst + (i-1)*AlfaU);
+        for ( j = 1; j <= NbVPoles; j++) {
+          NewPoles(i,j) = Poles(j).Transformed(Trsf);
+          NewWeights(i,j) = Weights(j);
+        }
       }
       gp_GTrsf Aff;
       Aff.SetAffinity( Revol->Axis(), 1/Cos(AlfaU));
       gp_XYZ coord;
       for ( j= 1; j<= NbVPoles; j++) {
-       coord = Poles(j).XYZ();
-       Aff.Transforms(coord);
-       Poles(j).SetXYZ(coord);
+        coord = Poles(j).XYZ();
+        Aff.Transforms(coord);
+        Poles(j).SetXYZ(coord);
       }
       for ( i = 2; i<= NbUPoles; i+=2) {
-       Trsf.SetRotation( Revol->Axis(), UFirst + (i-1)*AlfaU);
-       for ( j = 1; j <= NbVPoles; j++) {
-         NewPoles(i,j) = Poles(j).Transformed(Trsf);
-         NewWeights(i,j) = Weights(j) * Cos(AlfaU);
-       }
+        Trsf.SetRotation( Revol->Axis(), UFirst + (i-1)*AlfaU);
+        for ( j = 1; j <= NbVPoles; j++) {
+          NewPoles(i,j) = Poles(j).Transformed(Trsf);
+          NewWeights(i,j) = Weights(j) * Cos(AlfaU);
+        }
       }
 
       TheSurface = new Geom_BSplineSurface(NewPoles, NewWeights, 
-                                          UKnots, VKnots, 
-                                          UMults, VMults,
-                                          2 , C->Degree(),
-                                          periodic, C->IsPeriodic());
+        UKnots, VKnots, 
+        UMults, VMults,
+        2 , C->Degree(),
+        periodic, C->IsPeriodic());
     }
-    
-    
+
+
     else if (S->IsKind(STANDARD_TYPE(Geom_BezierSurface))) {
-      
+
       Handle(Geom_BezierSurface) SBez = 
-       Handle(Geom_BezierSurface)::DownCast(S);
-      
+        Handle(Geom_BezierSurface)::DownCast(S);
+
       Standard_Integer NbUPoles = SBez->NbUPoles();
       Standard_Integer NbVPoles = SBez->NbVPoles();
       Standard_Integer UDegree  = SBez->UDegree();
@@ -844,16 +844,16 @@ Handle(BSplineSurface) GeomConvert::SplitBSplineSurface
       VMults (2) = VDegree + 1;
       SBez->Poles (Poles);
       if (SBez->IsURational() || SBez->IsVRational()) {    
-       TColStd_Array2OfReal    Weights (1, NbUPoles, 1, NbVPoles);
-       SBez->Weights (Weights);
-       TheSurface = new Geom_BSplineSurface (Poles, Weights, UKnots, VKnots,
-                                             UMults, VMults,
-                                             UDegree, VDegree);
+        TColStd_Array2OfReal    Weights (1, NbUPoles, 1, NbVPoles);
+        SBez->Weights (Weights);
+        TheSurface = new Geom_BSplineSurface (Poles, Weights, UKnots, VKnots,
+          UMults, VMults,
+          UDegree, VDegree);
       }
       else {
-       TheSurface = new Geom_BSplineSurface (Poles, UKnots, VKnots, 
-                                             UMults, VMults,
-                                             UDegree, VDegree);
+        TheSurface = new Geom_BSplineSurface (Poles, UKnots, VKnots, 
+          UMults, VMults,
+          UDegree, VDegree);
       }
     }
 
@@ -863,16 +863,31 @@ Handle(BSplineSurface) GeomConvert::SplitBSplineSurface
 
     else { // In other cases => Approx
       Standard_Real Tol3d=1.e-4;
-      Standard_Integer MaxDegree =14, MaxSeg;
-      GeomAbs_Shape cont;
+      Standard_Integer MaxDegree = 14, MaxSeg;
+      GeomAbs_Shape ucont = GeomAbs_C0, vcont = GeomAbs_C0;
       GeomAdaptor_Surface AS(Sr);
-      if (AS.NbUIntervals(GeomAbs_C2) > 1 || AS.NbVIntervals(GeomAbs_C2) > 1 ) 
-         cont=GeomAbs_C1;
-      else
-         cont=GeomAbs_C2;
+      //
+      if (Sr->IsCNu(2)) 
+      {
+        ucont=GeomAbs_C2;
+      }
+      else if(Sr->IsCNu(1)) 
+      {
+        ucont=GeomAbs_C1;
+      }
+      //
+      if (Sr->IsCNv(2)) 
+      {
+        vcont=GeomAbs_C2;
+      }
+      else if(Sr->IsCNv(1)) 
+      {
+        vcont=GeomAbs_C1;
+      }
+      //
       MaxSeg = 4*(AS.NbUIntervals(GeomAbs_CN)+1)*(AS.NbVIntervals(GeomAbs_CN)+1);      
-      GeomConvert_ApproxSurface BSpS(Sr,Tol3d,cont,cont,
-                                    MaxDegree,MaxDegree,MaxSeg,1);
+      GeomConvert_ApproxSurface BSpS(Sr, Tol3d, ucont, vcont,
+                                     MaxDegree, MaxDegree, MaxSeg, 1);
       TheSurface = BSpS.Surface();
     }
   } // Fin du cas direct
diff --git a/tests/bugs/modalg_5/bug25976 b/tests/bugs/modalg_5/bug25976
new file mode 100644 (file)
index 0000000..baf03c4
--- /dev/null
@@ -0,0 +1,13 @@
+puts "========"
+puts "OCC25976"
+puts "========"
+puts ""
+##########################################################################################
+# Conversion of an offset face from a spline into a spline face hangs-up the application
+##########################################################################################
+
+smallview
+restore [locate_data_file OCC25976-copiedFace.brep] f
+nurbsconvert r f
+fit
+set only_screen_axo 1