0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / BRepFeat / BRepFeat_MakeRevolutionForm.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 8ee1198..22de2b6
-// File:       BRepFeat_MakeRevolutionForm.cxx
-// Created:    Tue Oct 14 16:15:49 1997
-// Author:     Olga KOULECHOVA
-//             <opt@cleox.paris1.matra-dtv.fr>
+// Created on: 1997-10-14
+// Created by: Olga KOULECHOVA
+// 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.
 
 
-#include <BRepFeat_MakeRevolutionForm.ixx>
-
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepAlgo.hxx>
+#include <BRepAlgoAPI_Common.hxx>
+#include <BRepAlgoAPI_Cut.hxx>
+#include <BRepAlgoAPI_Section.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+#include <BRepBuilderAPI_Transform.hxx>
+#include <BRepExtrema_ExtCF.hxx>
+#include <BRepExtrema_ExtPC.hxx>
 #include <BRepFeat.hxx>
-
-#include <LocOpe.hxx>
-#include <LocOpe_Builder.hxx>
-#include <LocOpe_RevolutionForm.hxx>
-#include <LocOpe_CSIntersector.hxx>
-#include <LocOpe_PntFace.hxx>
-#include <LocOpe_Gluer.hxx>
-#include <LocOpe_FindEdges.hxx>
-
-#include <gp_Vec.hxx>
-#include <gp_Ax1.hxx>
-#include <gp_Pln.hxx>
-#include <gp_Lin.hxx>
-#include <gp_Pnt.hxx>
-
-#include <gp_Vec2d.hxx>
-#include <gp_Pnt2d.hxx>
-
-#include <Geom_Curve.hxx>
-
+#include <BRepFeat_MakeRevolutionForm.hxx>
+#include <BRepLib_MakeEdge.hxx>
+#include <BRepLib_MakeFace.hxx>
+#include <BRepLib_MakeVertex.hxx>
+#include <BRepPrimAPI_MakeBox.hxx>
+#include <BRepTools.hxx>
+#include <BRepTools_Modifier.hxx>
+#include <BRepTools_TrsfModification.hxx>
+#include <BRepTools_WireExplorer.hxx>
+#include <BRepTopAdaptor_FClass2d.hxx>
+#include <CSLib.hxx>
+#include <ElCLib.hxx>
+#include <ElSLib.hxx>
 #include <Geom2d_Curve.hxx>
 #include <Geom2d_Line.hxx>
-
-#include <Geom_Line.hxx>
+#include <Geom2dAPI_ExtremaCurveCurve.hxx>
+#include <Geom2dAPI_InterCurveCurve.hxx>
 #include <Geom_Circle.hxx>
+#include <Geom_ConicalSurface.hxx>
+#include <Geom_Curve.hxx>
+#include <Geom_CylindricalSurface.hxx>
+#include <Geom_Line.hxx>
 #include <Geom_Plane.hxx>
+#include <Geom_RectangularTrimmedSurface.hxx>
 #include <Geom_Surface.hxx>
-#include <Geom_CylindricalSurface.hxx>
-#include <Geom_ConicalSurface.hxx>
 #include <Geom_ToroidalSurface.hxx>
-#include <Geom_RectangularTrimmedSurface.hxx>
-
 #include <Geom_TrimmedCurve.hxx>
-#include <GeomProjLib.hxx>
-
-#include <Geom2dAPI_InterCurveCurve.hxx>
-#include <Geom2dAPI_ExtremaCurveCurve.hxx>
-#include <Geom2d_Curve.hxx>
-#include <Geom2d_Curve.hxx>
-
-
 #include <GeomAPI.hxx>
 #include <GeomAPI_ProjectPointOnCurve.hxx>
