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
00028 #include "SMESHGUI_Filter.h"
00029
00030 #include "SMESHGUI_Utils.h"
00031
00032 #include <SMESH_Actor.h>
00033 #include <SMDS_Mesh.hxx>
00034 #include <SMDSAbs_ElementType.hxx>
00035
00036 IMPLEMENT_STANDARD_HANDLE(SMESHGUI_Filter, VTKViewer_Filter)
00037 IMPLEMENT_STANDARD_RTTIEXT(SMESHGUI_Filter, VTKViewer_Filter)
00038
00039 IMPLEMENT_STANDARD_HANDLE(SMESHGUI_PredicateFilter, SMESHGUI_Filter)
00040 IMPLEMENT_STANDARD_RTTIEXT(SMESHGUI_PredicateFilter, SMESHGUI_Filter)
00041
00042 IMPLEMENT_STANDARD_HANDLE(SMESHGUI_QuadrangleFilter, SMESHGUI_Filter)
00043 IMPLEMENT_STANDARD_RTTIEXT(SMESHGUI_QuadrangleFilter, SMESHGUI_Filter)
00044
00045 IMPLEMENT_STANDARD_HANDLE(SMESHGUI_TriangleFilter, SMESHGUI_Filter)
00046 IMPLEMENT_STANDARD_RTTIEXT(SMESHGUI_TriangleFilter, SMESHGUI_Filter)
00047
00048 IMPLEMENT_STANDARD_HANDLE(SMESHGUI_FacesFilter, SMESHGUI_Filter)
00049 IMPLEMENT_STANDARD_RTTIEXT(SMESHGUI_FacesFilter, SMESHGUI_Filter)
00050
00051 IMPLEMENT_STANDARD_HANDLE(SMESHGUI_VolumesFilter, SMESHGUI_Filter)
00052 IMPLEMENT_STANDARD_RTTIEXT(SMESHGUI_VolumesFilter, SMESHGUI_Filter)
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 SMESHGUI_PredicateFilter::SMESHGUI_PredicateFilter()
00065 {
00066 }
00067
00068 SMESHGUI_PredicateFilter::~SMESHGUI_PredicateFilter()
00069 {
00070 }
00071
00072
00073
00074
00075
00076 bool SMESHGUI_PredicateFilter::IsValid( const int theCellId ) const
00077 {
00078 if ( myActor == 0 || myPred->_is_nil() )
00079 return false;
00080
00081 SMESH_Actor* anActor = dynamic_cast<SMESH_Actor*>( myActor );
00082 if ( !anActor || anActor->GetObject() == 0 )
00083 return false;
00084
00085 SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
00086 SMDSAbs_ElementType anElemType = (SMDSAbs_ElementType)myPred->GetElementType();
00087 int aMeshId = anElemType == SMDSAbs_Node ? anActor->GetNodeObjId( theCellId )
00088 : anActor->GetElemObjId( theCellId );
00089
00090
00091
00092 const SMDS_MeshElement* anElem = anElemType == SMDSAbs_Node ? aMesh->FindNode( aMeshId )
00093 : aMesh->FindElement( aMeshId );
00094
00095 if ( !anElem || (anElemType != SMDSAbs_All && anElem->GetType() != anElemType) )
00096 return false;
00097
00098 return myPred->IsSatisfy( aMeshId );
00099 }
00100
00101
00102
00103
00104
00105 bool SMESHGUI_PredicateFilter::IsObjValid( const int theObjId ) const
00106 {
00107 if ( myActor == 0 || myPred->_is_nil() )
00108 return false;
00109
00110 SMESH_Actor* anActor = dynamic_cast< SMESH_Actor* >( myActor );
00111 if ( !anActor || anActor->GetObject() == 0 )
00112 return false;
00113
00114 SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
00115 SMDSAbs_ElementType anElemType = (SMDSAbs_ElementType)myPred->GetElementType();
00116
00117
00118
00119 const SMDS_MeshElement* anElem = anElemType == SMDSAbs_Node ? aMesh->FindNode( theObjId )
00120 : aMesh->FindElement( theObjId );
00121
00122 if ( !anElem || (anElemType != SMDSAbs_All && anElem->GetType() != anElemType) )
00123 return false;
00124
00125 return myPred->IsSatisfy( theObjId );
00126 }
00127
00128
00129
00130
00131
00132 bool SMESHGUI_PredicateFilter::IsNodeFilter() const
00133 {
00134 return GetId() == SMESH::NodeFilter;
00135 }
00136
00137
00138
00139
00140
00141 void SMESHGUI_PredicateFilter::SetPredicate( SMESH::Predicate_ptr thePred )
00142 {
00143 myPred = SMESH::Predicate::_duplicate( thePred );
00144 }
00145
00146
00147
00148
00149
00150 void SMESHGUI_PredicateFilter::SetActor( SALOME_Actor* theActor )
00151 {
00152 if ( myActor == theActor )
00153 return;
00154 SMESHGUI_Filter::SetActor( theActor );
00155
00156 if ( myActor != 0 && !myPred->_is_nil() )
00157 {
00158 SALOME_Actor* sActor = dynamic_cast<SALOME_Actor*>( myActor );
00159 Handle(SALOME_InteractiveObject) anIO;
00160 if( sActor )
00161 anIO = sActor->getIO();
00162 if ( !anIO.IsNull() )
00163 {
00164 SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
00165 if(!aMesh->_is_nil())
00166 myPred->SetMesh(aMesh);
00167 }
00168 }
00169 }
00170
00171
00172
00173
00174
00175
00176 int SMESHGUI_PredicateFilter::GetId() const
00177 {
00178 if ( myPred->GetElementType() == SMESH::NODE ) return SMESH::NodeFilter;
00179 else if ( myPred->GetElementType() == SMESH::EDGE ) return SMESH::EdgeFilter;
00180 else if ( myPred->GetElementType() == SMESH::FACE ) return SMESH::FaceFilter;
00181 else if ( myPred->GetElementType() == SMESH::VOLUME ) return SMESH::VolumeFilter;
00182 else if ( myPred->GetElementType() == SMESH::ALL ) return SMESH::AllElementsFilter;
00183 else return SMESH::UnknownFilter;
00184 }
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196 SMESHGUI_QuadrangleFilter::SMESHGUI_QuadrangleFilter()
00197 : SMESHGUI_Filter()
00198 {
00199 }
00200
00201 SMESHGUI_QuadrangleFilter::~SMESHGUI_QuadrangleFilter()
00202 {
00203 }
00204
00205
00206
00207
00208
00209 bool SMESHGUI_QuadrangleFilter::IsValid( const int theCellId ) const
00210 {
00211 if ( myActor == 0 )
00212 return false;
00213
00214 SMESH_Actor* anActor = dynamic_cast< SMESH_Actor* >( myActor );
00215 if ( !anActor || anActor->GetObject() == 0 )
00216 return false;
00217
00218 SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
00219 const SMDS_MeshElement* anElem = aMesh->FindElement( anActor->GetElemObjId( theCellId ) );
00220
00221 return anElem && anElem->GetType() == SMDSAbs_Face &&
00222 ( anElem->NbNodes() == ( anElem->IsQuadratic() ? 8 : 4 ));
00223 }
00224
00225
00226
00227
00228
00229 bool SMESHGUI_QuadrangleFilter::IsObjValid( const int theObjId ) const
00230 {
00231 if ( myActor == 0 )
00232 return false;
00233
00234 SMESH_Actor* anActor = dynamic_cast< SMESH_Actor* >( myActor );
00235 if ( !anActor || anActor->GetObject() == 0 )
00236 return false;
00237
00238 SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
00239 const SMDS_MeshElement* anElem = aMesh->FindElement( theObjId );
00240
00241 return anElem && anElem->GetType() == SMDSAbs_Face &&
00242 ( anElem->NbNodes() == ( anElem->IsQuadratic() ? 8 : 4 ));
00243 }
00244
00245
00246
00247
00248
00249
00250 int SMESHGUI_QuadrangleFilter::GetId() const
00251 {
00252 return SMESH::QuadFilter;
00253 }
00254
00255
00256
00257
00258
00259 bool SMESHGUI_QuadrangleFilter::IsNodeFilter() const
00260 {
00261 return false;
00262 }
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275 SMESHGUI_TriangleFilter::SMESHGUI_TriangleFilter()
00276 : SMESHGUI_Filter()
00277 {
00278 }
00279
00280 SMESHGUI_TriangleFilter::~SMESHGUI_TriangleFilter()
00281 {
00282 }
00283
00284
00285
00286
00287
00288 bool SMESHGUI_TriangleFilter::IsValid( const int theCellId ) const
00289 {
00290 if ( myActor == 0 )
00291 return false;
00292
00293 SMESH_Actor* anActor = dynamic_cast< SMESH_Actor* >( myActor );
00294 if ( !anActor || anActor->GetObject() == 0 )
00295 return false;
00296
00297 SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
00298 const SMDS_MeshElement* anElem = aMesh->FindElement( anActor->GetElemObjId( theCellId ) );
00299
00300 return anElem && anElem->GetType() == SMDSAbs_Face &&
00301 ( anElem->NbNodes() == ( anElem->IsQuadratic() ? 6 : 3 ));
00302 }
00303
00304
00305
00306
00307
00308 bool SMESHGUI_TriangleFilter::IsObjValid( const int theObjId ) const
00309 {
00310 if ( myActor == 0 )
00311 return false;
00312
00313 SMESH_Actor* anActor = dynamic_cast< SMESH_Actor* >( myActor );
00314 if ( !anActor || anActor->GetObject() == 0 )
00315 return false;
00316
00317 SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
00318 const SMDS_MeshElement* anElem = aMesh->FindElement( theObjId );
00319
00320 return anElem && anElem->GetType() == SMDSAbs_Face &&
00321 ( anElem->NbNodes() == ( anElem->IsQuadratic() ? 6 : 3 ));
00322 }
00323
00324
00325
00326
00327
00328
00329 int SMESHGUI_TriangleFilter::GetId() const
00330 {
00331 return SMESH::TriaFilter;
00332 }
00333
00334
00335
00336
00337
00338 bool SMESHGUI_TriangleFilter::IsNodeFilter() const
00339 {
00340 return false;
00341 }
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353 SMESHGUI_FacesFilter::SMESHGUI_FacesFilter()
00354 : SMESHGUI_Filter()
00355 {
00356 }
00357
00358 SMESHGUI_FacesFilter::~SMESHGUI_FacesFilter()
00359 {
00360 }
00361
00362
00363
00364
00365
00366 bool SMESHGUI_FacesFilter::IsValid( const int theCellId ) const
00367 {
00368 if ( myActor == 0 )
00369 return false;
00370
00371 SMESH_Actor* anActor = dynamic_cast< SMESH_Actor* >( myActor );
00372 if ( !anActor || anActor->GetObject() == 0 )
00373 return false;
00374
00375 SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
00376 const SMDS_MeshElement* anElem = aMesh->FindElement( anActor->GetElemObjId( theCellId ) );
00377
00378 return anElem && anElem->GetType() == SMDSAbs_Face;
00379 }
00380
00381
00382
00383
00384
00385 bool SMESHGUI_FacesFilter::IsObjValid( const int theObjId ) const
00386 {
00387 if ( myActor == 0 )
00388 return false;
00389
00390 SMESH_Actor* anActor = dynamic_cast< SMESH_Actor* >( myActor );
00391 if ( !anActor || anActor->GetObject() == 0 )
00392 return false;
00393
00394 SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
00395 const SMDS_MeshElement* anElem = aMesh->FindElement( theObjId );
00396
00397 return anElem && anElem->GetType() == SMDSAbs_Face;
00398 }
00399
00400
00401
00402
00403
00404
00405 int SMESHGUI_FacesFilter::GetId() const
00406 {
00407 return SMESH::FaceFilter;
00408 }
00409
00410
00411
00412
00413
00414 bool SMESHGUI_FacesFilter::IsNodeFilter() const
00415 {
00416 return false;
00417 }
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430 SMESHGUI_VolumesFilter::SMESHGUI_VolumesFilter()
00431 : SMESHGUI_Filter()
00432 {
00433 }
00434
00435 SMESHGUI_VolumesFilter::~SMESHGUI_VolumesFilter()
00436 {
00437 }
00438
00439
00440
00441
00442
00443 bool SMESHGUI_VolumesFilter::IsValid( const int theCellId ) const
00444 {
00445 if ( myActor == 0 || theCellId < 1 )
00446 return false;
00447
00448 SMESH_Actor* anActor = dynamic_cast< SMESH_Actor* >( myActor );
00449 if ( !anActor || anActor->GetObject() == 0 )
00450 return false;
00451
00452 SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
00453 const SMDS_MeshElement* anElem = aMesh->FindElement( anActor->GetElemObjId( theCellId ) );
00454
00455 return anElem && anElem->GetType() == SMDSAbs_Volume;
00456 }
00457
00458
00459
00460
00461
00462 bool SMESHGUI_VolumesFilter::IsObjValid( const int theObjId ) const
00463 {
00464 if ( myActor == 0 )
00465 return false;
00466
00467 SMESH_Actor* anActor = dynamic_cast< SMESH_Actor* >( myActor );
00468 if ( !anActor || anActor->GetObject() == 0 )
00469 return false;
00470
00471 SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
00472 const SMDS_MeshElement* anElem = aMesh->FindElement( theObjId );
00473
00474 return anElem && anElem->GetType() == SMDSAbs_Volume;
00475 }
00476
00477
00478
00479
00480
00481
00482 int SMESHGUI_VolumesFilter::GetId() const
00483 {
00484 return SMESH::VolumeFilter;
00485 }
00486
00487
00488
00489
00490
00491 bool SMESHGUI_VolumesFilter::IsNodeFilter() const
00492 {
00493 return false;
00494 }