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

SMESH_NumberFilter Class Reference

Class : SMESH_NumberFilter Description : Filter for geom or smesh objects. More...

#include <SMESH_NumberFilter.hxx>

Inheritance diagram for SMESH_NumberFilter:
Inheritance graph
[legend]

Public Member Functions

 SMESH_NumberFilter (const char *theKind, const TopAbs_ShapeEnum theSubShapeType, const int theNumber, const TopAbs_ShapeEnum theShapeType=TopAbs_SHAPE, GEOM::GEOM_Object_ptr theMainObj=GEOM::GEOM_Object::_nil(), const bool theIsClosedOnly=false)
 Class : SMESH_NumberFilter Description : Filter for geom objects.
 SMESH_NumberFilter (const char *theKind, const TopAbs_ShapeEnum theSubShapeType, const int theNumber, const TColStd_MapOfInteger &theShapeTypes, GEOM::GEOM_Object_ptr theMainObj=GEOM::GEOM_Object::_nil(), const bool theIsClosedOnly=false)
virtual ~SMESH_NumberFilter ()
virtual bool isOk (const SUIT_DataOwner *) const
void SetSubShapeType (const TopAbs_ShapeEnum)
void SetNumber (const int)
void SetClosedOnly (const bool)
void SetShapeType (const TopAbs_ShapeEnum)
void SetShapeTypes (const TColStd_MapOfInteger &)
void SetMainShape (GEOM::GEOM_Object_ptr)

Private Member Functions

GEOM::GEOM_Object_ptr getGeom (const SUIT_DataOwner *, const bool extractReference=true) const

Private Attributes

std::string myKind
TopAbs_ShapeEnum mySubShapeType
int myNumber
bool myIsClosedOnly
TColStd_MapOfInteger myShapeTypes
GEOM::GEOM_Object_var myMainObj

Detailed Description

Class : SMESH_NumberFilter Description : Filter for geom or smesh objects.

Filter geom objects by number of subshapes of the given type Parameters of constructor: * theSubShapeType - Type of subshape * theNumber - Number of subshapes. Object is selected if it contains theNumber of theSubShapeType sub-shapes, or at least one theSubShapeType, provided that theNumber==0 * theShapeType - This map specifies types of object to be selected * theMainObject - Sub-shapes of this object is selected only * theIsClosedOnly - Closed shapes is selected if this parameter is true

Definition at line 56 of file SMESH_NumberFilter.hxx.


Constructor & Destructor Documentation

SMESH_NumberFilter::SMESH_NumberFilter ( const char *  theKind,
const TopAbs_ShapeEnum  theSubShapeType,
const int  theNumber,
const TopAbs_ShapeEnum  theShapeType = TopAbs_SHAPE,
GEOM::GEOM_Object_ptr  theMainObj = GEOM::GEOM_Object::_nil(),
const bool  theIsClosedOnly = false 
)

Class : SMESH_NumberFilter Description : Filter for geom objects.

Filter geom objects by number of subshapes of the given type

Definition at line 55 of file SMESH_NumberFilter.cxx.

References myIsClosedOnly, myKind, myMainObj, myNumber, myShapeTypes, and mySubShapeType.

{
  myKind = (char*)theKind;
  mySubShapeType = theSubShapeType;
  myNumber = theNumber;
  myIsClosedOnly = theIsClosedOnly;
  myShapeTypes.Add(theShapeType);
  myMainObj = GEOM::GEOM_Object::_duplicate(theMainObj);
}
SMESH_NumberFilter::SMESH_NumberFilter ( const char *  theKind,
const TopAbs_ShapeEnum  theSubShapeType,
const int  theNumber,
const TColStd_MapOfInteger &  theShapeTypes,
GEOM::GEOM_Object_ptr  theMainObj = GEOM::GEOM_Object::_nil(),
const bool  theIsClosedOnly = false 
)

Definition at line 74 of file SMESH_NumberFilter.cxx.

References myIsClosedOnly, myKind, myMainObj, myNumber, myShapeTypes, and mySubShapeType.

{
  myKind = (char*)theKind;
  mySubShapeType = theSubShapeType;
  myNumber = theNumber;
  myIsClosedOnly = theIsClosedOnly;
  myShapeTypes = theShapeTypes;
  myMainObj = GEOM::GEOM_Object::_duplicate(theMainObj);
}
SMESH_NumberFilter::~SMESH_NumberFilter ( ) [virtual]

Definition at line 89 of file SMESH_NumberFilter.cxx.

{
}

Member Function Documentation

GEOM::GEOM_Object_ptr SMESH_NumberFilter::getGeom ( const SUIT_DataOwner *  theDataOwner,
const bool  extractReference = true 
) const [private]

Definition at line 156 of file SMESH_NumberFilter.cxx.

References _PTR().

Referenced by isOk().

