From 0a1c58ac8b840aa1858a80c6282304b599de3cfa Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 3 Nov 2011 09:47:29 +0000 Subject: [PATCH] 0021336: EDF 1717 SMESH: New algorithm "body fitting" cartesian unstructured Shorten long python names like CartesianParameters3D_400_400_400_1000000_1 --- src/SMESH_I/SMESH_DumpPython.cxx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/SMESH_I/SMESH_DumpPython.cxx b/src/SMESH_I/SMESH_DumpPython.cxx index 680d724eb..87d876758 100644 --- a/src/SMESH_I/SMESH_DumpPython.cxx +++ b/src/SMESH_I/SMESH_DumpPython.cxx @@ -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; } } -- 2.39.2