Salome HOME
0021459: EDF 1495 SMESH: Manipulation of discrete elements with attributes
authoreap <eap@opencascade.com>
Thu, 19 Jul 2012 13:06:39 +0000 (13:06 +0000)
committereap <eap@opencascade.com>
Thu, 19 Jul 2012 13:06:39 +0000 (13:06 +0000)
+        virtual SMDSAbs_GeometryType GetGeomType() const;

18 files changed:
src/SMDS/SMDS_FaceOfEdges.cxx
src/SMDS/SMDS_FaceOfEdges.hxx
src/SMDS/SMDS_FaceOfNodes.cxx
src/SMDS/SMDS_FaceOfNodes.hxx
src/SMDS/SMDS_Mesh0DElement.cxx
src/SMDS/SMDS_Mesh0DElement.hxx
src/SMDS/SMDS_MeshEdge.hxx
src/SMDS/SMDS_MeshElement.hxx
src/SMDS/SMDS_MeshNode.hxx
src/SMDS/SMDS_VolumeOfFaces.cxx
src/SMDS/SMDS_VolumeOfFaces.hxx
src/SMDS/SMDS_VolumeOfNodes.cxx
src/SMDS/SMDS_VolumeOfNodes.hxx
src/SMDS/SMDS_VtkEdge.hxx
src/SMDS/SMDS_VtkFace.cxx
src/SMDS/SMDS_VtkFace.hxx
src/SMDS/SMDS_VtkVolume.cxx
src/SMDS/SMDS_VtkVolume.hxx

index 63f42c382d11f7f1b36e477b5d798592b158372e..a03bc0bf7d3d012d485236aae5025e11a3ba3189 100644 (file)
@@ -189,3 +189,8 @@ SMDSAbs_EntityType SMDS_FaceOfEdges::GetEntityType() const
 {
   return myNbEdges == 3 ? SMDSEntity_Triangle : SMDSEntity_Quadrangle;
 }
+
+SMDSAbs_GeometryType SMDS_FaceOfEdges::GetGeomType() const
+{
+  return myNbEdges == 3 ? SMDSGeom_TRIANGLE : SMDSGeom_QUADRANGLE;
+}
index 9748dd8520fdee188c76b6c8a20cf2ee6e06059a..9eb81b1f00eb868b345a30104401f74aeae12513 100644 (file)
@@ -46,25 +46,18 @@ class SMDS_EXPORT SMDS_FaceOfEdges:public SMDS_MeshFace
                          const SMDS_MeshEdge* edge3,
                          const SMDS_MeshEdge* edge4);
                 
-        SMDSAbs_ElementType GetType() const;
+        virtual SMDSAbs_ElementType  GetType() const;
         virtual SMDSAbs_EntityType   GetEntityType() const;
-        virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes) {return false;};
-        int NbNodes() const;
-        int NbEdges() const;
-        int NbFaces() const;
-//      friend bool operator<(const SMDS_FaceOfEdges& e1, const SMDS_FaceOfEdges& e2);
-
-
-  /*!
-   * \brief Return node by its index
-    * \param ind - node index
-    * \retval const SMDS_MeshNode* - the node
-   */
-  virtual const SMDS_MeshNode* GetNode(const int ind) const;
+        virtual SMDSAbs_GeometryType GetGeomType() const;
+        virtual bool ChangeNodes(const SMDS_MeshNode* nodes[],
+                                 const int            nbNodes) {return false;}
+        virtual int NbNodes() const;
+        virtual int NbEdges() const;
+        virtual int NbFaces() const;
+        virtual const SMDS_MeshNode* GetNode(const int ind) const;
 
   protected:
-        SMDS_ElemIteratorPtr
-                elementsIterator(SMDSAbs_ElementType type) const;
+        virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const;
 
   private:
         const SMDS_MeshEdge* myEdges[4];
