Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef SMESH_HypoFilter_HeaderFile
00028 #define SMESH_HypoFilter_HeaderFile
00029
00030 #include "SMESH_SMESH.hxx"
00031
00032
00033
00034
00035
00036 #include <list>
00037 #include <string>
00038 #include <TopoDS_Shape.hxx>
00039
00040 class SMESH_HypoFilter;
00041 class SMESH_Hypothesis;
00042
00043 class SMESH_EXPORT SMESH_HypoPredicate {
00044 public:
00045 virtual bool IsOk(const SMESH_Hypothesis* aHyp,
00046 const TopoDS_Shape& aShape) const = 0;
00047
00048 virtual ~SMESH_HypoPredicate() {}
00049 private:
00050 int _logical_op;
00051 friend class SMESH_HypoFilter;
00052 };
00053
00054 class SMESH_EXPORT SMESH_HypoFilter: public SMESH_HypoPredicate
00055 {
00056 public:
00057
00058
00059 SMESH_HypoFilter();
00060 SMESH_HypoFilter( SMESH_HypoPredicate* aPredicate, bool notNagate = true );
00061
00062 SMESH_HypoFilter & Init ( SMESH_HypoPredicate* aPredicate, bool notNagate = true );
00063 SMESH_HypoFilter & And ( SMESH_HypoPredicate* aPredicate );
00064 SMESH_HypoFilter & AndNot( SMESH_HypoPredicate* aPredicate );
00065 SMESH_HypoFilter & Or ( SMESH_HypoPredicate* aPredicate );
00066 SMESH_HypoFilter & OrNot ( SMESH_HypoPredicate* aPredicate );
00067
00068
00069 static SMESH_HypoPredicate* IsAlgo();
00070 static SMESH_HypoPredicate* IsAuxiliary();
00071 static SMESH_HypoPredicate* IsApplicableTo(const TopoDS_Shape& theShape);
00072 static SMESH_HypoPredicate* IsAssignedTo(const TopoDS_Shape& theShape);
00073 static SMESH_HypoPredicate* Is(const SMESH_Hypothesis* theHypo);
00074 static SMESH_HypoPredicate* IsGlobal(const TopoDS_Shape& theMainShape);
00075 static SMESH_HypoPredicate* IsMoreLocalThan(const TopoDS_Shape& theShape);
00076 static SMESH_HypoPredicate* HasName(const std::string & theName);
00077 static SMESH_HypoPredicate* HasDim(const int theDim);
00078 static SMESH_HypoPredicate* HasType(const int theHypType);
00079
00080 bool IsEmpty() const { return myPredicates.empty(); }
00081
00085 bool IsOk (const SMESH_Hypothesis* aHyp,
00086 const TopoDS_Shape& aShape) const;
00090 bool IsAny() const { return myPredicates.empty(); }
00091
00092 ~SMESH_HypoFilter();
00093
00094
00095 protected:
00096
00097
00098 std::list<SMESH_HypoPredicate*> myPredicates;
00099
00100
00101
00102 enum Logical { AND, AND_NOT, OR, OR_NOT };
00103 enum Comparison { EQUAL, NOT_EQUAL, MORE, LESS };
00104
00105 SMESH_HypoFilter(const SMESH_HypoFilter& other){}
00106
00107 void add( Logical bool_op, SMESH_HypoPredicate* pred )
00108 {
00109 if ( pred ) {
00110 pred->_logical_op = bool_op;
00111 myPredicates.push_back( pred );
00112 }
00113 }
00114
00115
00116
00117 template <typename TValue>
00118 struct templPredicate: public SMESH_HypoPredicate {
00119 Comparison _comp;
00120 TValue _val;
00121 virtual TValue Value(const SMESH_Hypothesis* aHyp) const = 0;
00122 virtual bool IsOk(const SMESH_Hypothesis* aHyp, const TopoDS_Shape& ) const
00123 {
00124 if ( _comp == EQUAL ) return _val == Value( aHyp );
00125 else if ( _comp == NOT_EQUAL ) return _val != Value( aHyp );
00126 else if ( _comp == MORE ) return _val < Value( aHyp );
00127 else return _val > Value( aHyp );
00128 }
00129 };
00130
00131 struct NamePredicate : public SMESH_HypoPredicate {
00132 std::string _name;
00133 NamePredicate( std::string name ): _name(name){}
00134 bool IsOk(const SMESH_Hypothesis* aHyp,
00135 const TopoDS_Shape& aShape) const;
00136 };
00137
00138 struct TypePredicate : public templPredicate< int > {
00139 TypePredicate( Comparison comp, int hypType )
00140 { _comp = comp; _val = hypType; }
00141 int Value( const SMESH_Hypothesis* aHyp ) const;
00142 };
00143
00144 struct DimPredicate : public templPredicate< int > {
00145 DimPredicate( Comparison comp, int dim )
00146 { _comp = comp; _val = dim; }
00147 int Value( const SMESH_Hypothesis* aHyp ) const;
00148 };
00149
00150 struct ApplicablePredicate : public SMESH_HypoPredicate {
00151 int _shapeType;
00152 ApplicablePredicate( const TopoDS_Shape& theShape );
00153 bool IsOk(const SMESH_Hypothesis* aHyp,
00154 const TopoDS_Shape& aShape) const;
00155 };
00156
00157 struct InstancePredicate : public SMESH_HypoPredicate {
00158 const SMESH_Hypothesis* _hypo;
00159 InstancePredicate( const SMESH_Hypothesis* hypo ):_hypo(hypo){}
00160 bool IsOk(const SMESH_Hypothesis* aHyp,
00161 const TopoDS_Shape& aShape) const;
00162 };
00163
00164 struct IsAssignedToPredicate : public SMESH_HypoPredicate {
00165 TopoDS_Shape _mainShape;
00166 IsAssignedToPredicate( const TopoDS_Shape& mainShape ):_mainShape(mainShape){}
00167 bool IsOk(const SMESH_Hypothesis* aHyp,
00168 const TopoDS_Shape& aShape) const;
00169 };
00170
00171 struct IsMoreLocalThanPredicate : public SMESH_HypoPredicate {
00172 TopoDS_Shape _shape;
00173 IsMoreLocalThanPredicate( const TopoDS_Shape& shape ):_shape(shape){}
00174 bool IsOk(const SMESH_Hypothesis* aHyp,
00175 const TopoDS_Shape& aShape) const;
00176 };
00177
00178 struct IsAuxiliaryPredicate : public SMESH_HypoPredicate {
00179 bool IsOk(const SMESH_Hypothesis* aHyp,
00180 const TopoDS_Shape& aShape) const;
00181 };
00182
00183 };
00184
00185
00186 #endif