+ 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("");
+ }
+