0031035: Coding - uninitialized class fields reported by Visual Studio Code Analysis
[occt.git] / src / BRepFeat / BRepFeat_Builder.cxx
index 280d8ca..4a6635e 100644 (file)
@@ -15,7 +15,6 @@
 
 
 #include <BOPAlgo_BuilderFace.hxx>
-#include <BOPCol_DataMapOfShapeListOfShape.hxx>
 #include <BOPDS_DS.hxx>
 #include <BOPDS_FaceInfo.hxx>
 #include <BOPDS_ListOfPave.hxx>
@@ -23,7 +22,6 @@
 #include <BOPDS_MapOfPaveBlock.hxx>
 #include <BOPDS_Pave.hxx>
 #include <BOPDS_ShapeInfo.hxx>
-#include <BOPTools.hxx>
 #include <BOPTools_AlgoTools.hxx>
 #include <BOPTools_AlgoTools2D.hxx>
 #include <BOPTools_AlgoTools3D.hxx>
 #include <Geom_Curve.hxx>
 #include <IntTools_Tools.hxx>
 #include <Precision.hxx>
+#include <TopExp.hxx>
 #include <TopExp_Explorer.hxx>
 #include <TopoDS_Edge.hxx>
 #include <TopoDS_Face.hxx>
 #include <TopoDS_Shape.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_DataMapOfShapeListOfShape.hxx>
 
 //=======================================================================
 //function : 
   TopoDS_Shape aF, aFOr;
   TopExp_Explorer aExp;
   //
-  BOPTools::MapShapes(thePart, myShapes);
+  TopExp::MapShapes(thePart, myShapes);
 }
 
 //=======================================================================
 //=======================================================================
   void BRepFeat_Builder::Prepare()
 {
-  myErrorStatus=0;
+  GetReport()->Clear();
   //
   BRep_Builder aBB;
   TopoDS_Compound aC;
   aBB.MakeCompound(aC);
   myShape=aC;
   //
-  myFlagHistory=Standard_True;
-  //
   FillRemoved();
 }
 
     return;
   }
   //
-  BOPCol_ListIteratorOfListOfShape aItIm;
+  TopTools_ListIteratorOfListOfShape aItIm;
   //
