Salome HOME
PAL16617 (Modification/Transformation operations with copy don't create a new mesh)
authoreap <eap@opencascade.com>
Wed, 19 Dec 2007 15:05:55 +0000 (15:05 +0000)
committereap <eap@opencascade.com>
Wed, 19 Dec 2007 15:05:55 +0000 (15:05 +0000)
+  QString UniqueMeshName(const char* theBaseName, const char* thePostfix);

src/SMESHGUI/SMESHGUI_MeshUtils.cxx
src/SMESHGUI/SMESHGUI_MeshUtils.h

index b8e5c305577653443872bd72959ded9e0f944eca..ccbdaff7d5855e096ec46ea9cdd8bcc07e2902a8 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "SMESHGUI_MeshUtils.h"
 #include "SMESHGUI_Utils.h"
+#include "SALOMEDSClient_Study.hxx"
 
 #include "SALOMEconfig.h"
 #include CORBA_SERVER_HEADER(SMESH_Group)
@@ -44,4 +45,27 @@ namespace SMESH
     return SMESH_Mesh::_nil();
   }
 
+  QString UniqueMeshName(const char* theBaseName, const char* thePostfix)
+  {
+    QString baseName = theBaseName;
+    if ( thePostfix/* && !name.contains( postfix )*/) { // add postfix
+      baseName += "_";
+      baseName += thePostfix;
+    }
+    if(_PTR(Study) aStudy = GetActiveStudyDocument()) {
+      QString name = baseName;
+      while ( !aStudy->FindObjectByName( name.latin1(), "SMESH" ).empty() ) {
+        int nb = 0;
+        if ( name[ name.length()-1 ].isNumber() ) {
+          int nbBeg = name.findRev("_");
+          nb = name.right( name.length() - nbBeg - 1 ).toInt();
+          name = name.left( nbBeg );
+        }
+        name += QString("_%1").arg( nb+1 );
+      }
+      return name;
+    }
+    return QString("");
+  }
+
 }
index 81cdb67c1c67b0f8b3c180201c7675d14f16c00e..c7e93a0659ed8d1a0037d06cbb9492d703267167 100644 (file)
 #include "SALOMEconfig.h"
 #include CORBA_SERVER_HEADER(SMESH_Mesh)
 
+#include <qstring.h>
+
 
 namespace SMESH{
 
 SMESHGUI_EXPORT
   SMESH_Mesh_var GetMeshByIO(const Handle(SALOME_InteractiveObject)& theIO);
 
+  QString UniqueMeshName(const char* theBaseName, const char* thePostfix);
 }