{
  const LightApp_DataOwner* owner =
    dynamic_cast<const LightApp_DataOwner*>(theDataOwner);
  SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>
    (SUIT_Session::session()->activeApplication()->activeStudy());

  GEOM::GEOM_Object_var anObj;

  if (!owner || !appStudy)
    return GEOM::GEOM_Object::_nil();

  _PTR(Study) study = appStudy->studyDS();
  QString entry = owner->entry();

  _PTR(SObject) aSO( study->FindObjectID( entry.toLatin1().data() ) ), aRefSO;
  if( extractReference && aSO && aSO->ReferencedObject( aRefSO ) )
    aSO = aRefSO;

  if (!aSO)
    return GEOM::GEOM_Object::_nil();

  CORBA::Object_var anObject = _CAST(SObject,aSO)->GetObject();
  anObj = GEOM::GEOM_Object::_narrow(anObject);
  if (!CORBA::is_nil(anObj))
    return anObj._retn();

  // Get geom object corresponding to the mesh
  if ( myKind == "SMESH" ) {
    _PTR(ChildIterator) anIter = study->NewChildIterator(aSO);
    for (; anIter->More(); anIter->Next()) {
      _PTR(SObject) aSO = anIter->Value();
      if (!aSO)
        continue;
      _PTR(SObject) aRefSO;
      _PTR(SObject) anObj;
      if (aSO->ReferencedObject(aRefSO))
        anObj = aRefSO;

      if (!anObj)
        anObj = aSO;

      anObject = _CAST(SObject,anObj)->GetObject();
      GEOM::GEOM_Object_var aMeshShape = GEOM::GEOM_Object::_narrow(anObject);

      if (!aMeshShape->_is_nil())
        return aMeshShape._retn();
    }
  }

  return GEOM::GEOM_Object::_nil();
}
bool SMESH_NumberFilter::isOk ( const SUIT_DataOwner *  theDataOwner) const [virtual]

Definition at line 97 of file SMESH_NumberFilter.cxx.

References SMESH_fixation.aShape, getGeom(), myIsClosedOnly, myMainObj, myNumber, myShapeTypes, and mySubShapeType.

{
  if (!theDataOwner)
    return false;

  // Get geom object from IO
  GEOM::GEOM_Object_var aGeomObj = getGeom(theDataOwner);
  if (aGeomObj->_is_nil())
    return false;

  // Get shape from geom object and verify its parameters
  GEOM_Client aGeomClient;
  if ( CORBA::is_nil( GeometryGUI::GetGeomGen() ) && !GeometryGUI::InitGeomGen() )
    return false;
  TopoDS_Shape aShape = aGeomClient.GetShape(GeometryGUI::GetGeomGen(), aGeomObj);
  if (aShape.IsNull() ||
      !myShapeTypes.Contains(aShape.ShapeType()))
    return false;

  if (myIsClosedOnly && aShape.ShapeType() == TopAbs_SHELL && !aShape.Closed())
    return false;

  // Verify whether shape of entry object is sub-shape of myMainObj
  if (!myMainObj->_is_nil()) {
    TopoDS_Shape aMainShape = aGeomClient.GetShape(GeometryGUI::GetGeomGen(), myMainObj);
    if (aMainShape.IsNull())
      return false;

    bool isFound = false;
    TopAbs_ShapeEnum aShapeType = aShape.ShapeType();
    TopExp_Explorer anExp (aMainShape, aShapeType);
    for (; anExp.More(); anExp.Next()) {
      if (anExp.Current() == aShape) {
        isFound = true;
        break;
      }
    }
    if (!isFound)
      return false;
  }

  // Verify number of sub-shapes
  if (mySubShapeType == TopAbs_SHAPE);
    return true;

  TopTools_IndexedMapOfShape aMap;
  TopExp::MapShapes(aShape, mySubShapeType, aMap);

  if ( myNumber )
    return myNumber == aMap.Extent(); // given number

  return aMap.Extent(); // at least one?
}
void SMESH_NumberFilter::SetClosedOnly ( const bool  theIsClosedOnly)

Definition at line 219 of file SMESH_NumberFilter.cxx.

References myIsClosedOnly.

{
  myIsClosedOnly = theIsClosedOnly;
}
void SMESH_NumberFilter::SetMainShape ( GEOM::GEOM_Object_ptr  theMainObj)

Definition at line 229 of file SMESH_NumberFilter.cxx.

References myMainObj.

{
  myMainObj = GEOM::GEOM_Object::_duplicate(theMainObj);
}
void SMESH_NumberFilter::SetNumber ( const int  theNumber)

Definition at line 214 of file SMESH_NumberFilter.cxx.

References myNumber.

{
  myNumber = theNumber;
}
void SMESH_NumberFilter::SetShapeType ( const TopAbs_ShapeEnum  theShapeType)

Definition at line 224 of file SMESH_NumberFilter.cxx.

References myShapeTypes.

{
  myShapeTypes.Add( theShapeType );
}
void SMESH_NumberFilter.SetShapeTypes ( const TColStd_MapOfInteger &  )
void SMESH_NumberFilter::SetSubShapeType ( const TopAbs_ShapeEnum  theSubShapeType)

Definition at line 209 of file SMESH_NumberFilter.cxx.

References mySubShapeType.

{
  mySubShapeType = theSubShapeType;
}

Field Documentation

Definition at line 91 of file SMESH_NumberFilter.hxx.

Referenced by isOk(), SetClosedOnly(), and SMESH_NumberFilter().

std::string SMESH_NumberFilter.myKind [private]

Definition at line 88 of file SMESH_NumberFilter.hxx.

Referenced by SMESH_NumberFilter().

GEOM::GEOM_Object_var SMESH_NumberFilter.myMainObj [private]

Definition at line 93 of file SMESH_NumberFilter.hxx.

Referenced by isOk(), SetMainShape(), and SMESH_NumberFilter().

Definition at line 90 of file SMESH_NumberFilter.hxx.

Referenced by isOk(), SetNumber(), and SMESH_NumberFilter().

TColStd_MapOfInteger SMESH_NumberFilter.myShapeTypes [private]

Definition at line 92 of file SMESH_NumberFilter.hxx.

Referenced by isOk(), SetShapeType(), and SMESH_NumberFilter().

TopAbs_ShapeEnum SMESH_NumberFilter.mySubShapeType [private]

Definition at line 89 of file SMESH_NumberFilter.hxx.

Referenced by isOk(), SetSubShapeType(), and SMESH_NumberFilter().

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