Salome HOME
Merge from V6_5_BR 05/06/2012
[modules/smesh.git] / src / Tools / MeshCut / MeshCut_Maillage.hxx
1 // Copyright (C) 2006-2012  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 __MESHCUT_MAILLAGE_HXX__
21 #define __MESHCUT_MAILLAGE_HXX__
22
23 #include "MeshCut_Utils.hxx"
24
25 #include <string>
26 #include <vector>
27 #include <map>
28
29 namespace MESHCUT
30   {
31     class Maillage
32     {
33     public:
34       // Toutes ces variables doivent être placées au niveau du principal pour être connues de toutes les fonctions
35
36       // Vecteurs des familles d'éléments
37       std::map<int, std::vector<int> > FAMILLES;
38       std::map<int, std::vector<TYPE_MAILLE> > FAM_TYPES;
39
40       // Vecteurs des familles de noeuds
41       std::map<int, std::vector<int> > FAMILLES_NOEUDS;
42
43       // Description des groupes (par familles)
44       std::map<std::string, std::vector<int> > GROUPES_MAILLES;
45       std::map<std::string, std::vector<int> > GROUPES_NOEUDS;
46
47       // Commun noeuds et mailles
48       std::map<int, int> tailleFAMILLES; // la clé est un num. de famille
49       std::map<std::string, int> tailleGROUPES; // Tailles des vecteurs GROUPES_MAILLES et GROUPES_NOEUDS - la clé est un nom de groupe (de noeuds ou de mailles)
50
51       // Résidus mailles
52       std::map<TYPE_MAILLE, std::vector<int> > RESIDU;
53
54     public:
55       std::string ID;
56       int nombreNoeudsMaillage; // ****** MED-OBLIGATOIRE ******
57       int nombreMaillesMaillage; // ****** MED-OBLIGATOIRE ******
58
59       class Cube *enveloppeMaillage;
60
61       int dimensionMaillage; // ****** MED-OBLIGATOIRE ******
62       int dimensionEspace; // ****** MED-OBLIGATOIRE ******
63
64       char axisname[3*MED_SNAME_SIZE+1]; // ****** MED-OBLIGATOIRE ******
65       char unitname[3*MED_SNAME_SIZE+1]; // ****** MED-OBLIGATOIRE ******
66
67       float *XX;
68       float *YY;
69       float *ZZ; // ****** MED-OBLIGATOIRE ******
70
71       // Effectifs des éléments par type
72       std::map<TYPE_MAILLE, int> EFFECTIFS_TYPES; // ****** MED-OBLIGATOIRE ******
73
74       // Connectivités des types
75       // Le numéro global du j-ième noeud de la maille de numéro global i est stocké à l'adresse
76       //           CNX[tm]+t*(i-1)+(j-1)
77       // (t = taille du type, i.e. nombre de noeuds de l'élément)
78       std::map<TYPE_MAILLE, int*> CNX; // ****** MED-OBLIGATOIRE ******
79
80       // Enveloppes cubiques
81       std::map<TYPE_MAILLE, float*> EC;
82
83       // Description des groupes
84       std::map<std::string, std::map<TYPE_MAILLE, std::vector<int> > > GM;
85       std::map<std::string, std::vector<int> > GN;
86
87       //  std::vector<std::string> IDS_NOEUDS; // Indice = num. global - 1
88       //  std::map<TYPE_MAILLE, std::vector<std::string> > IDS_MAILLES; // Indice = num local de maille dans le type
89       //
90       //  std::vector<int> NUM_NOEUDS; // Indice = num. global - 1
91       //  std::map<TYPE_MAILLE, std::vector<int> > NUM_MAILLES; // Indice = num local de maille dans le type
92
93       Maillage(std::string _ID);
94       virtual ~Maillage();
95
96       void creationGMtype(TYPE_MAILLE tm, std::string nomGMtype);
97       void afficheMailles(TYPE_MAILLE tm);
98       void listeMaillesType(TYPE_MAILLE tm);
99       void listeMaillesTousTypes();
100       void listeMaillesParGM();
101       void listeMaillesGM(std::string nomGM);
102       // void listeMaillesGMordonne(std::string nomGM);
103       void listeNoeuds();
104       void listeNoeudsGN(std::string nomGN);
105       void listeNoeudsGNordonne(std::string nomGN);
106       std::vector<float> G(int i, TYPE_MAILLE tm);
107       float distanceNoeudMaille(int ngnoeud, int imaille, TYPE_MAILLE tm);
108       int noeudVoisin(int ngnoeud, int imaille, TYPE_MAILLE tm);
109       float distanceNoeudNoeud(int ng1, int ng2);
110       //  void encombrements()
111
112       void inputMED(std::string fichierMED);
113       void outputMED(std::string fichierMED);
114       void outputMEDold(std::string fichierMED);
115
116       void inputHL(std::string fichierHL /*, std::string ficDICnoeuds, std::string ficDICmailles, bool DICO */);
117       void outputHL(std::string fichierHL);
118
119       void outputVRML(std::string ficVRML, float rNoeuds, char *renduAretes, char *renduFaces, float transparence);
120       // std::string vrmlType(TYPE_MAILLE tm, char *renduAretes, char *renduFaces, float transparence);
121       // void Maillage::creationGMtype(TYPE_MAILLE tm, std::vector<int> CON_TYPE);
122       int NGLOBAL(TYPE_MAILLE typeMaille, int nlocal);
123       int NLOCAL(int nglobal, TYPE_MAILLE tm);
124       TYPE_MAILLE TYPE(int nglobal);
125       void eliminationMailles(TYPE_MAILLE typeMaille, std::vector<int> listeMaillesSuppr);
126
127       // acquisitionTYPE_inputMED appelée par inputMED
128       void
129           acquisitionTYPE_inputMED(TYPE_MAILLE TYPE, int nTYPE, med_idt fid, char maa[MED_NAME_SIZE + 1], med_int mdim);
130
131       // void infoChamps(std::string type, med_entity_type MEM, med_geometry_type MGE, med_idt fid, char *maa,
132       //                 char *nomChamp, med_field_type typeChamp, med_int nCompChamp, std::map<std::string, int> REFGAUSS);
133
134       bool NoeudDansHEXA8(int n, int n0, int n1, int n2, int n3, int n4, int n5, int n6, int n7, float epsilon);
135       bool NoeudDansPENTA6(int n, int n0, int n1, int n2, int n3, int n4, int n5, float epsilon);
136       bool NoeudDansPYRAM5(int n, int n0, int n1, int n2, int n3, int n4, float epsilon);
137       bool NoeudDansTETRA4(int n, int n1, int n2, int n3, int n4, float epsilon);
138       bool NoeudDansQUAD4(int n, int n1, int n2, int n3, int n4, float epsilon);
139       bool NoeudDansTRIA3(int n, int n1, int n2, int n3, float epsilon);
140       double volumeTETRA(int n1, int n2, int n3, int n4);
141       double aireTRIA(int n1, int n2, int n3);
142       double DET3(int n1, int n2, int n3);
143       double DET2(int n1, int n2);
144       void * chargeEnveloppesCubiques(TYPE_MAILLE tm);
145       void * chargeEnveloppesCarrees(TYPE_MAILLE tm);
146       bool noeudDeMaille(int ngnoeud, int i, TYPE_MAILLE tm);
147       bool NoeudDansMaille3D(int n, int i, TYPE_MAILLE tm, float epsilon);
148       bool NoeudDansMaille2D(int n, int i, TYPE_MAILLE tm, float epsilon);
149       bool NoeudDansEnveloppeMaille2D(int n, int i, TYPE_MAILLE tm, float epsilon);
150       bool NoeudDansEnveloppeMaille3D(int n, int i, TYPE_MAILLE tm, float epsilon);
151       void * afficheEnveloppesCubiques(TYPE_MAILLE tm);
152       void * afficheEnveloppesCarrees(TYPE_MAILLE tm);
153
154       std::vector<int> noeudsGeomCommuns(int i1, TYPE_MAILLE tm1, int i2, TYPE_MAILLE tm2);
155       void creationGMresidu();
156
157       float longueurMoyenne();
158       // void Maillage::infoChamps2(std::string type, med_entity_type MEM, med_geometry_type MGE, med_idt fid,
159       //                            char *maa, char *nomChamp, med_field_type typeChamp, med_int nCompChamp, map<string,
160       //                            int> REFGAUSS);
161
162     };
163   }
164
165 #endif