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

SMESH.Controls.ElementsOnShape Class Reference

#include <SMESH_ControlsDef.hxx>

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

Public Member Functions

 ElementsOnShape ()
 ~ElementsOnShape ()
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 SetAllNodes (bool theAllNodes)
bool GetAllNodes () const
void SetShape (const TopoDS_Shape &theShape, const SMDSAbs_ElementType theType)

Private Member Functions

void addShape (const TopoDS_Shape &theShape)
void process ()
void process (const SMDS_MeshElement *theElem)

Private Attributes

const SMDS_MeshmyMesh
TColStd_MapOfInteger myIds
SMDSAbs_ElementType myType
TopoDS_Shape myShape
double myToler
bool myAllNodesFlag
TopTools_MapOfShape myShapesMap
TopAbs_ShapeEnum myCurShapeType
BRepClass3d_SolidClassifier myCurSC
GeomAPI_ProjectPointOnSurf myCurProjFace
TopoDS_Face myCurFace
GeomAPI_ProjectPointOnCurve myCurProjEdge
gp_Pnt myCurPnt

Detailed Description

Definition at line 761 of file SMESH_ControlsDef.hxx.


Constructor & Destructor Documentation

ElementsOnShape::ElementsOnShape ( )

Definition at line 3574 of file SMESH_Controls.cxx.

References SMESH.Controls.ElementsOnShape.myCurShapeType.

  : myMesh(0),
    myType(SMDSAbs_All),
    myToler(Precision::Confusion()),
    myAllNodesFlag(false)
{
  myCurShapeType = TopAbs_SHAPE;
}
ElementsOnShape::~ElementsOnShape ( )

Definition at line 3583 of file SMESH_Controls.cxx.

{
}

Member Function Documentation

void ElementsOnShape::addShape ( const TopoDS_Shape &  theShape) [private]

Definition at line 3660 of file SMESH_Controls.cxx.

References SMESH.Handle(), SMESH.Controls.ElementsOnShape.myCurFace, SMESH.Controls.ElementsOnShape.myCurPnt, SMESH.Controls.ElementsOnShape.myCurProjEdge, SMESH.Controls.ElementsOnShape.myCurProjFace, SMESH.Controls.ElementsOnShape.myCurSC, SMESH.Controls.ElementsOnShape.myCurShapeType, SMESH.Controls.ElementsOnShape.myMesh, SMESH.Controls.ElementsOnShape.myShapesMap, and SMESH.Controls.ElementsOnShape.process().

Referenced by SMESH.Controls.ElementsOnShape.SetShape().

{
  if (theShape.IsNull() || myMesh == 0)
    return;

  if (!myShapesMap.Add(theShape)) return;

  myCurShapeType = theShape.ShapeType();
  switch (myCurShapeType)
  {
  case TopAbs_COMPOUND:
  case TopAbs_COMPSOLID:
  case TopAbs_SHELL:
  case TopAbs_WIRE:
    {
      TopoDS_Iterator anIt (theShape, Standard_True, Standard_True);
      for (; anIt.More(); anIt.Next()) addShape(anIt.Value());
    }
    break;
  case TopAbs_SOLID:
    {
      myCurSC.Load(theShape);
      process();
    }
    break;
  case TopAbs_FACE:
    {
      TopoDS_Face aFace = TopoDS::Face(theShape);
      BRepAdaptor_Surface SA (aFace, true);
      Standard_Real
        u1 = SA.FirstUParameter(),
        u2 = SA.LastUParameter(),
        v1 = SA.FirstVParameter(),
        v2 = SA.LastVParameter();
      Handle(Geom_Surface) surf = BRep_Tool::Surface(aFace);
      myCurProjFace.Init(surf, u1,u2, v1,v2);
      myCurFace = aFace;
      process();
    }
    break;
  case TopAbs_EDGE:
    {
      TopoDS_Edge anEdge = TopoDS::Edge(theShape);
      Standard_Real u1, u2;
      Handle(Geom_Curve) curve = BRep_Tool::Curve(anEdge, u1, u2);
      myCurProjEdge.Init(curve, u1, u2);
      process();
    }
    break;
  case TopAbs_VERTEX:
    {
      TopoDS_Vertex aV = TopoDS::Vertex(theShape);
      myCurPnt = BRep_Tool::Pnt(aV);
      process();
    }
    break;
  default:
    break;
  }
}
bool SMESH.Controls.ElementsOnShape.GetAllNodes ( ) const

Definition at line 774 of file SMESH_ControlsDef.hxx.

{ return myAllNodesFlag; }
double ElementsOnShape::GetTolerance ( ) const

Definition at line 3613 of file SMESH_Controls.cxx.

References SMESH.Controls.ElementsOnShape.myToler.

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

Implements SMESH.Controls.Predicate.

Definition at line 3600 of file SMESH_Controls.cxx.

References SMESH.Controls.ElementsOnShape.myType.

{
  return myType;
}
bool ElementsOnShape::IsSatisfy ( long  theElementId) [virtual]

Implements SMESH.Controls.Predicate.

Definition at line 3595 of file SMESH_Controls.cxx.

References SMESH.Controls.ElementsOnShape.myIds.

{
  return myIds.Contains(theElementId);
}
void ElementsOnShape::process ( const SMDS_MeshElement theElem) [private]

Definition at line 3758 of file SMESH_Controls.cxx.

