X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FStdMeshers%2FStdMeshers_CartesianParameters3D.cxx;h=be2a1955699adcfbe1a6022373e2bf4620045b4d;hp=10e31de5953e299c63eac103fafd3a46310492fd;hb=HEAD;hpb=a274ade365bd0f0e19d56c577acc4a13aa1972a7 diff --git a/src/StdMeshers/StdMeshers_CartesianParameters3D.cxx b/src/StdMeshers/StdMeshers_CartesianParameters3D.cxx index 10e31de59..66256788b 100644 --- a/src/StdMeshers/StdMeshers_CartesianParameters3D.cxx +++ b/src/StdMeshers/StdMeshers_CartesianParameters3D.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -67,7 +67,9 @@ StdMeshers_CartesianParameters3D::StdMeshers_CartesianParameters3D(int h _toAddEdges( false ), _toConsiderInternalFaces( false ), _toUseThresholdForInternalFaces( false ), - _toCreateFaces( false ) + _toCreateFaces( false ), + _toUseQuanta(false), + _quanta(0.01) { _name = "CartesianParameters3D"; // used by "Cartesian_3D" _param_algo_dim = 3; // 3D @@ -331,13 +333,13 @@ void StdMeshers_CartesianParameters3D::ComputeCoordinates(const double x0, const double p1 = x0 * ( 1. - points[i+1]) + x1 * points[i+1]; const double length = p1 - p0; - const size_t nbSections = 1000; + const int nbSections = 1000; const double sectionLen = ( p1 - p0 ) / nbSections; vector< double > nbSegments( nbSections + 1 ); nbSegments[ 0 ] = 0.; double t, spacing = 0; - for ( size_t i = 1; i <= nbSections; ++i ) + for ( int i = 1; i <= nbSections; ++i ) { t = double( i ) / nbSections; if ( !fun.value( t, spacing ) || spacing < std::numeric_limits::min() ) @@ -350,11 +352,11 @@ void StdMeshers_CartesianParameters3D::ComputeCoordinates(const double x0, if ( coords.empty() ) coords.push_back( p0 ); - for ( size_t iCell = 1, i = 1; i <= nbSections; ++i ) + for ( int iCell = 1, j = 1; j <= nbSections; ++j ) { - if ( nbSegments[i]*corr >= iCell ) + if ( nbSegments[j]*corr >= iCell ) { - t = (i - ( nbSegments[i] - iCell/corr )/( nbSegments[i] - nbSegments[i-1] )) / nbSections; + t = (j - ( nbSegments[j] - iCell/corr )/( nbSegments[j] - nbSegments[j-1] )) / nbSections; coords.push_back( p0 + t * length ); ++iCell; } @@ -379,9 +381,9 @@ void StdMeshers_CartesianParameters3D::ComputeCoordinates(const double x0, const double tol = minLen * 1e-3; int iRem = -1; if (( iF > 1 ) && ( coords[iF] - coords[iF-1] < tol )) - iRem = iF-1; + iRem = (int) iF-1; else if (( iF < coords.size()-2 ) && ( coords[iF+1] - coords[iF] < tol )) - iRem = iF+1; + iRem = (int) iF+1; if ( iRem > 0 ) coords.erase( coords.begin() + iRem ); } @@ -774,6 +776,37 @@ void StdMeshers_CartesianParameters3D::SetToCreateFaces(bool toCreate) } } +//======================================================================= +//function : SetToUseQuanta +//purpose : Enables use of quanta +//======================================================================= + +void StdMeshers_CartesianParameters3D::SetToUseQuanta(bool toUseQuanta) +{ + if ( _toUseQuanta != toUseQuanta ) + { + _toUseQuanta = toUseQuanta; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : SetQuanta +//purpose : Set size quanta value +//======================================================================= + +void StdMeshers_CartesianParameters3D::SetQuanta(const double quanta) +{ + if ( quanta < 1e-6 || quanta > 1.0 ) + throw SALOME_Exception(LOCALIZED("Quanta must be in the range [0.01,1] ")); + + bool changed = (_quanta != quanta); + _quanta = quanta; + + if ( changed ) + NotifySubMeshesHypothesisModification(); +} + //======================================================================= //function : IsDefined //purpose : Return true if parameters are well defined @@ -823,7 +856,9 @@ std::ostream & StdMeshers_CartesianParameters3D::SaveTo(std::ostream & save) save << " " << _toConsiderInternalFaces << " " << _toUseThresholdForInternalFaces - << " " << _toCreateFaces; + << " " << _toCreateFaces + << " " << _toUseQuanta + << " " << _quanta; return save; } @@ -889,6 +924,9 @@ std::istream & StdMeshers_CartesianParameters3D::LoadFrom(std::istream & load) load >> _toCreateFaces; } + if ( load >> _toUseQuanta ) + load >> _quanta; + return load; }