Version: 6.3.1
Data Structures | Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes

SMESH.Controls.Length2D Class Reference

#include <SMESH_ControlsDef.hxx>

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

Data Structures

struct  Value

Public Types

typedef std::set< ValueTValues

Public Member Functions

virtual double GetValue (long theElementId)
virtual double GetBadRate (double Value, int nbNodes) const
virtual SMDSAbs_ElementType GetType () const
void GetValues (TValues &theValues)
virtual void SetMesh (const SMDS_Mesh *theMesh)
virtual double GetValue (const TSequenceOfXYZ &thePoints)
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 293 of file SMESH_ControlsDef.hxx.


Member Typedef Documentation

Definition at line 304 of file SMESH_ControlsDef.hxx.


Member Function Documentation

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

Implements SMESH.Controls.NumericalFunctor.

Definition at line 1643 of file SMESH_Controls.cxx.

{
  // meaningless as it is not quality control functor
  return Value;
}
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 Length2D::GetType ( ) const [virtual]

Implements SMESH.Controls.NumericalFunctor.

Definition at line 1649 of file SMESH_Controls.cxx.

References SMDSAbs_Face.

{
  return SMDSAbs_Face;
}
double Length2D::GetValue ( long  theElementId) [virtual]

Reimplemented from SMESH.Controls.NumericalFunctor.

Definition at line 1447 of file SMESH_Controls.cxx.

References SMDS_Mesh.FindElement(), SMESH.Controls.NumericalFunctor.GetPoints(), SMDS_MeshElement.GetType(), Max(), SMESH.Controls.NumericalFunctor.myMesh, SMESH.Controls.NumericalFunctor.myPrecision, SMESH.Controls.TSequenceOfXYZ.size(), SMDSAbs_All, SMDSAbs_Edge, SMDSAbs_Face, SMDSAbs_Node, and SMDSAbs_Volume.

