NPAL18604: Pb. of performance with MakeVertex. Fixed a bug from previous integration.

This commit is contained in:
jfa 2008-01-28 09:35:37 +00:00
parent e673545f08
commit e170a5ac49
2 changed files with 16 additions and 16 deletions

View File

@ -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();
@ -306,6 +304,7 @@ bool GEOM_Engine::RemoveObject(Handle(GEOM_Object) theObject)
TDF_Label aLabel = theObject->GetEntry();
aLabel.ForgetAllAttributes(Standard_True);
_lastCleared = aLabel;
theObject.Nullify();

View File

@ -30,6 +30,7 @@
#include <TDocStd_Document.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <TColStd_HSequenceOfAsciiString.hxx>
#include <TDF_Label.hxx>
class GEOM_Engine
{
@ -102,7 +103,7 @@ class GEOM_Engine
Resource_DataMapOfAsciiStringAsciiString _studyEntry2NameMap;
int _lastObjectTag;
TDF_Label _lastCleared;
};
#endif