0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / BiTgte / BiTgte_Blend.cxx
index 36c4125..acc44d0 100644 (file)
@@ -5,8 +5,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
-#include <stdio.h>
-
-#include <BiTgte_Blend.ixx>
-
-// include - all hxx,
-//         - all small static functions.
 
-//======================== START STATIC FUNCTIONS ============
-#include <BiTgte_DataMapOfShapeBox.hxx>
+#include <AppCont_Function.hxx>
+#include <AppParCurves_MultiCurve.hxx>
+#include <Approx_FitAndDivide.hxx>
+#include <BiTgte_Blend.hxx>
 #include <BiTgte_CurveOnEdge.hxx>
-
 #include <Bnd_Box.hxx>
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepAlgo_AsDes.hxx>
+#include <BRepAlgo_Loop.hxx>
 #include <BRepBndLib.hxx>
-#include <BRepTools.hxx>
-#include <BRepTools_Quilt.hxx>
 #include <BRepBuilderAPI_Sewing.hxx>
-#include <BRep_Tool.hxx>
-#include <BRep_Builder.hxx>
+#include <BRepLib.hxx>
 #include <BRepLib_MakeEdge.hxx>
-#include <BRepOffset_DataMapOfShapeOffset.hxx>
 #include <BRepOffset_DataMapIteratorOfDataMapOfShapeOffset.hxx>
-#include <BRepOffset_Offset.hxx>
-#include <BRepOffset_MakeLoops.hxx>
-#include <BRepOffset_Inter3d.hxx>
+#include <BRepOffset_DataMapOfShapeOffset.hxx>
 #include <BRepOffset_Inter2d.hxx>
+#include <BRepOffset_Inter3d.hxx>
 #include <BRepOffset_Interval.hxx>
 #include <BRepOffset_ListOfInterval.hxx>
+#include <BRepOffset_MakeLoops.hxx>
+#include <BRepOffset_Offset.hxx>
 #include <BRepOffset_Tool.hxx>
-#include <BRepAlgo_Loop.hxx>
+#include <BRepTools.hxx>
+#include <BRepTools_Quilt.hxx>
+#include <BSplCLib.hxx>
 #include <ChFi3d.hxx>
-#include <GeomAbs_SurfaceType.hxx>
-#include <GeomAPI_ProjectPointOnCurve.hxx>
+#include <Convert_CompBezierCurvesToBSplineCurve.hxx>
+#include <ElSLib.hxx>
+#include <Geom2d_Curve.hxx>
+#include <Geom2dAdaptor_Curve.hxx>
+#include <Geom2dAPI_ProjectPointOnCurve.hxx>
 #include <Geom_BSplineCurve.hxx>
-#include <Geom_TrimmedCurve.hxx>
 #include <Geom_Circle.hxx>
+#include <Geom_Curve.hxx>
 #include <Geom_Line.hxx>
-#include <Geom2d_Curve.hxx>
+#include <Geom_Surface.hxx>
+#include <Geom_TrimmedCurve.hxx>
+#include <GeomAbs_SurfaceType.hxx>
 #include <GeomAdaptor_Surface.hxx>
-#include <Geom2dAdaptor_Curve.hxx>
-#include <Geom2dAPI_ProjectPointOnCurve.hxx>
-#include <TopExp_Explorer.hxx>
-#include <TopoDS_Wire.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Compound.hxx>
-#include <TopTools_ListOfShape.hxx>
-#include <TopTools_SequenceOfShape.hxx>
-#include <TopTools_DataMapOfShapeShape.hxx>
-#include <TopTools_MapIteratorOfMapOfShape.hxx>
-#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <GeomAPI.hxx>
+#include <GeomAPI_ProjectPointOnCurve.hxx>
 #include <gp.hxx>
-#include <gp_Pnt2d.hxx>
-#include <gp_Lin2d.hxx>
-#include <gp_Lin.hxx>
-#include <gp_Dir2d.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Dir.hxx>
 #include <gp_Ax1.hxx>
 #include <gp_Ax3.hxx>
 #include <gp_Circ.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Dir2d.hxx>
+#include <gp_Lin.hxx>
+#include <gp_Lin2d.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Pnt2d.hxx>
 #include <gp_Sphere.hxx>