References SMDS_MeshElement.GetID(), SMESH.Controls.ElementsOnShape.myAllNodesFlag, SMESH.Controls.ElementsOnShape.myCurFace, SMESH.Controls.ElementsOnShape.myCurPnt, SMESH.Controls.ElementsOnShape.myCurProjEdge, SMESH.Controls.ElementsOnShape.myCurProjFace, SMESH.Controls.ElementsOnShape.myCurSC, SMESH.Controls.ElementsOnShape.myCurShapeType, SMESH.Controls.ElementsOnShape.myIds, SMESH.Controls.ElementsOnShape.myShape, SMESH.Controls.ElementsOnShape.myToler, SMDS_MeshElement.NbNodes(), SMDS_MeshElement.nodesIterator(), SMDS_MeshNode.X(), SMDS_MeshNode.Y(), and SMDS_MeshNode.Z().

{
  if (myShape.IsNull())
    return;

  SMDS_ElemIteratorPtr aNodeItr = theElemPtr->nodesIterator();
  bool isSatisfy = myAllNodesFlag;

  gp_XYZ centerXYZ (0, 0, 0);

  while (aNodeItr->more() && (isSatisfy == myAllNodesFlag))
  {
    SMDS_MeshNode* aNode = (SMDS_MeshNode*)aNodeItr->next();
    gp_Pnt aPnt (aNode->X(), aNode->Y(), aNode->Z());
    centerXYZ += aPnt.XYZ();

    switch (myCurShapeType)
    {
    case TopAbs_SOLID:
      {
        myCurSC.Perform(aPnt, myToler);
        isSatisfy = (myCurSC.State() == TopAbs_IN || myCurSC.State() == TopAbs_ON);
      }
      break;
    case TopAbs_FACE:
      {
        myCurProjFace.Perform(aPnt);
        isSatisfy = (myCurProjFace.IsDone() && myCurProjFace.LowerDistance() <= myToler);
        if (isSatisfy)
        {
          // check relatively the face
          Quantity_Parameter u, v;
          myCurProjFace.LowerDistanceParameters(u, v);
          gp_Pnt2d aProjPnt (u, v);
          BRepClass_FaceClassifier aClsf (myCurFace, aProjPnt, myToler);
          isSatisfy = (aClsf.State() == TopAbs_IN || aClsf.State() == TopAbs_ON);
        }
      }
      break;
    case TopAbs_EDGE:
      {
        myCurProjEdge.Perform(aPnt);
        isSatisfy = (myCurProjEdge.NbPoints() > 0 && myCurProjEdge.LowerDistance() <= myToler);
      }
      break;
    case TopAbs_VERTEX:
      {
        isSatisfy = (aPnt.Distance(myCurPnt) <= myToler);
      }
      break;
    default:
      {
        isSatisfy = false;
      }
    }
  }

  if (isSatisfy && myCurShapeType == TopAbs_SOLID) { // Check the center point for volumes MantisBug 0020168
    centerXYZ /= theElemPtr->NbNodes();
    gp_Pnt aCenterPnt (centerXYZ);
    myCurSC.Perform(aCenterPnt, myToler);
    if ( !(myCurSC.State() == TopAbs_IN || myCurSC.State() == TopAbs_ON))
      isSatisfy = false;
  }

  if (isSatisfy)
    myIds.Add(theElemPtr->GetID());
}
void ElementsOnShape::process ( ) [private]

Definition at line 3721 of file SMESH_Controls.cxx.

References SMDS_Mesh.edgesIterator(), SMDS_Mesh.facesIterator(), SMESH.Controls.ElementsOnShape.myMesh, SMESH.Controls.ElementsOnShape.myShape, SMESH.Controls.ElementsOnShape.myType, SMDS_Mesh.nodesIterator(), SMDSAbs_All, SMDSAbs_Edge, SMDSAbs_Face, SMDSAbs_Node, SMDSAbs_Volume, and SMDS_Mesh.volumesIterator().

Referenced by SMESH.Controls.ElementsOnShape.addShape().

{
  if (myShape.IsNull() || myMesh == 0)
    return;

  if (myType == SMDSAbs_Node)
  {
    SMDS_NodeIteratorPtr anIter = myMesh->nodesIterator();
    while (anIter->more())
      process(anIter->next());
  }
  else
  {
    if (myType == SMDSAbs_Edge || myType == SMDSAbs_All)
    {
      SMDS_EdgeIteratorPtr anIter = myMesh->edgesIterator();
      while (anIter->more())
        process(anIter->next());
    }

    if (myType == SMDSAbs_Face || myType == SMDSAbs_All)
    {
      SMDS_FaceIteratorPtr anIter = myMesh->facesIterator();
      while (anIter->more()) {
        process(anIter->next());
      }
    }

    if (myType == SMDSAbs_Volume || myType == SMDSAbs_All)
    {
      SMDS_VolumeIteratorPtr anIter = myMesh->volumesIterator();
      while (anIter->more())
        process(anIter->next());
    }
  }
}
void ElementsOnShape::SetAllNodes ( bool  theAllNodes)
void ElementsOnShape::SetMesh ( const SMDS_Mesh theMesh) [virtual]
void ElementsOnShape::SetShape ( const TopoDS_Shape &  theShape,
const SMDSAbs_ElementType  theType 
)
void ElementsOnShape::SetTolerance ( const double  theToler)

Field Documentation

GeomAPI_ProjectPointOnCurve SMESH.Controls.ElementsOnShape.myCurProjEdge [private]
GeomAPI_ProjectPointOnSurf SMESH.Controls.ElementsOnShape.myCurProjFace [private]
BRepClass3d_SolidClassifier SMESH.Controls.ElementsOnShape.myCurSC [private]
TColStd_MapOfInteger SMESH.Controls.ElementsOnShape.myIds [private]
TopTools_MapOfShape SMESH.Controls.ElementsOnShape.myShapesMap [private]
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