From: eap Date: Thu, 17 Feb 2011 14:37:46 +0000 (+0000) Subject: ACTION 31.3 from CoTech: X-Git-Tag: StartingPortingMED3~51 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f0a93964551f05d5647ee6266237657d4197efa3;p=modules%2Fsmesh.git ACTION 31.3 from CoTech: EURIWARE BO: Homogenize the formulas used to calculate the Controls in SMESH to fit with those of ParaView. The library used by ParaView for those calculations can be reused in SMESH. --- diff --git a/src/Controls/SMESH_Controls.cxx b/src/Controls/SMESH_Controls.cxx index b3f467436..eac69e6b4 100644 --- a/src/Controls/SMESH_Controls.cxx +++ b/src/Controls/SMESH_Controls.cxx @@ -66,6 +66,8 @@ #include "SMESHDS_Mesh.hxx" #include "SMESHDS_GroupBase.hxx" +#include + /* AUXILIARY METHODS */ @@ -284,24 +286,25 @@ long NumericalFunctor::GetPrecision() const void NumericalFunctor::SetPrecision( const long thePrecision ) { myPrecision = thePrecision; + myPrecisionValue = pow( 10., (double)( myPrecision ) ); } double NumericalFunctor::GetValue( long theId ) { + double aVal = 0; + myCurrElement = myMesh->FindElement( theId ); + TSequenceOfXYZ P; if ( GetPoints( theId, P )) - { - double aVal = GetValue( P ); - if ( myPrecision >= 0 ) - { - double prec = pow( 10., (double)( myPrecision ) ); - aVal = floor( aVal * prec + 0.5 ) / prec; - } - return aVal; - } + aVal = Round( GetValue( P )); - return 0.; + return aVal; +} + +double NumericalFunctor::Round( const double & aVal ) +{ + return ( myPrecision >= 0 ) ? floor( aVal * myPrecisionValue + 0.5 ) / myPrecisionValue : aVal; } //================================================================================ @@ -929,6 +932,28 @@ namespace{ } +double AspectRatio3D::GetValue( long theId ) +{ + double aVal = 0; + myCurrElement = myMesh->FindElement( theId ); + if ( myCurrElement && myCurrElement->GetVtkType() == VTK_TETRA ) + { + // Action from CoTech | ACTION 31.3: + // EURIWARE BO: Homogenize the formulas used to calculate the Controls in SMESH to fit with + // those of ParaView. The library used by ParaView for those calculations can be reused in SMESH. + vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myCurrElement->getMeshId()]->getGrid(); + if ( vtkCell* avtkCell = grid->GetCell( myCurrElement->getVtkId() )) + aVal = Round( vtkMeshQuality::TetAspectRatio( avtkCell )); + } + else + { + TSequenceOfXYZ P; + if ( GetPoints( myCurrElement, P )) + aVal = Round( GetValue( P )); + } + return aVal; +} + double AspectRatio3D::GetValue( const TSequenceOfXYZ& P ) { double aQuality = 0.0; diff --git a/src/Controls/SMESH_ControlsDef.hxx b/src/Controls/SMESH_ControlsDef.hxx index 0a71438d7..68420c300 100644 --- a/src/Controls/SMESH_ControlsDef.hxx +++ b/src/Controls/SMESH_ControlsDef.hxx @@ -136,15 +136,17 @@ namespace SMESH{ virtual double GetBadRate( double Value, int nbNodes ) const = 0; long GetPrecision() const; void SetPrecision( const long thePrecision ); + double Round( const double & value ); bool GetPoints(const int theId, TSequenceOfXYZ& theRes) const; static bool GetPoints(const SMDS_MeshElement* theElem, TSequenceOfXYZ& theRes); protected: - const SMDS_Mesh* myMesh; + const SMDS_Mesh* myMesh; const SMDS_MeshElement* myCurrElement; - long myPrecision; + long myPrecision; + double myPrecisionValue; }; @@ -215,6 +217,7 @@ namespace SMESH{ */ class SMESHCONTROLS_EXPORT AspectRatio3D: public virtual NumericalFunctor{ public: + virtual double GetValue( long theElementId ); virtual double GetValue( const TSequenceOfXYZ& thePoints ); virtual double GetBadRate( double Value, int nbNodes ) const; virtual SMDSAbs_ElementType GetType() const;