1 |
|
5 |
//------------------------------------------------------------
|
2 |
|
|
//------------------------------------------------------------
|
3 |
|
|
// MAGiC
|
4 |
|
|
// Jean Christophe Cuillière et Vincent FRANCOIS
|
5 |
|
|
// Département de Génie Mécanique - UQTR
|
6 |
|
|
//------------------------------------------------------------
|
7 |
|
|
// Le projet MAGIC est un projet de recherche du département
|
8 |
|
|
// de génie mécanique de l'Université du Québec à
|
9 |
|
|
// Trois Rivières
|
10 |
|
|
// Les librairies ne peuvent être utilisées 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 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
#include "gestionversion.h"
|
28 |
|
|
#ifdef WINDOWS_VERSION
|
29 |
|
|
#include "fenetre.h"
|
30 |
|
|
#endif
|
31 |
|
|
|
32 |
|
|
#pragma hdrstop
|
33 |
|
|
#include "mg_file.h"
|
34 |
francois |
56 |
#include "mg_export.h"
|
35 |
|
5 |
#include "main.h"
|
36 |
|
|
#include "fct_generateur_frontiere.h"
|
37 |
|
|
#include "fct_generateur_constante.h"
|
38 |
|
|
#include "fct_generateur_fichier.h"
|
39 |
|
|
|
40 |
|
|
//---------------------------------------------------------------------------
|
41 |
|
|
|
42 |
|
|
void affiche(char* message)
|
43 |
|
|
{
|
44 |
|
|
#ifdef WINDOWS_VERSION
|
45 |
|
|
Form1->Memo1->Lines->Add(message);
|
46 |
|
|
#else
|
47 |
|
|
std::cout << message << std::endl;
|
48 |
|
|
#endif
|
49 |
|
|
}
|
50 |
|
|
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
#ifdef WINDOWS_VERSION
|
54 |
|
|
int amain(int argc,char **argv)
|
55 |
|
|
#else
|
56 |
|
|
int main(int argc,char **argv)
|
57 |
|
|
#endif
|
58 |
|
|
{
|
59 |
|
|
if (argc<3) return 1;
|
60 |
|
|
char nomfichier[500];
|
61 |
|
|
char nomfichiersortie[500];
|
62 |
|
|
char nomfichierpoint[500]={""};;
|
63 |
|
|
double eng,eps,ind2;
|
64 |
|
|
int ind1,typecarte=-1;
|
65 |
|
|
int fechan,festim;
|
66 |
francois |
56 |
int exportgmsh=0;
|
67 |
|
5 |
|
68 |
|
|
for (int i=0;i<argc;i++)
|
69 |
|
|
{
|
70 |
|
|
if (strcmp(argv[i],"-fichier")==0) strcpy(nomfichier,argv[i+1]);
|
71 |
|
|
if (strcmp(argv[i],"-fichout")==0) strcpy(nomfichiersortie,argv[i+1]);
|
72 |
|
|
if (strcmp(argv[i],"-point")==0) strcpy(nomfichierpoint,argv[i+1]);
|
73 |
|
|
if (strcmp(argv[i],"-dg")==0) eng=atof(argv[i+1]);
|
74 |
|
|
if (strcmp(argv[i],"-eps")==0) eps=atof(argv[i+1]);
|
75 |
|
|
if (strcmp(argv[i],"-taillezone")==0) ind1=atoi(argv[i+1]);
|
76 |
|
|
if (strcmp(argv[i],"-tauxtransfert")==0) ind2=atof(argv[i+1]);
|
77 |
|
|
if (strcmp(argv[i],"-typecarte")==0) typecarte=atoi(argv[i+1]);
|
78 |
|
|
if (strcmp(argv[i],"-fechantillonage")==0) fechan=atoi(argv[i+1]);
|
79 |
|
|
if (strcmp(argv[i],"-festimation")==0) festim=atoi(argv[i+1]);
|
80 |
francois |
56 |
if (strcmp(argv[i],"-exportgmsh")==0) exportgmsh=1;;
|
81 |
|
5 |
}
|
82 |
|
|
|
83 |
|
|
if (typecarte==1)
|
84 |
|
|
{
|
85 |
|
|
affiche("Génération de carte de taille");
|
86 |
|
|
affiche("Lecture du fichier");
|
87 |
|
|
MG_FILE gest(nomfichier);
|
88 |
|
|
int nbptctl=0;
|
89 |
|
|
double *ptctl=NULL;
|
90 |
|
|
char mess[255];
|
91 |
|
|
FILE* in=fopen(nomfichierpoint,"rt");
|
92 |
|
|
if (in!=NULL)
|
93 |
|
|
{
|
94 |
|
|
affiche("Lecture du fichier de points de controles");
|
95 |
|
|
char mess[255];
|
96 |
|
|
fgets(mess,255,in);
|
97 |
|
|
sscanf(mess,"%d",&nbptctl);
|
98 |
|
|
ptctl=new double[4*nbptctl];
|
99 |
|
|
for (int i=0;i<nbptctl;i++)
|
100 |
|
|
{
|
101 |
|
|
fgets(mess,255,in);
|
102 |
|
|
sscanf(mess,"%lf %lf %lf %lf",ptctl+4*i,ptctl+4*i+1,ptctl+4*i+2,ptctl+4*i+3);
|
103 |
|
|
}
|
104 |
|
|
fclose(in);
|
105 |
|
|
}
|
106 |
|
|
FCT_GENERATEUR_FRONTIERE carte(gest,eng,eps,ind1,ind2,ptctl,nbptctl);
|
107 |
|
|
affiche("Construction de la carte");
|
108 |
|
|
carte.construit(fechan,festim);
|
109 |
|
|
affiche("Enregistrement de la carte");
|
110 |
|
|
carte.enregistrer(nomfichiersortie);
|
111 |
|
|
if (nbptctl!=0) delete [] ptctl;
|
112 |
francois |
56 |
if (exportgmsh)
|
113 |
|
|
{
|
114 |
|
|
affiche("Exportation GMSH");
|
115 |
|
|
MG_EXPORT exp;
|
116 |
|
|
exp.gmsh(&carte,nomfichiersortie);
|
117 |
|
|
}
|
118 |
|
5 |
affiche("Fin");
|
119 |
|
|
}
|
120 |
|
|
if (typecarte==0)
|
121 |
|
|
{
|
122 |
|
|
affiche("Génération de carte de taille");
|
123 |
|
|
affiche("Lecture du fichier");
|
124 |
|
|
MG_FILE gest(nomfichier);
|
125 |
|
|
FCT_GENERATEUR_CONSTANTE carte(gest,eng);
|
126 |
|
|
affiche("Construction de la carte");
|
127 |
|
|
carte.construit(fechan,festim);
|
128 |
|
|
affiche("Enregistrement de la carte");
|
129 |
|
|
carte.enregistrer(nomfichiersortie);
|
130 |
francois |
56 |
if (exportgmsh)
|
131 |
|
|
{
|
132 |
|
|
affiche("Exportation GMSH");
|
133 |
|
|
MG_EXPORT exp;
|
134 |
|
|
exp.gmsh(&carte,nomfichiersortie);
|
135 |
|
|
}
|
136 |
|
5 |
affiche("Fin");
|
137 |
|
|
}
|
138 |
|
|
if (typecarte==2)
|
139 |
|
|
{
|
140 |
|
|
affiche("Génération de carte de taille");
|
141 |
|
|
affiche(" à partir du fichier d'estimation");
|
142 |
|
|
FCT_GENERATEUR_FICHIER carte(nomfichier,eng,ind1,ind2);
|
143 |
|
|
affiche("Construction de la carte");
|
144 |
|
|
carte.construit(fechan,festim);
|
145 |
|
|
affiche("Enregistrement de la carte");
|
146 |
|
|
carte.enregistrer(nomfichiersortie);
|
147 |
francois |
56 |
if (exportgmsh)
|
148 |
|
|
{
|
149 |
|
|
affiche("Exportation GMSH");
|
150 |
|
|
MG_EXPORT exp;
|
151 |
|
|
exp.gmsh(&carte,nomfichiersortie);
|
152 |
|
|
}
|
153 |
|
5 |
affiche("Fin");
|
154 |
|
|
}
|
155 |
francois |
56 |
|
156 |
|
5 |
return 0;
|
157 |
|
|
}
|
158 |
|
|
|
159 |
|
|
|
160 |
|
|
|
161 |
|
|
#pragma package(smart_init)
|