-
-#include <AppCont_Function.hxx>
-#include <Approx_FitAndDivide.hxx>
-#include <AppParCurves_MultiCurve.hxx>
-#include <BSplCLib.hxx>
-#include <Convert_CompBezierCurvesToBSplineCurve.hxx>
 #include <Precision.hxx>
+#include <Standard_NotImplemented.hxx>
+#include <Standard_OutOfRange.hxx>
+#include <StdFail_NotDone.hxx>
 #include <TColgp_Array1OfPnt.hxx>
-#include <TColStd_Array1OfReal.hxx>
 #include <TColStd_Array1OfInteger.hxx>
-
-#include <Standard_NotImplemented.hxx>
-
-#include <BRepLib.hxx>
-#include <ElSLib.hxx>
-#include <GeomAPI.hxx>
-#include <TopoDS.hxx>
+#include <TColStd_Array1OfReal.hxx>
 #include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Compound.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopTools_DataMapOfShapeShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
+#include <TopTools_SequenceOfShape.hxx>
 
+#ifdef OCCT_DEBUG
 #include <OSD_Chronometer.hxx>
+#endif
+
+#include <stdio.h>
+// include - all hxx,
+//         - all small static functions.
+//======================== START STATIC FUNCTIONS ============
 // variables for performance 
 Standard_Real t_mkcurve;
+#ifdef OCCT_DEBUG
 extern void ChFi3d_InitChron(OSD_Chronometer& ch);
 extern void ChFi3d_ResultChron(OSD_Chronometer & ch, Standard_Real&    time);
+#endif
 #ifdef DRAW
 static Standard_Boolean Affich = Standard_False;
 static char name[100];
@@ -379,22 +384,40 @@ static void KPartCurve3d(TopoDS_Edge           Edge,
 class MakeCurve_Function : public AppCont_Function
 {
   BiTgte_CurveOnEdge myCurve;
-  
+
   public :
-  
-  MakeCurve_Function(const BiTgte_CurveOnEdge& C) : myCurve(C) {};
+
+  MakeCurve_Function(const BiTgte_CurveOnEdge& C)
+  : myCurve(C)
+  {
+    myNbPnt = 1;
+    myNbPnt2d = 0;
+  }
 
   Standard_Real FirstParameter() const
-    {return myCurve.FirstParameter();}
-  
+  {
+    return myCurve.FirstParameter();
+  }
+
   Standard_Real LastParameter() const
-    {return myCurve.LastParameter();}
-  
-  gp_Pnt Value(const Standard_Real t) const
-    {return myCurve.Value(t);}
+  {
+    return myCurve.LastParameter();
+  }
+
+  Standard_Boolean Value(const Standard_Real   theT,
+                         NCollection_Array1<gp_Pnt2d>& /*thePnt2d*/,
+                         NCollection_Array1<gp_Pnt>&   thePnt) const
+  {
+      thePnt(1) = myCurve.Value(theT);
+      return Standard_True;
+  }
   
-  Standard_Boolean D1(const Standard_Real /*t*/, gp_Pnt& /*P*/, gp_Vec& /*V*/) const
-    {return Standard_False;}
+  Standard_Boolean D1(const Standard_Real   /*theT*/,
+                      NCollection_Array1<gp_Vec2d>& /*theVec2d*/,
+                      NCollection_Array1<gp_Vec>&   /*theVec*/) const
+  {
+      return Standard_False;
+  }
 
 };
 
@@ -402,7 +425,7 @@ Handle(Geom_Curve) MakeCurve (const BiTgte_CurveOnEdge& HC)
 {
   Handle(Geom_Curve) C;
 
-#if DEB
+#ifdef OCCT_DEBUG
    OSD_Chronometer ch;
    ChFi3d_InitChron(ch);
 #endif
@@ -451,7 +474,7 @@ Handle(Geom_Curve) MakeCurve (const BiTgte_CurveOnEdge& HC)
                               Conv.Degree());
   }
 
-#if DEB
+#ifdef OCCT_DEBUG
   ChFi3d_ResultChron(ch, t_mkcurve);
 #endif
 
@@ -670,6 +693,7 @@ static TopoDS_Edge FindCreatedEdge
   return E1;
 }
 
+#ifdef DRAW
 //=======================================================================
 //function : Bubble
 //purpose  : Sets in increasing order the sequence of vertices. 
@@ -712,8 +736,8 @@ static void CutEdge (const TopoDS_Edge&          E,
                     const TopTools_ListOfShape& VOnE,
                           TopTools_ListOfShape& NE   )
 {
-  TopoDS_Shape aLocalShape = E.Oriented(TopAbs_FORWARD);
-  TopoDS_Edge WE = TopoDS::Edge(aLocalShape);
+  TopoDS_Shape aLocalShapeOrientedE = E.Oriented(TopAbs_FORWARD);
+  TopoDS_Edge WE = TopoDS::Edge(aLocalShapeOrientedE);
 //  TopoDS_Edge WE = TopoDS::Edge(E.Oriented(TopAbs_FORWARD));
 
   Standard_Real                      U1,U2;
@@ -770,7 +794,7 @@ static void CutEdge (const TopoDS_Edge&          E,
     SV.Remove(1);
     
     if ( V1.IsSame(V2)) {
-      cout << "Vertex Confondus dans CutEdges" << endl;
+      std::cout << "Vertex Confondus dans CutEdges" << std::endl;
       continue;
     }
     //-------------------------------------------
@@ -803,6 +827,8 @@ static void CutEdge (const TopoDS_Edge&          E,
     V1 = V2;
   }
 }
+#endif
+
 //======================== END OF STATIC FUNCTIONS ============
 
 
@@ -930,7 +956,7 @@ void BiTgte_Blend::Perform(const Standard_Boolean BuildShape)
   for ( ;expf.More(); expf.Next()) Sew->Add(expf.Current());
   Sew->Perform();
   TopoDS_Shape SewedShape = Sew->SewedShape();
-  if ( SewedShape.IsNull()) Standard_Failure::Raise("Sewing aux fraises");
+  if ( SewedShape.IsNull()) throw Standard_Failure("Sewing aux fraises");
 
   // Check if the sewing modified the orientation.
   expf.Init(myShape,TopAbs_FACE);
@@ -962,12 +988,7 @@ void BiTgte_Blend::Perform(const Standard_Boolean BuildShape)
   for ( ; expf.More(); expf.Next()) {
     const TopoDS_Shape& F = expf.Current();
     if ( myFaces.Contains(F) && Sew->IsModified(F)) {
-      //myFaces.Remove(F);
-      TopoDS_Shape LastFace = myFaces(myFaces.Extent());
-      myFaces.RemoveLast();
-      if (myFaces.FindIndex(F) != 0)
-        myFaces.Substitute(myFaces.FindIndex(F), LastFace);
-      ////////////////////
+      myFaces.RemoveKey(F);
       myFaces.Add(Sew->Modified(F));
     }
   }
@@ -975,7 +996,7 @@ void BiTgte_Blend::Perform(const Standard_Boolean BuildShape)
   myShape = SewedShape;
 // end Sewing for false free borders.
 
-#if DEB
+#ifdef OCCT_DEBUG
   OSD_Chronometer cl_total, ch;
   Standard_Real   t_total, t_center, t_surface, t_shape;
 
@@ -990,12 +1011,7 @@ void BiTgte_Blend::Perform(const Standard_Boolean BuildShape)
   for ( ; exp.More(); exp.Next()) {
     const TopoDS_Shape& F = exp.Current();
     if ( myFaces.Contains(F)) {
-      //myFaces.Remove(F);
-      TopoDS_Shape LastFace = myFaces(myFaces.Extent());
-      myFaces.RemoveLast();
-      if (myFaces.FindIndex(F) != 0)
-        myFaces.Substitute(myFaces.FindIndex(F), LastFace);
-      ////////////////////
+      myFaces.RemoveKey(F);
       myFaces.Add(F);
     }
     else if ( myStopFaces.Contains(F)) {
@@ -1007,39 +1023,39 @@ void BiTgte_Blend::Perform(const Standard_Boolean BuildShape)
   // ----------------------------------------------
   // Calculate lines of centers and of surfaces
   // ----------------------------------------------
-#if DEB
+#ifdef OCCT_DEBUG
   ChFi3d_InitChron(ch);
 #endif  
 
   ComputeCenters();
   
-#if DEB
+#ifdef OCCT_DEBUG
   ChFi3d_ResultChron(ch, t_center);
 #endif 
 
   // -----------------------------
   // Calculate connection Surfaces
   // -----------------------------
-#if DEB
+#ifdef OCCT_DEBUG
   ChFi3d_InitChron(ch);
 #endif
 
   ComputeSurfaces();
 
-#if DEB
+#ifdef OCCT_DEBUG
   ChFi3d_ResultChron(ch, t_surface);
 #endif 
 
   // ----------------------------------
   // Calculate the generated shape if required
   // ----------------------------------
-#if DEB
+#ifdef OCCT_DEBUG
   ChFi3d_InitChron(ch);
 #endif  
 
   if ( myBuildShape) ComputeShape();
 
-#if DEB
+#ifdef OCCT_DEBUG
   ChFi3d_ResultChron(ch, t_shape);
 #endif 
 
@@ -1047,14 +1063,14 @@ void BiTgte_Blend::Perform(const Standard_Boolean BuildShape)
   // since the partition is provided ( A Priori);
   BRepLib::BuildCurves3d(myResult, Precision::Confusion());
 
-#ifdef DEB
+#ifdef OCCT_DEBUG
   ChFi3d_ResultChron(cl_total, t_total);
-  cout<<endl; 
-  cout<<"Blend_PERFORM: temps total "<<t_total<<" s  dont :"<<endl;
-  cout<<"- ComputeCenters  "<<t_center<<" s"<<endl;  
-  cout<<"- ComputeSurfaces "<<t_surface<<" s"<<endl;
-  cout<<"----> MakeCurve   "<<t_mkcurve<<" s"<<endl;
-  if ( myBuildShape)  cout<<"- ComputeShape "<<t_shape<<" s"<<endl;
+  std::cout<<std::endl; 
+  std::cout<<"Blend_PERFORM: temps total "<<t_total<<" s  dont :"<<std::endl;
+  std::cout<<"- ComputeCenters  "<<t_center<<" s"<<std::endl;  
+  std::cout<<"- ComputeSurfaces "<<t_surface<<" s"<<std::endl;
+  std::cout<<"----> MakeCurve   "<<t_mkcurve<<" s"<<std::endl;
+  if ( myBuildShape)  std::cout<<"- ComputeShape "<<t_shape<<" s"<<std::endl;
 #endif
 
   myDone = Standard_True;
@@ -1149,7 +1165,7 @@ const
 const TopoDS_Face& BiTgte_Blend::Face(const TopoDS_Shape& CenterLine) const
 {
   if ( !myMapSF.IsBound(CenterLine)) {
-    Standard_DomainError::Raise("BiTgte_Blend::Face");
+    throw Standard_DomainError("BiTgte_Blend::Face");
   }
 
   return myMapSF(CenterLine).Face();
@@ -1176,35 +1192,42 @@ BiTgte_ContactType BiTgte_Blend::ContactType(const Standard_Integer Index)
   }
   BiTgte_ContactType Type = BiTgte_VertexVertex;
 
-  switch (Type1) {
-    
-  case TopAbs_VERTEX:
-    switch (Type2) {
-    case TopAbs_VERTEX: Type = BiTgte_VertexVertex; break;
-    case TopAbs_EDGE:   Type = BiTgte_EdgeVertex;   break;
-    case TopAbs_FACE:   Type = BiTgte_FaceVertex;   break;
-    default:
+  switch (Type1)
+  {
+    case TopAbs_VERTEX:
+      switch (Type2)
+      {
+        case TopAbs_VERTEX: Type = BiTgte_VertexVertex; break;
+        case TopAbs_EDGE:   Type = BiTgte_EdgeVertex;   break;
+        case TopAbs_FACE:   Type = BiTgte_FaceVertex;   break;
+        default:
+          break;
+      }
       break;
-    }
-    
-  case TopAbs_EDGE:
-    switch (Type2) {
-    case TopAbs_EDGE:   Type = BiTgte_EdgeEdge; break;
-    case TopAbs_FACE:   Type = BiTgte_FaceEdge; break;
-    default:
+
+    case TopAbs_EDGE:
+      switch (Type2)
+      {
+        case TopAbs_EDGE:   Type = BiTgte_EdgeEdge;     break;
+        case TopAbs_FACE:   Type = BiTgte_FaceEdge;     break;
+        default:
+          break;
+      }
       break;
-   }
-    
-  case TopAbs_FACE:
-    switch (Type2) {
-    case TopAbs_FACE:   Type = BiTgte_FaceEdge; break;
+
+    case TopAbs_FACE:
+      switch (Type2)
+      {
+        case TopAbs_FACE:   Type = BiTgte_FaceEdge;     break;
+        default:
+          break;
+      }
+      break;
+
     default:
       break;
-    }
-  default:
-    break;
   }
-  
+
   return Type;
 }
 
@@ -1477,7 +1500,7 @@ void BiTgte_Blend::ComputeCenters()
   if (myRadius < 0.) Side = TopAbs_OUT;
   BRepOffset_Inter3d Inter(myAsDes,Side,myTol);
 
-  BiTgte_DataMapOfShapeBox         MapSBox;
+  TopTools_DataMapOfShapeBox         MapSBox;
   TopTools_MapOfShape              Done;
   //TopTools_MapIteratorOfMapOfShape it;
 
@@ -1557,7 +1580,7 @@ void BiTgte_Blend::ComputeCenters()
        // ------------------------------------
        TopTools_ListOfShape Let;
        if ( AS.ShapeType() == TopAbs_FACE) { 
-         myAnalyse.Edges(TopoDS::Face(AS),BRepOffset_Tangent,Let);
+         myAnalyse.Edges(TopoDS::Face(AS),ChFiDS_Tangential,Let);
        }
        TopTools_ListIteratorOfListOfShape itlet(Let);
     
@@ -1573,14 +1596,14 @@ void BiTgte_Blend::ComputeCenters()
            TopExp::Vertices (OTE,OV1,OV2);      
            TopTools_ListOfShape LE;
            if (!EdgeTgt.IsBound(V1)) {
-             myAnalyse.Edges(V1,BRepOffset_Tangent,LE);
+             myAnalyse.Edges(V1,ChFiDS_Tangential,LE);
              const TopTools_ListOfShape& LA = myAnalyse.Ancestors(V1);
              if (LE.Extent() == LA.Extent())
                EdgeTgt.Bind(V1,OV1);
            }
            if (!EdgeTgt.IsBound(V2)) {
              LE.Clear();
-             myAnalyse.Edges(V2,BRepOffset_Tangent,LE);
+             myAnalyse.Edges(V2,ChFiDS_Tangential,LE);
              const TopTools_ListOfShape& LA = myAnalyse.Ancestors(V2);
              if (LE.Extent() == LA.Extent())
                EdgeTgt.Bind(V2,OV2);
@@ -1621,8 +1644,8 @@ void BiTgte_Blend::ComputeCenters()
     //--------------------------------------------------------
     // Construction of tubes on edge.
     //--------------------------------------------------------
-    BRepOffset_Type    OT = BRepOffset_Convex;
-    if (myRadius < 0.) OT = BRepOffset_Concave; 
+    ChFiDS_TypeOfConcavity OT = ChFiDS_Convex;
+    if (myRadius < 0.) OT = ChFiDS_Concave; 
     
     TopTools_IndexedDataMapOfShapeListOfShape Map;
     TopExp::MapShapesAndAncestors(Co,TopAbs_EDGE,TopAbs_FACE,Map);
@@ -1637,10 +1660,10 @@ void BiTgte_Blend::ComputeCenters()
       if (Anc.Extent() == 2) {
        const BRepOffset_ListOfInterval& L = myAnalyse.Type(E);
        if (!L.IsEmpty() && L.First().Type() == OT) {
-         TopoDS_Shape aLocalShape = myMapSF(Anc.First()).Generated(E);
-         TopoDS_Edge EOn1 = TopoDS::Edge(aLocalShape);
-         aLocalShape = myMapSF(Anc.Last()) .Generated(E);
-         TopoDS_Edge EOn2 = TopoDS::Edge(aLocalShape);
+         TopoDS_Shape aLocalShapeGen = myMapSF(Anc.First()).Generated(E);
+         TopoDS_Edge EOn1 = TopoDS::Edge(aLocalShapeGen);
+    aLocalShapeGen = myMapSF(Anc.Last()) .Generated(E);
+         TopoDS_Edge EOn2 = TopoDS::Edge(aLocalShapeGen);
 //       TopoDS_Edge EOn1 = TopoDS::Edge(myMapSF(Anc.First()).Generated(E));
 //       TopoDS_Edge EOn2 = TopoDS::Edge(myMapSF(Anc.Last()) .Generated(E));
          // find if exits tangent edges in the original shape
@@ -1707,9 +1730,9 @@ void BiTgte_Blend::ComputeCenters()
   // -------------------------------------------------------------------
 
   // Proceed with MakeLoops 
-
-  BRepOffset_Type    OT = BRepOffset_Concave;
-  if (myRadius < 0.) OT = BRepOffset_Convex; 
+  TopTools_IndexedDataMapOfShapeListOfShape aDMVV;
+  ChFiDS_TypeOfConcavity OT = ChFiDS_Concave;
+  if (myRadius < 0.) OT = ChFiDS_Convex; 
    
   TopTools_ListOfShape LOF;
   //it.Initialize(myFaces);
@@ -1760,7 +1783,8 @@ void BiTgte_Blend::ComputeCenters()
       BRepOffset_Inter2d::Compute(myAsDes,
                                  CurOF,
                                  myEdges,
-                                 myTol);
+                                 myTol,
+                                 aDMVV);
     }
   }
 
@@ -1792,8 +1816,12 @@ void BiTgte_Blend::ComputeCenters()
     BRepOffset_Inter2d::Compute(myAsDes,
                                CurOF,
                                myEdges,
-                               myTol);
+                               myTol,
+                               aDMVV);
   }
+  //
+  // fuse vertices on edges stored in AsDes
+  BRepOffset_Inter2d::FuseVertices(aDMVV, myAsDes);
   // ------------
   // unwinding 
   // ------------
@@ -1829,9 +1857,9 @@ void BiTgte_Blend::ComputeCenters()
     }
   }
 