index 054eeefdcf334ce026b811d4c56cb684004e76d3..9d05d450531589c03a9c3d27a62083a192a595c9 100644 (file)
@@ -180,5 +180,9 @@ const SMDS_MeshNode* SMDS_FaceOfNodes::GetNode(const int ind) const
 
 SMDSAbs_EntityType SMDS_FaceOfNodes::GetEntityType() const
 {
-  return myNbNodes == 3 ? SMDSEntity_Triangle : SMDSEntity_Quadrangle;
+  return NbNodes() == 3 ? SMDSEntity_Triangle : SMDSEntity_Quadrangle;
+}
+SMDSAbs_GeometryType SMDS_FaceOfNodes::GetGeomType() const
+{
+  return NbNodes() == 3 ? SMDSGeom_TRIANGLE : SMDSGeom_QUADRANGLE;
 }
index 48242b10fbbb44ad049d02c38fbb4a01865f2ba0..79b94ba05e4a9342a7f183f1579e02246aeaeba7 100644 (file)
@@ -58,6 +58,7 @@ class SMDS_EXPORT SMDS_FaceOfNodes:public SMDS_MeshFace
   virtual const SMDS_MeshNode* GetNode(const int ind) const;
 
   virtual SMDSAbs_EntityType   GetEntityType() const;
+  virtual SMDSAbs_GeometryType GetGeomType() const;
 
   protected:
         SMDS_ElemIteratorPtr
index fa61fb4fe7476a9c4d4cfe77db00d36f50a5f30e..a1a244c6dc3de014917bce36df57019e6bc02f69 100644 (file)
@@ -19,7 +19,6 @@
 
 //  SMESH SMDS : implementaion of Salome mesh data structure
 //  File   : SMDS_Mesh0DElement.cxx
-//  Author : Jean-Michel BOULCOURT
 //  Module : SMESH
 //
 #ifdef _MSC_VER
@@ -125,18 +124,6 @@ SMDS_ElemIteratorPtr SMDS_Mesh0DElement::elementsIterator (SMDSAbs_ElementType t
   }
 }
 
-//=======================================================================
-//function : operator<
-//purpose  :
-//=======================================================================
-bool operator< (const SMDS_Mesh0DElement & e1, const SMDS_Mesh0DElement & e2)
-{
-  int id1 = e1.myNode->getVtkId();
-  int id2 = e2.myNode->getVtkId();
-
-  return (id1 < id2);
-}
-
 /*!
  * \brief Return node by its index
  * \param ind - node index
index 106c5276d15fbc09cee5c930a84598898fa5c2c3..81578a81698665f12ec4ea275e58f8e1068b4da4 100644 (file)
@@ -36,24 +36,18 @@ class SMDS_EXPORT SMDS_Mesh0DElement: public SMDS_MeshCell
   SMDS_Mesh0DElement (const SMDS_MeshNode * node);
   bool ChangeNode (const SMDS_MeshNode * node);
   virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes) {return false;};
-  void Print (std::ostream & OS) const;
-
-  SMDSAbs_ElementType GetType() const;
-  virtual vtkIdType GetVtkType() const;
-  SMDSAbs_EntityType  GetEntityType() const {return SMDSEntity_0D;}
-  int NbNodes() const;
-  int NbEdges() const;
-  friend bool operator< (const SMDS_Mesh0DElement& e1, const SMDS_Mesh0DElement& e2);
-
-  /*!
-   * \brief Return node by its index
-   * \param ind - node index
-   * \retval const SMDS_MeshNode* - the node
-   */
+  virtual void Print (std::ostream & OS) const;
+
+  virtual SMDSAbs_ElementType  GetType() const;
+  virtual vtkIdType            GetVtkType() const;
+  virtual SMDSAbs_EntityType   GetEntityType() const {return SMDSEntity_0D;}
+  virtual SMDSAbs_GeometryType GetGeomType() const { return SMDSGeom_POINT; }
   virtual const SMDS_MeshNode* GetNode (const int ind) const;
+  virtual int NbNodes() const;
+  virtual int NbEdges() const;
 
  protected:
