Warnings on vc14 were eliminated
[occt.git] / src / BiTgte / BiTgte_Blend.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 65091b6..cc1c50b
 // Created on: 1996-12-16
 // Created by: Bruno DUMORTIER
 // Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2012 OPEN CASCADE SAS
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
 //
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
 //
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// 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.
 //
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
+// 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 <BiTgte_DataMapOfShapeBox.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;
-//Standard_IMPORT extern void ChFi3d_InitChron(OSD_Chronometer& ch);
-Standard_EXPORT void ChFi3d_InitChron(OSD_Chronometer& ch);
-//Standard_IMPORT extern void ChFi3d_ResultChron(OSD_Chronometer & ch,
-Standard_IMPORT void ChFi3d_ResultChron(OSD_Chronometer & ch,
-                                       Standard_Real&    time);
+#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];
@@ -237,8 +235,6 @@ static void KPartCurve3d(TopoDS_Edge           Edge,
   TopLoc_Location Loc;
   Standard_Real Tol = Precision::Confusion();
 
-  Standard_Boolean IsComputed = Standard_False;
-
   // Seach only isos on analytical surfaces.
   Geom2dAdaptor_Curve C(Curve);
   GeomAdaptor_Surface S(Surf);
@@ -269,7 +265,6 @@ static void KPartCurve3d(TopoDS_Edge           Edge,
              Circle->Reverse();
            TheBuilder.UpdateEdge(Edge, Circle, Loc, Tol);
          }
-         IsComputed = Standard_True;
        }
        else if ( STy == GeomAbs_Cylinder) {
          gp_Cylinder Cyl  = S.Cylinder();
@@ -285,7 +280,6 @@ static void KPartCurve3d(TopoDS_Edge           Edge,
          if ( D.IsOpposite(gp::DX2d(),Precision::Angular())) 
            Circle->Reverse();
          TheBuilder.UpdateEdge(Edge, Circle, Loc, Tol);
-         IsComputed = Standard_True;
        }
        else if ( STy == GeomAbs_Cone) {
          gp_Cone  Cone = S.Cone();
@@ -302,7 +296,6 @@ static void KPartCurve3d(TopoDS_Edge           Edge,
          if ( D.IsOpposite(gp::DX2d(),Precision::Angular())) 
            Circle->Reverse();
          TheBuilder.UpdateEdge(Edge, Circle, Loc, Tol);
-         IsComputed = Standard_True;
        }
        else if ( STy == GeomAbs_Torus) {
          gp_Torus Tore = S.Torus();
@@ -319,7 +312,6 @@ static void KPartCurve3d(TopoDS_Edge           Edge,
          if ( D.IsOpposite(gp::DX2d(),Precision::Angular())) 
            Circle->Reverse();
          TheBuilder.UpdateEdge(Edge, Circle, Loc, Tol);
-         IsComputed = Standard_True;
        }
       }
       else if ( D.IsParallel(gp::DY2d(),Precision::Angular())) { // Iso U.
@@ -344,7 +336,6 @@ static void KPartCurve3d(TopoDS_Edge           Edge,
          if ( D.IsOpposite(gp::DY2d(),Precision::Angular())) 
            Circle->Reverse();
          TheBuilder.UpdateEdge(Edge, Circle, Loc, Tol);
-         IsComputed = Standard_True;
        }
        else if ( STy == GeomAbs_Cylinder) {
          gp_Cylinder Cyl = S.Cylinder();
@@ -359,7 +350,6 @@ static void KPartCurve3d(TopoDS_Edge           Edge,
          if ( D.IsOpposite(gp::DY2d(),Precision::Angular()))
            Line->Reverse();
          TheBuilder.UpdateEdge(Edge, Line, Loc, Tol);
-         IsComputed = Standard_True;
        }
        else if ( STy == GeomAbs_Cone) {
          gp_Cone  Cone = S.Cone();
@@ -374,7 +364,6 @@ static void KPartCurve3d(TopoDS_Edge           Edge,
          if ( D.IsOpposite(gp::DY2d(),Precision::Angular()))
            Line->Reverse();
          TheBuilder.UpdateEdge(Edge, Line, Loc, Tol);
-         IsComputed = Standard_True;
        }
        else if ( STy == GeomAbs_Torus) {
        }
@@ -384,7 +373,6 @@ static void KPartCurve3d(TopoDS_Edge           Edge,
   else { // Case Plane
     Handle(Geom_Curve) C3d = GeomAPI::To3d(Curve,S.Plane());
     TheBuilder.UpdateEdge(Edge, C3d, Loc, Tol);
-    IsComputed = Standard_True;
   }
 }
 
@@ -397,22 +385,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;
+  }
 
 };
 
@@ -420,7 +426,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
@@ -469,7 +475,7 @@ Handle(Geom_Curve) MakeCurve (const BiTgte_CurveOnEdge& HC)
                               Conv.Degree());
   }
 
-#if DEB
+#ifdef OCCT_DEBUG
   ChFi3d_ResultChron(ch, t_mkcurve);
 #endif
 
@@ -482,13 +488,13 @@ Handle(Geom_Curve) MakeCurve (const BiTgte_CurveOnEdge& HC)
 //purpose  : Only the faces connected with caps are given
 //=======================================================================
 
-static void Touched(const BRepOffset_Analyse&  Analyse
-                   const TopTools_MapOfShape& StopFaces
-                   const TopoDS_Shape&        Shape,
-                   TopTools_MapOfShape& TouchedByCork)
+static void Touched(const BRepOffset_Analyse&, 
+                    const TopTools_MapOfShape&
+                    const TopoDS_Shape&,
+                    TopTools_MapOfShape&)
 {
   // currently nothing is done !!
-  if ( Standard_True) {
+  /*if ( Standard_True) {
     return;
   }
   else {
@@ -496,11 +502,12 @@ static void Touched(const BRepOffset_Analyse&  Analyse,
     for ( ; exp.More(); exp.Next()) {
       const TopTools_ListOfShape& L = Analyse.Ancestors(exp.Current());
       if (StopFaces.Contains(L.First())) 
-       TouchedByCork.Add(L.Last());
+        TouchedByCork.Add(L.Last());
       else if (StopFaces.Contains(L.Last())) 
-       TouchedByCork.Add(L.First());
+        TouchedByCork.Add(L.First());
     }
-  }
+  }*/
+  return;
 }
 
 //=======================================================================
@@ -595,11 +602,7 @@ static TopAbs_Orientation Orientation(const TopoDS_Edge& E,
                                      const TopoDS_Face& F,
                                      const TopTools_ListOfShape& L)
 {
-#ifndef DEB
   TopAbs_Orientation Orien = TopAbs_FORWARD;
-#else
-  TopAbs_Orientation Orien;
-#endif
   TopTools_ListIteratorOfListOfShape itld;
   for ( itld.Initialize(L); itld.More(); itld.Next()) {
     if ( itld.Value().IsSame(E)) {
@@ -733,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;
@@ -951,7 +954,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);
@@ -996,7 +999,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;
 
@@ -1028,39 +1031,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 
 
@@ -1068,7 +1071,7 @@ 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;
@@ -1170,7 +1173,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();
@@ -1658,10 +1661,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
@@ -1728,7 +1731,7 @@ void BiTgte_Blend::ComputeCenters()
   // -------------------------------------------------------------------
 
   // Proceed with MakeLoops 
-
+  TopTools_IndexedDataMapOfShapeListOfShape aDMVV;
   BRepOffset_Type    OT = BRepOffset_Concave;
   if (myRadius < 0.) OT = BRepOffset_Convex; 
    
@@ -1781,7 +1784,8 @@ void BiTgte_Blend::ComputeCenters()
       BRepOffset_Inter2d::Compute(myAsDes,
                                  CurOF,
                                  myEdges,
-                                 myTol);
+                                 myTol,
+                                 aDMVV);
     }
   }
 
@@ -1813,8 +1817,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 
   // ------------
@@ -1850,7 +1858,7 @@ void BiTgte_Blend::ComputeCenters()
     }
   }
 
