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