mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-11-15 01:58:36 +05:00
Bug 0020065: EDF 876 GEOM : Deleting an object leads to unusable dump.
This commit is contained in:
parent
2ca357cd29
commit
b19d40e8dd
@ -84,9 +84,9 @@ static Standard_Integer ExtractDocID(TCollection_AsciiString& theID)
|
|||||||
return aDocID.IntegerValue();
|
return aDocID.IntegerValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessFunction(Handle(GEOM_Function)& theFunction,
|
void ProcessFunction(Handle(GEOM_Function)& theFunction,
|
||||||
TCollection_AsciiString& theScript,
|
TCollection_AsciiString& theScript,
|
||||||
TColStd_MapOfTransient& theProcessed);
|
TColStd_MapOfTransient& theProcessed);
|
||||||
|
|
||||||
Handle(TColStd_HSequenceOfInteger) FindEntries(TCollection_AsciiString& theString);
|
Handle(TColStd_HSequenceOfInteger) FindEntries(TCollection_AsciiString& theString);
|
||||||
|
|
||||||
@ -122,9 +122,9 @@ GEOM_Engine::GEOM_Engine()
|
|||||||
* Destructor
|
* Destructor
|
||||||
*/
|
*/
|
||||||
GEOM_Engine::~GEOM_Engine()
|
GEOM_Engine::~GEOM_Engine()
|
||||||
{
|
{
|
||||||
GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient It(_objects);
|
GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient It(_objects);
|
||||||
for(; It.More(); It.Next())
|
for(; It.More(); It.Next())
|
||||||
{
|
{
|
||||||
RemoveObject(Handle(GEOM_Object)::DownCast(It.Value()));
|
RemoveObject(Handle(GEOM_Object)::DownCast(It.Value()));
|
||||||
}
|
}
|
||||||
@ -231,9 +231,9 @@ Handle(GEOM_Object) GEOM_Engine::AddObject(int theDocID, int theType)
|
|||||||
* AddSubShape
|
* AddSubShape
|
||||||
*/
|
*/
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
Handle(GEOM_Object) GEOM_Engine::AddSubShape(Handle(GEOM_Object) theMainShape,
|
Handle(GEOM_Object) GEOM_Engine::AddSubShape(Handle(GEOM_Object) theMainShape,
|
||||||
Handle(TColStd_HArray1OfInteger) theIndices,
|
Handle(TColStd_HArray1OfInteger) theIndices,
|
||||||
bool isStandaloneOperation)
|
bool isStandaloneOperation)
|
||||||
{
|
{
|
||||||
if(theMainShape.IsNull() || theIndices.IsNull()) return NULL;
|
if(theMainShape.IsNull() || theIndices.IsNull()) return NULL;
|
||||||
|
|
||||||
@ -286,7 +286,7 @@ Handle(GEOM_Object) GEOM_Engine::AddSubShape(Handle(GEOM_Object) theMainShape,
|
|||||||
_objects.Bind(anID, anObject);
|
_objects.Bind(anID, anObject);
|
||||||
|
|
||||||
GEOM::TPythonDump pd (aFunction);
|
GEOM::TPythonDump pd (aFunction);
|
||||||
|
|
||||||
if (isStandaloneOperation) {
|
if (isStandaloneOperation) {
|
||||||
pd << anObject << " = geompy.GetSubShape(" << theMainShape << ", [";
|
pd << anObject << " = geompy.GetSubShape(" << theMainShape << ", [";
|
||||||
Standard_Integer i = theIndices->Lower(), up = theIndices->Upper();
|
Standard_Integer i = theIndices->Lower(), up = theIndices->Upper();
|
||||||
@ -318,7 +318,7 @@ bool GEOM_Engine::RemoveObject(Handle(GEOM_Object) theObject)
|
|||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -421,23 +421,23 @@ void GEOM_Engine::Close(int theDocID)
|
|||||||
* DumpPython
|
* DumpPython
|
||||||
*/
|
*/
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID,
|
TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID,
|
||||||
Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
|
Resource_DataMapOfAsciiStringAsciiString& theObjectNames,
|
||||||
bool isPublished,
|
bool isPublished,
|
||||||
bool& aValidScript)
|
bool& aValidScript)
|
||||||
{
|
{
|
||||||
TCollection_AsciiString aScript;
|
TCollection_AsciiString aScript;
|
||||||
Handle(TDocStd_Document) aDoc = GetDocument(theDocID);
|
Handle(TDocStd_Document) aDoc = GetDocument(theDocID);
|
||||||
|
|
||||||
if(aDoc.IsNull()) return TCollection_AsciiString("def RebuildData(theStudy): pass\n");
|
if(aDoc.IsNull()) return TCollection_AsciiString("def RebuildData(theStudy): pass\n");
|
||||||
|
|
||||||
aScript = "import geompy\n";
|
aScript = "import geompy\n";
|
||||||
aScript += "import math\n";
|
aScript += "import math\n";
|
||||||
aScript += "import SALOMEDS\n\n";
|
aScript += "import SALOMEDS\n\n";
|
||||||
aScript += "def RebuildData(theStudy):";
|
aScript += "def RebuildData(theStudy):";
|
||||||
aScript += "\n\tgeompy.init_geom(theStudy)";
|
aScript += "\n\tgeompy.init_geom(theStudy)";
|
||||||
|
|
||||||
Standard_Integer posToInertGlobalVars = aScript.Length() + 1;
|
Standard_Integer posToInsertGlobalVars = aScript.Length() + 1;
|
||||||
|
|
||||||
Handle(TDataStd_TreeNode) aNode, aRoot;
|
Handle(TDataStd_TreeNode) aNode, aRoot;
|
||||||
Handle(GEOM_Function) aFunction;
|
Handle(GEOM_Function) aFunction;
|
||||||
@ -449,8 +449,8 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID,
|
|||||||
aNode = Itr.Value();
|
aNode = Itr.Value();
|
||||||
aFunction = GEOM_Function::GetFunction(aNode->Label());
|
aFunction = GEOM_Function::GetFunction(aNode->Label());
|
||||||
if(aFunction.IsNull()) {
|
if(aFunction.IsNull()) {
|
||||||
MESSAGE ( "Null function !!!!" );
|
MESSAGE ( "Null function !!!!" );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ProcessFunction(aFunction, aScript, aMap);
|
ProcessFunction(aFunction, aScript, aMap);
|
||||||
}
|
}
|
||||||
@ -532,8 +532,9 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Add final part of the script
|
//Add final part of the script
|
||||||
if(aLen && aSeq->Value(aLen) < aScriptLength) anUpdatedScript += aScript.SubString(aSeq->Value(aLen)+1, aScriptLength); // mkr : IPAL11865
|
if (aLen && aSeq->Value(aLen) < aScriptLength)
|
||||||
|
anUpdatedScript += aScript.SubString(aSeq->Value(aLen)+1, aScriptLength); // mkr : IPAL11865
|
||||||
|
|
||||||
// ouv : NPAL12872
|
// ouv : NPAL12872
|
||||||
for (anEntryToNameIt.Initialize( theObjectNames );
|
for (anEntryToNameIt.Initialize( theObjectNames );
|
||||||
anEntryToNameIt.More();
|
anEntryToNameIt.More();
|
||||||
@ -598,7 +599,7 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID,
|
|||||||
aCommand += "addToStudy( ";
|
aCommand += "addToStudy( ";
|
||||||
if ( anEntryToBadName.IsBound( aEntry ))
|
if ( anEntryToBadName.IsBound( aEntry ))
|
||||||
aCommand += aName + ", \"" + anEntryToBadName( aEntry ) + "\" )";
|
aCommand += aName + ", \"" + anEntryToBadName( aEntry ) + "\" )";
|
||||||
else
|
else
|
||||||
aCommand += aName + ", \"" + aName + "\" )";
|
aCommand += aName + ", \"" + aName + "\" )";
|
||||||
|
|
||||||
// bind a command to the last digit of the entry
|
// bind a command to the last digit of the entry
|
||||||
@ -633,15 +634,15 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID,
|
|||||||
}
|
}
|
||||||
if ( !globalVars.IsEmpty() ) {
|
if ( !globalVars.IsEmpty() ) {
|
||||||
globalVars.Insert( 1, "\n\tglobal " );
|
globalVars.Insert( 1, "\n\tglobal " );
|
||||||
anUpdatedScript.Insert( posToInertGlobalVars, globalVars );
|
anUpdatedScript.Insert( posToInsertGlobalVars, globalVars );
|
||||||
}
|
}
|
||||||
|
|
||||||
return anUpdatedScript;
|
return anUpdatedScript;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : GetDumpName
|
//function : GetDumpName
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
const char* GEOM_Engine::GetDumpName (const char* theStudyEntry) const
|
const char* GEOM_Engine::GetDumpName (const char* theStudyEntry) const
|
||||||
@ -654,7 +655,7 @@ const char* GEOM_Engine::GetDumpName (const char* theStudyEntry) const
|
|||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : GetAllDumpNames
|
//function : GetAllDumpNames
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
Handle(TColStd_HSequenceOfAsciiString) GEOM_Engine::GetAllDumpNames() const
|
Handle(TColStd_HSequenceOfAsciiString) GEOM_Engine::GetAllDumpNames() const
|
||||||
@ -673,9 +674,9 @@ Handle(TColStd_HSequenceOfAsciiString) GEOM_Engine::GetAllDumpNames() const
|
|||||||
//===========================================================================
|
//===========================================================================
|
||||||
// Internal functions
|
// Internal functions
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void ProcessFunction(Handle(GEOM_Function)& theFunction,
|
void ProcessFunction(Handle(GEOM_Function)& theFunction,
|
||||||
TCollection_AsciiString& theScript,
|
TCollection_AsciiString& theScript,
|
||||||
TColStd_MapOfTransient& theProcessed)
|
TColStd_MapOfTransient& theProcessed)
|
||||||
{
|
{
|
||||||
if(theFunction.IsNull() || theProcessed.Contains(theFunction)) return;
|
if(theFunction.IsNull() || theProcessed.Contains(theFunction)) return;
|
||||||
|
|
||||||
@ -683,26 +684,41 @@ void ProcessFunction(Handle(GEOM_Function)& theFunction,
|
|||||||
TDF_LabelSequence aSeq;
|
TDF_LabelSequence aSeq;
|
||||||
theFunction->GetDependency(aSeq);
|
theFunction->GetDependency(aSeq);
|
||||||
Standard_Integer aLen = aSeq.Length();
|
Standard_Integer aLen = aSeq.Length();
|
||||||
for(Standard_Integer i = 1; i<= aLen; i++) {
|
for(Standard_Integer i = 1; i <= aLen; i++) {
|
||||||
Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(aSeq.Value(i));
|
Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(aSeq.Value(i));
|
||||||
if(aFunction.IsNull()) continue;
|
if(aFunction.IsNull()) continue;
|
||||||
ProcessFunction(aFunction, theScript, theProcessed);
|
ProcessFunction(aFunction, theScript, theProcessed);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// pass functions, that depends on nonexisting ones
|
||||||
|
//jfa:test//bool doComment = false;
|
||||||
|
TDF_LabelSequence aSeq;
|
||||||
|
theFunction->GetDependency(aSeq);
|
||||||
|
Standard_Integer aLen = aSeq.Length();
|
||||||
|
//jfa:test//for (Standard_Integer i = 1; i <= aLen && !doComment; i++) {
|
||||||
|
for (Standard_Integer i = 1; i <= aLen; i++) {
|
||||||
|
Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(aSeq.Value(i));
|
||||||
|
//jfa:test//if (aFunction.IsNull()) doComment = true;
|
||||||
|
//jfa:test//else if (!theProcessed.Contains(aFunction)) doComment = true;
|
||||||
|
if (aFunction.IsNull()) return;
|
||||||
|
if (!theProcessed.Contains(aFunction)) return;
|
||||||
|
}
|
||||||
|
|
||||||
TCollection_AsciiString aDescr = theFunction->GetDescription();
|
TCollection_AsciiString aDescr = theFunction->GetDescription();
|
||||||
if(aDescr.Length() == 0) {
|
if(aDescr.Length() == 0) {
|
||||||
//cout << "Warning: the function has no description" << endl;
|
//cout << "Warning: the function has no description" << endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check if its internal function which doesn't requires dumping
|
//Check if its internal function which doesn't requires dumping
|
||||||
if(aDescr == "None") return;
|
if(aDescr == "None") return;
|
||||||
|
|
||||||
theScript += "\n\t";
|
theScript += "\n\t";
|
||||||
|
//jfa:test//if (doComment) theScript += "#";
|
||||||
theScript += aDescr;
|
theScript += aDescr;
|
||||||
|
|
||||||
theProcessed.Add(theFunction);
|
theProcessed.Add(theFunction);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
@ -723,19 +739,19 @@ Handle(TColStd_HSequenceOfInteger) FindEntries(TCollection_AsciiString& theStrin
|
|||||||
int c = (int)arr[i];
|
int c = (int)arr[i];
|
||||||
j = i+1;
|
j = i+1;
|
||||||
if(c >= 48 && c <= 57) { //Is digit?
|
if(c >= 48 && c <= 57) { //Is digit?
|
||||||
|
|
||||||
isFound = Standard_False;
|
isFound = Standard_False;
|
||||||
while((j < aLen) && ((c >= 48 && c <= 57) || c == 58) ) { //Check if it is an entry
|
while((j < aLen) && ((c >= 48 && c <= 57) || c == 58) ) { //Check if it is an entry
|
||||||
c = (int)arr[j++];
|
c = (int)arr[j++];
|
||||||
if(c == 58) isFound = Standard_True;
|
if(c == 58) isFound = Standard_True;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isFound && arr[j-2] != 58) { // last char should be a diggit
|
if(isFound && arr[j-2] != 58) { // last char should be a diggit
|
||||||
aSeq->Append(i+1); // +1 because AsciiString starts from 1
|
aSeq->Append(i+1); // +1 because AsciiString starts from 1
|
||||||
aSeq->Append(j-1);
|
aSeq->Append(j-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
i = j;
|
i = j;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user