Salome HOME
dd37f1b83e0b042148a10544a61a080139293e76
[tools/medcoupling.git] / src / INTERP_KERNEL / CellModel.hxx
1 // Copyright (C) 2007-2016  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, or (at your option) any later version.
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 // Author : Anthony Geay (CEA/DEN)
20
21 #ifndef __CELLMODEL_INTERP_KERNEL_HXX__
22 #define __CELLMODEL_INTERP_KERNEL_HXX__
23
24 #include "INTERPKERNELDefines.hxx"
25
26 #include "NormalizedUnstructuredMesh.hxx"
27
28 #include <map>
29
30 namespace INTERP_KERNEL
31 {
32   class DiameterCalculator;
33   class OrientationInverter;
34   
35   /*!
36    * This class describes all static elements (different from polygons and polyhedron) 3D, 2D and 1D.
37    */
38   class CellModel
39   {
40   public:
41     static const unsigned MAX_NB_OF_SONS=8;
42     static const unsigned MAX_NB_OF_NODES_PER_ELEM=30;
43     static const unsigned MAX_NB_OF_LITTLE_SONS=12;
44   private:
45     CellModel(NormalizedCellType type);
46     static void buildUniqueInstance();
47   public:
48     INTERPKERNEL_EXPORT static const CellModel& GetCellModel(NormalizedCellType type);
49     INTERPKERNEL_EXPORT NormalizedCellType getEnum() const { return _type; }
50     INTERPKERNEL_EXPORT const char *getRepr() const;
51     INTERPKERNEL_EXPORT bool isExtruded() const { return _is_extruded; }
52     INTERPKERNEL_EXPORT bool isDynamic() const { return _dyn; }
53     INTERPKERNEL_EXPORT bool isQuadratic() const { return _quadratic; }
54     INTERPKERNEL_EXPORT unsigned getDimension() const { return _dim; }
55     INTERPKERNEL_EXPORT bool isCompatibleWith(NormalizedCellType type) const;
56     INTERPKERNEL_EXPORT bool isSimplex() const { return _is_simplex; }
57     //! sonId is in C format.
58     INTERPKERNEL_EXPORT const unsigned *getNodesConstituentTheSon(unsigned sonId) const { return _sons_con[sonId]; }
59     INTERPKERNEL_EXPORT const unsigned *getNodesConstituentTheLittleSon(unsigned littleSonId) const { return _little_sons_con[littleSonId]; }
60     INTERPKERNEL_EXPORT bool getOrientationStatus(unsigned lgth, const int *conn1, const int *conn2) const;
61     INTERPKERNEL_EXPORT unsigned getNumberOfNodes() const { return _nb_of_pts; }
62     INTERPKERNEL_EXPORT unsigned getNumberOfSons() const { return _nb_of_sons; }
63     INTERPKERNEL_EXPORT unsigned getNumberOfSons2(const int *conn, int lgth) const;
64     INTERPKERNEL_EXPORT unsigned getNumberOfEdgesIn3D(const int *conn, int lgth) const;
65     INTERPKERNEL_EXPORT unsigned getNumberOfMicroEdges() const;
66     INTERPKERNEL_EXPORT unsigned getNumberOfNodesConstituentTheSon(unsigned sonId) const { return _nb_of_sons_con[sonId]; }
67     INTERPKERNEL_EXPORT unsigned getNumberOfNodesConstituentTheSon2(unsigned sonId, const int *nodalConn, int lgth) const;
68     INTERPKERNEL_EXPORT NormalizedCellType getExtrudedType() const { return _extruded_type; }
69     INTERPKERNEL_EXPORT NormalizedCellType getCorrespondingPolyType() const;
70     INTERPKERNEL_EXPORT NormalizedCellType getReverseExtrudedType() const { return _reverse_extruded_type; }
71     INTERPKERNEL_EXPORT NormalizedCellType getLinearType() const { return _linear_type; }
72     INTERPKERNEL_EXPORT NormalizedCellType getQuadraticType() const { return _quadratic_type; }
73     INTERPKERNEL_EXPORT NormalizedCellType getQuadraticType2() const { return _quadratic_type2; }
74     INTERPKERNEL_EXPORT NormalizedCellType getSonType(unsigned sonId) const { return _sons_type[sonId]; }
75     INTERPKERNEL_EXPORT NormalizedCellType getSonType2(unsigned sonId) const;
76     INTERPKERNEL_EXPORT unsigned fillSonCellNodalConnectivity(int sonId, const int *nodalConn, int *sonNodalConn) const;
77     INTERPKERNEL_EXPORT unsigned fillSonCellNodalConnectivity2(int sonId, const int *nodalConn, int lgth, int *sonNodalConn, NormalizedCellType& typeOfSon) const;
78     INTERPKERNEL_EXPORT unsigned fillSonCellNodalConnectivity4(int sonId, const int *nodalConn, int lgth, int *sonNodalConn, NormalizedCellType& typeOfSon) const;
79     INTERPKERNEL_EXPORT unsigned fillSonEdgesNodalConnectivity3D(int sonId, const int *nodalConn, int lgth, int *sonNodalConn, NormalizedCellType& typeOfSon) const;
80     INTERPKERNEL_EXPORT unsigned fillMicroEdgeNodalConnectivity(int sonId, const int *nodalConn, int *sonNodalConn, NormalizedCellType& typeOfSon) const;
81     INTERPKERNEL_EXPORT void changeOrientationOf2D(int *nodalConn, unsigned int sz) const;
82     INTERPKERNEL_EXPORT void changeOrientationOf1D(int *nodalConn, unsigned int sz) const;
83     INTERPKERNEL_EXPORT DiameterCalculator *buildInstanceOfDiameterCalulator(int spaceDim) const;
84     INTERPKERNEL_EXPORT OrientationInverter *buildOrientationInverter() const;
85   private:
86     bool _dyn;
87     bool _quadratic;
88     bool _is_simplex;
89     bool _is_extruded;
90     unsigned _dim;
91     unsigned _nb_of_pts;
92     unsigned _nb_of_sons;
93     unsigned _nb_of_little_sons;
94     NormalizedCellType _type;
95     NormalizedCellType _extruded_type;
96     NormalizedCellType _reverse_extruded_type;
97     NormalizedCellType _linear_type;
98     NormalizedCellType _quadratic_type;
99     NormalizedCellType _quadratic_type2;
100     unsigned _sons_con[MAX_NB_OF_SONS][MAX_NB_OF_NODES_PER_ELEM];
101     unsigned _little_sons_con[MAX_NB_OF_LITTLE_SONS][3];
102     unsigned _nb_of_sons_con[MAX_NB_OF_SONS];
103     NormalizedCellType _sons_type[MAX_NB_OF_SONS];
104     static std::map<NormalizedCellType,CellModel> _map_of_unique_instance;
105     static const char *CELL_TYPES_REPR[];
106   };
107 }
108
109 #endif