Salome HOME
1111856cd1683a0be13dd1e6934a0305effcb556
[tools/medcoupling.git] / src / INTERP_KERNEL / CellModel.hxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D
2 //
3 //  This library is free software; you can redistribute it and/or
4 //  modify it under the terms of the GNU Lesser General Public
5 //  License as published by the Free Software Foundation; either
6 //  version 2.1 of the License.
7 //
8 //  This library is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //  Lesser General Public License for more details.
12 //
13 //  You should have received a copy of the GNU Lesser General Public
14 //  License along with this library; if not, write to the Free Software
15 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 #ifndef __CELLMODEL_INTERP_KERNEL_HXX__
20 #define __CELLMODEL_INTERP_KERNEL_HXX__
21
22 #include "INTERPKERNELDefines.hxx"
23
24 #include "NormalizedUnstructuredMesh.hxx"
25
26 #include <map>
27
28 namespace INTERP_KERNEL
29 {
30   /*!
31    * This class descibes all static elements (different from polygons and polyhedron) 3D, 2D and 1D.
32    */
33   class INTERPKERNEL_EXPORT CellModel
34   {
35   public:
36     static const unsigned MAX_NB_OF_SONS=6;
37     static const unsigned MAX_NB_OF_NODES_PER_ELEM=30;
38   private:
39     CellModel(NormalizedCellType type);
40     static void buildUniqueInstance();
41   public:
42     static const CellModel& getCellModel(NormalizedCellType type);
43     bool isDynamic() const { return _dyn; }
44     bool isQuadratic() const { return _quadratic; }
45     unsigned getDimension() const { return _dim; }
46     //! sonId is in C format.
47     const unsigned *getNodesConstituentTheSon(unsigned sonId) const { return _sons_con[sonId]; }
48     unsigned getNumberOfNodes() const { return _nb_of_pts; }
49     unsigned getNumberOfSons() const { return _nb_of_sons; }
50     unsigned getNumberOfNodesConstituentTheSon(unsigned sonId) const { return _nb_of_sons_con[sonId]; }
51     NormalizedCellType getSonType(unsigned sonId) const { return _sons_type[sonId]; }
52     void fillSonCellNodalConnectivity(int sonId, const int *nodalConn, int *sonNodalConn) const;
53   private:
54     bool _dyn;
55     bool _quadratic;
56     unsigned _dim;
57     unsigned _nb_of_pts;
58     unsigned _nb_of_sons;
59     unsigned _sons_con[MAX_NB_OF_SONS][MAX_NB_OF_NODES_PER_ELEM];
60     unsigned _nb_of_sons_con[MAX_NB_OF_SONS];
61     NormalizedCellType _sons_type[MAX_NB_OF_SONS];
62     static std::map<NormalizedCellType,CellModel> _map_of_unique_instance;
63   };
64 }
65
66 #endif