{
  TSequenceOfXYZ P;

  //cout<<"Length2D::GetValue"<<endl;
  if (GetPoints(theElementId,P)){
    //for(int jj=1; jj<=P.size(); jj++)
    //  cout<<"jj="<<jj<<" P("<<P(jj).X()<<","<<P(jj).Y()<<","<<P(jj).Z()<<")"<<endl;

    double  aVal;// = GetValue( P );
    const SMDS_MeshElement* aElem = myMesh->FindElement( theElementId );
    SMDSAbs_ElementType aType = aElem->GetType();

    int len = P.size();

    switch (aType){
    case SMDSAbs_All:
    case SMDSAbs_Node:
    case SMDSAbs_Edge:
      if (len == 2){
        aVal = getDistance( P( 1 ), P( 2 ) );
        break;
      }
      else if (len == 3){ // quadratic edge
        aVal = getDistance(P( 1 ),P( 3 )) + getDistance(P( 3 ),P( 2 ));
        break;
      }
    case SMDSAbs_Face:
      if (len == 3){ // triangles
        double L1 = getDistance(P( 1 ),P( 2 ));
        double L2 = getDistance(P( 2 ),P( 3 ));
        double L3 = getDistance(P( 3 ),P( 1 ));
        aVal = Max(L1,Max(L2,L3));
        break;
      }
      else if (len == 4){ // quadrangles
        double L1 = getDistance(P( 1 ),P( 2 ));
        double L2 = getDistance(P( 2 ),P( 3 ));
        double L3 = getDistance(P( 3 ),P( 4 ));
        double L4 = getDistance(P( 4 ),P( 1 ));
        aVal = Max(Max(L1,L2),Max(L3,L4));
        break;
      }
      if (len == 6){ // quadratic triangles
        double L1 = getDistance(P( 1 ),P( 2 )) + getDistance(P( 2 ),P( 3 ));
        double L2 = getDistance(P( 3 ),P( 4 )) + getDistance(P( 4 ),P( 5 ));
        double L3 = getDistance(P( 5 ),P( 6 )) + getDistance(P( 6 ),P( 1 ));
        aVal = Max(L1,Max(L2,L3));
        //cout<<"L1="<<L1<<" L2="<<L2<<"L3="<<L3<<" aVal="<<aVal<<endl;
        break;
      }
      else if (len == 8){ // quadratic quadrangles
        double L1 = getDistance(P( 1 ),P( 2 )) + getDistance(P( 2 ),P( 3 ));
        double L2 = getDistance(P( 3 ),P( 4 )) + getDistance(P( 4 ),P( 5 ));
        double L3 = getDistance(P( 5 ),P( 6 )) + getDistance(P( 6 ),P( 7 ));
        double L4 = getDistance(P( 7 ),P( 8 )) + getDistance(P( 8 ),P( 1 ));
        aVal = Max(Max(L1,L2),Max(L3,L4));
        break;
      }
    case SMDSAbs_Volume:
      if (len == 4){ // tetraidrs
        double L1 = getDistance(P( 1 ),P( 2 ));
        double L2 = getDistance(P( 2 ),P( 3 ));
        double L3 = getDistance(P( 3 ),P( 1 ));
        double L4 = getDistance(P( 1 ),P( 4 ));
        double L5 = getDistance(P( 2 ),P( 4 ));
        double L6 = getDistance(P( 3 ),P( 4 ));
        aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6));
        break;
      }
      else if (len == 5){ // piramids
        double L1 = getDistance(P( 1 ),P( 2 ));
        double L2 = getDistance(P( 2 ),P( 3 ));
        double L3 = getDistance(P( 3 ),P( 4 ));
        double L4 = getDistance(P( 4 ),P( 1 ));
        double L5 = getDistance(P( 1 ),P( 5 ));
        double L6 = getDistance(P( 2 ),P( 5 ));
        double L7 = getDistance(P( 3 ),P( 5 ));
        double L8 = getDistance(P( 4 ),P( 5 ));

        aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6));
        aVal = Max(aVal,Max(L7,L8));
        break;
      }
      else if (len == 6){ // pentaidres
        double L1 = getDistance(P( 1 ),P( 2 ));
        double L2 = getDistance(P( 2 ),P( 3 ));
        double L3 = getDistance(P( 3 ),P( 1 ));
        double L4 = getDistance(P( 4 ),P( 5 ));
        double L5 = getDistance(P( 5 ),P( 6 ));
        double L6 = getDistance(P( 6 ),P( 4 ));
        double L7 = getDistance(P( 1 ),P( 4 ));
        double L8 = getDistance(P( 2 ),P( 5 ));
        double L9 = getDistance(P( 3 ),P( 6 ));

        aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6));
        aVal = Max(aVal,Max(Max(L7,L8),L9));
        break;
      }
      else if (len == 8){ // hexaider
        double L1 = getDistance(P( 1 ),P( 2 ));
        double L2 = getDistance(P( 2 ),P( 3 ));
        double L3 = getDistance(P( 3 ),P( 4 ));
        double L4 = getDistance(P( 4 ),P( 1 ));
        double L5 = getDistance(P( 5 ),P( 6 ));
        double L6 = getDistance(P( 6 ),P( 7 ));
        double L7 = getDistance(P( 7 ),P( 8 ));
        double L8 = getDistance(P( 8 ),P( 5 ));
        double L9 = getDistance(P( 1 ),P( 5 ));
        double L10= getDistance(P( 2 ),P( 6 ));
        double L11= getDistance(P( 3 ),P( 7 ));
        double L12= getDistance(P( 4 ),P( 8 ));

        aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6));
        aVal = Max(aVal,Max(Max(L7,L8),Max(L9,L10)));
        aVal = Max(aVal,Max(L11,L12));
        break;

      }

      if (len == 10){ // quadratic tetraidrs
        double L1 = getDistance(P( 1 ),P( 5 )) + getDistance(P( 5 ),P( 2 ));
        double L2 = getDistance(P( 2 ),P( 6 )) + getDistance(P( 6 ),P( 3 ));
        double L3 = getDistance(P( 3 ),P( 7 )) + getDistance(P( 7 ),P( 1 ));
        double L4 = getDistance(P( 1 ),P( 8 )) + getDistance(P( 8 ),P( 4 ));
        double L5 = getDistance(P( 2 ),P( 9 )) + getDistance(P( 9 ),P( 4 ));
        double L6 = getDistance(P( 3 ),P( 10 )) + getDistance(P( 10 ),P( 4 ));
        aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6));
        break;
      }
      else if (len == 13){ // quadratic piramids
        double L1 = getDistance(P( 1 ),P( 6 )) + getDistance(P( 6 ),P( 2 ));
        double L2 = getDistance(P( 2 ),P( 7 )) + getDistance(P( 7 ),P( 3 ));
        double L3 = getDistance(P( 3 ),P( 8 )) + getDistance(P( 8 ),P( 4 ));
        double L4 = getDistance(P( 4 ),P( 9 )) + getDistance(P( 9 ),P( 1 ));
        double L5 = getDistance(P( 1 ),P( 10 )) + getDistance(P( 10 ),P( 5 ));
        double L6 = getDistance(P( 2 ),P( 11 )) + getDistance(P( 11 ),P( 5 ));
        double L7 = getDistance(P( 3 ),P( 12 )) + getDistance(P( 12 ),P( 5 ));
        double L8 = getDistance(P( 4 ),P( 13 )) + getDistance(P( 13 ),P( 5 ));
        aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6));
        aVal = Max(aVal,Max(L7,L8));
        break;
      }
      else if (len == 15){ // quadratic pentaidres
        double L1 = getDistance(P( 1 ),P( 7 )) + getDistance(P( 7 ),P( 2 ));
        double L2 = getDistance(P( 2 ),P( 8 )) + getDistance(P( 8 ),P( 3 ));
        double L3 = getDistance(P( 3 ),P( 9 )) + getDistance(P( 9 ),P( 1 ));
        double L4 = getDistance(P( 4 ),P( 10 )) + getDistance(P( 10 ),P( 5 ));
        double L5 = getDistance(P( 5 ),P( 11 )) + getDistance(P( 11 ),P( 6 ));
        double L6 = getDistance(P( 6 ),P( 12 )) + getDistance(P( 12 ),P( 4 ));
        double L7 = getDistance(P( 1 ),P( 13 )) + getDistance(P( 13 ),P( 4 ));
        double L8 = getDistance(P( 2 ),P( 14 )) + getDistance(P( 14 ),P( 5 ));
        double L9 = getDistance(P( 3 ),P( 15 )) + getDistance(P( 15 ),P( 6 ));
        aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6));
        aVal = Max(aVal,Max(Max(L7,L8),L9));
        break;
      }
      else if (len == 20){ // quadratic hexaider
        double L1 = getDistance(P( 1 ),P( 9 )) + getDistance(P( 9 ),P( 2 ));
        double L2 = getDistance(P( 2 ),P( 10 )) + getDistance(P( 10 ),P( 3 ));
        double L3 = getDistance(P( 3 ),P( 11 )) + getDistance(P( 11 ),P( 4 ));
        double L4 = getDistance(P( 4 ),P( 12 )) + getDistance(P( 12 ),P( 1 ));
        double L5 = getDistance(P( 5 ),P( 13 )) + getDistance(P( 13 ),P( 6 ));
        double L6 = getDistance(P( 6 ),P( 14 )) + getDistance(P( 14 ),P( 7 ));
        double L7 = getDistance(P( 7 ),P( 15 )) + getDistance(P( 15 ),P( 8 ));
        double L8 = getDistance(P( 8 ),P( 16 )) + getDistance(P( 16 ),P( 5 ));
        double L9 = getDistance(P( 1 ),P( 17 )) + getDistance(P( 17 ),P( 5 ));
        double L10= getDistance(P( 2 ),P( 18 )) + getDistance(P( 18 ),P( 6 ));
        double L11= getDistance(P( 3 ),P( 19 )) + getDistance(P( 19 ),P( 7 ));
        double L12= getDistance(P( 4 ),P( 20 )) + getDistance(P( 20 ),P( 8 ));
        aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(L5,L6));
        aVal = Max(aVal,Max(Max(L7,L8),Max(L9,L10)));
        aVal = Max(aVal,Max(L11,L12));
        break;

      }

    default: aVal=-1;
    }

    if (aVal <0){
      return 0.;
    }

    if ( myPrecision >= 0 )
    {
      double prec = pow( 10., (double)( myPrecision ) );
      aVal = floor( aVal * prec + 0.5 ) / prec;
    }

    return aVal;

  }
  return 0.;
}
virtual double SMESH.Controls.NumericalFunctor.GetValue ( const TSequenceOfXYZ thePoints) [virtual, inherited]
void Length2D::GetValues ( TValues theValues)

