From: eap Date: Wed, 7 Sep 2005 08:07:34 +0000 (+0000) Subject: PAL9874. Fix error in SMESH_HypoFilter::IsGlobalPredicate; add possibility to add... X-Git-Tag: V3_1_0a1~14 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3291e2c4e1f98a5f37c397c06c254b7ba0f75e9d;p=modules%2Fsmesh.git PAL9874. Fix error in SMESH_HypoFilter::IsGlobalPredicate; add possibility to add all predicates in one statement. --- diff --git a/src/SMESH/SMESH_HypoFilter.cxx b/src/SMESH/SMESH_HypoFilter.cxx index 783547bb1..ff14016d8 100644 --- a/src/SMESH/SMESH_HypoFilter.cxx +++ b/src/SMESH/SMESH_HypoFilter.cxx @@ -97,11 +97,11 @@ bool SMESH_HypoFilter::InstancePredicate::IsOk(const SMESH_Hypothesis* aHyp, } //======================================================================= -//function : IsGlobalPredicate::IsOk +//function : IsAssignedToPredicate::IsOk //purpose : //======================================================================= -bool SMESH_HypoFilter::IsGlobalPredicate::IsOk(const SMESH_Hypothesis* aHyp, +bool SMESH_HypoFilter::IsAssignedToPredicate::IsOk(const SMESH_Hypothesis* aHyp, const TopoDS_Shape& aShape) const { return ( !_mainShape.IsNull() && !aShape.IsNull() && _mainShape.IsSame( aShape )); @@ -131,9 +131,10 @@ SMESH_HypoFilter::SMESH_HypoFilter( SMESH_HypoPredicate* aPredicate, bool notNag //purpose : //======================================================================= -void SMESH_HypoFilter::And( SMESH_HypoPredicate* aPredicate ) +SMESH_HypoFilter & SMESH_HypoFilter::And( SMESH_HypoPredicate* aPredicate ) { add( AND, aPredicate ); + return *this; } //======================================================================= @@ -141,9 +142,10 @@ void SMESH_HypoFilter::And( SMESH_HypoPredicate* aPredicate ) //purpose : //======================================================================= -void SMESH_HypoFilter::AndNot( SMESH_HypoPredicate* aPredicate ) +SMESH_HypoFilter & SMESH_HypoFilter::AndNot( SMESH_HypoPredicate* aPredicate ) { add( AND_NOT, aPredicate ); + return *this; } //======================================================================= @@ -151,9 +153,10 @@ void SMESH_HypoFilter::AndNot( SMESH_HypoPredicate* aPredicate ) //purpose : //======================================================================= -void SMESH_HypoFilter::Or( SMESH_HypoPredicate* aPredicate ) +SMESH_HypoFilter & SMESH_HypoFilter::Or( SMESH_HypoPredicate* aPredicate ) { add( OR, aPredicate ); + return *this; } //======================================================================= @@ -161,9 +164,10 @@ void SMESH_HypoFilter::Or( SMESH_HypoPredicate* aPredicate ) //purpose : Return predicates //======================================================================= -void SMESH_HypoFilter::OrNot( SMESH_HypoPredicate* aPredicate ) +SMESH_HypoFilter & SMESH_HypoFilter::OrNot( SMESH_HypoPredicate* aPredicate ) { add( OR_NOT, aPredicate ); + return *this; } //======================================================================= @@ -193,7 +197,17 @@ SMESH_HypoPredicate* SMESH_HypoFilter::IsAlgo() SMESH_HypoPredicate* SMESH_HypoFilter::IsGlobal(const TopoDS_Shape& theMainShape) { - return new IsGlobalPredicate( theMainShape ); + return new IsAssignedToPredicate( theMainShape ); +} + +//======================================================================= +//function : IsAssignedTo +//purpose : +//======================================================================= + + SMESH_HypoPredicate* SMESH_HypoFilter::IsAssignedTo(const TopoDS_Shape& theShape) +{ + return new IsAssignedToPredicate( theShape ); } //======================================================================= @@ -268,13 +282,14 @@ bool SMESH_HypoFilter::IsOk (const SMESH_Hypothesis* aHyp, //purpose : //======================================================================= -void SMESH_HypoFilter::Init ( SMESH_HypoPredicate* aPredicate, bool notNagate ) +SMESH_HypoFilter & SMESH_HypoFilter::Init ( SMESH_HypoPredicate* aPredicate, bool notNagate ) { list::const_iterator pred = myPredicates.begin(); for ( ; pred != myPredicates.end(); ++pred ) delete *pred; add( notNagate ? AND : AND_NOT, aPredicate ); + return *this; } diff --git a/src/SMESH/SMESH_HypoFilter.hxx b/src/SMESH/SMESH_HypoFilter.hxx index 673b9fe2a..6bc34bf53 100644 --- a/src/SMESH/SMESH_HypoFilter.hxx +++ b/src/SMESH/SMESH_HypoFilter.hxx @@ -35,10 +35,10 @@ #include #include +#include class SMESH_HypoFilter; class SMESH_Hypothesis; -class TopoDS_Shape; class SMESH_HypoPredicate { public: @@ -59,15 +59,16 @@ class SMESH_HypoFilter: public SMESH_HypoPredicate SMESH_HypoFilter(); SMESH_HypoFilter( SMESH_HypoPredicate* aPredicate, bool notNagate = true ); // notNagate==false means !aPredicate->IsOk() - void Init ( SMESH_HypoPredicate* aPredicate, bool notNagate = true ); - void And ( SMESH_HypoPredicate* aPredicate ); - void AndNot( SMESH_HypoPredicate* aPredicate ); - void Or ( SMESH_HypoPredicate* aPredicate ); - void OrNot ( SMESH_HypoPredicate* aPredicate ); + SMESH_HypoFilter & Init ( SMESH_HypoPredicate* aPredicate, bool notNagate = true ); + SMESH_HypoFilter & And ( SMESH_HypoPredicate* aPredicate ); + SMESH_HypoFilter & AndNot( SMESH_HypoPredicate* aPredicate ); + SMESH_HypoFilter & Or ( SMESH_HypoPredicate* aPredicate ); + SMESH_HypoFilter & OrNot ( SMESH_HypoPredicate* aPredicate ); // Create predicates static SMESH_HypoPredicate* IsAlgo(); - static SMESH_HypoPredicate* IsApplicableTo(const TopoDS_Shape& theMainShape); + static SMESH_HypoPredicate* IsApplicableTo(const TopoDS_Shape& theShape); + static SMESH_HypoPredicate* IsAssignedTo(const TopoDS_Shape& theShape); static SMESH_HypoPredicate* Is(const SMESH_Hypothesis* theHypo); static SMESH_HypoPredicate* IsGlobal(const TopoDS_Shape& theMainShape); static SMESH_HypoPredicate* HasName(const std::string & theName); @@ -150,9 +151,9 @@ class SMESH_HypoFilter: public SMESH_HypoPredicate const TopoDS_Shape& aShape) const; }; - struct IsGlobalPredicate : public SMESH_HypoPredicate { - const TopoDS_Shape& _mainShape; - IsGlobalPredicate( const TopoDS_Shape& mainShape ):_mainShape(mainShape){} + struct IsAssignedToPredicate : public SMESH_HypoPredicate { + TopoDS_Shape _mainShape; + IsAssignedToPredicate( const TopoDS_Shape& mainShape ):_mainShape(mainShape){} bool IsOk(const SMESH_Hypothesis* aHyp, const TopoDS_Shape& aShape) const; }; diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index c473bd612..8622faec5 100644 --- a/src/SMESH/SMESH_Mesh.cxx +++ b/src/SMESH/SMESH_Mesh.cxx @@ -1080,11 +1080,10 @@ void SMESH_Mesh::RemoveGroup (const int theGroupID) //============================================================================= const SMESH_Hypothesis* SMESH_Mesh::IsLocal1DHypothesis (const TopoDS_Shape& theEdge) { - SMESH_HypoFilter filter( SMESH_HypoFilter::HasDim( 1 )); - filter.AndNot( SMESH_HypoFilter::IsAlgo() ); - filter.AndNot( SMESH_HypoFilter::IsGlobal( GetMeshDS()->ShapeToMesh() )); + SMESH_HypoFilter hypo ( SMESH_HypoFilter::HasDim( 1 )); + hypo.AndNot( hypo.IsAlgo() ).AndNot( hypo.IsAssignedTo( GetMeshDS()->ShapeToMesh() )); - return GetHypothesis( theEdge, filter, true ); + return GetHypothesis( theEdge, hypo, true ); } //============================================================================= @@ -1426,4 +1425,4 @@ ostream& SMESH_Mesh::Dump(ostream& save) SMDSAbs_ElementType SMESH_Mesh::GetElementType( const int id, const bool iselem ) { return _myMeshDS->GetElementType( id, iselem ); -} \ No newline at end of file +}