-  SMDS_ElemIteratorPtr elementsIterator (SMDSAbs_ElementType type) const;
+  virtual SMDS_ElemIteratorPtr elementsIterator (SMDSAbs_ElementType type) const;
 
  protected:
   const SMDS_MeshNode* myNode;
index 54f426c96c7f3f9810768d23798bce44743b911e..63ae2f071ef62182e90f49c40288bf7787ab09e5 100644 (file)
 
 #include "SMDS_MeshCell.hxx"
 
-class SMDS_EXPORT SMDS_MeshEdge:public SMDS_MeshCell
+class SMDS_EXPORT SMDS_MeshEdge: public SMDS_MeshCell
 {
         
-  public:
-        SMDSAbs_ElementType GetType() const;
-        virtual vtkIdType GetVtkType() const;
+ public:
+  virtual SMDSAbs_ElementType  GetType() const;
+  virtual vtkIdType            GetVtkType() const;
+  virtual SMDSAbs_GeometryType GetGeomType() const { return SMDSGeom_EDGE; }
 };
 #endif
index 4ec911359e46e2769ad22c242b6c69e4ccd12c8e..918ebb668efe33ac67a27d406d4447f14296d1f7 100644 (file)
@@ -80,11 +80,11 @@ public:
 
   ///Return the type of the current element
   virtual SMDSAbs_ElementType GetType() const = 0;
+  virtual SMDSAbs_EntityType GetEntityType() const = 0;
+  virtual SMDSAbs_GeometryType GetGeomType() const = 0;
   virtual vtkIdType GetVtkType() const = 0;
-  virtual bool IsPoly() const { return false; };
+  virtual bool IsPoly() const { return false; }
   virtual bool IsQuadratic() const;
-  //! Return type of entity
-  virtual SMDSAbs_EntityType  GetEntityType() const = 0;
 
   virtual bool IsMediumNode(const SMDS_MeshNode* node) const;
   virtual int  NbCornerNodes() const;
@@ -140,10 +140,32 @@ public:
    */
   int GetNodeIndex( const SMDS_MeshNode* node ) const;
 
-  inline ShortType getMeshId() const {return myMeshId; }
-  inline LongType  getshapeId() const {return myShapeId; }
-  inline int getIdInShape() const { return myIdInShape; }
-  inline int getVtkId() const { return myVtkID; }
+  inline ShortType getMeshId()  const { return myMeshId; }
+  inline LongType  getshapeId() const { return myShapeId; }
+  inline int getIdInShape()     const { return myIdInShape; }
+  inline int getVtkId()         const { return myVtkID; }
+
+  /*!
+   * \brief Filters of elements, to be used with SMDS_SetIterator
+   */
+  struct TypeFilter
+  {
+    SMDSAbs_ElementType _type;
+    TypeFilter( SMDSAbs_ElementType t = SMDSAbs_NbElementTypes ):_type(t) {}
+    bool operator()(const SMDS_MeshElement* e) const { return e && e->GetType() == _type; }
+  };
+  struct EntityFilter
+  {
+    SMDSAbs_EntityType _type;
+    EntityFilter( SMDSAbs_EntityType t = SMDSEntity_Last ):_type(t) {}
+    bool operator()(const SMDS_MeshElement* e) const { return e && e->GetEntityType() == _type; }
+  };
+  struct GeomFilter
+  {
+    SMDSAbs_GeometryType _type;
+    GeomFilter( SMDSAbs_GeometryType t = SMDSGeom_NONE ):_type(t) {}
+    bool operator()(const SMDS_MeshElement* e) const { return e && e->GetGeomType() == _type; }
+  };
 
 protected:
   inline void setId(int id) {myID = id; }
index 483b01cb5bc163cadef071555e82d439efe5915e..78966bc5795fda355d610bb51f09ce9069995d02 100644 (file)
@@ -33,7 +33,7 @@
 #include "SMDS_Position.hxx"
 #include "ObjectPool.hxx"
 
