0027272: FixMissingSeam function creates G1 seam curves
[occt.git] / src / BRepFeat / BRepFeat.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 3211e3f..63ebee5
@@ -1,71 +1,63 @@
 // Created on: 1996-04-23
 // Created by: Jacques GOUSSARD
 // 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 <BRepFeat.ixx>
-
-//#include <BRepAlgo_Cut.hxx>
-
-#include <BRepBuilderAPI.hxx>
-#include <BRepAdaptor_Curve.hxx>
-#include <TopExp_Explorer.hxx>
-#include <TopTools_MapOfShape.hxx>
-#include <BRep_Tool.hxx>
+#include <Bnd_Box.hxx>
 #include <BRep_Builder.hxx>
-#include <Geom_Curve.hxx>
-#include <Geom_TrimmedCurve.hxx>
-#include <Geom2d_TrimmedCurve.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <BRepBndLib.hxx>
+#include <BRepBuilderAPI.hxx>
+#include <BRepFeat.hxx>
+#include <BRepLib_MakeFace.hxx>
+#include <BRepTools.hxx>
+#include <BRepTopAdaptor_FClass2d.hxx>
+#include <ElSLib.hxx>
 #include <Extrema_ExtPC.hxx>
-#include <GeomAdaptor_Curve.hxx>
-#include <BRepLProp.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Shell.hxx>
-#include <TopoDS_Solid.hxx>
-#include <Precision.hxx>
 #include <GCPnts_QuasiUniformDeflection.hxx>
-#include <BRepTopAdaptor_FClass2d.hxx>
+#include <Geom2d_TrimmedCurve.hxx>
 #include <Geom2dAdaptor_Curve.hxx>
+#include <Geom_ConicalSurface.hxx>
+#include <Geom_Curve.hxx>
+#include <Geom_CylindricalSurface.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_RectangularTrimmedSurface.hxx>
+#include <Geom_Surface.hxx>
+#include <Geom_TrimmedCurve.hxx>
+#include <GeomAdaptor_Curve.hxx>
 #include <GeomProjLib.hxx>
+#include <gp_Pnt.hxx>
 #include <gp_Vec2d.hxx>
-#include <BRepTools.hxx>
-#include <Geom_Surface.hxx>
-#include <Bnd_Box.hxx>
-#include <BRepBndLib.hxx>
-#include <BRepLib_MakeFace.hxx>
-#include <Geom_RectangularTrimmedSurface.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_CylindricalSurface.hxx>
-#include <Geom_ConicalSurface.hxx>
+#include <LocOpe.hxx>
+#include <LocOpe_BuildShape.hxx>
 #include <LocOpe_CSIntersector.hxx>
 #include <LocOpe_PntFace.hxx>
-#include <LocOpe_BuildShape.hxx> 
-
+#include <Precision.hxx>
 #include <TColGeom_SequenceOfCurve.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Shell.hxx>
+#include <TopoDS_Solid.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopTools_MapOfShape.hxx>
 
-
-#include <LocOpe.hxx>
-
+//#include <BRepAlgo_Cut.hxx>
 #define NECHANTBARYC 11
 
 //=======================================================================
@@ -74,7 +66,7 @@
 //=======================================================================
 
 void BRepFeat::SampleEdges(const TopoDS_Shape& theShape,
-                          TColgp_SequenceOfPnt& theSeq)
+                           TColgp_SequenceOfPnt& theSeq)
 {
   LocOpe::SampleEdges(theShape,theSeq);
 }
@@ -87,7 +79,7 @@ void BRepFeat::SampleEdges(const TopoDS_Shape& theShape,
 //=======================================================================
 
 void BRepFeat::Barycenter(const TopoDS_Shape& S, 
-                         gp_Pnt& B)
+                          gp_Pnt& B)
 {
   TopTools_MapOfShape theMap;
   TopExp_Explorer exp(S,TopAbs_EDGE);
@@ -106,9 +98,9 @@ void BRepFeat::Barycenter(const TopoDS_Shape& S,
       C = BRep_Tool::Curve(edg,Loc,f,l);
       C = Handle(Geom_Curve)::DownCast(C->Transformed(Loc.Transformation()));
       for (i=1;i<NECHANTBARYC; i++) {
-       prm = ((NECHANTBARYC-i)*f + i*l)/NECHANTBARYC;
-       Bar += C->Value(prm).XYZ();
-       nbp++;
+        prm = ((NECHANTBARYC-i)*f + i*l)/NECHANTBARYC;
+        Bar += C->Value(prm).XYZ();
+        nbp++;
       }
     }
   }
