0024510: Remove unused local variables
[occt.git] / src / IntTools / IntTools_EdgeEdge.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 5d257e5..efb517c
@@ -1,66 +1,61 @@
-// File:       IntTools_EdgeEdge.cxx
-// Created:    Thu Oct 26 10:14:32 2000
-// Author:     Peter KURNEV
-//             <pkv@irinox>
+// Created on: 2000-10-26
+// Created by: Peter KURNEV
+// Copyright (c) 2000-2014 OPEN CASCADE SAS
 //
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and / or modify it
+// under the terms of the GNU Lesser General Public version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
 
 #include <IntTools_EdgeEdge.ixx>
 
-#include <BRep_Tool.hxx>
-
-#include <GCPnts_QuasiUniformDeflection.hxx>
-
-#include <GeomAPI_ProjectPointOnCurve.hxx>
-#include <GeomAPI_ExtremaCurveCurve.hxx>
+#include <Precision.hxx>
 
-#include <TColStd_ListOfReal.hxx>
-#include <TColStd_ListIteratorOfListOfReal.hxx>
-#include <TColStd_MapOfInteger.hxx>
-#include <TColStd_ListOfReal.hxx>
 #include <TColStd_SequenceOfReal.hxx>
 
-#include <IntTools.hxx>
-#include <IntTools_Range.hxx>
-#include <IntTools_CArray1OfInteger.hxx>
-#include <IntTools_CArray1OfReal.hxx>
-#include <IntTools_Array1OfRange.hxx>
-#include <IntTools_QuickSortRange.hxx>
-#include <IntTools_CompareRange.hxx>
-#include <IntTools_Root.hxx>
-#include <IntTools_Array1OfRoots.hxx>
-#include <IntTools_Compare.hxx>
-#include <IntTools_QuickSort.hxx>
-#include <IntTools_Root.hxx>
-#include <IntTools_CommonPrt.hxx>
-#include <IntTools_SequenceOfRanges.hxx>
-
 #include <gp_Circ.hxx>
 #include <gp_Ax1.hxx>
 #include <gp_Lin.hxx>
 #include <gp_Dir.hxx>
 #include <gp_Pnt.hxx>
 
-#include <gce_MakeCirc.hxx>
-#include <Precision.hxx>
-#include <IntTools.hxx>
-//
-#include <Bnd_Box.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopExp.hxx>
-#include <BndLib_Add3dCurve.hxx>
-#include <IntTools_BeanBeanIntersector.hxx>
-#include <IntTools_Tools.hxx>
+#include <ElCLib.hxx>
+#include <Geom_Curve.hxx>
+
+#include <Geom_BSplineCurve.hxx>
+#include <GeomAdaptor_Curve.hxx>
 
 #include <CPnts_AbscissaPoint.hxx>
-#include <gp_Circ.hxx>
+
+#include <GeomAPI_ProjectPointOnCurve.hxx>
+
 #include <Extrema_ExtElC.hxx>
 #include <Extrema_POnCurv.hxx>
+#include <Extrema_ExtCC.hxx>
+
+#include <TopoDS_Iterator.hxx>
+#include <BRep_Tool.hxx>
+
+#include <IntTools.hxx>
+#include <IntTools_Range.hxx>
+#include <IntTools_CArray1OfReal.hxx>
+#include <IntTools_CommonPrt.hxx>
+#include <IntTools_SequenceOfRanges.hxx>
+#include <IntTools_Tools.hxx>
+#include <IntTools_BeanBeanIntersector.hxx>
+
 
 //=======================================================================
 //function : IntTools_EdgeEdge::IntTools_EdgeEdge
 //purpose  : 
 //=======================================================================
