X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH_I%2FSMESH_Filter_i.cxx;h=05d5f38482a1137aeee5e536db301aca76912719;hp=a5c073f29dd364497cbebc5192633d2e001f88f7;hb=1bf6ddbe2fe6f21e8c1ca914be6e423e402894f1;hpb=090aff07266d376ae028ae43434bdea7c0a0f9bb diff --git a/src/SMESH_I/SMESH_Filter_i.cxx b/src/SMESH_I/SMESH_Filter_i.cxx index a5c073f29..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, @@ -268,43 +284,31 @@ bool Controls::LyingOnGeom::Contains( SMESHDS_Mesh* theMeshDS, if (IsContains(theMeshDS, theShape, theElem, theFindShapeEnum, theAvoidShapeEnum)) return true; - if ( SMESHDS_SubMesh* aSubMesh = theMeshDS->MeshElements( theShape ) ) - { - SMDS_NodeIteratorPtr aNodeIt = aSubMesh->GetNodes(); - while ( aNodeIt->more() ) - { - const SMDS_MeshNode* aNode = static_cast(aNodeIt->next()); - SMDS_ElemIteratorPtr anElemIt = aNode->GetInverseElementIterator(); - while ( anElemIt->more() ) - { - const SMDS_MeshElement* anElement = static_cast(anElemIt->next()); - if (anElement == theElem) - return true; - } - } - } + TopTools_IndexedMapOfShape aSubShapes; + TopExp::MapShapes( theShape, aSubShapes ); - TopExp_Explorer anExp( theShape,TopAbs_VERTEX,theAvoidShapeEnum ); - - while( anExp.More() ) - { - const TopoDS_Shape& aShape = anExp.Current(); - if( SMESHDS_SubMesh* aSubMesh = theMeshDS->MeshElements( aShape ) ){ - SMDS_NodeIteratorPtr aNodeIt = aSubMesh->GetNodes(); - while ( aNodeIt->more() ) - { - const SMDS_MeshNode* aNode = static_cast(aNodeIt->next()); - SMDS_ElemIteratorPtr anElemIt = aNode->GetInverseElementIterator(); - while ( anElemIt->more() ) - { - const SMDS_MeshElement* anElement = static_cast(anElemIt->next()); - if (anElement == theElem) - return true; - } - } + for (int i = 1; i <= aSubShapes.Extent(); i++) + { + const TopoDS_Shape& aShape = aSubShapes.FindKey(i); + + if( SMESHDS_SubMesh* aSubMesh = theMeshDS->MeshElements( aShape ) ){ + if( aSubMesh->Contains( theElem ) ) + return true; + + SMDS_NodeIteratorPtr aNodeIt = aSubMesh->GetNodes(); + while ( aNodeIt->more() ) + { + const SMDS_MeshNode* aNode = static_cast(aNodeIt->next()); + SMDS_ElemIteratorPtr anElemIt = aNode->GetInverseElementIterator(); + while ( anElemIt->more() ) + { + const SMDS_MeshElement* anElement = static_cast(anElemIt->next()); + if (anElement == theElem) + return true; + } + } + } } - anExp.Next(); - } return false; } @@ -313,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() ); @@ -332,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() ); @@ -399,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 ) ); } @@ -978,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(); } @@ -1624,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: @@ -1695,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++ ) @@ -1714,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; @@ -1847,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()<