X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESH_I%2FSMESH_Filter_i.cxx;h=05d5f38482a1137aeee5e536db301aca76912719;hb=4679b8437be95e08b09e23f9d9069f3d18f4a754;hp=95893bc0eb2a956816822096a72b1408e83cdf5c;hpb=3fa31cc01e0e910bf0ade44749f1a843ede69336;p=modules%2Fsmesh.git diff --git a/src/SMESH_I/SMESH_Filter_i.cxx b/src/SMESH_I/SMESH_Filter_i.cxx index 95893bc0e..05d5f3848 100644 --- a/src/SMESH_I/SMESH_Filter_i.cxx +++ b/src/SMESH_I/SMESH_Filter_i.cxx @@ -29,6 +29,7 @@ #include "SMESH_Filter_i.hxx" #include "SMESH_Gen_i.hxx" +#include "SMESH_PythonDump.hxx" #include "SMDS_Mesh.hxx" #include "SMDS_MeshNode.hxx" @@ -63,6 +64,17 @@ using namespace SMESH; using namespace SMESH::Controls; + +namespace SMESH +{ + Predicate_i* + GetPredicate( Predicate_ptr thePredicate ) + { + return DownCast(thePredicate); + } +} + + /* Class : BelongToGeom Description : Predicate for verifying whether entiy belong to @@ -74,9 +86,9 @@ Controls::BelongToGeom::BelongToGeom() myType(SMDSAbs_All) {} -void Controls::BelongToGeom::SetMesh( SMDS_Mesh* theMesh ) +void Controls::BelongToGeom::SetMesh( const SMDS_Mesh* theMesh ) { - myMeshDS = dynamic_cast(theMesh); + myMeshDS = dynamic_cast(theMesh); } void Controls::BelongToGeom::SetGeom( const TopoDS_Shape& theShape ) @@ -84,7 +96,7 @@ void Controls::BelongToGeom::SetGeom( const TopoDS_Shape& theShape ) myShape = theShape; } -static bool IsContains( SMESHDS_Mesh* theMeshDS, +static bool IsContains( const SMESHDS_Mesh* theMeshDS, const TopoDS_Shape& theShape, const SMDS_MeshElement* theElem, TopAbs_ShapeEnum theFindShapeEnum, @@ -166,7 +178,9 @@ TopoDS_Shape Controls::BelongToGeom::GetShape() return myShape; } -SMESHDS_Mesh* Controls::BelongToGeom::GetMeshDS() +const SMESHDS_Mesh* +Controls::BelongToGeom:: +GetMeshDS() const { return myMeshDS; } @@ -182,9 +196,9 @@ Controls::LyingOnGeom::LyingOnGeom() myType(SMDSAbs_All) {} -void Controls::LyingOnGeom::SetMesh( SMDS_Mesh* theMesh ) +void Controls::LyingOnGeom::SetMesh( const SMDS_Mesh* theMesh ) { - myMeshDS = dynamic_cast(theMesh); + myMeshDS = dynamic_cast(theMesh); } void Controls::LyingOnGeom::SetGeom( const TopoDS_Shape& theShape ) @@ -254,12 +268,14 @@ TopoDS_Shape Controls::LyingOnGeom::GetShape() return myShape; } -SMESHDS_Mesh* Controls::LyingOnGeom::GetMeshDS() +const SMESHDS_Mesh* +Controls::LyingOnGeom:: +GetMeshDS() const { return myMeshDS; } -bool Controls::LyingOnGeom::Contains( SMESHDS_Mesh* theMeshDS, +bool Controls::LyingOnGeom::Contains( const SMESHDS_Mesh* theMeshDS, const TopoDS_Shape& theShape, const SMDS_MeshElement* theElem, TopAbs_ShapeEnum theFindShapeEnum, @@ -301,14 +317,17 @@ bool Controls::LyingOnGeom::Contains( SMESHDS_Mesh* theMeshDS, AUXILIARY METHODS */ -static inline SMDS_Mesh* MeshPtr2SMDSMesh( SMESH_Mesh_ptr theMesh ) +inline +const SMDS_Mesh* +MeshPtr2SMDSMesh( SMESH_Mesh_ptr theMesh ) { - SMESH_Mesh_i* anImplPtr = - dynamic_cast( SMESH_Gen_i::GetServant( theMesh ).in() ); + SMESH_Mesh_i* anImplPtr = DownCast(theMesh); 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; anArray->length( aList.Extent() ); @@ -320,7 +339,9 @@ static inline SMESH::long_array* toArray( const TColStd_ListOfInteger& aList ) 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; anArray->length( aList.Extent() ); @@ -387,13 +408,19 @@ static TopoDS_Shape getShapeByName( const char* theName ) Functor_i::Functor_i(): SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() ) { - SMESH_Gen_i::GetPOA()->activate_object( this ); + PortableServer::ObjectId_var anObjectId = + SMESH_Gen_i::GetPOA()->activate_object( this ); +} + +Functor_i::~Functor_i() +{ + TPythonDump()<SetMesh( MeshPtr2SMDSMesh( theMesh ) ); - INFOS("Functor_i::SetMesh~"); + TPythonDump()<SetPrecision( thePrecision ); + TPythonDump()<GetShapeReader()->GetShape( aGEOMGen, theGeom ); myBelongToGeomPtr->SetGeom( aLocShape ); + TPythonDump()<SetType(SMDSAbs_ElementType(theType)); + TPythonDump()<SetGeom( getShapeByName( myShapeName ) ); + TPythonDump()<SetSurface( TopoDS_Shape(), (SMDSAbs_ElementType)theType ); + TPythonDump()<SetSurface( getShapeByName( myShapeName ), (SMDSAbs_ElementType)theType ); + TPythonDump()<SetTolerance( theToler ); + TPythonDump()<GetShapeReader()->GetShape( aGEOMGen, theGeom ); myLyingOnGeomPtr->SetGeom( aLocShape ); + TPythonDump()<SetType(SMDSAbs_ElementType(theType)); + TPythonDump()<SetGeom( getShapeByName( myShapeName ) ); + TPythonDump()<AddToRange( theIds[ i ] ); + TPythonDump()<SetRangeStr( TCollection_AsciiString( (Standard_CString)theRange ) ); } @@ -966,6 +1022,7 @@ char* RangeOfIds_i::GetRangeStr() void RangeOfIds_i::SetElementType( ElementType theType ) { myRangeOfIdsPtr->SetType( SMDSAbs_ElementType( theType ) ); + TPythonDump()<SetMargin( theValue ); + TPythonDump()<Destroy(); - myNumericalFunctor = dynamic_cast( SMESH_Gen_i::GetServant( theFunct ).in() ); + myNumericalFunctor = DownCast(theFunct); if ( myNumericalFunctor ) { myComparatorPtr->SetNumFunctor( myNumericalFunctor->GetNumericalFunctor() ); myNumericalFunctor->Register(); + TPythonDump()<SetTolerance( theToler ); + TPythonDump()<Destroy(); } -void LogicalNOT_i::SetPredicate( Predicate_ptr thePred ) +void LogicalNOT_i::SetPredicate( Predicate_ptr thePredicate ) { if ( myPredicate ) myPredicate->Destroy(); - myPredicate = dynamic_cast( SMESH_Gen_i::GetServant( thePred ).in() ); + myPredicate = SMESH::GetPredicate(thePredicate); if ( myPredicate ){ myLogicalNOTPtr->SetPredicate(myPredicate->GetPredicate()); myPredicate->Register(); + TPythonDump()<Destroy(); - myPredicate1 = dynamic_cast( SMESH_Gen_i::GetServant( thePredicate ).in() ); + myPredicate1 = SMESH::GetPredicate(thePredicate); if ( myPredicate1 ){ myLogicalBinaryPtr->SetPredicate1(myPredicate1->GetPredicate()); myPredicate1->Register(); + TPythonDump()<Destroy(); - myPredicate2 = dynamic_cast( SMESH_Gen_i::GetServant( thePredicate ).in() ); + myPredicate2 = SMESH::GetPredicate(thePredicate); if ( myPredicate2 ){ myLogicalBinaryPtr->SetPredicate2(myPredicate2->GetPredicate()); myPredicate2->Register(); + TPythonDump()<activate_object( this ); + PortableServer::ObjectId_var anObjectId = + SMESH_Gen_i::GetPOA()->activate_object( this ); } + +FilterManager_i::~FilterManager_i() +{ + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<Destroy(); + + if(!CORBA::is_nil(myMesh)) + myMesh->Destroy(); + + TPythonDump()<Destroy(); - myPredicate = dynamic_cast( SMESH_Gen_i::GetServant( thePredicate ).in() ); + myPredicate = SMESH::GetPredicate(thePredicate); if ( myPredicate ) { myFilter.SetPredicate( myPredicate->GetPredicate() ); myPredicate->Register(); + TPythonDump()<SetMesh( theMesh ); + if(!CORBA::is_nil(theMesh)) + theMesh->Register(); + + if(!CORBA::is_nil(myMesh)) + myMesh->Destroy(); + + myMesh = theMesh; + TPythonDump()<GetPredicate(),theSequence); +} - anArray->length( iEnd ); - for ( ; i < iEnd; i++ ) - anArray[ i ] = aSequence[i]; +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_var anArray = new SMESH::long_array; + if(!CORBA::is_nil(theMesh)){ + Controls::Filter::TIdSequence aSequence; + GetElementsId(myPredicate,theMesh,aSequence); + long i = 0, iEnd = aSequence.size(); + anArray->length( iEnd ); + for ( ; i < iEnd; i++ ) + anArray[ i ] = aSequence[i]; + } return anArray._retn(); } @@ -1612,6 +1760,20 @@ static inline bool getCriteria( Predicate_i* thePred, theCriteria[ i ].ThresholdStr = aPred->GetRangeStr(); theCriteria[ i ].TypeOfElement = aPred->GetElementType(); + return true; + } + case FT_BadOrientedVolume: + { + BadOrientedVolume_i* aPred = dynamic_cast( thePred ); + + CORBA::ULong i = theCriteria->length(); + theCriteria->length( i + 1 ); + + theCriteria[ i ] = createCriterion(); + + theCriteria[ i ].Type = FT_BadOrientedVolume; + theCriteria[ i ].TypeOfElement = aPred->GetElementType(); + return true; } case FT_LessThan: @@ -1683,12 +1845,13 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria if ( myPredicate != 0 ) myPredicate->Destroy(); - SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i(); - FilterManager_ptr aFilterMgr = aFilter->_this(); - + SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i(); + FilterManager_ptr aFilterMgr = aFilter->_this(); + // CREATE two lists ( PREDICATES and LOG OP ) // Criterion + TPythonDump()<<"aCriteria = []"; std::list aPredicates; std::list aBinaries; for ( int i = 0, n = theCriteria.length(); i < n; i++ ) @@ -1702,6 +1865,10 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria const char* aThresholdStr = theCriteria[ i ].ThresholdStr; ElementType aTypeOfElem = theCriteria[ i ].TypeOfElement; long aPrecision = theCriteria[ i ].Precision; + + TPythonDump()<<"aCriteria.append(SMESH.Filter.Criterion("<< + aCriterion<<","<CreateBadOrientedVolume(); + } + break; default: continue; @@ -1835,6 +2007,7 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria aBinaries.push_back( aBinary ); } // end of for + TPythonDump()<CreateFilter(); aRes->SetCriteria( aCriteriaVar.inout() ); - + + TPythonDump()<(theFilter)) + TPythonDump()<(theFilter)) + TPythonDump()<