SALOME - SMESH
SMDS_MeshInfo.hxx
Go to the documentation of this file.
1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, 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.
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 // File : SMDS_MeshInfo.hxx
23 // Created : Mon Sep 24 18:32:41 2007
24 // Author : Edward AGAPOV (eap)
25 //
26 #ifndef SMDS_MeshInfo_HeaderFile
27 #define SMDS_MeshInfo_HeaderFile
28 
29 #ifdef __BORLANDC__
30 #pragma warn -8066
31 #pragma warn -8012
32 #endif
33 
34 using namespace std;
35 
36 #include "SMESH_SMDS.hxx"
37 
38 #include "SMDS_MeshElement.hxx"
39 
41 {
42 public:
43 
44  inline SMDS_MeshInfo();
45  inline void Clear();
46 
47  int NbNodes() const { return myNbNodes; }
48  inline int NbElements(SMDSAbs_ElementType type=SMDSAbs_All) const;
49  inline int NbEntities(SMDSAbs_EntityType type) const;
50 
51  int Nb0DElements() const { return myNb0DElements; }
52  inline int NbEdges (SMDSAbs_ElementOrder order = ORDER_ANY) const;
53  inline int NbFaces (SMDSAbs_ElementOrder order = ORDER_ANY) const;
54  inline int NbTriangles (SMDSAbs_ElementOrder order = ORDER_ANY) const;
55  inline int NbQuadrangles(SMDSAbs_ElementOrder order = ORDER_ANY) const;
56  int NbPolygons() const { return myNbPolygons; }
57 
58  inline int NbVolumes (SMDSAbs_ElementOrder order = ORDER_ANY) const;
59  inline int NbTetras (SMDSAbs_ElementOrder order = ORDER_ANY) const;
60  inline int NbHexas (SMDSAbs_ElementOrder order = ORDER_ANY) const;
61  inline int NbPyramids(SMDSAbs_ElementOrder order = ORDER_ANY) const;
62  inline int NbPrisms (SMDSAbs_ElementOrder order = ORDER_ANY) const;
63  int NbPolyhedrons() const { return myNbPolyhedrons; }
64 
65 private:
66  friend class SMDS_Mesh;
67 
68  // methods to count NOT POLY elements
69  inline void remove(const SMDS_MeshElement* el);
70  inline void add (const SMDS_MeshElement* el);
71  inline int index(SMDSAbs_ElementType type, int nbNodes) const;
72  // methods to remove elements of ANY kind
73  inline void RemoveEdge(const SMDS_MeshElement* el);
74  inline void RemoveFace(const SMDS_MeshElement* el);
75  inline void RemoveVolume(const SMDS_MeshElement* el);
76 
77  int myNbNodes;
78 
80  int myNbEdges , myNbQuadEdges ;
81  int myNbTriangles , myNbQuadTriangles ;
82  int myNbQuadrangles, myNbQuadQuadrangles;
84 
85  int myNbTetras , myNbQuadTetras ;
86  int myNbHexas , myNbQuadHexas ;
87  int myNbPyramids, myNbQuadPyramids;
88  int myNbPrisms , myNbQuadPrisms ;
90 
91  std::vector<int*> myNb; // pointers to myNb... fields
92  std::vector<int> myShift; // shift to get an index in myNb by elem->NbNodes()
93 };
94 
96  myNbNodes(0),
97  myNb0DElements(0),
98  myNbEdges (0), myNbQuadEdges (0),
99  myNbTriangles (0), myNbQuadTriangles (0),
100  myNbQuadrangles(0), myNbQuadQuadrangles(0),
101  myNbPolygons(0),
102  myNbTetras (0), myNbQuadTetras (0),
103  myNbHexas (0), myNbQuadHexas (0),
104  myNbPyramids(0), myNbQuadPyramids(0),
105  myNbPrisms (0), myNbQuadPrisms (0),
106  myNbPolyhedrons(0)
107 {
108  // Number of nodes in standard element types
109  // n v f e 0 n
110  // o o a d d o
111  // d l c g d
112  // e e e e
113  // s
114  // -----------------
115  // 0 *
116  // 1 . *
117  // 2 *
118  // 3 . *
119  // 4 * . .
120  // 5 *
121  // 6 * .
122  // 7
123  // 8 * .
124  // 9
125  // 10 *
126  // 11 *
127  // 12 *
128  // 13 *
129  // 14 *
130  // 15 *
131  // 16 *
132  // 17
133  // 18
134  // 19
135  // 20 *
136  //
137  // So to have a unique index for each type basing on nb of nodes, we use a shift:
138  myShift.resize(SMDSAbs_NbElementTypes, 0);
139 
140  myShift[ SMDSAbs_Face ] = +8; // 3->11, 4->12, 6->14, 8->16
141  myShift[ SMDSAbs_Edge ] = -2; // 2->0, 4->2
142  myShift[ SMDSAbs_0DElement ] = +2; // 1->3
143 
144  myNb.resize( index( SMDSAbs_Volume,20 ) + 1, NULL);
145 
146  myNb[ index( SMDSAbs_Node,1 )] = & myNbNodes;
147 
149 
150  myNb[ index( SMDSAbs_Edge,2 )] = & myNbEdges;
152 
157 
158  myNb[ index( SMDSAbs_Volume, 4)] = & myNbTetras;
160  myNb[ index( SMDSAbs_Volume, 6)] = & myNbPrisms;
161  myNb[ index( SMDSAbs_Volume, 8)] = & myNbHexas;
165  myNb[ index( SMDSAbs_Volume, 20)] = & myNbQuadHexas;
166 }
167 
168 inline void // Clear
170 { for ( unsigned int i=0; i<myNb.size(); ++i ) if ( myNb[i] ) (*myNb[i])=0;
172 }
173 
174 inline int // index
176 { return nbNodes + myShift[ type ]; }
177 
178 inline void // remove
180 { --(*myNb[ index(el->GetType(), el->NbNodes()) ]); }
181 
182 inline void // add
184 { ++(*myNb[ index(el->GetType(), el->NbNodes()) ]); }
185 
186 inline void // RemoveEdge
188 { if ( el->IsQuadratic() ) --myNbQuadEdges; else --myNbEdges; }
189 
190 inline void // RemoveFace
192 { if ( el->IsPoly() ) --myNbPolygons; else remove( el ); }
193 
194 inline void // RemoveVolume
196 { if ( el->IsPoly() ) --myNbPolyhedrons; else remove( el ); }
197 
198 inline int // NbEdges
200 { return order == ORDER_ANY ? myNbEdges+myNbQuadEdges : order == ORDER_LINEAR ? myNbEdges : myNbQuadEdges; }
201 
202 inline int // NbFaces
204 { return NbTriangles(order)+NbQuadrangles(order)+(order == ORDER_QUADRATIC ? 0 : myNbPolygons); }
205 
206 inline int // NbTriangles
209 
210 inline int // NbQuadrangles
213 
214 inline int // NbVolumes
216 { return NbTetras(order) + NbHexas(order) + NbPyramids(order) + NbPrisms(order) + (order == ORDER_QUADRATIC ? 0 : myNbPolyhedrons); }
217 
218 inline int // NbTetras
220 { return order == ORDER_ANY ? myNbTetras+myNbQuadTetras : order == ORDER_LINEAR ? myNbTetras : myNbQuadTetras; }
221 
222 inline int // NbHexas
224 { return order == ORDER_ANY ? myNbHexas+myNbQuadHexas : order == ORDER_LINEAR ? myNbHexas : myNbQuadHexas; }
225 
226 inline int // NbPyramids
229 
230 inline int // NbPrisms
232 { return order == ORDER_ANY ? myNbPrisms+myNbQuadPrisms : order == ORDER_LINEAR ? myNbPrisms : myNbQuadPrisms; }
233 
234 inline int // NbElements
236 {
237  int nb = 0;
238  switch (type) {
239  case SMDSAbs_All:
240  for (unsigned int i=1+index( SMDSAbs_Node,1 ); i<myNb.size(); ++i ) if ( myNb[i] ) nb += *myNb[i];
242  break;
243  case SMDSAbs_Volume:
246  break;
247  case SMDSAbs_Face:
249  break;
250  case SMDSAbs_Edge:
251  nb = myNbEdges + myNbQuadEdges;
252  break;
253  case SMDSAbs_0DElement:
254  nb = myNb0DElements;
255  break;
256  case SMDSAbs_Node:
257  nb = myNbNodes;
258  break;
259  default:;
260  }
261  return nb;
262 }
263 
264 int // NbEntities
266 {
267  switch (type) {
268  case SMDSEntity_Node:
269  return myNbNodes;
270  break;
271  case SMDSEntity_0D:
272  return myNb0DElements;
273  break;
274  case SMDSEntity_Edge:
275  return myNbEdges;
276  break;
278  return myNbQuadEdges;
279  break;
280  case SMDSEntity_Triangle:
281  return myNbTriangles;
282  break;
284  return myNbQuadTriangles;
285  break;
287  return myNbQuadrangles;
288  break;
290  return myNbQuadQuadrangles;
291  break;
292  case SMDSEntity_Polygon:
293  return myNbPolygons;
294  break;
295  case SMDSEntity_Tetra:
296  return myNbTetras;
297  break;
299  return myNbQuadTetras;
300  break;
301  case SMDSEntity_Pyramid:
302  return myNbPyramids;
303  break;
305  return myNbQuadPyramids;
306  break;
307  case SMDSEntity_Hexa:
308  return myNbHexas;
309  break;
311  return myNbQuadHexas;
312  break;
313  case SMDSEntity_Penta:
314  return myNbPrisms;
315  break;
317  return myNbQuadPrisms;
318  break;
320  return myNbPolyhedrons;
321  break;
324  default:
325  break;
326  }
327  return 0;
328 }
329 
330 #endif
SMDS_MeshElement::NbNodes
virtual int NbNodes() const
SMDS_MeshInfo::NbElements
int NbElements(SMDSAbs_ElementType type=SMDSAbs_All) const
Definition: SMDS_MeshInfo.hxx:235
SMDSEntity_Hexa
@ SMDSEntity_Hexa
Definition: SMDSAbs_ElementType.hxx:88
SMDSAbs_Face
@ SMDSAbs_Face
Definition: SMDSAbs_ElementType.hxx:37
SMDS_MeshInfo::myNb0DElements
int myNb0DElements
Definition: SMDS_MeshInfo.hxx:79
SMDSAbs_Node
@ SMDSAbs_Node
Definition: SMDSAbs_ElementType.hxx:35
SMDS_MeshInfo::myNbPolygons
int myNbPolygons
Definition: SMDS_MeshInfo.hxx:83
SMDSEntity_Quad_Hexa
@ SMDSEntity_Quad_Hexa
Definition: SMDSAbs_ElementType.hxx:89
SMDS_MeshInfo::myShift
std::vector< int > myShift
Definition: SMDS_MeshInfo.hxx:92
SMDSEntity_0D
@ SMDSEntity_0D
Definition: SMDSAbs_ElementType.hxx:75
SMDSEntity_Quad_Edge
@ SMDSEntity_Quad_Edge
Definition: SMDSAbs_ElementType.hxx:77
SMDS_MeshInfo::index
int index(SMDSAbs_ElementType type, int nbNodes) const
Definition: SMDS_MeshInfo.hxx:175
SMDS_MeshInfo::Nb0DElements
int Nb0DElements() const
Definition: SMDS_MeshInfo.hxx:51
SMDSAbs_All
@ SMDSAbs_All
Definition: SMDSAbs_ElementType.hxx:34
SMDS_EXPORT
#define SMDS_EXPORT
Definition: SMESH_SMDS.hxx:36
SMDS_MeshInfo::myNbPolyhedrons
int myNbPolyhedrons
Definition: SMDS_MeshInfo.hxx:89
SMDS_MeshInfo::myNbEdges
int myNbEdges
Definition: SMDS_MeshInfo.hxx:80
SMDSAbs_ElementOrder
SMDSAbs_ElementOrder
Definition: SMDSAbs_ElementType.hxx:63
SMDS_MeshInfo::myNbNodes
int myNbNodes
Definition: SMDS_MeshInfo.hxx:77
SMDS_MeshInfo::add
void add(const SMDS_MeshElement *el)
Definition: SMDS_MeshInfo.hxx:183
SMDS_MeshInfo::NbFaces
int NbFaces(SMDSAbs_ElementOrder order=ORDER_ANY) const
Definition: SMDS_MeshInfo.hxx:203
SMDS_MeshInfo::myNbQuadrangles
int myNbQuadrangles
Definition: SMDS_MeshInfo.hxx:82
SMDS_MeshElement::GetType
virtual SMDSAbs_ElementType GetType() const =0
Return the type of the current element.
SMDSAbs_0DElement
@ SMDSAbs_0DElement
Definition: SMDSAbs_ElementType.hxx:39
SMDSEntity_Quad_Penta
@ SMDSEntity_Quad_Penta
Definition: SMDSAbs_ElementType.hxx:91
SMDS_MeshInfo::myNbQuadQuadrangles
int myNbQuadQuadrangles
Definition: SMDS_MeshInfo.hxx:82
ORDER_ANY
@ ORDER_ANY
Definition: SMDSAbs_ElementType.hxx:64
SMESH_SMDS.hxx
SMDS_Mesh::RemoveVolume
virtual void RemoveVolume(const SMDS_MeshVolume *volume)
SMDSEntity_Node
@ SMDSEntity_Node
Definition: SMDSAbs_ElementType.hxx:74
SMDS_MeshInfo::NbPolygons
int NbPolygons() const
Definition: SMDS_MeshInfo.hxx:56
SMDS_MeshInfo::myNbTriangles
int myNbTriangles
Definition: SMDS_MeshInfo.hxx:81
SMDS_MeshInfo
Definition: SMDS_MeshInfo.hxx:41
SMDSEntity_Triangle
@ SMDSEntity_Triangle
Definition: SMDSAbs_ElementType.hxx:78
SMDS_MeshInfo::myNbPyramids
int myNbPyramids
Definition: SMDS_MeshInfo.hxx:87
SMDS_MeshInfo::NbEdges
int NbEdges(SMDSAbs_ElementOrder order=ORDER_ANY) const
Definition: SMDS_MeshInfo.hxx:199
SMDSEntity_Quad_Polyhedra
@ SMDSEntity_Quad_Polyhedra
Definition: SMDSAbs_ElementType.hxx:93
SMDS_MeshInfo::NbPrisms
int NbPrisms(SMDSAbs_ElementOrder order=ORDER_ANY) const
Definition: SMDS_MeshInfo.hxx:231
SMDS_MeshInfo::myNbTetras
int myNbTetras
Definition: SMDS_MeshInfo.hxx:85
SMDSEntity_Polyhedra
@ SMDSEntity_Polyhedra
Definition: SMDSAbs_ElementType.hxx:92
SMDSEntity_Pyramid
@ SMDSEntity_Pyramid
Definition: SMDSAbs_ElementType.hxx:86
SMDS_MeshInfo::myNbQuadEdges
int myNbQuadEdges
Definition: SMDS_MeshInfo.hxx:80
SMDS_Mesh
Definition: SMDS_Mesh.hxx:45
SMDS_MeshInfo::NbEntities
int NbEntities(SMDSAbs_EntityType type) const
Definition: SMDS_MeshInfo.hxx:265
SMDS_MeshInfo::NbTetras
int NbTetras(SMDSAbs_ElementOrder order=ORDER_ANY) const
Definition: SMDS_MeshInfo.hxx:219
SMDS_MeshInfo::RemoveFace
void RemoveFace(const SMDS_MeshElement *el)
Definition: SMDS_MeshInfo.hxx:191
SMDSEntity_Quad_Pyramid
@ SMDSEntity_Quad_Pyramid
Definition: SMDSAbs_ElementType.hxx:87
SMDS_MeshInfo::NbHexas
int NbHexas(SMDSAbs_ElementOrder order=ORDER_ANY) const
Definition: SMDS_MeshInfo.hxx:223
SMDS_Mesh::RemoveEdge
virtual void RemoveEdge(const SMDS_MeshEdge *edge)
ORDER_LINEAR
@ ORDER_LINEAR
Definition: SMDSAbs_ElementType.hxx:65
SMDSAbs_Volume
@ SMDSAbs_Volume
Definition: SMDSAbs_ElementType.hxx:38
SMDS_MeshInfo::myNbQuadTriangles
int myNbQuadTriangles
Definition: SMDS_MeshInfo.hxx:81
SMDS_MeshInfo::Clear
void Clear()
Definition: SMDS_MeshInfo.hxx:169
SMDS_MeshInfo::myNbQuadPyramids
int myNbQuadPyramids
Definition: SMDS_MeshInfo.hxx:87
SMDS_MeshInfo::remove
void remove(const SMDS_MeshElement *el)
Definition: SMDS_MeshInfo.hxx:179
SMDS_MeshInfo::NbQuadrangles
int NbQuadrangles(SMDSAbs_ElementOrder order=ORDER_ANY) const
Definition: SMDS_MeshInfo.hxx:211
SMDS_MeshInfo::NbVolumes
int NbVolumes(SMDSAbs_ElementOrder order=ORDER_ANY) const
Definition: SMDS_MeshInfo.hxx:215
SMDSEntity_Quad_Triangle
@ SMDSEntity_Quad_Triangle
Definition: SMDSAbs_ElementType.hxx:79
SMDS_Mesh::RemoveFace
virtual void RemoveFace(const SMDS_MeshFace *face)
ORDER_QUADRATIC
@ ORDER_QUADRATIC
Definition: SMDSAbs_ElementType.hxx:66
SMDSEntity_Quadrangle
@ SMDSEntity_Quadrangle
Definition: SMDSAbs_ElementType.hxx:80
SMDSEntity_Polygon
@ SMDSEntity_Polygon
Definition: SMDSAbs_ElementType.hxx:82
SMDS_MeshInfo::myNbQuadTetras
int myNbQuadTetras
Definition: SMDS_MeshInfo.hxx:85
SMDS_MeshElement::IsPoly
virtual bool IsPoly() const
Definition: SMDS_MeshElement.hxx:65
SMDS_MeshInfo::myNbQuadHexas
int myNbQuadHexas
Definition: SMDS_MeshInfo.hxx:86
SMDS_MeshElement.hxx
SMDS_MeshInfo::myNbPrisms
int myNbPrisms
Definition: SMDS_MeshInfo.hxx:88
SMDSEntity_Quad_Quadrangle
@ SMDSEntity_Quad_Quadrangle
Definition: SMDSAbs_ElementType.hxx:81
SMDSEntity_Edge
@ SMDSEntity_Edge
Definition: SMDSAbs_ElementType.hxx:76
SMDS_MeshInfo::NbNodes
int NbNodes() const
Definition: SMDS_MeshInfo.hxx:47
SMDSEntity_Quad_Polygon
@ SMDSEntity_Quad_Polygon
Definition: SMDSAbs_ElementType.hxx:83
SMDS_MeshInfo::NbPolyhedrons
int NbPolyhedrons() const
Definition: SMDS_MeshInfo.hxx:63
SMDSEntity_Quad_Tetra
@ SMDSEntity_Quad_Tetra
Definition: SMDSAbs_ElementType.hxx:85
SMDS_MeshInfo::NbTriangles
int NbTriangles(SMDSAbs_ElementOrder order=ORDER_ANY) const
Definition: SMDS_MeshInfo.hxx:207
SMDSAbs_EntityType
SMDSAbs_EntityType
Definition: SMDSAbs_ElementType.hxx:73
SMDSEntity_Tetra
@ SMDSEntity_Tetra
Definition: SMDSAbs_ElementType.hxx:84
SMDSAbs_ElementType
SMDSAbs_ElementType
Type (node, edge, face or volume) of elements.
Definition: SMDSAbs_ElementType.hxx:33
SMDS_MeshInfo::myNbQuadPrisms
int myNbQuadPrisms
Definition: SMDS_MeshInfo.hxx:88
SMDSEntity_Penta
@ SMDSEntity_Penta
Definition: SMDSAbs_ElementType.hxx:90
SMDS_MeshInfo::NbPyramids
int NbPyramids(SMDSAbs_ElementOrder order=ORDER_ANY) const
Definition: SMDS_MeshInfo.hxx:227
SMDS_MeshElement::IsQuadratic
virtual bool IsQuadratic() const
SMDS_MeshInfo::myNb
std::vector< int * > myNb
Definition: SMDS_MeshInfo.hxx:91
SMDSAbs_NbElementTypes
@ SMDSAbs_NbElementTypes
Definition: SMDSAbs_ElementType.hxx:40
SMDS_MeshElement
Base class for elements.
Definition: SMDS_MeshElement.hxx:50
SMDS_MeshInfo::SMDS_MeshInfo
SMDS_MeshInfo()
Definition: SMDS_MeshInfo.hxx:95
SMDS_MeshInfo::RemoveEdge
void RemoveEdge(const SMDS_MeshElement *el)
Definition: SMDS_MeshInfo.hxx:187
SMDS_MeshInfo::RemoveVolume
void RemoveVolume(const SMDS_MeshElement *el)
Definition: SMDS_MeshInfo.hxx:195
SMDSAbs_Edge
@ SMDSAbs_Edge
Definition: SMDSAbs_ElementType.hxx:36
SMDS_MeshInfo::myNbHexas
int myNbHexas
Definition: SMDS_MeshInfo.hxx:86