@@ -131,7 +123,7 @@ void BRepFeat::Barycenter(const TopoDS_Shape& S,
 //=======================================================================
 
 Standard_Real BRepFeat::ParametricBarycenter(const TopoDS_Shape& S, 
-                                            const Handle(Geom_Curve)& CC)
+                                             const Handle(Geom_Curve)& CC)
 {
   TopTools_MapOfShape theMap;
   TopExp_Explorer exp(S,TopAbs_EDGE);
@@ -153,24 +145,24 @@ Standard_Real BRepFeat::ParametricBarycenter(const TopoDS_Shape& S,
       C = BRep_Tool::Curve(edg,Loc,f,l);
       C = Handle(Geom_Curve)::DownCast(C->Transformed(Loc.Transformation()));
       for (i=1;i<NECHANTBARYC; i++) {
-       prm = ((NECHANTBARYC-i)*f + i*l)/NECHANTBARYC;
-       gp_Pnt pone = C->Value(prm);
-       // On projette sur CC
-       extpc.Perform(pone);
-       if (extpc.IsDone() && extpc.NbExt() >= 1) {
-         Standard_Real Dist2Min = extpc.SquareDistance(1);
-         Standard_Integer kmin = 1;
-         for (Standard_Integer k=2; k<=extpc.NbExt(); k++) {
-           Standard_Real Dist2 = extpc.SquareDistance(k);
-           if (Dist2 < Dist2Min) {
-             Dist2Min = Dist2;
-             kmin = k;
-           }
-         }
-         nbp++;
-         Standard_Real prmp = extpc.Point(kmin).Parameter();
-         parbar += prmp;
-       }         
+        prm = ((NECHANTBARYC-i)*f + i*l)/NECHANTBARYC;
+        gp_Pnt pone = C->Value(prm);
+        // On projette sur CC
+        extpc.Perform(pone);
+        if (extpc.IsDone() && extpc.NbExt() >= 1) {
+          Standard_Real Dist2Min = extpc.SquareDistance(1);
+          Standard_Integer kmin = 1;
+          for (Standard_Integer k=2; k<=extpc.NbExt(); k++) {
+            Standard_Real Dist2 = extpc.SquareDistance(k);
+            if (Dist2 < Dist2Min) {
+              Dist2Min = Dist2;
+              kmin = k;
+            }
+          }
+          nbp++;
+          Standard_Real prmp = extpc.Point(kmin).Parameter();
+          parbar += prmp;
+        }
       }
     }
   }
@@ -181,22 +173,15 @@ Standard_Real BRepFeat::ParametricBarycenter(const TopoDS_Shape& S,
       // On projette sur CC
       extpc.Perform(pone);
       if (extpc.IsDone() && extpc.NbExt() >= 1) {
-       Standard_Real Dist2Min = extpc.SquareDistance(1);
-       Standard_Integer kmin = 1;
-       for (Standard_Integer k=2; k<=extpc.NbExt(); k++) {
-         Standard_Real Dist2 = extpc.SquareDistance(k);
-         if (Dist2 < Dist2Min) {
-           Dist2Min = Dist2;
-           kmin = k;
-         }
-       }
-       nbp++;
-#ifdef DEB
-       Standard_Real prmp = extpc.Point(kmin).Parameter();
-#else
-        extpc.Point(kmin).Parameter();
-#endif
-      }          
+        Standard_Real Dist2Min = extpc.SquareDistance(1);
+        for (Standard_Integer k=2; k<=extpc.NbExt(); k++) {
+          Standard_Real Dist2 = extpc.SquareDistance(k);
+          if (Dist2 < Dist2Min) {
+            Dist2Min = Dist2;
+          }
+        }
+        nbp++;
+      }          
     }
   }
 
