PAL9874. Fix error in SMESH_HypoFilter::IsGlobalPredicate; add possibility to add all predicates in one statement.

This commit is contained in:
eap 2005-09-07 08:07:34 +00:00
parent 287d1c4720
commit 3291e2c4e1
3 changed files with 38 additions and 23 deletions

View File

@ -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<SMESH_HypoPredicate*>::const_iterator pred = myPredicates.begin();
for ( ; pred != myPredicates.end(); ++pred )
delete *pred;
add( notNagate ? AND : AND_NOT, aPredicate );
return *this;
}

View File

@ -35,10 +35,10 @@
#include <list>
#include <string>
#include <TopoDS_Shape.hxx>
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;
};

View File

@ -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 );
}
}