1 // File : SMDS_MeshInfo.hxx
2 // Created : Mon Sep 24 18:32:41 2007
3 // Author : Edward AGAPOV (eap)
6 #ifndef SMDS_MeshInfo_HeaderFile
7 #define SMDS_MeshInfo_HeaderFile
9 #include "SMESH_SMDS.hxx"
11 #include "SMDS_MeshElement.hxx"
13 class SMDS_EXPORT SMDS_MeshInfo
17 inline SMDS_MeshInfo();
19 int NbNodes() const { return myNbNodes; }
21 inline int NbEdges (SMDSAbs_ElementOrder order = ORDER_ANY) const;
22 inline int NbFaces (SMDSAbs_ElementOrder order = ORDER_ANY) const;
23 inline int NbTriangles (SMDSAbs_ElementOrder order = ORDER_ANY) const;
24 inline int NbQuadrangles(SMDSAbs_ElementOrder order = ORDER_ANY) const;
25 int NbPolygons() const { return myNbPolygons; }
27 inline int NbVolumes (SMDSAbs_ElementOrder order = ORDER_ANY) const;
28 inline int NbTetras (SMDSAbs_ElementOrder order = ORDER_ANY) const;
29 inline int NbHexas (SMDSAbs_ElementOrder order = ORDER_ANY) const;
30 inline int NbPyramids(SMDSAbs_ElementOrder order = ORDER_ANY) const;
31 inline int NbPrisms (SMDSAbs_ElementOrder order = ORDER_ANY) const;
32 int NbPolyhedrons() const { return myNbPolyhedrons; }
35 friend class SMDS_Mesh;
37 // methods to count NOT POLY elements
38 inline void remove(const SMDS_MeshElement* el);
39 inline void add (const SMDS_MeshElement* el);
40 inline int index(SMDSAbs_ElementType type, int nbNodes);
41 // methods to remove elements of ANY kind
42 inline void RemoveEdge(const SMDS_MeshElement* el);
43 inline void RemoveFace(const SMDS_MeshElement* el);
44 inline void RemoveVolume(const SMDS_MeshElement* el);
48 int myNbEdges , myNbQuadEdges ;
49 int myNbTriangles , myNbQuadTriangles ;
50 int myNbQuadrangles, myNbQuadQuadrangles;
53 int myNbTetras , myNbQuadTetras ;
54 int myNbHexas , myNbQuadHexas ;
55 int myNbPyramids, myNbQuadPyramids;
56 int myNbPrisms , myNbQuadPrisms ;
59 std::vector<int*> myNb; // pointers to myNb... fields
60 std::vector<int> myShift; // shift to get an index in myNb by elem->NbNodes()
63 inline SMDS_MeshInfo::SMDS_MeshInfo():
65 myNbEdges (0), myNbQuadEdges (0),
66 myNbTriangles (0), myNbQuadTriangles (0),
67 myNbQuadrangles(0), myNbQuadQuadrangles(0),
69 myNbTetras (0), myNbQuadTetras (0),
70 myNbHexas (0), myNbQuadHexas (0),
71 myNbPyramids(0), myNbQuadPyramids(0),
72 myNbPrisms (0), myNbQuadPrisms (0),
75 // Number of nodes in standard element types
102 // So to have a unique index for each type basing on nb of nodes, we use a shift:
103 myShift.resize(SMDSAbs_Volume + 1, 0);
104 myShift[ SMDSAbs_Face ] = +8; // 3->11, 4->12, 6->14, 8->16
105 myShift[ SMDSAbs_Edge ] = -2; // 2->0, 4->2
107 myNb.resize( index( SMDSAbs_Volume,20 ) + 1, NULL);
108 myNb[ index( SMDSAbs_Node,1 )] = & myNbNodes;
110 myNb[ index( SMDSAbs_Edge,2 )] = & myNbEdges;
111 myNb[ index( SMDSAbs_Edge,4 )] = & myNbQuadEdges;
113 myNb[ index( SMDSAbs_Face,3 )] = & myNbTriangles;
114 myNb[ index( SMDSAbs_Face,4 )] = & myNbQuadrangles;
115 myNb[ index( SMDSAbs_Face,6 )] = & myNbQuadTriangles;
116 myNb[ index( SMDSAbs_Face,8 )] = & myNbQuadQuadrangles;
118 myNb[ index( SMDSAbs_Volume, 4)] = & myNbTetras;
119 myNb[ index( SMDSAbs_Volume, 5)] = & myNbPyramids;
120 myNb[ index( SMDSAbs_Volume, 6)] = & myNbPrisms;
121 myNb[ index( SMDSAbs_Volume, 8)] = & myNbHexas;
122 myNb[ index( SMDSAbs_Volume, 10)] = & myNbQuadTetras;
123 myNb[ index( SMDSAbs_Volume, 13)] = & myNbQuadPyramids;
124 myNb[ index( SMDSAbs_Volume, 15)] = & myNbQuadPrisms;
125 myNb[ index( SMDSAbs_Volume, 20)] = & myNbQuadHexas;
129 SMDS_MeshInfo::index(SMDSAbs_ElementType type, int nbNodes)
130 { return nbNodes + myShift[ type ]; }
132 inline void // remove
133 SMDS_MeshInfo::remove(const SMDS_MeshElement* el)
134 { --(*myNb[ index(el->GetType(), el->NbNodes()) ]); }
137 SMDS_MeshInfo::add(const SMDS_MeshElement* el)
138 { ++(*myNb[ index(el->GetType(), el->NbNodes()) ]); }
140 inline void // RemoveEdge
141 SMDS_MeshInfo::RemoveEdge(const SMDS_MeshElement* el)
142 { if ( el->IsQuadratic() ) --myNbQuadEdges; else --myNbEdges; }
144 inline void // RemoveFace
145 SMDS_MeshInfo::RemoveFace(const SMDS_MeshElement* el)
146 { if ( el->IsPoly() ) --myNbPolygons; else remove( el ); }
148 inline void // RemoveVolume
149 SMDS_MeshInfo::RemoveVolume(const SMDS_MeshElement* el)
150 { if ( el->IsPoly() ) --myNbPolyhedrons; else remove( el ); }
152 inline int // NbEdges
153 SMDS_MeshInfo::NbEdges (SMDSAbs_ElementOrder order) const
154 { return order == ORDER_ANY ? myNbEdges+myNbQuadEdges : order == ORDER_LINEAR ? myNbEdges : myNbQuadEdges; }
156 inline int // NbFaces
157 SMDS_MeshInfo::NbFaces (SMDSAbs_ElementOrder order) const
158 { return NbTriangles(order)+NbQuadrangles(order)+(order == ORDER_QUADRATIC ? 0 : myNbPolygons); }
160 inline int // NbTriangles
161 SMDS_MeshInfo::NbTriangles (SMDSAbs_ElementOrder order) const
162 { return order == ORDER_ANY ? myNbTriangles+myNbQuadTriangles : order == ORDER_LINEAR ? myNbTriangles : myNbQuadTriangles; }
164 inline int // NbQuadrangles
165 SMDS_MeshInfo::NbQuadrangles(SMDSAbs_ElementOrder order) const
166 { return order == ORDER_ANY ? myNbQuadrangles+myNbQuadQuadrangles : order == ORDER_LINEAR ? myNbQuadrangles : myNbQuadQuadrangles; }
168 inline int // NbVolumes
169 SMDS_MeshInfo::NbVolumes (SMDSAbs_ElementOrder order) const
170 { return NbTetras(order) + NbHexas(order) + NbPyramids(order) + NbPrisms(order) + (order == ORDER_QUADRATIC ? 0 : myNbPolyhedrons); }
172 inline int // NbTetras
173 SMDS_MeshInfo::NbTetras (SMDSAbs_ElementOrder order) const
174 { return order == ORDER_ANY ? myNbTetras+myNbQuadTetras : order == ORDER_LINEAR ? myNbTetras : myNbQuadTetras; }
176 inline int // NbHexas
177 SMDS_MeshInfo::NbHexas (SMDSAbs_ElementOrder order) const
178 { return order == ORDER_ANY ? myNbHexas+myNbQuadHexas : order == ORDER_LINEAR ? myNbHexas : myNbQuadHexas; }
180 inline int // NbPyramids
181 SMDS_MeshInfo::NbPyramids(SMDSAbs_ElementOrder order) const
182 { return order == ORDER_ANY ? myNbPyramids+myNbQuadPyramids : order == ORDER_LINEAR ? myNbPyramids : myNbQuadPyramids; }
184 inline int // NbPrisms
185 SMDS_MeshInfo::NbPrisms (SMDSAbs_ElementOrder order) const
186 { return order == ORDER_ANY ? myNbPrisms+myNbQuadPrisms : order == ORDER_LINEAR ? myNbPrisms : myNbQuadPrisms; }