-
-#include <TColgp_SequenceOfPnt.hxx>
-
+#include <GeomLProp_CLProps.hxx>
+#include <GeomProjLib.hxx>
+#include <gp_Ax1.hxx>
+#include <gp_Lin.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Pnt2d.hxx>
+#include <gp_Vec.hxx>
+#include <gp_Vec2d.hxx>
+#include <IntRes2d_IntersectionPoint.hxx>
+#include <LocOpe.hxx>
+#include <LocOpe_CSIntersector.hxx>
+#include <LocOpe_FindEdges.hxx>
+#include <LocOpe_Gluer.hxx>
+#include <LocOpe_PntFace.hxx>
+#include <LocOpe_RevolutionForm.hxx>
+#include <Precision.hxx>
+#include <Standard_ConstructionError.hxx>
+#include <TColGeom_Array1OfCurve.hxx>
 #include <TColGeom_SequenceOfCurve.hxx>
-
+#include <TColgp_Array1OfPnt.hxx>
+#include <TColgp_SequenceOfPnt.hxx>
 #include <TColStd_Array1OfReal.hxx>
-#include <IntRes2d_IntersectionPoint.hxx>
-
-#include <BRepTools_WireExplorer.hxx>
-
-#include <BRep_Tool.hxx>
-#include <BRep_Builder.hxx>
-
-#include <TopExp_Explorer.hxx>
 #include <TopExp.hxx>
-
-#include <TopTools_MapOfShape.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopOpeBRepBuild_HBuilder.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
-#include <TopTools_ListOfShape.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
-#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
 #include <TopTools_MapIteratorOfMapOfShape.hxx>
-#include <TopOpeBRepBuild_HBuilder.hxx>
-#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
-
-#include <TColgp_Array1OfPnt.hxx>
-
-#include <TColGeom_Array1OfCurve.hxx>
-
-#include <TopoDS.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Face.hxx>
-
-#include <BRepLib_MakeVertex.hxx>
-#include <BRepLib_MakeEdge.hxx>
-#include <BRepLib_MakeFace.hxx>
-
-#include <BRepTools.hxx>
-
-#include <BRepPrimAPI_MakeBox.hxx>
-#include <BRepBuilderAPI_MakeFace.hxx>
-
-#include <BRepAlgo.hxx>
+#include <TopTools_MapOfShape.hxx>
 
 //modified by NIZNHY-PKV Fri Mar 22 16:56:15 2002
 //#include <BRepAlgo_Cut.hxx>
 //#include <BRepAlgo_Section.hxx>
 //#include <BRepAlgo_Common.hxx>
-#include <BRepAlgoAPI_Cut.hxx>
-#include <BRepAlgoAPI_Section.hxx>
-#include <BRepAlgoAPI_Common.hxx>
 //modified by NIZNHY-PKV Fri Mar 22 16:56:17 2002 t
