Back to index

salome-smesh  6.5.0
Public Member Functions | Public Attributes
VISCOUS::_SmoothNode Struct Reference

Data of node on a shrinked FACE. More...

Collaboration diagram for VISCOUS::_SmoothNode:
Collaboration graph
[legend]

List of all members.

Public Member Functions

bool Smooth (int &badNb, Handle(Geom_Surface)&surface, SMESH_MesherHelper &helper, const double refSign, bool isCentroidal, bool set3D)
 Perform smooth on the FACE.

Public Attributes

const SMDS_MeshNode * _node
vector< _Simplex_simplices

Detailed Description

Data of node on a shrinked FACE.

Definition at line 416 of file StdMeshers_ViscousLayers.cxx.


Member Function Documentation

bool _SmoothNode::Smooth ( int &  badNb,
Handle(Geom_Surface)&  surface,
SMESH_MesherHelper &  helper,
const double  refSign,
bool  isCentroidal,
bool  set3D 
)

Perform smooth on the FACE.

Return values:
bool- true if the node has been moved

Definition at line 4079 of file StdMeshers_ViscousLayers.cxx.

{
  const TopoDS_Face& face = TopoDS::Face( helper.GetSubShape() );

  // get uv of surrounding nodes
  vector<gp_XY> uv( _simplices.size() );
  for ( size_t i = 0; i < _simplices.size(); ++i )
    uv[i] = helper.GetNodeUV( face, _simplices[i]._nPrev, _node );

  // compute new UV for the node
  gp_XY newPos (0,0);
  if ( isCentroidal && _simplices.size() > 3 )
  {
    // average centers of diagonals wieghted with their reciprocal lengths
    if ( _simplices.size() == 4 )
    {
      double w1 = 1. / ( uv[2]-uv[0] ).SquareModulus();
      double w2 = 1. / ( uv[3]-uv[1] ).SquareModulus();
      newPos = ( w1 * ( uv[2]+uv[0] ) + w2 * ( uv[3]+uv[1] )) / ( w1+w2 ) / 2;
    }
    else
    {
      double sumWeight = 0;
      int nb = _simplices.size() == 4 ? 2 : _simplices.size();
      for ( int i = 0; i < nb; ++i )
      {
        int iFrom = i + 2;
        int iTo   = i + _simplices.size() - 1;
        for ( int j = iFrom; j < iTo; ++j )
        {
          int i2 = SMESH_MesherHelper::WrapIndex( j, _simplices.size() );
          double w = 1. / ( uv[i]-uv[i2] ).SquareModulus();
          sumWeight += w;
          newPos += w * ( uv[i]+uv[i2] );
        }
      }
      newPos /= 2 * sumWeight;
    }
  }
  else
  {
    // Laplacian smooth
    isCentroidal = false;
    for ( size_t i = 0; i < _simplices.size(); ++i )
      newPos += uv[i];
    newPos /= _simplices.size();
  }

  // count quality metrics (orientation) of triangles around the node
  int nbOkBefore = 0;
  gp_XY tgtUV = helper.GetNodeUV( face, _node );
  for ( unsigned i = 0; i < _simplices.size(); ++i )
    nbOkBefore += _simplices[i].IsForward( tgtUV, _node, face, helper, refSign );

  int nbOkAfter = 0;
  for ( unsigned i = 0; i < _simplices.size(); ++i )
    nbOkAfter += _simplices[i].IsForward( newPos, _node, face, helper, refSign );

  if ( nbOkAfter < nbOkBefore )
  {
    // if ( isCentroidal )
    //   return Smooth( badNb, surface, helper, refSign, !isCentroidal, set3D );
    badNb += _simplices.size() - nbOkBefore;
    return false;
  }

  SMDS_FacePosition* pos = static_cast<SMDS_FacePosition*>( _node->GetPosition() );
  pos->SetUParameter( newPos.X() );
  pos->SetVParameter( newPos.Y() );

#ifdef __myDEBUG
  set3D = true;
#endif
  if ( set3D )
  {
    gp_Pnt p = surface->Value( newPos.X(), newPos.Y() );
    const_cast< SMDS_MeshNode* >( _node )->setXYZ( p.X(), p.Y(), p.Z() );
    dumpMove( _node );
  }

  badNb += _simplices.size() - nbOkAfter;
  return ( (tgtUV-newPos).SquareModulus() > 1e-10 );
}

Member Data Documentation

const SMDS_MeshNode* VISCOUS::_SmoothNode::_node

Definition at line 418 of file StdMeshers_ViscousLayers.cxx.

Definition at line 420 of file StdMeshers_ViscousLayers.cxx.


The documentation for this struct was generated from the following file: