0030153: Visualization, TKOpenGl - AIS_ColoredShape::SynchronizeAspects() doesn't...
[occt.git] / src / ChFi3d / ChFi3d_Builder_CnCrn.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 2a05ab5..cb5a341
-// File:       ChFi3d_Builder_CnCrn.cxx
-// Created:    03-01-97 
-// Author:      MPS  
+// Created on: 1997-03-01
+// Created by: MPS  
+// Copyright (c) 1997-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public 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.
+
 // Modified by  MPS (14-04-97)  traitement des cas  ou il n'y a pas
 //                              d'intersection entre les stripes 
 //  Modified by  MPS (16-06-97) : on tient compte du fait que GeomPlate
 //                                rend les courbes 2d dans meme ordre que les
 //                                courbes frontieres passees en entree   
 //  Modified by JLR (20-08-97) mise en place des nouveaux constructeurs de GeomPlate
-//
 //  Modified by MPS (03-11-97) on ne cree pas un  batten lorsque le rapport
 //  entre les deux resolutions sur la surface est trop grand (PRO10649)  
-//
 //  Modified by MPS (05-12-97) on ne tient pas compte des aretes degenerees
 //                             lors du calcul du nombre d'aretes.
-//
 //  Modified by JCT (08-12-97) traitement des aretes vives consecutives ou non
 //                             (grille EDC412 sauf D2, L1, L2, L3)
-//
 //  Modified by JCT (11-12-97) pb osf avec indpoint + orientation de plate
 //                             ( --> D2, L1, L2, L3 valides mais laids)
-//  
 //  Modified by MPS (24-02-98)  traitement des aretes de regularite 
-//
 //  Modified by MPS (01-06-98)  traitement des aretes de couture 
 //  Modified by MPS (01-12-98)  traitement des bords libres 
 //  Modified by MPS (01-02-99)  traitement des aretes de regularite 
 //                              consecutives   
 // Traitement des coins                 
 
-#include <Adaptor3d_HCurveOnSurface.hxx>
+#include <Adaptor2d_HCurve2d.hxx>
 #include <Adaptor3d_CurveOnSurface.hxx>
+#include <Adaptor3d_HCurveOnSurface.hxx>
+#include <Adaptor3d_HSurface.hxx>
+#include <Adaptor3d_TopolTool.hxx>
+#include <AppBlend_Approx.hxx>
+#include <Blend_CurvPointFuncInv.hxx>
+#include <Blend_FuncInv.hxx>
+#include <Blend_Function.hxx>
+#include <Blend_RstRstFunction.hxx>
+#include <Blend_SurfCurvFuncInv.hxx>
+#include <Blend_SurfPointFuncInv.hxx>
+#include <Blend_SurfRstFunction.hxx>
 #include <Bnd_Box2d.hxx>
 #include <BndLib_Add2dCurve.hxx>
 #include <BRep_Tool.hxx>
-#include <BRepTools.hxx>
+#include <BRepAdaptor_HCurve2d.hxx>
+#include <BRepAdaptor_HSurface.hxx>
 #include <BRepAlgo_NormalProjection.hxx>
-#include <BRepLib_MakeEdge.hxx>  
-#include <ChFi3d_Builder.jxx>
+#include <BRepBlend_Line.hxx>
+#include <BRepLib_MakeEdge.hxx>
+#include <BRepLib_MakeFace.hxx>
+#include <BRepTools.hxx>
+#include <BRepTopAdaptor_TopolTool.hxx>
+#include <ChFi3d_Builder.hxx>
 #include <ChFi3d_Builder_0.hxx>
+#include <ChFiDS_CommonPoint.hxx>
 #include <ChFiDS_FaceInterference.hxx>
+#include <ChFiDS_HData.hxx>
+#include <ChFiDS_HElSpine.hxx>
 #include <ChFiDS_ListIteratorOfListOfStripe.hxx>
-#include <ChFiDS_SurfData.hxx>
+#include <ChFiDS_Regul.hxx>
 #include <ChFiDS_SequenceOfSurfData.hxx>
+#include <ChFiDS_Spine.hxx>
 #include <ChFiDS_Stripe.hxx>
