mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-11-14 17:48:34 +05:00
NPAL18604: Pb. of performance with MakeVertex. Fixed a bug from previous integration.
This commit is contained in:
parent
e673545f08
commit
e170a5ac49
@ -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();
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user