Version: 6.3.1
Public Member Functions | Private Member Functions | Private Attributes

SMESH.Controls.ElementsOnSurface Class Reference

#include <SMESH_ControlsDef.hxx>

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

Public Member Functions

 ElementsOnSurface ()
 ~ElementsOnSurface ()
virtual void SetMesh (const SMDS_Mesh *theMesh)
virtual bool IsSatisfy (long theElementId)
virtual SMDSAbs_ElementType GetType () const
void SetTolerance (const double theToler)
double GetTolerance () const
void SetSurface (const TopoDS_Shape &theShape, const SMDSAbs_ElementType theType)
void SetUseBoundaries (bool theUse)
bool GetUseBoundaries () const

Private Member Functions

void process ()
void process (const SMDS_MeshElement *theElem)
bool isOnSurface (const SMDS_MeshNode *theNode)

Private Attributes

const SMDS_MeshmyMesh
TColStd_MapOfInteger myIds
SMDSAbs_ElementType myType
TopoDS_Face mySurf
double myToler
bool myUseBoundaries
GeomAPI_ProjectPointOnSurf myProjector

Detailed Description

Definition at line 722 of file SMESH_ControlsDef.hxx.


Constructor & Destructor Documentation

ElementsOnSurface::ElementsOnSurface ( )

Definition at line 3417 of file SMESH_Controls.cxx.

References SMDS_Mesh.Clear(), SMESH.Controls.ManifoldPart.myMesh, and SMDSAbs_All.

{
  myMesh = 0;
  myIds.Clear();
  myType = SMDSAbs_All;
  mySurf.Nullify();
  myToler = Precision::Confusion();
  myUseBoundaries = false;
}
ElementsOnSurface::~ElementsOnSurface ( )

Definition at line 3427 of file SMESH_Controls.cxx.

References SMESH.Controls.ManifoldPart.myMesh.

{
  myMesh = 0;
}

Member Function Documentation

double ElementsOnSurface::GetTolerance ( ) const

Definition at line 3455 of file SMESH_Controls.cxx.

{ return myToler; }
SMDSAbs_ElementType ElementsOnSurface::GetType ( ) const [virtual]

Implements SMESH.Controls.Predicate.

Definition at line 3445 of file SMESH_Controls.cxx.

{ return myType; }
bool SMESH.Controls.ElementsOnSurface.GetUseBoundaries ( ) const

Definition at line 735 of file SMESH_ControlsDef.hxx.

{ return myUseBoundaries; }
bool ElementsOnSurface::isOnSurface ( const SMDS_MeshNode theNode) [private]

Definition at line 3537 of file SMESH_Controls.cxx.

References SMDS_MeshNode.X(), SMDS_MeshNode.Y(), and SMDS_MeshNode.Z().

{
  if ( mySurf.IsNull() )
    return false;

  gp_Pnt aPnt( theNode->X(), theNode->Y(), theNode->Z() );
  //  double aToler2 = myToler * myToler;
//   if ( mySurf->IsKind(STANDARD_TYPE(Geom_Plane)))
//   {
//     gp_Pln aPln = Handle(Geom_Plane)::DownCast(mySurf)->Pln();
//     if ( aPln.SquareDistance( aPnt ) > aToler2 )
//       return false;
//   }
//   else if ( mySurf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)))
//   {
//     gp_Cylinder aCyl = Handle(Geom_CylindricalSurface)::DownCast(mySurf)->Cylinder();
//     double aRad = aCyl.Radius();
//     gp_Ax3 anAxis = aCyl.Position();
//     gp_XYZ aLoc = aCyl.Location().XYZ();
//     double aXDist = anAxis.XDirection().XYZ() * ( aPnt.XYZ() - aLoc );
//     double aYDist = anAxis.YDirection().XYZ() * ( aPnt.XYZ() - aLoc );
//     if ( fabs(aXDist*aXDist + aYDist*aYDist - aRad*aRad) > aToler2 )
//       return false;
//   }
//   else
//     return false;
  myProjector.Perform( aPnt );
  bool isOn = ( myProjector.IsDone() && myProjector.LowerDistance() <= myToler );

  return isOn;
}
bool ElementsOnSurface::IsSatisfy ( long  theElementId) [virtual]

Implements SMESH.Controls.Predicate.

Definition at line 3440 of file SMESH_Controls.cxx.

{
  return myIds.Contains( theElementId );
}
void ElementsOnSurface::process ( ) [private]

Definition at line 3486 of file SMESH_Controls.cxx.