-#include <ChFiDS_HData.hxx>
-#include <ChFiDS_CommonPoint.hxx>
-#include <ChFiDS_Regul.hxx>
 #include <ChFiDS_StripeArray1.hxx>
-#include <Extrema_ExtPC.hxx>
+#include <ChFiDS_SurfData.hxx>
 #include <Extrema_ExtCC.hxx>
-#include <Extrema_POnCurv.hxx>
-#include <GeomLib.hxx>
 #include <Extrema_ExtPC.hxx>
+#include <Extrema_POnCurv.hxx>
+#include <FairCurve_Batten.hxx>
 #include <Geom2d_BSplineCurve.hxx>
-#include <GeomAdaptor_HSurface.hxx>
+#include <Geom2d_Curve.hxx>
 #include <Geom2d_Line.hxx>
-#include <Geom_Line.hxx>
-#include <Geom_Curve.hxx>
 #include <Geom2d_TrimmedCurve.hxx>
+#include <Geom2dAdaptor_HCurve.hxx>
+#include <Geom2dLProp_CLProps2d.hxx>
+#include <Geom_BezierCurve.hxx>
+#include <Geom_BSplineSurface.hxx>
+#include <Geom_Curve.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_Surface.hxx>
+#include <GeomAdaptor.hxx>
+#include <GeomAdaptor_HSurface.hxx>
 #include <GeomInt_IntSS.hxx>
 #include <GeomLib.hxx>
-#include <GeomAdaptor.hxx>
-#include <Geom2dAdaptor_HCurve.hxx>
 #include <GeomPlate_BuildPlateSurface.hxx>
-#include <GeomPlate_Surface.hxx>
+#include <GeomPlate_CurveConstraint.hxx>
+#include <GeomPlate_HArray1OfHCurve.hxx>
 #include <GeomPlate_MakeApprox.hxx>
 #include <GeomPlate_PlateG0Criterion.hxx>
-#include <GeomPlate_HArray1OfHCurveOnSurface.hxx>
-#include <Geom_Surface.hxx>
-#include <Geom_BezierCurve.hxx>
-#include <Geom2dLProp_CLProps2d.hxx>
-#include <GeomPlate_CurveConstraint.hxx>
-#include <FairCurve_Batten.hxx>
-#include <Geom2d_BSplineCurve.hxx>
+#include <GeomPlate_Surface.hxx>
+#include <gp_Dir2d.hxx>
 #include <gp_Pnt.hxx>
 #include <gp_Pnt2d.hxx>
-#include <gp_Dir2d.hxx>
 #include <math_Matrix.hxx>
 #include <PLib.hxx>
-#include <TColStd_HArray1OfInteger.hxx>
-#include <TColStd_ListOfInteger.hxx>
-#include <TColgp_SequenceOfXY.hxx>
-#include <TColgp_SequenceOfXYZ.hxx>
-#include <TColgp_Array1OfXYZ.hxx>
+#include <Precision.hxx>
+#include <Standard_ConstructionError.hxx>
+#include <Standard_NoSuchObject.hxx>
+#include <Standard_OutOfRange.hxx>
+#include <TColGeom2d_Array1OfCurve.hxx>
+#include <TColGeom2d_HArray1OfCurve.hxx>
+#include <TColGeom2d_SequenceOfCurve.hxx>
+#include <TColGeom_Array1OfCurve.hxx>
+#include <TColGeom_SequenceOfCurve.hxx>
 #include <TColgp_Array1OfPnt.hxx>
 #include <TColgp_Array1OfPnt2d.hxx>
-#include <TopTools_IndexedMapOfShape.hxx>
-#include <TColStd_Array1OfInteger.hxx>
+#include <TColgp_Array1OfXYZ.hxx>
+#include <TColgp_SequenceOfXY.hxx>
+#include <TColgp_SequenceOfXYZ.hxx>
 #include <TColStd_Array1OfBoolean.hxx>
-#include <TColStd_Array2OfInteger.hxx>
+#include <TColStd_Array1OfInteger.hxx>
 #include <TColStd_Array1OfReal.hxx>
