Salome HOME
Dump Python. Solve pb of dif objects having same name. Correct entry detection
authoreap <eap@opencascade.com>
Thu, 17 Mar 2005 08:20:47 +0000 (08:20 +0000)
committereap <eap@opencascade.com>
Thu, 17 Mar 2005 08:20:47 +0000 (08:20 +0000)
src/GEOM/GEOM_Engine.cxx

index e945d9853170833aec45d8b68ccb97754fe872ec..a840c694515bbac212323d18c26dc4281fca9599 100644 (file)
@@ -395,18 +395,31 @@ TCollection_AsciiString GEOM_Engine::DumpPython(int theDocID,
     anUpdatedScript += aScript.SubString(aStart, aSeq->Value(i)-1);
     anEntry = aScript.SubString(aSeq->Value(i), aSeq->Value(i+1));
     if(theObjectNames.IsBound(anEntry)) {
-      aName = theObjectNames.Find(anEntry); 
+      aName = theObjectNames.Find(anEntry);
+      if ( theObjectNames.IsBound( aName ) && anEntry != theObjectNames( aName ))
+      {  // diff objects have same name - make a new name
+        TCollection_AsciiString aName2;
+        Standard_Integer i = 0;
+        do {
+          aName2 = aName + "_" + ++i;
+        } while ( theObjectNames.IsBound( aName2 ) && anEntry != theObjectNames( aName2 ));
+        aName = aName2;
+        theObjectNames( anEntry ) = aName;
+      }
     }
     else {
-      aName = aBaseName + TCollection_AsciiString(++objectCounter);
-      while(theObjectNames.IsBound(aName)) aName = aBaseName + TCollection_AsciiString(++objectCounter);
+      do {
+        aName = aBaseName + TCollection_AsciiString(++objectCounter);
+      } while(theObjectNames.IsBound(aName));
+      theObjectNames.Bind(anEntry, aName);
     }
+    theObjectNames.Bind(aName, anEntry); // to detect same name of diff objects
 
     anUpdatedScript += aName;
     aNames.Bind(aName, "1");
     aStart = aSeq->Value(i+1) + 1;
   }
+
   //Add final part of the script
   if(aSeq->Value(aLen) < aScriptLength)  anUpdatedScript += aScript.SubString(aSeq->Value(aLen)+1, aScriptLength);
  
@@ -474,7 +487,7 @@ Handle(TColStd_HSequenceOfInteger) FindEntries(TCollection_AsciiString& theStrin
        if(c == 58) isFound = Standard_True;
       }
       
-      if(isFound) {
+      if(isFound && arr[j-2] != 58) { // last char should be a diggit
        aSeq->Append(i+1); // +1 because AsciiString starts from 1
        aSeq->Append(j-1);
       }