ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/app/mgoperation/src/main.cpp
Revision: 429
Committed: Fri Sep 27 21:45:39 2013 UTC (11 years, 8 months ago) by francois
File size: 30897 byte(s)
Log Message:
Correction dans l'importation et l'analyse des triangulations. Attention un STL est ecrit en float et non en double

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