+#include <TColStd_Array2OfInteger.hxx>
 #include <TColStd_Array2OfReal.hxx>
-#include <TColGeom2d_Array1OfCurve.hxx>
-#include <TColGeom2d_SequenceOfCurve.hxx>
-#include <TColGeom_Array1OfCurve.hxx>
-#include <TColGeom_SequenceOfCurve.hxx>
-#include <TColGeom2d_HArray1OfCurve.hxx>
+#include <TColStd_HArray1OfInteger.hxx>
+#include <TColStd_ListOfInteger.hxx>
 #include <TopAbs_Orientation.hxx>
 #include <TopExp.hxx>
-#include <TopExp_Explorer.hxx>    
-#include <TopOpeBRepDS_DataStructure.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopOpeBRepBuild_HBuilder.hxx>
 #include <TopOpeBRepDS_Curve.hxx>
-#include <TopOpeBRepDS_Point.hxx>
-#include <TopOpeBRepDS_Surface.hxx> 
+#include <TopOpeBRepDS_CurvePointInterference.hxx>
+#include <TopOpeBRepDS_DataStructure.hxx>
+#include <TopOpeBRepDS_HDataStructure.hxx>
+#include <TopOpeBRepDS_Kind.hxx>
 #include <TopOpeBRepDS_ListOfInterference.hxx>
+#include <TopOpeBRepDS_Point.hxx>
 #include <TopOpeBRepDS_SolidSurfaceInterference.hxx>
-#include <TopOpeBRepDS_Kind.hxx>
-#include <TopOpeBRepDS_Transition.hxx>
-#include <TopOpeBRepDS_CurvePointInterference.hxx>
+#include <TopOpeBRepDS_Surface.hxx>
 #include <TopOpeBRepDS_SurfaceCurveInterference.hxx>
+#include <TopOpeBRepDS_Transition.hxx>
 #include <TopTools_Array2OfShape.hxx>
-#include <BRepLib_MakeFace.hxx> 
-#include <Precision.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+
 // performances 
-#ifdef DEB
+#ifdef OCCT_DEBUG
 #include <OSD_Chronometer.hxx>
 extern Standard_Real  t_plate ,t_approxplate,t_batten; 
 extern void ChFi3d_InitChron(OSD_Chronometer& ch);
 extern void ChFi3d_ResultChron(OSD_Chronometer & ch,Standard_Real& time);
 #endif
 
-//  Modified by Sergey KHROMOV - Fri Dec 21 17:08:19 2001 Begin
-Standard_Boolean isTangentFaces(const TopoDS_Edge &theEdge,
-                               const TopoDS_Face &theFace1,
-                               const TopoDS_Face &theFace2);
-//  Modified by Sergey KHROMOV - Fri Dec 21 17:08:19 2001 End
 
 //=======================================================================
 //function : Indices
