ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/app/mgoperation/src/main.cpp
Revision: 408
Committed: Fri Jun 7 23:02:47 2013 UTC (12 years ago) by francois
File size: 29595 byte(s)
Log Message:
Resolution bug exportation gmsh + unite=0.001 pour les importations step via OCC

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