ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/app/mgoperation/src/main.cpp
Revision: 425
Committed: Tue Sep 24 22:01:46 2013 UTC (11 years, 8 months ago) by francois
File size: 29988 byte(s)
Log Message:
ajout d'une procedure d'analyse de qualité de maillage + amelioration de la sortie sur terminal des informations dans les mailleurs

File Contents

# User Rev Content
1 francois 283
2     //------------------------------------------------------------
3     //------------------------------------------------------------
4     // MAGiC
5     // Jean Christophe Cuilli�e et Vincent FRANCOIS
6     // D�artement de G�ie M�anique - UQTR
7     //------------------------------------------------------------
8     // Le projet MAGIC est un projet de recherche du d�artement
9     // de g�ie m�anique de l'Universit�du Qu�ec �
10     // Trois Rivi�es
11     // Les librairies ne peuvent �re utilis�s sans l'accord
12     // des auteurs (contact : francois@uqtr.ca)
13     //------------------------------------------------------------
14     //------------------------------------------------------------
15     //
16     // main.cpp
17     //
18     //------------------------------------------------------------
19     //------------------------------------------------------------
20     // COPYRIGHT 2000
21     // Version du 02/03/2006 �11H25
22     //------------------------------------------------------------
23     //------------------------------------------------------------
24     #include "gestionversion.h"
25     #ifdef WINDOWS_VERSION
26     #include "fenetre.h"
27     #endif
28    
29    
30     #include <string.h>
31     #include "main.h"
32     #include "mg_file.h"
33     #include "mg_export.h"
34     #include "mg_import.h"
35     #include "mg_lissage.h"
36     #include "step_import.h"
37     #include "acis_import.h"
38     #include "step_import.h"
39     #include "occ_import.h"
40     #include "aide.h"
41 francois 296 #include "mc_gestionnaire.h"
42 francois 283 #include "vct_multi_modele.h"
43 francois 326 #include "mgaster.h"
44 francois 283 #include <ctype.h>
45     #include <math.h>
46 francois 425 #include "mailleur_analyse.h"
47 francois 283
48     //---------------------------------------------------------------------------
49    
50     void affiche(char* message)
51     {
52     #ifdef WINDOWS_VERSION
53     Form1->Memo1->Lines->Add(message);
54     #else
55     std::cout << message << std::endl;
56     #endif
57     }
58    
59     void minuscule(char * mess)
60     {
61     int nb=strlen(mess);
62     for (int i=0;i<nb;i++)
63     mess[i]=tolower(mess[i]);
64     }
65    
66     #ifdef WINDOWS_VERSION
67     int amain(int argc,char **argv)
68     #else
69     int main(int argc,char **argv)
70     #endif
71     {
72 francois 375 affiche((char*)"Operation dans l'environnement MAGiC");
73 francois 283 char nomfichier[3000];
74     char fichierout[3000];
75     char fichieraster[3000];
76     char fichieroptis[3000];
77     char fichierflottant[3000];
78     char fichierdensite[3000];
79 francois 425 char fichierlog[5000];
80 francois 343 fichierdensite[0]=0;
81 francois 283 char coderesu[10];
82 francois 326 int nummai=-1;
83 francois 283 int degre;
84     int action=0;
85     int numgeo=0;
86 gervaislavoie 328 int numcoque=0;
87 francois 283 int numgt=0;
88     int numentite=0;
89     int expand=0;
90     int numsol1=0;
91     int numsol2=0;
92     int numsol3=0;
93     int numchamp1=0;
94     int numchamp2=0;
95     int numchamp3=0;
96     int flottant=0;
97 gervaislavoie 304 int desactivedeforme=0;
98 francois 283 int consimpose=0;
99     int consmailleurauto=0;
100     int consopti=0;
101     double unite=1;
102     double seuil=0.8;
103     double eps=1e-6;
104     double eps2=1.;
105     double niveau=150.;
106     int iter_max = 10;
107     double sigma;
108     double gamma=1.; //par d�faut 1.0
109     double sigmaf=1.; //par d�faut 1.0
110     double sigmag=1.; //par d�faut 1.0
111 francois 343 double limit=0.8;
112 francois 283 int reactivation = 0;
113     int bruitage = 0;
114     int lissage = 0;
115     int importtri=0;
116     sigma = 0.038/sqrt(10.); //valeur par d�faut
117 francois 292 char ccf[500];
118 francois 283 INIAIDE;
119 francois 326 strcpy(coderesu,"11111111");
120 gervaislavoie 328 fichierout[0]=0;
121 francois 425 fichierlog[0]=0;
122 francois 283 if (argc==2) strcpy(nomfichier,argv[1]);
123     else if (argc>2)
124     {
125     for (int i=0;i<argc;i++)
126     {
127     if (strcmp(argv[i],"-file")==0) strcpy(nomfichier,argv[i+1]);
128 francois 425 if (strcmp(argv[i],"-log")==0) strcpy(fichierlog,argv[i+1]);
129 francois 283 if (strcmp(argv[i],"-fileout")==0) strcpy(fichierout,argv[i+1]);
130     if (strcmp(argv[i],"-mesh")==0) nummai=atol(argv[i+1]);
131     if (strcmp(argv[i],"-numsol1")==0) numsol1=atol(argv[i+1]);
132     if (strcmp(argv[i],"-numsol2")==0) numsol2=atol(argv[i+1]);
133     if (strcmp(argv[i],"-numsol3")==0) numsol3=atol(argv[i+1]);
134     if (strcmp(argv[i],"-numchamp1")==0) numchamp1=atol(argv[i+1]);
135     if (strcmp(argv[i],"-numchamp2")==0) numchamp2=atol(argv[i+1]);
136     if (strcmp(argv[i],"-numchamp3")==0) numchamp3=atol(argv[i+1]);
137     if (strcmp(argv[i],"-geo")==0) numgeo=atol(argv[i+1]);
138     if (strcmp(argv[i],"-groupe")==0) numgt=atol(argv[i+1]);
139     if (strcmp(argv[i],"-entite")==0) numentite=atol(argv[i+1]);
140     if (strcmp(argv[i],"-degre")==0) degre=atoi(argv[i+1]);
141     if (strcmp(argv[i],"-unite")==0) unite=atof(argv[i+1]);
142     if (strcmp(argv[i],"-seuil")==0) seuil=atof(argv[i+1]);
143     if (strcmp(argv[i],"-niveau")==0) niveau=atof(argv[i+1]);
144     if (strcmp(argv[i],"-aster")==0) strcpy(fichieraster,argv[i+1]);
145     if (strcmp(argv[i],"-densite")==0) strcpy(fichierdensite,argv[i+1]);
146     if (strcmp(argv[i],"-optis")==0) strcpy(fichieroptis,argv[i+1]);
147     if (strcmp(argv[i],"-ficflottant")==0) strcpy(fichierflottant,argv[i+1]);
148     if (strcmp(argv[i],"-coderesu")==0) strcpy(coderesu,argv[i+1]);
149     if (strcmp(argv[i],"-flottant")==0) flottant = 1;
150     if (strcmp(argv[i],"-eps")==0) eps=atof(argv[i+1]);
151     if (strcmp(argv[i],"-iter")==0) iter_max=atol(argv[i+1]);
152     if (strcmp(argv[i],"-sigma")==0) sigma=atof(argv[i+1]);
153     if (strcmp(argv[i],"-gamma")==0) gamma=atof(argv[i+1]);
154     if (strcmp(argv[i],"-sigmaf")==0) sigmaf=atof(argv[i+1]);
155     if (strcmp(argv[i],"-sigmag")==0) sigmag=atof(argv[i+1]);
156 francois 343 if (strcmp(argv[i],"-seuil")==0) limit=atof(argv[i+1]);
157 francois 331 if (strcmp(argv[i],"-test")==0) action=-10;
158 francois 283 if (strcmp(argv[i],"-fem")==0) action=1;
159     if (strcmp(argv[i],"-femdef")==0) action=15;
160     if (strcmp(argv[i],"-expand")==0) expand=1;
161     if (strcmp(argv[i],"-stepocc")==0) action=2;
162     if (strcmp(argv[i],"-magicgmsh")==0) action=3;
163     if (strcmp(argv[i],"-magicaster")==0) action=4;
164     if (strcmp(argv[i],"-stepmagic")==0) action=5;
165     if (strcmp(argv[i],"-satmagic")==0) action=6;
166     if (strcmp(argv[i],"-cttgmsh")==0) action=7;
167     if (strcmp(argv[i],"-occmagic")==0) action=8;
168     if (strcmp(argv[i],"-astermagic")==0) action=9;
169     if (strcmp(argv[i],"-magicoptis")==0) action=10;
170     if (strcmp(argv[i],"-optismagic")==0) action=11;
171     if (strcmp(argv[i],"-selectionne")==0) action=12;
172     if (strcmp(argv[i],"-deselectionne")==0) action=13;
173     if (strcmp(argv[i],"-examine")==0) action=14;
174     if (strcmp(argv[i],"-fusiongeo")==0) action=17;
175     if (strcmp(argv[i],"-importdensite")==0) action=18;
176     if (strcmp(argv[i],"-lissage")==0) action=16;
177 francois 343 if (strcmp(argv[i],"-lissageiso")==0) action=160;
178 francois 283 if (strcmp(argv[i],"-liss1")==0) lissage = 1;
179     if (strcmp(argv[i],"-liss2")==0) lissage = 2;
180     if (strcmp(argv[i],"-liss3")==0) lissage = 3;
181     if (strcmp(argv[i],"-bruitage")==0) bruitage = 1;
182     if (strcmp(argv[i],"-reactivation")==0) reactivation = 1;
183     if (strcmp(argv[i],"-cons_optimise")==0) consopti = 1;
184     if (strcmp(argv[i],"-cons_impose")==0) consimpose = 1;
185     if (strcmp(argv[i],"-cons_mailleurauto")==0) consmailleurauto = 1;
186     if (strcmp(argv[i],"-importtriangulation")==0) importtri=1;
187     if (strcmp(argv[i],"-importstl")==0) importtri=2;
188     if (strcmp(argv[i],"-deflexion")==0) eps2=atof(argv[i+1]);
189 francois 293 if (strcmp(argv[i],"-ccf_id")==0) {action=19;strcpy(ccf,argv[i+1]);};
190     if (strcmp(argv[i],"-ccft_id")==0) {action=20;strcpy(ccf,argv[i+1]);};
191     if (strcmp(argv[i],"-ccf_num")==0) {action=21;strcpy(ccf,argv[i+1]);};
192     if (strcmp(argv[i],"-ccft_num")==0) {action=22;strcpy(ccf,argv[i+1]);};
193 francois 296 if (strcmp(argv[i],"-ccfhelp")==0) action=23;
194 gervaislavoie 304 if (strcmp(argv[i],"-nodeforme")==0) desactivedeforme=1;
195 francois 326 if (strcmp(argv[i],"-calculaster")==0) action=24;
196 gervaislavoie 328 if (strcmp(argv[i],"-orienter")==0) {action=25;numcoque=atol(argv[i+1]);};
197     }
198 francois 283 }
199     else {
200 francois 375 GESTIONVERSION v;
201     char version[500];
202     v.print(version);
203     affiche(version);
204 francois 283 AFFAIDE;
205     return 0;
206     }
207 francois 296 char mess[3000];
208     char *p;
209     char extension[50];
210     char chaine[3000];
211    
212     if (strcmp(nomfichier,"-ccfhelp")==0) action=23;
213     else
214     {
215 francois 283
216     sprintf(mess," Fichier : %s",nomfichier);
217     affiche(mess);
218 francois 296 p=strrchr(nomfichier,'.');
219 francois 283 strcpy(extension,p);
220     minuscule(extension);
221     for (int i=0;i<3000;i++) chaine[i]=0;
222 francois 296 }
223 francois 283 if ( ((strcmp(extension,".magic")==0) && (action==0)) || (action==3))
224     {
225     sprintf(mess," Conversion MAGiC vers GMSH");
226     affiche(mess);
227     MG_FILE gest(nomfichier);
228     int nb=gest.get_nb_mg_maillage();
229     char chaine[3000];
230     for (int i=0;i<nb;i++)
231     {
232     MG_MAILLAGE* mai=gest.get_mg_maillage(i);
233     unsigned long id=mai->get_id();
234     strncpy(chaine,nomfichier,p-nomfichier);
235     char chaine2[3000];
236     sprintf(chaine2,"%s%lu",chaine,id);
237     std::string namefic=chaine2;
238     MG_EXPORT exp;
239 francois 339 sprintf(mess," Maillage geometrique : creation de %s.msh",namefic.c_str());
240 francois 331 affiche(mess);
241     exp.gmsh(mai,namefic);
242 francois 283 }
243     nb=gest.get_nb_fem_maillage();
244     for (int i=0;i<nb;i++)
245     {
246     FEM_MAILLAGE* mai=gest.get_fem_maillage(i);
247 gervaislavoie 304 if (desactivedeforme==1) mai->desactive_deforme();
248     unsigned long id=mai->get_id();
249 francois 283 strncpy(chaine,nomfichier,p-nomfichier);
250     char chaine2[3000];
251     sprintf(chaine2,"%s%lu",chaine,id);
252     std::string namefic=chaine2;
253     MG_EXPORT exp;
254 francois 331 sprintf(mess," Maillage EF : Creation de %s.msh",namefic.c_str());
255     affiche(mess);
256     exp.gmsh(mai,namefic);
257 francois 283 }
258     }
259 francois 331 if (action==-10)
260     {
261     MG_FILE gest(nomfichier);
262     gest.enregistrer(fichierout);
263     }
264 francois 283 if (action==4)
265     {
266     sprintf(mess," Conversion MAGiC vers code ASTER");
267     affiche(mess);
268     MG_FILE gest(nomfichier);
269     int nb=gest.get_nb_fem_maillage();
270     char chaine[1000];
271     for (int i=0;i<nb;i++)
272     {
273     FEM_MAILLAGE* mai=gest.get_fem_maillage(i);
274 francois 319 MG_VOLUME* vol=mai->get_mg_geometrie()->get_mg_volume(0);
275     MG_COQUE* coq=mai->get_mg_geometrie()->get_mg_coque(0);
276 francois 283 unsigned long id=mai->get_id();
277     strncpy(chaine,nomfichier,p-nomfichier);
278     char chaine2[3000];
279     sprintf(chaine2,"%s%lu",chaine,id);
280     std::string namefic=chaine2;
281     MG_EXPORT exp;
282 francois 319 if (vol!=NULL) exp.aster(vol,mai,namefic,0,coderesu);
283     if (coq!=NULL) exp.aster(coq,mai,namefic,0,coderesu);
284 francois 283 }
285     }
286     if (((strcmp(extension,".ctt")==0) && (action==0)) || (action==7))
287     {
288     sprintf(mess," Conversion carte de taille vers GMSH");
289     affiche(mess);
290     FCT_GENERATEUR_3D<4> carte;
291     carte.lire(nomfichier);
292     strncpy(chaine,nomfichier,p-nomfichier);
293     std::string namefic=chaine;
294     MG_EXPORT exp;
295     exp.gmsh(&carte,namefic);
296     }
297 francois 295 #ifdef BREP_STEP
298 francois 283 if (((strcmp(extension,".step")==0) &&(action==0)) || (action==5))
299     {
300     sprintf(mess," Conversion STEP vers MAGiC");
301     affiche(mess);
302     STEP_IMPORT stepimport;
303     MG_GESTIONNAIRE gest;
304     stepimport.importer(gest,nomfichier) ;
305     strncpy(chaine,nomfichier,p-nomfichier);
306     std::string namefic=chaine;
307     namefic=namefic + ".magic";
308     int nb=gest.get_nb_mg_geometrie();
309     for (int i=0;i<nb;i++)
310     gest.get_mg_geometrie(i)->change_valeur_unite(unite);
311     gest.enregistrer(namefic.c_str());
312     }
313 francois 295 #endif
314     #ifdef BREP_SAT
315 francois 283 if (((strcmp(extension,".sat")==0) && (action==0)) || (action==6))
316     {
317     sprintf(mess," Conversion SAT vers MAGiC");
318     affiche(mess);
319     MG_GESTIONNAIRE gest;
320     ACIS_IMPORT acisimport;
321     acisimport.importer(gest,nomfichier) ;
322     strncpy(chaine,nomfichier,p-nomfichier);
323     std::string namefic=chaine;
324     namefic=namefic + ".magic";
325     int nb=gest.get_nb_mg_geometrie();
326     for (int i=0;i<nb;i++)
327     gest.get_mg_geometrie(i)->change_valeur_unite(unite);
328     gest.enregistrer(namefic.c_str());
329     }
330 francois 295 #endif
331 francois 283 if (((strcmp(extension,".brep")==0) && (action==0)) ||(action==8))
332     {
333     #ifdef BREP_OCC
334     sprintf(mess," Conversion OpenCascade vers MAGiC");
335     affiche(mess);
336     MG_GESTIONNAIRE gest;
337     OCC_IMPORT occimport;
338     MG_GEOMETRIE* mggeo=occimport.importer(gest,nomfichier,FICHIEROCC,unite,eps) ;
339     if (importtri>0) occimport.importer(gest,mggeo,eps2,importtri);
340     strncpy(chaine,nomfichier,p-nomfichier);
341     std::string namefic=chaine;
342     namefic=namefic + ".magic";
343     int nb=gest.get_nb_mg_geometrie();
344     for (int i=0;i<nb;i++)
345     gest.get_mg_geometrie(i)->change_valeur_unite(unite);
346     gest.enregistrer(namefic.c_str());
347     #endif
348     }
349     if (action==2)
350     {
351     #ifdef BREP_OCC
352     sprintf(mess," Conversion STEP via OpenCascade vers MAGiC avec epsilon=%lf",eps);
353     affiche(mess);
354     MG_GESTIONNAIRE gest;
355     OCC_IMPORT occimport;
356 francois 408 MG_GEOMETRIE* mggeo=occimport.importer(gest,nomfichier,FICHIERSTEP,0.001,eps) ;
357 francois 283 if (importtri>0) occimport.importer(gest,mggeo,eps2,importtri);
358     strncpy(chaine,nomfichier,p-nomfichier);
359     std::string namefic=chaine;
360     namefic=namefic + ".magic";
361     int nb=gest.get_nb_mg_geometrie();
362     for (int i=0;i<nb;i++)
363     gest.get_mg_geometrie(i)->change_valeur_unite(unite);
364     gest.enregistrer(namefic.c_str());
365     #endif
366     }
367     if (action==1)
368     {
369     sprintf(mess," Creation d'un maillage FEM");
370     affiche(mess);
371     MG_FILE gest(nomfichier);
372     MG_MAILLAGE* mai=gest.get_mg_maillageid(nummai);
373     FEM_MAILLAGE* fem=new FEM_MAILLAGE(mai->get_mg_geometrie(),mai,degre);
374     gest.ajouter_fem_maillage(fem);
375     fem->construire(0);
376     gest.enregistrer(nomfichier);
377     }
378     if (action==9)
379     {
380     sprintf(mess," Importation des résultats ASTER vers MAGIC");
381     affiche(mess);
382     MG_FILE gest(nomfichier);
383     FEM_MAILLAGE* mai=gest.get_fem_maillageid(nummai);
384     MG_IMPORT imp;
385 francois 322 imp.aster(mai,fichieraster,nomfichier);
386 francois 283 gest.enregistrer(nomfichier);
387     }
388     if (action==10)
389     {
390     sprintf(mess," Conversion MAGiC vers OPTIS");
391     affiche(mess);
392     MG_FILE gest(nomfichier);
393     int nb=gest.get_nb_fem_maillage();
394     char chaine[1000];
395     for (int i=0;i<nb;i++)
396     {
397     FEM_MAILLAGE* mai=gest.get_fem_maillage(i);
398     unsigned long id=mai->get_id();
399     strncpy(chaine,nomfichier,p-nomfichier);
400     char chaine2[3000];
401     sprintf(chaine2,"%s%lu",chaine,id);
402     std::string namefic=chaine2;
403     MG_EXPORT exp;
404 francois 319 MG_VOLUME* vol=mai->get_mg_geometrie()->get_mg_volume(0);
405     MG_COQUE* coq=mai->get_mg_geometrie()->get_mg_coque(0);
406     if (vol!=NULL) exp.aster(vol,mai,namefic,1,coderesu);
407     if (coq!=NULL) exp.aster(coq,mai,namefic,1,coderesu);
408 francois 283 }
409     }
410     if (action==11)
411     {
412     sprintf(mess," Importation des résultats d'optimisation vers MAGIC");
413     affiche(mess);
414     MG_FILE gest(nomfichier);
415     FEM_MAILLAGE* mai=gest.get_fem_maillageid(nummai);
416     MG_IMPORT imp;
417     imp.optis(mai,fichieroptis,fichierflottant,seuil,niveau,flottant);
418     gest.enregistrer(nomfichier);
419     }
420     if (action==12)
421     {
422     sprintf(mess," Selection dans MAGIC");
423     affiche(mess);
424     MG_FILE gest(nomfichier);
425     MG_GEOMETRIE* mggeo=gest.get_mg_geometrieid(numgeo);
426     MG_GROUPE_TOPOLOGIQUE* mggt;
427     if (numgt==0)
428     {
429     mggt=new MG_GROUPE_TOPOLOGIQUE;
430     mggeo->ajouter_mg_groupe_topologique(mggt);
431     }
432     else mggt=mggeo->get_mg_groupe_topologiqueid(numgt);
433     MG_ELEMENT_TOPOLOGIQUE* ele;
434     ele=mggeo->get_mg_sommetid(numentite);
435     if (ele==NULL) ele=mggeo->get_mg_areteid(numentite);
436     if (ele==NULL) ele=mggeo->get_mg_faceid(numentite);
437     if (ele==NULL) ele=mggeo->get_mg_volumeid(numentite);
438     if (ele!=NULL)
439     {
440     mggt->ajouter(ele);
441     if (expand)
442     {
443     TPL_MAP_ENTITE<MG_ELEMENT_TOPOLOGIQUE*> lst;
444     ele->get_topologie_sousjacente(&lst);
445     TPL_MAP_ENTITE<MG_ELEMENT_TOPOLOGIQUE*>::ITERATEUR it;
446     for (MG_ELEMENT_TOPOLOGIQUE *ele2=lst.get_premier(it);ele2!=NULL;ele2=lst.get_suivant(it))
447     mggt->ajouter(ele2);
448     }
449     }
450     gest.enregistrer(nomfichier);
451     }
452     if (action==13)
453     {
454     sprintf(mess," Deselection dans MAGIC");
455     affiche(mess);
456     MG_FILE gest(nomfichier);
457     MG_GEOMETRIE* mggeo=gest.get_mg_geometrieid(numgeo);
458     MG_GROUPE_TOPOLOGIQUE* mggt=mggeo->get_mg_groupe_topologiqueid(numgt);
459     MG_ELEMENT_TOPOLOGIQUE* ele;
460     ele=mggeo->get_mg_sommetid(numentite);
461     if (ele==NULL) ele=mggeo->get_mg_areteid(numentite);
462     if (ele==NULL) ele=mggeo->get_mg_faceid(numentite);
463     if (ele==NULL) ele=mggeo->get_mg_volumeid(numentite);
464     if (ele!=NULL)
465     {
466     mggt->supprimer(ele);
467     if (expand)
468     {
469     TPL_MAP_ENTITE<MG_ELEMENT_TOPOLOGIQUE*> lst;
470     ele->get_topologie_sousjacente(&lst);
471     TPL_MAP_ENTITE<MG_ELEMENT_TOPOLOGIQUE*>::ITERATEUR it;
472     for (MG_ELEMENT_TOPOLOGIQUE *ele2=lst.get_premier(it);ele2!=NULL;ele2=lst.get_suivant(it))
473     mggt->supprimer(ele2);
474     }
475     }
476     gest.enregistrer(nomfichier);
477     }
478 francois 343 if ((action==16) || (action==160))
479 francois 283 {
480     sprintf(mess," Lissage de l'enveloppe externe du maillage optimisee");
481     affiche(mess);
482 francois 343 affiche ("");
483     affiche ("");
484     affiche ("Lecture fichier");
485     MG_FILE gest(nomfichier);
486 francois 283 FEM_MAILLAGE* mai=gest.get_fem_maillageid(nummai);
487     MG_GESTIONNAIRE gest2;
488     MG_LISSAGE liss;
489     liss.active_affichage(affiche);
490 francois 343 if (action==16) liss.lisse(mai,gest2,eps,sigma,sigmaf,sigmag,gamma,iter_max,reactivation,bruitage,lissage,consopti,consimpose,consmailleurauto);
491     if (action==160)
492     {
493     FEM_SOLUTION* sol=gest.get_fem_solutionid(numsol1);
494     liss.extract_skin_par_decoupage(sol,limit,gest2,lissage,eps,sigma,gamma,iter_max,sigmaf,sigmag,fichierdensite);
495     }
496 francois 283 gest2.enregistrer(fichierout);
497     }
498     sprintf(mess,"Conversion reussie");
499    
500     if (action==14)
501     {
502     sprintf(mess," Analyse MAGIC");
503     affiche(mess);
504     MG_FILE gest(nomfichier);
505 francois 425 if (nummai!=-1)
506     {
507     MG_MAILLAGE* mai=gest.get_mg_maillageid(nummai);
508     MAILLEUR_ANALYSE m3d(mai);
509     m3d.active_affichage(affiche);
510     if (fichierlog[0]==0)
511     m3d.analyse();
512     else
513     m3d.analyse(fichierlog);
514     }
515     else
516     {
517     char message [5000];
518 francois 283 int nbgeo=gest.get_nb_mg_geometrie();
519     sprintf(message," %d geometrie :",nbgeo);
520     for (int i=0;i<nbgeo;i++)
521     {
522     MG_GEOMETRIE* geo=gest.get_mg_geometrie(i);
523     sprintf(message,"%s %lu ",message,geo->get_id());
524     }
525     affiche(message);
526     for (int i=0;i<nbgeo;i++)
527     {
528     MG_GEOMETRIE* geo=gest.get_mg_geometrie(i);
529     sprintf(message," geometrie %lu",geo->get_id());
530     affiche(message);
531     int nbmg=geo->get_nb_mg_groupe_topologique();
532     sprintf(message," %d groupe topologique",nbmg);
533     for (int j=0;j<nbmg;j++)
534     {
535     MG_GROUPE_TOPOLOGIQUE* mggp=geo->get_mg_groupe_topologique(j);
536     sprintf(message,"%s %lu ",message,mggp->get_id());
537     }
538     affiche(message);
539 francois 299 int nbvolume=geo->get_nb_mg_volume();
540     if (nbvolume==0) sprintf(message," %d volumes",geo->get_nb_mg_volume());
541     else sprintf(message," %d volumes : ",geo->get_nb_mg_volume());
542     for (int i=0;i<nbvolume;i++) sprintf(message,"%s %lu",message,geo->get_mg_volume(i)->get_id());
543 francois 290 affiche(message);
544 francois 299 int nbcoque=geo->get_nb_mg_coque();
545     if (nbcoque==0) sprintf(message," %d coques",geo->get_nb_mg_coque());
546     else sprintf(message," %d coques : ",geo->get_nb_mg_coque());
547     for (int i=0;i<nbcoque;i++) sprintf(message,"%s %lu",message,geo->get_mg_coque(i)->get_id());
548 francois 290 affiche(message);
549 francois 299 int nbpoutre=geo->get_nb_mg_poutre();
550     if (nbpoutre==0) sprintf(message," %d poutres",geo->get_nb_mg_poutre());
551     else sprintf(message," %d poutres : ",geo->get_nb_mg_poutre());
552     for (int i=0;i<nbpoutre;i++) sprintf(message,"%s %lu",message,geo->get_mg_poutre(i)->get_id());
553     affiche(message);
554 francois 290 sprintf(message," %d coquilles",geo->get_nb_mg_coquille());
555     affiche(message);
556 francois 283 sprintf(message," %d faces",geo->get_nb_mg_face());
557     affiche(message);
558     sprintf(message," %d aretes",geo->get_nb_mg_arete());
559     affiche(message);
560     sprintf(message," %d sommets",geo->get_nb_mg_sommet());
561     affiche(message);
562 francois 425
563 francois 283
564     }
565     int nbmai=gest.get_nb_mg_maillage();
566     sprintf(message," %d maillage geometrique :",nbmai);
567     affiche(message);
568     for (int i=0;i<nbmai;i++)
569     {
570     MG_MAILLAGE* mai=gest.get_mg_maillage(i);
571     sprintf(message," maillage geometrique %lu ",mai->get_id());
572     affiche(message);
573     sprintf(message," %d noeuds",mai->get_nb_mg_noeud());
574     affiche(message);
575     sprintf(message," %d segments",mai->get_nb_mg_segment());
576     affiche(message);
577     sprintf(message," %d triangles",mai->get_nb_mg_triangle());
578     affiche(message);
579     sprintf(message," %d tetras",mai->get_nb_mg_tetra());
580     affiche(message);
581     }
582     int nbmaif=gest.get_nb_fem_maillage();
583     sprintf(message," %d maillage FEM :",nbmaif);
584     affiche(message);
585     for (int i=0;i<nbmaif;i++)
586     {
587     FEM_MAILLAGE* maif=gest.get_fem_maillage(i);
588     sprintf(message," maillage FEM %lu ",maif->get_id());
589     affiche(message);
590     sprintf(message," %d noeuds",maif->get_nb_fem_noeud());
591     affiche(message);
592 francois 309 sprintf(message," %d elements 1D",maif->get_nb_fem_element1());
593 francois 283 affiche(message);
594 francois 309 sprintf(message," %d elements 2D",maif->get_nb_fem_element2());
595 francois 283 affiche(message);
596 francois 309 sprintf(message," %d elements 3D",maif->get_nb_fem_element3());
597 francois 283 affiche(message);
598 francois 325 double rx,ry,rz;
599     maif->calcul_somme_reaction(rx,ry,rz);
600     sprintf(message," Reactions : \n Rx=%lf\n Ry=%lf\n Rz=%lf",rx,ry,rz);
601     affiche(message);
602    
603 francois 283 }
604     int nbsol=gest.get_nb_mg_solution();
605     sprintf(message," %d solution maillage geometrique :",nbsol);
606     for (int i=0;i<nbsol;i++)
607     {
608     MG_SOLUTION* sol=gest.get_mg_solution(i);
609     sprintf(message,"%s %lu ",message,sol->get_id());
610     }
611     affiche(message);
612     int nbsolf=gest.get_nb_fem_solution();
613     sprintf(message," %d solution maillage FEM :",nbsolf);
614     for (int i=0;i<nbsolf;i++)
615     {
616     FEM_SOLUTION* sol=gest.get_fem_solution(i);
617     sprintf(message,"%s %lu ",message,sol->get_id());
618     }
619     affiche(message);
620 francois 425 }
621 francois 283 }
622     if (action==15)
623     {
624     sprintf(mess," Calcul de deforme");
625     affiche(mess);
626     MG_FILE gest(nomfichier);
627     FEM_MAILLAGE* mai=gest.get_fem_maillageid(nummai);
628     FEM_SOLUTION* sol1=gest.get_fem_solutionid(numsol1);
629     FEM_SOLUTION* sol2=gest.get_fem_solutionid(numsol2);
630     FEM_SOLUTION* sol3=gest.get_fem_solutionid(numsol3);
631     mai->calcul_deforme(sol1,numchamp1,sol2,numchamp2,sol3,numchamp3);
632     gest.enregistrer(nomfichier);
633     }
634     if (action==17)
635     {
636     sprintf(mess," Fusion de géométrie");
637     affiche(mess);
638     MG_FILE gest(nomfichier);
639     MG_GEOMETRIE* mggeo=gest.get_mg_geometrieid(numgeo);
640     VCT_MULTI_MODELE fusion(mggeo);
641     fusion.recherche_identite();
642     gest.enregistrer(nomfichier);
643     }
644     if (action==18)
645     {
646 francois 292 sprintf(mess," Création d'une pseudo-solution de la répartition de densite");
647 francois 283 affiche(mess);
648     MG_FILE gest(nomfichier);
649     FEM_MAILLAGE* mai=gest.get_fem_maillageid(nummai);
650     MG_IMPORT imp;
651 gervaislavoie 302 imp.import_densite(mai,fichierdensite,nomfichier,3);
652 francois 283 gest.enregistrer(nomfichier);
653     }
654 francois 293 if ((action==19) || (action==20))
655 francois 292 {
656 francois 296 unsigned long identity;
657     char typeccf[3];
658 gervaislavoie 318 typeccf[2]=0;
659 gervaislavoie 302 double valccf=0.5; // Valeur par défaut
660 francois 296 sscanf(ccf,"%lu:%c%c:%le\n",&identity,&typeccf[0],&typeccf[1],&valccf);
661     MC_GESTIONNAIRE mcgest;
662     int res=mcgest.existe(typeccf);
663     if (res==0)
664     {
665     sprintf(mess," ERREUR!!!! Code conditions aux limites inconnu");
666     affiche(mess);
667     return 0;
668     }
669     sprintf(mess," Ajout d'une condition aux limites : %s",mcgest.get_description(typeccf).c_str());
670 francois 292 affiche(mess);
671     MG_FILE gest(nomfichier);
672     MG_GEOMETRIE* geo=gest.get_mg_geometrieid(numgeo);
673     TPL_MAP_ENTITE<MG_ELEMENT_TOPOLOGIQUE*> liste;
674 francois 296 MG_VOLUME* ele;
675     ele=geo->get_mg_volumeid(identity);
676 francois 292 if (ele!=NULL) liste.ajouter(ele);
677 francois 296 else
678     {
679     MG_COQUE* ele;
680     ele=geo->get_mg_coqueid(identity);
681     if (ele!=NULL) liste.ajouter(ele);
682     else
683 francois 292 {
684 francois 296 MG_POUTRE* ele;
685     ele=geo->get_mg_poutreid(identity);
686 francois 292 if (ele!=NULL) liste.ajouter(ele);
687     else
688 francois 296 {
689     MG_FACE* ele;
690     ele=geo->get_mg_faceid(identity);
691     if (ele!=NULL) liste.ajouter(ele);
692     else
693     {
694     MG_ARETE* ele;
695     ele=geo->get_mg_areteid(identity);
696     if (ele!=NULL) liste.ajouter(ele);
697     else
698     {
699     MG_SOMMET* ele;
700     ele=geo->get_mg_sommetid(identity);
701     if (ele!=NULL) liste.ajouter(ele);
702     }
703     }
704     }
705 francois 292 }
706 francois 296 }
707 francois 292 if (action==20)
708     {
709     int nb=liste.get_nb();
710     for (int i=0;i<nb;i++) liste.get(i)->get_topologie_sousjacente(&liste);
711     }
712     int nb=liste.get_nb();
713     for (int i=0;i<nb;i++) liste.get(i)->ajouter_ccf(typeccf,valccf);;
714     gest.enregistrer(nomfichier);
715     }
716 francois 293 if ((action==21)|| (action==22))
717     {
718 francois 296 MC_GESTIONNAIRE mcgest;
719     unsigned long identity;
720 francois 293 char typeccf[3];
721     double valccf=0.5;
722     char c;
723     sscanf(ccf,"%c:%lu:%c%c:%le\n",&c,&identity,&typeccf[0],&typeccf[1],&valccf);
724 francois 296 int res=mcgest.existe(typeccf);
725     if (res==0)
726     {
727     sprintf(mess," ERREUR!!!! Code conditions aux limites inconnu");
728     affiche(mess);
729     return 0;
730     }
731     sprintf(mess," Ajout d'une condition aux limites : %s",mcgest.get_description(typeccf).c_str());
732     affiche(mess);
733     MG_FILE gest(nomfichier);
734     MG_GEOMETRIE* geo=gest.get_mg_geometrieid(numgeo);
735     TPL_MAP_ENTITE<MG_ELEMENT_TOPOLOGIQUE*> liste;
736 francois 293 MG_FACE* ele=NULL;
737     if (c=='F') ele=geo->get_mg_face(identity);
738     if (ele!=NULL) liste.ajouter(ele);
739     else
740     {
741     MG_ARETE* ele=NULL;
742     if (c=='A') ele=geo->get_mg_arete(identity);
743     if (ele!=NULL) liste.ajouter(ele);
744     else
745     {
746     MG_SOMMET* ele=NULL;
747     if (c=='S') ele=geo->get_mg_sommet(identity);
748     if (ele!=NULL) liste.ajouter(ele);
749 francois 296 else
750     {
751     MG_VOLUME* ele=NULL;
752     if (c=='V') ele=geo->get_mg_volume(identity);
753     if (ele!=NULL) liste.ajouter(ele);
754     else
755     {
756     MG_COQUE* ele=NULL;
757     if (c=='C') ele=geo->get_mg_coque(identity);
758     if (ele!=NULL) liste.ajouter(ele);
759     else
760     {
761     MG_POUTRE* ele=NULL;
762     if (c=='P') ele=geo->get_mg_poutre(identity);
763     if (ele!=NULL) liste.ajouter(ele);
764    
765     }
766     }
767     }
768 francois 293 }
769     }
770     if (action==22)
771     {
772     int nb=liste.get_nb();
773     for (int i=0;i<nb;i++) liste.get(i)->get_topologie_sousjacente(&liste);
774     }
775     int nb=liste.get_nb();
776     for (int i=0;i<nb;i++) liste.get(i)->ajouter_ccf(typeccf,valccf);;
777     gest.enregistrer(nomfichier);
778     }
779 francois 296 if (action==23)
780     {
781     sprintf(mess," Liste des conditions aux limites disponibles");
782     affiche(mess);
783     MC_GESTIONNAIRE mcgest;
784     int ok=0;
785     do
786     {
787     std::string code;
788     std::string description;
789     int res=mcgest.get_description(code,description);
790     if (res)
791     {
792     sprintf(mess," %s : %s",code.c_str(),description.c_str());
793     affiche(mess);
794     }
795     else ok=1;
796     }
797     while (ok==0);
798     }
799 francois 326 if (action==24)
800     {
801     char nometude[1000];
802     char *p=strchr(nomfichier,'.');
803     strncpy(nometude,nomfichier,p-nomfichier);
804     nometude[p-nomfichier]=0;
805     MG_FILE gest(nomfichier);
806     FEM_MAILLAGE* mai;
807     if (nummai!=-1) mai=gest.get_fem_maillageid(nummai); else mai=gest.get_fem_maillage(0);
808     MGASTER mgaster;
809     mgaster.active_affichage(affiche);
810 francois 327 mgaster.calcule(mai,nometude,coderesu);
811 francois 326 }
812 gervaislavoie 328 if (action==25)
813     {
814     sprintf(mess," Orientation d'une coque");
815     affiche(mess);
816     MG_FILE gest(nomfichier);
817     MG_GEOMETRIE* geo=gest.get_mg_geometrieid(numgeo);
818     MG_MAILLAGE* mai=gest.get_mg_maillageid(nummai);
819     MG_COQUE* coque=mai->get_mg_geometrie()->get_mg_coqueid(numcoque);
820     coque->orienter(mai);
821     if (fichierout[0]==0) strcpy(fichierout,nomfichier);
822     gest.enregistrer(fichierout);
823     }
824 francois 296 sprintf(mess,"Fin");
825 francois 283 affiche(mess);
826    
827     return 0;
828 francois 326
829 francois 283 }
830    
831    
832    
833     #pragma package(smart_init)