@@ -367,7 +395,7 @@ static void CurveHermite (const TopOpeBRepDS_DataStructure& DStr,
       TopExp::MapShapes(OrtProj.Projection() , TopAbs_EDGE, MapE1);
         if (MapE1.Extent()!=0){
           if (MapE1.Extent()!=1) {
-            BRepLib_MakeFace Bface (BRep_Tool::Surface(F));
+            BRepLib_MakeFace Bface (BRep_Tool::Surface(F), Precision::Confusion());
             F=Bface.Face();
             OrtProj.Init(F);
             OrtProj.Build();
@@ -412,7 +440,17 @@ static void CurveHermite (const TopOpeBRepDS_DataStructure& DStr,
       if (ext.NbExt()!=0){ 
         Extrema_POnCurv POnC, POnL;
         ext.Points(1, POnC, POnL);
-        param.ChangeValue(nb) =POnC.Parameter();
+        if (POnC.Value().Distance(POnL.Value()) < Precision::Confusion())
+          param.ChangeValue(nb) =POnC.Parameter();
+        else
+        {
+          if (!cproj.Value(nb).IsNull()) {
+            cproj.Value(nb)->D0(cproj.Value(nb)->LastParameter(),p01);
+          }
+          else if (!cproj.Value(nb+1).IsNull()) {
+            cproj.Value(nb+1)->D0(cproj.Value(nb+1)->FirstParameter(),p01);
+          }
+        }
       }
     }
     if (!ext.IsDone()||ext.NbExt()==0) {
@@ -472,11 +510,7 @@ static void CalculBatten (const Handle (GeomAdaptor_HSurface) ASurf,
                           Handle (Geom2d_Curve)& pcurve)
 {  
   Standard_Boolean isplane;
-#ifndef DEB
   Standard_Boolean anglebig = Standard_False;
-#else
-  Standard_Boolean anglebig;
-#endif
   isplane=ASurf->GetType()==GeomAbs_Plane;
   gp_Dir2d dir1 (xdir, ydir);
   Geom2dLProp_CLProps2d CL1(curv2d1, picicplus, 1, 1.e-4);
@@ -491,15 +525,15 @@ static void CalculBatten (const Handle (GeomAdaptor_HSurface) ASurf,
   Bat.SetFreeSliding (Standard_True);
   Standard_Real ang1,ang2;
   ang1=dir1.Angle(dir3);
-  if (dir1.Angle(dir4) >0 ) ang2=PI-dir1.Angle(dir4);
-  else ang2=-PI-dir1.Angle(dir4);
+  if (dir1.Angle(dir4) >0 ) ang2=M_PI-dir1.Angle(dir4);
+  else ang2=-M_PI-dir1.Angle(dir4);
   if (contraint1&&contraint2) 
   anglebig=(Abs(ang1)>1.2)|| (Abs(ang2)>1.2 );
   else if (contraint1) 
   anglebig=Abs(ang1)>1.2;
   else if (contraint2)
   anglebig=Abs(ang2)>1.2; 
-  if (isplane && (Abs(ang1)>PI/2 || Abs(ang2)>PI/2))
+  if (isplane && (Abs(ang1)>M_PI/2 || Abs(ang2)>M_PI/2))
   isplane=Standard_False;
   if (anglebig && !isplane) {
     CalculDroite(p2d1,xdir,ydir,pcurve);
@@ -512,7 +546,7 @@ static void CalculBatten (const Handle (GeomAdaptor_HSurface) ASurf,
     FairCurve_AnalysisCode Iana; 
     Standard_Boolean Ok;
     Ok = Bat.Compute(Iana,25,1.e-2);
-#if DEB
+#ifdef OCCT_DEBUG
     if (!Ok) { 
       cout<<"no batten :";
       Bat.Dump(cout);
@@ -598,11 +632,7 @@ static void OrientationAreteViveConsecutive (const TopoDS_Shape & Fviveicicplus,
                                              TopAbs_Orientation & orien)
 
 { // orinterf is orientation of edge ic corresponding to face Fviveicicplus taken FORWARD
-#ifndef DEB
   TopAbs_Orientation orinterf = TopAbs_FORWARD;
-#else
-  TopAbs_Orientation orinterf;
-#endif
   TopoDS_Face F=TopoDS::Face( Fviveicicplus);
   TopoDS_Edge E=TopoDS::Edge( Eviveic);  
   TopExp_Explorer ex;
@@ -655,7 +685,7 @@ static void PerformTwoCornerSameExt(TopOpeBRepDS_DataStructure& DStr,
   ChFiDS_CommonPoint& Com12= stripe1->SetOfSurfData()->Value(index1)->ChangeVertex (isfirst,2);
   isfirst=sens2==1;
   ChFiDS_CommonPoint& Com21= stripe2->SetOfSurfData()->Value(index2)->ChangeVertex (isfirst,1);
-#ifdef DEB
+#ifdef OCCT_DEBUG
 //  ChFiDS_CommonPoint& Com22= 
 //    stripe2->SetOfSurfData()->Value(index2)->ChangeVertex (isfirst,2);
 #endif
@@ -914,7 +944,6 @@ static Standard_Integer SurfIndex(const ChFiDS_StripeArray1& StripeArray1,
   case FACE2:       return aSurfData->IndexOfS2();
   default:          return -1;
   }
-  return -1;
 }
 
 //=======================================================================
@@ -980,7 +1009,7 @@ void  ChFi3d_Builder::PerformMoreThreeCorner(const Standard_Integer Jndex,
 //    ========================================
 //             Initialisations
 //     ========================================
-#ifdef DEB
+#ifdef OCCT_DEBUG
   OSD_Chronometer ch;
 #endif 
   TopOpeBRepDS_DataStructure& DStr=myDS->ChangeDS();  
@@ -994,7 +1023,7 @@ void  ChFi3d_Builder::PerformMoreThreeCorner(const Standard_Integer Jndex,
   Standard_Boolean droit=Standard_False;
   if (bordlibre) {nedge=(nedge-2)/2 +2;
      Standard_Real angedg=Abs(ChFi3d_AngleEdge(V1,edgelibre1,edgelibre2));
-     droit=Abs(angedg-PI)<0.01;   
+     droit=Abs(angedg-M_PI)<0.01;   
   }
   else  nedge=nedge/2;
   Standard_Integer size=nedge*2;
@@ -1040,13 +1069,13 @@ void  ChFi3d_Builder::PerformMoreThreeCorner(const Standard_Integer Jndex,
   ChFiDS_ListIteratorOfListOfStripe It;
   Handle(ChFiDS_Stripe) cd2,cdbid,cnext;
   TopoDS_Face face;
-  Standard_Integer jfp,ii;
+  Standard_Integer jfp = 0,ii;
   Standard_Integer ic,icplus,icmoins,icplus2,
-                   sense,index,indice,isurf1,isurf2;
-  Standard_Integer cbplus=0, n3d=0,IVtx,nb;
+                   sense,index = 0,indice,isurf1,isurf2;
+  Standard_Integer cbplus=0, n3d=0,IVtx = 0,nb;
   Standard_Boolean sameside,trouve,isfirst;
   Standard_Real pardeb ,parfin,xdir,ydir;
-  Standard_Real tolapp=1.e-4,maxapp,maxapp1,avedev;
+  Standard_Real tolapp=1.e-4,maxapp = 0.,maxapp1 = 0.,avedev;
   Handle (TopOpeBRepDS_CurvePointInterference) Interfp1, Interfp2;
   Handle (TopOpeBRepDS_SurfaceCurveInterference) Interfc;
   Handle(Geom_Curve) Curv3d;
@@ -1055,7 +1084,7 @@ void  ChFi3d_Builder::PerformMoreThreeCorner(const Standard_Integer Jndex,
   Standard_Integer num;
   TopoDS_Edge Ecur; 
   TopTools_ListIteratorOfListOfShape ItF;
-#ifdef DEB
+#ifdef OCCT_DEBUG
 //  Standard_Integer nface=ChFi3d_nbface(myVFMap(V1));
 #endif
   TopoDS_Face F1,F2;
@@ -1109,8 +1138,7 @@ void  ChFi3d_Builder::PerformMoreThreeCorner(const Standard_Integer Jndex,
       nbcouture++;
     }
     else ChFi3d_cherche_edge(V1,Evive,Fcur,Enext,VV);
-    if (Enext.IsNull())Standard_Failure::Raise
-    ("PerformMoreThreeCorner: pb in the parsing of edges and faces"); 
+    if (Enext.IsNull())throw Standard_Failure("PerformMoreThreeCorner: pb in the parsing of edges and faces");
     if (Enext.IsSame(edgelibre1)|| Enext.IsSame(edgelibre2)) {
       CD.SetValue(ii, cdbid);
       Index.SetValue(ii, 0);
@@ -1233,7 +1261,7 @@ void  ChFi3d_Builder::PerformMoreThreeCorner(const Standard_Integer Jndex,
 //  Modified by Sergey KHROMOV - Fri Dec 21 18:11:02 2001 Begin
 //     regul.SetValue(ic,BRep_Tool::Continuity(TopoDS::Edge(Evive.Value(ic)),F1,F2)
 //                  !=GeomAbs_C0); 
-       regul.SetValue(ic,isTangentFaces(TopoDS::Edge(Evive.Value(ic)),F1,F2)); 
+       regul.SetValue(ic, ChFi3d_isTangentFaces(TopoDS::Edge(Evive.Value(ic)),F1,F2)); 
 //  Modified by Sergey KHROMOV - Fri Dec 21 18:11:07 2001 End
       }
     }
@@ -1248,7 +1276,7 @@ void  ChFi3d_Builder::PerformMoreThreeCorner(const Standard_Integer Jndex,
        if (ind!=ic) {
          TopoDS_Edge ecur=TopoDS::Edge(Evive.Value(ind));
          Standard_Real ang=Abs(ChFi3d_AngleEdge(V1,ecur,ereg)); 
-         if (ang<0.01 || Abs(ang-PI) <0.01) {
+         if (ang<0.01 || Abs(ang-M_PI) <0.01) {
            regul.SetValue(ic,Standard_False);
            tangentregul.SetValue(ic,Standard_True);
            trouve=Standard_True;
@@ -1290,7 +1318,7 @@ void  ChFi3d_Builder::PerformMoreThreeCorner(const Standard_Integer Jndex,
          if ( !E1.IsSame(edgelibre1) && !E1.IsSame(edgelibre2) &&
               !E2.IsSame(edgelibre1) && !E2.IsSame(edgelibre2)){ 
           Standard_Real ang=Abs(ChFi3d_AngleEdge(V1 ,E1,E2));
-          deuxconges=(ang<0.01 || Abs(ang-PI)<0.01);
+          deuxconges=(ang<0.01 || Abs(ang-M_PI)<0.01);
          }
        }
      }
@@ -1322,7 +1350,7 @@ void  ChFi3d_Builder::PerformMoreThreeCorner(const Standard_Integer Jndex,
     isOnSameDiff = isOnSame && isOnDiff;
   }
   if ( isOnSameDiff ) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
     cout << "OnSame + OnDiff, PerformMoreThreeCorner() calls PerformOneCorner()" << endl;
 #endif
     PerformOneCorner (Jndex, Standard_True);
@@ -1339,7 +1367,7 @@ void  ChFi3d_Builder::PerformMoreThreeCorner(const Standard_Integer Jndex,
        Indices(nedge,ic,icplus,icmoins);
         TopoDS_Edge Arc=TopoDS::Edge(Evive.Value(ic));
        ChFiDS_CommonPoint cp1, cp2;
-        Standard_Real angedg=PI;
+        Standard_Real angedg=M_PI;
         TopoDS_Vertex Vcom;
        if (!sharp.Value(icplus)) {
          isfirst=(sens.Value(icplus)==1);
@@ -1349,7 +1377,7 @@ void  ChFi3d_Builder::PerformMoreThreeCorner(const Standard_Integer Jndex,
          if (cp1.IsOnArc()){
             ChFi3d_cherche_vertex(Arc,cp1.Arc(),Vcom,trouve);
             if (trouve) angedg=Abs(ChFi3d_AngleEdge(Vcom,Arc,cp1.Arc()));
-           if (!cp1.Arc().IsSame(Arc) && Abs(angedg-PI)<0.01){
+           if (!cp1.Arc().IsSame(Arc) && Abs(angedg-M_PI)<0.01){
              Evive.SetValue(ic,cp1.Arc());
              ChFi3d_edge_common_faces(myEFMap(cp1.Arc()),F1,F2);
              if (!Fvive.Value(ic,icplus).IsSame(F1) && !Fvive.Value(ic,icplus).IsSame(F2)) {
@@ -1378,10 +1406,10 @@ void  ChFi3d_Builder::PerformMoreThreeCorner(const Standard_Integer Jndex,
          cp2 = CD.Value(icmoins)->SetOfSurfData()->Value(Index.Value(icmoins))->
            ChangeVertex (isfirst,jf.Value(icmoins));
          if (cp2.IsOnArc()) {
-            angedg=PI;
+            angedg=M_PI;
             ChFi3d_cherche_vertex(Arc,cp2.Arc(),Vcom,trouve);
             if (trouve) angedg=Abs(ChFi3d_AngleEdge(Vcom,Arc,cp2.Arc()));
-           if (!cp2.Arc().IsSame(Arc)&&Abs(angedg-PI)<0.01) {
+           if (!cp2.Arc().IsSame(Arc)&&Abs(angedg-M_PI)<0.01) {
              Evive.SetValue(ic,cp2.Arc());
              ChFi3d_edge_common_faces(myEFMap(cp2.Arc()),F1,F2);
              if (!Fvive.Value(ic,icmoins).IsSame(F1) && !Fvive.Value(ic,icmoins).IsSame(F2)) {
@@ -1450,16 +1478,16 @@ void  ChFi3d_Builder::PerformMoreThreeCorner(const Standard_Integer Jndex,
       oksea.SetValue(ic, Standard_False);
     }
     else {
-      Standard_Integer jf1;
-      Standard_Integer i1,i2;
-      Standard_Real pa1,pa2;
+      Standard_Integer jf1 = 0;
+      Standard_Integer i1 = 0,i2 = 0;
+      Standard_Real pa1 = 0.,pa2;
       Standard_Boolean ok;
       Handle(ChFiDS_Stripe) strip;
       Standard_Real angedg;
       Standard_Integer iface;
       // if two edges are tangent the intersection is not attempted (cts60046)
       angedg=Abs(ChFi3d_AngleEdge(V1,TopoDS::Edge(Evive.Value(ic)),TopoDS::Edge(Evive.Value(icplus))));
-      if (Abs(angedg-PI)>0.01)
+      if (Abs(angedg-M_PI)>0.01)
        ok = ChFi3d_SearchFD(DStr,CD.Value(ic),CD.Value(icplus),sens.Value(ic),sens.Value(icplus),
                                  i1,i2,pa1,pa2,
                                  Index.Value(ic),Index.Value(icplus),
@@ -1821,12 +1849,8 @@ void  ChFi3d_Builder::PerformMoreThreeCorner(const Standard_Integer Jndex,
 // between edges (or stripes ) icmoins and indfin. 
 // Then this courbe3d is projected on all faces (nbface) that
 // separate icmoins and indfin
-#ifndef DEB
   Standard_Integer nbface = 0;
-#else
-  Standard_Integer nbface;
-#endif
-  Standard_Real  error;
+  Standard_Real  error = 0.;
   TColGeom2d_Array1OfCurve proj2d1(0,size);
   TColGeom2d_Array1OfCurve proj2d2(0,size);
   TColGeom_Array1OfCurve cproj1(0,size);
@@ -1986,11 +2010,7 @@ void  ChFi3d_Builder::PerformMoreThreeCorner(const Standard_Integer Jndex,
   Standard_Boolean intersection=Standard_False, introuve;
   if (nconges==2 && !deuxconges) { 
     gp_Pnt P1,P2,P3,P4;
-#ifndef DEB
     Standard_Integer ic1 = 0,ic2 = 0;
-#else
-    Standard_Integer ic1,ic2;
-#endif
     trouve=Standard_False;
     for (ic=0;ic<nedge&&!trouve;ic++) {
       if (!sharp.Value(ic)){ 
@@ -2230,20 +2250,20 @@ void  ChFi3d_Builder::PerformMoreThreeCorner(const Standard_Integer Jndex,
         if (couture) {
          Standard_Boolean PI1=Standard_False, PI2=Standard_False;
          Standard_Real xx;
-         PI1=0<=p2d1.X() && p2d1.X() <=PI;
-         PI2=0<=p2d2.X() && p2d2.X() <=PI;
+         PI1=0<=p2d1.X() && p2d1.X() <=M_PI;
+         PI2=0<=p2d2.X() && p2d2.X() <=M_PI;
          
          if (Evive.Value(ic).IsSame(edgecouture)){
            xx=p2d1.X();
-           if (PI2&&!PI1) xx=xx-2*PI;
-           if (!PI2&&PI1) xx=xx+2*PI;
+           if (PI2&&!PI1) xx=xx-2*M_PI;
+           if (!PI2&&PI1) xx=xx+2*M_PI;
            p2d1.SetX(xx);
               
          }
          if (Evive.Value(icplus).IsSame(edgecouture)){
            xx=p2d2.X();
-           if (PI2&&!PI1) xx=xx+2*PI;
-           if (!PI2&&PI1) xx=xx-2*PI;
+           if (PI2&&!PI1) xx=xx+2*M_PI;
+           if (!PI2&&PI1) xx=xx-2*M_PI;
            p2d2.SetX(xx); 
          }
         }
@@ -2298,7 +2318,7 @@ void  ChFi3d_Builder::PerformMoreThreeCorner(const Standard_Integer Jndex,
           Standard_Boolean contraint1=Standard_True,
                             contraint2=Standard_True;
           if (raccordbatten) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
            ChFi3d_InitChron(ch);// initial performances for  battens  
 #endif  
             Standard_Boolean inverseic,inverseicplus;
@@ -2324,7 +2344,7 @@ void  ChFi3d_Builder::PerformMoreThreeCorner(const Standard_Integer Jndex,
             contraint2=Standard_False;
            CalculBatten(Asurf,TopoDS::Face(Fvive(ic,icplus)),xdir,ydir,p2d1,p2d2,contraint1,contraint2,curv2d1,curv2d2,p.Value(ic,icplus),
                         p.Value(icplus,ic),inverseic,inverseicplus,pcurve);
-#ifdef DEB
+#ifdef OCCT_DEBUG
            ChFi3d_ResultChron( ch,t_batten);  // resulting performances for battens 
 #endif 
           }
@@ -2596,19 +2616,19 @@ void  ChFi3d_Builder::PerformMoreThreeCorner(const Standard_Integer Jndex,
       }
   } 
  
-#ifdef DEB
+#ifdef OCCT_DEBUG
   ChFi3d_InitChron(ch); // init performances for plate 
 #endif
 
   PSurf.Perform();
 
-#ifdef DEB  
+#ifdef OCCT_DEBUG
   ChFi3d_ResultChron(ch, t_plate); //result performances for plate 
 #endif 
 
   // call of approx  
  
-#ifdef DEB
+#ifdef OCCT_DEBUG
   ChFi3d_InitChron(ch);  // init performances for approxplate
 #endif
   if (PSurf.IsDone()) {
@@ -2630,14 +2650,14 @@ void  ChFi3d_Builder::PerformMoreThreeCorner(const Standard_Integer Jndex,
     Standard_Real coef = 1.1 ,apperror;
     apperror=Mapp.CriterionError()*coef;
 
-#ifdef DEB  
+#ifdef OCCT_DEBUG
   ChFi3d_ResultChron(ch, t_approxplate); // result performances for approxplate
 #endif
   
 //  Storage of the surface plate and corresponding curves in the DS 
 
     TopAbs_Orientation orplate,orsurfdata,orpcurve,orien;
-#ifdef DEB
+#ifdef OCCT_DEBUG
 //    Standard_Real ang1=PSurf.G1Error();
 #endif
 //     gp_Vec n1,n2,du,dv,du1,dv1;
@@ -2674,11 +2694,7 @@ void  ChFi3d_Builder::PerformMoreThreeCorner(const Standard_Integer Jndex,
          else  
            Arcspine= CD.Value(ic)->Spine()->Edges(nbedge);
          Standard_Integer IArcspine = DStr.AddShape(Arcspine);
-#ifndef DEB
          TopAbs_Orientation OVtx = TopAbs_FORWARD;
-#else
-         TopAbs_Orientation OVtx;
-#endif
          for(ex.Init(Arcspine.Oriented(TopAbs_FORWARD),TopAbs_VERTEX); 
              ex.More(); ex.Next()){
            if(V1.IsSame(ex.Current())) {
@@ -2731,11 +2747,7 @@ void  ChFi3d_Builder::PerformMoreThreeCorner(const Standard_Integer Jndex,
   // the curves from ic to icplus the pcurves of Plate 
   // all have the same orientation  
     Standard_Integer Ishape1,Ishape2; 
-#ifndef DEB
     TopAbs_Orientation trafil1 = TopAbs_FORWARD, trafil2 = TopAbs_FORWARD;
-#else
-    TopAbs_Orientation trafil1,trafil2;
-#endif
     Ishape1 = Fd->IndexOfS1();
     Ishape2 = Fd->IndexOfS2();
     const ChFiDS_FaceInterference& Fi1 = Fd->InterferenceOnS1();