@@ -211,34 +196,34 @@ Standard_Real BRepFeat::ParametricBarycenter(const TopoDS_Shape& S,
 //=======================================================================
 
 void BRepFeat::ParametricMinMax(const TopoDS_Shape& S, 
-                               const Handle(Geom_Curve)& CC,
-                               Standard_Real& prmin,
-                               Standard_Real& prmax,
-                               Standard_Real& prbmin,
-                               Standard_Real& prbmax,
-                               Standard_Boolean& flag,
-                               const Standard_Boolean Ori)
+                                const Handle(Geom_Curve)& CC,
+                                Standard_Real& prmin,
+                                Standard_Real& prmax,
+                                Standard_Real& prbmin,
+                                Standard_Real& prbmax,
+                                Standard_Boolean& flag,
+                                const Standard_Boolean theOri)
 {
   LocOpe_CSIntersector ASI(S);
   TColGeom_SequenceOfCurve scur;
   scur.Append(CC);
   ASI.Perform(scur);
   if(ASI.IsDone() && ASI.NbPoints(1) >=1) {
-    if (!Ori) {
+    if (!theOri) {
       prmin = Min(ASI.Point(1,1).Parameter(), 
-                 ASI.Point(1, ASI.NbPoints(1)).Parameter());
+                  ASI.Point(1, ASI.NbPoints(1)).Parameter());
       prmax = Max(ASI.Point(1,1).Parameter(), 
-                 ASI.Point(1, ASI.NbPoints(1)).Parameter());
+                  ASI.Point(1, ASI.NbPoints(1)).Parameter());
     }
     else {
       TopAbs_Orientation Ori = ASI.Point(1,1).Orientation();
       if (Ori ==  TopAbs_FORWARD) {
-       prmin = ASI.Point(1,1).Parameter();
-       prmax = ASI.Point(1, ASI.NbPoints(1)).Parameter();
+        prmin = ASI.Point(1,1).Parameter();
+        prmax = ASI.Point(1, ASI.NbPoints(1)).Parameter();
       }
       else {
-       prmax = ASI.Point(1,1).Parameter();
-       prmin = ASI.Point(1, ASI.NbPoints(1)).Parameter();
+        prmax = ASI.Point(1,1).Parameter();
+        prmin = ASI.Point(1, ASI.NbPoints(1)).Parameter();
       }
     }
     flag = Standard_True;
@@ -270,28 +255,28 @@ void BRepFeat::ParametricMinMax(const TopoDS_Shape& S,
       C = BRep_Tool::Curve(edg,Loc,f,l);
       C = Handle(Geom_Curve)::DownCast(C->Transformed(Loc.Transformation()));
       for (i=1;i<NECHANTBARYC; i++) {
-       prm = ((NECHANTBARYC-i)*f + i*l)/NECHANTBARYC;
-       gp_Pnt pone = C->Value(prm);
-       // On projette sur CC
-       extpc.Perform(pone);
-       if (extpc.IsDone() && extpc.NbExt() >= 1) {
-         Standard_Real Dist2Min = extpc.SquareDistance(1);
-         Standard_Integer kmin = 1;
-         for (Standard_Integer k=2; k<=extpc.NbExt(); k++) {
-           Standard_Real Dist2 = extpc.SquareDistance(k);
-           if (Dist2 < Dist2Min) {
-             Dist2Min = Dist2;
-             kmin = k;
-           }
-         }
-         Standard_Real prmp = extpc.Point(kmin).Parameter();
-         if (prmp <= prbmin) {
-           prbmin = prmp;
-         }
-         if (prmp >= prbmax) {
-           prbmax = prmp;
-         }
-       }         
+        prm = ((NECHANTBARYC-i)*f + i*l)/NECHANTBARYC;
+        gp_Pnt pone = C->Value(prm);
+        // On projette sur CC
+        extpc.Perform(pone);
+        if (extpc.IsDone() && extpc.NbExt() >= 1) {
+          Standard_Real Dist2Min = extpc.SquareDistance(1);
+          Standard_Integer kmin = 1;
+          for (Standard_Integer k=2; k<=extpc.NbExt(); k++) {
+            Standard_Real Dist2 = extpc.SquareDistance(k);
+            if (Dist2 < Dist2Min) {
+              Dist2Min = Dist2;
+              kmin = k;
+            }
+          }
+          Standard_Real prmp = extpc.Point(kmin).Parameter();
+          if (prmp <= prbmin) {
+            prbmin = prmp;
+          }
+          if (prmp >= prbmax) {
+            prbmax = prmp;
+          }
+        }          
       }
     }
   }
@@ -302,23 +287,23 @@ void BRepFeat::ParametricMinMax(const TopoDS_Shape& S,
       // On projette sur CC
       extpc.Perform(pone);
       if (extpc.IsDone() && extpc.NbExt() >= 1) {
-       Standard_Real Dist2Min = extpc.SquareDistance(1);
-       Standard_Integer kmin = 1;
-       for (Standard_Integer k=2; k<=extpc.NbExt(); k++) {
-         Standard_Real Dist2 = extpc.SquareDistance(k);
-         if (Dist2 < Dist2Min) {
-           Dist2Min = Dist2;
-           kmin = k;
-         }
-       }
-       Standard_Real prmp = extpc.Point(kmin).Parameter();
-       if (prmp <= prbmin) {
-         prbmin = prmp;
-       }
-       if (prmp >= prbmax) {
-         prbmax = prmp;
-       }
-      }          
+        Standard_Real Dist2Min = extpc.SquareDistance(1);
+        Standard_Integer kmin = 1;
+        for (Standard_Integer k=2; k<=extpc.NbExt(); k++) {
+          Standard_Real Dist2 = extpc.SquareDistance(k);
+          if (Dist2 < Dist2Min) {
+            Dist2Min = Dist2;
+            kmin = k;
+          }
+        }
+        Standard_Real prmp = extpc.Point(kmin).Parameter();
+        if (prmp <= prbmin) {
+          prbmin = prmp;
+        }
+        if (prmp >= prbmax) {
+          prbmax = prmp;
+        }
+      }          
     }
   }
 }