-class SMDS_EXPORT SMDS_MeshNode:public SMDS_MeshElement
+class SMDS_EXPORT SMDS_MeshNode: public SMDS_MeshElement
 {
 public:
   friend class SMESHDS_Mesh;
@@ -49,12 +49,11 @@ public:
   SMDS_ElemIteratorPtr    GetInverseElementIterator(SMDSAbs_ElementType type=SMDSAbs_All) const;
   int                     NbInverseElements(SMDSAbs_ElementType type=SMDSAbs_All) const;
   const SMDS_PositionPtr& GetPosition() const;
-  SMDSAbs_ElementType     GetType() const;
-  virtual vtkIdType       GetVtkType() const;
-  SMDSAbs_EntityType      GetEntityType() const {return SMDSEntity_Node;}
-  int                     NbNodes() const;
-
-  friend bool operator<(const SMDS_MeshNode& e1, const SMDS_MeshNode& e2);
+  virtual SMDSAbs_ElementType  GetType() const;
+  virtual vtkIdType            GetVtkType() const;
+  virtual SMDSAbs_EntityType   GetEntityType() const { return SMDSEntity_Node;}
+  virtual SMDSAbs_GeometryType GetGeomType() const   { return SMDSGeom_NONE; }
+  virtual int                  NbNodes() const;
 
   void SetPosition(const SMDS_PositionPtr& aPos);
   void setXYZ(double x, double y, double z);
index aef6b777c7417c3efcf804d208d6be8c6850d148..e5aa46096702d8ab9cf73c53489511f38ca3a505 100644 (file)
@@ -153,3 +153,17 @@ SMDSAbs_EntityType SMDS_VolumeOfFaces::GetEntityType() const
   }
   return aType;
 }
+
+SMDSAbs_GeometryType SMDS_VolumeOfFaces::GetGeomType() const
+{
+  SMDSAbs_GeometryType aType = SMDSGeom_NONE;
+  switch(myNbFaces)
+  {
+  case 4: aType = SMDSGeom_TETRA;   break;
+  case 5: aType = SMDSGeom_PYRAMID; break;
+  case 6: aType = SMDSGeom_PENTA;   break;
+  case 8:
+  default: aType = SMDSGeom_HEXA;   break;
+  }
+  return aType;
+}
index 5da8fc71f7d9cc275acb929e415889cdcd867667..a64d53ab51f6c46c668a085e9cec370ac0a52cc0 100644 (file)
@@ -56,14 +56,15 @@ class SMDS_EXPORT SMDS_VolumeOfFaces:public SMDS_MeshVolume
                            const SMDS_MeshFace * face6);
 
         virtual SMDSAbs_EntityType GetEntityType() const;
-        virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes) {return false;};
-        void Print(std::ostream & OS) const;
+        virtual SMDSAbs_GeometryType GetGeomType() const;
+        virtual bool ChangeNodes(const SMDS_MeshNode* nodes[],
+                                 const int            nbNodes) {return false;}
+        virtual void Print(std::ostream & OS) const;
 
-        int NbFaces() const;
+        virtual int NbFaces() const;
 
   protected:
-        SMDS_ElemIteratorPtr
-                elementsIterator(SMDSAbs_ElementType type) const;
+        virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const;
         const SMDS_MeshFace * myFaces[6];
         int                   myNbFaces;
 };
index e38d61b2a82f41e1f820c16cddec57c6da0f7a3a..cb4cdfa34d4d26494c6d89e19e1ae604f47e84ff 100644 (file)
@@ -254,4 +254,18 @@ SMDSAbs_EntityType SMDS_VolumeOfNodes::GetEntityType() const
   return aType;
 }
 
