From 4c604aa71201fd8552991b413aecb20c3a1079d2 Mon Sep 17 00:00:00 2001 From: ptv Date: Tue, 15 Sep 2009 07:51:41 +0000 Subject: [PATCH] avoid FPE exception --- src/StdMeshers/StdMeshers_MEFISTO_2D.cxx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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); -- 2.39.2