mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-13 10:10:34 +05:00
Bug 0020229: Perf of MakeSphere and RemoveObject.
This commit is contained in:
parent
090f4cc227
commit
9557a996af
@ -18,7 +18,7 @@
|
|||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
//
|
//
|
||||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
//
|
|
||||||
#ifdef WNT
|
#ifdef WNT
|
||||||
#pragma warning( disable:4786 )
|
#pragma warning( disable:4786 )
|
||||||
#endif
|
#endif
|
||||||
@ -229,17 +229,12 @@ Handle(GEOM_Object) GEOM_Engine::AddObject(int theDocID, int theType)
|
|||||||
// 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 (!_lastCleared.IsNull()) {
|
if (_freeLabels.find(theDocID) != _freeLabels.end()) {
|
||||||
if (_lastCleared.Root() == aDoc->Main().Root()) {
|
std::list<TDF_Label>& aFreeLabels = _freeLabels[theDocID];
|
||||||
|
if (!aFreeLabels.empty()) {
|
||||||
useExisting = true;
|
useExisting = true;
|
||||||
aChild = _lastCleared;
|
aChild = aFreeLabels.front();
|
||||||
// 0020229: if next label exists and is empty, try to reuse it
|
aFreeLabels.pop_front();
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!useExisting) {
|
if (!useExisting) {
|
||||||
@ -275,6 +270,7 @@ Handle(GEOM_Object) GEOM_Engine::AddSubShape(Handle(GEOM_Object) theMainShape,
|
|||||||
// 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 (!_lastCleared.IsNull()) {
|
if (!_lastCleared.IsNull()) {
|
||||||
if (_lastCleared.Root() == aDoc->Main().Root()) {
|
if (_lastCleared.Root() == aDoc->Main().Root()) {
|
||||||
useExisting = true;
|
useExisting = true;
|
||||||
@ -288,6 +284,16 @@ Handle(GEOM_Object) GEOM_Engine::AddSubShape(Handle(GEOM_Object) theMainShape,
|
|||||||
_lastCleared.Nullify();
|
_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) {
|
if (!useExisting) {
|
||||||
// create new label
|
// create new label
|
||||||
aChild = TDF_TagSource::NewChild(aDoc->Main());
|
aChild = TDF_TagSource::NewChild(aDoc->Main());
|
||||||
@ -347,6 +353,8 @@ bool GEOM_Engine::RemoveObject(Handle(GEOM_Object) theObject)
|
|||||||
{
|
{
|
||||||
if (!theObject) return false;
|
if (!theObject) return false;
|
||||||
|
|
||||||
|
int aDocID = theObject->GetDocID();
|
||||||
|
|
||||||
//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);
|
||||||
@ -361,7 +369,10 @@ bool GEOM_Engine::RemoveObject(Handle(GEOM_Object) theObject)
|
|||||||
|
|
||||||
TDF_Label aLabel = theObject->GetEntry();
|
TDF_Label aLabel = theObject->GetEntry();
|
||||||
aLabel.ForgetAllAttributes(Standard_True);
|
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();
|
theObject.Nullify();
|
||||||
|
|
||||||
@ -445,7 +456,11 @@ void GEOM_Engine::Close(int theDocID)
|
|||||||
}
|
}
|
||||||
for (Standard_Integer i=1; i<=aSeq.Length(); i++) _objects.UnBind(aSeq.Value(i));
|
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);
|
_mapIDDocument.UnBind(theDocID);
|
||||||
_OCAFApp->Close(aDoc);
|
_OCAFApp->Close(aDoc);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
//
|
//
|
||||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
//
|
|
||||||
#ifndef _GEOM_Engine_HXX_
|
#ifndef _GEOM_Engine_HXX_
|
||||||
#define _GEOM_Engine_HXX_
|
#define _GEOM_Engine_HXX_
|
||||||
|
|
||||||
@ -34,6 +34,7 @@
|
|||||||
#include <TDF_Label.hxx>
|
#include <TDF_Label.hxx>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <list>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
struct TVariable{
|
struct TVariable{
|
||||||
@ -67,6 +68,8 @@ private:
|
|||||||
|
|
||||||
typedef std::map<TCollection_AsciiString, ObjectStates* > TVariablesList;
|
typedef std::map<TCollection_AsciiString, ObjectStates* > TVariablesList;
|
||||||
|
|
||||||
|
typedef std::map<int, std::list<TDF_Label> > TFreeLabelsList;
|
||||||
|
|
||||||
class GEOM_Engine
|
class GEOM_Engine
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -139,7 +142,7 @@ class GEOM_Engine
|
|||||||
|
|
||||||
Resource_DataMapOfAsciiStringAsciiString _studyEntry2NameMap;
|
Resource_DataMapOfAsciiStringAsciiString _studyEntry2NameMap;
|
||||||
|
|
||||||
TDF_Label _lastCleared;
|
TFreeLabelsList _freeLabels;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user