mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-02-22 02:35:37 +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();
|
_OCAFApp = new GEOM_Application();
|
||||||
_UndoLimit = 10;
|
_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(TDocStd_Document) aDoc = GetDocument(theDocID);
|
||||||
Handle(TDataStd_TreeNode) aRoot = TDataStd_TreeNode::Set(aDoc->Main());
|
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,
|
// NPAL18604: use existing label to decrease memory usage,
|
||||||
// if this label has been freed (object deleted)
|
// if this label has been freed (object deleted)
|
||||||
bool useExisting = false;
|
bool useExisting = false;
|
||||||
TDF_Label aChild;
|
TDF_Label aChild;
|
||||||
if (_lastObjectTag > 0) {
|
if (!_lastCleared.IsNull()) {
|
||||||
aChild = aDoc->Main().FindChild(_lastObjectTag, Standard_False);
|
if (_lastCleared.Root() == aDoc->Main().Root()) {
|
||||||
if (!aChild.IsAttribute(TDataStd_TreeNode::GetDefaultTreeID())) {
|
|
||||||
useExisting = true;
|
useExisting = true;
|
||||||
|
aChild = _lastCleared;
|
||||||
|
_lastCleared.Nullify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!useExisting) {
|
if (!useExisting) {
|
||||||
// create new label
|
// create new label
|
||||||
aChild = TDF_TagSource::NewChild(aDoc->Main());
|
aChild = TDF_TagSource::NewChild(aDoc->Main());
|
||||||
_lastObjectTag = aChild.Tag();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle(GEOM_Object) anObject = new GEOM_Object(aChild, theType);
|
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(TDocStd_Document) aDoc = GetDocument(theMainShape->GetDocID());
|
||||||
Handle(TDataStd_TreeNode) aRoot = TDataStd_TreeNode::Set(aDoc->Main());
|
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,
|
// NPAL18604: use existing label to decrease memory usage,
|
||||||
// if this label has been freed (object deleted)
|
// if this label has been freed (object deleted)
|
||||||
bool useExisting = false;
|
bool useExisting = false;
|
||||||
TDF_Label aChild;
|
TDF_Label aChild;
|
||||||
if (_lastObjectTag > 0) {
|
if (!_lastCleared.IsNull()) {
|
||||||
aChild = aDoc->Main().FindChild(_lastObjectTag, Standard_False);
|
if (_lastCleared.Root() == aDoc->Main().Root()) {
|
||||||
if (!aChild.IsAttribute(TDataStd_TreeNode::GetDefaultTreeID())) {
|
|
||||||
useExisting = true;
|
useExisting = true;
|
||||||
|
aChild = _lastCleared;
|
||||||
|
_lastCleared.Nullify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!useExisting) {
|
if (!useExisting) {
|
||||||
// create new label
|
// create new label
|
||||||
aChild = TDF_TagSource::NewChild(aDoc->Main());
|
aChild = TDF_TagSource::NewChild(aDoc->Main());
|
||||||
_lastObjectTag = aChild.Tag();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle(GEOM_Function) aMainShape = theMainShape->GetLastFunction();
|
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)
|
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
|
//Remove an object from the map of available objects
|
||||||
TCollection_AsciiString anID = BuildIDFromObject(theObject);
|
TCollection_AsciiString anID = BuildIDFromObject(theObject);
|
||||||
if(_objects.IsBound(anID)) _objects.UnBind(anID);
|
if (_objects.IsBound(anID)) _objects.UnBind(anID);
|
||||||
|
|
||||||
int nb = theObject->GetNbFunctions();
|
int nb = theObject->GetNbFunctions();
|
||||||
Handle(TDataStd_TreeNode) aNode;
|
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);
|
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();
|
aNode->Remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
TDF_Label aLabel = theObject->GetEntry();
|
TDF_Label aLabel = theObject->GetEntry();
|
||||||
aLabel.ForgetAllAttributes(Standard_True);
|
aLabel.ForgetAllAttributes(Standard_True);
|
||||||
|
_lastCleared = aLabel;
|
||||||
|
|
||||||
theObject.Nullify();
|
theObject.Nullify();
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include <TDocStd_Document.hxx>
|
#include <TDocStd_Document.hxx>
|
||||||
#include <TColStd_HArray1OfInteger.hxx>
|
#include <TColStd_HArray1OfInteger.hxx>
|
||||||
#include <TColStd_HSequenceOfAsciiString.hxx>
|
#include <TColStd_HSequenceOfAsciiString.hxx>
|
||||||
|
#include <TDF_Label.hxx>
|
||||||
|
|
||||||
class GEOM_Engine
|
class GEOM_Engine
|
||||||
{
|
{
|
||||||
@ -102,7 +103,7 @@ class GEOM_Engine
|
|||||||
|
|
||||||
Resource_DataMapOfAsciiStringAsciiString _studyEntry2NameMap;
|
Resource_DataMapOfAsciiStringAsciiString _studyEntry2NameMap;
|
||||||
|
|
||||||
int _lastObjectTag;
|
TDF_Label _lastCleared;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user