0021336: EDF 1717 SMESH: New algorithm "body fitting" cartesian unstructured

Shorten long python names like CartesianParameters3D_400_400_400_1000000_1
This commit is contained in:
eap 2011-11-03 09:47:29 +00:00
parent adefda0404
commit 0a1c58ac8b

View File

@ -708,20 +708,28 @@ namespace {
const TCollection_AsciiString allowedChars =
"qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM0987654321_";
bool isValidName = true;
int p=1; // replace not allowed chars with underscore
int nbUnderscore = 0;
int p=1; // replace not allowed chars by underscore
while (p <= aName.Length() &&
(p = aName.FirstLocationNotInSet(allowedChars, p, aName.Length())))
{
if ( p == 1 || p == aName.Length() || aName.Value(p-1) == '_')
aName.Remove( p, 1 ); // remove double _ and from the start and the end
else
aName.SetValue(p, '_');
aName.SetValue(p, '_'), nbUnderscore++;
isValidName = false;
}
if ( aName.IsIntegerValue() ) { // aName must not start with a digit
aName.Insert( 1, 'a' );
isValidName = false;
}
// shorten names like CartesianParameters3D_400_400_400_1000000_1
if ( aName.Length() > 20 && nbUnderscore > 2 )
{
p = aName.Location( "_", 20, aName.Length());
if ( p > 1 )
aName.Trunc( p-1 );
}
return isValidName;
}
}