Salome HOME
22316: EDF 2719 SMESH: Split hexas into prisms
authoreap <eap@opencascade.com>
Mon, 20 Jan 2014 10:34:21 +0000 (10:34 +0000)
committereap <eap@opencascade.com>
Mon, 20 Jan 2014 10:34:21 +0000 (10:34 +0000)
 namespace SMESH
 {
   enum SMESHGUI_FilterType {
     QuadFilter              =  5,
     TriaFilter              =  6,
+    FirstGeometryTypeFilter,
+    FirstEntityTypeFilter   = FirstGeometryTypeFilter + SMDSGeom_NONE,
+    LastFilter              = FirstEntityTypeFilter   + SMDSEntity_Last
   };
 };

+class SMESHGUI_VolumeShapeFilter : public SMESHGUI_Filter
+{

src/SMESHGUI/SMESHGUI_Filter.cxx
src/SMESHGUI/SMESHGUI_Filter.h

index 95e02173e8edea037f28fc4711fef1cb87bb7dfa..10c6210eb7827f0fe2eaa53794935b2b4c8607da 100755 (executable)
@@ -51,6 +51,9 @@ IMPLEMENT_STANDARD_RTTIEXT(SMESHGUI_FacesFilter, SMESHGUI_Filter)
 IMPLEMENT_STANDARD_HANDLE(SMESHGUI_VolumesFilter, SMESHGUI_Filter)
 IMPLEMENT_STANDARD_RTTIEXT(SMESHGUI_VolumesFilter, SMESHGUI_Filter)
 
+IMPLEMENT_STANDARD_HANDLE(SMESHGUI_VolumeShapeFilter, SMESHGUI_Filter)
+IMPLEMENT_STANDARD_RTTIEXT(SMESHGUI_VolumeShapeFilter, SMESHGUI_Filter)
+
 /*
   Class       : SMESHGUI_PredicateFilter
   Description : Selection filter for VTK viewer. This class aggregate object
@@ -492,3 +495,86 @@ bool SMESHGUI_VolumesFilter::IsNodeFilter() const
 {
   return false;
 }
+
+
+/*
+  Class       : SMESHGUI_VolumeShapeFilter
+  Description : Verify whether selected cell is a volume of a certain shape
+*/
+
+
+//=======================================================================
+// name    : SMESHGUI_VolumeShapeFilter::SMESHGUI_VolumeShapeFilter
+// Purpose : Constructor
+//=======================================================================
+SMESHGUI_VolumeShapeFilter::SMESHGUI_VolumeShapeFilter(const SMDSAbs_GeometryType shape)
+  : SMESHGUI_Filter(), myGeometryType( shape )
+{
+}
+
+//=======================================================================
+// name    : SMESHGUI_VolumeShapeFilter::IsValid
+// Purpose : Verify whether selected cell is a volume of a certain shape
+//=======================================================================
+bool SMESHGUI_VolumeShapeFilter::IsValid( const int theCellId ) const
+{
+  if ( myActor == 0 || theCellId < 1 )
+    return false;
+
+  SMESH_Actor* anActor = dynamic_cast< SMESH_Actor* >( myActor );
+  if ( !anActor || anActor->GetObject() == 0 )
+    return false;
+
+  SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
+  const SMDS_MeshElement* anElem = aMesh->FindElement( anActor->GetElemObjId( theCellId ) );
+
+  return anElem && anElem->GetGeomType() == myGeometryType;
+}
+
+//=======================================================================
+// name    : SMESHGUI_VolumeShapeFilter::IsValid
+// Purpose : Verify whether selected cell is volume
+//=======================================================================
+bool SMESHGUI_VolumeShapeFilter::IsObjValid( const int theObjId ) const
+{
+  if ( myActor == 0 )
+    return false;
+
+  SMESH_Actor* anActor = dynamic_cast< SMESH_Actor* >( myActor );
+  if ( !anActor || anActor->GetObject() == 0 )
+    return false;
+
+  SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
+  const SMDS_MeshElement* anElem = aMesh->FindElement( theObjId );
+
+  return anElem && anElem->GetGeomType() == myGeometryType;
+}
+
+//=======================================================================
+// name    : SMESHGUI_VolumeShapeFilter::GetId
+// Purpose : Get ID of the filter. Must return value from SMESHGUI_FilterType
+//           enumeration. All filters must have different ids
+//=======================================================================
+int SMESHGUI_VolumeShapeFilter::GetId() const
+{
+  return GetId( myGeometryType );
+}
+
+//=======================================================================
+//function : GetId
+//purpose  : Compose filter ID basing on 
+//=======================================================================
+
+int SMESHGUI_VolumeShapeFilter::GetId( SMDSAbs_GeometryType shape )
+{
+  return SMESH::FirstGeometryTypeFilter + shape;
+}
+
+//=======================================================================
+// name    : SMESHGUI_VolumeShapeFilter::IsNodeFilter
+// Purpose : Returns true if filter is intended for nodes
+//=======================================================================
+bool SMESHGUI_VolumeShapeFilter::IsNodeFilter() const
+{
+  return false;
+}
index 26c5feffd1fed0a0b64b2b7a3b7016e7bc3c9fb6..a07ae7c136c46e59e6f0563f026a5e7f93e6a70f 100755 (executable)
@@ -29,6 +29,7 @@
 
 // SMESH includes
 #include "SMESH_SMESHGUI.hxx"
+#include "SMDSAbs_ElementType.hxx"
 
 // SALOME GUI includes
 #include <VTKViewer_Filter.h>
@@ -42,15 +43,17 @@ class SALOME_Actor;
 namespace SMESH
 {
   enum SMESHGUI_FilterType {
-    UnknownFilter      = -1,
-    NodeFilter         =  0,
-    EdgeFilter         =  1,
-    FaceFilter         =  2,
-    VolumeFilter       =  3,
-    AllElementsFilter  =  4,
-    QuadFilter         =  5,
-    TriaFilter         =  6,
-    LastFilter
+    UnknownFilter           = -1,
+    NodeFilter              =  0,
+    EdgeFilter              =  1,
+    FaceFilter              =  2,
+    VolumeFilter            =  3,
+    AllElementsFilter       =  4,
+    QuadFilter              =  5,
+    TriaFilter              =  6,
+    FirstGeometryTypeFilter,
+    FirstEntityTypeFilter   = FirstGeometryTypeFilter + SMDSGeom_NONE,
+    LastFilter              = FirstEntityTypeFilter   + SMDSEntity_Last
   };
 };
 
@@ -181,10 +184,34 @@ public:
   Standard_EXPORT virtual bool IsValid( const int ) const;
   Standard_EXPORT virtual bool IsObjValid( const int ) const;
   Standard_EXPORT virtual int  GetId() const;
-  Standard_EXPORT virtual bool IsNodeFilter() const;  
+  Standard_EXPORT virtual bool IsNodeFilter() const;
 
 public:
   DEFINE_STANDARD_RTTI(SMESHGUI_VolumesFilter)
 };
 
+/*
+  Class       : SMESHGUI_VolumeShapeFilter
+  Description : Verify whether selected cell is a volume of a certain shape
+*/
+
+DEFINE_STANDARD_HANDLE(SMESHGUI_VolumeShapeFilter, SMESHGUI_Filter)
+
+class SMESHGUI_VolumeShapeFilter : public SMESHGUI_Filter
+{
+  SMDSAbs_GeometryType myGeometryType;
+public:
+  Standard_EXPORT SMESHGUI_VolumeShapeFilter(const SMDSAbs_GeometryType shape);
+
+  Standard_EXPORT virtual bool IsValid( const int ) const;
+  Standard_EXPORT virtual bool IsObjValid( const int ) const;
+  Standard_EXPORT virtual int  GetId() const;
+  Standard_EXPORT virtual bool IsNodeFilter() const;
+
+  Standard_EXPORT static int GetId( SMDSAbs_GeometryType geom );
+
+public:
+  DEFINE_STANDARD_RTTI(SMESHGUI_VolumeShapeFilter)
+};
+
 #endif // SMESHGUI_FILTER_H