Salome HOME
Vadim s review of 47fc37875313e44
[tools/medcoupling.git] / src / MEDLoader / libmesh5.hxx
1 #ifndef MESHFORMATPARSER_HXX
2 #define MESHFORMATPARSER_HXX
3 /*----------------------------------------------------------*/
4 /*                                                                                                                      */
5 /*                                              LIBMESH V 5.46                                          */
6 /*                                                                                                                      */
7 /*----------------------------------------------------------*/
8 /*                                                                                                                      */
9 /*      Description:            handle .meshb file format I/O           */
10 /*      Author:                         Loic MARECHAL                                           */
11 /*      Creation date:          feb 16 2007                                                     */
12 /*      Last modification:      dec 12 2020                                                     */
13 /*                                                                                                                      */
14 /*----------------------------------------------------------*/
15
16
17 /*----------------------------------------------------------*/
18 /* Defines                                                                                                      */
19 /*----------------------------------------------------------*/
20
21
22 #define GmfStrSiz 1024
23 #define GmfMaxTyp 1000
24 #define GmfMaxKwd 81
25 #define GmfMshVer 1
26 #define GmfRead 1
27 #define GmfWrite 2
28 #define GmfSca 1
29 #define GmfVec 2
30 #define GmfSymMat 3
31 #define GmfMat 4
32 #define GmfFloat 1
33 #define GmfDouble 2
34
35
36 /*----------------------------------------------------------*/
37 /* Defines                                                                                                      */
38 /*----------------------------------------------------------*/
39
40 #define Asc 1
41 #define Bin 2
42 #define MshFil 4
43 #define SolFil 8
44 #define MaxMsh 100
45 #define InfKwd 1
46 #define RegKwd 2
47 #define SolKwd 3
48 #define WrdSiz 4
49 #define BufSiz 10000
50
51
52 // see MeshGems/Docs/meshgems_formats_description.pdf
53 extern const char* GmfKwdFmt[ GmfMaxKwd + 1 ][4];
54 /*----------------------------------------------------------*/
55 /* Structures                                                                                           */
56 /*----------------------------------------------------------*/
57 namespace  MeshFormat {
58 typedef struct
59 {
60     int typ, SolSiz, NmbWrd, NmbLin, NmbTyp, TypTab[ GmfMaxTyp ];
61     long pos;
62     char fmt[ GmfMaxTyp*9 ];
63 } KwdSct;
64
65 typedef struct
66 {
67     int dim, ver, mod, typ, cod, pos;
68     long NexKwdPos, siz;
69     KwdSct KwdTab[ GmfMaxKwd + 1 ];
70     FILE *hdl;
71     int *IntBuf;
72     float *FltBuf;
73     unsigned char *buf;
74     char FilNam[ GmfStrSiz ];
75     double DblBuf[1000/8];
76     unsigned char blk[ BufSiz + 1000 ];
77 } GmfMshSct;
78
79
80
81
82
83 // see MeshGems/Docs/meshgems_formats_description.pdf
84 enum GmfKwdCod
85 {
86     GmfReserved1, \
87     GmfVersionFormatted, \
88     GmfReserved2, \
89     GmfDimension, \
90     GmfVertices, \
91     GmfEdges, \
92     GmfTriangles, \
93     GmfQuadrilaterals, \
94     GmfTetrahedra, \
95     GmfPrisms, \
96     GmfHexahedra, \
97     GmfIterationsAll, \
98     GmfTimesAll, \
99     GmfCorners, \
100     GmfRidges, \
101     GmfRequiredVertices, \
102     GmfRequiredEdges, \
103     GmfRequiredTriangles, \
104     GmfRequiredQuadrilaterals, \
105     GmfTangentAtEdgeVertices, \
106     GmfNormalAtVertices, \
107     GmfNormalAtTriangleVertices, \
108     GmfNormalAtQuadrilateralVertices, \
109     GmfAngleOfCornerBound, \
110     GmfTrianglesP2, \
111     GmfEdgesP2, \
112     GmfSolAtPyramids, \
113     GmfQuadrilateralsQ2, \
114     GmfISolAtPyramids, \
115     GmfSubDomainFromGeom, \
116     GmfTetrahedraP2, \
117     GmfFault_NearTri, \
118     GmfFault_Inter, \
119     GmfHexahedraQ2, \
120     GmfExtraVerticesAtEdges, \
121     GmfExtraVerticesAtTriangles, \
122     GmfExtraVerticesAtQuadrilaterals, \
123     GmfExtraVerticesAtTetrahedra, \
124     GmfExtraVerticesAtPrisms, \
125     GmfExtraVerticesAtHexahedra, \
126     GmfVerticesOnGeometricVertices, \
127     GmfVerticesOnGeometricEdges, \
128     GmfVerticesOnGeometricTriangles, \
129     GmfVerticesOnGeometricQuadrilaterals, \
130     GmfEdgesOnGeometricEdges, \
131     GmfFault_FreeEdge, \
132     GmfPolyhedra, \
133     GmfPolygons, \
134     GmfFault_Overlap, \
135     GmfPyramids, \
136     GmfBoundingBox, \
137     GmfBody, \
138     GmfPrivateTable, \
139     GmfFault_BadShape, \
140     GmfEnd, \
141     GmfTrianglesOnGeometricTriangles, \
142     GmfTrianglesOnGeometricQuadrilaterals, \
143     GmfQuadrilateralsOnGeometricTriangles, \
144     GmfQuadrilateralsOnGeometricQuadrilaterals, \
145     GmfTangents, \
146     GmfNormals, \
147     GmfTangentAtVertices, \
148     GmfSolAtVertices, \
149     GmfSolAtEdges, \
150     GmfSolAtTriangles, \
151     GmfSolAtQuadrilaterals, \
152     GmfSolAtTetrahedra, \
153     GmfSolAtPrisms, \
154     GmfSolAtHexahedra, \
155     GmfDSolAtVertices, \
156     GmfISolAtVertices, \
157     GmfISolAtEdges, \
158     GmfISolAtTriangles, \
159     GmfISolAtQuadrilaterals, \
160     GmfISolAtTetrahedra, \
161     GmfISolAtPrisms, \
162     GmfISolAtHexahedra, \
163     GmfIterations, \
164     GmfTime, \
165     GmfFault_SmallTri, \
166     GmfCoarseHexahedra, \
167     GmfFault_MultipleEdge
168 };
169
170
171
172 class MeshFormatParser {
173     /*----------------------------------------------------------*/
174     /* External procedures                                                                          */
175     /*----------------------------------------------------------*/
176 public :
177     MeshFormatParser();
178     int GmfOpenMesh(const char *, int, ...);
179     int GmfCloseMesh(int);
180     int GmfStatKwd(int, int, ...);
181     int GmfGotoKwd(int, int);
182     int GmfSetKwd(int, int, ...);
183     void GmfGetLin(int, int, ...);
184     void GmfSetLin(int, int, ...);
185 private :
186
187
188     /*----------------------------------------------------------*/
189     /*  private procedures methods                                                       */
190     /*----------------------------------------------------------*/
191
192     void ScaWrd(GmfMshSct *, unsigned char *);
193     void ScaDblWrd(GmfMshSct *, unsigned char *);
194     void ScaBlk(GmfMshSct *, unsigned char *, int);
195     long GetPos(GmfMshSct *);
196     void RecWrd(GmfMshSct *, unsigned char *);
197     void RecDblWrd(GmfMshSct *, unsigned char *);
198     void RecBlk(GmfMshSct *, unsigned char *, int);
199     void SetPos(GmfMshSct *, long);
200     int ScaKwdTab(GmfMshSct *);
201     void ExpFmt(GmfMshSct *, int);
202     void ScaKwdHdr(GmfMshSct *, int);
203
204     void GmfCpyLin(int, int, int);
205
206
207     int GmfIniFlg;
208     GmfMshSct *GmfMshTab[ MaxMsh + 1 ];
209
210
211
212
213
214 };
215
216 }
217 #endif // MESHFORMATPARSER_HXX