_OCAFApp = new GEOM_Application();
_UndoLimit = 10;
+ _lastObjectTag = 0;
}
//=============================================================================
//=============================================================================
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());
+ Handle(TDocStd_Document) aDoc = GetDocument(theDocID);
+ Handle(TDataStd_TreeNode) aRoot = TDataStd_TreeNode::Set(aDoc->Main());
- TDF_Label aChild = TDF_TagSource::NewChild(aDoc->Main());
- Handle(GEOM_Object) anObject = new GEOM_Object(aChild, theType);
+ //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())) {
+ useExisting = true;
+ }
+ }
+ if (!useExisting) {
+ // create new label
+ aChild = TDF_TagSource::NewChild(aDoc->Main());
+ _lastObjectTag = aChild.Tag();
+ }
+
+ Handle(GEOM_Object) anObject = new GEOM_Object(aChild, theType);
- //Put an object in the map of created objects
- TCollection_AsciiString anID = BuildIDFromObject(anObject);
- if(_objects.IsBound(anID)) _objects.UnBind(anID);
- _objects.Bind(anID, anObject);
+ //Put an object in the map of created objects
+ TCollection_AsciiString anID = BuildIDFromObject(anObject);
+ if(_objects.IsBound(anID)) _objects.UnBind(anID);
+ _objects.Bind(anID, anObject);
- return anObject;
+ return anObject;
}
//=============================================================================
Handle(TDocStd_Document) aDoc = GetDocument(theMainShape->GetDocID());
Handle(TDataStd_TreeNode) aRoot = TDataStd_TreeNode::Set(aDoc->Main());
- TDF_Label aChild = TDF_TagSource::NewChild(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())) {
+ useExisting = true;
+ }
+ }
+ if (!useExisting) {
+ // create new label
+ aChild = TDF_TagSource::NewChild(aDoc->Main());
+ _lastObjectTag = aChild.Tag();
+ }
Handle(GEOM_Function) aMainShape = theMainShape->GetLastFunction();
Handle(GEOM_Object) anObject = new GEOM_Object(aChild, 28); //28 is SUBSHAPE type
//=============================================================================
/*!
- * AboutOperation
+ * AbortOperation
*/
//=============================================================================
void GEOM_IOperations_i::AbortOperation()
if(theObject.IsNull()) return NULL;
TCollection_AsciiString anEntry;
TDF_Tool::Entry(theObject->GetEntry(), anEntry);
- GEOM::GEOM_Object_var GO = GEOM::GEOM_Object::_duplicate(_engine->GetObject(theObject->GetDocID(), anEntry.ToCString()));
+ GEOM::GEOM_Object_var GO = _engine->GetObject(theObject->GetDocID(), anEntry.ToCString());
return GO._retn();
}