Salome HOME
DCQ : Merge with Ecole_Ete_a6.
[modules/smesh.git] / src / SMESHFiltersSelection / SMESH_TypeFilter.cxx
index dd7de5e4d68d2d8ad1b1ddbce9186a11074671fc..6514bfd8002788c23112550cd07c8ee9191e8348 100644 (file)
@@ -1,32 +1,12 @@
-//  SMESH SMESHFiltersSelection : filter selector for viewer
-//
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  This library is free software; you can redistribute it and/or 
-//  modify it under the terms of the GNU Lesser General Public 
-//  License as published by the Free Software Foundation; either 
-//  version 2.1 of the License. 
-// 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
-// 
-//  You should have received a copy of the GNU Lesser General Public 
-//  License along with this library; if not, write to the Free Software 
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
-// 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : SMESH_TypeFilter.cxx
-//  Author : Nicolas REJNERI
-//  Module : SMESH
+using namespace std;
+//  File      : SMESH_TypeFilter.cxx
+//  Created   : Fri Dec 07 09:57:24 2001
+//  Author    : Nicolas REJNERI
+//  Project   : SALOME
+//  Module    : SMESH
+//  Copyright : Open CASCADE
 //  $Header$
 
-using namespace std;
 #include "SMESH_TypeFilter.ixx"
 
 #include "SALOME_InteractiveObject.hxx"
@@ -49,111 +29,92 @@ Standard_Boolean SMESH_TypeFilter::IsOk(const Handle(SALOME_InteractiveObject)&
   if ( !meshFilter->IsOk(anObj) ) 
     return false;
 
+  bool Ok = false;
+
   if ( anObj->hasEntry() ) {
     QAD_Study* ActiveStudy = QAD_Application::getDesktop()->getActiveStudy();
     SALOMEDS::Study_var aStudy = ActiveStudy->getStudyDocument();
     SALOMEDS::SObject_var obj = aStudy->FindObjectID( anObj->getEntry() );
 
-    bool Ok = false;
+    SALOMEDS::SObject_var objFather = obj->GetFather();
+    SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
+    
+    if ( strlen( obj->GetID() ) <= strlen( objComponent->GetID() ) )
+      return false;
 
     switch ( myKind )
       {
       case HYPOTHESIS:
        {
-         SALOMEDS::SObject_var objFather = obj->GetFather();
-         SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
          if (( objFather->Tag() == 1 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) )
            Ok = true;
          break;
        }
       case ALGORITHM:
        {
-         SALOMEDS::SObject_var objFather = obj->GetFather();
-         SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
          if (( objFather->Tag() == 2 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) )
            Ok = true;
          break;
        }
       case MESH:
        {
-         SALOMEDS::SObject_var objFather = obj->GetFather();
-         SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
-         
          if (( obj->Tag() >= 3 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) == 0 ) )
            Ok = true;
          break;
        }
       case SUBMESH:
        {
-         SALOMEDS::SObject_var objFather = obj->GetFather();
-         SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
-         
-         if (( objFather->Tag() >= 4 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) )
+         if (( objFather->Tag() >= 4 && objFather->Tag() < 9 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) )
            Ok = true;
          break;
        }
       case MESHorSUBMESH:
        {
-         SALOMEDS::SObject_var objFather = obj->GetFather();
-         SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
-         
          if (( obj->Tag() >= 3 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) == 0 ) )
            Ok = true;
 
-          if (( objFather->Tag() >= 4 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) )
+         if (( objFather->Tag() >= 4 && objFather->Tag() < 9 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) )
            Ok = true;
 
          break;
        }
-      case SUBMESH_VERTEX:
+      case SUBMESH_VERTEX:  // Label "SubMeshes on vertexes"
        {
-         SALOMEDS::SObject_var objFather = obj->GetFather();
-         SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
-         
          if (( obj->Tag() == 4 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 ))
            Ok = true;
          break;
        }
       case SUBMESH_EDGE:
        {
-         SALOMEDS::SObject_var objFather = obj->GetFather();
-         SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
-         
          if (( obj->Tag() == 5 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 ))
            Ok = true;
          break;
        }
       case SUBMESH_FACE:
        {
-         SALOMEDS::SObject_var objFather = obj->GetFather();
-         SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
-         
          if (( obj->Tag() == 6 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 ))
            Ok = true;
          break;
        }
       case SUBMESH_SOLID:
        {
-         SALOMEDS::SObject_var objFather = obj->GetFather();
-         SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
-         
          if (( obj->Tag() == 7 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 ))
            Ok = true;
          break;
        }
       case SUBMESH_COMPOUND:
        {
-         SALOMEDS::SObject_var objFather = obj->GetFather();
-         SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
-         
          if (( obj->Tag() == 8 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 ))
            Ok = true;
          break;
        }
+      case GROUP:
+       {
+         if (( objFather->Tag() >= 9 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) )
+           Ok = true;
+         break;
+       }
       }
-
-    if ( Ok )
-      return true;
   }
-  return false;
+  return Ok;
 }