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 #include "SMESH_HypoFilter.hxx"
00028
00029 #include "SMESH_Gen.hxx"
00030 #include "SMESH_Hypothesis.hxx"
00031 #include "SMESH_MesherHelper.hxx"
00032 #include "SMESH_subMesh.hxx"
00033
00034 #include <TopExp_Explorer.hxx>
00035
00036 using namespace std;
00037
00038
00039
00040
00041
00042
00043
00044 bool SMESH_HypoFilter::NamePredicate::IsOk (const SMESH_Hypothesis* aHyp,
00045 const TopoDS_Shape& ) const
00046 {
00047 return ( _name == aHyp->GetName() );
00048 }
00049
00050
00051
00052
00053
00054
00055 int SMESH_HypoFilter::TypePredicate::Value( const SMESH_Hypothesis* aHyp ) const
00056 {
00057 return aHyp->GetType();
00058 };
00059
00060
00061
00062
00063
00064
00065 int SMESH_HypoFilter::DimPredicate::Value( const SMESH_Hypothesis* aHyp ) const
00066 {
00067 return aHyp->GetDim();
00068 }
00069
00070
00071
00072
00073
00074
00075 bool SMESH_HypoFilter::ApplicablePredicate::IsOk(const SMESH_Hypothesis* aHyp,
00076 const TopoDS_Shape& ) const
00077 {
00078 return SMESH_subMesh::IsApplicableHypotesis( aHyp, (TopAbs_ShapeEnum)_shapeType );
00079 };
00080
00081
00082
00083
00084
00085
00086 bool SMESH_HypoFilter::IsAuxiliaryPredicate::IsOk(const SMESH_Hypothesis* aHyp,
00087 const TopoDS_Shape& ) const
00088 {
00089 return aHyp->IsAuxiliary();
00090 };
00091
00092
00093
00094
00095
00096
00097 SMESH_HypoFilter::ApplicablePredicate::ApplicablePredicate( const TopoDS_Shape& theShape )
00098 {
00099 _shapeType = ( theShape.IsNull() ? TopAbs_SHAPE : theShape.ShapeType());
00100 }
00101
00102
00103
00104
00105
00106
00107 bool SMESH_HypoFilter::InstancePredicate::IsOk(const SMESH_Hypothesis* aHyp,
00108 const TopoDS_Shape& ) const
00109 {
00110 return _hypo == aHyp;
00111 }
00112
00113
00114
00115
00116
00117
00118 bool SMESH_HypoFilter::IsAssignedToPredicate::IsOk(const SMESH_Hypothesis* aHyp,
00119 const TopoDS_Shape& aShape) const
00120 {
00121 return ( !_mainShape.IsNull() && !aShape.IsNull() && _mainShape.IsSame( aShape ));
00122 }
00123
00124
00125
00126
00127
00128
00129 bool SMESH_HypoFilter::IsMoreLocalThanPredicate::IsOk(const SMESH_Hypothesis* aHyp,
00130 const TopoDS_Shape& aShape) const
00131 {
00132 if ( SMESH_MesherHelper::IsSubShape( aShape, _shape ))
00133 return true;
00134
00135 if ( aShape.ShapeType() == TopAbs_COMPOUND &&
00136 !SMESH_MesherHelper::IsSubShape( _shape, aShape))
00137 {
00138 for ( int type = TopAbs_SOLID; type < TopAbs_SHAPE; ++type )
00139 if ( aHyp->GetDim() == SMESH_Gen::GetShapeDim( TopAbs_ShapeEnum( type )))
00140 for ( TopExp_Explorer exp( aShape, TopAbs_ShapeEnum( type )); exp.More(); exp.Next())
00141 if ( SMESH_MesherHelper::IsSubShape( exp.Current(), _shape ))
00142 return true;
00143 }
00144 return false;
00145 }
00146
00147
00148
00149
00150
00151
00152 SMESH_HypoFilter::SMESH_HypoFilter()
00153 {
00154 }
00155
00156
00157
00158
00159
00160
00161 SMESH_HypoFilter::SMESH_HypoFilter( SMESH_HypoPredicate* aPredicate, bool notNagate )
00162 {
00163 add( notNagate ? AND : AND_NOT, aPredicate );
00164 }
00165
00166
00167
00168
00169
00170
00171 SMESH_HypoFilter & SMESH_HypoFilter::And( SMESH_HypoPredicate* aPredicate )
00172 {
00173 add( AND, aPredicate );
00174 return *this;
00175 }
00176
00177
00178
00179
00180
00181
00182 SMESH_HypoFilter & SMESH_HypoFilter::AndNot( SMESH_HypoPredicate* aPredicate )
00183 {
00184 add( AND_NOT, aPredicate );
00185 return *this;
00186 }
00187
00188
00189
00190
00191
00192
00193 SMESH_HypoFilter & SMESH_HypoFilter::Or( SMESH_HypoPredicate* aPredicate )
00194 {
00195 add( OR, aPredicate );
00196 return *this;
00197 }
00198
00199
00200
00201
00202
00203
00204 SMESH_HypoFilter & SMESH_HypoFilter::OrNot( SMESH_HypoPredicate* aPredicate )
00205 {
00206 add( OR_NOT, aPredicate );
00207 return *this;
00208 }
00209
00210
00211
00212
00213
00214
00215 SMESH_HypoPredicate* SMESH_HypoFilter::Is(const SMESH_Hypothesis* theHypo)
00216 {
00217 return new InstancePredicate( theHypo );
00218 }
00219
00220
00221
00222
00223
00224
00225 SMESH_HypoPredicate* SMESH_HypoFilter::IsAlgo()
00226 {
00227 return new TypePredicate( MORE, SMESHDS_Hypothesis::PARAM_ALGO );
00228 }
00229
00230
00231
00232
00233
00234
00235 SMESH_HypoPredicate* SMESH_HypoFilter::IsAuxiliary()
00236 {
00237 return new IsAuxiliaryPredicate();
00238 }
00239
00240
00241
00242
00243
00244
00245
00246 SMESH_HypoPredicate* SMESH_HypoFilter::IsGlobal(const TopoDS_Shape& theMainShape)
00247 {
00248 return new IsAssignedToPredicate( theMainShape );
00249 }
00250
00251
00252
00253
00254
00255
00256 SMESH_HypoPredicate* SMESH_HypoFilter::IsAssignedTo(const TopoDS_Shape& theShape)
00257 {
00258 return new IsAssignedToPredicate( theShape );
00259 }
00260
00261
00262
00263
00264
00265
00266 SMESH_HypoPredicate* SMESH_HypoFilter::HasName(const string & theName)
00267 {
00268 return new NamePredicate( theName );
00269 }
00270
00271
00272
00273
00274
00275
00276 SMESH_HypoPredicate* SMESH_HypoFilter::HasDim(const int theDim)
00277 {
00278 return new DimPredicate( EQUAL, theDim );
00279 }
00280
00281
00282
00283
00284
00285
00286 SMESH_HypoPredicate* SMESH_HypoFilter::IsApplicableTo(const TopoDS_Shape& theShape)
00287 {
00288 return new ApplicablePredicate( theShape );
00289 }
00290
00291
00292
00293
00294
00295
00296 SMESH_HypoPredicate* SMESH_HypoFilter::IsMoreLocalThan(const TopoDS_Shape& theShape)
00297 {
00298 return new IsMoreLocalThanPredicate( theShape );
00299 }
00300
00301
00302
00303
00304
00305
00306 SMESH_HypoPredicate* SMESH_HypoFilter::HasType(const int theHypType)
00307 {
00308 return new TypePredicate( EQUAL, theHypType );
00309 }
00310
00311
00312
00313
00314
00315
00316 bool SMESH_HypoFilter::IsOk (const SMESH_Hypothesis* aHyp,
00317 const TopoDS_Shape& aShape) const
00318 {
00319 if ( myPredicates.empty() )
00320 return true;
00321
00322 bool ok = ( myPredicates.front()->_logical_op <= AND_NOT );
00323 list<SMESH_HypoPredicate*>::const_iterator pred = myPredicates.begin();
00324 for ( ; pred != myPredicates.end(); ++pred )
00325 {
00326 bool ok2 = (*pred)->IsOk( aHyp, aShape );
00327 switch ( (*pred)->_logical_op ) {
00328 case AND: ok = ok && ok2; break;
00329 case AND_NOT: ok = ok && !ok2; break;
00330 case OR: ok = ok || ok2; break;
00331 case OR_NOT: ok = ok || !ok2; break;
00332 default:;
00333 }
00334 }
00335 return ok;
00336 }
00337
00338
00339
00340
00341
00342
00343 SMESH_HypoFilter & SMESH_HypoFilter::Init ( SMESH_HypoPredicate* aPredicate, bool notNagate )
00344 {
00345 list<SMESH_HypoPredicate*>::const_iterator pred = myPredicates.begin();
00346 for ( ; pred != myPredicates.end(); ++pred )
00347 delete *pred;
00348 myPredicates.clear();
00349
00350 add( notNagate ? AND : AND_NOT, aPredicate );
00351 return *this;
00352 }
00353
00354
00355
00356
00357
00358
00359
00360 SMESH_HypoFilter::~SMESH_HypoFilter()
00361 {
00362 Init(0);
00363 }
00364
00365
00366