0024255: Regressions in test cases on OCCT vc9 win64 Release
authorifv <ifv@opencascade.com>
Thu, 12 Feb 2015 11:38:39 +0000 (14:38 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 12 Feb 2015 11:40:14 +0000 (14:40 +0300)
Updated test-cases from branch CR24255_3

0024255: Regressions in test cases on OCCT vc9 win64 Release

Small refactoring.

Fix for CASE bugs modalg_5 bug25298_09: FAILED (error)

Test-cases correction (bugs modalg_5 bugs25804_1, bug25704_2)

102 files changed:
src/BOPTools/BOPTools_AlgoTools3D.cxx
src/BRepFill/BRepFill_OffsetWire.cxx
src/BRepFill/BRepFill_TrimEdgeTool.cxx
src/BRepLib/BRepLib.cxx
src/BRepLib/BRepLib_FindSurface.cxx
src/BRepMAT2d/BRepMAT2d_Explorer.cxx
src/BRepOffsetAPI/BRepOffsetAPI_MakeOffset.cxx
src/Bisector/Bisector_Bisec.cxx
src/Bisector/Bisector_BisecCC.cxx
src/Bisector/Bisector_Inter.cxx
src/ChFi3d/ChFi3d_Builder_0.cxx
src/IntCurve/IntCurve_ExactIntersectionPoint.gxx
src/IntCurve/IntCurve_IntPolyPolyGen.gxx
src/MAT2d/MAT2d_Mat2d.cxx
src/MAT2d/MAT2d_Tool2d.cxx
tests/blend/buildevol/D9
tests/blend/buildevol/E2
tests/blend/buildevol/E3
tests/blend/simple/I1
tests/blend/simple/I2
tests/blend/simple/I4
tests/blend/simple/I5
tests/blend/simple/I6
tests/blend/simple/I7
tests/blend/simple/I8
tests/blend/simple/P5
tests/boolean/bsection/R3
tests/bugs/caf/bug21707
tests/bugs/modalg_1/buc60782_1
tests/bugs/modalg_2/bug423_1
tests/bugs/modalg_4/bug745_10
tests/bugs/modalg_4/bug829_1
tests/bugs/modalg_5/bug23706_1
tests/bugs/modalg_5/bug23952_1
tests/bugs/modalg_5/bug25298_09
tests/bugs/modalg_5/bug25704_1
tests/bugs/modalg_5/bug25704_2
tests/caf/driver/B6
tests/caf/driver/B7
tests/caf/named_shape/F6
tests/caf/named_shape/F7
tests/draft/angle/M2
tests/feat/featdprism/A1
tests/feat/featdprism/A2
tests/feat/featdprism/A3
tests/feat/featdprism/A4
tests/feat/featdprism/A5
tests/feat/featdprism/A6
tests/feat/featdprism/A9
tests/feat/featdprism/B1
tests/feat/featdprism/B2
tests/feat/featdprism/B3
tests/feat/featdprism/B4
tests/feat/featdprism/B5
tests/feat/featdprism/B6
tests/offset/faces_type_i/M7
tests/offset/faces_type_i/M9
tests/offset/wire_closed_inside_0_005/B5
tests/offset/wire_closed_inside_0_005/E8
tests/offset/wire_closed_inside_0_005/G4
tests/offset/wire_closed_inside_0_005/H3
tests/offset/wire_closed_inside_0_025/A2
tests/offset/wire_closed_inside_0_025/B2
tests/offset/wire_closed_inside_0_025/D1
tests/offset/wire_closed_inside_0_025/E8
tests/offset/wire_closed_inside_0_025/F7
tests/offset/wire_closed_inside_0_025/G4
tests/offset/wire_closed_inside_0_025/H3
tests/offset/wire_closed_inside_0_075/A8
tests/offset/wire_closed_inside_0_075/C7
tests/offset/wire_closed_inside_0_075/E8
tests/offset/wire_closed_inside_0_075/F6
tests/offset/wire_closed_inside_0_075/G4
tests/offset/wire_closed_inside_0_075/H3
tests/offset/wire_closed_outside_0_005/D1
tests/offset/wire_closed_outside_0_005/E8
tests/offset/wire_closed_outside_0_005/G1
tests/offset/wire_closed_outside_0_025/B7
tests/offset/wire_closed_outside_0_025/E8
tests/offset/wire_closed_outside_0_025/F7
tests/offset/wire_closed_outside_0_025/F8
tests/offset/wire_closed_outside_0_075/A2
tests/offset/wire_closed_outside_0_075/B7
tests/offset/wire_closed_outside_0_075/E8
tests/offset/wire_closed_outside_0_075/F7
tests/offset/wire_closed_outside_0_075/H3
tests/offset/wire_unclosed_outside_0_005/A7
tests/offset/wire_unclosed_outside_0_005/B9
tests/offset/wire_unclosed_outside_0_005/C1
tests/offset/wire_unclosed_outside_0_005/C2
tests/offset/wire_unclosed_outside_0_005/C4
tests/offset/wire_unclosed_outside_0_025/A1
tests/offset/wire_unclosed_outside_0_025/A6
tests/offset/wire_unclosed_outside_0_025/A7
tests/offset/wire_unclosed_outside_0_025/B9
tests/offset/wire_unclosed_outside_0_025/C4
tests/offset/wire_unclosed_outside_0_075/A1
tests/offset/wire_unclosed_outside_0_075/A6
tests/offset/wire_unclosed_outside_0_075/A7
tests/offset/wire_unclosed_outside_0_075/A8
tests/offset/wire_unclosed_outside_0_075/A9
tests/offset/wire_unclosed_outside_0_075/C4

index 5dceb7d..81b3ad4 100644 (file)
@@ -742,7 +742,7 @@ Standard_Integer BOPTools_AlgoTools3D::PointInFace
    Handle(IntTools_Context)& theContext)
 {
   Standard_Boolean bIsDone, bHasFirstPoint, bHasSecondPoint;
-  Standard_Integer iErr, aIx, aNbDomains;
+  Standard_Integer iErr, aIx = 0, aNbDomains = 0;
   Standard_Real aUMin, aUMax, aVMin, aVMax;
   Standard_Real aVx = 0., aUx, aV1, aV2;
   gp_Dir2d aD2D (0., 1.);
@@ -764,24 +764,36 @@ Standard_Integer BOPTools_AlgoTools3D::PointInFace
   BRepTools::UVBounds(aFF, aUMin, aUMax, aVMin, aVMax);
   //
   aUx=IntTools_Tools::IntermediatePoint(aUMin, aUMax);
-  aP2D.SetCoord(aUx, 0.);
-  aL2D=new Geom2d_Line (aP2D, aD2D);
-  Geom2dAdaptor_Curve aHCur(aL2D);
-  //
-  aIx=aHatcher.AddHatching(aHCur) ;
-  //
-  aHatcher.Trim();
-  bIsDone=aHatcher.TrimDone(aIx);
-  if (!bIsDone) {
-    iErr=1;
-    return iErr;
-  }
-  //
-  aHatcher.ComputeDomains(aIx);
-  bIsDone=aHatcher.IsDone(aIx);
-  if (!bIsDone) {
-    iErr=2;
-    return iErr;
+  Standard_Integer i;
+  for(i = 1; i <= 2; ++i)
+  {
+    aP2D.SetCoord(aUx, 0.);
+    aL2D=new Geom2d_Line (aP2D, aD2D);
+    Geom2dAdaptor_Curve aHCur(aL2D);
+    //
+    aIx=aHatcher.AddHatching(aHCur) ;
+    //
+    aHatcher.Trim(aIx);
+    bIsDone=aHatcher.TrimDone(aIx);
+    if (!bIsDone) {
+      iErr=1;
+      return iErr;
+    }
+    //
+    if(aHatcher.NbPoints(aIx) > 1)
+    {
+      aHatcher.ComputeDomains(aIx);
+      bIsDone=aHatcher.IsDone(aIx);
+      if (!bIsDone) {
+        iErr=2;
+        return iErr;
+      }
+      break;
+    }
+    else
+    {
+      aUx = aUMax - (aUx - aUMin);
+    }
   }
   //
   aNbDomains=aHatcher.NbDomains(aIx);
index 3b34558..32d9920 100644 (file)
 #include <Geom2dLProp_CLProps2d.hxx>
 #include <Geom2dConvert_CompCurveToBSplineCurve.hxx>
 #include <Standard_ErrorHandler.hxx>
-
+#ifdef OCCT_DEBUG
+//#define DRAW
 #ifdef DRAW
 #include <Draw.hxx>
 #include <DrawTrSurf.hxx>
@@ -114,51 +115,52 @@ static Standard_Integer NbOFFSET    = 0;
 static Standard_Integer NbEDGES     = 0;
 static Standard_Integer NbBISSEC    = 0;
 #endif
+#endif
 
 //  Modified by Sergey KHROMOV - Thu Nov 16 17:24:39 2000 Begin
 
 static void QuasiFleche(const Adaptor3d_Curve& C,
-                       const Standard_Real Deflection2, 
-                       const Standard_Real Udeb,
-                       const gp_Pnt& Pdeb,
-                       const gp_Vec& Vdeb,
-                       const Standard_Real Ufin,
-                       const gp_Pnt& Pfin,
-                       const gp_Vec& Vfin,
-                       const Standard_Integer Nbmin,
-                       const Standard_Real Eps,
-                       TColStd_SequenceOfReal& Parameters,
-                       TColgp_SequenceOfPnt& Points);
+  const Standard_Real Deflection2, 
+  const Standard_Real Udeb,
+  const gp_Pnt& Pdeb,
+  const gp_Vec& Vdeb,
+  const Standard_Real Ufin,
+  const gp_Pnt& Pfin,
+  const gp_Vec& Vfin,
+  const Standard_Integer Nbmin,
+  const Standard_Real Eps,
+  TColStd_SequenceOfReal& Parameters,
+  TColgp_SequenceOfPnt& Points);
 
 static Standard_Boolean PerformCurve (TColStd_SequenceOfReal& Parameters,
-                                     TColgp_SequenceOfPnt&   Points,
-                                     const Adaptor3d_Curve& C, 
-                                     const Standard_Real Deflection,
-                                     const Standard_Real U1,
-                                     const Standard_Real U2,
-                                     const Standard_Real EPSILON,
-                                     const Standard_Integer Nbmin);
+  TColgp_SequenceOfPnt&   Points,
+  const Adaptor3d_Curve& C, 
+  const Standard_Real Deflection,
+  const Standard_Real U1,
+  const Standard_Real U2,
+  const Standard_Real EPSILON,
+  const Standard_Integer Nbmin);
 
 static void CheckBadEdges(const TopoDS_Face& Spine, const Standard_Real Offset,
-                         const BRepMAT2d_BisectingLocus& Locus, 
-                         const BRepMAT2d_LinkTopoBilo&   Link,
-                         TopTools_ListOfShape& BadEdges);
+  const BRepMAT2d_BisectingLocus& Locus, 
+  const BRepMAT2d_LinkTopoBilo&   Link,
+  TopTools_ListOfShape& BadEdges);
 
 static Standard_Integer CutEdge (const TopoDS_Edge& E, 
-                                const TopoDS_Face& F,
-                                      Standard_Integer ForceCut,
-                                      TopTools_ListOfShape& Cuts);
+  const TopoDS_Face& F,
+  Standard_Integer ForceCut,
+  TopTools_ListOfShape& Cuts);
 
 
 static void CutCurve (const Handle(Geom2d_TrimmedCurve)& C,
-                     const Standard_Integer nbParts,
-                           TColGeom2d_SequenceOfCurve& theCurves);
+  const Standard_Integer nbParts,
+  TColGeom2d_SequenceOfCurve& theCurves);
 //  Modified by Sergey KHROMOV - Thu Nov 16 17:24:47 2000 End
 
 
 static void EdgeVertices (const TopoDS_Edge&   E,
-                               TopoDS_Vertex& V1, 
-                               TopoDS_Vertex& V2)
+  TopoDS_Vertex& V1, 
+  TopoDS_Vertex& V2)
 {
   if (E.Orientation() == TopAbs_REVERSED) {
     TopExp::Vertices(E,V2,V1);
@@ -167,22 +169,21 @@ static void EdgeVertices (const TopoDS_Edge&   E,
     TopExp::Vertices(E,V1,V2);
   }
 }
-                                     
 static Standard_Boolean VertexFromNode
-(const Handle(MAT_Node)&      aNode, 
- const Standard_Real          Offset,
- gp_Pnt2d&                    PN,
- BRepFill_DataMapOfNodeShape& MapNodeVertex,
- TopoDS_Vertex&               VN);
+  (const Handle(MAT_Node)&      aNode, 
+  const Standard_Real          Offset,
+  gp_Pnt2d&                    PN,
+  BRepFill_DataMapOfNodeShape& MapNodeVertex,
+  TopoDS_Vertex&               VN);
 
 static void StoreInMap (const TopoDS_Shape& V1,
-                       const TopoDS_Shape& V2,
-                       TopTools_IndexedDataMapOfShapeShape& MapVV);
+  const TopoDS_Shape& V2,
+  TopTools_IndexedDataMapOfShapeShape& MapVV);
 
 static void TrimEdge (const TopoDS_Edge&              CurrentEdge,
                       const TopoDS_Shape&             CurrentSpine,
                       const TopoDS_Face&              AllSpine,
-                     const TopTools_ListOfShape&     D,
+                      const TopTools_ListOfShape&     D,
                       TopTools_SequenceOfShape& Sv,  
                       TColStd_SequenceOfReal&   MapverPar,
                       TopTools_SequenceOfShape& S,
@@ -195,28 +196,28 @@ static Standard_Boolean IsInnerEdge(const TopoDS_Shape& ProE,
                                     Standard_Real& TrPar2);
 
 static Standard_Boolean DoubleOrNotInside (const TopTools_ListOfShape& EC,
-                                          const TopoDS_Vertex&        V);
+  const TopoDS_Vertex&        V);
 
 static Standard_Boolean IsSmallClosedEdge(const TopoDS_Edge& anEdge,
-                                         const TopoDS_Vertex& aVertex);
+  const TopoDS_Vertex& aVertex);
 
 static void MakeCircle 
-(const TopoDS_Edge&                          E, 
- const TopoDS_Vertex&                        V, 
- const TopoDS_Face&                          F,
- const Standard_Real                         Offset, 
- BRepFill_IndexedDataMapOfOrientedShapeListOfShape& Map,
- const Handle(Geom_Plane)&                   RefPlane);
+  (const TopoDS_Edge&                          E, 
+  const TopoDS_Vertex&                        V, 
+  const TopoDS_Face&                          F,
+  const Standard_Real                         Offset, 
+  BRepFill_IndexedDataMapOfOrientedShapeListOfShape& Map,
+  const Handle(Geom_Plane)&                   RefPlane);
 
 static void MakeOffset 
-(const TopoDS_Edge&                          E,
- const TopoDS_Face&                          F,
- const Standard_Real                         Offset, 
- BRepFill_IndexedDataMapOfOrientedShapeListOfShape& Map,
- const Handle(Geom_Plane)&                   RefPlane,
- const Standard_Boolean                      IsOpenResult,
+  (const TopoDS_Edge&                          E,
+  const TopoDS_Face&                          F,
+  const Standard_Real                         Offset, 
+  BRepFill_IndexedDataMapOfOrientedShapeListOfShape& Map,
+  const Handle(Geom_Plane)&                   RefPlane,
+  const Standard_Boolean                      IsOpenResult,
  const GeomAbs_JoinType                      theJoinType,
- const TopoDS_Vertex *                       Ends);
+  const TopoDS_Vertex *                       Ends);
 
 //=======================================================================
 //function : KPartCircle
@@ -224,13 +225,13 @@ static void MakeOffset
 //=======================================================================
 
 static Standard_Boolean KPartCircle
-(const TopoDS_Face&  mySpine,
- const Standard_Real myOffset,
- const Standard_Boolean IsOpenResult,
- const Standard_Real Alt,
- TopoDS_Shape&       myShape, 
- BRepFill_IndexedDataMapOfOrientedShapeListOfShape& myMap,
- Standard_Boolean&    myIsDone)
+  (const TopoDS_Face&  mySpine,
+  const Standard_Real myOffset,
+  const Standard_Boolean IsOpenResult,
+  const Standard_Real Alt,
+  TopoDS_Shape&       myShape, 
+  BRepFill_IndexedDataMapOfOrientedShapeListOfShape& myMap,
+  Standard_Boolean&    myIsDone)
 {
   // The only contour which is a closed circle
   TopExp_Explorer exp(mySpine,TopAbs_EDGE);
@@ -276,7 +277,7 @@ static Standard_Boolean KPartCircle
       {
         myIsDone = Standard_False;
         return Standard_False;
-      }
+    }
     }
     else
     {
@@ -333,8 +334,8 @@ BRepFill_OffsetWire::BRepFill_OffsetWire()
 //=======================================================================
 
 BRepFill_OffsetWire::BRepFill_OffsetWire(const TopoDS_Face&     Spine,
-                                        const GeomAbs_JoinType Join,
-                                         const Standard_Boolean IsOpenResult)
+  const GeomAbs_JoinType Join,
+  const Standard_Boolean IsOpenResult)
 {
   Init(Spine,Join,IsOpenResult);
 }
@@ -345,48 +346,49 @@ BRepFill_OffsetWire::BRepFill_OffsetWire(const TopoDS_Face&     Spine,
 //=======================================================================
 
 void BRepFill_OffsetWire::Init(const TopoDS_Face&     Spine,
-                              const GeomAbs_JoinType Join,
-                               const Standard_Boolean IsOpenResult)
+  const GeomAbs_JoinType Join,
+  const Standard_Boolean IsOpenResult)
 {
   myIsDone   = Standard_False;
   TopoDS_Shape aLocalShape = Spine.Oriented(TopAbs_FORWARD);
   mySpine    = TopoDS::Face(aLocalShape);
-//  mySpine    = TopoDS::Face(Spine.Oriented(TopAbs_FORWARD));
+  //  mySpine    = TopoDS::Face(Spine.Oriented(TopAbs_FORWARD));
   myJoinType = Join;
   myIsOpenResult = IsOpenResult;
+  
   myMap.Clear();
   myMapSpine.Clear();
   //------------------------------------------------------------------
   // cut the spine for bissectors.
   //------------------------------------------------------------------
-//  Modified by Sergey KHROMOV - Tue Nov 26 17:39:03 2002 Begin
+  //  Modified by Sergey KHROMOV - Tue Nov 26 17:39:03 2002 Begin
   static BRepMAT2d_Explorer Exp;
 
   Exp.Perform(mySpine);
 
-//  TopoDS_Face anOldSpine = mySpine;
+  //  TopoDS_Face anOldSpine = mySpine;
 
   mySpine = TopoDS::Face(Exp.ModifiedShape(mySpine));
   PrepareSpine  ();
 
-//  Modified by Sergey KHROMOV - Tue Nov 26 17:39:03 2002 End
+  //  Modified by Sergey KHROMOV - Tue Nov 26 17:39:03 2002 End
   TopoDS_Shape aShape;
   BRepFill_IndexedDataMapOfOrientedShapeListOfShape aMap;
   Standard_Boolean Done;
   if (KPartCircle(myWorkSpine,1.,myIsOpenResult,0.,aShape,aMap,Done)) return;
-  
+
 
   //-----------------------------------------------------
   // Calculate the map of bissectors to the left.  
   // and Links Topology -> base elements of the map.
   //-----------------------------------------------------
   
-//  Modified by Sergey KHROMOV - Tue Nov 26 17:39:03 2002 Begin
-//   static BRepMAT2d_Explorer Exp;
-//  Modified by Sergey KHROMOV - Tue Nov 26 17:39:03 2002 End
+  //  Modified by Sergey KHROMOV - Tue Nov 26 17:39:03 2002 Begin
+  //   static BRepMAT2d_Explorer Exp;
+  //  Modified by Sergey KHROMOV - Tue Nov 26 17:39:03 2002 End
   Exp.Perform(myWorkSpine);
   myBilo.Compute(Exp, 1 ,MAT_Left, myJoinType, myIsOpenResult);
-  myLink.Perform(Exp, myBilo);
+  myLink.Perform(Exp,myBilo);
 }
 
 
@@ -429,7 +431,7 @@ const TopoDS_Shape& BRepFill_OffsetWire::Shape() const
 //=======================================================================
 
 const TopTools_ListOfShape& BRepFill_OffsetWire::GeneratedShapes
-(const TopoDS_Shape& SpineShape)
+  (const TopoDS_Shape& SpineShape)
 {  
   if (!myCallGen) {
     if (!myMapSpine.IsEmpty()) {
@@ -472,7 +474,7 @@ const TopTools_ListOfShape& BRepFill_OffsetWire::GeneratedShapes
     }
     myCallGen = Standard_True;
   }
-  
+
   if (myMap.Contains(SpineShape)) {
     return myMap.FindFromKey(SpineShape);
   }
@@ -499,7 +501,7 @@ GeomAbs_JoinType BRepFill_OffsetWire::JoinType() const
 //=======================================================================
 
 void BRepFill_OffsetWire::Perform (const Standard_Real Offset,
-                                  const Standard_Real Alt)
+  const Standard_Real Alt)
 {
   //  Modified by skv - Fri Jul  8 11:21:38 2005 OCC9145 Begin
   try
@@ -538,7 +540,7 @@ void BRepFill_OffsetWire::Perform (const Standard_Real Offset,
         GeomAdaptor_Curve  AC(G3d,f,l);
 
         PerformCurve(Parameters, Points, AC, aDefl, f, 
-                                          l, Precision::Confusion(), 2);
+          l, Precision::Confusion(), 2);
 
         Standard_Integer NPnts = Points.Length();
         if(NPnts > 2)
@@ -603,9 +605,9 @@ void BRepFill_OffsetWire::Perform (const Standard_Real Offset,
       TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itmap( wwmap );
       for (; itmap.More(); itmap.Next())
         aSubst.Substitute( itmap.Key(), itmap.Value() );
-      
+
       aSubst.Build(myWorkSpine);
-      
+
       if(aSubst.IsCopied(myWorkSpine)) {
         myWorkSpine = TopoDS::Face(aSubst.Copy(myWorkSpine).First());
 
@@ -653,10 +655,10 @@ void BRepFill_OffsetWire::Perform (const Standard_Real Offset,
   if (!myIsOpenResult)
   {
     TopExp_Explorer anExp(myShape, TopAbs_WIRE);
-    
+
     for (; anExp.More(); anExp.Next()) {
       const TopoDS_Shape &aWire = anExp.Current();
-      
+
       if (!aWire.Closed()) {
         myShape.Nullify();
         myIsDone = Standard_False;
@@ -673,9 +675,9 @@ void BRepFill_OffsetWire::Perform (const Standard_Real Offset,
 //=======================================================================
 
 void Compute (const TopoDS_Face&  Spine,
-                   TopoDS_Shape& aShape,
-                   BRepFill_IndexedDataMapOfOrientedShapeListOfShape& Map,
-             const Standard_Real Alt)
+  TopoDS_Shape& aShape,
+  BRepFill_IndexedDataMapOfOrientedShapeListOfShape& Map,
+  const Standard_Real Alt)
 {
   BRep_Builder B;
   B.MakeCompound(TopoDS::Compound(aShape));
@@ -689,7 +691,7 @@ void Compute (const TopoDS_Face&  Spine,
     const TopoDS_Wire& CurW = TopoDS::Wire(exp.Current());
     TopoDS_Shape aLocalShape = CurW.Moved(L);
     TopoDS_Wire        NewW = TopoDS::Wire(aLocalShape);
-//    TopoDS_Wire        NewW = TopoDS::Wire(CurW.Moved(L));
+    //    TopoDS_Wire        NewW = TopoDS::Wire(CurW.Moved(L));
     B.Add(aShape,NewW);
     // update Map.
     TopoDS_Iterator it1( CurW);
@@ -708,17 +710,17 @@ void Compute (const TopoDS_Face&  Spine,
 //=======================================================================
 
 void BRepFill_OffsetWire::PerformWithBiLo
-(const TopoDS_Face&              Spine,
- const Standard_Real             Offset,
- const BRepMAT2d_BisectingLocus& Locus, 
-       BRepMAT2d_LinkTopoBilo&   Link,
- const GeomAbs_JoinType          Join,
- const Standard_Real             Alt)
+  (const TopoDS_Face&              Spine,
+  const Standard_Real             Offset,
+  const BRepMAT2d_BisectingLocus& Locus, 
+  BRepMAT2d_LinkTopoBilo&   Link,
+  const GeomAbs_JoinType          Join,
+  const Standard_Real             Alt)
 {
   myIsDone     = Standard_False;
   TopoDS_Shape aLocalShape = Spine.Oriented(TopAbs_FORWARD);
   myWorkSpine  = TopoDS::Face(aLocalShape);
-//  myWorkSpine  = TopoDS::Face(Spine.Oriented(TopAbs_FORWARD));
+  //  myWorkSpine  = TopoDS::Face(Spine.Oriented(TopAbs_FORWARD));
   myJoinType   = Join;
   myOffset     = Offset ;
   myShape.Nullify();
@@ -727,8 +729,8 @@ void BRepFill_OffsetWire::PerformWithBiLo
   if (mySpine.IsNull()) {
     TopoDS_Shape aLocalShape = Spine.Oriented(TopAbs_FORWARD);
     mySpine = TopoDS::Face(aLocalShape);
-//    mySpine = TopoDS::Face(Spine.Oriented(TopAbs_FORWARD));
-}
+    //    mySpine = TopoDS::Face(Spine.Oriented(TopAbs_FORWARD));
+  }
   myMap.Clear();
 
   if ( Abs(myOffset) < Precision::Confusion()) {
@@ -745,7 +747,7 @@ void BRepFill_OffsetWire::PerformWithBiLo
 
   BRep_Builder myBuilder;
   myBuilder.MakeCompound(TopoDS::Compound(myShape));
-  
+
   //---------------------------------------------------------------------
   // MapNodeVertex : associate to each node of the map (key1) and to
   //                 each element of the profile (key2) a vertex (item).
@@ -785,7 +787,7 @@ void BRepFill_OffsetWire::PerformWithBiLo
     theWire = TopoDS::Wire(iter.Value());
     TopExp::Vertices(theWire, Ends[0], Ends[1]);
   }
-  
+
   for (Standard_Integer ic = 1; ic <= Locus.NumberOfContours(); ic++) {
     TopoDS_Shape PEE = Link.GeneratingShape(Locus.BasicElt(ic,Locus.NumberOfElts(ic)));
     TopoDS_Shape& PE = PEE ;      
@@ -797,19 +799,21 @@ void BRepFill_OffsetWire::PerformWithBiLo
                       myWorkSpine,myOffset,myMap,RefPlane);
       }
       else {
-       MakeOffset (TopoDS::Edge(SE),myWorkSpine,myOffset,myMap,RefPlane,
+        MakeOffset (TopoDS::Edge(SE),myWorkSpine,myOffset,myMap,RefPlane,
                     myIsOpenResult, myJoinType, Ends);
-       PE = SE;
+        PE = SE;
       }
     }
   }
 
 
+#ifdef OCCT_DEBUG
 #ifdef DRAW
   if (AffichEdge) {
     cout << " End Construction of geometric primitives "<<endl;
   }
 #endif
+#endif
 
 
   //---------------------------------------------------
@@ -830,13 +834,15 @@ void BRepFill_OffsetWire::PerformWithBiLo
 
     CurrentArc           = Locus.Graph()->Arc(i);
     Bisector_Bisec Bisec = Locus.GeomBis(CurrentArc,Reverse);
-    
+#ifdef OCCT_DEBUG
 #ifdef DRAW
-  if ( AffichGeom) {
-    char name[256];
-    sprintf(name,"BISSEC_%d",NbBISSEC++);
-    DrawTrSurf::Set(name,Bisec.Value());
-  }
+
+    if ( AffichGeom) {
+      char name[256];
+      sprintf(name,"BISSEC_%d",NbBISSEC++);
+      DrawTrSurf::Set(name,Bisec.Value());
+    }
+#endif
 #endif
 
     //-------------------------------------------------------------------
@@ -847,7 +853,7 @@ void BRepFill_OffsetWire::PerformWithBiLo
 
     TopTools_SequenceOfShape Vertices;
     TColgp_SequenceOfPnt     Params;
-    
+
     TopTools_DataMapOfShapeSequenceOfShape MapSeqVer;
     BRepFill_DataMapOfShapeSequenceOfPnt   MapSeqPar;
 
@@ -876,29 +882,29 @@ void BRepFill_OffsetWire::PerformWithBiLo
       Node1 = CurrentArc->FirstNode();
       Node2 = CurrentArc->SecondNode();
     }
-    
+
     Standard_Boolean StartOnEdge = 0, EndOnEdge = 0;
-    
+
     if (!Node1->Infinite()) {
       gp_Pnt2d aLocalPnt2d = Locus.GeomElt(Node1);
       StartOnEdge = VertexFromNode(Node1, myOffset, aLocalPnt2d ,MapNodeVertex,VS);
-//      StartOnEdge = VertexFromNode(Node1, myOffset, Locus.GeomElt(Node1),
-//                                MapNodeVertex,VS);
+      //      StartOnEdge = VertexFromNode(Node1, myOffset, Locus.GeomElt(Node1),
+      //                                  MapNodeVertex,VS);
     }
     if (!Node2->Infinite()) {
       gp_Pnt2d aLocalPnt2d = Locus.GeomElt(Node2) ;
       EndOnEdge   = VertexFromNode(Node2, myOffset, aLocalPnt2d ,MapNodeVertex,VE);
-//      EndOnEdge   = VertexFromNode(Node2, myOffset, Locus.GeomElt(Node2),
-//                                MapNodeVertex,VE);
+      //      EndOnEdge   = VertexFromNode(Node2, myOffset, Locus.GeomElt(Node2),
+      //                                  MapNodeVertex,VE);
     }
 
     //---------------------------------------------
     // Construction of geometries.
     //---------------------------------------------
     BRepFill_TrimEdgeTool Trim (Bisec, 
-                               Locus.GeomElt(CurrentArc->FirstElement()),
-                               Locus.GeomElt(CurrentArc->SecondElement()),
-                               myOffset);
+      Locus.GeomElt(CurrentArc->FirstElement()),
+      Locus.GeomElt(CurrentArc->SecondElement()),
+      myOffset);
 
     //-----------------------------------------------------------
     // Construction of vertices on edges parallel to the spine.
@@ -919,21 +925,21 @@ void BRepFill_OffsetWire::PerformWithBiLo
       Standard_Boolean Start = 1;
       Trim.AddOrConfuse(Start, E[0], E[1], Params);
       if (Params.Length() == Vertices.Length()) 
-        Vertices.SetValue(1,VS);
+        Vertices.SetValue(1,VS);
       
       else
-       // the point was not found by IntersectWith
-       Vertices.Prepend(VS);
+        // the point was not found by IntersectWith
+        Vertices.Prepend(VS);
     }
     if (EndOnEdge) {     
       Standard_Boolean Start = 0;
       Trim.AddOrConfuse(Start, E[0], E[1], Params);
       if (Params.Length() == Vertices.Length()) 
-        Vertices.SetValue(Params.Length(),VE);
+        Vertices.SetValue(Params.Length(),VE);
       
       else
-       // the point was not found by IntersectWith
-       Vertices.Append(VE);
+        // the point was not found by IntersectWith
+        Vertices.Append(VE);
     }
 
     //------------------------------------------------------------
@@ -949,22 +955,22 @@ void BRepFill_OffsetWire::PerformWithBiLo
 
     
     UpdateDetromp (Detromp, S[0], S[1], Vertices, Params, 
-                  Bisec, StartOnEdge, EndOnEdge, Trim);
+      Bisec, StartOnEdge, EndOnEdge, Trim);
     //----------------------------------------------
     // Storage of vertices on parallel edges.
     // fill MapBis and MapVerPar.
     //----------------------------------------------
     if (!Vertices.IsEmpty()) {
       for (k = 0; k <= 1; k++) {
-       if (!MapBis.IsBound(E[k])) {
-         MapBis   .Bind(E[k],EmptySeq);
-         MapVerPar.Bind(E[k],EmptySeqOfReal);
-       } 
-       for (Standard_Integer ii = 1; ii <= Vertices.Length(); ii++) {
-         MapBis (E[k]).Append(Vertices.Value(ii));
-         if (k == 0) MapVerPar (E[k]).Append(Params.Value(ii).Y());
-         else        MapVerPar (E[k]).Append(Params.Value(ii).Z());
-       }
+        if (!MapBis.IsBound(E[k])) {
+          MapBis   .Bind(E[k],EmptySeq);
+          MapVerPar.Bind(E[k],EmptySeqOfReal);
+        } 
+        for (Standard_Integer ii = 1; ii <= Vertices.Length(); ii++) {
+          MapBis (E[k]).Append(Vertices.Value(ii));
+          if (k == 0) MapVerPar (E[k]).Append(Params.Value(ii).Y());
+          else        MapVerPar (E[k]).Append(Params.Value(ii).Z());
+        }
       }
     }
     else {
@@ -975,21 +981,23 @@ void BRepFill_OffsetWire::PerformWithBiLo
       // if myoffset is < distance of nodes the parallel can be valid.
       //-------------------------------------------------------------
       for (k = 0; k <= 1; k++) {
-       if (!MapBis.IsBound(E[k])) {
-         if (Node1->Distance() > myOffset && Node2->Distance() > myOffset) {
-           MapBis   .Bind(E[k],EmptySeq); 
-           MapVerPar.Bind(E[k],EmptySeqOfReal);
-         }
-       }
+        if (!MapBis.IsBound(E[k])) {
+          if (Node1->Distance() > myOffset && Node2->Distance() > myOffset) {
+            MapBis   .Bind(E[k],EmptySeq); 
+            MapVerPar.Bind(E[k],EmptySeqOfReal);
+          }
+        }
       }
     }
   }
-  
+
+#ifdef OCCT_DEBUG
 #ifdef DRAW
   if (AffichEdge) {
     cout << " End Construction of vertices on offsets"<<endl;
   }
 #endif
+#endif
 
   //----------------------------------
   // Construction of parallel edges.
@@ -1016,54 +1024,54 @@ void BRepFill_OffsetWire::PerformWithBiLo
           else if (j == myMap.Extent())
             IndOfE = -1;
         }
-       TrimEdge (CurrentEdge,
-                  CurrentSpine,
-                  mySpine,
-                 Detromp  (CurrentSpine),
-                 MapBis   (CurrentEdge) ,  
-                 MapVerPar(CurrentEdge) ,
-                 S, MapVV, IndOfE);
-       for ( k = 1; k <= S.Length(); k++) {
-         myMap(j).Append(S.Value(k));
-       }
+        TrimEdge (CurrentEdge,
+          CurrentSpine,
+          mySpine,
+          Detromp  (CurrentSpine),
+          MapBis   (CurrentEdge) ,  
+          MapVerPar(CurrentEdge) ,
+          S, MapVV, IndOfE);
+        for ( k = 1; k <= S.Length(); k++) {
+          myMap(j).Append(S.Value(k));
+        }
       }
       else {
-       //-----------------
-       // Complete circles
-       //-----------------
-       myMap(j).Append(CurrentEdge);
+        //-----------------
+        // Complete circles
+        //-----------------
+        myMap(j).Append(CurrentEdge);
       }
     }
   }
-  
+
   Standard_Integer ind;
   for (ind = 1; ind <= MapVV.Extent(); ind++)
+  {
+    TopoDS_Vertex OldV = TopoDS::Vertex(MapVV.FindKey(ind));
+    TopoDS_Vertex NewV = TopoDS::Vertex(MapVV(ind));
+    gp_Pnt P1 = BRep_Tool::Pnt(OldV);
+    gp_Pnt P2 = BRep_Tool::Pnt(NewV);
+    myBuilder.UpdateVertex(NewV, P1.Distance(P2));
+    TopTools_ListOfShape LV;
+    LV.Append( NewV.Oriented(TopAbs_FORWARD) );
+    BRepTools_Substitution aSubst;
+    aSubst.Substitute( OldV, LV );
+    for (j = 1; j <= myMap.Extent(); j++)
     {
-      TopoDS_Vertex OldV = TopoDS::Vertex(MapVV.FindKey(ind));
-      TopoDS_Vertex NewV = TopoDS::Vertex(MapVV(ind));
-      gp_Pnt P1 = BRep_Tool::Pnt(OldV);
-      gp_Pnt P2 = BRep_Tool::Pnt(NewV);
-      myBuilder.UpdateVertex(NewV, P1.Distance(P2));
-      TopTools_ListOfShape LV;
-      LV.Append( NewV.Oriented(TopAbs_FORWARD) );
-      BRepTools_Substitution aSubst;
-      aSubst.Substitute( OldV, LV );
-      for (j = 1; j <= myMap.Extent(); j++)
-       {
-         TopTools_ListIteratorOfListOfShape itl(myMap(j));
-         for (; itl.More(); itl.Next())
-           {
-             aSubst.Build(itl.Value());
-             if (aSubst.IsCopied(itl.Value()))
-               {
-                 const TopTools_ListOfShape& listSh = aSubst.Copy(itl.Value());
-                  TopAbs_Orientation SaveOr = itl.Value().Orientation();
-                 itl.Value() = listSh.First();
-                  itl.Value().Orientation(SaveOr);
-               }
-           }
-       }
+      TopTools_ListIteratorOfListOfShape itl(myMap(j));
+      for (; itl.More(); itl.Next())
+      {
+        aSubst.Build(itl.Value());
+        if (aSubst.IsCopied(itl.Value()))
+        {
+          const TopTools_ListOfShape& listSh = aSubst.Copy(itl.Value());
+          TopAbs_Orientation SaveOr = itl.Value().Orientation();
+          itl.Value() = listSh.First();
+          itl.Value().Orientation(SaveOr);
+        }
+      }
     }
+  }
       
   //----------------------------------
   // Construction of offset wires.
@@ -1086,39 +1094,40 @@ void BRepFill_OffsetWire::PerformWithBiLo
   MapVertex.Clear();
   TopExp_Explorer Explo( myShape, TopAbs_EDGE );
   for (; Explo.More(); Explo.Next())
+  {
+    TopoDS_Edge E = TopoDS::Edge( Explo.Current() );
+    TopoDS_Vertex V1, V2;
+    TopExp::Vertices( E, V1, V2 );
+    Handle(BRep_TVertex)& TV1 = *((Handle(BRep_TVertex)*) &(V1).TShape());
+    Handle(BRep_TVertex)& TV2 = *((Handle(BRep_TVertex)*) &(V2).TShape());
+
+    TopLoc_Location loc;
+    Standard_Real f, l;
+    Handle( Geom_Curve ) theCurve = BRep_Tool::Curve( E, loc, f, l );
+    theCurve = Handle( Geom_Curve )::DownCast( theCurve->Copy() );
+    theCurve->Transform( loc.Transformation() );
+    gp_Pnt f3d = theCurve->Value( f );
+    gp_Pnt l3d = theCurve->Value( l );
+
+    Standard_Real dist1, dist2;
+    dist1 = f3d.Distance( TV1->Pnt() );
+    dist2 = l3d.Distance( TV2->Pnt() );
+    if (! MapVertex.Contains( V1 ))
     {
-      TopoDS_Edge E = TopoDS::Edge( Explo.Current() );
-      TopoDS_Vertex V1, V2;
-      TopExp::Vertices( E, V1, V2 );
-      Handle(BRep_TVertex)& TV1 = *((Handle(BRep_TVertex)*) &(V1).TShape());
-      Handle(BRep_TVertex)& TV2 = *((Handle(BRep_TVertex)*) &(V2).TShape());
       
-      TopLoc_Location loc;
-      Standard_Real f, l;
-      Handle( Geom_Curve ) theCurve = BRep_Tool::Curve( E, loc, f, l );
-      theCurve = Handle( Geom_Curve )::DownCast( theCurve->Copy() );
-      theCurve->Transform( loc.Transformation() );
-      gp_Pnt f3d = theCurve->Value( f );
-      gp_Pnt l3d = theCurve->Value( l );
-
-      Standard_Real dist1, dist2;
-      dist1 = f3d.Distance( TV1->Pnt() );
-      dist2 = l3d.Distance( TV2->Pnt() );
-      if (! MapVertex.Contains( V1 ))
-       {
-         TV1->Pnt( f3d );
-         MapVertex.Add( V1 );
-       }
-      else
-       TV1->UpdateTolerance( 1.5*dist1 );
-      if (! MapVertex.Contains( V2 ))
-       {
-         TV2->Pnt( l3d );
-         MapVertex.Add( V2 );
-       }
-      else
-       TV2->UpdateTolerance( 1.5*dist2 );
+      TV1->Pnt( f3d );
+      MapVertex.Add( V1 );
     }
+    else
+      TV1->UpdateTolerance( 1.5*dist1 );
+    if (! MapVertex.Contains( V2 ))
+    {
+      TV2->Pnt( l3d );
+      MapVertex.Add( V2 );
+    }
+    else
+      TV2->UpdateTolerance( 1.5*dist2 );
+  }
 
   FixHoles();
 
@@ -1132,7 +1141,7 @@ void BRepFill_OffsetWire::PerformWithBiLo
 //=======================================================================
 
 BRepFill_IndexedDataMapOfOrientedShapeListOfShape& 
-BRepFill_OffsetWire::Generated() 
+  BRepFill_OffsetWire::Generated() 
 {
   return myMap;
 }
@@ -1163,7 +1172,7 @@ void BRepFill_OffsetWire::PrepareSpine()
     TopoDS_Wire NW;
     B.MakeWire (NW);
 
-//  Modified by Sergey KHROMOV - Thu Nov 16 17:29:55 2000 Begin
+    //  Modified by Sergey KHROMOV - Thu Nov 16 17:29:55 2000 Begin
     Standard_Integer ForcedCut = 0;
     Standard_Integer nbResEdges = -1;
     TopTools_IndexedMapOfShape EdgeMap;
@@ -1173,7 +1182,7 @@ void BRepFill_OffsetWire::PrepareSpine()
     
     if (nbEdges == 1 && !myIsOpenResult) //in case of open wire there's no need to do it
       ForcedCut = 2;
-//  Modified by Sergey KHROMOV - Thu Nov 16 17:29:48 2000 End
+    //  Modified by Sergey KHROMOV - Thu Nov 16 17:29:48 2000 End
 
     for (TopoDS_Iterator IteW(IteF.Value()); IteW.More(); IteW.Next()) {
       
@@ -1185,44 +1194,50 @@ void BRepFill_OffsetWire::PrepareSpine()
 
       // Cut
       TopoDS_Shape aLocalShape = E.Oriented(TopAbs_FORWARD);
-//  Modified by Sergey KHROMOV - Thu Nov 16 17:29:29 2000 Begin
+      //  Modified by Sergey KHROMOV - Thu Nov 16 17:29:29 2000 Begin
       if (nbEdges == 2 && nbResEdges == 0)
-       ForcedCut = 1;
-//  Modified by Sergey KHROMOV - Thu Nov 16 17:29:33 2000 End
+        ForcedCut = 1;
+      //  Modified by Sergey KHROMOV - Thu Nov 16 17:29:33 2000 End
       nbResEdges = CutEdge (TopoDS::Edge(aLocalShape), mySpine, ForcedCut, Cuts);
       
       if (Cuts.IsEmpty()) {
-       B.Add(NW,E);
-       myMapSpine.Bind(E,E);
+        B.Add(NW,E);
+        myMapSpine.Bind(E,E);
       }
       else {   
-       for (IteCuts.Initialize(Cuts); IteCuts.More(); IteCuts.Next()) {
-         TopoDS_Edge NE = TopoDS::Edge(IteCuts.Value());
-         NE.Orientation(E.Orientation());
-         B.Add(NW,NE);
-         myMapSpine.Bind(NE,E);
-         EdgeVertices(NE,V1,V2);
-         if (!myMapSpine.IsBound(V1)) myMapSpine.Bind(V1,E);
-         if (!myMapSpine.IsBound(V2)) myMapSpine.Bind(V2,E);
-       }
+        for (IteCuts.Initialize(Cuts); IteCuts.More(); IteCuts.Next()) {
+          TopoDS_Edge NE = TopoDS::Edge(IteCuts.Value());
+          NE.Orientation(E.Orientation());
+          B.Add(NW,NE);
+          myMapSpine.Bind(NE,E);
+          EdgeVertices(NE,V1,V2);
+          if (!myMapSpine.IsBound(V1)) myMapSpine.Bind(V1,E);
+          if (!myMapSpine.IsBound(V2)) myMapSpine.Bind(V2,E);
+        }
       }
     }
-//  Modified by Sergey KHROMOV - Thu Mar  7 09:17:41 2002 Begin
+    //  Modified by Sergey KHROMOV - Thu Mar  7 09:17:41 2002 Begin
     TopoDS_Vertex aV1;
     TopoDS_Vertex aV2;
 
     TopExp::Vertices(NW, aV1, aV2);
 
     NW.Closed(aV1.IsSame(aV2));
-//  Modified by Sergey KHROMOV - Thu Mar  7 09:17:43 2002 End
+
+    //  Modified by Sergey KHROMOV - Thu Mar  7 09:17:43 2002 End
     B.Add(myWorkSpine, NW);
   }
 
+#ifdef OCCT_DEBUG
 #ifdef DRAW
   if ( AffichEdge) {
     DBRep::Set("WS",myWorkSpine);
+    DBRep::Set("MS",mySpine);
+    BRepTools::Write(myWorkSpine, "WS");
+    BRepTools::Write(mySpine, "MS");
   }
 #endif
+#endif
 
 }
 
@@ -1266,7 +1281,7 @@ void BRepFill_OffsetWire::UpdateDetromp (BRepFill_DataMapOfOrientedShapeListOfSh
 
     gp_Pnt2d P = Bis->Value((U2 + U1)*0.5);
     Standard_Boolean IsP_inside = Standard_True;
-    if (myJoinType == GeomAbs_Arc)
+    if ((myJoinType != GeomAbs_Intersection) || EOnE)
       IsP_inside = Trim.IsInside(P);
     if (!IsP_inside) {
       if (!V1.IsNull()) {
@@ -1290,19 +1305,26 @@ void BRepFill_OffsetWire::UpdateDetromp (BRepFill_DataMapOfOrientedShapeListOfSh
       if (myJoinType == GeomAbs_Arc)
         IsP_inside = Trim.IsInside(P);
       if (!IsP_inside) {
-       if (!V1.IsNull()) {
-         Detromp(Shape1).Append(V1);
-         Detromp(Shape2).Append(V1);
-       }
+        if (!V1.IsNull()) {
+          Detromp(Shape1).Append(V1);
+          Detromp(Shape2).Append(V1);
+        }
       }
     }
     else {
       if (!V1.IsNull()) {
-       Detromp(Shape1).Append(V1);
-       Detromp(Shape2).Append(V1);
+        Detromp(Shape1).Append(V1);
+        Detromp(Shape2).Append(V1);
       }
     }
   }    
+  //else if(myJoinType != GeomAbs_Arc)
+  //{
+  //  if (!V1.IsNull()) {
+  //    Detromp(Shape1).Append(V1);
+  //    Detromp(Shape2).Append(V1);
+  //  }
+  //}
 }
 
 //=======================================================================
@@ -1329,15 +1351,15 @@ void BRepFill_OffsetWire::MakeWires()
       const TopoDS_Edge& E = TopoDS::Edge(itl.Value());
       TopExp::Vertices (E,V1,V2);
       if (V1.IsSame(V2) && IsSmallClosedEdge(E, V1))
-       continue; //remove small closed edges
+        continue; //remove small closed edges
       if (!MVE.Contains(V1)) {
-       TopTools_ListOfShape empty;
-       MVE.Add(V1,empty);
+        TopTools_ListOfShape empty;
+        MVE.Add(V1,empty);
       }
       MVE.ChangeFromKey(V1).Append(E);
       if (!MVE.Contains(V2)) {
-       TopTools_ListOfShape empty;
-       MVE.Add(V2,empty);
+        TopTools_ListOfShape empty;
+        MVE.Add(V2,empty);
       }
       MVE.ChangeFromKey(V2).Append(E);
     }
@@ -1348,9 +1370,10 @@ void BRepFill_OffsetWire::MakeWires()
   //--------------------------------------
   BRep_Builder B;
 
-//  Standard_Integer NbEdges;
-//  Standard_Boolean NewWire  = Standard_True;
-//  Standard_Boolean AddEdge  = Standard_False;
+
+  //  Standard_Integer NbEdges;
+  //  Standard_Boolean NewWire  = Standard_True;
+  //  Standard_Boolean AddEdge  = Standard_False;
 
   TopoDS_Wire      NW;
   Standard_Boolean End;
@@ -1373,9 +1396,10 @@ void BRepFill_OffsetWire::MakeWires()
     End = Standard_False;
     MVE.ChangeFromKey(CV).RemoveFirst(); 
 
-//  Modified by Sergey KHROMOV - Thu Mar 14 11:29:59 2002 Begin
+    //  Modified by Sergey KHROMOV - Thu Mar 14 11:29:59 2002 Begin
     Standard_Boolean isClosed = Standard_False;
-//  Modified by Sergey KHROMOV - Thu Mar 14 11:30:00 2002 End
+
+    //  Modified by Sergey KHROMOV - Thu Mar 14 11:30:00 2002 End
 
     while(!End) {      
       //-------------------------------
@@ -1387,11 +1411,11 @@ void BRepFill_OffsetWire::MakeWires()
       B.Add (NW,CE);
 
       if (VF.IsSame(CV) || !MVE.Contains(CV)) {
-//  Modified by Sergey KHROMOV - Thu Mar 14 11:30:14 2002 Begin
-       isClosed = VF.IsSame(CV);
-//  Modified by Sergey KHROMOV - Thu Mar 14 11:30:15 2002 End
-       End = Standard_True;
-       //MVE.UnBind(VF);
+        //  Modified by Sergey KHROMOV - Thu Mar 14 11:30:14 2002 Begin
+        isClosed = VF.IsSame(CV);
+        //  Modified by Sergey KHROMOV - Thu Mar 14 11:30:15 2002 End
+        End = Standard_True;
+        //MVE.UnBind(VF);
         TopoDS_Shape LastShape = MVE.FindKey(MVE.Extent());
         TopTools_ListOfShape LastList;
         LastList.Append(MVE(MVE.Extent()));
@@ -1401,20 +1425,20 @@ void BRepFill_OffsetWire::MakeWires()
       }
 
       if (!End) {
-       if (MVE.FindFromKey(CV).Extent() > 2) {
-         //cout <<"vertex on more that 2 edges in a face."<<endl;
-       }
-       for ( itl.Initialize(MVE.FindFromKey(CV)); itl.More(); itl.Next()) {
-         if (itl.Value().IsSame(CE)) {
-           MVE.ChangeFromKey(CV).Remove(itl);
-           break;
-         }
-       }
-       if (!MVE.FindFromKey(CV).IsEmpty()) {
-         CE = TopoDS::Edge(MVE.FindFromKey(CV).First());
-         MVE.ChangeFromKey(CV).RemoveFirst();
-       }
-       if (MVE.FindFromKey(CV).IsEmpty())
+        if (MVE.FindFromKey(CV).Extent() > 2) {
+          //cout <<"vertex on more that 2 edges in a face."<<endl;
+        }
+        for ( itl.Initialize(MVE.FindFromKey(CV)); itl.More(); itl.Next()) {
+          if (itl.Value().IsSame(CE)) {
+            MVE.ChangeFromKey(CV).Remove(itl);
+            break;
+          }
+        }
+        if (!MVE.FindFromKey(CV).IsEmpty()) {
+          CE = TopoDS::Edge(MVE.FindFromKey(CV).First());
+          MVE.ChangeFromKey(CV).RemoveFirst();
+        }
+        if (MVE.FindFromKey(CV).IsEmpty())
         {
           //MVE.UnBind(CV);
           TopoDS_Shape LastShape = MVE.FindKey(MVE.Extent());
@@ -1426,10 +1450,10 @@ void BRepFill_OffsetWire::MakeWires()
         }
       }
     }
-//  Modified by Sergey KHROMOV - Thu Mar 14 11:29:31 2002 Begin
-//     NW.Closed(Standard_True);
+    //  Modified by Sergey KHROMOV - Thu Mar 14 11:29:31 2002 Begin
+    //     NW.Closed(Standard_True);
     NW.Closed(isClosed);
-//  Modified by Sergey KHROMOV - Thu Mar 14 11:29:37 2002 End
+    //  Modified by Sergey KHROMOV - Thu Mar 14 11:29:37 2002 End
     TheWires.Append(NW);
   }
 
@@ -1514,7 +1538,12 @@ void BRepFill_OffsetWire::FixHoles()
     TopoDS_Vertex Vf, Vl;
     TopExp::Vertices( Base, Vf, Vl );
     if(Vf.IsNull() || Vl.IsNull())
+    {
       Standard_Failure::Raise("BRepFill_OffsetWire::FixHoles(): Wrong wire.");
+#ifdef OCCT_DEBUG
+      BRepTools::Write(Base, "Base");
+#endif
+    }
     gp_Pnt Pf, Pl;
     Pf = BRep_Tool::Pnt(Vf);
     Pl = BRep_Tool::Pnt(Vl);
@@ -1528,7 +1557,15 @@ void BRepFill_OffsetWire::FixHoles()
       TopExp::Vertices( aWire, V1, V2 );
 
       if(V1.IsNull() || V2.IsNull())
+      {
         Standard_Failure::Raise("BRepFill_OffsetWire::FixHoles(): Wrong wire.");
+#ifdef OCCT_DEBUG
+        BRepTools::Write(Base, "Base");
+        char name[128];
+        sprintf(name,"Wire_%d",i);
+        BRepTools::Write(aWire, name);
+#endif
+      }
 
       gp_Pnt P1, P2;
       P1 = BRep_Tool::Pnt(V1);
@@ -1737,9 +1774,9 @@ void BRepFill_OffsetWire::FixHoles()
 //           belong to the first and the last parts respectively.
 //=======================================================================
 Standard_Integer CutEdge (const TopoDS_Edge& E, 
-                         const TopoDS_Face& F,
-                               Standard_Integer ForceCut,
-                               TopTools_ListOfShape& Cuts)
+  const TopoDS_Face& F,
+  Standard_Integer ForceCut,
+  TopTools_ListOfShape& Cuts)
 {
   Cuts.Clear();
   MAT2d_CutCurve              Cuter;
@@ -1747,25 +1784,25 @@ Standard_Integer CutEdge (const TopoDS_Edge& E,
   Standard_Real               f,l;
   Handle(Geom2d_Curve)        C2d;
   Handle(Geom2d_TrimmedCurve) CT2d;
-//  Modified by Sergey KHROMOV - Wed Mar  6 17:36:25 2002 Begin
+  //  Modified by Sergey KHROMOV - Wed Mar  6 17:36:25 2002 Begin
   Standard_Real               aTol = BRep_Tool::Tolerance(E);
   Handle(Geom_Curve)          aC;
-//  Modified by Sergey KHROMOV - Wed Mar  6 17:36:25 2002 End
+  //  Modified by Sergey KHROMOV - Wed Mar  6 17:36:25 2002 End
   
   TopoDS_Vertex V1,V2,VF,VL;
   TopExp::Vertices (E,V1,V2);
   BRep_Builder B;
   
   C2d  = BRep_Tool::CurveOnSurface (E,F,f,l);
-//  Modified by Sergey KHROMOV - Wed Mar  6 17:36:54 2002 Begin
+  //  Modified by Sergey KHROMOV - Wed Mar  6 17:36:54 2002 Begin
   aC   = BRep_Tool::Curve(E,f,l);
-//  Modified by Sergey KHROMOV - Wed Mar  6 17:36:54 2002 End
+  //  Modified by Sergey KHROMOV - Wed Mar  6 17:36:54 2002 End
   CT2d = new Geom2d_TrimmedCurve(C2d,f,l);
   //if (E.Orientation() == TopAbs_REVERSED) CT2d->Reverse();
 
   if (CT2d->BasisCurve()->IsKind(STANDARD_TYPE(Geom2d_Circle)) &&
-      ( Abs(f-l) >= M_PI) ) {
-    return 0;
+    ( Abs(f-l) >= M_PI) ) {
+      return 0;
   }
 
   //-------------------------
@@ -1773,45 +1810,48 @@ Standard_Integer CutEdge (const TopoDS_Edge& E,
   //-------------------------
   Cuter.Perform(CT2d);
 
-//  Modified by Sergey KHROMOV - Thu Nov 16 17:28:29 2000 Begin
+  //  Modified by Sergey KHROMOV - Thu Nov 16 17:28:29 2000 Begin
   if (ForceCut == 0) {
     if (Cuter.UnModified()) {
-    //-----------------------------
-    // edge not modified => return.
-    //-----------------------------
+      //-----------------------------
+      // edge not modified => return.
+      //-----------------------------
       return 0;
     } else {
       for (Standard_Integer k = 1; k <= Cuter.NbCurves(); k++)
-       theCurves.Append(Cuter.Value(k));
+        theCurves.Append(Cuter.Value(k));
     }
   } else if (ForceCut == 1) {
     if (Cuter.UnModified()) {
       CutCurve (CT2d, 2, theCurves);
     } else {
       for (Standard_Integer k = 1; k <= Cuter.NbCurves(); k++)
-       theCurves.Append(Cuter.Value(k));
+
+       theCurves.Append(Cuter.Value(k));
     }
   } else if (ForceCut == 2) {
     if (Cuter.UnModified()) {
       CutCurve (CT2d, 3, theCurves);
     } else {
       if (Cuter.NbCurves() == 2) {
-       Handle(Geom2d_TrimmedCurve)CC = Cuter.Value(1);
-
-       if (CC->LastParameter() > (l+f)/2.) {
-         CutCurve (CC, 2, theCurves);
-         theCurves.Append(Cuter.Value(2));
-       } else {
-         theCurves.Append(CC);
-         CutCurve (Cuter.Value(2), 2, theCurves);
-       }
+
+        Handle(Geom2d_TrimmedCurve)CC = Cuter.Value(1);
+
+        if (CC->LastParameter() > (l+f)/2.) {
+          CutCurve (CC, 2, theCurves);
+          theCurves.Append(Cuter.Value(2));
+        } else {
+          theCurves.Append(CC);
+          CutCurve (Cuter.Value(2), 2, theCurves);
+        }
       } else {
-       for (Standard_Integer k = 1; k <= Cuter.NbCurves(); k++)
-         theCurves.Append(Cuter.Value(k));
+        for (Standard_Integer k = 1; k <= Cuter.NbCurves(); k++)
+          theCurves.Append(Cuter.Value(k));
       }
     }
   }
-//  Modified by Sergey KHROMOV - Thu Nov 16 17:28:37 2000 End
+
+  //  Modified by Sergey KHROMOV - Thu Nov 16 17:28:37 2000 End
 
   //--------------------------------------
   // Creation of cut edges.
@@ -1824,16 +1864,16 @@ Standard_Integer CutEdge (const TopoDS_Edge& E,
 
     if (k == theCurves.Length()) {VL = V2;}
     else { 
-//  Modified by Sergey KHROMOV - Wed Mar  6 17:38:02 2002 Begin
+      //  Modified by Sergey KHROMOV - Wed Mar  6 17:38:02 2002 Begin
       gp_Pnt        P = aC->Value(CC->LastParameter());
 
       VL = BRepLib_MakeVertex(P);
       B.UpdateVertex(VL, aTol);
-//  Modified by Sergey KHROMOV - Wed Mar  6 17:38:05 2002 End
+      //  Modified by Sergey KHROMOV - Wed Mar  6 17:38:05 2002 End
     }
     TopoDS_Shape aLocalShape = E.EmptyCopied();
     TopoDS_Edge NE = TopoDS::Edge(aLocalShape);
-//      TopoDS_Edge NE = TopoDS::Edge(E.EmptyCopied());
+    //      TopoDS_Edge NE = TopoDS::Edge(E.EmptyCopied());
     NE.Orientation(TopAbs_FORWARD);
     B.Add  (NE,VF.Oriented(TopAbs_FORWARD));
     B.Add  (NE,VL.Oriented(TopAbs_REVERSED));      
@@ -1852,8 +1892,8 @@ Standard_Integer CutEdge (const TopoDS_Edge& E,
 //=======================================================================
 
 void CutCurve (const Handle(Geom2d_TrimmedCurve)& C,
-              const Standard_Integer nbParts,
-                    TColGeom2d_SequenceOfCurve& theCurves)
+  const Standard_Integer nbParts,
+  TColGeom2d_SequenceOfCurve& theCurves)
 {
   Handle(Geom2d_TrimmedCurve) TrimC;
   Standard_Real               UF,UL,UC;
@@ -1877,7 +1917,7 @@ void CutCurve (const Handle(Geom2d_TrimmedCurve)& C,
 
     if (UC - UF > PTol && PC.Distance(PF) > Tol) {
       if ( UL - UC < PTol || PL.Distance(PC) < Tol)
-       continue;
+        continue;
 
       TrimC = new Geom2d_TrimmedCurve(C,UF,UC);
       theCurves.Append(TrimC);
@@ -1900,11 +1940,11 @@ void CutCurve (const Handle(Geom2d_TrimmedCurve)& C,
 //=======================================================================
 
 void MakeCircle (const TopoDS_Edge&          E,
-                const TopoDS_Vertex&        V,
-                const TopoDS_Face&          F,
-                const Standard_Real         Offset, 
-                      BRepFill_IndexedDataMapOfOrientedShapeListOfShape& Map,
-                const Handle(Geom_Plane)&   RefPlane)
+  const TopoDS_Vertex&        V,
+  const TopoDS_Face&          F,
+  const Standard_Real         Offset, 
+  BRepFill_IndexedDataMapOfOrientedShapeListOfShape& Map,
+  const Handle(Geom_Plane)&   RefPlane)
 {
   // evaluate the Axis of the Circle.
   Standard_Real f,l;
@@ -1929,6 +1969,7 @@ void MakeCircle (const TopoDS_Edge&          E,
   LL.Append(OE);
   Map.Add(V,LL);
 
+#ifdef OCCT_DEBUG
 #ifdef DRAW
   if ( AffichGeom && !OE.IsNull()) {
     char name[256];
@@ -1936,6 +1977,7 @@ void MakeCircle (const TopoDS_Edge&          E,
     DBRep::Set(name,OE);
   }
 #endif
+#endif
 }
 
 //=======================================================================
@@ -1944,13 +1986,13 @@ void MakeCircle (const TopoDS_Edge&          E,
 //=======================================================================
 
 void MakeOffset (const TopoDS_Edge&        E, 
-                const TopoDS_Face&        F,
-                const Standard_Real       Offset, 
-                      BRepFill_IndexedDataMapOfOrientedShapeListOfShape& Map,
-                const Handle(Geom_Plane)& RefPlane,
-                 const Standard_Boolean    IsOpenResult,
+  const TopoDS_Face&        F,
+  const Standard_Real       Offset, 
+  BRepFill_IndexedDataMapOfOrientedShapeListOfShape& Map,
+  const Handle(Geom_Plane)& RefPlane,
+  const Standard_Boolean    IsOpenResult,
                  const GeomAbs_JoinType    theJoinType,
-                 const TopoDS_Vertex *     Ends)
+  const TopoDS_Vertex *     Ends)
 {
   Standard_Real f,l;
   Standard_Real anOffset = Offset;
@@ -1967,10 +2009,10 @@ void MakeOffset (const TopoDS_Edge&        E,
     TopoDS_Vertex V1, V2;
     TopExp::Vertices(E, V1, V2);
     if (V1.IsSame(Ends[0]) ||
-        V1.IsSame(Ends[1]))
+      V1.IsSame(Ends[1]))
       ToExtendFirstPar = Standard_False;
     if (V2.IsSame(Ends[0]) ||
-        V2.IsSame(Ends[1]))
+      V2.IsSame(Ends[1]))
       ToExtendLastPar  = Standard_False;
   }
 
@@ -1988,17 +2030,17 @@ void MakeOffset (const TopoDS_Edge&        E,
     if (anOffset*Signe < AC.Circle().Radius() - Precision::Confusion()) {
 
       Handle(Geom2dAdaptor_HCurve) AHC = 
-       new Geom2dAdaptor_HCurve(G2d);
+        new Geom2dAdaptor_HCurve(G2d);
       Adaptor3d_OffsetCurve   Off(AHC,-anOffset);
       Handle(Geom2d_Circle) CC = new Geom2d_Circle(Off.Circle());      
 
       Standard_Real Delta = 2*M_PI - l + f;
       if (theJoinType == GeomAbs_Arc)
       {
-        if (ToExtendFirstPar)
-          f -= 0.2*Delta;
-        if (ToExtendLastPar)
-          l += 0.2*Delta;
+      if (ToExtendFirstPar)
+        f -= 0.2*Delta;
+      if (ToExtendLastPar)
+        l += 0.2*Delta;
       }
       else //GeomAbs_Intersection
       {
@@ -2030,14 +2072,14 @@ void MakeOffset (const TopoDS_Edge&        E,
     if (ToExtendFirstPar)
     {
       if (theJoinType == GeomAbs_Arc)
-        f -= Delta;
+      f -= Delta;
       else //GeomAbs_Intersection
         f = -Precision::Infinite();
     }
     if (ToExtendLastPar)
     {
       if (theJoinType == GeomAbs_Arc)
-        l += Delta;
+      l += Delta;
       else //GeomAbs_Intersection
         l = Precision::Infinite();
     }
@@ -2059,15 +2101,17 @@ void MakeOffset (const TopoDS_Edge&        E,
     LL.Append(OE);
     Map.Add(E,LL);
 
+#ifdef OCCT_DEBUG
 #ifdef DRAW  
     if (AffichGeom && !OE.IsNull()) {
       char name[256];
       sprintf(name,"OFFSET_%d",++NbOFFSET);
       DBRep::Set(name,OE);
-      Standard_Real ii = 0;
+      //Standard_Real ii = 0;
     }
 #endif
-    
+#endif
+
   }
 }  
 
@@ -2078,10 +2122,10 @@ void MakeOffset (const TopoDS_Edge&        E,
 //=======================================================================
 
 Standard_Boolean VertexFromNode (const Handle(MAT_Node)&      aNode, 
-                                const Standard_Real          Offset,
-                                 gp_Pnt2d&                   PN,
-                                BRepFill_DataMapOfNodeShape& MapNodeVertex,
-                                TopoDS_Vertex&               VN)
+  const Standard_Real          Offset,
+  gp_Pnt2d&                   PN,
+  BRepFill_DataMapOfNodeShape& MapNodeVertex,
+  TopoDS_Vertex&               VN)
 {  
   Standard_Boolean Status;
   Standard_Real    Tol = Precision::Confusion();
@@ -2114,8 +2158,8 @@ Standard_Boolean VertexFromNode (const Handle(MAT_Node)&      aNode,
 //=======================================================================
 
 void StoreInMap (const TopoDS_Shape& V1,
-                const TopoDS_Shape& V2,
-                TopTools_IndexedDataMapOfShapeShape& MapVV)
+  const TopoDS_Shape& V2,
+  TopTools_IndexedDataMapOfShapeShape& MapVV)
 {
   TopoDS_Shape OldV = V1, NewV = V2;
   Standard_Integer i;
@@ -2159,9 +2203,9 @@ void TrimEdge (const TopoDS_Edge&              E,
     Change = Standard_False;
     for (Standard_Integer i = 1; i < ThePar.Length(); i++) {
       if (ThePar.Value(i) > ThePar.Value(i+1)) {
-       ThePar.Exchange(i,i+1);
-       TheVer.Exchange(i,i+1);
-       Change = Standard_True;
+        ThePar.Exchange(i,i+1);
+        TheVer.Exchange(i,i+1);
+        Change = Standard_True;
       }
     }
   }
@@ -2172,10 +2216,10 @@ void TrimEdge (const TopoDS_Edge&              E,
   if (!BRep_Tool::Degenerated(E)) {
     for (Standard_Integer k = 1; k <= TheVer.Length(); k ++) {
       if ( DoubleOrNotInside (Detromp,
-                             TopoDS::Vertex(TheVer.Value(k)))) {
-       TheVer.Remove(k);
-       ThePar.Remove(k);
-       k--;
+        TopoDS::Vertex(TheVer.Value(k)))) {
+          TheVer.Remove(k);
+          ThePar.Remove(k);
+          k--;
       }
     }
   }
@@ -2188,27 +2232,28 @@ void TrimEdge (const TopoDS_Edge&              E,
   if (!BRep_Tool::Degenerated(E)) {
     for (Standard_Integer k = 1; k < TheVer.Length(); k ++) {
       if (TheVer.Value(k).IsSame(TheVer.Value(k+1)) || 
-        Abs(ThePar.Value(k)-ThePar.Value(k+1)) <= Precision::PConfusion()) {
-
-       if(k+1 == TheVer.Length()) {
-         StoreInMap(TheVer(k), TheVer(k+1), MapVV);
-         TheVer.Remove(k);
-         ThePar.Remove(k);
-       }
-       else {
-         StoreInMap(TheVer(k+1), TheVer(k), MapVV);
-         TheVer.Remove(k+1);
-         ThePar.Remove(k+1);
-       }
-       /*
-       if ( DoubleOrNotInside (Detromp,
-                               TopoDS::Vertex(TheVer.Value(k)))) {
-         TheVer.Remove(k);
-         ThePar.Remove(k);
-         k--;
-       }
-       */
-       k--;
+
+        Abs(ThePar.Value(k)-ThePar.Value(k+1)) <= Precision::PConfusion()) {
+
+          if(k+1 == TheVer.Length()) {
+            StoreInMap(TheVer(k), TheVer(k+1), MapVV);
+            TheVer.Remove(k);
+            ThePar.Remove(k);
+          }
+          else {
+            StoreInMap(TheVer(k+1), TheVer(k), MapVV);
+            TheVer.Remove(k+1);
+            ThePar.Remove(k+1);
+          }
+          /*
+          if ( DoubleOrNotInside (Detromp,
+          TopoDS::Vertex(TheVer.Value(k)))) {
+          TheVer.Remove(k);
+          ThePar.Remove(k);
+          k--;
+          }
+          */
+          k--;
       }
     }
   }
@@ -2312,6 +2357,7 @@ void TrimEdge (const TopoDS_Edge&              E,
       
       TheBuilder.Range(NewEdge,ThePar.Value(k),ThePar.Value(k+1));
       
+#ifdef OCCT_DEBUG
 #ifdef DRAW
       if ( AffichEdge) {
         char name[256];
@@ -2333,7 +2379,7 @@ void TrimEdge (const TopoDS_Edge&              E,
         Draw::Set(name,dr);
       }
 #endif
-      
+#endif
       S.Append(NewEdge);
     }
   }
@@ -2375,7 +2421,7 @@ static Standard_Boolean IsInnerEdge(const TopoDS_Shape& ProE,
 //=======================================================================
 
 Standard_Boolean DoubleOrNotInside (const TopTools_ListOfShape& LV,
-                                   const TopoDS_Vertex&        V)
+  const TopoDS_Vertex&        V)
 {  
   Standard_Boolean Vu = Standard_False;
   TopTools_ListIteratorOfListOfShape it(LV);
@@ -2391,7 +2437,7 @@ Standard_Boolean DoubleOrNotInside (const TopTools_ListOfShape& LV,
 }
 
 Standard_Boolean IsSmallClosedEdge(const TopoDS_Edge& anEdge,
-                                  const TopoDS_Vertex& aVertex)
+  const TopoDS_Vertex& aVertex)
 {
   gp_Pnt PV = BRep_Tool::Pnt(aVertex);
   gp_Pnt2d PV2d, Pfirst, Plast, Pmid;
@@ -2422,9 +2468,9 @@ Standard_Boolean IsSmallClosedEdge(const TopoDS_Edge& anEdge,
 }
 
 static void CheckBadEdges(const TopoDS_Face& Spine, const Standard_Real Offset,
-                         const BRepMAT2d_BisectingLocus& Locus, 
-                         const BRepMAT2d_LinkTopoBilo&   Link,
-                         TopTools_ListOfShape& BadEdges)
+  const BRepMAT2d_BisectingLocus& Locus, 
+  const BRepMAT2d_LinkTopoBilo&   Link,
+  TopTools_ListOfShape& BadEdges)
 {
 
   TopoDS_Face F = TopoDS::Face(Spine.Oriented(TopAbs_FORWARD));
@@ -2438,82 +2484,97 @@ static void CheckBadEdges(const TopoDS_Face& Spine, const Standard_Real Offset,
       const TopoDS_Shape& SE = Link.GeneratingShape(Locus.BasicElt(ic,ie));
       if (SE.ShapeType() == TopAbs_EDGE) {
 
-       if (aMap.Contains(SE)) {
-         //cout << "Edge is treated second time" << endl;
-         continue;
-       }
-
-       TopoDS_Edge E = TopoDS::Edge(SE);
-
-       Standard_Real f,l;
-
-       Handle(Geom2d_Curve) G2d = BRep_Tool::CurveOnSurface(E,F,f,l);
-
-       Geom2dAdaptor_Curve  AC(G2d,f,l);
-       GeomAbs_CurveType aCType = AC.GetType();
-
-       if(aCType != GeomAbs_Line && aCType != GeomAbs_Circle) {
-
-         Standard_Boolean reverse = Standard_False;
-         if (E.Orientation() == TopAbs_FORWARD) reverse = Standard_True;
-
-         gp_Pnt2d P, Pc;
-         gp_Dir2d N;
-
-         Geom2dLProp_CLProps2d aCLProps(G2d, 2, eps);
-
-         aCLProps.SetParameter(f);
-         if(!aCLProps.IsTangentDefined()) {
-           BadEdges.Append(SE);
-           aMap.Add(SE);
-           continue;
-         }
-
-         P = aCLProps.Value();
-         Standard_Real Crv = aCLProps.Curvature();
-
-         if(Crv >= eps) {
-           aCLProps.Tangent(N);
-           Standard_Real x = N.Y(), y = -N.X();
-           N.SetCoord(x, y);
-           if (reverse) N.Reverse();
-           aCLProps.CentreOfCurvature(Pc);
-           gp_Vec2d Dir( P, Pc );
-           if (N.Dot(Dir) > 0.) {
-             if (LimCurv <= Crv + eps) {
-               BadEdges.Append(SE);
-               aMap.Add(SE);
-               continue;
-             }
-           }
-         }  
-
-         aCLProps.SetParameter(l);
-         if(!aCLProps.IsTangentDefined()) {
-           BadEdges.Append(SE);
-           aMap.Add(SE);
-           continue;
-         }
-
-         P = aCLProps.Value();
-         Crv = aCLProps.Curvature();
-
-         if(Crv >= eps) {
-           aCLProps.Tangent(N);
-           Standard_Real x = N.Y(), y = -N.X();
-           N.SetCoord(x, y);
-           if (reverse) N.Reverse();
-           aCLProps.CentreOfCurvature(Pc);
-           gp_Vec2d Dir( P, Pc );
-           if (N.Dot(Dir) > 0.) {
-             if (LimCurv <= Crv + eps) {
-               BadEdges.Append(SE);
-               aMap.Add(SE);
-               continue;
-             }
-           }
-         }  
-       }
+
+        if (aMap.Contains(SE)) {
+          //cout << "Edge is treated second time" << endl;
+          continue;
+        }
+
+
+        TopoDS_Edge E = TopoDS::Edge(SE);
+
+
+        Standard_Real f,l;
+
+
+        Handle(Geom2d_Curve) G2d = BRep_Tool::CurveOnSurface(E,F,f,l);
+
+
+        Geom2dAdaptor_Curve  AC(G2d,f,l);
+        GeomAbs_CurveType aCType = AC.GetType();
+
+
+        if(aCType != GeomAbs_Line && aCType != GeomAbs_Circle) {
+
+
+          Standard_Boolean reverse = Standard_False;
+          if (E.Orientation() == TopAbs_FORWARD) reverse = Standard_True;
+
+
+          gp_Pnt2d P, Pc;
+          gp_Dir2d N;
+
+
+          Geom2dLProp_CLProps2d aCLProps(G2d, 2, eps);
+
+
+          aCLProps.SetParameter(f);
+          if(!aCLProps.IsTangentDefined()) {
+            BadEdges.Append(SE);
+            aMap.Add(SE);
+            continue;
+          }
+
+
+          P = aCLProps.Value();
+          Standard_Real Crv = aCLProps.Curvature();
+
+
+          if(Crv >= eps) {
+            aCLProps.Tangent(N);
+            Standard_Real x = N.Y(), y = -N.X();
+            N.SetCoord(x, y);
+            if (reverse) N.Reverse();
+            aCLProps.CentreOfCurvature(Pc);
+            gp_Vec2d Dir( P, Pc );
+            if (N.Dot(Dir) > 0.) {
+              if (LimCurv <= Crv + eps) {
+                BadEdges.Append(SE);
+                aMap.Add(SE);
+                continue;
+              }
+            }
+          }  
+
+
+          aCLProps.SetParameter(l);
+          if(!aCLProps.IsTangentDefined()) {
+            BadEdges.Append(SE);
+            aMap.Add(SE);
+            continue;
+          }
+
+
+          P = aCLProps.Value();
+          Crv = aCLProps.Curvature();
+
+
+          if(Crv >= eps) {
+            aCLProps.Tangent(N);
+            Standard_Real x = N.Y(), y = -N.X();
+            N.SetCoord(x, y);
+            if (reverse) N.Reverse();
+            aCLProps.CentreOfCurvature(Pc);
+            gp_Vec2d Dir( P, Pc );
+            if (N.Dot(Dir) > 0.) {
+              if (LimCurv <= Crv + eps) {
+                BadEdges.Append(SE);
+                aMap.Add(SE);
+                continue;
+              }
+            }
+          }  
+        }
       }
     }
   }
@@ -2526,13 +2587,14 @@ static void CheckBadEdges(const TopoDS_Face& Spine, const Standard_Real Offset,
 //=======================================================================
 
 static Standard_Boolean PerformCurve (TColStd_SequenceOfReal& Parameters,
-                                     TColgp_SequenceOfPnt&   Points,
-                                     const Adaptor3d_Curve& C, 
-                                     const Standard_Real Deflection,
-                                     const Standard_Real U1,
-                                     const Standard_Real U2,
-                                     const Standard_Real EPSILON,
-                                     const Standard_Integer Nbmin)
+
+  TColgp_SequenceOfPnt&   Points,
+  const Adaptor3d_Curve& C, 
+  const Standard_Real Deflection,
+  const Standard_Real U1,
+  const Standard_Real U2,
+  const Standard_Real EPSILON,
+  const Standard_Integer Nbmin)
 {
   Standard_Real UU1 = Min(U1, U2);
   Standard_Real UU2 = Max(U1, U2);
@@ -2551,13 +2613,14 @@ static Standard_Boolean PerformCurve (TColStd_SequenceOfReal& Parameters,
   if((aDelta/aDist) > 5.0e-14)
   {
     QuasiFleche(C,Deflection*Deflection,
-                     UU1,Pdeb,
-                     Ddeb,
-                     UU2,Pfin,
-                     Dfin,
-                     Nbmin,
-                     EPSILON*EPSILON,
-                     Parameters,Points);
+
+      UU1,Pdeb,
+      Ddeb,
+      UU2,Pfin,
+      Dfin,
+      Nbmin,
+      EPSILON*EPSILON,
+      Parameters,Points);
   }
 
   return Standard_True;
@@ -2568,17 +2631,18 @@ static Standard_Boolean PerformCurve (TColStd_SequenceOfReal& Parameters,
 //=======================================================================
 
 static void QuasiFleche(const Adaptor3d_Curve& C,
-                       const Standard_Real Deflection2, 
-                       const Standard_Real Udeb,
-                       const gp_Pnt& Pdeb,
-                       const gp_Vec& Vdeb,
-                       const Standard_Real Ufin,
-                       const gp_Pnt& Pfin,
-                       const gp_Vec& Vfin,
-                       const Standard_Integer Nbmin,
-                       const Standard_Real Eps,
-                       TColStd_SequenceOfReal& Parameters,
-                       TColgp_SequenceOfPnt& Points)
+
+  const Standard_Real Deflection2, 
+  const Standard_Real Udeb,
+  const gp_Pnt& Pdeb,
+  const gp_Vec& Vdeb,
+  const Standard_Real Ufin,
+  const gp_Pnt& Pfin,
+  const gp_Vec& Vfin,
+  const Standard_Integer Nbmin,
+  const Standard_Real Eps,
+  TColStd_SequenceOfReal& Parameters,
+  TColgp_SequenceOfPnt& Points)
 {
   Standard_Integer Ptslength = Points.Length();
   Standard_Real Udelta = Ufin-Udeb;
@@ -2603,10 +2667,12 @@ static void QuasiFleche(const Adaptor3d_Curve& C,
     Standard_Real N2 = Vdelta.SquareMagnitude();
     if (N1 > Eps && N2 > Eps) {
       Standard_Real Normediff = 
-       (Vdeb.Normalized().XYZ()-Vdelta.Normalized().XYZ()).SquareModulus();
+
+        (Vdeb.Normalized().XYZ()-Vdelta.Normalized().XYZ()).SquareModulus();
       if (Normediff > Eps) {
-       theFleche = Normediff*Norme/64.;
-       flecheok = Standard_True;
+
+        theFleche = Normediff*Norme/64.;
+        flecheok = Standard_True;
       }
     }
   }
@@ -2622,23 +2688,25 @@ static void QuasiFleche(const Adaptor3d_Curve& C,
   }
   else {
     QuasiFleche(C,Deflection2,Udeb,Pdeb,
-               Vdeb,
-               Udeb+Udelta,Pdelta,
-               Vdelta,
-               3,
-               Eps,
-               Parameters,Points);
+
+      Vdeb,
+      Udeb+Udelta,Pdelta,
+      Vdelta,
+      3,
+      Eps,
+      Parameters,Points);
 
   }
 
   if (Nbmin > 2) {
     QuasiFleche(C,Deflection2,Udeb+Udelta,Pdelta,
-               Vdelta,
-               Ufin,Pfin,
-               Vfin,
-               Nbmin-(Points.Length()-Ptslength),
-               Eps,
-               Parameters,Points);
+
+      Vdelta,
+      Ufin,Pfin,
+      Vfin,
+      Nbmin-(Points.Length()-Ptslength),
+      Eps,
+      Parameters,Points);
   }
 }
 
index d3c4d56..89d90ee 100644 (file)
 #include <Precision.hxx>
 #include <IntRes2d_IntersectionPoint.hxx>
 #include <IntRes2d_IntersectionSegment.hxx>
-
+#include <ElCLib.hxx>
 #include <StdFail_NotDone.hxx>
-
+#ifdef OCCT_DEBUG
+//#define DRAW
 #ifdef DRAW
 #include <DrawTrSurf.hxx>
 #include <DBRep.hxx>
 static Standard_Boolean Affich       = Standard_False;
+static Standard_Boolean AffichInt    = Standard_False;
+static Standard_Integer intind       = 0;
+#endif
 #endif
 
 
@@ -47,7 +51,7 @@ static Standard_Boolean Affich       = Standard_False;
 //=======================================================================
 
 static void SimpleExpression (const Bisector_Bisec&        B, 
-                                   Handle(Geom2d_Curve)&  Bis)
+  Handle(Geom2d_Curve)&  Bis)
 {
   Bis = B.Value();
 
@@ -60,8 +64,8 @@ static void SimpleExpression (const Bisector_Bisec&        B,
     if (BT == STANDARD_TYPE(Bisector_BisecAna)) {
       Bis = Handle(Bisector_BisecAna)::DownCast(BasBis)->Geom2dCurve();
       Bis = new Geom2d_TrimmedCurve (Bis,
-                                    TrBis->FirstParameter(),
-                                    TrBis->LastParameter());
+        TrBis->FirstParameter(),
+        TrBis->LastParameter());
     }
   }
 }
@@ -83,18 +87,18 @@ BRepFill_TrimEdgeTool::BRepFill_TrimEdgeTool()
 //=======================================================================
 
 BRepFill_TrimEdgeTool::BRepFill_TrimEdgeTool
-(const Bisector_Bisec& Bisec,
- const Handle(Geom2d_Geometry)& S1,
- const Handle(Geom2d_Geometry)& S2,
- const Standard_Real   Offset) :
+  (const Bisector_Bisec& Bisec,
+  const Handle(Geom2d_Geometry)& S1,
+  const Handle(Geom2d_Geometry)& S2,
+  const Standard_Real   Offset) :
 myOffset(Offset),
-myBisec(Bisec)
+  myBisec(Bisec)
 {
   isPoint1 = (S1->DynamicType() == STANDARD_TYPE(Geom2d_CartesianPoint));
   isPoint2 = (S2->DynamicType() == STANDARD_TYPE(Geom2d_CartesianPoint));
 
-// return geometries of shapes.
-//  Standard_Real f,l;
+  // return geometries of shapes.
+  //  Standard_Real f,l;
   if (isPoint1) {
     myP1 = Handle(Geom2d_Point)::DownCast(S1)->Pnt2d();
   }
@@ -102,10 +106,10 @@ myBisec(Bisec)
     myC1 = Handle(Geom2d_Curve)::DownCast(S1);
 #ifdef DRAW
     if ( Affich) {
-//POP pour NT
+      //POP pour NT
       char* myC1name = "myC1";
       DrawTrSurf::Set(myC1name,myC1);
-//      DrawTrSurf::Set("myC1",myC1);
+      //      DrawTrSurf::Set("myC1",myC1);
     }
 #endif
   }
@@ -118,7 +122,7 @@ myBisec(Bisec)
     if ( Affich) {
       char* myC2name = "myC2";
       DrawTrSurf::Set(myC2name,myC2);
-//      DrawTrSurf::Set("myC2",myC2);
+      //      DrawTrSurf::Set("myC2",myC2);
     }
 #endif
   }
@@ -128,8 +132,8 @@ myBisec(Bisec)
   myBis = Geom2dAdaptor_Curve(Bis);
 #ifdef DRAW
   if ( Affich) {
-      char* myBisname = "myBis";
-      DrawTrSurf::Set(myBisname,Bis);
+    char* myBisname = "myBis";
+    DrawTrSurf::Set(myBisname,Bis);
   }
 #endif
 
@@ -150,8 +154,8 @@ static void Bubble(TColgp_SequenceOfPnt& Seq)
       gp_Pnt P1 = Seq.Value(i);
       gp_Pnt P2 = Seq.Value(i+1);
       if (P2.X()<P1.X())  {
-       Seq.Exchange(i,i+1);
-       Invert = Standard_True;
+        Seq.Exchange(i,i+1);
+        Invert = Standard_True;
       }
     }
   }
@@ -164,12 +168,12 @@ static void Bubble(TColgp_SequenceOfPnt& Seq)
 //=======================================================================
 
 static void EvalParameters(const Geom2dAdaptor_Curve& Bis,
-                          const Geom2dAdaptor_Curve& AC,
-                                TColgp_SequenceOfPnt& Params)
+  const Geom2dAdaptor_Curve& AC,
+  TColgp_SequenceOfPnt& Params)
 {
   Geom2dInt_GInter Intersector;
   Standard_Real Tol = Precision::Confusion();
-//  Standard_Real TolC = 1.e-9;
+  //  Standard_Real TolC = 1.e-9;
 
   Geom2dAdaptor_Curve CBis(Bis);
   Geom2dAdaptor_Curve CAC (AC);
@@ -184,9 +188,9 @@ static void EvalParameters(const Geom2dAdaptor_Curve& Bis,
   if ( !Intersector.IsDone()) {
     StdFail_NotDone::Raise("BRepFill_TrimSurfaceTool::IntersectWith");
   }
-  
+
   NbPoints = Intersector.NbPoints();
-  
+
   if (NbPoints > 0) {
     for ( Standard_Integer i = 1; i <= NbPoints; i++) {
       U1 = Intersector.Point(i).ParamOnSecond();
@@ -194,11 +198,11 @@ static void EvalParameters(const Geom2dAdaptor_Curve& Bis,
       P = gp_Pnt(U1,U2,0.);
       Params.Append(P);
     }
-    
+
   }
-  
+
   NbSegments = Intersector.NbSegments();
-  
+
   if (NbSegments > 0) {
     IntRes2d_IntersectionSegment Seg;
     for ( Standard_Integer i = 1; i <= NbSegments; i++) {
@@ -206,20 +210,20 @@ static void EvalParameters(const Geom2dAdaptor_Curve& Bis,
       U1  = Seg.FirstPoint().ParamOnSecond();
       Standard_Real Ulast = Seg.LastPoint().ParamOnSecond();
       if ( Abs(U1    - CBis.FirstParameter()) <= Tol &&
-          Abs(Ulast - CBis.LastParameter())  <= Tol    ) {
-       P = gp_Pnt(U1,Seg.FirstPoint().ParamOnFirst(),0.);
-       Params.Append(P);
-       P = gp_Pnt(Ulast,Seg.LastPoint().ParamOnFirst(),0.);
-       Params.Append(P);
+        Abs(Ulast - CBis.LastParameter())  <= Tol    ) {
+          P = gp_Pnt(U1,Seg.FirstPoint().ParamOnFirst(),0.);
+          Params.Append(P);
+          P = gp_Pnt(Ulast,Seg.LastPoint().ParamOnFirst(),0.);
+          Params.Append(P);
       }
       else {
-       U1 += Seg.LastPoint().ParamOnSecond();
-       U1 /= 2.;
-       U2  = Seg.FirstPoint().ParamOnFirst();
-       U2 += Seg.LastPoint().ParamOnFirst();
-       U2 /= 2.;
-       P = gp_Pnt(U1,U2,0.);
-       Params.Append(P);
+        U1 += Seg.LastPoint().ParamOnSecond();
+        U1 /= 2.;
+        U2  = Seg.FirstPoint().ParamOnFirst();
+        U2 += Seg.LastPoint().ParamOnFirst();
+        U2 /= 2.;
+        P = gp_Pnt(U1,U2,0.);
+        Params.Append(P);
       }
     }
   }
@@ -227,15 +231,15 @@ static void EvalParameters(const Geom2dAdaptor_Curve& Bis,
   // Order the sequence by growing parameter on the bissectrice.
   Bubble( Params);
 }
-                          
+
 static void EvalParametersBis(const Geom2dAdaptor_Curve& Bis,
-                             const Geom2dAdaptor_Curve& AC,
-                             TColgp_SequenceOfPnt& Params,
-                             const Standard_Real Tol)
+  const Geom2dAdaptor_Curve& AC,
+  TColgp_SequenceOfPnt& Params,
+  const Standard_Real Tol)
 {
   Geom2dInt_GInter Intersector;
   Standard_Real TolC = Tol;
-  
+
   Geom2dAdaptor_Curve CBis(Bis);
   Geom2dAdaptor_Curve CAC (AC);
 
@@ -248,9 +252,9 @@ static void EvalParametersBis(const Geom2dAdaptor_Curve& Bis,
   if ( !Intersector.IsDone()) {
     StdFail_NotDone::Raise("BRepFill_TrimSurfaceTool::IntersectWith");
   }
-  
+
   NbPoints = Intersector.NbPoints();
-  
+
   if (NbPoints > 0) {
     for ( Standard_Integer i = 1; i <= NbPoints; i++) {
       U1 = Intersector.Point(i).ParamOnSecond();
@@ -258,11 +262,11 @@ static void EvalParametersBis(const Geom2dAdaptor_Curve& Bis,
       P = gp_Pnt(U1,U2,0.);
       Params.Append(P);
     }
-    
+
   }
-  
+
   NbSegments = Intersector.NbSegments();
-  
+
   if (NbSegments > 0) {
     IntRes2d_IntersectionSegment Seg;
     for ( Standard_Integer i = 1; i <= NbSegments; i++) {
@@ -270,20 +274,20 @@ static void EvalParametersBis(const Geom2dAdaptor_Curve& Bis,
       U1  = Seg.FirstPoint().ParamOnSecond();
       Standard_Real Ulast = Seg.LastPoint().ParamOnSecond();
       if ( Abs(U1    - CBis.FirstParameter()) <= Tol &&
-          Abs(Ulast - CBis.LastParameter())  <= Tol    ) {
-       P = gp_Pnt(U1,Seg.FirstPoint().ParamOnFirst(),0.);
-       Params.Append(P);
-       P = gp_Pnt(Ulast,Seg.LastPoint().ParamOnFirst(),0.);
-       Params.Append(P);
+        Abs(Ulast - CBis.LastParameter())  <= Tol    ) {
+          P = gp_Pnt(U1,Seg.FirstPoint().ParamOnFirst(),0.);
+          Params.Append(P);
+          P = gp_Pnt(Ulast,Seg.LastPoint().ParamOnFirst(),0.);
+          Params.Append(P);
       }
       else {
-       U1 += Seg.LastPoint().ParamOnSecond();
-       U1 /= 2.;
-       U2  = Seg.FirstPoint().ParamOnFirst();
-       U2 += Seg.LastPoint().ParamOnFirst();
-       U2 /= 2.;
-       P = gp_Pnt(U1,U2,0.);
-       Params.Append(P);
+        U1 += Seg.LastPoint().ParamOnSecond();
+        U1 /= 2.;
+        U2  = Seg.FirstPoint().ParamOnFirst();
+        U2 += Seg.LastPoint().ParamOnFirst();
+        U2 /= 2.;
+        P = gp_Pnt(U1,U2,0.);
+        Params.Append(P);
       }
     }
   }
@@ -299,8 +303,8 @@ static void EvalParametersBis(const Geom2dAdaptor_Curve& Bis,
 //=======================================================================
 
 void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1,
-                                         const TopoDS_Edge& Edge2,
-                                               TColgp_SequenceOfPnt& Params)
+  const TopoDS_Edge& Edge2,
+  TColgp_SequenceOfPnt& Params)
 {
   Params.Clear();
 
@@ -318,27 +322,28 @@ void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1,
   Geom2dAdaptor_Curve AC2(C2,f,l);
 
 #ifdef DRAW
-  if ( Affich) {
+  if ( AffichInt) {
     f = AC1.FirstParameter();
     l = AC1.LastParameter();
-    char* CURVE1name = "CURVE1";
-    DrawTrSurf::Set(CURVE1name, new Geom2d_TrimmedCurve(C1,f,l));
+    char name[32];
+    sprintf(name,"C1_%d", ++intind);
+    DrawTrSurf::Set(name, new Geom2d_TrimmedCurve(C1,f,l));
     f = AC2.FirstParameter();
     l = AC2.LastParameter();
-    char* CURVE2name = "CURVE2";
-    DrawTrSurf::Set(CURVE2name, new Geom2d_TrimmedCurve(C2,f,l));
+    sprintf(name,"C2_%d", intind);
+    DrawTrSurf::Set(name, new Geom2d_TrimmedCurve(C2,f,l));
     f = myBis.FirstParameter();
     l = myBis.LastParameter();
-    char* bisname = "BIS";
-    DrawTrSurf::Set(bisname, new Geom2d_TrimmedCurve(myBis.Curve(),f,l));
-    char* Edge1name = "E1";
-    DBRep::Set(Edge1name, Edge1);
-    char* Edge2name = "E2";
-    DBRep::Set(Edge2name, Edge2);
+    sprintf(name,"BIS%d", intind);
+    DrawTrSurf::Set(name, new Geom2d_TrimmedCurve(myBis.Curve(),f,l));
+    sprintf(name,"E1_%d", intind);
+    DBRep::Set(name, Edge1);
+    sprintf(name,"E2_%d", intind);
+    DBRep::Set(name, Edge2);
 
   }
 #endif
-  
+
   // Calculate intersection
   TColgp_SequenceOfPnt Points2;
   gp_Pnt PSeq;
@@ -347,33 +352,91 @@ void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1,
   EvalParameters (myBis,AC2,Points2);
 
 
+
   Standard_Integer SeanceDeRattrapage=0;
   Standard_Real TolInit= 1.e-9;
   Standard_Integer nn = 7;
 
   if((AC1.GetType() != GeomAbs_Circle && AC1.GetType() != GeomAbs_Line) ||
-     (AC2.GetType() != GeomAbs_Circle && AC2.GetType() != GeomAbs_Line)) {
+    (AC2.GetType() != GeomAbs_Circle && AC2.GetType() != GeomAbs_Line)) {
+
+      TolInit = 1.e-8;
+      nn = 6;
+  }
 
-    TolInit = 1.e-8;
-    nn = 6;
+  if(Params.IsEmpty() && Points2.IsEmpty())
+  {
+    //Check, may be there are no intersections at all
+    // for case myBis == Line
+    if(myBis.GetType() == GeomAbs_Line)
+    {
+      Standard_Real dmax = TolInit;
+      Standard_Integer n = 0;
+      while(n < nn)
+      {
+        dmax *= 10.0;
+        ++n;
+      }
+      dmax *= dmax;
+      //
+      gp_Lin2d anL = myBis.Line();
+      Standard_Boolean isFar1 = Standard_True;
+      Standard_Boolean isFar2 = Standard_True;
+      gp_Pnt2d aP;
+      //
+      Standard_Real d = RealLast();
+      AC1.D0(AC1.FirstParameter(), aP);
+      Standard_Real par = ElCLib::Parameter(anL, aP);
+      if(par >= myBis.FirstParameter() && par <= myBis.LastParameter())
+      {
+        d = anL.SquareDistance(aP);
+      }
+      AC1.D0(AC1.LastParameter(), aP);
+      par = ElCLib::Parameter(anL, aP);
+      if(par >= myBis.FirstParameter() && par <= myBis.LastParameter())
+      {
+        d = Min(anL.SquareDistance(aP), d);
+      }
+      isFar1 = d > dmax;
+      //
+      d = RealLast();
+      AC2.D0(AC2.FirstParameter(), aP);
+      par = ElCLib::Parameter(anL, aP);
+      if(par >= myBis.FirstParameter() && par <= myBis.LastParameter())
+      {
+        d = anL.SquareDistance(aP);
+      }
+      AC2.D0(AC2.LastParameter(), aP);
+      par = ElCLib::Parameter(anL, aP);
+      if(par >= myBis.FirstParameter() && par <= myBis.LastParameter())
+      {
+        d = Min(anL.SquareDistance(aP), d);
+      }
+      isFar2 = d > dmax;
+      //
+      if(isFar1 && isFar2)
+      {
+        return;
+      }
+    }
   }
-  
+
   while (     SeanceDeRattrapage < nn // TolInit <= 0.01
-        && ( Points2.Length() != Params.Length() || 
-            (Points2.Length() == 0 && Params.Length() == 0) ) ) {
+    && ( Points2.Length() != Params.Length() || 
+    (Points2.Length() == 0 && Params.Length() == 0) ) ) {
 
 #ifdef OCCT_DEBUG
-    cout << "BRepFill_TrimEdgeTool: incoherent intersection. Try with a greater tolerance" << endl;
+      cout << "BRepFill_TrimEdgeTool: incoherent intersection. Try with a greater tolerance" << endl;
 #endif
 
-    Params.Clear();
-    Points2.Clear();
-    
-    TolInit*=10.0;
-    
-    EvalParametersBis(myBis,AC1,Params,TolInit);
-    EvalParametersBis(myBis,AC2,Points2,TolInit); 
-    SeanceDeRattrapage++;
+      Params.Clear();
+      Points2.Clear();
+
+      TolInit*=10.0;
+
+      EvalParametersBis(myBis,AC1,Params,TolInit);
+      EvalParametersBis(myBis,AC2,Points2,TolInit); 
+      SeanceDeRattrapage++;
   }
 
 #ifdef OCCT_DEBUG
@@ -387,7 +450,7 @@ void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1,
   if(Params.Length() == 0 && Points2.Length() == 1) {
 
     //cout << "Params.Length() == 0 && Points2.Length() == 1" << endl;
-    Standard_Real dmin;
+    Standard_Real dmin, dmax = 0.25*myOffset*myOffset;
     Standard_Real tBis = Points2(1).X();
     gp_Pnt2d PBis = myBis.Value(tBis);
 
@@ -395,19 +458,26 @@ void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1,
     gp_Pnt2d PC = AC1.Value(t);
     dmin = PC.SquareDistance(PBis);
     gp_Pnt P(tBis, t, 0.);
-    Params.Append(P);
+    if(dmin < dmax)
+    {
+      Params.Append(P);
+    }
 
     t = AC1.LastParameter();
     PC = AC1.Value(t);
-    if(dmin > PC.SquareDistance(PBis)) {
+    Standard_Real dmin1 = PC.SquareDistance(PBis);
+    if(dmin > dmin1 && dmin1 < dmax ) {
       P.SetY(t);
-      Params.SetValue(1,P);
+      if(Params.IsEmpty())
+        Params.Append(P);
+      else
+        Params.SetValue(1,P);
     }
   }
   else if(Params.Length() == 1 && Points2.Length() == 0) {
 
     //cout << "Params.Length() == 1 && Points2.Length() == 0" << endl;
-    Standard_Real dmin;
+    Standard_Real dmin, dmax = 0.25*myOffset*myOffset;
     Standard_Real tBis = Params(1).X();
     gp_Pnt2d PBis = myBis.Value(tBis);
 
@@ -415,13 +485,20 @@ void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1,
     gp_Pnt2d PC = AC2.Value(t);
     dmin = PC.SquareDistance(PBis);
     gp_Pnt P(tBis, t, 0.);
-    Points2.Append(P);
+    if(dmin < dmax)
+    {
+      Points2.Append(P);
+    }
 
     t = AC2.LastParameter();
     PC = AC2.Value(t);
-    if(dmin > PC.SquareDistance(PBis)) {
+    Standard_Real dmin1 = PC.SquareDistance(PBis);
+    if(dmin > dmin1 && dmin1 < dmax ) {
       P.SetY(t);
-      Points2.SetValue(1,P);
+      if(Points2.IsEmpty())
+        Points2.Append(P);
+      else
+        Points2.SetValue(1,P);
     }
   }
 
@@ -457,13 +534,13 @@ void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1,
 #endif
       if(P1xP2x>TolInit) { 
 #ifdef OCCT_DEBUG
-      cout << "BRepFill_TrimEdgeTool: Continue somehow" << endl;
+        cout << "BRepFill_TrimEdgeTool: Continue somehow" << endl;
 #endif 
-      i++;
+        i++;
       }
       else { 
-       if ( P1.X() < P2.X()) Params.Remove(i);
-       else                  Points2.Remove(i);
+        if ( P1.X() < P2.X()) Params.Remove(i);
+        else                  Points2.Remove(i);
       }
     }
     else i++;
@@ -492,10 +569,10 @@ void BRepFill_TrimEdgeTool::IntersectWith(const TopoDS_Edge& Edge1,
 //=======================================================================
 
 void BRepFill_TrimEdgeTool::AddOrConfuse(const Standard_Boolean  Start,
-                                        const TopoDS_Edge&      Edge1,
-                                        const TopoDS_Edge&      Edge2,
-                                        TColgp_SequenceOfPnt&   Params) 
-const 
+  const TopoDS_Edge&      Edge1,
+  const TopoDS_Edge&      Edge2,
+  TColgp_SequenceOfPnt&   Params) 
+  const 
 {
   Standard_Boolean  ToProj = Standard_True;
   gp_Pnt2d          PBis;
@@ -521,7 +598,7 @@ const
     else       P = AC1.Value(Params.Last ().Y()); 
     ToProj     = !PBis.IsEqual(P,Tol);
   }
-  
+
   if (ToProj) {
 #ifdef OCCT_DEBUG
     cout << " project extremity bissectrice on parallel."<<endl;
@@ -561,8 +638,8 @@ const
       return;
     }
     gp_Pnt PInt (0,
-                Projector1.LowerDistanceParameter(),
-                Projector2.LowerDistanceParameter());
+      Projector1.LowerDistanceParameter(),
+      Projector2.LowerDistanceParameter());
     if (Start) {
       PInt.SetX (myBis.FirstParameter());
       Params.Prepend(PInt);
@@ -581,10 +658,10 @@ const
 
 Standard_Boolean BRepFill_TrimEdgeTool::IsInside(const gp_Pnt2d& P) const 
 {
-//  Modified by Sergey KHROMOV - Fri Sep 27 11:43:12 2002 Begin
-//   Standard_Real Dist;
+  //  Modified by Sergey KHROMOV - Fri Sep 27 11:43:12 2002 Begin
+  //   Standard_Real Dist;
   Standard_Real Dist = RealLast();
-//  Modified by Sergey KHROMOV - Fri Sep 27 11:43:12 2002 End
+  //  Modified by Sergey KHROMOV - Fri Sep 27 11:43:12 2002 End
   if (isPoint1) 
     Dist = P.Distance(myP1);
   else if (isPoint2) 
@@ -594,26 +671,26 @@ Standard_Boolean BRepFill_TrimEdgeTool::IsInside(const gp_Pnt2d& P) const
     if (Projector.NbPoints() > 0) {
       Dist = Projector.LowerDistance();
     }
-//  Modified by Sergey KHROMOV - Fri Sep 27 11:43:43 2002 Begin
-//     else {
-//       gp_Pnt2d PF = myC1->Value(myC1->FirstParameter());
-//       gp_Pnt2d PL = myC1->Value(myC1->LastParameter());
-//       Dist = Min (P.Distance(PF),P.Distance(PL));
-//     }
-
-// Check of distances between P and first and last point of the first curve
-// should be performed in any case, despite of the results of projection.
+    //  Modified by Sergey KHROMOV - Fri Sep 27 11:43:43 2002 Begin
+    //     else {
+    //       gp_Pnt2d PF = myC1->Value(myC1->FirstParameter());
+    //       gp_Pnt2d PL = myC1->Value(myC1->LastParameter());
+    //       Dist = Min (P.Distance(PF),P.Distance(PL));
+    //     }
+
+    // Check of distances between P and first and last point of the first curve
+    // should be performed in any case, despite of the results of projection.
     gp_Pnt2d      PF       = myC1->Value(myC1->FirstParameter());
     gp_Pnt2d      PL       = myC1->Value(myC1->LastParameter());
     Standard_Real aDistMin = Min (P.Distance(PF),P.Distance(PL));
 
     if (Dist > aDistMin)
       Dist = aDistMin;
-//  Modified by Sergey KHROMOV - Fri Sep 27 11:43:44 2002 End
+    //  Modified by Sergey KHROMOV - Fri Sep 27 11:43:44 2002 End
   }
-  
-//  return (Dist < Abs(myOffset);
-// return (Dist < Abs(myOffset) + Precision::Confusion());
+
+  //  return (Dist < Abs(myOffset);
+  // return (Dist < Abs(myOffset) + Precision::Confusion());
   return (Dist < Abs(myOffset) - Precision::Confusion());
 }
 
index 3b72a6f..3cfa3d2 100644 (file)
@@ -780,7 +780,13 @@ static void SetEdgeTol(const TopoDS_Edge& E,
     gp_Pnt Pc3d = HC->Value(u);
     gp_Pnt2d p2d = pc->Value(u);
     gp_Pnt Pcons = ElSLib::Value(p2d.X(),p2d.Y(),pln);
+    Standard_Real eps = Max(Pc3d.XYZ().SquareModulus(), Pcons.XYZ().SquareModulus());
+    eps = Epsilon(eps);
     Standard_Real temp = Pc3d.SquareDistance(Pcons);
+    if(temp <= eps)
+    {
+      temp = 0.;
+    }
     if(temp > d2) d2 = temp;
   }
   d2 = 1.5*sqrt(d2);
index 5363865..5708e3e 100644 (file)
@@ -19,7 +19,7 @@
 #include <Precision.hxx>
 #include <math_Matrix.hxx>
 #include <math_Vector.hxx>
-#include <math_Gauss.hxx>
+#include <math_Jacobi.hxx>
 
 #include <gp_Lin.hxx>
 #include <gp_Circ.hxx>
@@ -45,6 +45,8 @@
 #include <TopoDS_Vertex.hxx>
 #include <TopoDS_Wire.hxx>
 #include <TopoDS.hxx>
+#include <BRep_Builder.hxx>
+#include <BRepTopAdaptor_FClass2d.hxx>
 
 #include <GeomLib.hxx>
 #include <Geom2d_Curve.hxx>
@@ -58,7 +60,7 @@
 //purpose  : 
 //=======================================================================
 static Standard_Real Controle(const TColgp_SequenceOfPnt& thePoints,
-  const Handle(Geom_Plane)& thePlane)
+                             const Handle(Geom_Plane)& thePlane)
 {
   Standard_Real dfMaxDist=0.;
   Standard_Real a,b,c,d, dist;
@@ -79,9 +81,9 @@ static Standard_Real Controle(const TColgp_SequenceOfPnt& thePoints,
 //           the first vertex of theEdge2 in parametric space of theFace
 //=======================================================================
 inline static Standard_Boolean Is2DConnected(const TopoDS_Edge& theEdge1,
-  const TopoDS_Edge& theEdge2,
-  const Handle(Geom_Surface)& theSurface,
-  const TopLoc_Location& theLocation)
+                                            const TopoDS_Edge& theEdge2,
+                                            const Handle(Geom_Surface)& theSurface,
+                                            const TopLoc_Location& theLocation)
 {
   Standard_Real f,l;
   //TopLoc_Location aLoc;
@@ -110,8 +112,8 @@ inline static Standard_Boolean Is2DConnected(const TopoDS_Edge& theEdge1,
 //=======================================================================
 
 static Standard_Boolean Is2DClosed(const TopoDS_Shape&         theShape,
-  const Handle(Geom_Surface)& theSurface,
-  const TopLoc_Location& theLocation)
+                                   const Handle(Geom_Surface)& theSurface,
+                                  const TopLoc_Location& theLocation)
 {
   try
   {
@@ -164,9 +166,9 @@ BRepLib_FindSurface::BRepLib_FindSurface()
 //purpose  : 
 //=======================================================================
 BRepLib_FindSurface::BRepLib_FindSurface(const TopoDS_Shape&    S, 
-  const Standard_Real    Tol,
-  const Standard_Boolean OnlyPlane,
-  const Standard_Boolean OnlyClosed)
+                                        const Standard_Real    Tol,
+                                        const Standard_Boolean OnlyPlane,
+                                         const Standard_Boolean OnlyClosed)
 {
   Init(S,Tol,OnlyPlane,OnlyClosed);
 }
@@ -175,9 +177,9 @@ BRepLib_FindSurface::BRepLib_FindSurface(const TopoDS_Shape&    S,
 //purpose  : 
 //=======================================================================
 void BRepLib_FindSurface::Init(const TopoDS_Shape&    S, 
-  const Standard_Real    Tol,
-  const Standard_Boolean OnlyPlane,
-  const Standard_Boolean OnlyClosed)
+                                                const Standard_Real    Tol,
+                                                const Standard_Boolean OnlyPlane,
+                               const Standard_Boolean OnlyClosed)
 {
   myTolerance = Tol;
   myTolReached = 0.;
@@ -331,27 +333,15 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape&    S,
           continue;
         else
         {
-          const Standard_Integer aNbPolMax = 200;
-          Standard_Integer incr = 1;
-          if(iNbPol > aNbPolMax)
-          {
-            Standard_Integer nb = iNbPol;
-            while(nb > aNbPolMax)
-            {
-              incr++;
-              nb = (iNbPol-1) / incr;
-            }
-          }
           Handle(TColgp_HArray1OfPnt) aPoles = new (TColgp_HArray1OfPnt) (1, iNbPol);
           GC->Poles(aPoles->ChangeArray1());
           gp_Pnt aPolePrev = aPoles->Value(1), aPoleNext;
           Standard_Real dfDistPrev = 0., dfDistNext;
-          Standard_Integer iPol;
-          for (iPol = 1; iPol <= iNbPol; iPol += incr)
+          for (Standard_Integer iPol=1; iPol<=iNbPol; iPol++)
           {
-            if (iPol <= iNbPol - incr)
+            if (iPol<iNbPol)
             {
-              aPoleNext = aPoles->Value(iPol+incr);
+              aPoleNext = aPoles->Value(iPol+1);
               dfDistNext = aPolePrev.Distance(aPoleNext);
             }
             else
@@ -436,50 +426,115 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape&    S,
     aMat(1,1)+=w*p.X()*p.X(); 
     aMat(1,2)+=w*p.X()*p.Y(); 
     aMat(1,3)+=w*p.X()*p.Z();
-    aMat(2,1)+=w*p.Y()*p.X();  
+    //  
     aMat(2,2)+=w*p.Y()*p.Y();  
     aMat(2,3)+=w*p.Y()*p.Z();
-    aMat(3,1)+=w*p.Z()*p.X();  
-    aMat(3,2)+=w*p.Z()*p.Y(); 
+    //  
     aMat(3,3)+=w*p.Z()*p.Z();
-    aVec(1) -= w*p.X();
-    aVec(2) -= w*p.Y();
-    aVec(3) -= w*p.Z();
   }
-
-  // Solve the system of equations to get plane coefficients
-  math_Gauss aSolver(aMat);
-  Standard_Boolean isSolved = aSolver.IsDone();
-  //
-  //  let us be more tolerant (occ415)
-  Standard_Real dfDist = RealLast();
-  Handle(Geom_Plane) aPlane;
+  aMat(2,1) = aMat(1,2);
+  aMat(3,1) = aMat(1,3);
+  aMat(3,2) = aMat(2,3);
   //
-  if (isSolved)  {
-    aSolver.Solve(aVec);
-    if (aVec.Norm2()<gp::Resolution()) {
+  math_Jacobi anEignval(aMat);
+  math_Vector anEVals(1,3);
+  Standard_Boolean isSolved = anEignval.IsDone();
+  Standard_Integer isol = 0;
+  if(isSolved)
+  {
+    anEVals = anEignval.Values();
+    //We need vector with eigenvalue ~ 0.
+    Standard_Real anEMin = RealLast();
+    Standard_Real anEMax = -anEMin;
+    for(i = 1; i <= 3; ++i)
+    {
+      Standard_Real anE = Abs(anEVals(i));
+      if(anEMin > anE)
+      {
+        anEMin = anE;
+        isol = i;
+      }
+      if(anEMax < anE)
+      {
+        anEMax = anE;
+      }
+    }
+    
+    if(isol == 0)
+    {
       isSolved = Standard_False;
     }
+    else
+    {
+      Standard_Real eps = Epsilon(anEMax);
+      if(anEMin <= eps)
+      {
+        anEignval.Vector(isol, aVec);
+      }
+      else
+      {
+        //try using vector product of other axes
+        Standard_Integer ind[2] = {0,0};
+        for(i = 1; i <= 3; ++i)
+        {
+          if(i == isol)
+          {
+            continue;
+          }
+          if(ind[0] == 0)
+          {
+            ind[0] = i;
+            continue;
+          }
+          if(ind[1] == 0)
+          {
+            ind[1] = i;
+            continue;
+          }
+        }
+        math_Vector aVec1(1, 3, 0.), aVec2(1, 3, 0.);
+        anEignval.Vector(ind[0], aVec1);
+        anEignval.Vector(ind[1], aVec2);
+        gp_Vec aV1(aVec1(1), aVec1(2), aVec1(3));
+        gp_Vec aV2(aVec2(1), aVec2(2), aVec2(3));
+        gp_Vec aN = aV1^ aV2;
+        aVec(1) = aN.X();
+        aVec(2) = aN.Y();
+        aVec(3) = aN.Z();
+      }
+      if (aVec.Norm2() < gp::Resolution()) {
+        isSolved = Standard_False;
+      }
+    }
   }
+    
+  //
+  //  let us be more tolerant (occ415)
+  Standard_Real dfDist = RealLast();
+  Handle(Geom_Plane) aPlane;
   //
   if (isSolved)  {
-    aPlane = new Geom_Plane(aBaryCenter,gp_Dir(aVec(1),aVec(2),aVec(3)));
+    //Plane normal can have two directions, direction is chosen
+    //according to direction of eigenvector
+    gp_Vec anN(aVec(1), aVec(2), aVec(3));
+    aPlane = new Geom_Plane(aBaryCenter,anN);
     dfDist = Controle (aPoints, aPlane);
   }
   //
   if (!isSolved || myTolerance < dfDist)  {
     gp_Pnt aFirstPnt=aPoints(1);
     for (iPoint=2; iPoint<=aPoints.Length(); iPoint++)  {
-      const gp_Pnt& aNextPnt = aPoints(iPoint); 
-      gp_Vec aDir(aFirstPnt, aNextPnt);
+      gp_Vec aDir(aFirstPnt,aPoints(iPoint));
       Standard_Real dfSide=aDir.Magnitude();
       if (dfSide<myTolerance) {
         continue; // degeneration
       }
       for (Standard_Integer iP1=iPoint+1; iP1<=aPoints.Length(); iP1++) {
-        gp_Vec aCross = gp_Vec(aFirstPnt,aPoints(iP1)) ^ aDir ;
+
+               gp_Vec aCross = gp_Vec(aFirstPnt,aPoints(iP1)) ^ aDir ;
+
         if (aCross.Magnitude() > dfSide*myTolerance) {
-          Handle(Geom_Plane) aPlane2 = new Geom_Plane(aFirstPnt, aCross);
+          Handle(Geom_Plane) aPlane2 = new Geom_Plane(aBaryCenter, aCross);
           Standard_Real dfDist2 = Controle (aPoints, aPlane2);
           if (dfDist2 < myTolerance)  {
             myTolReached = dfDist2;
@@ -504,6 +559,23 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape&    S,
     //myTolReached = dfDist;
     //XXt
     mySurface = aPlane;
+    //If S is wire, try to orient surface according to orientation of wire.
+    if(S.ShapeType() == TopAbs_WIRE && S.Closed())
+    {
+       //
+      TopoDS_Wire aW = TopoDS::Wire(S);
+      TopoDS_Face aTmpFace = BRepLib_MakeFace(mySurface, Precision::Confusion());
+      BRep_Builder BB;
+      BB.Add(aTmpFace, aW);
+      BRepTopAdaptor_FClass2d FClass(aTmpFace, 0.);
+      if ( FClass.PerformInfinitePoint() == TopAbs_IN ) 
+      {
+        gp_Dir aN = aPlane->Position().Direction();
+        aN.Reverse();
+        mySurface = new Geom_Plane(aPlane->Position().Location(), aN);
+      }
+
+    }
   }
   //XXf
   myTolReached = dfDist;
index 81dd364..327717b 100644 (file)
 #include <BRep_Builder.hxx>
 #include <BRepLib.hxx>
 #include <TopTools_IndexedDataMapOfShapeShape.hxx>
-
+#include <GeomAbs_CurveType.hxx>
+#include <Geom2d_Circle.hxx>
+#include <Geom2d_Line.hxx>
+#include <Geom2d_Ellipse.hxx>
+#include <Geom2d_Parabola.hxx>
+#include <Geom2d_Hyperbola.hxx>
+#include <Geom2d_BezierCurve.hxx>
+#include <GCE2d_MakeArcOfCircle.hxx>
+#include <GCE2d_MakeSegment.hxx> 
+//
 //  Modified by Sergey KHROMOV - Thu Dec  5 10:38:14 2002 Begin
 static TopoDS_Edge MakeEdge(const Handle(Geom2d_Curve) &theCurve,
-                           const TopoDS_Face          &theFace,
-                           const TopoDS_Vertex        &theVFirst,
-                           const TopoDS_Vertex        &theVLast);
+  const TopoDS_Face          &theFace,
+  const TopoDS_Vertex        &theVFirst,
+  const TopoDS_Vertex        &theVLast);
 //  Modified by Sergey KHROMOV - Thu Dec  5 10:38:16 2002 End
-
+//
+static GeomAbs_CurveType GetCurveType(const Handle(Geom2d_Curve)& theC2d);
+static void AdjustCurveEnd(Handle(Geom2d_BoundedCurve)& theC2d, const gp_Pnt2d theP,
+                           const Standard_Boolean isFirst);
+//
 //=======================================================================
 //function : BRepMAT2d_Explorer
 //purpose  : 
@@ -79,7 +92,7 @@ void BRepMAT2d_Explorer::Perform(const TopoDS_Face& aFace)
   TopoDS_Face  F = TopoDS::Face(aFace);
   F.Orientation(TopAbs_FORWARD);
   TopExp_Explorer Exp (F,TopAbs_WIRE);
-//  Modified by Sergey KHROMOV - Tue Nov 26 16:10:37 2002 Begin
+  //  Modified by Sergey KHROMOV - Tue Nov 26 16:10:37 2002 Begin
   Handle(Geom_Surface) aSurf = BRep_Tool::Surface(F);
   TopoDS_Face          aNewF = BRepBuilderAPI_MakeFace(aSurf, Precision::Confusion());
 
@@ -91,8 +104,8 @@ void BRepMAT2d_Explorer::Perform(const TopoDS_Face& aFace)
   BRepLib::BuildCurves3d(aNewF);
 
   myModifShapes.Add(aFace, aNewF);
-//   CheckConnection();
-//  Modified by Sergey KHROMOV - Tue Nov 26 16:10:38 2002 End
+  //   CheckConnection();
+  //  Modified by Sergey KHROMOV - Tue Nov 26 16:10:38 2002 End
 }
 
 //=======================================================================
@@ -101,43 +114,43 @@ void BRepMAT2d_Explorer::Perform(const TopoDS_Face& aFace)
 //=======================================================================
 
 void BRepMAT2d_Explorer::Add(const TopoDS_Wire& Spine,
-                            const TopoDS_Face& aFace,
-                                  TopoDS_Face& aNewFace)
+  const TopoDS_Face& aFace,
+  TopoDS_Face& aNewFace)
 {  
-//  Modified by Sergey KHROMOV - Tue Nov 26 14:25:46 2002 Begin
-// This method is totally rewroted to include check
-// of connection and creation of a new spine.
+  //  Modified by Sergey KHROMOV - Tue Nov 26 14:25:46 2002 Begin
+  // This method is totally rewroted to include check
+  // of connection and creation of a new spine.
   NewContour();
   myIsClosed(currentContour) = (Spine.Closed()) ? Standard_True : Standard_False;
 
-//  Modified by skv - Wed Jun 23 12:23:01 2004 Integration Begin
-//  Taking into account side of bisecting loci construction.
-//   TopoDS_Wire                         aWFwd = TopoDS::Wire(Spine.Oriented(TopAbs_FORWARD));
-//   BRepTools_WireExplorer              anExp(aWFwd, aFace);
+  //  Modified by skv - Wed Jun 23 12:23:01 2004 Integration Begin
+  //  Taking into account side of bisecting loci construction.
+  //   TopoDS_Wire                         aWFwd = TopoDS::Wire(Spine.Oriented(TopAbs_FORWARD));
+  //   BRepTools_WireExplorer              anExp(aWFwd, aFace);
   BRepTools_WireExplorer              anExp(Spine, aFace);
-//  Modified by skv - Wed Jun 23 12:23:02 2004 Integration End
+  //  Modified by skv - Wed Jun 23 12:23:02 2004 Integration End
   TopTools_IndexedDataMapOfShapeShape anOldNewE;
 
   if (!anExp.More())
     return;
 
   TopoDS_Edge                 aFirstEdge = anExp.Current();
+  TopoDS_Edge                 aPrevEdge = aFirstEdge;
   Standard_Real               UFirst,ULast, aD;
-  Handle(Geom2d_BSplineCurve) BCurve;
   Handle(Geom2d_Curve)        C2d;
   Handle(Geom2d_TrimmedCurve) CT2d;
   Handle(Geom2d_TrimmedCurve) aFirstCurve;
   gp_Pnt2d                    aPFirst;
   gp_Pnt2d                    aPLast;
   gp_Pnt2d                    aPCurFirst;
-//  Modified by skv - Mon Jul 11 19:00:25 2005 Integration Begin
-//  Set the confusion tolerance in accordance with the further algo
-//   Standard_Real               aTolConf   = Precision::Confusion();
+  //  Modified by skv - Mon Jul 11 19:00:25 2005 Integration Begin
+  //  Set the confusion tolerance in accordance with the further algo
+  //   Standard_Real               aTolConf   = Precision::Confusion();
   Standard_Real               aTolConf   = 1.e-8;
-//  Modified by skv - Mon Jul 11 19:00:25 2005 Integration End
+  //  Modified by skv - Mon Jul 11 19:00:25 2005 Integration End
   Standard_Boolean            isModif    = Standard_False;
 
-// Treatment of the first edge of a wire.
+  // Treatment of the first edge of a wire.
   anOldNewE.Add(aFirstEdge, aFirstEdge);
   C2d  = BRep_Tool::CurveOnSurface (aFirstEdge, aFace, UFirst, ULast);
   CT2d = new Geom2d_TrimmedCurve(C2d,UFirst,ULast);
@@ -152,7 +165,7 @@ void BRepMAT2d_Explorer::Add(const TopoDS_Wire& Spine,
   aFirstCurve = CT2d;
   anExp.Next();
 
-// Treatment of the next edges:
+  // Treatment of the next edges:
   for (; anExp.More(); anExp.Next()) {
     TopoDS_Edge  anEdge = anExp.Current();
 
@@ -175,64 +188,111 @@ void BRepMAT2d_Explorer::Add(const TopoDS_Wire& Spine,
       //             code should be rewritten.
       isModif = Standard_True;
       //
-      //modified by NIZNHY-PKV Tue Aug  7 09:14:03 2007f
-      //BCurve = Geom2dConvert::CurveToBSplineCurve(CT2d);
-      BCurve=Geom2dConvert::CurveToBSplineCurve(CT2d, Convert_QuasiAngular);
-      //modified by NIZNHY-PKV Tue Aug  7 09:14:07 2007t
-      
-      BCurve->SetPole(1, aPLast);
-      CT2d = new Geom2d_TrimmedCurve(BCurve, BCurve->FirstParameter(),
-                                            BCurve->LastParameter());
-
-      // Creation of new edge.
-      TopoDS_Edge aNewEdge;
-      TopoDS_Vertex aVf = TopExp::FirstVertex(anEdge);
-      TopoDS_Vertex aVl = TopExp::LastVertex(anEdge);
-
-      if (anEdge.Orientation() == TopAbs_FORWARD)
-       aNewEdge = MakeEdge(CT2d, aNewFace, aVf, aVl);
-      else 
-       aNewEdge = MakeEdge(CT2d->Reversed(), aNewFace, aVf, aVl);
-
-      aNewEdge.Orientation(anEdge.Orientation());
+      Standard_Integer aNbC = theCurves.Value(currentContour).Length();
+      Handle(Geom2d_BoundedCurve) CPrev = 
+        Handle(Geom2d_BoundedCurve)::DownCast(theCurves.ChangeValue(currentContour).ChangeValue(aNbC));
+      //
+      GeomAbs_CurveType TCPrev = GetCurveType(CPrev);
+      GeomAbs_CurveType TCCurr = GetCurveType(CT2d);
+      //
+      if(TCCurr <= TCPrev)
+      {
+        AdjustCurveEnd(CT2d, aPLast, Standard_True);
+        // Creation of new edge.
+        TopoDS_Edge aNewEdge;
+        TopoDS_Vertex aVf = TopExp::FirstVertex(anEdge);
+        TopoDS_Vertex aVl = TopExp::LastVertex(anEdge);
+
+        if (anEdge.Orientation() == TopAbs_FORWARD)
+          aNewEdge = MakeEdge(CT2d, aNewFace, aVf, aVl);
+        else 
+          aNewEdge = MakeEdge(CT2d->Reversed(), aNewFace, aVf, aVl);
+
+        aNewEdge.Orientation(anEdge.Orientation());
+
+        anOldNewE.ChangeFromKey(anEdge) = aNewEdge;
+      }
+      else
+      {
+        gp_Pnt2d aP = CT2d->Value(CT2d->FirstParameter());
+        AdjustCurveEnd(CPrev, aP, Standard_False);
+        theCurves.ChangeValue(currentContour).ChangeValue(aNbC) = CPrev;
+        //Change previous edge
+        TopoDS_Edge aNewEdge;
+        TopoDS_Vertex aVf = TopExp::FirstVertex(aPrevEdge);
+        TopoDS_Vertex aVl = TopExp::LastVertex(aPrevEdge);
+
+        if (aPrevEdge.Orientation() == TopAbs_FORWARD)
+          aNewEdge = MakeEdge(CPrev, aNewFace, aVf, aVl);
+        else 
+          aNewEdge = MakeEdge(CPrev->Reversed(), aNewFace, aVf, aVl);
+
+        aNewEdge.Orientation(aPrevEdge.Orientation());
+
+        anOldNewE.ChangeFromKey(aPrevEdge) = aNewEdge;
+        
+      }
 
-      anOldNewE.ChangeFromKey(anEdge) = aNewEdge;
     }
 
     aPLast = CT2d->Value(CT2d->LastParameter());
     Add(CT2d);
+    aPrevEdge = anEdge;
   }
 
   // Check of the distance between the first and the last point of wire
   // if the wire is closed.
-    if (myIsClosed(currentContour) && aPLast.Distance(aPFirst) > aTolConf) {
-      isModif = Standard_True;
-
-      
-      //modified by NIZNHY-PKV Tue Aug  7 09:20:08 2007f
-      //Handle(Geom2d_BSplineCurve)
-      //BCurve = Geom2dConvert::CurveToBSplineCurve(aFirstCurve);
-      BCurve = Geom2dConvert::CurveToBSplineCurve(aFirstCurve, Convert_QuasiAngular);
-      //modified by NIZNHY-PKV Tue Aug  7 09:20:11 2007t
+  if (myIsClosed(currentContour) && aPLast.Distance(aPFirst) > aTolConf) {
+    isModif = Standard_True;
 
-      BCurve->SetPole(1, aPLast);
-      aFirstCurve = new Geom2d_TrimmedCurve(BCurve, BCurve->FirstParameter(),
-                                                   BCurve->LastParameter());
+      //
+    Standard_Integer aNbC = theCurves.Value(currentContour).Length();
+    Handle(Geom2d_BoundedCurve) CPrev = 
+        Handle(Geom2d_BoundedCurve)::DownCast(theCurves.ChangeValue(currentContour).ChangeValue(aNbC));
+      //
+    GeomAbs_CurveType TCPrev = GetCurveType(CPrev);
+    GeomAbs_CurveType TCCurr = GetCurveType(aFirstCurve);
+    //
+    if(TCCurr <= TCPrev)
+    {
+      AdjustCurveEnd(aFirstCurve, aPLast, Standard_True);
       theCurves.ChangeValue(currentContour).ChangeValue(1) = aFirstCurve;
-
-      // Creation of new first edge.
+      // Creation of new edge.
       TopoDS_Edge aNewEdge;
       TopoDS_Vertex aVf = TopExp::FirstVertex(aFirstEdge);
       TopoDS_Vertex aVl = TopExp::LastVertex(aFirstEdge);
 
       if (aFirstEdge.Orientation() == TopAbs_FORWARD)
-       aNewEdge = MakeEdge(aFirstCurve, aNewFace, aVf, aVl);
+        aNewEdge = MakeEdge(aFirstCurve, aNewFace, aVf, aVl);
       else 
-       aNewEdge = MakeEdge(aFirstCurve->Reversed(), aNewFace, aVf, aVl);
+        aNewEdge = MakeEdge(aFirstCurve->Reversed(), aNewFace, aVf, aVl);
 
       aNewEdge.Orientation(aFirstEdge.Orientation());
+
       anOldNewE.ChangeFromKey(aFirstEdge) = aNewEdge;
     }
+    else
+    {
+      gp_Pnt2d aP = aFirstCurve->Value(aFirstCurve->FirstParameter());
+      AdjustCurveEnd(CPrev, aP, Standard_False);
+      theCurves.ChangeValue(currentContour).ChangeValue(aNbC) = CPrev;
+      //Change previous edge
+      TopoDS_Edge aNewEdge;
+      TopoDS_Vertex aVf = TopExp::FirstVertex(aPrevEdge);
+      TopoDS_Vertex aVl = TopExp::LastVertex(aPrevEdge);
+
+      if (aPrevEdge.Orientation() == TopAbs_FORWARD)
+        aNewEdge = MakeEdge(CPrev, aNewFace, aVf, aVl);
+      else 
+        aNewEdge = MakeEdge(CPrev->Reversed(), aNewFace, aVf, aVl);
+
+      aNewEdge.Orientation(aPrevEdge.Orientation());
+
+      anOldNewE.ChangeFromKey(aPrevEdge) = aNewEdge;
+
+    }
+
+  }
 
   TopoDS_Wire  aNewWire;
   BRep_Builder aBuilder;
@@ -263,7 +323,7 @@ void BRepMAT2d_Explorer::Add(const TopoDS_Wire& Spine,
     aNewWire = Spine;
 
   aBuilder.Add(aNewFace, aNewWire);
-//  Modified by Sergey KHROMOV - Tue Nov 26 14:25:53 2002 End
+  //  Modified by Sergey KHROMOV - Tue Nov 26 14:25:53 2002 End
 }
 
 //=======================================================================
@@ -302,10 +362,10 @@ void BRepMAT2d_Explorer::Clear()
 {  
   theCurves.Clear() ;
   currentContour = 0;
-//  Modified by Sergey KHROMOV - Wed Mar  6 16:07:55 2002 Begin
+  //  Modified by Sergey KHROMOV - Wed Mar  6 16:07:55 2002 Begin
   myIsClosed.Clear();
   myModifShapes.Clear();
-//  Modified by Sergey KHROMOV - Wed Mar  6 16:07:55 2002 End
+  //  Modified by Sergey KHROMOV - Wed Mar  6 16:07:55 2002 End
 }
 
 
@@ -318,9 +378,9 @@ void BRepMAT2d_Explorer::NewContour()
 {  
   TColGeom2d_SequenceOfCurve Contour;
   theCurves.Append(Contour);
-//  Modified by Sergey KHROMOV - Wed Mar  6 16:12:05 2002 Begin
+  //  Modified by Sergey KHROMOV - Wed Mar  6 16:12:05 2002 Begin
   myIsClosed.Append(Standard_False);
-//  Modified by Sergey KHROMOV - Wed Mar  6 16:12:05 2002 End
+  //  Modified by Sergey KHROMOV - Wed Mar  6 16:12:05 2002 End
   currentContour ++ ;
 }
 
@@ -353,7 +413,7 @@ Standard_Integer BRepMAT2d_Explorer::NumberOfContours() const
 
 Standard_Integer BRepMAT2d_Explorer::NumberOfCurves
   (const Standard_Integer IndexContour)
-const 
+  const 
 {  
   return theCurves.Value(IndexContour).Length();
 }
@@ -421,7 +481,7 @@ TopoDS_Shape BRepMAT2d_Explorer::Shape() const
 
 const TColGeom2d_SequenceOfCurve& BRepMAT2d_Explorer::Contour
   (const Standard_Integer IC)
-const
+  const
 {
   return theCurves.Value(IC);
 }
@@ -434,7 +494,7 @@ const
 //=======================================================================
 
 Standard_Boolean BRepMAT2d_Explorer::IsModified
-                                     (const TopoDS_Shape &aShape) const
+  (const TopoDS_Shape &aShape) const
 {
   if (myModifShapes.Contains(aShape)) {
     const TopoDS_Shape     &aNewShape = myModifShapes.FindFromKey(aShape);
@@ -452,7 +512,7 @@ Standard_Boolean BRepMAT2d_Explorer::IsModified
 //=======================================================================
 
 TopoDS_Shape BRepMAT2d_Explorer::ModifiedShape
-                                     (const TopoDS_Shape &aShape) const
+  (const TopoDS_Shape &aShape) const
 {
   if (myModifShapes.Contains(aShape)) {
     const TopoDS_Shape &aNewShape = myModifShapes.FindFromKey(aShape);
@@ -479,9 +539,9 @@ const TColStd_SequenceOfBoolean &BRepMAT2d_Explorer::GetIsClosed() const
 //=======================================================================
 
 TopoDS_Edge MakeEdge(const Handle(Geom2d_Curve) &theCurve,
-                    const TopoDS_Face          &theFace,
-                    const TopoDS_Vertex        &theVFirst,
-                    const TopoDS_Vertex        &theVLast)
+  const TopoDS_Face          &theFace,
+  const TopoDS_Vertex        &theVFirst,
+  const TopoDS_Vertex        &theVLast)
 {
   TopoDS_Edge   aNewEdge;
   BRep_Builder  aBuilder;
@@ -498,3 +558,85 @@ TopoDS_Edge MakeEdge(const Handle(Geom2d_Curve) &theCurve,
   return aNewEdge;
 }
 //  Modified by Sergey KHROMOV - Wed Mar  6 17:40:14 2002 End
+//
+//=======================================================================
+//function : GetCurveType
+//purpose  : Get curve type.
+//=======================================================================
+
+GeomAbs_CurveType GetCurveType(const Handle(Geom2d_Curve)& theC2d)
+{
+  GeomAbs_CurveType aTypeCurve = GeomAbs_OtherCurve;
+  Handle(Standard_Type) TheType = theC2d->DynamicType();
+  if ( TheType == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
+    TheType = (*((Handle(Geom2d_TrimmedCurve)*)&theC2d))->BasisCurve()->DynamicType();
+  }
+
+  if ( TheType ==  STANDARD_TYPE(Geom2d_Circle)) {
+    aTypeCurve = GeomAbs_Circle;
+  }
+  else if ( TheType ==STANDARD_TYPE(Geom2d_Line)) {
+    aTypeCurve = GeomAbs_Line;
+  }
+  else if ( TheType == STANDARD_TYPE(Geom2d_Ellipse)) {
+    aTypeCurve = GeomAbs_Ellipse;
+  }
+  else if ( TheType == STANDARD_TYPE(Geom2d_Parabola)) {
+    aTypeCurve = GeomAbs_Parabola;
+  }
+  else if ( TheType == STANDARD_TYPE(Geom2d_Hyperbola)) {
+    aTypeCurve = GeomAbs_Hyperbola;
+  }
+  else if ( TheType == STANDARD_TYPE(Geom2d_BezierCurve)) {
+    aTypeCurve = GeomAbs_BezierCurve;
+  }
+  else if ( TheType == STANDARD_TYPE(Geom2d_BSplineCurve)) {
+    aTypeCurve = GeomAbs_BSplineCurve;
+  }
+  else {
+    aTypeCurve = GeomAbs_OtherCurve;
+  }
+  return aTypeCurve;    
+}
+//=======================================================================
+//function : AdjustCurveEnd
+//purpose  : 
+//=======================================================================
+void AdjustCurveEnd(Handle(Geom2d_BoundedCurve)& theC2d, const gp_Pnt2d theP,
+                           const Standard_Boolean isFirst)
+{
+  GeomAbs_CurveType aType = GetCurveType(theC2d);
+  if(aType == GeomAbs_Line)
+  {
+    //create new line
+    if(isFirst)
+    {
+      gp_Pnt2d aP = theC2d->Value(theC2d->LastParameter());
+      theC2d = GCE2d_MakeSegment(theP, aP);
+    }
+    else
+    {
+      gp_Pnt2d aP = theC2d->Value(theC2d->FirstParameter());
+      theC2d = GCE2d_MakeSegment(aP, theP);
+    }
+  }
+  else
+  {
+    //Convert to BSpline and adjust first pole
+    Handle(Geom2d_BSplineCurve) BCurve = 
+      Geom2dConvert::CurveToBSplineCurve(theC2d, Convert_QuasiAngular);
+    if(isFirst)
+    {
+      BCurve->SetPole(1, theP);
+      theC2d = new Geom2d_TrimmedCurve(BCurve, BCurve->FirstParameter(),
+                                               BCurve->LastParameter());
+    }
+    else
+    {
+      BCurve->SetPole(BCurve->NbPoles(), theP);
+      theC2d = new Geom2d_TrimmedCurve(BCurve, BCurve->FirstParameter(),
+                                               BCurve->LastParameter());
+    }
+  }
+
+}
index 1889738..0f2f7d5 100644 (file)
 #include <TopoDS_Wire.hxx>
 
 #include <StdFail_NotDone.hxx>
+#ifdef OCCT_DEBUG
+#include <BRepTools.hxx>
+static Standard_Boolean AffichSpine = Standard_False;
+#endif
 
 //=======================================================================
 //function : BRepOffsetAPI_MakeOffset
@@ -183,8 +187,20 @@ static void BuildDomains(TopoDS_Face&               myFace,
     StdFail_NotDone::Raise ("BRepOffsetAPI_MakeOffset : Build Domains");
   }
   TopTools_ListOfShape Faces;
+#ifdef OCCT_DEBUG
+  Standard_Integer ns = 0;
+#endif
   for (; FR.More(); FR.Next()) {
     Faces.Append(FR.Current());
+#ifdef OCCT_DEBUG
+    if(AffichSpine)
+    {
+      char name[32];
+      ns++;
+      sprintf(name, "FR%d",ns);
+      BRepTools::Write(FR.Current(), name);
+    }
+#endif
   }
 
   //===========================================
index 35c4f03..6c45534 100644 (file)
@@ -21,6 +21,7 @@
 #include <Geom2d_Point.hxx>
 #include <Geom2d_CartesianPoint.hxx>
 #include <Geom2d_TrimmedCurve.hxx>
+#include <Geom2d_BSplineCurve.hxx>
 #include <gp.hxx>
 #include <gp_Pnt2d.hxx>
 #include <gp_Vec2d.hxx>
 #include <Bisector_BisecAna.hxx>
 #include <Bisector_BisecPC.hxx>
 #include <Bisector_BisecCC.hxx>
+#include <GCE2d_MakeSegment.hxx>
 
-/*
+#ifdef OCCT_DEBUG
+//#define DRAW
+#ifdef DRAW
 #include <DrawTrSurf.hxx>
-static char tname[100];
-static Standard_CString name = tname ;
+#pragma comment(lib, "TKDraw.lib")
+static char name[100];
 static Standard_Integer nbb  = 0;
-*/
+static Standard_Boolean Affich = Standard_False;
+#endif
+#endif
+
 
 static Standard_Boolean IsMaxRC (const Handle(Geom2d_Curve)& C,
-                                      Standard_Real         U,
-                                      Standard_Real&        R);
+  Standard_Real         U,
+  Standard_Real&        R);
 
 static void ReplaceByLineIfIsToSmall (Handle(Geom2d_Curve)& Bis,
-                                     Standard_Real&        UFirst,
-                                     Standard_Real&        ULast);                                     
+  Standard_Real&        UFirst,
+  Standard_Real&        ULast);                                        
 //=============================================================================
 //function : Empty Constructor                                                
 //=============================================================================
@@ -66,48 +73,97 @@ Bisector_Bisec::Bisector_Bisec()
 //===========================================================================
 
 void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve   ,
-                            const Handle(Geom2d_Curve)& asecondcurve  ,
-                            const gp_Pnt2d&             apoint        ,
-                            const gp_Vec2d&             afirstvector  ,
-                            const gp_Vec2d&             asecondvector ,
-                            const Standard_Real         adirection    ,
-                            const Standard_Real         tolerance     ,
-                            const Standard_Boolean      oncurve       )
+  const Handle(Geom2d_Curve)& asecondcurve  ,
+  const gp_Pnt2d&             apoint        ,
+  const gp_Vec2d&             afirstvector  ,
+  const gp_Vec2d&             asecondvector ,
+  const Standard_Real         adirection    ,
+  const Standard_Real         tolerance     ,
+  const Standard_Boolean      oncurve       )
 {
   Handle(Standard_Type)  Type1 = afirstcurve ->DynamicType();
   Handle(Standard_Type)  Type2 = asecondcurve->DynamicType();
   Handle(Bisector_Curve) Bis;
   Standard_Real          UFirst,ULast;
-  
+
   if (Type1 == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
     Type1 = Handle(Geom2d_TrimmedCurve)::DownCast(afirstcurve)
-            ->BasisCurve()->DynamicType();
+      ->BasisCurve()->DynamicType();
   }
   if (Type2 == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
     Type2 = Handle(Geom2d_TrimmedCurve)::DownCast(asecondcurve)
-            ->BasisCurve()->DynamicType();
+      ->BasisCurve()->DynamicType();
+  }
+
+  Handle(Geom2d_Curve) afirstcurve1 = afirstcurve;
+  Handle(Geom2d_Curve) asecondcurve1 = asecondcurve;
+
+  if(Type1 == STANDARD_TYPE(Geom2d_BSplineCurve))
+  {
+    Handle(Geom2d_BSplineCurve) aBS;
+    if(afirstcurve->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve))
+    {
+      aBS = Handle(Geom2d_BSplineCurve)::DownCast(Handle(Geom2d_TrimmedCurve)::DownCast(afirstcurve)
+                                                                               ->BasisCurve());
+    }
+    else
+    {
+      aBS = Handle(Geom2d_BSplineCurve)::DownCast(afirstcurve);
+    }
+    if(aBS->Degree() == 1 && aBS->NbPoles() == 2)
+    {
+      if(aBS->Pole(1).Distance(aBS->Pole(2)) < 1.e-4)
+      {
+        afirstcurve1 = GCE2d_MakeSegment(aBS->Pole(1), aBS->Pole(2));
+        Type1 = STANDARD_TYPE(Geom2d_Line);
+      }
+    }
+  }
+
+
+  if(Type2 == STANDARD_TYPE(Geom2d_BSplineCurve))
+  {
+    Handle(Geom2d_BSplineCurve) aBS;
+    if(asecondcurve->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve))
+    {
+      aBS = Handle(Geom2d_BSplineCurve)::DownCast(Handle(Geom2d_TrimmedCurve)::DownCast(asecondcurve)
+                                                                               ->BasisCurve());
+    }
+    else
+    {
+      aBS = Handle(Geom2d_BSplineCurve)::DownCast(asecondcurve);
+    }
+    if(aBS->Degree() == 1 && aBS->NbPoles() == 2)
+    {
+      if(aBS->Pole(1).Distance(aBS->Pole(2)) < 1.e-4)
+      {
+        asecondcurve1 = GCE2d_MakeSegment(aBS->Pole(1), aBS->Pole(2));
+        Type2 = STANDARD_TYPE(Geom2d_Line);
+      }
+    }
   }
 
   if ( (Type1 == STANDARD_TYPE(Geom2d_Circle) || Type1 == STANDARD_TYPE(Geom2d_Line)) &&
-       (Type2 == STANDARD_TYPE(Geom2d_Circle) || Type2 == STANDARD_TYPE(Geom2d_Line))   ) {    
+    (Type2 == STANDARD_TYPE(Geom2d_Circle) || Type2 == STANDARD_TYPE(Geom2d_Line))   )
+  {    
     //------------------------------------------------------------------
     // Analytic Bissectrice.
     //------------------------------------------------------------------
-     Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna();
-     BisAna->Perform(afirstcurve   ,
-                    asecondcurve  ,
-                    apoint        ,
-                    afirstvector  ,
-                    asecondvector ,
-                    adirection    ,
-                    tolerance     ,
-                    oncurve       );
-     UFirst = BisAna->ParameterOfStartPoint();
-     ULast  = BisAna->ParameterOfEndPoint();    
-     Bis = BisAna;   
+    Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna();
+    BisAna->Perform(afirstcurve1   ,
+      asecondcurve1  ,
+      apoint        ,
+      afirstvector  ,
+      asecondvector ,
+      adirection    ,
+      tolerance     ,
+      oncurve       );
+    UFirst = BisAna->ParameterOfStartPoint();
+    ULast  = BisAna->ParameterOfEndPoint(); 
+    Bis = BisAna;   
   }
   else {  
-     Standard_Boolean IsLine = Standard_False;
+    Standard_Boolean IsLine = Standard_False;
 
     if (oncurve) {
       gp_Dir2d Fd(afirstvector);
@@ -115,7 +171,7 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve   ,
       //if (Fd.Dot(Sd) < Precision::Angular() - 1.) { 
       //if (Fd.Dot(Sd) < 10*Precision::Angular() - 1.) //patch
       if (Fd.Dot(Sd) < Sqrt(2.*Precision::Angular()) - 1.)
-       IsLine = Standard_True;
+        IsLine = Standard_True;
     }
     if (IsLine) {     
       //------------------------------------------------------------------
@@ -125,7 +181,7 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve   ,
       Handle (Geom2d_CartesianPoint) PG     = new Geom2d_CartesianPoint(apoint);
       Handle (Geom2d_Line)           L      = new Geom2d_Line (apoint,N);
       Handle (Geom2d_TrimmedCurve)   
-       BisL   = new Geom2d_TrimmedCurve (L,0,Precision::Infinite());
+        BisL   = new Geom2d_TrimmedCurve (L,0,Precision::Infinite());
       Handle(Bisector_BisecAna)      BisAna = new Bisector_BisecAna ();
       BisAna->Init(BisL);
       UFirst = BisAna->ParameterOfStartPoint();
@@ -137,58 +193,78 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve   ,
       // Bissectrice algo
       //-------------------------------------------------------------------
       Handle(Bisector_BisecCC) BisCC = new Bisector_BisecCC();
-      BisCC -> Perform(asecondcurve, 
-                      afirstcurve ,
-                      adirection  , 
-                      adirection  , 
-                      apoint);
+      BisCC -> Perform(asecondcurve1, 
+        afirstcurve1 ,
+        adirection  , 
+        adirection  , 
+        apoint);
 
       if (BisCC -> IsEmpty()) {
-       // bissectrice is empty. a point is projected at the end of the guide curve. 
-       // Construction of a false bissectrice.
-//  modified by NIZHNY-EAP Mon Feb 21 12:00:13 2000 ___BEGIN___
-       gp_Dir2d dir1(afirstvector), dir2(asecondvector);
-       Standard_Real
-         Nx = - dir1.X() - dir2.X(),
-         Ny = - dir1.Y() - dir2.Y();
-       if (Abs(Nx) <= gp::Resolution() && Abs(Ny) <= gp::Resolution()) {
-         Nx = - afirstvector.Y();
-         Ny = afirstvector.X();
-       }
-       //gp_Dir2d N ( - adirection*afirstvector.Y(), adirection*afirstvector.X());
-       gp_Dir2d N ( adirection*Nx, adirection*Ny);
-//  modified by NIZHNY-EAP Mon Feb 21 12:00:19 2000 ___END___
-       
-       Handle (Geom2d_CartesianPoint) PG     = new Geom2d_CartesianPoint(apoint);
-       Handle (Geom2d_Line)           L      = new Geom2d_Line (apoint,N);
-       Handle (Geom2d_TrimmedCurve)   
-         BisL   = new Geom2d_TrimmedCurve (L,0,Precision::Infinite());
-       Handle(Bisector_BisecAna)      BisAna = new Bisector_BisecAna ();
-       BisAna->Init(BisL);
-       UFirst = BisAna->ParameterOfStartPoint();
-       ULast  = BisAna->ParameterOfEndPoint();
-       Bis    = BisAna;
+        // bissectrice is empty. a point is projected at the end of the guide curve. 
+        // Construction of a false bissectrice.
+        //  modified by NIZHNY-EAP Mon Feb 21 12:00:13 2000 ___BEGIN___
+        gp_Pnt2d aP1 = afirstcurve1->Value(afirstcurve1->LastParameter());
+        gp_Pnt2d aP2 = asecondcurve1->Value(asecondcurve1->FirstParameter());
+        gp_Pnt2d aPm(.5*(aP1.XY()+aP2.XY()));
+        Standard_Real Nx, Ny;
+        if(aPm.Distance(apoint) > 10.*Precision::Confusion())
+        {
+          Nx = apoint.X() - aPm.X();
+          Ny = apoint.Y() - aPm.Y();
+          if(adirection < 0)
+          {
+            Nx = -Nx;
+            Ny = -Ny;
+          }
+        }
+        else
+        {
+          gp_Dir2d dir1(afirstvector), dir2(asecondvector);
+          Nx = - dir1.X() - dir2.X(),
+          Ny = - dir1.Y() - dir2.Y();
+          if (Abs(Nx) <= gp::Resolution() && Abs(Ny) <= gp::Resolution()) {
+            Nx = -afirstvector.Y();
+            Ny = afirstvector.X();
+          }
+        }
+        gp_Dir2d N ( adirection*Nx, adirection*Ny);
+        //  modified by NIZHNY-EAP Mon Feb 21 12:00:19 2000 ___END___
+
+        Handle (Geom2d_CartesianPoint) PG     = new Geom2d_CartesianPoint(apoint);
+        Handle (Geom2d_Line)           L      = new Geom2d_Line (apoint,N);
+        Handle (Geom2d_TrimmedCurve)   
+          BisL   = new Geom2d_TrimmedCurve (L,0,Precision::Infinite());
+        Handle(Bisector_BisecAna)      BisAna = new Bisector_BisecAna ();
+        BisAna->Init(BisL);
+        UFirst = BisAna->ParameterOfStartPoint();
+        ULast  = BisAna->ParameterOfEndPoint();
+        Bis    = BisAna;
       }
       else {
-       UFirst = BisCC->FirstParameter();
-       ULast  = BisCC->LastParameter ();
-       Bis    = BisCC;
-       ReplaceByLineIfIsToSmall(Bis,UFirst,ULast);
+        UFirst = BisCC->FirstParameter();
+        ULast  = BisCC->LastParameter ();
+        Bis    = BisCC;
+        ReplaceByLineIfIsToSmall(Bis,UFirst,ULast);
       }
     }
   }
+  UFirst = Max(UFirst, Bis->FirstParameter());
+  ULast = Min(ULast, Bis->LastParameter());
   thebisector = new Geom2d_TrimmedCurve(Bis,UFirst,ULast);
-
-/*
-  sprintf( name, "c1_%d", ++nbb );
-  DrawTrSurf::Set( name, afirstcurve );
-  sprintf( name, "c2_%d", nbb );
-  DrawTrSurf::Set( name, asecondcurve );
-  sprintf( name, "p%d", nbb );
-  DrawTrSurf::Set( name, apoint );
-  sprintf( name, "b%d", nbb );
-  DrawTrSurf::Set( name, thebisector );
-*/
+#ifdef DRAW  
+  if(Affich) 
+  {
+    sprintf( name, "c1_%d", ++nbb );
+    DrawTrSurf::Set( name, afirstcurve );
+    sprintf( name, "c2_%d", nbb );
+    DrawTrSurf::Set( name, asecondcurve );
+    sprintf( name, "p%d", nbb );
+    DrawTrSurf::Set( name, apoint );
+    sprintf( name, "b%d", nbb );
+    DrawTrSurf::Set( name, thebisector );
+  }
+#endif
+  
 }
 
 //===========================================================================
@@ -204,13 +280,13 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve   ,
 //===========================================================================
 
 void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve  ,
-                            const Handle(Geom2d_Point)& asecondpoint ,
-                            const gp_Pnt2d&             apoint       ,
-                            const gp_Vec2d&             afirstvector ,
-                            const gp_Vec2d&             asecondvector,
-                            const Standard_Real         adirection   ,
-                            const Standard_Real         tolerance    ,
-                            const Standard_Boolean      oncurve       )
+  const Handle(Geom2d_Point)& asecondpoint ,
+  const gp_Pnt2d&             apoint       ,
+  const gp_Vec2d&             afirstvector ,
+  const gp_Vec2d&             asecondvector,
+  const Standard_Real         adirection   ,
+  const Standard_Real         tolerance    ,
+  const Standard_Boolean      oncurve       )
 {  
   //gp_Pnt2d SecondPnt = asecondpoint->Pnt2d();
 
@@ -220,7 +296,7 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve  ,
 
   if (Type1 == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
     Type1 = Handle(Geom2d_TrimmedCurve)::DownCast(afirstcurve)
-            ->BasisCurve()->DynamicType();
+      ->BasisCurve()->DynamicType();
   }
 
   if ( Type1 == STANDARD_TYPE(Geom2d_Circle) || Type1 == STANDARD_TYPE(Geom2d_Line)) {
@@ -229,13 +305,13 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve  ,
     //------------------------------------------------------------------
     Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna();
     BisAna -> Perform (afirstcurve   ,
-                      asecondpoint  ,
-                      apoint        ,
-                      afirstvector  ,
-                      asecondvector ,
-                      adirection    ,
-                      tolerance     ,
-                      oncurve       );
+      asecondpoint  ,
+      apoint        ,
+      afirstvector  ,
+      asecondvector ,
+      adirection    ,
+      tolerance     ,
+      oncurve       );
     UFirst = BisAna->ParameterOfStartPoint();
     ULast  = BisAna->ParameterOfEndPoint();
     Bis    = BisAna;
@@ -243,11 +319,11 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve  ,
   else {  
     Standard_Boolean IsLine    = Standard_False;
     Standard_Real    RC        = Precision::Infinite();
-    
+
     if (oncurve) {
       if (Bisector::IsConvex(afirstcurve,adirection) || 
-         IsMaxRC(afirstcurve,afirstcurve->LastParameter(),RC)) { 
-       IsLine = Standard_True; 
+        IsMaxRC(afirstcurve,afirstcurve->LastParameter(),RC)) { 
+          IsLine = Standard_True; 
       }
     }
     if (IsLine) {     
@@ -269,66 +345,73 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve  ,
       //-------------------------------------------------------------------
       Handle(Bisector_BisecPC) BisPC = new Bisector_BisecPC();
       Handle(Geom2d_Curve) afirstcurvereverse = afirstcurve->Reversed();
-      
+
       BisPC -> Perform(afirstcurvereverse   ,
-                      asecondpoint->Pnt2d(),
-                      - adirection         );
-//  Modified by Sergey KHROMOV - Thu Feb 21 16:49:54 2002 Begin
+        asecondpoint->Pnt2d(),
+        - adirection         );
+      //  Modified by Sergey KHROMOV - Thu Feb 21 16:49:54 2002 Begin
       if (BisPC -> IsEmpty()) {
-       gp_Dir2d dir1(afirstvector), dir2(asecondvector);
-       Standard_Real
-         Nx = - dir1.X() - dir2.X(),
-         Ny = - dir1.Y() - dir2.Y();
-       if (Abs(Nx) <= gp::Resolution() && Abs(Ny) <= gp::Resolution()) {
-         Nx = - afirstvector.Y();
-         Ny = afirstvector.X();
-       }
-//     gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
-       gp_Dir2d N ( adirection*Nx, adirection*Ny);
-       Handle (Geom2d_Line)         L      = new Geom2d_Line (apoint,N);
-       Handle (Geom2d_TrimmedCurve) BisL   = new Geom2d_TrimmedCurve(L,0,RC);
-       Handle(Bisector_BisecAna)    BisAna = new Bisector_BisecAna ();
-       BisAna->Init(BisL);
-       UFirst = BisAna->ParameterOfStartPoint();
-       ULast  = BisAna->ParameterOfEndPoint();
-       Bis    = BisAna;
+        gp_Dir2d dir1(afirstvector), dir2(asecondvector);
+        Standard_Real
+          Nx = - dir1.X() - dir2.X(),
+          Ny = - dir1.Y() - dir2.Y();
+        if (Abs(Nx) <= gp::Resolution() && Abs(Ny) <= gp::Resolution()) {
+          Nx = - afirstvector.Y();
+          Ny = afirstvector.X();
+        }
+        //     gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
+        gp_Dir2d N ( adirection*Nx, adirection*Ny);
+        Handle (Geom2d_Line)         L      = new Geom2d_Line (apoint,N);
+        Handle (Geom2d_TrimmedCurve) BisL   = new Geom2d_TrimmedCurve(L,0,RC);
+        Handle(Bisector_BisecAna)    BisAna = new Bisector_BisecAna ();
+        BisAna->Init(BisL);
+        UFirst = BisAna->ParameterOfStartPoint();
+        ULast  = BisAna->ParameterOfEndPoint();
+        Bis    = BisAna;
       } else {
-//  Modified by Sergey KHROMOV - Wed Mar  6 17:01:08 2002 End
-       UFirst = BisPC->Parameter(apoint);
-       ULast  = BisPC->LastParameter();
-       if(UFirst >= ULast)
-         {
-         //Standard_Real t = .9;
-         //UFirst = (1. - t) * BisPC->FirstParameter() + t * ULast;
-           //Extrapolate by line
-           //gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
-           gp_Vec2d V( BisPC->Value(BisPC->FirstParameter()), BisPC->Value(ULast) );
-           gp_Dir2d N( V );
-           Handle (Geom2d_Line)         L      = new Geom2d_Line         (apoint,N);
-           Handle (Geom2d_TrimmedCurve) BisL   = new Geom2d_TrimmedCurve (L,0,RC);
-           Handle(Bisector_BisecAna)    BisAna = new Bisector_BisecAna   ();
-           BisAna->Init(BisL);
-           UFirst = BisAna->ParameterOfStartPoint();
-           ULast  = BisAna->ParameterOfEndPoint();
-           Bis    = BisAna;
-         }
-       else
-         Bis    = BisPC;
+        //  Modified by Sergey KHROMOV - Wed Mar  6 17:01:08 2002 End
+        UFirst = BisPC->Parameter(apoint);
+        ULast  = BisPC->LastParameter();
+        if(UFirst >= ULast)
+        {
+          //Standard_Real t = .9;
+          //UFirst = (1. - t) * BisPC->FirstParameter() + t * ULast;
+          //Extrapolate by line
+          //gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
+          gp_Vec2d V( BisPC->Value(BisPC->FirstParameter()), BisPC->Value(ULast) );
+          gp_Dir2d N( V );
+          Handle (Geom2d_Line)         L      = new Geom2d_Line         (apoint,N);
+          Handle (Geom2d_TrimmedCurve) BisL   = new Geom2d_TrimmedCurve (L,0,RC);
+          Handle(Bisector_BisecAna)    BisAna = new Bisector_BisecAna   ();
+          BisAna->Init(BisL);
+          UFirst = BisAna->ParameterOfStartPoint();
+          ULast  = BisAna->ParameterOfEndPoint();
+          Bis    = BisAna;
+        }
+        else
+          Bis    = BisPC;
       }
     }
   }
+  if(UFirst < Bis->FirstParameter())
+    UFirst = Bis->FirstParameter();
+  if(ULast > Bis->LastParameter())
+    ULast = Bis->LastParameter();
   thebisector = new Geom2d_TrimmedCurve(Bis,UFirst,ULast);
 
-/*
+#ifdef DRAW
+  if(Affich)
+  {
   sprintf( name, "c1_%d", ++nbb );
   DrawTrSurf::Set( name, afirstcurve );
   sprintf( name, "c2_%d", nbb );
-  DrawTrSurf::Set( name, SecondPnt );
+  DrawTrSurf::Set( name, asecondpoint->Pnt2d() );
   sprintf( name, "p%d", nbb );
   DrawTrSurf::Set( name, apoint );
   sprintf( name, "b%d", nbb );
   DrawTrSurf::Set( name, thebisector );
-*/
+  }
+#endif
 }
 
 //===========================================================================
@@ -344,13 +427,13 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Curve)& afirstcurve  ,
 //===========================================================================
 
 void Bisector_Bisec::Perform(const Handle(Geom2d_Point)& afirstpoint  ,
-                            const Handle(Geom2d_Curve)& asecondcurve ,
-                            const gp_Pnt2d&             apoint       ,
-                            const gp_Vec2d&             afirstvector ,
-                            const gp_Vec2d&             asecondvector,
-                            const Standard_Real         adirection   ,
-                            const Standard_Real         tolerance    ,
-                            const Standard_Boolean      oncurve       )
+  const Handle(Geom2d_Curve)& asecondcurve ,
+  const gp_Pnt2d&             apoint       ,
+  const gp_Vec2d&             afirstvector ,
+  const gp_Vec2d&             asecondvector,
+  const Standard_Real         adirection   ,
+  const Standard_Real         tolerance    ,
+  const Standard_Boolean      oncurve       )
 
 {  
   //gp_Pnt2d FirstPnt = afirstpoint->Pnt2d();
@@ -358,38 +441,38 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Point)& afirstpoint  ,
   Handle(Bisector_Curve) Bis;
   Handle(Standard_Type)  Type1 = asecondcurve ->DynamicType();
   Standard_Real          UFirst,ULast;
-  
+
   if (Type1 == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
     Type1 = Handle(Geom2d_TrimmedCurve)::DownCast(asecondcurve)
-            ->BasisCurve()->DynamicType();
+      ->BasisCurve()->DynamicType();
   }
-  
+
   if ( Type1 == STANDARD_TYPE(Geom2d_Circle) || Type1 == STANDARD_TYPE(Geom2d_Line)) {
     //------------------------------------------------------------------
     // Analytic Bissectrice.
     //------------------------------------------------------------------
     Handle(Bisector_BisecAna) BisAna = new Bisector_BisecAna();
     BisAna -> Perform (afirstpoint   ,
-                      asecondcurve  ,
-                      apoint        ,
-                      afirstvector  ,
-                      asecondvector ,
-                      adirection    ,
-                      tolerance     ,
-                      oncurve       );
+      asecondcurve  ,
+      apoint        ,
+      afirstvector  ,
+      asecondvector ,
+      adirection    ,
+      tolerance     ,
+      oncurve       );
     UFirst = BisAna->ParameterOfStartPoint();
     ULast  = BisAna->ParameterOfEndPoint();
     Bis    = BisAna;
   }
   else {   
-//  Standard_Real    UPoint    = 0.;
+    //  Standard_Real    UPoint    = 0.;
     Standard_Boolean IsLine    = Standard_False;
     Standard_Real    RC        = Precision::Infinite();
-    
+
     if (oncurve) {
       if (Bisector::IsConvex(asecondcurve, adirection) || 
-         IsMaxRC(asecondcurve,asecondcurve->FirstParameter(),RC)) {
-       IsLine = Standard_True;
+        IsMaxRC(asecondcurve,asecondcurve->FirstParameter(),RC)) {
+          IsLine = Standard_True;
       }
     }    
     if (IsLine) {     
@@ -411,62 +494,69 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Point)& afirstpoint  ,
       //-------------------------------------------------------------------
       Handle(Bisector_BisecPC) BisPC = new Bisector_BisecPC();
       BisPC -> Perform(asecondcurve        ,
-                      afirstpoint->Pnt2d(),
-                      adirection          );
-//  Modified by Sergey KHROMOV - Thu Feb 21 16:49:54 2002 Begin
+        afirstpoint->Pnt2d(),
+        adirection          );
+      //  Modified by Sergey KHROMOV - Thu Feb 21 16:49:54 2002 Begin
       if (BisPC -> IsEmpty()) {
-       gp_Dir2d dir1(afirstvector), dir2(asecondvector);
-       Standard_Real
-         Nx = - dir1.X() - dir2.X(),
-         Ny = - dir1.Y() - dir2.Y();
-       if (Abs(Nx) <= gp::Resolution() && Abs(Ny) <= gp::Resolution()) {
-         Nx = - afirstvector.Y();
-         Ny = afirstvector.X();
-       }
-//     gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
-       gp_Dir2d N ( adirection*Nx, adirection*Ny);
-       Handle (Geom2d_Line)         L      = new Geom2d_Line (apoint,N);
-       Handle (Geom2d_TrimmedCurve) BisL   = new Geom2d_TrimmedCurve(L,0,RC);
-       Handle(Bisector_BisecAna)    BisAna = new Bisector_BisecAna ();
-       BisAna->Init(BisL);
-       UFirst = BisAna->ParameterOfStartPoint();
-       ULast  = BisAna->ParameterOfEndPoint();
-       Bis    = BisAna;
+        gp_Dir2d dir1(afirstvector), dir2(asecondvector);
+        Standard_Real
+          Nx = - dir1.X() - dir2.X(),
+          Ny = - dir1.Y() - dir2.Y();
+        if (Abs(Nx) <= gp::Resolution() && Abs(Ny) <= gp::Resolution()) {
+          Nx = - afirstvector.Y();
+          Ny = afirstvector.X();
+        }
+        //     gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
+        gp_Dir2d N ( adirection*Nx, adirection*Ny);
+        Handle (Geom2d_Line)         L      = new Geom2d_Line (apoint,N);
+        Handle (Geom2d_TrimmedCurve) BisL   = new Geom2d_TrimmedCurve(L,0,RC);
+        Handle(Bisector_BisecAna)    BisAna = new Bisector_BisecAna ();
+        BisAna->Init(BisL);
+        UFirst = BisAna->ParameterOfStartPoint();
+        ULast  = BisAna->ParameterOfEndPoint();
+        Bis    = BisAna;
       } else {
-//  Modified by Sergey KHROMOV - Thu Feb 21 16:49:58 2002 End
-       UFirst = BisPC->Parameter(apoint);
-       ULast  = BisPC->LastParameter();
-       if(UFirst >= ULast)
-         {
-           //Extrapolate by line
-           //gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
-           gp_Vec2d V( BisPC->Value(BisPC->FirstParameter()), BisPC->Value(ULast) );
-           gp_Dir2d N( V );
-           Handle (Geom2d_Line)         L      = new Geom2d_Line         (apoint,N);
-           Handle (Geom2d_TrimmedCurve) BisL   = new Geom2d_TrimmedCurve (L,0,RC);
-           Handle(Bisector_BisecAna)    BisAna = new Bisector_BisecAna   ();
-           BisAna->Init(BisL);
-           UFirst = BisAna->ParameterOfStartPoint();
-           ULast  = BisAna->ParameterOfEndPoint();
-           Bis    = BisAna;
-         }
-       else
-         Bis    = BisPC;
+        //  Modified by Sergey KHROMOV - Thu Feb 21 16:49:58 2002 End
+        UFirst = BisPC->Parameter(apoint);
+        ULast  = BisPC->LastParameter();
+        if(UFirst >= ULast)
+        {
+          //Extrapolate by line
+          //gp_Dir2d N ( -adirection*afirstvector.Y(), adirection*afirstvector.X());
+          gp_Vec2d V( BisPC->Value(BisPC->FirstParameter()), BisPC->Value(ULast) );
+          gp_Dir2d N( V );
+          Handle (Geom2d_Line)         L      = new Geom2d_Line         (apoint,N);
+          Handle (Geom2d_TrimmedCurve) BisL   = new Geom2d_TrimmedCurve (L,0,RC);
+          Handle(Bisector_BisecAna)    BisAna = new Bisector_BisecAna   ();
+          BisAna->Init(BisL);
+          UFirst = BisAna->ParameterOfStartPoint();
+          ULast  = BisAna->ParameterOfEndPoint();
+          Bis    = BisAna;
+        }
+        else
+          Bis    = BisPC;
       }
     }
   }
+  UFirst = Max(UFirst, Bis->FirstParameter());
+  ULast = Min(ULast, Bis->LastParameter());
   thebisector = new Geom2d_TrimmedCurve(Bis,UFirst,ULast);
 
-/*
+#ifdef DRAW
+  if(Affich)
+  {
   sprintf( name, "c1_%d", ++nbb );
-  DrawTrSurf::Set( name, FirstPnt );
+  DrawTrSurf::Set( name, afirstpoint->Pnt2d() );
   sprintf( name, "c2_%d", nbb );
   DrawTrSurf::Set( name, asecondcurve );
   sprintf( name, "p%d", nbb );
   DrawTrSurf::Set( name, apoint );
   sprintf( name, "b%d", nbb );
   DrawTrSurf::Set( name, thebisector );
-*/
+  }
+#endif
+
 }
 
 //===========================================================================
@@ -481,29 +571,31 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Point)& afirstpoint  ,
 //===========================================================================
 
 void Bisector_Bisec::Perform(const Handle(Geom2d_Point)& afirstpoint  ,
-                            const Handle(Geom2d_Point)& asecondpoint ,
-                            const gp_Pnt2d&             apoint       ,
-                            const gp_Vec2d&             afirstvector ,
-                            const gp_Vec2d&             asecondvector,
-                            const Standard_Real         adirection   ,
-                            const Standard_Real         tolerance    ,
-                            const Standard_Boolean      oncurve      )
+  const Handle(Geom2d_Point)& asecondpoint ,
+  const gp_Pnt2d&             apoint       ,
+  const gp_Vec2d&             afirstvector ,
+  const gp_Vec2d&             asecondvector,
+  const Standard_Real         adirection   ,
+  const Standard_Real         tolerance    ,
+  const Standard_Boolean      oncurve      )
 {
   Handle(Bisector_BisecAna) Bis = new Bisector_BisecAna();
 
   Bis -> Perform (afirstpoint   ,
-                 asecondpoint  ,
-                 apoint        ,
-                 afirstvector  ,
-                 asecondvector ,
-                 adirection    ,
-                 tolerance     ,
-                 oncurve       ); 
+    asecondpoint  ,
+    apoint        ,
+    afirstvector  ,
+    asecondvector ,
+    adirection    ,
+    tolerance     ,
+    oncurve       ); 
   thebisector = new Geom2d_TrimmedCurve(Bis,
-                                       Bis->ParameterOfStartPoint(),
-                                       Bis->ParameterOfEndPoint());
+    Bis->ParameterOfStartPoint(),
+    Bis->ParameterOfEndPoint());
 
-/*
+#ifdef DRAW
+  if(Affich)
+  {
   sprintf( name, "c1_%d", ++nbb );
   DrawTrSurf::Set( name, afirstpoint->Pnt2d() );
   sprintf( name, "c2_%d", nbb );
@@ -512,7 +604,8 @@ void Bisector_Bisec::Perform(const Handle(Geom2d_Point)& afirstpoint  ,
   DrawTrSurf::Set( name, apoint );
   sprintf( name, "b%d", nbb );
   DrawTrSurf::Set( name, thebisector );
-*/
+  }
+#endif
 }
 
 //=============================================================================
@@ -539,8 +632,8 @@ const Handle(Geom2d_TrimmedCurve)&  Bisector_Bisec::ChangeValue()
 //           replaced by a half-straight.
 //=============================================================================
 static void ReplaceByLineIfIsToSmall (Handle(Geom2d_Curve)& Bis,
-                                     Standard_Real&        UFirst,
-                                     Standard_Real&        ULast )
+  Standard_Real&        UFirst,
+  Standard_Real&        ULast )
 
 {
   if (Abs(ULast - UFirst) > 2.*Precision::PConfusion()*10.) return; //patch
@@ -568,8 +661,8 @@ static void ReplaceByLineIfIsToSmall (Handle(Geom2d_Curve)& Bis,
 //purpose  :
 //=============================================================================
 static Standard_Boolean  IsMaxRC (const Handle(Geom2d_Curve)& C,
-                                       Standard_Real         U,
-                                       Standard_Real&        R)
+  Standard_Real         U,
+  Standard_Real&        R)
 {  
   Standard_Real KF,KL;
   Standard_Real US = C->FirstParameter();
@@ -583,7 +676,7 @@ static Standard_Boolean  IsMaxRC (const Handle(Geom2d_Curve)& C,
   Norm2 = D1.SquareMagnitude();;
   if (Norm2 < gp::Resolution()) { KF = 0.0;}
   else                          { KF = Abs(D1^D2)/(Norm2*sqrt(Norm2));}
-  
+
   C->D2(UL,P,D1,D2);
   Norm2 = D1.SquareMagnitude();;
   if (Norm2 < gp::Resolution()) { KL = 0.0;}
index ce9c28b..165d4c5 100644 (file)
 
 
 static Standard_Boolean ProjOnCurve (const gp_Pnt2d& P,
-                                     const Handle(Geom2d_Curve)& C,
-                                     Standard_Real& theParam);
+  const Handle(Geom2d_Curve)& C,
+  Standard_Real& theParam);
 
 static Standard_Real    Curvature (const Handle(Geom2d_Curve)& C,
-                                        Standard_Real         U,
-                                        Standard_Real         Tol) ;
+  Standard_Real         U,
+  Standard_Real         Tol) ;
 
 static Standard_Boolean TestExtension (const Handle(Geom2d_Curve)& C1,
-                                      const Handle(Geom2d_Curve)& C2,
-                                      const Standard_Integer      Start_End);
+  const Handle(Geom2d_Curve)& C2,
+  const Standard_Integer      Start_End);
 
 static Standard_Boolean DiscretPar(const Standard_Real     DU, 
-                                  const Standard_Real     EpsMin, 
-                                  const Standard_Real     EpsMax,
-                                  const Standard_Integer  NbMin,
-                                  const Standard_Integer  NbMax,
-                                        Standard_Real&    Eps,
-                                        Standard_Integer& Nb);
+  const Standard_Real     EpsMin, 
+  const Standard_Real     EpsMax,
+  const Standard_Integer  NbMin,
+  const Standard_Integer  NbMax,
+  Standard_Real&    Eps,
+  Standard_Integer& Nb);
 
 //=============================================================================
 //function :
@@ -80,11 +80,11 @@ Bisector_BisecCC::Bisector_BisecCC()
 //purpose  :
 //=============================================================================
 Bisector_BisecCC::Bisector_BisecCC(const Handle(Geom2d_Curve)& Cu1,
-                                  const Handle(Geom2d_Curve)& Cu2,
-                                  const Standard_Real         Side1,
-                                  const Standard_Real         Side2,
-                                  const gp_Pnt2d&             Origin,
-                                  const Standard_Real         DistMax)
+  const Handle(Geom2d_Curve)& Cu2,
+  const Standard_Real         Side1,
+  const Standard_Real         Side2,
+  const gp_Pnt2d&             Origin,
+  const Standard_Real         DistMax)
 {
   Perform (Cu1,Cu2,Side1,Side2,Origin,DistMax);
 }
@@ -94,11 +94,11 @@ Bisector_BisecCC::Bisector_BisecCC(const Handle(Geom2d_Curve)& Cu1,
 //purpose  :
 //=============================================================================
 void  Bisector_BisecCC::Perform(const Handle(Geom2d_Curve)& Cu1,
-                               const Handle(Geom2d_Curve)& Cu2,
-                               const Standard_Real         Side1,
-                               const Standard_Real         Side2,
-                               const gp_Pnt2d&             Origin,                             
-                               const Standard_Real         DistMax)
+  const Handle(Geom2d_Curve)& Cu2,
+  const Standard_Real         Side1,
+  const Standard_Real         Side2,
+  const gp_Pnt2d&             Origin,                          
+  const Standard_Real         DistMax)
 {
   isEmpty = Standard_False;
   distMax = DistMax;
@@ -122,7 +122,6 @@ void  Bisector_BisecCC::Perform(const Handle(Geom2d_Curve)& Cu1,
   // Calculate first point of the polygon.
   //---------------------------------------------
   Standard_Boolean isProjDone = ProjOnCurve (Origin,curve1, U);
-  P                           = ValueByInt  (U,UC1,UC2,Dist);
 
   if(!isProjDone)
   {
@@ -130,6 +129,20 @@ void  Bisector_BisecCC::Perform(const Handle(Geom2d_Curve)& Cu1,
     return;
   }
 
+  P = ValueByInt  (U,UC1,UC2,Dist);
+  if(Dist < Precision::Confusion())
+  {
+    gp_Pnt2d aP1 = curve1->Value(UC1);
+    gp_Pnt2d aP2 = curve2->Value(UC2);
+    Standard_Real dp = (aP1.Distance(P)+aP2.Distance(P));
+    Standard_Real dorig = (aP1.Distance(Origin)+aP2.Distance(Origin));
+    if(dp < dorig)
+    {
+      isEmpty = Standard_True;
+      return;
+    }
+  }
+
   if (Dist < Precision::Infinite()) {
     //----------------------------------------------------
     // the parameter of the origin point gives a point 
@@ -363,11 +376,11 @@ Handle(Geom2d_Geometry) Bisector_BisecCC::Copy() const
 Handle(Bisector_BisecCC) Bisector_BisecCC::ChangeGuide() const
 {
   Handle(Bisector_BisecCC) C = new Bisector_BisecCC();
-  
+
   C -> Curve    (1, curve2)   ; C -> Curve    (2, curve1);
   C -> Sign     (1, sign2 )   ; C -> Sign     (2, sign1 );
   C -> IsConvex (1, isConvex2); C -> IsConvex (2, isConvex1); 
-  
+
   //-------------------------------------------------------------------------
   // Construction of the new polygon from the initial one.
   // inversion of PointOnBis and Calculation of new parameters on the bissectrice.
@@ -380,8 +393,8 @@ Handle(Bisector_BisecCC) Bisector_BisecCC::ChangeGuide() const
     for (Standard_Integer i = myPolygon.Length(); i >=1; i--) {
       Bisector_PointOnBis P = myPolygon.Value(i);
       Bisector_PointOnBis NewP (P.ParamOnC2(), P.ParamOnC1(), 
-                               P.ParamOnC2(), P.Distance (),
-                               P.Point());
+        P.ParamOnC2(), P.Distance (),
+        P.Point());
       Poly.Append (NewP);
     }
   }
@@ -389,15 +402,15 @@ Handle(Bisector_BisecCC) Bisector_BisecCC::ChangeGuide() const
     for (Standard_Integer i = 1; i <= myPolygon.Length(); i ++) {      
       Bisector_PointOnBis P = myPolygon.Value(i);
       Bisector_PointOnBis NewP (P.ParamOnC2(), P.ParamOnC1(), 
-                               P.ParamOnC2(), P.Distance (),
-                               P.Point());
+        P.ParamOnC2(), P.Distance (),
+        P.Point());
       Poly.Append (NewP);
     }
   }
   C -> Polygon        (Poly);
   C -> FirstParameter (Poly.First().ParamOnBis());
   C -> LastParameter  (Poly.Last() .ParamOnBis());
-  
+
   return C;  
 }
 
@@ -429,7 +442,7 @@ Standard_Boolean Bisector_BisecCC::IsCN (const Standard_Integer N) const
 //=============================================================================
 Standard_Real Bisector_BisecCC::FirstParameter() const
 {
- return startIntervals.First();
+  return startIntervals.First();
 }
 
 //=============================================================================
@@ -438,7 +451,7 @@ Standard_Real Bisector_BisecCC::FirstParameter() const
 //=============================================================================
 Standard_Real Bisector_BisecCC::LastParameter() const
 {
- return endIntervals.Last();
+  return endIntervals.Last();
 }
 
 //=============================================================================
@@ -475,7 +488,7 @@ Standard_Real Bisector_BisecCC::IntervalFirst(const Standard_Integer Index) cons
 {
   return startIntervals.Value(Index);
 }
-    
+
 //=============================================================================
 //function : IntervalLast
 //purpose  :
@@ -510,7 +523,7 @@ Standard_Boolean Bisector_BisecCC::IsClosed() const
 {
   if (curve1->IsClosed()) {
     if (startIntervals.First() == curve1->FirstParameter() &&
-       endIntervals  .Last () == curve1->LastParameter ()    )
+      endIntervals  .Last () == curve1->LastParameter ()    )
       return Standard_True;
   }
   return Standard_False;
@@ -531,8 +544,8 @@ Standard_Boolean Bisector_BisecCC::IsPeriodic() const
 //purpose  :
 //=============================================================================
 static Standard_Real Curvature (const Handle(Geom2d_Curve)& C,
-                                     Standard_Real         U,
-                                     Standard_Real         Tol)
+  Standard_Real         U,
+  Standard_Real         Tol)
 {
   Standard_Real K1; 
   gp_Vec2d      D1,D2;
@@ -569,9 +582,9 @@ static Standard_Real Curvature (const Handle(Geom2d_Curve)& C,
 //
 //=============================================================================
 gp_Pnt2d Bisector_BisecCC::ValueAndDist (const Standard_Real  U,
-                                              Standard_Real& U1,
-                                              Standard_Real& U2,
-                                              Standard_Real& Dist) const
+  Standard_Real& U1,
+  Standard_Real& U2,
+  Standard_Real& Dist) const
 {      
   gp_Vec2d T;  
 
@@ -619,11 +632,11 @@ gp_Pnt2d Bisector_BisecCC::ValueAndDist (const Standard_Real  U,
   //---------------------------------------------------------------
   gp_Pnt2d P1;
   gp_Vec2d T1;
-  Standard_Real    EpsH     = 1.E-8;
-  Standard_Real    EpsH100  = 1.E-6; 
+  Standard_Real    EpsH     = 1.E-9;
+  Standard_Real    EpsH100  = 1.E-7; 
   curve1->D1 (U1,P1,T1);
   gp_Vec2d N1(T1.Y(), - T1.X());
-  
+
   if ((VMax - VMin) < Precision::PConfusion()) {
     U2 = VInit;
   }
@@ -637,14 +650,14 @@ gp_Pnt2d Bisector_BisecCC::ValueAndDist (const Standard_Real  U,
     else {
       math_BissecNewton  SolNew (H,VMin - EpsH100,VMax + EpsH100,EpsH,10);
       if (SolNew.IsDone()) {
-       U2    = SolNew.Root();
+        U2    = SolNew.Root();
       }
       else {
-       math_FunctionRoot SolRoot (H,VInit,EpsH,VMin - EpsH100,VMax + EpsH100);
-       if (SolRoot.IsDone()) {
-         U2    = SolRoot.Root();
-       }
-       else { Valid = Standard_False;}
+        math_FunctionRoot SolRoot (H,VInit,EpsH,VMin - EpsH100,VMax + EpsH100);
+        if (SolRoot.IsDone()) {
+          U2    = SolRoot.Root();
+        }
+        else { Valid = Standard_False;}
       }
     }
   }
@@ -667,8 +680,8 @@ gp_Pnt2d Bisector_BisecCC::ValueAndDist (const Standard_Real  U,
       Valid = Standard_False;
     }
     else {     
-       PBis = P1.Translated(- (0.5*SquareP2P1/N1P2P1)*N1);
-       Dist = P1.SquareDistance(PBis);
+      PBis = P1.Translated(- (0.5*SquareP2P1/N1P2P1)*N1);
+      Dist = P1.SquareDistance(PBis);
     }
   }
 
@@ -691,20 +704,20 @@ gp_Pnt2d Bisector_BisecCC::ValueAndDist (const Standard_Real  U,
     Geom2dAdaptor_Curve ANorLi(NorLi);    
     //-------------------------------------------------------------------------
     Geom2dInt_GInter  Intersect(ABisPC,ANorLi,
-                               Precision::Confusion(),Precision::Confusion());
+      Precision::Confusion(),Precision::Confusion());
     //-------------------------------------------------------------------------
 
     if (Intersect.IsDone() && !Intersect.IsEmpty()) {
       for (Standard_Integer i = 1; i <= Intersect.NbPoints(); i++) {
-       if (Intersect.Point(i).ParamOnSecond()*sign1 < Precision::PConfusion()) {
-         P  = Intersect.Point(i).Value();
-         if (P.SquareDistance(P1) < DMin) {
-           DMin = P.SquareDistance(P1);
-           PBis = P;
-           U2   = BisPC->LinkBisCurve(Intersect.Point(i).ParamOnFirst());
-           Dist = DMin;
-         }
-       }
+        if (Intersect.Point(i).ParamOnSecond()*sign1 < Precision::PConfusion()) {
+          P  = Intersect.Point(i).Value();
+          if (P.SquareDistance(P1) < DMin) {
+            DMin = P.SquareDistance(P1);
+            PBis = P;
+            U2   = BisPC->LinkBisCurve(Intersect.Point(i).ParamOnFirst());
+            Dist = DMin;
+          }
+        }
       }
     }
   } 
@@ -725,9 +738,9 @@ gp_Pnt2d Bisector_BisecCC::ValueAndDist (const Standard_Real  U,
 //           normal at this point.
 //=============================================================================
 gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real  U,
-                                            Standard_Real& U1,
-                                            Standard_Real& U2,
-                                            Standard_Real& Dist) const
+  Standard_Real& U1,
+  Standard_Real& U2,
+  Standard_Real& Dist) const
 {
   //------------------------------------------------------------------
   // Return point, tangent, normal on C1 at parameter U.
@@ -738,7 +751,7 @@ gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real  U,
   gp_Vec2d Tan1,Tan2;
   curve1->D1(U1,P1,Tan1);
   gp_Vec2d N1(  Tan1.Y(), - Tan1.X());
+
   //--------------------------------------------------------------------------
   // test confusion of P1 with extremity of curve2.
   //--------------------------------------------------------------------------
@@ -777,7 +790,7 @@ gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real  U,
   Standard_Integer NbSamples =20;
   Standard_Real    UFirstOnC2 = curve2->FirstParameter();
   Standard_Real    ULastOnC2  = curve2->LastParameter();
-  
+
   if (!myPolygon.IsEmpty()){
     if (sign1 == sign2) { ULastOnC2  = myPolygon.Last().ParamOnC2();}
     else                { UFirstOnC2 = myPolygon.Last().ParamOnC2();} 
@@ -792,10 +805,10 @@ gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real  U,
 
   Bisector_FunctionH H  (curve2,P1,sign1*sign2*Tan1);
   math_FunctionRoots SolRoot (H,
-                             UFirstOnC2,
-                             ULastOnC2 ,
-                             NbSamples,
-                             EpsX,EpsH,EpsH);
+    UFirstOnC2,
+    ULastOnC2 ,
+    NbSamples,
+    EpsX,EpsH,EpsH);
   if (SolRoot.IsDone()) {
     for (Standard_Integer j = 1; j <= SolRoot.NbSolutions(); j++) {
       USol        = SolRoot.Value(j);
@@ -806,60 +819,60 @@ gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real  U,
 
       // Test if the solution is at the proper side of the curves.
       if (N1P2P1*sign1 > 0 ) {
-       P       = P1.Translated(- (0.5*SquareP2P1/N1P2P1)*N1);
-       DistPP1 = P1.SquareDistance(P);
-       if (DistPP1  < DMin) {
-         DMin  = DistPP1;
-         PSol  = P;
-         U2    = USol;
-         YaSol = Standard_True;
-       }
+        P       = P1.Translated(- (0.5*SquareP2P1/N1P2P1)*N1);
+        DistPP1 = P1.SquareDistance(P);
+        if (DistPP1  < DMin) {
+          DMin  = DistPP1;
+          PSol  = P;
+          U2    = USol;
+          YaSol = Standard_True;
+        }
       }
     }
   }
 
-/*
+  /*
   if (!YaSol) {
-    //--------------------------------------------------------------------
-    // Construction de la bisectrice point courbe et de la droite passant
-    // par P1 et portee par la normale.
-    //--------------------------------------------------------------------
-    Handle(Bisector_BisecPC) BisPC 
-      = new Bisector_BisecPC(curve2,P1,sign2,2*distMax);
-    //-------------------------------
-    // Test si la bissectrice existe.
-    //-------------------------------
-    if (BisPC->IsEmpty()) {
-      Dist = Precision::Infinite();
-      PSol = P1;
-      return PSol;
-    }
-    
-    Handle(Geom2d_Line)      NorLi  = new Geom2d_Line (P1,N1);
-    Geom2dAdaptor_Curve      NorLiAd;
-    if (sign1 < 0.) {NorLiAd.Load(NorLi,0.       ,distMax);}
-    else            {NorLiAd.Load(NorLi,- distMax,0.     );}
+  //--------------------------------------------------------------------
+  // Construction de la bisectrice point courbe et de la droite passant
+  // par P1 et portee par la normale.
+  //--------------------------------------------------------------------
+  Handle(Bisector_BisecPC) BisPC 
+  = new Bisector_BisecPC(curve2,P1,sign2,2*distMax);
+  //-------------------------------
+  // Test si la bissectrice existe.
+  //-------------------------------
+  if (BisPC->IsEmpty()) {
+  Dist = Precision::Infinite();
+  PSol = P1;
+  return PSol;
+  }
 
-    //-------------------------------------------------------------------------
-    Geom2dInt_GInter  Intersect(BisPC,NorLiAd,
-                               Precision::Confusion(),Precision::Confusion());
-    //-------------------------------------------------------------------------
-    if (Intersect.IsDone() && !Intersect.IsEmpty()) {
-      for (Standard_Integer i = 1; i <= Intersect.NbPoints(); i++) {
-       if (Intersect.Point(i).ParamOnSecond()*sign1< Precision::PConfusion()) {
-         P       = Intersect.Point(i).Value();
-         DistPP1 = P.SquareDistance(P1);
-         if (DistPP1  < DMin) {
-           DMin  = DistPP1;
-           PSol  = P;
-           U2   = Intersect.Point(i).ParamOnFirst();
-           YaSol = Standard_True;
-         }
-       }
-      }
-    }
+  Handle(Geom2d_Line)      NorLi  = new Geom2d_Line (P1,N1);
+  Geom2dAdaptor_Curve      NorLiAd;
+  if (sign1 < 0.) {NorLiAd.Load(NorLi,0.       ,distMax);}
+  else            {NorLiAd.Load(NorLi,- distMax,0.     );}
+
+  //-------------------------------------------------------------------------
+  Geom2dInt_GInter  Intersect(BisPC,NorLiAd,
+  Precision::Confusion(),Precision::Confusion());
+  //-------------------------------------------------------------------------
+  if (Intersect.IsDone() && !Intersect.IsEmpty()) {
+  for (Standard_Integer i = 1; i <= Intersect.NbPoints(); i++) {
+  if (Intersect.Point(i).ParamOnSecond()*sign1< Precision::PConfusion()) {
+  P       = Intersect.Point(i).Value();
+  DistPP1 = P.SquareDistance(P1);
+  if (DistPP1  < DMin) {
+  DMin  = DistPP1;
+  PSol  = P;
+  U2   = Intersect.Point(i).ParamOnFirst();
+  YaSol = Standard_True;
+  }
+  }
   }
-*/
+  }
+  }
+  */
 
   if (YaSol) {
     Dist = DMin;
@@ -869,7 +882,7 @@ gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real  U,
     P2 = curve2->Value(U2);
     gp_Vec2d PP1(P1.X() - PSol.X(),P1.Y() - PSol.Y());
     gp_Vec2d PP2(P2.X() - PSol.X(),P2.Y() - PSol.Y());
+
     //-----------------------------------------------
     // Dist = product of norms = distance at the square.
     //-----------------------------------------------
@@ -878,18 +891,18 @@ gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real  U,
     }
     else {
       if ( !isConvex1 ) {
-       Standard_Real K1 = Curvature(curve1,U1,Precision::Confusion());
-       if (K1 != 0.) {
-         if (Dist > 1/(K1*K1)) YaSol = Standard_False;
-       }
+        Standard_Real K1 = Curvature(curve1,U1,Precision::Confusion());
+        if (K1 != 0.) {
+          if (Dist > 1/(K1*K1)) YaSol = Standard_False;
+        }
       }
       if (YaSol) {
-       if ( !isConvex2 ) {
-         Standard_Real K2 = Curvature(curve2,U2,Precision::Confusion());
-         if (K2 != 0.) {
-           if (Dist > 1/(K2*K2)) YaSol = Standard_False;
-         }
-       }
+        if ( !isConvex2 ) {
+          Standard_Real K2 = Curvature(curve2,U2,Precision::Confusion());
+          if (K2 != 0.) {
+            if (Dist > 1/(K2*K2)) YaSol = Standard_False;
+          }
+        }
       }
     }
   }
@@ -905,7 +918,7 @@ gp_Pnt2d Bisector_BisecCC::ValueByInt (const Standard_Real  U,
 //purpose : 
 //=============================================================================
 void Bisector_BisecCC::D0(const Standard_Real     U,
-                               gp_Pnt2d&         P) const
+  gp_Pnt2d&         P) const
 {
   Standard_Real U1,U2,Dist;
 
@@ -917,8 +930,8 @@ void Bisector_BisecCC::D0(const Standard_Real     U,
 //purpose : 
 //=============================================================================
 void Bisector_BisecCC::D1(const Standard_Real     U,
-                               gp_Pnt2d&         P,
-                               gp_Vec2d&         V ) const
+  gp_Pnt2d&         P,
+  gp_Vec2d&         V ) const
 {
   V.SetCoord(0.,0.);
   gp_Vec2d V2,V3;
@@ -930,9 +943,9 @@ void Bisector_BisecCC::D1(const Standard_Real     U,
 //purpose : 
 //=============================================================================
 void Bisector_BisecCC::D2(const Standard_Real     U,
-                               gp_Pnt2d&         P,
-                               gp_Vec2d&         V1,
-                               gp_Vec2d&         V2) const
+  gp_Pnt2d&         P,
+  gp_Vec2d&         V1,
+  gp_Vec2d&         V2) const
 {
   V1.SetCoord(0.,0.);
   V2.SetCoord(0.,0.);
@@ -945,10 +958,10 @@ void Bisector_BisecCC::D2(const Standard_Real     U,
 //purpose : 
 //=============================================================================
 void Bisector_BisecCC::D3(const Standard_Real     U,
-                               gp_Pnt2d&         P,
-                               gp_Vec2d&         V1,
-                               gp_Vec2d&         V2,
-                               gp_Vec2d&         V3) const
+  gp_Pnt2d&         P,
+  gp_Vec2d&         V1,
+  gp_Vec2d&         V2,
+  gp_Vec2d&         V3) const
 {
   V1.SetCoord(0.,0.);
   V2.SetCoord(0.,0.);
@@ -961,7 +974,7 @@ void Bisector_BisecCC::D3(const Standard_Real     U,
 //purpose : 
 //=============================================================================
 gp_Vec2d Bisector_BisecCC::DN(const Standard_Real    U,
-                             const Standard_Integer N) const
+  const Standard_Integer N) const
 {
   gp_Pnt2d P;
   gp_Vec2d V1(0.,0.);
@@ -969,12 +982,12 @@ gp_Vec2d Bisector_BisecCC::DN(const Standard_Real    U,
   gp_Vec2d V3(0.,0.);
   Values (U,N,P,V1,V2,V3);
   switch (N) {
-    case 1 : return V1;
-    case 2 : return V2;
-    case 3 : return V3;
-    default: {
-      Standard_NotImplemented::Raise();
-    }
+  case 1 : return V1;
+  case 2 : return V2;
+  case 3 : return V3;
+  default: {
+    Standard_NotImplemented::Raise();
+           }
   }
   return V1;
 }
@@ -1000,11 +1013,11 @@ gp_Vec2d Bisector_BisecCC::DN(const Standard_Real    U,
 //
 //=============================================================================
 void  Bisector_BisecCC::Values (const Standard_Real     U,
-                               const Standard_Integer  N,
-                                     gp_Pnt2d&         P,
-                                     gp_Vec2d&         V1,
-                                     gp_Vec2d&         V2,
-                                     gp_Vec2d&         V3) const
+  const Standard_Integer  N,
+  gp_Pnt2d&         P,
+  gp_Vec2d&         V1,
+  gp_Vec2d&         V2,
+  gp_Vec2d&         V3) const
 {
   V1 = gp_Vec2d(0.,0.);
   V2 = gp_Vec2d(0.,0.);
@@ -1014,7 +1027,7 @@ void  Bisector_BisecCC::Values (const Standard_Real     U,
   // curve.
   //-------------------------------------------------------------------------
   Standard_Real U0,V0,Dist;  
-  
+
   //-----------------------------------------------
   // is the polygon reduced to a point or empty?
   //-----------------------------------------------
@@ -1066,16 +1079,16 @@ void  Bisector_BisecCC::Values (const Standard_Real     U,
   TvvPuPv = Tvv.Dot(PuPv) ; TvTvv  = Tv.Dot(Tvv) ;
 
   Standard_Real dHdu = 2*(TuPuPv*(TuuPuPv - TuTu)*TvTv +
-                         TvPuPv*TuTv*TuTu  -TuTuu*TvPuPv*TvPuPv);
+    TvPuPv*TuTv*TuTu  -TuTuu*TvPuPv*TvPuPv);
   Standard_Real dHdv = 2*(TuPuPv*TuTv*TvTv + TvTvv*TuPuPv*TuPuPv -
-                         TvPuPv*(TvvPuPv + TvTv)*TuTu);
+    TvPuPv*(TvvPuPv + TvTv)*TuTu);
 
   //-----------------------------
   // Calculate dF/du and dF/dv.
   //-----------------------------
   Standard_Real NorPuPv,NuPuPv,NorTv;
   Standard_Real A,B,dAdu,dAdv,dBdu,dBdv,BB;
-  
+
   NorPuPv = Nor.Dot(PuPv); 
   NuPuPv  = Nu .Dot(PuPv);  
   NorTv   = Nor.Dot(Tv)  ;
@@ -1087,7 +1100,7 @@ void  Bisector_BisecCC::Values (const Standard_Real     U,
   dBdu = - NuPuPv ;
   dAdv = TvPuPv;
   dBdv = - NorTv;
-  
+
   //---------------------------------------
   // F(u,v) = Pu - (A(u,v)/B(u,v))*Nor(u)
   //----------------------------------------
@@ -1098,7 +1111,7 @@ void  Bisector_BisecCC::Values (const Standard_Real     U,
   else {
     gp_Vec2d dFdu = Tu - (dAdu/B - dBdu*A/BB)*Nor - (A/B)*Nu; 
     gp_Vec2d dFdv = ( - dAdv/B + dBdv*A/BB)*Nor ;
-    
+
     if (Abs(dHdv) > gp::Resolution()) {
       V1 = dFdu + dFdv*( - dHdu / dHdv );
     }
@@ -1115,10 +1128,10 @@ void  Bisector_BisecCC::Values (const Standard_Real     U,
 //           by tangence of the curve.
 //============================================================================
 gp_Pnt2d Bisector_BisecCC::Extension (const Standard_Real  U,
-                                           Standard_Real& U1,
-                                           Standard_Real& U2,
-                                           Standard_Real& Dist,
-                                           gp_Vec2d&      T   ) const
+  Standard_Real& U1,
+  Standard_Real& U2,
+  Standard_Real& Dist,
+  gp_Vec2d&      T   ) const
 {
   Bisector_PointOnBis PRef;
   gp_Pnt2d            P,P1,P2,PBis;
@@ -1189,7 +1202,7 @@ gp_Pnt2d Bisector_BisecCC::Extension (const Standard_Real  U,
     }
     if (T1.Dot(Tang) < 0.) Tang = - Tang;
   } 
-  
+
   T = Tang.Normalized();
   PBis.SetCoord(P.X() + dU*T.X(),P.Y() + dU*T.Y());        
   Dist = P1.Distance(PBis);
@@ -1201,12 +1214,12 @@ gp_Pnt2d Bisector_BisecCC::Extension (const Standard_Real  U,
 // purpose : 
 //=============================================================================
 static Standard_Boolean PointByInt(const Handle(Geom2d_Curve)& CA,
-                                  const Handle(Geom2d_Curve)& CB,
-                                  const Standard_Real         SignA,
-                                  const Standard_Real         SignB,
-                                  const Standard_Real         UOnA,
-                                        Standard_Real&        UOnB,
-                                        Standard_Real&        Dist)
+  const Handle(Geom2d_Curve)& CB,
+  const Standard_Real         SignA,
+  const Standard_Real         SignB,
+  const Standard_Real         UOnA,
+  Standard_Real&        UOnB,
+  Standard_Real&        Dist)
 {  
   //------------------------------------------------------------------
   // Return point,tangent, normal on CA with parameter UOnA.
@@ -1218,7 +1231,7 @@ static Standard_Boolean PointByInt(const Handle(Geom2d_Curve)& CA,
 
   CA->D1(UOnA,P1,Tan1);
   gp_Vec2d N1(Tan1.Y(), - Tan1.X());
+
   //--------------------------------------------------------------------------
   // test of confusion of P1 with extremity of curve2.
   //--------------------------------------------------------------------------
@@ -1250,7 +1263,7 @@ static Standard_Boolean PointByInt(const Handle(Geom2d_Curve)& CA,
   Standard_Real    DMin = Precision::Infinite();
   Standard_Real    UPC;
   Standard_Boolean YaSol = Standard_False; 
- //--------------------------------------------------------------------
+  //--------------------------------------------------------------------
   // Construction of the bisectrice point curve and of the straight line passing
   // through P1 and carried by the normal. 
   //--------------------------------------------------------------------
@@ -1271,21 +1284,21 @@ static Standard_Boolean PointByInt(const Handle(Geom2d_Curve)& CA,
   Geom2dAdaptor_Curve ANorLi(NorLi);    
   //-------------------------------------------------------------------------
   Geom2dInt_GInter  Intersect(ABisPC,ANorLi,
-                             Precision::Confusion(),Precision::Confusion());
+    Precision::Confusion(),Precision::Confusion());
   //-------------------------------------------------------------------------
 
   if (Intersect.IsDone() && !Intersect.IsEmpty()) {
     for (Standard_Integer i = 1; i <= Intersect.NbPoints(); i++) {
       if (Intersect.Point(i).ParamOnSecond()*SignA < Precision::PConfusion()) {
-       P  = Intersect.Point(i).Value();
-       if (P.SquareDistance(P1) < DMin) {
-         DMin  = P.SquareDistance(P1);
-         PSol  = P;
-         UPC   = Intersect.Point(i).ParamOnFirst();
-         UOnB  = BisPC->LinkBisCurve(UPC);
-         Dist  = DMin;
-         YaSol = Standard_True;
-       }
+        P  = Intersect.Point(i).Value();
+        if (P.SquareDistance(P1) < DMin) {
+          DMin  = P.SquareDistance(P1);
+          PSol  = P;
+          UPC   = Intersect.Point(i).ParamOnFirst();
+          UOnB  = BisPC->LinkBisCurve(UPC);
+          Dist  = DMin;
+          YaSol = Standard_True;
+        }
       }
     }
   }  
@@ -1294,27 +1307,38 @@ static Standard_Boolean PointByInt(const Handle(Geom2d_Curve)& CA,
     // Point found => Test distance curvature + Angular test 
     //---------------------------------------------------------------
     P2 = CB->Value(UOnB);
+    if(P1.SquareDistance(PSol) < 1.e-32)
+    {
+      YaSol = Standard_False;
+      return YaSol;
+    }
+    if(P2.SquareDistance(PSol) < 1.e-32)
+    {
+      YaSol = Standard_False;
+      return YaSol;
+    }
+
     gp_Dir2d PP1Unit(P1.X() - PSol.X(),P1.Y() - PSol.Y());
     gp_Dir2d PP2Unit(P2.X() - PSol.X(),P2.Y() - PSol.Y());
-     
+
     if (PP1Unit*PP2Unit > 1. - Precision::Angular()) {
       YaSol = Standard_False;
     }
     else {
       Dist = sqrt(Dist);
       if ( !IsConvexA ) {
-       Standard_Real K1 = Curvature(CA,UOnA,Precision::Confusion());
-       if (K1 != 0.) {
-         if (Dist > Abs(1/K1)) YaSol = Standard_False;
-       }
+        Standard_Real K1 = Curvature(CA,UOnA,Precision::Confusion());
+        if (K1 != 0.) {
+          if (Dist > Abs(1/K1)) YaSol = Standard_False;
+        }
       }
       if (YaSol) {
-       if ( !IsConvexB ) {
-         Standard_Real K2 = Curvature(CB,UOnB,Precision::Confusion());
-         if (K2 != 0.) {
-           if (Dist > Abs(1/K2)) YaSol = Standard_False;
-         }
-       }
+        if ( !IsConvexB ) {
+          Standard_Real K2 = Curvature(CB,UOnB,Precision::Confusion());
+          if (K2 != 0.) {
+            if (Dist > Abs(1/K2)) YaSol = Standard_False;
+          }
+        }
       }
     }
   }
@@ -1426,20 +1450,20 @@ Standard_Real Bisector_BisecCC::Parameter(const gp_Pnt2d& P) const
 //=============================================================================
 //void Bisector_BisecCC::Dump(const Standard_Integer Deep, 
 void Bisector_BisecCC::Dump(const Standard_Integer , 
-                           const Standard_Integer Offset) const 
+  const Standard_Integer Offset) const 
 {
   Indent (Offset);
   cout <<"Bisector_BisecCC :"<<endl;
   Indent (Offset);
-//  cout <<"Curve1 :"<<curve1<<endl;
-//  cout <<"Curve2 :"<<curve2<<endl;
+  //  cout <<"Curve1 :"<<curve1<<endl;
+  //  cout <<"Curve2 :"<<curve2<<endl;
   cout <<"Sign1  :"<<sign1<<endl;
   cout <<"Sign2  :"<<sign2<<endl;
 
   cout <<"Number Of Intervals :"<<startIntervals.Length()<<endl;
   for (Standard_Integer i = 1; i <= startIntervals.Length(); i++) {
     cout <<"Interval number :"<<i<<"Start :"<<startIntervals.Value(i)
-                                 <<"  end :"<<  endIntervals.Value(i)<<endl ;
+      <<"  end :"<<  endIntervals.Value(i)<<endl ;
   }
   cout <<"Index Current Interval :"<<currentInterval<<endl;
 }
@@ -1449,7 +1473,7 @@ void Bisector_BisecCC::Dump(const Standard_Integer ,
 // purpose : 
 //=============================================================================
 void Bisector_BisecCC::Curve(const Standard_Integer      I,
-                            const Handle(Geom2d_Curve)& C)  
+  const Handle(Geom2d_Curve)& C)  
 {
   if      (I == 1) curve1 = C;
   else if (I == 2) curve2 = C;
@@ -1461,7 +1485,7 @@ void Bisector_BisecCC::Curve(const Standard_Integer      I,
 // purpose : 
 //=============================================================================
 void Bisector_BisecCC::Sign(const Standard_Integer      I,
-                           const Standard_Real         S)
+  const Standard_Real         S)
 {
   if      (I == 1) sign1 = S;
   else if (I == 2) sign2 = S;
@@ -1491,7 +1515,7 @@ void Bisector_BisecCC::DistMax(const Standard_Real D)
 // purpose : 
 //=============================================================================
 void Bisector_BisecCC::IsConvex(const Standard_Integer     I,
-                               const Standard_Boolean     IsConvex)  
+  const Standard_Boolean     IsConvex)  
 {
   if      (I == 1) isConvex1 = IsConvex;
   else if (I == 2) isConvex2 = IsConvex;
@@ -1586,7 +1610,7 @@ void Bisector_BisecCC::LastParameter (const Standard_Real U)
 // purpose : 
 //=============================================================================
 Standard_Real Bisector_BisecCC::SearchBound (const Standard_Real U1,
-                                            const Standard_Real U2) const
+  const Standard_Real U2) const
 {
   Standard_Real UMid,Dist1,Dist2,DistMid,U11,U22;
   Standard_Real UC1,UC2;
@@ -1596,22 +1620,22 @@ Standard_Real Bisector_BisecCC::SearchBound (const Standard_Real U1,
   U11 = U1; U22 = U2;
   PBisPrec = ValueByInt(U11,UC1,UC2,Dist1);
   PBis     = ValueByInt(U22,UC1,UC2,Dist2);
-  
+
   while ((U22 - U11) > TolPar || 
-        ((Dist1 < Precision::Infinite() && 
-          Dist2 < Precision::Infinite() &&
-          !PBis.IsEqual(PBisPrec,TolPnt)))) { 
-    PBisPrec = PBis;
-    UMid     = 0.5*( U22 + U11);
-    PBis     = ValueByInt(UMid,UC1,UC2,DistMid);
-    if ((Dist1 < Precision::Infinite()) == (DistMid < Precision::Infinite())) {
-      U11    = UMid;
-      Dist1 = DistMid;
-    }
-    else {
-      U22    = UMid;
-      Dist2 = DistMid;
-    }
+    ((Dist1 < Precision::Infinite() && 
+    Dist2 < Precision::Infinite() &&
+    !PBis.IsEqual(PBisPrec,TolPnt)))) { 
+      PBisPrec = PBis;
+      UMid     = 0.5*( U22 + U11);
+      PBis     = ValueByInt(UMid,UC1,UC2,DistMid);
+      if ((Dist1 < Precision::Infinite()) == (DistMid < Precision::Infinite())) {
+        U11    = UMid;
+        Dist1 = DistMid;
+      }
+      else {
+        U22    = UMid;
+        Dist2 = DistMid;
+      }
   }
   PBis = ValueByInt(U11,UC1,UC2,Dist1);
   if (Dist1 < Precision::Infinite()) {
@@ -1628,8 +1652,8 @@ Standard_Real Bisector_BisecCC::SearchBound (const Standard_Real U1,
 // purpose :
 //=============================================================================
 static Standard_Boolean ProjOnCurve (const gp_Pnt2d& P,
-                                     const Handle(Geom2d_Curve)& C,
-                                     Standard_Real& theParam)
+  const Handle(Geom2d_Curve)& C,
+  Standard_Real& theParam)
 {
   //Standard_Real UOnCurve =0.;
   theParam = 0.0;
@@ -1644,16 +1668,16 @@ static Standard_Boolean ProjOnCurve (const gp_Pnt2d& P,
     theParam =  C->FirstParameter();
     return Standard_True;
   }
-  
+
   if (P.IsEqual(PL ,Precision::Confusion()))
   {
     theParam = C->LastParameter();
     return Standard_True;
   }
-  
+
   gp_Vec2d PPF(PF.X() - P.X(), PF.Y() - P.Y());
   TF.Normalize();
-  
+
   if ( Abs (PPF.Dot(TF)) < Precision::Confusion())
   {
     theParam = C->FirstParameter();
@@ -1667,8 +1691,8 @@ static Standard_Boolean ProjOnCurve (const gp_Pnt2d& P,
     return Standard_True;
   }
   Geom2dAPI_ProjectPointOnCurve Proj(P,C,
-                                    C->FirstParameter(),
-                                    C->LastParameter());
+    C->FirstParameter(),
+    C->LastParameter());
   if (Proj.NbPoints() > 0) {
     theParam = Proj.LowerDistanceParameter();
   }
@@ -1684,8 +1708,8 @@ static Standard_Boolean ProjOnCurve (const gp_Pnt2d& P,
 // purpose : 
 //=============================================================================
 static Standard_Boolean TestExtension (const Handle(Geom2d_Curve)& C1,
-                                      const Handle(Geom2d_Curve)& C2,
-                                      const Standard_Integer      Start_End)
+  const Handle(Geom2d_Curve)& C2,
+  const Standard_Integer      Start_End)
 {
   gp_Pnt2d         P1,P2;
   gp_Vec2d         T1,T2;
@@ -1708,7 +1732,7 @@ static Standard_Boolean TestExtension (const Handle(Geom2d_Curve)& C1,
     if (P1.IsEqual(P2,Precision::Confusion())) {
       T2.Normalize();
       if (T1.Dot(T2) > 1.0 - Precision::Confusion()) {
-       Test = Standard_True;
+        Test = Standard_True;
       }
     }
   }
@@ -1753,12 +1777,12 @@ void  Bisector_BisecCC::ComputePointEnd  ()
 // purpose :
 //=============================================================================
 static Standard_Boolean DiscretPar(const Standard_Real     DU, 
-                                  const Standard_Real     EpsMin, 
-                                  const Standard_Real     EpsMax,
-                                  const Standard_Integer  NbMin,
-                                  const Standard_Integer  NbMax,
-                                        Standard_Real&    Eps,
-                                        Standard_Integer& Nb) 
+  const Standard_Real     EpsMin, 
+  const Standard_Real     EpsMax,
+  const Standard_Integer  NbMin,
+  const Standard_Integer  NbMax,
+  Standard_Real&    Eps,
+  Standard_Integer& Nb) 
 {
   if (DU <= NbMin*EpsMin) {
     Eps = DU/(NbMin + 1) ;
index 4360059..ab19c88 100644 (file)
 #include <Precision.hxx>
 #include <math_BissecNewton.hxx>
 #include <ElCLib.hxx>
-
+#ifdef OCCT_DEBUG
+//#define DRAW
 #ifdef DRAW
-#include <Draw_Appli.hxx>
-#include <DrawTrSurf_Curve2d.hxx>
-#include <Draw_Marker2D.hxx>
+#include <DrawTrSurf.hxx>
+static char name[100];
 static Standard_Boolean Affich = Standard_False;
+static Standard_Integer nbint = 0;
+#endif
 #endif
 
 //===================================================================================
@@ -172,14 +174,14 @@ void Bisector_Inter::Perform(const Bisector_Bisec&  C1,
                          PMax,UMax,D2.LastTolerance());
 
       if ((IB2 == 1                   && Bis2->IsExtendAtStart()) || 
-         (IB2 == Bis1->NbIntervals() && Bis2->IsExtendAtEnd())    ){
-       //--------------------------------------------------------
-       // Part corresponding to an extension is a segment.     
-       //--------------------------------------------------------
-       SBis2 [IB2] = ConstructSegment (PMin,PMax,UMin,UMax);
+              (IB2 == Bis1->NbIntervals() && Bis2->IsExtendAtEnd())    ){
+          //--------------------------------------------------------
+          // Part corresponding to an extension is a segment.  
+          //--------------------------------------------------------
+        SBis2 [IB2] = ConstructSegment (PMin,PMax,UMin,UMax);
       }
       else {
-       SBis2 [IB2] = Bis2;
+             SBis2 [IB2] = Bis2;
       }
       NB2++;
     }
@@ -269,11 +271,11 @@ void Bisector_Inter::SinglePerform(const Handle(Geom2d_Curve)&    CBis1,
 
     if (Type1 == STANDARD_TYPE(Geom2d_Line) && Type2 != STANDARD_TYPE(Geom2d_Line)) {
       TestBound(Handle(Geom2d_Line)::DownCast(Bis1),
-               D1,Bis2,D2,TolConf,Standard_False);
+                                  D1,Bis2,D2,TolConf,Standard_False);
     }
     else if (Type2 == STANDARD_TYPE(Geom2d_Line)&& Type1 != STANDARD_TYPE(Geom2d_Line)) {
       TestBound(Handle(Geom2d_Line)::DownCast(Bis2),
-               D2,Bis1,D1,TolConf,Standard_True);
+                                  D2,Bis1,D1,TolConf,Standard_True);
     }
     Geom2dInt_GInter Intersect;
     Geom2dAdaptor_Curve ABis1(Bis1);
@@ -285,21 +287,17 @@ void Bisector_Inter::SinglePerform(const Handle(Geom2d_Curve)&    CBis1,
 
 #ifdef DRAW
   if (Affich) {
-    Handle(DrawTrSurf_Curve2d) dr;
-    Draw_Color                 Couleur = Draw_bleu;
-    
-    dr = new DrawTrSurf_Curve2d(Bis1,Couleur,100);
-    dout << dr;
-    dr = new DrawTrSurf_Curve2d(Bis2,Couleur,100);
-    dout << dr;
-    if (IsDone() && !IsEmpty()) {
+    sprintf( name, "i1_%d", ++nbint);
+    DrawTrSurf::Set(name, Bis1);
+    sprintf( name, "i2_%d", nbint);
+    DrawTrSurf::Set(name, Bis2);
+   if (IsDone() && !IsEmpty()) {
       for (Standard_Integer k = 1; k <= NbPoints(); k++) {
-       gp_Pnt2d P =  Point(k).Value();
-       Handle(Draw_Marker2D) drp  = new Draw_Marker2D(P,Draw_Plus,Draw_vert); 
-       dout << drp;
+             gp_Pnt2d P =  Point(k).Value();
+        sprintf( name, "ip_%d_%d", nbint, k);
+             DrawTrSurf::Set(name, P); 
       }
     }
-    dout.Flush();
   }
 #endif  
 }
index 27aee9e..a57c2e3 100644 (file)
@@ -180,9 +180,9 @@ extern void ChFi3d_ResultChron(OSD_Chronometer & ch,Standard_Real& time);
 //purpose  : 
 //=======================================================================
 Standard_Real ChFi3d_InPeriod(const Standard_Real U, 
-                              const Standard_Real UFirst, 
-                              const Standard_Real ULast,
-                              const Standard_Real Eps)
+  const Standard_Real UFirst, 
+  const Standard_Real ULast,
+  const Standard_Real Eps)
 {
   const Standard_Real period = ULast - UFirst;
   Standard_Real u = U;
@@ -196,8 +196,8 @@ Standard_Real ChFi3d_InPeriod(const Standard_Real U,
 //purpose  : Calculation of min/max uv of the fillet to intersect.
 //=======================================================================
 void ChFi3d_Boite(const gp_Pnt2d& p1,const gp_Pnt2d& p2,
-                  Standard_Real& mu,Standard_Real& Mu,
-                  Standard_Real& mv,Standard_Real& Mv)
+  Standard_Real& mu,Standard_Real& Mu,
+  Standard_Real& mv,Standard_Real& Mv)
 {
   mu = Min(p1.X(),p2.X()); Mu = Max(p1.X(),p2.X());
   mv = Min(p1.Y(),p2.Y()); Mv = Max(p1.Y(),p2.Y());
@@ -207,10 +207,10 @@ void ChFi3d_Boite(const gp_Pnt2d& p1,const gp_Pnt2d& p2,
 //purpose  : Calculation of min/max uv of the fillet to intersect.
 //=======================================================================
 void ChFi3d_Boite(const gp_Pnt2d& p1,const gp_Pnt2d& p2,
-                  const gp_Pnt2d& p3,const gp_Pnt2d& p4,
-                  Standard_Real& Du,Standard_Real& Dv,
-                  Standard_Real& mu,Standard_Real& Mu,
-                  Standard_Real& mv,Standard_Real& Mv)
+  const gp_Pnt2d& p3,const gp_Pnt2d& p4,
+  Standard_Real& Du,Standard_Real& Dv,
+  Standard_Real& mu,Standard_Real& Mu,
+  Standard_Real& mv,Standard_Real& Mv)
 {
   Standard_Real a,b;
   a = Min(p1.X(),p2.X());  b = Min(p3.X(),p4.X()); mu = Min(a,b);
@@ -225,7 +225,7 @@ void ChFi3d_Boite(const gp_Pnt2d& p1,const gp_Pnt2d& p2,
 //purpose  : 
 //=======================================================================
 static Handle(Adaptor3d_HSurface) Geometry(TopOpeBRepDS_DataStructure& DStr,
-                                           const Standard_Integer      ind)
+  const Standard_Integer      ind)
 {
   if(ind == 0) return Handle(Adaptor3d_HSurface)();
   if(ind > 0) {
@@ -246,8 +246,8 @@ static Handle(Adaptor3d_HSurface) Geometry(TopOpeBRepDS_DataStructure& DStr,
 //purpose  : 
 //=======================================================================
 void ChFi3d_SetPointTolerance(TopOpeBRepDS_DataStructure& DStr,
-                              const Bnd_Box&              box,
-                              const Standard_Integer      IP)
+  const Bnd_Box&              box,
+  const Standard_Integer      IP)
 {
   Standard_Real a,b,c,d,e,f,vtol;
   box.Get(a,b,c,d,e,f); 
@@ -261,10 +261,10 @@ void ChFi3d_SetPointTolerance(TopOpeBRepDS_DataStructure& DStr,
 //purpose  : 
 //=======================================================================
 void ChFi3d_EnlargeBox(const Handle(Geom_Curve)& C,
-                       const Standard_Real       wd,
-                       const Standard_Real       wf,
-                       Bnd_Box&                  box1,
-                       Bnd_Box&                  box2)
+  const Standard_Real       wd,
+  const Standard_Real       wf,
+  Bnd_Box&                  box1,
+  Bnd_Box&                  box2)
 {
   box1.Add(C->Value(wd));
   box2.Add(C->Value(wf));
@@ -274,11 +274,11 @@ void ChFi3d_EnlargeBox(const Handle(Geom_Curve)& C,
 //purpose  : 
 //=======================================================================
 void ChFi3d_EnlargeBox(const Handle(Adaptor3d_HSurface)& S,
-                       const Handle(Geom2d_Curve)&     PC,
-                       const Standard_Real             wd,
-                       const Standard_Real             wf,
-                       Bnd_Box&                        box1,
-                       Bnd_Box&                        box2)
+  const Handle(Geom2d_Curve)&     PC,
+  const Standard_Real             wd,
+  const Standard_Real             wf,
+  Bnd_Box&                        box1,
+  Bnd_Box&                        box2)
 {
   Standard_Real u,v;
   PC->Value(wd).Coord(u,v);
@@ -291,9 +291,9 @@ void ChFi3d_EnlargeBox(const Handle(Adaptor3d_HSurface)& S,
 //purpose  : 
 //=======================================================================
 void ChFi3d_EnlargeBox(const TopoDS_Edge&           E,
-                       const TopTools_ListOfShape&  LF,
-                       const Standard_Real          w,
-                       Bnd_Box&                     box)
+  const TopTools_ListOfShape&  LF,
+  const Standard_Real          w,
+  Bnd_Box&                     box)
 
 {
   BRepAdaptor_Curve BC(E);
@@ -312,11 +312,11 @@ void ChFi3d_EnlargeBox(const TopoDS_Edge&           E,
 //purpose  : 
 //=======================================================================
 void ChFi3d_EnlargeBox(TopOpeBRepDS_DataStructure&    DStr,
-                       const Handle(ChFiDS_Stripe)&   st, 
-                       const Handle(ChFiDS_SurfData)& sd,
-                       Bnd_Box&                       b1,
-                       Bnd_Box&                       b2,
-                       const Standard_Boolean         isfirst)
+  const Handle(ChFiDS_Stripe)&   st, 
+  const Handle(ChFiDS_SurfData)& sd,
+  Bnd_Box&                       b1,
+  Bnd_Box&                       b2,
+  const Standard_Boolean         isfirst)
 {
   Standard_Real u,v;
   const ChFiDS_CommonPoint& cp1 = sd->Vertex(isfirst,1);
@@ -380,9 +380,9 @@ void ChFi3d_EnlargeBox(TopOpeBRepDS_DataStructure&    DStr,
 //purpose  : 
 //=======================================================================
 void ChFi3d_conexfaces(const TopoDS_Edge& E,
-                       TopoDS_Face&       F1,
-                       TopoDS_Face&       F2,
-                       const ChFiDS_Map&  EFMap)
+  TopoDS_Face&       F1,
+  TopoDS_Face&       F2,
+  const ChFiDS_Map&  EFMap)
 {
   TopTools_ListIteratorOfListOfShape It;
   F1.Nullify();
@@ -394,7 +394,7 @@ void ChFi3d_conexfaces(const TopoDS_Edge& E,
     else {
       F2 = TopoDS::Face(It.Value());
       if(!F2.IsSame(F1) || BRep_Tool::IsClosed(E,F1)) {
-       break;
+        break;
       }
       else F2.Nullify();
     }
@@ -405,7 +405,7 @@ void ChFi3d_conexfaces(const TopoDS_Edge& E,
 //purpose  : check concavities for the tops with 3 edges.
 //=======================================================================
 ChFiDS_State ChFi3d_EdgeState(TopoDS_Edge* E,
-                              const ChFiDS_Map&  EFMap)
+  const ChFiDS_Map&  EFMap)
 {
   ChFiDS_State sst;
   Standard_Integer i,j;
@@ -436,9 +436,9 @@ ChFiDS_State ChFi3d_EdgeState(TopoDS_Edge* E,
     else F[2] = F3;
     if(F5.IsSame(F[2])) F[1] = F6;
     else F[1] = F5;
-    
+
   }
-  
+
   if(F[0].IsNull() || F[1].IsNull() || F[2].IsNull()) sst = ChFiDS_FreeBoundary;
   else{
     TopAbs_Orientation o01,o02,o11,o12,o21,o22;
@@ -457,8 +457,8 @@ ChFiDS_State ChFi3d_EdgeState(TopoDS_Edge* E,
 //           refine the processing.
 //=======================================================================
 GeomAbs_Shape ChFi3d_evalconti(const TopoDS_Edge& /*E*/,
-                               const TopoDS_Face& F1,
-                               const TopoDS_Face& F2)
+  const TopoDS_Face& F1,
+  const TopoDS_Face& F2)
 {
   GeomAbs_Shape cont = GeomAbs_G1;
   if(!F1.IsSame(F2)) return cont;
@@ -467,8 +467,8 @@ GeomAbs_Shape ChFi3d_evalconti(const TopoDS_Edge& /*E*/,
   BRepAdaptor_Surface S(F,Standard_False);
   GeomAbs_SurfaceType typ = S.GetType();
   if(typ != GeomAbs_Cone && 
-     typ != GeomAbs_Sphere && 
-     typ != GeomAbs_Torus) return cont;
+    typ != GeomAbs_Sphere && 
+    typ != GeomAbs_Torus) return cont;
   return GeomAbs_CN;
 }
 //modified by NIZNHY-PKV Wed Dec 15 11:22:35 2010f
@@ -477,9 +477,9 @@ GeomAbs_Shape ChFi3d_evalconti(const TopoDS_Edge& /*E*/,
 //purpose  : 
 //=======================================================================
 Standard_Boolean ChFi3d_KParticular (const Handle(ChFiDS_Spine)& Spine,
-                                    const Standard_Integer      IE,
-                                    const BRepAdaptor_Surface&  S1,
-                                    const BRepAdaptor_Surface&  S2)
+  const Standard_Integer      IE,
+  const BRepAdaptor_Surface&  S1,
+  const BRepAdaptor_Surface&  S2)
 {
   Standard_Boolean bRet;
   //
@@ -552,11 +552,11 @@ Standard_Boolean ChFi3d_KParticular (const Handle(ChFiDS_Spine)& Spine,
 //           Useful for intersections with known extremities. 
 //=======================================================================
 void ChFi3d_BoundFac(BRepAdaptor_Surface& S,
-                     const Standard_Real uumin,
-                     const Standard_Real uumax,
-                     const Standard_Real vvmin,
-                     const Standard_Real vvmax,
-                     const Standard_Boolean checknaturalbounds)
+  const Standard_Real uumin,
+  const Standard_Real uumax,
+  const Standard_Real vvmin,
+  const Standard_Real vvmax,
+  const Standard_Boolean checknaturalbounds)
 {
   ChFi3d_BoundSrf(S.ChangeSurface(), uumin,uumax,vvmin,vvmax,checknaturalbounds);
 }
@@ -566,11 +566,11 @@ void ChFi3d_BoundFac(BRepAdaptor_Surface& S,
 //           Useful for intersections with known extremities.
 //=======================================================================
 void ChFi3d_BoundSrf(GeomAdaptor_Surface& S,
-                     const Standard_Real uumin,
-                     const Standard_Real uumax,
-                     const Standard_Real vvmin,
-                     const Standard_Real vvmax,
-                     const Standard_Boolean checknaturalbounds)
+  const Standard_Real uumin,
+  const Standard_Real uumax,
+  const Standard_Real vvmin,
+  const Standard_Real vvmax,
+  const Standard_Boolean checknaturalbounds)
 {
   Standard_Real umin = uumin, umax = uumax, vmin = vvmin, vmax = vvmax; 
   Handle(Geom_Surface) surface = S.Surface();
@@ -596,7 +596,7 @@ void ChFi3d_BoundSrf(GeomAdaptor_Surface& S,
 
   Standard_Real step3du = Stepu/scalu; 
   Standard_Real step3dv = Stepv/scalv;
-  
+
   if(step3du > step3dv) Stepv = step3du*scalv;
   if(step3dv > step3du) Stepu = step3dv*scalu;
 
@@ -618,36 +618,36 @@ void ChFi3d_BoundSrf(GeomAdaptor_Surface& S,
 //purpose  : 
 //=======================================================================
 Standard_Boolean  ChFi3d_InterPlaneEdge (Handle(Adaptor3d_HSurface)& Plan,
-                                         Handle(Adaptor3d_HCurve)&  C,
-                                         Standard_Real& W,
-                                         const Standard_Boolean Sens,
-                                         const Standard_Real tolc)
+  Handle(Adaptor3d_HCurve)&  C,
+  Standard_Real& W,
+  const Standard_Boolean Sens,
+  const Standard_Real tolc)
 { 
   IntCurveSurface_HInter Intersection;
   Standard_Integer isol = 0, nbp ,iip;
   Standard_Real uf = C->FirstParameter(),ul = C->LastParameter();
   Standard_Real CW;
-  
+
   Intersection.Perform(C,Plan);
-  
+
   if(Intersection.IsDone()) {
     nbp = Intersection.NbPoints();
     for (iip = 1; iip <= nbp; iip++) {
       CW = Intersection.Point(iip).W();
       if(C->IsPeriodic())
-       CW = ElCLib::InPeriod(CW,uf-tolc,uf-tolc+C->Period());
+        CW = ElCLib::InPeriod(CW,uf-tolc,uf-tolc+C->Period());
       if(uf - tolc <= CW && ul + tolc >= CW) {
-       if (isol == 0) {
-         isol = iip; W = CW;
-       }
-       else {
-         if      ( Sens && CW < W) {
-           W = CW; isol = iip;
-         }
-         else if (!Sens && CW > W) {
-           W = CW; isol = iip;
-         }
-       }
+        if (isol == 0) {
+          isol = iip; W = CW;
+        }
+        else {
+          if      ( Sens && CW < W) {
+            W = CW; isol = iip;
+          }
+          else if (!Sens && CW > W) {
+            W = CW; isol = iip;
+          }
+        }
       }
     }
   }
@@ -659,14 +659,14 @@ Standard_Boolean  ChFi3d_InterPlaneEdge (Handle(Adaptor3d_HSurface)& Plan,
 //purpose  : 
 //=======================================================================
 void ChFi3d_ExtrSpineCarac(const TopOpeBRepDS_DataStructure& DStr,
-                          const Handle(ChFiDS_Stripe)& cd,
-                          const Standard_Integer i,
-                          const Standard_Real p,
-                          const Standard_Integer jf,
-                          const Standard_Integer sens,
-                          gp_Pnt& P,
-                          gp_Vec& V,
-                          Standard_Real& R) //check if it is necessary to add D1,D2 and DR
+  const Handle(ChFiDS_Stripe)& cd,
+  const Standard_Integer i,
+  const Standard_Real p,
+  const Standard_Integer jf,
+  const Standard_Integer sens,
+  gp_Pnt& P,
+  gp_Vec& V,
+  Standard_Real& R) //check if it is necessary to add D1,D2 and DR
 {
   // Attention for approximated surfaces it is assumed that e
   // the parameters of the pcurve are the same as of  
@@ -695,15 +695,15 @@ void ChFi3d_ExtrSpineCarac(const TopOpeBRepDS_DataStructure& DStr,
     break;
   default:
     { Standard_Integer nbelspine;
-      const Handle(ChFiDS_Spine)& sp = cd->Spine();
-      Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(sp);
-      nbelspine=sp->NbEdges();
-      Handle(ChFiDS_HElSpine) hels;
-      if   (nbelspine==1) hels = sp->ElSpine(1);
-      else hels = sp->ElSpine(p);
-      if(fsp->IsConstant()) { R = fsp->Radius(); }
-      else { R = fsp->Law(hels)->Value(p); }
-      hels->D1(p,Pbid,V);
+    const Handle(ChFiDS_Spine)& sp = cd->Spine();
+    Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(sp);
+    nbelspine=sp->NbEdges();
+    Handle(ChFiDS_HElSpine) hels;
+    if   (nbelspine==1) hels = sp->ElSpine(1);
+    else hels = sp->ElSpine(p);
+    if(fsp->IsConstant()) { R = fsp->Radius(); }
+    else { R = fsp->Law(hels)->Value(p); }
+    hels->D1(p,Pbid,V);
     }
     break;
   }
@@ -717,17 +717,17 @@ void ChFi3d_ExtrSpineCarac(const TopOpeBRepDS_DataStructure& DStr,
 //           of guidelines of start and end fillets.
 //=======================================================================
 Handle(Geom_Circle) ChFi3d_CircularSpine(Standard_Real&      WFirst,
-                                        Standard_Real&      WLast,
-                                        const gp_Pnt&       Pdeb,
-                                        const gp_Vec&       Vdeb,
-                                        const gp_Pnt&       Pfin,
-                                        const gp_Vec&       Vfin,
-                                        const Standard_Real rad)
+  Standard_Real&      WLast,
+  const gp_Pnt&       Pdeb,
+  const gp_Vec&       Vdeb,
+  const gp_Pnt&       Pfin,
+  const gp_Vec&       Vfin,
+  const Standard_Real rad)
 {
   gp_Circ ccc;
   gp_Pln Pl1(Pdeb,gp_Dir(Vdeb)),Pl2(Pfin,gp_Dir(Vfin));
   IntAna_QuadQuadGeo LInt (Pl1,Pl2,Precision::Angular(),
-                          Precision::Confusion());
+    Precision::Confusion());
   gp_Lin li;
   if (LInt.IsDone()) {
     li = LInt.Line(1);
@@ -757,10 +757,10 @@ Handle(Geom_Circle) ChFi3d_CircularSpine(Standard_Real&      WFirst,
 //           guidelines of start and end fillets.
 //=======================================================================
 Handle(Geom_BezierCurve) ChFi3d_Spine(const gp_Pnt&       pd,
-                                      gp_Vec&             vd,
-                                      const gp_Pnt&       pf,
-                                      gp_Vec&             vf,
-                                      const Standard_Real R)
+  gp_Vec&             vd,
+  const gp_Pnt&       pf,
+  gp_Vec&             vf,
+  const Standard_Real R)
 {     
   TColgp_Array1OfPnt pol(1,4);
   const Standard_Real fac = 0.5 * tan((M_PI-vd.Angle(vf)) * 0.5);
@@ -777,22 +777,22 @@ Handle(Geom_BezierCurve) ChFi3d_Spine(const gp_Pnt&       pd,
 //purpose  : Checks if surfdata i1 and i2 are face to face
 //=======================================================================
 Standard_Boolean ChFi3d_IsInFront(TopOpeBRepDS_DataStructure& DStr,
-                                  const Handle(ChFiDS_Stripe)& cd1, 
-                                  const Handle(ChFiDS_Stripe)& cd2,
-                                  const Standard_Integer i1,
-                                  const Standard_Integer i2,
-                                  const Standard_Integer sens1,
-                                  const Standard_Integer sens2,
-                                  Standard_Real& p1,
-                                  Standard_Real& p2,
-                                  TopoDS_Face& face,
-                                  Standard_Boolean& sameside,
-                                  Standard_Integer& jf1,
-                                  Standard_Integer& jf2,
-                                  Standard_Boolean& visavis,
-                                  const TopoDS_Vertex& Vtx,
-                                  const Standard_Boolean Check2dDistance,
-                                  const Standard_Boolean enlarge)
+  const Handle(ChFiDS_Stripe)& cd1, 
+  const Handle(ChFiDS_Stripe)& cd2,
+  const Standard_Integer i1,
+  const Standard_Integer i2,
+  const Standard_Integer sens1,
+  const Standard_Integer sens2,
+  Standard_Real& p1,
+  Standard_Real& p2,
+  TopoDS_Face& face,
+  Standard_Boolean& sameside,
+  Standard_Integer& jf1,
+  Standard_Integer& jf2,
+  Standard_Boolean& visavis,
+  const TopoDS_Vertex& Vtx,
+  const Standard_Boolean Check2dDistance,
+  const Standard_Boolean enlarge)
 {
   Standard_Boolean isf1 = (sens1 == 1), isf2 = (sens2 == 1);
   const Handle(ChFiDS_SurfData)& fd1 = cd1->SetOfSurfData()->Value(i1);
@@ -843,14 +843,14 @@ Standard_Boolean ChFi3d_IsInFront(TopOpeBRepDS_DataStructure& DStr,
       P2d = BRep_Tool::Parameters( Vtx, face );
     if(ChFi3d_IntTraces(fd1,pref1,p1,jf1,sens1,fd2,pref2,p2,jf2,sens2,P2d,Check2dDistance,enlarge)) {
       Standard_Boolean restore = 
-       ok && ((j1 == jf1 && sens1*(p1 - u1) > 0.) || 
-              (j2 == jf2 && sens2*(p2 - u2) > 0.));
+        ok && ((j1 == jf1 && sens1*(p1 - u1) > 0.) || 
+        (j2 == jf2 && sens2*(p2 - u2) > 0.));
       ok = 1;
       if(restore) {
-       p1 = u1; p2 = u2; sameside = ss; jf1 = j1; jf2 = j2; face = ff;
+        p1 = u1; p2 = u2; sameside = ss; jf1 = j1; jf2 = j2; face = ff;
       }
       else {
-       u1 = p1; u2 = p2; ss = sameside; j1 = jf1; j2 = jf2; ff = face;
+        u1 = p1; u2 = p2; ss = sameside; j1 = jf1; j2 = jf2; ff = face;
       }
     }
     //the re-initialization is added in case p1,... take wrong values
@@ -876,14 +876,14 @@ Standard_Boolean ChFi3d_IsInFront(TopOpeBRepDS_DataStructure& DStr,
       P2d = BRep_Tool::Parameters( Vtx, face );
     if(ChFi3d_IntTraces(fd1,pref1,p1,jf1,sens1,fd2,pref2,p2,jf2,sens2,P2d,Check2dDistance,enlarge)) {
       Standard_Boolean restore = 
-       ok && ((j1 == jf1 && sens1*(p1 - u1) > 0.) || 
-              (j2 == jf2 && sens2*(p2 - u2) > 0.));
+        ok && ((j1 == jf1 && sens1*(p1 - u1) > 0.) || 
+        (j2 == jf2 && sens2*(p2 - u2) > 0.));
       ok = 1;
       if(restore) {
-       p1 = u1; p2 = u2; sameside = ss; jf1 = j1; jf2 = j2; face = ff;
+        p1 = u1; p2 = u2; sameside = ss; jf1 = j1; jf2 = j2; face = ff;
       }
       else {
-       u1 = p1; u2 = p2; ss = sameside; j1 = jf1; j2 = jf2; ff = face;
+        u1 = p1; u2 = p2; ss = sameside; j1 = jf1; j2 = jf2; ff = face;
       }
     }
     //the re-initialization is added in case p1,... take wrong values
@@ -909,14 +909,14 @@ Standard_Boolean ChFi3d_IsInFront(TopOpeBRepDS_DataStructure& DStr,
       P2d = BRep_Tool::Parameters( Vtx, face );
     if(ChFi3d_IntTraces(fd1,pref1,p1,jf1,sens1,fd2,pref2,p2,jf2,sens2,P2d,Check2dDistance,enlarge)) {
       Standard_Boolean restore = 
-       ok && ((j1 == jf1 && sens1*(p1 - u1) > 0.) || 
-              (j2 == jf2 && sens2*(p2 - u2) > 0.));
+        ok && ((j1 == jf1 && sens1*(p1 - u1) > 0.) || 
+        (j2 == jf2 && sens2*(p2 - u2) > 0.));
       ok = 1;
       if(restore) {
-       p1 = u1; p2 = u2; sameside = ss; jf1 = j1; jf2 = j2; face = ff;
+        p1 = u1; p2 = u2; sameside = ss; jf1 = j1; jf2 = j2; face = ff;
       }
       else {
-       u1 = p1; u2 = p2; ss = sameside; j1 = jf1; j2 = jf2; ff = face;
+        u1 = p1; u2 = p2; ss = sameside; j1 = jf1; j2 = jf2; ff = face;
       }
     }
     //the re-initialization is added in case p1,... take wrong values
@@ -931,10 +931,10 @@ Standard_Boolean ChFi3d_IsInFront(TopOpeBRepDS_DataStructure& DStr,
 //purpose  : 
 //=======================================================================
 static Standard_Real recadre(const Standard_Real p,
-                             const Standard_Real ref,
-                             const Standard_Integer sens,
-                             const Standard_Real first,
-                             const Standard_Real last)
+  const Standard_Real ref,
+  const Standard_Integer sens,
+  const Standard_Real first,
+  const Standard_Real last)
 {
   const Standard_Real pp = p + (sens > 0 ? (first - last) : (last - first));
   return ((Abs(pp - ref) < Abs(p - ref))? pp : p);
@@ -944,18 +944,18 @@ static Standard_Real recadre(const Standard_Real p,
 //purpose  : 
 //=======================================================================
 Standard_Boolean ChFi3d_IntTraces(const Handle(ChFiDS_SurfData)& fd1,
-                                 const Standard_Real            pref1,
-                                 Standard_Real&                 p1,
-                                 const Standard_Integer         jf1,
-                                 const Standard_Integer         sens1,
-                                 const Handle(ChFiDS_SurfData)& fd2,
-                                 const Standard_Real            pref2,
-                                 Standard_Real&                 p2,
-                                 const Standard_Integer         jf2,
-                                 const Standard_Integer         sens2,
-                                 const gp_Pnt2d&                RefP2d,
-                                 const Standard_Boolean         Check2dDistance,
-                                 const Standard_Boolean         enlarge)
+  const Standard_Real            pref1,
+  Standard_Real&                 p1,
+  const Standard_Integer         jf1,
+  const Standard_Integer         sens1,
+  const Handle(ChFiDS_SurfData)& fd2,
+  const Standard_Real            pref2,
+  Standard_Real&                 p2,
+  const Standard_Integer         jf2,
+  const Standard_Integer         sens2,
+  const gp_Pnt2d&                RefP2d,
+  const Standard_Boolean         Check2dDistance,
+  const Standard_Boolean         enlarge)
 {
   Geom2dAdaptor_Curve C1;
   Geom2dAdaptor_Curve C2;
@@ -979,7 +979,7 @@ Standard_Boolean ChFi3d_IntTraces(const Handle(ChFiDS_SurfData)& fd1,
   }
   else C1.Load(pcf1,first-delta,last+delta);
   Standard_Real first1 = pcf1->FirstParameter(), last1 = pcf1->LastParameter();
-  
+
   first = fd2->Interference(jf2).FirstParameter();
   last = fd2->Interference(jf2).LastParameter();
   if ((last-first) < Precision::PConfusion())
@@ -995,20 +995,20 @@ Standard_Boolean ChFi3d_IntTraces(const Handle(ChFiDS_SurfData)& fd1,
   }
   else C2.Load(fd2->Interference(jf2).PCurveOnFace(),first-delta,last+delta);
   Standard_Real first2 = pcf2->FirstParameter(), last2 = pcf2->LastParameter();
-    
+
   IntRes2d_IntersectionPoint int2d;
   Geom2dInt_GInter Intersection;
   Standard_Integer nbpt,nbseg;
   gp_Pnt2d p2d;
   if(fd1->Interference(jf1).PCurveOnFace() == fd2->Interference(jf2).PCurveOnFace()) {
     Intersection.Perform(C1,
-                        Precision::PIntersection(),
-                        Precision::PIntersection());
+      Precision::PIntersection(),
+      Precision::PIntersection());
   }
   else{
     Intersection.Perform(C1,C2,
-                        Precision::PIntersection(),
-                        Precision::PIntersection());
+      Precision::PIntersection(),
+      Precision::PIntersection());
   }
   if (Intersection.IsDone()) {
     if (!Intersection.IsEmpty()) {
@@ -1017,84 +1017,84 @@ Standard_Boolean ChFi3d_IntTraces(const Handle(ChFiDS_SurfData)& fd1,
       }
       nbpt = Intersection.NbPoints();
       if ( nbpt >= 1 ) {
-       // The criteria sets to filter the found points in a strict way 
+        // The criteria sets to filter the found points in a strict way 
         // are missing. Two different criterions chosen somewhat randomly 
         // are used :
-       // - periodic curves : closest to the border.
-       // - non-periodic curves : the closest to the left of 2 curves
-       //                             modulo sens1 and sens2
-       int2d = Intersection.Point(1);
-       p2d = int2d.Value();
-       p1 = int2d.ParamOnFirst();
-       p2 = int2d.ParamOnSecond();
-       if(isper1) p1 = recadre(p1,pref1,sens1,first1,last1);
-       if(isper2) p2 = recadre(p2,pref2,sens2,first2,last2);
-       for(Standard_Integer i = 2; i<=nbpt; i++) {
-         int2d = Intersection.Point(i);
-         if(isper1) {
-           Standard_Real pp1 = int2d.ParamOnFirst();
-           pp1 = recadre(pp1,pref1,sens1,first1,last1);
-           if((Abs(pp1 - pref1) < Abs(p1 - pref1))) {
-             p1 = pp1;
-             p2 = int2d.ParamOnSecond();
-             p2d = int2d.Value();
-           }
-           //  Modified by skv - Mon Jun 16 15:51:21 2003 OCC615 Begin
-           else if (Check2dDistance &&
-                    RefP2d.Distance(int2d.Value()) < RefP2d.Distance(p2d)) {
-             Standard_Real pp2 = int2d.ParamOnSecond();
-
-             if(isper2)
-               pp2 = recadre(pp2,pref2,sens2,first2,last2);
-
-             p1  = pp1;
-             p2  = pp2;
-             p2d = int2d.Value();
-           }
-           //  Modified by skv - Mon Jun 16 15:51:22 2003 OCC615 End
-         }
-         else if(isper2) {
-           Standard_Real pp2 = int2d.ParamOnSecond();
-           pp2 = recadre(pp2,pref2,sens2,first2,last2);
-           if((Abs(pp2 - pref2) < Abs(p2 - pref2))) {
-             p2 = pp2;
-             p1 = int2d.ParamOnFirst();
-             p2d = int2d.Value();
-           }
-           //  Modified by skv - Mon Jun 16 15:51:21 2003 OCC615 Begin
-           else if (Check2dDistance &&
-                    RefP2d.Distance(int2d.Value()) < RefP2d.Distance(p2d)) {
-             Standard_Real pp1 = int2d.ParamOnFirst();
-
-             if(isper1)
-               pp1 = recadre(pp1,pref1,sens1,first1,last1);
-
-             p1  = pp1;
-             p2  = pp2;
-             p2d = int2d.Value();
-           }
-           //  Modified by skv - Mon Jun 16 15:51:22 2003 OCC615 End
-         }
-         else if(((int2d.ParamOnFirst() - p1)*sens1 < 0.) &&
-                 ((int2d.ParamOnSecond() - p2)*sens2 < 0.)) {
-           p1 = int2d.ParamOnFirst();
-           p2 = int2d.ParamOnSecond();
-           p2d = int2d.Value();
-         }
-         else if((Abs(int2d.ParamOnFirst() - pref1) < Abs(p1 - pref1)) &&
-                 (Abs(int2d.ParamOnSecond() - pref2) < Abs(p2 - pref2))) {
-           p1 = int2d.ParamOnFirst();
-           p2 = int2d.ParamOnSecond();
-           p2d = int2d.Value();
-         }
-         else if (Check2dDistance && RefP2d.Distance(int2d.Value()) < RefP2d.Distance(p2d))
-           {
-             p1 = int2d.ParamOnFirst();
-             p2 = int2d.ParamOnSecond();
-             p2d = int2d.Value();
-           }
-       }
-       return Standard_True; 
+        // - periodic curves : closest to the border.
+        // - non-periodic curves : the closest to the left of 2 curves
+        //                             modulo sens1 and sens2
+        int2d = Intersection.Point(1);
+        p2d = int2d.Value();
+        p1 = int2d.ParamOnFirst();
+        p2 = int2d.ParamOnSecond();
+        if(isper1) p1 = recadre(p1,pref1,sens1,first1,last1);
+        if(isper2) p2 = recadre(p2,pref2,sens2,first2,last2);
+        for(Standard_Integer i = 2; i<=nbpt; i++) {
+          int2d = Intersection.Point(i);
+          if(isper1) {
+            Standard_Real pp1 = int2d.ParamOnFirst();
+            pp1 = recadre(pp1,pref1,sens1,first1,last1);
+            if((Abs(pp1 - pref1) < Abs(p1 - pref1))) {
+              p1 = pp1;
+              p2 = int2d.ParamOnSecond();
+              p2d = int2d.Value();
+            }
+            //  Modified by skv - Mon Jun 16 15:51:21 2003 OCC615 Begin
+            else if (Check2dDistance &&
+              RefP2d.Distance(int2d.Value()) < RefP2d.Distance(p2d)) {
+                Standard_Real pp2 = int2d.ParamOnSecond();
+
+                if(isper2)
+                  pp2 = recadre(pp2,pref2,sens2,first2,last2);
+
+                p1  = pp1;
+                p2  = pp2;
+                p2d = int2d.Value();
+            }
+            //  Modified by skv - Mon Jun 16 15:51:22 2003 OCC615 End
+          }
+          else if(isper2) {
+            Standard_Real pp2 = int2d.ParamOnSecond();
+            pp2 = recadre(pp2,pref2,sens2,first2,last2);
+            if((Abs(pp2 - pref2) < Abs(p2 - pref2))) {
+              p2 = pp2;
+              p1 = int2d.ParamOnFirst();
+              p2d = int2d.Value();
+            }
+            //  Modified by skv - Mon Jun 16 15:51:21 2003 OCC615 Begin
+            else if (Check2dDistance &&
+              RefP2d.Distance(int2d.Value()) < RefP2d.Distance(p2d)) {
+                Standard_Real pp1 = int2d.ParamOnFirst();
+
+                if(isper1)
+                  pp1 = recadre(pp1,pref1,sens1,first1,last1);
+
+                p1  = pp1;
+                p2  = pp2;
+                p2d = int2d.Value();
+            }
+            //  Modified by skv - Mon Jun 16 15:51:22 2003 OCC615 End
+          }
+          else if(((int2d.ParamOnFirst() - p1)*sens1 < 0.) &&
+            ((int2d.ParamOnSecond() - p2)*sens2 < 0.)) {
+              p1 = int2d.ParamOnFirst();
+              p2 = int2d.ParamOnSecond();
+              p2d = int2d.Value();
+          }
+          else if((Abs(int2d.ParamOnFirst() - pref1) < Abs(p1 - pref1)) &&
+            (Abs(int2d.ParamOnSecond() - pref2) < Abs(p2 - pref2))) {
+              p1 = int2d.ParamOnFirst();
+              p2 = int2d.ParamOnSecond();
+              p2d = int2d.Value();
+          }
+          else if (Check2dDistance && RefP2d.Distance(int2d.Value()) < RefP2d.Distance(p2d))
+          {
+            p1 = int2d.ParamOnFirst();
+            p2 = int2d.ParamOnSecond();
+            p2d = int2d.Value();
+          }
+        }
+        return Standard_True; 
       }
       return Standard_False; 
     }
@@ -1107,10 +1107,10 @@ Standard_Boolean ChFi3d_IntTraces(const Handle(ChFiDS_SurfData)& fd1,
 //purpose  : 
 //=======================================================================
 void ChFi3d_Coefficient(const gp_Vec& V3d,
-                        const gp_Vec& D1u,
-                        const gp_Vec& D1v,
-                        Standard_Real& DU,
-                        Standard_Real& DV) 
+  const gp_Vec& D1u,
+  const gp_Vec& D1v,
+  Standard_Real& DU,
+  Standard_Real& DV) 
 {
   const Standard_Real AA = D1u.SquareMagnitude();
   const Standard_Real BB = D1u.Dot(D1v);
@@ -1127,8 +1127,8 @@ void ChFi3d_Coefficient(const gp_Vec& V3d,
 //           ses parametres et on la reparametre eventuellement.
 //=======================================================================
 void ChFi3d_ReparamPcurv(const Standard_Real Uf, 
-                         const Standard_Real Ul, 
-                         Handle(Geom2d_Curve)& Pcurv) 
+  const Standard_Real Ul, 
+  Handle(Geom2d_Curve)& Pcurv) 
 {
   if(Pcurv.IsNull()) return;
   Standard_Real upcf = Pcurv->FirstParameter();
@@ -1139,20 +1139,20 @@ void ChFi3d_ReparamPcurv(const Standard_Real Uf,
   Handle(Geom2d_BSplineCurve) pc = Handle(Geom2d_BSplineCurve)::DownCast(basis);
   if(pc.IsNull()) return;
   if(Abs(upcf - pc->FirstParameter()) > Precision::PConfusion() ||
-     Abs(upcl - pc->LastParameter()) > Precision::PConfusion()) {
-    pc->Segment(upcf,upcl);
+    Abs(upcl - pc->LastParameter()) > Precision::PConfusion()) {
+      pc->Segment(upcf,upcl);
   }
   if(Abs(Uf - pc->FirstParameter()) > Precision::PConfusion() ||
-     Abs(Ul - pc->LastParameter()) > Precision::PConfusion()) {
-    TColgp_Array1OfPnt2d pol(1,pc->NbPoles());
-    pc->Poles(pol);
-    TColStd_Array1OfReal kn(1,pc->NbKnots());
-    pc->Knots(kn);
-    TColStd_Array1OfInteger mu(1,pc->NbKnots());
-    pc->Multiplicities(mu);
-    Standard_Integer deg = pc->Degree();
-    BSplCLib::Reparametrize(Uf,Ul,kn);
-    pc = new Geom2d_BSplineCurve(pol,kn,mu,deg);
+    Abs(Ul - pc->LastParameter()) > Precision::PConfusion()) {
+      TColgp_Array1OfPnt2d pol(1,pc->NbPoles());
+      pc->Poles(pol);
+      TColStd_Array1OfReal kn(1,pc->NbKnots());
+      pc->Knots(kn);
+      TColStd_Array1OfInteger mu(1,pc->NbKnots());
+      pc->Multiplicities(mu);
+      Standard_Integer deg = pc->Degree();
+      BSplCLib::Reparametrize(Uf,Ul,kn);
+      pc = new Geom2d_BSplineCurve(pol,kn,mu,deg);
   }
   Pcurv = pc;
 }
@@ -1162,55 +1162,55 @@ void ChFi3d_ReparamPcurv(const Standard_Real Uf,
 //           3d. Should be called only in analytic cases.
 //=======================================================================
 void ChFi3d_ProjectPCurv(const Handle(Adaptor3d_HCurve)&   HCg, 
-                        const Handle(Adaptor3d_HSurface)& HSg, 
-                        Handle(Geom2d_Curve)&           Pcurv,
-                        const Standard_Real             tol,
-                        Standard_Real&                  tolreached) 
+  const Handle(Adaptor3d_HSurface)& HSg, 
+  Handle(Geom2d_Curve)&           Pcurv,
+  const Standard_Real             tol,
+  Standard_Real&                  tolreached) 
 {
   if (HSg->GetType() != GeomAbs_BezierSurface &&
-      HSg->GetType() != GeomAbs_BSplineSurface) {
-    
-    ProjLib_ProjectedCurve Projc (HSg,HCg,tol);
-    tolreached = Projc.GetTolerance();
-    switch (Projc.GetType()) {
-    case GeomAbs_Line : 
-      {
-       Pcurv = new Geom2d_Line(Projc.Line());
-      }
-      break;
-    case GeomAbs_Circle :
-      {
-       Pcurv = new Geom2d_Circle(Projc.Circle());
-      }
-      break;
-    case GeomAbs_Ellipse :
-      {
-       Pcurv = new Geom2d_Ellipse(Projc.Ellipse());
-      }
-      break;
-    case GeomAbs_Hyperbola :
-      {
-       Pcurv = new Geom2d_Hyperbola(Projc.Hyperbola());
-      }
-      break;
-    case GeomAbs_Parabola :
-      {
-       Pcurv = new Geom2d_Parabola(Projc.Parabola());
-      }
-      break;
-    case GeomAbs_BezierCurve :
-      {
-       Pcurv = Projc.Bezier(); 
-      }
-      break;
-    case GeomAbs_BSplineCurve :
-      {
-       Pcurv = Projc.BSpline();
+    HSg->GetType() != GeomAbs_BSplineSurface) {
+
+      ProjLib_ProjectedCurve Projc (HSg,HCg,tol);
+      tolreached = Projc.GetTolerance();
+      switch (Projc.GetType()) {
+      case GeomAbs_Line : 
+        {
+          Pcurv = new Geom2d_Line(Projc.Line());
+        }
+        break;
+      case GeomAbs_Circle :
+        {
+          Pcurv = new Geom2d_Circle(Projc.Circle());
+        }
+        break;
+      case GeomAbs_Ellipse :
+        {
+          Pcurv = new Geom2d_Ellipse(Projc.Ellipse());
+        }
+        break;
+      case GeomAbs_Hyperbola :
+        {
+          Pcurv = new Geom2d_Hyperbola(Projc.Hyperbola());
+        }
+        break;
+      case GeomAbs_Parabola :
+        {
+          Pcurv = new Geom2d_Parabola(Projc.Parabola());
+        }
+        break;
+      case GeomAbs_BezierCurve :
+        {
+          Pcurv = Projc.Bezier(); 
+        }
+        break;
+      case GeomAbs_BSplineCurve :
+        {
+          Pcurv = Projc.BSpline();
+        }
+        break;
+      default:
+        Standard_NotImplemented::Raise("echec approximation de la pcurve ");
       }
-      break;
-    default:
-      Standard_NotImplemented::Raise("echec approximation de la pcurve ");
-    }
   }
 }
 //=======================================================================
@@ -1218,10 +1218,10 @@ void ChFi3d_ProjectPCurv(const Handle(Adaptor3d_HCurve)&   HCg,
 //purpose  : Controls a posteriori that sameparameter worked well
 //=======================================================================
 Standard_Boolean ChFi3d_CheckSameParameter (const Handle(Adaptor3d_HCurve)&   C3d,
-                                           Handle(Geom2d_Curve)&           Pcurv,
-                                           const Handle(Adaptor3d_HSurface)& S,
-                                           const Standard_Real             tol3d,
-                                           Standard_Real&                  tolreached)
+  Handle(Geom2d_Curve)&           Pcurv,
+  const Handle(Adaptor3d_HSurface)& S,
+  const Standard_Real             tol3d,
+  Standard_Real&                  tolreached)
 {
   tolreached = 0.;
   Standard_Real f = C3d->FirstParameter();
@@ -1252,10 +1252,10 @@ Standard_Boolean ChFi3d_CheckSameParameter (const Handle(Adaptor3d_HCurve)&   C3
 //purpose  : Encapsulation of Sameparameter
 //=======================================================================
 Standard_Boolean ChFi3d_SameParameter(const Handle(Adaptor3d_HCurve)&   C3d,
-                                      Handle(Geom2d_Curve)&           Pcurv,
-                                      const Handle(Adaptor3d_HSurface)& S,
-                                      const Standard_Real             tol3d,
-                                      Standard_Real&                  tolreached)
+  Handle(Geom2d_Curve)&           Pcurv,
+  const Handle(Adaptor3d_HSurface)& S,
+  const Standard_Real             tol3d,
+  Standard_Real&                  tolreached)
 {
   if(ChFi3d_CheckSameParameter(C3d,Pcurv,S,tol3d,tolreached)) return Standard_True;
   Approx_SameParameter sp(C3d,Pcurv,S,tol3d);
@@ -1271,12 +1271,12 @@ Standard_Boolean ChFi3d_SameParameter(const Handle(Adaptor3d_HCurve)&   C3d,
 //purpose  : Encapsulation de Sameparameter
 //=======================================================================
 Standard_Boolean ChFi3d_SameParameter(const Handle(Geom_Curve)&   C3d,
-                                      Handle(Geom2d_Curve)&       Pcurv,
-                                      const Handle(Geom_Surface)& S,
-                                      const Standard_Real         Pardeb,
-                                      const Standard_Real         Parfin,
-                                      const Standard_Real         tol3d,
-                                      Standard_Real&              tolreached)
+  Handle(Geom2d_Curve)&       Pcurv,
+  const Handle(Geom_Surface)& S,
+  const Standard_Real         Pardeb,
+  const Standard_Real         Parfin,
+  const Standard_Real         tol3d,
+  Standard_Real&              tolreached)
 {
   /*szv:static*/ Handle(GeomAdaptor_HSurface) hs(new GeomAdaptor_HSurface(S));
   /*szv:static*/ Handle(GeomAdaptor_HCurve) hc(new GeomAdaptor_HCurve(C3d,Pardeb,Parfin));
@@ -1289,15 +1289,15 @@ Standard_Boolean ChFi3d_SameParameter(const Handle(Geom_Curve)&   C3d,
 //           reference 3D curve.
 //=======================================================================
 void ChFi3d_ComputePCurv(const Handle(Adaptor3d_HCurve)&   C3d,
-                        const gp_Pnt2d&                 UV1,
-                        const gp_Pnt2d&                 UV2,
-                        Handle(Geom2d_Curve)&           Pcurv,
-                        const Handle(Adaptor3d_HSurface)& S,
-                        const Standard_Real             Pardeb,
-                        const Standard_Real             Parfin,
-                        const Standard_Real             tol3d,
-                        Standard_Real&                  tolreached,
-                        const Standard_Boolean          reverse)
+  const gp_Pnt2d&                 UV1,
+  const gp_Pnt2d&                 UV2,
+  Handle(Geom2d_Curve)&           Pcurv,
+  const Handle(Adaptor3d_HSurface)& S,
+  const Standard_Real             Pardeb,
+  const Standard_Real             Parfin,
+  const Standard_Real             tol3d,
+  Standard_Real&                  tolreached,
+  const Standard_Boolean          reverse)
 {
   ChFi3d_ComputePCurv(UV1,UV2,Pcurv,Pardeb,Parfin,reverse);
   ChFi3d_SameParameter(C3d,Pcurv,S,tol3d,tolreached);
@@ -1309,15 +1309,15 @@ void ChFi3d_ComputePCurv(const Handle(Adaptor3d_HCurve)&   C3d,
 //           reference 3D curve.
 //=======================================================================
 void ChFi3d_ComputePCurv(const Handle(Geom_Curve)&   C3d,
-                         const gp_Pnt2d&             UV1,
-                         const gp_Pnt2d&             UV2,
-                         Handle(Geom2d_Curve)&       Pcurv,
-                         const Handle(Geom_Surface)& S,
-                         const Standard_Real         Pardeb,
-                         const Standard_Real         Parfin,
-                         const Standard_Real         tol3d,
-                         Standard_Real&              tolreached,
-                         const Standard_Boolean      reverse)
+  const gp_Pnt2d&             UV1,
+  const gp_Pnt2d&             UV2,
+  Handle(Geom2d_Curve)&       Pcurv,
+  const Handle(Geom_Surface)& S,
+  const Standard_Real         Pardeb,
+  const Standard_Real         Parfin,
+  const Standard_Real         tol3d,
+  Standard_Real&              tolreached,
+  const Standard_Boolean      reverse)
 {
   /*szv:static*/ Handle(GeomAdaptor_HSurface) hs(new GeomAdaptor_HSurface(S));
   /*szv:static*/ Handle(GeomAdaptor_HCurve) hc(new GeomAdaptor_HCurve(C3d,Pardeb,Parfin));
@@ -1329,11 +1329,11 @@ void ChFi3d_ComputePCurv(const Handle(Geom_Curve)&   C3d,
 //           to guarantee the same range.
 //=======================================================================
 void ChFi3d_ComputePCurv(const gp_Pnt2d& UV1,
-                         const gp_Pnt2d& UV2,
-                         Handle(Geom2d_Curve)& Pcurv,
-                         const Standard_Real Pardeb,
-                         const Standard_Real Parfin,
-                         const Standard_Boolean reverse)
+  const gp_Pnt2d& UV2,
+  Handle(Geom2d_Curve)& Pcurv,
+  const Standard_Real Pardeb,
+  const Standard_Real Parfin,
+  const Standard_Boolean reverse)
 {
   const Standard_Real tol = Precision::PConfusion();
   gp_Pnt2d p1,p2;
@@ -1345,26 +1345,26 @@ void ChFi3d_ComputePCurv(const gp_Pnt2d& UV1,
     p1 = UV2;
     p2 = UV1;
   }
-  
+
   if (Abs(p1.X()-p2.X()) <= tol &&
-      Abs((p2.Y()-p1.Y())-(Parfin-Pardeb)) <= tol) {
-    gp_Pnt2d ppp(p1.X(),p1.Y()-Pardeb);
-    Pcurv = new Geom2d_Line(ppp,gp::DY2d());
+    Abs((p2.Y()-p1.Y())-(Parfin-Pardeb)) <= tol) {
+      gp_Pnt2d ppp(p1.X(),p1.Y()-Pardeb);
+      Pcurv = new Geom2d_Line(ppp,gp::DY2d());
   }
   else if (Abs(p1.X()-p2.X()) <= tol &&
-          Abs((p1.Y()-p2.Y())-(Parfin-Pardeb)) <= tol) {
-    gp_Pnt2d ppp(p1.X(),p1.Y()+Pardeb);
-    Pcurv = new Geom2d_Line(ppp,gp::DY2d().Reversed());
+    Abs((p1.Y()-p2.Y())-(Parfin-Pardeb)) <= tol) {
+      gp_Pnt2d ppp(p1.X(),p1.Y()+Pardeb);
+      Pcurv = new Geom2d_Line(ppp,gp::DY2d().Reversed());
   }
   else if (Abs(p1.Y()-p2.Y()) <= tol &&
-          Abs((p2.X()-p1.X())-(Parfin-Pardeb)) <= tol) {
-    gp_Pnt2d ppp(p1.X()-Pardeb,p1.Y());
-    Pcurv = new Geom2d_Line(ppp,gp::DX2d());
+    Abs((p2.X()-p1.X())-(Parfin-Pardeb)) <= tol) {
+      gp_Pnt2d ppp(p1.X()-Pardeb,p1.Y());
+      Pcurv = new Geom2d_Line(ppp,gp::DX2d());
   }
   else if (Abs(p1.Y()-p2.Y()) <= tol &&
-          Abs((p1.X()-p2.X())-(Parfin-Pardeb)) <= tol) {
-    gp_Pnt2d ppp(p1.X()+Pardeb,p1.Y());
-    Pcurv = new Geom2d_Line(ppp,gp::DX2d().Reversed());
+    Abs((p1.X()-p2.X())-(Parfin-Pardeb)) <= tol) {
+      gp_Pnt2d ppp(p1.X()+Pardeb,p1.Y());
+      Pcurv = new Geom2d_Line(ppp,gp::DX2d().Reversed());
   }
   else{
     TColgp_Array1OfPnt2d p(1,2);
@@ -1384,15 +1384,15 @@ void ChFi3d_ComputePCurv(const gp_Pnt2d& UV1,
 //purpose  : 
 //=======================================================================
 Handle(GeomFill_Boundary) ChFi3d_mkbound(const Handle(Adaptor3d_HSurface)& Fac,
-                                         Handle(Geom2d_Curve)& curv, 
-                                         const Standard_Integer sens1,
-                                         const gp_Pnt2d& pfac1,
-                                         const gp_Vec2d& vfac1,
-                                         const Standard_Integer sens2,
-                                         const gp_Pnt2d& pfac2,
-                                         const gp_Vec2d& vfac2,
-                                         const Standard_Real t3d,
-                                         const Standard_Real ta)
+  Handle(Geom2d_Curve)& curv, 
+  const Standard_Integer sens1,
+  const gp_Pnt2d& pfac1,
+  const gp_Vec2d& vfac1,
+  const Standard_Integer sens2,
+  const gp_Pnt2d& pfac2,
+  const gp_Vec2d& vfac2,
+  const Standard_Real t3d,
+  const Standard_Real ta)
 {
   gp_Dir2d v1(vfac1);
   if(sens1 == 1) v1.Reverse();
@@ -1406,15 +1406,15 @@ Handle(GeomFill_Boundary) ChFi3d_mkbound(const Handle(Adaptor3d_HSurface)& Fac,
 //purpose  : 
 //=======================================================================
 Handle(GeomFill_Boundary) ChFi3d_mkbound(const Handle(Adaptor3d_HSurface)& Surf,
-                                         Handle(Geom2d_Curve)& curv,
-                                         const Standard_Integer sens1,
-                                         const gp_Pnt2d& p1,
-                                         gp_Vec&   v1,
-                                         const Standard_Integer sens2,
-                                         const gp_Pnt2d& p2,
-                                         gp_Vec& v2,
-                                         const Standard_Real t3d,
-                                         const Standard_Real ta)
+  Handle(Geom2d_Curve)& curv,
+  const Standard_Integer sens1,
+  const gp_Pnt2d& p1,
+  gp_Vec&   v1,
+  const Standard_Integer sens2,
+  const gp_Pnt2d& p2,
+  gp_Vec& v2,
+  const Standard_Real t3d,
+  const Standard_Real ta)
 {
   if(sens1 == 1) v1.Reverse();
   if(sens2 == 1) v2.Reverse();
@@ -1426,11 +1426,11 @@ Handle(GeomFill_Boundary) ChFi3d_mkbound(const Handle(Adaptor3d_HSurface)& Surf,
 //purpose  : 
 //=======================================================================
 Handle(GeomFill_Boundary) ChFi3d_mkbound(const Handle(Geom_Surface)& s,
-                                         const gp_Pnt2d& p1,
-                                         const gp_Pnt2d& p2,
-                                         const Standard_Real t3d,
-                                         const Standard_Real ta,
-                                         const Standard_Boolean isfreeboundary)
+  const gp_Pnt2d& p1,
+  const gp_Pnt2d& p2,
+  const Standard_Real t3d,
+  const Standard_Real ta,
+  const Standard_Boolean isfreeboundary)
 {
   Handle(GeomAdaptor_HSurface) HS = new GeomAdaptor_HSurface(s);
   return ChFi3d_mkbound(HS,p1,p2,t3d,ta,isfreeboundary);
@@ -1440,11 +1440,11 @@ Handle(GeomFill_Boundary) ChFi3d_mkbound(const Handle(Geom_Surface)& s,
 //purpose  : 
 //=======================================================================
 Handle(GeomFill_Boundary) ChFi3d_mkbound(const Handle(Adaptor3d_HSurface)& HS,
-                                         const gp_Pnt2d& p1,
-                                         const gp_Pnt2d& p2,
-                                         const Standard_Real t3d,
-                                         const Standard_Real ta,
-                                         const Standard_Boolean isfreeboundary)
+  const gp_Pnt2d& p1,
+  const gp_Pnt2d& p2,
+  const Standard_Real t3d,
+  const Standard_Real ta,
+  const Standard_Boolean isfreeboundary)
 {
   TColgp_Array1OfPnt2d pol(1,2);
   pol(1)=p1;
@@ -1457,10 +1457,10 @@ Handle(GeomFill_Boundary) ChFi3d_mkbound(const Handle(Adaptor3d_HSurface)& HS,
 //purpose  : 
 //=======================================================================
 Handle(GeomFill_Boundary) ChFi3d_mkbound(const Handle(Adaptor3d_HSurface)& HS,
-                                         const Handle(Geom2d_Curve)& curv,
-                                         const Standard_Real t3d,
-                                         const Standard_Real ta,
-                                         const Standard_Boolean isfreeboundary)
+  const Handle(Geom2d_Curve)& curv,
+  const Standard_Real t3d,
+  const Standard_Real ta,
+  const Standard_Boolean isfreeboundary)
 {
   Handle(Geom2dAdaptor_HCurve) HC = new Geom2dAdaptor_HCurve(curv);
   Adaptor3d_CurveOnSurface COnS(HC,HS);
@@ -1475,12 +1475,12 @@ Handle(GeomFill_Boundary) ChFi3d_mkbound(const Handle(Adaptor3d_HSurface)& HS,
 //purpose  : 
 //=======================================================================
 Handle(GeomFill_Boundary) ChFi3d_mkbound(const Handle(Adaptor3d_HSurface)& Fac,
-                                         Handle(Geom2d_Curve)& curv, 
-                                         const gp_Pnt2d& p1,
-                                         const gp_Pnt2d& p2,
-                                         const Standard_Real t3d,
-                                         const Standard_Real ta,
-                                         const Standard_Boolean isfreeboundary)
+  Handle(Geom2d_Curve)& curv, 
+  const gp_Pnt2d& p1,
+  const gp_Pnt2d& p2,
+  const Standard_Real t3d,
+  const Standard_Real ta,
+  const Standard_Boolean isfreeboundary)
 {
   TColgp_Array1OfPnt2d pol(1,2);
   pol(1)=p1;
@@ -1493,10 +1493,10 @@ Handle(GeomFill_Boundary) ChFi3d_mkbound(const Handle(Adaptor3d_HSurface)& Fac,
 //purpose  : 
 //=======================================================================
 Handle(Geom2d_Curve) ChFi3d_BuildPCurve(const gp_Pnt2d& p1,
-                                       gp_Dir2d& d1,
-                                       const gp_Pnt2d& p2,
-                                       gp_Dir2d& d2,
-                                       const Standard_Boolean redresse)
+  gp_Dir2d& d1,
+  const gp_Pnt2d& p2,
+  gp_Dir2d& d2,
+  const Standard_Boolean redresse)
 {
   gp_Vec2d vref(p1,p2);
   gp_Dir2d dref(vref);
@@ -1522,11 +1522,11 @@ Handle(Geom2d_Curve) ChFi3d_BuildPCurve(const gp_Pnt2d& p1,
 //purpose  : 
 //=======================================================================
 Handle(Geom2d_Curve) ChFi3d_BuildPCurve(const Handle(Adaptor3d_HSurface)& Surf,
-                                       const gp_Pnt2d&                 p1,
-                                       const gp_Vec2d&                 v1,
-                                       const gp_Pnt2d&                 p2,
-                                       const gp_Vec2d&                 v2,
-                                       const Standard_Boolean          redresse)
+  const gp_Pnt2d&                 p1,
+  const gp_Vec2d&                 v1,
+  const gp_Pnt2d&                 p2,
+  const gp_Vec2d&                 v2,
+  const Standard_Boolean          redresse)
 {
   gp_Pnt2d pp1 = p1, pp2 = p2;
   gp_Vec2d vv1 = v1, vv2 = v2;
@@ -1554,11 +1554,11 @@ Handle(Geom2d_Curve) ChFi3d_BuildPCurve(const Handle(Adaptor3d_HSurface)& Surf,
 //purpose  : 
 //=======================================================================
 Handle(Geom2d_Curve) ChFi3d_BuildPCurve(const Handle(Adaptor3d_HSurface)& Surf,
-                                       const gp_Pnt2d&                 p1,
-                                       const gp_Vec&                   v1,
-                                       const gp_Pnt2d&                 p2,
-                                       const gp_Vec&                   v2,
-                                       const Standard_Boolean          redresse)
+  const gp_Pnt2d&                 p1,
+  const gp_Vec&                   v1,
+  const gp_Pnt2d&                 p2,
+  const gp_Vec&                   v2,
+  const Standard_Boolean          redresse)
 {
   gp_Vec D1u,D1v;
   gp_Pnt PP1,PP2;
@@ -1593,20 +1593,20 @@ Handle(Geom2d_Curve) ChFi3d_BuildPCurve(const Handle(Adaptor3d_HSurface)& Surf,
 //
 //=======================================================================
 void  ChFi3d_ComputeArete(const ChFiDS_CommonPoint&   P1,
-                         const gp_Pnt2d&             UV1,
-                         const ChFiDS_CommonPoint&   P2,
-                         const gp_Pnt2d&             UV2,
-                         const Handle(Geom_Surface)& Surf,
-                         Handle(Geom_Curve)&         C3d,
-                         Handle(Geom2d_Curve)&       Pcurv,
-                         Standard_Real&              Pardeb,
-                         Standard_Real&              Parfin,
-                         const Standard_Real         tol3d,
-                         const Standard_Real         tol2d,
-                         Standard_Real&              tolreached,
-                         const Standard_Integer      IFlag)
-     // IFlag=0 pcurve et courbe 3d 
-     // IFlag>0 pcurve (parametrage impose si IFlag=2)
+  const gp_Pnt2d&             UV1,
+  const ChFiDS_CommonPoint&   P2,
+  const gp_Pnt2d&             UV2,
+  const Handle(Geom_Surface)& Surf,
+  Handle(Geom_Curve)&         C3d,
+  Handle(Geom2d_Curve)&       Pcurv,
+  Standard_Real&              Pardeb,
+  Standard_Real&              Parfin,
+  const Standard_Real         tol3d,
+  const Standard_Real         tol2d,
+  Standard_Real&              tolreached,
+  const Standard_Integer      IFlag)
+  // IFlag=0 pcurve et courbe 3d 
+  // IFlag>0 pcurve (parametrage impose si IFlag=2)
 {
   /*szv:static*/ Handle(GeomAdaptor_HSurface) hs(new GeomAdaptor_HSurface());
   /*szv:static*/ Handle(GeomAdaptor_HCurve) hc(new GeomAdaptor_HCurve());
@@ -1619,17 +1619,17 @@ void  ChFi3d_ComputeArete(const ChFiDS_CommonPoint&   P1,
       Parfin = UV2.Y();
       C3d = Surf->UIso(UV1.X());
       if(Pardeb > Parfin) {
-       Pardeb = C3d->ReversedParameter(Pardeb);
-       Parfin = C3d->ReversedParameter(Parfin);
-       C3d->Reverse();
+        Pardeb = C3d->ReversedParameter(Pardeb);
+        Parfin = C3d->ReversedParameter(Parfin);
+        C3d->Reverse();
       }
       Handle(Geom_TrimmedCurve) tc = Handle(Geom_TrimmedCurve)::DownCast(C3d);
       if(!tc.IsNull()) {
-       C3d = tc->BasisCurve();
-       if (C3d->IsPeriodic()) {
-         ElCLib::AdjustPeriodic(C3d->FirstParameter(),C3d->LastParameter(),
-                                tol2d,Pardeb,Parfin);
-       }
+        C3d = tc->BasisCurve();
+        if (C3d->IsPeriodic()) {
+          ElCLib::AdjustPeriodic(C3d->FirstParameter(),C3d->LastParameter(),
+            tol2d,Pardeb,Parfin);
+        }
       }
     }
     if(IFlag != 1) {
@@ -1648,17 +1648,17 @@ void  ChFi3d_ComputeArete(const ChFiDS_CommonPoint&   P1,
       Parfin = UV2.X();
       C3d = Surf->VIso(UV1.Y());
       if(Pardeb > Parfin) {
-       Pardeb = C3d->ReversedParameter(Pardeb);
-       Parfin = C3d->ReversedParameter(Parfin);
-       C3d->Reverse();
+        Pardeb = C3d->ReversedParameter(Pardeb);
+        Parfin = C3d->ReversedParameter(Parfin);
+        C3d->Reverse();
       }
       Handle(Geom_TrimmedCurve) tc = Handle(Geom_TrimmedCurve)::DownCast(C3d);
       if(!tc.IsNull()) {
-       C3d = tc->BasisCurve();
-       if (C3d->IsPeriodic()) {
-         ElCLib::AdjustPeriodic(C3d->FirstParameter(),C3d->LastParameter(),
-                                tol2d,Pardeb,Parfin);
-       }
+        C3d = tc->BasisCurve();
+        if (C3d->IsPeriodic()) {
+          ElCLib::AdjustPeriodic(C3d->FirstParameter(),C3d->LastParameter(),
+            tol2d,Pardeb,Parfin);
+        }
       }
     }
     if(IFlag != 1) {
@@ -1673,8 +1673,8 @@ void  ChFi3d_ComputeArete(const ChFiDS_CommonPoint&   P1,
   else if (IFlag == 0) {
 
     if (P1.IsVertex() || P2.IsVertex() || !P1.IsOnArc() || !P2.IsOnArc()) {
-    // A straight line is constructed to avoid  
-    // arc and tangent.
+      // A straight line is constructed to avoid  
+      // arc and tangent.
       TColgp_Array1OfPnt2d qoles(1,2);
       qoles(1)=UV1;
       qoles(2)=UV2;
@@ -1702,12 +1702,12 @@ void  ChFi3d_ComputeArete(const ChFiDS_CommonPoint&   P1,
       Standard_Boolean aIN = Standard_True;
       for(Standard_Integer ii = 1; ii <= 4 && aIN; ii++) {
        if(bs.IsOut((*((Handle(Geom2d_BezierCurve)*) &Pcurv))->Pole(ii))) {
-         aIN = Standard_False;
-         TColgp_Array1OfPnt2d qoles(1,2);
-         qoles(1)=UV1;
-         qoles(2)=UV2;
-         Pcurv = new Geom2d_BezierCurve(qoles);
-       }
+          aIN = Standard_False;
+          TColgp_Array1OfPnt2d qoles(1,2);
+          qoles(1)=UV1;
+          qoles(2)=UV2;
+          Pcurv = new Geom2d_BezierCurve(qoles);
+        }
       }
     }
     Geom2dAdaptor_Curve AC(Pcurv);
@@ -1738,16 +1738,16 @@ void  ChFi3d_ComputeArete(const ChFiDS_CommonPoint&   P1,
 //purpose  : 
 //=======================================================================
 Handle(TopOpeBRepDS_SurfaceCurveInterference)  ChFi3d_FilCurveInDS
-(const Standard_Integer Icurv,
- const Standard_Integer Isurf,
- const Handle(Geom2d_Curve)& Pcurv,
- const TopAbs_Orientation Et)
+  (const Standard_Integer Icurv,
+  const Standard_Integer Isurf,
+  const Handle(Geom2d_Curve)& Pcurv,
+  const TopAbs_Orientation Et)
 {
   Handle(TopOpeBRepDS_SurfaceCurveInterference) SC1;
   SC1 = new TopOpeBRepDS_SurfaceCurveInterference(TopOpeBRepDS_Transition(Et),
-                                                 TopOpeBRepDS_SURFACE,
-                                                 Isurf,TopOpeBRepDS_CURVE,Icurv,
-                                                 Pcurv);
+    TopOpeBRepDS_SURFACE,
+    Isurf,TopOpeBRepDS_CURVE,Icurv,
+    Pcurv);
   return SC1;
 }
 //=======================================================================
@@ -1758,10 +1758,10 @@ Handle(TopOpeBRepDS_SurfaceCurveInterference)  ChFi3d_FilCurveInDS
 TopAbs_Orientation ChFi3d_TrsfTrans(const IntSurf_TypeTrans T1) 
 {
   switch (T1)  {
-    case IntSurf_In:  return TopAbs_FORWARD;
-    case IntSurf_Out: return TopAbs_REVERSED;
-    default:
-      break;
+  case IntSurf_In:  return TopAbs_FORWARD;
+  case IntSurf_Out: return TopAbs_REVERSED;
+  default:
+    break;
   }
   return TopAbs_INTERNAL;
 }
@@ -1771,12 +1771,12 @@ TopAbs_Orientation ChFi3d_TrsfTrans(const IntSurf_TypeTrans T1)
 //           management of the case when it happens on already existing vertex.
 //=======================================================================
 Standard_EXPORT void ChFi3d_FilCommonPoint(const BRepBlend_Extremity& SP,
-                                          const IntSurf_TypeTrans TransLine,
-                                          const Standard_Boolean Start,
-                                          ChFiDS_CommonPoint& CP,
-                                          const Standard_Real Tol)
+  const IntSurf_TypeTrans TransLine,
+  const Standard_Boolean Start,
+  ChFiDS_CommonPoint& CP,
+  const Standard_Real Tol)
 {
-//  BRep_Tool Outil;
+  //  BRep_Tool Outil;
   Standard_Real Dist, maxtol = Max(Tol,CP.Tolerance());
 
   CP.SetPoint(SP.Value()); // One starts with the point and the vector
@@ -1788,14 +1788,14 @@ Standard_EXPORT void ChFi3d_FilCommonPoint(const BRepBlend_Extremity& SP,
       CP.SetVector(SP.Tangent());
     }
   }
-  
+
   CP.SetParameter(SP.ParameterOnGuide()); // and the parameter of the spine
 
   if (SP.IsVertex()) { // the Vertex is loaded if required
-                       // (inside of a face)
+    // (inside of a face)
     TopoDS_Vertex V =  
       Handle(BRepTopAdaptor_HVertex)::DownCast(SP.Vertex())->Vertex();
-  
+
     CP.SetVertex(V);  
     Dist = (SP.Value()).Distance(BRep_Tool::Pnt(V));
     //// modified by jgv, 18.09.02 for OCC571 ////
@@ -1803,11 +1803,11 @@ Standard_EXPORT void ChFi3d_FilCommonPoint(const BRepBlend_Extremity& SP,
     maxtol = Max( Dist, maxtol );
     //////////////////////////////////////////////
     CP.SetPoint(BRep_Tool::Pnt(V));
-    
+
     //the sequence of arcs the information is known by thee vertex (ancestor)
     //in this case the transitions are not computed, it is done by this program
   }
-  
+
   if (SP.NbPointOnRst() != 0) { //  An arc, and/or a vertex is loaded
 
     const BRepBlend_PointOnRst& PR = SP.PointOnRst(1);
@@ -1825,35 +1825,35 @@ Standard_EXPORT void ChFi3d_FilCommonPoint(const BRepBlend_Extremity& SP,
       DistF = (SP.Value()).Distance(BRep_Tool::Pnt(V[0]));
       DistL = (SP.Value()).Distance(BRep_Tool::Pnt(V[1]));
       if (DistF<DistL) { Index_min = 0;
-                        Dist = DistF; }
+      Dist = DistF; }
       else             { Index_min = 1;
-                        Dist = DistL; }
+      Dist = DistL; }
 
       if (Dist <= maxtol + BRep_Tool::Tolerance(V[Index_min]) ) { 
-       // a prexisting vertex has been met
-        CP.SetVertex(V[Index_min]); //the old vertex is loaded
-         CP.SetPoint( BRep_Tool::Pnt(V[Index_min]) );
-         maxtol = Max(BRep_Tool::Tolerance(V[Index_min]),maxtol);
-        //// modified by jgv, 18.09.02 for OCC571 ////
-        //maxtol += Dist;
-        maxtol = Max( Dist, maxtol );
-        //////////////////////////////////////////////
-         LeParamAmoi = BRep_Tool::Parameter(V[Index_min], E);    
+        // a prexisting vertex has been met
+        CP.SetVertex(V[Index_min]); //the old vertex is loaded
+        CP.SetPoint( BRep_Tool::Pnt(V[Index_min]) );
+        maxtol = Max(BRep_Tool::Tolerance(V[Index_min]),maxtol);
+        //// modified by jgv, 18.09.02 for OCC571 ////
+        //maxtol += Dist;
+        maxtol = Max( Dist, maxtol );
+        //////////////////////////////////////////////
+        LeParamAmoi = BRep_Tool::Parameter(V[Index_min], E);    
       }
       else {   // Creation of an arc only
-       maxtol = Max(BRep_Tool::Tolerance(E),maxtol);
-       maxtol = Max(SP.Tolerance(),maxtol);
-       LeParamAmoi = PR.ParameterOnArc();
+        maxtol = Max(BRep_Tool::Tolerance(E),maxtol);
+        maxtol = Max(SP.Tolerance(),maxtol);
+        LeParamAmoi = PR.ParameterOnArc();
       }
 
       // Definition of the arc
       TopAbs_Orientation Tr;
       TopAbs_Orientation Or = E.Orientation();
       if (Start) {
-       Tr = TopAbs::Reverse(TopAbs::Compose(ChFi3d_TrsfTrans(TransLine),Or));
+        Tr = TopAbs::Reverse(TopAbs::Compose(ChFi3d_TrsfTrans(TransLine),Or));
       }
       else {
-       Tr = TopAbs::Compose(ChFi3d_TrsfTrans(TransLine),Or);
+        Tr = TopAbs::Compose(ChFi3d_TrsfTrans(TransLine),Or);
       }
       CP.SetArc(maxtol, E, LeParamAmoi, Tr);
     }
@@ -1866,9 +1866,9 @@ Standard_EXPORT void ChFi3d_FilCommonPoint(const BRepBlend_Extremity& SP,
 //purpose  : 
 //=======================================================================
 Standard_Integer ChFi3d_SolidIndex(const Handle(ChFiDS_Spine)&  sp,
-                                  TopOpeBRepDS_DataStructure&  DStr,
-                                  ChFiDS_Map&                  MapESo,
-                                  ChFiDS_Map&                  MapESh)
+  TopOpeBRepDS_DataStructure&  DStr,
+  ChFiDS_Map&                  MapESo,
+  ChFiDS_Map&                  MapESh)
 {
   if(sp.IsNull() || sp->NbEdges() == 0) 
     Standard_Failure::Raise("SolidIndex : Spine incomplete");
@@ -1884,7 +1884,7 @@ Standard_Integer ChFi3d_SolidIndex(const Handle(ChFiDS_Spine)&  sp,
 //purpose  : 
 //=======================================================================
 Standard_Integer  ChFi3d_IndexPointInDS(const ChFiDS_CommonPoint& P1,
-                                       TopOpeBRepDS_DataStructure& DStr) 
+  TopOpeBRepDS_DataStructure& DStr) 
 {
   if (P1.IsVertex()) {
     // --------------------------------->  !*!*!* 
@@ -1901,21 +1901,21 @@ Standard_Integer  ChFi3d_IndexPointInDS(const ChFiDS_CommonPoint& P1,
 //purpose  : 
 //=======================================================================
 Handle(TopOpeBRepDS_CurvePointInterference) 
-     ChFi3d_FilPointInDS(const TopAbs_Orientation Et,
-                        const Standard_Integer Ic,
-                        const Standard_Integer Ip,
-                        const Standard_Real Par,
-                        const Standard_Boolean IsVertex)
+  ChFi3d_FilPointInDS(const TopAbs_Orientation Et,
+  const Standard_Integer Ic,
+  const Standard_Integer Ip,
+  const Standard_Real Par,
+  const Standard_Boolean IsVertex)
 {
   Handle(TopOpeBRepDS_CurvePointInterference) CP1;
   if (IsVertex)    
     CP1 = new TopOpeBRepDS_CurvePointInterference (TopOpeBRepDS_Transition(Et),
-                                                  TopOpeBRepDS_CURVE,Ic,
-                                                  TopOpeBRepDS_VERTEX,Ip,Par); 
+    TopOpeBRepDS_CURVE,Ic,
+    TopOpeBRepDS_VERTEX,Ip,Par); 
   else
     CP1 = new TopOpeBRepDS_CurvePointInterference (TopOpeBRepDS_Transition(Et),
-                                                  TopOpeBRepDS_CURVE,Ic,
-                                                  TopOpeBRepDS_POINT,Ip,Par);
+    TopOpeBRepDS_CURVE,Ic,
+    TopOpeBRepDS_POINT,Ip,Par);
   return CP1;
 }
 //=======================================================================
@@ -1923,16 +1923,16 @@ Handle(TopOpeBRepDS_CurvePointInterference)
 //purpose  : 
 //=======================================================================
 Handle(TopOpeBRepDS_CurvePointInterference) 
-     ChFi3d_FilVertexInDS(const TopAbs_Orientation Et,
-                         const Standard_Integer Ic,
-                         const Standard_Integer Ip,
-                         const Standard_Real Par)
+  ChFi3d_FilVertexInDS(const TopAbs_Orientation Et,
+  const Standard_Integer Ic,
+  const Standard_Integer Ip,
+  const Standard_Real Par)
 {
-  
+
   Handle(TopOpeBRepDS_CurvePointInterference) CP1 = new
     TopOpeBRepDS_CurvePointInterference (TopOpeBRepDS_Transition(Et),
-                                        TopOpeBRepDS_CURVE,Ic,
-                                        TopOpeBRepDS_VERTEX,Ip,Par);
+    TopOpeBRepDS_CURVE,Ic,
+    TopOpeBRepDS_VERTEX,Ip,Par);
   return CP1;
 }
 //=======================================================================
@@ -1943,11 +1943,11 @@ Handle(TopOpeBRepDS_CurvePointInterference)
 
 static Standard_Boolean
   ChFi3d_Orientation(const TopOpeBRepDS_ListOfInterference& LI,
-                    const Standard_Integer                 igros,
-                    const Standard_Integer                 ipetit,
-                    TopAbs_Orientation&                    Or,
-                    const Standard_Boolean                 isvertex = Standard_False,
-                    const Standard_Boolean                 aprendre = Standard_False)
+  const Standard_Integer                 igros,
+  const Standard_Integer                 ipetit,
+  TopAbs_Orientation&                    Or,
+  const Standard_Boolean                 isvertex = Standard_False,
+  const Standard_Boolean                 aprendre = Standard_False)
 {
   //In case, when it is necessary to insert a point/vertex, it should be 
   //known if this is a point or a vertex, because their index can be the same.
@@ -1966,14 +1966,14 @@ static Standard_Boolean
     cur->GKGSKS(GK,G,SK,S);
     if (aprendre) {
       if ( S == igros && G == ipetit && GK == typepetit) {
-       Or = cur->Transition().Orientation(TopAbs_IN);
-       return Standard_True;
+        Or = cur->Transition().Orientation(TopAbs_IN);
+        return Standard_True;
       }
     }
     else  {
       if ( S == igros && G == ipetit) {
-       Or = cur->Transition().Orientation(TopAbs_IN);
-       return Standard_True;
+        Or = cur->Transition().Orientation(TopAbs_IN);
+        return Standard_True;
       } 
     }
   }
@@ -1986,11 +1986,11 @@ static Standard_Boolean
 //====================================================================
 
 static Standard_Boolean ChFi3d_Contains
-(const TopOpeBRepDS_ListOfInterference& LI,
- const Standard_Integer                 igros,
- const Standard_Integer                 ipetit,
- const Standard_Boolean                 isvertex = Standard_False,
- const Standard_Boolean                 aprendre = Standard_False)                             
+  (const TopOpeBRepDS_ListOfInterference& LI,
+  const Standard_Integer                 igros,
+  const Standard_Integer                 ipetit,
+  const Standard_Boolean                 isvertex = Standard_False,
+  const Standard_Boolean                 aprendre = Standard_False)                             
 {
   TopAbs_Orientation bidOr;
   return ChFi3d_Orientation(LI,igros,ipetit,bidOr,isvertex,aprendre);
@@ -2000,10 +2000,10 @@ static Standard_Boolean ChFi3d_Contains
 //purpose  : 
 //=======================================================================
 static void QueryAddVertexInEdge(TopOpeBRepDS_ListOfInterference& LI,
-                                const Standard_Integer                 IC,
-                                const Standard_Integer                 IV,
-                                const Standard_Real                    par,
-                                const TopAbs_Orientation               Or)
+  const Standard_Integer                 IC,
+  const Standard_Integer                 IV,
+  const Standard_Real                    par,
+  const TopAbs_Orientation               Or)
 {
   TopOpeBRepDS_ListIteratorOfListOfInterference it(LI);
   for (; it.More(); it.Next() ) {
@@ -2016,8 +2016,8 @@ static void QueryAddVertexInEdge(TopOpeBRepDS_ListOfInterference& LI,
       TopAbs_Orientation newOr = cpi->Transition().Orientation(TopAbs_IN);
       Standard_Real newpar = cpi->Parameter();
       if(IV == newIV && kv == TopOpeBRepDS_VERTEX && 
-        Or == newOr && Abs(par - newpar) < 1.e-10) {
-       return;
+        Or == newOr && Abs(par - newpar) < 1.e-10) {
+          return;
       }
     }
   }
@@ -2031,10 +2031,10 @@ static void QueryAddVertexInEdge(TopOpeBRepDS_ListOfInterference& LI,
 //purpose  : 
 //=======================================================================
 static void CutEdge(const TopoDS_Vertex&           V,
-                   const Handle(ChFiDS_SurfData)& SD,
-                   TopOpeBRepDS_DataStructure&    DStr,
-                   const Standard_Boolean         ,
-                   const Standard_Integer         ons)
+  const Handle(ChFiDS_SurfData)& SD,
+  TopOpeBRepDS_DataStructure&    DStr,
+  const Standard_Boolean         ,
+  const Standard_Integer         ons)
 {
   if(!SD->IsOnCurve(ons)) return;
   Standard_Integer IC = SD->IndexOfC(ons);
@@ -2061,15 +2061,15 @@ static void CutEdge(const TopoDS_Vertex&           V,
 //=======================================================================
 static Standard_Boolean 
   findIndexPoint(const TopOpeBRepDS_DataStructure& DStr,
-                const Handle(ChFiDS_SurfData)&    Fd,
-                const Standard_Integer            OnS,
-                Standard_Integer&                 ipoin)
+  const Handle(ChFiDS_SurfData)&    Fd,
+  const Standard_Integer            OnS,
+  Standard_Integer&                 ipoin)
 {
   ipoin = 0;
   gp_Pnt P = Fd->Vertex(Standard_False,OnS).Point();
 
   TopOpeBRepDS_ListIteratorOfListOfInterference SCIIt, CPIIt;
-  
+
   SCIIt.Initialize (DStr.SurfaceInterferences(Fd->Surf()));
   for (; SCIIt.More(); SCIIt.Next()) {
     Handle(TopOpeBRepDS_SurfaceCurveInterference) SCI =
@@ -2078,13 +2078,13 @@ static Standard_Boolean
     CPIIt.Initialize (DStr.CurveInterferences(SCI->Geometry()));
     for (; CPIIt.More(); CPIIt.Next()) {
       Handle(TopOpeBRepDS_CurvePointInterference) CPI =
-       Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(CPIIt.Value());
+        Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(CPIIt.Value());
       if (CPI.IsNull()) continue;
       Standard_Integer iPoint = CPI->Geometry();
       TopOpeBRepDS_Point tp = DStr.Point(iPoint);
       if (P.IsEqual(tp.Point(), tp.Tolerance())) {
-       ipoin = iPoint;
-       return Standard_True;
+        ipoin = iPoint;
+        return Standard_True;
       }
     }
   }
@@ -2095,13 +2095,13 @@ static Standard_Boolean
 //purpose  : 
 //=======================================================================
 void  ChFi3d_FilDS(const Standard_Integer       SolidIndex,
-                  const Handle(ChFiDS_Stripe)& CorDat,
-                  TopOpeBRepDS_DataStructure&  DStr,
-                  ChFiDS_Regularities&         reglist,
-                  const Standard_Real          tol3d,
-                  const Standard_Real          tol2d) 
+  const Handle(ChFiDS_Stripe)& CorDat,
+  TopOpeBRepDS_DataStructure&  DStr,
+  ChFiDS_Regularities&         reglist,
+  const Standard_Real          tol3d,
+  const Standard_Real          tol2d) 
 {
-//  BRep_Tool Outil;
+  //  BRep_Tool Outil;
   TopExp_Explorer ex;
   Handle(ChFiDS_Spine) spine = CorDat->Spine();
   Standard_Boolean Closed = Standard_False;
@@ -2146,25 +2146,25 @@ void  ChFi3d_FilDS(const Standard_Integer       SolidIndex,
       Handle(ChFiDS_SurfData) Fd = SeqFil(j);
       Standard_Integer onS;
       for (onS=1; onS<=2; onS++) {
-       const ChFiDS_FaceInterference& Fi = Fd->Interference(onS);
-       IcFil1 = Fi.LineIndex();
-       if (!IcFil1) continue;
-       Standard_Real FiLen = Abs(Fi.FirstParameter()-Fi.LastParameter());
-       if (FiLen > Precision::PConfusion()) continue;
-       TopOpeBRepDS_Curve& cc = DStr.ChangeCurve(IcFil1);
-       cc.ChangeCurve().Nullify();
-
-       // care of CommonPoint, eap occ354
-       if (j!=1 && j!=SeqFil.Length()) continue;
-       Standard_Boolean isfirst = (j==1);
-       Standard_Integer i = isfirst ? j+1 : j-1;
-       ChFiDS_CommonPoint& CP1 = SeqFil(i)->ChangeVertex(isfirst,onS);
-       if (Fd->Vertex(isfirst,onS).IsOnArc() && CP1.IsOnArc()) {
-         ChFiDS_CommonPoint& CP2 = Fd->ChangeVertex(!isfirst,onS);
-         CP1.Reset();
-         CP1.SetPoint(CP2.Point());
-         CP2.Reset();
-         CP2.SetPoint(CP1.Point());
+        const ChFiDS_FaceInterference& Fi = Fd->Interference(onS);
+        IcFil1 = Fi.LineIndex();
+        if (!IcFil1) continue;
+        Standard_Real FiLen = Abs(Fi.FirstParameter()-Fi.LastParameter());
+        if (FiLen > Precision::PConfusion()) continue;
+        TopOpeBRepDS_Curve& cc = DStr.ChangeCurve(IcFil1);
+        cc.ChangeCurve().Nullify();
+
+        // care of CommonPoint, eap occ354
+        if (j!=1 && j!=SeqFil.Length()) continue;
+        Standard_Boolean isfirst = (j==1);
+        Standard_Integer i = isfirst ? j+1 : j-1;
+        ChFiDS_CommonPoint& CP1 = SeqFil(i)->ChangeVertex(isfirst,onS);
+        if (Fd->Vertex(isfirst,onS).IsOnArc() && CP1.IsOnArc()) {
+          ChFiDS_CommonPoint& CP2 = Fd->ChangeVertex(!isfirst,onS);
+          CP1.Reset();
+          CP1.SetPoint(CP2.Point());
+          CP2.Reset();
+          CP2.SetPoint(CP1.Point());
         }
       }
     }
@@ -2189,19 +2189,19 @@ void  ChFi3d_FilDS(const Standard_Integer       SolidIndex,
       isInDS2 = Standard_True;
       isInDS1 = isInDS1 || SeqFil.Length()-j+1 < CorDat->IsInDS(Standard_False);
     }
-    
+
     // creation of SolidSurfaceInterference
-    
+
     Handle(TopOpeBRepDS_SolidSurfaceInterference) 
       SSI = new TopOpeBRepDS_SolidSurfaceInterference
-       (TopOpeBRepDS_Transition(Fd->Orientation()),
-        TopOpeBRepDS_SOLID,
-        SolidIndex,
-        TopOpeBRepDS_SURFACE,
-        Isurf);
-    
+      (TopOpeBRepDS_Transition(Fd->Orientation()),
+      TopOpeBRepDS_SOLID,
+      SolidIndex,
+      TopOpeBRepDS_SURFACE,
+      Isurf);
+
     SolidInterfs.Append(SSI);
-    
+
     const ChFiDS_FaceInterference& Fi1 = Fd->InterferenceOnS1();
     const ChFiDS_FaceInterference& Fi2 = Fd->InterferenceOnS2();     
     const ChFiDS_CommonPoint& V1 = Fd->VertexFirstOnS1();
@@ -2210,34 +2210,34 @@ void  ChFi3d_FilDS(const Standard_Integer       SolidIndex,
     // Processing to manage double interferences
     if (j>1) {
       if (V1.IsOnArc() && V3.IsOnArc() && V1.Arc().IsSame(V3.Arc())) {
-       //Iarc1 is initialized
-       //Iarc1 = DStr.AddShape(V1.Arc());
-       if (ChFi3d_Contains(DStr.ShapeInterferences(Iarc1),Iarc1,Ipoin1) && 
-           (V1.TransitionOnArc() != V3.TransitionOnArc()) ) {
-         Interfp1= ChFi3d_FilPointInDS(V1.TransitionOnArc(),Iarc1,Ipoin1,
-                                       V1.ParameterOnArc());
-         DStr.ChangeShapeInterferences(V1.Arc()).Append(Interfp1);
-       }
+        //Iarc1 is initialized
+        //Iarc1 = DStr.AddShape(V1.Arc());
+        if (ChFi3d_Contains(DStr.ShapeInterferences(Iarc1),Iarc1,Ipoin1) && 
+          (V1.TransitionOnArc() != V3.TransitionOnArc()) ) {
+            Interfp1= ChFi3d_FilPointInDS(V1.TransitionOnArc(),Iarc1,Ipoin1,
+              V1.ParameterOnArc());
+            DStr.ChangeShapeInterferences(V1.Arc()).Append(Interfp1);
+        }
       }
 
       if (V2.IsOnArc() && V4.IsOnArc() && V2.Arc().IsSame(V4.Arc())) {
-       //Iarc2 is initialized
-       //Iarc2 = DStr.AddShape(V2.Arc());
-       if ( ChFi3d_Contains(DStr.ShapeInterferences(Iarc2),Iarc2,Ipoin2)  && 
-           (V2.TransitionOnArc() != V4.TransitionOnArc()) ) {
-         Interfp2= ChFi3d_FilPointInDS(V2.TransitionOnArc(),Iarc2,Ipoin2,
-                                       V2.ParameterOnArc());
-         DStr.ChangeShapeInterferences(V2.Arc()).Append(Interfp2);
-       }
+        //Iarc2 is initialized
+        //Iarc2 = DStr.AddShape(V2.Arc());
+        if ( ChFi3d_Contains(DStr.ShapeInterferences(Iarc2),Iarc2,Ipoin2)  && 
+          (V2.TransitionOnArc() != V4.TransitionOnArc()) ) {
+            Interfp2= ChFi3d_FilPointInDS(V2.TransitionOnArc(),Iarc2,Ipoin2,
+              V2.ParameterOnArc());
+            DStr.ChangeShapeInterferences(V2.Arc()).Append(Interfp2);
+        }
       }
     }
 
     V3 = Fd->VertexLastOnS1();
     V4 = Fd->VertexLastOnS2();
-    
+
     if(Ishape1 != 0) {
       if(Ishape1 > 0) {
-       trafil1 = DStr.Shape(Ishape1).Orientation();
+        trafil1 = DStr.Shape(Ishape1).Orientation();
       }
       else{
         ChFi3d_Orientation(SolidInterfs,SolidIndex,-Ishape1,trafil1);
@@ -2248,7 +2248,7 @@ void  ChFi3d_FilDS(const Standard_Integer       SolidIndex,
     }
     else{
       if(Ishape2 > 0) {
-       trafil2 = DStr.Shape(Ishape2).Orientation();
+        trafil2 = DStr.Shape(Ishape2).Orientation();
       }
       else{
         ChFi3d_Orientation(SolidInterfs,SolidIndex,-Ishape2,trafil2);
@@ -2257,9 +2257,9 @@ void  ChFi3d_FilDS(const Standard_Integer       SolidIndex,
       trafil2 = TopAbs::Compose(TopAbs::Reverse(Fi2.Transition()),trafil2);
       trafil1 = TopAbs::Reverse(trafil2);
     }
-    
+
     ET1 = TopAbs::Reverse(trafil1);
-    
+
     // A small paragraph to process contacts of edges, which touch 
     // a vertex of the obstacle.
     if(V1.IsVertex() && Fd->IsOnCurve1()) {
@@ -2278,103 +2278,103 @@ void  ChFi3d_FilDS(const Standard_Integer       SolidIndex,
       const TopoDS_Vertex& vv4 = V4.Vertex();
       CutEdge(vv4,Fd,DStr,0,2);
     }
-    
+
     if (j == 1) {
       isVertex1 = V1.IsVertex();
       isVertex2 = V2.IsVertex();
       Singulier_en_Bout =  (V1.Point().IsEqual(V2.Point(), 0));
-      
+
       if (Singulier_en_Bout) {
-         // Queue de Billard
-         if ((!V1.IsVertex()) || (!V2.IsVertex())) {
-
-        }
-        else {
-          isVertex1 = isVertex2 = Standard_True; //caution...
-          // The edge is removed from spine starting on this vertex.
-          TopoDS_Edge Arcspine = spine->Edges(1);
-          BoutdeVtx = V1.Vertex();
-          Standard_Integer IArcspine = DStr.AddShape(Arcspine);
-          Standard_Integer IVtx = CorDat->IndexFirstPointOnS1();
-
-          TopAbs_Orientation OVtx = TopAbs_FORWARD;;
-
-          for(ex.Init(Arcspine.Oriented(TopAbs_FORWARD),TopAbs_VERTEX); 
-              ex.More(); ex.Next()) {
-            if(BoutdeVtx.IsSame(ex.Current())) {
-              OVtx = ex.Current().Orientation();
-              break;
-            }
-          }
-          OVtx = TopAbs::Reverse(OVtx);
-          Standard_Real parVtx = BRep_Tool::Parameter(BoutdeVtx,Arcspine);
-          Handle(TopOpeBRepDS_CurvePointInterference) 
-            interfv = ChFi3d_FilVertexInDS(OVtx,IArcspine,IVtx,parVtx);
-          DStr.ChangeShapeInterferences(IArcspine).Append(interfv);
-        }
-       }
+        // Queue de Billard
+        if ((!V1.IsVertex()) || (!V2.IsVertex())) {
+
+        }
+        else {
+          isVertex1 = isVertex2 = Standard_True; //caution...
+          // The edge is removed from spine starting on this vertex.
+          TopoDS_Edge Arcspine = spine->Edges(1);
+          BoutdeVtx = V1.Vertex();
+          Standard_Integer IArcspine = DStr.AddShape(Arcspine);
+          Standard_Integer IVtx = CorDat->IndexFirstPointOnS1();
+
+          TopAbs_Orientation OVtx = TopAbs_FORWARD;;
+
+          for(ex.Init(Arcspine.Oriented(TopAbs_FORWARD),TopAbs_VERTEX); 
+            ex.More(); ex.Next()) {
+              if(BoutdeVtx.IsSame(ex.Current())) {
+                OVtx = ex.Current().Orientation();
+                break;
+              }
+          }
+          OVtx = TopAbs::Reverse(OVtx);
+          Standard_Real parVtx = BRep_Tool::Parameter(BoutdeVtx,Arcspine);
+          Handle(TopOpeBRepDS_CurvePointInterference) 
+            interfv = ChFi3d_FilVertexInDS(OVtx,IArcspine,IVtx,parVtx);
+          DStr.ChangeShapeInterferences(IArcspine).Append(interfv);
+        }
+      }
       else {
-       if (V1.IsOnArc()) {
-         Iarc1 = DStr.AddShape(V1.Arc()); 
-         if ( !ChFi3d_Contains(DStr.ShapeInterferences(Iarc1),Iarc1,Ipoin1) ) {
-           Interfp1= ChFi3d_FilPointInDS(V1.TransitionOnArc(),Iarc1,Ipoin1,
-                                         V1.ParameterOnArc(), isVertex1);
-           DStr.ChangeShapeInterferences(V1.Arc()).Append(Interfp1);
-         }
-       }
-
-       if (V2.IsOnArc()) {
-         Iarc2 = DStr.AddShape(V2.Arc());
-         if ( !ChFi3d_Contains(DStr.ShapeInterferences(Iarc2),Iarc2,Ipoin2) ) {
-           Interfp2= ChFi3d_FilPointInDS(V2.TransitionOnArc(),Iarc2,Ipoin2,
-                                         V2.ParameterOnArc(),isVertex2);
-           DStr.ChangeShapeInterferences(V2.Arc()).Append(Interfp2);
-         }
-       }
+        if (V1.IsOnArc()) {
+          Iarc1 = DStr.AddShape(V1.Arc()); 
+          if ( !ChFi3d_Contains(DStr.ShapeInterferences(Iarc1),Iarc1,Ipoin1) ) {
+            Interfp1= ChFi3d_FilPointInDS(V1.TransitionOnArc(),Iarc1,Ipoin1,
+              V1.ParameterOnArc(), isVertex1);
+            DStr.ChangeShapeInterferences(V1.Arc()).Append(Interfp1);
+          }
+        }
+
+        if (V2.IsOnArc()) {
+          Iarc2 = DStr.AddShape(V2.Arc());
+          if ( !ChFi3d_Contains(DStr.ShapeInterferences(Iarc2),Iarc2,Ipoin2) ) {
+            Interfp2= ChFi3d_FilPointInDS(V2.TransitionOnArc(),Iarc2,Ipoin2,
+              V2.ParameterOnArc(),isVertex2);
+            DStr.ChangeShapeInterferences(V2.Arc()).Append(Interfp2);
+          }
+        }
       }
 
       if (!isInDS1) {
-       ET1 = TopAbs::Compose(ET1,CorDat->FirstPCurveOrientation());
-       Icurv = CorDat->FirstCurve();
-       if(Closed && !Singulier_en_Bout) {
-         regcout.SetCurve(Icurv);
-         regcout.SetS1(Isurf,Standard_False);
-       }
-       PCurv = CorDat->FirstPCurve();
-       CorDat->FirstParameters(Pardeb,Parfin);
-       
-       TopOpeBRepDS_ListOfInterference& Li = DStr.ChangeCurveInterferences(Icurv);
-       if (Li.IsEmpty()) {
-         if(CorDat->FirstPCurveOrientation()==TopAbs_REVERSED) {
-           Interfp1=ChFi3d_FilPointInDS
-             (TopAbs_REVERSED,Icurv,Ipoin1,Parfin,isVertex1);
-           Interfp2=ChFi3d_FilPointInDS
-             (TopAbs_FORWARD,Icurv,Ipoin2,Pardeb,isVertex2);
-         }
-         else{
-           Interfp1=ChFi3d_FilPointInDS
-             (TopAbs_FORWARD,Icurv,Ipoin1,Pardeb,isVertex1);
-           Interfp2=ChFi3d_FilPointInDS
-             (TopAbs_REVERSED,Icurv,Ipoin2,Parfin,isVertex2);
-         }
-         Li.Append(Interfp1);
-         Li.Append(Interfp2);
-       }
-       Interfc1= ChFi3d_FilCurveInDS (Icurv,Isurf,PCurv,ET1);
-       DStr.ChangeSurfaceInterferences(Isurf).Append(Interfc1);
+        ET1 = TopAbs::Compose(ET1,CorDat->FirstPCurveOrientation());
+        Icurv = CorDat->FirstCurve();
+        if(Closed && !Singulier_en_Bout) {
+          regcout.SetCurve(Icurv);
+          regcout.SetS1(Isurf,Standard_False);
+        }
+        PCurv = CorDat->FirstPCurve();
+        CorDat->FirstParameters(Pardeb,Parfin);
+
+        TopOpeBRepDS_ListOfInterference& Li = DStr.ChangeCurveInterferences(Icurv);
+        if (Li.IsEmpty()) {
+          if(CorDat->FirstPCurveOrientation()==TopAbs_REVERSED) {
+            Interfp1=ChFi3d_FilPointInDS
+              (TopAbs_REVERSED,Icurv,Ipoin1,Parfin,isVertex1);
+            Interfp2=ChFi3d_FilPointInDS
+              (TopAbs_FORWARD,Icurv,Ipoin2,Pardeb,isVertex2);
+          }
+          else{
+            Interfp1=ChFi3d_FilPointInDS
+              (TopAbs_FORWARD,Icurv,Ipoin1,Pardeb,isVertex1);
+            Interfp2=ChFi3d_FilPointInDS
+              (TopAbs_REVERSED,Icurv,Ipoin2,Parfin,isVertex2);
+          }
+          Li.Append(Interfp1);
+          Li.Append(Interfp2);
+        }
+        Interfc1= ChFi3d_FilCurveInDS (Icurv,Isurf,PCurv,ET1);
+        DStr.ChangeSurfaceInterferences(Isurf).Append(Interfc1);
         if (Ipoin1 == Ipoin2) {
-         TopOpeBRepDS_Curve& TCurv = DStr.ChangeCurve(Icurv);
-         TCurv.ChangeCurve().Nullify();
-         Handle(TopOpeBRepDS_Interference) bidinterf;
-         TCurv.SetSCI(Interfc1,bidinterf);         
-       }
+          TopOpeBRepDS_Curve& TCurv = DStr.ChangeCurve(Icurv);
+          TCurv.ChangeCurve().Nullify();
+          Handle(TopOpeBRepDS_Interference) bidinterf;
+          TCurv.SetSCI(Interfc1,bidinterf);        
+        }
       }
     } // End of the Initial Processing (j==1)
     else {
       // ---- Interference between Fillets ------
-      
+
       if (!isInDS1) {// eap, Apr 29 2002, occ 293 
-       
+
         if (Degene && isVertex1) {
           // The edge is removed from the spine starting on this vertex.
           NumEdge++; // The previous edge of the vertex has already been found.
@@ -2383,11 +2383,11 @@ void  ChFi3d_FilDS(const Standard_Integer       SolidIndex,
           Standard_Integer IVtx = DStr.AddShape(BoutdeVtx);
           TopAbs_Orientation OVtx = TopAbs_FORWARD;
           for(ex.Init(Arcspine.Oriented(TopAbs_FORWARD),TopAbs_VERTEX); 
-              ex.More(); ex.Next()) {
-            if(BoutdeVtx.IsSame(ex.Current())) {
-              OVtx = ex.Current().Orientation();
-              break;
-            }
+            ex.More(); ex.Next()) {
+              if(BoutdeVtx.IsSame(ex.Current())) {
+                OVtx = ex.Current().Orientation();
+                break;
+              }
           }
           OVtx = TopAbs::Reverse(OVtx);
           Standard_Real parVtx = BRep_Tool::Parameter(BoutdeVtx,Arcspine);
@@ -2415,242 +2415,242 @@ void  ChFi3d_FilDS(const Standard_Integer       SolidIndex,
           reglist.Append(regfilfil);
           Standard_Real tolreached;
           ChFi3d_ComputePCurv(TCurv.ChangeCurve(),UV1,UV2,PCurv,
-                              DStr.Surface(Fd->Surf()).Surface(),
-                              Pardeb,Parfin,tol3d,tolreached);
+            DStr.Surface(Fd->Surf()).Surface(),
+            Pardeb,Parfin,tol3d,tolreached);
           TCurv.Tolerance(Max(TCurv.Tolerance(),tolreached));
           Interfc1= ChFi3d_FilCurveInDS (Icurv,Isurf,PCurv,ET1);
           DStr.ChangeSurfaceInterferences(Isurf).Append(Interfc1);
         }
       }
     } // End of Interference between fillets 
-   
+
     // ---- Interference Fillets / Faces
     IcFil1 = Fi1.LineIndex();
-    
+
     if (IcFil1!=0 ) {
       Interfc3= ChFi3d_FilCurveInDS (IcFil1,Isurf,
-                                    Fi1.PCurveOnSurf(),trafil1);
+        Fi1.PCurveOnSurf(),trafil1);
       DStr.ChangeSurfaceInterferences(Isurf).Append(Interfc3);
       Ishape1 = Fd->IndexOfS1();
       // Case of degenerated edge : pcurve is associated via SCI 
       // to TopOpeBRepDSCurve.
       TopOpeBRepDS_Curve& cc = DStr.ChangeCurve(IcFil1);
       if(cc.Curve().IsNull()) {
-       Handle(TopOpeBRepDS_Interference) bidinterf;
-       cc.SetSCI(Interfc3,bidinterf);
+        Handle(TopOpeBRepDS_Interference) bidinterf;
+        cc.SetSCI(Interfc3,bidinterf);
       }
       else{
-       ChFiDS_Regul regon1;
-       regon1.SetCurve(IcFil1);
-       regon1.SetS1(Isurf,Standard_False);
-       if ( Ishape1 < 0 ) {
-         Ishape1 = -Ishape1;
-         regon1.SetS2(Ishape1,Standard_False);
-         Interfc1=ChFi3d_FilCurveInDS(IcFil1,Ishape1,Fi1.PCurveOnFace(),
-                                      Fi1.Transition()); 
-         DStr.ChangeSurfaceInterferences(Ishape1).Append(Interfc1);      
-       }
-       else if ( Ishape1 > 0 ) {
-         regon1.SetS2(Ishape1,Standard_True);
-         Interfc1=ChFi3d_FilCurveInDS(IcFil1,Ishape1,Fi1.PCurveOnFace(),
-                                      Fi1.Transition()); 
-         DStr.ChangeShapeInterferences(Ishape1).Append(Interfc1);      
-       }
-       reglist.Append(regon1);
+        ChFiDS_Regul regon1;
+        regon1.SetCurve(IcFil1);
+        regon1.SetS1(Isurf,Standard_False);
+        if ( Ishape1 < 0 ) {
+          Ishape1 = -Ishape1;
+          regon1.SetS2(Ishape1,Standard_False);
+          Interfc1=ChFi3d_FilCurveInDS(IcFil1,Ishape1,Fi1.PCurveOnFace(),
+            Fi1.Transition()); 
+          DStr.ChangeSurfaceInterferences(Ishape1).Append(Interfc1);      
+        }
+        else if ( Ishape1 > 0 ) {
+          regon1.SetS2(Ishape1,Standard_True);
+          Interfc1=ChFi3d_FilCurveInDS(IcFil1,Ishape1,Fi1.PCurveOnFace(),
+            Fi1.Transition()); 
+          DStr.ChangeShapeInterferences(Ishape1).Append(Interfc1);      
+        }
+        reglist.Append(regon1);
       }
       // Indice and type of the point at End
       Standard_Integer ipoin;
       Standard_Boolean isVertex = Fd->VertexLastOnS1().IsVertex();
       if (j == SeqFil.Length()) ipoin = CorDat->IndexLastPointOnS1();
       else if ( j == (SeqFil.Length()-1)  &&  /*Closed &&*/
-              (DStr.Curve(SeqFil.Last()->InterferenceOnS1().
-                          LineIndex()).Curve().IsNull())) {
-       if (Closed) {
-         ipoin = CorDat->IndexFirstPointOnS1();
-         isVertex = SeqFil(1)->VertexFirstOnS1().IsVertex();
-       } else {
-         ipoin = CorDat->IndexLastPointOnS1();
-         isVertex = SeqFil.Last()->VertexLastOnS1().IsVertex();
-       }
+        (DStr.Curve(SeqFil.Last()->InterferenceOnS1().
+        LineIndex()).Curve().IsNull())) {
+          if (Closed) {
+            ipoin = CorDat->IndexFirstPointOnS1();
+            isVertex = SeqFil(1)->VertexFirstOnS1().IsVertex();
+          } else {
+            ipoin = CorDat->IndexLastPointOnS1();
+            isVertex = SeqFil.Last()->VertexLastOnS1().IsVertex();
+          }
       }
       else if(DStr.Curve(IcFil1).Curve().IsNull()) {// Rotation !!
-       ipoin = Ipoin1;
-       isVertex = isVertex1;
+        ipoin = Ipoin1;
+        isVertex = isVertex1;
       }
       else if ( ((j==1) || (j== SeqFil.Length()-1)) && 
-               ( (Fd->VertexLastOnS1().Point().IsEqual(
-                 SeqFil(1)->VertexFirstOnS1().Point(), 1.e-7)) ||
-                 (Fd->VertexLastOnS1().Point().IsEqual(
-                 SeqFil(SeqFil.Length())->VertexLastOnS1().Point(), 1.e-7))) )
-       // Case of SurfData cut in "Triangular" way.   
-       ipoin=CorDat->IndexLastPointOnS1();
+        ( (Fd->VertexLastOnS1().Point().IsEqual(
+        SeqFil(1)->VertexFirstOnS1().Point(), 1.e-7)) ||
+        (Fd->VertexLastOnS1().Point().IsEqual(
+        SeqFil(SeqFil.Length())->VertexLastOnS1().Point(), 1.e-7))) )
+        // Case of SurfData cut in "Triangular" way.   
+        ipoin=CorDat->IndexLastPointOnS1();
 
       // eap, Apr 29 2002, occ 293
       else if (isInDS2 && findIndexPoint(DStr, Fd, 1, ipoin)) {
 
       }
       else ipoin = ChFi3d_IndexPointInDS(Fd->VertexLastOnS1(),DStr);
-      
+
       TopOpeBRepDS_ListOfInterference& Li = DStr.ChangeCurveInterferences(IcFil1);
 
       if (!ChFi3d_Contains(Li,IcFil1,Ipoin1)) { 
-       
-       Interfp1 = ChFi3d_FilPointInDS(TopAbs_FORWARD,IcFil1,Ipoin1,
-                                      Fi1.FirstParameter(),isVertex1);
-       DStr.ChangeCurveInterferences(IcFil1).Append(Interfp1);
+
+        Interfp1 = ChFi3d_FilPointInDS(TopAbs_FORWARD,IcFil1,Ipoin1,
+          Fi1.FirstParameter(),isVertex1);
+        DStr.ChangeCurveInterferences(IcFil1).Append(Interfp1);
       }
       if (ipoin == Ipoin1 || !ChFi3d_Contains(Li,IcFil1,ipoin)) { 
-       Interfp3 = ChFi3d_FilPointInDS(TopAbs_REVERSED,IcFil1,ipoin,
-                                      Fi1.LastParameter(), isVertex);
-       DStr.ChangeCurveInterferences(IcFil1).Append(Interfp3);
+        Interfp3 = ChFi3d_FilPointInDS(TopAbs_REVERSED,IcFil1,ipoin,
+          Fi1.LastParameter(), isVertex);
+        DStr.ChangeCurveInterferences(IcFil1).Append(Interfp3);
       }
       Ipoin1 = ipoin;
       isVertex1 = isVertex;
     }
-    
+
     IcFil2 = Fi2.LineIndex();
     if (IcFil2!=0) {
       Interfc4=ChFi3d_FilCurveInDS(IcFil2,Isurf,
-                                  Fi2.PCurveOnSurf(),trafil2);
+        Fi2.PCurveOnSurf(),trafil2);
       DStr.ChangeSurfaceInterferences(Isurf).Append(Interfc4);
       Ishape2 = Fd->IndexOfS2();
       // Case of degenerated edge : pcurve is associated via SCI 
       // to TopOpeBRepDSCurve.
       TopOpeBRepDS_Curve& cc = DStr.ChangeCurve(IcFil2);
       if(cc.Curve().IsNull()) {
-       Handle(TopOpeBRepDS_Interference) bidinterf;
-       cc.SetSCI(Interfc4,bidinterf);
+        Handle(TopOpeBRepDS_Interference) bidinterf;
+        cc.SetSCI(Interfc4,bidinterf);
       }
       else{
-       ChFiDS_Regul regon2;
-       regon2.SetCurve(IcFil2);
-       regon2.SetS1(Isurf,Standard_False);
-       if ( Ishape2 < 0 ) {
-         Ishape2 = -Ishape2;
-         regon2.SetS2(Ishape2,Standard_False);
-         Interfc2=ChFi3d_FilCurveInDS(IcFil2,Ishape2,Fi2.PCurveOnFace(),
-                                      Fi2.Transition());
-         DStr.ChangeSurfaceInterferences(Ishape2).Append(Interfc2);      
-       }
-       else if ( Ishape2 > 0 ) {
-         regon2.SetS2(Ishape2,Standard_True);
-         Interfc2=ChFi3d_FilCurveInDS(IcFil2,Ishape2,Fi2.PCurveOnFace(),
-                                      Fi2.Transition());
-         DStr.ChangeShapeInterferences(Ishape2).Append(Interfc2);      
-       }
-       reglist.Append(regon2);
+        ChFiDS_Regul regon2;
+        regon2.SetCurve(IcFil2);
+        regon2.SetS1(Isurf,Standard_False);
+        if ( Ishape2 < 0 ) {
+          Ishape2 = -Ishape2;
+          regon2.SetS2(Ishape2,Standard_False);
+          Interfc2=ChFi3d_FilCurveInDS(IcFil2,Ishape2,Fi2.PCurveOnFace(),
+            Fi2.Transition());
+          DStr.ChangeSurfaceInterferences(Ishape2).Append(Interfc2);      
+        }