ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/app/mgoperation/src/main.cpp
Revision: 428
Committed: Fri Sep 27 12:26:07 2013 UTC (11 years, 8 months ago) by francois
File size: 30780 byte(s)
Log Message:
Ajout d'une procedure pour importer des fichiers stl dans magic. Fonction existante dans la vieille version windows mais jamis reintroduite dans la version universelle

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