Salome HOME
Merge branch 'V9_2_2_BR'
[plugins/ghs3dprlplugin.git] / src / tepal2med / ghs3dprl_mesh_wrap.h
1 // Copyright (C) 2007-2019  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
20 // ---
21 // File   : ghs3dprl_mesh_wrap.h
22 // Author : Christian VAN WAMBEKE (CEA) (from Hexotic plugin Lioka RAZAFINDRAZAKA)
23 // ---
24 //
25 #ifndef GHS3DPRL_MESH_WRAP_H
26 #define GHS3DPRL_MESH_WRAP_H
27
28 #include <string>
29 #include <map>
30 #include <QHash>
31 #include <QRegExp>
32
33 #include <libxml/tree.h>
34 #include <libxml/parser.h>
35 #include <libxml/xpath.h>
36 #include <libxml/xpathInternals.h>
37
38 //Med File V 2.2 attributes
39 //#undef MED_H
40 //#undef MED_PROTO_H
41
42 #include <med.h>
43 //#include <med_proto.h>
44
45 class CVWtab
46 //contains size=size of vector and the vector (med_int or med_float)
47 {
48
49 public:
50    static long memoryuse;
51    static long memorymax;
52    long size,type;
53    med_int *tmint;   //integer med
54    med_float *tmflo; //float med
55    QString filename;
56
57    CVWtab(long nb, med_int *pmint);
58    CVWtab(long nb, med_float *pmflo);
59    ~CVWtab();
60    bool CVWtab_deallocate();
61    bool is_equal(CVWtab *tab2);
62 };
63
64 typedef std::map<QString,  int> fend;
65 typedef std::map<QString, fend> fagr;
66 class familles{
67    private:
68    void newfam(QString nom);
69    void newgro(QString nom);
70    public:
71    int no;
72    fagr fam;
73    fagr gro;
74    void write();
75    xmlNodePtr xml_groups();
76    void add(QString nomfam, QString nomgro);
77    void addgro();
78    bool get_number_of_new_family(int sign,med_int *num,QString *tmp);
79    med_int find_family_on_groups(med_int fam1, med_int fam2);
80    fend fuse_goups(med_int fam1, med_int fam2);
81 };
82
83 class ghs3dprl_mesh_wrap
84 {
85 public:
86    QString 
87       medname,
88       casename,
89       path,
90       pathini,
91       filemed,
92       format,
93       format_tetra;
94    bool for_tetrahpc;    //to know what files to read: .noboite or .mesh
95    bool for_multithread; //to know what files to read: one or more
96    QRegExp deletegroups; //regular expression
97    long
98       nbtetrastotal,
99       nofile,nbfiles,nbfilestot,
100       nbelem_limit_swap,
101       verbose;
102    med_err err;
103    med_idt fid,fidjoint;
104    med_int idom;
105
106    //master.xml
107    std::string filemaster,domainname;
108    char distfilename[MED_COMMENT_SIZE];
109    xmlDocPtr master_doc;
110    xmlNodePtr root_node,node,node2,
111               joints_node,info_node,files_node,mesh_node;
112
113    QHash<QString,CVWtab*> mestab;
114    familles families;
115
116    //from skin.med
117    char nommaa[MED_NAME_SIZE+1];
118    char maillage_description[MED_COMMENT_SIZE+1];
119    char nomcoo[3*MED_SNAME_SIZE+1];
120    char unicoo[3*MED_SNAME_SIZE+1];
121    med_int *famnodesskin;    //from skin.med...
122    med_int *famseg2skin;     //...valid on global index/numerotation
123    med_int *famtria3skin;
124
125    //to final files .med with tetrahedra
126    char nomfinal[MED_NAME_SIZE+1];
127    med_int *famnodes,nbnodes,famnewnodes,famallnodes;  //to final files .med with tetrahedra
128    med_int *famseg2,nbseg2,famnewseg2,famallseg2;
129    med_int *famtria3,nbtria3,famnewtria3,famalltria3;
130    med_int *famtetra4,nbtetra4,famnewtetra4,famalltetra4;
131
132    //low level
133    bool list_keys_mesh_wrap(); //list keys
134    bool list_onekey_mesh_wrap(const QString &key);
135    long remove_key_mesh_wrap(const QRegExp &rxp);
136    long nb_key_mesh_wrap(const QRegExp &rxp);
137    long remove_all_keys_mesh_wrap();
138    bool insert_key(const QString &key,CVWtab *tab);
139    CVWtab* restore_key(const QString &key);
140
141    //family level
142    bool set_one_more_family(med_int *fami, med_int *more, med_int nb);
143    med_int create_families(med_idt fid, int sign);
144    med_int create_family_zero(med_idt fid, QString nameMesh);
145    void add_family(med_int num,QString newgro);
146    void cout_families_and_groups();
147    bool idom_nodes();
148    bool idom_edges();
149    bool idom_faces();
150    bool idom_joints();
151    bool idom_tetras();
152
153    //test level
154    bool test_msg_wrap();
155    bool test_vertices_wrap();
156
157    //hight level
158    long SwapOutOfMemory_key_mesh_wrap(const QRegExp &rxp,long ifgreaterthan=0);
159    bool ReadFileMSGnew(const QString FileName);
160    bool TestExistingFileMESHnew(const QString FileName);
161    bool ReadFileGLO(const QString FileName);
162    bool ReadFileGLOBAL(const QString FileName); //mg-tetra v2.1.11
163    bool ReadFileFACES(const QString FileName);
164    bool ReadFileMESH(const QString FileName);
165    bool ReadFileNOBOITE(const QString FileName);
166    bool ReadFileNOBOITEB(const QString FileName);
167    bool ReadFilePOINTS(const QString FileName);
168    bool Find_VerticesDomainToVerticesSkin();
169    bool Write_masterxmlMEDfile();
170    bool Write_MEDfiles_v0(bool deletekeys=false); 
171    bool Write_MEDfiles_v1(bool deletekeys=false); 
172    bool Write_MEDfiles_v2(bool deletekeys=false);
173 };
174
175 #endif