0028567: Get rid of the unused DRAW commands based on old Boolean Operations (BRepAlgo)
[occt.git] / src / BRepFeat / BRepFeat_MakeLinearForm.cxx
index 97968c2..143cb58 100644 (file)
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
-#include <BRepFeat_MakeLinearForm.ixx>
 
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepAlgoAPI_Common.hxx>
+#include <BRepAlgoAPI_Section.hxx>
+#include <BRepBuilderAPI.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+#include <BRepBuilderAPI_Transform.hxx>
+#include <BRepExtrema_ExtCF.hxx>
+#include <BRepExtrema_ExtPC.hxx>
+#include <BRepExtrema_ExtPF.hxx>
 #include <BRepFeat.hxx>
-
-#include <LocOpe.hxx>
-#include <LocOpe_LinearForm.hxx>
-#include <LocOpe_Gluer.hxx>
-#include <LocOpe_FindEdges.hxx>
-
-#include <gp_Vec.hxx>
-#include <gp_Pln.hxx>
-#include <gp_Lin.hxx>
-#include <gp_Dir.hxx>
-#include <gp_Pnt.hxx>
-
-#include <gp_Vec2d.hxx>
-#include <gp_Pnt2d.hxx>
-
-#include <Geom_Curve.hxx>
-
+#include <BRepFeat_MakeLinearForm.hxx>
+#include <BRepLib_MakeEdge.hxx>
+#include <BRepLib_MakeFace.hxx>
+#include <BRepLib_MakeVertex.hxx>
+#include <BRepLib_MakeWire.hxx>
+#include <BRepPrimAPI_MakeBox.hxx>
+#include <BRepTools.hxx>
+#include <BRepTools_Modifier.hxx>
+#include <BRepTools_TrsfModification.hxx>
+#include <BRepTools_WireExplorer.hxx>
 #include <Geom2d_Curve.hxx>
 #include <Geom2d_Line.hxx>
-
-#include <Geom_Plane.hxx>
-#include <Geom_Surface.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 <GeomLProp_CLProps.hxx>
 #include <GeomProjLib.hxx>
-
-#include <Geom2d_Curve.hxx>
-#include <Geom2d_Curve.hxx>
-
+#include <gp_Dir.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_FindEdges.hxx>
+#include <LocOpe_Gluer.hxx>
+#include <LocOpe_LinearForm.hxx>
+#include <Precision.hxx>
+#include <Standard_ConstructionError.hxx>
+#include <TColGeom_Array1OfCurve.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 <BRepBuilderAPI.hxx>
-#include <BRepPrimAPI_MakeBox.hxx>
-#include <BRepBuilderAPI_MakeFace.hxx>
-
-//modified by NIZNHY-PKV Fri Mar 22 16:51:33 2002 f
-//#include <BRepAlgo_Section.hxx>
-//#include <BRepAlgo_Common.hxx>
-#include <BRepAlgoAPI_Section.hxx>
-#include <BRepAlgoAPI_Common.hxx>
-//modified by NIZNHY-PKV Fri Mar 22 16:51:35 2002 t
-
-#include <BRepExtrema_ExtPC.hxx>
-#include <BRepExtrema_ExtPF.hxx>
-#include <BRepExtrema_ExtCF.hxx>
-
-#include <BRepTools_Modifier.hxx>
-#include <BRepTools_TrsfModification.hxx>
-
-#include <Standard_ConstructionError.hxx>
-
-#include <Precision.hxx>
-
-#include <GeomLProp_CLProps.hxx>
-
-#include <BRepBuilderAPI_Transform.hxx>
-#include <BRepLib_MakeWire.hxx>
-//#include <DbgTools.hxx>
+#include <TopTools_MapOfShape.hxx>
 
-#ifdef DEB
+#ifdef OCCT_DEBUG
 extern Standard_Boolean BRepFeat_GettraceFEAT();
 extern Standard_Boolean BRepFeat_GettraceFEATRIB();
 #endif
