Back to index

salome-smesh  6.5.0
Classes | Namespaces | Defines | Typedefs | Enumerations | Functions
StdMeshers_ViscousLayers.cxx File Reference
#include "StdMeshers_ViscousLayers.hxx"
#include "SMDS_EdgePosition.hxx"
#include "SMDS_FaceOfNodes.hxx"
#include "SMDS_FacePosition.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMDS_SetIterator.hxx"
#include "SMESHDS_Group.hxx"
#include "SMESHDS_Hypothesis.hxx"
#include "SMESH_Algo.hxx"
#include "SMESH_ComputeError.hxx"
#include "SMESH_ControlsDef.hxx"
#include "SMESH_Gen.hxx"
#include "SMESH_Group.hxx"
#include "SMESH_Mesh.hxx"
#include "SMESH_MesherHelper.hxx"
#include "SMESH_ProxyMesh.hxx"
#include "SMESH_subMesh.hxx"
#include "SMESH_subMeshEventListener.hxx"
#include "utilities.h"
#include <BRepAdaptor_Curve2d.hxx>
#include <BRep_Tool.hxx>
#include <Bnd_B2d.hxx>
#include <Bnd_B3d.hxx>
#include <ElCLib.hxx>
#include <GCPnts_AbscissaPoint.hxx>
#include <Geom2d_Circle.hxx>
#include <Geom2d_Line.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <Geom_Circle.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Line.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Precision.hxx>
#include <Standard_ErrorHandler.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Vertex.hxx>
#include <gp_Ax1.hxx>
#include <gp_Vec.hxx>
#include <gp_XY.hxx>
#include <list>
#include <string>
#include <cmath>
#include <limits>

Go to the source code of this file.

Classes

struct  VISCOUS::_MeshOfSolid
 SMESH_ProxyMesh computed by _ViscousBuilder for a SOLID. More...
class  VISCOUS::_SrinkShapeListener
 Listener of events of 3D sub-meshes computed with viscous layers. More...
class  VISCOUS::_ViscousListener
 Listener of events of 3D sub-meshes computed with viscous layers. More...
struct  VISCOUS::_Simplex
 Simplex (triangle or tetrahedron) based on 1 (tria) or 2 (tet) nodes of _LayerEdge and 2 nodes of the mesh surface beening smoothed. More...
struct  VISCOUS::_Curvature
 Structure used to take into account surface curvature while smoothing. More...
struct  VISCOUS::_2NearEdges
 Structure used to smooth a _LayerEdge (master) based on an EDGE. More...
struct  VISCOUS::_LayerEdge
 Edge normal to surface, connecting a node on solid surface (_nodes[0]) and a node of the most internal layer (_nodes.back()) More...
struct  VISCOUS::_LayerEdgeCmp
struct  VISCOUS::_SolidData
 Data of a SOLID. More...
struct  VISCOUS::_SmoothNode
 Data of node on a shrinked FACE. More...
class  VISCOUS::_ViscousBuilder
 Builder of viscous layers. More...
class  VISCOUS::_Shrinker1D
 Shrinker of nodes on the EDGE. More...
struct  VISCOUS::TmpMeshFace
 Class of temporary mesh face. More...
struct  VISCOUS::TmpMeshFaceOnEdge
 Class of temporary mesh face storing _LayerEdge it's based on. More...

Namespaces

namespace  VISCOUS

Defines

#define dumpFunction(f)   f
#define dumpMove(n)
#define dumpCmd(txt)
#define dumpFunctionEnd()
#define dumpChangeNodes(f)

Typedefs

typedef int VISCOUS::TGeomID
typedef map< const
SMDS_MeshNode *, _LayerEdge
*, TIDCompare
VISCOUS::TNode2Edge

Enumerations

enum  VISCOUS::UIndex { VISCOUS::U_TGT = 1, VISCOUS::U_SRC, VISCOUS::LEN_TGT }

Functions

 Handle (Geom_Curve) _SolidData
 Return a curve of the EDGE to be used for smoothing and arrange _LayerEdge's to be in a consequent order.

Define Documentation

#define dumpChangeNodes (   f)

Definition at line 847 of file StdMeshers_ViscousLayers.cxx.

#define dumpCmd (   txt)

Definition at line 845 of file StdMeshers_ViscousLayers.cxx.

#define dumpFunction (   f)    f

Definition at line 843 of file StdMeshers_ViscousLayers.cxx.

#define dumpFunctionEnd ( )

Definition at line 846 of file StdMeshers_ViscousLayers.cxx.

#define dumpMove (   n)

Definition at line 844 of file StdMeshers_ViscousLayers.cxx.


Function Documentation

Handle ( Geom_Curve  )

Return a curve of the EDGE to be used for smoothing and arrange _LayerEdge's to be in a consequent order.

Definition at line 2289 of file StdMeshers_ViscousLayers.cxx.

