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