@@ -140,7 +108,7 @@ void BRepFeat_MakeLinearForm::Init(const TopoDS_Shape& Sbase,
                                   const Standard_Integer Mode,
                                   const Standard_Boolean Modify)
 {
-#ifdef DEB
+#ifdef OCCT_DEBUG
   Standard_Boolean trc = BRepFeat_GettraceFEAT();
   if (trc) cout << "BRepFeat_MakeLinearForm::Init" << endl;
 #endif
@@ -166,8 +134,8 @@ void BRepFeat_MakeLinearForm::Init(const TopoDS_Shape& Sbase,
   myListOfEdges.Clear();
   mySlface.Clear();
 
-  TopoDS_Shape aLocalShape = W.Oriented(TopAbs_FORWARD);
-  myWire = TopoDS::Wire(aLocalShape);
+  TopoDS_Shape aLocalShapeW = W.Oriented(TopAbs_FORWARD);
+  myWire = TopoDS::Wire(aLocalShapeW);
 //  myWire = TopoDS::Wire(W.Oriented(TopAbs_FORWARD));
   myDir  = Direc;
   myDir1 = Direc1;
@@ -177,7 +145,7 @@ void BRepFeat_MakeLinearForm::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;
@@ -209,7 +177,7 @@ void BRepFeat_MakeLinearForm::Init(const TopoDS_Shape& Sbase,
   if(!myDir1.IsEqual(nulldir, myTol, myTol)) {
     Standard_Real ang = myDir1.Angle(myDir);
     if(ang != M_PI) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
       if (trc) cout << " Directions must be opposite" << endl;
 #endif
       myStatusError = BRepFeat_BadDirect;
@@ -220,7 +188,7 @@ void BRepFeat_MakeLinearForm::Init(const TopoDS_Shape& Sbase,
   else {
 
 // Rib is centre in the middle of translation
-#ifdef DEB
+#ifdef OCCT_DEBUG
     if (trc)  cout << " Rib is centre" << endl;
 #endif
     const gp_Vec& DirTranslation = (Direc + Direc1) * 0.5;
@@ -254,10 +222,7 @@ void BRepFeat_MakeLinearForm::Init(const TopoDS_Shape& Sbase,
                          6.*myBnd, -6.*myBnd, 6.*myBnd);
   TopoDS_Face PlaneFace = TopoDS::Face(PlaneF.Shape());
 
-  //modified by NIZNHY-PKV Fri Mar 22 16:49:28 2002 f
-  //BRepAlgo_Common PlaneS(BndBox, PlaneFace);
   BRepAlgoAPI_Common PlaneS(BndBox, PlaneFace);
-  //modified by NIZNHY-PKV Fri Mar 22 16:49:39 2002 t  
   TopExp_Explorer EXP;
   TopoDS_Shape PlaneSect = PlaneS.Shape();
   EXP.Init(PlaneSect, TopAbs_WIRE);
@@ -286,7 +251,7 @@ void BRepFeat_MakeLinearForm::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;
@@ -312,10 +277,10 @@ void BRepFeat_MakeLinearForm::Init(const TopoDS_Shape& Sbase,
   SliList.Append(FirstFace);
 
   if(Sliding) {    // sliding
-#ifdef DEB
+#ifdef OCCT_DEBUG
     if (trc) cout << " Sliding" << endl;
 #endif
-    Standard_Boolean Sliding = Standard_False;
+    Sliding = Standard_False;
     Handle(Geom_Surface) s = BRep_Tool::Surface(FirstFace);
     if (s->DynamicType() == 
        STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
@@ -388,7 +353,7 @@ void BRepFeat_MakeLinearForm::Init(const TopoDS_Shape& Sbase,
 
 // ---case of sliding : construction of the profile face 
   if(Sliding) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
     if (trc) cout << " still Sliding" << endl;
 #endif
     TopoDS_Face Prof;
@@ -398,9 +363,12 @@ void BRepFeat_MakeLinearForm::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();
@@ -414,7 +382,7 @@ void BRepFeat_MakeLinearForm::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;
@@ -456,10 +424,8 @@ void BRepFeat_MakeLinearForm::Init(const TopoDS_Shape& Sbase,
          pt = myLastPnt;
          Standard_Real fpar = IntPar(cc, myFirstPnt);
          Standard_Real lpar = IntPar(cc, pt);
-         Handle(Geom_Curve) ccc;
          if(fpar > lpar) {
-           ccc = Handle(Geom_Curve)::DownCast(cc->Reversed());
-           cc = ccc;
+           cc = cc->Reversed();
          }
        }
        TopoDS_Edge ee1;
@@ -523,7 +489,6 @@ void BRepFeat_MakeLinearForm::Init(const TopoDS_Shape& Sbase,
          counter++;
        }
        else {
-         Standard_Real f, l;
          Handle(Geom_Curve) cc = BRep_Tool::Curve(E, f, l);
          gp_Pnt pf = BRep_Tool::Pnt(TopExp::FirstVertex(E,Standard_True));
          gp_Pnt pl = myLastPnt;
@@ -662,7 +627,6 @@ void BRepFeat_MakeLinearForm::Init(const TopoDS_Shape& Sbase,
     SlidMap.Clear();
     
     if(Sliding && counter1 > counter) {
-      TopTools_ListIteratorOfListOfShape it;
       TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm;
       TopExp_Explorer EX2(w, TopAbs_EDGE);
       Standard_Integer ii = 0;
@@ -707,6 +671,7 @@ void BRepFeat_MakeLinearForm::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);
 //    BRepLib_MakeFace F(myPln->Pln(),w, Standard_True);
     mySkface = F;
@@ -717,7 +682,7 @@ void BRepFeat_MakeLinearForm::Init(const TopoDS_Shape& Sbase,
 
 // ---Case without sliding : construction of the profile face   
   if(!Sliding) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
     if (trc) {
       if (Modify) cout << " Sliding failure" << endl;
       cout << " no Sliding" << endl;
@@ -731,9 +696,12 @@ void BRepFeat_MakeLinearForm::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();
@@ -747,7 +715,7 @@ void BRepFeat_MakeLinearForm::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;
@@ -762,12 +730,12 @@ void BRepFeat_MakeLinearForm::Init(const TopoDS_Shape& Sbase,
     
     TopoDS_Shape comp;
     
-    BRep_Builder BB;
     BB.MakeShell(TopoDS::Shell(comp));
     
     for(; it.More(); it.Next()) {
       BB.Add(comp, it.Value());
     }
+    comp.Closed (BRep_Tool::IsClosed (comp));
     
     mySUntil = comp;
 
@@ -794,7 +762,7 @@ void BRepFeat_MakeLinearForm::Init(const TopoDS_Shape& Sbase,
 void BRepFeat_MakeLinearForm::Add(const TopoDS_Edge& E,
                                  const TopoDS_Face& F)
 {
-#ifdef DEB
+#ifdef OCCT_DEBUG
   Standard_Boolean trc = BRepFeat_GettraceFEAT();
   if (trc) cout << "BRepFeat_MakeLinearForm::Add" << endl;
 #endif
@@ -806,7 +774,7 @@ void BRepFeat_MakeLinearForm::Add(const TopoDS_Edge& E,
       }
     }
     if (!exp.More()) {
-      Standard_ConstructionError::Raise();
+      throw Standard_ConstructionError();
     }
   
     if (!mySlface.IsBound(F)) {
@@ -834,12 +802,12 @@ void BRepFeat_MakeLinearForm::Add(const TopoDS_Edge& E,
 
 void BRepFeat_MakeLinearForm::Perform()
 {
-#ifdef DEB
+#ifdef OCCT_DEBUG
   Standard_Boolean trc = BRepFeat_GettraceFEAT();
   if (trc) cout << "BRepFeat_MakeLinearForm::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;
@@ -878,7 +846,7 @@ void BRepFeat_MakeLinearForm::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;
@@ -891,9 +859,12 @@ void BRepFeat_MakeLinearForm::Perform()
   SetGluedFaces(mySlface, theForm, myGluedF);  // management of sliding faces  
 
   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();
@@ -950,7 +921,7 @@ void BRepFeat_MakeLinearForm::Perform()
                                                      const gp_Pnt& Lastpnt, 
                                                      Standard_Boolean& falseside)
 {
-#ifdef DEB
+#ifdef OCCT_DEBUG
   Standard_Boolean trc = BRepFeat_GettraceFEATRIB();
   if (trc) cout << "BRepFeat_MakeLinearForm::Propagate" << endl;
 #endif
@@ -966,10 +937,7 @@ void BRepFeat_MakeLinearForm::Perform()
   Standard_Boolean v1OK = Standard_False, v2OK= Standard_False;
   TopoDS_Vertex v1, v2, v3, v4, ve1, ve2;
 
-  //modified by NIZNHY-PKV Fri Mar 22 16:50:24 2002 f
-  //BRepAlgo_Section sect (fac, CurrentFace, Standard_False);
   BRepAlgoAPI_Section sect (fac, CurrentFace, Standard_False);
-  //modified by NIZNHY-PKV Fri Mar 22 16:50:32 2002 t
 
   sect.Approximation(Standard_True);
   sect.Build();
@@ -1090,10 +1058,7 @@ void BRepFeat_MakeLinearForm::Perform()
       }
     }
 
-    //modified by NIZNHY-PKV Fri Mar 22 16:50:53 2002 f
-    //BRepAlgo_Section sectf (fac, CurrentFace, Standard_False);
     BRepAlgoAPI_Section sectf (fac, CurrentFace, Standard_False);
-    //modified by NIZNHY-PKV Fri Mar 22 16:51:03 2002 t
     sectf.Approximation(Standard_True);
     sectf.Build();
 
@@ -1216,7 +1181,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
        }