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 |
|
|
// magicform.cpp
|
16 |
|
|
//
|
17 |
|
|
//------------------------------------------------------------
|
18 |
|
|
//------------------------------------------------------------
|
19 |
|
|
// COPYRIGHT 2000
|
20 |
|
|
// Version du 02/03/2006 à 11H26
|
21 |
|
|
//------------------------------------------------------------
|
22 |
|
|
//------------------------------------------------------------
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
#include "gestionversion.h"
|
26 |
|
|
|
27 |
|
|
#include <vcl.h>
|
28 |
|
|
#include "main.h"
|
29 |
|
|
#pragma hdrstop
|
30 |
|
|
|
31 |
|
|
#include "magicform.h"
|
32 |
|
|
#include "tmaille.h"
|
33 |
|
|
//#include "mailleur.h"
|
34 |
|
|
//#include "mailleur2d.h"
|
35 |
|
|
//#include "affiche.h"
|
36 |
|
|
#include "process.h"
|
37 |
|
|
|
38 |
|
|
//---------------------------------------------------------------------------
|
39 |
|
|
#pragma package(smart_init)
|
40 |
|
|
#pragma link "CGAUGES"
|
41 |
|
|
#pragma link "PERFGRAP"
|
42 |
|
|
#pragma resource "*.dfm"
|
43 |
|
|
TVisuMagicform *VisuMagicform;
|
44 |
|
|
//---------------------------------------------------------------------------
|
45 |
francois |
62 |
__fastcall TVisuMagicform::TVisuMagicform(TComponent* Owner,TMainForm *win,MG_FILE* mgest)
|
46 |
|
|
: TForm(Owner),maille_process(NULL),fen(win),gest(mgest)
|
47 |
|
5 |
{
|
48 |
|
|
}
|
49 |
|
|
//---------------------------------------------------------------------------
|
50 |
|
|
void __fastcall TVisuMagicform::FormClose(TObject *Sender,
|
51 |
|
|
TCloseAction &Action)
|
52 |
|
|
{
|
53 |
|
|
Action=caFree;
|
54 |
|
|
}
|
55 |
|
|
//---------------------------------------------------------------------------
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
void __fastcall TVisuMagicform::RadioButton1Click(TObject *Sender)
|
59 |
|
|
{
|
60 |
|
|
GroupBox2->Caption="Carte de taille standard";
|
61 |
|
|
Label2->Caption="Distance maximale";
|
62 |
|
|
Label3->Caption="Epsilon";
|
63 |
|
|
Label2->Visible=true;
|
64 |
|
|
Label3->Visible=true;
|
65 |
|
|
Edit1->Text="";
|
66 |
|
|
Edit2->Text="";
|
67 |
|
|
Edit1->Visible=true;
|
68 |
|
|
Edit2->Visible=true;
|
69 |
|
|
GroupBox2->Visible=true;
|
70 |
|
|
Button1->Enabled=true;
|
71 |
|
|
Button3->Visible=false;
|
72 |
francois |
62 |
TrackBar3->Visible=false;
|
73 |
|
|
Edit5->Visible=false;
|
74 |
|
|
Label5->Caption="Géométrie";
|
75 |
|
|
ComboBox1->Clear();
|
76 |
|
|
int nb=gest->get_nb_mg_geometrie();
|
77 |
|
|
for (int i=0;i<nb;i++)
|
78 |
|
|
{
|
79 |
|
|
char mess[200];
|
80 |
|
|
sprintf(mess,"%lu",gest->get_mg_geometrie(i)->get_id());
|
81 |
|
|
ComboBox1->Items->Add(mess);
|
82 |
|
|
}
|
83 |
|
|
ComboBox1->ItemIndex=0;}
|
84 |
|
5 |
//---------------------------------------------------------------------------
|
85 |
|
|
|
86 |
|
|
|
87 |
|
|
void __fastcall TVisuMagicform::Button1Click(TObject *Sender)
|
88 |
|
|
{
|
89 |
|
|
DWORD type,taille;
|
90 |
|
|
HKEY clef;
|
91 |
|
|
char name[500];
|
92 |
|
|
RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\UQTR\\VMM\\",0,KEY_EXECUTE,&clef);
|
93 |
|
|
RegQueryValueEx(clef,"pathmodule",0,&type,0,&taille);
|
94 |
|
|
RegQueryValueEx(clef,"pathmodule",0,&type,name,&taille);
|
95 |
|
|
strcat(name,"\\mailleur");
|
96 |
|
|
char niveau[2];niveau[1]=0;
|
97 |
|
|
char pm[20];
|
98 |
|
|
sprintf(pm,"%.2f",TrackBar1->Position*0.01);
|
99 |
|
|
if (RadioButton2->Checked) niveau[0]='1';
|
100 |
|
|
if (RadioButton3->Checked) niveau[0]='2';
|
101 |
|
|
if (RadioButton4->Checked) niveau[0]='3';
|
102 |
|
|
if (RadioButton5->Checked)
|
103 |
|
|
{
|
104 |
|
|
niveau[0]='3';
|
105 |
|
|
strcat(name,"erin");
|
106 |
|
|
}
|
107 |
|
|
double eng=atof(Edit1->Text.c_str());
|
108 |
|
|
double eps=atof(Edit2->Text.c_str());
|
109 |
|
|
char nomfichier[500];
|
110 |
francois |
62 |
char nomfichiersortie[500];
|
111 |
|
5 |
sprintf(nomfichier,"\"%s\"",Caption.c_str());
|
112 |
francois |
62 |
if (CheckBox3->Checked) {strcpy(nomfichiersortie,"\"");strcat(nomfichiersortie,Edit4->Text.c_str());strcat(nomfichiersortie,"\"");} else strcpy(nomfichiersortie,nomfichier);
|
113 |
|
5 |
char nomfichiercarte[500];
|
114 |
|
|
sprintf(nomfichiercarte,"\"%s\"",Edit1->Text.c_str());
|
115 |
francois |
62 |
int numentite=ComboBox1->ItemIndex;
|
116 |
|
|
char numentitechar[20];
|
117 |
|
|
sprintf(numentitechar,"%d",numentite);
|
118 |
|
|
char visufront[20];
|
119 |
|
|
char analyse[20];
|
120 |
|
|
if (CheckBox2->Checked) strcpy(visufront,"-visufront"); else strcpy(visufront," ");
|
121 |
|
|
if (CheckBox1->Checked) strcpy(analyse,"-analyse"); else strcpy(analyse," ");
|
122 |
|
5 |
if (RadioButton1->Checked)
|
123 |
|
|
{
|
124 |
|
|
if (eng<0.000001) MessageBox(Handle,"Mauvaise valeur de distance","Erreur",0);
|
125 |
|
|
else if (eps<0.000001) MessageBox(Handle,"Mauvaise valeur de epsilon","Erreur",0);
|
126 |
|
|
else
|
127 |
|
|
{
|
128 |
francois |
62 |
spawnl(P_NOWAIT,name,name,"-magic",nomfichier,"-typecarte","1","-eng",Edit1->Text.c_str(),"-eps",Edit2->Text.c_str(),"-niveau",niveau,"-prioritemetrique",pm,"-out",nomfichiersortie,"-numgeo",numentitechar,NULL);
|
129 |
|
5 |
if (fen->fenlog!=NULL)
|
130 |
|
|
{
|
131 |
|
|
char mess[2000];
|
132 |
francois |
62 |
sprintf(mess,"%s -magic %s -typecarte 1 -eng %s -eps %s -niveau %s -prioritemetrique %s -out %s -numgeo %s",name,nomfichier,Edit1->Text.c_str(),Edit2->Text.c_str(),niveau,pm,nomfichiersortie,numentitechar);
|
133 |
|
5 |
fen->fenlog->ajouter(mess);
|
134 |
|
|
}
|
135 |
|
|
}
|
136 |
|
|
}
|
137 |
|
|
if (RadioButton6->Checked)
|
138 |
|
|
{
|
139 |
|
|
if (Edit1->Text=="") MessageBox(Handle,"Pas de fichier carte de taille","Erreur",0);
|
140 |
|
|
else
|
141 |
|
|
{
|
142 |
francois |
62 |
spawnl(P_NOWAIT,name,name,"-magic",nomfichier,"-typecarte","2","-carte",nomfichiercarte,"-niveau",niveau,"-prioritemetrique",pm,"-out",nomfichiersortie,"-numgeo",numentitechar,"-niveauopt",Edit3->Text.c_str(),analyse,visufront,NULL);
|
143 |
|
5 |
if (fen->fenlog!=NULL)
|
144 |
|
|
{
|
145 |
|
|
char mess[2000];
|
146 |
francois |
62 |
sprintf(mess,"%s -magic %s -typecarte 2 -carte %s -niveau %s -prioritemetrique %s -out %s -numgeo %s -niveauopt %s %s %s",name,nomfichier,nomfichiercarte,niveau,pm,nomfichiersortie,numentitechar,Edit3->Text.c_str(),analyse,visufront);
|
147 |
|
5 |
fen->fenlog->ajouter(mess);
|
148 |
|
|
}
|
149 |
|
|
}
|
150 |
|
|
}
|
151 |
francois |
62 |
if (RadioButton7->Checked)
|
152 |
|
|
{
|
153 |
|
|
if (Edit1->Text=="") MessageBox(Handle,"Pas de fichier carte de taille","Erreur",0);
|
154 |
|
|
else
|
155 |
|
|
{
|
156 |
|
|
spawnl(P_NOWAIT,name,name,"-magic",nomfichier,"-adapt","-typecarte","2","-carte",nomfichiercarte,"-prioritemetrique",pm,"-out",nomfichiersortie,"-nummai",ComboBox1->Text.c_str(),"-limitadapt",Edit5->Text.c_str(),"-niveauopt",Edit3->Text.c_str(),analyse,visufront,NULL);
|
157 |
|
|
if (fen->fenlog!=NULL)
|
158 |
|
|
{
|
159 |
|
|
char mess[2000];
|
160 |
|
|
sprintf(mess,"%s -magic %s -adapt -typecarte 2 -carte %s -niveau %s -prioritemetrique %s -out %s -nummai %s -limitadapt %s -niveauopt %s %s %s",name,nomfichier,nomfichiercarte,niveau,pm,nomfichiersortie,ComboBox1->Text,Edit5->Text.c_str(),Edit3->Text.c_str(),analyse,visufront);
|
161 |
|
|
fen->fenlog->ajouter(mess);
|
162 |
|
|
}
|
163 |
|
|
}
|
164 |
|
|
}
|
165 |
|
5 |
}
|
166 |
|
|
//---------------------------------------------------------------------------
|
167 |
|
|
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
|
171 |
|
|
|
172 |
|
|
void __fastcall TVisuMagicform::RadioButton6Click(TObject *Sender)
|
173 |
|
|
{
|
174 |
|
|
GroupBox2->Caption="Carte de taille 3D précalculée";
|
175 |
|
|
Label2->Caption="Fichier";
|
176 |
|
|
Label2->Visible=true;
|
177 |
|
|
Label3->Visible=false;
|
178 |
|
|
Edit1->Visible=true;
|
179 |
|
|
Edit2->Visible=false;
|
180 |
|
|
GroupBox2->Visible=true;
|
181 |
|
|
Button1->Enabled=true;
|
182 |
|
|
Button3->Visible=true;
|
183 |
francois |
62 |
TrackBar3->Visible=false;
|
184 |
|
|
Edit5->Visible=false;
|
185 |
|
|
Label5->Caption="Géométrie";
|
186 |
|
|
ComboBox1->Clear();
|
187 |
|
|
int nb=gest->get_nb_mg_geometrie();
|
188 |
|
|
for (int i=0;i<nb;i++)
|
189 |
|
|
{
|
190 |
|
|
char mess[200];
|
191 |
|
|
sprintf(mess,"%lu",gest->get_mg_geometrie(i)->get_id());
|
192 |
|
|
ComboBox1->Items->Add(mess);
|
193 |
|
|
}
|
194 |
|
|
ComboBox1->ItemIndex=0;
|
195 |
|
5 |
}
|
196 |
|
|
//---------------------------------------------------------------------------
|
197 |
|
|
|
198 |
|
|
|
199 |
|
|
void __fastcall TVisuMagicform::Button3Click(TObject *Sender)
|
200 |
|
|
{
|
201 |
|
|
if (OpenDialog1->Execute())
|
202 |
|
|
Edit1->Text=OpenDialog1->FileName;
|
203 |
|
|
}
|
204 |
|
|
//---------------------------------------------------------------------------
|
205 |
|
|
|
206 |
|
|
void __fastcall TVisuMagicform::TrackBar1Change(TObject *Sender)
|
207 |
|
|
{
|
208 |
|
|
char mess[30];
|
209 |
|
|
sprintf(mess,"%d\%",TrackBar1->Position);
|
210 |
|
|
Edit7->Text=mess;
|
211 |
|
|
}
|
212 |
|
|
//---------------------------------------------------------------------------
|
213 |
|
|
|
214 |
|
|
void __fastcall TVisuMagicform::Button2Click(TObject *Sender)
|
215 |
|
|
{
|
216 |
|
|
Close();
|
217 |
|
|
}
|
218 |
|
|
//---------------------------------------------------------------------------
|
219 |
|
|
|
220 |
francois |
62 |
|
221 |
|
|
void __fastcall TVisuMagicform::RadioButton7Click(TObject *Sender)
|
222 |
|
|
{
|
223 |
|
|
GroupBox2->Caption="Adaptation de maillage";
|
224 |
|
|
Label2->Caption="Fichier carte de taille";
|
225 |
|
|
Label2->Visible=true;
|
226 |
|
|
Label3->Visible=true;
|
227 |
|
|
Label3->Caption="Limite carte de taille";
|
228 |
|
|
Edit1->Visible=true;
|
229 |
|
|
Edit2->Visible=false;
|
230 |
|
|
GroupBox2->Visible=true;
|
231 |
|
|
Button1->Enabled=true;
|
232 |
|
|
Button3->Visible=true;
|
233 |
|
|
TrackBar3->Visible=true;
|
234 |
|
|
Edit5->Visible=true;
|
235 |
|
|
Label5->Caption="Maillage";
|
236 |
|
|
ComboBox1->Clear();
|
237 |
|
|
int nb=gest->get_nb_mg_maillage();
|
238 |
|
|
for (int i=0;i<nb;i++)
|
239 |
|
|
{
|
240 |
|
|
char mess[200];
|
241 |
|
|
sprintf(mess,"%lu",gest->get_mg_maillage(i)->get_id());
|
242 |
|
|
ComboBox1->Items->Add(mess);
|
243 |
|
|
}
|
244 |
|
|
ComboBox1->ItemIndex=0;
|
245 |
|
|
}
|
246 |
|
|
//---------------------------------------------------------------------------
|
247 |
|
|
|
248 |
|
|
void __fastcall TVisuMagicform::TrackBar2Change(TObject *Sender)
|
249 |
|
|
{
|
250 |
|
|
Edit3->Text=TrackBar2->Position;
|
251 |
|
|
}
|
252 |
|
|
//---------------------------------------------------------------------------
|
253 |
|
|
|
254 |
|
|
void __fastcall TVisuMagicform::Button4Click(TObject *Sender)
|
255 |
|
|
{
|
256 |
|
|
if (OpenDialog2->Execute())
|
257 |
|
|
Edit4->Text=OpenDialog2->FileName;
|
258 |
|
|
}
|
259 |
|
|
//---------------------------------------------------------------------------
|
260 |
|
|
|
261 |
|
|
void __fastcall TVisuMagicform::CheckBox3Click(TObject *Sender)
|
262 |
|
|
{
|
263 |
|
|
Button4->Visible=CheckBox3->Checked;
|
264 |
|
|
Edit4->Visible=CheckBox3->Checked;
|
265 |
|
|
}
|
266 |
|
|
//---------------------------------------------------------------------------
|
267 |
|
|
|
268 |
|
|
void __fastcall TVisuMagicform::TrackBar3Change(TObject *Sender)
|
269 |
|
|
{
|
270 |
|
|
char mess[30];
|
271 |
|
|
sprintf(mess,"%.2f",1.0*TrackBar3->Position/100.);
|
272 |
|
|
Edit5->Text=mess;
|
273 |
|
|
}
|
274 |
|
|
//---------------------------------------------------------------------------
|
275 |
|
|
|