// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
+
#ifdef WNT
#pragma warning( disable:4786 )
#endif
// if this label has been freed (object deleted)
bool useExisting = false;
TDF_Label aChild;
- if (!_lastCleared.IsNull()) {
- if (_lastCleared.Root() == aDoc->Main().Root()) {
+ if (_freeLabels.find(theDocID) != _freeLabels.end()) {
+ std::list<TDF_Label>& aFreeLabels = _freeLabels[theDocID];
+ if (!aFreeLabels.empty()) {
useExisting = true;
- aChild = _lastCleared;
- // 0020229: if next label exists and is empty, try to reuse it
- Standard_Integer aNextTag = aChild.Tag() + 1;
- TDF_Label aNextL = aDoc->Main().FindChild(aNextTag, Standard_False);
- if (!aNextL.IsNull() && !aNextL.HasAttribute())
- _lastCleared = aNextL;
- else
- _lastCleared.Nullify();
+ aChild = aFreeLabels.front();
+ aFreeLabels.pop_front();
}
}
if (!useExisting) {
// if this label has been freed (object deleted)
bool useExisting = false;
TDF_Label aChild;
+ /*
if (!_lastCleared.IsNull()) {
if (_lastCleared.Root() == aDoc->Main().Root()) {
useExisting = true;
_lastCleared.Nullify();
}
}
+ */
+ int aDocID = theMainShape->GetDocID();
+ if (_freeLabels.find(aDocID) != _freeLabels.end()) {
+ std::list<TDF_Label>& aFreeLabels = _freeLabels[aDocID];
+ if (!aFreeLabels.empty()) {
+ useExisting = true;
+ aChild = aFreeLabels.front();
+ aFreeLabels.pop_front();
+ }
+ }
if (!useExisting) {
// create new label
aChild = TDF_TagSource::NewChild(aDoc->Main());
{
if (!theObject) return false;
+ int aDocID = theObject->GetDocID();
+
//Remove an object from the map of available objects
TCollection_AsciiString anID = BuildIDFromObject(theObject);
if (_objects.IsBound(anID)) _objects.UnBind(anID);
TDF_Label aLabel = theObject->GetEntry();
aLabel.ForgetAllAttributes(Standard_True);
- _lastCleared = aLabel;
+
+ // Remember the label to reuse it then
+ std::list<TDF_Label>& aFreeLabels = _freeLabels[aDocID];
+ aFreeLabels.push_back(aLabel);
theObject.Nullify();
}
for (Standard_Integer i=1; i<=aSeq.Length(); i++) _objects.UnBind(aSeq.Value(i));
- _lastCleared.Nullify();
+ // Forget free labels for this document
+ TFreeLabelsList::iterator anIt = _freeLabels.find(theDocID);
+ if (anIt != _freeLabels.end()) {
+ _freeLabels.erase(anIt);
+ }
_mapIDDocument.UnBind(theDocID);
_OCAFApp->Close(aDoc);
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
+
#ifndef _GEOM_Engine_HXX_
#define _GEOM_Engine_HXX_
#include <TDF_Label.hxx>
#include <map>
+#include <list>
#include <vector>
struct TVariable{
typedef std::map<TCollection_AsciiString, ObjectStates* > TVariablesList;
+typedef std::map<int, std::list<TDF_Label> > TFreeLabelsList;
+
class GEOM_Engine
{
public:
Resource_DataMapOfAsciiStringAsciiString _studyEntry2NameMap;
- TDF_Label _lastCleared;
+ TFreeLabelsList _freeLabels;
};
#endif