From: eap Date: Tue, 13 Jan 2009 12:46:38 +0000 (+0000) Subject: 0019923: EDF 765 SMESH : default values of hypothesis X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2420f680073563bccac2ab9fd9cf280ddb642361;p=modules%2Fsmesh.git 0019923: EDF 765 SMESH : default values of hypothesis + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ + virtual bool SetParametersByElementSize(double elemLenght, const SMESH_Mesh* theMesh=0)=0; --- diff --git a/src/SMESH/SMESH_Algo.cxx b/src/SMESH/SMESH_Algo.cxx index dacac14c3..f38e9552a 100644 --- a/src/SMESH/SMESH_Algo.cxx +++ b/src/SMESH/SMESH_Algo.cxx @@ -286,12 +286,7 @@ bool SMESH_Algo::IsReversedSubMesh (const TopoDS_Face& theFace, //================================================================================ /*! - * \brief Initialize my parameter values by the mesh built on the geometry - * \param theMesh - the built mesh - * \param theShape - the geometry of interest - * \retval bool - true if parameter values have been successfully defined - * - * Just return false as the algorithm does not hold parameters values + * \brief Just return false as the algorithm does not hold parameters values */ //================================================================================ @@ -300,7 +295,10 @@ bool SMESH_Algo::SetParametersByMesh(const SMESH_Mesh* /*theMesh*/, { return false; } - +bool SMESH_Algo::SetParametersByElementSize(double, const SMESH_Mesh*) +{ + return false; +} //================================================================================ /*! * \brief Fill vector of node parameters on geometrical edge, including vertex nodes diff --git a/src/SMESH/SMESH_Algo.hxx b/src/SMESH/SMESH_Algo.hxx index 39e876c03..cd274136b 100644 --- a/src/SMESH/SMESH_Algo.hxx +++ b/src/SMESH/SMESH_Algo.hxx @@ -164,12 +164,10 @@ public: bool InitCompatibleHypoFilter( SMESH_HypoFilter & theFilter, const bool ignoreAuxiliary) const; /*! - * \brief Initialize my parameter values by the mesh built on the geometry - * - * Just return false as the algorithm does not hold parameters values + * \brief Just return false as the algorithm does not hold parameters values */ - virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, - const TopoDS_Shape& theShape); + virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); + virtual bool SetParametersByElementSize(double elemLenght, const SMESH_Mesh* theMesh=0); /*! * \brief return compute error */ diff --git a/src/SMESH/SMESH_Hypothesis.hxx b/src/SMESH/SMESH_Hypothesis.hxx index ea3f8c6b4..83a8fd1ce 100644 --- a/src/SMESH/SMESH_Hypothesis.hxx +++ b/src/SMESH/SMESH_Hypothesis.hxx @@ -80,12 +80,18 @@ public: /*! * \brief Initialize my parameter values by the mesh built on the geometry - * \param theMesh - the built mesh - * \param theShape - the geometry of interest - * \retval bool - true if parameter values have been successfully defined + * \param theMesh - the built mesh + * \param theShape - the geometry of interest + * \retval bool - true if parameter values have been successfully defined */ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape)=0; + /*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ + virtual bool SetParametersByElementSize(double elemLenght, const SMESH_Mesh* theMesh=0)=0; + /*! * \brief Return true if me is an auxiliary hypothesis * \retval bool - auxiliary or not diff --git a/src/StdMeshers/StdMeshers_Arithmetic1D.cxx b/src/StdMeshers/StdMeshers_Arithmetic1D.cxx index ea72ca004..c0da1a734 100644 --- a/src/StdMeshers/StdMeshers_Arithmetic1D.cxx +++ b/src/StdMeshers/StdMeshers_Arithmetic1D.cxx @@ -197,3 +197,17 @@ bool StdMeshers_Arithmetic1D::SetParametersByMesh(const SMESH_Mesh* theMesh, } return nbEdges; } + +//================================================================================ +/*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ +//================================================================================ + +bool StdMeshers_Arithmetic1D::SetParametersByElementSize(double elemLenght, + const SMESH_Mesh* /*mesh*/) +{ + return bool( _begLength = _endLength = elemLenght ); +} + diff --git a/src/StdMeshers/StdMeshers_Arithmetic1D.hxx b/src/StdMeshers/StdMeshers_Arithmetic1D.hxx index 09b7edd15..5bd8d1159 100644 --- a/src/StdMeshers/StdMeshers_Arithmetic1D.hxx +++ b/src/StdMeshers/StdMeshers_Arithmetic1D.hxx @@ -58,6 +58,12 @@ public: */ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); + /*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ + virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0); + protected: double _begLength, _endLength; }; diff --git a/src/StdMeshers/StdMeshers_AutomaticLength.cxx b/src/StdMeshers/StdMeshers_AutomaticLength.cxx index 7d2343888..b9972ba39 100644 --- a/src/StdMeshers/StdMeshers_AutomaticLength.cxx +++ b/src/StdMeshers/StdMeshers_AutomaticLength.cxx @@ -368,3 +368,37 @@ bool StdMeshers_AutomaticLength::SetParametersByMesh(const SMESH_Mesh* theMesh return nbEdges; } + +//================================================================================ +/*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ +//================================================================================ + +bool StdMeshers_AutomaticLength::SetParametersByElementSize(double elemLenght, + const SMESH_Mesh* theMesh) +{ + return false; + + // assure the base automatic length is stored in _TShapeToLength +// GetLength( theMesh, elemLenght ); + +// // find maximal edge length +// double maxLen = 0; +// map::iterator +// tshape_length = _TShapeToLength.begin(), slEnd = _TShapeToLength.end(); +// for ( ; tshape_length != slEnd; ++tshape_length ) +// if ( tshape_length->second > maxLen ) +// maxLen = tshape_length->second; + +// // automatic length for longest element +// double autoLen = GetLength( theMesh, maxLen ); + +// // elemLenght = autoLen / (theCoarseConst + theFineConst * _fineness) --> +// _fineness = ( autoLen / elemLenght - theCoarseConst ) / theFineConst; + +// return true; +} + + diff --git a/src/StdMeshers/StdMeshers_AutomaticLength.hxx b/src/StdMeshers/StdMeshers_AutomaticLength.hxx index ba7504985..34b6ec122 100644 --- a/src/StdMeshers/StdMeshers_AutomaticLength.hxx +++ b/src/StdMeshers/StdMeshers_AutomaticLength.hxx @@ -97,6 +97,12 @@ public: */ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); + /*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ + virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0); + protected: std::map _TShapeToLength; const SMESH_Mesh* _mesh; diff --git a/src/StdMeshers/StdMeshers_Deflection1D.cxx b/src/StdMeshers/StdMeshers_Deflection1D.cxx index de3d52778..b317e8d55 100644 --- a/src/StdMeshers/StdMeshers_Deflection1D.cxx +++ b/src/StdMeshers/StdMeshers_Deflection1D.cxx @@ -222,3 +222,16 @@ bool StdMeshers_Deflection1D::SetParametersByMesh(const SMESH_Mesh* theMesh, } return nbEdges; } + +//================================================================================ +/*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ +//================================================================================ + +bool StdMeshers_Deflection1D::SetParametersByElementSize(double /*elemLenght*/, + const SMESH_Mesh* /*theMesh*/) +{ + return false; +} diff --git a/src/StdMeshers/StdMeshers_Deflection1D.hxx b/src/StdMeshers/StdMeshers_Deflection1D.hxx index f321c83d5..0014d0d6e 100644 --- a/src/StdMeshers/StdMeshers_Deflection1D.hxx +++ b/src/StdMeshers/StdMeshers_Deflection1D.hxx @@ -56,7 +56,13 @@ class STDMESHERS_EXPORT StdMeshers_Deflection1D:public SMESH_Hypothesis */ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); - protected: + /*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ + virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0); + +protected: double _value; }; diff --git a/src/StdMeshers/StdMeshers_LayerDistribution.cxx b/src/StdMeshers/StdMeshers_LayerDistribution.cxx index 42d99c8ed..cea6ab212 100644 --- a/src/StdMeshers/StdMeshers_LayerDistribution.cxx +++ b/src/StdMeshers/StdMeshers_LayerDistribution.cxx @@ -146,3 +146,15 @@ bool StdMeshers_LayerDistribution::SetParametersByMesh(const SMESH_Mesh* , { return false; } +//================================================================================ +/*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ +//================================================================================ + +bool StdMeshers_LayerDistribution::SetParametersByElementSize(double elemLenght, + const SMESH_Mesh* theMesh) +{ + return myHyp ? myHyp->SetParametersByElementSize(elemLenght,theMesh) : false; +} diff --git a/src/StdMeshers/StdMeshers_LayerDistribution.hxx b/src/StdMeshers/StdMeshers_LayerDistribution.hxx index 93c16c873..f8a0aff89 100644 --- a/src/StdMeshers/StdMeshers_LayerDistribution.hxx +++ b/src/StdMeshers/StdMeshers_LayerDistribution.hxx @@ -84,6 +84,12 @@ public: */ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); + /*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ + virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0); + protected: SMESH_Hypothesis* myHyp; std::string mySavedHyp; diff --git a/src/StdMeshers/StdMeshers_LengthFromEdges.cxx b/src/StdMeshers/StdMeshers_LengthFromEdges.cxx index e055a9247..e213f3aaa 100644 --- a/src/StdMeshers/StdMeshers_LengthFromEdges.cxx +++ b/src/StdMeshers/StdMeshers_LengthFromEdges.cxx @@ -153,3 +153,15 @@ bool StdMeshers_LengthFromEdges::SetParametersByMesh(const SMESH_Mesh* /*theMesh { return false; } +//================================================================================ +/*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ +//================================================================================ + +bool StdMeshers_LengthFromEdges::SetParametersByElementSize(double /*elemLenght*/, + const SMESH_Mesh* /*theMesh*/) +{ + return true; +} diff --git a/src/StdMeshers/StdMeshers_LengthFromEdges.hxx b/src/StdMeshers/StdMeshers_LengthFromEdges.hxx index 7fa99ee5e..41944701d 100644 --- a/src/StdMeshers/StdMeshers_LengthFromEdges.hxx +++ b/src/StdMeshers/StdMeshers_LengthFromEdges.hxx @@ -62,6 +62,12 @@ public: */ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); + /*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ + virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0); + protected: int _mode; }; diff --git a/src/StdMeshers/StdMeshers_LocalLength.cxx b/src/StdMeshers/StdMeshers_LocalLength.cxx index e3fe6e898..09f756191 100644 --- a/src/StdMeshers/StdMeshers_LocalLength.cxx +++ b/src/StdMeshers/StdMeshers_LocalLength.cxx @@ -235,3 +235,16 @@ bool StdMeshers_LocalLength::SetParametersByMesh(const SMESH_Mesh* theMesh, return nbEdges; } +//================================================================================ +/*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ +//================================================================================ + +bool StdMeshers_LocalLength::SetParametersByElementSize(double elemLenght, + const SMESH_Mesh* /*theMesh*/) +{ + return bool( _length = elemLenght ); +} + diff --git a/src/StdMeshers/StdMeshers_LocalLength.hxx b/src/StdMeshers/StdMeshers_LocalLength.hxx index 93fc49a6f..19252e461 100644 --- a/src/StdMeshers/StdMeshers_LocalLength.hxx +++ b/src/StdMeshers/StdMeshers_LocalLength.hxx @@ -60,6 +60,12 @@ class STDMESHERS_EXPORT StdMeshers_LocalLength: public SMESH_Hypothesis */ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); + /*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ + virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0); + protected: double _length; double _precision; diff --git a/src/StdMeshers/StdMeshers_MaxElementArea.cxx b/src/StdMeshers/StdMeshers_MaxElementArea.cxx index f02d21e9e..fd01f4525 100644 --- a/src/StdMeshers/StdMeshers_MaxElementArea.cxx +++ b/src/StdMeshers/StdMeshers_MaxElementArea.cxx @@ -186,3 +186,16 @@ bool StdMeshers_MaxElementArea::SetParametersByMesh(const SMESH_Mesh* theMesh, } return _maxArea > 0; } +//================================================================================ +/*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ +//================================================================================ + +bool StdMeshers_MaxElementArea::SetParametersByElementSize(double elemLenght, + const SMESH_Mesh* /*theMesh*/) +{ + return bool( _maxArea = elemLenght*elemLenght ); +} + diff --git a/src/StdMeshers/StdMeshers_MaxElementArea.hxx b/src/StdMeshers/StdMeshers_MaxElementArea.hxx index e8e33aa1a..d72fd2613 100644 --- a/src/StdMeshers/StdMeshers_MaxElementArea.hxx +++ b/src/StdMeshers/StdMeshers_MaxElementArea.hxx @@ -58,6 +58,12 @@ public: */ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); + /*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ + virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0); + protected: double _maxArea; }; diff --git a/src/StdMeshers/StdMeshers_MaxElementVolume.cxx b/src/StdMeshers/StdMeshers_MaxElementVolume.cxx index 42b8b469e..6c3dfe49b 100644 --- a/src/StdMeshers/StdMeshers_MaxElementVolume.cxx +++ b/src/StdMeshers/StdMeshers_MaxElementVolume.cxx @@ -198,3 +198,16 @@ bool StdMeshers_MaxElementVolume::SetParametersByMesh(const SMESH_Mesh* theMes } return _maxVolume > 0; } +//================================================================================ +/*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ +//================================================================================ + +bool StdMeshers_MaxElementVolume::SetParametersByElementSize(double elemLenght, + const SMESH_Mesh* /*theMesh*/) +{ + return bool( _maxVolume = elemLenght*elemLenght*elemLenght ); +} + diff --git a/src/StdMeshers/StdMeshers_MaxElementVolume.hxx b/src/StdMeshers/StdMeshers_MaxElementVolume.hxx index 16dc5a604..38729e9c2 100644 --- a/src/StdMeshers/StdMeshers_MaxElementVolume.hxx +++ b/src/StdMeshers/StdMeshers_MaxElementVolume.hxx @@ -60,6 +60,12 @@ public: */ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); + /*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ + virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0); + protected: double _maxVolume; }; diff --git a/src/StdMeshers/StdMeshers_NotConformAllowed.cxx b/src/StdMeshers/StdMeshers_NotConformAllowed.cxx index 7e0bd11cb..d19c6bbd3 100644 --- a/src/StdMeshers/StdMeshers_NotConformAllowed.cxx +++ b/src/StdMeshers/StdMeshers_NotConformAllowed.cxx @@ -111,5 +111,18 @@ istream & operator >> (istream & load, StdMeshers_NotConformAllowed & hyp) bool StdMeshers_NotConformAllowed::SetParametersByMesh(const SMESH_Mesh* /*theMesh*/, const TopoDS_Shape& /*theShape*/) { - return false; + return true; } +//================================================================================ +/*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ +//================================================================================ + +bool StdMeshers_NotConformAllowed::SetParametersByElementSize(double /*elemLenght*/, + const SMESH_Mesh* /*theMesh*/) +{ + return true; +} + diff --git a/src/StdMeshers/StdMeshers_NotConformAllowed.hxx b/src/StdMeshers/StdMeshers_NotConformAllowed.hxx index 5cbbb4265..f74a0be4f 100644 --- a/src/StdMeshers/StdMeshers_NotConformAllowed.hxx +++ b/src/StdMeshers/StdMeshers_NotConformAllowed.hxx @@ -56,6 +56,12 @@ public: */ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); + /*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ + virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0); + }; #endif diff --git a/src/StdMeshers/StdMeshers_NumberOfLayers.cxx b/src/StdMeshers/StdMeshers_NumberOfLayers.cxx index c1bab0f62..5ef0b646a 100644 --- a/src/StdMeshers/StdMeshers_NumberOfLayers.cxx +++ b/src/StdMeshers/StdMeshers_NumberOfLayers.cxx @@ -29,6 +29,7 @@ #include "StdMeshers_NumberOfLayers.hxx" +#include "SMESH_Mesh.hxx" #include "utilities.h" using namespace std; @@ -160,3 +161,17 @@ bool StdMeshers_NumberOfLayers::SetParametersByMesh(const SMESH_Mesh* , { return false; } + +//================================================================================ +/*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ +//================================================================================ + +bool StdMeshers_NumberOfLayers::SetParametersByElementSize(double elemLenght, + const SMESH_Mesh* theMesh) +{ + return bool( theMesh ? _nbLayers = int( theMesh->GetShapeDiagonalSize() / elemLenght/ 2.) : 0); +} + diff --git a/src/StdMeshers/StdMeshers_NumberOfLayers.hxx b/src/StdMeshers/StdMeshers_NumberOfLayers.hxx index c0b5a6b1b..a660c5f60 100644 --- a/src/StdMeshers/StdMeshers_NumberOfLayers.hxx +++ b/src/StdMeshers/StdMeshers_NumberOfLayers.hxx @@ -75,6 +75,12 @@ public: */ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); + /*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ + virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0); + protected: int _nbLayers; }; diff --git a/src/StdMeshers/StdMeshers_NumberOfSegments.cxx b/src/StdMeshers/StdMeshers_NumberOfSegments.cxx index 766a92e3f..872a3b70f 100644 --- a/src/StdMeshers/StdMeshers_NumberOfSegments.cxx +++ b/src/StdMeshers/StdMeshers_NumberOfSegments.cxx @@ -65,7 +65,7 @@ StdMeshers_NumberOfSegments::StdMeshers_NumberOfSegments(int hypId, int studyId, SMESH_Gen * gen) : SMESH_Hypothesis(hypId, studyId, gen), - _numberOfSegments(1), + _numberOfSegments(15),//issue 19923 _distrType(DT_Regular), _scaleFactor(1.), _convMode(1) //cut negative by default @@ -684,3 +684,16 @@ bool StdMeshers_NumberOfSegments::SetParametersByMesh(const SMESH_Mesh* theMes return nbEdges; } +//================================================================================ +/*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ +//================================================================================ + +bool StdMeshers_NumberOfSegments::SetParametersByElementSize(double elemLenght, + const SMESH_Mesh* /*theMesh*/) +{ + return false; +} + diff --git a/src/StdMeshers/StdMeshers_NumberOfSegments.hxx b/src/StdMeshers/StdMeshers_NumberOfSegments.hxx index b967dc933..0317f7466 100644 --- a/src/StdMeshers/StdMeshers_NumberOfSegments.hxx +++ b/src/StdMeshers/StdMeshers_NumberOfSegments.hxx @@ -172,6 +172,12 @@ public: */ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); + /*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ + virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0); + virtual std::ostream & SaveTo(std::ostream & save); virtual std::istream & LoadFrom(std::istream & load); friend std::ostream& operator << (std::ostream & save, StdMeshers_NumberOfSegments & hyp); diff --git a/src/StdMeshers/StdMeshers_ProjectionSource1D.cxx b/src/StdMeshers/StdMeshers_ProjectionSource1D.cxx index 8c3ecd939..2c23dab10 100644 --- a/src/StdMeshers/StdMeshers_ProjectionSource1D.cxx +++ b/src/StdMeshers/StdMeshers_ProjectionSource1D.cxx @@ -230,3 +230,16 @@ void StdMeshers_ProjectionSource1D::RestoreParams(const TopoDS_Shape& s1, _sourceMesh = mesh; } +//================================================================================ +/*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ +//================================================================================ + +bool StdMeshers_ProjectionSource1D::SetParametersByElementSize(double /*elemLenght*/, + const SMESH_Mesh* /*theMesh*/) +{ + return false; +} + diff --git a/src/StdMeshers/StdMeshers_ProjectionSource1D.hxx b/src/StdMeshers/StdMeshers_ProjectionSource1D.hxx index e9847420f..414aea25b 100644 --- a/src/StdMeshers/StdMeshers_ProjectionSource1D.hxx +++ b/src/StdMeshers/StdMeshers_ProjectionSource1D.hxx @@ -138,6 +138,12 @@ public: */ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); + /*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ + virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0); + protected: TopoDS_Shape _sourceEdge; diff --git a/src/StdMeshers/StdMeshers_ProjectionSource2D.cxx b/src/StdMeshers/StdMeshers_ProjectionSource2D.cxx index 84440d25d..543931972 100644 --- a/src/StdMeshers/StdMeshers_ProjectionSource2D.cxx +++ b/src/StdMeshers/StdMeshers_ProjectionSource2D.cxx @@ -298,3 +298,17 @@ void StdMeshers_ProjectionSource2D::RestoreParams(const TopoDS_Shape& s1, _targetVertex2 = TopoDS::Vertex( s5 ); _sourceMesh = mesh; } + +//================================================================================ +/*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ +//================================================================================ + +bool StdMeshers_ProjectionSource2D::SetParametersByElementSize(double /*elemLenght*/, + const SMESH_Mesh* /*theMesh*/) +{ + return false; +} + diff --git a/src/StdMeshers/StdMeshers_ProjectionSource2D.hxx b/src/StdMeshers/StdMeshers_ProjectionSource2D.hxx index e75e38dab..61f1d4ced 100644 --- a/src/StdMeshers/StdMeshers_ProjectionSource2D.hxx +++ b/src/StdMeshers/StdMeshers_ProjectionSource2D.hxx @@ -148,6 +148,12 @@ public: */ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); + /*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ + virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0); + protected: TopoDS_Shape _sourceFace; diff --git a/src/StdMeshers/StdMeshers_ProjectionSource3D.cxx b/src/StdMeshers/StdMeshers_ProjectionSource3D.cxx index 00a889160..94370f830 100644 --- a/src/StdMeshers/StdMeshers_ProjectionSource3D.cxx +++ b/src/StdMeshers/StdMeshers_ProjectionSource3D.cxx @@ -297,3 +297,17 @@ void StdMeshers_ProjectionSource3D::RestoreParams(const TopoDS_Shape& s1, _targetVertex2 = TopoDS::Vertex( s5 ); _sourceMesh = mesh; } + +//================================================================================ +/*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ +//================================================================================ + +bool StdMeshers_ProjectionSource3D::SetParametersByElementSize(double /*elemLenght*/, + const SMESH_Mesh* /*theMesh*/) +{ + return false; +} + diff --git a/src/StdMeshers/StdMeshers_ProjectionSource3D.hxx b/src/StdMeshers/StdMeshers_ProjectionSource3D.hxx index 7dfeca6f0..fd7b8cd5f 100644 --- a/src/StdMeshers/StdMeshers_ProjectionSource3D.hxx +++ b/src/StdMeshers/StdMeshers_ProjectionSource3D.hxx @@ -140,6 +140,12 @@ public: */ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); + /*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ + virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0); + protected: TopoDS_Shape _sourceShape; diff --git a/src/StdMeshers/StdMeshers_Propagation.cxx b/src/StdMeshers/StdMeshers_Propagation.cxx index b442e6d79..aa985613a 100644 --- a/src/StdMeshers/StdMeshers_Propagation.cxx +++ b/src/StdMeshers/StdMeshers_Propagation.cxx @@ -97,6 +97,7 @@ ostream & operator << (ostream & save, StdMeshers_Propagation & hyp) { return istream & operator >> (istream & load, StdMeshers_Propagation & hyp) { return hyp.LoadFrom(load); } bool StdMeshers_Propagation::SetParametersByMesh(const SMESH_Mesh*, const TopoDS_Shape& ) { return false; } +bool StdMeshers_Propagation::SetParametersByElementSize(double,const SMESH_Mesh*) { return false; } void StdMeshers_Propagation::SetPropagationMgr(SMESH_subMesh* subMesh) { PropagationMgr::Set( subMesh ); } /*! * \brief Return an edge from which hypotheses are propagated from diff --git a/src/StdMeshers/StdMeshers_Propagation.hxx b/src/StdMeshers/StdMeshers_Propagation.hxx index 62ad2a439..fbdac1aec 100644 --- a/src/StdMeshers/StdMeshers_Propagation.hxx +++ b/src/StdMeshers/StdMeshers_Propagation.hxx @@ -80,5 +80,12 @@ class STDMESHERS_EXPORT StdMeshers_Propagation:public SMESH_Hypothesis * Just return false as this hypothesis does not have parameters values */ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); + + /*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ + virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0); + }; #endif diff --git a/src/StdMeshers/StdMeshers_QuadranglePreference.cxx b/src/StdMeshers/StdMeshers_QuadranglePreference.cxx index 3e04aa872..5b4151e21 100644 --- a/src/StdMeshers/StdMeshers_QuadranglePreference.cxx +++ b/src/StdMeshers/StdMeshers_QuadranglePreference.cxx @@ -114,3 +114,17 @@ bool StdMeshers_QuadranglePreference::SetParametersByMesh(const SMESH_Mesh* /*th { return false; } + +//================================================================================ +/*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ +//================================================================================ + +bool StdMeshers_QuadranglePreference::SetParametersByElementSize(double /*elemLenght*/, + const SMESH_Mesh* /*theMesh*/) +{ + return false; +} + diff --git a/src/StdMeshers/StdMeshers_QuadranglePreference.hxx b/src/StdMeshers/StdMeshers_QuadranglePreference.hxx index 3d00d7acd..32698551f 100644 --- a/src/StdMeshers/StdMeshers_QuadranglePreference.hxx +++ b/src/StdMeshers/StdMeshers_QuadranglePreference.hxx @@ -60,6 +60,12 @@ class STDMESHERS_EXPORT StdMeshers_QuadranglePreference:public SMESH_Hypothesis */ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); + /*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ + virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0); + }; #endif diff --git a/src/StdMeshers/StdMeshers_QuadraticMesh.cxx b/src/StdMeshers/StdMeshers_QuadraticMesh.cxx index 2e56a6560..e01053c95 100644 --- a/src/StdMeshers/StdMeshers_QuadraticMesh.cxx +++ b/src/StdMeshers/StdMeshers_QuadraticMesh.cxx @@ -109,3 +109,17 @@ bool StdMeshers_QuadraticMesh::SetParametersByMesh(const SMESH_Mesh*, const Topo { return false; } + +//================================================================================ +/*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ +//================================================================================ + +bool StdMeshers_QuadraticMesh::SetParametersByElementSize(double /*elemLenght*/, + const SMESH_Mesh* /*theMesh*/) +{ + return false; +} + diff --git a/src/StdMeshers/StdMeshers_QuadraticMesh.hxx b/src/StdMeshers/StdMeshers_QuadraticMesh.hxx index f6146f8b6..240540081 100644 --- a/src/StdMeshers/StdMeshers_QuadraticMesh.hxx +++ b/src/StdMeshers/StdMeshers_QuadraticMesh.hxx @@ -62,6 +62,12 @@ class STDMESHERS_EXPORT StdMeshers_QuadraticMesh:public SMESH_Hypothesis */ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); + /*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ + virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0); + }; #endif diff --git a/src/StdMeshers/StdMeshers_Regular_1D.cxx b/src/StdMeshers/StdMeshers_Regular_1D.cxx index fe7f869d3..da059a272 100644 --- a/src/StdMeshers/StdMeshers_Regular_1D.cxx +++ b/src/StdMeshers/StdMeshers_Regular_1D.cxx @@ -30,14 +30,15 @@ #include "StdMeshers_Regular_1D.hxx" #include "StdMeshers_Distribution.hxx" -#include "StdMeshers_LocalLength.hxx" -#include "StdMeshers_NumberOfSegments.hxx" #include "StdMeshers_Arithmetic1D.hxx" -#include "StdMeshers_StartEndLength.hxx" -#include "StdMeshers_Deflection1D.hxx" #include "StdMeshers_AutomaticLength.hxx" -#include "StdMeshers_SegmentLengthAroundVertex.hxx" +#include "StdMeshers_Deflection1D.hxx" +#include "StdMeshers_LocalLength.hxx" +#include "StdMeshers_MaxLength.hxx" +#include "StdMeshers_NumberOfSegments.hxx" #include "StdMeshers_Propagation.hxx" +#include "StdMeshers_SegmentLengthAroundVertex.hxx" +#include "StdMeshers_StartEndLength.hxx" #include "SMESH_Gen.hxx" #include "SMESH_Mesh.hxx" @@ -81,6 +82,7 @@ StdMeshers_Regular_1D::StdMeshers_Regular_1D(int hypId, int studyId, _shapeType = (1 << TopAbs_EDGE); _compatibleHypothesis.push_back("LocalLength"); + _compatibleHypothesis.push_back("MaxLength"); _compatibleHypothesis.push_back("NumberOfSegments"); _compatibleHypothesis.push_back("StartEndLength"); _compatibleHypothesis.push_back("Deflection1D"); @@ -146,14 +148,28 @@ bool StdMeshers_Regular_1D::CheckHypothesis const StdMeshers_LocalLength * hyp = dynamic_cast (theHyp); ASSERT(hyp); - //_value[ BEG_LENGTH_IND ] = _value[ END_LENGTH_IND ] = hyp->GetLength(); _value[ BEG_LENGTH_IND ] = hyp->GetLength(); - _value[ END_LENGTH_IND ] = hyp->GetPrecision(); + _value[ PRECISION_IND ] = hyp->GetPrecision(); ASSERT( _value[ BEG_LENGTH_IND ] > 0 ); _hypType = LOCAL_LENGTH; aStatus = SMESH_Hypothesis::HYP_OK; } + else if (hypName == "MaxLength") + { + const StdMeshers_MaxLength * hyp = + dynamic_cast (theHyp); + ASSERT(hyp); + _value[ BEG_LENGTH_IND ] = hyp->GetLength(); + if ( hyp->GetUsePreestimatedLength() ) { + if ( int nbSeg = aMesh.GetNbElementsPerDiagonal() ) + _value[ BEG_LENGTH_IND ] = aMesh.GetShapeDiagonalSize() / nbSeg; + } + ASSERT( _value[ BEG_LENGTH_IND ] > 0 ); + _hypType = MAX_LENGTH; + aStatus = SMESH_Hypothesis::HYP_OK; + } + else if (hypName == "NumberOfSegments") { const StdMeshers_NumberOfSegments * hyp = @@ -226,11 +242,11 @@ bool StdMeshers_Regular_1D::CheckHypothesis StdMeshers_AutomaticLength * hyp = const_cast (dynamic_cast (theHyp)); ASSERT(hyp); - //_value[ BEG_LENGTH_IND ] = _value[ END_LENGTH_IND ] = hyp->GetLength( &aMesh, aShape ); - _value[ BEG_LENGTH_IND ] = hyp->GetLength( &aMesh, aShape ); - _value[ END_LENGTH_IND ] = Precision::Confusion(); // ?? or set to zero? + _value[ BEG_LENGTH_IND ] = _value[ END_LENGTH_IND ] = hyp->GetLength( &aMesh, aShape ); +// _value[ BEG_LENGTH_IND ] = hyp->GetLength( &aMesh, aShape ); +// _value[ END_LENGTH_IND ] = Precision::Confusion(); // ?? or set to zero? ASSERT( _value[ BEG_LENGTH_IND ] > 0 ); - _hypType = LOCAL_LENGTH; + _hypType = MAX_LENGTH; aStatus = SMESH_Hypothesis::HYP_OK; } else @@ -413,11 +429,6 @@ static void compensateError(double a1, double an, void StdMeshers_Regular_1D::SetEventListener(SMESH_subMesh* subMesh) { -// static VertexEventListener listener; -// SMESH_subMeshIteratorPtr smIt = subMesh->getDependsOnIterator(false,false); -// while (smIt->more()) { -// subMesh->SetEventListener( &listener, 0, smIt->next() ); -// } StdMeshers_Propagation::SetPropagationMgr( subMesh ); } @@ -567,10 +578,18 @@ bool StdMeshers_Regular_1D::computeInternalParameters(SMESH_Mesh & theMesh, switch( _hypType ) { case LOCAL_LENGTH: + case MAX_LENGTH: case NB_SEGMENTS: { double eltSize = 1; - if ( _hypType == LOCAL_LENGTH ) + if ( _hypType == MAX_LENGTH ) + { + double nbseg = ceil(theLength / _value[ BEG_LENGTH_IND ]); // integer sup + if (nbseg <= 0) + nbseg = 1; // degenerated edge + eltSize = theLength / nbseg; + } + else if ( _hypType == LOCAL_LENGTH ) { // Local Length hypothesis double nbseg = ceil(theLength / _value[ BEG_LENGTH_IND ]); // integer sup @@ -601,7 +620,7 @@ bool StdMeshers_Regular_1D::computeInternalParameters(SMESH_Mesh & theMesh, } if (!isFound) // not found by meshed edge in the propagation chain, use precision { - double aPrecision = _value[ END_LENGTH_IND ]; + double aPrecision = _value[ PRECISION_IND ]; double nbseg_prec = ceil((theLength / _value[ BEG_LENGTH_IND ]) - aPrecision); if (nbseg_prec == (nbseg - 1)) nbseg--; } diff --git a/src/StdMeshers/StdMeshers_Regular_1D.hxx b/src/StdMeshers/StdMeshers_Regular_1D.hxx index 4a22e7253..c0f664a0d 100644 --- a/src/StdMeshers/StdMeshers_Regular_1D.hxx +++ b/src/StdMeshers/StdMeshers_Regular_1D.hxx @@ -96,13 +96,14 @@ protected: StdMeshers_SegmentLengthAroundVertex* getVertexHyp(SMESH_Mesh & theMesh, const TopoDS_Vertex & theV); - enum HypothesisType { LOCAL_LENGTH, NB_SEGMENTS, BEG_END_LENGTH, DEFLECTION, ARITHMETIC_1D, NONE }; + enum HypothesisType { LOCAL_LENGTH, MAX_LENGTH, NB_SEGMENTS, BEG_END_LENGTH, DEFLECTION, ARITHMETIC_1D, NONE }; enum ValueIndex { SCALE_FACTOR_IND = 0, BEG_LENGTH_IND = 0, END_LENGTH_IND = 1, - DEFLECTION_IND = 0 + DEFLECTION_IND = 0, + PRECISION_IND = 0 }; enum IValueIndex { diff --git a/src/StdMeshers/StdMeshers_SegmentLengthAroundVertex.cxx b/src/StdMeshers/StdMeshers_SegmentLengthAroundVertex.cxx index f44b75574..f74e473be 100644 --- a/src/StdMeshers/StdMeshers_SegmentLengthAroundVertex.cxx +++ b/src/StdMeshers/StdMeshers_SegmentLengthAroundVertex.cxx @@ -202,3 +202,17 @@ bool StdMeshers_SegmentLengthAroundVertex::SetParametersByMesh(const SMESH_Mesh* return nbSegs; } + +//================================================================================ +/*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ +//================================================================================ + +bool StdMeshers_SegmentLengthAroundVertex::SetParametersByElementSize(double, + const SMESH_Mesh*) +{ + return false; +} + diff --git a/src/StdMeshers/StdMeshers_SegmentLengthAroundVertex.hxx b/src/StdMeshers/StdMeshers_SegmentLengthAroundVertex.hxx index 3584b51db..d0fa1cd36 100644 --- a/src/StdMeshers/StdMeshers_SegmentLengthAroundVertex.hxx +++ b/src/StdMeshers/StdMeshers_SegmentLengthAroundVertex.hxx @@ -61,6 +61,12 @@ class STDMESHERS_EXPORT StdMeshers_SegmentLengthAroundVertex:public SMESH_Hypoth */ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); + /*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ + virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0); + protected: double _length; }; diff --git a/src/StdMeshers/StdMeshers_StartEndLength.cxx b/src/StdMeshers/StdMeshers_StartEndLength.cxx index 14563332d..e8b4ef1e7 100644 --- a/src/StdMeshers/StdMeshers_StartEndLength.cxx +++ b/src/StdMeshers/StdMeshers_StartEndLength.cxx @@ -198,3 +198,17 @@ bool StdMeshers_StartEndLength::SetParametersByMesh(const SMESH_Mesh* theMesh, } return nbEdges; } + +//================================================================================ +/*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ +//================================================================================ + +bool StdMeshers_StartEndLength::SetParametersByElementSize(double elemLenght, + const SMESH_Mesh* /*theMesh*/) +{ + return bool(_begLength = _endLength = elemLenght ); +} + diff --git a/src/StdMeshers/StdMeshers_StartEndLength.hxx b/src/StdMeshers/StdMeshers_StartEndLength.hxx index c680b9802..4c908ca70 100644 --- a/src/StdMeshers/StdMeshers_StartEndLength.hxx +++ b/src/StdMeshers/StdMeshers_StartEndLength.hxx @@ -57,6 +57,12 @@ class STDMESHERS_EXPORT StdMeshers_StartEndLength:public SMESH_Hypothesis */ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); + /*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ + virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0); + protected: double _begLength, _endLength; }; diff --git a/src/StdMeshers/StdMeshers_TrianglePreference.cxx b/src/StdMeshers/StdMeshers_TrianglePreference.cxx index af14e2ef2..4cd3ae516 100644 --- a/src/StdMeshers/StdMeshers_TrianglePreference.cxx +++ b/src/StdMeshers/StdMeshers_TrianglePreference.cxx @@ -114,3 +114,17 @@ bool StdMeshers_TrianglePreference::SetParametersByMesh(const SMESH_Mesh* /*theM { return false; } + +//================================================================================ +/*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ +//================================================================================ + +bool StdMeshers_TrianglePreference::SetParametersByElementSize(double /*elemLenght*/, + const SMESH_Mesh* /*theMesh*/) +{ + return false; +} + diff --git a/src/StdMeshers/StdMeshers_TrianglePreference.hxx b/src/StdMeshers/StdMeshers_TrianglePreference.hxx index 247bf1d47..08581564f 100644 --- a/src/StdMeshers/StdMeshers_TrianglePreference.hxx +++ b/src/StdMeshers/StdMeshers_TrianglePreference.hxx @@ -59,6 +59,12 @@ class STDMESHERS_EXPORT StdMeshers_TrianglePreference:public SMESH_Hypothesis */ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); + /*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ + virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0); + }; #endif