References SMDS_Mesh.edgesIterator(), SMDS_Mesh.facesIterator(), SMESH.Controls.ManifoldPart.myMesh, SMDS_Mesh.NbEdges(), SMDS_Mesh.NbFaces(), SMDS_Mesh.NbNodes(), SMDS_Mesh.nodesIterator(), SMESH.Controls.ManifoldPart.process(), SMDSAbs_All, SMDSAbs_Edge, SMDSAbs_Face, and SMDSAbs_Node.

{
  myIds.Clear();
  if ( mySurf.IsNull() )
    return;

  if ( myMesh == 0 )
    return;

  if ( myType == SMDSAbs_Face || myType == SMDSAbs_All )
  {
    myIds.ReSize( myMesh->NbFaces() );
    SMDS_FaceIteratorPtr anIter = myMesh->facesIterator();
    for(; anIter->more(); )
      process( anIter->next() );
  }

  if ( myType == SMDSAbs_Edge || myType == SMDSAbs_All )
  {
    myIds.ReSize( myIds.Extent() + myMesh->NbEdges() );
    SMDS_EdgeIteratorPtr anIter = myMesh->edgesIterator();
    for(; anIter->more(); )
      process( anIter->next() );
  }

  if ( myType == SMDSAbs_Node )
  {
    myIds.ReSize( myMesh->NbNodes() );
    SMDS_NodeIteratorPtr anIter = myMesh->nodesIterator();
    for(; anIter->more(); )
      process( anIter->next() );
  }
}
void ElementsOnSurface::process ( const SMDS_MeshElement theElem) [private]

Definition at line 3520 of file SMESH_Controls.cxx.

References SMDS_MeshElement.GetID(), and SMDS_MeshElement.nodesIterator().

{
  SMDS_ElemIteratorPtr aNodeItr = theElemPtr->nodesIterator();
  bool isSatisfy = true;
  for ( ; aNodeItr->more(); )
  {
    SMDS_MeshNode* aNode = (SMDS_MeshNode*)aNodeItr->next();
    if ( !isOnSurface( aNode ) )
    {
      isSatisfy = false;
      break;
    }
  }
  if ( isSatisfy )
    myIds.Add( theElemPtr->GetID() );
}
void ElementsOnSurface::SetMesh ( const SMDS_Mesh theMesh) [virtual]

Implements SMESH.Controls.Functor.

Definition at line 3432 of file SMESH_Controls.cxx.

References SMESH.Controls.ManifoldPart.myMesh, and SMESH.Controls.ManifoldPart.process().

{
  if ( myMesh == theMesh )
    return;
  myMesh = theMesh;
  process();
}
void ElementsOnSurface::SetSurface ( const TopoDS_Shape &  theShape,
const SMDSAbs_ElementType  theType 
)

Definition at line 3466 of file SMESH_Controls.cxx.

References SMESH.Handle(), and SMESH.Controls.ManifoldPart.process().

{
  myIds.Clear();
  myType = theType;
  mySurf.Nullify();
  if ( theShape.IsNull() || theShape.ShapeType() != TopAbs_FACE )
    return;
  mySurf = TopoDS::Face( theShape );
  BRepAdaptor_Surface SA( mySurf, myUseBoundaries );
  Standard_Real
    u1 = SA.FirstUParameter(),
    u2 = SA.LastUParameter(),
    v1 = SA.FirstVParameter(),
    v2 = SA.LastVParameter();
  Handle(Geom_Surface) surf = BRep_Tool::Surface( mySurf );
  myProjector.Init( surf, u1,u2, v1,v2 );
  process();
}
void ElementsOnSurface::SetTolerance ( const double  theToler)

Definition at line 3448 of file SMESH_Controls.cxx.

{
  if ( myToler != theToler )
    myIds.Clear();
  myToler = theToler;
}
void ElementsOnSurface::SetUseBoundaries ( bool  theUse)

Definition at line 3458 of file SMESH_Controls.cxx.

{
  if ( myUseBoundaries != theUse ) {
    myUseBoundaries = theUse;
    SetSurface( mySurf, myType );
  }
}

Field Documentation

TColStd_MapOfInteger SMESH.Controls.ElementsOnSurface.myIds [private]

Definition at line 744 of file SMESH_ControlsDef.hxx.

Definition at line 743 of file SMESH_ControlsDef.hxx.

GeomAPI_ProjectPointOnSurf SMESH.Controls.ElementsOnSurface.myProjector [private]

Definition at line 750 of file SMESH_ControlsDef.hxx.

Definition at line 747 of file SMESH_ControlsDef.hxx.

Definition at line 748 of file SMESH_ControlsDef.hxx.

Definition at line 745 of file SMESH_ControlsDef.hxx.

Definition at line 749 of file SMESH_ControlsDef.hxx.

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