Salome HOME
[bos #37951][EDF 25230] SIGSEGV with MakeVertexInsideFace. Added check for an uniniti...
[modules/geom.git] / src / GEOMAlgo / GEOMAlgo_ShellSolid.cxx
index cb7f85322304c906e6fe03256d9de7f8d76c67db..863621166325301f6c8411f5dadf0ba633bc32c4 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  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,109 +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
 {
-#if OCC_VERSION_LARGE <= 0x07010000
-  myErrorStatus=0;
-#endif 
-   //
   myPaveFiller=(BOPAlgo_PaveFiller*)&theFiller;
   myDS=myPaveFiller->PDS();
   myContext=myPaveFiller->Context();
   //
   // 1. CheckData
   CheckData();
-#if OCC_VERSION_LARGE > 0x07010001
   if (HasErrors()) {
-#else
-  if (myErrorStatus) {
-#endif
     return;
   }
   //
   // 2. Prepare
   Prepare();
-#if OCC_VERSION_LARGE > 0x07010001
   if (HasErrors()) {
-#else
-  if (myErrorStatus) {
-#endif
     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 OCC_VERSION_LARGE > 0x07010001
-  if (HasErrors()) {
 #else
-  if (myErrorStatus) {
+  FillImagesVertices(aPS.Next(aSteps.GetStep(PIOperation_TreatVertices)));
 #endif
+  if (HasErrors()) {
     return;
   }
   //
   BuildResult(TopAbs_VERTEX);
-#if OCC_VERSION_LARGE > 0x07010001
   if (HasErrors()) {
-#else
-  if (myErrorStatus) {
-#endif
     return;
   }
   // 3.2 Edges
+#if OCC_VERSION_LARGE < 0x07070000
   FillImagesEdges();
-#if OCC_VERSION_LARGE > 0x07010001
-  if (HasErrors()) {
 #else
-  if (myErrorStatus) {
+  FillImagesEdges(aPS.Next(aSteps.GetStep(PIOperation_TreatEdges)));
 #endif
+  if (HasErrors()) {
     return;
   }
   //
   BuildResult(TopAbs_EDGE);
-#if OCC_VERSION_LARGE > 0x07010001
   if (HasErrors()) {
-#else
-  if (myErrorStatus) {
-#endif
     return;
   } 
   //
   // 3.3 Wires
+#if OCC_VERSION_LARGE < 0x07070000
   FillImagesContainers(TopAbs_WIRE);
-#if OCC_VERSION_LARGE > 0x07010001
-  if (HasErrors()) {
 #else
-  if (myErrorStatus) {
+  FillImagesContainers(TopAbs_WIRE, aPS.Next(aSteps.GetStep(PIOperation_TreatWires)));
 #endif
+  if (HasErrors()) {
     return;
   }
   //
   BuildResult(TopAbs_WIRE);
-#if OCC_VERSION_LARGE > 0x07010001
   if (HasErrors()) {
-#else
-  if (myErrorStatus) {
-#endif
     return;
   }
   
   // 3.4 Faces
+#if OCC_VERSION_LARGE < 0x07070000
   FillImagesFaces();
-#if OCC_VERSION_LARGE > 0x07010001
-  if (HasErrors()) {
 #else
-  if (myErrorStatus) {
+  FillImagesFaces(aPS.Next(aSteps.GetStep(PIOperation_TreatFaces)));
 #endif
+  if (HasErrors()) {
     return;
   }
   //
   BuildResult(TopAbs_FACE);
-#if OCC_VERSION_LARGE > 0x07010001
   if (HasErrors()) {
-#else
-  if (myErrorStatus) {
-#endif
     return;
   }
 }
@@ -228,9 +214,6 @@ GEOMAlgo_ShellSolid::~GEOMAlgo_ShellSolid()
 //=======================================================================
 void GEOMAlgo_ShellSolid::Perform()
 {
-#if OCC_VERSION_LARGE <= 0x07010000
-  myErrorStatus=0;
-#endif
   //
   try {
     Standard_Integer aNbArgs, iRank, iErr, iBeg, iEnd, i, aNbSp;
@@ -251,18 +234,14 @@ void GEOMAlgo_ShellSolid::Perform()
       myErrorStatus=10;
       return;
     }
-#if OCC_VERSION_LARGE > 0x07010001
     if(myDSFiller->HasErrors()) {
-#else
-    if(myDSFiller->ErrorStatus()) {
-#endif
       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) {
@@ -285,11 +264,7 @@ 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);
@@ -299,17 +274,13 @@ void GEOMAlgo_ShellSolid::Perform()
     GEOMAlgo_ShellSolidBuilder aSSB;
     //
     aSSB.PerformWithFiller(*myDSFiller);
-#if OCC_VERSION_LARGE > 0x07010001
     iErr=aSSB.HasErrors();
-#else
-    iErr=aSSB.ErrorStatus();
-#endif
     if (iErr) {
       myErrorStatus=15;
       return;
     }
     //
-    const BOPCol_DataMapOfShapeListOfShape& aImages=aSSB.Images();
+    const TopTools_DataMapOfShapeListOfShape& aImages=aSSB.Images();
     //
     //-------------------------------
     for (i=iBeg; i<=iEnd; ++i) {
@@ -332,7 +303,7 @@ void GEOMAlgo_ShellSolid::Perform()
         aState=BOPTools_AlgoTools::ComputeState(aP, aSolid, aTol, aCtx);
       }
       else {
-        const BOPCol_ListOfShape& aLSp=aImages.Find(aS);
+        const TopTools_ListOfShape& aLSp=aImages.Find(aS);
         aNbSp=aLSp.Extent();
         if (aNbSp>0) {
           continue;
@@ -364,7 +335,7 @@ void GEOMAlgo_ShellSolid::Perform()
     }//for (i=iBeg; i<=iEnd; ++i) {
     
   }// try
-  catch (Standard_Failure) {
+  catch (Standard_Failure&) {
     myErrorStatus=12;
   }
 }