Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/med.git] / src / INTERP_KERNEL / CellModel.hxx
1 // Copyright (C) 2007-2012  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
20 #ifndef __CELLMODEL_INTERP_KERNEL_HXX__
21 #define __CELLMODEL_INTERP_KERNEL_HXX__
22
23 #include "INTERPKERNELDefines.hxx"
24
25 #include "NormalizedUnstructuredMesh.hxx"
26
27 #include <map>
28
29 namespace INTERP_KERNEL
30 {
31   /*!
32    * This class descibes all static elements (different from polygons and polyhedron) 3D, 2D and 1D.
33    */
34   class CellModel
35   {
36   public:
37     static const unsigned MAX_NB_OF_SONS=8;
38     static const unsigned MAX_NB_OF_NODES_PER_ELEM=30;
39   private:
40     CellModel(NormalizedCellType type);
41     static void buildUniqueInstance();
42   public:
43     INTERPKERNEL_EXPORT static const CellModel& GetCellModel(NormalizedCellType type);
44     INTERPKERNEL_EXPORT const char *getRepr() const;
45     INTERPKERNEL_EXPORT bool isExtruded() const { return _is_extruded; }
46     INTERPKERNEL_EXPORT bool isDynamic() const { return _dyn; }
47     INTERPKERNEL_EXPORT bool isQuadratic() const { return _quadratic; }
48     INTERPKERNEL_EXPORT unsigned getDimension() const { return _dim; }
49     INTERPKERNEL_EXPORT bool isCompatibleWith(NormalizedCellType type) const;
50     INTERPKERNEL_EXPORT bool isSimplex() const { return _is_simplex; }
51     //! sonId is in C format.
52     INTERPKERNEL_EXPORT const unsigned *getNodesConstituentTheSon(unsigned sonId) const { return _sons_con[sonId]; }
53     INTERPKERNEL_EXPORT bool getOrientationStatus(unsigned lgth, const int *conn1, const int *conn2) const;
54     INTERPKERNEL_EXPORT unsigned getNumberOfNodes() const { return _nb_of_pts; }
55     INTERPKERNEL_EXPORT unsigned getNumberOfSons() const { return _nb_of_sons; }
56     INTERPKERNEL_EXPORT unsigned getNumberOfSons2(const int *conn, int lgth) const;
57     INTERPKERNEL_EXPORT unsigned getNumberOfNodesConstituentTheSon(unsigned sonId) const { return _nb_of_sons_con[sonId]; }
58     INTERPKERNEL_EXPORT unsigned getNumberOfNodesConstituentTheSon2(unsigned sonId, const int *nodalConn, int lgth) const;
59     INTERPKERNEL_EXPORT NormalizedCellType getExtrudedType() const { return _extruded_type; }
60     INTERPKERNEL_EXPORT NormalizedCellType getLinearType() const { return _linear_type; }
61     INTERPKERNEL_EXPORT NormalizedCellType getQuadraticType() const { return _quadratic_type; }
62     INTERPKERNEL_EXPORT NormalizedCellType getSonType(unsigned sonId) const { return _sons_type[sonId]; }
63     INTERPKERNEL_EXPORT NormalizedCellType getSonType2(unsigned sonId) const;
64     INTERPKERNEL_EXPORT unsigned fillSonCellNodalConnectivity(int sonId, const int *nodalConn, int *sonNodalConn) const;
65     INTERPKERNEL_EXPORT unsigned fillSonCellNodalConnectivity2(int sonId, const int *nodalConn, int lgth, int *sonNodalConn, NormalizedCellType& typeOfSon) const;
66   private:
67     bool _dyn;
68     bool _quadratic;
69     bool _is_simplex;
70     bool _is_extruded;
71     unsigned _dim;
72     unsigned _nb_of_pts;
73     unsigned _nb_of_sons;
74     NormalizedCellType _type;
75     NormalizedCellType _extruded_type;
76     NormalizedCellType _linear_type;
77     NormalizedCellType _quadratic_type;
78     unsigned _sons_con[MAX_NB_OF_SONS][MAX_NB_OF_NODES_PER_ELEM];
79     unsigned _nb_of_sons_con[MAX_NB_OF_SONS];
80     NormalizedCellType _sons_type[MAX_NB_OF_SONS];
81     static std::map<NormalizedCellType,CellModel> _map_of_unique_instance;
82     static const char *CELL_TYPES_REPR[];
83   };
84 }
85
86 #endif