Definition at line 1670 of file SMESH_Controls.cxx.

References SMDS_Mesh.facesIterator(), SMDS_MeshElement.GetID(), SMDS_VtkFace.interlacedNodesElemIterator(), SMDS_MeshElement.IsQuadratic(), SMESH.Controls.NumericalFunctor.myMesh, SMDS_MeshElement.nodesIterator(), SMDS_MeshNode.X(), SMDS_MeshNode.Y(), and SMDS_MeshNode.Z().

                                          {
  TValues aValues;
  SMDS_FaceIteratorPtr anIter = myMesh->facesIterator();
  for(; anIter->more(); ){
    const SMDS_MeshFace* anElem = anIter->next();

    if(anElem->IsQuadratic()) {
      const SMDS_VtkFace* F =
        dynamic_cast<const SMDS_VtkFace*>(anElem);
      // use special nodes iterator
      SMDS_ElemIteratorPtr anIter = F->interlacedNodesElemIterator();
      long aNodeId[4];
      gp_Pnt P[4];

      double aLength;
      const SMDS_MeshElement* aNode;
      if(anIter->more()){
        aNode = anIter->next();
        const SMDS_MeshNode* aNodes = (SMDS_MeshNode*) aNode;
        P[0] = P[1] = gp_Pnt(aNodes->X(),aNodes->Y(),aNodes->Z());
        aNodeId[0] = aNodeId[1] = aNode->GetID();
        aLength = 0;
      }
      for(; anIter->more(); ){
        const SMDS_MeshNode* N1 = static_cast<const SMDS_MeshNode*> (anIter->next());
        P[2] = gp_Pnt(N1->X(),N1->Y(),N1->Z());
        aNodeId[2] = N1->GetID();
        aLength = P[1].Distance(P[2]);
        if(!anIter->more()) break;
        const SMDS_MeshNode* N2 = static_cast<const SMDS_MeshNode*> (anIter->next());
        P[3] = gp_Pnt(N2->X(),N2->Y(),N2->Z());
        aNodeId[3] = N2->GetID();
        aLength += P[2].Distance(P[3]);
        Value aValue1(aLength,aNodeId[1],aNodeId[2]);
        Value aValue2(aLength,aNodeId[2],aNodeId[3]);
        P[1] = P[3];
        aNodeId[1] = aNodeId[3];
        theValues.insert(aValue1);
        theValues.insert(aValue2);
      }
      aLength += P[2].Distance(P[0]);
      Value aValue1(aLength,aNodeId[1],aNodeId[2]);
      Value aValue2(aLength,aNodeId[2],aNodeId[0]);
      theValues.insert(aValue1);
      theValues.insert(aValue2);
    }
    else {
      SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
      long aNodeId[2];
      gp_Pnt P[3];

      double aLength;
      const SMDS_MeshElement* aNode;
      if(aNodesIter->more()){
        aNode = aNodesIter->next();
        const SMDS_MeshNode* aNodes = (SMDS_MeshNode*) aNode;
        P[0] = P[1] = gp_Pnt(aNodes->X(),aNodes->Y(),aNodes->Z());
        aNodeId[0] = aNodeId[1] = aNode->GetID();
        aLength = 0;
      }
      for(; aNodesIter->more(); ){
        aNode = aNodesIter->next();
        const SMDS_MeshNode* aNodes = (SMDS_MeshNode*) aNode;
        long anId = aNode->GetID();
        
        P[2] = gp_Pnt(aNodes->X(),aNodes->Y(),aNodes->Z());
        
        aLength = P[1].Distance(P[2]);
        
        Value aValue(aLength,aNodeId[1],anId);
        aNodeId[1] = anId;
        P[1] = P[2];
        theValues.insert(aValue);
      }

      aLength = P[0].Distance(P[1]);

      Value aValue(aLength,aNodeId[0],aNodeId[1]);
      theValues.insert(aValue);
    }
  }
}
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