]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
Fix bug 10020. Now NumberOfSegments hypothesis allow scale distribution with scale...
authorjfa <jfa@opencascade.com>
Mon, 6 Mar 2006 13:18:20 +0000 (13:18 +0000)
committerjfa <jfa@opencascade.com>
Mon, 6 Mar 2006 13:18:20 +0000 (13:18 +0000)
src/StdMeshers/StdMeshers_NumberOfSegments.cxx
src/StdMeshers/StdMeshers_Regular_1D.cxx

index c5eef67000a13c00fe965161792a9b3e4f981b33..b949d872bce24ca1d54b0ae73fb95b0308261b39 100644 (file)
@@ -170,8 +170,8 @@ void StdMeshers_NumberOfSegments::SetScaleFactor(double scaleFactor)
     throw SALOME_Exception(LOCALIZED("not a scale distribution"));
   if (scaleFactor < PRECISION)
     throw SALOME_Exception(LOCALIZED("scale factor must be positive"));
-  if (fabs(scaleFactor - 1.0) < PRECISION)
-    throw SALOME_Exception(LOCALIZED("scale factor must not be equal to 1"));
+  //if (fabs(scaleFactor - 1.0) < PRECISION)
+  //  throw SALOME_Exception(LOCALIZED("scale factor must not be equal to 1"));
 
   if (fabs(_scaleFactor - scaleFactor) > PRECISION)
   {
index c890c67ee372937fb23c69c2e6888bb102d74261..0c6144988cca81e45a20bf2d3344afea9b00d6dc 100644 (file)
@@ -354,17 +354,27 @@ bool StdMeshers_Regular_1D::computeInternalParameters(const TopoDS_Edge& theEdge
       {
       case StdMeshers_NumberOfSegments::DT_Scale:
         {
+          int NbSegm   = _ivalue[ NB_SEGMENTS_IND ];
           double scale = _value[ SCALE_FACTOR_IND ];
-          if ( theReverse )
-            scale = 1. / scale;
-          double alpha = pow( scale , 1.0 / (_ivalue[ NB_SEGMENTS_IND ] - 1));
-          double factor = (l - f) / (1 - pow( alpha,_ivalue[ NB_SEGMENTS_IND ]));
-
-          int i, NbPoints = 1 + _ivalue[ NB_SEGMENTS_IND ];
-          for ( i = 2; i < NbPoints; i++ )
-          {
-            double param = f + factor * (1 - pow(alpha, i - 1));
-            theParams.push_back( param );
+
+          if (fabs(scale - 1.0) < Precision::Confusion()) {
+            // special case to avoid division on zero
+            for (int i = 1; i < NbSegm; i++) {
+              double param = f + (l - f) * i / NbSegm;
+              theParams.push_back( param );
+            }
+          } else {
+            // general case of scale distribution
+            if ( theReverse )
+              scale = 1.0 / scale;
+
+            double alpha = pow(scale, 1.0 / (NbSegm - 1));
+            double factor = (l - f) / (1.0 - pow(alpha, NbSegm));
+
+            for (int i = 1; i < NbSegm; i++) {
+              double param = f + factor * (1.0 - pow(alpha, i));
+              theParams.push_back( param );
+            }
           }
           return true;
         }