0028661: BRepOffsetAPI_MakePipeShell throws an exception Standard_NoSuchObject: NColl...
[occt.git] / src / GeomFill / GeomFill_Sweep.cxx
index 3589a23..d37105d 100644 (file)
 
 //  Modified by skv - Fri Feb  6 11:44:48 2004 OCC5073
 
-#include <GeomFill_Sweep.ixx>
-#include <GeomFill_SweepFunction.hxx>
+#include <AdvApprox_ApproxAFunction.hxx>
+#include <AdvApprox_PrefAndRec.hxx>
+#include <Approx_SweepApproximation.hxx>
+#include <ElCLib.hxx>
+#include <ElSLib.hxx>
+#include <Geom2d_BSplineCurve.hxx>
+#include <Geom2d_Curve.hxx>
+#include <Geom2d_Line.hxx>
+#include <Geom2d_TrimmedCurve.hxx>
+#include <Geom_BSplineSurface.hxx>
+#include <Geom_Circle.hxx>
+#include <Geom_ConicalSurface.hxx>
+#include <Geom_CylindricalSurface.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_RectangularTrimmedSurface.hxx>
+#include <Geom_SphericalSurface.hxx>
+#include <Geom_Surface.hxx>
+#include <Geom_SurfaceOfLinearExtrusion.hxx>
+#include <Geom_SurfaceOfRevolution.hxx>
+#include <Geom_ToroidalSurface.hxx>
+#include <Geom_TrimmedCurve.hxx>
+#include <GeomAbs_CurveType.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <GeomConvert_ApproxSurface.hxx>
+#include <GeomFill_LocationLaw.hxx>
 #include <GeomFill_LocFunction.hxx>
-
-#include <Standard_ErrorHandler.hxx>
-
-#include <gp_Pnt2d.hxx>
-#include <gp_Dir2d.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Dir.hxx>
-#include <gp_Lin.hxx>
+#include <GeomFill_SectionLaw.hxx>
+#include <GeomFill_Sweep.hxx>
+#include <GeomFill_SweepFunction.hxx>
+#include <GeomLib.hxx>
+#include <gp_Ax2.hxx>
 #include <gp_Circ.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Dir2d.hxx>
 #include <gp_GTrsf.hxx>
+#include <gp_Lin.hxx>
 #include <gp_Mat.hxx>
-#include <gp_Ax2.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Pnt2d.hxx>
 #include <gp_Sphere.hxx>
-
+#include <Precision.hxx>
+#include <Standard_ConstructionError.hxx>
+#include <Standard_ErrorHandler.hxx>
+#include <Standard_OutOfRange.hxx>
+#include <StdFail_NotDone.hxx>
 #include <TColgp_Array1OfPnt.hxx>
 #include <TColgp_Array2OfPnt.hxx>
 #include <TColgp_HArray2OfPnt.hxx>
-//#include <GeomLib_Array1OfMat.hxx>
 #include <TColStd_Array1OfInteger.hxx>
 #include <TColStd_Array1OfReal.hxx>
 #include <TColStd_Array2OfReal.hxx>
 
-#include <GeomAbs_CurveType.hxx>
-#include <GeomAdaptor_Curve.hxx>
-#include <GeomLib.hxx>
-
-#include <Geom2d_Line.hxx>
-#include <Geom2d_BSplineCurve.hxx>
-#include <Geom2d_TrimmedCurve.hxx>
-
-#include <Geom_Circle.hxx>
-#include <Geom_Line.hxx>
-#include <Geom_BSplineSurface.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_SurfaceOfLinearExtrusion.hxx>
-#include <Geom_CylindricalSurface.hxx>
-#include <Geom_ConicalSurface.hxx>
-#include <Geom_ToroidalSurface.hxx>
-#include <Geom_SphericalSurface.hxx>
-#include <Geom_SurfaceOfRevolution.hxx>
-#include <Geom_RectangularTrimmedSurface.hxx>
-#include <Geom_TrimmedCurve.hxx>
-
-#include <Approx_SweepApproximation.hxx>
-#include <AdvApprox_PrefAndRec.hxx>
-#include <AdvApprox_ApproxAFunction.hxx>
-#include <GeomConvert_ApproxSurface.hxx>
-
-#include <Precision.hxx>
-#include <ElCLib.hxx>
-#include <ElSLib.hxx>
-
+//#include <GeomLib_Array1OfMat.hxx>
 //=======================================================================
 //class : GeomFill_Sweep_Eval
 //purpose: The evaluator for curve approximation
 //=======================================================================
