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