0026515: Exponential memory usage problems with BOPDS_IndexedMapOfPaveBlock and NColl...
[occt.git] / src / BOPAlgo / BOPAlgo_PaveFiller_8.cxx
index 124490b..ae4ca2e 100644 (file)
@@ -6,8 +6,8 @@
 //
 // 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 version 2.1 as published
+// 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 <BOPAlgo_PaveFiller.ixx>
-
-#include <Precision.hxx>
-
-#include <NCollection_IncAllocator.hxx>
-
-#include <gp_Pnt2d.hxx>
-#include <gp_Lin2d.hxx>
+#include <BOPAlgo_PaveFiller.hxx>
+#include <BOPAlgo_SectionAttribute.hxx>
+#include <BOPCol_ListOfInteger.hxx>
+#include <BOPDS_Curve.hxx>
+#include <BOPDS_DS.hxx>
+#include <BOPDS_FaceInfo.hxx>
+#include <BOPDS_MapOfPaveBlock.hxx>
+#include <BOPDS_Pave.hxx>
+#include <BOPDS_PaveBlock.hxx>
+#include <BOPDS_ShapeInfo.hxx>
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
 #include <ElCLib.hxx>
-
-#include <IntRes2d_IntersectionPoint.hxx>
-
 #include <Geom2d_Curve.hxx>
-#include <Geom2d_TrimmedCurve.hxx>
 #include <Geom2d_Line.hxx>
+#include <Geom2d_TrimmedCurve.hxx>
 #include <Geom2dAdaptor_Curve.hxx>
 #include <Geom2dInt_GInter.hxx>
-
+#include <gp_Lin2d.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Pnt2d.hxx>
+#include <IntRes2d_IntersectionPoint.hxx>
+#include <IntTools_Context.hxx>
+#include <Precision.hxx>
 #include <TopoDS_Edge.hxx>
 #include <TopoDS_Face.hxx>
 #include <TopoDS_Vertex.hxx>
 
-#include <BRep_Tool.hxx>
-#include <BRep_Builder.hxx>
-
-#include <BOPCol_ListOfInteger.hxx>
-
-#include <BOPDS_ShapeInfo.hxx>
-#include <BOPDS_DS.hxx>
-#include <BOPDS_FaceInfo.hxx>
-#include <BOPDS_MapOfPaveBlock.hxx>
-#include <BOPDS_PaveBlock.hxx>
-#include <BOPDS_Pave.hxx>
-
 static
   void MakeSplitEdge1 (const TopoDS_Edge&   aE,
                        const TopoDS_Face&   aF,
@@ -62,10 +56,10 @@ static
 //function : ProcessDE
 //purpose  : 
 //=======================================================================
-  void BOPAlgo_PaveFiller::ProcessDE()
+void BOPAlgo_PaveFiller::ProcessDE()
 {
   Standard_Integer nF, aNb, nE, nV, nVSD, aNbPB;
-  Handle(NCollection_IncAllocator) aAllocator;
+  Handle(NCollection_BaseAllocator) aAllocator;
   Handle(BOPDS_PaveBlock) aPBD;
   BOPCol_ListIteratorOfListOfInteger aItLI;
   //
@@ -74,7 +68,8 @@ static
   // 1. Find degnerated edges
   //-----------------------------------------------------scope f
   //
-  aAllocator=new NCollection_IncAllocator();
+  aAllocator=
+    NCollection_BaseAllocator::CommonBaseAllocator();
   BOPDS_ListOfPaveBlock aLPBOut(aAllocator);
   //
   aNb=myDS->NbSourceShapes();
@@ -142,15 +137,14 @@ static
                                           const Standard_Integer nF,
                                           BOPDS_ListOfPaveBlock& aLPBOut)
 {
-  Standard_Integer nV1, nV2;
-  BOPDS_MapIteratorOfMapOfPaveBlock aItMPB;
+  Standard_Integer i, aNbPBOn, aNbPBIn, aNbPBSc, nV1, nV2;
   //
   const BOPDS_FaceInfo& aFI=myDS->ChangeFaceInfo(nF);
   // In
   const BOPDS_IndexedMapOfPaveBlock& aMPBIn=aFI.PaveBlocksIn();
-  aItMPB.Initialize(aMPBIn);
-  for(; aItMPB.More(); aItMPB.Next()) {
-    const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
+  aNbPBIn = aMPBIn.Extent();
+  for (i = 1; i <= aNbPBIn; ++i) {
+    const Handle(BOPDS_PaveBlock)& aPB = aMPBIn(i);
     aPB->Indices(nV1, nV2);
     if (nV==nV1 || nV==nV2) {
       aLPBOut.Append(aPB);
@@ -158,9 +152,9 @@ static
   }
   // On
   const BOPDS_IndexedMapOfPaveBlock& aMPBOn=aFI.PaveBlocksOn();
-  aItMPB.Initialize(aMPBOn);
-  for(; aItMPB.More(); aItMPB.Next()) {
-    const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
+  aNbPBOn = aMPBOn.Extent();
+  for (i = 1; i <= aNbPBOn; ++i) {
+    const Handle(BOPDS_PaveBlock)& aPB = aMPBOn(i);
     aPB->Indices(nV1, nV2);
     if (nV==nV1 || nV==nV2) {
       aLPBOut.Append(aPB);
@@ -168,9 +162,9 @@ static
   }
   // Sections
   const BOPDS_IndexedMapOfPaveBlock& aMPBSc=aFI.PaveBlocksSc();
-  aItMPB.Initialize(aMPBSc);
-  for(; aItMPB.More(); aItMPB.Next()) {
-    const Handle(BOPDS_PaveBlock)& aPB=aItMPB.Value();
+  aNbPBSc = aMPBSc.Extent();
+  for (i = 1; i <= aNbPBSc; ++i) {
+    const Handle(BOPDS_PaveBlock)& aPB = aMPBSc(i);
     aPB->Indices(nV1, nV2);
     if (nV==nV1 || nV==nV2) {
       aLPBOut.Append(aPB);
@@ -243,8 +237,8 @@ static
                                      const BOPDS_ListOfPaveBlock& aLPBOut,
                                      const Handle(BOPDS_PaveBlock)& aPBD)
 {
-  Standard_Boolean bXDir, bIsDone, bReject;
-  Standard_Integer nE, aNbPoints, j;
+  Standard_Boolean bXDir, bIsDone;
+  Standard_Integer nE, aNbPoints, j, anInd;
   Standard_Real aTD1, aTD2, aT1, aT2, aTolInter, aX, aDT;
   Standard_Real aTolCmp;
   gp_Pnt2d aP2d1, aP2d2, aP2D;
@@ -329,8 +323,7 @@ static
         continue; 
       }
       //
-      bReject=Standard_False;
-      if (aPBD->ContainsParameter(aX, aDT)) {
+      if (aPBD->ContainsParameter(aX, aDT, anInd)) {
         continue;
       }
       aPave.SetParameter(aX);