-
-#include <BRepBuilderAPI_Transform.hxx>
-#include <BRepExtrema_ExtPC.hxx>
-#include <BRepExtrema_ExtCF.hxx>
-
-#include <BRepTools_Modifier.hxx>
-#include <BRepTools_TrsfModification.hxx>
-
-#include <BRepTopAdaptor_FClass2d.hxx>
-
-#include <Standard_ConstructionError.hxx>
-
-#include <Precision.hxx>
-
-
-#include <ElCLib.hxx>
-#include <ElSLib.hxx>
-#include <CSLib.hxx>
-
-#include <GeomLProp_CLProps.hxx>
-
-#ifdef DEB
-Standard_IMPORT Standard_Boolean BRepFeat_GettraceFEAT();
-Standard_IMPORT Standard_Boolean BRepFeat_GettraceFEATRIB();
+#ifdef OCCT_DEBUG
+extern Standard_Boolean BRepFeat_GettraceFEAT();
+extern Standard_Boolean BRepFeat_GettraceFEATRIB();
 #endif
 
 static void MajMap(const TopoDS_Shape&, // base
@@ -153,7 +129,7 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase,
                                       const Standard_Integer Mode,
                                       Standard_Boolean& Modify)
 { 
-#ifdef DEB
+#ifdef OCCT_DEBUG
   Standard_Boolean trc = BRepFeat_GettraceFEAT();
   if (trc) cout << "BRepFeat_MakeRevolutionForm::Init" << endl;
 #endif
@@ -203,7 +179,7 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase,
     GeomAPI_ProjectPointOnCurve proj1(p1, Line);
     GeomAPI_ProjectPointOnCurve proj2(p2, Line);
     if(proj1.NbPoints() < 1 || proj2.NbPoints() < 1) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
       if (trc) cout << " No projection points" << endl;
 #endif
       myStatusError = BRepFeat_NoProjPt;
@@ -236,7 +212,7 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase,
     myFuse   = Standard_False;
   else // if(Mode == 1) 
     myFuse   = Standard_True;
-#ifdef DEB
+#ifdef OCCT_DEBUG
   if (trc) {
     if (myFuse)  cout << " Fuse" << endl;
     if (!myFuse)  cout << " Cut" << endl;
@@ -326,7 +302,7 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase,
                                       OnFirstEdge, OnLastEdge);
   
   if(!Data) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
     if (trc) cout << " No Extreme faces" << endl;
 #endif
     myStatusError = BRepFeat_NoExtFace;
@@ -352,7 +328,7 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase,
   SliList.Append(FirstFace);
   
   if(Sliding) {    // sliding
-#ifdef DEB
+#ifdef OCCT_DEBUG
     if (trc) cout << " Sliding" << endl;
 #endif
     Handle(Geom_Surface) s = BRep_Tool::Surface(FirstFace);
@@ -392,7 +368,7 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase,
   if(Sliding) {    // sliding
     GeomAPI_ProjectPointOnCurve proj(myFirstPnt, Line);
     if(proj.NbPoints() < 1) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
       if (trc) cout << " No First Point projection" << endl;
 #endif
       myStatusError = BRepFeat_NoProjPt;
@@ -404,7 +380,7 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase,
     
     GeomAPI_ProjectPointOnCurve proj1(myLastPnt, Line);
     if(proj.NbPoints() < 1) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
       if (trc) cout << " No Last Point projection" << endl;
 #endif
       myStatusError = BRepFeat_NoProjPt;
@@ -437,20 +413,12 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase,
     
     if(Sliding && !PtOnFirstEdge) {
       BRepExtrema_ExtCF ext1(TopoDS::Edge(ee1.Shape()), FirstFace);
-#ifdef DEB
-      Standard_Integer nb = 
-#endif
-                            ext1.NbExt();
-#ifdef DEB
-      Standard_Real dist =
-#endif
-                            ext1.SquareDistance(1);
-      if(ext1.NbExt() < 1 || ext1.SquareDistance(1) > Precision::Confusion() * Precision::Confusion()) 
+      if(ext1.NbExt() < 1 || ext1.SquareDistance(1) > Precision::SquareConfusion())
        Sliding = Standard_False;
     }
     if(Sliding && !PtOnLastEdge) {
       BRepExtrema_ExtCF ext2(ee2, LastFace); // ExtCF : curves and surfaces
-      if(ext2.NbExt() < 1 || ext2.SquareDistance(1) > Precision::Confusion() * Precision::Confusion()) 
+      if(ext2.NbExt() < 1 || ext2.SquareDistance(1) > Precision::SquareConfusion())
        Sliding = Standard_False;
     }
     if(Sliding && PtOnFirstEdge) {
@@ -467,7 +435,7 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase,
                             Precision::Confusion())) 
          Sliding = Standard_False;
        else {
-//#ifndef DEB
+//#ifndef OCCT_DEBUG
          if(fabs(FirstCircle.Radius()-FirstRayon) >=
 //#else
 //       if(abs(FirstCircle.Radius()-FirstRayon) >=
@@ -493,7 +461,7 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase,
          Sliding = Standard_False;
        else {
          Standard_Real rad = LastCircle.Radius();
-//#ifndef DEB
+//#ifndef OCCT_DEBUG
          if(fabs(rad - LastRayon) >= Precision::Confusion()) { 
 //#else
 //       if(abs(rad - LastRayon) >= Precision::Confusion()) { 
@@ -514,7 +482,7 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase,
 
 // ---case of sliding : construction of the face profile
   if(Sliding) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
     if (trc) cout << " still Sliding" << endl;
 #endif
     TopoDS_Face Prof;
@@ -524,9 +492,12 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase,
                               FirstEdge,LastEdge);
 
     if (!ProfileOK) {
-#ifdef DEB
-      cout << "Not computable" << endl;
-      if (trc) cout << "Face profile not computable" << endl;
+#ifdef OCCT_DEBUG
+      if (trc)
+      {
+        cout << "Not computable" << endl;
+        cout << "Face profile not computable" << endl;
+      }
 #endif
       myStatusError = BRepFeat_NoFaceProf;
       NotDone();
@@ -540,7 +511,7 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase,
     Sliding = Propagate(SliList, Prof, myFirstPnt, myLastPnt, falseside);
 // Control if there is everything required to have the material at the proper side
     if(falseside == Standard_False) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
       cout << " Verify plane and wire orientation" << endl;
 #endif
       myStatusError = BRepFeat_FalseSide;
@@ -754,10 +725,7 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase,
        counter1++;
        NewListOfEdges.Append(edg);
        theEdge = eeee;
-#ifdef DEB
-       Standard_Real dist1 = 
-#endif
-         theLastPnt.Distance(myLastPnt);
+
        if(dist <= myTol) 
          theFEdge = edg;
        theLastPnt = BRep_Tool::Pnt(TopExp::LastVertex(theEdge,Standard_True));
@@ -833,6 +801,7 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase,
   if(Sliding) {
     TopoDS_Face F;
     BB.MakeFace(F, myPln, myTol);
+    w.Closed (BRep_Tool::IsClosed (w));
     BB.Add(F, w);
     mySkface = F;
     myPbase  = mySkface;
@@ -842,7 +811,7 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase,
 
 // ---Case without sliding : construction of the face profile  
   if(!Sliding) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
     if (trc) {
       if (Modify) cout << " Sliding failure" << endl;
       cout << " no Sliding" << endl;
@@ -916,6 +885,7 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase,
        break;
       } 
     }
+    Wiwiwi.Closed (BRep_Tool::IsClosed (Wiwiwi));
     
     BRepLib_MakeFace newbndface(myPln->Pln(), Wiwiwi, Standard_True);
     TopoDS_Face NewBndFace = TopoDS::Face(newbndface.Shape());
@@ -939,7 +909,7 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase,
    
     
     if(!BRepAlgo::IsValid(NewBndFace)) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
       cout << "Invalid new bounding face" << endl;
 #endif
       myStatusError = BRepFeat_InvShape;
@@ -958,9 +928,12 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase,
                                 FirstEdge,LastEdge,OnFirstFace,OnLastFace);
 
     if (!ProfileOK) {
-#ifdef DEB
-      cout << "Not computable" << endl;
-      if (trc) cout << " Face profile not computable" << endl;
+#ifdef OCCT_DEBUG
+      if (trc)
+      {
+        cout << "Not computable" << endl;
+        cout << " Face profile not computable" << endl;
+      }
 #endif
       myStatusError = BRepFeat_NoFaceProf;
       NotDone();
@@ -974,7 +947,7 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase,
     Propagate(SliList, Prof, myFirstPnt, myLastPnt, falseside);
 // Control if there is everything required to have the material at the proper side
     if(falseside == Standard_False) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
       cout << " Verify plane and wire orientation" << endl;
 #endif
       myStatusError = BRepFeat_FalseSide;
@@ -995,6 +968,7 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase,
     for(; it.More(); it.Next()) {
       BB.Add(comp, it.Value());
     }
+    comp.Closed (BRep_Tool::IsClosed (comp));
     
     mySUntil = comp;
    
@@ -1022,7 +996,7 @@ void BRepFeat_MakeRevolutionForm::Init(const TopoDS_Shape& Sbase,
 void BRepFeat_MakeRevolutionForm::Add(const TopoDS_Edge& E,
                             const TopoDS_Face& F)
 {
-#ifdef DEB
+#ifdef OCCT_DEBUG
   Standard_Boolean trc = BRepFeat_GettraceFEAT();
   if (trc) cout << "BRepFeat_MakeRevolutionForm::Add" << endl;
 #endif 
@@ -1062,12 +1036,12 @@ void BRepFeat_MakeRevolutionForm::Add(const TopoDS_Edge& E,
 
 void BRepFeat_MakeRevolutionForm::Perform()
 {
-#ifdef DEB
+#ifdef OCCT_DEBUG
   Standard_Boolean trc = BRepFeat_GettraceFEAT();
   if (trc) cout << "BRepFeat_MakeRevolutionForm::Perform()" << endl;
 #endif
   if(mySbase.IsNull() || mySkface.IsNull() || myPbase.IsNull()) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
     if (trc) cout << " Fields not initialized" << endl;
 #endif
     myStatusError = BRepFeat_NotInitialized;
@@ -1169,7 +1143,7 @@ void BRepFeat_MakeRevolutionForm::Perform()
 
   if(!ASI1.IsDone() || !ASI2.IsDone() ||
      ASI1.NbPoints(1) != 1 || ASI2.NbPoints(1) != 1) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
     if (trc) cout << " Intersection failure" << endl;
 #endif
     myStatusError = BRepFeat_BadIntersect;
@@ -1265,7 +1239,7 @@ void BRepFeat_MakeRevolutionForm::Perform()
   for(; exx.More(); exx.Next()) {
     const TopoDS_Edge& e = TopoDS::Edge(exx.Current());
     if(!myMap.IsBound(e)) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
       if (trc) cout << " Sliding face not in Base shape" << endl;
 #endif
       myStatusError = BRepFeat_IncSlidFace;
@@ -1277,9 +1251,12 @@ void BRepFeat_MakeRevolutionForm::Perform()
   myGShape = VraiForm;
 
   if(!myGluedF.IsEmpty() && !mySUntil.IsNull()) {
-#ifdef DEB
-    cout << "The case is not computable" << endl;
-    if (trc) cout << " Glued faces not empty and Until shape not null" << endl;
+#ifdef OCCT_DEBUG
+    if (trc)
+    {
+      cout << "The case is not computable" << endl;
+      cout << " Glued faces not empty and Until shape not null" << endl;
+    }
 #endif
     myStatusError = BRepFeat_InvShape;
     NotDone();
@@ -1302,7 +1279,7 @@ Standard_Boolean BRepFeat_MakeRevolutionForm::Propagate(TopTools_ListOfShape& Sl
                                                        const gp_Pnt& Lastpnt, 
                                                        Standard_Boolean& falseside)
 {
-#ifdef DEB
+#ifdef OCCT_DEBUG
   Standard_Boolean trc = BRepFeat_GettraceFEATRIB();
   if (trc) cout << "BRepFeat_MakeRevolutionForm::Propagate" << endl;
 #endif
@@ -1453,12 +1430,11 @@ Standard_Boolean BRepFeat_MakeRevolutionForm::Propagate(TopTools_ListOfShape& Sl
       }
     }
     else {
+      e = e1;
       e1.Nullify();
     }
   }
   if(e1.IsNull()) {
-    //Standard_Real f, l;
-    
     myListOfEdges.Clear();
     TopTools_ListOfShape thelist2;    
     mySlface.Bind(CurrentFace, thelist2);
@@ -1732,10 +1708,6 @@ static void MajMap(const TopoDS_Shape& theB,
 
   for (exp.Init(theB,TopAbs_EDGE); exp.More(); exp.Next()) {
     if (!theMap.IsBound(exp.Current())) {
-#ifdef DEB
-      const TopoDS_Edge& e = 
-#endif
-      TopoDS::Edge(exp.Current());
       TopTools_ListOfShape thelist2;
       theMap.Bind(exp.Current(), thelist2);
       theMap(exp.Current()) = theP.Shapes(exp.Current());
@@ -1764,7 +1736,7 @@ static void SetGluedFaces(const TopTools_DataMapOfShapeListOfShape& theSlmap,
       for (it.Initialize(ledg); it.More(); it.Next()) {
        const TopTools_ListOfShape& gfac = thePrism.Shapes(it.Value());
        if (gfac.Extent() != 1) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
          cout << "Pb SetGluedFace" << endl;
 #endif
        }