Salome HOME
0020431: EDF 1020 SMESH : Radial Mesh of a cylinder
[modules/smesh.git] / src / StdMeshers / StdMeshers_MEFISTO_2D.cxx
index 23582d72eda627e1dcbccb2159afea69092876f5..f913336ebc399f4b4e519934a8b55b2f4f12c5ab 100644 (file)
@@ -53,6 +53,7 @@
 #include <Geom_Curve.hxx>
 #include <Geom2d_Curve.hxx>
 #include <Geom_Surface.hxx>
+#include <Precision.hxx>
 #include <TopExp.hxx>
 #include <TopExp_Explorer.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
@@ -295,15 +296,15 @@ bool StdMeshers_MEFISTO_2D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aSh
 //=============================================================================
 
 bool StdMeshers_MEFISTO_2D::Evaluate(SMESH_Mesh & aMesh,
-                                    const TopoDS_Shape & aShape,
-                                    MapShapeNbElems& aResMap)
+                                     const TopoDS_Shape & aShape,
+                                     MapShapeNbElems& aResMap)
 {
   MESSAGE("StdMeshers_MEFISTO_2D::Evaluate");
 
   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,27 @@ bool StdMeshers_MEFISTO_2D::Evaluate(SMESH_Mesh & aMesh,
       P1 = P2;
     }
   }
+  if(NbSeg<1) {
+    std::vector<int> aResVec(SMDSEntity_Last);
+    for(int i=SMDSEntity_Node; i<SMDSEntity_Last; i++) aResVec[i] = 0;
+    SMESH_subMesh * sm = aMesh.GetSubMesh(aShape);
+    aResMap.insert(std::make_pair(sm,aResVec));
+    SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
+    smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED,
+                                          "Submesh can not be evaluated",this));
+    return false;
+  }
   aLen = aLen/NbSeg; // middle length
 
-  _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<int> aVec(SMDSEntity_Last);