From e170a5ac497c2fb9ecef0feeca029bfed7dfc6ec Mon Sep 17 00:00:00 2001 From: jfa Date: Mon, 28 Jan 2008 09:35:37 +0000 Subject: [PATCH] NPAL18604: Pb. of performance with MakeVertex. Fixed a bug from previous integration. --- src/GEOM/GEOM_Engine.cxx | 29 ++++++++++++++--------------- src/GEOM/GEOM_Engine.hxx | 3 ++- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/GEOM/GEOM_Engine.cxx b/src/GEOM/GEOM_Engine.cxx index bf231425c..a02a558f3 100644 --- a/src/GEOM/GEOM_Engine.cxx +++ b/src/GEOM/GEOM_Engine.cxx @@ -114,7 +114,7 @@ GEOM_Engine::GEOM_Engine() _OCAFApp = new GEOM_Application(); _UndoLimit = 10; - _lastObjectTag = 0; + //_lastObjectTag = 0; } //============================================================================= @@ -180,21 +180,20 @@ Handle(GEOM_Object) GEOM_Engine::AddObject(int theDocID, int theType) Handle(TDocStd_Document) aDoc = GetDocument(theDocID); Handle(TDataStd_TreeNode) aRoot = TDataStd_TreeNode::Set(aDoc->Main()); - //TDF_Label aChild = TDF_TagSource::NewChild(aDoc->Main()); // NPAL18604: use existing label to decrease memory usage, // if this label has been freed (object deleted) bool useExisting = false; TDF_Label aChild; - if (_lastObjectTag > 0) { - aChild = aDoc->Main().FindChild(_lastObjectTag, Standard_False); - if (!aChild.IsAttribute(TDataStd_TreeNode::GetDefaultTreeID())) { + if (!_lastCleared.IsNull()) { + if (_lastCleared.Root() == aDoc->Main().Root()) { useExisting = true; + aChild = _lastCleared; + _lastCleared.Nullify(); } } if (!useExisting) { // create new label aChild = TDF_TagSource::NewChild(aDoc->Main()); - _lastObjectTag = aChild.Tag(); } Handle(GEOM_Object) anObject = new GEOM_Object(aChild, theType); @@ -221,21 +220,20 @@ Handle(GEOM_Object) GEOM_Engine::AddSubShape(Handle(GEOM_Object) theMainShape, Handle(TDocStd_Document) aDoc = GetDocument(theMainShape->GetDocID()); Handle(TDataStd_TreeNode) aRoot = TDataStd_TreeNode::Set(aDoc->Main()); - //TDF_Label aChild = TDF_TagSource::NewChild(aDoc->Main()); // NPAL18604: use existing label to decrease memory usage, // if this label has been freed (object deleted) bool useExisting = false; TDF_Label aChild; - if (_lastObjectTag > 0) { - aChild = aDoc->Main().FindChild(_lastObjectTag, Standard_False); - if (!aChild.IsAttribute(TDataStd_TreeNode::GetDefaultTreeID())) { + if (!_lastCleared.IsNull()) { + if (_lastCleared.Root() == aDoc->Main().Root()) { useExisting = true; + aChild = _lastCleared; + _lastCleared.Nullify(); } } if (!useExisting) { // create new label aChild = TDF_TagSource::NewChild(aDoc->Main()); - _lastObjectTag = aChild.Tag(); } Handle(GEOM_Function) aMainShape = theMainShape->GetLastFunction(); @@ -290,22 +288,23 @@ Handle(GEOM_Object) GEOM_Engine::AddSubShape(Handle(GEOM_Object) theMainShape, //============================================================================= bool GEOM_Engine::RemoveObject(Handle(GEOM_Object) theObject) { - if(!theObject) return false; + if (!theObject) return false; //Remove an object from the map of available objects TCollection_AsciiString anID = BuildIDFromObject(theObject); - if(_objects.IsBound(anID)) _objects.UnBind(anID); + if (_objects.IsBound(anID)) _objects.UnBind(anID); int nb = theObject->GetNbFunctions(); Handle(TDataStd_TreeNode) aNode; - for(int i = 1; i<=nb; i++) { + for (int i = 1; i<=nb; i++) { Handle(GEOM_Function) aFunction = theObject->GetFunction(i); - if(aFunction->GetEntry().FindAttribute(GEOM_Function::GetFunctionTreeID(), aNode)) + if (aFunction->GetEntry().FindAttribute(GEOM_Function::GetFunctionTreeID(), aNode)) aNode->Remove(); } TDF_Label aLabel = theObject->GetEntry(); aLabel.ForgetAllAttributes(Standard_True); + _lastCleared = aLabel; theObject.Nullify(); diff --git a/src/GEOM/GEOM_Engine.hxx b/src/GEOM/GEOM_Engine.hxx index d3fe9a3f7..52d418dd0 100644 --- a/src/GEOM/GEOM_Engine.hxx +++ b/src/GEOM/GEOM_Engine.hxx @@ -30,6 +30,7 @@ #include #include #include +#include class GEOM_Engine { @@ -102,7 +103,7 @@ class GEOM_Engine Resource_DataMapOfAsciiStringAsciiString _studyEntry2NameMap; - int _lastObjectTag; + TDF_Label _lastCleared; }; #endif -- 2.39.2