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.
This commit is contained in:
eap 2011-02-17 14:37:46 +00:00
parent 18e25f5736
commit f0a9396455
2 changed files with 40 additions and 12 deletions

View File

@ -66,6 +66,8 @@
#include "SMESHDS_Mesh.hxx" #include "SMESHDS_Mesh.hxx"
#include "SMESHDS_GroupBase.hxx" #include "SMESHDS_GroupBase.hxx"
#include <vtkMeshQuality.h>
/* /*
AUXILIARY METHODS AUXILIARY METHODS
*/ */
@ -284,24 +286,25 @@ long NumericalFunctor::GetPrecision() const
void NumericalFunctor::SetPrecision( const long thePrecision ) void NumericalFunctor::SetPrecision( const long thePrecision )
{ {
myPrecision = thePrecision; myPrecision = thePrecision;
myPrecisionValue = pow( 10., (double)( myPrecision ) );
} }
double NumericalFunctor::GetValue( long theId ) double NumericalFunctor::GetValue( long theId )
{ {
double aVal = 0;
myCurrElement = myMesh->FindElement( theId ); myCurrElement = myMesh->FindElement( theId );
TSequenceOfXYZ P; TSequenceOfXYZ P;
if ( GetPoints( theId, P )) if ( GetPoints( theId, P ))
{ aVal = Round( GetValue( P ));
double aVal = GetValue( P );
if ( myPrecision >= 0 )
{
double prec = pow( 10., (double)( myPrecision ) );
aVal = floor( aVal * prec + 0.5 ) / prec;
}
return aVal;
}
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 AspectRatio3D::GetValue( const TSequenceOfXYZ& P )
{ {
double aQuality = 0.0; double aQuality = 0.0;

View File

@ -136,15 +136,17 @@ namespace SMESH{
virtual double GetBadRate( double Value, int nbNodes ) const = 0; virtual double GetBadRate( double Value, int nbNodes ) const = 0;
long GetPrecision() const; long GetPrecision() const;
void SetPrecision( const long thePrecision ); void SetPrecision( const long thePrecision );
double Round( const double & value );
bool GetPoints(const int theId, bool GetPoints(const int theId,
TSequenceOfXYZ& theRes) const; TSequenceOfXYZ& theRes) const;
static bool GetPoints(const SMDS_MeshElement* theElem, static bool GetPoints(const SMDS_MeshElement* theElem,
TSequenceOfXYZ& theRes); TSequenceOfXYZ& theRes);
protected: protected:
const SMDS_Mesh* myMesh; const SMDS_Mesh* myMesh;
const SMDS_MeshElement* myCurrElement; const SMDS_MeshElement* myCurrElement;
long myPrecision; long myPrecision;
double myPrecisionValue;
}; };
@ -215,6 +217,7 @@ namespace SMESH{
*/ */
class SMESHCONTROLS_EXPORT AspectRatio3D: public virtual NumericalFunctor{ class SMESHCONTROLS_EXPORT AspectRatio3D: public virtual NumericalFunctor{
public: public:
virtual double GetValue( long theElementId );
virtual double GetValue( const TSequenceOfXYZ& thePoints ); virtual double GetValue( const TSequenceOfXYZ& thePoints );
virtual double GetBadRate( double Value, int nbNodes ) const; virtual double GetBadRate( double Value, int nbNodes ) const;
virtual SMDSAbs_ElementType GetType() const; virtual SMDSAbs_ElementType GetType() const;