X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FStdMeshers%2FStdMeshers_NumberOfSegments.cxx;h=a768b6c1670b3365ba661ba31bb6acde6572fdda;hb=e07015e9cc33a528a8ab0ad4733ee86aef2d5d3e;hp=ecceafd146ce1e0d1a890961321ba1853ea775e4;hpb=2ad752b10cb247a162b27593121a7ae13173258d;p=modules%2Fsmesh.git diff --git a/src/StdMeshers/StdMeshers_NumberOfSegments.cxx b/src/StdMeshers/StdMeshers_NumberOfSegments.cxx index ecceafd14..a768b6c16 100644 --- a/src/StdMeshers/StdMeshers_NumberOfSegments.cxx +++ b/src/StdMeshers/StdMeshers_NumberOfSegments.cxx @@ -474,8 +474,18 @@ istream & StdMeshers_NumberOfSegments::LoadFrom(istream & load) else load.clear(ios::badbit | load.rdstate()); - // read ditribution type - isOK = (load >> a); + // read second stored value. It can be two variants here: + // 1. If the hypothesis is stored in old format (nb.segments and scale factor), + // we wait here the scale factor, which is double. + // 2. If the hypothesis is stored in new format + // (nb.segments, distr.type, some other params.), + // we wait here the ditribution type, which is integer + double scale_factor; + isOK = (load >> scale_factor); + a = (int)scale_factor; + + // try to interprete ditribution type, + // supposing that this hypothesis was written in the new format if (isOK) { if (a < DT_Regular || a > DT_ExprFunc) @@ -496,24 +506,36 @@ istream & StdMeshers_NumberOfSegments::LoadFrom(istream & load) if (isOK) _scaleFactor = b; else + { load.clear(ios::badbit | load.rdstate()); + // this can mean, that the hypothesis is stored in old format + _distrType = DT_Regular; + _scaleFactor = scale_factor; + } } break; case DT_TabFunc: { isOK = (load >> a); if (isOK) + { _table.resize(a, 0.); + int i; + for (i=0; i < _table.size(); i++) + { + isOK = (load >> b); + if (isOK) + _table[i] = b; + else + load.clear(ios::badbit | load.rdstate()); + } + } else - load.clear(ios::badbit | load.rdstate()); - int i; - for (i=0; i < _table.size(); i++) { - isOK = (load >> b); - if (isOK) - _table[i] = b; - else - load.clear(ios::badbit | load.rdstate()); + load.clear(ios::badbit | load.rdstate()); + // this can mean, that the hypothesis is stored in old format + _distrType = DT_Regular; + _scaleFactor = scale_factor; } } break; @@ -524,7 +546,12 @@ istream & StdMeshers_NumberOfSegments::LoadFrom(istream & load) if (isOK) _func = str; else + { load.clear(ios::badbit | load.rdstate()); + // this can mean, that the hypothesis is stored in old format + _distrType = DT_Regular; + _scaleFactor = scale_factor; + } } break; case DT_Regular: