Salome HOME
21680: EDF 2288 SMESH: creation of 0D elements from other elements
[modules/smesh.git] / src / SMDS / SMDS_MeshElement.hxx
index d4f32a51b40e68426a55d5fc545abed0a570f51a..918ebb668efe33ac67a27d406d4447f14296d1f7 100644 (file)
@@ -1,23 +1,23 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007  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 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.
+// 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
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 //  SMESH SMDS : implementaion of Salome mesh data structure
@@ -43,6 +43,7 @@
 
 //typedef unsigned short UShortType;
 typedef short ShortType;
+typedef int   LongType;
 
 class SMDS_MeshNode;
 class SMDS_MeshEdge;
@@ -79,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;
@@ -139,18 +140,41 @@ public:
    */
   int GetNodeIndex( const SMDS_MeshNode* node ) const;
 
-  inline ShortType getMeshId() const {return myMeshId; };
-  inline ShortType 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; };
-  inline void setShapeId(ShortType shapeId) {myShapeId = shapeId; };
-  inline void setIdInShape(int id) { myIdInShape = id; };
-  inline void setVtkId(int vtkId) { myVtkID = vtkId; };
+  inline void setId(int id) {myID = id; }
+  inline void setShapeId(LongType shapeId) {myShapeId = shapeId; }
+  inline void setIdInShape(int id) { myIdInShape = id; }
+  inline void setVtkId(int vtkId) { myVtkID = vtkId; }
   SMDS_MeshElement(int ID=-1);
-  SMDS_MeshElement(int id, ShortType meshId, ShortType shapeId = 0);
+  SMDS_MeshElement(int id, ShortType meshId, LongType shapeId = 0);
+  virtual void init(int id = -1, ShortType meshId = -1, LongType shapeId = 0);
   virtual void Print(std::ostream & OS) const;
 
   //! Element index in vector SMDS_Mesh::myNodes or SMDS_Mesh::myCells
@@ -160,7 +184,7 @@ protected:
   //! SMDS_Mesh identification in SMESH
   ShortType myMeshId;
   //! SubShape and SubMesh identification in SMESHDS
-  ShortType myShapeId;
+  LongType myShapeId;
   //! Element index in SMESHDS_SubMesh vector
   int myIdInShape;
 };