]> OCCT Git - occt-copy.git/commitdiff
0026329: Restore floating point signals handling in DRAW
authorifv <ifv@opencascade.com>
Tue, 9 Aug 2016 17:12:59 +0000 (20:12 +0300)
committerabv <abv@opencascade.com>
Tue, 9 Aug 2016 17:13:28 +0000 (20:13 +0300)
Handling of FPE signals has been restored for MSVC and GCC compilers.

The test bug6143 (that checks signals handling) has been corrected accordingly.

A number of changes in the code have been done in order to fix floating point exceptions that became generated after enabling signals:

- Global functions Sinh() and Cosh() defined in Standard_Real.hxx are improved to raise Standard_NumericError exception if argument is too big (greater than 710.47586), instead of relying on system treatment of floating point overflow. These functions are used instead of sinh and cosh in ElCLib.cxx.

- Maximal value of parameter on hyperbola is restricted by 23 in order to avoid FP overflow in Extrema_GenExtCS.cxx, ShapeFix_EdgeProjAux.cxx.

- Interface of the root curve adaptor class Adaptor3d_Curve has been updated to add new virtual methods BasisCurve and OffsetValue. They complement the adaptor for the case of offset curves. They allow setting the correct limitation of domain search in the case of offset of hyperbola, in order to get rid of floating point overflow (see Extrema_GenExtCS.cxx). All classes inheriting Adaptor3d_Curve have been changed to implement the new virtual methods.

- Protection against division by zero has been implemented in ApproxInt_KnotTools.cxx, BRepClass3d_SClassifier.cxx, BRepGProp_Face.cxx, BRepMesh_FastDiscretFace.cxx, Geom2dGcc_Circ2d2TanOnIter.cxx, Geom2dInt_Geom2dCurveTool.cxx, Graphic3d_Camera.cxx, IntPolyh_MaillageAffinage.cxx.

- Protection against calling of math functions of infinite arguments has been added in BRepCheck_Edge.cxx, BRepLib.cxx, CSLib_NormalPolyDef.cxx, Extrema_FuncExtPC.gxx, Extrema_GExtPC.gxx, Extrema_GLocateExtPC.gxx, Intf_InterferencePolygonPolyhedron.gxx, ShapeAnalysis_Surface.cxx, ShapeAnalysis_TransferParametersProj.cxx, ShapeAnalysis_Wire.cxx, math_FunctionSetRoot.cxx.

- Proper initialization of local variables is done in BOPAlgo_PaveFiller_6.cxx, XSDRAWSTLVRML.cxx.

Some test cases have been updated to actual state.

45 files changed:
src/Adaptor3d/Adaptor3d_Curve.cxx
src/Adaptor3d/Adaptor3d_Curve.hxx
src/Adaptor3d/Adaptor3d_HCurve.hxx
src/Adaptor3d/Adaptor3d_HCurve.lxx
src/ApproxInt/ApproxInt_KnotTools.cxx
src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx
src/BRepAdaptor/BRepAdaptor_Curve.cxx
src/BRepAdaptor/BRepAdaptor_Curve.hxx
src/BRepCheck/BRepCheck_Edge.cxx
src/BRepClass3d/BRepClass3d_SClassifier.cxx
src/BRepGProp/BRepGProp_Face.cxx
src/BRepLib/BRepLib.cxx
src/BRepMesh/BRepMesh_FastDiscretFace.cxx
src/BRepOffset/BRepOffset_MakeOffset.cxx
src/BRepOffset/BRepOffset_Tool.cxx
src/CSLib/CSLib_NormalPolyDef.cxx
src/Draw/Draw.cxx
src/Draw/Draw_Window.cxx
src/ElCLib/ElCLib.cxx
src/Extrema/Extrema_FuncExtPC.gxx
src/Extrema/Extrema_GExtPC.gxx
src/Extrema/Extrema_GLocateExtPC.gxx
src/Extrema/Extrema_GenExtCS.cxx
src/Geom2dGcc/Geom2dGcc_Circ2d2TanOnIter.cxx
src/Geom2dInt/Geom2dInt_Geom2dCurveTool.cxx
src/GeomAdaptor/GeomAdaptor_Curve.cxx
src/GeomAdaptor/GeomAdaptor_Curve.hxx
src/IntPolyh/IntPolyh_MaillageAffinage.cxx
src/Intf/Intf_InterferencePolygonPolyhedron.gxx
src/ProjLib/ProjLib_ComputeApproxOnPolarSurface.cxx
src/QABugs/QABugs_11.cxx
src/ShapeAnalysis/ShapeAnalysis_Surface.cxx
src/ShapeAnalysis/ShapeAnalysis_TransferParametersProj.cxx
src/ShapeAnalysis/ShapeAnalysis_Wire.cxx
src/ShapeConstruct/ShapeConstruct_ProjectCurveOnSurface.cxx
src/ShapeFix/ShapeFix_EdgeProjAux.cxx
src/Standard/Standard_Real.cxx
src/Standard/Standard_Real.hxx
src/XSDRAWSTLVRML/XSDRAWSTLVRML.cxx
src/math/math_FunctionSetRoot.cxx
tests/bugs/fclasses/bug6143
tests/bugs/moddata_1/bug22759
tests/offset/with_intersect_80/J9
tests/offset/with_intersect_80/K8
tests/v3d/mesh/B7

index 487dd59a0d25591a9a00d8d8141cf418c51e35f2..afb5789e4d27e30c798cda7b99c2bedf32acc725 100644 (file)
@@ -376,3 +376,26 @@ Handle(Geom_BSplineCurve) Adaptor3d_Curve::BSpline() const
   Standard_NotImplemented::Raise("Adaptor3d_Curve::BSpline");
   return Handle(Geom_BSplineCurve)();
 }
+
+//=======================================================================
+//function : BasisCurve
+//purpose  : 
+//=======================================================================
+
+Handle(Adaptor3d_HCurve) Adaptor3d_Curve::BasisCurve() const 
+{
+  Standard_NotImplemented::Raise("Adaptor3d_Curve::BasisCurve");
+  return Handle(Adaptor3d_HCurve)();
+}
+
+
+//=======================================================================
+//function : OffsetValue
+//purpose  : 
+//=======================================================================
+
+Standard_Real Adaptor3d_Curve::OffsetValue() const 
+{
+  Standard_NotImplemented::Raise("Adaptor3d_Curve::OffsetValue");
+  return 0.;
+}
index 647cf03d71ba376387e5ed7959363a54cf11de86..c8bf429748d4ab3ef43c233add9303eba72e956e 100644 (file)
@@ -155,6 +155,11 @@ public:
   Standard_EXPORT virtual Handle(Geom_BezierCurve) Bezier() const;
   
   Standard_EXPORT virtual Handle(Geom_BSplineCurve) BSpline() const;
+
+  Standard_EXPORT virtual Handle(Adaptor3d_HCurve) BasisCurve() const;
+  
+  Standard_EXPORT virtual Standard_Real OffsetValue() const;
+
   Standard_EXPORT virtual ~Adaptor3d_Curve();
 
 
index 2ca8d2522d6a1ad8d7fe8e898a40af8f993a47e4..75a4cd9c9de1ba22d75a7a607975c9514840ddbc 100644 (file)
@@ -134,6 +134,9 @@ public:
   
     Handle(Geom_BSplineCurve) BSpline() const;
 
+    Handle(Adaptor3d_HCurve) BasisCurve() const;
+  
+    Standard_Real OffsetValue() const;
 
 
 
index 8a81896fd01e545d4e5c4901d8fbd49f363c0f87..94eb2f2e26fb3067b26b3cfd63f224d9a74c2392 100644 (file)
@@ -293,3 +293,23 @@ inline Standard_Integer  Adaptor3d_HCurve::NbKnots() const
   return Curve().BSpline();
 }
 
