From: jfa Date: Thu, 4 Jun 2009 08:15:41 +0000 (+0000) Subject: Bug 0020229: Perf of MakeSphere and RemoveObject. X-Git-Tag: V4_1_0_maintainance_FINAL~23 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c87ab347dfa437b85af60f69690a2e097ecbae5f;p=modules%2Fgeom.git Bug 0020229: Perf of MakeSphere and RemoveObject. --- diff --git a/src/GEOM/GEOM_Engine.cxx b/src/GEOM/GEOM_Engine.cxx index 3b700a01d..bce32c746 100644 --- a/src/GEOM/GEOM_Engine.cxx +++ b/src/GEOM/GEOM_Engine.cxx @@ -18,7 +18,7 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// + #ifdef WNT #pragma warning( disable:4786 ) #endif @@ -206,17 +206,12 @@ Handle(GEOM_Object) GEOM_Engine::AddObject(int theDocID, int theType) // if this label has been freed (object deleted) bool useExisting = false; TDF_Label aChild; - if (!_lastCleared.IsNull()) { - if (_lastCleared.Root() == aDoc->Main().Root()) { + if (_freeLabels.find(theDocID) != _freeLabels.end()) { + std::list& aFreeLabels = _freeLabels[theDocID]; + if (!aFreeLabels.empty()) { useExisting = true; - aChild = _lastCleared; - // 0020229: if next label exists and is empty, try to reuse it - Standard_Integer aNextTag = aChild.Tag() + 1; - TDF_Label aNextL = aDoc->Main().FindChild(aNextTag, Standard_False); - if (!aNextL.IsNull() && !aNextL.HasAttribute()) - _lastCleared = aNextL; - else - _lastCleared.Nullify(); + aChild = aFreeLabels.front(); + aFreeLabels.pop_front(); } } if (!useExisting) { @@ -252,6 +247,7 @@ Handle(GEOM_Object) GEOM_Engine::AddSubShape(Handle(GEOM_Object) theMainShape, // if this label has been freed (object deleted) bool useExisting = false; TDF_Label aChild; + /* if (!_lastCleared.IsNull()) { if (_lastCleared.Root() == aDoc->Main().Root()) { useExisting = true; @@ -265,6 +261,16 @@ Handle(GEOM_Object) GEOM_Engine::AddSubShape(Handle(GEOM_Object) theMainShape, _lastCleared.Nullify(); } } + */ + int aDocID = theMainShape->GetDocID(); + if (_freeLabels.find(aDocID) != _freeLabels.end()) { + std::list& aFreeLabels = _freeLabels[aDocID]; + if (!aFreeLabels.empty()) { + useExisting = true; + aChild = aFreeLabels.front(); + aFreeLabels.pop_front(); + } + } if (!useExisting) { // create new label aChild = TDF_TagSource::NewChild(aDoc->Main()); @@ -324,6 +330,8 @@ bool GEOM_Engine::RemoveObject(Handle(GEOM_Object) theObject) { if (!theObject) return false; + int aDocID = theObject->GetDocID(); + //Remove an object from the map of available objects TCollection_AsciiString anID = BuildIDFromObject(theObject); if (_objects.IsBound(anID)) _objects.UnBind(anID); @@ -338,7 +346,10 @@ bool GEOM_Engine::RemoveObject(Handle(GEOM_Object) theObject) TDF_Label aLabel = theObject->GetEntry(); aLabel.ForgetAllAttributes(Standard_True); - _lastCleared = aLabel; + + // Remember the label to reuse it then + std::list& aFreeLabels = _freeLabels[aDocID]; + aFreeLabels.push_back(aLabel); theObject.Nullify(); @@ -422,7 +433,11 @@ void GEOM_Engine::Close(int theDocID) } for (Standard_Integer i=1; i<=aSeq.Length(); i++) _objects.UnBind(aSeq.Value(i)); - _lastCleared.Nullify(); + // Forget free labels for this document + TFreeLabelsList::iterator anIt = _freeLabels.find(theDocID); + if (anIt != _freeLabels.end()) { + _freeLabels.erase(anIt); + } _mapIDDocument.UnBind(theDocID); _OCAFApp->Close(aDoc); diff --git a/src/GEOM/GEOM_Engine.hxx b/src/GEOM/GEOM_Engine.hxx index 9ce2a4f7f..48f61cb8d 100644 --- a/src/GEOM/GEOM_Engine.hxx +++ b/src/GEOM/GEOM_Engine.hxx @@ -18,7 +18,7 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// + #ifndef _GEOM_Engine_HXX_ #define _GEOM_Engine_HXX_ @@ -33,6 +33,11 @@ #include #include +#include +#include + +typedef std::map > TFreeLabelsList; + class GEOM_Engine { public: @@ -104,7 +109,7 @@ class GEOM_Engine Resource_DataMapOfAsciiStringAsciiString _studyEntry2NameMap; - TDF_Label _lastCleared; + TFreeLabelsList _freeLabels; }; #endif