Salome HOME
[bos #37951][EDF 25230] SIGSEGV with MakeVertexInsideFace. Added check for an uniniti...
[modules/geom.git] / src / GEOMAlgo / GEOMAlgo_ShellSolid.cxx
index 47499114c95e0f96fbab454e4d7a354cf9289dd4..863621166325301f6c8411f5dadf0ba633bc32c4 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -27,8 +27,6 @@
 //
 #include <GEOMAlgo_ShellSolid.hxx>
 
-#include <Basics_OCCTVersion.hxx>
-
 #include <Standard_Failure.hxx>
 
 #include <gp_Pnt2d.hxx>
 
 #include <BOPTools_AlgoTools.hxx>
 
-#include <BOPCol_DataMapOfShapeListOfShape.hxx>
-#include <BOPCol_ListOfShape.hxx>
-#if OCC_VERSION_LARGE > 0x06070100
+#include <TopTools_DataMapOfShapeListOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
 #include <IntTools_Context.hxx>
-#else
-#include <BOPInt_Context.hxx>
-#endif
 #include <BOPDS_DS.hxx>
 #include <BOPAlgo_Builder.hxx>
 
 #include <GEOMAlgo_AlgoTools.hxx>
+
+#include <Basics_OCCTVersion.hxx>
+
 /////////////////////////////////////////////////////////////////////////
 //=======================================================================
 //class : GEOMAlgo_ShellSolidBuilder
@@ -76,7 +73,12 @@ class GEOMAlgo_ShellSolidBuilder : public BOPAlgo_Builder {
 
  protected:
   Standard_EXPORT
+#if OCC_VERSION_LARGE < 0x07070000
     virtual void PerformInternal(const BOPAlgo_PaveFiller& theFiller);
+#else
+    virtual void PerformInternal(const BOPAlgo_PaveFiller& theFiller,
+                                 const Message_ProgressRange& theRange);
+#endif
 };
 
 //=======================================================================
@@ -99,67 +101,93 @@ GEOMAlgo_ShellSolidBuilder::~GEOMAlgo_ShellSolidBuilder()
 //function : PerformInternal
 //purpose  : 
 //=======================================================================
+#if OCC_VERSION_LARGE < 0x07070000
 void GEOMAlgo_ShellSolidBuilder::PerformInternal(const BOPAlgo_PaveFiller& theFiller)
+#else
+void GEOMAlgo_ShellSolidBuilder::PerformInternal(const BOPAlgo_PaveFiller& theFiller,
+                                                 const Message_ProgressRange& theRange)
+#endif
 {
-  myErrorStatus=0;
-   //
   myPaveFiller=(BOPAlgo_PaveFiller*)&theFiller;
   myDS=myPaveFiller->PDS();
   myContext=myPaveFiller->Context();
   //
   // 1. CheckData
   CheckData();
-  if (myErrorStatus) {
+  if (HasErrors()) {
     return;
   }
   //
   // 2. Prepare
   Prepare();
-  if (myErrorStatus) {
+  if (HasErrors()) {
     return;
   }
+
+#if OCC_VERSION_LARGE >= 0x07070000
+  Message_ProgressScope aPS(theRange, "Building the result of Boolean operation", 100);
   //
+  BOPAlgo_PISteps aSteps (PIOperation_Last);
+  analyzeProgress (100, aSteps);
+#endif
+
   // 3. Fill Images
   // 3.1 Vertice
+#if OCC_VERSION_LARGE < 0x07070000
   FillImagesVertices();
-  if (myErrorStatus) {
+#else
+  FillImagesVertices(aPS.Next(aSteps.GetStep(PIOperation_TreatVertices)));
+#endif
+  if (HasErrors()) {
     return;
   }
   //
   BuildResult(TopAbs_VERTEX);
-  if (myErrorStatus) {
+  if (HasErrors()) {
     return;
   }
   // 3.2 Edges
+#if OCC_VERSION_LARGE < 0x07070000
   FillImagesEdges();
-  if (myErrorStatus) {
+#else
+  FillImagesEdges(aPS.Next(aSteps.GetStep(PIOperation_TreatEdges)));
+#endif
+  if (HasErrors()) {
     return;
   }
   //
   BuildResult(TopAbs_EDGE);
-  if (myErrorStatus) {
+  if (HasErrors()) {
     return;
   } 
   //
   // 3.3 Wires
+#if OCC_VERSION_LARGE < 0x07070000
   FillImagesContainers(TopAbs_WIRE);
-  if (myErrorStatus) {
+#else
+  FillImagesContainers(TopAbs_WIRE, aPS.Next(aSteps.GetStep(PIOperation_TreatWires)));
+#endif
+  if (HasErrors()) {
     return;
   }
   //
   BuildResult(TopAbs_WIRE);
-  if (myErrorStatus) {
+  if (HasErrors()) {
     return;
   }
   
   // 3.4 Faces
+#if OCC_VERSION_LARGE < 0x07070000
   FillImagesFaces();
-  if (myErrorStatus) {
+#else
+  FillImagesFaces(aPS.Next(aSteps.GetStep(PIOperation_TreatFaces)));
+#endif
+  if (HasErrors()) {
     return;
   }
   //
   BuildResult(TopAbs_FACE);
-  if (myErrorStatus) {
+  if (HasErrors()) {
     return;
   }
 }
@@ -186,7 +214,6 @@ GEOMAlgo_ShellSolid::~GEOMAlgo_ShellSolid()
 //=======================================================================
 void GEOMAlgo_ShellSolid::Perform()
 {
-  myErrorStatus=0;
   //
   try {
     Standard_Integer aNbArgs, iRank, iErr, iBeg, iEnd, i, aNbSp;
@@ -207,14 +234,14 @@ void GEOMAlgo_ShellSolid::Perform()
       myErrorStatus=10;
       return;
     }
-    if(myDSFiller->ErrorStatus()) {
+    if(myDSFiller->HasErrors()) {
       myErrorStatus=11;
       return;
     }
     //
     const BOPDS_DS& aDS=myDSFiller->DS();
     BOPDS_DS* pDS=(BOPDS_DS*)&aDS;
-    const BOPCol_ListOfShape& aLS=pDS->Arguments();
+    const TopTools_ListOfShape& aLS=pDS->Arguments();
     //
     aNbArgs=aLS.Extent();
     if (aNbArgs!=2) {
@@ -237,82 +264,78 @@ void GEOMAlgo_ShellSolid::Perform()
       return;
     }
     //
-#if OCC_VERSION_LARGE > 0x06070100
     Handle(IntTools_Context) aCtx=myDSFiller->Context();
-#else
-    Handle(BOPInt_Context) aCtx=myDSFiller->Context();
-#endif
     const BOPDS_IndexRange& aRange=pDS->Range(iRank);
     aRange.Indices(iBeg, iEnd);
     const TopoDS_Solid& aSolid=(!iRank) ? *((TopoDS_Solid*)&aTool) : *((TopoDS_Solid*)&aObj);
-    BRepClass3d_SolidClassifier& aSC=aCtx->SolidClassifier(aSolid);
+    //BRepClass3d_SolidClassifier& aSC=aCtx->SolidClassifier(aSolid);
     //
     //------------------------------ShellSolidBuilder
     GEOMAlgo_ShellSolidBuilder aSSB;
     //
     aSSB.PerformWithFiller(*myDSFiller);
-    iErr=aSSB.ErrorStatus();
+    iErr=aSSB.HasErrors();
     if (iErr) {
       myErrorStatus=15;
       return;
     }
     //
-    const BOPCol_DataMapOfShapeListOfShape& aImages=aSSB.Images();
+    const TopTools_DataMapOfShapeListOfShape& aImages=aSSB.Images();
     //
     //-------------------------------
     for (i=iBeg; i<=iEnd; ++i) {
       const TopoDS_Shape& aS=pDS->Shape(i);
       aType=aS.ShapeType();
       if (aType!=TopAbs_FACE) {
-       continue;
+        continue;
       }
       //
       aState=TopAbs_UNKNOWN;
       aF=*((TopoDS_Face*)&aS);
       //
       if (!aImages.IsBound(aS)) {
-       iErr=GEOMAlgo_AlgoTools::PntInFace(aF, aP, aP2D);
-       if (iErr) {
-         myErrorStatus=16;
-         return;
-       }
-       //
-       aState=BOPTools_AlgoTools::ComputeState(aP, aSolid, aTol, aCtx);
+        iErr=GEOMAlgo_AlgoTools::PntInFace(aF, aP, aP2D);
+        if (iErr) {
+          myErrorStatus=16;
+          return;
+        }
+        //
+        aState=BOPTools_AlgoTools::ComputeState(aP, aSolid, aTol, aCtx);
       }
       else {
-       const BOPCol_ListOfShape& aLSp=aImages.Find(aS);
-       aNbSp=aLSp.Extent();
-       if (aNbSp>0) {
-         continue;
-       }
-       //
-       if (aNbSp==1) {
-         aF=*((TopoDS_Face*)&aLSp.First());
-       }
-       //
-       iErr=GEOMAlgo_AlgoTools::PntInFace(aF, aP, aP2D);
-       if (iErr) {
-         myErrorStatus=16;
-         return;
-       }
-       //
-       aState=BOPTools_AlgoTools::ComputeState(aP, aSolid, aTol, aCtx);
+        const TopTools_ListOfShape& aLSp=aImages.Find(aS);
+        aNbSp=aLSp.Extent();
+        if (aNbSp>0) {
+          continue;
+        }
+        //
+        if (aNbSp==1) {
+          aF=*((TopoDS_Face*)&aLSp.First());
+        }
+        //
+        iErr=GEOMAlgo_AlgoTools::PntInFace(aF, aP, aP2D);
+        if (iErr) {
+          myErrorStatus=16;
+          return;
+        }
+        //
+        aState=BOPTools_AlgoTools::ComputeState(aP, aSolid, aTol, aCtx);
       }
       //----------
       if (aState==TopAbs_ON) {
-       myLSON.Append(aF);
+        myLSON.Append(aF);
       }
       else if (aState==TopAbs_OUT) {
-       myLSOUT.Append(aF);
+        myLSOUT.Append(aF);
       }
       else if (aState==TopAbs_IN) {
-       myLSIN.Append(aF);
-      }        
+        myLSIN.Append(aF);
+      } 
       //----------
     }//for (i=iBeg; i<=iEnd; ++i) {
     
   }// try
-  catch (Standard_Failure) {
+  catch (Standard_Failure&) {
     myErrorStatus=12;
   }
 }