1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 File MEDMEM_CellModel.hxx
36 #include "MEDMEM_Utilities.hxx"
37 #include "MEDMEM_define.hxx"
42 This class is an internal class and should not be used by the end-user.
43 This class describes all possible cell models and is used in order
44 to acces informations about geometric type of the cell :
45 Each object (if instancied), contains generic informations about
46 the cell model it describes as cell dimensions, number of nodes...
52 MEDMEM_EXPORT ostream & operator<<(ostream &os,const CELLMODEL &my);
54 class MEDMEM_EXPORT CELLMODEL
58 /*! private method : \n
59 used by constructor and operator= */
60 void init(const CELLMODEL &m);
62 /*! private method : \n */
67 /*! explicit name (as MED_POINT1) */
69 /*! type of cell (cf define.h) */
70 MED_EN::medGeometryElement _type;
71 /*! Cell dimension (not space dimension) */
73 /*! number of nodes forming this type of a cell */
75 /*! number of vertexes forming this type of a cell */
76 int _numberOfVertexes;
77 /*! 2 for a 3D Cell and 1 for a 2DCell */
78 int _numberOfConstituentsDimension;
79 /*! Array of size numberOfConstituentsDimension */
80 int* _numberOfConstituents ;
81 /*! Array of size _numberOfConstituentsDimension
82 x_numberOfConstituents[i] */
83 int** _numberOfNodeOfEachConstituent ;
84 /*! defines nodal local connectivity for each
85 constituents of each dimension:
86 should be seen as a vector<vector<vector>> \n
87 - first vector : for each cell dimension
88 (first : dim-1, second if any : dim-2)\n
89 - second vector : for each constituent of
91 - third vector : list of local nodes */
92 int*** _constituents ;
93 MED_EN::medGeometryElement** _constituentsType ;
100 CELLMODEL(MED_EN::medGeometryElement t);
101 /*! Copy constructor. */
102 inline CELLMODEL(const CELLMODEL &m);
106 /*! Operator = : duplicate CELLMODEL. */
107 inline CELLMODEL & operator=(const CELLMODEL &m);
109 /*! Operator << : print CELLMODEL to the given stream. */
110 friend MEDMEM_EXPORT ostream & operator<<(ostream &os,const CELLMODEL &my);
112 /*! returns _name attribute (ie: MED_PENTA15).\n
113 see med.h (in med/include) */
114 inline string getName() const;
116 /*! returns number of vertexes forming this type of cell */
117 inline int getNumberOfVertexes() const;
119 /*! returns number of nodes forming this type of cell */
120 inline int getNumberOfNodes() const;
122 /*! returns the dimension of this type of cell.\n
123 it can be different from mesh dimension */
124 inline int getDimension() const;
126 /*! returns the geometric type of the cell. \n
127 see med.h (in med/include) */
128 inline MED_EN::medGeometryElement getType() const;
130 /*! returns all constituents which dimension is _dimension-dim.*/
131 int** getConstituents(int dim) const;
133 /*! returns number of constituents which dimension is _dimension-dim.*/
134 int getNumberOfConstituents(int dim) const;
136 /*! returns local nodes numbers vector for num-th constituent
137 which dimension is _dimension-dim.*/
138 int* getNodesConstituent(int dim,int num) const;
140 /*! returns local node number of nodes_index-th node for
141 num-th constituent which dimension is _dimension-dim.*/
142 int getNodeConstituent(int dim,int num,int nodes_index) const;
144 /*! returns types of each constituents which dimension
146 MED_EN::medGeometryElement* getConstituentsType(int dim) const;
148 /*! returns type of num-th constituent which dimension
150 MED_EN::medGeometryElement getConstituentType(int dim,int num) const;
152 /*! returns number of constituents type
153 (which dimension is _dimension-1).*/
154 int getNumberOfConstituentsType() const;
156 /*! returns all types of constituents which dimension
158 set<MED_EN::medGeometryElement> getAllConstituentsType() const;
160 /*! returns number of constituents foreach type (which dimension
162 map<MED_EN::medGeometryElement,int> getNumberOfConstituentsForeachType() const;
167 // ------------------------------------------
169 // ------------------------------------------
171 inline CELLMODEL::CELLMODEL():
172 _type(MED_EN::MED_NONE),
175 _numberOfVertexes(0),
176 _numberOfConstituentsDimension(0),
177 _numberOfConstituents((int*)NULL),
178 _numberOfNodeOfEachConstituent((int**)NULL),
179 _constituents((int***)NULL),
180 _constituentsType((MED_EN::medGeometryElement**)NULL)
183 inline CELLMODEL::CELLMODEL(const CELLMODEL &m):
184 _type(MED_EN::MED_NONE),
187 _numberOfVertexes(0),
188 _numberOfConstituentsDimension(0),
189 _numberOfConstituents((int*)NULL),
190 _numberOfNodeOfEachConstituent((int**)NULL),
191 _constituents((int***)NULL),
192 _constituentsType((MED_EN::medGeometryElement**)NULL)
196 inline CELLMODEL::~CELLMODEL()
198 // MESSAGE_MED("CELLMODEL::~CELLMODEL() destroying the cell");
201 inline CELLMODEL & CELLMODEL::operator=(const CELLMODEL &m)
207 inline string CELLMODEL::getName() const
211 inline int CELLMODEL::getNumberOfVertexes() const
213 return _numberOfVertexes;
215 inline int CELLMODEL::getNumberOfNodes() const
217 return _numberOfNodes;
219 inline int CELLMODEL::getDimension() const
223 inline MED_EN::medGeometryElement CELLMODEL::getType() const
227 inline int** CELLMODEL::getConstituents(int dim) const
229 return _constituents[dim-1] ;
231 inline int CELLMODEL::getNumberOfConstituents(int dim) const
233 return _numberOfConstituents[dim-1] ;
235 inline int* CELLMODEL::getNodesConstituent(int dim,int num) const
237 return _constituents[dim-1][num-1];
239 inline int CELLMODEL::getNodeConstituent(int dim,int num,int nodesNumber) const
241 return _constituents[dim-1][num-1][nodesNumber-1] ;
243 inline MED_EN::medGeometryElement* CELLMODEL::getConstituentsType(int dim) const
245 return _constituentsType[dim-1];
247 inline MED_EN::medGeometryElement CELLMODEL::getConstituentType(int dim,int num) const
249 return _constituentsType[dim-1][num-1];
252 /*!: Utility class for storing cell models. Avoids calling the cellmodel constructor too
255 class MEDMEM_EXPORT CELLMODEL_Map
258 static const MEDMEM::CELLMODEL& retrieveCellModel(MED_EN::medGeometryElement type);
260 static CELLMODEL_Map *getInstance();
261 static CELLMODEL_Map *_singleton;
262 std::map<MED_EN::medGeometryElement,MEDMEM::CELLMODEL> _cell_models;
265 ~CELLMODEL_Map(){ if(_singleton) delete _singleton;}
267 const MEDMEM::CELLMODEL& getCellModel(MED_EN::medGeometryElement type);
271 }//End of namespace MEDMEM
273 #endif /* CELLMODEL_HXX */