-#ifdef DEB
+#ifdef OCCT_DEBUG
   if ( myResult.IsNull()) {
     cout << " No Lines of Generated Centers" << endl;
   }
@@ -1908,8 +1916,6 @@ void BiTgte_Blend::ComputeSurfaces()
   // Iteration on the edges lines of center
   // and their valid valid part is taken after cut and tube construction.
   // --------------------------------------------------------------------
-  BRepOffset_Type    OT = BRepOffset_Concave;
-  if (myRadius < 0.) OT = BRepOffset_Convex; 
 
   //TopTools_MapIteratorOfMapOfShape ic(myEdges);
   Standard_Integer i;
@@ -2015,7 +2021,7 @@ void BiTgte_Blend::ComputeSurfaces()
       Handle(Geom2d_Curve) PC2 = 
        BRep_Tool::CurveOnSurface(CurCutE,F2,f2,l2);
       if ( PC1.IsNull() || PC2.IsNull()) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
        cout << "No PCurves on Intersections : No tubes constructed";
        cout << endl;
 #endif 
@@ -2132,15 +2138,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;
            }
@@ -2152,9 +2158,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;
            }
@@ -2255,15 +2261,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());
@@ -2293,6 +2299,7 @@ void BiTgte_Blend::ComputeSurfaces()
 //purpose  : 
 //=======================================================================
 #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
+#include <Geom_Curve.hxx>
 
 void BiTgte_Blend::ComputeShape() 
 {
@@ -2347,9 +2354,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 
@@ -2472,9 +2476,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);
@@ -2612,7 +2616,7 @@ 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;
@@ -2651,7 +2655,7 @@ 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";
@@ -2680,7 +2684,7 @@ 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";