-  IntTools_EdgeEdge::IntTools_EdgeEdge()
+IntTools_EdgeEdge::IntTools_EdgeEdge()
 {
   myTol1=1.e-7;
   myTol2=1.e-7;
 //=======================================================================
   void IntTools_EdgeEdge::Perform() 
 {
-  Standard_Integer i, pri;
+  Standard_Boolean bIsSameCurves;
+  Standard_Integer i, pri, aNbCommonPrts, aNbRange;
+  Standard_Real aT1, aT2, aPC;
   IntTools_CommonPrt aCommonPrt;
-  GeomAbs_CurveType   aCTFrom, aCTTo;
-  
+  GeomAbs_CurveType aCTFrom, aCTTo;
+  //
+  myIsDone=Standard_False;
   myErrorStatus=0;
+  //
   CheckData();
   if (myErrorStatus)
     return;
   //
-  // ProjectableRanges, etc
   Prepare();
+
   if (myErrorStatus) {
     return;
   }
   //
-
-  if(myCFrom.GetType() == GeomAbs_Line && myCTo.GetType() == GeomAbs_Line) {
+  aCTFrom = myCFrom.GetType();
+  aCTTo   = myCTo.GetType();
+  //
+  if(aCTFrom==GeomAbs_Line && aCTTo==GeomAbs_Line) {
     ComputeLineLine();
     if (myOrder) {
       TopoDS_Edge aTmp;
     }
     return;
   }
-
+  //
+  bIsSameCurves=IsSameCurves();
+  if (bIsSameCurves) {
+    aCommonPrt.SetType(TopAbs_EDGE);
+    aCommonPrt.SetRange1 (myTminFrom, myTmaxFrom);
+    aCommonPrt.AppendRange2 (myTminTo, myTmaxTo);
+    mySeqOfCommonPrts.Append(aCommonPrt);
+    myIsDone=Standard_True;
+    return;
+  }
+  //
   IntTools_BeanBeanIntersector anIntersector(myCFrom, myCTo, myTolFrom, myTolTo);
   anIntersector.SetBeanParameters(Standard_True, myTminFrom, myTmaxFrom);
   anIntersector.SetBeanParameters(Standard_False, myTminTo, myTmaxTo);
+  //
   anIntersector.Perform();
-  
   if(!anIntersector.IsDone()) {
     myIsDone = Standard_False;
     return;
   }
-  aCTFrom = myCFrom.GetType();
-  aCTTo   = myCTo.GetType();
-  
+  //
+  aPC=Precision::PConfusion();
   aCommonPrt.SetEdge1(myCFrom.Edge());
   aCommonPrt.SetEdge2(myCTo.Edge());
-
-  for(Standard_Integer r = 1; r <= anIntersector.Result().Length(); r++) {
-    const IntTools_Range& aRange = anIntersector.Result().Value(r);
-    
-    if(IsProjectable(IntTools_Tools::IntermediatePoint(aRange.First(), aRange.Last()))) {
-      aCommonPrt.SetRange1(aRange.First(), aRange.Last());
-
-      if(((aRange.First() - myTminFrom) < Precision::PConfusion()) &&
-        ((myTmaxFrom  - aRange.Last()) < Precision::PConfusion())) {
+  //
+  const IntTools_SequenceOfRanges& aSR=anIntersector.Result();
+  aNbRange=aSR.Length();
+  for(i=1; i <=aNbRange; ++i) {
+    const IntTools_Range& aRange =aSR.Value(i);
+    aT1=aRange.First();
+    aT2=aRange.Last();
+    //
+    if(IsProjectable(IntTools_Tools::IntermediatePoint(aT1, aT2))) {
+      aCommonPrt.SetRange1(aT1, aT2);
+      //
+      if(((aT1 - myTminFrom)<aPC) && ((myTmaxFrom  - aT2)<aPC)) {
        aCommonPrt.SetAllNullFlag(Standard_True);
       }
       mySeqOfCommonPrts.Append(aCommonPrt);
     }
   }
-  
-  Standard_Integer aNbCommonPrts;
+  //
   aNbCommonPrts=mySeqOfCommonPrts.Length();
-  
-  for (i=1; i<=aNbCommonPrts; i++) {
+  for (i=1; i<=aNbCommonPrts; ++i) {
     IntTools_CommonPrt& aCmnPrt=mySeqOfCommonPrts.ChangeValue(i);
     pri=FindRangeOnCurve2 (aCmnPrt); 
-    
     if (pri) {
       myErrorStatus=10;
       return;
     }
   }
   //
-  
-  {
-    // Line Circle's Common Parts treatement
-    if ((aCTFrom==GeomAbs_Line   && aCTTo==GeomAbs_Circle) || 
-       (aCTFrom==GeomAbs_Circle && aCTTo==GeomAbs_Line) ||
-       (aCTFrom==GeomAbs_Ellipse && aCTTo==GeomAbs_Ellipse) ||
-       (aCTFrom==GeomAbs_Circle && aCTTo==GeomAbs_Circle))  {
-      for (i=1; i<=aNbCommonPrts; i++) {
-       IntTools_CommonPrt& aCP=mySeqOfCommonPrts(i);
-       TopAbs_ShapeEnum aType=aCP.Type();
-       Standard_Boolean bIsTouch;
-       Standard_Real aTx1, aTx2;
-       //
-       if ((aType==TopAbs_EDGE) && !aCommonPrt.AllNullFlag()) {
-         bIsTouch=CheckTouch (aCP, aTx1, aTx2);
+  // Line Circle's Common Parts treatement
+  if ((aCTFrom==GeomAbs_Line   && aCTTo==GeomAbs_Circle) || 
+      (aCTFrom==GeomAbs_Circle && aCTTo==GeomAbs_Line) ||
+      (aCTFrom==GeomAbs_Ellipse && aCTTo==GeomAbs_Ellipse) ||
+      (aCTFrom==GeomAbs_Circle && aCTTo==GeomAbs_Circle))  {
+    for (i=1; i<=aNbCommonPrts; i++) {
+      IntTools_CommonPrt& aCP=mySeqOfCommonPrts(i);
+      TopAbs_ShapeEnum aType=aCP.Type();
+      Standard_Boolean bIsTouch;
+      Standard_Real aTx1, aTx2;
+      //
+      if ((aType==TopAbs_EDGE) && !aCommonPrt.AllNullFlag()) {
+       bIsTouch=CheckTouch (aCP, aTx1, aTx2);
+       if (bIsTouch) {
+         aCP.SetType(TopAbs_VERTEX);
+         aCP.SetVertexParameter1(aTx1);
+         aCP.SetRange1 (aTx1, aTx1);
+         IntTools_Range& aRange2=(aCP.ChangeRanges2()).ChangeValue(1);
+         aRange2.SetFirst(aTx2);
+         aRange2.SetLast (aTx2);
+       }
+      }
+      //
+      if (aType==TopAbs_VERTEX) {
+       if(aCTFrom==GeomAbs_Line || aCTTo==GeomAbs_Line) {
+         bIsTouch=CheckTouchVertex (aCP, aTx1, aTx2);
          if (bIsTouch) {
-           aCP.SetType(TopAbs_VERTEX);
            aCP.SetVertexParameter1(aTx1);
            aCP.SetRange1 (aTx1, aTx1);
            IntTools_Range& aRange2=(aCP.ChangeRanges2()).ChangeValue(1);
            aRange2.SetLast (aTx2);
          }
        }
-       //
-       if (aType==TopAbs_VERTEX) {
-         if(aCTFrom==GeomAbs_Line || aCTTo==GeomAbs_Line) {
-           bIsTouch=CheckTouchVertex (aCP, aTx1, aTx2);
-           if (bIsTouch) {
-             aCP.SetVertexParameter1(aTx1);
-             aCP.SetRange1 (aTx1, aTx1);
-             IntTools_Range& aRange2=(aCP.ChangeRanges2()).ChangeValue(1);
-             aRange2.SetFirst(aTx2);
-             aRange2.SetLast (aTx2);
-           }
-         }
-       }
       }
     }
   }
-
+  //
   if (myOrder) {
     TopoDS_Edge aTmp;
     aTmp=myEdge1;
     myEdge1=myEdge2;
     myEdge2=aTmp;
   }
-    
+  //
   myIsDone=Standard_True;
 } 
+
 //=======================================================================
 //function : CheckData
 //purpose  : 
 //=======================================================================
   void IntTools_EdgeEdge::Prepare() 
 {
-  Standard_Real aLE1, aLE2;
-  
+  Standard_Real aLE1, aLE2, aT1, aT2, aTol1, aTol2;
+  GeomAdaptor_Curve aGAC;
+  GeomAbs_CurveType aCT1, aCT2;
   //
   // 1.Prepare Curves' data
-  aLE1 = 0.;
-
-  if (!BRep_Tool::Degenerated(myEdge1) &&
-      BRep_Tool::IsGeometric(myEdge1)) {
-    Standard_Real f, l;
-    const Handle(Geom_Curve)&  aCurve   =BRep_Tool::Curve  (myEdge1, f, l);
-    GeomAdaptor_Curve   aGACurve   (aCurve, myRange1.First(), myRange1.Last());
-    aLE1 = CPnts_AbscissaPoint::Length(aGACurve, myRange1.First(), myRange1.Last());
-  }
-  aLE2 = 0.;
-
-  if (!BRep_Tool::Degenerated(myEdge2) &&
-      BRep_Tool::IsGeometric(myEdge2)) {
-    Standard_Real f, l;
-    const Handle(Geom_Curve)&  aCurve   =BRep_Tool::Curve  (myEdge2, f, l);
-    GeomAdaptor_Curve   aGACurve   (aCurve, myRange2.First(), myRange2.Last());
-    aLE2 = CPnts_AbscissaPoint::Length(aGACurve, myRange2.First(), myRange2.Last());
-  }
-  
+  const Handle(Geom_Curve)& aC1=BRep_Tool::Curve  (myEdge1, aT1, aT2);
+  aT1=myRange1.First();
+  aT2=myRange1.Last();
+  aGAC.Load(aC1, myRange1.First(), myRange1.Last());
+  aLE1=CPnts_AbscissaPoint::Length(aGAC, aT1, aT2);
+  //
+  const Handle(Geom_Curve)& aC2=BRep_Tool::Curve  (myEdge2,  aT1, aT2);
+  aT1=myRange2.First();
+  aT2=myRange2.Last();
+  aGAC.Load(aC2, aT1, aT2);
+  aLE2=CPnts_AbscissaPoint::Length(aGAC, aT1, aT2);
+  //
+  myOrder=Standard_False;
   if (aLE1 <= aLE2) {
     myCFrom.Initialize(myEdge1);
     myCTo  .Initialize(myEdge2);
     myTmaxFrom=myRange2.Last ();
     myTminTo  =myRange1.First();
     myTmaxTo  =myRange1.Last ();
-
+    //
     myOrder=Standard_True; // revesed order
   }
   //
   // 2.Prepare myCriteria
-  GeomAbs_CurveType aCT1, aCT2;
   aCT1=myCFrom.GetType();
-  aCT2=myCTo.GetType()  ;
-  
-  Standard_Real aTol1, aTol2;
-  aTol1=(aCT1==GeomAbs_BSplineCurve||
-        aCT1==GeomAbs_BezierCurve) ? 1.20*myTol1 : myTol1;
-  
-  aTol2=(aCT2==GeomAbs_BSplineCurve||
-        aCT2==GeomAbs_BezierCurve) ? 1.20*myTol2 : myTol2;
-  
-  myCriteria=aTol1+aTol2;
-}
-
-//=======================================================================
-//function : FindProjectableRoot
-//purpose  : 
-//=======================================================================
-  void IntTools_EdgeEdge::FindProjectableRoot (const Standard_Real tt1,
-                                              const Standard_Real tt2,
-                                              const Standard_Integer ff1,
-                                              const Standard_Integer ff2,
-                                              Standard_Real& tRoot)
-{
-  Standard_Real tm, t1, t2;
-  Standard_Integer anIsProj1, anIsProj2, anIsProjm;
+  aCT2=myCTo.GetType();
   //
-  // Root can be on the ends of [tt1, tt2]
-  Standard_Integer anOldErrorStatus=myErrorStatus;
-
-  t1=DistanceFunction(tt1);
-  myErrorStatus=anOldErrorStatus;
-  if (fabs(t1)<myCriteria) {
-    tRoot=tt1;
-    return;
-  }
-
-  t1=DistanceFunction(tt2);
-  myErrorStatus=anOldErrorStatus;
-  if (fabs(t1)<myCriteria) {
-    tRoot=tt2;
-    return;
+  aTol1=myTol1;
+  if(aCT1==GeomAbs_BSplineCurve|| aCT1==GeomAbs_BezierCurve){
+    aTol1=1.2*myTol1;
   }
-  
-  
-  //
-  // Root is inside [tt1, tt2]
-  t1=tt1;  
-  t2=tt2;
-  anIsProj1=ff1;
-  anIsProj2=ff2;
-  
-  while (1) {
-    if (fabs(t1-t2) < myEpsT) {
-      tRoot=.5*(t1+t2);
-      return;
-    }
-    tm=.5*(t1+t2);
-    anIsProjm=IsProjectable(tm);
-    
-    if (anIsProjm != anIsProj1) {
-      t2=tm;
-      anIsProj2=anIsProjm;
-    }
-    else {
-      t1=tm;
-      anIsProj1=anIsProjm;
-    }
+  aTol2=myTol2;
+  if(aCT2==GeomAbs_BSplineCurve|| aCT2==GeomAbs_BezierCurve){
+    aTol2=1.2*myTol2;
   }
+  myCriteria=aTol1+aTol2;
 }
-
 //=======================================================================
 //function : IsProjectable
 //purpose  : 
   aCurveFrom->D0(t, aPFrom);
   
   Handle(Geom_Curve)aCurveTo=BRep_Tool::Curve (myCTo.Edge(), f, l);
-  //modified by NIZNHY-PKV Mon Jun  8 09:52:09 2009f
-  //aProjector.Init(aPFrom, aCurveTo, myTminTo, myTmaxTo);
   aProjector.Init(aCurveTo, myTminTo, myTmaxTo);
   aProjector.Perform(aPFrom);
-  //modified by NIZNHY-PKV Mon Jun  8 09:53:00 2009t
   aNbProj=aProjector.NbPoints();
   //
   if (myCTo.GetType()==GeomAbs_Circle) {
     }
   }
   
-  //modified by NIZNHY-PKV Mon Jun  8 09:54:19 2009f
-  //aProjector.Init(aPFrom, aCurveTo, myTminTo, myTmaxTo);
   aProjector.Init(aCurveTo, myTminTo, myTmaxTo);
   aProjector.Perform(aPFrom);
-  //modified by NIZNHY-PKV Mon Jun  8 09:55:11 2009t
   //
   Standard_Integer j, aNbPoints;
   //
       }
        
       aCurveFrom->D0 (tt, aPFrom);
-      //modified by NIZNHY-PKV Mon Jun  8 09:54:52 2009f
-      //aProjector.Init(aPFrom, aCurveTo, myTminTo, myTmaxTo);
       aProjector.Init(aCurveTo, myTminTo, myTmaxTo);
       aProjector.Perform(aPFrom);
-      //modified by NIZNHY-PKV Mon Jun  8 09:55:07 2009t
       aNbPoints=aProjector.NbPoints();
       if (aNbPoints) {
        break;
   return aD2; 
 }
 
-//=======================================================================
-//function : FindGoldRoot
-//purpose  : [private]
-//=======================================================================
-  Standard_Real IntTools_EdgeEdge::FindGoldRoot (const Standard_Real tA,
-                                                const Standard_Real tB,
-                                                const Standard_Real coeff)
-{
-  Standard_Real gs=0.61803399;
-  Standard_Real a, b, xp, xl, yp, yl;
 
-  a=tA;  b=tB;
-  
-  xp=a+(b-a)*gs;
-  xl=b-(b-a)*gs;
-  yp=coeff*DistanceFunction(xp);
-  yl=coeff*DistanceFunction(xl);
-  
-  while (1) {
-    
-    if (fabs(b-a) < myEpsT) {
-      return .5*(b+a);
-    }
-    
-    if (yp < yl) {
-      a=xl;
-      xl=xp;
-      xp=a+(b-a)*gs;
-      yp=coeff*DistanceFunction(xp);
-    }
-    
-    else {
-      b=xp;
-      xp=xl;
-      yp=yl;
-      xl=b-(b-a)*gs;
-      yl=coeff*DistanceFunction(xl);
-    }
-  }
-}  
 //=======================================================================
 //function : FindSimpleRoot
 //purpose  : [private]
   Standard_Integer step = 1, stepcheck = 1000, steplimit = 100000;
   Standard_Real value = (IP==1) ? DistanceFunction(0.5*(a+b)) : DerivativeFunction(0.5*(a+b));
   
-  while (1) {
+  for(;;) {
     x0=.5*(a+b);
 
     if (IP==1)
 //function : FindRangeOnCurve2
 //purpose  : 
 //=======================================================================
-  Standard_Integer IntTools_EdgeEdge::FindRangeOnCurve2(IntTools_CommonPrt&  aCommonPrt)
+Standard_Integer IntTools_EdgeEdge::FindRangeOnCurve2(IntTools_CommonPrt&  aCommonPrt)
 {
-  Standard_Real ttmp, f, l, af1, al1, am1, af2, al2, am2;
   Standard_Integer pri;
+  //
+  pri=0;
+  if (aCommonPrt.AllNullFlag()) {
+    aCommonPrt.SetType(TopAbs_EDGE);
+    aCommonPrt.AppendRange2 (myTminTo, myTmaxTo);
+    return pri;
+  }
+  //
+  Standard_Real ttmp, f, l, af1, al1, am1, af2, al2, am2;
   gp_Pnt aPf1, aPl1, aPm1, aPf2, aPl2, aPm2;
   GeomAPI_ProjectPointOnCurve aProjector;
 
   //
   //
   Standard_Boolean aVFlag1, aVFlag2, aGeomFlag1, aGeomFlag2;
-  Standard_Real Df2m2, Dm2l2, Df2l2, df2m2, dm2l2, df2l2, df1m1, dm1l1, df1l1;
+  Standard_Real Df2m2, Dm2l2, Df2l2, df2m2, dm2l2, df2l2, df1l1;
   Standard_Real tV1, tV2;
   //
   // parametric differences for C2
   }
   //
   // geometric distances for C1
-  df1m1=aPf1.Distance(aPm1);
-  dm1l1=aPm1.Distance(aPl1);
   df1l1=aPf1.Distance(aPl1);
   //
   // if geometric distances between boundaries is less than myCriteria
     }
   }
   //
-  //modified by NIZNHY-PKV Mon Jun  8 09:55:42 2009f
-  //aProjector.Init(aPm2, aCurveFrom, myTminFrom, myTmaxFrom);
   aProjector.Init(aCurveFrom, myTminFrom, myTmaxFrom);
   aProjector.Perform(aPm2);
-  //modified by NIZNHY-PKV Mon Jun  8 09:56:12 2009t
   Standard_Integer aNbPoints=aProjector.NbPoints();
   if (aNbPoints) { 
     Standard_Real aDD=aProjector.LowerDistance();
   void IntTools_EdgeEdge::IsIntersection (const Standard_Real ta, 
                                          const Standard_Real tb) 
 {
-  Standard_Integer i, aNb, pri;
+  Standard_Integer i, aNb;
   Standard_Real t, f;
   GeomAbs_CurveType aCT1, aCT2;
   IntTools_CArray1OfReal anArgs, aFunc;
     }
   }
   //
-  //modified by NIZNHY-PKV Wed May 13 11:08:46 2009f
   if (aCT1==GeomAbs_Circle && aCT2==GeomAbs_Circle) {
     Standard_Boolean bIsDone, bIsParallel;
     Standard_Integer aNbExt;
       }
     }
   }
-  //modified by NIZNHY-PKV Wed May 13 11:08:51 2009t
   //
   // Prepare values of arguments for the interval [ta, tb]
-  pri=IntTools::PrepareArgs (myCFrom, tb, ta, myDiscret, myDeflection, anArgs);
+  IntTools::PrepareArgs (myCFrom, tb, ta, myDiscret, myDeflection, anArgs);
   aNb=anArgs.Length();
 
   aFunc.Resize(aNb);
                                             const IntTools_CArray1OfReal& f)  
 {
   Standard_Integer i, n, k;
-  Standard_Real fr, tr, anEpsNull;
+  Standard_Real tr, anEpsNull;
   IntTools_CArray1OfReal fd;
   TColStd_SequenceOfReal aTSeq, aFSeq;
   
     //aa
     if (fd1*fd2 < 0.) {
       tr=FindSimpleRoot(2, t1, t2, fd1);
-      fr=DistanceFunction(tr);
       myPar1=tr;
       myParallel=Standard_False;
       break;
     
     if (!bF1 && bF2) {
       tr=t2;
-      fr=fd2;
       myPar1=tr;
       myParallel=Standard_False;
       break;
     
     if (bF1 && !bF2) {
       tr=t1;
-      fr=fd1;
       myPar1=tr;
       myParallel=Standard_False;
       break;
   gp_Pnt aP1;
   aCurveFrom->D0 (aT1, aP1);
   GeomAPI_ProjectPointOnCurve aProjector;
-  //modified by NIZNHY-PKV Mon Jun  8 09:56:53 2009f
-  //aProjector.Init(aP1, aCurveTo, myTminTo, myTmaxTo);
   aProjector.Init(aCurveTo, myTminTo, myTmaxTo);
   aProjector.Perform(aP1);
-  //modified by NIZNHY-PKV Mon Jun  8 09:57:12 2009t
   aNbPoints=aProjector.NbPoints();
   found=1;
   if (!aNbPoints) {
        tt=aT1-myEpsT;
       }
       aCurveFrom->D0 (tt, aP1);
-      //modified by NIZNHY-PKV Mon Jun  8 09:57:34 2009f
-      //aProjector.Init(aP1, aCurveTo, myTminTo, myTmaxTo);
       aProjector.Init(aCurveTo, myTminTo, myTmaxTo);
       aProjector.Perform(aP1);
-      //modified by NIZNHY-PKV Mon Jun  8 09:57:51 2009t
       aNbPoints=aProjector.NbPoints();
       if (aNbPoints) {
        found=1;
 //      on myCTo
 //   
 
-#include <Precision.hxx>
-#include <Geom_Curve.hxx>
-#include <GeomAdaptor_Curve.hxx>
-#include <BRep_Tool.hxx>
-#include <Extrema_ExtCC.hxx>
-#include <ElCLib.hxx>
+
 //=======================================================================
 //function : CheckTouchVertex 
 //purpose  : line/Circle refinement
   Standard_Real aTFR1, aTLR1, aTFR2, aTLR2;
   Standard_Real aTL1, aTL2, aTC1, aTC2;
   Standard_Real aRC, aDLC, aD2, aC2, aTLx, aTCx;
-  GeomAbs_CurveType aTFrom, aTTo;
+  GeomAbs_CurveType aTFrom;
   gp_Circ aCirc;
   gp_Lin  aLine;
   gp_Pnt aPC, aPLx, aPCx;
   (aCP.Ranges2())(1).Range(aTFR2, aTLR2);
   //
   aTFrom=myCFrom.GetType();
-  aTTo  =myCTo.GetType();
   //
   aTL1=aTFR1;
   aTL2=aTLR1;
     if(!isfirst || !islast) {
       if(isfirst) {
        aTx1 = aTF1;
-       //modified by NIZNHY-PKV Mon Jun  8 09:59:27 2009f
-       //GeomAPI_ProjectPointOnCurve aProjector(Curve1->Value(aTx1), Curve2, aTF2, aTL2);      
        GeomAPI_ProjectPointOnCurve aProjector;
        aProjector.Init(Curve2, aTF2, aTL2);
        aProjector.Perform(Curve1->Value(aTx1));
-       //modified by NIZNHY-PKV Mon Jun  8 10:00:12 2009t
        //
        if(aProjector.NbPoints() > 0)
          aTx2 = aProjector.LowerDistanceParameter();
       
       if(islast) {
        aTx1 = aTL1;
-       //modified by NIZNHY-PKV Mon Jun  8 10:00:24 2009f
-       //GeomAPI_ProjectPointOnCurve aProjector(Curve1->Value(aTx1), Curve2, aTF2, aTL2);
        GeomAPI_ProjectPointOnCurve aProjector;
        aProjector.Init(Curve2, aTF2, aTL2);
        aProjector.Perform(Curve1->Value(aTx1));
-       //modified by NIZNHY-PKV Mon Jun  8 10:00:26 2009t
        if(aProjector.NbPoints() > 0)
          aTx2 = aProjector.LowerDistanceParameter();
        else {
      (myCFrom.GetType() == GeomAbs_Circle && myCTo.GetType() == GeomAbs_Line))
   {
     Standard_Real aRadius;
-    GeomAbs_CurveType aTFrom, aTTo;
+    GeomAbs_CurveType aTFrom;
     gp_Circ aCirc;
     gp_Lin  aLine;
     gp_Pnt aPCenter, aPOnLine;
 
     aTFrom=myCFrom.GetType();
-    aTTo  =myCTo.GetType();
     
     if (aTFrom==GeomAbs_Circle) {
       aCirc=myCFrom.Circle();
   GeomAPI_ProjectPointOnCurve aProjector;
   Standard_Real aMidPar, aMidDist;   
   aMidPar = (aTF1 + aTL1) * 0.5;  
-  //modified by NIZNHY-PKV Mon Jun  8 10:01:32 2009f
-  //aProjector.Init(Curve1->Value(aMidPar), Curve2, aTF2, aTL2);
   aProjector.Init(Curve2, aTF2, aTL2);
   aProjector.Perform(Curve1->Value(aMidPar));
-  //modified by NIZNHY-PKV Mon Jun  8 10:02:09 2009t
   if(aProjector.NbPoints() > 0) {
     aMidDist=aProjector.LowerDistance();
     if(aMidDist * aMidDist < aDist2 || !istouch) {
 
   return theflag;
 }
-//=======================================================================
-//function :  CheckInterval
-//purpose  : 
-//=======================================================================
-  Standard_Boolean IntTools_EdgeEdge::CheckInterval(const Standard_Real aT1,
-                                                   const Standard_Real aT2)
-{
-  Standard_Boolean bFlag=Standard_False;
-  Standard_Integer i, aNb=4;
-  Standard_Real aT, dT, aDist;
-  
-  dT=(aT2-aT1)/aNb;
-  
-  for (i=1; i<aNb; ++i) {
-    aT=aT1+i*dT;
-    aDist=DistanceFunction(aT);
-    if (aDist>myEpsNull) {
-      return bFlag;
-    }
-  }
-  return !bFlag;
-}
-
-//=======================================================================
-//function : RemoveIdenticalRoots 
-//purpose  : 
-//=======================================================================
-  void IntTools_EdgeEdge::RemoveIdenticalRoots()
-{
-  Standard_Integer aNbRoots, j, k;
-
-  aNbRoots=mySequenceOfRoots.Length();
-  for (j=1; j<=aNbRoots; j++) { 
-    const IntTools_Root& aRj=mySequenceOfRoots(j);
-    for (k=j+1; k<=aNbRoots; k++) {
-      const IntTools_Root& aRk=mySequenceOfRoots(k);
-      
-      Standard_Real aTj, aTk, aDistance;
-      gp_Pnt aPj, aPk;
-
-      aTj=aRj.Root();
-      aTk=aRk.Root();
-
-      myCFrom.D0(aTj, aPj);
-      myCFrom.D0(aTk, aPk);
-
-      aDistance=aPj.Distance(aPk);
-      if (aDistance < myCriteria) {
-       mySequenceOfRoots.Remove(k);
-       aNbRoots=mySequenceOfRoots.Length();
-      }
-    }
-  }
-}
 
 //=======================================================================
 //function : ComputeLineLine 
 //=======================================================================
   void IntTools_EdgeEdge::ComputeLineLine()
 {
-  Standard_Real Tolang2 = 1.e-16; 
-  Standard_Real Tol2 = myCriteria*myCriteria; 
-  Standard_Boolean IsParallel = Standard_False, IsCoincide = Standard_False;
-  myIsDone = Standard_True;
-
+  Standard_Boolean IsParallel, IsCoincide;
+  Standard_Real Tolang2, Tol2;
   gp_Pnt P11, P12, P21, P22;
-
+  //
+  myIsDone = Standard_True;
+  //
+  IsParallel = Standard_False;
+  IsCoincide = Standard_False;
+  Tolang2 = Precision::Angular();
+  Tol2 = myCriteria*myCriteria; 
+  //
   gp_Lin C1 = myCFrom.Line();
   gp_Lin C2 = myCTo.Line();
   const gp_Dir& D1 = C1.Position().Direction();
   const gp_Dir& D2 = C2.Position().Direction();
   Standard_Real aCos = D1.Dot(D2);
   Standard_Real Ang2;
+
   if(aCos >= 0. ) {
     Ang2 = 2.*(1. - aCos);
   }
   if(IsParallel) {
     return;
   }
-
+  //
+  {
+    TopoDS_Iterator aIt1, aIt2;
+    //
+    aIt1.Initialize(myEdge1);
+    for (; aIt1.More(); aIt1.Next()) {
+      const TopoDS_Shape& aV1=aIt1.Value();
+      aIt2.Initialize(myEdge2);
+      for (; aIt2.More(); aIt2.Next()) {
+       const TopoDS_Shape& aV2=aIt2.Value();
+       if (aV2.IsSame(aV1)) {
+         // the two straight lines have commpn vertex
+         return;
+       }
+      }
+    }
+  }
+  //
   Standard_Real aSin2 = 1. - aCos*aCos;
   gp_Pnt O1 = C1.Location();
   gp_Pnt O2 = C2.Location();
   if(d2 > Tol2) {
     return;
   }
-
+  //
   IntTools_CommonPrt aCommonPrt;
   aCommonPrt.SetEdge1(myCFrom.Edge());
   aCommonPrt.SetEdge2(myCTo.Edge());
   mySeqOfCommonPrts.Append(aCommonPrt);
   
 }
-/*
-//=======================================================================
-//function : CheckTouchVertex 
-//purpose  : 
-//=======================================================================
-  Standard_Boolean IntTools_EdgeEdge::CheckTouchVertex (const IntTools_CommonPrt& aCP,
-                                                       Standard_Real& aTx1,
-                                                       Standard_Real& aTx2) const
-{
-  Standard_Real aTF1, aTL1, aTF2, aTL2, Tol, af, al, aDist, aDistNew;
-  Standard_Real aTFR1, aTLR1, aTFR2, aTLR2;
-  Standard_Boolean theflag=Standard_False;
-  Standard_Integer iNb, aNbExt, i;
-
-  aCP.Range1(aTFR1, aTLR1);
-  (aCP.Ranges2())(1).Range(aTFR2, aTLR2);
-  
-  Tol = Precision::PConfusion();
-  
-  GeomAbs_CurveType aTFrom, aTTo;
-
-  aTFrom=myCFrom.GetType();
-  aTTo  =myCTo.GetType();
-  gp_Circ aCirc;
-  gp_Lin  aLine;
-
-  if (aTFrom==GeomAbs_Circle) {
-    aCirc=myCFrom.Circle();
-    aLine=myCTo.Line();
-  }
-  else {
-    aCirc=myCTo.Circle();
-    aLine=myCFrom.Line();
-  }
-  
-  Standard_Real aRadius;
-  gp_Pnt aPCenter;
-  aPCenter=aCirc.Location();
-  aRadius =aCirc.Radius();
-  
-  aDist=aLine.Distance(aPCenter);
-  aDist=fabs (aDist-aRadius);
-  if (aDist > Tol) {
-    return theflag;
-  }
-  //
-  aTF1=myTminFrom;
-  aTL1=myTmaxFrom;
-  aTF2=myTminTo;
-  aTL2=myTmaxTo;
-
-  const Handle(Geom_Curve)&  Curve1   =BRep_Tool::Curve  (myCFrom.Edge(), af, al);
-  const Handle(Geom_Curve)&  Curve2   =BRep_Tool::Curve  (myCTo.Edge()  , af, al);
-  
-  GeomAdaptor_Curve   TheCurve1   (Curve1, aTF1, aTL1);
-  GeomAdaptor_Curve   TheCurve2   (Curve2, aTF2, aTL2);
-                                
-  Extrema_ExtCC anExtrema (TheCurve1, 
-                          TheCurve2, 
-                          aTF1-Tol, 
-                          aTL1+Tol, 
-                          aTF2-Tol, 
-                          aTL2+Tol, 
-                          Tol, Tol);
-  
-  if(!anExtrema.IsDone()) {
-    return theflag;
-  }
-  if (anExtrema.IsParallel()) {
-    return theflag;
-  }
-  
-  aNbExt=anExtrema.NbExt() ;
-  if (!aNbExt) {
-     return theflag;
-  }
-  //
-  iNb=0;
-  Standard_Real aTx1Av=0., aTx2Av=0.;
-  
-  gp_Pnt aPC1, aPC2;
-  
-  for (i=1; i<=aNbExt; ++i) {
-    Extrema_POnCurv aPOnC1, aPOnC2;
-    anExtrema.Points(i, aPOnC1, aPOnC2);
-    
-    aTx1=aPOnC1.Parameter();
-    aTx2=aPOnC2.Parameter();
-    if (fabs (aTx1-aTFR1) < 1.e-4 && fabs (aTx2-aTFR2) < 1.e-4) {
-      aTx1Av=aTx1Av+aTx1;
-      aTx2Av=aTx2Av+aTx2;
-      iNb++;
-    }
-  }
-
-  if (!iNb) {
-    return theflag;
-  }
-
-  aTx1=aTx1Av/iNb;
-  aTx2=aTx2Av/iNb;
-  
-  Curve1->D0(aTx1, aPC1);
-  Curve2->D0(aTx2, aPC2);
-  //
-  aDistNew=aPC1.Distance(aPC2);
-  if (aDistNew > aDist) {
-    aTx1=0.5*(aTFR1+aTLR1);
-    aTx2=0.5*(aTFR2+aTLR2);
-    return !theflag;
-  }
-  //
-
-  aDist=aDistNew;
-  if (aDist > myCriteria) {
-    return theflag;
-  }
-  
-  if (fabs (aTx1-aTF1) < Tol) {
-    return !theflag;
-  }
-
-  if (fabs (aTx1-aTL1) < Tol) {
-    return !theflag;
-  }
-
-  if (aTx1 > (aTF1-Tol) && aTx1 < (aTL1+Tol) ) {
-    return !theflag;
-  }
-
-  return theflag;
-}
-
-*/