SALOME - SMESH
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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 using namespace std;
30 
31 #include "SMESH_SMDS.hxx"
32 
33 #include "SMDS_MeshElement.hxx"
34 
36 {
37 public:
38 
39  inline SMDS_MeshInfo();
40  inline void Clear();
41 
42  int NbNodes() const { return myNbNodes; }
43 
44  inline int NbEdges (SMDSAbs_ElementOrder order = ORDER_ANY) const;
45  inline int NbFaces (SMDSAbs_ElementOrder order = ORDER_ANY) const;
46  inline int NbTriangles (SMDSAbs_ElementOrder order = ORDER_ANY) const;
47  inline int NbQuadrangles(SMDSAbs_ElementOrder order = ORDER_ANY) const;
48  int NbPolygons() const { return myNbPolygons; }
49 
50  inline int NbVolumes (SMDSAbs_ElementOrder order = ORDER_ANY) const;
51  inline int NbTetras (SMDSAbs_ElementOrder order = ORDER_ANY) const;
52  inline int NbHexas (SMDSAbs_ElementOrder order = ORDER_ANY) const;
53  inline int NbPyramids(SMDSAbs_ElementOrder order = ORDER_ANY) const;
54  inline int NbPrisms (SMDSAbs_ElementOrder order = ORDER_ANY) const;
55  int NbPolyhedrons() const { return myNbPolyhedrons; }
56 
57 private:
58  friend class SMDS_Mesh;
59 
60  // methods to count NOT POLY elements
61  inline void remove(const SMDS_MeshElement* el);
62  inline void add (const SMDS_MeshElement* el);
63  inline int index(SMDSAbs_ElementType type, int nbNodes);
64  // methods to remove elements of ANY kind
65  inline void RemoveEdge(const SMDS_MeshElement* el);
66  inline void RemoveFace(const SMDS_MeshElement* el);
67  inline void RemoveVolume(const SMDS_MeshElement* el);
68 
69  int myNbNodes;
70 
71  int myNbEdges , myNbQuadEdges ;
72  int myNbTriangles , myNbQuadTriangles ;
73  int myNbQuadrangles, myNbQuadQuadrangles;
75 
76  int myNbTetras , myNbQuadTetras ;
77  int myNbHexas , myNbQuadHexas ;
78  int myNbPyramids, myNbQuadPyramids;
79  int myNbPrisms , myNbQuadPrisms ;
81 
82  std::vector<int*> myNb; // pointers to myNb... fields
83  std::vector<int> myShift; // shift to get an index in myNb by elem->NbNodes()
84 };
85 
87  myNbNodes(0),
88  myNbEdges (0), myNbQuadEdges (0),
89  myNbTriangles (0), myNbQuadTriangles (0),
90  myNbQuadrangles(0), myNbQuadQuadrangles(0),
91  myNbPolygons(0),
92  myNbTetras (0), myNbQuadTetras (0),
93  myNbHexas (0), myNbQuadHexas (0),
94  myNbPyramids(0), myNbQuadPyramids(0),
95  myNbPrisms (0), myNbQuadPrisms (0),
96  myNbPolyhedrons(0)
97 {
98  // Number of nodes in standard element types
99  // n v f e
100  // o o a d
101  // d l c g
102  // e e e
103  // -----------
104  // 1
105  // 2 *
106  // 3 *
107  // 4 * * *
108  // 5 *
109  // 6 * *
110  // 7
111  // 8 * *
112  // 9
113  // 10 *
114  // 11
115  // 12
116  // 13 *
117  // 14
118  // 15 *
119  // 16
120  // 17
121  // 18
122  // 19
123  // 20 *
124  //
125  // So to have a unique index for each type basing on nb of nodes, we use a shift:
126  myShift.resize(SMDSAbs_Volume + 1, 0);
127  myShift[ SMDSAbs_Face ] = +8; // 3->11, 4->12, 6->14, 8->16
128  myShift[ SMDSAbs_Edge ] = -2; // 2->0, 4->2
129 
130  myNb.resize( index( SMDSAbs_Volume,20 ) + 1, NULL);
131  myNb[ index( SMDSAbs_Node,1 )] = & myNbNodes;
132 
133  myNb[ index( SMDSAbs_Edge,2 )] = & myNbEdges;
135 
140 
141  myNb[ index( SMDSAbs_Volume, 4)] = & myNbTetras;
143  myNb[ index( SMDSAbs_Volume, 6)] = & myNbPrisms;
144  myNb[ index( SMDSAbs_Volume, 8)] = & myNbHexas;
148  myNb[ index( SMDSAbs_Volume, 20)] = & myNbQuadHexas;
149 }
150 inline void // Clear
152 { for ( int i=0; i<myNb.size(); ++i ) if ( myNb[i] ) (*myNb[i])=0;
154 }
155 inline int // index
157 { return nbNodes + myShift[ type ]; }
158 
159 inline void // remove
161 { --(*myNb[ index(el->GetType(), el->NbNodes()) ]); }
162 
163 inline void // add
165 { ++(*myNb[ index(el->GetType(), el->NbNodes()) ]); }
166 
167 inline void // RemoveEdge
169 { if ( el->IsQuadratic() ) --myNbQuadEdges; else --myNbEdges; }
170 
171 inline void // RemoveFace
173 { if ( el->IsPoly() ) --myNbPolygons; else remove( el ); }
174 
175 inline void // RemoveVolume
177 { if ( el->IsPoly() ) --myNbPolyhedrons; else remove( el ); }
178 
179 inline int // NbEdges
181 { return order == ORDER_ANY ? myNbEdges+myNbQuadEdges : order == ORDER_LINEAR ? myNbEdges : myNbQuadEdges; }
182 
183 inline int // NbFaces
185 { return NbTriangles(order)+NbQuadrangles(order)+(order == ORDER_QUADRATIC ? 0 : myNbPolygons); }
186 
187 inline int // NbTriangles
190 
191 inline int // NbQuadrangles
194 
195 inline int // NbVolumes
197 { return NbTetras(order) + NbHexas(order) + NbPyramids(order) + NbPrisms(order) + (order == ORDER_QUADRATIC ? 0 : myNbPolyhedrons); }
198 
199 inline int // NbTetras
201 { return order == ORDER_ANY ? myNbTetras+myNbQuadTetras : order == ORDER_LINEAR ? myNbTetras : myNbQuadTetras; }
202 
203 inline int // NbHexas
205 { return order == ORDER_ANY ? myNbHexas+myNbQuadHexas : order == ORDER_LINEAR ? myNbHexas : myNbQuadHexas; }
206 
207 inline int // NbPyramids
210 
211 inline int // NbPrisms
213 { return order == ORDER_ANY ? myNbPrisms+myNbQuadPrisms : order == ORDER_LINEAR ? myNbPrisms : myNbQuadPrisms; }
214 
215 #endif
void RemoveVolume(const SMDS_MeshElement *el)
virtual int NbNodes() const
int index(SMDSAbs_ElementType type, int nbNodes)
void RemoveEdge(const SMDS_MeshElement *el)
int NbFaces(SMDSAbs_ElementOrder order=ORDER_ANY) const
int NbVolumes(SMDSAbs_ElementOrder order=ORDER_ANY) const
int NbPyramids(SMDSAbs_ElementOrder order=ORDER_ANY) const
#define SMDS_EXPORT
Definition: SMESH_SMDS.hxx:36
int NbPolygons() const
int NbPrisms(SMDSAbs_ElementOrder order=ORDER_ANY) const
void remove(const SMDS_MeshElement *el)
virtual SMDSAbs_ElementType GetType() const =0
Return the type of the current element.
SMDSAbs_ElementType
Type (node, edge, face or volume) of elements.
SMDSAbs_ElementOrder
std::vector< int > myShift
int NbEdges(SMDSAbs_ElementOrder order=ORDER_ANY) const
int NbHexas(SMDSAbs_ElementOrder order=ORDER_ANY) const
virtual void RemoveVolume(const SMDS_MeshVolume *volume)
virtual bool IsPoly() const
Base class for elements.
virtual bool IsQuadratic() const
void add(const SMDS_MeshElement *el)
virtual void RemoveEdge(const SMDS_MeshEdge *edge)
std::vector< int * > myNb
int NbPolyhedrons() const
virtual void RemoveFace(const SMDS_MeshFace *face)
void RemoveFace(const SMDS_MeshElement *el)
int NbQuadrangles(SMDSAbs_ElementOrder order=ORDER_ANY) const
int NbTetras(SMDSAbs_ElementOrder order=ORDER_ANY) const
int NbTriangles(SMDSAbs_ElementOrder order=ORDER_ANY) const
int NbNodes() const