]> OCCT Git - occt-copy.git/commitdiff
0025772: Boolean operation produces invalid result after patch for 0025416
authornbv <nbv@opencascade.com>
Mon, 2 Feb 2015 13:15:39 +0000 (16:15 +0300)
committernbv <nbv@opencascade.com>
Thu, 5 Feb 2015 10:28:10 +0000 (13:28 +0300)
Patch for bug #0025416 and #0025697

Test cases for the issue #25416 and #25697 have been added.
New test case for this issue has been created.

16 files changed:
src/BOPTest/BOPTest_BOPCommands.cxx
src/BRepCheck/FILES
src/IntPatch/IntPatch_ImpPrmIntersection.cxx
src/IntPatch/IntPatch_WLine.cdl
src/IntPatch/IntPatch_WLine.cxx
src/IntPatch/IntPatch_WLine.lxx
src/IntTools/IntTools_LineConstructor.cxx
src/IntWalk/IntWalk_IWalking.cdl
src/IntWalk/IntWalk_IWalking_1.gxx
src/IntWalk/IntWalk_IWalking_3.gxx
src/IntWalk/IntWalk_IWalking_4.gxx
src/IntWalk/IntWalk_IWalking_5.gxx
tests/bugs/modalg_5/bug25416_1 [new file with mode: 0644]
tests/bugs/modalg_5/bug25697_1 [new file with mode: 0644]
tests/bugs/modalg_5/bug25697_2 [new file with mode: 0644]
tests/bugs/modalg_5/bug25772 [new file with mode: 0644]

index f4944b96a269713c32c80546fb2f3c1f6c7a64f3..c85c733bb0edda0243ca04ac75377b9c35b27125 100644 (file)
@@ -541,19 +541,19 @@ Standard_Integer bopcurves (Draw_Interpretor& di,
                             const char** a)
 {
   if (n<3) {
-    di << " use bopcurves F1 F2\n";
+    di << " use bopcurves F1 F2 [-2d/-2d1/-2d2]\n";
     return 1;
   }
-
+  //
   TopoDS_Shape S1 = DBRep::Get(a[1]);
   TopoDS_Shape S2 = DBRep::Get(a[2]);
   TopAbs_ShapeEnum aType;
-
+  //
   if (S1.IsNull() || S2.IsNull()) {
     di << " Null shapes is not allowed \n";
     return 1;
   }
-
+  //
   aType=S1.ShapeType();
   if (aType != TopAbs_FACE) {
     di << " Type mismatch F1\n";
@@ -564,38 +564,53 @@ Standard_Integer bopcurves (Draw_Interpretor& di,
     di << " Type mismatch F2\n";
     return 1;
   }
-
-
+  //
   const TopoDS_Face& aF1=*(TopoDS_Face*)(&S1);
   const TopoDS_Face& aF2=*(TopoDS_Face*)(&S2);
-
+  //
   Standard_Boolean aToApproxC3d, aToApproxC2dOnS1, aToApproxC2dOnS2, anIsDone;
   Standard_Integer i, aNbCurves;
   Standard_Real anAppTol, aTolR;
   TCollection_AsciiString aNm("c_");
-
-  aToApproxC3d=Standard_True;
-  aToApproxC2dOnS1=Standard_False;
-  aToApproxC2dOnS2=Standard_False;
-  anAppTol=0.0000001;
-
-
+  //
+  anAppTol = 0.0000001;
+  aToApproxC3d = Standard_True;
+  aToApproxC2dOnS1 = Standard_False;
+  aToApproxC2dOnS2 = Standard_False;
+  //
+  if (n > 3) {
+    if (!strcasecmp(a[3],"-2d")) {
+      aToApproxC2dOnS1 = Standard_True;
+      aToApproxC2dOnS2 = Standard_True;
+    } 
+    else if (!strcasecmp(a[3],"-2d1")) {
+      aToApproxC2dOnS1 = Standard_True;
+    }
+    else if (!strcasecmp(a[3],"-2d2")) {
+      aToApproxC2dOnS2 = Standard_True;
+    }
+    else {
+      di << "Wrong key. To build 2d curves use: bopcurves F1 F2 -2d/-2d1/-2d2 \n";
+      return 1;
+    }
+  }
+  //
   IntTools_FaceFace aFF;
-  
+  //
   aFF.SetParameters (aToApproxC3d,
                      aToApproxC2dOnS1,
                      aToApproxC2dOnS2,
                      anAppTol);
-  
+  //
   aFF.Perform (aF1, aF2);
-  
+  //
   anIsDone=aFF.IsDone();
   if (!anIsDone) {
     di << " anIsDone=" << (Standard_Integer) anIsDone << "\n";
     return 1;
   }
-
-  aFF.PrepareLines3D();
+  //
+  aFF.PrepareLines3D(Standard_False);
   const IntTools_SequenceOfCurves& aSCs=aFF.Lines();
 
   //
@@ -607,25 +622,60 @@ Standard_Integer bopcurves (Draw_Interpretor& di,
     di << " has no 3d curve\n";
     return 1;
   }
+  else
+  {
+    di << aNbCurves << " curve(s) found.\n";
+  }
 
   for (i=1; i<=aNbCurves; i++) {
     const IntTools_Curve& anIC=aSCs(i);
 
-    Handle (Geom_Curve) aC3D=anIC.Curve();
+    Handle (Geom_Curve)  aC3D = anIC.Curve();
 
     if (aC3D.IsNull()) {
-      di << " has Null 3d curve# " << i << "%d\n";
+      di << " has Null 3d curve# " << i << "\n";
       continue;
     }
 
     TCollection_AsciiString anIndx(i), aNmx;
-    aNmx=aNm+anIndx;
-    Standard_CString name= aNmx.ToCString();
-    DrawTrSurf::Set(name, aC3D);
-    di << name << " ";
-  }
+    aNmx = aNm + anIndx;
 
+    Standard_CString nameC = aNmx.ToCString();
+
+    DrawTrSurf::Set(nameC, aC3D);
+    di << nameC << " ";
+    //
+    Handle(Geom2d_Curve) aPC1 = anIC.FirstCurve2d();
+    Handle(Geom2d_Curve) aPC2 = anIC.SecondCurve2d();
+    //
+    if (!aPC1.IsNull() || !aPC2.IsNull()) {
+      di << "(";
+      //
+      if (!aPC1.IsNull()) {
+        TCollection_AsciiString pc1N("c2d1_"), pc1Nx;
+        pc1Nx = pc1N + anIndx;
+        Standard_CString nameC2d1 = pc1Nx.ToCString();
+        //
+        DrawTrSurf::Set(nameC2d1, aPC1);
+        di << nameC2d1;
+      }
+      //
+      if (!aPC2.IsNull()) {
+        TCollection_AsciiString pc2N("c2d2_"), pc2Nx;
+        pc2Nx = pc2N + anIndx;
+        Standard_CString nameC2d2 = pc2Nx.ToCString();
+        //
+        DrawTrSurf::Set(nameC2d2, aPC2);
+        //
+        if (!aPC1.IsNull()) {
+          di << ", ";
+        }
+        di << nameC2d2;
+      }
+      di << ") ";
+    }
+  }
+  //
   di << "\n";
-  
   return 0;
 }
index 23f46ec3c5e9245655aabbf99a74890d2d290d8b..478f09dd4c00a1eb26073f0fbde4e48e90822a21 100644 (file)
@@ -1 +1,2 @@
 BRepCheck_SurfNormAnalyzer.hxx
+BRepCheck_SurfNormAnalyzer.cxx
\ No newline at end of file
index 2208aee1b48b7defdf5b0a0ca22b67ca8be15619..4fadc90d3f4230b46655f2ff24af8fccbb3f4b6a 100644 (file)
@@ -571,6 +571,7 @@ void IntPatch_ImpPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Sur
     }
     //
     Nblines = iwalk.NbLines();
+    const Standard_Integer aMinNbWLPoins = 40;
     for (j=1; j<=Nblines; j++) {
       const Handle(IntPatch_TheIWLineOfTheIWalking)&  iwline  = iwalk.Value(j);
       const Handle(IntSurf_LineOn2S)&                 thelin  = iwline->Line();
@@ -891,75 +892,27 @@ void IntPatch_ImpPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Sur
           wline->SetLastPoint(wline->NbVertex());
         }
 
-        if(wline->NbPnts() < 40)
+        if(wline->NbPnts() < aMinNbWLPoins)
         {
-          Standard_Boolean hasBeenAdded = iwalk.SeekAdditionalPoints(Surf1, Surf2, 40, j);
-
-          if (!reversed)
-            IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang, hasBeenAdded);
-          else
-            IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang, hasBeenAdded);
-
-          if(hasBeenAdded)
+          Standard_Integer aDeltaParam = 0;
+          for(Standard_Integer aVertNum = 1; aVertNum < wline->NbVertex(); aVertNum++)
           {
-            const Standard_Real aTol = Precision::Confusion()*Precision::Confusion();
-            Standard_Real aDecrParam = 0.0;
-            Standard_Integer aNbVert = wline->NbVertex();
-            for (Standard_Integer aV = 2; aV <= aNbVert; aV++)
-            {
-              IntPatch_Point aVert = wline->Vertex(aV);
-
-              const gp_Pnt aP(aVert.Value()), aP1(wline->Vertex(aV-1).Value());
-
-              if(aV == aNbVert)
-              {
-                if(aP.SquareDistance(aP1) <= aTol)
-                {
-                  wline->RemoveVertex(aV-1);
-                }
-
-                break;
-              }
-              else
-              {
-                aVert.SetParameter(aVert.ParameterOnLine() - aDecrParam);
-                wline->RemoveVertex(aV);
-                wline->InsertVertexBefore(aV, aVert);
-              }
+            const Standard_Integer aFirst = 
+                            RealToInt(wline->Vertex(aVertNum).ParameterOnLine());
+            const Standard_Integer aLast = 
+                            RealToInt(wline->Vertex(aVertNum + 1).ParameterOnLine());
 
-              const gp_Pnt aP2(wline->Vertex(aV+1).Value());
+            const Standard_Integer aNbPoints = wline->NbPnts();
 
-              if(aP.SquareDistance(aP1) <= aTol)
-              {
-                wline->RemoveVertex(aV);
-              }
-              else if(aP.SquareDistance(aP2) <= aTol)
-              {
-                wline->RemoveVertex(aV);
+            iwalk.SeekAdditionalPoints(Surf1, Surf2, aFirst, aLast, aMinNbWLPoins, j);
 
-                aDecrParam++;
-                aV--;
-                aNbVert = wline->NbVertex();
-              }
+            aDeltaParam += (wline->NbPnts() - aNbPoints);
 
-              aNbVert = wline->NbVertex();
-            }
-          }
-
-          if (wline->HasLastPoint())
-          {
-            wline->SetLastPoint(wline->NbVertex());
-            wline->LastPoint(indlast);
+            IntPatch_Point aVert = wline->Vertex(aVertNum + 1);
+            aVert.SetParameter(aLast + aDeltaParam);
+            wline->Replace(aVertNum + 1, aVert);
           }
         }
-        else
-        {
-          if (!reversed)
-            IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
-          else
-            IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
-        }
-
         //
         // Il faut traiter les points de passage.
         slin.Append(wline);
@@ -1323,17 +1276,11 @@ void IntPatch_ImpPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Sur
   for (i=1; i<=slin.Length(); i++)
   {
     Handle(IntPatch_Line)& aL = slin(i);
-    const Handle(IntPatch_WLine)& wline = Handle(IntPatch_WLine)::DownCast(aL);
     
-    if(!wline.IsNull())
-    {//It was processed above
-      continue;
-    }
-
     if (!reversed)
-      IntPatch_RstInt::PutVertexOnLine(aL,Surf1,D1,Surf2,Standard_True,TolTang, 1);
+      IntPatch_RstInt::PutVertexOnLine(aL,Surf1,D1,Surf2,Standard_True,TolTang);
     else
-      IntPatch_RstInt::PutVertexOnLine(aL,Surf2,D2,Surf1,Standard_False,TolTang, 1);
+      IntPatch_RstInt::PutVertexOnLine(aL,Surf2,D2,Surf1,Standard_False,TolTang);
   }
   empt = (slin.Length() == 0 && spnt.Length() == 0);
   done = Standard_True;
