0021021: EDF 1586 SMESH: Memory saturation when using start and end length

protect from too large segment lengths with geometric and
     arithmetic progression hypotheses
This commit is contained in:
eap 2010-10-06 08:42:50 +00:00
parent 489ea51f65
commit b17ca59357

View File

@ -731,6 +731,9 @@ bool StdMeshers_Regular_1D::computeInternalParameters(SMESH_Mesh & theMesh,
double a1 = _value[ BEG_LENGTH_IND ]; double a1 = _value[ BEG_LENGTH_IND ];
double an = _value[ END_LENGTH_IND ]; double an = _value[ END_LENGTH_IND ];
double q = ( theLength - a1 ) / ( theLength - an ); double q = ( theLength - a1 ) / ( theLength - an );
if ( q < theLength/1e6 || 1.01*theLength < a1 + an)
return error ( SMESH_Comment("Invalid segment lengths (")<<a1<<" and "<<an<<") "<<
"for an edge of length "<<theLength);
double U1 = theReverse ? l : f; double U1 = theReverse ? l : f;
double Un = theReverse ? f : l; double Un = theReverse ? f : l;
@ -759,6 +762,9 @@ bool StdMeshers_Regular_1D::computeInternalParameters(SMESH_Mesh & theMesh,
double a1 = _value[ BEG_LENGTH_IND ]; double a1 = _value[ BEG_LENGTH_IND ];
double an = _value[ END_LENGTH_IND ]; double an = _value[ END_LENGTH_IND ];
if ( 1.01*theLength < a1 + an)
return error ( SMESH_Comment("Invalid segment lengths (")<<a1<<" and "<<an<<") "<<
"for an edge of length "<<theLength);
double q = ( an - a1 ) / ( 2 *theLength/( a1 + an ) - 1 ); double q = ( an - a1 ) / ( 2 *theLength/( a1 + an ) - 1 );
int n = int(fabs(q) > numeric_limits<double>::min() ? ( 1+( an-a1 )/q ) : ( 1+theLength/a1 )); int n = int(fabs(q) > numeric_limits<double>::min() ? ( 1+( an-a1 )/q ) : ( 1+theLength/a1 ));