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