+SMDSAbs_GeometryType SMDS_VolumeOfNodes::GetGeomType() const
+{
+  SMDSAbs_GeometryType aType = SMDSGeom_NONE;
+  switch(myNbNodes)
+  {
+  case 4: aType = SMDSGeom_TETRA;   break;
+  case 5: aType = SMDSGeom_PYRAMID; break;
+  case 6: aType = SMDSGeom_PENTA;   break;
+  case 12: aType = SMDSGeom_HEXAGONAL_PRISM; break;
+  case 8:
+  default: aType = SMDSGeom_HEXA;    break;
+  }
+  return aType;
+}
 
index 420d855fc8ecacc9f9667af3ea86f66148da5949..86e22b6229638450cbfc0840492b6e79255494c8 100644 (file)
@@ -70,8 +70,9 @@ class SMDS_EXPORT SMDS_VolumeOfNodes:public SMDS_MeshVolume
         int NbFaces() const;
         int NbNodes() const;
         int NbEdges() const;
-        virtual SMDSAbs_ElementType GetType() const;    
-        virtual SMDSAbs_EntityType GetEntityType() const;
+        virtual SMDSAbs_ElementType  GetType() const;    
+        virtual SMDSAbs_EntityType   GetEntityType() const;
+        virtual SMDSAbs_GeometryType GetGeomType() const;
 
   /*!
    * \brief Return node by its index
index 226625861b22d9f8cdae4cbb2510a574a464d838..c5f04300b98cb283a8c3b83ecad479ca93df59a9 100644 (file)
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
+//  SMESH SMDS : implementaion of Salome mesh data structure
+//  File   : SMDS_VtkEdge.hxx
+//  Module : SMESH
+
 #ifndef _SMDS_VTKEDGE_HXX_
 #define _SMDS_VTKEDGE_HXX_
 
@@ -38,9 +42,9 @@ public:
   virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes);
   virtual bool IsMediumNode(const SMDS_MeshNode* node) const;
 
-  void Print(std::ostream & OS) const;
-  int NbNodes() const;
-  int NbEdges() const;
+  virtual void Print(std::ostream & OS) const;
+  virtual int NbNodes() const;
+  virtual int NbEdges() const;
 
   virtual vtkIdType GetVtkType() const;
   virtual SMDSAbs_EntityType GetEntityType() const;
index 338795e3539a1590d8f4e8af3d3bc37d4943fd6b..80644c7e2ab6b2f9869d7755b043da4876fb52fc 100644 (file)
@@ -238,6 +238,25 @@ SMDSAbs_EntityType SMDS_VtkFace::GetEntityType() const
   return SMDS_MeshCell::toSmdsType( VTKCellType( aVtkType ));
 }
 
+SMDSAbs_GeometryType SMDS_VtkFace::GetGeomType() const
+{
+  vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
+  vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
+  switch ( aVtkType ) {
+  case VTK_TRIANGLE:
+  case VTK_QUADRATIC_TRIANGLE:
+    return SMDSGeom_TRIANGLE;
+  case VTK_QUAD:
+  case VTK_QUADRATIC_QUAD:
+  case VTK_BIQUADRATIC_QUAD:
+    return SMDSGeom_QUADRANGLE;
+  case VTK_POLYGON:
+    return SMDSGeom_POLYGON;
+  default:;
+  }
+  return SMDSGeom_NONE;
+}
+
 vtkIdType SMDS_VtkFace::GetVtkType() const
 {
   vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
index e9fda428b62ee6257d7e9fce89b01416a7b5dbc4..f84192f3fd49f73d700d30cc529d0cc155023e3e 100644 (file)
@@ -34,16 +34,20 @@ public:
   ~SMDS_VtkFace();
   void init(const std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh);
   void initPoly(const std::vector<vtkIdType>& nodeIds, SMDS_Mesh* mesh);
+
   bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes);
   void ChangeApex(SMDS_MeshNode* node); // to use only for tmp triangles
-  void Print(std::ostream & OS) const;
-  int NbEdges() const;
-  int NbFaces() const;
-  int NbNodes() const;
 
-  virtual vtkIdType GetVtkType() const;
-  virtual SMDSAbs_EntityType GetEntityType() const;
+  virtual void Print(std::ostream & OS) const;
+  virtual int NbEdges() const;
+  virtual int NbFaces() const;
+  virtual int NbNodes() const;
+
+  virtual vtkIdType            GetVtkType() const;
+  virtual SMDSAbs_EntityType   GetEntityType() const;
+  virtual SMDSAbs_GeometryType GetGeomType() const;
   virtual const SMDS_MeshNode* GetNode(const int ind) const;
+
   virtual bool IsQuadratic() const;
   virtual bool IsPoly() const;
   virtual bool IsMediumNode(const SMDS_MeshNode* node) const;
index 640b4484406cd954dd4cbb4ac1fea6a0843e24ce..de9174e0b6273d8f62e90b4ff02ad583797a1bac 100644 (file)
@@ -571,6 +571,46 @@ SMDSAbs_EntityType SMDS_VtkVolume::GetEntityType() const
   return aType;
 }
 
+SMDSAbs_GeometryType SMDS_VtkVolume::GetGeomType() const
+{
+  vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
+  vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
+
+  SMDSAbs_GeometryType aType = SMDSGeom_NONE;
+  switch (aVtkType)
+  {
+    case VTK_TETRA:
+    case VTK_QUADRATIC_TETRA:
+      aType = SMDSGeom_TETRA;
+      break;
+    case VTK_PYRAMID:
+    case VTK_QUADRATIC_PYRAMID:
+      aType = SMDSGeom_PYRAMID;
+      break;
+    case VTK_WEDGE:
+    case VTK_QUADRATIC_WEDGE:
+      aType = SMDSGeom_PENTA;
+      break;
+    case VTK_HEXAHEDRON:
+    case VTK_QUADRATIC_HEXAHEDRON:
+    case VTK_TRIQUADRATIC_HEXAHEDRON:
+      aType = SMDSGeom_HEXA;
+      break;
+    case VTK_HEXAGONAL_PRISM:
+      aType = SMDSGeom_HEXAGONAL_PRISM;
+      break;
+//#ifdef VTK_HAVE_POLYHEDRON
+    case VTK_POLYHEDRON:
+      aType = SMDSGeom_POLYHEDRA;
+      break;
+//#endif
+    default:
+      aType = SMDSGeom_POLYHEDRA;
+      break;
+  }
+  return aType;
+}
+
 vtkIdType SMDS_VtkVolume::GetVtkType() const
 {
   vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
index 5192c5d0ab3366ecc10ab0c706efccbfc3bc9c14..5f3f62b31935dcbbefea015acc73b3ef60659260 100644 (file)
@@ -40,10 +40,10 @@ public:
   virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes);
   virtual bool vtkOrder(const SMDS_MeshNode* nodes[], const int nbNodes);
 
-  void Print(std::ostream & OS) const;
-  int NbFaces() const;
-  int NbNodes() const;
-  int NbEdges() const;
+  virtual void Print(std::ostream & OS) const;
+  virtual int NbFaces() const;
+  virtual int NbNodes() const;
+  virtual int NbEdges() const;
 
   // 1 <= face_ind <= NbFaces()
   int NbFaceNodes (const int face_ind) const;
@@ -51,9 +51,10 @@ public:
   // 1 <= node_ind <= NbFaceNodes()
   const SMDS_MeshNode* GetFaceNode (const int face_ind, const int node_ind) const;
 
-  virtual SMDSAbs_ElementType GetType() const;
-  virtual vtkIdType GetVtkType() const;
-  virtual SMDSAbs_EntityType GetEntityType() const;
+  virtual SMDSAbs_ElementType  GetType() const;
+  virtual vtkIdType            GetVtkType() const;
+  virtual SMDSAbs_EntityType   GetEntityType() const;
+  virtual SMDSAbs_GeometryType GetGeomType() const;
   virtual const SMDS_MeshNode* GetNode(const int ind) const;
   virtual bool IsQuadratic() const;
   virtual bool IsPoly() const;