Debian Codegraph @

3rdparty/mmg3d/patch-mmg3dv4.diff

raw
1 >diff -r -u mmg3d4/build/sources/analarcutting.c mmg3d4-new/build/sources/analarcutting.c
2 --- mmg3d4/build/sources/analarcutting.c 2012-12-19 16:05:32.000000000 +0100
3 +++ mmg3d4-new/build/sources/analarcutting.c 2013-01-18 16:33:45.000000000 +0100
4 @@ -307,7 +307,7 @@
5 printf("6 cut : %8d\n",n6);
6 printf("---------------------------\n"); */
7 if ( !na ) return(na);
8 -#warning check memory allocation
9 + // #warning check memory allocation
10
11 //printf("%d cut init --- nb tet %d\n",na,mesh->ne);
12 return(na);
13 diff -r -u mmg3d4/build/sources/cutelt.c mmg3d4-new/build/sources/cutelt.c
14 --- mmg3d4/build/sources/cutelt.c 2012-12-19 16:05:32.000000000 +0100
15 +++ mmg3d4-new/build/sources/cutelt.c 2013-01-18 16:35:41.000000000 +0100
16 @@ -305,8 +305,7 @@
17 // }
18 // return(1);
19 // }
20 -int ddebug=0;
21 -
22 +extern int ddebug;
23 int MMG_decouphex(pMesh mesh, pHedge hed,int k,int* p,int ref) {
24 pTetra pt;
25 int i,nu1,nu2;
26 diff -r -u mmg3d4/build/sources/dataff.h mmg3d4-new/build/sources/dataff.h
27 --- mmg3d4/build/sources/dataff.h 2013-01-18 21:52:48.000000000 +0100
28 +++ mmg3d4-new/build/sources/dataff.h 2013-01-18 18:50:04.000000000 +0100
29 @@ -0,0 +1,60 @@
30 +/*
31 + * dataff.h
32 + *
33 + *
34 + * Created by Fr\E9d\E9ric Hecht on 19/06/11.
35 + * Copyright 2011 UPMC. All rights reserved.
36 + *
37 +
38 + */
39 +
40 +enum ff_data_type {
41 + ff_id_vertex =0,
42 + ff_id_seg =1,
43 + ff_id_tria=2,
44 + ff_id_tet =3,
45 +
46 + ff_id_prism =5,
47 + ff_id_hex =6,
48 + ff_id_quad =7,
49 + ff_id_corner=8
50 +} ;
51 +
52 +
53 +typedef struct DataFF
54 +{
55 + const char * meshname;
56 + const char * movename;
57 + const char * solname;
58 + int imprim;
59 + int memory;
60 + int np; // nb of vertices in/out
61 + int typesol; // 1 iso , 6 : m11; m12,m13,m22,m23,m33
62 + void * mesh;
63 + double * sol; /* metric :size typesol*np */
64 + double * mov; /* displac. size :3*np */
65 + void (*set_mesh)(void *dataff,int *data,int ldata);
66 + void (*end_mesh)(void *dataff);
67 + void (*set_v)(void *dataff,int i,double *xyz,int lab);
68 + void (*set_elmt)(void *dataff,int ff_id,int i,int *k,int lab);
69 + void (*get_mesh)(void *dataff,int *data,int ldata);
70 + void (*get_v3)(void *dataff,int i,double *xyz,int *lab);
71 + void (*get_elmt)(void *dataff,int ff_id,int i,int *k,int *lab);
72 +} DataFF;
73 +
74 +#ifdef __cplusplus
75 +extern "C" {
76 +#endif
77 + int mainmmg3d(int argc,char *argv[],DataFF *dataff);
78 +
79 +#ifdef __cplusplus
80 +}
81 +#endif
82 +/*
83 + m11 = met[0]
84 + m12 = met[1]
85 + m13 = met[2]
86 + m22 = met[3]
87 + m23 = met[4]
88 + m33 = met[5]
89 +*/
90 diff -r -u mmg3d4/build/sources/delaunay.c mmg3d4-new/build/sources/delaunay.c
91 --- mmg3d4/build/sources/delaunay.c 2012-12-19 16:05:32.000000000 +0100
92 +++ mmg3d4-new/build/sources/delaunay.c 2013-01-18 16:32:41.000000000 +0100
93 @@ -728,7 +728,7 @@
94 if ( ppt->tag & M_UNUSED ) return(0);
95
96 tref = mesh->tetra[list->tetra[1]/6].ref;
97 -#warning remove this test
98 + // #warning remove this test
99 for (k=1; k<=lon; k++)
100 if(tref!=mesh->tetra[list->tetra[k]/6].ref)
101 printf("pbs coquil %d %d tet %d\n",tref,mesh->tetra[list->tetra[k]/6].ref,list->tetra[k]/6);
102 diff -r -u mmg3d4/build/sources/libmmg3d.h mmg3d4-new/build/sources/libmmg3d.h
103 --- mmg3d4/build/sources/libmmg3d.h 2012-12-19 16:05:36.000000000 +0100
104 +++ mmg3d4-new/build/sources/libmmg3d.h 2013-01-18 16:32:41.000000000 +0100
105 @@ -118,12 +118,12 @@
106 typedef MMG_Sol * MMG_pSol;
107
108 /* inout */
109 -int MMG_loadMesh(MMG_pMesh ,char *);
110 -int MMG_loadSol(MMG_pSol ,char *,int );
111 -int MMG_loadVect(MMG_pMesh ,char *,int );
112 -int MMG_saveMesh(MMG_pMesh ,char *);
113 -int MMG_saveSol(MMG_pMesh ,MMG_pSol ,char *);
114 -int MMG_saveVect(MMG_pMesh ,char *);
115 +int MMG_loadMesh(MMG_pMesh ,char *,void *);
116 +int MMG_loadSol(MMG_pSol ,char *,int ,void *);
117 +int MMG_loadVect(MMG_pMesh ,char *,int ,void *);
118 +int MMG_saveMesh(MMG_pMesh ,char *,void *);
119 +int MMG_saveSol(MMG_pMesh ,MMG_pSol ,char *,void *);
120 +int MMG_saveVect(MMG_pMesh ,char *,void *);
121
122 #ifdef __cplusplus
123 namespace mmg3d{
124 diff -r -u mmg3d4/build/sources/mesh.h mmg3d4-new/build/sources/mesh.h
125 --- mmg3d4/build/sources/mesh.h 2012-12-19 16:05:36.000000000 +0100
126 +++ mmg3d4-new/build/sources/mesh.h 2013-01-18 16:32:41.000000000 +0100
127 @@ -405,17 +405,17 @@
128
129 /* function pointers */
130 typedef int (*MMG_Swap)(pMesh ,pSol ,pList );
131 -MMG_Swap MMG_swpptr;
132 -double (*MMG_length)(double *,double *,double *,double *);
133 -double (*MMG_caltet)(pMesh ,pSol ,int );
134 -double (*MMG_calte1)(pMesh ,pSol ,int );
135 -int (*MMG_caltet2)(pMesh ,pSol ,int ,int ,double ,double *);
136 -int (*MMG_cavity)(pMesh ,pSol ,int ,int ,pList ,int );
137 -int (*MMG_buckin)(pMesh ,pSol ,pBucket ,int );
138 -int (*MMG_optlen)(pMesh ,pSol ,double ,int );
139 -int (*MMG_interp)(double *,double *,double *,double );
140 -int (*MMG_optlentet)(pMesh ,pSol ,pQueue ,double ,int ,int );
141 -int (*MMG_movevertex)(pMesh ,pSol ,int ,int );
142 +extern MMG_Swap MMG_swpptr;
143 +extern double (*MMG_length)(double *,double *,double *,double *);
144 +extern double (*MMG_caltet)(pMesh ,pSol ,int );
145 +extern double (*MMG_calte1)(pMesh ,pSol ,int );
146 +extern int (*MMG_caltet2)(pMesh ,pSol ,int ,int ,double ,double *);
147 +extern int (*MMG_cavity)(pMesh ,pSol ,int ,int ,pList ,int );
148 +extern int (*MMG_buckin)(pMesh ,pSol ,pBucket ,int );
149 +extern int (*MMG_optlen)(pMesh ,pSol ,double ,int );
150 +extern int (*MMG_interp)(double *,double *,double *,double );
151 +extern int (*MMG_optlentet)(pMesh ,pSol ,pQueue ,double ,int ,int );
152 +extern int (*MMG_movevertex)(pMesh ,pSol ,int ,int );
153
154
155 #endif
156 diff -r -u mmg3d4/build/sources/mmg3d4.c mmg3d4-new/build/sources/mmg3d4.c
157 --- mmg3d4/build/sources/mmg3d4.c 2012-12-19 16:05:33.000000000 +0100
158 +++ mmg3d4-new/build/sources/mmg3d4.c 2013-01-18 18:28:05.000000000 +0100
159 @@ -3,32 +3,32 @@
160 Co-auteurs : Cecile Dobrzynski et Pascal Frey.
161 Propriétaires :IPB - UPMC -INRIA.
162
163 -Copyright © 2004-2005-2006-2007-2008-2009-2010-2011,
164 +Copyright © 2004-2005-2006-2007-2008-2009-2010-2011,
165 diffusé sous les termes et conditions de la licence publique générale de GNU
166 -Version 3 ou toute version ultérieure.
167 +Version 3 ou toute version ultérieure.
168
169 Ce fichier est une partie de MMG3D.
170 MMG3D est un logiciel libre ; vous pouvez le redistribuer et/ou le modifier
171 suivant les termes de la licence publique générale de GNU
172 Version 3 ou toute version ultérieure.
173 -MMG3D est distribué dans l'espoir qu'il sera utile, mais SANS
174 -AUCUNE GARANTIE ; sans même garantie de valeur marchande.
175 +MMG3D est distribué dans l'espoir qu'il sera utile, mais SANS
176 +AUCUNE GARANTIE ; sans même garantie de valeur marchande.
177 Voir la licence publique générale de GNU pour plus de détails.
178 -MMG3D est diffusé en espérant qu’il sera utile,
179 -mais SANS AUCUNE GARANTIE, ni explicite ni implicite,
180 -y compris les garanties de commercialisation ou
181 -d’adaptation dans un but spécifique.
182 +MMG3D est diffusé en espérant qu’il sera utile,
183 +mais SANS AUCUNE GARANTIE, ni explicite ni implicite,
184 +y compris les garanties de commercialisation ou
185 +d’adaptation dans un but spécifique.
186 Reportez-vous à la licence publique générale de GNU pour plus de détails.
187 -Vous devez avoir reçu une copie de la licence publique générale de GNU
188 -en même temps que ce document.
189 +Vous devez avoir reçu une copie de la licence publique générale de GNU
190 +en même temps que ce document.
191 Si ce n’est pas le cas, aller voir <http://www.gnu.org/licenses/>.
192 /****************************************************************************
193 Initial software: MMG3D Version 4.0
194 Co-authors: Cecile Dobrzynski et Pascal Frey.
195 Owners: IPB - UPMC -INRIA.
196
197 -Copyright © 2004-2005-2006-2007-2008-2009-2010-2011,
198 -spread under the terms and conditions of the license GNU General Public License
199 +Copyright © 2004-2005-2006-2007-2008-2009-2010-2011,
200 +spread under the terms and conditions of the license GNU General Public License
201 as published Version 3, or (at your option) any later version.
202
203 This file is part of MMG3D
204 @@ -41,26 +41,26 @@
205 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
206 GNU General Public License for more details.
207 You should have received a copy of the GNU General Public License
208 -along with MMG3D. If not, see <http://www.gnu.org/licenses/>.
209 +along with MMG3D. If not, see <http://www.gnu.org/licenses/>.
210 ****************************************************************************/
211 #include "mesh.h"
212
213 -int MMG_npuiss,MMG_nvol,MMG_npres;
214 -int MMG_nlen,MMG_ncal,MMG_ntopo,MMG_nex;
215 -int MMG_npuisstot,MMG_nvoltot,MMG_nprestot;
216 -int MMG_npdtot;
217 -int MMG_nplen,MMG_npref,MMG_bouffe;
218 +extern int MMG_npuiss,MMG_nvol,MMG_npres;
219 +extern int MMG_nlen,MMG_ncal,MMG_ntopo,MMG_nex;
220 +extern int MMG_npuisstot,MMG_nvoltot,MMG_nprestot;
221 +extern int MMG_npdtot;
222 +extern int MMG_nplen,MMG_npref,MMG_bouffe;
223
224 int ddebug;
225
226 int MMG_mmg3d4(pMesh mesh,pSol sol,int *alert) {
227 Hedge hash;
228 - pBucket bucket;
229 + pBucket bucket;
230 double declic;
231 - int base,na,nd,ns,nna,nnd,nns,dd,it,nf,maxtou;
232 - double lmoy,LLLONG;
233 - int k;
234 - pTetra pt;
235 + int base,na,nd,ns,nna,nnd,nns,dd,it,nf,maxtou;
236 + double lmoy,LLLONG;
237 + int k;
238 + pTetra pt;
239 if ( abs(mesh->info.imprim) > 3 )
240 fprintf(stdout," ** SIZE OPTIMIZATION\n");
241 if ( mesh->info.imprim < 0 ) {
242 @@ -73,82 +73,82 @@
243 maxtou = 10;
244 nna = nns = nnd = 0;
245 it = 0;
246 - declic = 3. / ALPHAD;
247 + declic = 3. / ALPHAD;
248 lmoy = 10.;
249 LLLONG = 1.5;
250 -
251 +
252 nna = 10;
253 - do {
254 - na = nd = ns = 0;
255 + do {
256 + na = nd = ns = 0;
257 if(0) ddebug = 1;
258 else ddebug = 0;
259 -
260 +
261 if(it && !(it%2) ) {
262 bucket = MMG_newBucket(mesh,M_MAX(mesh->info.bucksiz,BUCKSIZ));
263 if ( !bucket ) return(0);
264 - //MMG_saveMesh(mesh,"avtana.mesh");
265 - MMG_analar(mesh,sol,bucket,&na,&nd,&nf,alert);
266 - //MMG_saveMesh(mesh,"apresana.mesh");
267 - if ( abs(mesh->info.imprim) > 5 )
268 - fprintf(stdout," %7d INSERTED %7d REMOVED %7d FILTERED\n",na,nd,nf);
269 -
270 - M_free(bucket->head);
271 - M_free(bucket->link);
272 - M_free(bucket);
273 -
274 + //MMG_saveMesh(mesh,"avtana.mesh",0);
275 + MMG_analar(mesh,sol,bucket,&na,&nd,&nf,alert);
276 + //MMG_saveMesh(mesh,"apresana.mesh",0);
277 + if ( abs(mesh->info.imprim) > 5 )
278 + fprintf(stdout," %7d INSERTED %7d REMOVED %7d FILTERED\n",na,nd,nf);
279 +
280 + M_free(bucket->head);
281 + M_free(bucket->link);
282 + M_free(bucket);
283 +
284 } else {
285 - ++mesh->flag;
286 + ++mesh->flag;
287 }
288 - //printf("IT %d $$$$$$$$$$$ LLLONG %9.3f\n",it,LLLONG);
289 - nna = nns = nnd = 0;
290 -
291 + //printf("IT %d $$$$$$$$$$$ LLLONG %9.3f\n",it,LLLONG);
292 + nna = nns = nnd = 0;
293 +
294 /*splitting*/
295 if ( !mesh->info.noinsert && (!*alert) ) {
296 /* store points on edges */
297 if ( !MMG_zaldy4(&hash,mesh->np) ) {
298 - if ( mesh->info.ddebug ) fprintf(stdout," ## MEMORY ALLOCATION PROBLEM.\n");
299 - *alert = 2;
300 - break;
301 + if ( mesh->info.ddebug ) fprintf(stdout," ## MEMORY ALLOCATION PROBLEM.\n");
302 + *alert = 2;
303 + break;
304 }
305 - nna = MMG_analarcutting(mesh,sol,&hash,alert,&lmoy,LLLONG);
306 + nna = MMG_analarcutting(mesh,sol,&hash,alert,&lmoy,LLLONG);
307 if ( abs(mesh->info.imprim) > 5 ) { printf("lmoy %9.5f\n",lmoy); }
308 /*puts("--------------------------------------");
309 - puts("--------------------------------------");
310 - puts("--------------------------------------");
311 - */
312 + puts("--------------------------------------");
313 + puts("--------------------------------------");
314 + */
315 if ( *alert ) {
316 - fprintf(stdout," \n\n ** UNABLE TO CUT (analarcutting)\n");
317 - fprintf(stdout," ** RETRY WITH -m > %6d \n\n",mesh->info.memory);
318 - MMG_saveMesh(mesh,"crash.mesh");
319 - MMG_saveSol(mesh,sol,"crash.sol");
320 - exit(0);
321 + fprintf(stdout," \n\n ** UNABLE TO CUT (analarcutting)\n");
322 + fprintf(stdout," ** RETRY WITH -m > %6d \n\n",mesh->info.memory);
323 + MMG_saveMesh(mesh,"crash.mesh",0);
324 + MMG_saveSol(mesh,sol,"crash.sol",0);
325 + exit(0);
326 }
327 - M_free(hash.item);
328 + M_free(hash.item);
329 }
330 - else if ( *alert ) nna = 0;
331 - /* adjacencies */
332 + else if ( *alert ) nna = 0;
333 + /* adjacencies */
334 if ( nna /*|| it == (maxtou-1)*/ ) {
335 mesh->nt = 0;
336 if ( !MMG_hashTetra(mesh) ) return(0);
337 if ( !MMG_markBdry(mesh) ) return(0);
338 }
339 - // printf("chkmsh\n");
340 - // MMG_unscaleMesh(mesh,sol);
341 - // MMG_saveMesh(mesh,"chk.mesh");
342 + // printf("chkmsh\n");
343 + // MMG_unscaleMesh(mesh,sol);
344 + // MMG_saveMesh(mesh,"chk.mesh",0);
345 //MMG_chkmsh(mesh,1,-1);
346 - //if(it==1)exit(0);
347 - /* delaunization */
348 - if ( !mesh->info.noswap && (nna || na) ) {
349 + //if(it==1)exit(0);
350 + /* delaunization */
351 + if ( !mesh->info.noswap && (nna || na) ) {
352 nns = MMG_cendel(mesh,sol,declic,base);
353 }
354
355 /* deletion */
356 /*if ( 0 && nna ) {
357 nnd = MMG_colvert(mesh,sol,base);
358 - } */
359 + } */
360 if ( nna+nnd+nns && abs(mesh->info.imprim) > 3 )
361 fprintf(stdout," %7d INSERTED %7d REMOVED %7d FLIPPED\n",nna+na,nnd+nd,nns);
362 -
363 +
364 }
365 while ( na+nd+nns+nna+nnd > 0 && ++it < maxtou && lmoy > 1.3);
366
367 @@ -161,80 +161,80 @@
368 MMG_prilen(mesh,sol);
369 }
370
371 - //return(1);
372 - //MMG_saveMesh(mesh,"aprescut.mesh");
373 - fprintf(stdout," ---\n");
374 -
375 + //return(1);
376 + //MMG_saveMesh(mesh,"aprescut.mesh",0);
377 + fprintf(stdout," ---\n");
378 +
379 /*analyze standard*/
380 - base = mesh->flag;
381 - *alert = 0;
382 + base = mesh->flag;
383 + *alert = 0;
384
385 - nna = 0;
386 - nnd = 0;
387 - nf = 0;
388 - it = 0;
389 - maxtou = 100;
390 - MMG_npdtot=0;
391 - MMG_npuisstot=0;
392 - MMG_nprestot=0;
393 - MMG_nvoltot=0;
394 -
395 - /* 2. field points */
396 - if ( mesh->info.imprim < -4 ) {
397 - MMG_prilen(mesh,sol);
398 - fprintf(stdout," -- FIELD POINTS\n");
399 - }
400 -
401 - /* create filter */
402 - bucket = MMG_newBucket(mesh,M_MAX(mesh->info.bucksiz,BUCKSIZ));
403 - if ( !bucket ) return(0);
404 -
405 - do {
406 - MMG_analar(mesh,sol,bucket,&na,&nd,&nf,alert);
407 - nna += na;
408 - nnd += nd;
409 - if ( *alert ) {
410 - if ( nd < 1000 ) break;
411 - else *alert = 0;
412 - }
413 - if ( it > 5 ) {
414 - dd = abs(nd-na);
415 - if ( dd < 5 || dd < 0.05*nd ) break;
416 - else if ( it > 12 && nd >= na ) break;
417 - }
418 - if ( na+nd && abs(mesh->info.imprim) > 3 )
419 - fprintf(stdout," %7d INSERTED %7d REMOVED %7d FILTERED\n",na,nd,nf);
420 - // MMG_saveMesh(mesh,"chk.mesh");
421 - // //if(it==1) exit(0);
422 - }
423 - while ( na+nd > 0 && ++it < maxtou );
424 -
425 - if ( nna+nnd && abs(mesh->info.imprim) < 3 ) {
426 - fprintf(stdout," %7d INSERTED %7d REMOVED %7d FILTERED\n",na,nd,nf);
427 - }
428 -
429 - if(MMG_npdtot>0) {
430 - fprintf(stdout," REJECTED : %5d\n",MMG_npdtot);
431 - fprintf(stdout," VOL : %6.2f %% %5d \n",
432 - 100*(MMG_nvoltot/(float)
433 - MMG_npdtot),MMG_nvoltot);
434 - fprintf(stdout," PUISS : %6.2f %% %5d \n",
435 - 100*(MMG_npuisstot/(float) MMG_npdtot),MMG_npuisstot);
436 - fprintf(stdout," PROCHE : %6.2f %% %5d \n",
437 - 100*(MMG_nprestot/(float) MMG_npuisstot),MMG_nprestot);
438 + nna = 0;
439 + nnd = 0;
440 + nf = 0;
441 + it = 0;
442 + maxtou = 100;
443 MMG_npdtot=0;
444 MMG_npuisstot=0;
445 + MMG_nprestot=0;
446 MMG_nvoltot=0;
447 - }
448 - if ( mesh->info.imprim < 0 ) {
449 - MMG_outqua(mesh,sol);
450 - MMG_prilen(mesh,sol);
451 - }
452
453 - M_free(bucket->head);
454 - M_free(bucket->link);
455 - M_free(bucket);
456 + /* 2. field points */
457 + if ( mesh->info.imprim < -4 ) {
458 + MMG_prilen(mesh,sol);
459 + fprintf(stdout," -- FIELD POINTS\n");
460 + }
461 +
462 + /* create filter */
463 + bucket = MMG_newBucket(mesh,M_MAX(mesh->info.bucksiz,BUCKSIZ));
464 + if ( !bucket ) return(0);
465 +
466 + do {
467 + MMG_analar(mesh,sol,bucket,&na,&nd,&nf,alert);
468 + nna += na;
469 + nnd += nd;
470 + if ( *alert ) {
471 + if ( nd < 1000 ) break;
472 + else *alert = 0;
473 + }
474 + if ( it > 5 ) {
475 + dd = abs(nd-na);
476 + if ( dd < 5 || dd < 0.05*nd ) break;
477 + else if ( it > 12 && nd >= na ) break;
478 + }
479 + if ( na+nd && abs(mesh->info.imprim) > 3 )
480 + fprintf(stdout," %7d INSERTED %7d REMOVED %7d FILTERED\n",na,nd,nf);
481 + // MMG_saveMesh(mesh,"chk.mesh",0);
482 + // //if(it==1) exit(0);
483 + }
484 + while ( na+nd > 0 && ++it < maxtou );
485 +
486 + if ( nna+nnd && abs(mesh->info.imprim) < 3 ) {
487 + fprintf(stdout," %7d INSERTED %7d REMOVED %7d FILTERED\n",na,nd,nf);
488 + }
489 +
490 + if(MMG_npdtot>0) {
491 + fprintf(stdout," REJECTED : %5d\n",MMG_npdtot);
492 + fprintf(stdout," VOL : %6.2f %% %5d \n",
493 + 100*(MMG_nvoltot/(float)
494 + MMG_npdtot),MMG_nvoltot);
495 + fprintf(stdout," PUISS : %6.2f %% %5d \n",
496 + 100*(MMG_npuisstot/(float) MMG_npdtot),MMG_npuisstot);
497 + fprintf(stdout," PROCHE : %6.2f %% %5d \n",
498 + 100*(MMG_nprestot/(float) MMG_npuisstot),MMG_nprestot);
499 + MMG_npdtot=0;
500 + MMG_npuisstot=0;
501 + MMG_nvoltot=0;
502 + }
503 + if ( mesh->info.imprim < 0 ) {
504 + MMG_outqua(mesh,sol);
505 + MMG_prilen(mesh,sol);
506 + }
507
508 + M_free(bucket->head);
509 + M_free(bucket->link);
510 + M_free(bucket);
511 +
512
513 return(1);
514 }
515 diff -r -u mmg3d4/build/sources/mmg3dConfig.h mmg3d4-new/build/sources/mmg3dConfig.h
516 --- mmg3d4/build/sources/mmg3dConfig.h 2012-12-19 16:05:36.000000000 +0100
517 +++ mmg3d4-new/build/sources/mmg3dConfig.h 2013-01-18 16:32:41.000000000 +0100
518 @@ -2,4 +2,4 @@
519 #define Tutorial_VERSION_MAJOR
520 #define Tutorial_VERSION_MINOR
521
522 -#define USE_SCOTCH
523 +/* #undef USE_SCOTCH */
524 diff -r -u mmg3d4/build/sources/mmg3dlib/mmg3dlib.c mmg3d4-new/build/sources/mmg3dlib/mmg3dlib.c
525 --- mmg3d4/build/sources/mmg3dlib/mmg3dlib.c 2012-12-19 16:06:03.000000000 +0100
526 +++ mmg3d4-new/build/sources/mmg3dlib/mmg3dlib.c 2013-01-18 16:32:41.000000000 +0100
527 @@ -385,7 +385,7 @@
528 if ( !MMG_hashTetra(mesh) ) return(1);
529 if ( !MMG_markBdry(mesh) ) return(1);
530 if (abs(mesh->info.option)==10) {
531 - MMG_saveMesh(mesh,"tetra.mesh");
532 + MMG_saveMesh(mesh,"tetra.mesh",0);
533 return(0);
534 }
535 if ( !sol->np) {
536 @@ -431,7 +431,7 @@
537 if ( abs(info->option) == 9 ) {
538 if(!MMG_mmg3d9(mesh,sol,&alert)) {
539 if ( !MMG_unscaleMesh(mesh,sol) ) return(1);
540 - MMG_saveMesh(mesh,"errormoving.mesh");
541 + MMG_saveMesh(mesh,"errormoving.mesh",0);
542 //MMG_saveSol(mesh,sol,mesh->outf);
543 return(1);
544 }
545 diff -r -u mmg3d4/build/sources/optlen.c mmg3d4-new/build/sources/optlen.c
546 --- mmg3d4/build/sources/optlen.c 2012-12-19 16:05:33.000000000 +0100
547 +++ mmg3d4-new/build/sources/optlen.c 2013-01-18 16:32:41.000000000 +0100
548 @@ -48,7 +48,7 @@
549 #define HQCOEF 0.9
550 #define HCRIT 0.98
551
552 -double MMG_rao(pMesh mesh,int k,int inm);
553 +double MMG_rao(pMesh mesh,int k,FILE* );
554 int MMG_optlen_ani(pMesh mesh,pSol sol,double declic,int base) {
555 pTetra pt,pt1;
556 pPoint ppa,ppb;
557 diff -r -u mmg3d4/build/sources/pattern.c mmg3d4-new/build/sources/pattern.c
558 --- mmg3d4/build/sources/pattern.c 2012-12-19 16:05:33.000000000 +0100
559 +++ mmg3d4-new/build/sources/pattern.c 2013-01-18 18:41:02.000000000 +0100
560 @@ -47,7 +47,7 @@
561
562
563 unsigned char MMG_arfa[3][4] = { {2,0,1,3}, {1,2,0,3}, {0,1,2,3} };
564 -extern int MMG_permar[10][4];
565 +extern int MMG_permar[12][4];
566 extern int MMG_pointar[64][2];
567 extern int ddebug;
568 //insert ip on ia-ib
569 diff -r -u mmg3d4/build/sources/quality.c mmg3d4-new/build/sources/quality.c
570 --- mmg3d4/build/sources/quality.c 2012-12-19 16:05:33.000000000 +0100
571 +++ mmg3d4-new/build/sources/quality.c 2013-01-18 16:32:41.000000000 +0100
572 @@ -46,7 +46,7 @@
573 #include "mesh.h"
574
575
576 -double MMG_rao(pMesh mesh,int k,int inm);
577 +double MMG_rao(pMesh mesh,int k,FILE* inm) ;
578 double MMG_caltetrao(pMesh mesh,pSol sol,int iel) {
579 return(MMG_rao(mesh,iel,0));
580 }
581 diff -r -u mmg3d4/build/sources/ratio.c mmg3d4-new/build/sources/ratio.c
582 --- mmg3d4/build/sources/ratio.c 2012-12-19 16:05:33.000000000 +0100
583 +++ mmg3d4-new/build/sources/ratio.c 2013-01-18 16:32:41.000000000 +0100
584 @@ -365,7 +365,7 @@
585 fprintf(stdout," ELEMENT %d (%d) %d %d %d %d\n",
586 iel,ielreal,pt->v[0],pt->v[1],pt->v[2],pt->v[3]);
587
588 - if ( abs(mesh->info.imprim) < 5 ) return;
589 + if ( abs(mesh->info.imprim) < 5 ) return (1) ;
590
591 fprintf(stdout,"\n HISTOGRAMM\n");
592 for (k=1; k<9; k++) {
593 diff -r -u mmg3d4/build/sources/sproto.h mmg3d4-new/build/sources/sproto.h
594 --- mmg3d4/build/sources/sproto.h 2012-12-19 16:05:36.000000000 +0100
595 +++ mmg3d4-new/build/sources/sproto.h 2013-01-18 16:32:41.000000000 +0100
596 @@ -67,13 +67,13 @@
597 int MMG_inEdge(pHedge ,int *,int *,int *);
598 int MMG_markBdry(pMesh );
599
600 -/* inout */
601 -int MMG_loadMesh(pMesh ,char *);
602 -int MMG_loadSol(pSol ,char *,int );
603 -int MMG_loadVect(pMesh ,char *,int );
604 -int MMG_saveMesh(pMesh ,char *);
605 -int MMG_saveSol(pMesh ,pSol ,char *);
606 -int MMG_saveVect(pMesh ,char *);
607 +/* inout add param F.H. june 2011 (dataff) */
608 +int MMG_loadMesh(pMesh ,char *,void *);
609 +int MMG_loadSol(pSol ,char *,int ,void *);
610 +int MMG_loadVect(pMesh ,char *,int ,void *);
611 +int MMG_saveMesh(pMesh ,char *,void *);
612 +int MMG_saveSol(pMesh ,pSol ,char *,void *);
613 +int MMG_saveVect(pMesh ,char *,void *);
614
615 int MMG_loctet(pMesh ,int ,int ,double *,double *);
616 int MMG_computeMetric(pMesh ,pSol ,int ,double * );
617 diff -r -u mmg3d4/build/sources/swapar.c mmg3d4-new/build/sources/swapar.c
618 --- mmg3d4/build/sources/swapar.c 2012-12-19 16:05:33.000000000 +0100
619 +++ mmg3d4-new/build/sources/swapar.c 2013-01-18 18:43:38.000000000 +0100
620 @@ -1,106 +1,107 @@
621 -/****************************************************************************
622 -Logiciel initial: MMG3D Version 4.0
623 -Co-auteurs : Cecile Dobrzynski et Pascal Frey.
624 -Propriétaires :IPB - UPMC -INRIA.
625 -
626 -Copyright © 2004-2005-2006-2007-2008-2009-2010-2011,
627 -diffusé sous les termes et conditions de la licence publique générale de GNU
628 -Version 3 ou toute version ultérieure.
629 -
630 -Ce fichier est une partie de MMG3D.
631 -MMG3D est un logiciel libre ; vous pouvez le redistribuer et/ou le modifier
632 -suivant les termes de la licence publique générale de GNU
633 -Version 3 ou toute version ultérieure.
634 -MMG3D est distribué dans l'espoir qu'il sera utile, mais SANS
635 -AUCUNE GARANTIE ; sans même garantie de valeur marchande.
636 -Voir la licence publique générale de GNU pour plus de détails.
637 -MMG3D est diffusé en espérant qu’il sera utile,
638 -mais SANS AUCUNE GARANTIE, ni explicite ni implicite,
639 -y compris les garanties de commercialisation ou
640 -d’adaptation dans un but spécifique.
641 -Reportez-vous à la licence publique générale de GNU pour plus de détails.
642 -Vous devez avoir reçu une copie de la licence publique générale de GNU
643 -en même temps que ce document.
644 -Si ce n’est pas le cas, aller voir <http://www.gnu.org/licenses/>.
645 -/****************************************************************************
646 -Initial software: MMG3D Version 4.0
647 -Co-authors: Cecile Dobrzynski et Pascal Frey.
648 -Owners: IPB - UPMC -INRIA.
649 -
650 -Copyright © 2004-2005-2006-2007-2008-2009-2010-2011,
651 -spread under the terms and conditions of the license GNU General Public License
652 -as published Version 3, or (at your option) any later version.
653 -
654 -This file is part of MMG3D
655 -MMG3D is free software; you can redistribute it and/or modify
656 -it under the terms of the GNU General Public License as published by
657 -the Free Software Foundation; either version 3 of the License, or
658 -(at your option) any later version.
659 -MMG3D is distributed in the hope that it will be useful,
660 -but WITHOUT ANY WARRANTY; without even the implied warranty of
661 -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
662 -GNU General Public License for more details.
663 -You should have received a copy of the GNU General Public License
664 -along with MMG3D. If not, see <http://www.gnu.org/licenses/>.
665 -****************************************************************************/
666 -#include "mesh.h"
667 -
668 -int MMG_swapar(pMesh mesh,pSol sol,pQueue q,List *list,int lon,double crit,double declic) {
669 - pTetra pt;
670 - int i,l,jel,ncas,ddebug,iadr;
671 -
672 - MMG_swpptr = 0;
673 - ncas = 0;
674 - if ( !MMG_getnElt(mesh,10) ) return(-1);
675 - if(0 && list->tetra[1]/6==2352) ddebug=1;
676 - else ddebug=0;
677 -
678 - switch(lon) {
679 - case 3:
680 - ncas = MMG_simu32(mesh,sol,list,crit);
681 - break;
682 - case 4:
683 - ncas = MMG_simu44(mesh,sol,list,crit);
684 - break;
685 - case 5:
686 - ncas = MMG_simu56(mesh,sol,list,crit);
687 - break;
688 - case 6:
689 - ncas = MMG_simu68(mesh,sol,list,crit);
690 - break;
691 - case 7:
692 - ncas = MMG_simu710(mesh,sol,list,crit);
693 - break;
694 - default:
695 - return(0);
696 - }
697 - if(ddebug) printf("on fait swap %d\n",ncas);
698 - if ( ncas && MMG_swpptr ) {
699 - if(ddebug) MMG_saveMesh(mesh,"avt.mesh");
700 - for (l=1; l<=lon; l++) {
701 - jel = list->tetra[l]/6;
702 - pt = &mesh->tetra[jel];
703 - if(ddebug) {
704 - printf("tet %d : %d %d %d %d -- %d %d %d %d %d %d\n",jel,pt->v[0],pt->v[1],pt->v[2],pt->v[3],
705 - pt->bdryinfo[0],pt->bdryinfo[1],pt->bdryinfo[2],pt->bdryinfo[3],pt->bdryinfo[4],pt->bdryinfo[5]);
706 -
707 - }
708 - MMG_kiudel(q,jel);
709 - }
710 - lon = MMG_swpptr(mesh,sol,list);
711 - assert(lon);
712 - if(!lon) return(0);
713 -
714 - for (l=1; l<=lon; l++) {
715 - jel = list->tetra[l];
716 - pt = &mesh->tetra[jel];
717 - if ( pt->qual >= declic ) MMG_kiuput(q,jel);
718 - for (i=0; i<4; i++) mesh->point[pt->v[i]].flag = mesh->flag;
719 -
720 - }
721 - if(ddebug) {MMG_saveMesh(mesh,"sw.mesh"); exit(0);}
722 - return(1);
723 - }
724 -
725 - return(0);
726 -}
727 +/****************************************************************************
728 +Logiciel initial: MMG3D Version 4.0
729 +Co-auteurs : Cecile Dobrzynski et Pascal Frey.
730 +Propriétaires :IPB - UPMC -INRIA.
731 +
732 +Copyright © 2004-2005-2006-2007-2008-2009-2010-2011,
733 +diffusé sous les termes et conditions de la licence publique générale de GNU
734 +Version 3 ou toute version ultérieure.
735 +
736 +Ce fichier est une partie de MMG3D.
737 +MMG3D est un logiciel libre ; vous pouvez le redistribuer et/ou le modifier
738 +suivant les termes de la licence publique générale de GNU
739 +Version 3 ou toute version ultérieure.
740 +MMG3D est distribué dans l'espoir qu'il sera utile, mais SANS
741 +AUCUNE GARANTIE ; sans même garantie de valeur marchande.
742 +Voir la licence publique générale de GNU pour plus de détails.
743 +MMG3D est diffusé en espérant qu’il sera utile,
744 +mais SANS AUCUNE GARANTIE, ni explicite ni implicite,
745 +y compris les garanties de commercialisation ou
746 +d’adaptation dans un but spécifique.
747 +Reportez-vous à la licence publique générale de GNU pour plus de détails.
748 +Vous devez avoir reçu une copie de la licence publique générale de GNU
749 +en même temps que ce document.
750 +Si ce n’est pas le cas, aller voir <http://www.gnu.org/licenses/>.
751 +/****************************************************************************
752 +Initial software: MMG3D Version 4.0
753 +Co-authors: Cecile Dobrzynski et Pascal Frey.
754 +Owners: IPB - UPMC -INRIA.
755 +
756 +Copyright © 2004-2005-2006-2007-2008-2009-2010-2011,
757 +spread under the terms and conditions of the license GNU General Public License
758 +as published Version 3, or (at your option) any later version.
759 +
760 +This file is part of MMG3D
761 +MMG3D is free software; you can redistribute it and/or modify
762 +it under the terms of the GNU General Public License as published by
763 +the Free Software Foundation; either version 3 of the License, or
764 +(at your option) any later version.
765 +MMG3D is distributed in the hope that it will be useful,
766 +but WITHOUT ANY WARRANTY; without even the implied warranty of
767 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
768 +GNU General Public License for more details.
769 +You should have received a copy of the GNU General Public License
770 +along with MMG3D. If not, see <http://www.gnu.org/licenses/>.
771 +****************************************************************************/
772 +#include "mesh.h"
773 +
774 +int MMG_swapar(pMesh mesh,pSol sol,pQueue q,List *list,int lon,double crit,double declic) {
775 + pTetra pt;
776 + int i,l,jel,ncas,ddebug,iadr;
777 +
778 + MMG_swpptr = 0;
779 + ncas = 0;
780 + if ( !MMG_getnElt(mesh,10) ) return(-1);
781 + if(0 && list->tetra[1]/6==2352) ddebug=1;
782 + else ddebug=0;
783 +
784 + switch(lon) {
785 + case 3:
786 + ncas = MMG_simu32(mesh,sol,list,crit);
787 + break;
788 + case 4:
789 + ncas = MMG_simu44(mesh,sol,list,crit);
790 + break;
791 + case 5:
792 + ncas = MMG_simu56(mesh,sol,list,crit);
793 + break;
794 + case 6:
795 + ncas = MMG_simu68(mesh,sol,list,crit);
796 + break;
797 + case 7:
798 + ncas = MMG_simu710(mesh,sol,list,crit);
799 + break;
800 + default:
801 + return(0);
802 + }
803 + if(ddebug) printf("on fait swap %d\n",ncas);
804 + if ( ncas && MMG_swpptr ) {
805 + if(ddebug) MMG_saveMesh(mesh,"avt.mesh",0);
806 + for (l=1; l<=lon; l++) {
807 + jel = list->tetra[l]/6;
808 + pt = &mesh->tetra[jel];
809 + if(ddebug) {
810 + printf("tet %d : %d %d %d %d -- %d %d %d %d %d %d\n",jel,pt->v[0],pt->v[1],pt->v[2],pt->v[3],
811 + pt->bdryinfo[0],pt->bdryinfo[1],pt->bdryinfo[2],pt->bdryinfo[3],pt->bdryinfo[4],pt->bdryinfo[5]);
812 +
813 + }
814 + MMG_kiudel(q,jel);
815 + }
816 + lon = MMG_swpptr(mesh,sol,list);
817 + assert(lon);
818 + if(!lon) return(0);
819 +
820 + for (l=1; l<=lon; l++) {
821 + jel = list->tetra[l];
822 + pt = &mesh->tetra[jel];
823 + if ( pt->qual >= declic ) MMG_kiuput(q,jel);
824 + for (i=0; i<4; i++) mesh->point[pt->v[i]].flag = mesh->flag;
825 +
826 + }
827 + if(ddebug) {MMG_saveMesh(mesh,"sw.mesh",0); exit(0);}
828 + return(1);
829 + }
830 +
831 + return(0);
832 +}
833 +
834 diff -u mmg3d4/build/sources/inout.c mmg3d4-ok/build/sources/inout.c
835 --- mmg3d4/build/sources/inout.c 2012-12-19 16:05:32.000000000 +0100
836 +++ mmg3d4-ok/build/sources/inout.c 2013-07-11 11:43:47.000000000 +0200
837 @@ -44,6 +44,7 @@
838 along with MMG3D. If not, see <http://www.gnu.org/licenses/>.
839 ****************************************************************************/
840 #include "mesh.h"
841 +#include "dataff.h"
842
843
844 extern short MMG_imprim;
845 @@ -100,35 +101,467 @@
846 return(out);
847 }
848
849 +
850 +int MMG_loadMeshff(pMesh mesh,char *filename,DataFF *dataff) {
851 +
852 +
853 + Hedge hed,hed2;
854 + pPoint ppt;
855 + pTetra pt;
856 + pTria pt1;
857 + int i,j,k;
858 + int nhex=0, npris=0, netmp=0,nq=0, pp[10] , ned=0, ncor=0;
859 + int p0,p1,p2,p3,p4,p5,p6,ref ;
860 + int data[10],ldata=10;
861 + dataff->get_mesh(dataff,data,10);
862 + mesh->np = data[ff_id_vertex];
863 + ned = data[ff_id_seg];
864 + mesh->nt = data[ff_id_tria];
865 + mesh->ne = data[ff_id_tet];
866 + netmp=mesh->ne;
867 + nhex=data[ff_id_hex];
868 + npris=data[ff_id_prism];
869 + nq=data[ff_id_quad];
870 + ncor= data[ff_id_corner];
871 +
872 + if( nhex || npris) {
873 + printf("mmg3d ff interface , hex or prism NOT SUPPORTED to day (sorry FH) \n");
874 + goto L0;
875 + }
876 +
877 + mesh->ncor = 0;
878 + mesh->ver =1;
879 + if ( abs(mesh->info.option)==10 ) {
880 + fprintf(stdout," -- READING %8d HEXA %8d PRISMS\n",nhex,npris);
881 + if(!mesh->ne) netmp = 0;
882 + mesh->ne += 6*nhex + 3*npris;
883 + }
884 +
885 + if ( abs(mesh->info.imprim) > 5 )
886 + fprintf(stdout," -- READING DATA for ff interface ");
887 +
888 + if ( !mesh->np || !mesh->ne ) {
889 + fprintf(stdout," ** MISSING DATA yy\n");
890 + goto L0; ;
891 + }
892 + if ( !MMG_zaldy(mesh) ) goto L0;
893 +
894 + /* read mesh vertices */
895 + mesh->npfixe = mesh->np;
896 +
897 + for (k=1; k<=mesh->np; k++) {
898 + ppt = &mesh->point[k];
899 + dataff->get_v3(dataff,k,ppt->c,&ppt->ref);
900 + ppt->tag = M_UNUSED;
901 + }
902 +
903 + /* read mesh triangles */
904 + mesh->ntfixe = mesh->nt;
905 +
906 + for (k=1; k<=mesh->nt; k++) {
907 + pt1 = &mesh->tria[k];
908 + dataff->get_elmt(dataff,ff_id_tria,k,pt1->v,&pt1->ref);
909 +
910 + }
911 +
912 +
913 +
914 + /* read mesh quads (option 10)*/
915 + if(abs(mesh->info.option)==10) {
916 + fprintf(stdout," QUADS READING %d\n",nq);
917 + mesh->ntfixe += 4*nq;
918 + for (k=1; k<=nq; k++) {
919 + dataff->get_elmt(dataff, ff_id_quad ,k,pp,&ref);
920 +
921 + pt1 = &mesh->tria[++mesh->nt];
922 + pt1->v[0] = pp[0];
923 + pt1->v[1] = pp[1];
924 + pt1->v[2] = pp[2];
925 + pt1->ref = ref;
926 + pt1 = &mesh->tria[++mesh->nt];
927 + pt1->v[0] = pp[0];
928 + pt1->v[1] = pp[2];
929 + pt1->v[2] = pp[3];
930 + pt1->ref = ref;
931 + pt1 = &mesh->tria[++mesh->nt];
932 + pt1->v[0] = pp[0];
933 + pt1->v[1] = pp[1];
934 + pt1->v[2] = pp[3];
935 + pt1->ref = ref;
936 + pt1 = &mesh->tria[++mesh->nt];
937 + pt1->v[0] = pp[1];
938 + pt1->v[1] = pp[2];
939 + pt1->v[2] = pp[3];
940 + pt1->ref = ref;
941 +
942 + }
943 + }
944 +
945 + /*read and store edges*/
946 + if (ned) {
947 + if ( !MMG_zaldy4(&hed,ned) ) {
948 + if ( mesh->info.ddebug ) fprintf(stdout," ## MEMORY ALLOCATION PROBLEM : EDGES IGNORED\n");
949 + ned = 0;
950 + }
951 + mesh->ned = ned;
952 +
953 + for (k=1; k<=ned; k++) {
954 + dataff->get_elmt(dataff, ff_id_seg ,k,pp,&ref);
955 +
956 + if(MMG_edgePut(&hed,pp[0],pp[1],2)>1) {
957 + fprintf(stdout," ## WARNING DOUBLE EDGE : %d %d\n",pp[0],pp[1]);
958 + }
959 + }
960 + }
961 +
962 + /* read mesh tetrahedra */
963 + mesh->nefixe = mesh->ne;
964 +
965 +
966 + for (k=1; k<=netmp; k++) {
967 + pt = &mesh->tetra[k];
968 + dataff->get_elmt(dataff,ff_id_tet,k,pt->v,&ref);
969 + pt->ref = ref;//0;//ref ;
970 + for(i=0 ; i<4 ; i++)
971 + pt->bdryref[i] = -1;
972 +
973 + if (ned) { int nu1,nu2;
974 + for(i=0 ; i<6 ; i++) {
975 + nu1 = pt->v[MMG_iare[i][0]];
976 + nu2 = pt->v[MMG_iare[i][1]];
977 + pt->bdryinfo[i] = MMG_edgePoint(&hed,nu1,nu2);
978 + }
979 +
980 + } else {
981 + for(i=0 ; i<6 ; i++)
982 + pt->bdryinfo[i] = 0;
983 + }
984 + }
985 + if (ned) M_free(hed.item);
986 +
987 + /*read corners*/
988 + if (ncor) {
989 +
990 + mesh->ncor = ncor;
991 + for (k=1; k<=ncor; k++) {
992 + dataff->get_elmt(dataff,ff_id_corner,k,&ref,0);
993 +
994 + ppt = &mesh->point[ref];
995 + ppt->geom = M_CORNER;
996 + }
997 + }
998 +#ifdef XXXXXXXXXXXXXXX
999 + if ( abs(mesh->info.option)==10 ) {
1000 + if(bin) {
1001 + printf("NOT SUPPORTED\n");
1002 + exit(0);
1003 + }
1004 + if ( !MMG_zaldy4(&hed2,3*npris+6*nhex) ) {
1005 + if ( mesh->info.ddebug ) fprintf(stdout," ## MEMORY ALLOCATION PROBLEM : PRISM IGNORED\n");
1006 + npris = 0;
1007 + nhex = 0;
1008 + }
1009 +
1010 + /*read hexa and transform to tetra*/
1011 + rewind(inm);
1012 + fseek(inm,posnhex,SEEK_SET);
1013 + for (k=1; k<=nhex; k++) {
1014 + fscanf(inm,"%d %d %d %d %d %d %d %d %d",&p0,&p1,&p2,&p3,&p4,&p5,&p6,&p7,&ref);
1015 + //fscanf(inm,"%d %d %d %d %d %d %d %d %d",&p0,&p4,&p2,&p1,&p3,&p5,&p6,&p7,&ref);
1016 + //printf("hex %d : %d %d %d %d %d %d %d %d\n",k,p0,p1,p2,p3,p4,p5,p6,p7);
1017 + MMG_cuthex(mesh,&hed2,netmp+(k-1)*6,p0,p1,p2,p3,p4,p5,p6,p7,ref);
1018 + }
1019 +
1020 + /*read prism and transform to tetra
1021 + ---> compatibility pbs ==> hash edge and switch case*/
1022 + rewind(inm);
1023 + fseek(inm,posnpris,SEEK_SET);
1024 + nimp = 0;
1025 + ne = netmp+6*nhex;
1026 + for (k=1; k<=npris; k++) {
1027 + fscanf(inm,"%d %d %d %d %d %d %d",&p0,&p1,&p2,&p3,&p4,&p5,&ref);
1028 + if(!MMG_cutprism(mesh,&hed2,ne,p0,p1,p2,p3,p4,p5,ref))
1029 + {
1030 + if(mesh->info.imprim < 0 ) fprintf(stdout,"DECOMPOSITION PRISM INVALID \n\n");
1031 + mesh->ne += 5;
1032 + ne += 8;
1033 + nimp++;
1034 + continue;
1035 + }
1036 + ne += 3;
1037 + }
1038 + if(abs(mesh->info.imprim) > 3 )fprintf(stdout," %d INVALID DECOMPOSITION\n\n",nimp);
1039 + }
1040 +#endif
1041 + if ( abs(mesh->info.imprim) > 3 ) {
1042 + fprintf(stdout," NUMBER OF GIVEN VERTICES %8d\n",mesh->npfixe);
1043 + if ( mesh->ntfixe )
1044 + fprintf(stdout," NUMBER OF GIVEN TRIANGLES %8d\n",mesh->ntfixe);
1045 + fprintf(stdout," NUMBER OF GIVEN TETRAHEDRA %8d\n",mesh->nefixe);
1046 + if ( ncor )
1047 + fprintf(stdout," NUMBER OF GIVEN CORNERS %8d\n",ncor);
1048 + if ( ned )
1049 + fprintf(stdout," NUMBER OF GIVEN EDGES %8d\n",ned);
1050 + }
1051 + // MMG_saveMesh(mesh,"XXXXX.mesh",0);
1052 + dataff->mesh=0; // used
1053 + return 1;
1054 +L0:
1055 + dataff->mesh=0;// used
1056 + return 1;
1057 +}
1058 +
1059 +int MMG_loadSolff(pSol sol,char *filename,int npmax,DataFF *dataff) {
1060 +
1061 + double tmp , *dsol ;
1062 + int binch,bdim,iswp;
1063 + int k,i,isol,type,bin,dim,btyp,bpos;
1064 + long posnp;
1065 + char *ptr,data[128],chaine[128];
1066 + if( ! dataff->sol){
1067 + fprintf(stdout," ** MISSING DATA metrix ff \n");
1068 + return(1);
1069 + }
1070 + dsol = dataff->sol;
1071 + dataff->sol=0;// used
1072 +
1073 +
1074 + btyp = (dataff->typesol== 6) ? 3: dataff->typesol ;
1075 + sol->np= dataff->np;
1076 +
1077 + if ( !sol->np ) {
1078 + fprintf(stdout," ** MISSING DATA zz\n");
1079 + return(1);
1080 + }
1081 +
1082 + if ( btyp!= 1 && btyp!=3 ) {
1083 + fprintf(stdout," ** DATA IGNORED (ff) btyp=%d\n",btyp);
1084 + sol->np = 0;
1085 + return(1);
1086 + }
1087 +
1088 + sol->offset = (btyp==1) ? 1 : 6;
1089 +
1090 + if ( abs(MMG_imprim) > 5 )
1091 + fprintf(stdout," -- READING DATA FILE(ff) %s\n",data);
1092 +
1093 + if ( !sol->np ) {
1094 + fprintf(stdout," ** MISSING DATA no metrix \n");
1095 + return(0);
1096 + }
1097 + sol->npfixe = sol->np;
1098 + sol->npmax = npmax;
1099 + if ( !MMG_zaldy3(sol) ) return(0);
1100 +
1101 + /* read mesh solutions */
1102 + sol->npfixe = sol->np;
1103 +
1104 + for (k=1; k<=sol->np; k++) {
1105 + isol = (k-1) * sol->offset + 1;
1106 + for (i=0; i<sol->offset; i++)
1107 + sol->met[isol + i] = *dsol++;
1108 +
1109 + }
1110 +
1111 + if ( abs(MMG_imprim) > 3 )
1112 + fprintf(stdout," NUMBER OF GIVEN DATA %8d\n",sol->npfixe);
1113 +
1114 +
1115 + return(1);
1116 +
1117 +}
1118 +/* load solution (metric) */
1119 +int MMG_loadVectff(pMesh mesh,char *filename,int npmax,DataFF *dataff) {
1120 +
1121 +
1122 + pDispl pd;
1123 + int binch,bdim,iswp;
1124 + int k,i,type,bin,dim,btyp,bpos,iadr;
1125 + long posnp;
1126 + char *ptr,data[128],chaine[128];
1127 + double *fsol = dataff->mov;
1128 + dataff->mov=0;// used
1129 +
1130 + pd = mesh->disp;
1131 + pd->np =mesh->np ;
1132 +
1133 + if ( !pd->np || !fsol ) {
1134 + fprintf(stdout," ** MISSING DATA dep ff %d %p\n",pd->np, fsol);
1135 + return(0);
1136 + }
1137 +
1138 +
1139 + if ( abs(mesh->info.imprim) > 5 )
1140 + fprintf(stdout," -- COPY DATA form ff interface %s\n",data);
1141 +
1142 + /* read mesh solutions */
1143 + for (k=1; k<=pd->np; k++) {
1144 + iadr = (k - 1) * 3 + 1;
1145 +
1146 + for (i=0; i<3; i++) {
1147 + pd->mv[iadr + i] = *fsol++;
1148 + }
1149 + }
1150 +
1151 +
1152 +
1153 + if ( abs(mesh->info.imprim) > 3 )
1154 + fprintf(stdout," NUMBER OF GIVEN DATA %8d\n",pd->np);
1155 + return(1);
1156 +
1157 +
1158 +}
1159 +int MMG_saveMeshff(pMesh mesh,char *filename,DataFF *dataff) {
1160 +
1161 + pPoint ppt;
1162 + pTetra pt;
1163 + pTria pt1;
1164 + int j,k,np,nc,k0;
1165 + int data[10],ldata=10;
1166 + int kn[10];
1167 + np = 0;
1168 + nc = 0;
1169 + // compress vertex ... fist case ...
1170 + for (k=1; k<=mesh->np; k++) {
1171 + ppt = &mesh->point[k];
1172 + if ( ppt->tag & M_UNUSED ) continue;
1173 + ppt->tmp = ++np;
1174 + /* if ( ppt->geom & M_CORNER ) cor[nc++] = ppt->tmp; */
1175 + }
1176 +
1177 + /* seacrch vertex not in tet ???? */
1178 + {
1179 + int kk=0,npp=np;
1180 + for (k=1; k<=mesh->np; k++)
1181 + {
1182 + ppt = &mesh->point[k];
1183 + if ((ppt->tag & M_UNUSED )) ppt->tmp =-2;
1184 + else ppt->tmp =-1;
1185 +
1186 + }
1187 + for ( k=1; k<=mesh->ne; k++)
1188 + {
1189 + pt = &mesh->tetra[k];
1190 + if ( !pt->v[0] ) continue;
1191 + k0++;
1192 + for(j=0;j<4;++j)
1193 + mesh->point[pt->v[j]].tmp=0;
1194 + }
1195 + np=0;
1196 + for (k=1; k<=mesh->np; k++)
1197 + {
1198 + ppt = &mesh->point[k];
1199 +
1200 + if ( ppt->tmp ==0)
1201 + ppt->tmp = ++np;
1202 + else
1203 + {
1204 +
1205 + if (ppt->tmp==-1)
1206 + {
1207 + kk++;
1208 + ppt->tag |= M_UNUSED;
1209 + }
1210 + ppt->tmp=0;
1211 + }
1212 + }
1213 + if(kk) printf(" mmg3d: Strange nb of point %d not in tet is not zero (correct by FH)!\n" , kk);
1214 +
1215 + }
1216 +
1217 + mesh->nt=0;
1218 + if(! MMG_markBdry(mesh))
1219 + mesh->nt=0;
1220 + data[ff_id_vertex]=np ;
1221 + //data[ff_id_seg]=ned ;
1222 + data[ff_id_tria]=mesh->nt ;
1223 + int ne=0;
1224 + for ( k=1; k<=mesh->ne; k++)
1225 + {
1226 + pt = &mesh->tetra[k];
1227 + if ( !pt->v[0] ) continue;
1228 + ne++;
1229 + }
1230 +
1231 + data[ff_id_tet]=ne ;
1232 + printf(" mmg3d: nbp = %d, nb tet %d\n",np,ne);
1233 + //data[ff_id_hex]=nhex;
1234 + //data[ff_id_prism]=npris;
1235 + //data[ff_id_quad]=nq;
1236 + // data[ff_id_corner]=ncor;
1237 +
1238 + dataff->set_mesh(dataff,data,10);
1239 +
1240 +
1241 + for ( k=1; k<=mesh->np; k++)
1242 + {
1243 + ppt = &mesh->point[k];
1244 + if ( ! ppt->tmp ) continue;
1245 + dataff->set_v(dataff, ppt->tmp,ppt->c,ppt->ref);
1246 + }
1247 +
1248 +
1249 + for (k=1; k<=mesh->nt; k++)
1250 + {
1251 + pt1 = &mesh->tria[k];
1252 + for(j=0;j<3;++j)
1253 + kn[j] = mesh->point[pt1->v[j]].tmp;
1254 + dataff->set_elmt(dataff,ff_id_tria,k,kn,pt1->ref);
1255 +
1256 + }
1257 + k0=0;
1258 + for ( k=1; k<=mesh->ne; k++)
1259 + {
1260 +
1261 + pt = &mesh->tetra[k];
1262 + if ( !pt->v[0] ) continue;
1263 + k0++;
1264 + for(j=0;j<4;++j)
1265 + kn[j] = mesh->point[pt->v[j]].tmp;
1266 + dataff->set_elmt(dataff,ff_id_tet,k0,kn,pt->ref);
1267 +
1268 + }
1269 + dataff->end_mesh(dataff);
1270 + return 1;
1271 +}
1272 +int MMG_saveSolff (pMesh mesh,pSol sol,char *filename,DataFF *dataff) {
1273 + return 1;
1274 +}
1275 +/*save the node speed : coornew-coorold/dt*/
1276 +int MMG_saveVectff(pMesh mesh,char *filename,DataFF *dataff) {
1277 + return 1;
1278 +}
1279 /* read mesh data */
1280 -int MMG_loadMesh(pMesh mesh,char *filename) {
1281 +int MMG_loadMesh(pMesh mesh,char *filename,void *dataff) {
1282 FILE* inm;
1283 Hedge hed,hed2;
1284 pPoint ppt;
1285 pTetra pt;
1286 pHexa ph,listhexa;
1287 pTria pt1;
1288 - int k,dim,ref,bin,bpos,i,tmp;
1289 - int *adjahex;
1290 + int k,dim,ref,bin,bpos,i,tmp;
1291 + int *adjahex;
1292 long posnp,posnt,posne,posnhex,posnpris,posncor,posned,posnq;
1293 char *ptr,data[128],chaine[128];
1294 int nhex,npris,netmp,ncor,ned,nq;
1295 - int p0,p1,p2,p3,p4,p5,p6,p7;
1296 - int binch,bdim,iswp,nu1,nu2,nimp,ne,nbado;
1297 - float fc;
1298 - double volhex,volref;
1299 + int p0,p1,p2,p3,p4,p5,p6,p7;
1300 + int binch,bdim,iswp,nu1,nu2,nimp,ne,nbado;
1301 + float fc;
1302 + double volhex,volref;
1303 int iadr,reorient;
1304 -
1305 + if(dataff)
1306 + return MMG_loadMeshff( mesh,filename,(DataFF*) dataff);
1307 +
1308
1309 posnp = posnt = posne = posnhex = posnpris = 0;
1310 netmp = ncor = ned = 0;
1311 bin = 0;
1312 iswp = 0;
1313 - mesh->np = mesh->nt = mesh->ne = mesh->ncor = 0;
1314 + mesh->np = mesh->nt = mesh->ne = mesh->ncor = 0;
1315 npris = nhex = nq = 0;
1316 -
1317 +
1318 strcpy(data,filename);
1319 - ptr = strstr(data,".mesh");
1320 + ptr = strstr(data,".mesh");
1321 if ( !ptr ) {
1322 strcat(data,".meshb");
1323 if( !(inm = fopen(data,"rb")) ) {
1324 @@ -136,8 +569,8 @@
1325 *ptr = '\0';
1326 strcat(data,".mesh");
1327 if( !(inm = fopen(data,"r")) ) {
1328 - fprintf(stderr," ** %s NOT FOUND.\n",data);
1329 - return(0);
1330 + fprintf(stderr," ** %s NOT FOUND.\n",data);
1331 + return(0);
1332 }
1333 } else {
1334 bin = 1;
1335 @@ -147,194 +580,194 @@
1336 ptr = strstr(data,".meshb");
1337 if( !ptr ) {
1338 if( !(inm = fopen(data,"r")) ) {
1339 - fprintf(stderr," ** %s NOT FOUND.\n",data);
1340 - return(0);
1341 - }
1342 + fprintf(stderr," ** %s NOT FOUND.\n",data);
1343 + return(0);
1344 + }
1345 } else {
1346 bin = 1;
1347 if( !(inm = fopen(data,"rb")) ) {
1348 - fprintf(stderr," ** %s NOT FOUND.\n",data);
1349 - return(0);
1350 + fprintf(stderr," ** %s NOT FOUND.\n",data);
1351 + return(0);
1352 }
1353 -
1354 - }
1355 +
1356 + }
1357 }
1358
1359 fprintf(stdout," %%%% %s OPENED\n",data);
1360 if (!bin) {
1361 - strcpy(chaine,"D");
1362 - while(fscanf(inm,"%s",&chaine[0])!=EOF && strncmp(chaine,"End",strlen("End")) ) {
1363 + strcpy(chaine,"D");
1364 + while(fscanf(inm,"%s",&chaine[0])!=EOF && strncmp(chaine,"End",strlen("End")) ) {
1365 if(!strncmp(chaine,"MeshVersionFormatted",strlen("MeshVersionFormatted"))) {
1366 - fscanf(inm,"%d",&mesh->ver);
1367 - continue;
1368 + fscanf(inm,"%d",&mesh->ver);
1369 + continue;
1370 } else if(!strncmp(chaine,"Dimension",strlen("Dimension"))) {
1371 - fscanf(inm,"%d",&dim);
1372 - if(dim!=3) {
1373 - fprintf(stdout,"BAD DIMENSION : %d\n",dim);
1374 - return(0);
1375 - }
1376 - continue;
1377 + fscanf(inm,"%d",&dim);
1378 + if(dim!=3) {
1379 + fprintf(stdout,"BAD DIMENSION : %d\n",dim);
1380 + return(0);
1381 + }
1382 + continue;
1383 } else if(!strncmp(chaine,"Vertices",strlen("Vertices"))) {
1384 - fscanf(inm,"%d",&mesh->np);
1385 - posnp = ftell(inm);
1386 - continue;
1387 + fscanf(inm,"%d",&mesh->np);
1388 + posnp = ftell(inm);
1389 + continue;
1390 } else if(!strncmp(chaine,"Triangles",strlen("Triangles"))) {
1391 - fscanf(inm,"%d",&mesh->nt);
1392 - posnt = ftell(inm);
1393 - continue;
1394 + fscanf(inm,"%d",&mesh->nt);
1395 + posnt = ftell(inm);
1396 + continue;
1397 } else if(!strncmp(chaine,"Tetrahedra",strlen("Tetrahedra"))) {
1398 - fscanf(inm,"%d",&mesh->ne);
1399 - netmp = mesh->ne;
1400 - posne = ftell(inm);
1401 - continue;
1402 - } else if(!strncmp(chaine,"Hexahedra",strlen("Hexahedra"))) {
1403 - assert(abs(mesh->info.option)==10);
1404 - fscanf(inm,"%d",&nhex);
1405 - //nhex=0;
1406 - posnhex = ftell(inm);
1407 - continue;
1408 - } else if(!strncmp(chaine,"Pentahedra",strlen("Pentahedra"))) {
1409 - assert(abs(mesh->info.option)==10);
1410 - fscanf(inm,"%d",&npris);
1411 - //npris=0;
1412 - posnpris = ftell(inm);
1413 - continue;
1414 - } else if(!strncmp(chaine,"Corners",strlen("Corners"))) {
1415 - fscanf(inm,"%d",&ncor);
1416 - posncor = ftell(inm);
1417 - continue;
1418 - } else if(!strncmp(chaine,"Edges",strlen("Edges"))) {
1419 - fscanf(inm,"%d",&ned);
1420 - posned = ftell(inm);
1421 - continue;
1422 - } else if(abs(mesh->info.option)==10 && !strncmp(chaine,"Quadrilaterals",strlen("Quadrilaterals"))) {
1423 - fscanf(inm,"%d",&nq);
1424 - posnq = ftell(inm);
1425 - continue;
1426 - }
1427 - }
1428 + fscanf(inm,"%d",&mesh->ne);
1429 + netmp = mesh->ne;
1430 + posne = ftell(inm);
1431 + continue;
1432 + } else if(!strncmp(chaine,"Hexahedra",strlen("Hexahedra"))) {
1433 + assert(abs(mesh->info.option)==10);
1434 + fscanf(inm,"%d",&nhex);
1435 + //nhex=0;
1436 + posnhex = ftell(inm);
1437 + continue;
1438 + } else if(!strncmp(chaine,"Pentahedra",strlen("Pentahedra"))) {
1439 + assert(abs(mesh->info.option)==10);
1440 + fscanf(inm,"%d",&npris);
1441 + //npris=0;
1442 + posnpris = ftell(inm);
1443 + continue;
1444 + } else if(!strncmp(chaine,"Corners",strlen("Corners"))) {
1445 + fscanf(inm,"%d",&ncor);
1446 + posncor = ftell(inm);
1447 + continue;
1448 + } else if(!strncmp(chaine,"Edges",strlen("Edges"))) {
1449 + fscanf(inm,"%d",&ned);
1450 + posned = ftell(inm);
1451 + continue;
1452 + } else if(abs(mesh->info.option)==10 && !strncmp(chaine,"Quadrilaterals",strlen("Quadrilaterals"))) {
1453 + fscanf(inm,"%d",&nq);
1454 + posnq = ftell(inm);
1455 + continue;
1456 + }
1457 + }
1458 } else {
1459 bdim = 0;
1460 fread(&mesh->ver,sw,1,inm);
1461 - iswp=0;
1462 - if(mesh->ver==16777216)
1463 - iswp=1;
1464 + iswp=0;
1465 + if(mesh->ver==16777216)
1466 + iswp=1;
1467 else if(mesh->ver!=1) {
1468 fprintf(stdout,"BAD FILE ENCODING\n");
1469 - }
1470 - fread(&mesh->ver,sw,1,inm);
1471 - if(iswp) mesh->ver = MMG_swapbin(mesh->ver);
1472 - while(fread(&binch,sw,1,inm)!=0 && binch!=54 ) {
1473 - if(iswp) binch=MMG_swapbin(binch);
1474 - if(binch==54) break;
1475 + }
1476 + fread(&mesh->ver,sw,1,inm);
1477 + if(iswp) mesh->ver = MMG_swapbin(mesh->ver);
1478 + while(fread(&binch,sw,1,inm)!=0 && binch!=54 ) {
1479 + if(iswp) binch=MMG_swapbin(binch);
1480 + if(binch==54) break;
1481 if(!bdim && binch==3) { //Dimension
1482 - fread(&bdim,sw,1,inm); //NulPos=>20
1483 - if(iswp) bdim=MMG_swapbin(bdim);
1484 - fread(&bdim,sw,1,inm);
1485 - if(iswp) bdim=MMG_swapbin(bdim);
1486 - if(bdim!=3) {
1487 - fprintf(stdout,"BAD SOL DIMENSION : %d\n",dim);
1488 - exit(0);
1489 - return(1);
1490 - }
1491 - continue;
1492 + fread(&bdim,sw,1,inm); //NulPos=>20
1493 + if(iswp) bdim=MMG_swapbin(bdim);
1494 + fread(&bdim,sw,1,inm);
1495 + if(iswp) bdim=MMG_swapbin(bdim);
1496 + if(bdim!=3) {
1497 + fprintf(stdout,"BAD SOL DIMENSION : %d\n",dim);
1498 + exit(0);
1499 + return(1);
1500 + }
1501 + continue;
1502 } else if(!mesh->np && binch==4) { //Vertices
1503 - fread(&bpos,sw,1,inm); //NulPos
1504 - if(iswp) bpos=MMG_swapbin(bpos);
1505 - fread(&mesh->np,sw,1,inm);
1506 - if(iswp) mesh->np=MMG_swapbin(mesh->np);
1507 - posnp = ftell(inm);
1508 - rewind(inm);
1509 - fseek(inm,bpos,SEEK_SET);
1510 - continue;
1511 + fread(&bpos,sw,1,inm); //NulPos
1512 + if(iswp) bpos=MMG_swapbin(bpos);
1513 + fread(&mesh->np,sw,1,inm);
1514 + if(iswp) mesh->np=MMG_swapbin(mesh->np);
1515 + posnp = ftell(inm);
1516 + rewind(inm);
1517 + fseek(inm,bpos,SEEK_SET);
1518 + continue;
1519 } else if(!mesh->nt && binch==6) {//Triangles
1520 - fread(&bpos,sw,1,inm); //NulPos
1521 - if(iswp) bpos=MMG_swapbin(bpos);
1522 - fread(&mesh->nt,sw,1,inm);
1523 - if(iswp) mesh->nt=MMG_swapbin(mesh->nt);
1524 - posnt = ftell(inm);
1525 - rewind(inm);
1526 - fseek(inm,bpos,SEEK_SET);
1527 - continue;
1528 - } else if(!mesh->ne && binch==8) {
1529 - fread(&bpos,sw,1,inm); //NulPos
1530 - if(iswp) bpos=MMG_swapbin(bpos);
1531 - fread(&mesh->ne,sw,1,inm);
1532 - if(iswp) mesh->ne=MMG_swapbin(mesh->ne);
1533 - netmp = mesh->ne;
1534 - posne = ftell(inm);
1535 - rewind(inm);
1536 - fseek(inm,bpos,SEEK_SET);
1537 - continue;
1538 - } else if(!nhex && binch==10) {
1539 - assert(abs(mesh->info.option)==10);
1540 - fread(&bpos,sw,1,inm); //NulPos
1541 - if(iswp) bpos=MMG_swapbin(bpos);
1542 - fread(&nhex,sw,1,inm);
1543 - if(iswp) nhex=MMG_swapbin(nhex);
1544 - posnhex = ftell(inm);
1545 - rewind(inm);
1546 - fseek(inm,bpos,SEEK_SET);
1547 - continue;
1548 - } else if(!npris && binch==9) {
1549 - assert(abs(mesh->info.option)==10);
1550 - fread(&bpos,sw,1,inm); //NulPos
1551 - if(iswp) bpos=MMG_swapbin(bpos);
1552 - fread(&npris,sw,1,inm);
1553 - if(iswp) npris=MMG_swapbin(npris);
1554 - posnpris = ftell(inm);
1555 - rewind(inm);
1556 - fseek(inm,bpos,SEEK_SET);
1557 - continue;
1558 - } else if(!ncor && binch==13) {
1559 - fread(&bpos,sw,1,inm); //NulPos
1560 - if(iswp) bpos=MMG_swapbin(bpos);
1561 - fread(&ncor,sw,1,inm);
1562 - if(iswp) ncor=MMG_swapbin(ncor);
1563 - posncor = ftell(inm);
1564 - rewind(inm);
1565 - fseek(inm,bpos,SEEK_SET);
1566 - continue;
1567 - } else if(!ned && binch==5) { //Edges
1568 - fread(&bpos,sw,1,inm); //NulPos
1569 - if(iswp) bpos=MMG_swapbin(bpos);
1570 - fread(&ned,sw,1,inm);
1571 - if(iswp) ned=MMG_swapbin(ned);
1572 - posned = ftell(inm);
1573 - rewind(inm);
1574 - fseek(inm,bpos,SEEK_SET);
1575 - continue;
1576 - } else {
1577 - //printf("on traite ? %d\n",binch);
1578 - fread(&bpos,sw,1,inm); //NulPos
1579 - if(iswp) bpos=MMG_swapbin(bpos);
1580 - //printf("on avance... Nulpos %d\n",bpos);
1581 - rewind(inm);
1582 - fseek(inm,bpos,SEEK_SET);
1583 - }
1584 - }
1585 -
1586 + fread(&bpos,sw,1,inm); //NulPos
1587 + if(iswp) bpos=MMG_swapbin(bpos);
1588 + fread(&mesh->nt,sw,1,inm);
1589 + if(iswp) mesh->nt=MMG_swapbin(mesh->nt);
1590 + posnt = ftell(inm);
1591 + rewind(inm);
1592 + fseek(inm,bpos,SEEK_SET);
1593 + continue;
1594 + } else if(!mesh->ne && binch==8) {
1595 + fread(&bpos,sw,1,inm); //NulPos
1596 + if(iswp) bpos=MMG_swapbin(bpos);
1597 + fread(&mesh->ne,sw,1,inm);
1598 + if(iswp) mesh->ne=MMG_swapbin(mesh->ne);
1599 + netmp = mesh->ne;
1600 + posne = ftell(inm);
1601 + rewind(inm);
1602 + fseek(inm,bpos,SEEK_SET);
1603 + continue;
1604 + } else if(!nhex && binch==10) {
1605 + assert(abs(mesh->info.option)==10);
1606 + fread(&bpos,sw,1,inm); //NulPos
1607 + if(iswp) bpos=MMG_swapbin(bpos);
1608 + fread(&nhex,sw,1,inm);
1609 + if(iswp) nhex=MMG_swapbin(nhex);
1610 + posnhex = ftell(inm);
1611 + rewind(inm);
1612 + fseek(inm,bpos,SEEK_SET);
1613 + continue;
1614 + } else if(!npris && binch==9) {
1615 + assert(abs(mesh->info.option)==10);
1616 + fread(&bpos,sw,1,inm); //NulPos
1617 + if(iswp) bpos=MMG_swapbin(bpos);
1618 + fread(&npris,sw,1,inm);
1619 + if(iswp) npris=MMG_swapbin(npris);
1620 + posnpris = ftell(inm);
1621 + rewind(inm);
1622 + fseek(inm,bpos,SEEK_SET);
1623 + continue;
1624 + } else if(!ncor && binch==13) {
1625 + fread(&bpos,sw,1,inm); //NulPos
1626 + if(iswp) bpos=MMG_swapbin(bpos);
1627 + fread(&ncor,sw,1,inm);
1628 + if(iswp) ncor=MMG_swapbin(ncor);
1629 + posncor = ftell(inm);
1630 + rewind(inm);
1631 + fseek(inm,bpos,SEEK_SET);
1632 + continue;
1633 + } else if(!ned && binch==5) { //Edges
1634 + fread(&bpos,sw,1,inm); //NulPos
1635 + if(iswp) bpos=MMG_swapbin(bpos);
1636 + fread(&ned,sw,1,inm);
1637 + if(iswp) ned=MMG_swapbin(ned);
1638 + posned = ftell(inm);
1639 + rewind(inm);
1640 + fseek(inm,bpos,SEEK_SET);
1641 + continue;
1642 + } else {
1643 + //printf("on traite ? %d\n",binch);
1644 + fread(&bpos,sw,1,inm); //NulPos
1645 + if(iswp) bpos=MMG_swapbin(bpos);
1646 + //printf("on avance... Nulpos %d\n",bpos);
1647 + rewind(inm);
1648 + fseek(inm,bpos,SEEK_SET);
1649 + }
1650 + }
1651 +
1652 }
1653
1654 if ( abs(mesh->info.option)==10 ) {
1655 - fprintf(stdout," -- READING %8d HEXA %8d PRISMS\n",nhex,npris);
1656 - if(!mesh->ne) netmp = 0;
1657 - mesh->ne += 6*nhex + 3*npris;
1658 + fprintf(stdout," -- READING %8d HEXA %8d PRISMS\n",nhex,npris);
1659 + if(!mesh->ne) netmp = 0;
1660 + mesh->ne += 6*nhex + 3*npris;
1661 }
1662
1663 if ( abs(mesh->info.imprim) > 5 )
1664 fprintf(stdout," -- READING DATA FILE %s\n",data);
1665
1666 if ( !mesh->np || !mesh->ne ) {
1667 - fprintf(stdout," ** MISSING DATA\n");
1668 + fprintf(stdout," ** MISSING DAT qqA\n");
1669 return(0);
1670 }
1671 - if(abs(mesh->info.option)==10) { //allocation
1672 + if(abs(mesh->info.option)==10) { //allocation
1673 listhexa = (pHexa)M_calloc(nhex+1,sizeof(Hexa),"allochexa");
1674 - assert(listhexa);
1675 - adjahex = (int*)M_calloc(6*nhex+7,sizeof(int),"allocadjhexa");
1676 - assert(adjahex);
1677 - }
1678 + assert(listhexa);
1679 + adjahex = (int*)M_calloc(6*nhex+7,sizeof(int),"allocadjhexa");
1680 + assert(adjahex);
1681 + }
1682 if ( !MMG_zaldy(mesh) ) return(0);
1683 /* read mesh vertices */
1684 mesh->npfixe = mesh->np;
1685 @@ -342,35 +775,35 @@
1686 fseek(inm,posnp,SEEK_SET);
1687 for (k=1; k<=mesh->np; k++) {
1688 ppt = &mesh->point[k];
1689 - if (mesh->ver < 2) { /*float*/
1690 + if (mesh->ver < 2) { /*float*/
1691 if (!bin) {
1692 - for (i=0 ; i<3 ; i++) {
1693 - fscanf(inm,"%f",&fc);
1694 - ppt->c[i] = (double) fc;
1695 - }
1696 - fscanf(inm,"%d",&ppt->ref);
1697 + for (i=0 ; i<3 ; i++) {
1698 + fscanf(inm,"%f",&fc);
1699 + ppt->c[i] = (double) fc;
1700 + }
1701 + fscanf(inm,"%d",&ppt->ref);
1702 } else {
1703 - for (i=0 ; i<3 ; i++) {
1704 - fread(&fc,sw,1,inm);
1705 - if(iswp) fc=MMG_swapf(fc);
1706 - ppt->c[i] = (double) fc;
1707 - }
1708 - fread(&ppt->ref,sw,1,inm);
1709 - if(iswp) ppt->ref=MMG_swapbin(ppt->ref);
1710 + for (i=0 ; i<3 ; i++) {
1711 + fread(&fc,sw,1,inm);
1712 + if(iswp) fc=MMG_swapf(fc);
1713 + ppt->c[i] = (double) fc;
1714 + }
1715 + fread(&ppt->ref,sw,1,inm);
1716 + if(iswp) ppt->ref=MMG_swapbin(ppt->ref);
1717 }
1718 } else {
1719 - if (!bin)
1720 - fscanf(inm,"%lf %lf %lf %d",&ppt->c[0],&ppt->c[1],&ppt->c[2],&ppt->ref);
1721 + if (!bin)
1722 + fscanf(inm,"%lf %lf %lf %d",&ppt->c[0],&ppt->c[1],&ppt->c[2],&ppt->ref);
1723 else {
1724 - for (i=0 ; i<3 ; i++) {
1725 - fread(&ppt->c[i],sd,1,inm);
1726 - if(iswp) ppt->c[i]=MMG_swapd(ppt->c[i]);
1727 - }
1728 - fread(&ppt->ref,sw,1,inm);
1729 - if(iswp) ppt->ref=MMG_swapbin(ppt->ref);
1730 - }
1731 - }
1732 - ppt->tag = M_UNUSED;
1733 + for (i=0 ; i<3 ; i++) {
1734 + fread(&ppt->c[i],sd,1,inm);
1735 + if(iswp) ppt->c[i]=MMG_swapd(ppt->c[i]);
1736 + }
1737 + fread(&ppt->ref,sw,1,inm);
1738 + if(iswp) ppt->ref=MMG_swapbin(ppt->ref);
1739 + }
1740 + }
1741 + ppt->tag = M_UNUSED;
1742 }
1743
1744 /* read mesh triangles */
1745 @@ -378,227 +811,226 @@
1746 rewind(inm);
1747 fseek(inm,posnt,SEEK_SET);
1748 for (k=1; k<=mesh->nt; k++) {
1749 - pt1 = &mesh->tria[k];
1750 + pt1 = &mesh->tria[k];
1751 if (!bin)
1752 fscanf(inm,"%d %d %d %d",&pt1->v[0],&pt1->v[1],&pt1->v[2],&pt1->ref);
1753 else {
1754 - for (i=0 ; i<3 ; i++) {
1755 - fread(&pt1->v[i],sw,1,inm);
1756 - if(iswp) pt1->v[i]=MMG_swapbin(pt1->v[i]);
1757 - }
1758 - fread(&pt1->ref,sw,1,inm);
1759 - if(iswp) pt1->ref=MMG_swapbin(pt1->ref);
1760 - }
1761 - }
1762 - /* read mesh quads (option 10)*/
1763 - if(abs(mesh->info.option)==10) {
1764 - fprintf(stdout," QUADS READING %d\n",nq);
1765 + for (i=0 ; i<3 ; i++) {
1766 + fread(&pt1->v[i],sw,1,inm);
1767 + if(iswp) pt1->v[i]=MMG_swapbin(pt1->v[i]);
1768 + }
1769 + fread(&pt1->ref,sw,1,inm);
1770 + if(iswp) pt1->ref=MMG_swapbin(pt1->ref);
1771 + }
1772 + }
1773 + /* read mesh quads (option 10)*/
1774 + if(abs(mesh->info.option)==10) {
1775 + fprintf(stdout," QUADS READING %d\n",nq);
1776 mesh->ntfixe += 4*nq;
1777
1778 rewind(inm);
1779 fseek(inm,posnq,SEEK_SET);
1780 for (k=1; k<=nq; k++) {
1781 if (!bin)
1782 - fscanf(inm,"%d %d %d %d %d",&p0,&p1,&p2,&p3,&ref);
1783 + fscanf(inm,"%d %d %d %d %d",&p0,&p1,&p2,&p3,&ref);
1784 else {
1785 - fread(&p0,sw,1,inm);
1786 - if(iswp) p0=MMG_swapbin(p0);
1787 - fread(&p1,sw,1,inm);
1788 - if(iswp) p1=MMG_swapbin(p1);
1789 - fread(&p2,sw,1,inm);
1790 - if(iswp) p2=MMG_swapbin(p2);
1791 - fread(&p3,sw,1,inm);
1792 - if(iswp) p3=MMG_swapbin(p3);
1793 - fread(&pt1->ref,sw,1,inm);
1794 - if(iswp) ref=MMG_swapbin(ref);
1795 - }
1796 + fread(&p0,sw,1,inm);
1797 + if(iswp) p0=MMG_swapbin(p0);
1798 + fread(&p1,sw,1,inm);
1799 + if(iswp) p1=MMG_swapbin(p1);
1800 + fread(&p2,sw,1,inm);
1801 + if(iswp) p2=MMG_swapbin(p2);
1802 + fread(&p3,sw,1,inm);
1803 + if(iswp) p3=MMG_swapbin(p3);
1804 + fread(&pt1->ref,sw,1,inm);
1805 + if(iswp) ref=MMG_swapbin(ref);
1806 + }
1807 /*creation of 4 triangles per quads because we don't know how hexa will be cut*/
1808 - pt1 = &mesh->tria[++mesh->nt];
1809 - pt1->v[0] = p0;
1810 - pt1->v[1] = p1;
1811 - pt1->v[2] = p2;
1812 - pt1->ref = ref;
1813 - pt1 = &mesh->tria[++mesh->nt];
1814 - pt1->v[0] = p0;
1815 - pt1->v[1] = p2;
1816 - pt1->v[2] = p3;
1817 - pt1->ref = ref;
1818 - pt1 = &mesh->tria[++mesh->nt];
1819 - pt1->v[0] = p0;
1820 - pt1->v[1] = p1;
1821 - pt1->v[2] = p3;
1822 - pt1->ref = ref;
1823 - pt1 = &mesh->tria[++mesh->nt];
1824 - pt1->v[0] = p1;
1825 - pt1->v[1] = p2;
1826 - pt1->v[2] = p3;
1827 - pt1->ref = ref;
1828 -
1829 - }
1830 - }
1831 - /*read and store edges*/
1832 - if (ned) {
1833 - if ( !MMG_zaldy4(&hed,ned) ) {
1834 - if ( mesh->info.ddebug ) fprintf(stdout," ## MEMORY ALLOCATION PROBLEM : EDGES IGNORED\n");
1835 - ned = 0;
1836 - }
1837 - mesh->ned = ned;
1838 + pt1 = &mesh->tria[++mesh->nt];
1839 + pt1->v[0] = p0;
1840 + pt1->v[1] = p1;
1841 + pt1->v[2] = p2;
1842 + pt1->ref = ref;
1843 + pt1 = &mesh->tria[++mesh->nt];
1844 + pt1->v[0] = p0;
1845 + pt1->v[1] = p2;
1846 + pt1->v[2] = p3;
1847 + pt1->ref = ref;
1848 + pt1 = &mesh->tria[++mesh->nt];
1849 + pt1->v[0] = p0;
1850 + pt1->v[1] = p1;
1851 + pt1->v[2] = p3;
1852 + pt1->ref = ref;
1853 + pt1 = &mesh->tria[++mesh->nt];
1854 + pt1->v[0] = p1;
1855 + pt1->v[1] = p2;
1856 + pt1->v[2] = p3;
1857 + pt1->ref = ref;
1858 +
1859 + }
1860 + }
1861 + /*read and store edges*/
1862 + if (ned) {
1863 + if ( !MMG_zaldy4(&hed,ned) ) {
1864 + if ( mesh->info.ddebug ) fprintf(stdout," ## MEMORY ALLOCATION PROBLEM : EDGES IGNORED\n");
1865 + ned = 0;
1866 + }
1867 + mesh->ned = ned;
1868 rewind(inm);
1869 - fseek(inm,posned,SEEK_SET);
1870 - for (k=1; k<=ned; k++) {
1871 + fseek(inm,posned,SEEK_SET);
1872 + for (k=1; k<=ned; k++) {
1873 if (!bin)
1874 - fscanf(inm,"%d %d %d",&nu1,&nu2,&ref);
1875 + fscanf(inm,"%d %d %d",&nu1,&nu2,&ref);
1876 else {
1877 - fread(&nu1,sw,1,inm);
1878 - if(iswp) nu1=MMG_swapbin(nu1);
1879 - fread(&nu2,sw,1,inm);
1880 - if(iswp) nu2=MMG_swapbin(nu2);
1881 - fread(&ref,sw,1,inm);
1882 - if(iswp) ref=MMG_swapbin(ref);
1883 - }
1884 - if(MMG_edgePut(&hed,nu1,nu2,2)>1) {
1885 - fprintf(stdout," ## WARNING DOUBLE EDGE : %d %d\n",nu1,nu2);
1886 - }
1887 - mesh->point[nu1].geom = M_RIDGE_GEO;
1888 - mesh->point[nu2].geom = M_RIDGE_GEO;
1889 + fread(&nu1,sw,1,inm);
1890 + if(iswp) nu1=MMG_swapbin(nu1);
1891 + fread(&nu2,sw,1,inm);
1892 + if(iswp) nu2=MMG_swapbin(nu2);
1893 + fread(&ref,sw,1,inm);
1894 + if(iswp) ref=MMG_swapbin(ref);
1895 + }
1896 + if(MMG_edgePut(&hed,nu1,nu2,2)>1) {
1897 + fprintf(stdout," ## WARNING DOUBLE EDGE : %d %d\n",nu1,nu2);
1898 + }
1899 + mesh->point[nu1].geom = M_RIDGE_GEO;
1900 + mesh->point[nu2].geom = M_RIDGE_GEO;
1901 }
1902 }
1903
1904 /* read mesh tetrahedra */
1905 mesh->nefixe = mesh->ne;
1906 rewind(inm);
1907 - fseek(inm,posne,SEEK_SET);
1908 - reorient = 0;
1909 - for (k=1; k<=netmp; k++) {
1910 + fseek(inm,posne,SEEK_SET);
1911 + reorient = 0;
1912 + for (k=1; k<=netmp; k++) {
1913 pt = &mesh->tetra[k];
1914 - if (!bin)
1915 - fscanf(inm,"%d %d %d %d %d",&pt->v[0],&pt->v[1],&pt->v[2],&pt->v[3],&ref);
1916 - else {
1917 -
1918 - for (i=0 ; i<4 ; i++) {
1919 - fread(&pt->v[i],sw,1,inm);
1920 - if(iswp) pt->v[i]=MMG_swapbin(pt->v[i]);
1921 - }
1922 - fread(&ref,sw,1,inm);
1923 - if(iswp) ref=MMG_swapbin(ref);
1924 - }
1925 + if (!bin)
1926 + fscanf(inm,"%d %d %d %d %d",&pt->v[0],&pt->v[1],&pt->v[2],&pt->v[3],&ref);
1927 + else {
1928 +
1929 + for (i=0 ; i<4 ; i++) {
1930 + fread(&pt->v[i],sw,1,inm);
1931 + if(iswp) pt->v[i]=MMG_swapbin(pt->v[i]);
1932 + }
1933 + fread(&ref,sw,1,inm);
1934 + if(iswp) ref=MMG_swapbin(ref);
1935 + }
1936 pt->ref = ref;//0;//ref ;
1937
1938 /*check orientation*/
1939 - volref = MMG_voltet(mesh,k);
1940 - if(volref < 0) {
1941 - reorient++;
1942 - tmp = pt->v[2];
1943 - pt->v[2] = pt->v[3];
1944 - pt->v[3] = tmp;
1945 - }
1946 -
1947 + volref = MMG_voltet(mesh,k);
1948 + if(volref < 0) {
1949 + if(!reorient) {
1950 + fprintf(stdout,"\n $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ \n");
1951 + fprintf(stdout," BAD ORIENTATION : vol < 0 -- Some tetra will be reoriented\n");
1952 + fprintf(stdout," $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ \n\n");
1953 + reorient = 1;
1954 + }
1955 + tmp = pt->v[2];
1956 + pt->v[2] = pt->v[3];
1957 + pt->v[3] = tmp;
1958 + }
1959 +
1960 for(i=0 ; i<4 ; i++)
1961 - pt->bdryref[i] = -1;
1962 -
1963 - if (ned) {
1964 - for(i=0 ; i<6 ; i++) {
1965 - nu1 = pt->v[MMG_iare[i][0]];
1966 - nu2 = pt->v[MMG_iare[i][1]];
1967 - pt->bdryinfo[i] = MMG_edgePoint(&hed,nu1,nu2);
1968 - }
1969 -
1970 - } else {
1971 - for(i=0 ; i<6 ; i++)
1972 - pt->bdryinfo[i] = 0;
1973 - }
1974 + pt->bdryref[i] = -1;
1975 +
1976 + if (ned) {
1977 + for(i=0 ; i<6 ; i++) {
1978 + nu1 = pt->v[MMG_iare[i][0]];
1979 + nu2 = pt->v[MMG_iare[i][1]];
1980 + pt->bdryinfo[i] = MMG_edgePoint(&hed,nu1,nu2);
1981 + }
1982 +
1983 + } else {
1984 + for(i=0 ; i<6 ; i++)
1985 + pt->bdryinfo[i] = 0;
1986 + }
1987 }
1988 - if(reorient) {
1989 - fprintf(stdout,"\n $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ \n");
1990 - fprintf(stdout," BAD ORIENTATION : vol < 0 -- %8d tetra reoriented\n",reorient);
1991 - fprintf(stdout," $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ \n\n");
1992 - reorient = 1;
1993 - }
1994 - if (ned) M_free(hed.item);
1995 + if (ned) M_free(hed.item);
1996
1997 - /*read corners*/
1998 + /*read corners*/
1999 if (ncor) {
2000 rewind(inm);
2001 - fseek(inm,posncor,SEEK_SET);
2002 + fseek(inm,posncor,SEEK_SET);
2003 mesh->ncor = ncor;
2004 - for (k=1; k<=ncor; k++) {
2005 + for (k=1; k<=ncor; k++) {
2006 if (!bin)
2007 - fscanf(inm,"%d",&ref);
2008 + fscanf(inm,"%d",&ref);
2009 else {
2010 - fread(&ref,sw,1,inm);
2011 - if(iswp) ref=MMG_swapbin(ref);
2012 - }
2013 + fread(&ref,sw,1,inm);
2014 + if(iswp) ref=MMG_swapbin(ref);
2015 + }
2016 ppt = &mesh->point[ref];
2017 - ppt->geom = M_CORNER;
2018 - }
2019 + ppt->geom = M_CORNER;
2020 + }
2021 }
2022 -
2023 -
2024 - if ( abs(mesh->info.option)==10 ) {
2025 +
2026 +
2027 + if ( abs(mesh->info.option)==10 ) {
2028 if(bin) {
2029 printf("NOT SUPPORTED\n");
2030 exit(0);
2031 - }
2032 - if ( !MMG_zaldy4(&hed2,3*npris+6*nhex) ) {
2033 - if ( mesh->info.ddebug ) fprintf(stdout," ## MEMORY ALLOCATION PROBLEM : PRISM IGNORED\n");
2034 - npris = 0;
2035 - nhex = 0;
2036 - }
2037 + }
2038 + if ( !MMG_zaldy4(&hed2,3*npris+6*nhex) ) {
2039 + if ( mesh->info.ddebug ) fprintf(stdout," ## MEMORY ALLOCATION PROBLEM : PRISM IGNORED\n");
2040 + npris = 0;
2041 + nhex = 0;
2042 + }
2043
2044 /*read hexa and transform to tetra*/
2045 rewind(inm);
2046 - fseek(inm,posnhex,SEEK_SET);
2047 - nbado = 0;
2048 + fseek(inm,posnhex,SEEK_SET);
2049 + nbado = 0;
2050 for (k=1; k<=nhex; k++) {
2051 - ph = &listhexa[k];
2052 - fscanf(inm,"%d %d %d %d %d %d %d %d %d",&ph->v[0],&ph->v[1],&ph->v[2],&ph->v[3],&ph->v[4],&ph->v[5],&ph->v[6],&ph->v[7],&ph->ref);
2053 - //fscanf(inm,"%d %d %d %d %d %d %d %d %d",&p0,&p4,&p2,&p1,&p3,&p5,&p6,&p7,&ref);
2054 - //printf("hex %d : %d %d %d %d %d %d %d %d\n",k,p0,p1,p2,p3,p4,p5,p6,p7);
2055 + ph = &listhexa[k];
2056 + fscanf(inm,"%d %d %d %d %d %d %d %d %d",&ph->v[0],&ph->v[1],&ph->v[2],&ph->v[3],&ph->v[4],&ph->v[5],&ph->v[6],&ph->v[7],&ph->ref);
2057 + //fscanf(inm,"%d %d %d %d %d %d %d %d %d",&p0,&p4,&p2,&p1,&p3,&p5,&p6,&p7,&ref);
2058 + //printf("hex %d : %d %d %d %d %d %d %d %d\n",k,p0,p1,p2,p3,p4,p5,p6,p7);
2059 //check orientability of the hexahedra : vol of tet p0 p1 p3 p4
2060 - volhex = MMG_quickvol(mesh->point[ph->v[0]].c,mesh->point[ph->v[1]].c,mesh->point[ph->v[2]].c,mesh->point[ph->v[3]].c);
2061 - if(k==1) {
2062 - volref = volhex;
2063 - //printf("vol %e\n",volref);
2064 - }
2065 - else {
2066 - if(volref*volhex < 0) {
2067 - fprintf(stdout,"BAD ORIENTATION OF HEXAHEDRON %d : %d %d %d %d %d %d %d %d\n",k,p0,p1,p2,p3,p4,p5,p6,p7);
2068 - nbado++;
2069 - tmp = ph->v[3];
2070 - ph->v[3] = ph->v[1];
2071 - ph->v[1] = tmp;
2072 - tmp = ph->v[5];
2073 - ph->v[5] = ph->v[7];
2074 - ph->v[7] = tmp;
2075 - }
2076 - }
2077 - // MMG_cuthex(mesh,&hed2,netmp+(k-1)*6,ph->v[0],ph->v[1],ph->v[2],ph->v[3],ph->v[4],ph->v[5],ph->v[6],ph->v[7],ph->ref);
2078 - }
2079 - fprintf(stdout,"%8d HEXA REORIENTED\n",nbado);
2080 + volhex = MMG_quickvol(mesh->point[ph->v[0]].c,mesh->point[ph->v[1]].c,mesh->point[ph->v[2]].c,mesh->point[ph->v[3]].c);
2081 + if(k==1) {
2082 + volref = volhex;
2083 + //printf("vol %e\n",volref);
2084 + }
2085 + else {
2086 + if(volref*volhex < 0) {
2087 + fprintf(stdout,"BAD ORIENTATION OF HEXAHEDRON %d : %d %d %d %d %d %d %d %d\n",k,p0,p1,p2,p3,p4,p5,p6,p7);
2088 + nbado++;
2089 + tmp = ph->v[3];
2090 + ph->v[3] = ph->v[1];
2091 + ph->v[1] = tmp;
2092 + tmp = ph->v[5];
2093 + ph->v[5] = ph->v[7];
2094 + ph->v[7] = tmp;
2095 + }
2096 + }
2097 + // MMG_cuthex(mesh,&hed2,netmp+(k-1)*6,ph->v[0],ph->v[1],ph->v[2],ph->v[3],ph->v[4],ph->v[5],ph->v[6],ph->v[7],ph->ref);
2098 + }
2099 + fprintf(stdout,"%8d HEXA REORIENTED\n",nbado);
2100
2101 - if(!MMG_hashHexa(listhexa,adjahex,nhex)) return(0);
2102 - MMG_cuthex(mesh,&hed2,listhexa,adjahex,nhex,netmp);
2103 + if(!MMG_hashHexa(listhexa,adjahex,nhex)) return(0);
2104 + MMG_cuthex(mesh,&hed2,listhexa,adjahex,nhex,netmp);
2105 /*read prism and transform to tetra
2106 - ---> compatibility pbs ==> hash edge and switch case*/
2107 + ---> compatibility pbs ==> hash edge and switch case*/
2108 rewind(inm);
2109 - fseek(inm,posnpris,SEEK_SET);
2110 - nimp = 0;
2111 - ne = netmp+6*nhex;
2112 + fseek(inm,posnpris,SEEK_SET);
2113 + nimp = 0;
2114 + ne = netmp+6*nhex;
2115 for (k=1; k<=npris; k++) {
2116 - fscanf(inm,"%d %d %d %d %d %d %d",&p0,&p1,&p2,&p3,&p4,&p5,&ref);
2117 - if(!MMG_cutprism(mesh,&hed2,ne,p0,p1,p2,p3,p4,p5,ref))
2118 - {
2119 - if(mesh->info.imprim < 0 ) fprintf(stdout,"DECOMPOSITION PRISM INVALID \n\n");
2120 - mesh->ne += 5;
2121 - ne += 8;
2122 - nimp++;
2123 - continue;
2124 - }
2125 - ne += 3;
2126 + fscanf(inm,"%d %d %d %d %d %d %d",&p0,&p1,&p2,&p3,&p4,&p5,&ref);
2127 + if(!MMG_cutprism(mesh,&hed2,ne,p0,p1,p2,p3,p4,p5,ref))
2128 + {
2129 + if(mesh->info.imprim < 0 ) fprintf(stdout,"DECOMPOSITION PRISM INVALID \n\n");
2130 + mesh->ne += 5;
2131 + ne += 8;
2132 + nimp++;
2133 + continue;
2134 + }
2135 + ne += 3;
2136 }
2137 - if(abs(mesh->info.imprim) > 3 )fprintf(stdout," %d INVALID DECOMPOSITION\n\n",nimp);
2138 + if(abs(mesh->info.imprim) > 3 )fprintf(stdout," %d INVALID DECOMPOSITION\n\n",nimp);
2139 }
2140 -
2141 +
2142 if ( abs(mesh->info.imprim) > 3 && abs(mesh->info.option)!=10 ) {
2143 fprintf(stdout," NUMBER OF GIVEN VERTICES %8d\n",mesh->npfixe);
2144 if ( mesh->ntfixe )
2145 @@ -609,24 +1041,26 @@
2146 if ( ned )
2147 fprintf(stdout," NUMBER OF GIVEN EDGES %8d\n",ned);
2148 }
2149 - fclose(inm);
2150 - return(1);
2151 + fclose(inm);
2152 + return(1);
2153 }
2154
2155
2156 /* load solution (metric) */
2157 -int MMG_loadSol(pSol sol,char *filename,int npmax) {
2158 - FILE *inm;
2159 +int MMG_loadSol(pSol sol,char *filename,int npmax,void *dataff) {
2160 + FILE *inm;
2161 float fsol;
2162 - double tmp;
2163 + double tmp;
2164 int binch,bdim,iswp;
2165 int k,i,isol,type,bin,dim,btyp,bpos;
2166 long posnp;
2167 char *ptr,data[128],chaine[128];
2168 -
2169 - posnp = 0;
2170 + if(dataff)
2171 + return MMG_loadSolff( sol,filename,npmax,(DataFF*) dataff);
2172 +
2173 + posnp = 0;
2174 bin = 0;
2175 - iswp = 0;
2176 + iswp = 0;
2177
2178 strcpy(data,filename);
2179 ptr = strstr(data,".mesh");
2180 @@ -645,94 +1079,94 @@
2181 }
2182 fprintf(stdout," %%%% %s OPENED\n",data);
2183
2184 -
2185 - if(!bin) {
2186 +
2187 + if(!bin) {
2188 strcpy(chaine,"DDD");
2189 - while(fscanf(inm,"%s",&chaine[0])!=EOF && strncmp(chaine,"End",strlen("End")) ) {
2190 + while(fscanf(inm,"%s",&chaine[0])!=EOF && strncmp(chaine,"End",strlen("End")) ) {
2191 if(!strncmp(chaine,"Dimension",strlen("Dimension"))) {
2192 - fscanf(inm,"%d",&dim);
2193 - if(dim!=3) {
2194 - fprintf(stdout,"BAD SOL DIMENSION : %d\n",dim);
2195 - return(1);
2196 - }
2197 - continue;
2198 + fscanf(inm,"%d",&dim);
2199 + if(dim!=3) {
2200 + fprintf(stdout,"BAD SOL DIMENSION : %d\n",dim);
2201 + return(1);
2202 + }
2203 + continue;
2204 } else if(!strncmp(chaine,"SolAtVertices",strlen("SolAtVertices"))) {
2205 - fscanf(inm,"%d",&sol->np);
2206 - fscanf(inm,"%d",&type);
2207 - if(type!=1) {
2208 - fprintf(stdout,"SEVERAL SOLUTION => IGNORED : %d\n",type);
2209 - return(1);
2210 - }
2211 - fscanf(inm,"%d",&btyp);
2212 - posnp = ftell(inm);
2213 - break;
2214 - }
2215 - }
2216 - } else {
2217 - fread(&binch,sw,1,inm);
2218 - iswp=0;
2219 - if(binch==16777216) iswp=1;
2220 + fscanf(inm,"%d",&sol->np);
2221 + fscanf(inm,"%d",&type);
2222 + if(type!=1) {
2223 + fprintf(stdout,"SEVERAL SOLUTION => IGNORED : %d\n",type);
2224 + return(1);
2225 + }
2226 + fscanf(inm,"%d",&btyp);
2227 + posnp = ftell(inm);
2228 + break;
2229 + }
2230 + }
2231 + } else {
2232 + fread(&binch,sw,1,inm);
2233 + iswp=0;
2234 + if(binch==16777216) iswp=1;
2235 else if(binch!=1) {
2236 fprintf(stdout,"BAD FILE ENCODING\n");
2237 - }
2238 - fread(&sol->ver,sw,1,inm);
2239 - if(iswp) sol->ver = MMG_swapbin(sol->ver);
2240 + }
2241 + fread(&sol->ver,sw,1,inm);
2242 + if(iswp) sol->ver = MMG_swapbin(sol->ver);
2243 while(fread(&binch,sw,1,inm)!=EOF && binch!=54 ) {
2244 - if(iswp) binch=MMG_swapbin(binch);
2245 - if(binch==54) break;
2246 + if(iswp) binch=MMG_swapbin(binch);
2247 + if(binch==54) break;
2248 if(binch==3) { //Dimension
2249 - fread(&bdim,sw,1,inm); //NulPos=>20
2250 - if(iswp) bdim=MMG_swapbin(bdim);
2251 - fread(&bdim,sw,1,inm);
2252 - if(iswp) bdim=MMG_swapbin(bdim);
2253 - if(bdim!=3) {
2254 - fprintf(stdout,"BAD SOL DIMENSION : %d\n",dim);
2255 - exit(0);
2256 - return(1);
2257 - }
2258 - continue;
2259 + fread(&bdim,sw,1,inm); //NulPos=>20
2260 + if(iswp) bdim=MMG_swapbin(bdim);
2261 + fread(&bdim,sw,1,inm);
2262 + if(iswp) bdim=MMG_swapbin(bdim);
2263 + if(bdim!=3) {
2264 + fprintf(stdout,"BAD SOL DIMENSION : %d\n",dim);
2265 + exit(0);
2266 + return(1);
2267 + }
2268 + continue;
2269 } else if(binch==62) { //SolAtVertices
2270 - fread(&binch,sw,1,inm); //NulPos
2271 - if(iswp) binch=MMG_swapbin(binch);
2272 - fread(&sol->np,sw,1,inm);
2273 - if(iswp) sol->np=MMG_swapbin(sol->np);
2274 - fread(&binch,sw,1,inm); //nb sol
2275 - if(iswp) binch=MMG_swapbin(binch);
2276 - if(binch!=1) {
2277 - fprintf(stdout,"SEVERAL SOLUTION => IGNORED : %d\n",type);
2278 - return(1);
2279 - }
2280 - fread(&btyp,sw,1,inm); //typsol
2281 - if(iswp) btyp=MMG_swapbin(btyp);
2282 - posnp = ftell(inm);
2283 - break;
2284 + fread(&binch,sw,1,inm); //NulPos
2285 + if(iswp) binch=MMG_swapbin(binch);
2286 + fread(&sol->np,sw,1,inm);
2287 + if(iswp) sol->np=MMG_swapbin(sol->np);
2288 + fread(&binch,sw,1,inm); //nb sol
2289 + if(iswp) binch=MMG_swapbin(binch);
2290 + if(binch!=1) {
2291 + fprintf(stdout,"SEVERAL SOLUTION => IGNORED : %d\n",type);
2292 + return(1);
2293 + }
2294 + fread(&btyp,sw,1,inm); //typsol
2295 + if(iswp) btyp=MMG_swapbin(btyp);
2296 + posnp = ftell(inm);
2297 + break;
2298 } else {
2299 - fread(&bpos,sw,1,inm); //Pos
2300 - if(iswp) bpos=MMG_swapbin(bpos);
2301 - rewind(inm);
2302 - fseek(inm,bpos,SEEK_SET);
2303 - }
2304 - }
2305 -
2306 - }
2307 + fread(&bpos,sw,1,inm); //Pos
2308 + if(iswp) bpos=MMG_swapbin(bpos);
2309 + rewind(inm);
2310 + fseek(inm,bpos,SEEK_SET);
2311 + }
2312 + }
2313 +
2314 + }
2315 if ( !sol->np ) {
2316 - fprintf(stdout," ** MISSING DATA\n");
2317 + fprintf(stdout," ** MISSING DATA ss\n");
2318 return(1);
2319 }
2320
2321 if ( btyp!= 1 && btyp!=3 ) {
2322 - fprintf(stdout," ** DATA IGNORED\n");
2323 + fprintf(stdout," ** DATA IGNORED %d\n",btyp);
2324 sol->np = 0;
2325 return(1);
2326 }
2327 -
2328 +
2329 sol->offset = (btyp==1) ? 1 : 6;
2330
2331 if ( abs(MMG_imprim) > 5 )
2332 fprintf(stdout," -- READING DATA FILE %s\n",data);
2333
2334 if ( !sol->np ) {
2335 - fprintf(stdout," ** MISSING DATA\n");
2336 + fprintf(stdout," ** MISSING DATA xx\n");
2337 return(0);
2338 }
2339 sol->npfixe = sol->np;
2340 @@ -742,31 +1176,31 @@
2341 /* read mesh solutions */
2342 sol->npfixe = sol->np;
2343 rewind(inm);
2344 - fseek(inm,posnp,SEEK_SET);
2345 + fseek(inm,posnp,SEEK_SET);
2346 for (k=1; k<=sol->np; k++) {
2347 isol = (k-1) * sol->offset + 1;
2348 - if (sol->ver == 1) {
2349 + if (sol->ver == 1) {
2350 for (i=0; i<sol->offset; i++) {
2351 - if(!bin){
2352 - fscanf(inm,"%f",&fsol);
2353 - sol->met[isol + i] = (double) fsol;
2354 - } else {
2355 - fread(&fsol,sw,1,inm);
2356 - if(iswp) fsol=MMG_swapf(fsol);
2357 - sol->met[isol + i] = (double) fsol;
2358 - }
2359 - }
2360 + if(!bin){
2361 + fscanf(inm,"%f",&fsol);
2362 + sol->met[isol + i] = (double) fsol;
2363 + } else {
2364 + fread(&fsol,sw,1,inm);
2365 + if(iswp) fsol=MMG_swapf(fsol);
2366 + sol->met[isol + i] = (double) fsol;
2367 + }
2368 + }
2369 } else {
2370 for (i=0; i<sol->offset; i++) {
2371 - if(!bin){
2372 - fscanf(inm,"%lf",&sol->met[isol + i]);
2373 + if(!bin){
2374 + fscanf(inm,"%lf",&sol->met[isol + i]);
2375
2376 - } else {
2377 - fread(&sol->met[isol + i],sd,1,inm);
2378 - if(iswp) sol->met[isol + i]=MMG_swapd(sol->met[isol + i]);
2379 - }
2380 - }
2381 - }
2382 + } else {
2383 + fread(&sol->met[isol + i],sd,1,inm);
2384 + if(iswp) sol->met[isol + i]=MMG_swapd(sol->met[isol + i]);
2385 + }
2386 + }
2387 + }
2388 /* MMG_swap data */
2389 if ( sol->offset == 6 ) {
2390 tmp = sol->met[isol + 2];
2391 @@ -778,13 +1212,13 @@
2392 if ( abs(MMG_imprim) > 3 )
2393 fprintf(stdout," NUMBER OF GIVEN DATA %8d\n",sol->npfixe);
2394
2395 - fclose(inm);
2396 - return(1);
2397 + fclose(inm);
2398 + return(1);
2399 }
2400
2401
2402 -int MMG_loadVect(pMesh mesh,char *filename,int npmax) {
2403 - FILE *inm;
2404 +int MMG_loadVect(pMesh mesh,char *filename,int npmax,void *dataff) {
2405 + FILE *inm;
2406 pDispl pd;
2407 float fsol;
2408 int binch,bdim,iswp;
2409 @@ -792,10 +1226,13 @@
2410 long posnp;
2411 char *ptr,data[128],chaine[128];
2412
2413 - pd = mesh->disp;
2414 + if(dataff)
2415 + return MMG_loadVectff( mesh, filename,npmax,(DataFF*) dataff);
2416
2417 - posnp = 0;
2418 - bin = 0;
2419 + pd = mesh->disp;
2420 +
2421 + posnp = 0;
2422 + bin = 0;
2423 iswp = 0;
2424
2425 strcpy(data,filename);
2426 @@ -815,76 +1252,76 @@
2427 }
2428 fprintf(stdout," %%%% %s OPENED\n",data);
2429
2430 -
2431 - if(!bin) {
2432 +
2433 + if(!bin) {
2434 strcpy(chaine,"DDD");
2435 - while(fscanf(inm,"%s",&chaine[0])!=EOF && strncmp(chaine,"End",strlen("End")) ) {
2436 + while(fscanf(inm,"%s",&chaine[0])!=EOF && strncmp(chaine,"End",strlen("End")) ) {
2437 if(!strncmp(chaine,"Dimension",strlen("Dimension"))) {
2438 - fscanf(inm,"%d",&dim);
2439 - if(dim!=3) {
2440 - fprintf(stdout,"BAD SOL DIMENSION : %d\n",dim);
2441 - return(1);
2442 - }
2443 - continue;
2444 + fscanf(inm,"%d",&dim);
2445 + if(dim!=3) {
2446 + fprintf(stdout,"BAD SOL DIMENSION : %d\n",dim);
2447 + return(1);
2448 + }
2449 + continue;
2450 } else if(!strncmp(chaine,"SolAtVertices",strlen("SolAtVertices"))) {
2451 - fscanf(inm,"%d",&pd->np);
2452 - fscanf(inm,"%d",&type);
2453 - if(type!=1) {
2454 - fprintf(stdout,"SEVERAL SOLUTION => IGNORED : %d\n",type);
2455 - return(1);
2456 - }
2457 - fscanf(inm,"%d",&btyp);
2458 - posnp = ftell(inm);
2459 - break;
2460 - }
2461 - }
2462 - } else {
2463 - fread(&pd->ver,sw,1,inm);
2464 - iswp=0;
2465 - if(pd->ver==16777216) iswp=1;
2466 + fscanf(inm,"%d",&pd->np);
2467 + fscanf(inm,"%d",&type);
2468 + if(type!=1) {
2469 + fprintf(stdout,"SEVERAL SOLUTION => IGNORED : %d\n",type);
2470 + return(1);
2471 + }
2472 + fscanf(inm,"%d",&btyp);
2473 + posnp = ftell(inm);
2474 + break;
2475 + }
2476 + }
2477 + } else {
2478 + fread(&pd->ver,sw,1,inm);
2479 + iswp=0;
2480 + if(pd->ver==16777216) iswp=1;
2481 else if(pd->ver!=1) {
2482 fprintf(stdout,"BAD FILE ENCODING\n");
2483 - }
2484 - fread(&pd->ver,sw,1,inm);
2485 - if(iswp) pd->ver = MMG_swapbin(pd->ver);
2486 + }
2487 + fread(&pd->ver,sw,1,inm);
2488 + if(iswp) pd->ver = MMG_swapbin(pd->ver);
2489 while(fread(&binch,sw,1,inm)!=EOF && binch!=54 ) {
2490 - if(iswp) binch=MMG_swapbin(binch);
2491 - if(binch==54) break;
2492 + if(iswp) binch=MMG_swapbin(binch);
2493 + if(binch==54) break;
2494 if(binch==3) { //Dimension
2495 - fread(&bdim,sw,1,inm); //Pos=>20
2496 - if(iswp) bdim=MMG_swapbin(bdim);
2497 - fread(&bdim,sw,1,inm);
2498 - if(iswp) bdim=MMG_swapbin(bdim);
2499 - if(bdim!=3) {
2500 - fprintf(stdout,"BAD SOL DIMENSION : %d\n",dim);
2501 - exit(0);
2502 - return(1);
2503 - }
2504 - continue;
2505 + fread(&bdim,sw,1,inm); //Pos=>20
2506 + if(iswp) bdim=MMG_swapbin(bdim);
2507 + fread(&bdim,sw,1,inm);
2508 + if(iswp) bdim=MMG_swapbin(bdim);
2509 + if(bdim!=3) {
2510 + fprintf(stdout,"BAD SOL DIMENSION : %d\n",dim);
2511 + exit(0);
2512 + return(1);
2513 + }
2514 + continue;
2515 } else if(binch==62) { //SolAtVertices
2516 - fread(&binch,sw,1,inm); //Pos
2517 - if(iswp) binch=MMG_swapbin(binch);
2518 - fread(&pd->np,sw,1,inm);
2519 - if(iswp) pd->np=MMG_swapbin(pd->np);
2520 - fread(&binch,sw,1,inm); //nb sol
2521 - if(iswp) binch=MMG_swapbin(binch);
2522 - if(binch!=1) {
2523 - fprintf(stdout,"SEVERAL SOLUTION => IGNORED : %d\n",type);
2524 - return(1);
2525 - }
2526 - fread(&btyp,sw,1,inm); //typsol
2527 - if(iswp) btyp=MMG_swapbin(btyp);
2528 - posnp = ftell(inm);
2529 - break;
2530 + fread(&binch,sw,1,inm); //Pos
2531 + if(iswp) binch=MMG_swapbin(binch);
2532 + fread(&pd->np,sw,1,inm);
2533 + if(iswp) pd->np=MMG_swapbin(pd->np);
2534 + fread(&binch,sw,1,inm); //nb sol
2535 + if(iswp) binch=MMG_swapbin(binch);
2536 + if(binch!=1) {
2537 + fprintf(stdout,"SEVERAL SOLUTION => IGNORED : %d\n",type);
2538 + return(1);
2539 + }
2540 + fread(&btyp,sw,1,inm); //typsol
2541 + if(iswp) btyp=MMG_swapbin(btyp);
2542 + posnp = ftell(inm);
2543 + break;
2544 } else {
2545 - fread(&bpos,sw,1,inm); //Pos
2546 - if(iswp) bpos=MMG_swapbin(bpos);
2547 - rewind(inm);
2548 - fseek(inm,bpos,SEEK_SET);
2549 - }
2550 - }
2551 -
2552 - }
2553 + fread(&bpos,sw,1,inm); //Pos
2554 + if(iswp) bpos=MMG_swapbin(bpos);
2555 + rewind(inm);
2556 + fseek(inm,bpos,SEEK_SET);
2557 + }
2558 + }
2559 +
2560 + }
2561 if ( !pd->np ) {
2562 fprintf(stdout," ** MISSING DATA\n");
2563 return(0);
2564 @@ -895,7 +1332,7 @@
2565 }
2566
2567 if ( btyp != 2 ) {
2568 - fprintf(stdout," ** DATA IGNORED\n");
2569 + fprintf(stdout," ** DATA IGNORED %d !=2\n",btyp);
2570 return(0);
2571 }
2572
2573 @@ -907,47 +1344,50 @@
2574 fseek(inm,posnp,SEEK_SET);
2575 for (k=1; k<=pd->np; k++) {
2576 iadr = (k - 1) * 3 + 1;
2577 - if (pd->ver < 2) {
2578 + if (pd->ver < 2) {
2579 for (i=0; i<3; i++) {
2580 - if(!bin){
2581 - fscanf(inm,"%f",&fsol);
2582 - pd->mv[iadr + i] = (double) fsol;
2583 - } else {
2584 - fread(&fsol,sw,1,inm);
2585 - if(iswp) fsol=MMG_swapf(fsol);
2586 - pd->mv[iadr + i] = (double) fsol;
2587 - }
2588 - }
2589 + if(!bin){
2590 + fscanf(inm,"%f",&fsol);
2591 + pd->mv[iadr + i] = (double) fsol;
2592 + } else {
2593 + fread(&fsol,sw,1,inm);
2594 + if(iswp) fsol=MMG_swapf(fsol);
2595 + pd->mv[iadr + i] = (double) fsol;
2596 + }
2597 + }
2598 } else {
2599 for (i=0; i<3; i++) {
2600 - if(!bin){
2601 - fscanf(inm,"%lf",&pd->mv[iadr + i]);
2602 - } else {
2603 - fread(&pd->mv[iadr + i],sd,1,inm);
2604 - if(iswp) pd->mv[iadr + i]=MMG_swapd(pd->mv[iadr + i]);
2605 - }
2606 - }
2607 - }
2608 + if(!bin){
2609 + fscanf(inm,"%lf",&pd->mv[iadr + i]);
2610 + } else {
2611 + fread(&pd->mv[iadr + i],sd,1,inm);
2612 + if(iswp) pd->mv[iadr + i]=MMG_swapd(pd->mv[iadr + i]);
2613 + }
2614 + }
2615 + }
2616 }
2617
2618 if ( abs(mesh->info.imprim) > 3 )
2619 fprintf(stdout," NUMBER OF GIVEN DATA %8d\n",pd->np);
2620
2621 - fclose(inm);
2622 + fclose(inm);
2623 return(1);
2624 }
2625
2626
2627 /* save mesh to disk */
2628 -int MMG_saveMesh(pMesh mesh,char *filename) {
2629 - FILE* inm;
2630 - Hedge hed;
2631 +int MMG_saveMesh(pMesh mesh,char *filename,void *dataff) {
2632 + FILE* inm;
2633 + Hedge hed;
2634 pPoint ppt;
2635 pTria pt1;
2636 pTetra pt;
2637 int i,k,np,ne,nc,ned,*cor,*ed,ref,bin,bpos;
2638 - char *ptr,data[128],chaine[128];
2639 + char *ptr,data[128],chaine[128];
2640 int binch,nu1,nu2;
2641 + if(dataff)
2642 + return MMG_saveMeshff( mesh, filename,(DataFF*) dataff);
2643 +
2644 mesh->ver = 2; //double precision
2645 bin = 0;
2646 strcpy(data,filename);
2647 @@ -959,28 +1399,28 @@
2648 *ptr = '\0';
2649 strcat(data,".mesh");
2650 if( !(inm = fopen(data,"w")) ) {
2651 - fprintf(stderr," ** UNABLE TO OPEN %s.\n",data);
2652 - return(0);
2653 + fprintf(stderr," ** UNABLE TO OPEN %s.\n",data);
2654 + return(0);
2655 }
2656 } else {
2657 - bin = 1;
2658 + bin = 1;
2659 }
2660 }
2661 - else {
2662 + else {
2663 ptr = strstr(data,".meshb");
2664 if( ptr ) bin = 1;
2665 if( !(inm = fopen(data,"w")) ) {
2666 fprintf(stderr," ** UNABLE TO OPEN %s.\n",data);
2667 return(0);
2668 - }
2669 + }
2670 }
2671 fprintf(stdout," %%%% %s OPENED\n",data);
2672
2673 /*entete fichier*/
2674 if(!bin) {
2675 - strcpy(&chaine[0],"MeshVersionFormatted 2\n");
2676 + strcpy(&chaine[0],"MeshVersionFormatted 2\n");
2677 fprintf(inm,"%s",chaine);
2678 - strcpy(&chaine[0],"\n\nDimension 3\n");
2679 + strcpy(&chaine[0],"\n\nDimension 3\n");
2680 fprintf(inm,"%s ",chaine);
2681 } else {
2682 binch = 1; //MeshVersionFormatted
2683 @@ -993,33 +1433,38 @@
2684 fwrite(&bpos,sw,1,inm);
2685 binch = 3;
2686 fwrite(&binch,sw,1,inm);
2687 -
2688 +
2689 }
2690
2691 /* compact vertices */
2692 - if(mesh->ncor) {
2693 + if(mesh->ncor) {
2694 cor = (int*) M_calloc(mesh->ncor,sizeof(int),"MMG_savemesh");
2695 - assert(cor);
2696 + assert(cor);
2697 }
2698 - if(mesh->ned) {
2699 - if ( !MMG_zaldy4(&hed,mesh->ned) ) {
2700 - if ( mesh->info.ddebug ) fprintf(stdout," ## MEMORY ALLOCATION PROBLEM : EXPORT EDGES IGNORED\n");
2701 - mesh->ned = 0;
2702 - }
2703 + if(mesh->ned) {
2704 + if ( !MMG_zaldy4(&hed,mesh->ned) ) {
2705 + if ( mesh->info.ddebug ) fprintf(stdout," ## MEMORY ALLOCATION PROBLEM : EXPORT EDGES IGNORED\n");
2706 + mesh->ned = 0;
2707 + }
2708 ed = (int*)M_calloc(2*mesh->ned,sizeof(int),"MMG_savemesh");
2709 - assert(ed);
2710 + assert(ed);
2711 }
2712 - np = 0;
2713 + np = 0;
2714 nc = 0;
2715 for (k=1; k<=mesh->np; k++) {
2716 ppt = &mesh->point[k];
2717 - if ( ppt->tag & M_UNUSED ) continue;
2718 - ppt->tmp = ++np;
2719 + if ( ppt->tag & M_UNUSED ) continue;
2720 + ppt->tmp = ++np;
2721 if ( ppt->geom & M_CORNER ) cor[nc++] = ppt->tmp;
2722 + }
2723 + //assert(mesh->ncor==nc);
2724 + if(mesh->ncor!=nc) {
2725 + fprintf(stdout,"WARNING: some corners have been added or deleted\n");
2726 + mesh->ncor = nc;
2727 }
2728 - assert(mesh->ncor==nc);
2729 +
2730 if(!bin) {
2731 - strcpy(&chaine[0],"\n\nVertices\n");
2732 + strcpy(&chaine[0],"\n\nVertices\n");
2733 fprintf(inm,"%s",chaine);
2734 fprintf(inm,"%d\n",np);
2735 } else {
2736 @@ -1027,27 +1472,27 @@
2737 fwrite(&binch,sw,1,inm);
2738 bpos += 12+(1+3*mesh->ver)*4*np; //NullPos
2739 fwrite(&bpos,sw,1,inm);
2740 - fwrite(&np,sw,1,inm);
2741 + fwrite(&np,sw,1,inm);
2742 }
2743 for(k=1; k<=mesh->np; k++) {
2744 ppt = &mesh->point[k];
2745 - if ( ppt->tag & M_UNUSED ) continue;
2746 - //if(ppt->tmp==52453) printf("point %d --> %d\n",ppt->tmp,k);
2747 + if ( ppt->tag & M_UNUSED ) continue;
2748 + //if(ppt->tmp==52453) printf("point %d --> %d\n",ppt->tmp,k);
2749 if(!bin) {
2750 fprintf(inm,"%.15lg %.15lg %.15lg %d\n",ppt->c[0],ppt->c[1],ppt->c[2],ppt->ref);
2751 } else {
2752 - fwrite((unsigned char*)&ppt->c[0],sd,1,inm);
2753 - fwrite((unsigned char*)&ppt->c[1],sd,1,inm);
2754 - fwrite((unsigned char*)&ppt->c[2],sd,1,inm);
2755 - fwrite((unsigned char*)&ppt->ref,sw,1,inm);
2756 + fwrite((unsigned char*)&ppt->c[0],sd,1,inm);
2757 + fwrite((unsigned char*)&ppt->c[1],sd,1,inm);
2758 + fwrite((unsigned char*)&ppt->c[2],sd,1,inm);
2759 + fwrite((unsigned char*)&ppt->ref,sw,1,inm);
2760 }
2761 }
2762
2763 - /* rebuild triangles tabular and write triangles */
2764 + /* rebuild triangles tabular and write triangles */
2765 mesh->nt = 0;
2766 if(MMG_markBdry(mesh)) {
2767 if(!bin) {
2768 - strcpy(&chaine[0],"\n\nTriangles\n");
2769 + strcpy(&chaine[0],"\n\nTriangles\n");
2770 fprintf(inm,"%s",chaine);
2771 fprintf(inm,"%d \n",mesh->nt);
2772 } else {
2773 @@ -1055,49 +1500,48 @@
2774 fwrite(&binch,sw,1,inm);
2775 bpos += 12+16*mesh->nt; //Pos
2776 fwrite(&bpos,sw,1,inm);
2777 - fwrite(&mesh->nt,sw,1,inm);
2778 + fwrite(&mesh->nt,sw,1,inm);
2779 }
2780 for (k=1; k<=mesh->nt; k++) {
2781 pt1 = &mesh->tria[k];
2782 - ref = pt1->ref;
2783 + ref = pt1->ref;
2784 if(!bin) {
2785 - //if(ref==0) printf("tr %d bad ref!!\n",k);
2786 - fprintf(inm,"%d %d %d %d\n",mesh->point[pt1->v[0]].tmp,mesh->point[pt1->v[1]].tmp
2787 - ,mesh->point[pt1->v[2]].tmp,ref);
2788 + fprintf(inm,"%d %d %d %d\n",mesh->point[pt1->v[0]].tmp,mesh->point[pt1->v[1]].tmp
2789 + ,mesh->point[pt1->v[2]].tmp,ref);
2790 } else {
2791 - fwrite(&mesh->point[pt1->v[0]].tmp,sw,1,inm);
2792 - fwrite(&mesh->point[pt1->v[1]].tmp,sw,1,inm);
2793 - fwrite(&mesh->point[pt1->v[2]].tmp,sw,1,inm);
2794 - fwrite(&ref,sw,1,inm);
2795 + fwrite(&mesh->point[pt1->v[0]].tmp,sw,1,inm);
2796 + fwrite(&mesh->point[pt1->v[1]].tmp,sw,1,inm);
2797 + fwrite(&mesh->point[pt1->v[2]].tmp,sw,1,inm);
2798 + fwrite(&ref,sw,1,inm);
2799 }
2800 }
2801 - }
2802 -
2803 + }
2804 +
2805 /* write tetrahedra */
2806 - ne = 0;
2807 - ned = 0;
2808 - //printf("avt %d\n",mesh->ned);
2809 + ne = 0;
2810 + ned = 0;
2811 + //printf("avt %d\n",mesh->ned);
2812 for (k=1; k<=mesh->ne; k++) {
2813 pt = &mesh->tetra[k];
2814 - if ( !pt->v[0] ) continue;
2815 - if(mesh->ned) {
2816 - for (i=0 ; i<6 ; i++) {
2817 - if (pt->bdryinfo[i]) {
2818 - nu1 = pt->v[MMG_iare[i][0]];
2819 - nu2 = pt->v[MMG_iare[i][1]];
2820 - if (MMG_edgePut(&hed,nu1,nu2,2)<=1) {
2821 - ed[2*ned] = (mesh->point[nu1]).tmp;
2822 - ed[2*ned + 1] = (mesh->point[nu2]).tmp;
2823 - ned++;
2824 - }
2825 - }
2826 - }
2827 - }
2828 - ne++;
2829 + if ( !pt->v[0] ) continue;
2830 + if(mesh->ned) {
2831 + for (i=0 ; i<6 ; i++) {
2832 + if (pt->bdryinfo[i]) {
2833 + nu1 = pt->v[MMG_iare[i][0]];
2834 + nu2 = pt->v[MMG_iare[i][1]];
2835 + if (MMG_edgePut(&hed,nu1,nu2,2)<=1) {
2836 + ed[2*ned] = (mesh->point[nu1]).tmp;
2837 + ed[2*ned + 1] = (mesh->point[nu2]).tmp;
2838 + ned++;
2839 + }
2840 + }
2841 + }
2842 + }
2843 + ne++;
2844 }
2845 - //printf("ned %d\n",ned);
2846 + //printf("ned %d\n",ned);
2847 if(!bin) {
2848 - strcpy(&chaine[0],"\n\nTetrahedra\n");
2849 + strcpy(&chaine[0],"\n\nTetrahedra\n");
2850 fprintf(inm,"%s",chaine);
2851 fprintf(inm,"%d\n",ne);
2852 } else {
2853 @@ -1105,29 +1549,29 @@
2854 fwrite(&binch,sw,1,inm);
2855 bpos += 12 + 20*ne;//Pos
2856 fwrite(&bpos,sw,1,inm);
2857 - fwrite((unsigned char*)&ne,sw,1,inm);
2858 - }
2859 - ne=0;
2860 + fwrite((unsigned char*)&ne,sw,1,inm);
2861 + }
2862 + ne=0;
2863 for (k=1; k<=mesh->ne; k++) {
2864 pt = &mesh->tetra[k];
2865 - if ( !pt->v[0] ) continue;
2866 - ne++;
2867 - ref = pt->ref;
2868 + if ( !pt->v[0] ) continue;
2869 + ne++;
2870 + ref = pt->ref;
2871 if(!bin) {
2872 fprintf(inm,"%d %d %d %d %d\n",mesh->point[pt->v[0]].tmp,mesh->point[pt->v[1]].tmp
2873 - ,mesh->point[pt->v[2]].tmp,mesh->point[pt->v[3]].tmp,ref);
2874 + ,mesh->point[pt->v[2]].tmp,mesh->point[pt->v[3]].tmp,ref);
2875 } else {
2876 - fwrite(&mesh->point[pt->v[0]].tmp,sw,1,inm);
2877 - fwrite(&mesh->point[pt->v[1]].tmp,sw,1,inm);
2878 - fwrite(&mesh->point[pt->v[2]].tmp,sw,1,inm);
2879 - fwrite(&mesh->point[pt->v[3]].tmp,sw,1,inm);
2880 - fwrite(&ref,sw,1,inm);
2881 + fwrite(&mesh->point[pt->v[0]].tmp,sw,1,inm);
2882 + fwrite(&mesh->point[pt->v[1]].tmp,sw,1,inm);
2883 + fwrite(&mesh->point[pt->v[2]].tmp,sw,1,inm);
2884 + fwrite(&mesh->point[pt->v[3]].tmp,sw,1,inm);
2885 + fwrite(&ref,sw,1,inm);
2886 }
2887 - }
2888 -
2889 + }
2890 +
2891 if(mesh->ned) {
2892 if(!bin) {
2893 - strcpy(&chaine[0],"\n\nEdges\n");
2894 + strcpy(&chaine[0],"\n\nEdges\n");
2895 fprintf(inm,"%s",chaine);
2896 fprintf(inm,"%d\n",ned);
2897 } else {
2898 @@ -1135,50 +1579,50 @@
2899 fwrite(&binch,sw,1,inm);
2900 bpos += 12 + 3*4*ned;//Pos
2901 fwrite(&bpos,sw,1,inm);
2902 - fwrite((unsigned char*)&ned,sw,1,inm);
2903 - }
2904 - for (k=0; k<ned; k++) {
2905 - ref = 0;
2906 - if(!bin) {
2907 - fprintf(inm,"%d %d %d \n",ed[2*k],ed[2*k+1],ref);
2908 - } else {
2909 - fwrite(&ed[2*k],sw,1,inm);
2910 - fwrite(&ed[2*k+1],sw,1,inm);
2911 - fwrite(&ref,sw,1,inm);
2912 - }
2913 - }
2914 - M_free(hed.item);
2915 - M_free(ed);
2916 + fwrite((unsigned char*)&ned,sw,1,inm);
2917 + }
2918 + for (k=0; k<ned; k++) {
2919 + ref = 0;
2920 + if(!bin) {
2921 + fprintf(inm,"%d %d %d \n",ed[2*k],ed[2*k+1],ref);
2922 + } else {
2923 + fwrite(&ed[2*k],sw,1,inm);
2924 + fwrite(&ed[2*k+1],sw,1,inm);
2925 + fwrite(&ref,sw,1,inm);
2926 + }
2927 + }
2928 + M_free(hed.item);
2929 + M_free(ed);
2930 }
2931 -
2932 +
2933 /* write corners */
2934 if(!bin) {
2935 - strcpy(&chaine[0],"\n\nCorners\n");
2936 + strcpy(&chaine[0],"\n\nCorners\n");
2937 fprintf(inm,"%s",chaine);
2938 fprintf(inm,"%d\n",mesh->ncor);
2939 } else {
2940 binch = 13; //Corners
2941 fwrite(&binch,sw,1,inm);
2942 - bpos += 12 + 4*mesh->ncor;//Pos
2943 + bpos += 12 + 4*mesh->ncor;//Pos
2944 fwrite(&bpos,sw,1,inm);
2945 - fwrite((unsigned char*)&mesh->ncor,sw,1,inm);
2946 + fwrite((unsigned char*)&mesh->ncor,sw,1,inm);
2947 }
2948 for (k=0; k<mesh->ncor; k++) {
2949 if(!bin) {
2950 fprintf(inm,"%d \n",cor[k]);
2951 } else {
2952 - fwrite(&cor[k],sw,1,inm);
2953 + fwrite(&cor[k],sw,1,inm);
2954 }
2955 - }
2956 + }
2957 /*fin fichier*/
2958 if(!bin) {
2959 - strcpy(&chaine[0],"\n\nEnd\n");
2960 + strcpy(&chaine[0],"\n\nEnd\n");
2961 fprintf(inm,"%s",chaine);
2962 } else {
2963 binch = 54; //End
2964 fwrite(&binch,sw,1,inm);
2965 }
2966 - fclose(inm);
2967 + fclose(inm);
2968 if(mesh->ncor) M_free(cor);
2969 if ( mesh->info.imprim ) {
2970 fprintf(stdout," NUMBER OF GIVEN VERTICES %8d\n",mesh->npfixe);
2971 @@ -1193,20 +1637,22 @@
2972 if ( mesh->ned )
2973 fprintf(stdout," TOTAL NUMBER OF EDGES %8d\n",ned);
2974 }
2975 - //if(ned!=mesh->ned) exit(0);
2976 + //if(ned!=mesh->ned) exit(0);
2977 return(1);
2978
2979 }
2980
2981
2982 -int MMG_saveSol(pMesh mesh,pSol sol,char *filename) {
2983 +int MMG_saveSol(pMesh mesh,pSol sol,char *filename,void *dataff) {
2984 FILE* inm;
2985 pPoint ppt;
2986 float fsol;
2987 double tmp;
2988 int i,k,nbl,isol,bin,bpos,typ;
2989 - char *ptr,data[128],chaine[128];
2990 + char *ptr,data[128],chaine[128];
2991 int binch;
2992 + if(dataff)
2993 + return MMG_saveSolff( mesh, sol, filename,(DataFF*) dataff);
2994
2995 if ( !sol->np ) return(1);
2996 bin = 1;
2997 @@ -1219,24 +1665,24 @@
2998 *ptr = '\0';
2999 bin = 0;
3000 } else {
3001 - ptr = strstr(data,".solb");
3002 - if ( ptr ) {
3003 - *ptr = '\0';
3004 - bin = 1;
3005 + ptr = strstr(data,".solb");
3006 + if ( ptr ) {
3007 + *ptr = '\0';
3008 + bin = 1;
3009 } else {
3010 - ptr = strstr(data,".sol");
3011 - if ( ptr ) {
3012 - *ptr = '\0';
3013 - bin = 0;
3014 - }
3015 - }
3016 - }
3017 + ptr = strstr(data,".sol");
3018 + if ( ptr ) {
3019 + *ptr = '\0';
3020 + bin = 0;
3021 + }
3022 + }
3023 + }
3024 }
3025 - if ( bin )
3026 + if ( bin )
3027 strcat(data,".solb");
3028 else
3029 strcat(data,".sol");
3030 -
3031 +
3032 sol->ver = 2;
3033 if( bin && !(inm = fopen(data,"wb")) ) {
3034 fprintf(stderr," ** UNABLE TO OPEN %s.\n",data);
3035 @@ -1251,9 +1697,9 @@
3036
3037 /*entete fichier*/
3038 if(!bin) {
3039 - strcpy(&chaine[0],"MeshVersionFormatted 2\n");
3040 + strcpy(&chaine[0],"MeshVersionFormatted 2\n");
3041 fprintf(inm,"%s",chaine);
3042 - strcpy(&chaine[0],"\n\nDimension 3\n");
3043 + strcpy(&chaine[0],"\n\nDimension 3\n");
3044 fprintf(inm,"%s ",chaine);
3045 } else {
3046 binch = 1; //MeshVersionFormatted
3047 @@ -1266,19 +1712,19 @@
3048 fwrite(&bpos,sw,1,inm);
3049 binch = 3;
3050 fwrite(&binch,sw,1,inm);
3051 -
3052 +
3053 }
3054
3055
3056 switch(sol->offset) {
3057 case 1:
3058 - typ = 1;
3059 - break;
3060 + typ = 1;
3061 + break;
3062 case 6:
3063 - typ = 3;
3064 + typ = 3;
3065 break;
3066 default:
3067 - fprintf(stdout," ** DATA IGNORED\n");
3068 + fprintf(stdout," ** DATA IGNORED not 1 ou 6 == %d\n",sol->offset);
3069 return(0);
3070 }
3071
3072 @@ -1287,11 +1733,11 @@
3073 for (k=1; k<=mesh->np; k++) {
3074 ppt = &mesh->point[k];
3075 if ( ppt->tag & M_UNUSED ) continue;
3076 - nbl++;
3077 + nbl++;
3078 }
3079 -
3080 +
3081 if(!bin) {
3082 - strcpy(&chaine[0],"\n\nSolAtVertices\n");
3083 + strcpy(&chaine[0],"\n\nSolAtVertices\n");
3084 fprintf(inm,"%s",chaine);
3085 fprintf(inm,"%d\n",nbl);
3086 fprintf(inm,"%d %d\n",1,typ);
3087 @@ -1300,7 +1746,7 @@
3088 fwrite(&binch,sw,1,inm);
3089 bpos += 20+(sol->offset*sol->ver)*4*nbl; //Pos
3090 fwrite(&bpos,sw,1,inm);
3091 - fwrite(&nbl,sw,1,inm);
3092 + fwrite(&nbl,sw,1,inm);
3093 binch = 1; //nb sol
3094 fwrite(&binch,sw,1,inm);
3095 binch = typ; //typ sol
3096 @@ -1317,34 +1763,34 @@
3097 sol->met[isol + 3] = tmp;
3098 }
3099 if (sol->ver < 2) {
3100 - if(!bin) {
3101 - for (i=0; i<sol->offset; i++) {
3102 - fsol = (float) sol->met[isol + i];
3103 - fprintf(inm,"%f ",fsol);
3104 - }
3105 - fprintf(inm,"\n");
3106 + if(!bin) {
3107 + for (i=0; i<sol->offset; i++) {
3108 + fsol = (float) sol->met[isol + i];
3109 + fprintf(inm,"%f ",fsol);
3110 + }
3111 + fprintf(inm,"\n");
3112 } else {
3113 - for (i=0; i<sol->offset; i++) {
3114 - fsol = (float) sol->met[isol + i];
3115 - fwrite(&fsol,sw,1,inm);
3116 - }
3117 + for (i=0; i<sol->offset; i++) {
3118 + fsol = (float) sol->met[isol + i];
3119 + fwrite(&fsol,sw,1,inm);
3120 + }
3121 }
3122 } else {
3123 - if(!bin) {
3124 - for (i=0; i<sol->offset; i++)
3125 - fprintf(inm,"%.15lg ",sol->met[isol + i]);
3126 - fprintf(inm,"\n");
3127 + if(!bin) {
3128 + for (i=0; i<sol->offset; i++)
3129 + fprintf(inm,"%.15lg ",sol->met[isol + i]);
3130 + fprintf(inm,"\n");
3131 } else {
3132 - for (i=0; i<sol->offset; i++)
3133 - fwrite(&sol->met[isol + i],sd,1,inm);
3134 + for (i=0; i<sol->offset; i++)
3135 + fwrite(&sol->met[isol + i],sd,1,inm);
3136 }
3137 -
3138 +
3139 }
3140 }
3141 -
3142 +
3143 /*fin fichier*/
3144 if(!bin) {
3145 - strcpy(&chaine[0],"\n\nEnd\n");
3146 + strcpy(&chaine[0],"\n\nEnd\n");
3147 fprintf(inm,"%s",chaine);
3148 } else {
3149 binch = 54; //End
3150 @@ -1355,14 +1801,16 @@
3151 }
3152
3153 /*save the node speed : coornew-coorold/dt*/
3154 -int MMG_saveVect(pMesh mesh,char *filename) {
3155 - FILE* inm;
3156 +int MMG_saveVect(pMesh mesh,char *filename,void *dataff) {
3157 + FILE* inm;
3158 pDispl pd;
3159 pPoint ppt;
3160 double dsol,dd;
3161 int i,k,nbl,bin,bpos,typ;
3162 - char *ptr,data[128],chaine[128];
3163 + char *ptr,data[128],chaine[128];
3164 unsigned char binch;
3165 + if(dataff)
3166 + return MMG_saveVectff( mesh, filename,(DataFF*) dataff);
3167
3168 pd = mesh->disp;
3169 pd->ver = 2;
3170 @@ -1378,7 +1826,7 @@
3171 bin = 0;
3172 }
3173 }
3174 - if ( bin )
3175 + if ( bin )
3176 strcat(data,".o.solb");
3177 else
3178 strcat(data,".o.sol");
3179 @@ -1395,9 +1843,9 @@
3180
3181 /*entete fichier*/
3182 if(!bin) {
3183 - strcpy(&chaine[0],"MeshVersionFormatted 2\n");
3184 + strcpy(&chaine[0],"MeshVersionFormatted 2\n");
3185 fprintf(inm,"%s",chaine);
3186 - strcpy(&chaine[0],"\n\nDimension 3\n");
3187 + strcpy(&chaine[0],"\n\nDimension 3\n");
3188 fprintf(inm,"%s ",chaine);
3189 } else {
3190 binch = 1; //MeshVersionFormatted
3191 @@ -1410,20 +1858,20 @@
3192 fwrite(&bpos,sw,1,inm);
3193 binch = 3;
3194 fwrite(&binch,sw,1,inm);
3195 -
3196 +
3197 }
3198 - typ = 2;
3199 + typ = 2;
3200
3201 /* write data */
3202 nbl = 0;
3203 for (k=1; k<=mesh->np; k++) {
3204 ppt = &mesh->point[k];
3205 if ( ppt->tag & M_UNUSED ) continue;
3206 - nbl++;
3207 + nbl++;
3208 }
3209 -
3210 +
3211 if(!bin) {
3212 - strcpy(&chaine[0],"\n\nSolAtVertices\n");
3213 + strcpy(&chaine[0],"\n\nSolAtVertices\n");
3214 fprintf(inm,"%s",chaine);
3215 fprintf(inm,"%d\n",nbl);
3216 fprintf(inm,"%d %d\n",1,typ);
3217 @@ -1432,34 +1880,34 @@
3218 fwrite(&binch,sw,1,inm);
3219 bpos += 20+(3*pd->ver)*4*nbl; //Pos
3220 fwrite(&bpos,sw,1,inm);
3221 - fwrite(&nbl,sw,1,inm);
3222 + fwrite(&nbl,sw,1,inm);
3223 binch = 1; //nb sol
3224 fwrite(&binch,sw,1,inm);
3225 binch = typ; //typ sol
3226 fwrite(&binch,sw,1,inm);
3227 - }
3228 -
3229 -
3230 - dd = mesh->info.delta / (double)PRECI;
3231 + }
3232 +
3233 +
3234 + dd = mesh->info.delta / (double)PRECI;
3235 fprintf(stdout," DT %e\n",mesh->info.dt);
3236 for (k=1; k<=mesh->np; k++) {
3237 ppt = &mesh->point[k];
3238 - if ( ppt->tag & M_UNUSED ) continue;
3239 + if ( ppt->tag & M_UNUSED ) continue;
3240 for (i=0 ; i<3 ; i++) {
3241 - dsol = (ppt->c[i] - mesh->disp->cold[3*(k-1) + 1 + i]* dd - mesh->info.min[i])/mesh->info.dt;
3242 - if(!bin) {
3243 - fprintf(inm,"%.15lg ",dsol);
3244 + dsol = (ppt->c[i] - mesh->disp->cold[3*(k-1) + 1 + i]* dd - mesh->info.min[i])/mesh->info.dt;
3245 + if(!bin) {
3246 + fprintf(inm,"%.15lg ",dsol);
3247 } else {
3248 - fwrite(&dsol,sd,1,inm);
3249 + fwrite(&dsol,sd,1,inm);
3250 }
3251 }
3252 - if (!bin) fprintf(inm,"\n");
3253 + if (!bin) fprintf(inm,"\n");
3254 }
3255 -
3256 -
3257 +
3258 +
3259 /*fin fichier*/
3260 if(!bin) {
3261 - strcpy(&chaine[0],"\n\nEnd\n");
3262 + strcpy(&chaine[0],"\n\nEnd\n");
3263 fprintf(inm,"%s",chaine);
3264 } else {
3265 binch = 54; //End
3266 --- mmg3d4/build/sources/mmg3d9.c 2012-12-19 16:05:33.000000000 +0100
3267 +++ mmg3d4-nnew/build/sources/mmg3d9.c 2014-03-05 18:37:03.000000000 +0100
3268 @@ -382,7 +382,7 @@
3269 fprintf(stdout," ** MOVING MESH\n");
3270
3271 /*alloc et init metold*/
3272 - sol->metold = (double*)M_calloc(sol->npmax+1,sol->offset*sizeof(double),"MMG_mmg3d9");
3273 + if(!sol->metold) sol->metold = (double*)M_calloc(sol->npmax+1,sol->offset*sizeof(double),"MMG_mmg3d9");
3274 assert(sol->metold);
3275 mesh->disp->cold = (double*)M_calloc(3*(mesh->npmax + 1),sizeof(double),"MMG_mmg3d9");
3276 assert(mesh->disp->cold);
3277
3278 --- mmg3d4/build/sources/mmg3dmain/mmg3d.c 2012-12-19 16:05:53.000000000 +0100
3279 +++ mmg3d4-new/build/sources/mmg3dmain/mmg3d.c 2014-04-22 16:37:41.000000000 +0200
3280 @@ -46,7 +46,7 @@
3281 #include "compil.date"
3282 #include "mesh.h"
3283 #include "eigenv.h"
3284 -
3285 +#include "dataff.h"
3286 TIM_mytime MMG_ctim[TIMEMAX];
3287 short MMG_imprim;
3288
3289 @@ -310,7 +310,8 @@
3290 strcpy(sol->name,mesh->name);
3291 }
3292 if ( mesh->outf == NULL ) {
3293 - mesh->outf = (char *)calloc(128,sizeof(char));
3294 + static char stbub [256];
3295 + mesh->outf = stbub; /*(char *)calloc(128,sizeof(char)); */
3296 assert(mesh->outf);
3297 strcpy(mesh->outf,mesh->name);
3298 ptr = strstr(mesh->outf,".mesh");
3299 @@ -397,6 +398,7 @@
3300 100.*ttot/ttim[0],call[0],ttot/(float)call[0]);
3301 }
3302 fprintf(stdout,"\n ELAPSED TIME %.2f SEC. (%.2f)\n",ttim[0],ttot);
3303 + fflush(stdout);
3304 }
3305
3306
3307 @@ -433,8 +435,7 @@
3308 return(1);
3309 }
3310
3311 -
3312 -int main(int argc,char *argv[]) {
3313 +int mainmmg3d(int argc,char *argv[],DataFF *dataff) {
3314 pMesh mesh;
3315 pSol sol;
3316 Info *info;
3317 @@ -442,7 +443,7 @@
3318 int k,iadr,i,jj,kk,ii;
3319 double lambda[3],v[3][3],*mold,*m,declic,maxLES,calLES;
3320 fprintf(stdout," -- MMG3d, Release %s (%s) \n",M_VER,M_REL);
3321 - fprintf(stdout," Copyright (c) LJLL/IMB, 2010\n");
3322 + fprintf(stdout," Copyright (c) LJLL/IMB, 2014\n");
3323 fprintf(stdout," %s\n",COMPIL);
3324
3325 signal(SIGABRT,excfun);
3326 @@ -451,7 +452,7 @@
3327 signal(SIGSEGV,excfun);
3328 signal(SIGTERM,excfun);
3329 signal(SIGINT,excfun);
3330 - atexit(endcod);
3331 + if(dataff==0) atexit(endcod);
3332
3333 TIM_tminit(MMG_ctim,TIMEMAX);
3334 TIM_chrono(ON,&MMG_ctim[0]);
3335 @@ -479,15 +480,27 @@
3336 info->dt = 1.;
3337 info->bdry = 0;
3338 info->optles = 0;
3339 -
3340 + /* modif F. Hecht ..*/
3341 + if(dataff)
3342 + {
3343 + mesh->name=dataff->meshname;
3344 + mesh->move=dataff->movename;
3345 + sol->name=dataff->solname;
3346 + /* printf(" #### %p %p %p --- \n",mesh->name,mesh->move,sol->name); */
3347 + info->imprim=dataff->imprim;
3348 + info->memory=dataff->memory;
3349 + }
3350 + /* end modf */
3351 if ( !parsar(argc,argv,mesh,sol) ) return(1);
3352 MMG_imprim = info->imprim;
3353
3354 /* load data */
3355 if ( MMG_imprim ) fprintf(stdout,"\n -- INPUT DATA\n");
3356 TIM_chrono(ON,&MMG_ctim[1]);
3357 - if ( !MMG_loadMesh(mesh,mesh->name) ) return(1);
3358 - if ( !MMG_loadSol(sol,sol->name,mesh->npmax) ) return(1);
3359 + /* modif FH. for interface with ff++ add dataff param */
3360 + if ( !MMG_loadMesh(mesh,mesh->name,dataff) ) return(1);
3361 + if ( !MMG_loadSol(sol,sol->name,mesh->npmax,dataff ) ) return(1);
3362 +
3363 if ( sol->np && sol->np != mesh->np ) {
3364 fprintf(stdout," ## WARNING: WRONG SOLUTION NUMBER. IGNORED\n");
3365 sol->np = 0;
3366 @@ -495,7 +508,7 @@
3367
3368 if ( !parsop(mesh) ) return(1);
3369
3370 - if ( abs(info->option) == 9 && !MMG_loadVect(mesh,mesh->move,mesh->np) ) return(0);
3371 + if ( abs(info->option) == 9 && !MMG_loadVect(mesh,mesh->move,mesh->np,dataff) ) return(0);
3372
3373 if ( !MMG_setfunc(sol->offset) ) return(1);
3374 if ( !MMG_scaleMesh(mesh,sol) ) return(1);
3375 @@ -527,7 +540,7 @@
3376 if ( !MMG_hashTetra(mesh) ) return(1);
3377 if ( !MMG_markBdry(mesh) ) return(1);
3378 if (abs(mesh->info.option)==10) {
3379 - MMG_saveMesh(mesh,"tetra.mesh");
3380 + MMG_saveMesh(mesh,"tetra.mesh",dataff);
3381 return(0);
3382 }
3383
3384 @@ -571,8 +584,8 @@
3385 if ( abs(info->option) == 9 ) {
3386 if(!MMG_mmg3d9(mesh,sol,&alert)) {
3387 if ( !MMG_unscaleMesh(mesh,sol) ) return(1);
3388 - MMG_saveMesh(mesh,mesh->outf);
3389 - MMG_saveSol(mesh,sol,mesh->outf);
3390 + MMG_saveMesh(mesh,mesh->outf,dataff);
3391 + MMG_saveSol(mesh,sol,mesh->outf,dataff);
3392 return(1);
3393 }
3394 /*puts("appel 1");
3395 @@ -678,18 +691,18 @@
3396 fprintf(stdout,"\n ## WARNING: INCOMPLETE MESH %d , %d\n",
3397 mesh->np,mesh->ne);
3398
3399 - if ( MMG_imprim ) fprintf(stdout,"\n -- WRITING DATA FILE %s\n",mesh->outf);
3400 + if ( MMG_imprim && !dataff) fprintf(stdout,"\n -- WRITING DATA FILE %s\n",mesh->outf);
3401 TIM_chrono(ON,&MMG_ctim[1]);
3402 if ( !MMG_unscaleMesh(mesh,sol) ) return(1);
3403 - MMG_saveMesh(mesh,mesh->outf);
3404 + MMG_saveMesh(mesh,mesh->outf,dataff);
3405 if ( info->option == 9 ) {
3406 - MMG_saveSol(mesh,sol,mesh->outf);
3407 - MMG_saveVect(mesh,mesh->move);
3408 + MMG_saveSol(mesh,sol,mesh->outf,dataff);
3409 + MMG_saveVect(mesh,mesh->move,dataff);
3410 }
3411 else
3412 - MMG_saveSol(mesh,sol,mesh->outf);
3413 + MMG_saveSol(mesh,sol,mesh->outf,dataff);
3414 TIM_chrono(OFF,&MMG_ctim[1]);
3415 - if ( MMG_imprim ) fprintf(stdout," -- WRITING COMPLETED\n");
3416 + if ( MMG_imprim && !dataff) fprintf(stdout," -- WRITING COMPLETED\n");
3417
3418 /* free mem */
3419 M_free(mesh->point);
3420 @@ -697,14 +710,42 @@
3421 M_free(mesh->tetra);
3422 /*la desallocation de ce pointeur plante dans certains cas...*/
3423 M_free(mesh->adja);
3424 + /* free FH thank to Iztok Bajc */
3425 + /* if( mesh->outf ) free( mesh->outf ); */
3426 + if(sol->metold ) M_free(sol->metold );
3427 + if(mesh->disp->cold ) M_free(mesh->disp->cold);
3428 + /* ---- */
3429 M_free(mesh->disp->alpha);
3430 M_free(mesh->disp->mv);
3431 M_free(mesh->disp);
3432
3433 - if ( sol->npfixe ) M_free(sol->met);
3434 + if ( sol->met ) M_free(sol->met);
3435 M_free(sol);
3436
3437 if ( MMG_imprim < -4 || info->ddebug ) M_memDump();
3438 M_free(mesh);
3439 + if(MMG_imprim && dataff ) endcod();
3440 + if( M_memLeak() > 1000)
3441 + {
3442 + M_memDump();
3443 + }
3444 return(0);
3445 }
3446 +
3447 +int main(int argc,char *argv[]) {
3448 + return mainmmg3d( argc,argv,0);
3449 +}
3450 +/*
3451 + def
3452 + */
3453 + MMG_Swap MMG_swpptr;
3454 + double (*MMG_length)(double *,double *,double *,double *);
3455 + double (*MMG_caltet)(pMesh ,pSol ,int );
3456 + double (*MMG_calte1)(pMesh ,pSol ,int );
3457 + int (*MMG_caltet2)(pMesh ,pSol ,int ,int ,double ,double *);
3458 + int (*MMG_cavity)(pMesh ,pSol ,int ,int ,pList ,int );
3459 + int (*MMG_buckin)(pMesh ,pSol ,pBucket ,int );
3460 + int (*MMG_optlen)(pMesh ,pSol ,double ,int );
3461 + int (*MMG_interp)(double *,double *,double *,double );
3462 + int (*MMG_optlentet)(pMesh ,pSol ,pQueue ,double ,int ,int );
3463 + int (*MMG_movevertex)(pMesh ,pSol ,int ,int );
3464 --- mmg3d4/build/sources/eigenv.c 2012-12-19 16:05:32.000000000 +0100
3465 +++ mmg3d4-new/build/sources/eigenv.c 2016-01-28 12:10:07.000000000 +0100
3466 @@ -48,7 +48,7 @@
3467 #include <math.h>
3468
3469 /* seeking 1.e-05 accuracy */
3470 -#define EPSD 1.e-15
3471 +#define EPSD 1.e-12
3472 #define EPSD2 1.e-10
3473 #define EPS6 5.e-06
3474 #define EPS 1.e-06