Version: 9.12.0
SMDS_MeshElement.hxx
Go to the documentation of this file.
1 // Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 
23 // SMESH SMDS : implementation of Salome mesh data structure
24 // File : SMDS_MeshElement.hxx
25 // Module : SMESH
26 //
27 #ifndef _SMDS_MeshElement_HeaderFile
28 #define _SMDS_MeshElement_HeaderFile
29 
30 #include "SMESH_SMDS.hxx"
31 
32 #include "SMDSAbs_ElementType.hxx"
33 #include "SMDS_MeshObject.hxx"
34 #include "SMDS_ElemIterator.hxx"
35 #include "SMDS_StdIterator.hxx"
36 
37 #include <iostream>
38 
39 #include <vtkType.h>
40 #include <vtkCellType.h>
41 #include <smIdType.hxx>
42 
43 class SMDS_ElementChunk;
44 class SMDS_Mesh;
45 class SMDS_MeshNode;
47 
48 // ============================================================
52 // ============================================================
53 
54 
56 {
57 public:
58 
59  // ===========================
60  // Access to nodes
61  // ===========================
62  virtual SMDS_ElemIteratorPtr nodesIterator() const = 0;
63 
64  virtual SMDS_NodeIteratorPtr nodeIterator() const = 0;
65  virtual SMDS_NodeIteratorPtr interlacedNodesIterator() const { return nodeIterator(); }
66  virtual SMDS_NodeIteratorPtr nodesIteratorToUNV() const { return nodeIterator(); }
67 
68  // std-like iteration on nodes
70  iterator begin_nodes() const { return iterator( nodeIterator() ); }
71  iterator end_nodes() const { return iterator(); }
72 
73  // ===========================
74  // Type of element
75  // ===========================
76  virtual int NbNodes() const = 0;
77  virtual int NbEdges() const = 0;
78  virtual int NbFaces() const = 0;
79 
80  virtual SMDSAbs_ElementType GetType() const = 0;
81  virtual SMDSAbs_EntityType GetEntityType() const = 0;
82  virtual SMDSAbs_GeometryType GetGeomType() const = 0;
83  virtual VTKCellType GetVtkType() const = 0;
84 
85  virtual bool IsPoly() const = 0;
86  virtual bool IsQuadratic() const = 0;
87  virtual bool IsMediumNode(const SMDS_MeshNode* node) const;
88  virtual int NbCornerNodes() const = 0;
89 
90  // ===========================
91  // Access to nodes by index
92  // ===========================
98  virtual const SMDS_MeshNode* GetNode(const int ind) const = 0;
99 
107  const SMDS_MeshNode* GetNodeWrap(const int ind) const { return GetNode( WrappedIndex( ind )); }
108 
114  virtual bool IsValidIndex(const int ind) const;
115 
121  int WrappedIndex(const int ind) const;
122 
128  virtual int GetNodeIndex( const SMDS_MeshNode* node ) const;
129 
130 
131  virtual smIdType GetID() const;
132  virtual vtkIdType GetVtkID() const;
133  virtual int getshapeId() const { return GetShapeID(); }
134  virtual int GetShapeID() const;
135 
136  // mark this element; to be used in algos
137  virtual void setIsMarked( bool is ) const;
138  virtual bool isMarked() const;
139 
140  // element can be allocated but "not used"
141  bool IsNull() const { return myHolder == 0; }
142 
143  SMDS_Mesh* GetMesh() const;
144 
145  void Print(std::ostream & OS) const;
146 
147  friend SMDS_EXPORT std::ostream & operator <<(std::ostream & OS, const SMDS_MeshElement *);
148  friend class SMDS_ElementFactory;
149  friend class SMESHDS_SubMesh;
150 
154  struct Filter
155  {
156  virtual bool operator()(const SMDS_MeshElement* e) const = 0;
157  virtual ~Filter() {}
158  };
159  struct NonNullFilter: public Filter
160  {
161  bool operator()(const SMDS_MeshElement* e) const { return e; }
162  };
163  struct TypeFilter : public Filter
164  {
167  bool operator()(const SMDS_MeshElement* e) const { return e && e->GetType() == _type; }
168  };
169  struct EntityFilter : public Filter
170  {
173  bool operator()(const SMDS_MeshElement* e) const { return e && e->GetEntityType() == _type; }
174  };
175  struct GeomFilter : public Filter
176  {
179  bool operator()(const SMDS_MeshElement* e) const { return e && e->GetGeomType() == _type; }
180  };
181 
182  protected:
183 
185 
186  void setVtkID(const vtkIdType vtkID );
187  virtual void setShapeID( const int shapeID ) const;
188 
189  SMDS_UnstructuredGrid* getGrid() const;
190 
191  protected:
192 
194 };
195 
196 // ============================================================
200 // ============================================================
201 
203  bool operator () (const SMDS_MeshElement* e1, const SMDS_MeshElement* e2) const
204  { return e1->GetType() == e2->GetType() ? e1->GetID() < e2->GetID() : e1->GetType() < e2->GetType(); }
205 };
206 
207 // WARNING: this comparator makes impossible to store both nodes and elements in the same set
208 // because there are nodes and elements with the same ID. Use TIDTypeCompare for such containers.
209 struct TIDCompare {
210  bool operator () (const SMDS_MeshElement* e1, const SMDS_MeshElement* e2) const
211  { return e1->GetID() < e2->GetID(); }
212 };
213 
214 #endif
SMDSAbs_GeometryType
enumeration for element geometry type
Definition: SMDSAbs_ElementType.hxx:47
@ SMDSGeom_NONE
Definition: SMDSAbs_ElementType.hxx:66
SMDSAbs_ElementType
Type (node, edge, face or volume) of elements.
Definition: SMDSAbs_ElementType.hxx:34
@ SMDSAbs_NbElementTypes
Definition: SMDSAbs_ElementType.hxx:42
SMDSAbs_EntityType
Enumeration of entity type used in mesh info array.
Definition: SMDSAbs_ElementType.hxx:79
@ SMDSEntity_Last
Definition: SMDSAbs_ElementType.hxx:106
boost::shared_ptr< SMDS_Iterator< const SMDS_MeshElement * > > SMDS_ElemIteratorPtr
Definition: SMDS_ElemIterator.hxx:43
boost::shared_ptr< SMDS_Iterator< const SMDS_MeshNode * > > SMDS_NodeIteratorPtr
Definition: SMDS_ElemIterator.hxx:46
ostream & operator<<(ostream &OS, const SMDS_MeshElement *e)
Definition: SMDS_MeshElement.cxx:212
#define SMDS_EXPORT
Definition: SMESH_SMDS.hxx:37
Allocate SMDS_MeshElement's (SMDS_MeshCell's or SMDS_MeshNode's ) and bind some attributes to element...
Definition: SMDS_ElementFactory.hxx:374
Allocate SMDS_MeshElement's (SMDS_MeshCell's or SMDS_MeshNode's ) and bind some attributes to element...
Definition: SMDS_ElementFactory.hxx:65
Base class for elements.
Definition: SMDS_MeshElement.hxx:56
virtual bool IsPoly() const =0
virtual int getshapeId() const
Definition: SMDS_MeshElement.hxx:133
virtual smIdType GetID() const
Return ID of an element.
Definition: SMDS_MeshElement.cxx:108
SMDS_StdIterator< const SMDS_MeshNode *, SMDS_NodeIteratorPtr > iterator
Definition: SMDS_MeshElement.hxx:69
virtual int NbCornerNodes() const =0
iterator end_nodes() const
Definition: SMDS_MeshElement.hxx:71
virtual int NbFaces() const =0
virtual SMDSAbs_EntityType GetEntityType() const =0
virtual int NbEdges() const =0
const SMDS_MeshNode * GetNodeWrap(const int ind) const
Return node by its index.
Definition: SMDS_MeshElement.hxx:107
virtual SMDS_ElemIteratorPtr nodesIterator() const =0
virtual SMDSAbs_GeometryType GetGeomType() const =0
virtual bool IsQuadratic() const =0
bool IsNull() const
Definition: SMDS_MeshElement.hxx:141
virtual const SMDS_MeshNode * GetNode(const int ind) const =0
Return node by its index.
virtual SMDS_NodeIteratorPtr interlacedNodesIterator() const
Definition: SMDS_MeshElement.hxx:65
virtual SMDS_NodeIteratorPtr nodesIteratorToUNV() const
Definition: SMDS_MeshElement.hxx:66
virtual int NbNodes() const =0
virtual SMDSAbs_ElementType GetType() const =0
iterator begin_nodes() const
Definition: SMDS_MeshElement.hxx:70
virtual SMDS_NodeIteratorPtr nodeIterator() const =0
SMDS_ElementChunk * myHolder
Definition: SMDS_MeshElement.hxx:193
virtual VTKCellType GetVtkType() const =0
Definition: SMDS_MeshNode.hxx:36
Definition: SMDS_MeshObject.hxx:33
Definition: SMDS_Mesh.hxx:53
Wrapper over pointer to SMDS_Iterator, like SMDS_ElemIteratorPtr, enabling its usage in std-like way:...
Definition: SMDS_StdIterator.hxx:38
Definition: SMDS_UnstructuredGrid.hxx:74
Definition: SMESHDS_SubMesh.hxx:48
void Print(SharedPtr< TimeStampValueType > theTimeStampValue)
Definition: MED_Wrapper.cxx:161
Definition: SMDS_MeshElement.hxx:170
bool operator()(const SMDS_MeshElement *e) const
Definition: SMDS_MeshElement.hxx:173
EntityFilter(SMDSAbs_EntityType t=SMDSEntity_Last)
Definition: SMDS_MeshElement.hxx:172
SMDSAbs_EntityType _type
Definition: SMDS_MeshElement.hxx:171
Filters of elements, to be used with SMDS_SetIterator.
Definition: SMDS_MeshElement.hxx:155
virtual ~Filter()
Definition: SMDS_MeshElement.hxx:157
virtual bool operator()(const SMDS_MeshElement *e) const =0
Definition: SMDS_MeshElement.hxx:176
SMDSAbs_GeometryType _type
Definition: SMDS_MeshElement.hxx:177
bool operator()(const SMDS_MeshElement *e) const
Definition: SMDS_MeshElement.hxx:179
GeomFilter(SMDSAbs_GeometryType t=SMDSGeom_NONE)
Definition: SMDS_MeshElement.hxx:178
Definition: SMDS_MeshElement.hxx:160
bool operator()(const SMDS_MeshElement *e) const
Definition: SMDS_MeshElement.hxx:161
Definition: SMDS_MeshElement.hxx:164
bool operator()(const SMDS_MeshElement *e) const
Definition: SMDS_MeshElement.hxx:167
SMDSAbs_ElementType _type
Definition: SMDS_MeshElement.hxx:165
TypeFilter(SMDSAbs_ElementType t=SMDSAbs_NbElementTypes)
Definition: SMDS_MeshElement.hxx:166
Definition: SMDS_MeshElement.hxx:209
bool operator()(const SMDS_MeshElement *e1, const SMDS_MeshElement *e2) const
Definition: SMDS_MeshElement.hxx:210
Comparator of elements by ID for usage in std containers.
Definition: SMDS_MeshElement.hxx:202
bool operator()(const SMDS_MeshElement *e1, const SMDS_MeshElement *e2) const
Definition: SMDS_MeshElement.hxx:203