Version: 6.3.1
Public Member Functions | Static Public Member Functions | Protected Attributes

SMESH.Controls.AspectRatio Class Reference

#include <SMESH_ControlsDef.hxx>

Inheritance diagram for SMESH.Controls.AspectRatio:
Inheritance graph
[legend]

Public Member Functions

virtual double GetValue (const TSequenceOfXYZ &thePoints)
virtual double GetBadRate (double Value, int nbNodes) const
virtual SMDSAbs_ElementType GetType () const
virtual void SetMesh (const SMDS_Mesh *theMesh)
virtual double GetValue (long theElementId)
void GetHistogram (int nbIntervals, std::vector< int > &nbEvents, std::vector< double > &funValues, const std::vector< int > &elements, const double *minmax=0)
long GetPrecision () const
void SetPrecision (const long thePrecision)
double Round (const double &value)
bool GetPoints (const int theId, TSequenceOfXYZ &theRes) const

Static Public Member Functions

static bool GetPoints (const SMDS_MeshElement *theElem, TSequenceOfXYZ &theRes)

Protected Attributes

const SMDS_MeshmyMesh
const SMDS_MeshElementmyCurrElement
long myPrecision
double myPrecisionValue

Detailed Description

Definition at line 206 of file SMESH_ControlsDef.hxx.


Member Function Documentation

double AspectRatio::GetBadRate ( double  Value,
int  nbNodes 
) const [virtual]

Implements SMESH.Controls.NumericalFunctor.

Definition at line 855 of file SMESH_Controls.cxx.

{
  // the aspect ratio is in the range [1.0,infinity]
  // 1.0 = good
  // infinity = bad
  return Value / 1000.;
}
void SMESH.Controls.NumericalFunctor.GetHistogram ( int  nbIntervals,
std::vector< int > &  nbEvents,
std::vector< double > &  funValues,
const std::vector< int > &  elements,
const double *  minmax = 0 
) [inherited]

Referenced by SaveDistribution().

bool NumericalFunctor::GetPoints ( const int  theId,
TSequenceOfXYZ theRes 
) const [inherited]
bool NumericalFunctor::GetPoints ( const SMDS_MeshElement theElem,
TSequenceOfXYZ theRes 
) [static, inherited]

Definition at line 239 of file SMESH_Controls.cxx.

References SMESH.Controls.TSequenceOfXYZ.clear(), SMDS_MeshElement.GetType(), SMDS_MeshElement.IsQuadratic(), SMDS_MeshElement.NbNodes(), SMDS_MeshElement.nodesIterator(), SMESH.Controls.TSequenceOfXYZ.push_back(), SMESH.Controls.TSequenceOfXYZ.reserve(), SMDSAbs_Edge, SMDSAbs_Face, SMDS_MeshNode.X(), SMDS_MeshNode.Y(), and SMDS_MeshNode.Z().

{
  theRes.clear();

  if ( anElem == 0)
    return false;

  theRes.reserve( anElem->NbNodes() );

  // Get nodes of the element
  SMDS_ElemIteratorPtr anIter;

  if ( anElem->IsQuadratic() ) {
    switch ( anElem->GetType() ) {
    case SMDSAbs_Edge:
      anIter = dynamic_cast<const SMDS_VtkEdge*>
        (anElem)->interlacedNodesElemIterator();
      break;
    case SMDSAbs_Face:
      anIter = dynamic_cast<const SMDS_VtkFace*>
        (anElem)->interlacedNodesElemIterator();
      break;
    default:
      anIter = anElem->nodesIterator();
      //return false;
    }
  }
  else {
    anIter = anElem->nodesIterator();
  }

  if ( anIter ) {
    while( anIter->more() ) {
      if ( const SMDS_MeshNode* aNode = static_cast<const SMDS_MeshNode*>( anIter->next() ))
        theRes.push_back( gp_XYZ( aNode->X(), aNode->Y(), aNode->Z() ) );
    }
  }

  return true;
}
long NumericalFunctor::GetPrecision ( ) const [inherited]

Definition at line 281 of file SMESH_Controls.cxx.

References SMESH.Controls.NumericalFunctor.myPrecision.

{
  return myPrecision;
}
SMDSAbs_ElementType AspectRatio::GetType ( ) const [virtual]

Implements SMESH.Controls.NumericalFunctor.

Definition at line 863 of file SMESH_Controls.cxx.

References SMDSAbs_Face.

{
  return SMDSAbs_Face;
}
double NumericalFunctor::GetValue ( long  theElementId) [virtual, inherited]
double AspectRatio::GetValue ( const TSequenceOfXYZ thePoints) [virtual]

Reimplemented from SMESH.Controls.NumericalFunctor.

Definition at line 710 of file SMESH_Controls.cxx.

References Max(), Min(), and SMESH.Controls.TSequenceOfXYZ.size().

Referenced by SMESH.Controls.AspectRatio3D.GetValue().

{
  // According to "Mesh quality control" by Nadir Bouhamau referring to
  // Pascal Jean Frey and Paul-Louis George. Maillages, applications aux elements finis.
  // Hermes Science publications, Paris 1999 ISBN 2-7462-0024-4
  // PAL10872

  int nbNodes = P.size();

  if ( nbNodes < 3 )
    return 0;

  // Compute aspect ratio

  if ( nbNodes == 3 ) {
    // Compute lengths of the sides
    std::vector< double > aLen (nbNodes);
    for ( int i = 0; i < nbNodes - 1; i++ )
      aLen[ i ] = getDistance( P( i + 1 ), P( i + 2 ) );
    aLen[ nbNodes - 1 ] = getDistance( P( 1 ), P( nbNodes ) );
    // Q = alfa * h * p / S, where
    //
    // alfa = sqrt( 3 ) / 6
    // h - length of the longest edge
    // p - half perimeter
    // S - triangle surface
    const double alfa = sqrt( 3. ) / 6.;
    double maxLen = Max( aLen[ 0 ], Max( aLen[ 1 ], aLen[ 2 ] ) );
    double half_perimeter = ( aLen[0] + aLen[1] + aLen[2] ) / 2.;
    double anArea = getArea( P( 1 ), P( 2 ), P( 3 ) );
    if ( anArea <= Precision::Confusion() )
      return 0.;
    return alfa * maxLen * half_perimeter / anArea;
  }
  else if ( nbNodes == 6 ) { // quadratic triangles
    // Compute lengths of the sides
    std::vector< double > aLen (3);
    aLen[0] = getDistance( P(1), P(3) );
    aLen[1] = getDistance( P(3), P(5) );
    aLen[2] = getDistance( P(5), P(1) );
    // Q = alfa * h * p / S, where
    //
    // alfa = sqrt( 3 ) / 6
    // h - length of the longest edge
    // p - half perimeter
    // S - triangle surface
    const double alfa = sqrt( 3. ) / 6.;
    double maxLen = Max( aLen[ 0 ], Max( aLen[ 1 ], aLen[ 2 ] ) );
    double half_perimeter = ( aLen[0] + aLen[1] + aLen[2] ) / 2.;
    double anArea = getArea( P(1), P(3), P(5) );
    if ( anArea <= Precision::Confusion() )
      return 0.;
    return alfa * maxLen * half_perimeter / anArea;
  }
  else if( nbNodes == 4 ) { // quadrangle
    // Compute lengths of the sides
    std::vector< double > aLen (4);
    aLen[0] = getDistance( P(1), P(2) );
    aLen[1] = getDistance( P(2), P(3) );
    aLen[2] = getDistance( P(3), P(4) );
    aLen[3] = getDistance( P(4), P(1) );
    // Compute lengths of the diagonals
    std::vector< double > aDia (2);
    aDia[0] = getDistance( P(1), P(3) );
    aDia[1] = getDistance( P(2), P(4) );
    // Compute areas of all triangles which can be built
    // taking three nodes of the quadrangle
    std::vector< double > anArea (4);
    anArea[0] = getArea( P(1), P(2), P(3) );
    anArea[1] = getArea( P(1), P(2), P(4) );
    anArea[2] = getArea( P(1), P(3), P(4) );
    anArea[3] = getArea( P(2), P(3), P(4) );
    // Q = alpha * L * C1 / C2, where
    //
    // alpha = sqrt( 1/32 )
    // L = max( L1, L2, L3, L4, D1, D2 )
    // C1 = sqrt( ( L1^2 + L1^2 + L1^2 + L1^2 ) / 4 )
    // C2 = min( S1, S2, S3, S4 )
    // Li - lengths of the edges
    // Di - lengths of the diagonals
    // Si - areas of the triangles
    const double alpha = sqrt( 1 / 32. );
    double L = Max( aLen[ 0 ],
                 Max( aLen[ 1 ],
                   Max( aLen[ 2 ],
                     Max( aLen[ 3 ],
                       Max( aDia[ 0 ], aDia[ 1 ] ) ) ) ) );
    double C1 = sqrt( ( aLen[0] * aLen[0] +
                        aLen[1] * aLen[1] +
                        aLen[2] * aLen[2] +
                        aLen[3] * aLen[3] ) / 4. );
    double C2 = Min( anArea[ 0 ],
                  Min( anArea[ 1 ],
                    Min( anArea[ 2 ], anArea[ 3 ] ) ) );
    if ( C2 <= Precision::Confusion() )
      return 0.;
    return alpha * L * C1 / C2;
  }
  else if( nbNodes == 8 ){ // nbNodes==8 - quadratic quadrangle
    // Compute lengths of the sides
    std::vector< double > aLen (4);
    aLen[0] = getDistance( P(1), P(3) );
    aLen[1] = getDistance( P(3), P(5) );
    aLen[2] = getDistance( P(5), P(7) );
    aLen[3] = getDistance( P(7), P(1) );
    // Compute lengths of the diagonals
    std::vector< double > aDia (2);
    aDia[0] = getDistance( P(1), P(5) );
    aDia[1] = getDistance( P(3), P(7) );
    // Compute areas of all triangles which can be built
    // taking three nodes of the quadrangle
    std::vector< double > anArea (4);
    anArea[0] = getArea( P(1), P(3), P(5) );
    anArea[1] = getArea( P(1), P(3), P(7) );
    anArea[2] = getArea( P(1), P(5), P(7) );
    anArea[3] = getArea( P(3), P(5), P(7) );
    // Q = alpha * L * C1 / C2, where
    //
    // alpha = sqrt( 1/32 )
    // L = max( L1, L2, L3, L4, D1, D2 )
    // C1 = sqrt( ( L1^2 + L1^2 + L1^2 + L1^2 ) / 4 )
    // C2 = min( S1, S2, S3, S4 )
    // Li - lengths of the edges
    // Di - lengths of the diagonals
    // Si - areas of the triangles
    const double alpha = sqrt( 1 / 32. );
    double L = Max( aLen[ 0 ],
                 Max( aLen[ 1 ],
                   Max( aLen[ 2 ],
                     Max( aLen[ 3 ],
                       Max( aDia[ 0 ], aDia[ 1 ] ) ) ) ) );
    double C1 = sqrt( ( aLen[0] * aLen[0] +
                        aLen[1] * aLen[1] +
                        aLen[2] * aLen[2] +
                        aLen[3] * aLen[3] ) / 4. );
    double C2 = Min( anArea[ 0 ],
                  Min( anArea[ 1 ],
                    Min( anArea[ 2 ], anArea[ 3 ] ) ) );
    if ( C2 <= Precision::Confusion() )
      return 0.;
    return alpha * L * C1 / C2;
  }
  return 0;
}
double NumericalFunctor::Round ( const double &  value) [inherited]
void NumericalFunctor::SetMesh ( const SMDS_Mesh theMesh) [virtual, inherited]

Implements SMESH.Controls.Functor.

Definition at line 223 of file SMESH_Controls.cxx.

References SMESH.Controls.NumericalFunctor.myMesh.

{
  myMesh = theMesh;
}
void NumericalFunctor::SetPrecision ( const long  thePrecision) [inherited]

Field Documentation

const SMDS_Mesh* SMESH.Controls.NumericalFunctor.myMesh [protected, inherited]
long SMESH.Controls.NumericalFunctor.myPrecision [protected, inherited]
double SMESH.Controls.NumericalFunctor.myPrecisionValue [protected, inherited]
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS