]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/MEDMEM_CellModel.hxx
Salome HOME
NRI : Merge from V1_2.
[modules/med.git] / src / MEDMEM / MEDMEM_CellModel.hxx
1 //  MED MEDMEM : MED files in memory
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : MEDMEM_CellModel.hxx
25 //  Module : MED
26
27 /*
28  File MEDMEM_CellModel.hxx
29  $Header$
30 */
31
32 #ifndef CELLMODEL_HXX
33 #define CELLMODEL_HXX
34
35 #include <set>
36 #include <map>
37 #include <string>
38
39 #include "utilities.h"
40 #include "MEDMEM_define.hxx"
41
42 using namespace std ;
43 using namespace MED_EN;
44
45 /*!
46   This class is an internal class and should not be used by the end-user.
47   This class describes all possible cell models and is used in order
48   to acces informations about geometric type of the cell : 
49   Each object (if instancied), contains generic informations about
50   the cell model it describes as cell dimensions, number of nodes...
51 */
52
53 class CELLMODEL 
54 {
55
56 private:
57                         /*! private method : /n
58                             used by constructor and operator= */
59   void init(const CELLMODEL &m);
60
61                         /*! private method : /n */
62   void clean();
63
64
65   //protected:
66                         /*! explicit name (as MED_POINT1)           */
67   string             _name;
68                         /*! type of cell (cf define.h)              */
69   medGeometryElement _type;
70                         /*! Cell dimension (not space dimension)    */
71   int                _dimension;
72                         /*! number of nodes forming this type of a cell    */
73   int                _numberOfNodes;
74                         /*! number of vertexes forming this type of a cell */
75   int                _numberOfVertexes;
76                         /*!  2 for a  3D Cell and 1 for a 2DCell */
77   int                _numberOfConstituentsDimension;
78                         /*! Array of size numberOfConstituentsDimension */
79   int*               _numberOfConstituents ;
80                         /*! Array of size _numberOfConstituentsDimension
81                             x_numberOfConstituents[i]               */
82   int**              _numberOfNodeOfEachConstituent ;
83                         /*! defines nodal local connectivity for each 
84                             constituents of each dimension: 
85                             should be seen as a vector<vector<vector>> \n
86                             - first vector : for each cell dimension 
87                               (first : dim-1, second if any : dim-2)\n
88                             - second vector : for each constituent of 
89                               this dimension\n
90                             - third vector : list of local nodes    */
91   int***                _constituents ;
92   medGeometryElement**  _constituentsType ;
93
94 public :
95
96                         /*! Constructor. */
97   inline CELLMODEL();
98                         /*! Constructor. */
99   CELLMODEL(medGeometryElement t);
100                         /*! Copy constructor. */
101   inline CELLMODEL(const CELLMODEL &m);
102                         /*! Destructor. */
103   inline ~CELLMODEL();
104
105                         /*! Operator = : duplicate CELLMODEL. */
106   inline CELLMODEL & operator=(const CELLMODEL &m);
107
108                         /*! Operator << : print CELLMODEL to the given stream. */
109   friend ostream & operator<<(ostream &os,const CELLMODEL &my);
110
111                         /*! returns _name attribute (ie: MED_PENTA15).\n
112                             see med.h (in med/include) */
113   inline string                 getName()             const;
114
115                         /*! returns number of vertexes forming this type of cell */
116   inline int                    getNumberOfVertexes() const;
117
118                         /*! returns number of nodes forming this type of cell    */
119   inline int                    getNumberOfNodes()    const;
120
121                         /*! returns the dimension of this type of cell./n
122                             it can be different from mesh dimension              */
123   inline int                    getDimension()        const;
124
125                         /*! returns the geometric type of the cell. \n
126                             see med.h (in med/include) */
127   inline medGeometryElement     getType()             const;
128
129                         /*! returns all constituents which dimension is _dimension-dim.*/
130   int** getConstituents(int dim) const;
131
132                         /*! returns number of constituents which dimension is _dimension-dim.*/
133   int   getNumberOfConstituents(int dim) const;
134
135                         /*! returns local nodes numbers vector for num-th constituent 
136                             which dimension is _dimension-dim.*/
137   int* getNodesConstituent(int dim,int num) const;
138
139                         /*! returns local node number of nodes_index-th node for 
140                             num-th constituent which dimension is _dimension-dim.*/
141   int getNodeConstituent(int dim,int num,int nodes_index) const;
142
143                         /*! returns types of each constituents which dimension 
144                             is _dimension-dim.*/
145   medGeometryElement*  getConstituentsType(int dim) const;
146
147                         /*! returns type of num-th constituent which dimension 
148                             is _dimension-dim.*/
149   medGeometryElement getConstituentType(int dim,int num) const;
150
151                         /*! returns number of constituents type 
152                             (which dimension is _dimension-1).*/
153   int getNumberOfConstituentsType() const;
154
155                         /*! returns all types of constituents which dimension 
156                             is (_dimension-1).*/
157   set<medGeometryElement>  getAllConstituentsType() const;
158
159                         /*! returns number of constituents foreach type (which dimension 
160                             is _dimension-1).*/
161   map<medGeometryElement,int>  getNumberOfConstituentsForeachType() const;
162
163
164 };
165
166 // ------------------------------------------
167 //      Methodes Inline
168 // ------------------------------------------
169
170 inline CELLMODEL::CELLMODEL():
171     _type(MED_NONE),
172     _dimension(0),
173     _numberOfNodes(0),
174     _numberOfVertexes(0),
175     _numberOfConstituentsDimension(0),
176     _numberOfConstituents((int*)NULL),
177     _numberOfNodeOfEachConstituent((int**)NULL),
178     _constituents((int***)NULL),
179     _constituentsType((medGeometryElement**)NULL)
180 {
181 }
182 inline CELLMODEL::CELLMODEL(const CELLMODEL &m)
183 {
184     init(m) ;
185 }
186 inline CELLMODEL::~CELLMODEL() 
187 {
188   MESSAGE("CELLMODEL::~CELLMODEL() destroying the cell");
189   clean() ;
190 };
191 inline CELLMODEL & CELLMODEL::operator=(const CELLMODEL &m) 
192 {
193     clean() ;
194     init(m) ;
195     return *this ;
196 }
197 inline string CELLMODEL::getName() const
198 {
199   return _name ;
200 }
201 inline int CELLMODEL::getNumberOfVertexes() const
202 {
203   return _numberOfVertexes;
204 }
205 inline int CELLMODEL::getNumberOfNodes() const
206 {
207   return _numberOfNodes;
208 }
209 inline int CELLMODEL::getDimension() const
210 {
211   return _dimension;
212 }
213 inline medGeometryElement CELLMODEL::getType() const
214 {
215   return _type;
216 }
217 inline int** CELLMODEL::getConstituents(int dim) const
218 {
219   return _constituents[dim-1] ;
220 }
221 inline int CELLMODEL::getNumberOfConstituents(int dim) const
222 {
223   return _numberOfConstituents[dim-1] ;
224 }
225 inline int* CELLMODEL::getNodesConstituent(int dim,int num) const
226 {
227   return _constituents[dim-1][num-1];
228 }
229 inline int CELLMODEL::getNodeConstituent(int dim,int num,int nodesNumber) const
230 {
231   return _constituents[dim-1][num-1][nodesNumber-1] ;
232 }
233 inline medGeometryElement* CELLMODEL::getConstituentsType(int dim) const
234 {
235   return _constituentsType[dim-1];
236 }
237 inline medGeometryElement CELLMODEL::getConstituentType(int dim,int num) const
238 {
239   return _constituentsType[dim-1][num-1];
240 }
241
242 #endif /* CELLMODEL_HXX */