@@ -1838,7 +1785,7 @@ static void ToSmooth(Handle(IntSurf_LineOn2S)& Line,
                     Standard_Boolean          IsReversed,
                     IntSurf_Quadric&          Quad,
                     Standard_Boolean          IsFirst,
-  Standard_Real&                  D3D)
+                      Standard_Real&                  D3D)
 {
   if(Line->NbPoints() <= 10)
     return;
@@ -1934,9 +1881,9 @@ static void ToSmooth(Handle(IntSurf_LineOn2S)& Line,
 } 
 
 static Standard_Boolean TestMiddleOnPrm(const IntSurf_PntOn2S& aP,
-  const IntSurf_PntOn2S& aV,
-  const Standard_Boolean IsReversed,
-  const Standard_Real    ArcTol,
+                                        const IntSurf_PntOn2S& aV,
+                                        const Standard_Boolean IsReversed,
+                                        const Standard_Real    ArcTol,
                                         Handle(Adaptor3d_TopolTool)&  PDomain)
 
 {
@@ -1962,12 +1909,12 @@ static void VerifyVertices(Handle(IntSurf_LineOn2S)& Line,
                            Standard_Boolean          IsReversed,
                            Handle(IntSurf_LineOn2S)& Vertices,
                            Standard_Real             TOL2D,
-  const Standard_Real       ArcTol,
+                            const Standard_Real       ArcTol,
                            Handle(Adaptor3d_TopolTool)&     PDomain,
-  IntSurf_PntOn2S&          VrtF,
-  Standard_Boolean&         AddFirst,
-  IntSurf_PntOn2S&          VrtL,
-  Standard_Boolean&         AddLast)
+                            IntSurf_PntOn2S&          VrtF,
+                            Standard_Boolean&         AddFirst,
+                            IntSurf_PntOn2S&          VrtL,
+                            Standard_Boolean&         AddLast)
 {
   Standard_Integer nbp = Line->NbPoints(), nbv = Vertices->NbPoints();
   Standard_Integer FIndexSame = 0, FIndexNear = 0, LIndexSame = 0, LIndexNear = 0;
index f72b750d1fbe9b86448ee0a08eb3b9d57b9b3a6f..c3624cc7554e55e00357d6ac3f050efd85c336c7 100644 (file)
@@ -309,21 +309,9 @@ is
        ---C++: return const&
         returns HCurve2d from Adaptor2d;
 
-    ClearVertexes(me: mutable)
-      is static;
+    Dump(me)
     
-    RemoveVertex(me: mutable;
-                  theIndex : Integer from Standard)
-      is static;
-      
-    InsertVertexBefore(me: mutable;
-                        theIndex : Integer from Standard;
-                        thePnt   : Point from IntPatch)
-      is static;
-    
-         Dump(me)
-    
-      is static;
+       is static;
 
  
 fields
index a178ae9e293eaa14fdd9686abb80a1ed7753f1c6..6673009d85f2c686d393453683b1ba46ef660ac5 100644 (file)
@@ -1079,7 +1079,7 @@ void IntPatch_WLine::Dump() const {
   for(i=1;i<=nbp;i++) {
     Standard_Real u1,v1,u2,v2;
     Point(i).Parameters(u1,v1,u2,v2);
-    printf("%4d  [%+5.8e %+5.8e %+5.8e]  [%+5.8e %+5.8e]  [%+5.8e %+5.8e]\n",
+    printf("%4d  [%+10.20f %+10.20f %+10.20f]  [%+10.20f %+10.20f]  [%+10.20f %+10.20f]\n",
           i,
           Point(i).Value().X(),
           Point(i).Value().Y(),
index 36b41e3ba411aa8387c74f4d0f96aaa82442600e..0a37e0e501153c822913453f974682b5fd79ec80 100644 (file)
@@ -97,27 +97,3 @@ inline const IntPatch_Point& IntPatch_WLine::Vertex (const Standard_Integer Inde
 {
   return svtx(Index);
 }
-
-inline void IntPatch_WLine::ClearVertexes()
-{
-  svtx.Clear();
-}
-
-inline void IntPatch_WLine::RemoveVertex(const Standard_Integer theIndex)
-{
-  if((theIndex < 1) || (theIndex > NbVertex()))
-    Standard_OutOfRange::Raise("Cannot delete not existing vertex");
-  svtx.Remove(theIndex);
-}
-
-inline void IntPatch_WLine::InsertVertexBefore( const Standard_Integer theIndex,
-                                                const IntPatch_Point& thePnt)
-{
-  const Standard_Integer aNbVertexes = NbVertex();
-  Standard_Integer anIndex = Max(theIndex, 1);
-
-  if(anIndex > aNbVertexes)
-    svtx.Append(thePnt);
-  else
-    svtx.InsertBefore(theIndex, thePnt);
-}
index 86246dd4e1c92f0e10dd29f7b55744120effff8f..ac2993ea366ddf7e0e7f08d9cee2adee146978a0 100644 (file)
@@ -77,7 +77,7 @@ void IntTools_LineConstructor::Perform(const Handle(IntPatch_Line)& L)
 {
   Standard_Integer i,nbvtx;
   Standard_Real firstp,lastp;
-  const Standard_Real Tol = 1.001e-6;//Precision::PConfusion() * 35.0;
+  const Standard_Real Tol = Precision::PConfusion() * 35.0;
   
   const IntPatch_IType typl = L->ArcType();
   if(typl == IntPatch_Analytic)  {
index dcacd61784f8a0541b4f63c47bf52ca7f218b3d8..7862ef5962ed6caffa9caabf834ccad8ea734455 100644 (file)
@@ -319,6 +319,7 @@ is
 
     SeekAdditionalPoints( me    : in out;
                           theASurf1 , theASurf2  : ThePSurface;
+                          theFromPoint, theToPoint : Integer from Standard;
                           theMinNbPoints : Integer from Standard;
                           theNCurve : Integer from Standard)
       returns Boolean from Standard;
index 018fa62eae36da052739734d3af59c6182f7051c..44959e2e87a98db4849d39d26b27aeb3b793727b 100644 (file)
@@ -1619,12 +1619,15 @@ Standard_Boolean IntWalk_IWalking::
 
 //=======================================================================
 //function : SeekAdditionalPoints
-//purpose  : This function is same as in IntWalk_PWalking_1.gxx file.
-//            If you change it, you should change and that function too.
+//purpose  : If you are changing this function please pay attention to
+//            the analogical function in IntWalk_PWalking_1.gxx file.
+//            Do there necessary corrections too.
 //=======================================================================
 Standard_Boolean IntWalk_IWalking::
   SeekAdditionalPoints( const ThePSurface& theASurf1,
                         const ThePSurface& theASurf2,
+                        const Standard_Integer theFromPoint,
+                        const Standard_Integer theToPoint,
                         const Standard_Integer theMinNbPoints,
                         const Standard_Integer theNCurve)
 {
@@ -1644,16 +1647,17 @@ Standard_Boolean IntWalk_IWalking::
   const Standard_Real aV2bFirst = theASurf2->FirstVParameter();
   const Standard_Real aV2bLast = theASurf2->LastVParameter();
 
+  Standard_Integer aLastPoint = theToPoint;
   
   Standard_Boolean isPrecise = Standard_False;
 
   Standard_Real U1prec = 0.0, V1prec = 0.0, U2prec = 0.0, V2prec = 0.0;
 
   Standard_Integer aNbPointsPrev = 0;
-  while(aNbPoints < theMinNbPoints && (aNbPoints != aNbPointsPrev))
+  while((aLastPoint - theFromPoint) < theMinNbPoints && (aNbPoints != aNbPointsPrev))
   {
     aNbPointsPrev = aNbPoints;
-    for(Standard_Integer fp = 1, lp = 2; fp < aNbPoints; fp = lp + 1)
+    for(Standard_Integer fp = theFromPoint, lp = theFromPoint+1; fp < aLastPoint; fp = lp + 1)
     {
       Standard_Real U1f, V1f, U2f, V2f; //first point in 1st and 2nd surafaces
       Standard_Real U1l, V1l, U2l, V2l; //last  point in 1st and 2nd surafaces
@@ -1719,20 +1723,28 @@ Standard_Boolean IntWalk_IWalking::
       }
       while(!aStatus && (--aNbIter > 0));
 
-      //if((U1prec-U1f)*(U1l-U1prec) < 0.0)
-      //  aStatus = Standard_False;
-
-      //if((U2prec-U2f)*(U2l-U2prec) < 0.0)
-      //  aStatus = Standard_False;
-
-      //if((V1prec-V1f)*(V1l-V1prec) < 0.0)
-      //  aStatus = Standard_False;
-
-      //if((V2prec-V2f)*(V2l-V2prec) < 0.0)
-      //  aStatus = Standard_False;
-
       if(aStatus)
       {
+        if(U1prec < aU1bFirst)
+          U1prec = aU1bFirst;
+        if(U1prec > aU1bLast)
+          U1prec = aU1bLast;
+
+        if(V1prec < aV1bFirst)
+          V1prec = aV1bFirst;
+        if(V1prec > aV1bLast)
+          V1prec = aV1bLast;
+
+        if(U2prec < aU2bFirst)
+          U2prec = aU2bFirst;
+        if(U2prec > aU2bLast)
+          U2prec = aU2bLast;
+
+        if(V2prec < aV2bFirst)
+          V2prec = aV2bFirst;
+        if(V2prec > aV2bLast)
+          V2prec = aV2bLast;
+
         gp_Pnt  aP1 = theASurf1->Value(U1prec, V1prec),
                 aP2 = theASurf2->Value(U2prec, V2prec);
         gp_Pnt aPInt(0.5*(aP1.XYZ() + aP2.XYZ()));
@@ -1747,9 +1759,10 @@ Standard_Boolean IntWalk_IWalking::
           line->InsertBefore(lp, anIP);
           
           isPrecise = Standard_True;
+          aLastPoint++;
 
           aNbPoints = line->NbPoints();
-          if(aNbPoints >= theMinNbPoints)
+          if((aLastPoint - theFromPoint) >= theMinNbPoints)
             break;
         }
         else
index 1c2271907f04886c3204f5003a38f289fc1eebba..7e49fff9dbdc701f172ac8919ccfe3a50a467353 100644 (file)
@@ -118,27 +118,27 @@ void IntWalk_IWalking::ComputeOpenLine(const TColStd_SequenceOfReal& Umult,
       CurrentLine->AddPoint(previousPoint);
       // modified by NIZHNY-MKK  Fri Oct 27 12:34:32 2000.BEGIN
       if(movementdirectioninfo[I] !=0) {
-       if(movementdirectioninfo[I] < 0) {
-         StepSign = -1;
-         CurrentLine->SetTangentVector(previousd3d.Reversed(),1);
-       } else {
-         StepSign = 1; 
-         CurrentLine->SetTangentVector(previousd3d,1);
-       }
+        if(movementdirectioninfo[I] < 0) {
+          StepSign = -1;
+          CurrentLine->SetTangentVector(previousd3d.Reversed(),1);
+        } else {
+          StepSign = 1; 
+          CurrentLine->SetTangentVector(previousd3d,1);
+        }
       } else {
-       Standard_Real tyutuyt=ThePointOfPathTool::Direction3d(PathPnt) * previousd3d;
-       if( tyutuyt < 0) {
-         StepSign = -1;
-         CurrentLine->SetTangentVector(previousd3d.Reversed(),1);
-       }
-       else {
-         StepSign = 1; 
-         CurrentLine->SetTangentVector(previousd3d,1);
-       }
+        Standard_Real tyutuyt=ThePointOfPathTool::Direction3d(PathPnt) * previousd3d;
+        if( tyutuyt < 0) {
+          StepSign = -1;
+          CurrentLine->SetTangentVector(previousd3d.Reversed(),1);
+        }
+        else {
+          StepSign = 1; 
+          CurrentLine->SetTangentVector(previousd3d,1);
+        }
       }
       // modified by NIZHNY-MKK  Fri Oct 27 12:34:37 2000.END
 
-//  Modified by Sergey KHROMOV - Tue Nov 20 10:41:45 2001 Begin
+      //  Modified by Sergey KHROMOV - Tue Nov 20 10:41:45 2001 Begin
       wd1[I].etat = - abs(wd1[I].etat);
       movementdirectioninfo[I] = (movementdirectioninfo[I]==0) ? StepSign : 0;
 //  Modified by Sergey KHROMOV - Tue Nov 20 10:41:56 2001 End
@@ -146,13 +146,13 @@ void IntWalk_IWalking::ComputeOpenLine(const TColStd_SequenceOfReal& Umult,
       Standard_Real d2dx = Abs(previousd2d.X()); 
       Standard_Real d2dy = Abs(previousd2d.Y()); 
       if (d2dx < tolerance(1)) {
-       PasC = pas * (VM-Vm)/d2dy;
+        PasC = pas * (VM-Vm)/d2dy;
       }
       else if (d2dy < tolerance(2)) {
-       PasC = pas * (UM-Um)/d2dx;
+        PasC = pas * (UM-Um)/d2dx;
       }
       else {
-       PasC = pas * Min((UM-Um)/d2dx,(VM-Vm)/d2dy);
+        PasC = pas * Min((UM-Um)/d2dx,(VM-Vm)/d2dy);
       }
 
       Arrive = Standard_False;
@@ -161,274 +161,280 @@ void IntWalk_IWalking::ComputeOpenLine(const TColStd_SequenceOfReal& Umult,
       StatusPrecedent = IntWalk_OK;
       // modified by NIZHNY-MKK  Fri Oct 27 12:39:37 2000
       Standard_Integer IndexOfPathPointDoNotCheck=0;
-
+      Standard_Integer aNbIter = 10;
       while (!Arrive) { //    as one of stop tests is not checked
-
-       Cadre = Cadrage(BornInf,BornSup,UVap,PasC,StepSign);
-       //  Border?
+        Cadre = Cadrage(BornInf,BornSup,UVap,PasC,StepSign);
+        //  Border?
 
 #ifdef CHRONO
-       Chronrsnld.Start();
+        Chronrsnld.Start();
 #endif
 
-       Rsnld.Perform(Func,UVap,BornInf,BornSup);
+        Rsnld.Perform(Func,UVap,BornInf,BornSup);
 
 #ifdef CHRONO
-       Chronrsnld.Stop();
+        Chronrsnld.Stop();
 #endif
 
-       if (Cadre) {
-         BornInf(1) = Um; BornSup(1) = UM; BornInf(2) = Vm; BornSup(2) = VM;
-       }
-       if (Rsnld.IsDone()) {
-         if (Abs(Func.Root()) > Func.Tolerance()) {
-           PasC = PasC / 2.0;
-           PasCu = Abs(PasC*previousd2d.X());
-           PasCv = Abs(PasC*previousd2d.Y());
-           if (PasCu <= tolerance(1) && PasCv <= tolerance(2)) {
-             if (CurrentLine->NbPoints() == 1) break;
-             Arrive = Standard_True;
-             CurrentLine->AddStatusLast(Standard_False);
-             Tgtend = Standard_True; // check
+        if (Cadre) {
+          BornInf(1) = Um; BornSup(1) = UM; BornInf(2) = Vm; BornSup(2) = VM;
+        }
+        if (Rsnld.IsDone()) {
+          if (Abs(Func.Root()) > Func.Tolerance()) {
+            PasC = PasC / 2.0;
+            PasCu = Abs(PasC*previousd2d.X());
+            PasCv = Abs(PasC*previousd2d.Y());
+            if (PasCu <= tolerance(1) && PasCv <= tolerance(2)) {
+              if (CurrentLine->NbPoints() == 1) break;
+              Arrive = Standard_True;
+              CurrentLine->AddStatusLast(Standard_False);
+              Tgtend = Standard_True; // check
               Rajout = Standard_True;
-             seqAjout.Append(lines.Length() + 1);
-           }  
-         }
-         else { // test stop
-           Rsnld.Root(UVap);
-           Arrive = TestArretPassage(Umult, Vmult, Func, UVap, N);
-           if (Arrive) {
-             Cadre = Standard_False;
-             //in case if there is a frame and arrive at the same time
-           }
-           else {
-             if (Rajout) {
-               ArretAjout =TestArretAjout(Func, UVap, N, Psol);
-               if (ArretAjout) {
-                 // jag 940615
-                 Tgtend = lines.Value(N)->IsTangentAtEnd();
-                 N = -N;
-               }
-             }
-             // modified by NIZHNY-MKK  Thu Nov  2 15:09:08 2000.BEGIN
-             if(!(Rajout && ArretAjout)) {
-               Standard_Real prevUp, prevVp;
-               if (!reversed) {
-                 previousPoint.ParametersOnS2(prevUp, prevVp);
-               }
-               else {
-                 previousPoint.ParametersOnS1(prevUp, prevVp);
-               }
-               Arrive = TestPassedSolutionWithNegativeState(wd1, Umult, Vmult, prevUp, prevVp,
-                                                            nbMultiplicities, tolerance, Func, UVap, N);               
-               if(Arrive) {
-                 Cadre = Standard_False;
-               }
-             }
-             // modified by NIZHNY-MKK  Thu Nov  2 15:09:13 2000.END
-             if (!ArretAjout && Cadre) {
-               if (CurrentLine->NbPoints() == 1) break; // cancel the line
-               TestArretCadre(Umult, Vmult, CurrentLine, Func, UVap, N);
-//             if (N == 0) {
-               if (N <= 0) { // jag 941017
-                 MakeWalkingPoint(2, UVap(1), UVap(2), Func, Psol);
-                 Tgtend = Func.IsTangent();
+              seqAjout.Append(lines.Length() + 1);
+            }  
+          }
+          else { // test stop
+            Rsnld.Root(UVap);
+            Arrive = TestArretPassage(Umult, Vmult, Func, UVap, N);
+            if (Arrive) {
+              Cadre = Standard_False;
+              //in case if there is a frame and arrive at the same time
+            }
+            else {
+              if (Rajout) {
+                ArretAjout =TestArretAjout(Func, UVap, N, Psol);
+                if (ArretAjout) {
+                  // jag 940615
+                  Tgtend = lines.Value(N)->IsTangentAtEnd();
                   N = -N;
-               }
-             }
-           }
-           Status = TestDeflection(Func, Arrive, UVap, StatusPrecedent,
-                                   NbDivision,PasC,StepSign);
-           StatusPrecedent = Status;
-           if (Status == IntWalk_PasTropGrand) {
-             Arrive = Standard_False;
-             ArretAjout = Standard_False;
-             Tgtend = Standard_False; // jag 940615
-             if (!reversed) {
-               previousPoint.ParametersOnS2(UVap(1), UVap(2));
-             }
-             else {
-               previousPoint.ParametersOnS1(UVap(1), UVap(2));
-             }
-           }
-           else if (ArretAjout || Cadre) {
-             Arrive = Standard_True;
-             CurrentLine->AddStatusLast(Standard_False);
-             if (Status != IntWalk_ArretSurPointPrecedent) {
-               CurrentLine->AddPoint(Psol);                      
-             }
-             if (Cadre && N==0) {
-               Rajout = Standard_True;
-               seqAjout.Append(lines.Length()+1);
-             }
-           }
-           else if (Status == IntWalk_ArretSurPointPrecedent) {
-             if (CurrentLine->NbPoints() == 1) { //cancel the line
-               Arrive = Standard_False;
-               break;
-             }
-             Arrive = Standard_True;
-             Rajout = Standard_True;
+                }
+              }
+              // modified by NIZHNY-MKK  Thu Nov  2 15:09:08 2000.BEGIN
+              if(!(Rajout && ArretAjout)) {
+                Standard_Real prevUp, prevVp;
+                if (!reversed) {
+                  previousPoint.ParametersOnS2(prevUp, prevVp);
+                }
+                else {
+                  previousPoint.ParametersOnS1(prevUp, prevVp);
+                }
+                Arrive = TestPassedSolutionWithNegativeState(wd1, Umult, Vmult, prevUp, prevVp,
+                  nbMultiplicities, tolerance, Func, UVap, N);         
+                if(Arrive) {
+                  Cadre = Standard_False;
+                }
+              }
+              // modified by NIZHNY-MKK  Thu Nov  2 15:09:13 2000.END
+              if (!ArretAjout && Cadre) {
+                if (CurrentLine->NbPoints() == 1) break; // cancel the line
+                TestArretCadre(Umult, Vmult, CurrentLine, Func, UVap, N);
+                //             if (N == 0) {
+                if (N <= 0) { // jag 941017
+                  MakeWalkingPoint(2, UVap(1), UVap(2), Func, Psol);
+                  Tgtend = Func.IsTangent();
+                  N = -N;
+                }
+              }
+            }
+            Status = TestDeflection(Func, Arrive, UVap, StatusPrecedent,
+              NbDivision,PasC,StepSign);
+            StatusPrecedent = Status;
+            if (Status == IntWalk_PasTropGrand) {
+              Arrive = Standard_False;
+              ArretAjout = Standard_False;
+              Tgtend = Standard_False; // jag 940615
+              if (!reversed) {
+                previousPoint.ParametersOnS2(UVap(1), UVap(2));
+              }
+              else {
+                previousPoint.ParametersOnS1(UVap(1), UVap(2));
+              }
+            }
+            else if (ArretAjout || Cadre) {
+              Arrive = Standard_True;
+              CurrentLine->AddStatusLast(Standard_False);
+              if (Status != IntWalk_ArretSurPointPrecedent) {
+                CurrentLine->AddPoint(Psol);                      
+              }
+              if (Cadre && N==0) {
+                Rajout = Standard_True;
+                seqAjout.Append(lines.Length()+1);
+              }
+            }
+            else if (Status == IntWalk_ArretSurPointPrecedent) {
+              if (CurrentLine->NbPoints() == 1) { //cancel the line
+                Arrive = Standard_False;
+                break;
+              }
+              Arrive = Standard_True;
+              Rajout = Standard_True;
               seqAjout.Append(lines.Length() + 1);
-             CurrentLine->AddStatusLast(Standard_False);
-             Tgtend = Standard_True; // check
-           }
-           else if (Arrive)  {
-             if (CurrentLine->NbPoints() == 1 &&    // cancel the line
-                 (N == I || Status == IntWalk_PointConfondu) ) {
-               // if N == I the main uv is probably lost
-               // or the point is a point of accumulation
-               // if point is confused the start data is bad
-               Arrive =  Standard_False;
-               break;
-             }
-             // necessairily N > 0 jag 940617
+              CurrentLine->AddStatusLast(Standard_False);
+              Tgtend = Standard_True; // check
+            }
+            else if (Arrive)  {
+              if (CurrentLine->NbPoints() == 1 &&    // cancel the line
+                (N == I || Status == IntWalk_PointConfondu) ) {
+                  // if N == I the main uv is probably lost
+                  // or the point is a point of accumulation
+                  // if point is confused the start data is bad
+                  Arrive =  Standard_False;
+                  break;
+              }
+              // necessairily N > 0 jag 940617
               // point of stop given at input 
-             PathPnt = Pnts1.Value(N);
-             
-             Standard_Integer etat1N=wd1[N].etat;
-             // modified by NIZHNY-MKK  Thu Nov  2 15:09:51 2000.BEGIN
-             //              if (etat1N < 11) { // passing point that is a stop  
-             if (Abs(etat1N) < 11) { // passing point that is a stop    
-               // modified by NIZHNY-MKK  Thu Nov  2 15:12:11 2000.END
-               if (Status == IntWalk_ArretSurPoint) { 
-                 CurrentLine->AddStatusLast(Standard_False);
-                 Tgtend = Standard_True; // need check
-               }
-               else { 
-                 Arrive = Standard_False;
-               }
-               CurrentLine->AddIndexPassing(N);
-             }
-             else { // point of stop given at input
-               if (etat1N == 11) {
-                 Tgtend = Standard_True;
-               }
-               CurrentLine->AddStatusLast(Standard_True, N, PathPnt);
-             }
-             AddPointInCurrentLine(N,PathPnt,CurrentLine);
-             if ((etat1N != 1 && etat1N != 11)) {
-               // modified by NIZHNY-MKK  Fri Oct 27 12:43:05 2000.BEGIN
-               //              wd1[N].etat= - wd1[N].etat;
-               wd1[N].etat = - Abs(etat1N);            
-               movementdirectioninfo[N] = (movementdirectioninfo[N]==0) ? StepSign : 0;
-               if(Arrive && movementdirectioninfo[N]!=0) {
-                 IndexOfPathPointDoNotCheck = N;
-               }
+              PathPnt = Pnts1.Value(N);
 
-               if(Arrive) {
-                 Rajout = Standard_True;
-                 seqAjout.Append(lines.Length() + 1);
-               }
-               // modified by NIZHNY-MKK  Fri Oct 27 12:45:33 2000.END
-             }
-           }
-           else if (Status == IntWalk_ArretSurPoint) {
-             Arrive = Standard_True;                   
-             CurrentLine->AddStatusLast(Standard_False);
-             Tgtend = Standard_True;
+              Standard_Integer etat1N=wd1[N].etat;
+              // modified by NIZHNY-MKK  Thu Nov  2 15:09:51 2000.BEGIN
+              //             if (etat1N < 11) { // passing point that is a stop  
+              if (Abs(etat1N) < 11) { // passing point that is a stop    
+                // modified by NIZHNY-MKK  Thu Nov  2 15:12:11 2000.END
+                if (Status == IntWalk_ArretSurPoint) { 
+                  CurrentLine->AddStatusLast(Standard_False);
+                  Tgtend = Standard_True; // need check
+                }
+                else { 
+                  Arrive = Standard_False;
+                }
+                CurrentLine->AddIndexPassing(N);
+              }
+              else { // point of stop given at input
+                if (etat1N == 11) {
+                  Tgtend = Standard_True;
+                }
+                CurrentLine->AddStatusLast(Standard_True, N, PathPnt);
+              }
+              AddPointInCurrentLine(N,PathPnt,CurrentLine);
+              if ((etat1N != 1 && etat1N != 11)) {
+                // modified by NIZHNY-MKK  Fri Oct 27 12:43:05 2000.BEGIN
+                //             wd1[N].etat= - wd1[N].etat;
+                wd1[N].etat = - Abs(etat1N);           
+                movementdirectioninfo[N] = (movementdirectioninfo[N]==0) ? StepSign : 0;
+                if(Arrive && movementdirectioninfo[N]!=0) {
+                  IndexOfPathPointDoNotCheck = N;
+                }
+
+                if(Arrive) {
+                  Rajout = Standard_True;
+                  seqAjout.Append(lines.Length() + 1);
+                }
+                // modified by NIZHNY-MKK  Fri Oct 27 12:45:33 2000.END
+              }
+            }
+            else if (Status == IntWalk_ArretSurPoint) {
+              Arrive = Standard_True;                   
+              CurrentLine->AddStatusLast(Standard_False);
+              Tgtend = Standard_True;
               MakeWalkingPoint(1, UVap(1), UVap(2), Func, Psol);
-             CurrentLine->AddPoint(Psol);
-             Rajout = Standard_True;
+              CurrentLine->AddPoint(Psol);
+              Rajout = Standard_True;
               seqAjout.Append(lines.Length() + 1);
-           }
-           else if (Status == IntWalk_OK) { 
+            }
+            else if (Status == IntWalk_OK) { 
               MakeWalkingPoint(2, UVap(1), UVap(2), Func, previousPoint);
-             previousd3d = Func.Direction3d();
-             previousd2d = Func.Direction2d();
-             CurrentLine->AddPoint(previousPoint);
-           }                           
-         }
-       }
-       else { // no numerical solution
-         PasC = PasC / 2.;
-         PasCu = Abs(PasC*previousd2d.X());
-         PasCv = Abs(PasC*previousd2d.Y());
-         if (PasCu <= tolerance(1) && PasCv <= tolerance(2)) {
-           if (CurrentLine->NbPoints()==1) break;
-           Arrive = Standard_True;
-           CurrentLine->AddStatusLast(Standard_False);
-           Tgtend = Standard_True; // need check
-           Rajout = Standard_True;
+              previousd3d = Func.Direction3d();
+              previousd2d = Func.Direction2d();
+              CurrentLine->AddPoint(previousPoint);
+            }     
+            else if (Status == IntWalk_PointConfondu)
+            {
+              aNbIter --;
+            }
+          }
+        }
+        else { // no numerical solution
+          PasC = PasC / 2.;
+          PasCu = Abs(PasC*previousd2d.X());
+          PasCv = Abs(PasC*previousd2d.Y());
+          if (PasCu <= tolerance(1) && PasCv <= tolerance(2)) {
+            if (CurrentLine->NbPoints()==1) break;
+            Arrive = Standard_True;
+            CurrentLine->AddStatusLast(Standard_False);
+            Tgtend = Standard_True; // need check
+            Rajout = Standard_True;
             seqAjout.Append(lines.Length() + 1);
-         }  
-       }
+          }  
+        }
+
+        if(aNbIter < 0)
+          break;
       } // end of started line
       
       if (Arrive) {
-       CurrentLine->SetTangencyAtEnd(Tgtend);
-       lines.Append(CurrentLine);
-       // modified by NIZHNY-MKK  Fri Oct 27 12:59:29 2000.BEGIN
-       movementdirectioninfo[I]=0;
-       if(wd1[I].etat > 0)
-       // modified by NIZHNY-MKK  Fri Oct 27 12:59:42 2000.END
-         wd1[I].etat=-wd1[I].etat;
+        CurrentLine->SetTangencyAtEnd(Tgtend);
+        lines.Append(CurrentLine);
+        // modified by NIZHNY-MKK  Fri Oct 27 12:59:29 2000.BEGIN
+        movementdirectioninfo[I]=0;
+        if(wd1[I].etat > 0)
+          // modified by NIZHNY-MKK  Fri Oct 27 12:59:42 2000.END
+          wd1[I].etat=-wd1[I].etat;
 
-       //-- lbr le 5 juin 97 (Pb ds Contap)
-       for(Standard_Integer av=1; av<=nbPath; av++) { 
-         // modified by NIZHNY-MKK  Fri Oct 27 13:00:22 2000.BEGIN
-         //      if (wd1[av].etat > 11) {
-         if ((wd1[av].etat > 11) || 
-             ((av!=I) && 
-              (av!=IndexOfPathPointDoNotCheck) && 
-              (wd1[av].etat < -11)  && 
-              (movementdirectioninfo[av]!=0))) {
-         // modified by NIZHNY-MKK  Fri Oct 27 13:00:26 2000.END
-           Standard_Real Uav=wd1[av].ustart;
-           Standard_Real Vav=wd1[av].vstart;
-           Standard_Real Uavp,Vavp;
-           const IntSurf_PntOn2S &avP=CurrentLine->Value(CurrentLine->NbPoints());
-           if (!reversed) {
-             avP.ParametersOnS2(Uavp,Vavp);
-           }
-           else {
-             avP.ParametersOnS1(Uavp,Vavp);
-           }
-           Uav-=Uavp;
-           Vav-=Vavp;
-           Uav*=0.001; Vav*=0.001;
-           if(Abs(Uav)<tolerance(1) && Abs(Vav)<tolerance(2)) { 
-             // modified by NIZHNY-MKK  Fri Oct 27 13:01:38 2000.BEGIN
-             //              wd1[av].etat=-wd1[av].etat;
-             if(wd1[av].etat < 0) {
-               movementdirectioninfo[av] = 0;
-             } else {
-               wd1[av].etat=-wd1[av].etat;
-               movementdirectioninfo[av] = StepSign;
-             }
-             // modified by NIZHNY-MKK  Fri Oct 27 13:01:42 2000.END
-             CurrentLine->AddStatusLast(Standard_True, av, Pnts1.Value(av));
-             //-- cout<<"\n Debug ? lbr ds IntWalk_IWalking_3.gxx"<<endl;
-           }
-           
-           const IntSurf_PntOn2S &avPP=CurrentLine->Value(1);
-           if (!reversed) {
-             avPP.ParametersOnS2(Uavp,Vavp);
-           }
-           else {
-             avPP.ParametersOnS1(Uavp,Vavp);
-           }
-           Uav=wd1[av].ustart;
-           Vav=wd1[av].vstart;
-           Uav-=Uavp;
-           Vav-=Vavp;
-           Uav*=0.001; Vav*=0.001;
-           if(Abs(Uav)<tolerance(1) && Abs(Vav)<tolerance(2)) { 
-             // modified by NIZHNY-MKK  Fri Oct 27 13:02:49 2000.BEGIN
-             //              wd1[av].etat=-wd1[av].etat;
-             if(wd1[av].etat < 0) {
-               movementdirectioninfo[av] = 0;
-             } else {
-               wd1[av].etat=-wd1[av].etat;
-               movementdirectioninfo[av] = -StepSign;
-             }
-             // modified by NIZHNY-MKK  Fri Oct 27 13:02:52 2000.END
-             //-- cout<<"\n Debug ? lbr ds IntWalk_IWalking_3.gxx"<<endl;
-             CurrentLine->AddStatusFirst(Standard_False, Standard_True, av, Pnts1.Value(av));
-           }
-         }
-       }
-         
+        //-- lbr le 5 juin 97 (Pb ds Contap)
+        for(Standard_Integer av=1; av<=nbPath; av++) { 
+          // modified by NIZHNY-MKK  Fri Oct 27 13:00:22 2000.BEGIN
+          //     if (wd1[av].etat > 11) {
+          if ((wd1[av].etat > 11) || 
+            ((av!=I) && 
+            (av!=IndexOfPathPointDoNotCheck) && 
+            (wd1[av].etat < -11)  && 
+            (movementdirectioninfo[av]!=0)))
+          {
+            // modified by NIZHNY-MKK  Fri Oct 27 13:00:26 2000.END
+            Standard_Real Uav=wd1[av].ustart;
+            Standard_Real Vav=wd1[av].vstart;
+            Standard_Real Uavp,Vavp;
+            const IntSurf_PntOn2S &avP=CurrentLine->Value(CurrentLine->NbPoints());
+            if (!reversed) {
+              avP.ParametersOnS2(Uavp,Vavp);
+            }
+            else {
+              avP.ParametersOnS1(Uavp,Vavp);
+            }
+            Uav-=Uavp;
+            Vav-=Vavp;
+            Uav*=0.001; Vav*=0.001;
+            if(Abs(Uav)<tolerance(1) && Abs(Vav)<tolerance(2)) { 
+              // modified by NIZHNY-MKK  Fri Oct 27 13:01:38 2000.BEGIN
+              //             wd1[av].etat=-wd1[av].etat;
+              if(wd1[av].etat < 0) {
+                movementdirectioninfo[av] = 0;
+              } else {
+                wd1[av].etat=-wd1[av].etat;
+                movementdirectioninfo[av] = StepSign;
+              }
+              // modified by NIZHNY-MKK  Fri Oct 27 13:01:42 2000.END
+              CurrentLine->AddStatusLast(Standard_True, av, Pnts1.Value(av));
+              //-- cout<<"\n Debug ? lbr ds IntWalk_IWalking_3.gxx"<<endl;
+            }
+
+            const IntSurf_PntOn2S &avPP=CurrentLine->Value(1);
+            if (!reversed) {
+              avPP.ParametersOnS2(Uavp,Vavp);
+            }
+            else {
+              avPP.ParametersOnS1(Uavp,Vavp);
+            }
+            Uav=wd1[av].ustart;
+            Vav=wd1[av].vstart;
+            Uav-=Uavp;
+            Vav-=Vavp;
+            Uav*=0.001; Vav*=0.001;
+            if(Abs(Uav)<tolerance(1) && Abs(Vav)<tolerance(2)) { 
+              // modified by NIZHNY-MKK  Fri Oct 27 13:02:49 2000.BEGIN
+              //             wd1[av].etat=-wd1[av].etat;
+              if(wd1[av].etat < 0) {
+                movementdirectioninfo[av] = 0;
+              } else {
+                wd1[av].etat=-wd1[av].etat;
+                movementdirectioninfo[av] = -StepSign;
+              }
+              // modified by NIZHNY-MKK  Fri Oct 27 13:02:52 2000.END
+              //-- cout<<"\n Debug ? lbr ds IntWalk_IWalking_3.gxx"<<endl;
+              CurrentLine->AddStatusFirst(Standard_False, Standard_True, av, Pnts1.Value(av));
+            }
+          }
+        }
       }
     } //end of point processing
   } //end of all points
index 6ec8ccb0e9b1cfc05ed1a91af3e2efae4ed01733..c35183b0e1a286a47aaa84651831331daa56c23c 100644 (file)
@@ -77,13 +77,13 @@ void IntWalk_IWalking::ComputeCloseLine(const TColStd_SequenceOfReal& Umult,
   
   math_FunctionSetRoot Rsnld(Func,tolerance);
   Standard_Integer nbLoop = Pnts2.Length();
-  
+
   for (I = 1;I<=nbLoop;I++) {
-    if (wd2[I].etat > 12) { // start point of closed line
-      
+    if (wd2[I].etat > 12)
+    { // start point of closed line
       LoopPnt = Pnts2.Value(I);
       previousPoint.SetValue(ThePointOfLoopTool::Value3d(LoopPnt),reversed,
-                            wd2[I].ustart,wd2[I].vstart);
+           wd2[I].ustart,wd2[I].vstart);
       previousd3d = ThePointOfLoopTool::Direction3d(LoopPnt);
       previousd2d = ThePointOfLoopTool::Direction2d(LoopPnt);
 
@@ -102,13 +102,13 @@ void IntWalk_IWalking::ComputeCloseLine(const TColStd_SequenceOfReal& Umult,
       Standard_Real d2dx = Abs(previousd2d.X()); 
       Standard_Real d2dy = Abs(previousd2d.Y()); 
       if (d2dx < tolerance(1)) {
-       PasC = pas * (VM-Vm)/d2dy;
+        PasC = pas * (VM-Vm)/d2dy;
       }
       else if (d2dy < tolerance(2)) {
-       PasC = pas * (UM-Um)/d2dx;
+        PasC = pas * (UM-Um)/d2dx;
       }
       else {
-       PasC = pas * Min((UM-Um)/d2dx,(VM-Vm)/d2dy);
+        PasC = pas * Min((UM-Um)/d2dx,(VM-Vm)/d2dy);
       }
 
       PasSav = PasC;
@@ -117,225 +117,232 @@ void IntWalk_IWalking::ComputeCloseLine(const TColStd_SequenceOfReal& Umult,
       ArretAjout = Standard_False;
       NbDivision = 0;
       StatusPrecedent = IntWalk_OK;
+      Standard_Integer aNbIter = 10;
       while (!Arrive) {  // as no test of stop is passed
-       Cadre=Cadrage(BornInf,BornSup,Uvap,PasC, StepSign);  // border?
+        Cadre=Cadrage(BornInf,BornSup,Uvap,PasC, StepSign);  // border?
 #ifdef CHRONO
-       Chronrsnld.Start();
+        Chronrsnld.Start();
 #endif
 
-       Rsnld.Perform(Func,Uvap,BornInf,BornSup);
+        Rsnld.Perform(Func,Uvap,BornInf,BornSup);
 
 #ifdef CHRONO
-       Chronrsnld.Stop();
+        Chronrsnld.Stop();
 #endif
 
-       if (Cadre) { // update of limits.
-         BornInf(1) = Um;BornSup(1) = UM;BornInf(2) = Vm;BornSup(2) = VM;
-       }
-       if (Rsnld.IsDone()) {
-         if (Abs(Func.Root()) > Func.Tolerance()) { // no solution for the tolerance
-           PasC = PasC/2.;
-           PasCu = Abs(PasC*previousd2d.X());
-           PasCv = Abs(PasC*previousd2d.Y());
-
-           if (PasCu <= tolerance(1) && PasCv <= tolerance(2)) {
-             if (CurrentLine->NbPoints()==1) break;
-             Arrive = Standard_True;
-             CurrentLine->AddStatusFirstLast(Standard_False,
-                                             Standard_False,Standard_False);
-             Rajout = Standard_True;
+        if (Cadre) { // update of limits.
+          BornInf(1) = Um;BornSup(1) = UM;BornInf(2) = Vm;BornSup(2) = VM;
+        }
+        if (Rsnld.IsDone()) {
+          if (Abs(Func.Root()) > Func.Tolerance()) { // no solution for the tolerance
+            PasC = PasC/2.;
+            PasCu = Abs(PasC*previousd2d.X());
+            PasCv = Abs(PasC*previousd2d.Y());
+
+            if (PasCu <= tolerance(1) && PasCv <= tolerance(2)) {
+              if (CurrentLine->NbPoints()==1) break;
+              Arrive = Standard_True;
+              CurrentLine->AddStatusFirstLast(Standard_False,
+                Standard_False,Standard_False);
+              Rajout = Standard_True;
               seqAjout.Append(lines.Length()+1);
-             Tgtend = Standard_True;
-           }
-         }
-         else { // there is a solution
-           Rsnld.Root(Uvap);
-           Arrive = TestArretPassage(Umult,Vmult,Uvap,I,Ipass);
-           if (Arrive) {//reset proper parameter to test the arrow.
-             Psol = CurrentLine->Value(1);
-             if (!reversed) {
-               Psol.ParametersOnS2(Uvap(1),Uvap(2));
-             }
-             else {
-               Psol.ParametersOnS1(Uvap(1),Uvap(2));
-             }
+              Tgtend = Standard_True;
+            }
+          }
+          else { // there is a solution
+            Rsnld.Root(Uvap);
+            Arrive = TestArretPassage(Umult,Vmult,Uvap,I,Ipass);
+            if (Arrive) {//reset proper parameter to test the arrow.
+              Psol = CurrentLine->Value(1);
+              if (!reversed) {
+                Psol.ParametersOnS2(Uvap(1),Uvap(2));
+              }
+              else {
+                Psol.ParametersOnS1(Uvap(1),Uvap(2));
+              }
               Cadre=Standard_False; 
-             //in case if there is a frame and arrival at the same time
-           }
-           else { // modif jag 940615
-
-             if (Rajout) {    // test on added points
-               ArretAjout =TestArretAjout(Func,Uvap,N,Psol);
-               if (ArretAjout) {
-                 if (N >0) {
-                   Tgtend = lines.Value(N)->IsTangentAtEnd();
-                   N = -N;
-                 }
-                 else {
-                   Tgtend = lines.Value(-N)->IsTangentAtBegining();
-                 }
-                 Arrive = (wd2[I].etat == 12);
-               }
-             }
-
-             if (!ArretAjout&& Cadre) {  // test on already marked points
-               if (CurrentLine->NbPoints() == 1)  break; // cancel the line
-               TestArretCadre(Umult,Vmult,CurrentLine,Func,Uvap,N);
-//             if (N==0) {
-               if (N <= 0) { // jag 941017
-                 MakeWalkingPoint(2,Uvap(1),Uvap(2),Func,Psol);
-                 Tgtend = Func.IsTangent(); // jag 940616
-                 N = -N;
-               }
-               Arrive = (wd2[I].etat == 12); // the line is open
-             }
-           }
-           Status = TestDeflection(Func, Arrive,Uvap,StatusPrecedent,
-                                   NbDivision,PasC,StepSign);
-           StatusPrecedent = Status; 
-           if (Status == IntWalk_PasTropGrand) {// division of the step
-             Arrive = Standard_False;
-             ArretAjout = Standard_False;
-             Tgtend = Standard_False; // jag 940616
-             if (!reversed) {
-               previousPoint.ParametersOnS2(Uvap(1),Uvap(2));
-             }
-             else {
-               previousPoint.ParametersOnS1(Uvap(1),Uvap(2));
-             }
-           }
-           else if (ArretAjout || Cadre) {
-
-             if (Arrive) { // line s is open
-               CurrentLine->AddStatusLast(Standard_False);
-               if (Status != IntWalk_ArretSurPointPrecedent) {
-                 CurrentLine->AddPoint(Psol);                      
-               }
-               if (Cadre && N==0) {
-                 Rajout = Standard_True;
-                 seqAjout.Append(lines.Length()+1);
-               }
-                
-             }
-             else { // open
-               wd2[I].etat = 12; // declare it open
-               Tgtbeg = Tgtend;
-               Tgtend = Standard_False;
-               ArretAjout = Standard_False;
-               StepSign = -1;
+              //in case if there is a frame and arrival at the same time
+            }
+            else { // modif jag 940615
+              if (Rajout) {    // test on added points
+                ArretAjout =TestArretAjout(Func,Uvap,N,Psol);
+                if (ArretAjout) {
+                  if (N >0) {
+                    Tgtend = lines.Value(N)->IsTangentAtEnd();
+                    N = -N;
+                  }
+                  else {
+                    Tgtend = lines.Value(-N)->IsTangentAtBegining();
+                  }
+                  Arrive = (wd2[I].etat == 12);
+                }
+              }
+
+              if (!ArretAjout&& Cadre) {  // test on already marked points
+                if (CurrentLine->NbPoints() == 1)  break; // cancel the line
+                TestArretCadre(Umult,Vmult,CurrentLine,Func,Uvap,N);
+                //             if (N==0) {
+                if (N <= 0) { // jag 941017
+                  MakeWalkingPoint(2,Uvap(1),Uvap(2),Func,Psol);
+                  Tgtend = Func.IsTangent(); // jag 940616
+                  N = -N;
+                }
+                Arrive = (wd2[I].etat == 12); // the line is open
+              }
+            }
+            Status = TestDeflection(Func, Arrive,Uvap,StatusPrecedent,
+                                                NbDivision,PasC,StepSign);
+
+            StatusPrecedent = Status; 
+            if (Status == IntWalk_PasTropGrand) {// division of the step
+              Arrive = Standard_False;
+              ArretAjout = Standard_False;
+              Tgtend = Standard_False; // jag 940616
+              if (!reversed) {
+                previousPoint.ParametersOnS2(Uvap(1),Uvap(2));
+              }
+              else {
+                previousPoint.ParametersOnS1(Uvap(1),Uvap(2));
+              }
+            }
+            else if (ArretAjout || Cadre) {
+
+              if (Arrive) { // line s is open
+                CurrentLine->AddStatusLast(Standard_False);
+                if (Status != IntWalk_ArretSurPointPrecedent) {
+                  CurrentLine->AddPoint(Psol);                      
+                }
+                if (Cadre && N==0) {
+                  Rajout = Standard_True;
+                  seqAjout.Append(lines.Length()+1);
+                }
+
+              }
+              else { // open
+                wd2[I].etat = 12; // declare it open
+                Tgtbeg = Tgtend;
+                Tgtend = Standard_False;
+                ArretAjout = Standard_False;
+                StepSign = -1;
                 StatusPrecedent = IntWalk_OK;
-               PasC = PasSav;
-               if (Status == IntWalk_ArretSurPointPrecedent) {
-                 OpenLine(0,Psol,Pnts1,Func,CurrentLine);
-               }
-               else {
-                 OpenLine(-lines.Length()-1,Psol,Pnts1,Func,CurrentLine);
-               }
-               if (Cadre && N==0) {
-                 Rajout = Standard_True;
-                 seqAjout.Append(-lines.Length()-1);
-               }
-             }
-           }
-
-           else if ( Status == IntWalk_ArretSurPointPrecedent) {
-             if (CurrentLine->NbPoints() == 1) { //cancel the line
-               Arrive = Standard_False;
-               break;
-             }
-             if (wd2[I].etat >12) { //the line should become open
-               wd2[I].etat = 12; //declare it open
-               ArretAjout = Standard_False;
-               OpenLine(0,Psol,Pnts1,Func,CurrentLine);
-               StepSign = -1;
+                PasC = PasSav;
+                if (Status == IntWalk_ArretSurPointPrecedent) {
+                  OpenLine(0,Psol,Pnts1,Func,CurrentLine);
+                }
+                else {
+                  OpenLine(-lines.Length()-1,Psol,Pnts1,Func,CurrentLine);
+                }
+                if (Cadre && N==0) {
+                  Rajout = Standard_True;
+                  seqAjout.Append(-lines.Length()-1);
+                }
+              }
+            }
+            else if ( Status == IntWalk_ArretSurPointPrecedent) {
+              if (CurrentLine->NbPoints() == 1) { //cancel the line
+                Arrive = Standard_False;
+                break;
+              }
+              if (wd2[I].etat >12) { //the line should become open
+                wd2[I].etat = 12; //declare it open
+                ArretAjout = Standard_False;
+                OpenLine(0,Psol,Pnts1,Func,CurrentLine);
+                StepSign = -1;
                 StatusPrecedent = IntWalk_OK;
-               Arrive = Standard_False;
-               PasC = PasSav;
-               Rajout = Standard_True;
+                Arrive = Standard_False;
+                PasC = PasSav;
+                Rajout = Standard_True;
                 seqAjout.Append(-lines.Length()-1);
-             }
-             else { // line s is open                 
-               Arrive =Standard_True;
-               CurrentLine->AddStatusLast(Standard_False);
-               Rajout = Standard_True;
+              }
+              else { // line s is open                 
+                Arrive =Standard_True;
+                CurrentLine->AddStatusLast(Standard_False);
+                Rajout = Standard_True;
                 seqAjout.Append(lines.Length()+1);
-             } 
-           }
-           else if (Arrive)  {
-             if (wd2[I].etat > 12) {  //line closed good case
-               CurrentLine->AddStatusFirstLast(Standard_True,
-                                               Standard_False,Standard_False);
-               CurrentLine->AddPoint(CurrentLine->Value(1));              
-             }
-             else if (N >0) { //point of stop given at input 
-               PathPnt = Pnts1.Value(N);
-               CurrentLine->AddStatusLast(Standard_True,N,PathPnt);
+              
+            }
+            else if (Arrive)  {
+              if (wd2[I].etat > 12) {  //line closed good case
+                CurrentLine->AddStatusFirstLast(Standard_True,
+                  Standard_False,Standard_False);
+                CurrentLine->AddPoint(CurrentLine->Value(1));              
+              }
+              else if (N >0) { //point of stop given at input 
+                PathPnt = Pnts1.Value(N);
+                CurrentLine->AddStatusLast(Standard_True,N,PathPnt);
                 AddPointInCurrentLine(N,PathPnt,CurrentLine);
-             }
-           }
-           else if (Status == IntWalk_ArretSurPoint) {
-             if (wd2[I].etat >12) { //line should become open
-               wd2[I].etat = 12; //declare it open
-               Tgtbeg = Standard_True;
-               Tgtend = Standard_False;
+              }
+            }
+            else if (Status == IntWalk_ArretSurPoint) {
+              if (wd2[I].etat >12) { //line should become open
+                wd2[I].etat = 12; //declare it open
+                Tgtbeg = Standard_True;
+                Tgtend = Standard_False;
                 N= -lines.Length()-1;
                 Psol.SetValue(Func.Point(),reversed,Uvap(1),Uvap(2));
-               OpenLine(N,Psol,Pnts1,Func,CurrentLine);
-               StepSign = -1;
-               Rajout = Standard_True;
+                OpenLine(N,Psol,Pnts1,Func,CurrentLine);
+                StepSign = -1;
+                Rajout = Standard_True;
                 seqAjout.Append(N);
                 StatusPrecedent = IntWalk_OK;
-               Arrive = Standard_False;
-               PasC = PasSav;  
-             }
-             else { 
-               Arrive = Standard_True;                   
-               if (Ipass!=0) { //point of passage, point of stop
-                 PathPnt = Pnts1.Value(Ipass);
-                 CurrentLine->AddStatusLast(Standard_True,Ipass,PathPnt);
+                Arrive = Standard_False;
+                PasC = PasSav; 
+              }
+              else { 
+                Arrive = Standard_True;                   
+                if (Ipass!=0) { //point of passage, point of stop
+                  PathPnt = Pnts1.Value(Ipass);
+                  CurrentLine->AddStatusLast(Standard_True,Ipass,PathPnt);
                   AddPointInCurrentLine(Ipass,PathPnt,CurrentLine);
-               }
-               else {
+                }
+                else {
                   CurrentLine->AddStatusLast(Standard_False);
-                 IntSurf_PntOn2S newP;
-                 newP.SetValue(Func.Point(),reversed,Uvap(1),Uvap(2));
+                  IntSurf_PntOn2S newP;
+                  newP.SetValue(Func.Point(),reversed,Uvap(1),Uvap(2));
                   CurrentLine->AddPoint(newP);
-                 Rajout = Standard_True;
-                 seqAjout.Append(lines.Length()+1);
+                  Rajout = Standard_True;
+                  seqAjout.Append(lines.Length()+1);
                 }
-             }
-           }
-           else if (Status == IntWalk_OK) { 
-             if (Ipass!=0) CurrentLine->AddIndexPassing(Ipass);
-             previousPoint.SetValue(Func.Point(),reversed,Uvap(1),Uvap(2));
-             previousd3d = Func.Direction3d();
-             previousd2d = Func.Direction2d();
-             CurrentLine->AddPoint(previousPoint);
-           }
-         }
-       }
-       else { //no numerical solution NotDone
-         PasC = PasC/2.;
-         PasCu = Abs(PasC*previousd2d.X());
-         PasCv = Abs(PasC*previousd2d.Y());
-
-         if (PasCu <= tolerance(1) && PasCv <= tolerance(2)) {
+              }
+            }
+            else if (Status == IntWalk_OK) { 
+              if (Ipass!=0) CurrentLine->AddIndexPassing(Ipass);
+              previousPoint.SetValue(Func.Point(),reversed,Uvap(1),Uvap(2));
+              previousd3d = Func.Direction3d();
+              previousd2d = Func.Direction2d();
+              CurrentLine->AddPoint(previousPoint);
+            }
+            else if (Status == IntWalk_PointConfondu)
+            {
+              aNbIter --;
+            }
+          }
+        }
+        else { //no numerical solution NotDone
+          PasC = PasC/2.;
+          PasCu = Abs(PasC*previousd2d.X());
+          PasCv = Abs(PasC*previousd2d.Y());
+
+          if (PasCu <= tolerance(1) && PasCv <= tolerance(2)) {
             if (CurrentLine->NbPoints() == 1)  break; // cancel the line
-           Arrive = Standard_True;
-           CurrentLine->AddStatusFirstLast(Standard_False,Standard_False,
-                                           Standard_False);
-           Tgtend = Standard_True;
-           Rajout = Standard_True;
-           seqAjout.Append(lines.Length()+1);
-         }  
-       }
+            Arrive = Standard_True;
+            CurrentLine->AddStatusFirstLast(Standard_False,Standard_False,
+              Standard_False);
+            Tgtend = Standard_True;
+            Rajout = Standard_True;
+            seqAjout.Append(lines.Length()+1);
+          }  
+        }
+
+        if(aNbIter < 0)
+          break;
       }// end of started line 
       if (Arrive) {
-       CurrentLine->SetTangencyAtBegining(Tgtbeg);
-       CurrentLine->SetTangencyAtEnd(Tgtend);
-       
-       lines.Append(CurrentLine);
-       wd2[I].etat=-wd2[I].etat; //mark point as processed
+        CurrentLine->SetTangencyAtBegining(Tgtbeg);
+        CurrentLine->SetTangencyAtEnd(Tgtend);
+
+        lines.Append(CurrentLine);
+        wd2[I].etat=-wd2[I].etat; //mark point as processed
       }
     } //end of processing of start point
   } //end of all start points
index 84da416112f066eb57fc6948e9fb3ec715955c78..5747d79027757365c6707f0b72e559d5011c67e2 100644 (file)
@@ -58,85 +58,83 @@ IntWalk_StatusDeflection IntWalk_IWalking::TestDeflection
   //-- if epsilon is great enough (1e-11). In this case one loops 
   //-- without ever changing the values sent to Rsnld. 
   //---------------------------------------------------------------------------------
-  Standard_Real Paramu, Paramv, StepU,StepV;
-  Standard_Real Cosi, Cosi2, Norme;
+  Standard_Real Paramu = 0.0, Paramv = 0.0;
+
+  if (!reversed) {
+    previousPoint.ParametersOnS2(Paramu, Paramv);
+  }
+  else
+  {
+    previousPoint.ParametersOnS1(Paramu, Paramv);
+  }
+
+  const Standard_Real Du = UV(1) - Paramu;
+  const Standard_Real Dv = UV(2) - Paramv;
+  const Standard_Real Duv = Du * Du + Dv * Dv;
 
   gp_Vec Corde(previousPoint.Value(), sp.Point());
 
-  Norme = Corde.SquareMagnitude();
-//  if (Norme <= epsilon*epsilon) {
-  if ((++NbPointsConfondusConsecutifs < 10) && (Norme <= epsilon)) { // the square is already taken in the constructor
+  const Standard_Real Norme = Corde.SquareMagnitude(), 
+                      aTol = epsilon*Precision::PConfusion();
+
+  //if ((++NbPointsConfondusConsecutifs < 10) && (Norme <= epsilon)) { // the square is already taken in the constructor
+  if ((Norme <= epsilon) && ((Duv <= aTol) || (StatusPrecedent != IntWalk_OK)))
+  { // the square is already taken in the constructor
     Status = IntWalk_PointConfondu;
     if (StatusPrecedent == IntWalk_PasTropGrand) {
       return IntWalk_ArretSurPointPrecedent;
     }
-
-    if(++EpsilonSembleTropGrand > 5   &&  NbPointsConfondusConsecutifs == 8)  {     //--    Temporary 
-      if(epsilon>0.00000000001) epsilon*=0.5;                                       //--    Temporary
-      EpsilonSembleTropGrand = 0;                                                   //--    Temporary 
-    }
   }
   else {
-    NbPointsConfondusConsecutifs = 0;   //--    Temporary
-    EpsilonSembleTropGrand = 0;         //--    Temporary
-    if(Norme<1e-16) Norme = 1e-16;      //--    Temporary 
-    
-    Cosi = Corde * previousd3d;
-    if (Cosi*StepSign < 0.) { // angle 3d > pi/2 !!!!
-      Cosi2 = 0.;
-    }
-    else {
-      Cosi2 = Cosi * Cosi / previousd3d.SquareMagnitude() / Norme;
+    Standard_Real Cosi = Corde * previousd3d;
+    Standard_Real Cosi2 = 0.0;
+
+    if (Cosi*StepSign >= 0.) {// angle 3d <= pi/2 !!!!
+      const Standard_Real aDiv = previousd3d.SquareMagnitude()*Norme;
+      if(aDiv == 0)
+        return Status;
+      Cosi2 = Cosi * Cosi / aDiv;
     }
     if (Cosi2 < CosRef3D) { //angle 3d too great
       Step = Step /2.0;
-      StepU = Abs(Step*previousd2d.X());
-      StepV = Abs(Step*previousd2d.Y());
+      Standard_Real StepU = Abs(Step*previousd2d.X()),
+                    StepV = Abs(Step*previousd2d.Y());
       if (StepU < tolerance(1) && StepV < tolerance(2)) 
-       Status = IntWalk_ArretSurPointPrecedent;
+        Status = IntWalk_ArretSurPointPrecedent;
       else 
-       Status = IntWalk_PasTropGrand;
+        Status = IntWalk_PasTropGrand;
       return Status;
     }
   }
 
-  if (!reversed) {
-    previousPoint.ParametersOnS2(Paramu, Paramv);
-  }
-  else {
-    previousPoint.ParametersOnS1(Paramu, Paramv);
-  }
-  Standard_Real Du = UV(1) - Paramu;
-  Standard_Real Dv = UV(2) - Paramv;
-  Standard_Real Duv = Du * Du + Dv * Dv;
   if (Abs(Du) < tolerance(1) && Abs(Dv) < tolerance(2))
     return IntWalk_ArretSurPointPrecedent; //confused point 2d
-  Cosi = StepSign * (Du * previousd2d.X() + 
-                     Dv * previousd2d.Y());
+
+  Standard_Real Cosi = StepSign * (Du * previousd2d.X() + Dv * previousd2d.Y());
+
   if (Cosi < 0 && Status == IntWalk_PointConfondu) 
     return IntWalk_ArretSurPointPrecedent; // leave as step back  
                                            // with confused point
 
-
   if (sp.IsTangent()) 
     return IntWalk_ArretSurPoint;       
 
 //if during routing one has subdivided more than  MaxDivision for each
 //previous step, bug on the square; do nothing (experience U4)
 
-  if (NbDivision < MaxDivision && 
-      Status != IntWalk_PointConfondu && 
-      StatusPrecedent!= IntWalk_PointConfondu ) {
-    Cosi2 = Cosi * Cosi / Duv;
+  if ((NbDivision < MaxDivision) && (Status != IntWalk_PointConfondu) && 
+    (StatusPrecedent!= IntWalk_PointConfondu))
+  {
+    Standard_Real Cosi2 = Cosi * Cosi / Duv;
     if (Cosi2 < CosRef2D || Cosi < 0  ) {
       Step = Step / 2.0;
-      StepU = Abs(Step*previousd2d.X());
-      StepV = Abs(Step*previousd2d.Y());
+      Standard_Real StepU = Abs(Step*previousd2d.X()),
+                    StepV = Abs(Step*previousd2d.Y());
 
       if (StepU < tolerance(1) && StepV < tolerance(2))
-       Status = IntWalk_ArretSurPointPrecedent;
+        Status = IntWalk_ArretSurPointPrecedent;
       else 
-       Status = IntWalk_PasTropGrand;
+        Status = IntWalk_PasTropGrand;
       NbDivision = NbDivision + 1;
       return Status;
     }
@@ -145,139 +143,149 @@ IntWalk_StatusDeflection IntWalk_IWalking::TestDeflection
     Cosi2 = Cosi * Cosi / sp.Direction3d().SquareMagnitude() / Norme;
     if (Cosi2 < CosRef3D ){ //angle 3d too great
       Step = Step / 2.;
-      StepU = Abs(Step*previousd2d.X());
-      StepV = Abs(Step*previousd2d.Y());
+      Standard_Real StepU = Abs(Step*previousd2d.X()),
+                    StepV = Abs(Step*previousd2d.Y());
       if (StepU < tolerance(1) && StepV < tolerance(2))
-       Status = IntWalk_ArretSurPoint;
+        Status = IntWalk_ArretSurPoint;
       else 
-       Status = IntWalk_PasTropGrand;
+        Status = IntWalk_PasTropGrand;
       return Status;
     }
     Cosi = Du * sp.Direction2d().X() + 
-           Dv * sp.Direction2d().Y();
+      Dv * sp.Direction2d().Y();
     Cosi2 = Cosi * Cosi / Duv;
     if (Cosi2 < CosRef2D || 
-       sp.Direction2d() * previousd2d < 0) {
-      //angle 2d too great or change the side       
-      Step  = Step / 2.;
-      StepU = Abs(Step*previousd2d.X());
-      StepV = Abs(Step*previousd2d.Y());
-      if (StepU < tolerance(1) && StepV < tolerance(2))
-       Status = IntWalk_ArretSurPointPrecedent;
-      else 
-       Status = IntWalk_PasTropGrand;
-      return Status;
+      sp.Direction2d() * previousd2d < 0) {
+        //angle 2d too great or change the side       
+        Step  = Step / 2.;
+        Standard_Real StepU = Abs(Step*previousd2d.X()),
+                      StepV = Abs(Step*previousd2d.Y());
+        if (StepU < tolerance(1) && StepV < tolerance(2))
+          Status = IntWalk_ArretSurPointPrecedent;
+        else 
+          Status = IntWalk_PasTropGrand;
+        return Status;
     }
   }
 
   if (!Finished) {
-
-    if (Status == IntWalk_PointConfondu) {
-      StepU = Min(Abs(1.5 * Du),pas*(UM-Um));
-      StepV = Min(Abs(1.5 * Dv),pas*(VM-Vm));
+    if (Status == IntWalk_PointConfondu)
+    {
+      Standard_Real StepU = Min(Abs(1.5 * Du),pas*(UM-Um)),
+                    StepV = Min(Abs(1.5 * Dv),pas*(VM-Vm));
 
       Standard_Real d2dx = Abs(previousd2d.X()); 
       Standard_Real d2dy = Abs(previousd2d.Y()); 
 
-      if (d2dx < tolerance(1)) {
-       Step = StepV/d2dy;
+      if (d2dx < tolerance(1))
+      {
+        Step = StepV/d2dy;
       }
-      else if (d2dy < tolerance(2)) {
-       Step = StepU/d2dx;
+      else if (d2dy < tolerance(2))
+      {
+        Step = StepU/d2dx;
       }
-      else {
-       Step = Min(StepU/d2dx,StepV/d2dy);
+      else
+      {
+        Step = Min(StepU/d2dx,StepV/d2dy);
       }
-
-
-
     }
-    else {
-//   estimate the current vector.
-//   if vector/2<=current vector<= vector it is considered that the criterion
-//   is observed.
-//   otherwise adjust the step depending on the previous step 
-
-/*
-      Standard_Real Dist = Sqrt(Norme)/3.;
-      TColgp_Array1OfPnt Poles(1,4);
-      gp_Pnt POnCurv,Milieu;
-      Poles(1) = previousPoint.Value();
-      Poles(4) = sp.Point();
-      Poles(2) = Poles(1).XYZ() + 
-       StepSign * Dist* previousd3d.Normalized().XYZ();
-      Poles(3) = Poles(4).XYZ() - 
-       StepSign * Dist*sp.Direction3d().Normalized().XYZ();
-      BzCLib::PntPole(0.5,Poles,POnCurv);
-      Milieu = (Poles(1).XYZ() + Poles(4).XYZ())*0.5;
-//      FlecheCourante = Milieu.Distance(POnCurv);
-      Standard_Real FlecheCourante = Milieu.SquareDistance(POnCurv);
-*/
-
-      // Direct calculation : 
-      // POnCurv=(((p1+p2)/2.+(p2+p3)/2.)/2. + ((p2+p3)/2.+(p3+P4)/2.)/2.)/2.
-      // either POnCurv = p1/8. + 3.p2/8. + 3.p3/8. + p4/8.
-      // Or p2 = p1 + lambda*d1 et p3 = p4 - lambda*d4
-      // So POnCurv = (p1 + p4)/2. + 3.*(lambda d1 - lambda d4)/8.
-      // Calculate the deviation with (p1+p4)/2. . So it is just necessary to calculate
-      // the norm (square) of 3.*lambda (d1 - d4)/8.
-      // either the norm of :
-      //    3.*(Sqrt(Norme)/3.)*StepSign*(d1-d4)/8.
-      // which produces, takin the square :
-      //         Norme * (d1-d4).SquareMagnitude()/64.
+    else
+    {
+      //   estimate the current vector.
+      //   if vector/2<=current vector<= vector it is considered that the criterion
+      //   is observed.
+      //   otherwise adjust the step depending on the previous step 
+
+      /*
+        Standard_Real Dist = Sqrt(Norme)/3.;
+        TColgp_Array1OfPnt Poles(1,4);
+        gp_Pnt POnCurv,Milieu;
+        Poles(1) = previousPoint.Value();
+        Poles(4) = sp.Point();
+        Poles(2) = Poles(1).XYZ() + 
+      StepSign * Dist* previousd3d.Normalized().XYZ();
+        Poles(3) = Poles(4).XYZ() - 
+      StepSign * Dist*sp.Direction3d().Normalized().XYZ();
+        BzCLib::PntPole(0.5,Poles,POnCurv);
+        Milieu = (Poles(1).XYZ() + Poles(4).XYZ())*0.5;
+      //      FlecheCourante = Milieu.Distance(POnCurv);
+        Standard_Real FlecheCourante = Milieu.SquareDistance(POnCurv);
+      */
+
+        // Direct calculation : 
+        // POnCurv=(((p1+p2)/2.+(p2+p3)/2.)/2. + ((p2+p3)/2.+(p3+P4)/2.)/2.)/2.
+        // either POnCurv = p1/8. + 3.p2/8. + 3.p3/8. + p4/8.
+        // Or p2 = p1 + lambda*d1 et p3 = p4 - lambda*d4
+        // So POnCurv = (p1 + p4)/2. + 3.*(lambda d1 - lambda d4)/8.
+        // Calculate the deviation with (p1+p4)/2. . So it is just necessary to calculate
+        // the norm (square) of 3.*lambda (d1 - d4)/8.
+        // either the norm of :
+        //    3.*(Sqrt(Norme)/3.)*StepSign*(d1-d4)/8.
+        // which produces, takin the square :
+        //         Norme * (d1-d4).SquareMagnitude()/64.
 
       Standard_Real FlecheCourante = 
        (previousd3d.Normalized().XYZ()-sp.Direction3d().Normalized().XYZ()).SquareModulus()*Norme/64.;
 
   
 //      if (FlecheCourante <= 0.5*fleche) {
-      if (FlecheCourante <= 0.25*fleche*fleche) {
-
-       Standard_Real d2dx = Abs(sp.Direction2d().X()); 
-       Standard_Real d2dy = Abs(sp.Direction2d().Y()); 
-
-       StepU = Min(Abs(1.5*Du),pas*(UM-Um));
-       StepV = Min(Abs(1.5*Dv),pas*(VM-Vm));
-
-       if (d2dx < tolerance(1)) {
-         Step = StepV/d2dy;
-       }
-       else if (d2dy < tolerance(2)) {
-         Step = StepU/d2dx;
-       }
-       else {
-         Step = Min(StepU/d2dx,StepV/d2dy);
-       }
-       
+      if (FlecheCourante <= 0.25*fleche*fleche)
+      {
+        Standard_Real d2dx = Abs(sp.Direction2d().X()); 
+        Standard_Real d2dy = Abs(sp.Direction2d().Y()); 
+        
+        Standard_Real StepU = Min(Abs(1.5*Du),pas*(UM-Um)),
+                      StepV = Min(Abs(1.5*Dv),pas*(VM-Vm));
+
+        if (d2dx < tolerance(1))
+        {
+          Step = StepV/d2dy;
+        }
+        else if (d2dy < tolerance(2))
+        {
+          Step = StepU/d2dx;
+        }
+        else
+        {
+          Step = Min(StepU/d2dx,StepV/d2dy);
+        }      
       }
-      else {
-//     if (FlecheCourante > fleche) {  // step too great
-       if (FlecheCourante > fleche*fleche) {  // step too great
-         Step = Step /2.;
-          StepU = Abs(Step*previousd2d.X());
-          StepV = Abs(Step*previousd2d.Y());
+      else
+      {
+        //if (FlecheCourante > fleche) {  // step too great
+        if (FlecheCourante > fleche*fleche)
+        {  // step too great
+          Step = Step /2.;
+          Standard_Real StepU = Abs(Step*previousd2d.X()),
+                        StepV = Abs(Step*previousd2d.Y());
+          
           if (StepU < tolerance(1) && StepV < tolerance(2)) 
             Status = IntWalk_ArretSurPointPrecedent;
           else 
             Status = IntWalk_PasTropGrand;
-       }
-       else {
-         Standard_Real d2dx = Abs(sp.Direction2d().X()); 
-         Standard_Real d2dy = Abs(sp.Direction2d().Y()); 
-
-         StepU = Min(Abs(1.5*Du),pas*(UM-Um));
-         StepV = Min(Abs(1.5*Dv),pas*(VM-Vm));
-
-         if (d2dx < tolerance(1)) {
-           Step = Min(Step,StepV/d2dy);
-         }
-         else if (d2dy < tolerance(2)) {
-           Step = Min(Step,StepU/d2dx);
-         }
-         else {
-           Step = Min(Step,Min(StepU/d2dx,StepV/d2dy));
-         }
-       }
+        }
+        else
+        {
+          Standard_Real d2dx = Abs(sp.Direction2d().X()); 
+          Standard_Real d2dy = Abs(sp.Direction2d().Y()); 
+          
+          Standard_Real StepU = Min(Abs(1.5*Du),pas*(UM-Um)),
+                        StepV = Min(Abs(1.5*Dv),pas*(VM-Vm));
+
+          if (d2dx < tolerance(1))
+          {
+            Step = Min(Step,StepV/d2dy);
+          }
+          else if (d2dy < tolerance(2))
+          {
+            Step = Min(Step,StepU/d2dx);
+          }
+          else
+          {
+            Step = Min(Step,Min(StepU/d2dx,StepV/d2dy));
+          }
+        }
       }
     }
   }
diff --git a/tests/bugs/modalg_5/bug25416_1 b/tests/bugs/modalg_5/bug25416_1
new file mode 100644 (file)
index 0000000..f36c2b0
--- /dev/null
@@ -0,0 +1,124 @@
+puts "================"
+puts "OCC25416"
+puts "================"
+puts ""
+#######################################################################
+# Face/Face intersection algorithm gives different results for different order of the arguments
+#######################################################################
+
+# Check if list of xdistcs-command is valid
+proc checkList {List Tolerance D_good Limit_Tol} {
+   set L1 [llength ${List}]
+   set L2 10
+   set L3 5
+   set N [expr (${L1} - ${L2})/${L3} + 1]
+
+   for {set i 1} {${i} <= ${N}} {incr i} {
+      set j1 [expr ${L2} + (${i}-1)*${L3}]
+      set j2 [expr ${j1} + 2]
+      set T [lindex ${List} ${j1}]
+      set D [lindex ${List} ${j2}]
+      #puts "i=${i} j1=${j1} j2=${j2} T=${T} D=${D}"
+      if { [expr abs(${D} - ${D_good})] > ${Tolerance} } {
+         puts "Error: T=${T} D=${D}"
+      }
+      
+      if { ${Tolerance} > ${Limit_Tol} } {
+        if { [expr abs(${D} - ${D_good})] > ${Limit_Tol} 
+             && [expr abs(${D} - ${D_good})] <= ${Tolerance} } {
+           puts "Attention (critical value of tolerance) : T=${T} D=${D}"
+        }
+      }
+   }
+}
+
+
+puts "##############################"
+puts "#!!!Search \"Attention\" keyword on this web-page for additional checking!!!"
+puts "##############################"
+puts ""
+puts ""
+
+# bopcurves command
+
+restore [locate_data_file bug25416_f1.brep] f1
+restore [locate_data_file bug25416_f2.brep] f2
+
+#############################
+set log [bopcurves f1 f2 -2d]
+#############################
+
+regexp {Tolerance Reached=+([-0-9.+eE]+)\n+([-0-9.+eE]+)} ${log} full Toler NbCurv
+
+#This value must be equal to the analogical value in bug25292_31 and bug25292_32 of "bugs modalg_5" testgrid. 
+set MaxTol 1.e-6
+
+#This value must be equal to the analogical value in bug25292_31 and bug25292_32 of "bugs modalg_5" testgrid. 
+set GoodNbCurv 1
+
+if {${Toler} > ${MaxTol}} {
+  puts "Error: Tolerance is too big!"
+}
+if {${NbCurv} != ${GoodNbCurv}} {
+  puts "Error: Curve Number is bad!"
+}
+
+#-------------
+
+mksurface s1 f1
+mksurface s2 f2
+
+erase s1 s2
+
+for {set i 1} {$i <= ${NbCurv}} {incr i} {
+  set log [dump c_$i]
+  set dumptrimres [regexp {Trimmed curve\nParameters : +([-0-9.+eE]+) +([-0-9.+eE]+)} ${log} full U1 U2]
+  
+  if {${dumptrimres} == 0} {
+    regexp {Degree +([-0-9.+eE]+), +([-0-9.+eE]+) Poles, +([-0-9.+eE]+)} ${log} full Degree Poles KnotsPoles
+    
+    puts "Degree=${Degree}"
+    puts "Poles=${Poles}"
+    puts "KnotsPoles=${KnotsPoles}"
+    puts ""
+    
+    set Knot 1
+    set exp_string "Knots :\n\n +${Knot} :  +(\[-0-9.+eE\]+) +(\[-0-9.+eE\]+)"
+    regexp ${exp_string} ${log} full U1 Mult1
+    
+    set Knot ${KnotsPoles}
+    set exp_string " +${Knot} :  +(\[-0-9.+eE\]+) +(\[-0-9.+eE\]+)"
+    regexp ${exp_string} ${log} full U2 Mult2
+  }
+  
+  puts "U1=${U1}"
+  puts "U2=${U2}"
+  
+  if {[expr {$U2 - $U1}] < 1.0e-20} {
+    puts "Error: Wrong curve's range!"
+  }
+
+  dlog reset
+  dlog on
+  xdistcs c_$i s1 ${U1} ${U2} 10
+  set Log2 [dlog get]
+  set List2 [split ${Log2} {TD= \t\n}]
+  set Tolerance 1.0e-7
+  set Limit_Tol 1.0e-7
+  set D_good 0.
+  checkList ${List2} ${Tolerance} ${D_good} ${Limit_Tol}
+
+  dlog reset
+  dlog on
+  xdistcs c_$i s2 ${U1} ${U2} 10
+  set Log2 [dlog get]
+  set List2 [split ${Log2} {TD= \t\n}]
+  set Tolerance 1.0e-7
+  set Limit_Tol 1.0e-7
+  set D_good 0.
+  checkList ${List2} ${Tolerance} ${D_good} ${Limit_Tol}
+}
+
+smallview
+fit
+set only_screen_axo 1
diff --git a/tests/bugs/modalg_5/bug25697_1 b/tests/bugs/modalg_5/bug25697_1
new file mode 100644 (file)
index 0000000..a0c7d87
--- /dev/null
@@ -0,0 +1,20 @@
+puts "==========="
+puts "OCC25697"
+puts "==========="
+puts ""
+##########################################################################################
+# Regression : Section obtained after command "bsection" in Test Harness is incorrect.
+##########################################################################################
+
+restore [locate_data_file bug25697_shell_for_seam.brep] s1
+restore [locate_data_file bug25697_prism.brep] p1
+bsection result s1 p1 -n2d2
+
+regexp {nb alone Vertices : +([-0-9.+eE]+)} [checksection result] full nb_alone_Vertices
+if { ${nb_alone_Vertices} == 2 } {
+  puts "OK: Good result done by Boolean Operation algorithm"
+} else {
+  puts "Error: Wrong result done by Boolean Operation algorithm"
+}
+
+set length 107.503
diff --git a/tests/bugs/modalg_5/bug25697_2 b/tests/bugs/modalg_5/bug25697_2
new file mode 100644 (file)
index 0000000..36b8621
--- /dev/null
@@ -0,0 +1,90 @@
+puts "=========="
+puts "OCC25697"
+puts "=========="
+puts ""
+########################################################################################
+# Regression : Section obtained after command "bsection" in Test Harness is incorrect.
+########################################################################################
+
+# Check if list of xdistcs-command is valid
+proc checkList {List Tolerance D_good Limit_Tol} {
+   set L1 [llength ${List}]
+   set L2 10
+   set L3 5
+   set N [expr (${L1} - ${L2})/${L3} + 1]
+
+   for {set i 1} {${i} <= ${N}} {incr i} {
+      set j1 [expr ${L2} + (${i}-1)*${L3}]
+      set j2 [expr ${j1} + 2]
+      set T [lindex ${List} ${j1}]
+      set D [lindex ${List} ${j2}]
+      #puts "i=${i} j1=${j1} j2=${j2} T=${T} D=${D}"
+      if { [expr abs(${D} - ${D_good})] > ${Tolerance} } {
+         puts "Error : T=${T} D=${D}"
+      }
+      
+      if { ${Tolerance} > ${Limit_Tol} } {
+        if { [expr abs(${D} - ${D_good})] > ${Limit_Tol} 
+             && [expr abs(${D} - ${D_good})] <= ${Tolerance} } {
+           puts "Attention (critical value of tolerance) : T=${T} D=${D}"
+        }
+      }
+   }
+}
+
+
+restore [locate_data_file bug25697_shell_for_seam.brep] b1
+restore [locate_data_file bug25697_prism.brep] b2
+explode b1 f
+copy b1_1 b1
+explode b2 f
+copy b2_1 b2
+
+#################################
+set log [bopcurves b1 b2 -2d1]
+#################################
+
+regexp {Tolerance Reached=+([-0-9.+eE]+)\n+([-0-9.+eE]+)} ${log} full Toler NbCurv
+
+set MaxTol 1.e-7
+set GoodNbCurv 3
+
+if { ${Toler} > ${MaxTol} } {
+  puts "Error: Tolerance is too big!"
+}
+
+if { ${NbCurv} != ${GoodNbCurv} } {
+  puts "Error: Curve Number is bad!"
+}
+
+#---------------
+mksurface s1 b1
+mksurface s2 b2
+
+for {set i 1} {$i <= ${NbCurv}} {incr i} {
+  bounds c_$i u1 u2
+  dump u1 u2
+  dlog reset
+  dlog on
+  xdistcs c_$i s1 u1 u2 10
+  set Log2 [dlog get]
+  set List2 [split ${Log2} {TD= \t\n}]
+  set Tolerance 1.0e-7
+  set Limit_Tol 1.0e-7
+  set D_good 0.
+  checkList ${List2} ${Tolerance} ${D_good} ${Limit_Tol}
+
+  dlog reset
+  dlog on
+  xdistcs c_$i s2 u1 u2 10
+  set Log2 [dlog get]
+  set List2 [split ${Log2} {TD= \t\n}]
+  set Tolerance 1.0e-7
+  set Limit_Tol 1.0e-7
+  set D_good 0.
+  checkList ${List2} ${Tolerance} ${D_good} ${Limit_Tol}
+}
+
+smallview
+fit
+set only_screen_axo 1
diff --git a/tests/bugs/modalg_5/bug25772 b/tests/bugs/modalg_5/bug25772
new file mode 100644 (file)
index 0000000..b9a4302
--- /dev/null
@@ -0,0 +1,37 @@
+puts "============"
+puts "OCC24154"
+puts "============"
+puts ""
+######################################################
+# Wrong result of CUT operation
+######################################################
+
+restore [locate_data_file pl1.brep] pl
+restore [locate_data_file selected_holes.brep] hl
+
+set log [bopargcheck pl hl #F]
+
+if{[string compare $log "Shape(s) seem(s) to be valid for BOP.\n"] == 0} {
+  puts "OK: Source shapes are valid in terms of bopargcheck"
+}else{
+  puts "Error: source shapes are invalid in terms of bopargcheck"
+}
+
+bcut result pl hl
+
+set log [bopargcheck result #F]
+
+if{[string compare $log "Shape(s) seem(s) to be valid for BOP.\n"] == 0} {
+  puts "OK: Source shapes are valid in terms of bopargcheck"
+}else{
+  puts "Error: source shapes are invalid in terms of bopargcheck"
+}
+
+
+# Analysis of "nbshapes res"
+set nb_f_good 2
+set nb_sh_good 1
+set nb_sol_good 0
+set nb_compsol_good 0
+set nb_compound_good 1
+