Salome HOME
NPAL18076: EDF617: Regression smesh.py Only the 1st netgen parameters is added/used.
[modules/smesh.git] / src / SMDS / SMDS_MeshInfo.hxx
1 // File      : SMDS_MeshInfo.hxx
2 // Created   : Mon Sep 24 18:32:41 2007
3 // Author    : Edward AGAPOV (eap)
4
5
6 #ifndef SMDS_MeshInfo_HeaderFile
7 #define SMDS_MeshInfo_HeaderFile
8
9 #include "SMDS_MeshElement.hxx"
10
11 class SMDS_MeshInfo
12 {
13 public:
14
15   inline SMDS_MeshInfo();
16
17   int NbNodes() const { return myNbNodes; }
18
19   inline int NbEdges      (SMDSAbs_ElementOrder order = ORDER_ANY) const;
20   inline int NbFaces      (SMDSAbs_ElementOrder order = ORDER_ANY) const;
21   inline int NbTriangles  (SMDSAbs_ElementOrder order = ORDER_ANY) const;
22   inline int NbQuadrangles(SMDSAbs_ElementOrder order = ORDER_ANY) const;
23   int NbPolygons() const { return myNbPolygons; }
24
25   inline int NbVolumes (SMDSAbs_ElementOrder order = ORDER_ANY) const;
26   inline int NbTetras  (SMDSAbs_ElementOrder order = ORDER_ANY) const;
27   inline int NbHexas   (SMDSAbs_ElementOrder order = ORDER_ANY) const;
28   inline int NbPyramids(SMDSAbs_ElementOrder order = ORDER_ANY) const;
29   inline int NbPrisms  (SMDSAbs_ElementOrder order = ORDER_ANY) const;
30   int NbPolyhedrons() const { return myNbPolyhedrons; }
31
32 private:
33   friend class SMDS_Mesh;
34
35   // methods to count NOT POLY elements
36   inline void remove(const SMDS_MeshElement* el);
37   inline void add   (const SMDS_MeshElement* el);
38   inline int  index(SMDSAbs_ElementType type, int nbNodes);
39   // methods to remove elements of ANY kind
40   inline void RemoveEdge(const SMDS_MeshElement* el);
41   inline void RemoveFace(const SMDS_MeshElement* el);
42   inline void RemoveVolume(const SMDS_MeshElement* el);
43
44   int myNbNodes;
45
46   int myNbEdges      , myNbQuadEdges      ;
47   int myNbTriangles  , myNbQuadTriangles  ;
48   int myNbQuadrangles, myNbQuadQuadrangles;
49   int myNbPolygons;
50
51   int myNbTetras  , myNbQuadTetras  ;
52   int myNbHexas   , myNbQuadHexas   ;
53   int myNbPyramids, myNbQuadPyramids;
54   int myNbPrisms  , myNbQuadPrisms  ;
55   int myNbPolyhedrons;
56
57   vector<int*> myNb; // pointers to myNb... fields
58   vector<int>  myShift; // shift to get an index in myNb by elem->NbNodes()
59 };
60
61 inline SMDS_MeshInfo::SMDS_MeshInfo():
62   myNbNodes(0),
63   myNbEdges      (0), myNbQuadEdges      (0),
64   myNbTriangles  (0), myNbQuadTriangles  (0),
65   myNbQuadrangles(0), myNbQuadQuadrangles(0),
66   myNbPolygons(0),
67   myNbTetras  (0), myNbQuadTetras  (0),
68   myNbHexas   (0), myNbQuadHexas   (0),
69   myNbPyramids(0), myNbQuadPyramids(0),
70   myNbPrisms  (0), myNbQuadPrisms  (0),
71   myNbPolyhedrons(0)
72 {
73   // Number of nodes in standard element types
74   // n   v  f  e
75   // o   o  a  d
76   // d   l  c  g
77   // e      e  e
78   // -----------
79   // 1      
80   // 2         *
81   // 3      *
82   // 4   *  *  *
83   // 5   *  
84   // 6   *  *
85   // 7      
86   // 8   *  *
87   // 9      
88   // 10  *  
89   // 11     
90   // 12     
91   // 13  *  
92   // 14     
93   // 15  *  
94   // 16     
95   // 17     
96   // 18     
97   // 19     
98   // 20  *
99   //
100   // So to have a unique index for each type basing on nb of nodes, we use a shift:
101   myShift.resize(SMDSAbs_Volume + 1, 0);
102   myShift[ SMDSAbs_Face ] = +8; // 3->11, 4->12, 6->14, 8->16
103   myShift[ SMDSAbs_Edge ] = -2; // 2->0, 4->2
104
105   myNb.resize( index( SMDSAbs_Volume,20 ) + 1, NULL);
106   myNb[ index( SMDSAbs_Node,1 )] = & myNbNodes;
107
108   myNb[ index( SMDSAbs_Edge,2 )] = & myNbEdges;
109   myNb[ index( SMDSAbs_Edge,4 )] = & myNbQuadEdges;
110
111   myNb[ index( SMDSAbs_Face,3 )] = & myNbTriangles;
112   myNb[ index( SMDSAbs_Face,4 )] = & myNbQuadrangles;
113   myNb[ index( SMDSAbs_Face,6 )] = & myNbQuadTriangles;
114   myNb[ index( SMDSAbs_Face,8 )] = & myNbQuadQuadrangles;
115
116   myNb[ index( SMDSAbs_Volume, 4)]  = & myNbTetras;
117   myNb[ index( SMDSAbs_Volume, 5)]  = & myNbPyramids;
118   myNb[ index( SMDSAbs_Volume, 6)]  = & myNbPrisms;
119   myNb[ index( SMDSAbs_Volume, 8)]  = & myNbHexas;
120   myNb[ index( SMDSAbs_Volume, 10)] = & myNbQuadTetras;  
121   myNb[ index( SMDSAbs_Volume, 13)] = & myNbQuadPyramids;
122   myNb[ index( SMDSAbs_Volume, 15)] = & myNbQuadPrisms;  
123   myNb[ index( SMDSAbs_Volume, 20)] = & myNbQuadHexas;   
124 }
125
126 inline int // index
127 SMDS_MeshInfo::index(SMDSAbs_ElementType type, int nbNodes)
128 { return nbNodes + myShift[ type ]; }
129
130 inline void // remove
131 SMDS_MeshInfo::remove(const SMDS_MeshElement* el)
132 { --(*myNb[ index(el->GetType(), el->NbNodes()) ]); }
133
134 inline void // add
135 SMDS_MeshInfo::add(const SMDS_MeshElement* el)
136 { ++(*myNb[ index(el->GetType(), el->NbNodes()) ]); }
137
138 inline void // RemoveEdge
139 SMDS_MeshInfo::RemoveEdge(const SMDS_MeshElement* el)
140 { if ( el->IsQuadratic() ) --myNbQuadEdges; else --myNbEdges; }
141
142 inline void // RemoveFace
143 SMDS_MeshInfo::RemoveFace(const SMDS_MeshElement* el)
144 { if ( el->IsPoly() ) --myNbPolygons; else remove( el ); }
145
146 inline void // RemoveVolume
147 SMDS_MeshInfo::RemoveVolume(const SMDS_MeshElement* el)
148 { if ( el->IsPoly() ) --myNbPolyhedrons; else remove( el ); }
149
150 inline int // NbEdges
151 SMDS_MeshInfo::NbEdges      (SMDSAbs_ElementOrder order) const
152 { return order == ORDER_ANY ? myNbEdges+myNbQuadEdges : order == ORDER_LINEAR ? myNbEdges : myNbQuadEdges; }
153
154 inline int // NbFaces
155 SMDS_MeshInfo::NbFaces      (SMDSAbs_ElementOrder order) const
156 { return NbTriangles(order)+NbQuadrangles(order)+(order == ORDER_QUADRATIC ? 0 : myNbPolygons); }
157
158 inline int // NbTriangles
159 SMDS_MeshInfo::NbTriangles  (SMDSAbs_ElementOrder order) const
160 { return order == ORDER_ANY ? myNbTriangles+myNbQuadTriangles : order == ORDER_LINEAR ? myNbTriangles : myNbQuadTriangles; }
161
162 inline int // NbQuadrangles
163 SMDS_MeshInfo::NbQuadrangles(SMDSAbs_ElementOrder order) const
164 { return order == ORDER_ANY ? myNbQuadrangles+myNbQuadQuadrangles : order == ORDER_LINEAR ? myNbQuadrangles : myNbQuadQuadrangles; }
165
166 inline int // NbVolumes
167 SMDS_MeshInfo::NbVolumes (SMDSAbs_ElementOrder order) const
168 { return NbTetras(order) + NbHexas(order) + NbPyramids(order) + NbPrisms(order) + (order == ORDER_QUADRATIC ? 0 : myNbPolyhedrons); }
169
170 inline int // NbTetras
171 SMDS_MeshInfo::NbTetras  (SMDSAbs_ElementOrder order) const
172 { return order == ORDER_ANY ? myNbTetras+myNbQuadTetras : order == ORDER_LINEAR ? myNbTetras : myNbQuadTetras; }
173
174 inline int // NbHexas
175 SMDS_MeshInfo::NbHexas   (SMDSAbs_ElementOrder order) const
176 { return order == ORDER_ANY ? myNbHexas+myNbQuadHexas : order == ORDER_LINEAR ? myNbHexas : myNbQuadHexas; }
177
178 inline int // NbPyramids
179 SMDS_MeshInfo::NbPyramids(SMDSAbs_ElementOrder order) const
180 { return order == ORDER_ANY ? myNbPyramids+myNbQuadPyramids : order == ORDER_LINEAR ? myNbPyramids : myNbQuadPyramids; }
181
182 inline int // NbPrisms
183 SMDS_MeshInfo::NbPrisms  (SMDSAbs_ElementOrder order) const
184 { return order == ORDER_ANY ? myNbPrisms+myNbQuadPrisms : order == ORDER_LINEAR ? myNbPrisms : myNbQuadPrisms; }
185
186 #endif