Salome HOME
Merge branch 'agy/arch2_ic0'
[modules/smesh.git] / src / StdMeshers / StdMeshers_Regular_1D.cxx
index 6746a502c1daef9cd0bd9655ceae17c87baafcde..c6e41cbb2b48aea869f7ffb67f042a73745e6e0f 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2020  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -78,9 +78,8 @@ using namespace StdMeshers;
 //=============================================================================
 
 StdMeshers_Regular_1D::StdMeshers_Regular_1D(int         hypId,
-                                             int         studyId,
                                              SMESH_Gen * gen)
-  :SMESH_1D_Algo( hypId, studyId, gen )
+  :SMESH_1D_Algo( hypId, gen )
 {
   _name = "Regular_1D";
   _shapeType = (1 << TopAbs_EDGE);
@@ -363,7 +362,10 @@ static bool computeParamByFunc(Adaptor3d_Curve& C3d,
   int nbPnt = 1 + nbSeg;
   vector<double> x( nbPnt, 0. );
 
-  if ( !buildDistribution( func, 0.0, 1.0, nbSeg, x, 1E-4 ))
+
+  const double eps = Min( 1E-4, 1./nbSeg/100. );
+
+  if ( !buildDistribution( func, 0.0, 1.0, nbSeg, x, eps ))
      return false;
 
   // apply parameters in range [0,1] to the space of the curve
@@ -538,7 +540,7 @@ void StdMeshers_Regular_1D::SetEventListener(SMESH_subMesh* subMesh)
  */
 //=============================================================================
 
-void StdMeshers_Regular_1D::SubmeshRestored(SMESH_subMesh* subMesh)
+void StdMeshers_Regular_1D::SubmeshRestored(SMESH_subMesh* /*subMesh*/)
 {
 }
 
@@ -629,7 +631,7 @@ void StdMeshers_Regular_1D::redistributeNearVertices (SMESH_Mesh &          theM
         double L = GCPnts_AbscissaPoint::Length( theC3d, *itU, l);
         static StdMeshers_Regular_1D* auxAlgo = 0;
         if ( !auxAlgo ) {
-          auxAlgo = new StdMeshers_Regular_1D( _gen->GetANewId(), _studyId, _gen );
+          auxAlgo = new StdMeshers_Regular_1D( _gen->GetANewId(), _gen );
           auxAlgo->_hypType = BEG_END_LENGTH;
         }
         auxAlgo->_value[ BEG_LENGTH_IND ] = Lm;
@@ -975,6 +977,8 @@ bool StdMeshers_Regular_1D::computeInternalParameters(SMESH_Mesh &     theMesh,
       an = eltSize;
       eltSize *= q;
       ++nbParams;
+      if ( q < 1. && eltSize < 1e-100 )
+        return error("Too small common ratio causes too many segments");
     }
     if ( nbParams > 1 )
     {
@@ -1139,7 +1143,7 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & t
   if ( !nFirst || !nLast )
     return error( COMPERR_BAD_INPUT_MESH, "No node on vertex");
 
-  // remove elements created by e.g. patern mapping (PAL21999)
+  // remove elements created by e.g. pattern mapping (PAL21999)
   // CLEAN event is incorrectly ptopagated seemingly due to Propagation hyp
   // so TEMPORARY solution is to clean the submesh manually
   if (SMESHDS_SubMesh * subMeshDS = meshDS->MeshElements(theShape))