From: ptv Date: Tue, 15 Sep 2009 07:51:41 +0000 (+0000) Subject: avoid FPE exception X-Git-Tag: V5_1_3rc1~56 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4c604aa71201fd8552991b413aecb20c3a1079d2;p=modules%2Fsmesh.git avoid FPE exception --- diff --git a/src/StdMeshers/StdMeshers_MEFISTO_2D.cxx b/src/StdMeshers/StdMeshers_MEFISTO_2D.cxx index 23582d72e..6a84ee7b8 100644 --- a/src/StdMeshers/StdMeshers_MEFISTO_2D.cxx +++ b/src/StdMeshers/StdMeshers_MEFISTO_2D.cxx @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -303,7 +304,7 @@ bool StdMeshers_MEFISTO_2D::Evaluate(SMESH_Mesh & aMesh, TopoDS_Face F = TopoDS::Face(aShape.Oriented(TopAbs_FORWARD)); double aLen = 0.0; - double NbSeg = 0; + int NbSeg = 0; bool IsQuadratic = false; bool IsFirst = true; TopExp_Explorer exp(F,TopAbs_EDGE); @@ -331,16 +332,20 @@ bool StdMeshers_MEFISTO_2D::Evaluate(SMESH_Mesh & aMesh, P1 = P2; } } - aLen = aLen/NbSeg; // middle length + if ( NbSeg > 0 ) + aLen = aLen/NbSeg; // middle length + else + aLen = Precision::Infinite(); - _edgeLength = DBL_MAX; + _edgeLength = Precision::Infinite(); double tmpLength = Min( _edgeLength, aLen ); GProp_GProps G; BRepGProp::SurfaceProperties(aShape,G); double anArea = G.Mass(); - int nbFaces = (int) ( anArea/(tmpLength*tmpLength*sqrt(3.)/4) ); + int nbFaces = Precision::IsInfinite( tmpLength ) ? 0 : + (int)( anArea/(tmpLength*tmpLength*sqrt(3.)/4) ); int nbNodes = (int) ( nbFaces*3 - (NbSeg-1)*2 ) / 6; std::vector aVec(SMDSEntity_Last);