{
  TGeomID eIndex = helper.GetMeshDS()->ShapeToIndex( E );

  map< TGeomID, Handle(Geom_Curve)>::iterator i2curve = _edge2curve.find( eIndex );

  if ( i2curve == _edge2curve.end() )
  {
    // sort _LayerEdge's by position on the EDGE
    {
      map< double, _LayerEdge* > u2edge;
      for ( int i = iFrom; i < iTo; ++i )
        u2edge.insert( make_pair( helper.GetNodeU( E, _edges[i]->_nodes[0] ), _edges[i] ));

      ASSERT( u2edge.size() == iTo - iFrom );
      map< double, _LayerEdge* >::iterator u2e = u2edge.begin();
      for ( int i = iFrom; i < iTo; ++i, ++u2e )
        _edges[i] = u2e->second;

      // set _2neibors according to the new order
      for ( int i = iFrom; i < iTo-1; ++i )
        if ( _edges[i]->_2neibors->_nodes[1] != _edges[i+1]->_nodes.back() )
          _edges[i]->_2neibors->reverse();
      if ( u2edge.size() > 1 &&
           _edges[iTo-1]->_2neibors->_nodes[0] != _edges[iTo-2]->_nodes.back() )
        _edges[iTo-1]->_2neibors->reverse();
    }

    SMESHDS_SubMesh* smDS = helper.GetMeshDS()->MeshElements( eIndex );

    TopLoc_Location loc; double f,l;

    Handle(Geom_Line)   line;
    Handle(Geom_Circle) circle;
    bool isLine, isCirc;
    if ( F.IsNull() ) // 3D case
    {
      // check if the EDGE is a line
      Handle(Geom_Curve) curve = BRep_Tool::Curve( E, loc, f, l);
      if ( curve->IsKind( STANDARD_TYPE( Geom_TrimmedCurve )))
        curve = Handle(Geom_TrimmedCurve)::DownCast( curve )->BasisCurve();

      line   = Handle(Geom_Line)::DownCast( curve );
      circle = Handle(Geom_Circle)::DownCast( curve );
      isLine = (!line.IsNull());
      isCirc = (!circle.IsNull());

      if ( !isLine && !isCirc ) // Check if the EDGE is close to a line
      {
        Bnd_B3d bndBox;
        SMDS_NodeIteratorPtr nIt = smDS->GetNodes();
        while ( nIt->more() )
          bndBox.Add( SMESH_TNodeXYZ( nIt->next() ));
        gp_XYZ size = bndBox.CornerMax() - bndBox.CornerMin();

        SMESH_TNodeXYZ p0( _edges[iFrom]->_2neibors->_nodes[0] );
        SMESH_TNodeXYZ p1( _edges[iFrom]->_2neibors->_nodes[1] );
        const double lineTol = 1e-2 * ( p0 - p1 ).Modulus();
        for ( int i = 0; i < 3 && !isLine; ++i )
          isLine = ( size.Coord( i+1 ) <= lineTol );
      }
      if ( !isLine && !isCirc && iTo-iFrom > 2) // Check if the EDGE is close to a circle
      {
        // TODO
      }
    }
    else // 2D case
    {
      // check if the EDGE is a line
      Handle(Geom2d_Curve) curve = BRep_Tool::CurveOnSurface( E, F, f, l);
      if ( curve->IsKind( STANDARD_TYPE( Geom2d_TrimmedCurve )))
        curve = Handle(Geom2d_TrimmedCurve)::DownCast( curve )->BasisCurve();

      Handle(Geom2d_Line)   line2d   = Handle(Geom2d_Line)::DownCast( curve );
      Handle(Geom2d_Circle) circle2d = Handle(Geom2d_Circle)::DownCast( curve );
      isLine = (!line2d.IsNull());
      isCirc = (!circle2d.IsNull());

      if ( !isLine && !isCirc) // Check if the EDGE is close to a line
      {
        Bnd_B2d bndBox;
        SMDS_NodeIteratorPtr nIt = smDS->GetNodes();
        while ( nIt->more() )
          bndBox.Add( helper.GetNodeUV( F, nIt->next() ));
        gp_XY size = bndBox.CornerMax() - bndBox.CornerMin();

        const double lineTol = 1e-2 * sqrt( bndBox.SquareExtent() );
        for ( int i = 0; i < 2 && !isLine; ++i )
          isLine = ( size.Coord( i+1 ) <= lineTol );
      }
      if ( !isLine && !isCirc && iTo-iFrom > 2) // Check if the EDGE is close to a circle
      {
        // TODO
      }
      if ( isLine )
      {
        line = new Geom_Line( gp::OX() ); // only type does matter
      }
      else if ( isCirc )
      {
        gp_Pnt2d p = circle2d->Location();
        gp_Ax2 ax( gp_Pnt( p.X(), p.Y(), 0), gp::DX());
        circle = new Geom_Circle( ax, 1.); // only center position does matter
      }
    }

    Handle(Geom_Curve)& res = _edge2curve[ eIndex ];
    if ( isLine )
      res = line;
    else if ( isCirc )
      res = circle;

    return res;
  }
  return i2curve->second;
}

Here is the call graph for this function: