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