X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FStdMeshers%2FStdMeshers_AutomaticLength.cxx;h=1176ebe185ad5b6c3d2e49f49f2a26ee8402c1b5;hp=36ae6bec58e3668e2b5fd495ecae92302421b149;hb=5c933ecde0251d3c4894d0cdeab8dc67b6c4c3a5;hpb=1f81f404ba35217a7a514c2b1be1087f9c1fd6fd diff --git a/src/StdMeshers/StdMeshers_AutomaticLength.cxx b/src/StdMeshers/StdMeshers_AutomaticLength.cxx index 36ae6bec5..1176ebe18 100644 --- a/src/StdMeshers/StdMeshers_AutomaticLength.cxx +++ b/src/StdMeshers/StdMeshers_AutomaticLength.cxx @@ -54,6 +54,7 @@ StdMeshers_AutomaticLength::StdMeshers_AutomaticLength(int hypId, int studyId, _param_algo_dim = 1; // is used by SMESH_Regular_1D _mesh = 0; + _fineness = 0; } //============================================================================= @@ -66,6 +67,32 @@ StdMeshers_AutomaticLength::~StdMeshers_AutomaticLength() { } +//================================================================================ +/*! + * \brief Set Fineness + * \param theFineness - The Fineness value [0.0-1.0], + * 0 - coarse mesh + * 1 - fine mesh + * + * Raise if theFineness is out of range + * The "Initial Number of Elements on the Shortest Edge" (S0) + * is divided by (0.5 + 4.5 x theFineness) + */ +//================================================================================ + +void StdMeshers_AutomaticLength::SetFineness(double theFineness) + throw(SALOME_Exception) +{ + if ( theFineness < 0.0 || theFineness > 1.0 ) + throw SALOME_Exception(LOCALIZED("theFineness is out of range [0.0-1.0]")); + + if ( _fineness != theFineness ) + { + NotifySubMeshesHypothesisModification(); + _fineness = theFineness; + } +} + //================================================================================ /*! * \brief Return pointer to TopoDS_TShape @@ -101,14 +128,16 @@ static void computeLengths( const SMESH_Mesh* theMesh, for ( int i = 1; i <= edgeMap.Extent(); ++i ) { TopoDS_Edge edge = TopoDS::Edge( edgeMap(i) ); + //if ( BRep_Tool::Degenerated( edge )) continue; + Standard_Real L = SMESH_Algo::EdgeLength( edge ); - if ( L > Lmax ) - Lmax = L; - if ( L < Lmin ) - Lmin = L; + if ( L < DBL_MIN ) continue; + + if ( L > Lmax ) Lmax = L; + if ( L < Lmin ) Lmin = L; + // remember i-th edge length - theTShapeToLengthMap.insert( theTShapeToLengthMap.end(), - make_pair( getTShape( edge ), L )); + theTShapeToLengthMap.insert( make_pair( getTShape( edge ), L )); } // Compute S0 @@ -175,8 +204,11 @@ double StdMeshers_AutomaticLength::GetLength(const SMESH_Mesh* theMesh, map::iterator tshape_length = _TShapeToLength.find( getTShape( anEdge )); - ASSERT( tshape_length != _TShapeToLength.end() ); - return tshape_length->second; + + if ( tshape_length == _TShapeToLength.end() ) + return 1; // it is a dgenerated edge + + return tshape_length->second / (0.5 + 4.5 * _fineness); } //============================================================================= @@ -187,6 +219,7 @@ double StdMeshers_AutomaticLength::GetLength(const SMESH_Mesh* theMesh, ostream & StdMeshers_AutomaticLength::SaveTo(ostream & save) { + save << _fineness; return save; } @@ -198,6 +231,8 @@ ostream & StdMeshers_AutomaticLength::SaveTo(ostream & save) istream & StdMeshers_AutomaticLength::LoadFrom(istream & load) { + if ( ! ( load >> _fineness )) + load.clear(ios::badbit | load.rdstate()); return load; }