-  BOPCol_ListOfShape& aLS = myImages.ChangeFind(aArgs1);
+  TopTools_ListOfShape& aLS = myImages.ChangeFind(aArgs1);
   aItIm.Initialize(aLS);
   for (; aItIm.More(); aItIm.Next()) {
     const TopoDS_Shape& aS = aItIm.Value();
     RebuildFaces();
     //
     FillImagesContainers(TopAbs_SHELL);
-    if (myErrorStatus) {
+    if (HasErrors()) {
       return;
     }
     //
     FillImagesSolids();
-    if (myErrorStatus) {
+    if (HasErrors()) {
       return;
     }
     //
     CheckSolidImages();
     //
     BuildResult(TopAbs_SOLID);
-    if (myErrorStatus) {
+    if (HasErrors()) {
       return;
     }
     // 
     FillImagesCompounds();
-    if (myErrorStatus) {
+    if (HasErrors()) {
       return;
     }
     //
     BuildResult(TopAbs_COMPOUND);
-    if (myErrorStatus) {
+    if (HasErrors()) {
       return;
     }
   }
   TopoDS_Edge aSp;
   TopoDS_Shape aSx;
   TopExp_Explorer aExp, aExpE;
-  BOPCol_MapOfShape aME, aMESplit;
-  BOPCol_ListIteratorOfListOfShape aItIm;
+  TopTools_MapOfShape aME, aMESplit;
+  TopTools_ListIteratorOfListOfShape aItIm;
   BOPDS_MapIteratorOfMapOfPaveBlock aItMPB;
-  BOPCol_MapIteratorOfMapOfShape aItM;
+  TopTools_MapIteratorOfMapOfShape aItM;
   BOPTools_MapOfSet aMST;
-  BOPCol_ListOfShape aLE;
+  TopTools_ListOfShape aLE;
   //
   aItM.Initialize(myShapes);
   for (; aItM.More(); aItM.Next()) {
       const TopoDS_Shape& aS = aSI.Shape();
       //
       if (myImages.IsBound(aS)) {
-        BOPCol_ListOfShape& aLIm = myImages.ChangeFind(aS);
+        TopTools_ListOfShape& aLIm = myImages.ChangeFind(aS);
         aItIm.Initialize(aLIm);
         for (; aItIm.More(); ) {
           const TopoDS_Shape& aSIm = aItIm.Value();
       bIsDegenerated=BRep_Tool::Degenerated(aE);
       bIsClosed=BRep_Tool::IsClosed(aE, aF);
       if (myImages.IsBound(aE)) {
-        BOPCol_ListOfShape& aLEIm = myImages.ChangeFind(aE);
+        TopTools_ListOfShape& aLEIm = myImages.ChangeFind(aE);
         //
         bRem = Standard_False;
         bIm = Standard_False;
         aME.Clear();
-        BOPCol_ListOfShape aLEImNew;
+        TopTools_ListOfShape aLEImNew;
         //
         aItIm.Initialize(aLEIm);
         for (; aItIm.More(); aItIm.Next()) {
     
     aBF.Perform();
 
-    BOPCol_ListOfShape& aLFIm = myImages.ChangeFind(aF);
+    TopTools_ListOfShape& aLFIm = myImages.ChangeFind(aF);
     aLFIm.Clear();
 
-    const BOPCol_ListOfShape& aLFR=aBF.Areas();
+    const TopTools_ListOfShape& aLFR=aBF.Areas();
     aItIm.Initialize(aLFR);
     for (; aItIm.More(); aItIm.Next()) {
       TopoDS_Shape& aFR=aItIm.ChangeValue();
       aSx=aSTx.Shape();
       aSx.Orientation(anOriF);
       aLFIm.Append(aSx);
-      myOrigins.Bind(aSx, aF);
+      //
+      TopTools_ListOfShape* pLOr = myOrigins.ChangeSeek(aSx);
+      if (!pLOr) {
+        pLOr = myOrigins.Bound(aSx, TopTools_ListOfShape());
+      }
+      pLOr->Append(aF);
       //
       if (bFlagSD) {
         myShapesSD.Bind(aFR, aSx);
       }
     }
     //
-    mySplits.Bind(aF, aLFIm); 
     if (aLFIm.Extent() == 0) {
-      mySplits.UnBind(aF);
       myImages.UnBind(aF);
     }
   }
 //=======================================================================
   void BRepFeat_Builder::RebuildEdge(const TopoDS_Shape& theE,
                                      const TopoDS_Face& theF,
-                                     const BOPCol_MapOfShape& aME,
-                                     BOPCol_ListOfShape& aLIm)
+                                     const TopTools_MapOfShape& aME,
+                                     TopTools_ListOfShape& aLIm)
 {
   Standard_Integer nE, nSp, nV1, nV2, nE1, nV, nVx, nVSD;
   Standard_Integer nV11, nV21;
   BOPDS_ShapeInfo aSI;
   TopoDS_Vertex aV1, aV2;
   Handle(BOPDS_PaveBlock) aPBNew;
-  BOPCol_MapOfInteger aMI, aMAdd, aMV, aMVOr;
+  TColStd_MapOfInteger aMI, aMAdd, aMV, aMVOr;
   BOPDS_ListIteratorOfListOfPaveBlock aItPB;
-  BOPCol_ListIteratorOfListOfShape aIt;
-  BOPCol_ListIteratorOfListOfInteger aItLI;
-  BOPCol_MapIteratorOfMapOfShape aItM;
+  TopTools_ListIteratorOfListOfShape aIt;
+  TColStd_ListIteratorOfListOfInteger aItLI;
+  TopTools_MapIteratorOfMapOfShape aItM;
   BOPDS_MapOfPaveBlock aMPB;
   BOPDS_MapIteratorOfMapOfPaveBlock aItMPB;
   //
   //1. collect origin vertices to aMV map.
   nE = myDS->Index(theE);
   const BOPDS_ShapeInfo& aSIE = myDS->ShapeInfo(nE);
-  const BOPCol_ListOfInteger& aLS = aSIE.SubShapes();
+  const TColStd_ListOfInteger& aLS = aSIE.SubShapes();
   aItLI.Initialize(aLS);
   for(; aItLI.More(); aItLI.Next()) {
     nV = aItLI.Value();
     aV2=(*(TopoDS_Vertex *)(&myDS->Shape(nV2)));
     aV2.Orientation(TopAbs_REVERSED); 
     //
-    BOPTools_AlgoTools::MakeSplitEdge(aE, aV1, aT1, aV2, aT2, aSp);  
-    BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(aSp, theF);
+    BOPTools_AlgoTools::MakeSplitEdge(aE, aV1, aT1, aV2, aT2, aSp);
+    BOPTools_AlgoTools2D::BuildPCurveForEdgeOnFace(aSp, theF, myContext);
     //
     aSI.SetShape(aSp);
     //
   void BRepFeat_Builder::CheckSolidImages()
 {
   BOPTools_MapOfSet aMST;
-  BOPCol_ListOfShape aLSImNew;
-  BOPCol_MapOfShape aMS;
-  BOPCol_ListIteratorOfListOfShape aIt;
+  TopTools_ListOfShape aLSImNew;
+  TopTools_MapOfShape aMS;
+  TopTools_ListIteratorOfListOfShape aIt;
   TopExp_Explorer aExp, aExpF;
   Standard_Boolean bFlagSD;
   // 
   const TopoDS_Shape& aArgs0=myArguments.First();
   const TopoDS_Shape& aArgs1=myTools.First();
   //
-  const BOPCol_ListOfShape& aLSIm = myImages.Find(aArgs1);
+  const TopTools_ListOfShape& aLSIm = myImages.Find(aArgs1);
   aIt.Initialize(aLSIm);
   for(;aIt.More();aIt.Next()) {
     const TopoDS_Shape& aSolIm = aIt.Value();
   for(; aExp.More(); aExp.Next()) {
     const TopoDS_Shape& aSolid = aExp.Current();
     if (myImages.IsBound(aSolid)) {
-      BOPCol_ListOfShape& aLSImSol = myImages.ChangeFind(aSolid);
+      TopTools_ListOfShape& aLSImSol = myImages.ChangeFind(aSolid);
       aIt.Initialize(aLSImSol);
       for(;aIt.More();aIt.Next()) {
         const TopoDS_Shape& aSolIm = aIt.Value();
 //purpose  : 
 //=======================================================================
   void BRepFeat_Builder::FillRemoved(const TopoDS_Shape& S,  
-                                     BOPCol_MapOfShape& M)
+                                     TopTools_MapOfShape& M)
 {
   if (myShapes.Contains(S)) {
     return;
 //function : FillIn3DParts
 //purpose  : 
 //=======================================================================
-  void BRepFeat_Builder::FillIn3DParts(BOPCol_DataMapOfShapeListOfShape& theInParts,
-                                       BOPCol_DataMapOfShapeShape& theDraftSolids,
-                                       const Handle(NCollection_BaseAllocator)& theAllocator)
+  void BRepFeat_Builder::FillIn3DParts(TopTools_DataMapOfShapeShape& theDraftSolids)
 {
-  myErrorStatus=0;
-  //
-  Standard_Boolean bIsIN, bHasImage;
-  Standard_Integer aNbS, i, j, aNbFP, aNbFPx, aNbFIN, aNbLIF, aNbEFP;
-  TopAbs_ShapeEnum aType;  
-  TopAbs_State aState;
-  TopoDS_Iterator aIt, aItF;
-  BRep_Builder aBB;
-  TopoDS_Solid aSolidSp; 
-  TopoDS_Face aFP;
-  BOPCol_ListIteratorOfListOfShape aItS, aItFP, aItEx; 
-  BOPCol_MapIteratorOfMapOfShape aItMS, aItMS1;
-  //
-  BOPCol_ListOfShape aLIF(theAllocator);
-  BOPCol_MapOfShape aMFDone(100, theAllocator);
-  BOPCol_MapOfShape aMSolids(100, theAllocator);
-  BOPCol_MapOfShape aMFaces(100, theAllocator);
-  BOPCol_MapOfShape aMFIN(100, theAllocator);
-  BOPCol_IndexedMapOfShape aMS(100, theAllocator);
-  BOPCol_IndexedDataMapOfShapeListOfShape aMEF(100, theAllocator);
-  //
-  theDraftSolids.Clear();
-  //
-  aNbS=myDS->NbSourceShapes();
-  for (i=0; i<aNbS; ++i) {
-    const BOPDS_ShapeInfo& aSI=myDS->ShapeInfo(i);
-    const TopoDS_Shape& aS=aSI.Shape();
-    //
-    aType=aSI.ShapeType();
-    switch(aType) {
-      case TopAbs_SOLID: {
-        aMSolids.Add(aS);
-        break;
-      }
-      //
-      case TopAbs_FACE: {
-        // all faces (originals or images)
-        if (myImages.IsBound(aS)) {
-          const BOPCol_ListOfShape& aLS=myImages.Find(aS);
-          aItS.Initialize(aLS);
-          for (; aItS.More(); aItS.Next()) {
-            const TopoDS_Shape& aFx=aItS.Value();
-            if (!myRemoved.Contains(aFx)) {
-              aMFaces.Add(aFx);
-            }
-          }
-        }
-        else {
-          if (!myRemoved.Contains(aS)) {
-            aMFaces.Add(aS);
-          }
-        }
-        break;
-      }
-      //
-      default:
-        break;
+  GetReport()->Clear();
+
+  BOPAlgo_Builder::FillIn3DParts(theDraftSolids);
+
+  // Clear the IN parts of the solids from the removed faces
+  TopTools_DataMapOfShapeListOfShape::Iterator itM(myInParts);
+  for (; itM.More(); itM.Next())
+  {
+    TopTools_ListOfShape& aList = itM.ChangeValue();
+    TopTools_ListOfShape::Iterator itL(aList);
+    for (; itL.More();)
+    {
+      if (myRemoved.Contains(itL.Value()))
+        aList.Remove(itL);
+      else
+        itL.Next();
     }
   }
-  //
-  aItMS.Initialize(aMSolids);
-  for (; aItMS.More(); aItMS.Next()) {
-    const TopoDS_Solid& aSolid=(*(TopoDS_Solid*)(&aItMS.Value()));
-    //
-    aMFDone.Clear();
-    aMFIN.Clear();
-    aMEF.Clear();
-    //
-    aBB.MakeSolid(aSolidSp);
-    // 
-    // Draft solid and its pure internal faces => aSolidSp, aLIF
-    aLIF.Clear();
-    BuildDraftSolid(aSolid, aSolidSp, aLIF);
-    aNbLIF=aLIF.Extent();
-    //
-    // 1 all faces/edges from aSolid [ aMS ]
-    bHasImage=Standard_False;
-    aMS.Clear();
-    aIt.Initialize(aSolid);
-    for (; aIt.More(); aIt.Next()) {
-      const TopoDS_Shape& aShell=aIt.Value();
-      //
-      if (myImages.IsBound(aShell)) {
-        bHasImage=Standard_True;
-        //
-        const BOPCol_ListOfShape& aLS=myImages.Find(aShell);
-        aItS.Initialize(aLS);
-        for (; aItS.More(); aItS.Next()) {
-          const TopoDS_Shape& aSx=aItS.Value();
-          aMS.Add(aSx);
-          BOPTools::MapShapes(aSx, TopAbs_FACE, aMS);
-          BOPTools::MapShapes(aSx, TopAbs_EDGE, aMS);
-          BOPTools::MapShapesAndAncestors(aSx, TopAbs_EDGE, TopAbs_FACE, aMEF);
-        }
-      }
-      else {
-        //aMS.Add(aShell);
-        BOPTools::MapShapes(aShell, TopAbs_FACE, aMS);
-        BOPTools::MapShapesAndAncestors(aShell, TopAbs_EDGE, TopAbs_FACE, aMEF);
-      }
-    }
-    //
-    // 2 all faces that are not from aSolid [ aLFP1 ]
-    BOPCol_IndexedDataMapOfShapeListOfShape aMEFP(100, theAllocator);
-    BOPCol_ListOfShape aLFP1(theAllocator);
-    BOPCol_ListOfShape aLFP(theAllocator);
-    BOPCol_ListOfShape aLCBF(theAllocator);
-    BOPCol_ListOfShape aLFIN(theAllocator);
-    BOPCol_ListOfShape aLEx(theAllocator);
-    //
-    // for all non-solid faces build EF map [ aMEFP ]
-    aItMS1.Initialize(aMFaces);
-    for (; aItMS1.More(); aItMS1.Next()) {
-      const TopoDS_Shape& aFace=aItMS1.Value();
-      if (!aMS.Contains(aFace)) {
-        BOPTools::MapShapesAndAncestors(aFace, TopAbs_EDGE, TopAbs_FACE, aMEFP);
-      }
-    }
-    //
-    // among all faces from aMEFP select these that have same edges
-    // with the solid (i.e aMEF). These faces will be treated first 
-    // to prevent the usage of 3D classifier.
-    // The full list of faces to process is aLFP1. 
-    aNbEFP=aMEFP.Extent();
-    for (j=1; j<=aNbEFP; ++j) {
-      const TopoDS_Shape& aE=aMEFP.FindKey(j);
-      //
-      if (aMEF.Contains(aE)) { // !!
-        const BOPCol_ListOfShape& aLF=aMEFP(j);
-        aItFP.Initialize(aLF);
-        for (; aItFP.More(); aItFP.Next()) {
-          const TopoDS_Shape& aF=aItFP.Value();
-          if (aMFDone.Add(aF)) {
-            aLFP1.Append(aF);
-          }
-        }
-      }
-      else {
-        aLEx.Append(aE);
-      }
-    }
-    //
-    aItEx.Initialize(aLEx);
-    for (; aItEx.More(); aItEx.Next()) {
-      const TopoDS_Shape& aE=aItEx.Value();
-      const BOPCol_ListOfShape& aLF=aMEFP.FindFromKey(aE);
-      aItFP.Initialize(aLF);
-      for (; aItFP.More(); aItFP.Next()) {
-        const TopoDS_Shape& aF=aItFP.Value();
-        if (aMFDone.Add(aF)) {
-          //aLFP2.Append(aF);
-          aLFP1.Append(aF);
-        }
-      }
-    }
-    //
-    //==========
-    //
-    // 3 Process faces aLFP1
-    aMFDone.Clear();
-    aNbFP=aLFP1.Extent();
-    aItFP.Initialize(aLFP1);
-    for (; aItFP.More(); aItFP.Next()) {
-      const TopoDS_Shape& aSP=aItFP.Value();
-      if (!aMFDone.Add(aSP)) {
-        continue;
-      }
-      
-      //
-      // first face to process
-      aFP=(*(TopoDS_Face*)(&aSP));
-      bIsIN=BOPTools_AlgoTools::IsInternalFace(aFP, aSolidSp, aMEF, 1.e-14, myContext);
-      aState=(bIsIN) ? TopAbs_IN : TopAbs_OUT;
-      //
-      // collect faces to process [ aFP is the first ]
-      aLFP.Clear();
-      aLFP.Append(aFP);
-      aItS.Initialize(aLFP1);
-      for (; aItS.More(); aItS.Next()) {
-        const TopoDS_Shape& aSk=aItS.Value();
-        if (!aMFDone.Contains(aSk)) {
-          aLFP.Append(aSk);
-        }
-      }
-      //
-      // Connexity Block that spreads from aFP the Bound 
-      // or till the end of the block itself
-      aLCBF.Clear();
-      BOPTools_AlgoTools::MakeConnexityBlock(aLFP, aMS, aLCBF, theAllocator);
-      //
-      // fill states for the Connexity Block 
-      aItS.Initialize(aLCBF);
-      for (; aItS.More(); aItS.Next()) {
-        const TopoDS_Shape& aSx=aItS.Value();
-        aMFDone.Add(aSx);
-        if (aState==TopAbs_IN) {
-          aMFIN.Add(aSx);
-        }
-      }
-      //
-      aNbFPx=aMFDone.Extent();
-      if (aNbFPx==aNbFP) {
-        break;
-      }
-    }//for (; aItFP.More(); aItFP.Next())
-    //
-    // faces Inside aSolid
-    aLFIN.Clear();
-    aNbFIN=aMFIN.Extent();
-    if (aNbFIN || aNbLIF) {
-      aItMS1.Initialize(aMFIN);
-      for (; aItMS1.More(); aItMS1.Next()) {
-        const TopoDS_Shape& aFIn=aItMS1.Value();
-        aLFIN.Append(aFIn);
-      }
-      //
-      aItS.Initialize(aLIF);
-      for (; aItS.More(); aItS.Next()) {
-        const TopoDS_Shape& aFIN=aItS.Value();
-        aLFIN.Append(aFIN);
-      }
-      //
-      theInParts.Bind(aSolid, aLFIN);
-    }
-    if (aNbFIN || bHasImage) {
-      theDraftSolids.Bind(aSolid, aSolidSp);
-    }
-  }// for (; aItMS.More(); aItMS.Next()) {
 }