From 488e5b9da02059d79a9cdfe4130940c124d6e882 Mon Sep 17 00:00:00 2001 From: isn Date: Thu, 17 Sep 2015 13:26:46 +0300 Subject: [PATCH] 0026515: Exponential memory usage problems with BOPDS_IndexedMapOfPaveBlock and NCollection_IncAllocator Correcting the usage of NCollection_IncAllocator Conflicts: src/BOPAlgo/BOPAlgo_BOP.cxx src/BOPAlgo/BOPAlgo_Builder.cxx src/BOPAlgo/BOPAlgo_BuilderSolid.cxx src/BOPAlgo/BOPAlgo_Builder_2.cxx src/BOPAlgo/BOPAlgo_MakerVolume.cxx src/BOPAlgo/BOPAlgo_PaveFiller.cdl src/BOPAlgo/BOPAlgo_PaveFiller_1.cxx src/BOPAlgo/BOPAlgo_PaveFiller_10.cxx src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx src/BOPAlgo/BOPAlgo_PaveFiller_4.cxx src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx src/BOPAlgo/BOPAlgo_PaveFiller_7.cxx src/BOPAlgo/BOPAlgo_PaveFiller_8.cxx src/BOPAlgo/BOPAlgo_Section.cxx src/BOPDS/BOPDS_DS.cxx src/BOPDS/BOPDS_Iterator.cxx src/BOPDS/BOPDS_IteratorSI.cxx src/BOPDS/BOPDS_SubIterator.cxx src/BOPTest/BOPTest_BOPCommands.cxx src/BOPTest/BOPTest_PartitionCommands.cxx src/IntTools/IntTools_Context.cxx additional corrections Adaptation of test case bugs fclasses bug7287_1 (limit for detection of memory leak reduced due to leak reduction) Adjusting test-case bugs fclasses bug7287_1 --- src/BOPAlgo/BOPAlgo_BOP.cxx | 4 +- src/BOPAlgo/BOPAlgo_Builder.cxx | 4 +- src/BOPAlgo/BOPAlgo_BuilderSolid.cxx | 4 +- src/BOPAlgo/BOPAlgo_Builder_2.cxx | 19 +- src/BOPAlgo/BOPAlgo_Builder_3.cxx | 29 +- src/BOPAlgo/BOPAlgo_MakerVolume.cxx | 5 +- src/BOPAlgo/BOPAlgo_PaveFiller.hxx | 2 + src/BOPAlgo/BOPAlgo_PaveFiller_1.cxx | 9 +- src/BOPAlgo/BOPAlgo_PaveFiller_10.cxx | 391 +++++++++++++++++----- src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx | 4 +- src/BOPAlgo/BOPAlgo_PaveFiller_4.cxx | 8 +- src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx | 7 +- src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx | 7 +- src/BOPAlgo/BOPAlgo_PaveFiller_7.cxx | 1 - src/BOPAlgo/BOPAlgo_PaveFiller_8.cxx | 9 +- src/BOPAlgo/BOPAlgo_Section.cxx | 1 - src/BOPDS/BOPDS_DS.cxx | 7 +- src/BOPDS/BOPDS_Iterator.cxx | 6 +- src/BOPDS/BOPDS_IteratorSI.cxx | 7 +- src/BOPDS/BOPDS_SubIterator.cxx | 11 +- src/BOPTest/BOPTest_BOPCommands.cxx | 7 +- src/BOPTest/BOPTest_Objects.cxx | 7 +- src/BOPTest/BOPTest_PartitionCommands.cxx | 1 - src/IntTools/IntTools_Context.cxx | 3 +- tests/bugs/fclasses/bug7287_1 | 7 +- 25 files changed, 379 insertions(+), 181 deletions(-) diff --git a/src/BOPAlgo/BOPAlgo_BOP.cxx b/src/BOPAlgo/BOPAlgo_BOP.cxx index 2d0eb30436..0492ef451d 100644 --- a/src/BOPAlgo/BOPAlgo_BOP.cxx +++ b/src/BOPAlgo/BOPAlgo_BOP.cxx @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -340,7 +339,8 @@ void BOPAlgo_BOP::Perform() } } // - aAllocator=new NCollection_IncAllocator; + aAllocator= + NCollection_BaseAllocator::CommonBaseAllocator(); BOPCol_ListOfShape aLS(aAllocator); // aItLS.Initialize(myArguments); diff --git a/src/BOPAlgo/BOPAlgo_Builder.cxx b/src/BOPAlgo/BOPAlgo_Builder.cxx index 8ef995ebe5..6240147948 100644 --- a/src/BOPAlgo/BOPAlgo_Builder.cxx +++ b/src/BOPAlgo/BOPAlgo_Builder.cxx @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -251,7 +250,8 @@ void BOPAlgo_Builder::Perform() } } // - Handle(NCollection_BaseAllocator) aAllocator=new NCollection_IncAllocator; + Handle(NCollection_BaseAllocator) aAllocator= + NCollection_BaseAllocator::CommonBaseAllocator(); // BOPAlgo_PaveFiller* pPF=new BOPAlgo_PaveFiller(aAllocator); // diff --git a/src/BOPAlgo/BOPAlgo_BuilderSolid.cxx b/src/BOPAlgo/BOPAlgo_BuilderSolid.cxx index 52ea0d569b..44e1769c9b 100644 --- a/src/BOPAlgo/BOPAlgo_BuilderSolid.cxx +++ b/src/BOPAlgo/BOPAlgo_BuilderSolid.cxx @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include @@ -437,7 +436,8 @@ void BOPAlgo_BuilderSolid::PerformLoops() myErrorStatus=0; myLoops.Clear(); // - aAlr=new NCollection_IncAllocator(); + aAlr= + NCollection_BaseAllocator::CommonBaseAllocator(); BOPAlgo_ShellSplitter aSSp(aAlr); // // 1. Shells Usual diff --git a/src/BOPAlgo/BOPAlgo_Builder_2.cxx b/src/BOPAlgo/BOPAlgo_Builder_2.cxx index 8127f1c5f6..a303a7bbb4 100644 --- a/src/BOPAlgo/BOPAlgo_Builder_2.cxx +++ b/src/BOPAlgo/BOPAlgo_Builder_2.cxx @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include @@ -69,11 +68,11 @@ static void FillMap(const TopoDS_Shape& aS1, const TopoDS_Shape& aS2, BOPCol_IndexedDataMapOfShapeListOfShape& aDMSLS, - Handle(NCollection_IncAllocator)& aAllocator); + Handle(NCollection_BaseAllocator)& aAllocator); static void MakeBlocksCnx(const BOPCol_IndexedDataMapOfShapeListOfShape& aMILI, BOPCol_DataMapOfIntegerListOfShape& aMBlocks, - Handle(NCollection_IncAllocator)& aAllocator); + Handle(NCollection_BaseAllocator)& aAllocator); // typedef BOPCol_NCVector BOPAlgo_VectorOfShape; // @@ -270,7 +269,8 @@ void BOPAlgo_Builder::BuildSplitFaces() myErrorStatus=0; // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~scope f - aAllocator=new NCollection_IncAllocator(); + aAllocator= + NCollection_BaseAllocator::CommonBaseAllocator(); // BOPCol_ListOfShape aLE(aAllocator); BOPCol_MapOfShape aMDE(100, aAllocator); @@ -444,7 +444,6 @@ void BOPAlgo_Builder::BuildSplitFaces() mySplits.Bind(aF, aLFIm); }// for (k=0; k // -#include #include // #include @@ -253,7 +252,7 @@ class BOPAlgo_FillIn3DParts : public BOPAlgo_Algo { //======================================================================= void BOPAlgo_FillIn3DParts::Perform() { - Handle(NCollection_IncAllocator) aAlr1; + Handle(NCollection_BaseAllocator) aAlr1; BOPAlgo_Algo::UserBreak(); // Standard_Integer aNbFP, k, nFP, iIsIN; @@ -262,7 +261,8 @@ void BOPAlgo_FillIn3DParts::Perform() BOPCol_ListIteratorOfListOfShape aItLS; BOPCol_BoxBndTreeSelector aSelector; // - aAlr1=new NCollection_IncAllocator(); + aAlr1= + NCollection_BaseAllocator::CommonBaseAllocator(); // BOPCol_ListOfShape aLFP(aAlr1); BOPCol_ListOfShape aLCBF(aAlr1); @@ -518,10 +518,11 @@ void BOPAlgo_Builder::FillImagesSolids() if (!bHasSolids) { return; } + // + Handle(NCollection_BaseAllocator) aAlr; // - Handle(NCollection_IncAllocator) aAlr; + aAlr=NCollection_BaseAllocator::CommonBaseAllocator(); // - aAlr=new NCollection_IncAllocator(); BOPCol_DataMapOfShapeListOfShape theInParts(100, aAlr); BOPCol_DataMapOfShapeShape theDraftSolids(100, aAlr); // @@ -543,7 +544,7 @@ void BOPAlgo_Builder::FillIn3DParts { Standard_Boolean bHasImage; Standard_Integer i, k, aNbS, aNbLIF, aNbFIN, aNbVSB, aNbVFIP; - Handle(NCollection_IncAllocator) aAlr0; + Handle(NCollection_BaseAllocator) aAlr0; TopoDS_Solid aSD; TopoDS_Iterator aIt; BRep_Builder aBB; @@ -551,7 +552,8 @@ void BOPAlgo_Builder::FillIn3DParts BOPCol_ListIteratorOfListOfInteger aItLI, aItLI1; BOPCol_ListIteratorOfListOfShape aItLS; // - aAlr0=new NCollection_IncAllocator(); + aAlr0= + NCollection_BaseAllocator::CommonBaseAllocator(); // BOPCol_MapOfShape aMFence(100, aAlr0); BOPAlgo_VectorOfShapeBox aVSB(256, aAlr0); @@ -802,8 +804,8 @@ void BOPAlgo_Builder::BuildSplitSolids TopExp_Explorer aExp; BOPCol_ListIteratorOfListOfShape aIt; // - Handle(NCollection_IncAllocator) aAlr0; - aAlr0=new NCollection_IncAllocator(); + Handle(NCollection_BaseAllocator) aAlr0; + aAlr0=NCollection_BaseAllocator::CommonBaseAllocator(); // BOPCol_ListOfShape aSFS(aAlr0), aLSEmpty(aAlr0); BOPCol_MapOfShape aMFence(100, aAlr0); @@ -869,10 +871,7 @@ void BOPAlgo_Builder::BuildSplitSolids aSFS.Append(aF); } // - // 1.3 Build new solids - Handle(NCollection_IncAllocator) aAlr1; - aAlr1=new NCollection_IncAllocator(); - // + // 1.3 Build new solids BOPAlgo_BuilderSolid& aBS=aVBS.Append1(); aBS.SetSolid(aSolid); aBS.SetShapes(aSFS); @@ -934,9 +933,9 @@ void BOPAlgo_Builder::FillInternalShapes() BRep_Builder aBB; BOPCol_ListIteratorOfListOfShape aIt, aIt1; // - Handle(NCollection_IncAllocator) aAllocator; + Handle(NCollection_BaseAllocator) aAllocator; //-----------------------------------------------------scope f - aAllocator=new NCollection_IncAllocator(); + aAllocator=NCollection_BaseAllocator::CommonBaseAllocator(); // BOPCol_IndexedDataMapOfShapeListOfShape aMSx(100, aAllocator); BOPCol_IndexedMapOfShape aMx(100, aAllocator); diff --git a/src/BOPAlgo/BOPAlgo_MakerVolume.cxx b/src/BOPAlgo/BOPAlgo_MakerVolume.cxx index 14f4832cee..1743a0d5c8 100644 --- a/src/BOPAlgo/BOPAlgo_MakerVolume.cxx +++ b/src/BOPAlgo/BOPAlgo_MakerVolume.cxx @@ -12,7 +12,6 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. - #include #include #include @@ -23,7 +22,6 @@ #include #include #include -#include #include #include @@ -73,7 +71,8 @@ void BOPAlgo_MakerVolume::Perform() } } // - Handle(NCollection_BaseAllocator) aAllocator = new NCollection_IncAllocator; + Handle(NCollection_BaseAllocator) aAllocator = + NCollection_BaseAllocator::CommonBaseAllocator(); BOPAlgo_PaveFiller* pPF = new BOPAlgo_PaveFiller(aAllocator); // if (!myIntersect) { diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller.hxx b/src/BOPAlgo/BOPAlgo_PaveFiller.hxx index e3d4ad109e..62399568f9 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller.hxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller.hxx @@ -124,6 +124,8 @@ protected: Standard_EXPORT virtual void PerformFZ(); Standard_EXPORT virtual void PerformZZ(); + + Standard_EXPORT virtual void PerformSZ(const TopAbs_ShapeEnum aTS); Standard_EXPORT void TreatVerticesEE(); diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_1.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_1.cxx index 8eb388e51f..418bdaef9e 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_1.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_1.cxx @@ -34,7 +34,6 @@ #include #include #include -#include #include #include @@ -42,11 +41,11 @@ // function: PerformVV // purpose: //======================================================================= - void BOPAlgo_PaveFiller::PerformVV() +void BOPAlgo_PaveFiller::PerformVV() { Standard_Boolean bWithSubShape; Standard_Integer n1, n2, iFlag, nX, n, aSize, i, j, k, aNbBlocks; - Handle(NCollection_IncAllocator) aAllocator; + Handle(NCollection_BaseAllocator) aAllocator; BOPCol_ListIteratorOfListOfInteger aItLI, aItLI2; TopoDS_Vertex aVn; BOPDS_ShapeInfo aSIn; @@ -65,7 +64,8 @@ aVVs.SetIncrement(aSize); // //-----------------------------------------------------scope f - aAllocator=new NCollection_IncAllocator(); + aAllocator= + NCollection_BaseAllocator::CommonBaseAllocator(); BOPCol_IndexedDataMapOfIntegerListOfInteger aMILI(100, aAllocator); BOPCol_DataMapOfIntegerListOfInteger aMBlocks(100, aAllocator); BOPCol_ListOfShape aLV(aAllocator); @@ -134,5 +134,4 @@ aLV.Clear(); aMBlocks.Clear(); aMILI.Clear(); - aAllocator.Nullify(); } diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_10.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_10.cxx index 68bb407464..d9ea039311 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_10.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_10.cxx @@ -15,7 +15,6 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. - #include #include #include @@ -25,12 +24,215 @@ #include #include #include -#include #include +#include +#include +#include #include +#include #include #include -#include +///////////////////////////////////////////////////////////////////////// +//======================================================================= +//class : BOPAlgo_VertexSolid +//purpose : +//======================================================================= +class BOPAlgo_VertexSolid { + public: + DEFINE_STANDARD_ALLOC + + BOPAlgo_VertexSolid() + : myIV(-1), myIZ(-1), myState(TopAbs_UNKNOWN) { + }; + // + virtual ~BOPAlgo_VertexSolid(){ + }; + // + void SetIndices(const Standard_Integer nV, + const Standard_Integer nZ){ + myIV=nV; + myIZ=nZ; + } + // + void Indices(Standard_Integer& nV, + Standard_Integer& nZ) const { + nV=myIV; + nZ=myIZ; + } + // + void SetVertex(const TopoDS_Vertex& aV) { + myV=aV; + } + // + const TopoDS_Vertex& Vertex()const { + return myV; + } + // + void SetSolid(const TopoDS_Solid& aZ) { + myZ=aZ; + } + // + const TopoDS_Solid& Solid()const { + return myZ; + } + // + void SetContext(const Handle(IntTools_Context)& aContext) { + myContext=aContext; + } + // + const Handle(IntTools_Context)& Context()const { + return myContext; + } + // + TopAbs_State State() const{ + return myState; + }; + // + void Perform() { + Standard_Real aTol; + gp_Pnt aPV; + // + BRepClass3d_SolidClassifier& aSC=myContext->SolidClassifier(myZ); + // + aPV=BRep_Tool::Pnt(myV); + aTol=BRep_Tool::Tolerance(myV); + // + aSC.Perform(aPV, aTol); + // + myState=aSC.State(); + }; + // + protected: + Standard_Integer myIV; + Standard_Integer myIZ; + TopAbs_State myState; + TopoDS_Vertex myV; + TopoDS_Solid myZ; + Handle(IntTools_Context) myContext; +}; +//======================================================================= +typedef BOPCol_NCVector + BOPAlgo_VectorOfVertexSolid; +// +typedef BOPCol_ContextFunctor + BOPAlgo_VertexSolidFunctor; +// +typedef BOPCol_ContextCnt + BOPAlgo_VertexSolidCnt; +///////////////////////////////////////////////////////////////////////// +//======================================================================= +//class : BOPAlgo_ShapeSolid +//purpose : +//======================================================================= +class BOPAlgo_ShapeSolid { + public: + DEFINE_STANDARD_ALLOC + + BOPAlgo_ShapeSolid() : + myIE(-1), + myIZ(-1), + myHasInterf(Standard_False), + myDS(NULL) { + }; + // + virtual ~BOPAlgo_ShapeSolid(){ + }; + // + void SetIndices(const Standard_Integer nE, + const Standard_Integer nZ){ + myIE=nE; + myIZ=nZ; + } + // + void Indices(Standard_Integer& nE, + Standard_Integer& nZ) const { + nE=myIE; + nZ=myIZ; + } + // + void SetDS(BOPDS_DS* pDS) { + myDS=pDS; + } + // + Standard_Boolean HasInterf() const{ + return myHasInterf; + }; + // + virtual void Perform() { + Standard_Boolean bHasInterf; + // + myHasInterf=Standard_False; + // + bHasInterf=myDS->HasInterfShapeSubShapes(myIE, myIZ); + if (!bHasInterf) { + myHasInterf=myDS->HasInterfShapeSubShapes(myIZ, myIE); + } + }; + // + protected: + Standard_Integer myIE; + Standard_Integer myIZ; + Standard_Boolean myHasInterf; + BOPDS_DS* myDS; +}; +//======================================================================= +typedef BOPCol_NCVector + BOPAlgo_VectorOfShapeSolid; +// +typedef BOPCol_Functor + BOPAlgo_ShapeSolidFunctor; +// +typedef BOPCol_Cnt + BOPAlgo_ShapeSolidCnt; +// +///////////////////////////////////////////////////////////////////////// +//======================================================================= +//class : BOPAlgo_SolidSolid +//purpose : +//======================================================================= +class BOPAlgo_SolidSolid : public BOPAlgo_ShapeSolid { + public: + DEFINE_STANDARD_ALLOC + + BOPAlgo_SolidSolid() : + BOPAlgo_ShapeSolid() { + }; + // + virtual ~BOPAlgo_SolidSolid(){ + }; + // + virtual void Perform() { + Standard_Boolean bFlag; + // + bFlag=Standard_False; + myHasInterf=Standard_False; + // + myHasInterf=myDS->HasInterfShapeSubShapes(myIZ, myIE, bFlag); + if (!myHasInterf) { + myHasInterf=myDS->HasInterfShapeSubShapes(myIE, myIZ, bFlag); + } + }; +}; +//======================================================================= +typedef BOPCol_NCVector + BOPAlgo_VectorOfSolidSolid; +// +typedef BOPCol_Functor + BOPAlgo_SolidSolidFunctor; +// +typedef BOPCol_Cnt + BOPAlgo_SolidSolidCnt; +// +///////////////////////////////////////////////////////////////////////// //======================================================================= //function : PerformVZ @@ -39,9 +241,7 @@ void BOPAlgo_PaveFiller::PerformVZ() { Standard_Boolean bJustAdd; - Standard_Integer iSize, nV, nZ; - Standard_Real aTol; - gp_Pnt aPV; + Standard_Integer iSize, nV, nZ, k, aNbVVS; TopAbs_State aState; // myErrorStatus=0; @@ -55,6 +255,8 @@ void BOPAlgo_PaveFiller::PerformVZ() BOPDS_VectorOfInterfVZ& aVZs=myDS->InterfVZ(); aVZs.SetIncrement(iSize); // + BOPAlgo_VectorOfVertexSolid aVVS; + // for (; myIterator->More(); myIterator->Next()) { myIterator->Value(nV, nZ, bJustAdd); if(bJustAdd) { @@ -67,15 +269,22 @@ void BOPAlgo_PaveFiller::PerformVZ() const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&aSIV.Shape()); const TopoDS_Solid& aZ=*((TopoDS_Solid*)&aSIZ.Shape()); // - BRepClass3d_SolidClassifier& aSC=myContext->SolidClassifier(aZ); - // - aPV=BRep_Tool::Pnt(aV); - aTol=BRep_Tool::Tolerance(aV); - // - aSC.Perform(aPV, aTol); - // - aState=aSC.State(); + BOPAlgo_VertexSolid& aVertexSolid=aVVS.Append1(); + aVertexSolid.SetIndices(nV, nZ); + aVertexSolid.SetVertex(aV); + aVertexSolid.SetSolid(aZ); + } + // + aNbVVS=aVVS.Extent(); + //============================================================= + BOPAlgo_VertexSolidCnt::Perform(myRunParallel, aVVS, myContext); + //============================================================= + for (k=0; k < aNbVVS; ++k) { + const BOPAlgo_VertexSolid& aVertexSolid=aVVS(k); + aState=aVertexSolid.State(); if (aState==TopAbs_IN) { + aVertexSolid.Indices(nV, nZ); + // BOPDS_InterfVZ& aVZ=aVZs.Append1(); aVZ.SetIndices(nV, nZ); // @@ -88,124 +297,130 @@ void BOPAlgo_PaveFiller::PerformVZ() //purpose : //======================================================================= void BOPAlgo_PaveFiller::PerformEZ() -{ - Standard_Boolean bJustAdd, bHasInterf; - Standard_Integer iSize, nE, nZ; - // - myErrorStatus=0; - // - myIterator->Initialize(TopAbs_EDGE, TopAbs_SOLID); - iSize=myIterator->ExpectedLength(); - if (!iSize) { - return; - } - // - BOPDS_VectorOfInterfEZ& aEZs=myDS->InterfEZ(); - aEZs.SetIncrement(iSize); - // - for (; myIterator->More(); myIterator->Next()) { - myIterator->Value(nE, nZ, bJustAdd); - if(bJustAdd) { - continue; - } - // - bHasInterf=myDS->HasInterfShapeSubShapes(nE, nZ); - if (bHasInterf) { - continue; - } - // - bHasInterf=myDS->HasInterfShapeSubShapes(nZ, nE); - if (!bHasInterf) { - continue; - } - // - BOPDS_InterfEZ& aEZ=aEZs.Append1(); - aEZ.SetIndices(nE, nZ); - // - myDS->AddInterf(nE, nZ); - } +{ + PerformSZ(TopAbs_EDGE); } //======================================================================= //function : PerformFZ //purpose : //======================================================================= void BOPAlgo_PaveFiller::PerformFZ() +{ + PerformSZ(TopAbs_FACE); +} +//======================================================================= +//function : PerformZZ +//purpose : +//======================================================================= +void BOPAlgo_PaveFiller::PerformZZ() { Standard_Boolean bJustAdd, bHasInterf; - Standard_Integer iSize, nF, nZ; + Standard_Integer iSize, nZ1, nZ, k, aNbSolidSolid; // myErrorStatus=0; // - myIterator->Initialize(TopAbs_FACE, TopAbs_SOLID); + myIterator->Initialize(TopAbs_SOLID, TopAbs_SOLID); iSize=myIterator->ExpectedLength(); if (!iSize) { return; } // - BOPDS_VectorOfInterfFZ& aFZs=myDS->InterfFZ(); - aFZs.SetIncrement(iSize); + BOPAlgo_VectorOfSolidSolid aVSolidSolid; // for (; myIterator->More(); myIterator->Next()) { - myIterator->Value(nF, nZ, bJustAdd); + myIterator->Value(nZ1, nZ, bJustAdd); if(bJustAdd) { continue; } // - bHasInterf=myDS->HasInterfShapeSubShapes(nF, nZ); + BOPAlgo_SolidSolid& aSolidSolid=aVSolidSolid.Append1(); + aSolidSolid.SetIndices(nZ1, nZ); + aSolidSolid.SetDS(myDS); + } + // + aNbSolidSolid=aVSolidSolid.Extent(); + //====================================================== + BOPAlgo_SolidSolidCnt::Perform(myRunParallel, aVSolidSolid); + //====================================================== + // + BOPDS_VectorOfInterfZZ& aZZs=myDS->InterfZZ(); + // + aZZs.SetIncrement(iSize); + // + for (k=0; k < aNbSolidSolid; ++k) { + const BOPAlgo_SolidSolid& aSolidSolid=aVSolidSolid(k); + bHasInterf=aSolidSolid.HasInterf(); if (bHasInterf) { - continue; - } - // - bHasInterf=myDS->HasInterfShapeSubShapes(nZ, nF); - if (!bHasInterf) { - continue; + aSolidSolid.Indices(nZ1, nZ); + // + BOPDS_InterfZZ& aZZ=aZZs.Append1(); + aZZ.SetIndices(nZ1, nZ); + // + myDS->AddInterf(nZ1, nZ); } - // - BOPDS_InterfFZ& aFZ=aFZs.Append1(); - aFZ.SetIndices(nF, nZ); - // - myDS->AddInterf(nF, nZ); } } //======================================================================= -//function : PerformZZ +//function : PerformSZ //purpose : //======================================================================= -void BOPAlgo_PaveFiller::PerformZZ() +void BOPAlgo_PaveFiller::PerformSZ(const TopAbs_ShapeEnum aTS) { - Standard_Boolean bJustAdd, bHasInterf, bFlag; - Standard_Integer iSize, nZ1, nZ; + Standard_Boolean bJustAdd, bHasInterf; + Standard_Integer iSize, nS, nZ, k, aNbShapeSolid; // myErrorStatus=0; // - myIterator->Initialize(TopAbs_SOLID, TopAbs_SOLID); + myIterator->Initialize(aTS, TopAbs_SOLID); iSize=myIterator->ExpectedLength(); if (!iSize) { return; } // - BOPDS_VectorOfInterfZZ& aZZs=myDS->InterfZZ(); - aZZs.SetIncrement(iSize); - // - bFlag=Standard_False; + BOPAlgo_VectorOfShapeSolid aVShapeSolid; // for (; myIterator->More(); myIterator->Next()) { - myIterator->Value(nZ1, nZ, bJustAdd); + myIterator->Value(nS, nZ, bJustAdd); if(bJustAdd) { continue; } // - bHasInterf=myDS->HasInterfShapeSubShapes(nZ, nZ1, bFlag); - if (!bHasInterf) { - bHasInterf=myDS->HasInterfShapeSubShapes(nZ1, nZ, bFlag); - } - if (!bHasInterf) { - continue; + BOPAlgo_ShapeSolid& aShapeSolid=aVShapeSolid.Append1(); + aShapeSolid.SetIndices(nS, nZ); + aShapeSolid.SetDS(myDS); + } + // + aNbShapeSolid=aVShapeSolid.Extent(); + //====================================================== + BOPAlgo_ShapeSolidCnt::Perform(myRunParallel, aVShapeSolid); + //====================================================== + // + BOPDS_VectorOfInterfEZ& aEZs=myDS->InterfEZ(); + BOPDS_VectorOfInterfFZ& aFZs=myDS->InterfFZ(); + // + if (aTS==TopAbs_EDGE) { + aEZs.SetIncrement(iSize); + } + else {//if (aTS==TopAbs_FACE) + aFZs.SetIncrement(iSize); + } + // + for (k=0; k < aNbShapeSolid; ++k) { + const BOPAlgo_ShapeSolid& aShapeSolid=aVShapeSolid(k); + bHasInterf=aShapeSolid.HasInterf(); + if (bHasInterf) { + aShapeSolid.Indices(nS, nZ); + // + if (aTS==TopAbs_EDGE) { + BOPDS_InterfEZ& aEZ=aEZs.Append1(); + aEZ.SetIndices(nS, nZ); + } + else {//if (aTS==TopAbs_FACE) + BOPDS_InterfFZ& aFZ=aFZs.Append1(); + aFZ.SetIndices(nS, nZ); + } + // + myDS->AddInterf(nS, nZ); } - // - BOPDS_InterfZZ& aZZ=aZZs.Append1(); - aZZ.SetIndices(nZ1, nZ); - // - myDS->AddInterf(nZ1, nZ); } } diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx index 93f9ca925e..bbad799819 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_3.cxx @@ -54,7 +54,6 @@ #include #include #include -#include #include #include #include @@ -291,11 +290,12 @@ void BOPAlgo_PaveFiller::PerformEE() Standard_Real aTS11, aTS12, aTS21, aTS22, aT11, aT12, aT21, aT22; TopAbs_ShapeEnum aType; BOPDS_ListIteratorOfListOfPaveBlock aIt1, aIt2; - Handle(NCollection_IncAllocator) aAllocator; + Handle(NCollection_BaseAllocator) aAllocator; BOPDS_MapOfPaveBlock aMPBToUpdate; BOPAlgo_VectorOfEdgeEdge aVEdgeEdge; BOPDS_MapIteratorOfMapOfPaveBlock aItPB; // + aAllocator=NCollection_BaseAllocator::CommonBaseAllocator(); //-----------------------------------------------------scope f BOPDS_IndexedDataMapOfPaveBlockListOfPaveBlock aMPBLPB(100, aAllocator); BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks aMVCPB(100, aAllocator); diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_4.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_4.cxx index 4ff9d3ea82..c43f8ba50e 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_4.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_4.cxx @@ -35,7 +35,6 @@ #include #include #include -#include #include #include @@ -255,9 +254,10 @@ void BOPAlgo_PaveFiller::TreatVerticesEE() Standard_Integer i, aNbS,aNbEEs, nF, nV, iFlag; Standard_Real aT1, aT2; BOPCol_ListIteratorOfListOfInteger aItLI; - Handle(NCollection_IncAllocator) aAllocator; + Handle(NCollection_BaseAllocator) aAllocator; // - aAllocator=new NCollection_IncAllocator(); + aAllocator= + NCollection_BaseAllocator::CommonBaseAllocator(); BOPCol_ListOfInteger aLIV(aAllocator), aLIF(aAllocator); BOPCol_MapOfInteger aMI(100, aAllocator); BOPDS_MapOfPaveBlock aMPBF(100, aAllocator); @@ -328,6 +328,4 @@ void BOPAlgo_PaveFiller::TreatVerticesEE() } } } - // - aAllocator.Nullify(); } diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx index 5c99402318..3f9824a264 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_5.cxx @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include @@ -156,15 +155,15 @@ void BOPAlgo_PaveFiller::PerformEF() Standard_Integer nE, nF, aDiscretize, i, aNbCPrts, iX, nV[2]; Standard_Integer aNbEdgeFace, k; Standard_Real aTolE, aTolF, aTS1, aTS2, aT1, aT2, aDeflection; - Handle(NCollection_IncAllocator) aAllocator; + Handle(NCollection_BaseAllocator) aAllocator; TopAbs_ShapeEnum aType; BOPDS_ListIteratorOfListOfPaveBlock aIt; BOPAlgo_VectorOfEdgeFace aVEdgeFace; BRep_Builder aBB; //-----------------------------------------------------scope f // - ////aAllocator=new NCollection_IncAllocator(); - + aAllocator=NCollection_BaseAllocator::CommonBaseAllocator(); + // BOPCol_MapOfInteger aMIEFC(100, aAllocator); BOPDS_IndexedDataMapOfShapeCoupleOfPaveBlocks aMVCPB(100, aAllocator); BOPDS_IndexedDataMapOfPaveBlockListOfInteger aMPBLI(100, aAllocator); diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx index 4522482dc2..bf019a43fb 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_6.cxx @@ -67,7 +67,6 @@ #include #include #include -#include #include #include #include @@ -351,13 +350,14 @@ void BOPAlgo_PaveFiller::MakeBlocks() Standard_Integer i, nF1, nF2, aNbC, aNbP, j; Standard_Integer nV1, nV2; Standard_Real aTolR3D, aT1, aT2, aTol; - Handle(NCollection_IncAllocator) aAllocator; + Handle(NCollection_BaseAllocator) aAllocator; BOPDS_ListIteratorOfListOfPaveBlock aItLPB; TopoDS_Edge aES; Handle(BOPDS_PaveBlock) aPBOut; // //-----------------------------------------------------scope f - aAllocator=new NCollection_IncAllocator(); + aAllocator= + NCollection_BaseAllocator::CommonBaseAllocator(); // BOPCol_ListOfInteger aLSE(aAllocator), aLBV(aAllocator); BOPCol_MapOfInteger aMVOnIn(100, aAllocator), aMF(100, aAllocator), @@ -595,7 +595,6 @@ void BOPAlgo_PaveFiller::MakeBlocks() aDMExEdges.Clear(); aMI.Clear(); aDMI.Clear(); - aAllocator.Nullify(); } //======================================================================= diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_7.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_7.cxx index 77f2bc0f28..8bc56b9329 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_7.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_7.cxx @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include diff --git a/src/BOPAlgo/BOPAlgo_PaveFiller_8.cxx b/src/BOPAlgo/BOPAlgo_PaveFiller_8.cxx index 1638690b7d..ae4ca2ef11 100644 --- a/src/BOPAlgo/BOPAlgo_PaveFiller_8.cxx +++ b/src/BOPAlgo/BOPAlgo_PaveFiller_8.cxx @@ -15,7 +15,6 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. - #include #include #include @@ -39,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -58,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; // @@ -70,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(); diff --git a/src/BOPAlgo/BOPAlgo_Section.cxx b/src/BOPAlgo/BOPAlgo_Section.cxx index 3486e4fb7c..d7985e4c99 100644 --- a/src/BOPAlgo/BOPAlgo_Section.cxx +++ b/src/BOPAlgo/BOPAlgo_Section.cxx @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include diff --git a/src/BOPDS/BOPDS_DS.cxx b/src/BOPDS/BOPDS_DS.cxx index 732a5e138e..0665589934 100644 --- a/src/BOPDS/BOPDS_DS.cxx +++ b/src/BOPDS/BOPDS_DS.cxx @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #include @@ -354,7 +353,7 @@ void BOPDS_DS::Init() BOPCol_ListIteratorOfListOfInteger aIt1, aIt2, aIt3; BOPCol_ListIteratorOfListOfShape aIt; BOPDS_IndexRange aR; - Handle(NCollection_IncAllocator) aAllocator; + Handle(NCollection_BaseAllocator) aAllocator; // // 1 Append Source Shapes aNb=myArguments.Extent(); @@ -382,7 +381,8 @@ void BOPDS_DS::Init() // myLines.SetIncrement(2*aNbS); //-----------------------------------------------------scope_1 f - aAllocator=new NCollection_IncAllocator(); + aAllocator= + NCollection_BaseAllocator::CommonBaseAllocator(); // BOPCol_DataMapOfShapeInteger& aMSI=myMapShapeIndex; // @@ -647,7 +647,6 @@ void BOPDS_DS::Init() }//for (j=0; j #include #include -#include #include #include @@ -272,11 +271,11 @@ void BOPDS_Iterator::Intersect() Standard_Integer aNb, i, aNbR, iTi, iTj; Standard_Integer i1, i2, aNbSD, iX, j, iR; TopAbs_ShapeEnum aTi, aTj; - Handle(NCollection_IncAllocator) aAllocator; + Handle(NCollection_BaseAllocator) aAllocator; BOPCol_ListIteratorOfListOfInteger aIt; // //-----------------------------------------------------scope_1 f - aAllocator=new NCollection_IncAllocator(); + aAllocator=NCollection_BaseAllocator::CommonBaseAllocator(); // BOPDS_MapOfPassKeyBoolean aMPKXB(100, aAllocator); BOPDS_PassKeyBoolean aPKXB; @@ -375,6 +374,5 @@ void BOPDS_Iterator::Intersect() // aMPKXB.Clear(); aVTSR.Clear(); - aAllocator.Nullify(); //-----------------------------------------------------scope_1 t } diff --git a/src/BOPDS/BOPDS_IteratorSI.cxx b/src/BOPDS/BOPDS_IteratorSI.cxx index 3cf6c4c891..c59c06a35b 100644 --- a/src/BOPDS/BOPDS_IteratorSI.cxx +++ b/src/BOPDS/BOPDS_IteratorSI.cxx @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -85,11 +84,12 @@ void BOPDS_IteratorSI::Intersect() Standard_Integer aNbS, i, aNbB; Standard_Integer aNbSD, iX, j, iDS, jB; TopAbs_ShapeEnum aTi, aTj; - Handle(NCollection_IncAllocator) aAllocator; + Handle(NCollection_BaseAllocator) aAllocator; BOPCol_ListIteratorOfListOfInteger aIt; // //-----------------------------------------------------scope_1 f - aAllocator=new NCollection_IncAllocator(); + aAllocator= + NCollection_BaseAllocator::CommonBaseAllocator(); // BOPCol_DataMapOfShapeInteger aMSI(100, aAllocator); BOPCol_DataMapOfIntegerInteger aMII(100, aAllocator); @@ -199,6 +199,5 @@ void BOPDS_IteratorSI::Intersect() aMPKXB.Clear(); aMSB.Clear(); // - aAllocator.Nullify(); //-----------------------------------------------------scope_1 t } diff --git a/src/BOPDS/BOPDS_SubIterator.cxx b/src/BOPDS/BOPDS_SubIterator.cxx index 625dbee8cb..ad85e78227 100644 --- a/src/BOPDS/BOPDS_SubIterator.cxx +++ b/src/BOPDS/BOPDS_SubIterator.cxx @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -142,7 +141,7 @@ // purpose: //======================================================================= void BOPDS_SubIterator::Value(Standard_Integer& theI1, - Standard_Integer& theI2) const + Standard_Integer& theI2) const { Standard_Integer iT1, iT2, n1, n2; // @@ -182,12 +181,13 @@ void BOPDS_SubIterator::Intersect() { Standard_Integer i, aNbB, aNbSD, j, iDS, jB; - Handle(NCollection_IncAllocator) aAllocator; + Handle(NCollection_BaseAllocator) aAllocator; BOPCol_ListIteratorOfListOfInteger aIt, aIt1, aIt2; BOPDS_PassKeyBoolean aPKXB; // //-----------------------------------------------------scope_1 f - aAllocator=new NCollection_IncAllocator(); + aAllocator= + NCollection_BaseAllocator::CommonBaseAllocator(); // BOPCol_DataMapOfShapeInteger aMSI(100, aAllocator); BOPCol_DataMapOfIntegerInteger aMII(100, aAllocator); @@ -244,7 +244,7 @@ // aPKXB.SetIds(i, j); if (aMPKXB.Add(aPKXB)) { - myList.Append(aPKXB); + myList.Append(aPKXB); }// if (aMPKXB.Add(aPKXB)) { }// for (; aIt.More(); aIt.Next()) { } @@ -254,6 +254,5 @@ aMPKXB.Clear(); aMSB.Clear(); // - aAllocator.Nullify(); //-----------------------------------------------------scope_1 t } diff --git a/src/BOPTest/BOPTest_BOPCommands.cxx b/src/BOPTest/BOPTest_BOPCommands.cxx index 35c36e3f06..8807317e08 100644 --- a/src/BOPTest/BOPTest_BOPCommands.cxx +++ b/src/BOPTest/BOPTest_BOPCommands.cxx @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -153,7 +152,8 @@ Standard_Integer bop(Draw_Interpretor& di, delete pPF; pPF=NULL; } - Handle(NCollection_BaseAllocator)aAL=new NCollection_IncAllocator; + Handle(NCollection_BaseAllocator)aAL= + NCollection_BaseAllocator::CommonBaseAllocator(); pPF=new BOPAlgo_PaveFiller(aAL); // pPF->SetArguments(aLC); @@ -484,7 +484,8 @@ Standard_Integer bsmt (Draw_Interpretor& di, aTol=BOPTest_Objects::FuzzyValue(); bRunParallel = BOPTest_Objects::RunParallel(); // - Handle(NCollection_BaseAllocator)aAL=new NCollection_IncAllocator; + Handle(NCollection_BaseAllocator)aAL= + NCollection_BaseAllocator::CommonBaseAllocator(); // //--------------------------------------------------------------- BOPAlgo_PaveFiller aPF(aAL); diff --git a/src/BOPTest/BOPTest_Objects.cxx b/src/BOPTest/BOPTest_Objects.cxx index 37bd0da77e..44a528ee05 100644 --- a/src/BOPTest/BOPTest_Objects.cxx +++ b/src/BOPTest/BOPTest_Objects.cxx @@ -19,7 +19,6 @@ #include #include #include -#include static Handle(NCollection_BaseAllocator)& Allocator1(); @@ -42,8 +41,8 @@ class BOPTest_Session { void Init() { Handle(NCollection_BaseAllocator) pA1, pA2; // - pA1=new NCollection_IncAllocator; - pA2=new NCollection_IncAllocator; + pA1=NCollection_BaseAllocator::CommonBaseAllocator(); + pA2=NCollection_BaseAllocator::CommonBaseAllocator(); // myPaveFiller=new BOPAlgo_PaveFiller(pA1); myBuilderDefault=new BOPAlgo_Builder(pA2); @@ -279,6 +278,6 @@ Standard_Real BOPTest_Objects::FuzzyValue() Handle(NCollection_BaseAllocator)& Allocator1() { static Handle(NCollection_BaseAllocator) sAL1= - new NCollection_IncAllocator; + NCollection_BaseAllocator::CommonBaseAllocator(); return sAL1; } diff --git a/src/BOPTest/BOPTest_PartitionCommands.cxx b/src/BOPTest/BOPTest_PartitionCommands.cxx index b03a0192de..fa414052cb 100644 --- a/src/BOPTest/BOPTest_PartitionCommands.cxx +++ b/src/BOPTest/BOPTest_PartitionCommands.cxx @@ -25,7 +25,6 @@ #include #include #include -#include #include #include diff --git a/src/IntTools/IntTools_Context.cxx b/src/IntTools/IntTools_Context.cxx index df477ef095..1d7fd8c73b 100644 --- a/src/IntTools/IntTools_Context.cxx +++ b/src/IntTools/IntTools_Context.cxx @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -54,7 +53,7 @@ //======================================================================= IntTools_Context::IntTools_Context() : - myAllocator(new NCollection_IncAllocator()), + myAllocator(NCollection_BaseAllocator::CommonBaseAllocator()), myFClass2dMap(100, myAllocator), myProjPSMap(100, myAllocator), myProjPCMap(100, myAllocator), diff --git a/tests/bugs/fclasses/bug7287_1 b/tests/bugs/fclasses/bug7287_1 index ae913b5193..93ce439337 100755 --- a/tests/bugs/fclasses/bug7287_1 +++ b/tests/bugs/fclasses/bug7287_1 @@ -1,6 +1,3 @@ -puts "TODO OCC25921 ALL: Tcl Exception: Memory leak detected" -puts "TODO OCC25921 ALL: TEST INCOMPLETE" - puts "============" puts "OCC7287" puts "============" @@ -18,6 +15,8 @@ set BugNumber OCC7287 set NCycles 10 box b1 100 100 100 box b2 50 50 50 +bop b1 b2 +bopcut r set listmem {} for {set i 1} {${i} <= ${NCycles}} {incr i } { @@ -25,5 +24,5 @@ for {set i 1} {${i} <= ${NCycles}} {incr i } { bopcut r lappend listmem [meminfo h] - checktrend $listmem 0 100 "Memory leak detected" + checktrend $listmem 0 10 "Memory leak detected" } -- 2.20.1