PythonDump for SMESH Controls / Filter

This commit is contained in:
apo 2005-03-29 14:29:33 +00:00
parent 108ee5d360
commit 83630f8314
12 changed files with 1191 additions and 797 deletions

View File

@ -33,6 +33,8 @@
module SMESH module SMESH
{ {
interface Predicate;
/*! /*!
* SMESH_Group: base interface of group object * SMESH_Group: base interface of group object
*/ */
@ -98,11 +100,13 @@ module SMESH
* Adds elements to the group * Adds elements to the group
*/ */
long Add( in long_array elem_ids ); long Add( in long_array elem_ids );
long AddByPredicate( in Predicate thePredicate );
/*! /*!
* Removes elements from the group * Removes elements from the group
*/ */
long Remove( in long_array elem_ids ); long Remove( in long_array elem_ids );
long RemoveByPredicate( in Predicate thePredicate );
}; };
/*! /*!

View File

@ -81,7 +81,7 @@ namespace{
return aDist; return aDist;
} }
int getNbMultiConnection( SMDS_Mesh* theMesh, const int theId ) int getNbMultiConnection( const SMDS_Mesh* theMesh, const int theId )
{ {
if ( theMesh == 0 ) if ( theMesh == 0 )
return 0; return 0;
@ -137,7 +137,7 @@ NumericalFunctor::NumericalFunctor():
myPrecision = -1; myPrecision = -1;
} }
void NumericalFunctor::SetMesh( SMDS_Mesh* theMesh ) void NumericalFunctor::SetMesh( const SMDS_Mesh* theMesh )
{ {
myMesh = theMesh; myMesh = theMesh;
} }
@ -1030,7 +1030,6 @@ double MultiConnection2D::GetValue( long theElementId )
int aResult = 0; int aResult = 0;
if (GetPoints(theElementId,P)){ if (GetPoints(theElementId,P)){
double aVal;
const SMDS_MeshElement* anFaceElem = myMesh->FindElement( theElementId ); const SMDS_MeshElement* anFaceElem = myMesh->FindElement( theElementId );
SMDSAbs_ElementType aType = anFaceElem->GetType(); SMDSAbs_ElementType aType = anFaceElem->GetType();
@ -1112,7 +1111,6 @@ void MultiConnection2D::GetValues(MValues& theValues){
SMDS_FaceIteratorPtr anIter = myMesh->facesIterator(); SMDS_FaceIteratorPtr anIter = myMesh->facesIterator();
for(; anIter->more(); ){ for(; anIter->more(); ){
const SMDS_MeshFace* anElem = anIter->next(); const SMDS_MeshFace* anElem = anIter->next();
long anElemId = anElem->GetID();
SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator(); SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
long aNodeId[3]; long aNodeId[3];
@ -1172,7 +1170,7 @@ BadOrientedVolume::BadOrientedVolume()
myMesh = 0; myMesh = 0;
} }
void BadOrientedVolume::SetMesh( SMDS_Mesh* theMesh ) void BadOrientedVolume::SetMesh( const SMDS_Mesh* theMesh )
{ {
myMesh = theMesh; myMesh = theMesh;
} }
@ -1203,7 +1201,7 @@ FreeBorders::FreeBorders()
myMesh = 0; myMesh = 0;
} }
void FreeBorders::SetMesh( SMDS_Mesh* theMesh ) void FreeBorders::SetMesh( const SMDS_Mesh* theMesh )
{ {
myMesh = theMesh; myMesh = theMesh;
} }
@ -1228,7 +1226,7 @@ FreeEdges::FreeEdges()
myMesh = 0; myMesh = 0;
} }
void FreeEdges::SetMesh( SMDS_Mesh* theMesh ) void FreeEdges::SetMesh( const SMDS_Mesh* theMesh )
{ {
myMesh = theMesh; myMesh = theMesh;
} }
@ -1375,7 +1373,7 @@ RangeOfIds::RangeOfIds()
// name : SetMesh // name : SetMesh
// Purpose : Set mesh // Purpose : Set mesh
//======================================================================= //=======================================================================
void RangeOfIds::SetMesh( SMDS_Mesh* theMesh ) void RangeOfIds::SetMesh( const SMDS_Mesh* theMesh )
{ {
myMesh = theMesh; myMesh = theMesh;
} }
@ -1577,7 +1575,7 @@ Comparator::Comparator():
Comparator::~Comparator() Comparator::~Comparator()
{} {}
void Comparator::SetMesh( SMDS_Mesh* theMesh ) void Comparator::SetMesh( const SMDS_Mesh* theMesh )
{ {
if ( myFunctor ) if ( myFunctor )
myFunctor->SetMesh( theMesh ); myFunctor->SetMesh( theMesh );
@ -1662,7 +1660,7 @@ bool LogicalNOT::IsSatisfy( long theId )
return myPredicate && !myPredicate->IsSatisfy( theId ); return myPredicate && !myPredicate->IsSatisfy( theId );
} }
void LogicalNOT::SetMesh( SMDS_Mesh* theMesh ) void LogicalNOT::SetMesh( const SMDS_Mesh* theMesh )
{ {
if ( myPredicate ) if ( myPredicate )
myPredicate->SetMesh( theMesh ); myPredicate->SetMesh( theMesh );
@ -1689,7 +1687,7 @@ LogicalBinary::LogicalBinary()
LogicalBinary::~LogicalBinary() LogicalBinary::~LogicalBinary()
{} {}
void LogicalBinary::SetMesh( SMDS_Mesh* theMesh ) void LogicalBinary::SetMesh( const SMDS_Mesh* theMesh )
{ {
if ( myPredicate1 ) if ( myPredicate1 )
myPredicate1->SetMesh( theMesh ); myPredicate1->SetMesh( theMesh );
@ -1763,9 +1761,8 @@ void Filter::SetPredicate( PredicatePtr thePredicate )
myPredicate = thePredicate; myPredicate = thePredicate;
} }
template<class TElement, class TIterator, class TPredicate> template<class TElement, class TIterator, class TPredicate>
void FillSequence(const TIterator& theIterator, inline void FillSequence(const TIterator& theIterator,
TPredicate& thePredicate, TPredicate& thePredicate,
Filter::TIdSequence& theSequence) Filter::TIdSequence& theSequence)
{ {
@ -1779,40 +1776,46 @@ void FillSequence(const TIterator& theIterator,
} }
} }
Filter::TIdSequence void
Filter::GetElementsId( SMDS_Mesh* theMesh ) Filter::
GetElementsId( const SMDS_Mesh* theMesh,
PredicatePtr thePredicate,
TIdSequence& theSequence )
{ {
TIdSequence aSequence; theSequence.clear();
if ( !theMesh || !myPredicate ) return aSequence;
myPredicate->SetMesh( theMesh ); if ( !theMesh || !thePredicate )
return;
SMDSAbs_ElementType aType = myPredicate->GetType(); thePredicate->SetMesh( theMesh );
SMDSAbs_ElementType aType = thePredicate->GetType();
switch(aType){ switch(aType){
case SMDSAbs_Node:{ case SMDSAbs_Node:
FillSequence<const SMDS_MeshNode*>(theMesh->nodesIterator(),myPredicate,aSequence); FillSequence<const SMDS_MeshNode*>(theMesh->nodesIterator(),thePredicate,theSequence);
break;
case SMDSAbs_Edge:
FillSequence<const SMDS_MeshElement*>(theMesh->edgesIterator(),thePredicate,theSequence);
break;
case SMDSAbs_Face:
FillSequence<const SMDS_MeshElement*>(theMesh->facesIterator(),thePredicate,theSequence);
break;
case SMDSAbs_Volume:
FillSequence<const SMDS_MeshElement*>(theMesh->volumesIterator(),thePredicate,theSequence);
break;
case SMDSAbs_All:
FillSequence<const SMDS_MeshElement*>(theMesh->edgesIterator(),thePredicate,theSequence);
FillSequence<const SMDS_MeshElement*>(theMesh->facesIterator(),thePredicate,theSequence);
FillSequence<const SMDS_MeshElement*>(theMesh->volumesIterator(),thePredicate,theSequence);
break; break;
} }
case SMDSAbs_Edge:{ }
FillSequence<const SMDS_MeshElement*>(theMesh->edgesIterator(),myPredicate,aSequence);
break; void
} Filter::GetElementsId( const SMDS_Mesh* theMesh,
case SMDSAbs_Face:{ Filter::TIdSequence& theSequence )
FillSequence<const SMDS_MeshElement*>(theMesh->facesIterator(),myPredicate,aSequence); {
break; GetElementsId(theMesh,myPredicate,theSequence);
}
case SMDSAbs_Volume:{
FillSequence<const SMDS_MeshElement*>(theMesh->volumesIterator(),myPredicate,aSequence);
break;
}
case SMDSAbs_All:{
FillSequence<const SMDS_MeshElement*>(theMesh->edgesIterator(),myPredicate,aSequence);
FillSequence<const SMDS_MeshElement*>(theMesh->facesIterator(),myPredicate,aSequence);
FillSequence<const SMDS_MeshElement*>(theMesh->volumesIterator(),myPredicate,aSequence);
break;
}
}
return aSequence;
} }
/* /*
@ -1876,7 +1879,7 @@ ManifoldPart::~ManifoldPart()
myMesh = 0; myMesh = 0;
} }
void ManifoldPart::SetMesh( SMDS_Mesh* theMesh ) void ManifoldPart::SetMesh( const SMDS_Mesh* theMesh )
{ {
myMesh = theMesh; myMesh = theMesh;
process(); process();
@ -2205,7 +2208,7 @@ ElementsOnSurface::~ElementsOnSurface()
myMesh = 0; myMesh = 0;
} }
void ElementsOnSurface::SetMesh( SMDS_Mesh* theMesh ) void ElementsOnSurface::SetMesh( const SMDS_Mesh* theMesh )
{ {
if ( myMesh == theMesh ) if ( myMesh == theMesh )
return; return;

View File

@ -97,14 +97,14 @@ namespace SMESH{
{ {
public: public:
~Functor(){} ~Functor(){}
virtual void SetMesh( SMDS_Mesh* theMesh ) = 0; virtual void SetMesh( const SMDS_Mesh* theMesh ) = 0;
virtual SMDSAbs_ElementType GetType() const = 0; virtual SMDSAbs_ElementType GetType() const = 0;
}; };
class NumericalFunctor: public virtual Functor{ class NumericalFunctor: public virtual Functor{
public: public:
NumericalFunctor(); NumericalFunctor();
virtual void SetMesh( SMDS_Mesh* theMesh ); virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual double GetValue( long theElementId ); virtual double GetValue( long theElementId );
virtual double GetValue(const TSequenceOfXYZ& thePoints) { return -1.0;}; virtual double GetValue(const TSequenceOfXYZ& thePoints) { return -1.0;};
virtual SMDSAbs_ElementType GetType() const = 0; virtual SMDSAbs_ElementType GetType() const = 0;
@ -117,7 +117,7 @@ namespace SMESH{
static bool GetPoints(const SMDS_MeshElement* theElem, static bool GetPoints(const SMDS_MeshElement* theElem,
TSequenceOfXYZ& theRes); TSequenceOfXYZ& theRes);
protected: protected:
SMDS_Mesh* myMesh; const SMDS_Mesh* myMesh;
long myPrecision; long myPrecision;
}; };
@ -295,12 +295,12 @@ namespace SMESH{
class FreeBorders: public virtual Predicate{ class FreeBorders: public virtual Predicate{
public: public:
FreeBorders(); FreeBorders();
virtual void SetMesh( SMDS_Mesh* theMesh ); virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual bool IsSatisfy( long theElementId ); virtual bool IsSatisfy( long theElementId );
virtual SMDSAbs_ElementType GetType() const; virtual SMDSAbs_ElementType GetType() const;
protected: protected:
SMDS_Mesh* myMesh; const SMDS_Mesh* myMesh;
}; };
@ -311,12 +311,12 @@ namespace SMESH{
class BadOrientedVolume: public virtual Predicate{ class BadOrientedVolume: public virtual Predicate{
public: public:
BadOrientedVolume(); BadOrientedVolume();
virtual void SetMesh( SMDS_Mesh* theMesh ); virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual bool IsSatisfy( long theElementId ); virtual bool IsSatisfy( long theElementId );
virtual SMDSAbs_ElementType GetType() const; virtual SMDSAbs_ElementType GetType() const;
protected: protected:
SMDS_Mesh* myMesh; const SMDS_Mesh* myMesh;
}; };
@ -327,7 +327,7 @@ namespace SMESH{
class FreeEdges: public virtual Predicate{ class FreeEdges: public virtual Predicate{
public: public:
FreeEdges(); FreeEdges();
virtual void SetMesh( SMDS_Mesh* theMesh ); virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual bool IsSatisfy( long theElementId ); virtual bool IsSatisfy( long theElementId );
virtual SMDSAbs_ElementType GetType() const; virtual SMDSAbs_ElementType GetType() const;
static bool IsFreeEdge( const SMDS_MeshNode** theNodes, const int theFaceId ); static bool IsFreeEdge( const SMDS_MeshNode** theNodes, const int theFaceId );
@ -342,7 +342,7 @@ namespace SMESH{
void GetBoreders(TBorders& theBorders); void GetBoreders(TBorders& theBorders);
protected: protected:
SMDS_Mesh* myMesh; const SMDS_Mesh* myMesh;
}; };
typedef boost::shared_ptr<FreeEdges> FreeEdgesPtr; typedef boost::shared_ptr<FreeEdges> FreeEdgesPtr;
@ -359,7 +359,7 @@ namespace SMESH{
{ {
public: public:
RangeOfIds(); RangeOfIds();
virtual void SetMesh( SMDS_Mesh* theMesh ); virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual bool IsSatisfy( long theNodeId ); virtual bool IsSatisfy( long theNodeId );
virtual SMDSAbs_ElementType GetType() const; virtual SMDSAbs_ElementType GetType() const;
virtual void SetType( SMDSAbs_ElementType theType ); virtual void SetType( SMDSAbs_ElementType theType );
@ -369,7 +369,7 @@ namespace SMESH{
bool SetRangeStr( const TCollection_AsciiString& ); bool SetRangeStr( const TCollection_AsciiString& );
protected: protected:
SMDS_Mesh* myMesh; const SMDS_Mesh* myMesh;
TColStd_SequenceOfInteger myMin; TColStd_SequenceOfInteger myMin;
TColStd_SequenceOfInteger myMax; TColStd_SequenceOfInteger myMax;
@ -389,7 +389,7 @@ namespace SMESH{
public: public:
Comparator(); Comparator();
virtual ~Comparator(); virtual ~Comparator();
virtual void SetMesh( SMDS_Mesh* theMesh ); virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual void SetMargin(double theValue); virtual void SetMargin(double theValue);
virtual void SetNumFunctor(NumericalFunctorPtr theFunct); virtual void SetNumFunctor(NumericalFunctorPtr theFunct);
virtual bool IsSatisfy( long theElementId ) = 0; virtual bool IsSatisfy( long theElementId ) = 0;
@ -449,7 +449,7 @@ namespace SMESH{
LogicalNOT(); LogicalNOT();
virtual ~LogicalNOT(); virtual ~LogicalNOT();
virtual bool IsSatisfy( long theElementId ); virtual bool IsSatisfy( long theElementId );
virtual void SetMesh( SMDS_Mesh* theMesh ); virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual void SetPredicate(PredicatePtr thePred); virtual void SetPredicate(PredicatePtr thePred);
virtual SMDSAbs_ElementType GetType() const; virtual SMDSAbs_ElementType GetType() const;
@ -467,7 +467,7 @@ namespace SMESH{
public: public:
LogicalBinary(); LogicalBinary();
virtual ~LogicalBinary(); virtual ~LogicalBinary();
virtual void SetMesh( SMDS_Mesh* theMesh ); virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual void SetPredicate1(PredicatePtr thePred); virtual void SetPredicate1(PredicatePtr thePred);
virtual void SetPredicate2(PredicatePtr thePred); virtual void SetPredicate2(PredicatePtr thePred);
virtual SMDSAbs_ElementType GetType() const; virtual SMDSAbs_ElementType GetType() const;
@ -532,7 +532,7 @@ namespace SMESH{
ManifoldPart(); ManifoldPart();
~ManifoldPart(); ~ManifoldPart();
virtual void SetMesh( SMDS_Mesh* theMesh ); virtual void SetMesh( const SMDS_Mesh* theMesh );
// inoke when all parameters already set // inoke when all parameters already set
virtual bool IsSatisfy( long theElementId ); virtual bool IsSatisfy( long theElementId );
virtual SMDSAbs_ElementType GetType() const; virtual SMDSAbs_ElementType GetType() const;
@ -560,7 +560,7 @@ namespace SMESH{
TVectorOfFacePtr& theFaces ) const; TVectorOfFacePtr& theFaces ) const;
private: private:
SMDS_Mesh* myMesh; const SMDS_Mesh* myMesh;
TColStd_MapOfInteger myMapIds; TColStd_MapOfInteger myMapIds;
TColStd_MapOfInteger myMapBadGeomIds; TColStd_MapOfInteger myMapBadGeomIds;
TVectorOfFacePtr myAllFacePtr; TVectorOfFacePtr myAllFacePtr;
@ -582,7 +582,7 @@ namespace SMESH{
public: public:
ElementsOnSurface(); ElementsOnSurface();
~ElementsOnSurface(); ~ElementsOnSurface();
virtual void SetMesh( SMDS_Mesh* theMesh ); virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual bool IsSatisfy( long theElementId ); virtual bool IsSatisfy( long theElementId );
virtual SMDSAbs_ElementType GetType() const; virtual SMDSAbs_ElementType GetType() const;
@ -597,7 +597,7 @@ namespace SMESH{
bool isOnSurface( const SMDS_MeshNode* theNode ) const; bool isOnSurface( const SMDS_MeshNode* theNode ) const;
private: private:
SMDS_Mesh* myMesh; const SMDS_Mesh* myMesh;
TColStd_MapOfInteger myIds; TColStd_MapOfInteger myIds;
SMDSAbs_ElementType myType; SMDSAbs_ElementType myType;
Handle(Geom_Surface) mySurf; Handle(Geom_Surface) mySurf;
@ -615,8 +615,19 @@ namespace SMESH{
Filter(); Filter();
virtual ~Filter(); virtual ~Filter();
virtual void SetPredicate(PredicatePtr thePred); virtual void SetPredicate(PredicatePtr thePred);
typedef std::vector<long> TIdSequence; typedef std::vector<long> TIdSequence;
virtual TIdSequence GetElementsId( SMDS_Mesh* theMesh );
virtual
void
GetElementsId( const SMDS_Mesh* theMesh,
TIdSequence& theSequence );
static
void
GetElementsId( const SMDS_Mesh* theMesh,
PredicatePtr thePredicate,
TIdSequence& theSequence );
protected: protected:
PredicatePtr myPredicate; PredicatePtr myPredicate;

View File

@ -876,13 +876,14 @@ bool SMESHDS_Mesh::IsGroupOfSubShapes (const TopoDS_Shape& theShape) const
/// Return the sub mesh linked to the a given TopoDS_Shape or NULL if the given /// Return the sub mesh linked to the a given TopoDS_Shape or NULL if the given
/// TopoDS_Shape is unknown /// TopoDS_Shape is unknown
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S) SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S) const
{ {
if (myShape.IsNull()) MESSAGE("myShape is NULL"); if (myShape.IsNull()) MESSAGE("myShape is NULL");
int Index = ShapeToIndex(S); int Index = ShapeToIndex(S);
if (myShapeIndexToSubMesh.find(Index)!=myShapeIndexToSubMesh.end()) TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
return myShapeIndexToSubMesh[Index]; if (anIter != myShapeIndexToSubMesh.end())
return anIter->second;
else else
return NULL; return NULL;
} }
@ -1033,7 +1034,7 @@ TopoDS_Shape SMESHDS_Mesh::IndexToShape(int ShapeIndex)
//function : ShapeToIndex //function : ShapeToIndex
//purpose : //purpose :
//======================================================================= //=======================================================================
int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) const
{ {
if (myShape.IsNull()) if (myShape.IsNull())
MESSAGE("myShape is NULL"); MESSAGE("myShape is NULL");

View File

@ -204,7 +204,7 @@ public:
const TopoDS_Shape & S); const TopoDS_Shape & S);
TopoDS_Shape ShapeToMesh() const; TopoDS_Shape ShapeToMesh() const;
bool HasMeshElements(const TopoDS_Shape & S); bool HasMeshElements(const TopoDS_Shape & S);
SMESHDS_SubMesh * MeshElements(const TopoDS_Shape & S); SMESHDS_SubMesh * MeshElements(const TopoDS_Shape & S) const;
SMESHDS_SubMesh * MeshElements(const int Index); SMESHDS_SubMesh * MeshElements(const int Index);
std::list<int> SubMeshIndices(); std::list<int> SubMeshIndices();
const std::map<int,SMESHDS_SubMesh*>& SubMeshes() const std::map<int,SMESHDS_SubMesh*>& SubMeshes()
@ -214,7 +214,7 @@ public:
const std::list<const SMESHDS_Hypothesis*>& GetHypothesis(const TopoDS_Shape & S) const; const std::list<const SMESHDS_Hypothesis*>& GetHypothesis(const TopoDS_Shape & S) const;
SMESHDS_Script * GetScript(); SMESHDS_Script * GetScript();
void ClearScript(); void ClearScript();
int ShapeToIndex(const TopoDS_Shape & aShape); int ShapeToIndex(const TopoDS_Shape & aShape) const;
TopoDS_Shape IndexToShape(int ShapeIndex); TopoDS_Shape IndexToShape(int ShapeIndex);
SMESHDS_SubMesh * NewSubMesh(int Index); SMESHDS_SubMesh * NewSubMesh(int Index);
@ -246,9 +246,15 @@ private:
int myMeshID; int myMeshID;
TopoDS_Shape myShape; TopoDS_Shape myShape;
typedef std::map<int,SMESHDS_SubMesh*> TShapeIndexToSubMesh;
TShapeIndexToSubMesh myShapeIndexToSubMesh;
TopTools_IndexedMapOfShape myIndexToShape; TopTools_IndexedMapOfShape myIndexToShape;
std::map<int,SMESHDS_SubMesh*> myShapeIndexToSubMesh;
std::set<SMESHDS_GroupBase*> myGroups; typedef std::set<SMESHDS_GroupBase*> TGroups;
TGroups myGroups;
SMESHDS_Script* myScript; SMESHDS_Script* myScript;
}; };

View File

@ -56,7 +56,7 @@ LIB= libSMESHEngine.la
LIB_SRC = \ LIB_SRC = \
SMESH_Gen_i.cxx \ SMESH_Gen_i.cxx \
SMESH_Gen_i_1.cxx \ SMESH_Gen_i_1.cxx \
SMESH_Gen_i_DumpPython.cxx \ SMESH_DumpPython.cxx \
SMESH_Mesh_i.cxx \ SMESH_Mesh_i.cxx \
SMESH_MEDMesh_i.cxx \ SMESH_MEDMesh_i.cxx \
SMESH_MEDFamily_i.cxx \ SMESH_MEDFamily_i.cxx \

View File

@ -4,10 +4,184 @@
// Module : SMESH // Module : SMESH
// $Header : $ // $Header : $
#include "SMESH_PythonDump.hxx"
#include "SMESH_Gen_i.hxx" #include "SMESH_Gen_i.hxx"
#include "SMESH_Filter_i.hxx"
#include <TColStd_HSequenceOfInteger.hxx> #include <TColStd_HSequenceOfInteger.hxx>
namespace SMESH
{
TCollection_AsciiString&
operator<<(TCollection_AsciiString& theString, const char* theArg){
theString += Standard_CString(theArg);
return theString;
}
TCollection_AsciiString&
operator<<(TCollection_AsciiString& theString, int theArg){
theString += TCollection_AsciiString(theArg);
return theString;
}
TCollection_AsciiString&
operator<<(TCollection_AsciiString& theString, float theArg){
theString += TCollection_AsciiString(theArg);
return theString;
}
TCollection_AsciiString&
operator<<(TCollection_AsciiString& theString,
const SMESH::long_array& theArg)
{
theString<<"[ ";
CORBA::Long i = 1, iEnd = theArg.length();
for(; i <= iEnd; i++) {
theString<<int(theArg[i-1]);
if(i < iEnd)
theString<< ", ";
}
theString<<" ]";
return theString;
}
TCollection_AsciiString&
operator<<(TCollection_AsciiString& theString,
CORBA::Object_ptr theArg)
{
CORBA::String_var aString("None");
SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
SALOMEDS::SObject_var aSObject = SMESH_Gen_i::ObjectToSObject(aStudy,theArg);
if(!aSObject->_is_nil()){
aString = aSObject->GetID();
}else if(!CORBA::is_nil(theArg)){
aString = SMESH_Gen_i::GetORB()->object_to_string(theArg);
}
theString<<aString.in();
return theString;
}
TCollection_AsciiString&
operator<<(TCollection_AsciiString& theString,
SMESH::FilterLibrary_i* theArg)
{
theString += TCollection_AsciiString("aFilterLibrary_");
theString += TCollection_AsciiString(int(theArg));
return theString;
}
TCollection_AsciiString&
operator<<(TCollection_AsciiString& theString,
SMESH::FilterManager_i* theArg)
{
theString += TCollection_AsciiString("aFilterManager_");
theString += TCollection_AsciiString(int(theArg));
return theString;
}
TCollection_AsciiString&
operator<<(TCollection_AsciiString& theString,
SMESH::Functor_i* theArg)
{
FunctorType aFunctorType = theArg->GetFunctorType();
switch(aFunctorType){
case FT_AspectRatio:
theString += TCollection_AsciiString("anAspectRatio");
break;
case FT_AspectRatio3D:
theString += TCollection_AsciiString("anAspectRatio3D");
break;
case FT_Warping:
theString += TCollection_AsciiString("aWarping");
break;
case FT_MinimumAngle:
theString += TCollection_AsciiString("aMinimumAngle");
break;
case FT_Taper:
theString += TCollection_AsciiString("aTaper");
break;
case FT_Skew:
theString += TCollection_AsciiString("aSkew");
break;
case FT_Area:
theString += TCollection_AsciiString("aArea");
break;
case FT_FreeBorders:
theString += TCollection_AsciiString("aFreeBorders");
break;
case FT_FreeEdges:
theString += TCollection_AsciiString("aFreeEdges");
break;
case FT_MultiConnection:
theString += TCollection_AsciiString("aMultiConnection");
break;
case FT_MultiConnection2D:
theString += TCollection_AsciiString("aMultiConnection2D");
break;
case FT_Length:
theString += TCollection_AsciiString("aLength");
break;
case FT_Length2D:
theString += TCollection_AsciiString("aLength");
break;
case FT_BelongToGeom:
theString += TCollection_AsciiString("aBelongToGeom");
break;
case FT_BelongToPlane:
theString += TCollection_AsciiString("aBelongToPlane");
break;
case FT_BelongToCylinder:
theString += TCollection_AsciiString("aBelongToCylinder");
break;
case FT_LyingOnGeom:
theString += TCollection_AsciiString("aLyingOnGeom");
break;
case FT_RangeOfIds:
theString += TCollection_AsciiString("aRangeOfIds");
break;
case FT_BadOrientedVolume:
theString += TCollection_AsciiString("aBadOrientedVolume");
break;
case FT_LessThan:
theString += TCollection_AsciiString("aLessThan");
break;
case FT_MoreThan:
theString += TCollection_AsciiString("aMoreThan");
break;
case FT_EqualTo:
theString += TCollection_AsciiString("anEqualTo");
break;
case FT_LogicalNOT:
theString += TCollection_AsciiString("aLogicalNOT");
break;
case FT_LogicalAND:
theString += TCollection_AsciiString("aLogicalAND");
break;
case FT_LogicalOR:
theString += TCollection_AsciiString("aLogicalOR");
break;
case FT_Undefined:
theString += TCollection_AsciiString("anUndefined");
break;
}
theString += Standard_CString("_");
theString += TCollection_AsciiString(int(theArg));
return theString;
}
TPythonDump::
~TPythonDump()
{
SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
if(!aStudy->_is_nil()){
aSMESHGen->AddToPythonScript(aStudy->StudyId(),myString);
}
}
}
//======================================================================= //=======================================================================
//function : DumpPython //function : DumpPython
//purpose : //purpose :

View File

@ -29,6 +29,7 @@
#include "SMESH_Filter_i.hxx" #include "SMESH_Filter_i.hxx"
#include "SMESH_Gen_i.hxx" #include "SMESH_Gen_i.hxx"
#include "SMESH_PythonDump.hxx"
#include "SMDS_Mesh.hxx" #include "SMDS_Mesh.hxx"
#include "SMDS_MeshNode.hxx" #include "SMDS_MeshNode.hxx"
@ -63,6 +64,18 @@
using namespace SMESH; using namespace SMESH;
using namespace SMESH::Controls; using namespace SMESH::Controls;
namespace SMESH
{
Predicate_i*
GetPredicate( Predicate_ptr thePredicate )
{
PortableServer::ServantBase_var aServant = SMESH_Gen_i::GetServant( thePredicate );
return dynamic_cast<Predicate_i*>(aServant.in());
}
}
/* /*
Class : BelongToGeom Class : BelongToGeom
Description : Predicate for verifying whether entiy belong to Description : Predicate for verifying whether entiy belong to
@ -74,9 +87,9 @@ Controls::BelongToGeom::BelongToGeom()
myType(SMDSAbs_All) myType(SMDSAbs_All)
{} {}
void Controls::BelongToGeom::SetMesh( SMDS_Mesh* theMesh ) void Controls::BelongToGeom::SetMesh( const SMDS_Mesh* theMesh )
{ {
myMeshDS = dynamic_cast<SMESHDS_Mesh*>(theMesh); myMeshDS = dynamic_cast<const SMESHDS_Mesh*>(theMesh);
} }
void Controls::BelongToGeom::SetGeom( const TopoDS_Shape& theShape ) void Controls::BelongToGeom::SetGeom( const TopoDS_Shape& theShape )
@ -84,7 +97,7 @@ void Controls::BelongToGeom::SetGeom( const TopoDS_Shape& theShape )
myShape = theShape; myShape = theShape;
} }
static bool IsContains( SMESHDS_Mesh* theMeshDS, static bool IsContains( const SMESHDS_Mesh* theMeshDS,
const TopoDS_Shape& theShape, const TopoDS_Shape& theShape,
const SMDS_MeshElement* theElem, const SMDS_MeshElement* theElem,
TopAbs_ShapeEnum theFindShapeEnum, TopAbs_ShapeEnum theFindShapeEnum,
@ -166,7 +179,9 @@ TopoDS_Shape Controls::BelongToGeom::GetShape()
return myShape; return myShape;
} }
SMESHDS_Mesh* Controls::BelongToGeom::GetMeshDS() const SMESHDS_Mesh*
Controls::BelongToGeom::
GetMeshDS() const
{ {
return myMeshDS; return myMeshDS;
} }
@ -182,9 +197,9 @@ Controls::LyingOnGeom::LyingOnGeom()
myType(SMDSAbs_All) myType(SMDSAbs_All)
{} {}
void Controls::LyingOnGeom::SetMesh( SMDS_Mesh* theMesh ) void Controls::LyingOnGeom::SetMesh( const SMDS_Mesh* theMesh )
{ {
myMeshDS = dynamic_cast<SMESHDS_Mesh*>(theMesh); myMeshDS = dynamic_cast<const SMESHDS_Mesh*>(theMesh);
} }
void Controls::LyingOnGeom::SetGeom( const TopoDS_Shape& theShape ) void Controls::LyingOnGeom::SetGeom( const TopoDS_Shape& theShape )
@ -254,12 +269,14 @@ TopoDS_Shape Controls::LyingOnGeom::GetShape()
return myShape; return myShape;
} }
SMESHDS_Mesh* Controls::LyingOnGeom::GetMeshDS() const SMESHDS_Mesh*
Controls::LyingOnGeom::
GetMeshDS() const
{ {
return myMeshDS; return myMeshDS;
} }
bool Controls::LyingOnGeom::Contains( SMESHDS_Mesh* theMeshDS, bool Controls::LyingOnGeom::Contains( const SMESHDS_Mesh* theMeshDS,
const TopoDS_Shape& theShape, const TopoDS_Shape& theShape,
const SMDS_MeshElement* theElem, const SMDS_MeshElement* theElem,
TopAbs_ShapeEnum theFindShapeEnum, TopAbs_ShapeEnum theFindShapeEnum,
@ -301,14 +318,18 @@ bool Controls::LyingOnGeom::Contains( SMESHDS_Mesh* theMeshDS,
AUXILIARY METHODS AUXILIARY METHODS
*/ */
static inline SMDS_Mesh* MeshPtr2SMDSMesh( SMESH_Mesh_ptr theMesh ) inline
const SMDS_Mesh*
MeshPtr2SMDSMesh( SMESH_Mesh_ptr theMesh )
{ {
SMESH_Mesh_i* anImplPtr = SMESH_Mesh_i* anImplPtr =
dynamic_cast<SMESH_Mesh_i*>( SMESH_Gen_i::GetServant( theMesh ).in() ); dynamic_cast<SMESH_Mesh_i*>( SMESH_Gen_i::GetServant( theMesh ).in() );
return anImplPtr ? anImplPtr->GetImpl().GetMeshDS() : 0; return anImplPtr ? anImplPtr->GetImpl().GetMeshDS() : 0;
} }
static inline SMESH::long_array* toArray( const TColStd_ListOfInteger& aList ) inline
SMESH::long_array*
toArray( const TColStd_ListOfInteger& aList )
{ {
SMESH::long_array_var anArray = new SMESH::long_array; SMESH::long_array_var anArray = new SMESH::long_array;
anArray->length( aList.Extent() ); anArray->length( aList.Extent() );
@ -320,7 +341,9 @@ static inline SMESH::long_array* toArray( const TColStd_ListOfInteger& aList )
return anArray._retn(); return anArray._retn();
} }
static inline SMESH::double_array* toArray( const TColStd_ListOfReal& aList ) inline
SMESH::double_array*
toArray( const TColStd_ListOfReal& aList )
{ {
SMESH::double_array_var anArray = new SMESH::double_array; SMESH::double_array_var anArray = new SMESH::double_array;
anArray->length( aList.Extent() ); anArray->length( aList.Extent() );
@ -1005,6 +1028,7 @@ Comparator_i::~Comparator_i()
void Comparator_i::SetMargin( CORBA::Double theValue ) void Comparator_i::SetMargin( CORBA::Double theValue )
{ {
myComparatorPtr->SetMargin( theValue ); myComparatorPtr->SetMargin( theValue );
TPythonDump()<<this<<".SetMargin("<<float(theValue)<<")";
} }
CORBA::Double Comparator_i::GetMargin() CORBA::Double Comparator_i::GetMargin()
@ -1023,6 +1047,7 @@ void Comparator_i::SetNumFunctor( NumericalFunctor_ptr theFunct )
{ {
myComparatorPtr->SetNumFunctor( myNumericalFunctor->GetNumericalFunctor() ); myComparatorPtr->SetNumFunctor( myNumericalFunctor->GetNumericalFunctor() );
myNumericalFunctor->Register(); myNumericalFunctor->Register();
TPythonDump()<<this<<".SetNumFunctor("<<myNumericalFunctor<<")";
} }
} }
@ -1111,12 +1136,12 @@ LogicalNOT_i::~LogicalNOT_i()
myPredicate->Destroy(); myPredicate->Destroy();
} }
void LogicalNOT_i::SetPredicate( Predicate_ptr thePred ) void LogicalNOT_i::SetPredicate( Predicate_ptr thePredicate )
{ {
if ( myPredicate ) if ( myPredicate )
myPredicate->Destroy(); myPredicate->Destroy();
myPredicate = dynamic_cast<Predicate_i*>( SMESH_Gen_i::GetServant( thePred ).in() ); myPredicate = SMESH::GetPredicate(thePredicate);
if ( myPredicate ){ if ( myPredicate ){
myLogicalNOTPtr->SetPredicate(myPredicate->GetPredicate()); myLogicalNOTPtr->SetPredicate(myPredicate->GetPredicate());
@ -1167,7 +1192,7 @@ void LogicalBinary_i::SetPredicate1( Predicate_ptr thePredicate )
if ( myPredicate1 ) if ( myPredicate1 )
myPredicate1->Destroy(); myPredicate1->Destroy();
myPredicate1 = dynamic_cast<Predicate_i*>( SMESH_Gen_i::GetServant( thePredicate ).in() ); myPredicate1 = SMESH::GetPredicate(thePredicate);
if ( myPredicate1 ){ if ( myPredicate1 ){
myLogicalBinaryPtr->SetPredicate1(myPredicate1->GetPredicate()); myLogicalBinaryPtr->SetPredicate1(myPredicate1->GetPredicate());
@ -1180,7 +1205,7 @@ void LogicalBinary_i::SetPredicate2( Predicate_ptr thePredicate )
if ( myPredicate2 ) if ( myPredicate2 )
myPredicate2->Destroy(); myPredicate2->Destroy();
myPredicate2 = dynamic_cast<Predicate_i*>( SMESH_Gen_i::GetServant( thePredicate ).in() ); myPredicate2 = SMESH::GetPredicate(thePredicate);
if ( myPredicate2 ){ if ( myPredicate2 ){
myLogicalBinaryPtr->SetPredicate2(myPredicate2->GetPredicate()); myLogicalBinaryPtr->SetPredicate2(myPredicate2->GetPredicate());
@ -1297,6 +1322,7 @@ Area_ptr FilterManager_i::CreateArea()
{ {
SMESH::Area_i* aServant = new SMESH::Area_i(); SMESH::Area_i* aServant = new SMESH::Area_i();
SMESH::Area_var anObj = aServant->_this(); SMESH::Area_var anObj = aServant->_this();
TPythonDump()<<aServant<<" = "<<this<<".CreateArea()";
return anObj._retn(); return anObj._retn();
} }
@ -1397,6 +1423,7 @@ MoreThan_ptr FilterManager_i::CreateMoreThan()
{ {
SMESH::MoreThan_i* aServant = new SMESH::MoreThan_i(); SMESH::MoreThan_i* aServant = new SMESH::MoreThan_i();
SMESH::MoreThan_var anObj = aServant->_this(); SMESH::MoreThan_var anObj = aServant->_this();
TPythonDump()<<aServant<<" = "<<this<<".CreateMoreThan()";
return anObj._retn(); return anObj._retn();
} }
@ -1469,6 +1496,7 @@ SMESH::FilterManager_ptr SMESH_Gen_i::CreateFilterManager()
{ {
SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i(); SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i();
SMESH::FilterManager_var anObj = aFilter->_this(); SMESH::FilterManager_var anObj = aFilter->_this();
TPythonDump()<<aFilter<<" = smesh.CreateFilterManager()";
return anObj._retn(); return anObj._retn();
} }
@ -1504,7 +1532,7 @@ void Filter_i::SetPredicate( Predicate_ptr thePredicate )
if ( myPredicate ) if ( myPredicate )
myPredicate->Destroy(); myPredicate->Destroy();
myPredicate = dynamic_cast<Predicate_i*>( SMESH_Gen_i::GetServant( thePredicate ).in() ); myPredicate = SMESH::GetPredicate(thePredicate);
if ( myPredicate ) if ( myPredicate )
{ {
@ -1536,10 +1564,29 @@ void Filter_i::SetMesh( SMESH_Mesh_ptr theMesh )
// name : Filter_i::GetElementsId // name : Filter_i::GetElementsId
// Purpose : Get ids of entities // Purpose : Get ids of entities
//======================================================================= //=======================================================================
void
Filter_i::
GetElementsId( Predicate_i* thePredicate,
const SMDS_Mesh* theMesh,
Controls::Filter::TIdSequence& theSequence )
{
Controls::Filter::GetElementsId(theMesh,thePredicate->GetPredicate(),theSequence);
}
void
Filter_i::
GetElementsId( Predicate_i* thePredicate,
SMESH_Mesh_ptr theMesh,
Controls::Filter::TIdSequence& theSequence )
{
if(const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(theMesh))
Controls::Filter::GetElementsId(aMesh,thePredicate->GetPredicate(),theSequence);
}
SMESH::long_array* Filter_i::GetElementsId( SMESH_Mesh_ptr theMesh ) SMESH::long_array* Filter_i::GetElementsId( SMESH_Mesh_ptr theMesh )
{ {
SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(theMesh); Controls::Filter::TIdSequence aSequence;
Controls::Filter::TIdSequence aSequence = myFilter.GetElementsId(aMesh); GetElementsId(myPredicate,theMesh,aSequence);
SMESH::long_array_var anArray = new SMESH::long_array; SMESH::long_array_var anArray = new SMESH::long_array;
long i = 0, iEnd = aSequence.size(); long i = 0, iEnd = aSequence.size();

View File

@ -42,20 +42,20 @@ class SMESHDS_Mesh;
namespace SMESH namespace SMESH
{ {
namespace Controls namespace Controls
{ {
/* /*
Class : BelongToGeom Class : BelongToGeom
Description : Predicate for verifying whether entiy belong to Description : Predicate for verifying whether entiy belong to
specified geometrical support specified geometrical support
*/ */
class BelongToGeom: public virtual Predicate class BelongToGeom: public virtual Predicate
{ {
public: public:
BelongToGeom(); BelongToGeom();
virtual void SetMesh( SMDS_Mesh* theMesh ); virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual void SetGeom( const TopoDS_Shape& theShape ); virtual void SetGeom( const TopoDS_Shape& theShape );
virtual bool IsSatisfy( long theElementId ); virtual bool IsSatisfy( long theElementId );
@ -64,26 +64,26 @@ public:
virtual SMDSAbs_ElementType GetType() const; virtual SMDSAbs_ElementType GetType() const;
TopoDS_Shape GetShape(); TopoDS_Shape GetShape();
SMESHDS_Mesh* GetMeshDS(); const SMESHDS_Mesh* GetMeshDS() const;
private: private:
TopoDS_Shape myShape; TopoDS_Shape myShape;
SMESHDS_Mesh* myMeshDS; const SMESHDS_Mesh* myMeshDS;
SMDSAbs_ElementType myType; SMDSAbs_ElementType myType;
}; };
typedef boost::shared_ptr<BelongToGeom> BelongToGeomPtr; typedef boost::shared_ptr<BelongToGeom> BelongToGeomPtr;
/* /*
Class : LyingOnGeom Class : LyingOnGeom
Description : Predicate for verifying whether entiy lying or partially lying on Description : Predicate for verifying whether entiy lying or partially lying on
specified geometrical support specified geometrical support
*/ */
class LyingOnGeom: public virtual Predicate class LyingOnGeom: public virtual Predicate
{ {
public: public:
LyingOnGeom(); LyingOnGeom();
virtual void SetMesh( SMDS_Mesh* theMesh ); virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual void SetGeom( const TopoDS_Shape& theShape ); virtual void SetGeom( const TopoDS_Shape& theShape );
virtual bool IsSatisfy( long theElementId ); virtual bool IsSatisfy( long theElementId );
@ -92,251 +92,250 @@ public:
virtual SMDSAbs_ElementType GetType() const; virtual SMDSAbs_ElementType GetType() const;
TopoDS_Shape GetShape(); TopoDS_Shape GetShape();
SMESHDS_Mesh* GetMeshDS(); const SMESHDS_Mesh* GetMeshDS() const;
virtual bool Contains( SMESHDS_Mesh* theMeshDS, virtual bool Contains( const SMESHDS_Mesh* theMeshDS,
const TopoDS_Shape& theShape, const TopoDS_Shape& theShape,
const SMDS_MeshElement* theElem, const SMDS_MeshElement* theElem,
TopAbs_ShapeEnum theFindShapeEnum, TopAbs_ShapeEnum theFindShapeEnum,
TopAbs_ShapeEnum theAvoidShapeEnum = TopAbs_SHAPE ); TopAbs_ShapeEnum theAvoidShapeEnum = TopAbs_SHAPE );
private: private:
TopoDS_Shape myShape; TopoDS_Shape myShape;
SMESHDS_Mesh* myMeshDS; const SMESHDS_Mesh* myMeshDS;
SMDSAbs_ElementType myType; SMDSAbs_ElementType myType;
}; };
typedef boost::shared_ptr<LyingOnGeom> LyingOnGeomPtr; typedef boost::shared_ptr<LyingOnGeom> LyingOnGeomPtr;
} }
/* /*
FUNCTORS FUNCTORS
*/ */
/* /*
Class : Functor_i Class : Functor_i
Description : An abstact class for all functors Description : An abstact class for all functors
*/ */
class Functor_i: public virtual POA_SMESH::Functor, class Functor_i: public virtual POA_SMESH::Functor,
public virtual SALOME::GenericObj_i public virtual SALOME::GenericObj_i
{ {
public: public:
void SetMesh( SMESH_Mesh_ptr theMesh ); void SetMesh( SMESH_Mesh_ptr theMesh );
Controls::FunctorPtr GetFunctor(){ return myFunctorPtr;} Controls::FunctorPtr GetFunctor(){ return myFunctorPtr;}
ElementType GetElementType(); ElementType GetElementType();
protected: protected:
Functor_i(); Functor_i();
protected: protected:
Controls::FunctorPtr myFunctorPtr; Controls::FunctorPtr myFunctorPtr;
}; };
/*
/*
Class : NumericalFunctor_i Class : NumericalFunctor_i
Description : Base class for numerical functors Description : Base class for numerical functors
*/ */
class NumericalFunctor_i: public virtual POA_SMESH::NumericalFunctor, class NumericalFunctor_i: public virtual POA_SMESH::NumericalFunctor,
public virtual Functor_i public virtual Functor_i
{ {
public: public:
CORBA::Double GetValue( CORBA::Long theElementId ); CORBA::Double GetValue( CORBA::Long theElementId );
void SetPrecision( CORBA::Long thePrecision ); void SetPrecision( CORBA::Long thePrecision );
CORBA::Long GetPrecision(); CORBA::Long GetPrecision();
Controls::NumericalFunctorPtr GetNumericalFunctor(); Controls::NumericalFunctorPtr GetNumericalFunctor();
protected: protected:
Controls::NumericalFunctorPtr myNumericalFunctorPtr; Controls::NumericalFunctorPtr myNumericalFunctorPtr;
}; };
/* /*
Class : SMESH_MinimumAngleFunct Class : SMESH_MinimumAngleFunct
Description : Functor for calculation of minimum angle Description : Functor for calculation of minimum angle
*/ */
class MinimumAngle_i: public virtual POA_SMESH::MinimumAngle, class MinimumAngle_i: public virtual POA_SMESH::MinimumAngle,
public virtual NumericalFunctor_i public virtual NumericalFunctor_i
{ {
public: public:
MinimumAngle_i(); MinimumAngle_i();
FunctorType GetFunctorType(); FunctorType GetFunctorType();
}; };
/* /*
Class : AspectRatio_i Class : AspectRatio_i
Description : Functor for calculating aspect ratio Description : Functor for calculating aspect ratio
*/ */
class AspectRatio_i: public virtual POA_SMESH::AspectRatio, class AspectRatio_i: public virtual POA_SMESH::AspectRatio,
public virtual NumericalFunctor_i public virtual NumericalFunctor_i
{ {
public: public:
AspectRatio_i(); AspectRatio_i();
FunctorType GetFunctorType(); FunctorType GetFunctorType();
}; };
/* /*
Class : AspectRatio3D_i Class : AspectRatio3D_i
Description : Functor for calculating aspect ratio for 3D Description : Functor for calculating aspect ratio for 3D
*/ */
class AspectRatio3D_i: public virtual POA_SMESH::AspectRatio3D, class AspectRatio3D_i: public virtual POA_SMESH::AspectRatio3D,
public virtual NumericalFunctor_i public virtual NumericalFunctor_i
{ {
public: public:
AspectRatio3D_i(); AspectRatio3D_i();
FunctorType GetFunctorType(); FunctorType GetFunctorType();
}; };
/* /*
Class : Warping_i Class : Warping_i
Description : Functor for calculating warping Description : Functor for calculating warping
*/ */
class Warping_i: public virtual POA_SMESH::Warping, class Warping_i: public virtual POA_SMESH::Warping,
public virtual NumericalFunctor_i public virtual NumericalFunctor_i
{ {
public: public:
Warping_i(); Warping_i();
FunctorType GetFunctorType(); FunctorType GetFunctorType();
}; };
/* /*
Class : Taper_i Class : Taper_i
Description : Functor for calculating taper Description : Functor for calculating taper
*/ */
class Taper_i: public virtual POA_SMESH::Taper, class Taper_i: public virtual POA_SMESH::Taper,
public virtual NumericalFunctor_i public virtual NumericalFunctor_i
{ {
public: public:
Taper_i(); Taper_i();
FunctorType GetFunctorType(); FunctorType GetFunctorType();
}; };
/* /*
Class : Skew_i Class : Skew_i
Description : Functor for calculating skew in degrees Description : Functor for calculating skew in degrees
*/ */
class Skew_i: public virtual POA_SMESH::Skew, class Skew_i: public virtual POA_SMESH::Skew,
public virtual NumericalFunctor_i public virtual NumericalFunctor_i
{ {
public: public:
Skew_i(); Skew_i();
FunctorType GetFunctorType(); FunctorType GetFunctorType();
}; };
/* /*
Class : Area_i Class : Area_i
Description : Functor for calculating area Description : Functor for calculating area
*/ */
class Area_i: public virtual POA_SMESH::Area, class Area_i: public virtual POA_SMESH::Area,
public virtual NumericalFunctor_i public virtual NumericalFunctor_i
{ {
public: public:
Area_i(); Area_i();
FunctorType GetFunctorType(); FunctorType GetFunctorType();
}; };
/* /*
Class : Length_i Class : Length_i
Description : Functor for calculating length of edge Description : Functor for calculating length of edge
*/ */
class Length_i: public virtual POA_SMESH::Length, class Length_i: public virtual POA_SMESH::Length,
public virtual NumericalFunctor_i public virtual NumericalFunctor_i
{ {
public: public:
Length_i(); Length_i();
FunctorType GetFunctorType(); FunctorType GetFunctorType();
}; };
/* /*
Class : Length2D_i Class : Length2D_i
Description : Functor for calculating length of edge Description : Functor for calculating length of edge
*/ */
class Length2D_i: public virtual POA_SMESH::Length2D, class Length2D_i: public virtual POA_SMESH::Length2D,
public virtual NumericalFunctor_i public virtual NumericalFunctor_i
{ {
public: public:
Length2D_i(); Length2D_i();
SMESH::Length2D::Values* GetValues(); SMESH::Length2D::Values* GetValues();
FunctorType GetFunctorType(); FunctorType GetFunctorType();
protected: protected:
Controls::Length2DPtr myLength2DPtr; Controls::Length2DPtr myLength2DPtr;
}; };
/* /*
Class : MultiConnection_i Class : MultiConnection_i
Description : Functor for calculating number of faces conneted to the edge Description : Functor for calculating number of faces conneted to the edge
*/ */
class MultiConnection_i: public virtual POA_SMESH::MultiConnection, class MultiConnection_i: public virtual POA_SMESH::MultiConnection,
public virtual NumericalFunctor_i public virtual NumericalFunctor_i
{ {
public: public:
MultiConnection_i(); MultiConnection_i();
FunctorType GetFunctorType(); FunctorType GetFunctorType();
}; };
/* /*
Class : MultiConnection2D_i Class : MultiConnection2D_i
Description : Functor for calculating number of faces conneted to the edge Description : Functor for calculating number of faces conneted to the edge
*/ */
class MultiConnection2D_i: public virtual POA_SMESH::MultiConnection2D, class MultiConnection2D_i: public virtual POA_SMESH::MultiConnection2D,
public virtual NumericalFunctor_i public virtual NumericalFunctor_i
{ {
public: public:
MultiConnection2D_i(); MultiConnection2D_i();
SMESH::MultiConnection2D::Values* GetValues(); SMESH::MultiConnection2D::Values* GetValues();
FunctorType GetFunctorType(); FunctorType GetFunctorType();
protected: protected:
Controls::MultiConnection2DPtr myMulticonnection2DPtr; Controls::MultiConnection2DPtr myMulticonnection2DPtr;
}; };
/* /*
PREDICATES PREDICATES
*/ */
/* /*
Class : Predicate_i Class : Predicate_i
Description : Base class for all predicates Description : Base class for all predicates
*/ */
class Predicate_i: public virtual POA_SMESH::Predicate, class Predicate_i: public virtual POA_SMESH::Predicate,
public virtual Functor_i public virtual Functor_i
{ {
public: public:
CORBA::Boolean IsSatisfy( CORBA::Long theElementId ); CORBA::Boolean IsSatisfy( CORBA::Long theElementId );
Controls::PredicatePtr GetPredicate(); Controls::PredicatePtr GetPredicate();
protected: protected:
Controls::PredicatePtr myPredicatePtr; Controls::PredicatePtr myPredicatePtr;
}; };
/* /*
Class : BadOrientedVolume_i Class : BadOrientedVolume_i
Description : Verify whether a mesh volume is incorrectly oriented from Description : Verify whether a mesh volume is incorrectly oriented from
the point of view of MED convention the point of view of MED convention
*/ */
class BadOrientedVolume_i: public virtual POA_SMESH::BadOrientedVolume, class BadOrientedVolume_i: public virtual POA_SMESH::BadOrientedVolume,
public virtual Predicate_i public virtual Predicate_i
{ {
public: public:
BadOrientedVolume_i(); BadOrientedVolume_i();
FunctorType GetFunctorType(); FunctorType GetFunctorType();
}; };
/* /*
Class : BelongToGeom_i Class : BelongToGeom_i
Description : Predicate for selection on geometrical support Description : Predicate for selection on geometrical support
*/ */
class BelongToGeom_i: public virtual POA_SMESH::BelongToGeom, class BelongToGeom_i: public virtual POA_SMESH::BelongToGeom,
public virtual Predicate_i public virtual Predicate_i
{ {
public: public:
BelongToGeom_i(); BelongToGeom_i();
virtual ~BelongToGeom_i(); virtual ~BelongToGeom_i();
@ -349,19 +348,19 @@ public:
void SetShapeName( const char* theName ); void SetShapeName( const char* theName );
char* GetShapeName(); char* GetShapeName();
protected: protected:
Controls::BelongToGeomPtr myBelongToGeomPtr; Controls::BelongToGeomPtr myBelongToGeomPtr;
char* myShapeName; char* myShapeName;
}; };
/* /*
Class : BelongToSurface_i Class : BelongToSurface_i
Description : Verify whether mesh element lie in pointed Geom planar object Description : Verify whether mesh element lie in pointed Geom planar object
*/ */
class BelongToSurface_i: public virtual POA_SMESH::BelongToSurface, class BelongToSurface_i: public virtual POA_SMESH::BelongToSurface,
public virtual Predicate_i public virtual Predicate_i
{ {
public: public:
BelongToSurface_i( const Handle(Standard_Type)& ); BelongToSurface_i( const Handle(Standard_Type)& );
virtual ~BelongToSurface_i(); virtual ~BelongToSurface_i();
@ -373,46 +372,46 @@ public:
void SetTolerance( CORBA::Double ); void SetTolerance( CORBA::Double );
CORBA::Double GetTolerance(); CORBA::Double GetTolerance();
protected: protected:
Controls::ElementsOnSurfacePtr myElementsOnSurfacePtr; Controls::ElementsOnSurfacePtr myElementsOnSurfacePtr;
char* myShapeName; char* myShapeName;
Handle(Standard_Type) mySurfaceType; Handle(Standard_Type) mySurfaceType;
}; };
/* /*
Class : BelongToPlane_i Class : BelongToPlane_i
Description : Verify whether mesh element lie in pointed Geom planar object Description : Verify whether mesh element lie in pointed Geom planar object
*/ */
class BelongToPlane_i: public virtual POA_SMESH::BelongToPlane, class BelongToPlane_i: public virtual POA_SMESH::BelongToPlane,
public virtual BelongToSurface_i public virtual BelongToSurface_i
{ {
public: public:
BelongToPlane_i(); BelongToPlane_i();
void SetPlane( GEOM::GEOM_Object_ptr theGeom, ElementType theType ); void SetPlane( GEOM::GEOM_Object_ptr theGeom, ElementType theType );
FunctorType GetFunctorType(); FunctorType GetFunctorType();
}; };
/* /*
Class : BelongToCylinder_i Class : BelongToCylinder_i
Description : Verify whether mesh element lie in pointed Geom cylindrical object Description : Verify whether mesh element lie in pointed Geom cylindrical object
*/ */
class BelongToCylinder_i: public virtual POA_SMESH::BelongToCylinder, class BelongToCylinder_i: public virtual POA_SMESH::BelongToCylinder,
public virtual BelongToSurface_i public virtual BelongToSurface_i
{ {
public: public:
BelongToCylinder_i(); BelongToCylinder_i();
void SetCylinder( GEOM::GEOM_Object_ptr theGeom, ElementType theType ); void SetCylinder( GEOM::GEOM_Object_ptr theGeom, ElementType theType );
FunctorType GetFunctorType(); FunctorType GetFunctorType();
}; };
/* /*
Class : LyingOnGeom_i Class : LyingOnGeom_i
Description : Predicate for selection on geometrical support(lying or partially lying) Description : Predicate for selection on geometrical support(lying or partially lying)
*/ */
class LyingOnGeom_i: public virtual POA_SMESH::LyingOnGeom, class LyingOnGeom_i: public virtual POA_SMESH::LyingOnGeom,
public virtual Predicate_i public virtual Predicate_i
{ {
public: public:
LyingOnGeom_i(); LyingOnGeom_i();
virtual ~LyingOnGeom_i(); virtual ~LyingOnGeom_i();
@ -425,49 +424,49 @@ public:
void SetShapeName( const char* theName ); void SetShapeName( const char* theName );
char* GetShapeName(); char* GetShapeName();
protected: protected:
Controls::LyingOnGeomPtr myLyingOnGeomPtr; Controls::LyingOnGeomPtr myLyingOnGeomPtr;
char* myShapeName; char* myShapeName;
}; };
/* /*
Class : FreeBorders_i Class : FreeBorders_i
Description : Predicate for free borders Description : Predicate for free borders
*/ */
class FreeBorders_i: public virtual POA_SMESH::FreeBorders, class FreeBorders_i: public virtual POA_SMESH::FreeBorders,
public virtual Predicate_i public virtual Predicate_i
{ {
public: public:
FreeBorders_i(); FreeBorders_i();
FunctorType GetFunctorType(); FunctorType GetFunctorType();
}; };
/* /*
Class : FreeEdges_i Class : FreeEdges_i
Description : Predicate for free edges Description : Predicate for free edges
*/ */
class FreeEdges_i: public virtual POA_SMESH::FreeEdges, class FreeEdges_i: public virtual POA_SMESH::FreeEdges,
public virtual Predicate_i public virtual Predicate_i
{ {
public: public:
FreeEdges_i(); FreeEdges_i();
SMESH::FreeEdges::Borders* GetBorders(); SMESH::FreeEdges::Borders* GetBorders();
FunctorType GetFunctorType(); FunctorType GetFunctorType();
protected: protected:
Controls::FreeEdgesPtr myFreeEdgesPtr; Controls::FreeEdgesPtr myFreeEdgesPtr;
}; };
/* /*
Class : RangeOfIds_i Class : RangeOfIds_i
Description : Predicate for Range of Ids Description : Predicate for Range of Ids
*/ */
class RangeOfIds_i: public virtual POA_SMESH::RangeOfIds, class RangeOfIds_i: public virtual POA_SMESH::RangeOfIds,
public virtual Predicate_i public virtual Predicate_i
{ {
public: public:
RangeOfIds_i(); RangeOfIds_i();
void SetRange( const SMESH::long_array& theIds ); void SetRange( const SMESH::long_array& theIds );
CORBA::Boolean SetRangeStr( const char* theRange ); CORBA::Boolean SetRangeStr( const char* theRange );
@ -476,18 +475,18 @@ public:
void SetElementType( ElementType theType ); void SetElementType( ElementType theType );
FunctorType GetFunctorType(); FunctorType GetFunctorType();
protected: protected:
Controls::RangeOfIdsPtr myRangeOfIdsPtr; Controls::RangeOfIdsPtr myRangeOfIdsPtr;
}; };
/* /*
Class : Comparator_i Class : Comparator_i
Description : Base class for comparators Description : Base class for comparators
*/ */
class Comparator_i: public virtual POA_SMESH::Comparator, class Comparator_i: public virtual POA_SMESH::Comparator,
public virtual Predicate_i public virtual Predicate_i
{ {
public: public:
virtual ~Comparator_i(); virtual ~Comparator_i();
virtual void SetMargin( CORBA::Double ); virtual void SetMargin( CORBA::Double );
@ -497,66 +496,66 @@ public:
NumericalFunctor_i* GetNumFunctor_i(); NumericalFunctor_i* GetNumFunctor_i();
CORBA::Double GetMargin(); CORBA::Double GetMargin();
protected: protected:
Comparator_i(); Comparator_i();
protected: protected:
Controls::ComparatorPtr myComparatorPtr; Controls::ComparatorPtr myComparatorPtr;
NumericalFunctor_i* myNumericalFunctor; NumericalFunctor_i* myNumericalFunctor;
}; };
/* /*
Class : LessThan_i Class : LessThan_i
Description : Comparator "<" Description : Comparator "<"
*/ */
class LessThan_i: public virtual POA_SMESH::LessThan, class LessThan_i: public virtual POA_SMESH::LessThan,
public virtual Comparator_i public virtual Comparator_i
{ {
public: public:
LessThan_i(); LessThan_i();
FunctorType GetFunctorType(); FunctorType GetFunctorType();
}; };
/* /*
Class : MoreThan_i Class : MoreThan_i
Description : Comparator ">" Description : Comparator ">"
*/ */
class MoreThan_i: public virtual POA_SMESH::MoreThan, class MoreThan_i: public virtual POA_SMESH::MoreThan,
public virtual Comparator_i public virtual Comparator_i
{ {
public: public:
MoreThan_i(); MoreThan_i();
FunctorType GetFunctorType(); FunctorType GetFunctorType();
}; };
/* /*
Class : EqualTo_i Class : EqualTo_i
Description : Comparator "=" Description : Comparator "="
*/ */
class EqualTo_i: public virtual POA_SMESH::EqualTo, class EqualTo_i: public virtual POA_SMESH::EqualTo,
public virtual Comparator_i public virtual Comparator_i
{ {
public: public:
EqualTo_i(); EqualTo_i();
virtual void SetTolerance( CORBA::Double ); virtual void SetTolerance( CORBA::Double );
CORBA::Double GetTolerance(); CORBA::Double GetTolerance();
FunctorType GetFunctorType(); FunctorType GetFunctorType();
protected: protected:
Controls::EqualToPtr myEqualToPtr; Controls::EqualToPtr myEqualToPtr;
}; };
/* /*
Class : LogicalNOT_i Class : LogicalNOT_i
Description : Logical NOT predicate Description : Logical NOT predicate
*/ */
class LogicalNOT_i: public virtual POA_SMESH::LogicalNOT, class LogicalNOT_i: public virtual POA_SMESH::LogicalNOT,
public virtual Predicate_i public virtual Predicate_i
{ {
public: public:
LogicalNOT_i(); LogicalNOT_i();
virtual ~LogicalNOT_i(); virtual ~LogicalNOT_i();
@ -564,20 +563,20 @@ public:
Predicate_i* GetPredicate_i(); Predicate_i* GetPredicate_i();
FunctorType GetFunctorType(); FunctorType GetFunctorType();
protected: protected:
Controls::LogicalNOTPtr myLogicalNOTPtr; Controls::LogicalNOTPtr myLogicalNOTPtr;
Predicate_i* myPredicate; Predicate_i* myPredicate;
}; };
/* /*
Class : LogicalBinary_i Class : LogicalBinary_i
Description : Base class for binary logical predicate Description : Base class for binary logical predicate
*/ */
class LogicalBinary_i: public virtual POA_SMESH::LogicalBinary, class LogicalBinary_i: public virtual POA_SMESH::LogicalBinary,
public virtual Predicate_i public virtual Predicate_i
{ {
public: public:
virtual ~LogicalBinary_i(); virtual ~LogicalBinary_i();
virtual void SetMesh( SMESH_Mesh_ptr theMesh ); virtual void SetMesh( SMESH_Mesh_ptr theMesh );
virtual void SetPredicate1( Predicate_ptr ); virtual void SetPredicate1( Predicate_ptr );
@ -587,54 +586,63 @@ public:
Predicate_i* GetPredicate1_i(); Predicate_i* GetPredicate1_i();
Predicate_i* GetPredicate2_i(); Predicate_i* GetPredicate2_i();
protected: protected:
LogicalBinary_i(); LogicalBinary_i();
protected: protected:
Controls::LogicalBinaryPtr myLogicalBinaryPtr; Controls::LogicalBinaryPtr myLogicalBinaryPtr;
Predicate_i* myPredicate1; Predicate_i* myPredicate1;
Predicate_i* myPredicate2; Predicate_i* myPredicate2;
}; };
/* /*
Class : LogicalAND_i Class : LogicalAND_i
Description : Logical AND Description : Logical AND
*/ */
class LogicalAND_i: public virtual POA_SMESH::LogicalAND, class LogicalAND_i: public virtual POA_SMESH::LogicalAND,
public virtual LogicalBinary_i public virtual LogicalBinary_i
{ {
public: public:
LogicalAND_i(); LogicalAND_i();
FunctorType GetFunctorType(); FunctorType GetFunctorType();
}; };
/* /*
Class : LogicalOR_i Class : LogicalOR_i
Description : Logical OR Description : Logical OR
*/ */
class LogicalOR_i: public virtual POA_SMESH::LogicalOR, class LogicalOR_i: public virtual POA_SMESH::LogicalOR,
public virtual LogicalBinary_i public virtual LogicalBinary_i
{ {
public: public:
LogicalOR_i(); LogicalOR_i();
FunctorType GetFunctorType(); FunctorType GetFunctorType();
}; };
/* /*
FILTER FILTER
*/ */
class Filter_i: public virtual POA_SMESH::Filter, class Filter_i: public virtual POA_SMESH::Filter,
public virtual SALOME::GenericObj_i public virtual SALOME::GenericObj_i
{ {
public: public:
Filter_i(); Filter_i();
virtual ~Filter_i(); virtual ~Filter_i();
void SetPredicate( Predicate_ptr ); void SetPredicate( Predicate_ptr );
void SetMesh( SMESH_Mesh_ptr ); void SetMesh( SMESH_Mesh_ptr );
static
void GetElementsId( Predicate_i*,
const SMDS_Mesh*,
Controls::Filter::TIdSequence& );
static
void GetElementsId( Predicate_i*,
SMESH_Mesh_ptr,
Controls::Filter::TIdSequence& );
long_array* GetElementsId( SMESH_Mesh_ptr ); long_array* GetElementsId( SMESH_Mesh_ptr );
ElementType GetElementType(); ElementType GetElementType();
@ -644,19 +652,19 @@ public:
Predicate_ptr GetPredicate(); Predicate_ptr GetPredicate();
Predicate_i* GetPredicate_i(); Predicate_i* GetPredicate_i();
private: private:
Controls::Filter myFilter; Controls::Filter myFilter;
Predicate_i* myPredicate; Predicate_i* myPredicate;
}; };
/* /*
FILTER LIBRARY FILTER LIBRARY
*/ */
class FilterLibrary_i: public virtual POA_SMESH::FilterLibrary, class FilterLibrary_i: public virtual POA_SMESH::FilterLibrary,
public virtual SALOME::GenericObj_i public virtual SALOME::GenericObj_i
{ {
public: public:
FilterLibrary_i( const char* theFileName ); FilterLibrary_i( const char* theFileName );
FilterLibrary_i(); FilterLibrary_i();
~FilterLibrary_i(); ~FilterLibrary_i();
@ -680,21 +688,21 @@ public:
void SetFileName( const char* theFileName ); void SetFileName( const char* theFileName );
char* GetFileName(); char* GetFileName();
private: private:
char* myFileName; char* myFileName;
LDOM_Document myDoc; LDOM_Document myDoc;
FilterManager_var myFilterMgr; FilterManager_var myFilterMgr;
}; };
/* /*
FILTER MANAGER FILTER MANAGER
*/ */
class FilterManager_i: public virtual POA_SMESH::FilterManager, class FilterManager_i: public virtual POA_SMESH::FilterManager,
public virtual SALOME::GenericObj_i public virtual SALOME::GenericObj_i
{ {
public: public:
FilterManager_i(); FilterManager_i();
MinimumAngle_ptr CreateMinimumAngle(); MinimumAngle_ptr CreateMinimumAngle();
AspectRatio_ptr CreateAspectRatio(); AspectRatio_ptr CreateAspectRatio();
@ -734,11 +742,12 @@ public:
FilterLibrary_ptr LoadLibrary( const char* aFileName ); FilterLibrary_ptr LoadLibrary( const char* aFileName );
FilterLibrary_ptr CreateLibrary(); FilterLibrary_ptr CreateLibrary();
CORBA::Boolean DeleteLibrary( const char* aFileName ); CORBA::Boolean DeleteLibrary( const char* aFileName );
}; };
Predicate_i*
}; GetPredicate( SMESH::Predicate_ptr thePredicate );
}
#endif #endif

View File

@ -33,8 +33,14 @@
#include "SMESHDS_Group.hxx" #include "SMESHDS_Group.hxx"
#include "SMESHDS_GroupOnGeom.hxx" #include "SMESHDS_GroupOnGeom.hxx"
#include "SMDSAbs_ElementType.hxx" #include "SMDSAbs_ElementType.hxx"
#include "SMESH_Filter_i.hxx"
#include "SMESH_PythonDump.hxx"
#include "utilities.h" #include "utilities.h"
using namespace SMESH;
//============================================================================= //=============================================================================
/*! /*!
* *
@ -270,6 +276,86 @@ CORBA::Long SMESH_Group_i::Add( const SMESH::long_array& theIDs )
*/ */
//============================================================================= //=============================================================================
CORBA::Long SMESH_Group_i::Remove( const SMESH::long_array& theIDs )
{
// Update Python script
TCollection_AsciiString aStr ("nbDel = ");
SMESH_Gen_i::AddObject(aStr, _this()) += ".Remove(";
SMESH_Gen_i::AddArray(aStr, theIDs) += ")";
SMESH_Gen_i::AddToCurrentPyScript(aStr);
// Remove elements from the group
SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( GetGroupDS() );
if (aGroupDS) {
int nbDel = 0;
for (int i = 0; i < theIDs.length(); i++) {
int anID = (int) theIDs[i];
if (aGroupDS->Remove(anID))
nbDel++;
}
return nbDel;
}
MESSAGE("attempt to remove elements from a vague group");
return 0;
}
//=============================================================================
/*!
*
*/
//=============================================================================
typedef bool (SMESHDS_Group::*TFunChangeGroup)(const int);
CORBA::Long
ChangeByPredicate( SMESH::Predicate_i* thePredicate,
SMESHDS_GroupBase* theGroupBase,
TFunChangeGroup theFun)
{
CORBA::Long aNb = 0;
if(SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>(theGroupBase)){
SMESH::Controls::Filter::TIdSequence aSequence;
const SMDS_Mesh* aMesh = theGroupBase->GetMesh();
SMESH::Filter_i::GetElementsId(thePredicate,aMesh,aSequence);
CORBA::Long i = 0, iEnd = aSequence.size();
for(; i < iEnd; i++)
if((aGroupDS->*theFun)(aSequence[i]))
aNb++;
return aNb;
}
return aNb;
}
CORBA::Long
SMESH_Group_i::
AddByPredicate( SMESH::Predicate_ptr thePredicate )
{
if(SMESH::Predicate_i* aPredicate = SMESH::GetPredicate(thePredicate)){
TPythonDump()<<_this()<<".AddByPredicate("<<aPredicate<<")";
return ChangeByPredicate(aPredicate,GetGroupDS(),&SMESHDS_Group::Add);
}
return 0;
}
CORBA::Long
SMESH_Group_i::
RemoveByPredicate( SMESH::Predicate_ptr thePredicate )
{
if(SMESH::Predicate_i* aPredicate = SMESH::GetPredicate(thePredicate)){
TPythonDump()<<_this()<<".RemoveByPredicate("<<aPredicate<<")";
return ChangeByPredicate(aPredicate,GetGroupDS(),&SMESHDS_Group::Remove);
}
return 0;
}
//=============================================================================
/*!
*
*/
//=============================================================================
CORBA::Long SMESH_GroupBase_i::GetID( CORBA::Long theIndex ) CORBA::Long SMESH_GroupBase_i::GetID( CORBA::Long theIndex )
{ {
SMESHDS_GroupBase* aGroupDS = GetGroupDS(); SMESHDS_GroupBase* aGroupDS = GetGroupDS();
@ -300,36 +386,6 @@ SMESH::long_array* SMESH_GroupBase_i::GetListOfID()
return aRes._retn(); return aRes._retn();
} }
//=============================================================================
/*!
*
*/
//=============================================================================
CORBA::Long SMESH_Group_i::Remove( const SMESH::long_array& theIDs )
{
// Update Python script
TCollection_AsciiString aStr ("nbDel = ");
SMESH_Gen_i::AddObject(aStr, _this()) += ".Remove(";
SMESH_Gen_i::AddArray(aStr, theIDs) += ")";
SMESH_Gen_i::AddToCurrentPyScript(aStr);
// Remove elements from the group
SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( GetGroupDS() );
if (aGroupDS) {
int nbDel = 0;
for (int i = 0; i < theIDs.length(); i++) {
int anID = (int) theIDs[i];
if (aGroupDS->Remove(anID))
nbDel++;
}
return nbDel;
}
MESSAGE("attempt to remove elements from a vague group");
return 0;
}
//============================================================================= //=============================================================================
/*! /*!
* *

View File

@ -93,6 +93,9 @@ class SMESH_Group_i:
void Clear(); void Clear();
CORBA::Long Add( const SMESH::long_array& theIDs ); CORBA::Long Add( const SMESH::long_array& theIDs );
CORBA::Long Remove( const SMESH::long_array& theIDs ); CORBA::Long Remove( const SMESH::long_array& theIDs );
CORBA::Long AddByPredicate( SMESH::Predicate_ptr thePredicate );
CORBA::Long RemoveByPredicate( SMESH::Predicate_ptr thePredicate );
}; };
// ========================= // =========================

View File

@ -0,0 +1,80 @@
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#ifndef _SMESH_PYTHONDUMP_HXX_
#define _SMESH_PYTHONDUMP_HXX_
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
#include <TCollection_AsciiString.hxx>
namespace SMESH
{
TCollection_AsciiString&
operator<<(TCollection_AsciiString& theString,
const char* theArg);
TCollection_AsciiString&
operator<<(TCollection_AsciiString& theString,
int theArg);
TCollection_AsciiString&
operator<<(TCollection_AsciiString& theString,
float theArg);
class FilterLibrary_i;
TCollection_AsciiString&
operator<<(TCollection_AsciiString& theString,
SMESH::FilterLibrary_i* theArg);
class FilterManager_i;
TCollection_AsciiString&
operator<<(TCollection_AsciiString& theString,
SMESH::FilterManager_i* theArg);
class Functor_i;
TCollection_AsciiString&
operator<<(TCollection_AsciiString& theString,
SMESH::Functor_i* theArg);
TCollection_AsciiString&
operator<<(TCollection_AsciiString& theString,
CORBA::Object_ptr theArg);
TCollection_AsciiString&
operator<<(TCollection_AsciiString& theString,
const SMESH::long_array& theArg);
class TPythonDump
{
TCollection_AsciiString myString;
public:
virtual ~TPythonDump();
template<class T>
TCollection_AsciiString&
operator<<(T theArg){
return myString<<theArg;
}
};
}
#endif