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

SMESH.Controls.BelongToGeom Class Reference

#include <SMESH_Filter_i.hxx>

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

Public Member Functions

 BelongToGeom ()
virtual void SetMesh (const SMDS_Mesh *theMesh)
virtual void SetGeom (const TopoDS_Shape &theShape)
virtual bool IsSatisfy (long theElementId)
virtual void SetType (SMDSAbs_ElementType theType)
virtual SMDSAbs_ElementType GetType () const
TopoDS_Shape GetShape ()
const SMESHDS_MeshGetMeshDS () const
void SetTolerance (double)
double GetTolerance ()

Private Member Functions

virtual void init ()

Private Attributes

TopoDS_Shape myShape
const SMESHDS_MeshmyMeshDS
SMDSAbs_ElementType myType
bool myIsSubshape
double myTolerance
Controls::ElementsOnShapePtr myElementsOnShapePtr

Detailed Description

Definition at line 56 of file SMESH_Filter_i.hxx.


Constructor & Destructor Documentation

Controls::BelongToGeom::BelongToGeom ( )

Definition at line 84 of file SMESH_Filter_i.cxx.

  : myMeshDS(NULL),
    myType(SMDSAbs_All),
    myIsSubshape(false),
    myTolerance(Precision::Confusion())
{}

Member Function Documentation

const SMESHDS_Mesh * Controls::BelongToGeom::GetMeshDS ( ) const

Definition at line 238 of file SMESH_Filter_i.cxx.

{
  return myMeshDS;
}
TopoDS_Shape Controls::BelongToGeom::GetShape ( )

Definition at line 233 of file SMESH_Filter_i.cxx.

{
  return myShape;
}
double Controls::BelongToGeom::GetTolerance ( )

Definition at line 250 of file SMESH_Filter_i.cxx.

{
  return myTolerance;
}
SMDSAbs_ElementType Controls::BelongToGeom::GetType ( ) const [virtual]

Implements SMESH.Controls.Predicate.

Definition at line 228 of file SMESH_Filter_i.cxx.

{
  return myType;
}
void Controls::BelongToGeom::init ( ) [private, virtual]

Definition at line 124 of file SMESH_Filter_i.cxx.

References IsSubShape().

{
  if (!myMeshDS || myShape.IsNull()) return;

  // is subshape of main shape?
  TopoDS_Shape aMainShape = myMeshDS->ShapeToMesh();
  if (aMainShape.IsNull()) {
    myIsSubshape = false;
  }
  else {
    TopTools_IndexedMapOfShape aMap;
    TopExp::MapShapes(aMainShape, aMap);
    myIsSubshape = IsSubShape(aMap, myShape);
  }

  if (!myIsSubshape)
  {
    myElementsOnShapePtr.reset(new Controls::ElementsOnShape());
    myElementsOnShapePtr->SetTolerance(myTolerance);
    myElementsOnShapePtr->SetAllNodes(true); // belong, while false means "lays on"
    myElementsOnShapePtr->SetMesh(myMeshDS);
    myElementsOnShapePtr->SetShape(myShape, myType);
  }
}
bool Controls::BelongToGeom::IsSatisfy ( long  theElementId) [virtual]

Implements SMESH.Controls.Predicate.

Definition at line 169 of file SMESH_Filter_i.cxx.

References SMDS_Position.GetTypeOfPosition(), IsContains(), SMDS_TOP_3DSPACE, SMDS_TOP_EDGE, SMDS_TOP_FACE, SMDS_TOP_VERTEX, SMDSAbs_All, SMDSAbs_Edge, SMDSAbs_Face, SMDSAbs_Node, and SMDSAbs_Volume.

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

  if (!myIsSubshape)
  {
    return myElementsOnShapePtr->IsSatisfy(theId);
  }

  // Case of submesh
  if (myType == SMDSAbs_Node)
  {
    if( const SMDS_MeshNode* aNode = myMeshDS->FindNode( theId ) )
    {
      const SMDS_PositionPtr& aPosition = aNode->GetPosition();
      SMDS_TypeOfPosition aTypeOfPosition = aPosition->GetTypeOfPosition();
      switch( aTypeOfPosition )
      {
      case SMDS_TOP_VERTEX : return IsContains( myMeshDS,myShape,aNode,TopAbs_VERTEX );
      case SMDS_TOP_EDGE   : return IsContains( myMeshDS,myShape,aNode,TopAbs_EDGE );
      case SMDS_TOP_FACE   : return IsContains( myMeshDS,myShape,aNode,TopAbs_FACE );
      case SMDS_TOP_3DSPACE: return IsContains( myMeshDS,myShape,aNode,TopAbs_SHELL );
      }
    }
  }
  else
  {
    if( const SMDS_MeshElement* anElem = myMeshDS->FindElement( theId ) )
    {
      if( myType == SMDSAbs_All )
      {
        return IsContains( myMeshDS,myShape,anElem,TopAbs_EDGE ) ||
               IsContains( myMeshDS,myShape,anElem,TopAbs_FACE ) ||
               IsContains( myMeshDS,myShape,anElem,TopAbs_SHELL )||
               IsContains( myMeshDS,myShape,anElem,TopAbs_SOLID );
      }
      else if( myType == anElem->GetType() )
      {
        switch( myType )
        {
        case SMDSAbs_Edge  : return IsContains( myMeshDS,myShape,anElem,TopAbs_EDGE );
        case SMDSAbs_Face  : return IsContains( myMeshDS,myShape,anElem,TopAbs_FACE );
        case SMDSAbs_Volume: return IsContains( myMeshDS,myShape,anElem,TopAbs_SHELL )||
                                    IsContains( myMeshDS,myShape,anElem,TopAbs_SOLID );
        }
      }
    }
  }

  return false;
}
void Controls::BelongToGeom::SetGeom ( const TopoDS_Shape &  theShape) [virtual]

Definition at line 97 of file SMESH_Filter_i.cxx.

{
  myShape = theShape;
  init();
}
void Controls::BelongToGeom::SetMesh ( const SMDS_Mesh theMesh) [virtual]

Implements SMESH.Controls.Functor.

Definition at line 91 of file SMESH_Filter_i.cxx.

{
  myMeshDS = dynamic_cast<const SMESHDS_Mesh*>(theMesh);
  init();
}
void Controls::BelongToGeom::SetTolerance ( double  theTolerance)

Definition at line 243 of file SMESH_Filter_i.cxx.

{
  myTolerance = theTolerance;
  if (!myIsSubshape)
    init();
}
void Controls::BelongToGeom::SetType ( SMDSAbs_ElementType  theType) [virtual]

Definition at line 222 of file SMESH_Filter_i.cxx.

{
  myType = theType;
  init();
}

Field Documentation

Definition at line 83 of file SMESH_Filter_i.hxx.

Definition at line 81 of file SMESH_Filter_i.hxx.

Definition at line 79 of file SMESH_Filter_i.hxx.

TopoDS_Shape SMESH.Controls.BelongToGeom.myShape [private]

Definition at line 78 of file SMESH_Filter_i.hxx.

Definition at line 82 of file SMESH_Filter_i.hxx.

Definition at line 80 of file SMESH_Filter_i.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