-
 class GeomFill_Sweep_Eval : public AdvApprox_EvaluatorFunction
 {
  public:
@@ -325,8 +323,7 @@ GeomFill_Sweep::GeomFill_Sweep(const Handle(GeomFill_LocationLaw)& Location,
         myCurve2d = new  (TColGeom2d_HArray1OfCurve) (1, 2);
         CError =  new (TColStd_HArray2OfReal) (1,2, 1,2);
 
-        const Handle(Geom_BSplineSurface)& BSplSurf =
-          Handle(Geom_BSplineSurface)::DownCast(mySurface);
+        Handle(Geom_BSplineSurface) BSplSurf (Handle(Geom_BSplineSurface)::DownCast(mySurface));
         
         gp_Dir2d D(0., 1.);
         gp_Pnt2d P(BSplSurf->UKnot(1), 0);
@@ -648,6 +645,8 @@ static Standard_Boolean IsSweepParallelSpine (const Handle(GeomFill_LocationLaw)
     
   // (1.1.b) Cas Cylindrique
       if ( (SectionType == GeomAbs_Circle) && IsTrsf) {
+        const Standard_Real TolProd = 1.e-6;
+        
        gp_Circ C = AC.Circle();
        C.Transform(Tf2);
        
@@ -655,7 +654,7 @@ static Standard_Boolean IsSweepParallelSpine (const Handle(GeomFill_LocationLaw)
        DS.Normalize();
         levier = Abs(DS.CrossMagnitude(DP)) * C.Radius();
         SError = levier * Abs(Last - First);
-       if (SError <= Tol) {
+       if (SError <= TolProd) {
          Ok = Standard_True;
           gp_Ax3 axe (C.Location(), DP, C.Position().XDirection());
          S = new (Geom_CylindricalSurface) 
@@ -836,14 +835,15 @@ static Standard_Boolean IsSweepParallelSpine (const Handle(GeomFill_LocationLaw)
         error *= C.Radius();
        if (error <= Tol) {
          SError = error;
-         error += Radius + Abs(RotRadius - C.Radius())/2;
-         if (error <= Tol) {
+         error += Radius;
+          if (Radius <= Tol) {
            // (2.1.a) Sphere
-           Standard_Real f = UFirst , l =  ULast;
+           Standard_Real f = UFirst , l =  ULast, aRadius = 0.0;
            SError = error;
            Centre.BaryCenter(1.0, C.Location(), 1.0); 
            gp_Ax3 AxisOfSphere(Centre, DN, DS);
-            gp_Sphere theSphere( AxisOfSphere, (RotRadius + C.Radius())/2 );
+            aRadius = C.Radius();
+            gp_Sphere theSphere( AxisOfSphere, aRadius );
            S = new Geom_SphericalSurface(theSphere);
            // Pour les spheres on ne peut pas controler le parametre
             // V (donc U car  myExchUV = Standard_True)
@@ -1094,7 +1094,7 @@ static Standard_Boolean IsSweepParallelSpine (const Handle(GeomFill_LocationLaw)
 {
   Standard_Integer ind = IndexOfTrace+1;
   if (IndexOfTrace > myLoc->TraceNumber())
-    Standard_OutOfRange::Raise(" GeomFill_Sweep::ErrorOnTrace");
+    throw Standard_OutOfRange(" GeomFill_Sweep::ErrorOnTrace");
 
   UError =  CError->Value(1, ind);
   VError =  CError->Value(2, ind);
@@ -1139,6 +1139,6 @@ static Standard_Boolean IsSweepParallelSpine (const Handle(GeomFill_LocationLaw)
 {
   Standard_Integer ind = IndexOfTrace+1;
   if (IndexOfTrace > myLoc->TraceNumber())
-    Standard_OutOfRange::Raise(" GeomFill_Sweep::Trace");
+    throw Standard_OutOfRange(" GeomFill_Sweep::Trace");
   return  myCurve2d->Value(ind);  
 }