1 |
|
5 |
//------------------------------------------------------------
|
2 |
|
|
//------------------------------------------------------------
|
3 |
|
|
// MAGiC
|
4 |
|
|
// Jean Christophe Cuilli�e et Vincent FRANCOIS
|
5 |
|
|
// D�artement de G�ie M�anique - UQTR
|
6 |
|
|
//------------------------------------------------------------
|
7 |
|
|
// Le projet MAGIC est un projet de recherche du d�artement
|
8 |
|
|
// de g�ie m�anique de l'Universit�du Qu�ec �
|
9 |
|
|
// Trois Rivi�es
|
10 |
|
|
// Les librairies ne peuvent �re utilis�s sans l'accord
|
11 |
|
|
// des auteurs (contact : francois@uqtr.ca)
|
12 |
|
|
//------------------------------------------------------------
|
13 |
|
|
//------------------------------------------------------------
|
14 |
|
|
//
|
15 |
|
|
// main.cpp
|
16 |
|
|
//
|
17 |
|
|
//------------------------------------------------------------
|
18 |
|
|
//------------------------------------------------------------
|
19 |
|
|
// COPYRIGHT 2000
|
20 |
|
|
// Version du 02/03/2006 �11H25
|
21 |
|
|
//------------------------------------------------------------
|
22 |
|
|
//------------------------------------------------------------
|
23 |
|
|
#include "gestionversion.h"
|
24 |
|
|
#ifdef WINDOWS_VERSION
|
25 |
|
|
#include "fenetre.h"
|
26 |
|
|
#endif
|
27 |
|
|
|
28 |
|
|
#pragma hdrstop
|
29 |
|
|
|
30 |
|
|
#include "main.h"
|
31 |
|
|
#include "mg_file.h"
|
32 |
|
|
#include "fct_taille.h"
|
33 |
|
|
#include "mailleur0d.h"
|
34 |
|
|
#include "mailleur1d.h"
|
35 |
|
|
#include "mailleur2d.h"
|
36 |
|
|
#include "mailleur3d.h"
|
37 |
francois |
56 |
#include "mailleur_adaptatif.h"
|
38 |
|
5 |
#include "mailleur3d_dia.h"
|
39 |
|
|
#include "fct_generateur_3D.h"
|
40 |
francois |
56 |
#include "mg_export.h"
|
41 |
|
5 |
|
42 |
|
|
//---------------------------------------------------------------------------
|
43 |
|
|
|
44 |
|
|
void affiche(char* message)
|
45 |
|
|
{
|
46 |
|
|
#ifdef WINDOWS_VERSION
|
47 |
|
|
Form1->Memo1->Lines->Add(message);
|
48 |
|
|
#else
|
49 |
|
|
std::cout << message << std::endl;
|
50 |
|
|
#endif
|
51 |
|
|
}
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
#ifdef WINDOWS_VERSION
|
56 |
|
|
int amain(int argc,char **argv)
|
57 |
|
|
#else
|
58 |
|
|
int main(int argc,char **argv)
|
59 |
|
|
#endif
|
60 |
|
|
{
|
61 |
|
|
if (argc<3) return 1;
|
62 |
francois |
56 |
char fichier[1000],fichier2[1000],fichiercarte[1000];
|
63 |
|
|
int typecarte,niveau=3,numgeometrie=0,adapt=0,nummaillage=0;
|
64 |
|
|
int exportgmsh=0;
|
65 |
|
|
int diff=0;
|
66 |
|
5 |
double eps,dg,prioritemetrique=0.65;
|
67 |
|
|
for (int i=0;i<argc;i++)
|
68 |
|
|
{
|
69 |
|
|
if (strcmp(argv[i],"-magic")==0) strcpy(fichier,argv[i+1]);
|
70 |
|
|
if (strcmp(argv[i],"-typecarte")==0) typecarte=atoi(argv[i+1]);
|
71 |
|
|
if (strcmp(argv[i],"-carte")==0) strcpy(fichiercarte,argv[i+1]);
|
72 |
|
|
if (strcmp(argv[i],"-eng")==0) dg=atof(argv[i+1]);
|
73 |
|
|
if (strcmp(argv[i],"-eps")==0) eps=atof(argv[i+1]);
|
74 |
|
|
if (strcmp(argv[i],"-niveau")==0) niveau=atoi(argv[i+1]);
|
75 |
|
|
if (strcmp(argv[i],"-prioritemetrique")==0) prioritemetrique=atof(argv[i+1]);
|
76 |
|
|
if (strcmp(argv[i],"-numgeo")==0) numgeometrie=atoi(argv[i+1]);
|
77 |
francois |
56 |
if (strcmp(argv[i],"-adapt")==0) adapt=1;
|
78 |
|
|
if (strcmp(argv[i],"-nummai")==0) nummaillage=atoi(argv[i+1]);
|
79 |
|
|
if (strcmp(argv[i],"-exportgmsh")==0) exportgmsh=1;;
|
80 |
|
|
if (strcmp(argv[i],"-out")==0) {strcpy(fichier2,argv[i+1]);diff=1;}
|
81 |
|
5 |
}
|
82 |
|
|
char message[500];
|
83 |
|
|
char nomtypecarte[9][9]={"Standard","Fichier"};
|
84 |
francois |
56 |
if (adapt)
|
85 |
|
|
{
|
86 |
|
|
affiche("Adaptation de maillage");
|
87 |
|
|
sprintf(message," Fichier magic : %s",fichier);affiche(message);
|
88 |
|
|
sprintf(message," Numero de maillage : %d",nummaillage);affiche(message);
|
89 |
|
|
sprintf(message," Carte : %s",fichiercarte);affiche(message);
|
90 |
|
|
MG_FILE gest(fichier);
|
91 |
|
|
MG_MAILLAGE* mai=gest.get_mg_maillageid(nummaillage);
|
92 |
|
|
FCT_GENERATEUR_3D<4> carte;
|
93 |
|
|
FCT_TAILLE* metrique;
|
94 |
|
|
carte.lire(fichiercarte);
|
95 |
|
|
metrique=&carte;
|
96 |
|
|
MG_MAILLAGE* nvmai=new MG_MAILLAGE(mai->get_mg_geometrie());
|
97 |
|
|
gest.ajouter_mg_maillage(nvmai);
|
98 |
|
|
MAILLEUR_ADAPTATIF mesh(mai,nvmai,metrique);
|
99 |
|
|
mesh.active_affichage(affiche);
|
100 |
|
|
mesh.maille();
|
101 |
|
|
affiche("Enregistrement");
|
102 |
|
|
if (diff) strcpy(fichier,fichier2);
|
103 |
|
|
strcat(fichier,".magic");
|
104 |
|
|
gest.enregistrer(fichier);
|
105 |
|
|
if (exportgmsh)
|
106 |
|
|
{
|
107 |
|
|
affiche("Exportation GMSH");
|
108 |
|
|
MG_EXPORT exp;
|
109 |
|
|
exp.gmsh(mai,fichier);
|
110 |
|
|
}
|
111 |
|
|
affiche("Fin");
|
112 |
|
|
return 1;
|
113 |
|
|
}
|
114 |
|
|
affiche("Paramétre d'étude");
|
115 |
|
5 |
sprintf(message," Fichier magic : %s",fichier);affiche(message);
|
116 |
francois |
56 |
sprintf(message," Numero de géométrie : %d",numgeometrie);affiche(message);
|
117 |
|
5 |
sprintf(message," Type de carte : %s",nomtypecarte[typecarte-1]);affiche(message);
|
118 |
|
|
if (typecarte==1)
|
119 |
|
|
{
|
120 |
|
|
sprintf(message," Eng : %f",dg);affiche(message);
|
121 |
|
|
sprintf(message," eps : %f",eps);affiche(message);
|
122 |
|
|
}
|
123 |
|
|
if (typecarte==2)
|
124 |
|
|
{
|
125 |
|
|
sprintf(message," Fichier carte : %s",fichiercarte);affiche(message);
|
126 |
|
|
}
|
127 |
|
|
sprintf(message," Parametre de metrique : %2.2f%",prioritemetrique*100);affiche(message);
|
128 |
|
|
affiche("Lecture du fichier M.A.G.i.C");
|
129 |
|
|
MG_FILE gest(fichier);
|
130 |
|
|
MG_GEOMETRIE* mggeo=gest.get_mg_geometrie(numgeometrie);
|
131 |
|
|
MG_MAILLAGE* mgmai=new MG_MAILLAGE(mggeo);
|
132 |
|
|
gest.ajouter_mg_maillage(mgmai);
|
133 |
|
|
FCT_GENERATEUR_3D<4> carte;
|
134 |
|
|
FCT_TAILLE* metrique;
|
135 |
|
|
MAILLEUR2D::priorite_metrique=prioritemetrique;
|
136 |
|
|
if (typecarte==1)
|
137 |
|
|
{
|
138 |
|
|
metrique=NULL;
|
139 |
|
|
MAILLEUR::epsilon=eps;
|
140 |
|
|
MAILLEUR::distance_maximale=dg;
|
141 |
|
|
}
|
142 |
|
|
if (typecarte==2)
|
143 |
|
|
{
|
144 |
|
|
affiche("Lecture carte de taille");
|
145 |
|
|
carte.lire(fichiercarte);
|
146 |
|
|
metrique=&carte;
|
147 |
|
|
}
|
148 |
|
|
if (niveau>-1)
|
149 |
|
|
{
|
150 |
|
|
affiche("MAILLAGE 0D");
|
151 |
|
|
MAILLEUR0D m0d(mgmai,mggeo);
|
152 |
|
|
m0d.maille();
|
153 |
|
|
}
|
154 |
|
|
if (niveau>0)
|
155 |
|
|
{
|
156 |
|
|
affiche("MAILLAGE 1D");
|
157 |
|
|
int nb=mggeo->get_nb_mg_arete();
|
158 |
|
|
for (int i=0;i<nb;i++)
|
159 |
|
|
{
|
160 |
|
|
MG_ARETE* arete=mggeo->get_mg_arete(i);
|
161 |
|
|
MAILLEUR1D m1d(mgmai,mggeo,arete,metrique);
|
162 |
|
|
m1d.maille();
|
163 |
|
|
}
|
164 |
|
|
}
|
165 |
|
|
if (niveau>1)
|
166 |
|
|
{
|
167 |
|
|
affiche("MAILLAGE 2D");
|
168 |
|
|
int nb=mggeo->get_nb_mg_face();
|
169 |
|
|
for (int i=0;i<nb;i++)
|
170 |
|
|
{
|
171 |
|
|
char mess[100];
|
172 |
|
|
sprintf(mess," face %d",i);
|
173 |
|
|
affiche(mess);
|
174 |
|
|
MG_FACE* mgface=mggeo->get_mg_face(i);
|
175 |
|
|
MAILLEUR2D m2d(mgmai,mggeo,mgface,metrique);
|
176 |
|
|
m2d.maille();
|
177 |
|
|
}
|
178 |
|
|
}
|
179 |
|
|
if (niveau==3)
|
180 |
|
|
{
|
181 |
|
|
affiche("MAILLAGE 3D");
|
182 |
francois |
56 |
int nb=mggeo->get_nb_mg_volume();
|
183 |
|
|
for (int i=0;i<nb;i++)
|
184 |
|
|
{
|
185 |
|
|
MG_VOLUME* mgvol=mggeo->get_mg_volume(i);
|
186 |
|
|
MAILLEUR3D m3d(mgmai,mggeo,mgvol,metrique);
|
187 |
|
|
m3d.active_affichage(affiche);
|
188 |
|
|
//if (form->CheckBox2->Checked==true) m3d.active_log(form->Caption.c_str());
|
189 |
|
|
m3d.maille(mgvol);
|
190 |
|
|
affiche("Analyse maillage");
|
191 |
|
|
double vol;
|
192 |
|
|
m3d.analyse_maillage_obtenu(vol);
|
193 |
|
|
char mess[100];
|
194 |
|
|
sprintf(mess," nombre de tetra theorique %f, nombre de tetra pratique %d ",vol,mgmai->get_nb_mg_tetra());
|
195 |
|
|
affiche(mess);
|
196 |
|
|
sprintf(mess," erreur %f%",(mgmai->get_nb_mg_tetra()-vol)*100./vol);
|
197 |
|
|
affiche(mess);
|
198 |
|
|
}
|
199 |
|
5 |
}
|
200 |
|
|
affiche("Enregistrement");
|
201 |
francois |
56 |
if (diff) strcpy(fichier,fichier2);
|
202 |
|
5 |
gest.enregistrer(fichier);
|
203 |
francois |
56 |
if (exportgmsh)
|
204 |
|
|
{
|
205 |
|
|
affiche("Exportation GMSH");
|
206 |
|
|
MG_EXPORT exp;
|
207 |
|
|
exp.gmsh(mgmai,fichier);
|
208 |
|
|
}
|
209 |
|
5 |
affiche("Fin");
|
210 |
|
|
return 0;
|
211 |
|
|
}
|
212 |
|
|
|
213 |
|
|
|
214 |
|
|
|
215 |
|
|
#pragma package(smart_init)
|