mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-04-12 12:17:27 +05:00
Dump Python: respect dump names of GEOM to avoid same names of different objects.
This commit is contained in:
parent
c243d4eb63
commit
01952c2742
@ -494,8 +494,6 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
|
|||||||
else
|
else
|
||||||
aScript += "\n\tsmesh.SetCurrentStudy(None)";
|
aScript += "\n\tsmesh.SetCurrentStudy(None)";
|
||||||
|
|
||||||
TCollection_AsciiString globalVars;
|
|
||||||
|
|
||||||
// Dump trace of restored study
|
// Dump trace of restored study
|
||||||
if (theSavedTrace.Length() > 0) {
|
if (theSavedTrace.Length() > 0) {
|
||||||
aScript += "\n";
|
aScript += "\n";
|
||||||
@ -520,42 +518,50 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
|
|||||||
GEOM::GEOM_Gen_ptr geom = GetGeomEngine();
|
GEOM::GEOM_Gen_ptr geom = GetGeomEngine();
|
||||||
TColStd_SequenceOfAsciiString seqRemoved;
|
TColStd_SequenceOfAsciiString seqRemoved;
|
||||||
Resource_DataMapOfAsciiStringAsciiString mapRemoved;
|
Resource_DataMapOfAsciiStringAsciiString mapRemoved;
|
||||||
Resource_DataMapOfAsciiStringAsciiString aNames;
|
|
||||||
Standard_Integer objectCounter = 0, aStart = 1, aScriptLength = aScript.Length();
|
Standard_Integer objectCounter = 0, aStart = 1, aScriptLength = aScript.Length();
|
||||||
TCollection_AsciiString anUpdatedScript, anEntry, aName, aBaseName("smeshObj_");
|
TCollection_AsciiString anUpdatedScript, anEntry, aName, aBaseName("smeshObj_");
|
||||||
|
|
||||||
|
// Collect names of GEOM objects to exclude same names for SMESH objects
|
||||||
|
GEOM::string_array_var aGeomNames = geom->GetAllDumpNames();
|
||||||
|
int ign = 0, nbgn = aGeomNames->length();
|
||||||
|
for (; ign < nbgn; ign++) {
|
||||||
|
aName = aGeomNames[ign];
|
||||||
|
theObjectNames.Bind(aName, "1");
|
||||||
|
}
|
||||||
|
|
||||||
for (Standard_Integer i = 1; i <= aLen; i += 2) {
|
for (Standard_Integer i = 1; i <= aLen; i += 2) {
|
||||||
anUpdatedScript += aScript.SubString(aStart, aSeq->Value(i) - 1);
|
anUpdatedScript += aScript.SubString(aStart, aSeq->Value(i) - 1);
|
||||||
anEntry = aScript.SubString(aSeq->Value(i), aSeq->Value(i + 1));
|
anEntry = aScript.SubString(aSeq->Value(i), aSeq->Value(i + 1));
|
||||||
if (theObjectNames.IsBound(anEntry)) {
|
// is a GEOM object?
|
||||||
aName = theObjectNames.Find(anEntry);
|
aName = geom->GetDumpName( anEntry.ToCString() );
|
||||||
if (theObjectNames.IsBound(aName) && anEntry != theObjectNames(aName)) {
|
if (aName.IsEmpty()) {
|
||||||
// diff objects have same name - make a new name
|
// is a SMESH object
|
||||||
TCollection_AsciiString aName2;
|
if (theObjectNames.IsBound(anEntry)) {
|
||||||
Standard_Integer i = 0;
|
// The Object is in Study
|
||||||
do {
|
aName = theObjectNames.Find(anEntry);
|
||||||
aName2 = aName + "_" + ++i;
|
if (theObjectNames.IsBound(aName) && anEntry != theObjectNames(aName)) {
|
||||||
} while (theObjectNames.IsBound(aName2) && anEntry != theObjectNames(aName2));
|
// diff objects have same name - make a new name
|
||||||
aName = aName2;
|
TCollection_AsciiString aName2;
|
||||||
theObjectNames(anEntry) = aName;
|
Standard_Integer i = 0;
|
||||||
}
|
do {
|
||||||
} else {
|
aName2 = aName + "_" + ++i;
|
||||||
// is a GEOM object?
|
} while (theObjectNames.IsBound(aName2) && anEntry != theObjectNames(aName2));
|
||||||
aName = geom->GetDumpName( anEntry.ToCString() );
|
aName = aName2;
|
||||||
if ( aName.IsEmpty() ) {
|
theObjectNames(anEntry) = aName;
|
||||||
// ? Removed Object ?
|
}
|
||||||
|
} else {
|
||||||
|
// Removed Object
|
||||||
do {
|
do {
|
||||||
aName = aBaseName + TCollection_AsciiString(++objectCounter);
|
aName = aBaseName + TCollection_AsciiString(++objectCounter);
|
||||||
} while (theObjectNames.IsBound(aName));
|
} while (theObjectNames.IsBound(aName));
|
||||||
seqRemoved.Append(aName);
|
seqRemoved.Append(aName);
|
||||||
mapRemoved.Bind(anEntry, "1");
|
mapRemoved.Bind(anEntry, "1");
|
||||||
|
theObjectNames.Bind(anEntry, aName);
|
||||||
}
|
}
|
||||||
theObjectNames.Bind(anEntry, aName);
|
theObjectNames.Bind(aName, anEntry); // to detect same name of diff objects
|
||||||
}
|
}
|
||||||
theObjectNames.Bind(aName, anEntry); // to detect same name of diff objects
|
|
||||||
|
|
||||||
anUpdatedScript += aName;
|
anUpdatedScript += aName;
|
||||||
aNames.Bind(aName, "1");
|
|
||||||
aStart = aSeq->Value(i + 1) + 1;
|
aStart = aSeq->Value(i + 1) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user