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