+//=======================================================================
+//function : BasisCurve
+//purpose  : 
+//=======================================================================
+
+ inline Handle(Adaptor3d_HCurve) Adaptor3d_HCurve::BasisCurve() const 
+{
+  return Curve().BasisCurve();
+}
+
+
+//=======================================================================
+//function : OffsetValue
+//purpose  : 
+//=======================================================================
+
+ inline Standard_Real Adaptor3d_HCurve::OffsetValue() const 
+{
+  return Curve().OffsetValue();
+}
index 0fa204370440d7eb1c40298e3a2a85426b15fc7c..980a58fb2d3a05d6714da1b565c06fbfde6d2af7 100644 (file)
@@ -439,6 +439,7 @@ Standard_Boolean ApproxInt_KnotTools::InsKnotBefI(const Standard_Integer theI,
                                                   NCollection_Sequence<Standard_Integer>& theInds,
                                                   const Standard_Boolean ChkCurv)
 {
+  const Standard_Real eps = Epsilon(1.);
   Standard_Integer anInd1 = theInds(theI);
   Standard_Integer anInd = theInds(theI - 1);
   //
@@ -519,7 +520,15 @@ Standard_Boolean ApproxInt_KnotTools::InsKnotBefI(const Standard_Integer theI,
         }
         //mp *= 2.; //P(j,i) = -P(i,j);
         //
-        sina = mp/(m1*m2);
+        Standard_Real m1m2 = m1*m2;
+        if(m1m2 > eps)
+        {
+          sina = mp/m1m2;
+        }
+        else
+        {
+          sina = 0.;
+        }
         sina = Sqrt(sina);
 
         if(sina > aSinCoeff)
index c3b5b1a201a4db8e467598f17487e59753ddf2a7..36971a06f661adc50961c0fe403c137f48b20e99 100644 (file)
@@ -1258,7 +1258,7 @@ Standard_Boolean BOPAlgo_PaveFiller::IsExistingPaveBlock
     iFlag2 = (nV12 == nV21 || nV12 == nV22) ? 2 : 
       (!aBoxSp.IsOut(aBoxP2) ? 1 : 0);
     if (iFlag1 && iFlag2) {
-      Standard_Real aDist;
+      Standard_Real aDist = 0.;
 
       const Standard_Real aRealTol = myDS->IsCommonBlock(aPB) ?
                                      Max(aTolV1, aTolV2) : theTolR3D;
@@ -1275,14 +1275,20 @@ Standard_Boolean BOPAlgo_PaveFiller::IsExistingPaveBlock
       //
       if (iFlag1 == 1) {
         iFlag1 = !myContext->ComputePE(aP1, aRealTol, aSp, aTx, aDist);
-        if (theTolNew < aDist)
-          theTolNew = aDist;
+        if(iFlag1)
+        {
+          if (theTolNew < aDist)
+            theTolNew = aDist;
+        }
       }
       //
       if (iFlag2 == 1) {
         iFlag2 = !myContext->ComputePE(aP2, aRealTol, aSp, aTx, aDist);
-        if (theTolNew < aDist)
-          theTolNew = aDist;
+        if(iFlag2)
+        {
+          if (theTolNew < aDist)
+            theTolNew = aDist;
+        }
       }
       //
       if (iFlag1 && iFlag2) {
index ca986abac388e4e716d4ca6acfed9d6785f7adde..c53ed062d1fc3167ad7670027d485c9ad23c2a32 100644 (file)
@@ -42,6 +42,8 @@
 #include <Standard_OutOfRange.hxx>
 #include <TopoDS_Edge.hxx>
 #include <TopoDS_Face.hxx>
+#include <Geom_OffsetCurve.hxx>
+#include <GeomAdaptor_HCurve.hxx>
 
 //=======================================================================
 //function : BRepAdaptor_Curve
@@ -649,3 +651,36 @@ Handle(Geom_BSplineCurve) BRepAdaptor_Curve::BSpline() const
   return myTrsf.Form() == gp_Identity
     ? BS : Handle(Geom_BSplineCurve)::DownCast(BS->Transformed(myTrsf));
 }
+
+//=======================================================================
+//function : BasisCurve
+//purpose  : 
+//=======================================================================
+
+Handle(Adaptor3d_HCurve) BRepAdaptor_Curve::BasisCurve() const 
+{
+  if ( !Is3DCurve() || myCurve.GetType() != GeomAbs_OffsetCurve)
+    Standard_NoSuchObject::Raise("BRepAdaptor_Curve::BasisCurve");
+
+  const Handle(Geom_Curve)& aGC = myCurve.Curve();
+  Handle(Geom_OffsetCurve) anOffC = Handle(Geom_OffsetCurve)::DownCast(aGC);
+  Handle(Geom_Curve) aBC = anOffC->BasisCurve();
+  aBC = Handle(Geom_Curve)::DownCast(aBC->Transformed(myTrsf));
+  Handle(GeomAdaptor_HCurve) aGABC = new GeomAdaptor_HCurve(aBC);
+  return aGABC;
+}
+
+//=======================================================================
+//function : OffsetValue
+//purpose  : 
+//=======================================================================
+
+Standard_Real BRepAdaptor_Curve::OffsetValue() const 
+{
+  if ( !Is3DCurve() || myCurve.GetType() != GeomAbs_OffsetCurve)
+    Standard_NoSuchObject::Raise("BRepAdaptor_Curve::OffsetValue");
+  return myCurve.OffsetValue();
+} 
index 7440175f84cfee5e13247cc71e7bde141ba1eb46..7ffe3b3b925692038b5ae4746bab8910c27d35ef 100644 (file)
@@ -220,6 +220,9 @@ public:
   //! using this method
   Standard_EXPORT Handle(Geom_BSplineCurve) BSpline() const Standard_OVERRIDE;
 
+  Standard_EXPORT Handle(Adaptor3d_HCurve) BasisCurve() const Standard_OVERRIDE;
+  
+  Standard_EXPORT Standard_Real OffsetValue() const Standard_OVERRIDE;
 
 
 
index 0c192748a75af267e488d5636fdc3dbb89eb34fe..e0261a065f24011468b734c5bd029e0bb6c8581e 100644 (file)
@@ -555,8 +555,18 @@ Standard_Real BRepCheck_Edge::Tolerance()
     prm = ((NCONTROL-1-i)*First + i*Last)/(NCONTROL-1);
     tol2=dist2=0.;
     center=(*(Handle(Adaptor3d_HCurve)*)&theRep(1))->Value(prm);
+    if(Precision::IsInfinite(center.X()) || Precision::IsInfinite(center.Y()) 
+       || Precision::IsInfinite(center.Z()))
+    {
+      return Precision::Infinite();
+    }
     for (iRep=2; iRep<=nbRep; iRep++) {
       othP=(*(Handle(Adaptor3d_HCurve)*)&theRep(iRep))->Value(prm);
+      if(Precision::IsInfinite(othP.X()) || Precision::IsInfinite(othP.Y()) 
+        || Precision::IsInfinite(othP.Z()))
+      {
+        return Precision::Infinite();
+      }
       dist2=center.SquareDistance(othP);
       if (dist2>tolCal) tolCal=dist2;
     }
index 6a6891958707ef4a6e033cebaf533e8fdf7e1247..16e0bf8495135ec639a25c7c7e40ed82c14d356c 100644 (file)
@@ -579,7 +579,7 @@ static Standard_Integer GetTransi(const TopoDS_Face& f1,
     return -1;
   }
 
-  if (nf1.IsEqual(nf2, Precision::Angular()))
+  if (nf1.IsParallel(nf2, Precision::Angular()))
   {
     Standard_Real angD = nf1.Dot(LDir);
     if (Abs(angD) < Precision::Angular())
index 0ce1303e6a0e7a263f03d4350eee2992e2c8c95c..235c3165713cbe26014fb91ba346628aa0bbfb21 100644 (file)
@@ -382,6 +382,7 @@ void BRepGProp_Face::VKnots(TColStd_Array1OfReal& Knots) const
 Standard_Integer BRepGProp_Face::LIntOrder(const Standard_Real Eps) const
 {
   Bnd_Box2d aBox;
+  const Standard_Real eps = Epsilon(1.);
 
   BndLib_Add2dCurve::Add(myCurve, 1.e-7, aBox);
   Standard_Real aXmin, aXmax, aYmin, aYmax;
@@ -389,7 +390,13 @@ Standard_Integer BRepGProp_Face::LIntOrder(const Standard_Real Eps) const
   Standard_Real aVmin = mySurface.FirstVParameter();
   Standard_Real aVmax = mySurface.LastVParameter();
 
-  Standard_Real anR = Min((aYmax-aYmin)/(aVmax-aVmin), 1.);
+  Standard_Real dv = (aVmax-aVmin);
+  Standard_Real anR = 1.;
+  if(dv > eps)
+  {
+    anR = (aYmax-aYmin) / dv;
+    anR = Min(anR, 1.);
+  }
 
 //  Standard_Integer anRInt = Max(RealToInt(Ceiling(SVIntSubs()*anR)), 2);
   Standard_Integer anRInt = RealToInt(Ceiling(SVIntSubs()*anR));
index aced41ccb7c539837248e8bc0dd603abfb5971d0..3d42110453f2b389b247997b25ffce18cd12cf0a 100644 (file)
@@ -905,19 +905,53 @@ static Standard_Real ComputeTol(const Handle(Adaptor3d_HCurve)& c3d,
   TColStd_Array1OfReal dist(1,nbp+10);
   dist.Init(-1.);
 
-  Adaptor3d_CurveOnSurface  cons(c2d,surf);
+  //Adaptor3d_CurveOnSurface  cons(c2d,surf);
+  Standard_Real uf = surf->FirstUParameter(), ul = surf->LastUParameter(),
+                vf = surf->FirstVParameter(), vl = surf->LastVParameter();
+  Standard_Real du = 0.01 * (ul - uf), dv = 0.01 * (vl - vf);
+  Standard_Boolean isUPeriodic = surf->IsUPeriodic(), isVPeriodic = surf->IsVPeriodic();
+  Standard_Real DSdu = 1./surf->UResolution(1.), DSdv = 1./surf->VResolution(1.);
   Standard_Real d2 = 0.;
   Standard_Real first = c3d->FirstParameter();
   Standard_Real last  = c3d->LastParameter();
+  Standard_Real dapp = -1.;
   Standard_Integer i = 0;
   for(i = 0; i <= nbp; i++){
     const Standard_Real t = IntToReal(i)/IntToReal(nbp);
     const Standard_Real u = first*(1.-t) + last*t;
     gp_Pnt Pc3d = c3d->Value(u);
-    gp_Pnt Pcons = cons.Value(u);
+    gp_Pnt2d Puv = c2d->Value(u);
+    if(!isUPeriodic)
+    {
+      if(Puv.X() < uf - du)
+      {
+        dapp = Max(dapp, DSdu * (uf - Puv.X()));
+        continue;
+      }
+      else if(Puv.X() > ul + du)
+      {
+        dapp = Max(dapp, DSdu * (Puv.X() - ul));
+        continue;
+      }
+    }
+    if(!isVPeriodic)
+    {
+      if(Puv.Y() < vf - dv)
+      {
+        dapp = Max(dapp, DSdv * (vf - Puv.Y()));
+        continue;
+      }
+      else if(Puv.Y() > vl + dv)
+      {
+        dapp = Max(dapp, DSdv * (Puv.Y() - vl));
+        continue;
+      }
+    }
+    gp_Pnt Pcons = surf->Value(Puv.X(), Puv.Y());
     if (Precision::IsInfinite(Pcons.X()) ||
-      Precision::IsInfinite(Pcons.Y()) ||
-      Precision::IsInfinite(Pcons.Z())) {
+        Precision::IsInfinite(Pcons.Y()) ||
+        Precision::IsInfinite(Pcons.Z()))
+    {
         d2=Precision::Infinite();
         break;
     }
@@ -930,6 +964,16 @@ static Standard_Real ComputeTol(const Handle(Adaptor3d_HCurve)& c3d,
     if(temp > d2) d2 = temp;
   }
 
+  if(Precision::IsInfinite(d2))
+  {
+    return d2;
+  }
+
+  d2 = Sqrt(d2);
+  if(dapp > d2)
+  {
+    return dapp;
+  }
 
   Standard_Boolean ana = Standard_False;
   Standard_Real D2 = 0;
@@ -952,7 +996,7 @@ static Standard_Real ComputeTol(const Handle(Adaptor3d_HCurve)& c3d,
     }
 
     //d2 = 1.5*sqrt(d2);
-    d2 = (!ana) ? 1.5*sqrt(d2) : 1.5*sqrt(D2);
+    d2 = (!ana) ? 1.5 * d2 : 1.5*sqrt(D2);
     if(d2<1.e-7) d2 = 1.e-7;
 
     return d2;
@@ -1032,6 +1076,7 @@ void BRepLib::SameParameter(const TopoDS_Edge&  AnEdge,
   //  Modified by skv - Thu Jun  3 12:39:20 2004 OCC5898 End
   Standard_Boolean SameRange = BRep_Tool::SameRange(AnEdge);
   Standard_Boolean YaPCu = Standard_False;
+  const Standard_Real BigError = 1.e10;
   It.Initialize(CList);
 
   while (It.More()) {
@@ -1075,6 +1120,12 @@ void BRepLib::SameParameter(const TopoDS_Edge&  AnEdge,
 
         Standard_Real error = ComputeTol(HC, HC2d, HS, NCONTROL);
 
+        if(error > BigError)
+        {
+          maxdist = error;
+          break;
+        }
+
         if(GAC2d.GetType() == GeomAbs_BSplineCurve && 
           GAC2d.Continuity() == GeomAbs_C0) {
             Handle(Geom2d_BSplineCurve) bs2d = GAC2d.BSpline();
@@ -1416,6 +1467,7 @@ void  BRepLib::UpdateTolerances(const TopoDS_Shape& aShape,
   }
 
   //Vertices are processed
+  const Standard_Real BigTol = 1.e10;
   parents.Clear();
   TopExp::MapShapesAndAncestors(aShape, TopAbs_VERTEX, TopAbs_EDGE, parents);
   TColStd_MapOfTransient Initialized;
@@ -1432,6 +1484,7 @@ void  BRepLib::UpdateTolerances(const TopoDS_Shape& aShape,
       const TopoDS_Edge& E = TopoDS::Edge(lConx.Value());
       if(!Done.Add(E)) continue;
       tol=Max(tol, BRep_Tool::Tolerance(E));
+      if(tol > BigTol) continue;
       if(!BRep_Tool::SameRange(E)) continue;
       Standard_Real par = BRep_Tool::Parameter(V,E);
       Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&E.TShape());
index 2abfe722c780763fce467aea35ab266b225852f3..d017d37202a438aaca69c691c6438a694e24a5ba 100644 (file)
@@ -984,6 +984,7 @@ void BRepMesh_FastDiscretFace::insertInternalVerticesOther(
       gp_Pnt aPrevPnt2;
       gp_Vec aPrevVec2;
       aIso.D1 (aPrevParam2, aPrevPnt2, aPrevVec2);
+      Standard_Real aMod2PrevVec2 = aPrevVec2.SquareMagnitude();
       for (Standard_Integer j = 2; j <= aParams2.Length();)
       {
         Standard_Real aParam2 = aParams2(j);
@@ -1010,7 +1011,7 @@ void BRepMesh_FastDiscretFace::insertInternalVerticesOther(
           if (aDist < aDefFace)
           {
             // Lets check parameters for angular deflection.
-            if (aPrevVec2.Angle(aNextVec) < myAngle)
+            if (aMod2PrevVec2 > gp::Resolution() && (aPrevVec2.Angle(aNextVec) < myAngle))
             {
               // For current Iso line we can remove this parameter.
 #ifdef DEBUG_InsertInternal
@@ -1025,6 +1026,7 @@ void BRepMesh_FastDiscretFace::insertInternalVerticesOther(
               aPrevParam2 = aNextParam;
               aPrevPnt2 = aNextPnt;
               aPrevVec2 = aNextVec;
+              aMod2PrevVec2 = aPrevVec2.SquareMagnitude();
               j += 2;
               continue;
             }
@@ -1047,6 +1049,7 @@ void BRepMesh_FastDiscretFace::insertInternalVerticesOther(
         aPrevParam2 = aParam2;
         aPrevPnt2 = aPnt2;
         aPrevVec2 = aVec2;
+        aMod2PrevVec2 = aPrevVec2.SquareMagnitude();
         ++j;
       }
     }
index 8fa0fd15cc6c9633e5522666b9f0136827587cab..ae5a5a0192232b98339d682192c57ba206c8860f 100644 (file)
@@ -1052,9 +1052,14 @@ void TrimEdge(TopoDS_Edge&                  NE,
         Handle(Geom_Curve) theCurve = BRep_Tool::Curve(NE, f, l);
         gp_Pnt thePoint = BRep_Tool::Pnt(V);
         GeomAPI_ProjectPointOnCurve Projector(thePoint, theCurve);
-        if (Projector.NbPoints() == 0)
-          Standard_ConstructionError::Raise("BRepOffset_MakeOffset::TrimEdge no projection");
-        U = Projector.LowerDistanceParameter();
+        if (Projector.NbPoints() > 0)
+        {
+          U = Projector.LowerDistanceParameter();
+        }
+        else
+        {
+          U = .5*(f + l);
+        }
       }
       if (U < UMin) {
         UMin = U; V1   = V;
index 356ae06a0203814e81d52b7f2596ce86bbdeee86..0874a2310c7f7de9a0b57b6010e115559e841263 100644 (file)
@@ -1039,7 +1039,10 @@ static void ReconstructPCurves(const TopoDS_Edge& anEdge)
            (theSurf->Transformed(theLoc.Transformation()));
          Handle(Geom2d_Curve) ProjPCurve =
            GeomProjLib::Curve2d( C3d, f, l, theSurf );
-         CurveRep->PCurve( ProjPCurve );
+          if(!ProjPCurve.IsNull())
+          {
+           CurveRep->PCurve( ProjPCurve );
+          }
        }
     }
 }
index 909c5eea7837239e5fcd87f3d3319e998ad9df0c..5104fbca9cdb04b114f126a0746644fb84f5a6da 100644 (file)
@@ -39,6 +39,11 @@ Standard_Boolean CSLib_NormalPolyDef::Value(const Standard_Real X,
   co=cos(X);
   si=sin(X);
 
+  if(Abs(co) <= RealSmall() || Abs(si) <= RealSmall())
+  {
+    F = 0.;
+    return Standard_True;
+  }
   for(Standard_Integer i=0;i<=myK0;i++){
     F=F+PLib::Bin(myK0,i)*pow(co,i)*pow(si,(myK0-i))*myTABli(i);
   }
@@ -54,6 +59,11 @@ Standard_Boolean CSLib_NormalPolyDef::Derivative(const Standard_Real X,
   Standard_Real co,si;
   co=cos(X);
   si=sin(X);
+  if(Abs(co) <= RealSmall() || Abs(si) <= RealSmall())
+  {
+    D = 0.;
+    return Standard_True;
+  }
   for(Standard_Integer i=0;i<=myK0;i++){
     D=D+PLib::Bin(myK0,i)*pow(co,(i-1))*pow(si,(myK0-i-1))*(myK0*co*co-i);
   }
@@ -71,6 +81,12 @@ Standard_Boolean CSLib_NormalPolyDef::Values(const Standard_Real X,
   Standard_Real co,si;
   co=cos(X);
   si=sin(X);
+  if(Abs(co) <= RealSmall() || Abs(si) <= RealSmall())
+  {
+    F = 0.;
+    D = 0.;
+    return Standard_True;
+  }
   for(Standard_Integer i=0;i<=myK0;i++){
     F=F+PLib::Bin(myK0,i)*pow(co,i)*pow(si,(myK0-i))*myTABli(i);
     D=D+PLib::Bin(myK0,i)*pow(co,(i-1))*
index 7394dc8f43dc1be6c2ad8471bf118b20fed1a242..c09b7971bdbd82151c12c623f644e18938906978 100644 (file)
@@ -243,7 +243,12 @@ void Draw_Appli(Standard_Integer argc, char** argv,const FDraw_InitAppli Draw_In
   // *****************************************************************
   // set signals
   // *****************************************************************
+#if defined(__INTEL_COMPILER) || defined(__clang__)
+  // FPE signals are disabled for Intel compiler (see #24589) and CLang (see #23802)
   OSD::SetSignal(Standard_False);
+#else 
+  OSD::SetSignal();
+#endif
 
 #ifdef _WIN32
   // in interactive mode, force Windows to report dll loading problems interactively
index 1948e0aca62c01ef9c4e41ed8dfe8ee2bc343540..1ebb52390668beb6e5ccee9979184a249785bb36 100644 (file)
@@ -2110,7 +2110,12 @@ static DWORD WINAPI tkLoop(VOID)
 #endif //#ifdef _TK
 
   // set signal handler in the new thread
+#if defined(__INTEL_COMPILER) || defined(__clang__)
+  // FPE signals are disabled for Intel compiler (see #24589) and CLang (see #23802)
   OSD::SetSignal(Standard_False);
+#else 
+  OSD::SetSignal();
+#endif
 
   // inform the others that we have started
   isTkLoopStarted = true;
index 170dd2d6d9a0daf271d4662e87326d865c25a0b2..6bfb2de05aa3864f2f01570fa7b7b2d7707e1357 100644 (file)
@@ -154,8 +154,8 @@ gp_Pnt ElCLib::HyperbolaValue (const Standard_Real U,
   const gp_XYZ& XDir = Pos.XDirection().XYZ();
   const gp_XYZ& YDir = Pos.YDirection().XYZ();
   const gp_XYZ& PLoc = Pos.Location  ().XYZ();
-  Standard_Real A1 = MajorRadius * cosh(U);
-  Standard_Real A2 = MinorRadius * sinh(U);
+  Standard_Real A1 = MajorRadius * Cosh(U);
+  Standard_Real A2 = MinorRadius * Sinh(U);
   return gp_Pnt(A1 * XDir.X() + A2 * YDir.X() + PLoc.X(),
                A1 * XDir.Y() + A2 * YDir.Y() + PLoc.Y(),
                A1 * XDir.Z() + A2 * YDir.Z() + PLoc.Z());
@@ -382,8 +382,8 @@ void ElCLib::HyperbolaD2 (const Standard_Real U,
                          gp_Vec& V1,
                          gp_Vec& V2)
 {
-  Standard_Real Xc = cosh(U);
-  Standard_Real Yc = sinh(U);
+  Standard_Real Xc = Cosh(U);
+  Standard_Real Yc = Sinh(U);
   gp_XYZ Coord0; 
   gp_XYZ Coord1 (Pos.XDirection().XYZ());
   gp_XYZ Coord2 (Pos.YDirection().XYZ());
@@ -514,8 +514,8 @@ void ElCLib::HyperbolaD3 (const Standard_Real U,
                          gp_Vec& V2,
                          gp_Vec& V3)
 {
-  Standard_Real Xc = cosh(U);
-  Standard_Real Yc = sinh(U);
+  Standard_Real Xc = Cosh(U);
+  Standard_Real Yc = Sinh(U);
   gp_XYZ Coord0;
   gp_XYZ Coord1 (Pos.XDirection().XYZ());
   gp_XYZ Coord2 (Pos.YDirection().XYZ());
@@ -594,8 +594,8 @@ gp_Pnt2d ElCLib::HyperbolaValue (const Standard_Real U,
   const gp_XY& XDir = Pos.XDirection().XY();
   const gp_XY& YDir = Pos.YDirection().XY();
   const gp_XY& PLoc = Pos.Location  ().XY();
-  Standard_Real A1 = MajorRadius * cosh(U);
-  Standard_Real A2 = MinorRadius * sinh(U);
+  Standard_Real A1 = MajorRadius * Cosh(U);
+  Standard_Real A2 = MinorRadius * Sinh(U);
   return gp_Pnt2d(A1 * XDir.X() + A2 * YDir.X() + PLoc.X(),
                  A1 * XDir.Y() + A2 * YDir.Y() + PLoc.Y());
 }
@@ -706,8 +706,8 @@ void ElCLib::HyperbolaD1 (const Standard_Real U,
   gp_XY Vxy;
   gp_XY Xdir ((Pos.XDirection()).XY());
   gp_XY Ydir ((Pos.YDirection()).XY());
-  Standard_Real Xc = cosh(U);
-  Standard_Real Yc = sinh(U);
+  Standard_Real Xc = Cosh(U);
+  Standard_Real Yc = Sinh(U);
   //Point courant :
   Vxy.SetLinearForm (Xc*MajorRadius, Xdir, 
                     Yc*MinorRadius, Ydir,
@@ -825,8 +825,8 @@ void ElCLib::HyperbolaD2 (const Standard_Real U,
   gp_XY Vxy;
   gp_XY Xdir (Pos.XDirection().XY()); 
   gp_XY Ydir (Pos.YDirection().XY()); 
-  Standard_Real Xc = cosh(U);
-  Standard_Real Yc = sinh(U);
+  Standard_Real Xc = Cosh(U);
+  Standard_Real Yc = Sinh(U);
 
   //V2 :
   Vxy.SetLinearForm (Xc*MajorRadius, Xdir, Yc*MinorRadius, Ydir);
@@ -964,8 +964,8 @@ void ElCLib::HyperbolaD3 (const Standard_Real U,
   gp_XY Vxy;
   gp_XY Xdir (Pos.XDirection().XY());
   gp_XY Ydir (Pos.YDirection().XY());
-  Standard_Real Xc = cosh(U);
-  Standard_Real Yc = sinh(U);
+  Standard_Real Xc = Cosh(U);
+  Standard_Real Yc = Sinh(U);
 
   //V2 :
   Vxy.SetLinearForm (Xc*MajorRadius, Xdir, Yc*MinorRadius, Ydir);
@@ -1082,12 +1082,12 @@ gp_Vec ElCLib::HyperbolaDN (const Standard_Real U,
 {
   Standard_Real Xc=0, Yc=0;
   if (IsOdd (N)) {       
-    Xc = MajorRadius * sinh(U);
-    Yc = MinorRadius * cosh(U);
+    Xc = MajorRadius * Sinh(U);
+    Yc = MinorRadius * Cosh(U);
   }
   else if (IsEven (N)) {
-    Xc = MajorRadius * cosh(U);
-    Yc = MinorRadius * sinh(U);
+    Xc = MajorRadius * Cosh(U);
+    Yc = MinorRadius * Sinh(U);
   }
   gp_XYZ Coord1 (Pos.XDirection().XYZ());
   Coord1.SetLinearForm (Xc, Coord1, Yc, Pos.YDirection().XYZ());
@@ -1230,12 +1230,12 @@ gp_Vec2d ElCLib::HyperbolaDN (const Standard_Real U,
 {
   Standard_Real Xc=0, Yc=0;
   if (IsOdd (N)) {       
-    Xc = MajorRadius * sinh(U);
-    Yc = MinorRadius * cosh(U);
+    Xc = MajorRadius * Sinh(U);
+    Yc = MinorRadius * Cosh(U);
   }
   else if (IsEven (N)) {
-    Xc = MajorRadius * cosh(U);
-    Yc = MinorRadius * sinh(U);
+    Xc = MajorRadius * Cosh(U);
+    Yc = MinorRadius * Sinh(U);
   }
   gp_XY Xdir (Pos.XDirection().XY());
   gp_XY Ydir (Pos.YDirection().XY());
index a79915df84a5d90e4e93405a120704c8764f361b..8d83e39eac300ef720f7b45b7a87da5c7f4fe6f5 100644 (file)
@@ -55,6 +55,12 @@ Standard_Real Extrema_FuncExtPC::SearchOfTolerance()
     Pnt Ptemp;  //empty point (is not used below)
     Vec VDer;   // 1st derivative vector
     Tool::D1(*((Curve*)myC), u, Ptemp, VDer);
+
+    if(Precision::IsInfinite(VDer.X()) || Precision::IsInfinite(VDer.Y()))
+    {
+      continue;
+    }
+
     Standard_Real vm = VDer.Magnitude();
     if(vm > aMax)
       aMax = vm;
@@ -160,6 +166,13 @@ Standard_Boolean Extrema_FuncExtPC::Value (const Standard_Real U, Standard_Real&
   myU = U;
   Vec D1c;
   Tool::D1(*((Curve*)myC),myU,myPc,D1c);
+
+  if(Precision::IsInfinite(D1c.X()) || Precision::IsInfinite(D1c.Y()))
+  {
+    F = Precision::Infinite();
+    return Standard_False;
+  }
+
   Standard_Real Ndu = D1c.Magnitude();
 
   if(myMaxDerivOrder != 0)
index a61234cb9f5b69d13b418485265f7d233dc01d23..2ed746dac7d35c33aebb4b89a44251d24d304673 100644 (file)
@@ -204,7 +204,7 @@ void Extrema_GExtPC::Perform(const ThePoint& P)
       }
 
       // Solve on the first and last intervals.
-      if (mydist1 > Precision::SquareConfusion())
+      if (mydist1 > Precision::SquareConfusion() && !Precision::IsPositiveInfinite(mydist1))
       {
         ThePoint aP1, aP2;
         TheVector aV1, aV2;
@@ -213,21 +213,23 @@ void Extrema_GExtPC::Perform(const ThePoint& P)
         TheVector aBase1(P, aP1), aBase2(P, aP2);
         Standard_Real aVal1 = aV1.Dot(aBase1); // Derivative of (C(u) - P)^2
         Standard_Real aVal2 = aV2.Dot(aBase2); // Derivative of (C(u) - P)^2
-
-        // Derivatives have opposite signs - min or max inside of interval (sufficient condition).
-        // Necessary condition - when point lies on curve.
-        // Necessary condition - when derivative of point is too small.
-        if(aVal1 * aVal2 <= 0.0 ||
-           aBase1.Dot(aBase2) <= 0.0 ||
-           2.0 * Abs(aVal1) < Precision::Confusion() )
+        if(!(Precision::IsInfinite(aVal1) || Precision::IsInfinite(aVal2)))
         {
-          myintuinf = aParam(aVal.Lower());
-          myintusup = aParam(aVal.Lower() + 1);
-          IntervalPerform(P);
+          // Derivatives have opposite signs - min or max inside of interval (sufficient condition).
+          // Necessary condition - when point lies on curve.
+          // Necessary condition - when derivative of point is too small.
+          if(aVal1 * aVal2 <= 0.0 ||
+            aBase1.Dot(aBase2) <= 0.0 ||
+            2.0 * Abs(aVal1) < Precision::Confusion() )
+          {
+            myintuinf = aParam(aVal.Lower());
+            myintusup = aParam(aVal.Lower() + 1);
+            IntervalPerform(P);
+          }
         }
       }
 
-      if (mydist2 > Precision::SquareConfusion())
+      if (mydist2 > Precision::SquareConfusion() && !Precision::IsPositiveInfinite(mydist2))
       {
         ThePoint aP1, aP2;
         TheVector aV1, aV2;
@@ -237,16 +239,19 @@ void Extrema_GExtPC::Perform(const ThePoint& P)
         Standard_Real aVal1 = aV1.Dot(aBase1); // Derivative of (C(u) - P)^2
         Standard_Real aVal2 = aV2.Dot(aBase2); // Derivative of (C(u) - P)^2
 
-        // Derivatives have opposite signs - min or max inside of interval (sufficient condition).
-        // Necessary condition - when point lies on curve.
-        // Necessary condition - when derivative of point is too small.
-        if(aVal1 * aVal2 <= 0.0 ||
-           aBase1.Dot(aBase2) <= 0.0 ||
-           2.0 * Abs(aVal2) < Precision::Confusion() )
+        if(!(Precision::IsInfinite(aVal1) || Precision::IsInfinite(aVal2)))
         {
-          myintuinf = aParam(aVal.Upper() - 1);
-          myintusup = aParam(aVal.Upper());
-          IntervalPerform(P);
+          // Derivatives have opposite signs - min or max inside of interval (sufficient condition).
+          // Necessary condition - when point lies on curve.
+          // Necessary condition - when derivative of point is too small.
+          if(aVal1 * aVal2 <= 0.0 ||
+            aBase1.Dot(aBase2) <= 0.0 ||
+            2.0 * Abs(aVal2) < Precision::Confusion() )
+          {
+            myintuinf = aParam(aVal.Upper() - 1);
+            myintusup = aParam(aVal.Upper());
+            IntervalPerform(P);
+          }
         }
       }
 
index 5f9a911f44c740d65edc90c13281cd5dbd225114..3f5eb2ea10cf579b6c813fb1043a6aa72610fb1a 100644 (file)
@@ -187,6 +187,10 @@ void Extrema_GLocateExtPC::Perform(const ThePoint&     P,
             {
               TheCurveTool::D1(*((TheCurve*)myC), myintuinf, P1, V1);
               s2sup = (TheVector(P, P1)*V1);
+              if(Precision::IsInfinite(s2sup) || Precision::IsInfinite(s1sup))
+              {
+                break;
+              }
               if (s1sup*s2sup <= RealEpsilon())
               {
                 // extremum:
@@ -220,6 +224,10 @@ void Extrema_GLocateExtPC::Perform(const ThePoint&     P,
             {
               TheCurveTool::D1(*((TheCurve*)myC), myintusup, P1, V1);
               s1inf = (TheVector(P, P1)*V1);
+              if(Precision::IsInfinite(s2inf) || Precision::IsInfinite(s1inf))
+              {
+                break;
+              }
               if (s1inf*s2inf <= RealEpsilon())
               {
                 // extremum:
index dca7a2ac22bd91ffc6d9aad17b91eae50fb20178..f108016baae1d3e7f87871a2382266c6da468dab 100644 (file)
 #include <Standard_TypeMismatch.hxx>
 #include <StdFail_NotDone.hxx>
 #include <TColgp_HArray1OfPnt.hxx>
+#include <Adaptor3d_HSurface.hxx>
 
-const Standard_Real aMaxParamVal = 1.0e+10;
+const Standard_Real UMaxParamVal = 1.0e+10;
+const Standard_Real VMaxParamVal = 1.0e+10;
+const Standard_Real CMaxParamVal = 1.0e+10;
 const Standard_Real aBorderDivisor = 1.0e+4;
+const Standard_Real HyperbolaLimit = 23.; //ln(UMaxParamVal)
 
+static void GetSurfMaxParamVals(const Adaptor3d_SurfacePtr theS,
+                    Standard_Real& theUmax, Standard_Real& theVmax)
+{
+  theUmax = UMaxParamVal;
+  theVmax = VMaxParamVal;
+  Handle(Adaptor3d_HCurve) aBC;
+  GeomAbs_SurfaceType aST = GeomAbs_OtherSurface;
+  if(theS->GetType() == GeomAbs_OffsetSurface)
+  {
+    Handle(Adaptor3d_HSurface) aBS = theS->BasisSurface();
+    if(aBS->GetType() == GeomAbs_SurfaceOfExtrusion ||
+       aBS->GetType() == GeomAbs_SurfaceOfRevolution)
+    {
+      aST = aBS->GetType();
+      aBC = aBS->BasisCurve();
+    }
+    else
+    {
+      return;
+    }
+  }
+  else if(theS->GetType() == GeomAbs_SurfaceOfExtrusion ||
+          theS->GetType() == GeomAbs_SurfaceOfRevolution)
+  {
+    aST = theS->GetType();
+    aBC = theS->BasisCurve();
+  }
+  else
+  {
+    return;
+  }
+  //
+  if(aBC->GetType() == GeomAbs_OffsetCurve)
+  {
+    aBC = aBC->BasisCurve();
+  }
+    
+  if(aBC->GetType() == GeomAbs_Hyperbola)
+  {
+    if(aST == GeomAbs_SurfaceOfExtrusion)
+    {
+      theUmax = HyperbolaLimit;
+    }
+    else
+    {
+      theVmax = HyperbolaLimit;
+    }
+  }
+  return;
+}
+//
+static Standard_Real GetCurvMaxParamVal(const Adaptor3d_Curve& theC)
+{
+  if(theC.GetType() == GeomAbs_OffsetCurve)
+  {
+    Handle(Adaptor3d_HCurve) aBC = theC.BasisCurve();
+    if(aBC->GetType() == GeomAbs_Hyperbola)
+    {
+      return HyperbolaLimit;
+    }
+    else
+    {
+      return CMaxParamVal;
+    }
+  }
+  else if(theC.GetType() == GeomAbs_Hyperbola)
+  {
+    return HyperbolaLimit;
+  }
+  else
+  {
+    return CMaxParamVal;
+  }
+  //
+}
 //=======================================================================
 //function : Extrema_GenExtCS
 //purpose  : 
@@ -126,15 +205,32 @@ void Extrema_GenExtCS::Initialize (const Adaptor3d_Surface& S,
   myvsup = Vsup;
   mytol2 = Tol2;
 
-  const Standard_Real aTrimMaxU = Precision::IsInfinite (myusup) ?  aMaxParamVal : myusup;
-  const Standard_Real aTrimMinU = Precision::IsInfinite (myumin) ? -aMaxParamVal : myumin;
-  const Standard_Real aTrimMaxV = Precision::IsInfinite (myvsup) ?  aMaxParamVal : myvsup;
-  const Standard_Real aTrimMinV = Precision::IsInfinite (myvmin) ? -aMaxParamVal : myvmin;
+  Standard_Real umaxpar, vmaxpar;
+  GetSurfMaxParamVals(myS, umaxpar, vmaxpar);
 
-  const Standard_Real aMinU = aTrimMinU + (aTrimMaxU - aTrimMinU) / aBorderDivisor;
-  const Standard_Real aMinV = aTrimMinV + (aTrimMaxV - aTrimMinV) / aBorderDivisor;
-  const Standard_Real aMaxU = aTrimMaxU - (aTrimMaxU - aTrimMinU) / aBorderDivisor;
-  const Standard_Real aMaxV = aTrimMaxV - (aTrimMaxV - aTrimMinV) / aBorderDivisor;
+  if(Precision::IsInfinite (myusup))
+  {
+    myusup = umaxpar;
+  }
+  if(Precision::IsInfinite (myumin))
+  {
+    myumin = -umaxpar;
+  }
+  if(Precision::IsInfinite (myvsup))
+  {
+    myvsup =  vmaxpar;
+  }
+  if(Precision::IsInfinite (myvmin))
+  {
+    myvmin = -vmaxpar;
+  }
+
+  Standard_Real du = (myusup - myumin) / aBorderDivisor;
+  Standard_Real dv = (myvsup - myvmin) / aBorderDivisor;
+  const Standard_Real aMinU = myumin + du;
+  const Standard_Real aMinV = myvmin + dv;
+  const Standard_Real aMaxU = myusup - du;
+  const Standard_Real aMaxV = myvsup - dv;
   
   const Standard_Real aStepSU = (aMaxU - aMinU) / myusample;
   const Standard_Real aStepSV = (aMaxV - aMinV) / myvsample;
@@ -184,17 +280,12 @@ void Extrema_GenExtCS::Perform (const Adaptor3d_Curve& C,
   // Modif de lvt pour trimer la surface non pas aux infinis mais  a +/- 10000
 
   Standard_Real trimusup = myusup, trimumin = myumin,trimvsup = myvsup,trimvmin = myvmin;
-  if (Precision::IsInfinite(trimusup)){
-    trimusup = aMaxParamVal;
-  }
-  if (Precision::IsInfinite(trimvsup)){
-    trimvsup = aMaxParamVal;
-  }
-  if (Precision::IsInfinite(trimumin)){
-    trimumin = -aMaxParamVal;
+  Standard_Real aCMaxVal = GetCurvMaxParamVal(C);
+  if (Precision::IsInfinite(mytsup)){
+    mytsup = aCMaxVal;
   }
-  if (Precision::IsInfinite(trimvmin)){
-    trimvmin = -aMaxParamVal;
+  if (Precision::IsInfinite(mytmin)){
+    mytmin = -aCMaxVal;
   }
   //
   math_Vector Tol(1, 3);
index 3c0a921d4ec526b47182386691ea963530466030..f5441214d9e2d1f6102bffbbe43811bc364d1c35 100644 (file)
@@ -95,7 +95,7 @@ Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedLin&  Qualified1 ,
                               gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2);
                               gp_Pnt2d point3 = ElCLib::Value(Param3,OnLine);
                               Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.;
-                              Geom2dGcc_FunctionTanCuCuOnCu Func(L1,Cu2,OnLine,Ufirst(4));
+                              Geom2dGcc_FunctionTanCuCuOnCu Func(L1,Cu2,OnLine,Max(Ufirst(4), Tol));
                               math_FunctionSetRoot Root(Func, tol);
                               Root.Perform(Func, Ufirst, Umin, Umax);
                               Func.Value(Ufirst,Umin);
@@ -180,7 +180,7 @@ Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 ,
                               math_Vector tol(1,4);
                               Umin(1) = Geom2dGcc_CurveTool::FirstParameter(Cu1);
                               Umin(2) = Geom2dGcc_CurveTool::FirstParameter(Cu2);
-                              Umin(3) = RealFirst();
+                              Umin(3) = RealFirst();  
                               Umin(4) = 0.;
                               Umax(1) = Geom2dGcc_CurveTool::LastParameter(Cu1);
                               Umax(2) = Geom2dGcc_CurveTool::LastParameter(Cu2);
@@ -197,7 +197,7 @@ Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 ,
                               gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2);
                               gp_Pnt2d point3 = ElCLib::Value(Param3,OnLine);
                               Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.;
-                              Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Cu2,OnLine,Ufirst(4));
+                              Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Cu2,OnLine,Max(Ufirst(4), Tol));
                               math_FunctionSetRoot Root(Func, tol);
                               Root.Perform(Func, Ufirst, Umin, Umax);
                               Func.Value(Ufirst,Umin);
@@ -210,6 +210,10 @@ Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 ,
                                 gp_Pnt2d point3new(OnLine.Location().XY()+Ufirst(3)*Tan3.XY());
                                 Standard_Real dist1 = point3new.Distance(point1);
                                 Standard_Real dist2 = point3new.Distance(point2);
+                                if((dist1+dist2)/2. < Tol)
+                                {
+                                  return;
+                                }
                                 if ( Abs(dist1-dist2)/2. <= Tol) {
                                   cirsol = gp_Circ2d(gp_Ax2d(point3new,dirx),(dist1+dist2)/2.);
                                   Standard_Real normetan1 = Tan1.Magnitude();
@@ -294,7 +298,7 @@ Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 ,
                               gp_Pnt2d point1 = Geom2dGcc_CurveTool::Value(Cu1,Param1);
                               gp_Pnt2d point3 = ElCLib::Value(Param2,OnLine);
                               Ufirst(3) = (point3.Distance(Point2)+point3.Distance(point1))/2.;
-                              Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Point2,OnLine,Ufirst(3));
+                              Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Point2,OnLine,Max(Ufirst(3), Tol));
                               math_FunctionSetRoot Root(Func, tol);
                               Root.Perform(Func, Ufirst, Umin, Umax);
                               Func.Value(Ufirst,Umin);
@@ -388,7 +392,7 @@ Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedCirc& Qualified1 ,
                               gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2);
                               gp_Pnt2d point3 = ElCLib::Value(Param3,OnLine);
                               Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.;
-                              Geom2dGcc_FunctionTanCuCuOnCu Func(C1,Cu2,OnLine,Ufirst(4));
+                              Geom2dGcc_FunctionTanCuCuOnCu Func(C1,Cu2,OnLine,Max(Ufirst(4), Tol));
                               math_FunctionSetRoot Root(Func, tol);
                               Root.Perform(Func, Ufirst, Umin, Umax);
                               Func.Value(Ufirst,Umin);
@@ -496,7 +500,7 @@ Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedCirc& Qualified1 ,
                               gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2);
                               gp_Pnt2d point3 = ElCLib::Value(Param3,OnCirc);
                               Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.;
-                              Geom2dGcc_FunctionTanCuCuOnCu Func(C1,Cu2,OnCirc,Ufirst(4));
+                              Geom2dGcc_FunctionTanCuCuOnCu Func(C1,Cu2,OnCirc,Max(Ufirst(4), Tol));
                               math_FunctionSetRoot Root(Func, tol);
                               Root.Perform(Func, Ufirst, Umin, Umax);
                               Func.Value(Ufirst,Umin);
@@ -601,7 +605,7 @@ Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedLin&  Qualified1 ,
                               gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2);
                               gp_Pnt2d point3 = ElCLib::Value(Param3,OnCirc);
                               Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.;
-                              Geom2dGcc_FunctionTanCuCuOnCu Func(L1,Cu2,OnCirc,Ufirst(4));
+                              Geom2dGcc_FunctionTanCuCuOnCu Func(L1,Cu2,OnCirc,Max(Ufirst(4), Tol));
                               math_FunctionSetRoot Root(Func, tol);
                               Root.Perform(Func, Ufirst, Umin, Umax);
                               Func.Value(Ufirst,Umin);
@@ -706,7 +710,7 @@ Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 ,
                               Standard_Real R1 = OnCirc.Radius();
                               gp_Pnt2d point3(OnCirc.Location().XY()+R1*gp_XY(Cos(Param3),Sin(Param3)));
                               Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.;
-                              Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Cu2,OnCirc,Ufirst(4));
+                              Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Cu2,OnCirc,Max(Ufirst(4), Tol));
                               math_FunctionSetRoot Root(Func, tol);
                               Root.Perform(Func, Ufirst, Umin, Umax);
                               Func.Value(Ufirst,Umin);
@@ -807,7 +811,7 @@ Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve&  Qualified1 ,
                               gp_Pnt2d point1 = Geom2dGcc_CurveTool::Value(Cu1,Param1);
                               gp_Pnt2d point3 = ElCLib::Value(Param2,OnCirc);
                               Ufirst(3) = (point3.Distance(Point2)+point3.Distance(point1))/2.;
-                              Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Point2,OnCirc,Ufirst(3));
+                              Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Point2,OnCirc,Max(Ufirst(3), Tol));
                               math_FunctionSetRoot Root(Func, tol);
                               Root.Perform(Func, Ufirst, Umin, Umax);
                               Func.Value(Ufirst,Umin);
@@ -901,7 +905,7 @@ Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve& Qualified1 ,
                               gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2);
                               gp_Pnt2d point3 = Geom2dGcc_CurveTool::Value(OnCurv,Param3);
                               Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.;
-                              Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Cu2,OnCurv,Ufirst(4));
+                              Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Cu2,OnCurv,Max(Ufirst(4), Tol));
                               math_FunctionSetRoot Root(Func, tol);
                               Root.Perform(Func, Ufirst, Umin, Umax);
                               Func.Value(Ufirst,Umin);
@@ -1007,7 +1011,7 @@ Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedCirc& Qualified1 ,
                               gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2);
                               gp_Pnt2d point3 = Geom2dGcc_CurveTool::Value(OnCurv,ParamOn);
                               Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.;
-                              Geom2dGcc_FunctionTanCuCuOnCu Func(C1,Cu2,OnCurv,Ufirst(4));
+                              Geom2dGcc_FunctionTanCuCuOnCu Func(C1,Cu2,OnCurv,Max(Ufirst(4), Tol));
                               math_FunctionSetRoot Root(Func, tol);
                               Root.Perform(Func, Ufirst, Umin, Umax);
                               Func.Value(Ufirst,Umin);
@@ -1109,7 +1113,7 @@ Geom2dGcc_Circ2d2TanOnIter (const GccEnt_QualifiedLin&  Qualified1 ,
                               gp_Pnt2d point2 = Geom2dGcc_CurveTool::Value(Cu2,Param2);
                               gp_Pnt2d point3 = Geom2dGcc_CurveTool::Value(OnCurv,ParamOn);
                               Ufirst(4) = (point3.Distance(point2)+point3.Distance(point1))/2.;
-                              Geom2dGcc_FunctionTanCuCuOnCu Func(L1,Cu2,OnCurv,Ufirst(4));
+                              Geom2dGcc_FunctionTanCuCuOnCu Func(L1,Cu2,OnCurv,Max(Ufirst(4), Tol));
                               math_FunctionSetRoot Root(Func, tol);
                               Root.Perform(Func, Ufirst, Umin, Umax);
                               Func.Value(Ufirst,Umin);
@@ -1201,7 +1205,7 @@ Geom2dGcc_Circ2d2TanOnIter (const Geom2dGcc_QCurve&    Qualified1 ,
   gp_Pnt2d point1 = Geom2dGcc_CurveTool::Value(Cu1,Param1);
   gp_Pnt2d point3 = Geom2dGcc_CurveTool::Value(OnCurv,ParamOn);
   Ufirst(3) = (point3.Distance(Point2)+point3.Distance(point1))/2.;
-  Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Point2,OnCurv,Ufirst(3));
+  Geom2dGcc_FunctionTanCuCuOnCu Func(Cu1,Point2,OnCurv,Max(Ufirst(3), Tol));
   math_FunctionSetRoot Root(Func, tol);
   Root.Perform(Func, Ufirst, Umin, Umax);
   Func.Value(Ufirst,Umin);
index cdeca87d103eef39064e4126ef7d145909b455fa..d9c7adec21a1ba3f10c09078d68582115d0f16a7 100644 (file)
 #include <GeomAbs_CurveType.hxx>
 #include <gp_Pnt2d.hxx>
 #include <gp_Vec2d.hxx>
+#include <Precision.hxx>
 
 //============================================================
 Standard_Integer Geom2dInt_Geom2dCurveTool::NbSamples (const Adaptor2d_Curve2d& C,
-                                                       const Standard_Real U0,
-                                                       const Standard_Real U1)
+  const Standard_Real U0,
+  const Standard_Real U1) 
 {
   GeomAbs_CurveType typC = C.GetType();
   Standard_Integer nbs = C.NbSamples();
 
   if(typC == GeomAbs_BSplineCurve)
   {
-    Standard_Real t = C.LastParameter() - C.FirstParameter();
-    Standard_Real t1 = U1 - U0;
-    if(t1 < 0.0) t1 = -t1;
-    nbs = C.NbKnots();
-    nbs*= C.Degree();
-    Standard_Real anb = t1 / t * nbs;
-    nbs = (Standard_Integer)anb;
+    Standard_Real t=C.LastParameter()-C.FirstParameter();
+    if(t > Precision::PConfusion())
+    {
+      Standard_Real t1 = U1 - U0;
+      if(t1 < 0.0) t1 = -t1;
+      nbs = C.NbKnots();
+      nbs*= C.Degree();
+      Standard_Real anb = t1 / t * nbs;
+      nbs = (Standard_Integer)anb;
 
-    Standard_Integer aMinPntNb = Max(C.Degree() + 1, 4);
-    if(nbs < aMinPntNb)
-      nbs = aMinPntNb;
+      Standard_Integer aMinPntNb = Max(C.Degree() + 1, 4);
+      if(nbs < aMinPntNb)
+        nbs = aMinPntNb;
+    }
   }
   else if (typC == GeomAbs_Circle)
   {
index 5be1665b1d813bfcb27f347f312db6607650f586..bc265388d0235c8091bd20724b4cd1c6ce75645e 100644 (file)
@@ -142,7 +142,7 @@ void GeomAdaptor_Curve::load(const Handle(Geom_Curve)& C,
     myCurve = C;
     myNestedEvaluator.Nullify();
     myBSplineCurve.Nullify();
-
+    
     const Handle(Standard_Type)& TheType = C->DynamicType();
     if ( TheType == STANDARD_TYPE(Geom_TrimmedCurve)) {
       Load(Handle(Geom_TrimmedCurve)::DownCast (C)->BasisCurve(),UFirst,ULast);
@@ -540,10 +540,10 @@ void GeomAdaptor_Curve::RebuildCache(const Standard_Real theParameter) const
       myCurveCache = new BSplCLib_Cache(aDeg, aBezier->IsPeriodic(), aFlatKnots,
         aBezier->Poles(), aBezier->Weights());
     myCurveCache->BuildCache(theParameter, aDeg, aBezier->IsPeriodic(), aFlatKnots,
-      aBezier->Poles(), aBezier->Weights());
-  }
+        aBezier->Poles(), aBezier->Weights());
+}
   else if (myTypeCurve == GeomAbs_BSplineCurve)
-  {
+{
     // Create cache for B-spline
     if (myCurveCache.IsNull())
       myCurveCache = new BSplCLib_Cache(myBSplineCurve->Degree(), myBSplineCurve->IsPeriodic(),
@@ -551,7 +551,7 @@ void GeomAdaptor_Curve::RebuildCache(const Standard_Real theParameter) const
     myCurveCache->BuildCache(theParameter, myBSplineCurve->Degree(),
         myBSplineCurve->IsPeriodic(), myBSplineCurve->KnotSequence(),
         myBSplineCurve->Poles(), myBSplineCurve->Weights());
-  }
+}
 }
 
 //=======================================================================
@@ -583,7 +583,7 @@ Standard_Boolean GeomAdaptor_Curve::IsBoundary(const Standard_Real theU,
     return Standard_True;
   }
   return Standard_False;
-}
+  }
 
 //=======================================================================
 //function : Value
@@ -605,7 +605,7 @@ gp_Pnt GeomAdaptor_Curve::Value(const Standard_Real U) const
 void GeomAdaptor_Curve::D0(const Standard_Real U, gp_Pnt& P) const
 {
   switch (myTypeCurve)
-  {
+{
   case GeomAbs_BezierCurve:
   case GeomAbs_BSplineCurve:
   {
@@ -615,14 +615,14 @@ void GeomAdaptor_Curve::D0(const Standard_Real U, gp_Pnt& P) const
       myBSplineCurve->LocalD0(U, aStart, aFinish, P);
     }
     else
-    {
+  {
       // use cached data
       if (myCurveCache.IsNull() || !myCurveCache->IsCacheValid(U))
         RebuildCache(U);
       myCurveCache->D0(U, P);
-    }
-    break;
   }
+    break;
+}
 
   case GeomAbs_OffsetCurve:
     myNestedEvaluator->D0(U, P);
@@ -630,7 +630,7 @@ void GeomAdaptor_Curve::D0(const Standard_Real U, gp_Pnt& P) const
 
   default:
     myCurve->D0(U, P);
-  }
+}
 }
 
 //=======================================================================
@@ -641,7 +641,7 @@ void GeomAdaptor_Curve::D0(const Standard_Real U, gp_Pnt& P) const
 void GeomAdaptor_Curve::D1(const Standard_Real U, gp_Pnt& P, gp_Vec& V) const 
 {
   switch (myTypeCurve)
-  {
+{
   case GeomAbs_BezierCurve:
   case GeomAbs_BSplineCurve:
   {
@@ -651,14 +651,14 @@ void GeomAdaptor_Curve::D1(const Standard_Real U, gp_Pnt& P, gp_Vec& V) const
       myBSplineCurve->LocalD1(U, aStart, aFinish, P, V);
     }
     else
-    {
+  {
       // use cached data
       if (myCurveCache.IsNull() || !myCurveCache->IsCacheValid(U))
         RebuildCache(U);
       myCurveCache->D1(U, P, V);
-    }
-    break;
   }
+    break;
+}
 
   case GeomAbs_OffsetCurve:
     myNestedEvaluator->D1(U, P, V);
@@ -666,7 +666,7 @@ void GeomAdaptor_Curve::D1(const Standard_Real U, gp_Pnt& P, gp_Vec& V) const
 
   default:
     myCurve->D1(U, P, V);
-  }
+}
 }
 
 //=======================================================================
@@ -678,7 +678,7 @@ void GeomAdaptor_Curve::D2(const Standard_Real U,
                            gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const 
 {
   switch (myTypeCurve)
-  {
+{
   case GeomAbs_BezierCurve:
   case GeomAbs_BSplineCurve:
   {
@@ -688,14 +688,14 @@ void GeomAdaptor_Curve::D2(const Standard_Real U,
       myBSplineCurve->LocalD2(U, aStart, aFinish, P, V1, V2);
     }
     else
-    {
+  {
       // use cached data
       if (myCurveCache.IsNull() || !myCurveCache->IsCacheValid(U))
         RebuildCache(U);
       myCurveCache->D2(U, P, V1, V2);
-    }
-    break;
   }
+    break;
+}
 
   case GeomAbs_OffsetCurve:
     myNestedEvaluator->D2(U, P, V1, V2);
@@ -703,7 +703,7 @@ void GeomAdaptor_Curve::D2(const Standard_Real U,
 
   default:
     myCurve->D2(U, P, V1, V2);
-  }
+}
 }
 
 //=======================================================================
@@ -716,7 +716,7 @@ void GeomAdaptor_Curve::D3(const Standard_Real U,
                            gp_Vec& V2, gp_Vec& V3) const 
 {
   switch (myTypeCurve)
-  {
+{
   case GeomAbs_BezierCurve:
   case GeomAbs_BSplineCurve:
   {
@@ -726,14 +726,14 @@ void GeomAdaptor_Curve::D3(const Standard_Real U,
       myBSplineCurve->LocalD3(U, aStart, aFinish, P, V1, V2, V3);
     }
     else
-    {
+  {
       // use cached data
       if (myCurveCache.IsNull() || !myCurveCache->IsCacheValid(U))
         RebuildCache(U);
       myCurveCache->D3(U, P, V1, V2, V3);
-    }
-    break;
   }
+    break;
+}
 
   case GeomAbs_OffsetCurve:
     myNestedEvaluator->D3(U, P, V1, V2, V3);
@@ -741,7 +741,7 @@ void GeomAdaptor_Curve::D3(const Standard_Real U,
 
   default:
     myCurve->D3(U, P, V1, V2, V3);
-  }
+}
 }
 
 //=======================================================================
@@ -753,7 +753,7 @@ gp_Vec GeomAdaptor_Curve::DN(const Standard_Real    U,
                              const Standard_Integer N) const 
 {
   switch (myTypeCurve)
-  {
+{
   case GeomAbs_BezierCurve:
   case GeomAbs_BSplineCurve:
   {
@@ -763,9 +763,9 @@ gp_Vec GeomAdaptor_Curve::DN(const Standard_Real    U,
       return myBSplineCurve->LocalDN(U, aStart, aFinish, N);
     }
     else
-      return myCurve->DN(U, N);
+  return myCurve->DN( U, N);
     break;
-  }
+}
 
   case GeomAbs_OffsetCurve:
     return myNestedEvaluator->DN(U, N);
@@ -959,3 +959,34 @@ Handle(Geom_BSplineCurve) GeomAdaptor_Curve::BSpline() const
 
   return myBSplineCurve;
 }
+
+//=======================================================================
+//function : BasisCurve
+//purpose  : 
+//=======================================================================
+
+Handle(Adaptor3d_HCurve) GeomAdaptor_Curve::BasisCurve() const 
+{
+  if ( myTypeCurve != GeomAbs_OffsetCurve)
+    Standard_NoSuchObject::Raise("GeomAdaptor_Curve::BasisCurve");
+
+  Handle(Geom_OffsetCurve) anOffC = Handle(Geom_OffsetCurve)::DownCast(myCurve);
+  Handle(Geom_Curve) aBC = anOffC->BasisCurve();
+  Handle(GeomAdaptor_HCurve) aGABC = new GeomAdaptor_HCurve(aBC);
+  return aGABC;
+}
+
+//=======================================================================
+//function : OffsetValue
+//purpose  : 
+//=======================================================================
+
+Standard_Real GeomAdaptor_Curve::OffsetValue() const 
+{
+  if ( myTypeCurve != GeomAbs_OffsetCurve)
+    Standard_NoSuchObject::Raise("GeomAdaptor_Curve::OffsetValue");
+  return Handle(Geom_OffsetCurve)::DownCast(myCurve)->Offset();
+} 
+
index 1cc735c78f312decf99d26c299fb279a854121aa..7c197e2814e1fa0e35373079f916bf5def39f891 100644 (file)
@@ -207,6 +207,9 @@ public:
   //! myFirst/Last.
   Standard_EXPORT Handle(Geom_BSplineCurve) BSpline() const Standard_OVERRIDE;
 
+  Standard_EXPORT Handle(Adaptor3d_HCurve) BasisCurve() const Standard_OVERRIDE;
+  
+  Standard_EXPORT Standard_Real OffsetValue() const Standard_OVERRIDE;
 
 friend class GeomAdaptor_Surface;
 
index 78ee8bd73c4e26d312e70c21b21e9a7fbe3396fd..5f851793aa0c3458fd1a50cf4acf0670d8bdfa93 100644 (file)
@@ -2193,7 +2193,7 @@ void CalculPtsInterTriEdgeCoplanaires2(const Standard_Integer TriSurfID,
     Standard_Real p2p = Per.Dot(PE2);
     Standard_Real p0p = Per.Dot(PT1);
     ///The edge are PT1 are projected on the perpendicular of the side in the plane of the triangle
-    if ( ( (p1p>=p0p)&&(p0p>=p2p) )||( (p1p<=p0p)&&(p0p<=p2p) ) ) {
+    if ( ( ((p1p>=p0p)&&(p0p>=p2p) )||( (p1p<=p0p)&&(p0p<=p2p) )) && (Abs(p1p-p2p) > MyConfusionPrecision)) {
       Standard_Real lambda=(p1p-p0p)/(p1p-p2p);
       if (lambda<-MyConfusionPrecision) {
 
index 37507c3ac7ebd6da248e16f9da9b52eb56d978ea..b860baa279a00078587c356d7ff49c8eef8eacbe 100644 (file)
 
 #include <Extrema_ExtElC.hxx>
 #include <Extrema_POnCurv.hxx>
+#include <Precision.hxx>
 
 static const int Pourcent3[4] = {0, 1, 2, 0};
 
 static Standard_Boolean IsInSegment(const gp_Vec& P1P2,
-                                   const gp_Vec& P1P,
-                                   const Standard_Real NP1P2,
-                                   Standard_Real &Param,
-                                   const Standard_Real Tolerance) { 
-  Param = P1P2.Dot(P1P);
-  Param/= NP1P2;
-  if(Param > (NP1P2+Tolerance))
-    return(Standard_False);
-  if(Param < (-Tolerance))
-    return(Standard_False);
-  Param/=NP1P2;
-  if(Param<0.0) Param=0.0;
-  if(Param>1.0) Param=1.0;
-  return(Standard_True);
+  const gp_Vec& P1P,
+  const Standard_Real NP1P2,
+  Standard_Real &Param,
+  const Standard_Real Tolerance) { 
+    Param = P1P2.Dot(P1P);
+    Param/= NP1P2;
+    if(Param > (NP1P2+Tolerance))
+      return(Standard_False);
+    if(Param < (-Tolerance))
+      return(Standard_False);
+    Param/=NP1P2;
+    if(Param<0.0) Param=0.0;
+    if(Param>1.0) Param=1.0;
+    return(Standard_True);
 }
-    
+
 
 //=======================================================================
 //function : Intf_InterferencePolygonPolyhedron
@@ -57,7 +58,7 @@ static Standard_Boolean IsInSegment(const gp_Vec& P1P2,
 //=======================================================================
 
 Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron() 
-: Intf_Interference (Standard_False),
+  : Intf_Interference (Standard_False),
   BeginOfClosedPolygon (Standard_False),
   iLin (0)
 {} 
@@ -70,12 +71,12 @@ Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron()
 
 Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron
   (const Polygon3d& thePolyg, const Polyhedron& thePolyh) 
-: Intf_Interference (Standard_False),
+  : Intf_Interference (Standard_False),
   BeginOfClosedPolygon (Standard_False),
   iLin (0)
 {
   Tolerance=ToolPolygon3d::DeflectionOverEstimation(thePolyg)+
-           ToolPolyh::DeflectionOverEstimation(thePolyh);
+    ToolPolyh::DeflectionOverEstimation(thePolyh);
   if (Tolerance==0.)
     Tolerance=Epsilon(1000.);
 
@@ -87,13 +88,13 @@ Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron
 
 Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron
   (const Polygon3d& thePolyg, const Polyhedron& thePolyh,
-   Bnd_BoundSortBox &PolyhGrid) 
-: Intf_Interference (Standard_False),
+  Bnd_BoundSortBox &PolyhGrid) 
+  : Intf_Interference (Standard_False),
   BeginOfClosedPolygon (Standard_False),
   iLin (0)
 {
   Tolerance=ToolPolygon3d::DeflectionOverEstimation(thePolyg)+
-           ToolPolyh::DeflectionOverEstimation(thePolyh);
+    ToolPolyh::DeflectionOverEstimation(thePolyh);
   if (Tolerance==0.)
     Tolerance=Epsilon(1000.);
 
@@ -110,7 +111,7 @@ Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron
 
 Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron
   (const gp_Lin& theLin, const Polyhedron& thePolyh) 
-: Intf_Interference (Standard_False),
+  : Intf_Interference (Standard_False),
   BeginOfClosedPolygon (Standard_False),
   iLin (0)
 {
@@ -122,7 +123,7 @@ Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron
 
   Bnd_BoundSortBox PolyhGrid;
   PolyhGrid.Initialize(ToolPolyh::Bounding(thePolyh),
-                      ToolPolyh::ComponentsBounding(thePolyh));
+    ToolPolyh::ComponentsBounding(thePolyh));
   Standard_Integer indTri;
 
   iLin=0;
@@ -135,9 +136,9 @@ Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron
   while (iCl.More()) {
     indTri=iCl.Value();
     Intersect
-       (theLin.Location(), 
-        theLin.Location().Translated(gp_Vec(theLin.Direction())),
-        Standard_True, indTri, thePolyh);
+      (theLin.Location(), 
+      theLin.Location().Translated(gp_Vec(theLin.Direction())),
+      Standard_True, indTri, thePolyh);
     iCl.Next();
   }
 }
@@ -151,7 +152,7 @@ Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron
 
 Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron 
   (const Intf_Array1OfLin& theLins, const Polyhedron& thePolyh) 
-: Intf_Interference (Standard_False),
+  : Intf_Interference (Standard_False),
   BeginOfClosedPolygon (Standard_False),
   iLin (0)
 {
@@ -165,7 +166,7 @@ Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron
 
   Bnd_BoundSortBox PolyhGrid;
   PolyhGrid.Initialize(ToolPolyh::Bounding(thePolyh),
-                      ToolPolyh::ComponentsBounding(thePolyh));
+    ToolPolyh::ComponentsBounding(thePolyh));
 
   Standard_Integer indTri;
 
@@ -179,9 +180,9 @@ Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron
     while (ilC.More()) {
       indTri=ilC.Value();
       Intersect
-       (theLins(iLin).Location(), 
-       theLins(iLin).Location().Translated(gp_Vec(theLins(iLin).Direction())),
-       Standard_True, indTri, thePolyh);
+        (theLins(iLin).Location(), 
+        theLins(iLin).Location().Translated(gp_Vec(theLins(iLin).Direction())),
+        Standard_True, indTri, thePolyh);
       ilC.Next();
     }
   }
@@ -198,13 +199,13 @@ void Intf_InterferencePolygonPolyhedron::Perform
 {
   SelfInterference(Standard_False);
   Tolerance=ToolPolygon3d::DeflectionOverEstimation(thePolyg)+
-           ToolPolyh::DeflectionOverEstimation(thePolyh);
+    ToolPolyh::DeflectionOverEstimation(thePolyh);
   if (Tolerance==0.)
     Tolerance=Epsilon(1000.);
 
   if (!ToolPolygon3d::Bounding(thePolyg).IsOut
-      (ToolPolyh::Bounding(thePolyh))) {
-    Interference(thePolyg, thePolyh);
+    (ToolPolyh::Bounding(thePolyh))) {
+      Interference(thePolyg, thePolyh);
   }
 } 
 
@@ -226,7 +227,7 @@ void Intf_InterferencePolygonPolyhedron::Perform
 
   Bnd_BoundSortBox PolyhGrid;
   PolyhGrid.Initialize(ToolPolyh::Bounding(thePolyh),
-                      ToolPolyh::ComponentsBounding(thePolyh));
+    ToolPolyh::ComponentsBounding(thePolyh));
 
   Standard_Integer indTri;
 
@@ -240,9 +241,9 @@ void Intf_InterferencePolygonPolyhedron::Perform
   while (lCi.More()) {
     indTri=lCi.Value();
     Intersect
-       (theLin.Location(), 
-        theLin.Location().Translated(gp_Vec(theLin.Direction())),
-        Standard_True, indTri, thePolyh);
+      (theLin.Location(), 
+      theLin.Location().Translated(gp_Vec(theLin.Direction())),
+      Standard_True, indTri, thePolyh);
     lCi.Next();
   }
 }
@@ -268,7 +269,7 @@ void Intf_InterferencePolygonPolyhedron::Perform
 
   Bnd_BoundSortBox PolyhGrid;
   PolyhGrid.Initialize(ToolPolyh::Bounding(thePolyh),
-                      ToolPolyh::ComponentsBounding(thePolyh));
+    ToolPolyh::ComponentsBounding(thePolyh));
 
   Standard_Integer indTri;
 
@@ -281,9 +282,9 @@ void Intf_InterferencePolygonPolyhedron::Perform
     while (tlC.More()) {
       indTri=tlC.Value();
       Intersect
-       (theLins(iLin).Location(), 
-       theLins(iLin).Location().Translated(gp_Vec(theLins(iLin).Direction())),
-       Standard_True, indTri, thePolyh);
+        (theLins(iLin).Location(), 
+        theLins(iLin).Location().Translated(gp_Vec(theLins(iLin).Direction())),
+        Standard_True, indTri, thePolyh);
       tlC.Next();
     }
   }
@@ -304,7 +305,7 @@ void Intf_InterferencePolygonPolyhedron::Interference
 
   Bnd_BoundSortBox PolyhGrid;
   PolyhGrid.Initialize(ToolPolyh::Bounding(thePolyh),
-                      ToolPolyh::ComponentsBounding(thePolyh));
+    ToolPolyh::ComponentsBounding(thePolyh));
 
   Standard_Integer indTri;
   BeginOfClosedPolygon=ToolPolygon3d::Closed(thePolyg);
@@ -335,21 +336,21 @@ void Intf_InterferencePolygonPolyhedron::Interference
       gp_Vec Normale = PaPb.Crossed(PaPc);
       Standard_Real Norm_Normale=Normale.Magnitude();
       if(Norm_Normale<1e-14)
-       continue;
+        continue;
       Normale.Multiply(defPh/Norm_Normale);
       gp_Pnt p1m = p1.Translated(-Normale);
       gp_Pnt p1p = p1.Translated( Normale);
       gp_Pnt p2m = p2.Translated(-Normale);
       gp_Pnt p2p = p2.Translated( Normale);
       Intersect(p1m, 
-               p2p,
-               Standard_False, indTri, thePolyh);
+        p2p,
+        Standard_False, indTri, thePolyh);
       Intersect(p1p, 
-               p2m,
-               Standard_False, indTri, thePolyh);
-//      Intersect(ToolPolygon3d::BeginOfSeg(thePolyg, iLin), 
-//             ToolPolygon3d::EndOfSeg(thePolyg, iLin),
-//             Standard_False, indTri, thePolyh);
+        p2m,
+        Standard_False, indTri, thePolyh);
+      //      Intersect(ToolPolygon3d::BeginOfSeg(thePolyg, iLin), 
+      //               ToolPolygon3d::EndOfSeg(thePolyg, iLin),
+      //               Standard_False, indTri, thePolyh);
     }
     BeginOfClosedPolygon=Standard_False;
   }
@@ -382,8 +383,8 @@ void Intf_InterferencePolygonPolyhedron::Interference
 
 Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron
   (const gp_Lin& theLin, const Polyhedron& thePolyh,
-   Bnd_BoundSortBox &PolyhGrid) 
-: Intf_Interference(Standard_False)
+  Bnd_BoundSortBox &PolyhGrid) 
+  : Intf_Interference(Standard_False)
 {
   Tolerance=ToolPolyh::DeflectionOverEstimation(thePolyh);
   if (Tolerance==0.)
@@ -403,9 +404,9 @@ Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron
   while (iCl.More()) {
     indTri=iCl.Value();
     Intersect
-       (theLin.Location(), 
-        theLin.Location().Translated(gp_Vec(theLin.Direction())),
-        Standard_True, indTri, thePolyh);
+      (theLin.Location(), 
+      theLin.Location().Translated(gp_Vec(theLin.Direction())),
+      Standard_True, indTri, thePolyh);
     iCl.Next();
   }
 }
@@ -419,8 +420,8 @@ Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron
 
 Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron 
   (const Intf_Array1OfLin& theLins, const Polyhedron& thePolyh,
-   Bnd_BoundSortBox &PolyhGrid) 
-: Intf_Interference(Standard_False)
+  Bnd_BoundSortBox &PolyhGrid) 
+  : Intf_Interference(Standard_False)
 {
   Tolerance=ToolPolyh::DeflectionOverEstimation(thePolyh);
   if (Tolerance==0.)
@@ -442,9 +443,9 @@ Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron
     while (ilC.More()) {
       indTri=ilC.Value();
       Intersect
-       (theLins(iLin).Location(), 
-       theLins(iLin).Location().Translated(gp_Vec(theLins(iLin).Direction())),
-       Standard_True, indTri, thePolyh);
+        (theLins(iLin).Location(), 
+        theLins(iLin).Location().Translated(gp_Vec(theLins(iLin).Direction())),
+        Standard_True, indTri, thePolyh);
       ilC.Next();
     }
   }
@@ -458,17 +459,17 @@ Intf_InterferencePolygonPolyhedron::Intf_InterferencePolygonPolyhedron
 
 void Intf_InterferencePolygonPolyhedron::Perform 
   (const Polygon3d& thePolyg, const Polyhedron& thePolyh,
-   Bnd_BoundSortBox &PolyhGrid) 
+  Bnd_BoundSortBox &PolyhGrid) 
 {
   SelfInterference(Standard_False);
   Tolerance=ToolPolygon3d::DeflectionOverEstimation(thePolyg)+
-           ToolPolyh::DeflectionOverEstimation(thePolyh);
+    ToolPolyh::DeflectionOverEstimation(thePolyh);
   if (Tolerance==0.)
     Tolerance=Epsilon(1000.);
 
   if (!ToolPolygon3d::Bounding(thePolyg).IsOut
-      (ToolPolyh::Bounding(thePolyh))) {
-    Interference(thePolyg, thePolyh,PolyhGrid);
+    (ToolPolyh::Bounding(thePolyh))) {
+      Interference(thePolyg, thePolyh,PolyhGrid);
   }
 } 
 
@@ -480,7 +481,7 @@ void Intf_InterferencePolygonPolyhedron::Perform
 
 void Intf_InterferencePolygonPolyhedron::Perform 
   (const gp_Lin& theLin, const Polyhedron& thePolyh,
-   Bnd_BoundSortBox &PolyhGrid) 
+  Bnd_BoundSortBox &PolyhGrid) 
 {
   SelfInterference(Standard_False);
   Tolerance=ToolPolyh::DeflectionOverEstimation(thePolyh);
@@ -501,9 +502,9 @@ void Intf_InterferencePolygonPolyhedron::Perform
   while (lCi.More()) {
     indTri=lCi.Value();
     Intersect
-       (theLin.Location(), 
-        theLin.Location().Translated(gp_Vec(theLin.Direction())),
-        Standard_True, indTri, thePolyh);
+      (theLin.Location(), 
+      theLin.Location().Translated(gp_Vec(theLin.Direction())),
+      Standard_True, indTri, thePolyh);
     lCi.Next();
   }
 }
@@ -517,7 +518,7 @@ void Intf_InterferencePolygonPolyhedron::Perform
 
 void Intf_InterferencePolygonPolyhedron::Perform  
   (const Intf_Array1OfLin& theLins, const Polyhedron& thePolyh,
-   Bnd_BoundSortBox &PolyhGrid) 
+  Bnd_BoundSortBox &PolyhGrid) 
 {
   SelfInterference(Standard_False);
   Tolerance=ToolPolyh::DeflectionOverEstimation(thePolyh);
@@ -539,9 +540,9 @@ void Intf_InterferencePolygonPolyhedron::Perform
     while (tlC.More()) {
       indTri=tlC.Value();
       Intersect
-       (theLins(iLin).Location(), 
-       theLins(iLin).Location().Translated(gp_Vec(theLins(iLin).Direction())),
-       Standard_True, indTri, thePolyh);
+        (theLins(iLin).Location(), 
+        theLins(iLin).Location().Translated(gp_Vec(theLins(iLin).Direction())),
+        Standard_True, indTri, thePolyh);
       tlC.Next();
     }
   }
@@ -557,7 +558,7 @@ void Intf_InterferencePolygonPolyhedron::Perform
 
 void Intf_InterferencePolygonPolyhedron::Interference 
   (const Polygon3d& thePolyg, const Polyhedron& thePolyh,
-   Bnd_BoundSortBox &PolyhGrid)
+  Bnd_BoundSortBox &PolyhGrid)
 {
   Bnd_Box bofSeg;
 
@@ -594,38 +595,38 @@ void Intf_InterferencePolygonPolyhedron::Interference
       ToolPolyh::Triangle(thePolyh, indTri, pTri[0], pTri[1], pTri[2]);
       gp_XYZ triNor;                                   // Vecteur normal.
       Standard_Real triDp = 0.;                        // Distance polaire.
-      
+
       Intf::PlaneEquation(ToolPolyh::Point(thePolyh, pTri[0]),
-                         ToolPolyh::Point(thePolyh, pTri[1]),
-                         ToolPolyh::Point(thePolyh, pTri[2]),
-                         triNor, triDp);
+        ToolPolyh::Point(thePolyh, pTri[1]),
+        ToolPolyh::Point(thePolyh, pTri[2]),
+        triNor, triDp);
 
       // enlarge boundary segment
       if ( iLin == 1 ) {
-       gp_XYZ dif = p1.XYZ() - p2.XYZ();
-       Standard_Real dist = dif.Modulus();
-       if ( dist > gp::Resolution() ) {
-         dif /= dist;
-         Standard_Real aCos = dif * triNor;
-         aCos = fabs(aCos);
-         if ( aCos > gp::Resolution() ) {
-           Standard_Real shift = defPh / aCos;
-           Beg0.SetXYZ( p1.XYZ() + dif * shift );
-         }
-       }
+        gp_XYZ dif = p1.XYZ() - p2.XYZ();
+        Standard_Real dist = dif.Modulus();
+        if ( dist > gp::Resolution() ) {
+          dif /= dist;
+          Standard_Real aCos = dif * triNor;
+          aCos = fabs(aCos);
+          if ( aCos > gp::Resolution() ) {
+            Standard_Real shift = defPh / aCos;
+            Beg0.SetXYZ( p1.XYZ() + dif * shift );
+          }
+        }
       }
       else if ( iLin == ToolPolygon3d::NbSegments(thePolyg) ) {
-       gp_XYZ dif = p2.XYZ() - p1.XYZ();
-       Standard_Real dist = dif.Modulus();
-       if ( dist > gp::Resolution() ) {
-         dif /= dist;
-         Standard_Real aCos = dif * triNor;
-         aCos = fabs(aCos);
-         if ( aCos > gp::Resolution() ) {
-           Standard_Real shift = defPh / aCos;
-           End0.SetXYZ( p2.XYZ() + dif * shift );
-         }
-       }
+        gp_XYZ dif = p2.XYZ() - p1.XYZ();
+        Standard_Real dist = dif.Modulus();
+        if ( dist > gp::Resolution() ) {
+          dif /= dist;
+          Standard_Real aCos = dif * triNor;
+          aCos = fabs(aCos);
+          if ( aCos > gp::Resolution() ) {
+            Standard_Real shift = defPh / aCos;
+            End0.SetXYZ( p2.XYZ() + dif * shift );
+          }
+        }
       }
       Standard_Real dBegTri=(triNor*Beg0.XYZ())-triDp; // Distance <p1> plane
       Standard_Real dEndTri=(triNor*End0.XYZ())-triDp; // Distance <p2> plane
@@ -647,8 +648,8 @@ void Intf_InterferencePolygonPolyhedron::Interference
 //=======================================================================
 #if 0 
 void Intf_InterferencePolygonPolyhedron::Intersect 
-(const gp_Pnt& BegO, const gp_Pnt& EndO, const Standard_Boolean Infinite,
- const Standard_Integer TTri, const Polyhedron& thePolyh)
+  (const gp_Pnt& BegO, const gp_Pnt& EndO, const Standard_Boolean Infinite,
 const Standard_Integer TTri, const Polyhedron& thePolyh)
 {
   Standard_Integer pTri0,pTri1,pTri2;
   ToolPolyh::Triangle(thePolyh, TTri, pTri0, pTri1, pTri2);
@@ -661,13 +662,13 @@ void Intf_InterferencePolygonPolyhedron::Intersect
   Standard_Real Norm_Normale=Normale.Magnitude();
   if(Norm_Normale<1e-14)
     return;
-  
+
   //-- Equation du Plan 
   Standard_Real A=Normale.X()/Norm_Normale;
   Standard_Real B=Normale.Y()/Norm_Normale;
   Standard_Real C=Normale.Z()/Norm_Normale;
   Standard_Real D=-(A*Pa.X()+B*Pa.Y()+C*Pa.Z());
-  
+
   gp_Vec BegOEndO(BegO,EndO);
   Standard_Real Norm_BegOEndO=BegOEndO.Magnitude();
   if(Norm_BegOEndO<1e-14) 
@@ -675,17 +676,17 @@ void Intf_InterferencePolygonPolyhedron::Intersect
   Standard_Real Lx=BegOEndO.X()/Norm_BegOEndO;
   Standard_Real Ly=BegOEndO.Y()/Norm_BegOEndO;
   Standard_Real Lz=BegOEndO.Z()/Norm_BegOEndO;
-  
+
   Standard_Real Vd=A*Lx+B*Ly+C*Lz;  //-- DirLigne . NormalePlan
-  
+
   if(Vd==0) { //-- Droite parallele au plan 
     return;
   }
-  
-  
+
+
   //-- Calcul du parametre sur la ligne 
   Standard_Real t=-(A*BegO.X()+B*BegO.Y()+C*BegO.Z()+D) / Vd;
-  
+
   Standard_Real tol=1e-8; //-- Deflection sur le triangle
   if(t<-tol || t>(Norm_BegOEndO+tol)) { 
     if(Infinite==Standard_False) {
@@ -695,11 +696,11 @@ void Intf_InterferencePolygonPolyhedron::Intersect
   //-- On a une intersection droite plan 
   //-- On teste si c est dans le triangle 
   gp_Pnt PRes(BegO.X()+t*Lx,BegO.Y()+t*Ly,BegO.Z()+t*Lz);
-  
+
   Standard_Real AbsA=A; if(AbsA<0) AbsA=-AbsA;
   Standard_Real AbsB=B; if(AbsB<0) AbsB=-AbsB;
   Standard_Real AbsC=C; if(AbsC<0) AbsC=-AbsC;
-  
+
   Standard_Real Au,Av,Bu,Bv,Cu,Cv,Pu,Pv;
   if(AbsA>AbsB) { 
     if(AbsA>AbsC) { 
@@ -729,7 +730,7 @@ void Intf_InterferencePolygonPolyhedron::Intersect
   Standard_Real ABu=Bu-Au; Standard_Real ABv=Bv-Av;
   Standard_Real ACu=Cu-Au; Standard_Real ACv=Cv-Av;
   Standard_Real BCu=Cu-Bu; Standard_Real BCv=Cv-Bv;
-  
+
   Standard_Real t1,t2;
   //-- Test sur AB et C
   t1=-ABv*Cu + ABu*Cv;
@@ -748,18 +749,18 @@ void Intf_InterferencePolygonPolyhedron::Intersect
 
 
   Intf_SectionPoint SP(PRes,
-                      Intf_EDGE, 
-                      0, 
-                      iLin, //-- !!!!! VARIABLE STATIQUE 
-                      t / Norm_BegOEndO, 
-                      Intf_FACE, 
-                      TTri, 0, 0.,1.);
+    Intf_EDGE, 
+    0, 
+    iLin, //-- !!!!! VARIABLE STATIQUE 
+    t / Norm_BegOEndO, 
+    Intf_FACE, 
+    TTri, 0, 0.,1.);
   mySPoins.Append(SP);
 }
 #else 
 void Intf_InterferencePolygonPolyhedron::Intersect 
   (const gp_Pnt& BegO, const gp_Pnt& EndO, const Standard_Boolean Infinite,
-   const Standard_Integer TTri, const Polyhedron& thePolyh)
+  const Standard_Integer TTri, const Polyhedron& thePolyh)
 {
   Intf_PIType typOnG=Intf_EDGE;
   Standard_Real t;
@@ -769,9 +770,9 @@ void Intf_InterferencePolygonPolyhedron::Intersect
   Standard_Real triDp;                             // Distance polaire.
 
   Intf::PlaneEquation(ToolPolyh::Point(thePolyh, pTri[0]),
-                     ToolPolyh::Point(thePolyh, pTri[1]),
-                     ToolPolyh::Point(thePolyh, pTri[2]),
-                     triNor, triDp);
+    ToolPolyh::Point(thePolyh, pTri[1]),
+    ToolPolyh::Point(thePolyh, pTri[2]),
+    triNor, triDp);
 
 
   Standard_Real dBegTri=(triNor*BegO.XYZ())-triDp; // Distance <BegO> plan
@@ -786,12 +787,12 @@ void Intf_InterferencePolygonPolyhedron::Intersect
     param = dBegTri/t;
   else param = dBegTri;
   Standard_Real floatgap=Epsilon(1000.);
-  
+
   if (!Infinite) {
     if (dBegTri<=floatgap && dBegTri>=-floatgap ) {
       param=0.;typOnG=Intf_VERTEX;
       if (BeginOfClosedPolygon) 
-       NoIntersectionWithTriangle = Standard_False;
+        NoIntersectionWithTriangle = Standard_False;
     }
     else if (dEndTri<=floatgap && dEndTri>=-floatgap) {
       param=1.;typOnG=Intf_VERTEX;
@@ -810,127 +811,154 @@ void Intf_InterferencePolygonPolyhedron::Intersect
     Standard_Integer tbreak=0;
     { //-- is = 0
       gp_XYZ segT(ToolPolyh::Point(thePolyh, pTri[1]).XYZ()-
-                 ToolPolyh::Point(thePolyh, pTri[0]).XYZ());
+        ToolPolyh::Point(thePolyh, pTri[0]).XYZ());
       gp_XYZ vecP(spLieu-ToolPolyh::Point(thePolyh, pTri[0]).XYZ());
       dPtPi[0]=vecP.Modulus();
       if (dPtPi[0]<=floatgap) {
-       sVertex=0;
-       is=0;
-       tbreak=1;
+        sVertex=0;
+        is=0;
+        tbreak=1;
       }
       else { 
-       gp_XYZ segT_x_vecP(segT^vecP);
-       Standard_Real Modulus_segT_x_vecP = segT_x_vecP.Modulus();
-       sigd = segT_x_vecP*triNor;
-       if(sigd>floatgap) 
-         sigd = 1.0;
-       else if(sigd<-floatgap)
-         sigd = -1.0;
-       else {
-         sigd = 0.0;
-       }
-       dPiE[0]=sigd*(Modulus_segT_x_vecP/segT.Modulus());
-       if (dPiE[0]<=floatgap && dPiE[0]>=-floatgap) {
-         sEdge=0;
-         is=0;
-         tbreak=1;
-       }
+        gp_XYZ segT_x_vecP(segT^vecP);
+        Standard_Real Modulus_segT_x_vecP;
+        if(Precision::IsInfinite(segT_x_vecP.X()) || Precision::IsInfinite(segT_x_vecP.Y()) ||
+          Precision::IsInfinite(segT_x_vecP.Z()))
+        {
+          Modulus_segT_x_vecP = Precision::Infinite();
+        }
+        else
+        {
+          Modulus_segT_x_vecP = segT_x_vecP.Modulus();
+        }
+        sigd = segT_x_vecP*triNor;
+        if(sigd>floatgap) 
+          sigd = 1.0;
+        else if(sigd<-floatgap)
+          sigd = -1.0;
+        else {
+          sigd = 0.0;
+        }
+        dPiE[0]=sigd*(Modulus_segT_x_vecP/segT.Modulus());
+        if (dPiE[0]<=floatgap && dPiE[0]>=-floatgap) {
+          sEdge=0;
+          is=0;
+          tbreak=1;
+        }
       }
     }
 
     if(tbreak==0) { //-- is = 1 
       gp_XYZ segT(ToolPolyh::Point(thePolyh, pTri[2]).XYZ()-
-                 ToolPolyh::Point(thePolyh, pTri[1]).XYZ());
+        ToolPolyh::Point(thePolyh, pTri[1]).XYZ());
       gp_XYZ vecP(spLieu-ToolPolyh::Point(thePolyh, pTri[1]).XYZ());
       dPtPi[1]=vecP.Modulus();
       if (dPtPi[1]<=floatgap) {
-       sVertex=1;
-       is=1;
-       tbreak=1;
+        sVertex=1;
+        is=1;
+        tbreak=1;
       }
       else { 
-       gp_XYZ segT_x_vecP(segT^vecP);
-       Standard_Real Modulus_segT_x_vecP = segT_x_vecP.Modulus();
-       sigd = segT_x_vecP*triNor;
-       if(sigd>floatgap) 
-         sigd = 1.0;
-       else if(sigd<-floatgap)
-         sigd = -1.0;
-       else {
-         sigd = 0.0;
-       }
-       dPiE[1]=sigd*(Modulus_segT_x_vecP/segT.Modulus());
-       if (dPiE[1]<=floatgap && dPiE[1]>=-floatgap) {
-         sEdge=1;
-         is=1;
-         tbreak=1;
-       }
+        gp_XYZ segT_x_vecP(segT^vecP);
+        Standard_Real Modulus_segT_x_vecP;
+        if(Precision::IsInfinite(segT_x_vecP.X()) || Precision::IsInfinite(segT_x_vecP.Y()) ||
+          Precision::IsInfinite(segT_x_vecP.Z()))
+        {
+          Modulus_segT_x_vecP = Precision::Infinite();
+        }
+        else
+        {
+          Modulus_segT_x_vecP = segT_x_vecP.Modulus();
+        }
+        sigd = segT_x_vecP*triNor;
+        if(sigd>floatgap) 
+          sigd = 1.0;
+        else if(sigd<-floatgap)
+          sigd = -1.0;
+        else {
+          sigd = 0.0;
+        }
+        dPiE[1]=sigd*(Modulus_segT_x_vecP/segT.Modulus());
+        if (dPiE[1]<=floatgap && dPiE[1]>=-floatgap) {
+          sEdge=1;
+          is=1;
+          tbreak=1;
+        }
       }
     }
     if(tbreak==0) { //-- is = 2
       gp_XYZ segT(ToolPolyh::Point(thePolyh, pTri[0]).XYZ()-
-                 ToolPolyh::Point(thePolyh, pTri[2]).XYZ());
+        ToolPolyh::Point(thePolyh, pTri[2]).XYZ());
       gp_XYZ vecP(spLieu-ToolPolyh::Point(thePolyh, pTri[2]).XYZ());
       dPtPi[2]=vecP.Modulus();
       if (dPtPi[2]<=floatgap) {
-       sVertex=2;
-       is=2;
+        sVertex=2;
+        is=2;
       }
       gp_XYZ segT_x_vecP(segT^vecP);
-      Standard_Real Modulus_segT_x_vecP = segT_x_vecP.Modulus();
+      Standard_Real Modulus_segT_x_vecP;
+      if(Precision::IsInfinite(segT_x_vecP.X()) || Precision::IsInfinite(segT_x_vecP.Y()) ||
+        Precision::IsInfinite(segT_x_vecP.Z()))
+      {
+        Modulus_segT_x_vecP = Precision::Infinite();
+      }
+      else
+      {
+        Modulus_segT_x_vecP = segT_x_vecP.Modulus();
+      }
       sigd = segT_x_vecP*triNor;
       if(sigd>floatgap) 
-       sigd = 1.0;
+        sigd = 1.0;
       else if(sigd<-floatgap)
-       sigd = -1.0;
+        sigd = -1.0;
       else {
-       sigd = 0.0;
+        sigd = 0.0;
       }
       dPiE[2]=sigd*(Modulus_segT_x_vecP/segT.Modulus());
       if (dPiE[2]<=floatgap && dPiE[2]>=-floatgap) {
-       sEdge=2;
-       is=2;
+        sEdge=2;
+        is=2;
       }
     }
     //-- fin for i=0 to 2
     // !!cout<<endl;
-    
+
     Standard_Integer triCon, pedg;
     if      (sVertex>-1) {
       triCon=TTri;
       pedg=pTri[Pourcent3[sVertex+1]];
-//--      while (triCon!=0) {
-//--   ToolPolyh::TriConnex(thePolyh, triCon,pTri[sVertex],pedg,triCon,pedg);
-//--   //-- if (triCon<TTri) return;
-//--   if (triCon==TTri) break;
-//--      }
+      //--      while (triCon!=0) {
+      //--     ToolPolyh::TriConnex(thePolyh, triCon,pTri[sVertex],pedg,triCon,pedg);
+      //--     //-- if (triCon<TTri) return;
+      //--     if (triCon==TTri) break;
+      //--      }
       Intf_SectionPoint SP(spLieu,
-                          typOnG, 0, iLin, param, 
-                          Intf_VERTEX, pTri[is], 0, 0.,
-                          1.);
+        typOnG, 0, iLin, param, 
+        Intf_VERTEX, pTri[is], 0, 0.,
+        1.);
       mySPoins.Append(SP);
     }
     else if (sEdge>-1) {
       ToolPolyh::TriConnex(thePolyh, TTri, pTri[sEdge], pTri[Pourcent3[sEdge+1]],
-                          triCon, pedg);
+        triCon, pedg);
       //-- if (triCon<=TTri) return; ???????????????????? LBR 
       // !!cout<<" sEdge "<<endl;
       Intf_SectionPoint SP(spLieu,
-                          typOnG, 0, iLin, param, 
-                          Intf_EDGE, Min(pTri[sEdge], pTri[Pourcent3[sEdge+1]]),
-                          Max(pTri[sEdge], pTri[Pourcent3[sEdge+1]]), 0.,
-                          1.);
+        typOnG, 0, iLin, param, 
+        Intf_EDGE, Min(pTri[sEdge], pTri[Pourcent3[sEdge+1]]),
+        Max(pTri[sEdge], pTri[Pourcent3[sEdge+1]]), 0.,
+        1.);
       mySPoins.Append(SP);
     }
     else if (dPiE[0]>0. && dPiE[1]>0. && dPiE[2]>0.) {
       // !!cout<<" 3 Positifs "<<endl;
       Intf_SectionPoint SP(spLieu,
-                          typOnG, 0, iLin, param, 
-                          Intf_FACE, TTri, 0, 0.,
-                          1.);
+        typOnG, 0, iLin, param, 
+        Intf_FACE, TTri, 0, 0.,
+        1.);
       mySPoins.Append(SP);
     }
-//  Modified by Sergey KHROMOV - Fri Dec  7 14:40:11 2001 Begin
+    //  Modified by Sergey KHROMOV - Fri Dec  7 14:40:11 2001 Begin
     // Sometimes triangulation doesn't cover whole the face. In this
     // case it is necessary to take into account the deflection between boundary
     // isolines of the surface and boundary trianles. Computed value of this
@@ -939,54 +967,54 @@ void Intf_InterferencePolygonPolyhedron::Intersect
       Standard_Integer i;
 
       for (i = 1; i <= 3; i++) {
-       Standard_Integer indP1 = (i == 3) ? pTri[0] : pTri[i];
-       Standard_Integer indP2 = pTri[i - 1];
-
-       if (ToolPolyh::IsOnBound(thePolyh, indP1, indP2)) {
-         // For boundary line it is necessary to check the border deflection.
-         Standard_Real  Deflection = ToolPolyh::GetBorderDeflection(thePolyh);
-         const gp_Pnt  &BegP       = ToolPolyh::Point(thePolyh, indP1);
-         const gp_Pnt  &EndP       = ToolPolyh::Point(thePolyh, indP2);
-         gp_Vec         VecTri(BegP,EndP);
-         gp_Dir         DirTri(VecTri);
-         gp_Lin         LinTri(BegP,DirTri);
-         gp_Pnt         aPOnE(spLieu);
-         Standard_Real  aDist = LinTri.Distance(aPOnE);
-
-         if (aDist <= Deflection) {
-           gp_Vec        aVLocPOnE(BegP, aPOnE);
-           gp_Vec        aVecDirTri(DirTri);
-           Standard_Real aPar    = aVLocPOnE*aVecDirTri;
-           Standard_Real aMaxPar = VecTri.Magnitude();
-
-           if (aPar >= 0 && aPar <= aMaxPar) {
-             Intf_SectionPoint SP(spLieu,
-                                  typOnG, 0, iLin, param, 
-                                  Intf_FACE, TTri, 0, 0.,
-                                  1.);
-             mySPoins.Append(SP);
-           }
-         }
-       }
+        Standard_Integer indP1 = (i == 3) ? pTri[0] : pTri[i];
+        Standard_Integer indP2 = pTri[i - 1];
+
+        if (ToolPolyh::IsOnBound(thePolyh, indP1, indP2)) {
+          // For boundary line it is necessary to check the border deflection.
+          Standard_Real  Deflection = ToolPolyh::GetBorderDeflection(thePolyh);
+          const gp_Pnt  &BegP       = ToolPolyh::Point(thePolyh, indP1);
+          const gp_Pnt  &EndP       = ToolPolyh::Point(thePolyh, indP2);
+          gp_Vec         VecTri(BegP,EndP);
+          gp_Dir         DirTri(VecTri);
+          gp_Lin         LinTri(BegP,DirTri);
+          gp_Pnt         aPOnE(spLieu);
+          Standard_Real  aDist = LinTri.Distance(aPOnE);
+
+          if (aDist <= Deflection) {
+            gp_Vec        aVLocPOnE(BegP, aPOnE);
+            gp_Vec        aVecDirTri(DirTri);
+            Standard_Real aPar    = aVLocPOnE*aVecDirTri;
+            Standard_Real aMaxPar = VecTri.Magnitude();
+
+            if (aPar >= 0 && aPar <= aMaxPar) {
+              Intf_SectionPoint SP(spLieu,
+                typOnG, 0, iLin, param, 
+                Intf_FACE, TTri, 0, 0.,
+                1.);
+              mySPoins.Append(SP);
+            }
+          }
+        }
       }
     }
-//  Modified by Sergey KHROMOV - Fri Dec  7 14:40:29 2001 End
+    //  Modified by Sergey KHROMOV - Fri Dec  7 14:40:29 2001 End
   } //---- if(NoIntersectionWithTriangle == Standard_False)
-  
+
   //---------------------------------------------------------------------------
   //-- On teste la distance entre les cotes du triangle et le polygone 
   //-- 
   //-- Si cette distance est inferieure a Tolerance, on cree un SP.
   //--    
   //-- printf("\nIntf_InterferencePolygPolyh : dBegTri=%g dEndTri=%g Tolerance=%g\n",dBegTri,dEndTri,Tolerance);
-//  if(Abs(dBegTri) <= Tolerance || Abs(dEndTri) <= Tolerance)
+  //  if(Abs(dBegTri) <= Tolerance || Abs(dEndTri) <= Tolerance)
   {
     gp_Vec VecPol(BegO,EndO);
     Standard_Real NVecPol = VecPol.Magnitude();
     gp_Dir DirPol(VecPol);
     gp_Lin LinPol(BegO,DirPol);
     Standard_Real dist2,ParamOnO,ParamOnT;
-    
+
     for (Standard_Integer i=0; i<3; i++) {
       Standard_Integer pTri_ip1pc3 = pTri[Pourcent3[i+1]];
       Standard_Integer pTri_i      = pTri[i];
@@ -998,38 +1026,38 @@ void Intf_InterferencePolygonPolyhedron::Intersect
       gp_Lin  LinTri(BegT,DirTri);
       Extrema_ExtElC Extrema(LinPol,LinTri,0.00000001);
       if(Extrema.IsDone()) { 
-       if(Extrema.IsParallel() == Standard_False) { 
-         if(Extrema.NbExt()) { 
-           dist2 = Extrema.SquareDistance();
-           if(dist2<=Tolerance * Tolerance) {
-             Extrema_POnCurv POnC1,POnC2;
-             Extrema.Points(1,POnC1,POnC2);
-             const gp_Pnt& PO = POnC1.Value();
-             const gp_Pnt& PT = POnC2.Value();
-             //--cout<<" ** Nouveau "<<dist2<<endl;
-             if(IsInSegment(VecPol,gp_Vec(BegO,PO),NVecPol,ParamOnO,Tolerance)) {
-               if(IsInSegment(VecTri,gp_Vec(BegT,PT),NVecTri,ParamOnT,Tolerance)) {
-                 //-- cout<<" * "<<endl;
-                 gp_XYZ spLieu=BegT.XYZ()+((EndT.XYZ()-BegT.XYZ())*param);
-                 Standard_Integer tmin,tmax;
-                 if(pTri_i>pTri_ip1pc3) { 
-                   tmin=pTri_ip1pc3; tmax=pTri_i; 
-                 }
-                 else { 
-                   tmax=pTri_ip1pc3; tmin=pTri_i; 
-                 }
-                 Intf_SectionPoint SP(spLieu,
-                                      typOnG, 0, iLin, ParamOnO, 
-                                      Intf_EDGE, 
-                                      tmin, 
-                                      tmax, 0.,
-                                      1.);
-                 mySPoins.Append(SP);
-               }
-             }
-           }
-         }
-       }
+        if(Extrema.IsParallel() == Standard_False) { 
+          if(Extrema.NbExt()) { 
+            dist2 = Extrema.SquareDistance();
+            if(dist2<=Tolerance * Tolerance) {
+              Extrema_POnCurv POnC1,POnC2;
+              Extrema.Points(1,POnC1,POnC2);
+              const gp_Pnt& PO = POnC1.Value();
+              const gp_Pnt& PT = POnC2.Value();
+              //--cout<<" ** Nouveau "<<dist2<<endl;
+              if(IsInSegment(VecPol,gp_Vec(BegO,PO),NVecPol,ParamOnO,Tolerance)) {
+                if(IsInSegment(VecTri,gp_Vec(BegT,PT),NVecTri,ParamOnT,Tolerance)) {
+                  //-- cout<<" * "<<endl;
+                  gp_XYZ spLieu=BegT.XYZ()+((EndT.XYZ()-BegT.XYZ())*param);
+                  Standard_Integer tmin,tmax;
+                  if(pTri_i>pTri_ip1pc3) { 
+                    tmin=pTri_ip1pc3; tmax=pTri_i; 
+                  }
+                  else { 
+                    tmax=pTri_ip1pc3; tmin=pTri_i; 
+                  }
+                  Intf_SectionPoint SP(spLieu,
+                    typOnG, 0, iLin, ParamOnO, 
+                    Intf_EDGE, 
+                    tmin, 
+                    tmax, 0.,
+                    1.);
+                  mySPoins.Append(SP);
+                }
+              }
+            }
+          }
+        }
       }
     }
   } 
@@ -1038,14 +1066,14 @@ void Intf_InterferencePolygonPolyhedron::Intersect
 #endif
 
 void Intf_InterferencePolygonPolyhedron::Intersect (const gp_Pnt& BegO, 
-                                                    const gp_Pnt& EndO, 
-                                                    const Standard_Boolean Infinite,
-                                                    const Standard_Integer TTri, 
-                                                    const Polyhedron& thePolyh, 
-                                                    const gp_XYZ& TriNormal,
-                                                    const Standard_Real /*TriDp*/, 
-                                                    const Standard_Real dBegTri, 
-                                                    const Standard_Real dEndTri)
+  const gp_Pnt& EndO, 
+  const Standard_Boolean Infinite,
+  const Standard_Integer TTri, 
+  const Polyhedron& thePolyh, 
+  const gp_XYZ& TriNormal,
+  const Standard_Real /*TriDp*/, 
+  const Standard_Real dBegTri, 
+  const Standard_Real dEndTri)
 {
   Intf_PIType typOnG=Intf_EDGE;
   Standard_Real t;
@@ -1055,8 +1083,8 @@ void Intf_InterferencePolygonPolyhedron::Intersect (const gp_Pnt& BegO,
   //Standard_Real triDp = TriDp;                             // Distance polaire.
 
 
-//   Standard_Real dBegTri=(triNor*BegO.XYZ())-triDp; // Distance <BegO> plan
-//   Standard_Real dEndTri=(triNor*EndO.XYZ())-triDp; // Distance <EndO> plan
+  //   Standard_Real dBegTri=(triNor*BegO.XYZ())-triDp; // Distance <BegO> plan
+  //   Standard_Real dEndTri=(triNor*EndO.XYZ())-triDp; // Distance <EndO> plan
 
   Standard_Boolean NoIntersectionWithTriangle = Standard_False;
 
@@ -1066,12 +1094,12 @@ void Intf_InterferencePolygonPolyhedron::Intersect (const gp_Pnt& BegO,
     param = dBegTri/t;
   else param = dBegTri;
   Standard_Real floatgap=Epsilon(1000.);
-  
+
   if (!Infinite) {
     if (dBegTri<=floatgap && dBegTri>=-floatgap ) {
       param=0.;typOnG=Intf_VERTEX;
       if (BeginOfClosedPolygon) 
-       NoIntersectionWithTriangle = Standard_False;
+        NoIntersectionWithTriangle = Standard_False;
     }
     else if (dEndTri<=floatgap && dEndTri>=-floatgap) {
       param=1.;typOnG=Intf_VERTEX;
@@ -1090,127 +1118,154 @@ void Intf_InterferencePolygonPolyhedron::Intersect (const gp_Pnt& BegO,
     Standard_Integer tbreak=0;
     { //-- is = 0
       gp_XYZ segT(ToolPolyh::Point(thePolyh, pTri[1]).XYZ()-
-                 ToolPolyh::Point(thePolyh, pTri[0]).XYZ());
+        ToolPolyh::Point(thePolyh, pTri[0]).XYZ());
       gp_XYZ vecP(spLieu-ToolPolyh::Point(thePolyh, pTri[0]).XYZ());
       dPtPi[0]=vecP.Modulus();
       if (dPtPi[0]<=floatgap) {
-       sVertex=0;
-       is=0;
-       tbreak=1;
+        sVertex=0;
+        is=0;
+        tbreak=1;
       }
       else { 
-       gp_XYZ segT_x_vecP(segT^vecP);
-       Standard_Real Modulus_segT_x_vecP = segT_x_vecP.Modulus();
-       sigd = segT_x_vecP*triNor;
-       if(sigd>floatgap) 
-         sigd = 1.0;
-       else if(sigd<-floatgap)
-         sigd = -1.0;
-       else {
-         sigd = 0.0;
-       }
-       dPiE[0]=sigd*(Modulus_segT_x_vecP/segT.Modulus());
-       if (dPiE[0]<=floatgap && dPiE[0]>=-floatgap) {
-         sEdge=0;
-         is=0;
-         tbreak=1;
-       }
+        gp_XYZ segT_x_vecP(segT^vecP);
+        Standard_Real Modulus_segT_x_vecP;
+        if(Precision::IsInfinite(segT_x_vecP.X()) || Precision::IsInfinite(segT_x_vecP.Y()) ||
+          Precision::IsInfinite(segT_x_vecP.Z()))
+        {
+          Modulus_segT_x_vecP = Precision::Infinite();
+        }
+        else
+        {
+          Modulus_segT_x_vecP = segT_x_vecP.Modulus();
+        }
+        sigd = segT_x_vecP*triNor;
+        if(sigd>floatgap) 
+          sigd = 1.0;
+        else if(sigd<-floatgap)
+          sigd = -1.0;
+        else {
+          sigd = 0.0;
+        }
+        dPiE[0]=sigd*(Modulus_segT_x_vecP/segT.Modulus());
+        if (dPiE[0]<=floatgap && dPiE[0]>=-floatgap) {
+          sEdge=0;
+          is=0;
+          tbreak=1;
+        }
       }
     }
-    
+
     if(tbreak==0) { //-- is = 1 
       gp_XYZ segT(ToolPolyh::Point(thePolyh, pTri[2]).XYZ()-
-                 ToolPolyh::Point(thePolyh, pTri[1]).XYZ());
+        ToolPolyh::Point(thePolyh, pTri[1]).XYZ());
       gp_XYZ vecP(spLieu-ToolPolyh::Point(thePolyh, pTri[1]).XYZ());
       dPtPi[1]=vecP.Modulus();
       if (dPtPi[1]<=floatgap) {
-       sVertex=1;
-       is=1;
-       tbreak=1;
+        sVertex=1;
+        is=1;
+        tbreak=1;
       }
       else { 
-       gp_XYZ segT_x_vecP(segT^vecP);
-       Standard_Real Modulus_segT_x_vecP = segT_x_vecP.Modulus();
-       sigd = segT_x_vecP*triNor;
-       if(sigd>floatgap) 
-         sigd = 1.0;
-       else if(sigd<-floatgap)
-         sigd = -1.0;
-       else {
-         sigd = 0.0;
-       }
-       dPiE[1]=sigd*(Modulus_segT_x_vecP/segT.Modulus());
-       if (dPiE[1]<=floatgap && dPiE[1]>=-floatgap) {
-         sEdge=1;
-         is=1;
-         tbreak=1;
-       }
+        gp_XYZ segT_x_vecP(segT^vecP);
+        Standard_Real Modulus_segT_x_vecP;
+        if(Precision::IsInfinite(segT_x_vecP.X()) || Precision::IsInfinite(segT_x_vecP.Y()) ||
+          Precision::IsInfinite(segT_x_vecP.Z()))
+        {
+          Modulus_segT_x_vecP = Precision::Infinite();
+        }
+        else
+        {
+          Modulus_segT_x_vecP = segT_x_vecP.Modulus();
+        }
+        sigd = segT_x_vecP*triNor;
+        if(sigd>floatgap) 
+          sigd = 1.0;
+        else if(sigd<-floatgap)
+          sigd = -1.0;
+        else {
+          sigd = 0.0;
+        }
+        dPiE[1]=sigd*(Modulus_segT_x_vecP/segT.Modulus());
+        if (dPiE[1]<=floatgap && dPiE[1]>=-floatgap) {
+          sEdge=1;
+          is=1;
+          tbreak=1;
+        }
       }
     }
     if(tbreak==0) { //-- is = 2
       gp_XYZ segT(ToolPolyh::Point(thePolyh, pTri[0]).XYZ()-
-                 ToolPolyh::Point(thePolyh, pTri[2]).XYZ());
+        ToolPolyh::Point(thePolyh, pTri[2]).XYZ());
       gp_XYZ vecP(spLieu-ToolPolyh::Point(thePolyh, pTri[2]).XYZ());
       dPtPi[2]=vecP.Modulus();
       if (dPtPi[2]<=floatgap) {
-       sVertex=2;
-       is=2;
+        sVertex=2;
+        is=2;
       }
       gp_XYZ segT_x_vecP(segT^vecP);
-      Standard_Real Modulus_segT_x_vecP = segT_x_vecP.Modulus();
+      Standard_Real Modulus_segT_x_vecP;
+      if(Precision::IsInfinite(segT_x_vecP.X()) || Precision::IsInfinite(segT_x_vecP.Y()) ||
+        Precision::IsInfinite(segT_x_vecP.Z()))
+      {
+        Modulus_segT_x_vecP = Precision::Infinite();
+      }
+      else
+      {
+        Modulus_segT_x_vecP = segT_x_vecP.Modulus();
+      }
       sigd = segT_x_vecP*triNor;
       if(sigd>floatgap) 
-       sigd = 1.0;
+        sigd = 1.0;
       else if(sigd<-floatgap)
-       sigd = -1.0;
+        sigd = -1.0;
       else {
-       sigd = 0.0;
+        sigd = 0.0;
       }
       dPiE[2]=sigd*(Modulus_segT_x_vecP/segT.Modulus());
       if (dPiE[2]<=floatgap && dPiE[2]>=-floatgap) {
-       sEdge=2;
-       is=2;
+        sEdge=2;
+        is=2;
       }
     }
     //-- fin for i=0 to 2
     // !!cout<<endl;
-    
+
     Standard_Integer triCon, pedg;
     if      (sVertex>-1) {
       triCon=TTri;
       pedg=pTri[Pourcent3[sVertex+1]];
-//--      while (triCon!=0) {
-//--   ToolPolyh::TriConnex(thePolyh, triCon,pTri[sVertex],pedg,triCon,pedg);
-//--   //-- if (triCon<TTri) return;
-//--   if (triCon==TTri) break;
-//--      }
+      //--      while (triCon!=0) {
+      //--     ToolPolyh::TriConnex(thePolyh, triCon,pTri[sVertex],pedg,triCon,pedg);
+      //--     //-- if (triCon<TTri) return;
+      //--     if (triCon==TTri) break;
+      //--      }
       Intf_SectionPoint SP(spLieu,
-                          typOnG, 0, iLin, param, 
-                          Intf_VERTEX, pTri[is], 0, 0.,
-                          1.);
+        typOnG, 0, iLin, param, 
+        Intf_VERTEX, pTri[is], 0, 0.,
+        1.);
       mySPoins.Append(SP);
     }
     else if (sEdge>-1) {
       ToolPolyh::TriConnex(thePolyh, TTri, pTri[sEdge], pTri[Pourcent3[sEdge+1]],
-                          triCon, pedg);
+        triCon, pedg);
       //-- if (triCon<=TTri) return; ???????????????????? LBR 
       // !!cout<<" sEdge "<<endl;
       Intf_SectionPoint SP(spLieu,
-                          typOnG, 0, iLin, param, 
-                          Intf_EDGE, Min(pTri[sEdge], pTri[Pourcent3[sEdge+1]]),
-                          Max(pTri[sEdge], pTri[Pourcent3[sEdge+1]]), 0.,
-                          1.);
+        typOnG, 0, iLin, param, 
+        Intf_EDGE, Min(pTri[sEdge], pTri[Pourcent3[sEdge+1]]),
+        Max(pTri[sEdge], pTri[Pourcent3[sEdge+1]]), 0.,
+        1.);
       mySPoins.Append(SP);
     }
     else if (dPiE[0]>0. && dPiE[1]>0. && dPiE[2]>0.) {
       // !!cout<<" 3 Positifs "<<endl;
       Intf_SectionPoint SP(spLieu,
-                          typOnG, 0, iLin, param, 
-                          Intf_FACE, TTri, 0, 0.,
-                          1.);
+        typOnG, 0, iLin, param, 
+        Intf_FACE, TTri, 0, 0.,
+        1.);
       mySPoins.Append(SP);
     }
-//  Modified by Sergey KHROMOV - Fri Dec  7 14:40:11 2001 Begin
+    //  Modified by Sergey KHROMOV - Fri Dec  7 14:40:11 2001 Begin
     // Sometimes triangulation doesn't cover whole the face. In this
     // case it is necessary to take into account the deflection between boundary
     // isolines of the surface and boundary trianles. Computed value of this
@@ -1219,54 +1274,54 @@ void Intf_InterferencePolygonPolyhedron::Intersect (const gp_Pnt& BegO,
       Standard_Integer i;
 
       for (i = 1; i <= 3; i++) {
-       Standard_Integer indP1 = (i == 3) ? pTri[0] : pTri[i];
-       Standard_Integer indP2 = pTri[i - 1];
-
-       if (ToolPolyh::IsOnBound(thePolyh, indP1, indP2)) {
-         // For boundary line it is necessary to check the border deflection.
-         Standard_Real  Deflection = ToolPolyh::GetBorderDeflection(thePolyh);
-         const gp_Pnt  &BegP       = ToolPolyh::Point(thePolyh, indP1);
-         const gp_Pnt  &EndP       = ToolPolyh::Point(thePolyh, indP2);
-         gp_Vec         VecTri(BegP,EndP);
-         gp_Dir         DirTri(VecTri);
-         gp_Lin         LinTri(BegP,DirTri);
-         gp_Pnt         aPOnE(spLieu);
-         Standard_Real  aDist = LinTri.Distance(aPOnE);
-
-         if (aDist <= Deflection) {
-           gp_Vec        aVLocPOnE(BegP, aPOnE);
-           gp_Vec        aVecDirTri(DirTri);
-           Standard_Real aPar    = aVLocPOnE*aVecDirTri;
-           Standard_Real aMaxPar = VecTri.Magnitude();
-
-           if (aPar >= 0 && aPar <= aMaxPar) {
-             Intf_SectionPoint SP(spLieu,
-                                  typOnG, 0, iLin, param, 
-                                  Intf_FACE, TTri, 0, 0.,
-                                  1.);
-             mySPoins.Append(SP);
-           }
-         }
-       }
+        Standard_Integer indP1 = (i == 3) ? pTri[0] : pTri[i];
+        Standard_Integer indP2 = pTri[i - 1];
+
+        if (ToolPolyh::IsOnBound(thePolyh, indP1, indP2)) {
+          // For boundary line it is necessary to check the border deflection.
+          Standard_Real  Deflection = ToolPolyh::GetBorderDeflection(thePolyh);
+          const gp_Pnt  &BegP       = ToolPolyh::Point(thePolyh, indP1);
+          const gp_Pnt  &EndP       = ToolPolyh::Point(thePolyh, indP2);
+          gp_Vec         VecTri(BegP,EndP);
+          gp_Dir         DirTri(VecTri);
+          gp_Lin         LinTri(BegP,DirTri);
+          gp_Pnt         aPOnE(spLieu);
+          Standard_Real  aDist = LinTri.Distance(aPOnE);
+
+          if (aDist <= Deflection) {
+            gp_Vec        aVLocPOnE(BegP, aPOnE);
+            gp_Vec        aVecDirTri(DirTri);
+            Standard_Real aPar    = aVLocPOnE*aVecDirTri;
+            Standard_Real aMaxPar = VecTri.Magnitude();
+
+            if (aPar >= 0 && aPar <= aMaxPar) {
+              Intf_SectionPoint SP(spLieu,
+                typOnG, 0, iLin, param, 
+                Intf_FACE, TTri, 0, 0.,
+                1.);
+              mySPoins.Append(SP);
+            }
+          }
+        }
       }
     }
-//  Modified by Sergey KHROMOV - Fri Dec  7 14:40:29 2001 End
+    //  Modified by Sergey KHROMOV - Fri Dec  7 14:40:29 2001 End
   } //---- if(NoIntersectionWithTriangle == Standard_False)
-  
+
   //---------------------------------------------------------------------------
   //-- On teste la distance entre les cotes du triangle et le polygone 
   //-- 
   //-- Si cette distance est inferieure a Tolerance, on cree un SP.
   //--    
   //-- printf("\nIntf_InterferencePolygPolyh : dBegTri=%g dEndTri=%g Tolerance=%g\n",dBegTri,dEndTri,Tolerance);
-//  if (Abs(dBegTri) <= Tolerance || Abs(dEndTri) <= Tolerance)
+  //  if (Abs(dBegTri) <= Tolerance || Abs(dEndTri) <= Tolerance)
   {
     gp_Vec VecPol(BegO,EndO);
     Standard_Real NVecPol = VecPol.Magnitude();
     gp_Dir DirPol(VecPol);
     gp_Lin LinPol(BegO,DirPol);
     Standard_Real dist2,ParamOnO,ParamOnT;
-    
+
     for (Standard_Integer i=0; i<3; i++) {
       Standard_Integer pTri_ip1pc3 = pTri[Pourcent3[i+1]];
       Standard_Integer pTri_i      = pTri[i];
@@ -1278,38 +1333,38 @@ void Intf_InterferencePolygonPolyhedron::Intersect (const gp_Pnt& BegO,
       gp_Lin  LinTri(BegT,DirTri);
       Extrema_ExtElC Extrema(LinPol,LinTri,0.00000001);
       if(Extrema.IsDone()) { 
-       if(Extrema.IsParallel() == Standard_False) { 
-         if(Extrema.NbExt()) { 
-           dist2 = Extrema.SquareDistance();
-           if(dist2<=Tolerance * Tolerance) {
-             Extrema_POnCurv POnC1,POnC2;
-             Extrema.Points(1,POnC1,POnC2);
-             const gp_Pnt& PO = POnC1.Value();
-             const gp_Pnt& PT = POnC2.Value();
-             //--cout<<" ** Nouveau "<<dist2<<endl;
-             if(IsInSegment(VecPol,gp_Vec(BegO,PO),NVecPol,ParamOnO,Tolerance)) {
-               if(IsInSegment(VecTri,gp_Vec(BegT,PT),NVecTri,ParamOnT,Tolerance)) {
-                 //-- cout<<" * "<<endl;
-                 gp_XYZ spLieu=BegT.XYZ()+((EndT.XYZ()-BegT.XYZ())*param);
-                 Standard_Integer tmin,tmax;
-                 if(pTri_i>pTri_ip1pc3) { 
-                   tmin=pTri_ip1pc3; tmax=pTri_i; 
-                 }
-                 else { 
-                   tmax=pTri_ip1pc3; tmin=pTri_i; 
-                 }
-                 Intf_SectionPoint SP(spLieu,
-                                      typOnG, 0, iLin, ParamOnO, 
-                                      Intf_EDGE, 
-                                      tmin, 
-                                      tmax, 0.,
-                                      1.);
-                 mySPoins.Append(SP);
-               }
-             }
-           }
-         }
-       }
+        if(Extrema.IsParallel() == Standard_False) { 
+          if(Extrema.NbExt()) { 
+            dist2 = Extrema.SquareDistance();
+            if(dist2<=Tolerance * Tolerance) {
+              Extrema_POnCurv POnC1,POnC2;
+              Extrema.Points(1,POnC1,POnC2);
+              const gp_Pnt& PO = POnC1.Value();
+              const gp_Pnt& PT = POnC2.Value();
+              //--cout<<" ** Nouveau "<<dist2<<endl;
+              if(IsInSegment(VecPol,gp_Vec(BegO,PO),NVecPol,ParamOnO,Tolerance)) {
+                if(IsInSegment(VecTri,gp_Vec(BegT,PT),NVecTri,ParamOnT,Tolerance)) {
+                  //-- cout<<" * "<<endl;
+                  gp_XYZ spLieu=BegT.XYZ()+((EndT.XYZ()-BegT.XYZ())*param);
+                  Standard_Integer tmin,tmax;
+                  if(pTri_i>pTri_ip1pc3) { 
+                    tmin=pTri_ip1pc3; tmax=pTri_i; 
+                  }
+                  else { 
+                    tmax=pTri_ip1pc3; tmin=pTri_i; 
+                  }
+                  Intf_SectionPoint SP(spLieu,
+                    typOnG, 0, iLin, ParamOnO, 
+                    Intf_EDGE, 
+                    tmin, 
+                    tmax, 0.,
+                    1.);
+                  mySPoins.Append(SP);
+                }
+              }
+            }
+          }
+        }
       }
     }
   } 
index 4b410a518d1e48fbd2cc0bececddee5b7ac0ace2..597597e066e4c85020321c58e571ffa21481a8fc 100644 (file)
@@ -1508,7 +1508,14 @@ Handle(Geom2d_BSplineCurve)
   Standard_Real DistTol3d = 1.0*Tol3d;
   Standard_Real TolU = Surf->UResolution(Tol3d), TolV = Surf->VResolution(Tol3d);
   Standard_Real Tol2d = Max(Sqrt(TolU*TolU + TolV*TolV), Precision::PConfusion());
+  //
+  Standard_Real BigTol3d = 10.;
 
+  if(Tol3d > BigTol3d)
+  {
+    Tol2d = Max(Tol2d, 0.01 * Tol3d);//0.01 = PConfusion/Confusion
+  }
+  //
   Standard_Integer i;
   GeomAbs_SurfaceType TheTypeS = Surf->GetType();
   GeomAbs_CurveType TheTypeC = Curve->GetType();
index 84784786f6215389f8581d2828529ccebad52d5e..769a3a893c1c621825b5165ab84980961bac1c65 100644 (file)
@@ -2406,7 +2406,7 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
       di << "\n";
       Standard_Integer res, a =4, b = 0 ;
       res = a / b;
-      di << " 4 / 0 = " << res << "  Does not Caught... KO\n";
+      di << "Error: 4 / 0 = " << res << " - no exception is raised!\n";
       Succes = Standard_False;
     }
 #if defined(SOLARIS) || defined(_WIN32)
@@ -2415,10 +2415,9 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
     catch(Standard_NumericError)
 #endif
     {
-      di << " Ok\n";
+      di << "Caught, OK\n";
     }
     catch(Standard_Failure) {
-      //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
       di << " Caught (";
       di << Standard_Failure::Caught()->GetMessageString();
       di << ")... KO\n";
@@ -2442,17 +2441,16 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
       di << "\n";
       Standard_Real res, a= 4.0, b=0.0;
       res = a / b;
-      di << " 4.0 / 0.0 = " << res << "  Does not Caught... OK\n";
+      di << "Error: 4.0 / 0.0 = " << res << " - no exception is raised!\n";
+      Succes = Standard_False;
     }
     catch(Standard_DivideByZero) // Solaris, Windows w/o SSE2
     {
-      di << " KO\n";
-      Succes = Standard_False;
+      di << "Caught, OK\n";
     }
     catch(Standard_NumericError) // Linux, Windows with SSE2
     {
-      di << " KO\n";
-      Succes = Standard_False;
+      di << "Exception is caught, OK\n";
     }
     catch(Standard_Failure) {
       //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
@@ -2474,10 +2472,10 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
       res = i + 1;
       //++++ cout << " -- "<<res<<"="<<i<<"+1   Does not Caught... KO"<< endl;
       //++++ Succes = Standard_False;
-      di << " "<<res<<"="<<i<<"+1  Does not Caught... (But) Ok\n";
+      di << "Not caught: " << i << " + 1 = " << res << ", still OK\n";
     }
     catch(Standard_Overflow) {
-      di << " Ok\n";
+      di << "Caught, OK\n";
     }
     catch(Standard_Failure) {
       //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
@@ -2500,17 +2498,16 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
       
       (void)sin(1.); //this function tests FPU flags and raises signal (tested on LINUX).
 
-      di << "-- "<<res<<"="<<r<<"*"<<r<<"   Does not Caught... OK\n";
+      di << "Error: " << r << "*" << r << " = " << res << " - no exception is raised!\n";
+      Succes = Standard_False;
     }
     catch(Standard_Overflow) // Solaris, Windows w/o SSE2
     {
-      di << " KO\n";
-      Succes = Standard_False;
+      di << "Caught, OK\n";
     }
     catch(Standard_NumericError) // Linux, Windows with SSE2
     {
-      di << " KO\n";
-      Succes = Standard_False;
+      di << "Caught, OK\n";
     }
     catch(Standard_Failure) {
       //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
@@ -2533,16 +2530,16 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
       //res = res + 1.;
       //++++ cout<<"-- "<<res<<"="<<r<<"*"<<r<<"   Does not Caught... KO"<<endl;
       //++++ Succes = Standard_False;
-      di<<" -- "<<res<<"="<<r<<"*"<<r<<"   Does not Caught... (But) Ok\n";
+      di << "Not caught: " << r << "*" << r << " = " << res << ", still OK\n";
     }
     catch(Standard_Underflow) // could be on Solaris, Windows w/o SSE2
     {
-      di << " KO\n";
+      di << "Exception caught, KO\n";
       Succes = Standard_False;
     }
     catch(Standard_NumericError) // could be on Linux, Windows with SSE2
     {
-      di << " KO\n";
+      di << "Exception caught, KO\n";
       Succes = Standard_False;
     }
     catch(Standard_Failure) {
@@ -2563,11 +2560,11 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
       di << "\n";
       Standard_Real res, r=-1;
       res = sqrt(r);
-      di<<" "<<res<<"=sqrt("<<r<<")  Does not Caught... OK\n";
+      di << "Error: swrt(-1) = " << res << " - no exception is raised!\n";
+      Succes = Standard_False;
     }
     catch(Standard_NumericError) {
-      di << " KO\n";
-      Succes = Standard_False;
+      di << "Caught, OK\n";
     }
     catch(Standard_Failure) {
       //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
@@ -2587,7 +2584,7 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
       di << "\n";
       int* pint=NULL;
       *pint = 4;
-      di << "  Does not Caught... KO\n";
+      di << "Error: writing by NULL address - no exception is raised!\n";
       Succes = Standard_False;
     }
 #ifdef _WIN32
@@ -2596,7 +2593,7 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
     catch(OSD_SIGSEGV)
 #endif
     {
-      di << " Ok\n";
+      di << "Caught, OK\n";
     } catch(Standard_Failure) {
       //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
       di << " Caught (";
@@ -2615,11 +2612,11 @@ static Standard_Integer OCC6143 (Draw_Interpretor& di, Standard_Integer argc, co
       //cout.flush();
       di << "\n";
       StackOverflow();
-      di << "  Does not Caught... KO\n";
+      di << "Error - no exception is raised!\n";
       Succes = Standard_False;
     }
     catch(OSD_Exception_STACK_OVERFLOW) {
-      di << " Ok\n";
+      di << "Caught, OK\n";
     }
     catch(Standard_Failure) {
       //cout << " Caught (" << Standard_Failure::Caught() << ")... KO" << endl;
index 2611cd42464397994cff3d083f4d86ed688c1bc5..128eb3e3dc374ee060ba0cad908a16d1666a320b 100644 (file)
@@ -810,7 +810,7 @@ Standard_Boolean ShapeAnalysis_Surface::SurfaceNewton(const gp_Pnt2d &p2dPrev,
     Standard_Real ru2 = ru * ru, rv2 = rv * rv;
     gp_Vec n = ru ^ rv;
     Standard_Real nrm2 = n.SquareMagnitude();
-    if ( nrm2 < 1e-10 ) break; // n == 0, use standard
+    if ( nrm2 < 1e-10 || Precision::IsPositiveInfinite(nrm2)) break; // n == 0, use standard
 
     // descriminant
     gp_Vec rs = P3D.XYZ() - Value ( U, V ).XYZ();
index dca87ddd0eb81659bc3e4efb5b519b32d0acb522..d3403f982e63c85e40ea8e37193ae29c024c8e19 100644 (file)
@@ -296,7 +296,21 @@ void ShapeAnalysis_TransferParametersProj::TransferRange(TopoDS_Edge& newEdge,
   }
   if(Is2d) {
     p1 = myAC3d.Value(firstPar).Transformed(myLocation);
+    if(Precision::IsInfinite(p1.X()) || Precision::IsInfinite(p1.Y()) ||
+       Precision::IsInfinite(p1.Z()))
+    {
+      samerange = Standard_False;
+      B.SameRange(newEdge, samerange);
+      return;
+    }
     p2 = myAC3d.Value(lastPar).Transformed(myLocation);
+    if(Precision::IsInfinite(p2.X()) || Precision::IsInfinite(p2.Y()) ||
+       Precision::IsInfinite(p2.Z()))
+    {
+      samerange = Standard_False;
+      B.SameRange(newEdge, samerange);
+      return;
+    }
     Standard_Real fact = myAC3d.LastParameter() - myAC3d.FirstParameter();
     if( fact > Epsilon(myAC3d.LastParameter()) ) {
       alpha = ( firstPar - myAC3d.FirstParameter() ) / fact;
@@ -305,7 +319,21 @@ void ShapeAnalysis_TransferParametersProj::TransferRange(TopoDS_Edge& newEdge,
   }
   else {
     p1 = myCurve->Value(firstPar);
+    if(Precision::IsInfinite(p1.X()) || Precision::IsInfinite(p1.Y()) ||
+       Precision::IsInfinite(p1.Z()))
+    {
+      samerange = Standard_False;
+      B.SameRange(newEdge, samerange);
+      return;
+    }
     p2 = myCurve->Value(lastPar);
+    if(Precision::IsInfinite(p2.X()) || Precision::IsInfinite(p2.Y()) ||
+       Precision::IsInfinite(p2.Z()))
+    {
+      samerange = Standard_False;
+      B.SameRange(newEdge, samerange);
+      return;
+    }
     Standard_Real fact = myLast - myFirst;
     if( fact > Epsilon(myLast) ) {
       alpha = ( firstPar - myFirst ) / fact;
index 8032e2f5e2b841be9c22441b74e9706f1e64cb6c..e8ef6766b34352bedf4f9372b50820cbe3f526cb 100644 (file)
@@ -1763,6 +1763,10 @@ Standard_Boolean ShapeAnalysis_Wire::CheckSmallArea(const TopoDS_Wire& theWire,
       myStatus = ShapeExtend::EncodeStatus (ShapeExtend_FAIL2);
       return Standard_False;
     }
+    if (Precision::IsInfinite(aF) || Precision::IsInfinite(aL))
+    {
+      continue;
+    }
 
     Standard_Integer aBegin = 0;
     if (j == 1)
index 1fc1cb1f21440b4a7e316a2544535d9dafacb66a..35d6ad682d054d5ab218abecf4777a46f9213e62 100644 (file)
@@ -328,7 +328,7 @@ Standard_Boolean ShapeConstruct_ProjectCurveOnSurface::Perform (Handle(Geom_Curv
         aMinParSpeed = Min(aMinParSpeed, aDist / aStep);
       }
       const Standard_Real aCoeff = aLength3d / (aLastParam - aFirstParam);
-      if (Abs(aCoeff) > gp::Resolution())
+      if (aCoeff > gp::Resolution())
         aKnotCoeffs.Append(aCoeff);
       aFirstParam = aLastParam;
     }
index 08b00654459991259067b7bd559bc6536cf41606..e19cd9b7d332ee742f0c2b25624f51be03ddde9a 100644 (file)
@@ -43,6 +43,8 @@
 #include <TopoDS_Edge.hxx>
 #include <TopoDS_Face.hxx>
 #include <TopoDS_Vertex.hxx>
+#include <Adaptor3d_HCurve.hxx>
+#include <BSplCLib.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(ShapeFix_EdgeProjAux,MMgt_TShared)
 
@@ -281,8 +283,26 @@ void ShapeFix_EdgeProjAux::Init2d (const Standard_Real preci)
     if(theCurve2d->IsKind(STANDARD_TYPE(Geom2d_Line))) {
       Standard_Real uf,ul,vf,vl;
       theSurface->Bounds(uf,ul,vf,vl);
+      //Correct surface limits for extrusion/revolution surfaces based on hyperbola
+      //23 is ln(1.0e+10)
+      if(SA.GetType() == GeomAbs_SurfaceOfExtrusion)
+      {
+        if(SA.BasisCurve()->GetType() == GeomAbs_Hyperbola)
+        {
+          uf = Max(uf, -23.);
+          ul = Min(ul,  23.);
+        }
+      }
+      if(SA.GetType() == GeomAbs_SurfaceOfRevolution)
+      {
+        if(SA.BasisCurve()->GetType() == GeomAbs_Hyperbola)
+        {
+          vf = Max(vf, -23.);
+          vl = Min(vl,  23.);
+        }
+      }
       if(!Precision::IsInfinite(uf)&&!Precision::IsInfinite(ul)&&
-        !Precision::IsInfinite(vf)&&!Precision::IsInfinite(vl)) {
+         !Precision::IsInfinite(vf)&&!Precision::IsInfinite(vl)) {
           Standard_Real cfi,cli;
           Handle(Geom2d_Line) lin = Handle(Geom2d_Line)::DownCast(theCurve2d);
           gp_Pnt2d pnt = lin->Location();
@@ -343,6 +363,17 @@ void ShapeFix_EdgeProjAux::Init2d (const Standard_Real preci)
       //pdn not linear case not managed
       cf=-10000;
       cl= 10000;
+      if(theCurve2d->IsKind(STANDARD_TYPE(Geom2d_BSplineCurve)))
+      {
+        //Try to reparametrize (CASE dxf read bug25899)
+        Handle(Geom2d_BSplineCurve) aBspl = Handle(Geom2d_BSplineCurve)::DownCast(theCurve2d->Copy());
+        TColStd_Array1OfReal aNewKnots(1, aBspl->NbKnots());  
+        aBspl->Knots(aNewKnots);
+        BSplCLib::Reparametrize(cf, cl, aNewKnots);
+        aBspl->SetKnots(aNewKnots);
+        theCurve2d = aBspl;
+      }
+
 #ifdef OCCT_DEBUG
       cout<<"Some infinite curve"<<endl;
 #endif 
index 8345a8117da7d218ea97b3a5a5fa0e50c8fc085e..0c9733485a2bc6327adb1a9295d3255b15275a4e 100644 (file)
@@ -265,6 +265,34 @@ Standard_Real     ACosh (const Standard_Real Value)
 #endif
 }
 
+//-------------------------------------------------------------------
+// Cosh : Returns the hyperbolic cosine of a real
+//-------------------------------------------------------------------
+Standard_Real     Cosh (const Standard_Real Value) 
+{ 
+  if ( Abs(Value) > 0.71047586007394394e+03 ){
+    Standard_NumericError::Raise("Result of Cosh exceeds the maximum value Standard_Real");
+#ifdef OCCT_DEBUG
+    cout << "Result of Cosh exceeds the maximum value Standard_Real" << endl ;
+#endif
+  } 
+  return cosh(Value); 
+}
+
+//-------------------------------------------------------------------
+// Sinh : Returns the hyperbolicsine of a real
+//-------------------------------------------------------------------
+Standard_Real     Sinh (const Standard_Real Value) 
+{ 
+  if ( Abs(Value) > 0.71047586007394394e+03 ){
+    Standard_NumericError::Raise("Result of Sinh exceeds the maximum value Standard_Real");
+#ifdef OCCT_DEBUG
+    cout << "Result of Sinh exceeds the maximum value Standard_Real" << endl ;
+#endif
+  } 
+  return sinh(Value); 
+}
+
 //-------------------------------------------------------------------
 // Log : Returns the naturaOPl logarithm of a real
 //-------------------------------------------------------------------
index 6ce243eebd24c2387f3716ce733a7c529cccd22b..84e84e08325e962f0bc4be1c3e33dd68635c8711 100644 (file)
@@ -40,6 +40,8 @@ __Standard_API Standard_Real    NextAfter   (const Standard_Real , const Standar
 __Standard_API Standard_Real    Sign        (const Standard_Real , const Standard_Real );
 __Standard_API Standard_Real    ATanh       (const Standard_Real );
 __Standard_API Standard_Real    ACosh       (const Standard_Real );
+__Standard_API Standard_Real    Sinh       (const Standard_Real );
+__Standard_API Standard_Real    Cosh       (const Standard_Real );
 __Standard_API Standard_Real    Log         (const Standard_Real );
 __Standard_API Standard_Real    Sqrt        (const Standard_Real );
 
@@ -161,12 +163,6 @@ inline Standard_Real     Ceiling (const Standard_Real Value)
 inline Standard_Real     Cos (const Standard_Real Value) 
 { return cos(Value); }
 
-//-------------------------------------------------------------------
-// Cosh : Returns the hyperbolic cosine of a real
-//-------------------------------------------------------------------
-inline Standard_Real     Cosh (const Standard_Real Value) 
-{ return cosh(Value); }
-
 
 //-------------------------------------------------------------------
 // Epsilon : The function returns absolute value of difference
@@ -285,11 +281,6 @@ inline Standard_Real     Round (const Standard_Real Value)
 inline Standard_Real     Sin (const Standard_Real Value) 
 { return sin(Value); }
 
-//-------------------------------------------------------------------
-// Sinh : Returns the hyperbolic sine of a real
-//-------------------------------------------------------------------
-inline Standard_Real     Sinh(const Standard_Real Value) 
-{ return sinh(Value); }
 
 //-------------------------------------------------------------------
 // ASinh : Returns the hyperbolic arc sine of a real
index f0b3482391b00b7160f8b24525df538471c8808a..566701417897013bc3fb3f852374dff29c750d37 100644 (file)
@@ -963,14 +963,28 @@ static Standard_Integer meshvectors( Draw_Interpretor& di,
     for ( ; anIter.More(); anIter.Next() )
     {
       TColStd_Array1OfReal aCoords(1, 3);
+      aCoords(1) = 0.;
+      aCoords(2) = 0.;
+      aCoords(3) = 0.;
+      Standard_Boolean IsValidData = Standard_False; 
       if (anIsElement)
-        aMesh->GetDataSource()->GetNormal(anIter.Key(), 3, aCoords.ChangeValue(1), aCoords.ChangeValue(2), aCoords.ChangeValue(3));
+        IsValidData = aMesh->GetDataSource()->GetNormal(anIter.Key(), 3, aCoords.ChangeValue(1), aCoords.ChangeValue(2), aCoords.ChangeValue(3));
       else
-        aMesh->GetDataSource()->GetGeom(anIter.Key(), Standard_False, aCoords, aNbNodes, aEntType);
+        IsValidData = aMesh->GetDataSource()->GetGeom(anIter.Key(), Standard_False, aCoords, aNbNodes, aEntType);
 
-      gp_Vec aNorm = gp_Vec(aCoords.Value(1), aCoords.Value(2), aCoords.Value(3));
-      if( !aNorm.Magnitude() )
+      gp_Vec aNorm;
+      if(IsValidData)
+      { 
+        aNorm = gp_Vec(aCoords.Value(1), aCoords.Value(2), aCoords.Value(3));
+        if(aNorm.Magnitude() < gp::Resolution())
+        {
+          aNorm = gp_Vec(0,0,1); //method GetGeom(...) returns coordinates of nodes
+        }
+      }
+      else
+      {
         aNorm = gp_Vec(0,0,1);
+      }
       aBuilder->SetVector(anIsElement, anIter.Key(), aNorm.Normalized());
     }
 
index aa41d3dadb72eb741ff0a280812cd9f525471a6d..d2d6a6783ed7ea5b3e8ce3d0e62af12048082691 100644 (file)
@@ -254,6 +254,10 @@ static Standard_Boolean MinimizeDirection(const math_Vector&   P,
                                           //----------------------------------------------------------------------
 
 {
+  if(Precision::IsInfinite(PValue) || Precision::IsInfinite(PDirValue))
+  {
+    return Standard_False;
+  }
   // (0) Evaluation d'un tolerance parametrique 1D
   Standard_Boolean good = Standard_False;
   Standard_Real Eps = 1.e-20;
@@ -718,7 +722,25 @@ void math_FunctionSetRoot::Perform(math_FunctionSetWithDerivatives& F,
   for (i = 1; i <= Ninc ; i++) {
     // modified by NIZHNY-MKK  Mon Oct  3 18:03:50 2005
     //      InvLengthMax(i) = 1. / Max(Abs(SupBound(i) - InfBound(i))/4, 1.e-9);
-    InvLengthMax(i) = 1. / Max((theSupBound(i) - theInfBound(i))/4, 1.e-9);
+    Standard_Real SupBound = theSupBound(i), InfBound = theInfBound(i);
+    if(Precision::IsNegativeInfinite(SupBound))
+    {
+      SupBound = -Precision::Infinite();
+    }
+    else if(Precision::IsPositiveInfinite(SupBound))
+    {
+      SupBound = Precision::Infinite();
+    }
+    if(Precision::IsNegativeInfinite(InfBound))
+    {
+      InfBound = -Precision::Infinite();
+    }
+    else if(Precision::IsPositiveInfinite(InfBound))
+    {
+      InfBound = Precision::Infinite();
+    }
+
+    InvLengthMax(i) = 1. / Max((SupBound - InfBound)/4, 1.e-9);
   }
 
   MyDirFunction F_Dir(Temp1, Temp2, Temp3, Temp4, F);
index 3e1ffff6e91d1cc496f0f72935c68e48cea1838e..4f6efef41a3e0ca5ae2cbd900bd14d2e1898fc34 100644 (file)
@@ -1,4 +1,6 @@
 puts "TODO OCC24156 MacOS: Faulty OCC6143"
+puts "TODO OCC27713 Linux: Faulty OCC6143"
+puts "TODO OCC27713 Linux: Error"
 
 puts "================"
 puts "OCC1723"
index ee0042c42d7185b57d8d1bdc3c1df7a072df97c5..c9d306eb3144368537cccad89c395ba2a63c7907 100755 (executable)
@@ -31,4 +31,4 @@ vfit
 vsetdispmode 1
 
 checkview -screenshot -3d -path ${imagedir}/${test_image}.png
-checkprops result -s 9951.34
+checkprops result -s 9994.76
index 5c5f4e790464c5f7262e68be072f9447272f10fc..4db409e01eb627cf0d981c96c1e3da9369891311 100644 (file)
@@ -1,6 +1,9 @@
-puts "TODO OCC26578 All:An exception was caught"
-puts "TODO OCC26578 All:\\*\\* Exception \\*\\*"
-puts "TODO OCC26578 All:TEST INCOMPLETE"
+#puts "TODO OCC26578 All:An exception was caught"
+#puts "TODO OCC26578 All:\\*\\* Exception \\*\\*"
+#puts "TODO OCC26578 All:TEST INCOMPLETE"
+puts "TODO OCC26578 All: Error :  is WRONG because number of EDGE"
+puts "TODO OCC26578 All: Error :  is WRONG because number of SHELL"
+#puts "TODO OCC26578 All: Faulty shapes in variables faulty_1"
 restore [locate_data_file bug26663_test_offset_J9.brep] s
 OFFSETSHAPE ${off_param} {} ${calcul} ${type}
 checknbshapes result -ref [lrange [nbshapes s] 8 19]
index c7b86dc3dd43f70009d8c67b2563f5d823413e9e..d3cbc902b33f86c8105f55abb4921a5b1601a9a0 100644 (file)
@@ -1,6 +1,8 @@
-puts "TODO OCC26578 All:An exception was caught"
-puts "TODO OCC26578 All:\\*\\* Exception \\*\\*"
-puts "TODO OCC26578 All:TEST INCOMPLETE"
+#puts "TODO OCC26578 All:An exception was caught"
+#puts "TODO OCC26578 All:\\*\\* Exception \\*\\*"
+puts "TODO OCC26578 All:is WRONG"
+puts "TODO OCC26578 All:Faulty shapes in variables faulty_1 to faulty_"
+#
 restore [locate_data_file bug26663_test_offset_K8.brep] s
 OFFSETSHAPE ${off_param} {} ${calcul} ${type}
 checknbshapes result -ref [lrange [nbshapes s] 8 19]
index afd1f7ac0b20a7c301753d8e4ad51f205495e4cf..17c86a433558571a1f383a52cb8901f81c8b43ce 100644 (file)
@@ -5,7 +5,7 @@ vrotate 0 0.5 0
 meshtext m
 vsetdispmode m 33
 vdump $::imagedir/${::casename}_txt.png
-meshvectors m -mode elem -maxlen 10 -color green -arrowpart 0.5 -issipmle 0
+meshvectors m -mode elem -maxlen 10 -color green -arrowpart 0.5 -issimple 0
 vsetdispmode m 5
 vdump $::imagedir/${::casename}_vct1.png
 meshvectors m -mode nodal -maxlen 20 -color white -issimple 1