@@ -332,7 +317,7 @@ void BRepFeat::ParametricMinMax(const TopoDS_Shape& S,
 //=======================================================================
 
 static Standard_Boolean IsIn (BRepTopAdaptor_FClass2d& FC,
-                                Geom2dAdaptor_Curve      AC)
+                              Geom2dAdaptor_Curve      AC)
 {
  Standard_Real Def = 100*Precision::Confusion();
  GCPnts_QuasiUniformDeflection QU(AC,Def);
@@ -341,7 +326,6 @@ static Standard_Boolean IsIn (BRepTopAdaptor_FClass2d& FC,
    gp_Pnt2d P = AC.Value(QU.Parameter(i));
    if (FC.Perform(P, Standard_False) == TopAbs_OUT) {
      return Standard_False;
-     break;
    } 
  }
  return Standard_True;
@@ -357,12 +341,12 @@ static Standard_Boolean IsIn (BRepTopAdaptor_FClass2d& FC,
   //---------------
 
 static void PutInBoundsU (Standard_Real      umin,
-                        Standard_Real      umax,
-                        Standard_Real      eps,
-                        Standard_Real      period,
-                        Standard_Real      f,
-                        Standard_Real      l,
-                        Handle(Geom2d_Curve)&       C2d)
+                          Standard_Real      umax,
+                          Standard_Real      eps,
+                          Standard_Real      period,
+                          Standard_Real      f,
+                          Standard_Real      l,
+                          Handle(Geom2d_Curve)&       C2d)
 {
   gp_Pnt2d      Pf      = C2d->Value(f);
   gp_Pnt2d      Pl      = C2d->Value(l);
@@ -403,12 +387,12 @@ static void PutInBoundsU (Standard_Real      umin,
   //---------------
 
 static void PutInBoundsV (Standard_Real     vmin,
-                        Standard_Real      vmax,
-                        Standard_Real      eps,
-                        Standard_Real      period,
-                        Standard_Real      f,
-                        Standard_Real      l,
-                        Handle(Geom2d_Curve)&       C2d)
+                          Standard_Real      vmax,
+                          Standard_Real      eps,
+                          Standard_Real      period,
+                          Standard_Real      f,
+                          Standard_Real      l,
+                          Handle(Geom2d_Curve)&       C2d)
 {
   gp_Pnt2d      Pf      = C2d->Value(f);
   gp_Pnt2d      Pl      = C2d->Value(l);
@@ -447,7 +431,7 @@ static void PutInBoundsV (Standard_Real     vmin,
 
 
 Standard_Boolean BRepFeat::IsInside(const TopoDS_Face& F1,
-                                 const TopoDS_Face& F2)
+                                    const TopoDS_Face& F2)
 {
   TopExp_Explorer exp;
   exp.Init(F1, TopAbs_EDGE);
@@ -471,7 +455,7 @@ Standard_Boolean BRepFeat::IsInside(const TopoDS_Face& F1,
   TopoDS_Shape aLocalShape = F2.Oriented(TopAbs_FORWARD);
   BRepTopAdaptor_FClass2d FC (TopoDS::Face(aLocalShape),Precision::Confusion());
 //  BRepTopAdaptor_FClass2d FC (TopoDS::Face(F2.Oriented(TopAbs_FORWARD)),
-//                             Precision::Confusion());
+//                                Precision::Confusion());
   for(; exp.More(); exp.Next()) {
     Standard_Real   f1,l1;
     Handle(Geom_Curve) C0 = BRep_Tool::Curve(TopoDS::Edge(exp.Current()),f1,l1);
@@ -486,7 +470,6 @@ Standard_Boolean BRepFeat::IsInside(const TopoDS_Face& F1,
     Geom2dAdaptor_Curve  AC(C,f1,l1);
     if (!IsIn(FC,AC)) {
       return Standard_False;
-      break;
     }
   }
   return Standard_True;
@@ -501,18 +484,13 @@ Standard_Boolean BRepFeat::IsInside(const TopoDS_Face& F1,
 
 
 void BRepFeat::FaceUntil(const TopoDS_Shape& Sbase,
-                        TopoDS_Face& FUntil)
+                         TopoDS_Face& FUntil)
 {
   Bnd_Box B;
   BRepBndLib::Add(Sbase,B);
-  Standard_Real c[6], bnd;
-  B.Get(c[0],c[2],c[4],c[1],c[3],c[5]);
-  bnd = c[0];
-  for(Standard_Integer i = 1 ; i < 6; i++) {
-    if(c[i] > bnd) bnd = c[i];
-  }
-  bnd = 10*bnd;
-
+  Standard_Real x[2], y[2], z[2];
+  B.Get(x[0],y[0],z[0],x[1],y[1],z[1]);
+  Standard_Real diam = 10.*Sqrt(B.SquareExtent());
   
   Handle(Geom_Surface) s = BRep_Tool::Surface(FUntil);
   Handle(Standard_Type) styp = s->DynamicType();
@@ -522,16 +500,80 @@ void BRepFeat::FaceUntil(const TopoDS_Shape& Sbase,
   }
   Handle(Geom_RectangularTrimmedSurface) str;
   if (styp == STANDARD_TYPE(Geom_Plane)) {
+    gp_Pln aPln = Handle(Geom_Plane)::DownCast(s)->Pln();
+    Standard_Real u, v, umin = RealLast(), umax = -umin,
+                        vmin = RealLast(), vmax = -vmin;
+    for(Standard_Integer i = 0 ; i < 2; i++) 
+    {
+      for(Standard_Integer j = 0; j < 2; j++)
+      {
+        for(Standard_Integer k = 0; k < 2; k++)
+        {
+          gp_Pnt aP(x[i], y[j], z[k]);
+          ElSLib::Parameters(aPln, aP, u, v);
+          if(u < umin) 
+            umin = u;
+          if(u > umax) 
+            umax = u;
+          if(v < vmin)
+            vmin = v;
+          if(v > vmax)
+            vmax = v;
+        }
+      }
+    }
+    umin -= diam;
+    umax += diam;
+    vmin -= diam;
+    vmax += diam;
     str = new Geom_RectangularTrimmedSurface
-      (s, bnd, -bnd, bnd, -bnd, Standard_True, Standard_True);
+      (s, umin, umax, vmin, vmax, Standard_True, Standard_True);
   }
   else if (styp == STANDARD_TYPE(Geom_CylindricalSurface)) {
+    gp_Cylinder aCyl = Handle(Geom_CylindricalSurface)::DownCast(s)->Cylinder();
+    Standard_Real u, v, vmin = RealLast(), vmax = -vmin;
+    for(Standard_Integer i = 0 ; i < 2; i++) 
+    {
+      for(Standard_Integer j = 0; j < 2; j++)
+      {
+        for(Standard_Integer k = 0; k < 2; k++)
+        {
+          gp_Pnt aP(x[i], y[j], z[k]);
+          ElSLib::Parameters(aCyl, aP, u, v);
+          if(v < vmin)
+            vmin = v;
+          if(v > vmax)
+            vmax = v;
+        }
+      }
+    }
+    vmin -= diam;
+    vmax += diam;
     str = new Geom_RectangularTrimmedSurface
-      (s, 0., 2.*M_PI, bnd, -bnd, Standard_True, Standard_True);
+      (s, vmin, vmax, Standard_False, Standard_True);
   }
   else if (styp == STANDARD_TYPE(Geom_ConicalSurface)) {
+    gp_Cone aCon = Handle(Geom_ConicalSurface)::DownCast(s)->Cone();
+    Standard_Real u, v, vmin = RealLast(), vmax = -vmin;
+    for(Standard_Integer i = 0 ; i < 2; i++) 
+    {
+      for(Standard_Integer j = 0; j < 2; j++)
+      {
+        for(Standard_Integer k = 0; k < 2; k++)
+        {
+          gp_Pnt aP(x[i], y[j], z[k]);
+          ElSLib::Parameters(aCon, aP, u, v);
+          if(v < vmin)
+            vmin = v;
+          if(v > vmax)
+            vmax = v;
+        }
+      }
+    }
+    vmin -= diam;
+    vmax += diam;
     str = new Geom_RectangularTrimmedSurface
-      (s, 0., 2.*M_PI, bnd, -bnd, Standard_True, Standard_True);
+      (s, vmin, vmax, Standard_False, Standard_True);
   }
   else {
     FUntil.Nullify();
@@ -549,8 +591,8 @@ void BRepFeat::FaceUntil(const TopoDS_Shape& Sbase,
 //=======================================================================
 
 TopoDS_Solid BRepFeat::Tool(const TopoDS_Shape& SRef,
-                           const TopoDS_Face& Fac,
-                           const TopAbs_Orientation Orf)
+                            const TopoDS_Face& Fac,
+                            const TopAbs_Orientation Orf)
 {
   TopTools_ListOfShape lfaces;
 //  for (TopExp_Explorer exp(SRef,TopAbs_FACE); exp.More(); exp.Next()) {
@@ -584,11 +626,9 @@ TopoDS_Solid BRepFeat::Tool(const TopoDS_Shape& SRef,
 
 
   Sh.Orientation(TopAbs_FORWARD);
-#ifdef DEB
-  TopAbs_Orientation orient;
-#else
+
   TopAbs_Orientation orient = TopAbs_FORWARD;
-#endif
+
   for (exp.Init(Sh,TopAbs_FACE); exp.More(); exp.Next()) {
     if (exp.Current().IsSame(Fac)) {
       orient = exp.Current().Orientation();
@@ -618,9 +658,9 @@ TopoDS_Solid BRepFeat::Tool(const TopoDS_Shape& SRef,
 //function : Print
 //purpose  : Print the error Description of a StatusError on a stream.
 //=======================================================================
-       
+            
 Standard_OStream& BRepFeat::Print(const BRepFeat_StatusError se, 
-                                 Standard_OStream& s)
+                                  Standard_OStream& s)
 {
   switch(se) {
   case BRepFeat_OK :