-#ifdef DEB
+#ifdef OCCT_DEBUG
   if ( myResult.IsNull()) {
-    cout << " No Lines of Generated Centers" << endl;
+    std::cout << " No Lines of Generated Centers" << std::endl;
   }
 #ifdef DRAW
   else {
@@ -1992,9 +2020,9 @@ void BiTgte_Blend::ComputeSurfaces()
       Handle(Geom2d_Curve) PC2 = 
        BRep_Tool::CurveOnSurface(CurCutE,F2,f2,l2);
       if ( PC1.IsNull() || PC2.IsNull()) {
-#ifdef DEB
-       cout << "No PCurves on Intersections : No tubes constructed";
-       cout << endl;
+#ifdef OCCT_DEBUG
+       std::cout << "No PCurves on Intersections : No tubes constructed";
+       std::cout << std::endl;
 #endif 
        continue;
       }
@@ -2048,7 +2076,7 @@ void BiTgte_Blend::ComputeSurfaces()
        if (MKE.IsDone()) 
          E1 = MKE.Edge();
        else  {
-         cout << "Edge Not Done" << endl;
+         std::cout << "Edge Not Done" << std::endl;
          E1 = MKE.Edge();
        }
          
@@ -2087,7 +2115,7 @@ void BiTgte_Blend::ComputeSurfaces()
        if (MKE.IsDone()) 
          E2 = MKE.Edge();
        else {
-         cout << "edge not Done" << endl;
+         std::cout << "edge not Done" << std::endl;
          E2 = MKE.Edge();
        }
        KPartCurve3d(E2,PC2,GS2);
@@ -2109,15 +2137,15 @@ void BiTgte_Blend::ComputeSurfaces()
       // are not actually tangent ( Cf: Approximation of lines 
       // of intersection that add noise.)
       // ----------------------------------------------------------
-      TopoDS_Vertex V1,V2;
+      TopoDS_Vertex aVertex1, aVertex2;
       if ( E1f.IsNull() && !VfOnE1.IsNull() && !VfOnE2.IsNull()) {
        TopTools_MapIteratorOfMapOfShape it(MapOnV1f);
        for ( ; it.More(); it.Next()) {
          const TopoDS_Edge& E = TopoDS::Edge(it.Key());
          if ( !E.IsNull()) {
-           TopExp::Vertices(E,V1,V2);
-           if ((V1.IsSame(VfOnE1) && V2.IsSame(VfOnE2)) ||
-               (V2.IsSame(VfOnE1) && V1.IsSame(VfOnE2))   ) {
+           TopExp::Vertices(E, aVertex1, aVertex2);
+           if ((aVertex1.IsSame(VfOnE1) && aVertex2.IsSame(VfOnE2)) ||
+               (aVertex2.IsSame(VfOnE1) && aVertex1.IsSame(VfOnE2))   ) {
              E1f = E;
              break;
            }
@@ -2129,9 +2157,9 @@ void BiTgte_Blend::ComputeSurfaces()
        for ( ; it.More(); it.Next()) {
          const TopoDS_Edge& E = TopoDS::Edge(it.Key());
          if ( !E.IsNull()) {
-           TopExp::Vertices(E,V1,V2);
-           if ((V1.IsSame(VlOnE1) && V2.IsSame(VlOnE2)) ||
-               (V2.IsSame(VlOnE1) && V1.IsSame(VlOnE2))   ) {
+           TopExp::Vertices(E, aVertex1, aVertex2);
+           if ((aVertex1.IsSame(VlOnE1) && aVertex2.IsSame(VlOnE2)) ||
+               (aVertex2.IsSame(VlOnE1) && aVertex1.IsSame(VlOnE2))   ) {
              E1l = E;
              break;
            }
@@ -2188,7 +2216,7 @@ void BiTgte_Blend::ComputeSurfaces()
        if (OF2isEdge) { // Update CutEdges.
          exp.Next();
          const TopoDS_Edge& EOnF2 = TopoDS::Edge(exp.Current());
-         TopExp::Vertices(EOnF2,V1,V2);;
+         TopExp::Vertices(EOnF2,V1,V2);
 
          gp_Pnt P1 = BRep_Tool::Pnt(V1);
          Projector.Init(P1,GC2);
@@ -2232,15 +2260,15 @@ void BiTgte_Blend::ComputeSurfaces()
   // ---------------------------------------------------
   TopTools_IndexedDataMapOfShapeListOfShape Map;
   TopExp::MapShapesAndAncestors(Co,TopAbs_VERTEX,TopAbs_EDGE,Map);
-
-  for ( Standard_Integer i = 1; i <= Map.Extent(); i++) {
-    const TopoDS_Vertex& V = TopoDS::Vertex(Map.FindKey(i));
-    if ( Map(i).Extent() != 3) continue;
+  
+  for ( Standard_Integer j = 1; j <= Map.Extent(); j++) {
+    const TopoDS_Vertex& V = TopoDS::Vertex(Map.FindKey(j));
+    if ( Map(j).Extent() != 3) continue;
 
     TopTools_ListOfShape LOE;
     TopTools_ListIteratorOfListOfShape it;
     
-    for (it.Initialize(Map(i)) ; it.More(); it.Next()) {
+    for (it.Initialize(Map(j)) ; it.More(); it.Next()) {
       Standard_Boolean Reverse = Standard_True;
       if ( Reverse) 
        LOE.Append(myMapSF(it.Value()).Generated(V).Reversed());
@@ -2270,6 +2298,7 @@ void BiTgte_Blend::ComputeSurfaces()
 //purpose  : 
 //=======================================================================
 #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
+#include <Geom_Curve.hxx>
 
 void BiTgte_Blend::ComputeShape() 
 {
@@ -2298,25 +2327,6 @@ void BiTgte_Blend::ComputeShape()
 #endif
   // end debug
 
-  //
-  // modify the tubes on edge for partition of edges.
-  //
-  Standard_Integer NbS = NbSurfaces();
-  for (Standard_Integer i = 1; i <= NbS; i++) {
-    const TopoDS_Shape& S1 = SupportShape1(i);
-
-    if ( S1.ShapeType() == TopAbs_EDGE) {
-      const TopoDS_Edge& E1   = TopoDS::Edge(S1);
-      // it is required to replace in F the cut edges of E1, that
-      // represent CutE
-      const TopTools_ListOfShape& VonE = myCutEdges(E1);
-      TopTools_ListOfShape NewE;
-      CutEdge(E1,VonE,NewE);
-      
-    }
-  }
-
-
   TopTools_DataMapOfShapeShape Created;
 
   TopTools_ListOfShape Empty;
@@ -2324,9 +2334,6 @@ void BiTgte_Blend::ComputeShape()
   
   BRep_Builder B;
 
-#ifdef DRAW
-  Standard_Integer NbNT = 1;
-#endif
 
   // Maj of the Map of created.
   // Update edges that do not change in the resulting shape 
@@ -2449,9 +2456,9 @@ void BiTgte_Blend::ComputeShape()
            TopoDS_Edge OE;
            if ( MapSS.IsBound(E)) { // this is an edge of cutting 
              OE = TopoDS::Edge(MapSS(E));
-             TopoDS_Shape aLocalShape = E.Reversed();
+             TopoDS_Shape aLocalShapeReversedE = E.Reversed();
              Handle(Geom2d_Curve) C2d_1 = 
-               BRep_Tool::CurveOnSurface(TopoDS::Edge(aLocalShape),Face,f,l);
+               BRep_Tool::CurveOnSurface(TopoDS::Edge(aLocalShapeReversedE),Face,f,l);
 //           Handle(Geom2d_Curve) C2d_1 = 
 //             BRep_Tool::CurveOnSurface(TopoDS::Edge(E.Reversed()),
 //                                       Face,f,l);
@@ -2557,7 +2564,7 @@ void BiTgte_Blend::ComputeShape()
 Standard_Boolean BiTgte_Blend::Intersect
 (const TopoDS_Shape&             Init,
  const TopoDS_Face&              Face,
- const BiTgte_DataMapOfShapeBox& MapSBox,
+ const TopTools_DataMapOfShapeBox& MapSBox,
  const BRepOffset_Offset&        OF1,
        BRepOffset_Inter3d&       Inter) 
 {
@@ -2589,10 +2596,10 @@ Standard_Boolean BiTgte_Blend::Intersect
       InitShape2.ShapeType() == TopAbs_EDGE &&
        myStopFaces.Contains(InitShape2);
 
-#ifdef DEB
+#ifdef OCCT_DEBUG
     if ( F1surBordLibre && F2surBordLibre) {
-      cout << "Rejection : 2 tubes on free border are not intersected";
-      cout << endl;
+      std::cout << "Rejection : 2 tubes on free border are not intersected";
+      std::cout << std::endl;
     }
 #endif
 
@@ -2628,11 +2635,11 @@ Standard_Boolean BiTgte_Blend::Intersect
        if ( Done.Add(V1)) {
          Standard_Boolean IsOnR1 = IsOnRestriction(V1,CurE,Face,E1);
          Standard_Boolean IsOnR2 = IsOnRestriction(V1,CurE,F2,E2);
-#ifdef DEB
+#ifdef OCCT_DEBUG
          if (IsOnR1 && IsOnR2) {
-           cout << "Leave in the same tps on 2 faces, ";
-           cout << "propagation only on free border";
-           cout << endl;
+           std::cout << "Leave in the same tps on 2 faces, ";
+           std::cout << "propagation only on free border";
+           std::cout << std::endl;
          }
 #endif
          if ( IsOnR1 ) {
@@ -2657,11 +2664,11 @@ Standard_Boolean BiTgte_Blend::Intersect
          // Leave in the same tps on 2 faces, propagate only on 
          // free borders.
          // A priori, only facet is closed.
-#ifdef DEB
+#ifdef OCCT_DEBUG
          if (IsOnR1 && IsOnR2) {
-           cout << "Leave with the same tps on 2 faces, ";
-           cout << "propagate only if the border is free";
-           cout << endl;
+           std::cout << "Leave with the same tps on 2 faces, ";
+           std::cout << "propagate only if the border is free";
+           std::cout << std::endl;
          }
 #endif
          if ( IsOnR1) {