1 |
//---------------------------------------------------------------------------
|
2 |
#include <vcl\vcl.h>
|
3 |
#include <process.h>
|
4 |
#include <string.h>
|
5 |
#include <stdio.h>
|
6 |
#include <stdlib.h>
|
7 |
#include <math.h>
|
8 |
#include <dir.h>
|
9 |
#pragma hdrstop
|
10 |
|
11 |
#include "Fenetre.h"
|
12 |
#include "Edition.h"
|
13 |
#include "Igsopt.h"
|
14 |
#include "Rigsopt.h"
|
15 |
#include "diaopt.h"
|
16 |
#include "s_valeur.h"
|
17 |
#include "configure.h"
|
18 |
#include "aproposde.h"
|
19 |
#include "cface.h"
|
20 |
#include "tool.h"
|
21 |
#include "session.h"
|
22 |
#include "infopiece.h"
|
23 |
#include "debug.h"
|
24 |
|
25 |
extern void trirea(float *a,int *la,int *ir);
|
26 |
|
27 |
//---------------------------------------------------------------------------
|
28 |
#pragma resource "*.dfm"
|
29 |
TFenp *Fenp;
|
30 |
//---------------------------------------------------------------------------
|
31 |
__fastcall TFenp::TFenp(TComponent* Owner)
|
32 |
: TForm(Owner)
|
33 |
{
|
34 |
}
|
35 |
//---------------------------------------------------------------------------
|
36 |
void __fastcall TFenp::Fermer1Click(TObject *Sender)
|
37 |
{
|
38 |
Fenp->Close();
|
39 |
}
|
40 |
//---------------------------------------------------------------------------
|
41 |
void __fastcall TFenp::Ouvre(char *mess)
|
42 |
{
|
43 |
char messtmp[255],messf[255];
|
44 |
char *p,arg1[255],arg2[255],arg3[255],arg4[255];
|
45 |
FILE *out;
|
46 |
TObject *Sender=NULL;
|
47 |
|
48 |
strcpy(Fichier,mess);
|
49 |
strcpy(messtmp,"Mesh2000 ");
|
50 |
strcat(messtmp,mess);
|
51 |
Fenp->Caption=messtmp;
|
52 |
if (existetool==1)
|
53 |
{
|
54 |
Toolbar->Caption="Outil pour "+Fenp->Caption;
|
55 |
Toolbar->Invalidate();
|
56 |
}
|
57 |
Mailleur1->Enabled=True;
|
58 |
Remailleur1->Enabled=True;
|
59 |
Vue1->Enabled=True;
|
60 |
Geometrie1->Checked=false;
|
61 |
Maillage1D1->Checked=false;
|
62 |
Maillage2D1->Checked=false;
|
63 |
Maillage3D1->Checked=false;
|
64 |
Maillage3D2->Checked=false;
|
65 |
Remaillage2D1->Checked=false;
|
66 |
Remaillage3D1->Checked=false;
|
67 |
Aucun1->Checked=true;
|
68 |
Acismesh1->Enabled=True;
|
69 |
Acismesh2->Enabled=True;
|
70 |
Paramesh1->Enabled=True;
|
71 |
p=strstr(Fichier,".");
|
72 |
strcpy(messf,Fichier);
|
73 |
messf[strlen(messf)-4]=0;
|
74 |
strcat(messf,".geo");
|
75 |
out=fopen(messf,"rt");
|
76 |
if (strcmp(p,".igs")==0)
|
77 |
{
|
78 |
Acismesh1->Enabled=False;
|
79 |
Acismesh2->Enabled=False;
|
80 |
}
|
81 |
if (strcmp(p,".sat")==0)
|
82 |
{
|
83 |
if (out==NULL)
|
84 |
{
|
85 |
sprintf(arg1,"%s\\acismesh.exe",home);
|
86 |
strcpy(arg2,"-fich");
|
87 |
sprintf(arg3,"%s",Fichier);
|
88 |
strcpy(arg4,"-geo");
|
89 |
spawnl(P_WAIT,arg1,arg1,arg2,arg3,arg4,NULL);
|
90 |
}
|
91 |
Geometrie1->Checked=true;
|
92 |
Aucun1->Checked=false;
|
93 |
Geometrie1Click(Sender) ;
|
94 |
}
|
95 |
if (out!=NULL) fclose(out);
|
96 |
passe_norme=0;
|
97 |
}
|
98 |
//---------------------------------------------------------------------------
|
99 |
void __fastcall TFenp::wininit()
|
100 |
{
|
101 |
char mess[255];
|
102 |
int i;
|
103 |
FILE *out;
|
104 |
|
105 |
sprintf(mess,"%s\\mesh.ini",home);
|
106 |
out=fopen(mess,"wt");
|
107 |
fprintf(out,"[Apparence]\n");
|
108 |
fprintf(out,"%d %d %d %d\n",Fenp->Top,Fenp->Left,Fenp->Height,Fenp->Width);
|
109 |
if (existetool==1)
|
110 |
{
|
111 |
Fenp->toolx=Toolbar->Left;
|
112 |
Fenp->tooly=Toolbar->Top;
|
113 |
}
|
114 |
fprintf(out,"%d %d %d %d\n\n",existetool,toolx,tooly,horizon);
|
115 |
fprintf(out,"[Directory]\n");
|
116 |
fprintf(out,"%s\n",dir_defaut);
|
117 |
fprintf(out,"\n");
|
118 |
fprintf(out,"[History]\n");
|
119 |
fprintf(out,"%d\n",nb_fichier);
|
120 |
for (i=0;i<nb_fichier;i++)
|
121 |
fprintf(out,"%s\n",ancien_fichier[i]);
|
122 |
fprintf(out,"\n");
|
123 |
fprintf(out,"[Color]\n");
|
124 |
for (i=0;i<12;i++)
|
125 |
fprintf(out,"%X\n",Cshade[i]);
|
126 |
fprintf(out,"%d\n",uni);
|
127 |
fclose(out);
|
128 |
}
|
129 |
//---------------------------------------------------------------------------
|
130 |
void __fastcall TFenp::Ouvrir1Click(TObject *Sender)
|
131 |
{
|
132 |
char mess[255],*p;
|
133 |
int i;
|
134 |
TMenuItem *active;
|
135 |
|
136 |
OpenDialog1->InitialDir=dir_defaut;
|
137 |
if (OpenDialog1->Execute()==true)
|
138 |
{
|
139 |
strcpy(mess,OpenDialog1->FileName.c_str());
|
140 |
Ouvre(mess);
|
141 |
nb_fichier++;
|
142 |
if (nb_fichier>4) nb_fichier=4;
|
143 |
for (i=nb_fichier-1;i>=0;i--)
|
144 |
strcpy(ancien_fichier[i+1],ancien_fichier[i]);
|
145 |
strcpy(ancien_fichier[0],Fichier);
|
146 |
strcpy(dir_defaut,Fichier);
|
147 |
p=strrchr(dir_defaut,'\\');
|
148 |
dir_defaut[p-dir_defaut]=0;
|
149 |
wininit();
|
150 |
for (i=0;i<nb_fichier;i++)
|
151 |
{
|
152 |
if (i==0) active=ancien1;
|
153 |
if (i==1) active=ancien2;
|
154 |
if (i==2) active=ancien3;
|
155 |
if (i==3) active=ancien4;
|
156 |
active->Visible=true;
|
157 |
active->Caption=ancien_fichier[i];
|
158 |
}
|
159 |
if (i>0) N5->Visible=true;
|
160 |
Invalidate();
|
161 |
}
|
162 |
}
|
163 |
|
164 |
//---------------------------------------------------------------------------
|
165 |
void __fastcall TFenp::Igsmesh1Click(TObject *Sender)
|
166 |
{
|
167 |
char mess[255];
|
168 |
char arg1[255];
|
169 |
char arg2[255];
|
170 |
char arg3[255];
|
171 |
char arg4[255];
|
172 |
char arg5[255];
|
173 |
char arg6[255];
|
174 |
char arg7[255];
|
175 |
char arg8[255];
|
176 |
float dens;
|
177 |
int opt=5;
|
178 |
|
179 |
|
180 |
Igsoption->Edit2->Text="5";
|
181 |
Igsoption->GroupBox1->Caption=Fichier;
|
182 |
Igsoption->Label3->Enabled=false;
|
183 |
Igsoption->Edit3->Enabled=false;
|
184 |
Igsoption->RadioButton1->Enabled=false;
|
185 |
Igsoption->RadioButton2->Enabled=false;
|
186 |
Igsoption->ShowModal();
|
187 |
if (Igsoption->ok==1)
|
188 |
{
|
189 |
dens=0.;
|
190 |
strcpy(mess,Igsoption->Edit1->Text.c_str());
|
191 |
sscanf(mess,"%f",&dens);
|
192 |
strcpy(mess,Igsoption->Edit2->Text.c_str());
|
193 |
sscanf(mess,"%d",&opt);
|
194 |
if (Igsoption->CheckBox1->Checked==true) strcpy(arg8,"-analyse"); else strcpy(arg6,"");
|
195 |
sprintf(arg1,"%s\\igsmesh.exe",home);
|
196 |
strcpy(arg2,"-fich");
|
197 |
sprintf(arg3,"%s",Fichier);
|
198 |
strcpy(arg4,"-dens");
|
199 |
sprintf(arg5,"%f",dens);
|
200 |
strcpy(arg6,"-opt");
|
201 |
sprintf(arg7,"%d",opt);
|
202 |
if (dens>0.) spawnl(P_NOWAIT,arg1,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,NULL);
|
203 |
else MessageBox(Handle,"Mauvaise valeur de densite","Erreur",0);
|
204 |
}
|
205 |
}
|
206 |
//---------------------------------------------------------------------------
|
207 |
void __fastcall TFenp::FormCreate(TObject *Sender)
|
208 |
{
|
209 |
FILE *out;
|
210 |
int i,drive;
|
211 |
int top,height,left,width;
|
212 |
char mess[255],nom[255];
|
213 |
TMenuItem *active;
|
214 |
|
215 |
homo=0.8;
|
216 |
loin=1.;
|
217 |
passe_norme=0;
|
218 |
tete=NULL;
|
219 |
Mailleur1->Enabled=False;
|
220 |
Vue1->Enabled=False;
|
221 |
Acismesh1->Enabled=False;
|
222 |
Remailleur1->Enabled=False;
|
223 |
Acismesh2->Enabled=False;
|
224 |
Paramesh1->Enabled=False;
|
225 |
Face1->Enabled=False;
|
226 |
Activerlerendu3D1->Enabled=False;
|
227 |
Canvas->Pen->Color=clWhite;
|
228 |
rot[0][0]=1.;rot[0][1]=0.;rot[0][2]=0.;
|
229 |
rot[1][0]=0.;rot[1][1]=1.;rot[1][2]=0.;
|
230 |
rot[2][0]=0.;rot[2][1]=0.;rot[2][2]=1.;
|
231 |
batch=false;
|
232 |
fc=0;
|
233 |
uni=0;
|
234 |
zoomwin=0;
|
235 |
toolx=0;tooly=394;
|
236 |
horizon=1;
|
237 |
numface=(-1);
|
238 |
numero_noeud=(-1);
|
239 |
numero_maille=(-1);
|
240 |
drive=getdisk();
|
241 |
getcurdir(0,mess);
|
242 |
for (i=0;i<11;i++) Cshade[i]=clOlive;
|
243 |
Cshade[11]=clBlack;
|
244 |
sprintf(home,"%c:\\%s",'A'+drive,mess);
|
245 |
sprintf(mess,"%s\\mesh.ini",home);
|
246 |
out=fopen(mess,"rt");
|
247 |
if (out!=NULL)
|
248 |
{
|
249 |
fgets(mess,255,out);
|
250 |
fgets(mess,255,out);
|
251 |
sscanf(mess,"%d %d %d %d\n",&top,&left,&height,&width);
|
252 |
fgets(mess,255,out);
|
253 |
sscanf(mess,"%d %d %d %d\n\n",&tool,&toolx,&tooly,&horizon);
|
254 |
fgets(mess,255,out);
|
255 |
fgets(mess,255,out);
|
256 |
fgets(mess,255,out);
|
257 |
sscanf(mess,"%s",dir_defaut);
|
258 |
fgets(mess,255,out);
|
259 |
fgets(mess,255,out);
|
260 |
fgets(mess,255,out);
|
261 |
sscanf(mess,"%d",&nb_fichier);
|
262 |
if (nb_fichier!=0) N5->Visible=true;
|
263 |
for (i=0;i<nb_fichier;i++)
|
264 |
{
|
265 |
fgets(mess,255,out);
|
266 |
sscanf(mess,"%s",nom);
|
267 |
if (i==0) active=ancien1;
|
268 |
if (i==1) active=ancien2;
|
269 |
if (i==2) active=ancien3;
|
270 |
if (i==3) active=ancien4;
|
271 |
active->Visible=true;
|
272 |
active->Caption=nom;
|
273 |
strcpy(ancien_fichier[i],nom);
|
274 |
}
|
275 |
fgets(mess,255,out);
|
276 |
fgets(mess,255,out);
|
277 |
for (i=0;i<12;i++)
|
278 |
{
|
279 |
fgets(mess,255,out);
|
280 |
sscanf(mess,"%X",&Cshade[i]);
|
281 |
}
|
282 |
fclose(out);
|
283 |
fgets(mess,255,out);
|
284 |
sscanf(mess,"%d",&uni);
|
285 |
Fenp->Top=top;
|
286 |
Fenp->Left=left;
|
287 |
Fenp->Height=height;
|
288 |
Fenp->Width=width;
|
289 |
}
|
290 |
}
|
291 |
//---------------------------------------------------------------------------
|
292 |
void __fastcall TFenp::Vueisometrique1Click(TObject *Sender)
|
293 |
{
|
294 |
Vueisometrique1->Checked=true;
|
295 |
VueXY1->Checked=false;
|
296 |
VueXZ1->Checked=false;
|
297 |
VueYZ1->Checked=false;
|
298 |
rot[0][0]=1.0;rot[1][0]=0.0;rot[2][0]=0.0;
|
299 |
rot[0][1]=0.0;rot[1][1]=1.0;rot[2][1]=0.0;
|
300 |
rot[0][2]=0.0;rot[1][2]=0.0;rot[2][2]=1.0;
|
301 |
norme();
|
302 |
Invalidate();
|
303 |
}
|
304 |
//---------------------------------------------------------------------------
|
305 |
void __fastcall TFenp::VueXY1Click(TObject *Sender)
|
306 |
{
|
307 |
Vueisometrique1->Checked=false;
|
308 |
VueXY1->Checked=true;
|
309 |
VueXZ1->Checked=false;
|
310 |
VueYZ1->Checked=false;
|
311 |
rot[0][0]=1.0;rot[1][0]=0.0;rot[2][0]=0.0;
|
312 |
rot[0][1]=0.0;rot[1][1]=1.0;rot[2][1]=0.0;
|
313 |
rot[0][2]=0.0;rot[1][2]=0.0;rot[2][2]=1.0;
|
314 |
norme();
|
315 |
Invalidate();
|
316 |
}
|
317 |
//---------------------------------------------------------------------------
|
318 |
void __fastcall TFenp::VueXZ1Click(TObject *Sender)
|
319 |
{
|
320 |
Vueisometrique1->Checked=false;
|
321 |
VueXY1->Checked=false;
|
322 |
VueXZ1->Checked=true;
|
323 |
VueYZ1->Checked=false;
|
324 |
rot[0][0]=1.0;rot[1][0]=0.0;rot[2][0]=0.0;
|
325 |
rot[0][1]=0.0;rot[1][1]=1.0;rot[2][1]=0.0;
|
326 |
rot[0][2]=0.0;rot[1][2]=0.0;rot[2][2]=1.0;
|
327 |
norme();
|
328 |
Invalidate();
|
329 |
}
|
330 |
//---------------------------------------------------------------------------
|
331 |
void __fastcall TFenp::VueYZ1Click(TObject *Sender)
|
332 |
{
|
333 |
Vueisometrique1->Checked=false;
|
334 |
VueXY1->Checked=false;
|
335 |
VueXZ1->Checked=false;
|
336 |
VueYZ1->Checked=true;
|
337 |
rot[0][0]=1.0;rot[1][0]=0.0;rot[2][0]=0.0;
|
338 |
rot[0][1]=0.0;rot[1][1]=1.0;rot[2][1]=0.0;
|
339 |
rot[0][2]=0.0;rot[1][2]=0.0;rot[2][2]=1.0;
|
340 |
norme();
|
341 |
Invalidate();
|
342 |
}
|
343 |
//---------------------------------------------------------------------------
|
344 |
void __fastcall TFenp::Igsmesh2Click(TObject *Sender)
|
345 |
{
|
346 |
char mess[255];
|
347 |
char arg1[255];
|
348 |
char arg2[255];
|
349 |
char arg3[255];
|
350 |
char arg4[255];
|
351 |
char arg5[255];
|
352 |
char arg6[255];
|
353 |
char arg7[255];
|
354 |
char arg8[255];
|
355 |
int opt=5;
|
356 |
|
357 |
|
358 |
Rigsoption->Edit2->Text="5";
|
359 |
Rigsoption->Label3->Enabled=false;
|
360 |
Rigsoption->Edit3->Enabled=false;
|
361 |
Rigsoption->GroupBox1->Caption=Fichier;
|
362 |
Rigsoption->ShowModal();
|
363 |
if (Rigsoption->ok==1)
|
364 |
{
|
365 |
strcpy(mess,Rigsoption->Edit2->Text.c_str());
|
366 |
sscanf(mess,"%d",&opt);
|
367 |
if (Rigsoption->CheckBox1->Checked==true) strcpy(arg8,"-analyse"); else strcpy(arg8,"");
|
368 |
mess[0]=0;
|
369 |
strcpy(mess,Rigsoption->Edit1->Text.c_str());
|
370 |
sprintf(arg1,"%s\\igsmesh.exe",home);
|
371 |
strcpy(arg2,"-fich");
|
372 |
sprintf(arg3,"%s",Fichier);
|
373 |
strcpy(arg4,"-mesh");
|
374 |
strcpy(arg5,mess);
|
375 |
strcpy(arg6,"-opt");
|
376 |
sprintf(arg7,"%d",opt);
|
377 |
if (mess[0]!=0) spawnl(P_NOWAIT,arg1,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,NULL);
|
378 |
else MessageBox(Handle,"Pas de fichier modele","Erreur",0);
|
379 |
}
|
380 |
}
|
381 |
//---------------------------------------------------------------------------
|
382 |
void __fastcall TFenp::FormPaint(TObject *Sender)
|
383 |
{
|
384 |
Fenp->Cursor=crHourGlass;
|
385 |
Fenp->SetFocus();
|
386 |
Fenp->Color=Cshade[11];
|
387 |
if (Geometrie1->Checked==true) affiche_geo();
|
388 |
if (Maillage1D1->Checked==true) affiche_1D();
|
389 |
if (Maillage2D1->Checked==true) affiche_2D();
|
390 |
if (Maillage3D1->Checked==true) affiche_3D();
|
391 |
if (Maillage3D2->Checked==true) affiche_3D();
|
392 |
if (Remaillage2D1->Checked==true) affiche_2D();
|
393 |
if (Front3D1->Checked==true) affiche_2D();
|
394 |
if (Remaillage3D1->Checked==true) affiche_3D();
|
395 |
affiche_axe();
|
396 |
Fenp->Cursor=crDefault;
|
397 |
}
|
398 |
//---------------------------------------------------------------------------
|
399 |
void __fastcall TFenp::Mai1Click(TObject *Sender)
|
400 |
{
|
401 |
FILE *fic;
|
402 |
char mess[255];
|
403 |
char fich[255];
|
404 |
|
405 |
strcpy(fich,Fichier);
|
406 |
fich[strlen(fich)-4]=0;
|
407 |
|
408 |
|
409 |
strcpy(mess,fich);
|
410 |
strcat(mess,".geo");
|
411 |
fic=fopen(mess,"rt");
|
412 |
if (fic==NULL) Geometrie1->Enabled=false;
|
413 |
else
|
414 |
{
|
415 |
Geometrie1->Enabled=true;
|
416 |
fclose(fic);
|
417 |
}
|
418 |
|
419 |
|
420 |
|
421 |
strcpy(mess,fich);
|
422 |
strcat(mess,"_1D.mai");
|
423 |
fic=fopen(mess,"rt");
|
424 |
if (fic==NULL) Maillage1D1->Enabled=false;
|
425 |
else
|
426 |
{
|
427 |
Maillage1D1->Enabled=true;
|
428 |
fclose(fic);
|
429 |
}
|
430 |
|
431 |
|
432 |
strcpy(mess,fich);
|
433 |
strcat(mess,"_2D.mai");
|
434 |
fic=fopen(mess,"rt");
|
435 |
if (fic==NULL) Maillage2D1->Enabled=false;
|
436 |
else
|
437 |
{
|
438 |
Maillage2D1->Enabled=true;
|
439 |
fclose(fic);
|
440 |
}
|
441 |
|
442 |
strcpy(mess,fich);
|
443 |
strcat(mess,"r_2D.mai");
|
444 |
fic=fopen(mess,"rt");
|
445 |
if (fic==NULL) Remaillage2D1->Enabled=false;
|
446 |
else
|
447 |
{
|
448 |
Remaillage2D1->Enabled=true;
|
449 |
fclose(fic);
|
450 |
}
|
451 |
strcpy(mess,fich);
|
452 |
strcat(mess,"_3D.mai");
|
453 |
fic=fopen(mess,"rt");
|
454 |
if (fic==NULL) Maillage3D1->Enabled=false;
|
455 |
else
|
456 |
{
|
457 |
Maillage3D1->Enabled=true;
|
458 |
fclose(fic);
|
459 |
}
|
460 |
strcpy(mess,fich);
|
461 |
strcat(mess,"c_3D.mai");
|
462 |
fic=fopen(mess,"rt");
|
463 |
if (fic==NULL) Maillage3D2->Enabled=false;
|
464 |
else
|
465 |
{
|
466 |
Maillage3D2->Enabled=true;
|
467 |
fclose(fic);
|
468 |
}
|
469 |
strcpy(mess,fich);
|
470 |
strcat(mess,"r_3D.mai");
|
471 |
fic=fopen(mess,"rt");
|
472 |
if (fic==NULL) Remaillage3D1->Enabled=false;
|
473 |
else
|
474 |
{
|
475 |
Remaillage3D1->Enabled=true;
|
476 |
fclose(fic);
|
477 |
}
|
478 |
strcpy(mess,fich);
|
479 |
strcat(mess,"f_2D.mai");
|
480 |
fic=fopen(mess,"rt");
|
481 |
if (fic==NULL) Front3D1->Enabled=false;
|
482 |
else
|
483 |
{
|
484 |
Front3D1->Enabled=true;
|
485 |
fclose(fic);
|
486 |
}
|
487 |
}
|
488 |
//---------------------------------------------------------------------------
|
489 |
void __fastcall TFenp::Geometrie1Click(TObject *Sender)
|
490 |
{
|
491 |
FILE *fic;
|
492 |
int i,j,k,nb,nb2;
|
493 |
char fich[255];
|
494 |
char mess[255];
|
495 |
int nb_arete;
|
496 |
|
497 |
Geometrie1->Checked=true;
|
498 |
Maillage1D1->Checked=false;
|
499 |
Front3D1->Checked=false;
|
500 |
Maillage2D1->Checked=false;
|
501 |
Remaillage2D1->Checked=false;
|
502 |
Maillage3D1->Checked=false;
|
503 |
Maillage3D2->Checked=false;
|
504 |
Remaillage3D1->Checked=false;
|
505 |
Face1->Enabled=false;
|
506 |
Activerlerendu3D1->Enabled=false;
|
507 |
Activerlerendu3D1->Checked=false;
|
508 |
Aucun1->Checked=false;
|
509 |
if (point!=NULL) free(point);
|
510 |
if (segment!=NULL) free(segment);
|
511 |
if (triangle!=NULL) free(triangle);
|
512 |
if (tetra!=NULL) free(tetra);
|
513 |
nb_point=0;point=NULL;
|
514 |
nb_segment=0;segment=NULL;
|
515 |
nb_triangle=0;triangle=NULL;
|
516 |
nb_tetra=0;tetra=NULL;
|
517 |
tete=NULL;
|
518 |
strcpy(fich,Fichier);
|
519 |
fich[strlen(fich)-4]=0;
|
520 |
strcat(fich,".geo");
|
521 |
fic=fopen(fich,"rt");
|
522 |
fgets(mess,255,fic);
|
523 |
sscanf(mess,"%d",&nb_arete);
|
524 |
for (i=0;i<nb_arete;i++)
|
525 |
{
|
526 |
fgets(mess,255,fic);
|
527 |
sscanf(mess,"%d",&j);
|
528 |
nb_point=nb_point+j;
|
529 |
nb_segment=nb_segment+j-1;
|
530 |
for (k=0;k<j;k++)
|
531 |
fgets(mess,255,fic);
|
532 |
}
|
533 |
fclose(fic);
|
534 |
fic=fopen(fich,"rt");
|
535 |
point=(struct s_point *)calloc(nb_point,sizeof(struct s_point));
|
536 |
segment=(struct s_segment *)calloc(nb_segment,sizeof(struct s_segment));
|
537 |
fgets(mess,255,fic);
|
538 |
sscanf(mess,"%d",&nb_arete);
|
539 |
nb=0;nb2=0;
|
540 |
xpiece=0.;ypiece=0.;zpiece=0.;
|
541 |
for (i=0;i<nb_arete;i++)
|
542 |
{
|
543 |
fgets(mess,255,fic);
|
544 |
sscanf(mess,"%d",&j);
|
545 |
for (k=0;k<j;k++)
|
546 |
{
|
547 |
fgets(mess,255,fic);
|
548 |
sscanf(mess,"%f %f %f",&point[nb].x,&point[nb].y,&point[nb].z);
|
549 |
if (nb==0)
|
550 |
{
|
551 |
xmin=point[nb].x;
|
552 |
xmax=point[nb].x;
|
553 |
ymin=point[nb].y;
|
554 |
ymax=point[nb].y;
|
555 |
zmin=point[nb].z;
|
556 |
zmax=point[nb].z;
|
557 |
}
|
558 |
if (point[nb].x<xmin) xmin=point[nb].x;
|
559 |
if (point[nb].x>xmax) xmax=point[nb].x;
|
560 |
if (point[nb].y<ymin) ymin=point[nb].y;
|
561 |
if (point[nb].y>ymax) ymax=point[nb].y;
|
562 |
if (point[nb].z<zmin) zmin=point[nb].z;
|
563 |
if (point[nb].z>zmax) zmax=point[nb].z;
|
564 |
xpiece=xpiece+point[nb].x;
|
565 |
ypiece=ypiece+point[nb].y;
|
566 |
zpiece=zpiece+point[nb].z;
|
567 |
if (k!=0)
|
568 |
{
|
569 |
segment[nb2].n1=nb-1;
|
570 |
segment[nb2].n2=nb;
|
571 |
nb2++;
|
572 |
}
|
573 |
nb++;
|
574 |
}
|
575 |
}
|
576 |
xpiece=xpiece/nb;
|
577 |
ypiece=ypiece/nb;
|
578 |
zpiece=zpiece/nb;
|
579 |
fclose(fic);
|
580 |
if (passe_norme==0)
|
581 |
{
|
582 |
norme();
|
583 |
passe_norme=1;
|
584 |
}
|
585 |
Invalidate();
|
586 |
}
|
587 |
|
588 |
|
589 |
//---------------------------------------------------------------------------
|
590 |
void __fastcall TFenp::Maillage1D1Click(TObject *Sender)
|
591 |
{
|
592 |
char fich[255];
|
593 |
char mess[255];
|
594 |
FILE *fic;
|
595 |
int i,j;
|
596 |
|
597 |
Geometrie1->Checked=false;
|
598 |
Maillage1D1->Checked=true;
|
599 |
Front3D1->Checked=false;
|
600 |
Maillage2D1->Checked=false;
|
601 |
Face1->Enabled=false;
|
602 |
Remaillage2D1->Checked=false;
|
603 |
Maillage3D1->Checked=false;
|
604 |
Maillage3D2->Checked=false;
|
605 |
Remaillage3D1->Checked=false;
|
606 |
Activerlerendu3D1->Checked=false;
|
607 |
Activerlerendu3D1->Enabled=false;
|
608 |
Aucun1->Checked=false;
|
609 |
if (point!=NULL) free(point);
|
610 |
if (segment!=NULL) free(segment);
|
611 |
if (triangle!=NULL) free(triangle);
|
612 |
if (tetra!=NULL) free(tetra);
|
613 |
nb_point=0;point=NULL;
|
614 |
nb_segment=0;segment=NULL;
|
615 |
nb_triangle=0;triangle=NULL;
|
616 |
nb_tetra=0;tetra=NULL;
|
617 |
tete=NULL;
|
618 |
strcpy(fich,Fichier);
|
619 |
fich[strlen(fich)-4]=0;
|
620 |
strcat(fich,"_1D.mai");
|
621 |
fic=fopen(fich,"rt");
|
622 |
fgets(mess,255,fic);
|
623 |
sscanf(mess,"%d %d",&nb_point,&nb_segment);
|
624 |
point=(struct s_point *)calloc(nb_point,sizeof(struct s_point));
|
625 |
segment=(struct s_segment *)calloc(nb_segment,sizeof(struct s_segment));
|
626 |
xpiece=0.;ypiece=0.;zpiece=0.;
|
627 |
for (i=0;i<nb_point;i++)
|
628 |
{
|
629 |
fgets(mess,255,fic);
|
630 |
sscanf(mess,"%d %f %f %f",&j,&point[i].x,&point[i].y,&point[i].z);
|
631 |
xpiece=xpiece+point[i].x;
|
632 |
ypiece=ypiece+point[i].y;
|
633 |
zpiece=zpiece+point[i].z;
|
634 |
}
|
635 |
xpiece=xpiece/nb_point;
|
636 |
ypiece=ypiece/nb_point;
|
637 |
zpiece=zpiece/nb_point;
|
638 |
for (i=0;i<nb_segment;i++)
|
639 |
{
|
640 |
fgets(mess,255,fic);
|
641 |
sscanf(mess,"%d %d %d",&j,&segment[i].n1,&segment[i].n2);
|
642 |
segment[i].n1=segment[i].n1-1;
|
643 |
segment[i].n2=segment[i].n2-1;
|
644 |
segment[i].num=i;
|
645 |
point[segment[i].n1].segment[point[segment[i].n1].nb_segment]=&(segment[i]);
|
646 |
point[segment[i].n1].nb_segment++;
|
647 |
point[segment[i].n2].segment[point[segment[i].n2].nb_segment]=&(segment[i]);
|
648 |
point[segment[i].n2].nb_segment++;
|
649 |
}
|
650 |
fclose(fic);
|
651 |
if (passe_norme==0)
|
652 |
{
|
653 |
norme();
|
654 |
passe_norme=1;
|
655 |
}
|
656 |
Invalidate();
|
657 |
}
|
658 |
//---------------------------------------------------------------------------
|
659 |
void __fastcall TFenp::Maillage2D1Click(TObject *Sender)
|
660 |
{
|
661 |
int i,j;
|
662 |
FILE *fic;
|
663 |
int *test_face,maxface;
|
664 |
char fich[255];
|
665 |
char mess[255];
|
666 |
|
667 |
Geometrie1->Checked=false;
|
668 |
Front3D1->Checked=false;
|
669 |
Maillage1D1->Checked=false;
|
670 |
Maillage2D1->Checked=true;
|
671 |
Remaillage2D1->Checked=false;
|
672 |
Maillage3D1->Checked=false;
|
673 |
Maillage3D2->Checked=false;
|
674 |
Remaillage3D1->Checked=false;
|
675 |
Activerlerendu3D1->Enabled=false;
|
676 |
Activerlerendu3D1->Checked=false;
|
677 |
Aucun1->Checked=false;
|
678 |
Face1->Enabled=true;
|
679 |
Face->ListBox1->Items->Clear();
|
680 |
Face->ListBox1->Items->Add("Toutes");
|
681 |
Face->ListBox1->ItemIndex=0;
|
682 |
Fenp->numface=(-1);
|
683 |
if (point!=NULL) free(point);
|
684 |
if (segment!=NULL) free(segment);
|
685 |
if (triangle!=NULL) free(triangle);
|
686 |
if (tetra!=NULL) free(tetra);
|
687 |
nb_point=0;point=NULL;
|
688 |
nb_segment=0;segment=NULL;
|
689 |
nb_triangle=0;triangle=NULL;
|
690 |
nb_tetra=0;tetra=NULL;
|
691 |
tete=NULL;
|
692 |
strcpy(fich,Fichier);
|
693 |
fich[strlen(fich)-4]=0;
|
694 |
strcat(fich,"_2D.mai");
|
695 |
fic=fopen(fich,"rt");
|
696 |
fgets(mess,255,fic);
|
697 |
sscanf(mess,"%d %d",&nb_point,&nb_triangle);
|
698 |
point=(struct s_point *)calloc(nb_point,sizeof(struct s_point));
|
699 |
triangle=(struct s_triangle *)calloc(nb_triangle,sizeof(struct s_triangle));
|
700 |
xpiece=0.;ypiece=0.;zpiece=0.;
|
701 |
for (i=0;i<nb_point;i++)
|
702 |
{
|
703 |
fgets(mess,255,fic);
|
704 |
sscanf(mess,"%d %f %f %f",&j,&point[i].x,&point[i].y,&point[i].z);
|
705 |
if (i==0)
|
706 |
{
|
707 |
xmin=point[i].x;
|
708 |
xmax=point[i].x;
|
709 |
ymin=point[i].y;
|
710 |
ymax=point[i].y;
|
711 |
zmin=point[i].z;
|
712 |
zmax=point[i].z;
|
713 |
maxcoord=point[i].x;
|
714 |
}
|
715 |
if (point[i].x<xmin) xmin=point[i].x;
|
716 |
if (point[i].x>xmax) xmax=point[i].x;
|
717 |
if (point[i].y<ymin) ymin=point[i].y;
|
718 |
if (point[i].y>ymax) ymax=point[i].y;
|
719 |
if (point[i].z<zmin) zmin=point[i].z;
|
720 |
if (point[i].z>zmax) zmax=point[i].z;
|
721 |
if (fabs((double)point[i].x)>maxcoord) maxcoord=(float)fabs((double)point[i].x);
|
722 |
if (fabs((double)point[i].y)>maxcoord) maxcoord=(float)fabs((double)point[i].y);
|
723 |
if (fabs((double)point[i].z)>maxcoord) maxcoord=(float)fabs((double)point[i].z);
|
724 |
xpiece=xpiece+point[i].x;
|
725 |
ypiece=ypiece+point[i].y;
|
726 |
zpiece=zpiece+point[i].z;
|
727 |
}
|
728 |
xpiece=xpiece/nb_point;
|
729 |
ypiece=ypiece/nb_point;
|
730 |
zpiece=zpiece/nb_point;
|
731 |
maxface=0;
|
732 |
for (i=0;i<nb_triangle;i++)
|
733 |
{
|
734 |
fgets(mess,255,fic);
|
735 |
sscanf(mess,"%d %d %d %d %s %d",&j,&triangle[i].n1,&triangle[i].n2,&triangle[i].n3,&triangle[i].type,&triangle[i].num_ent);
|
736 |
triangle[i].n1=triangle[i].n1-1;
|
737 |
triangle[i].n2=triangle[i].n2-1;
|
738 |
triangle[i].n3=triangle[i].n3-1;
|
739 |
triangle[i].num=i;
|
740 |
if (triangle[i].num_ent>maxface) maxface=triangle[i].num_ent;
|
741 |
point[triangle[i].n1].triangle[point[triangle[i].n1].nb_triangle]=&(triangle[i]);
|
742 |
point[triangle[i].n1].nb_triangle++;
|
743 |
point[triangle[i].n2].triangle[point[triangle[i].n2].nb_triangle]=&(triangle[i]);
|
744 |
point[triangle[i].n2].nb_triangle++;
|
745 |
point[triangle[i].n3].triangle[point[triangle[i].n3].nb_triangle]=&(triangle[i]);
|
746 |
point[triangle[i].n3].nb_triangle++;
|
747 |
}
|
748 |
fclose(fic);
|
749 |
test_face=(int *)calloc(maxface+1,sizeof(int));
|
750 |
for (i=0;i<nb_triangle;i++)
|
751 |
test_face[triangle[i].num_ent]=1;
|
752 |
for (i=0;i<maxface+1;i++)
|
753 |
if (test_face[i]==1)
|
754 |
{
|
755 |
sprintf(mess,"%d",i);
|
756 |
Face->ListBox1->Items->Add(mess);
|
757 |
}
|
758 |
free(test_face);
|
759 |
if (passe_norme==0)
|
760 |
{
|
761 |
norme();
|
762 |
passe_norme=1;
|
763 |
}
|
764 |
Invalidate();
|
765 |
}
|
766 |
//---------------------------------------------------------------------------
|
767 |
void __fastcall TFenp::Maillage3D1Click(TObject *Sender)
|
768 |
{
|
769 |
int i,j;
|
770 |
FILE *fic;
|
771 |
char fich[255];
|
772 |
char mess[255];
|
773 |
|
774 |
|
775 |
Geometrie1->Checked=false;
|
776 |
Maillage1D1->Checked=false;
|
777 |
Maillage2D1->Checked=false;
|
778 |
Remaillage2D1->Checked=false;
|
779 |
Front3D1->Checked=false;
|
780 |
Maillage3D1->Checked=true;
|
781 |
Maillage3D2->Checked=false;
|
782 |
Remaillage3D1->Checked=false;
|
783 |
Activerlerendu3D1->Enabled=true;
|
784 |
Activerlerendu3D1->Checked=false;
|
785 |
Face1->Enabled=false;
|
786 |
Aucun1->Checked=false;
|
787 |
if (point!=NULL) free(point);
|
788 |
if (segment!=NULL) free(segment);
|
789 |
if (triangle!=NULL) free(triangle);
|
790 |
if (tetra!=NULL) free(tetra);
|
791 |
nb_point=0;point=NULL;
|
792 |
nb_segment=0;segment=NULL;
|
793 |
nb_triangle=0;triangle=NULL;
|
794 |
nb_tetra=0;tetra=NULL;
|
795 |
tete=NULL;
|
796 |
strcpy(fich,Fichier);
|
797 |
fich[strlen(fich)-4]=0;
|
798 |
strcat(fich,"_3D.mai");
|
799 |
fic=fopen(fich,"rt");
|
800 |
fgets(mess,255,fic);
|
801 |
sscanf(mess,"%d %d",&nb_point,&nb_tetra);
|
802 |
point=(struct s_point *)calloc(nb_point,sizeof(struct s_point));
|
803 |
tetra=(struct s_tetra *)calloc(nb_tetra,sizeof(struct s_tetra));
|
804 |
xpiece=0.;ypiece=0.;zpiece=0.;
|
805 |
for (i=0;i<nb_point;i++)
|
806 |
{
|
807 |
fgets(mess,255,fic);
|
808 |
sscanf(mess,"%d %f %f %f",&j,&point[i].x,&point[i].y,&point[i].z);
|
809 |
if (i==0)
|
810 |
{
|
811 |
xmin=point[i].x;
|
812 |
xmax=point[i].x;
|
813 |
ymin=point[i].y;
|
814 |
ymax=point[i].y;
|
815 |
zmin=point[i].z;
|
816 |
zmax=point[i].z;
|
817 |
maxcoord=point[i].x;
|
818 |
}
|
819 |
if (point[i].x<xmin) xmin=point[i].x;
|
820 |
if (point[i].x>xmax) xmax=point[i].x;
|
821 |
if (point[i].y<ymin) ymin=point[i].y;
|
822 |
if (point[i].y>ymax) ymax=point[i].y;
|
823 |
if (point[i].z<zmin) zmin=point[i].z;
|
824 |
if (point[i].z>zmax) zmax=point[i].z;
|
825 |
if (fabs((double)point[i].x)>maxcoord) maxcoord=(float)fabs((double)point[i].x);
|
826 |
if (fabs((double)point[i].y)>maxcoord) maxcoord=(float)fabs((double)point[i].y);
|
827 |
if (fabs((double)point[i].z)>maxcoord) maxcoord=(float)fabs((double)point[i].z);
|
828 |
xpiece=xpiece+point[i].x;
|
829 |
ypiece=ypiece+point[i].y;
|
830 |
zpiece=zpiece+point[i].z;
|
831 |
}
|
832 |
xpiece=xpiece/nb_point;
|
833 |
ypiece=ypiece/nb_point;
|
834 |
zpiece=zpiece/nb_point;
|
835 |
for (i=0;i<nb_tetra;i++)
|
836 |
{
|
837 |
fgets(mess,255,fic);
|
838 |
sscanf(mess,"%d %d %d %d %d",&j,&tetra[i].n1,&tetra[i].n2,&tetra[i].n3,&tetra[i].n4);
|
839 |
tetra[i].n1=tetra[i].n1-1;
|
840 |
tetra[i].n2=tetra[i].n2-1;
|
841 |
tetra[i].n3=tetra[i].n3-1;
|
842 |
tetra[i].n4=tetra[i].n4-1;
|
843 |
tetra[i].num=i;
|
844 |
point[tetra[i].n1].tetra[point[tetra[i].n1].nb_tetra]=&(tetra[i]);
|
845 |
point[tetra[i].n1].nb_tetra++;
|
846 |
point[tetra[i].n2].tetra[point[tetra[i].n2].nb_tetra]=&(tetra[i]);
|
847 |
point[tetra[i].n2].nb_tetra++;
|
848 |
point[tetra[i].n3].tetra[point[tetra[i].n3].nb_tetra]=&(tetra[i]);
|
849 |
point[tetra[i].n3].nb_tetra++;
|
850 |
point[tetra[i].n4].tetra[point[tetra[i].n4].nb_tetra]=&(tetra[i]);
|
851 |
point[tetra[i].n4].nb_tetra++;
|
852 |
}
|
853 |
fclose(fic);
|
854 |
if (passe_norme==0)
|
855 |
{
|
856 |
norme();
|
857 |
passe_norme=1;
|
858 |
}
|
859 |
Invalidate();
|
860 |
}
|
861 |
//---------------------------------------------------------------------------
|
862 |
void __fastcall TFenp::Aucun1Click(TObject *Sender)
|
863 |
{
|
864 |
Geometrie1->Checked=false;
|
865 |
Maillage1D1->Checked=false;
|
866 |
Front3D1->Checked=false;
|
867 |
Maillage2D1->Checked=false;
|
868 |
Remaillage2D1->Checked=false;
|
869 |
Maillage3D1->Checked=false;
|
870 |
Maillage3D2->Checked=false;
|
871 |
Remaillage3D1->Checked=false;
|
872 |
Aucun1->Checked=true;
|
873 |
Face1->Enabled=false;
|
874 |
if (point!=NULL) free(point);
|
875 |
if (segment!=NULL) free(segment);
|
876 |
if (triangle!=NULL) free(triangle);
|
877 |
if (tetra!=NULL) free(tetra);
|
878 |
nb_point=0;point=NULL;
|
879 |
nb_segment=0;segment=NULL;
|
880 |
nb_triangle=0;triangle=NULL;
|
881 |
nb_tetra=0;tetra=NULL;
|
882 |
Invalidate();
|
883 |
}
|
884 |
//---------------------------------------------------------------------------
|
885 |
void __fastcall TFenp::norme(void)
|
886 |
{
|
887 |
int i,xc,yc;
|
888 |
float zoomx,zoomy;
|
889 |
int xcmax,ycmin,ycmax,xcmin;
|
890 |
|
891 |
for (i=0;i<nb_point;i++)
|
892 |
{
|
893 |
projection(point[i].x,point[i].y,point[i].z,&xc,&yc,0);
|
894 |
if (i==0)
|
895 |
{
|
896 |
xcmax=xc;
|
897 |
xcmin=xc;
|
898 |
ycmax=yc;
|
899 |
ycmin=yc;
|
900 |
}
|
901 |
if (xc>xcmax) xcmax=xc;
|
902 |
if (yc>ycmax) ycmax=yc;
|
903 |
if (xc<xcmin) xcmin=xc;
|
904 |
if (yc<ycmin) ycmin=yc;
|
905 |
}
|
906 |
xcmax++;xcmin--;
|
907 |
ycmax++;ycmin--;
|
908 |
if (xcmax!=xcmin) zoomx=Fenp->ClientWidth*1./(xcmax-xcmin); else zoomx=1E30;
|
909 |
if (ycmax!=ycmin) zoomy=Fenp->ClientHeight*1./(ycmax-ycmin); else zoomy=1E30;
|
910 |
if (zoomx>zoomy) zoom=zoomy; else zoom=zoomx;
|
911 |
zoom=zoom/1.15;
|
912 |
xcentre=(Fenp->ClientWidth/2.-zoom*(xcmin+xcmax)/2.);
|
913 |
ycentre=(Fenp->ClientHeight/2.-zoom*(ycmin+ycmax)/2.);
|
914 |
}
|
915 |
//---------------------------------------------------------------------------
|
916 |
void __fastcall TFenp::projection(float x,float y,float z,int *xc,int *yc,int complete)
|
917 |
{
|
918 |
float alpha,calpha,salpha,xx,yy;
|
919 |
|
920 |
|
921 |
if (Vueisometrique1->Checked==true)
|
922 |
{
|
923 |
alpha=PI/6.;
|
924 |
calpha=(float)cos((double)alpha);
|
925 |
salpha=(float)sin((double)alpha);
|
926 |
xx=(-calpha*rot[0][0]+calpha*rot[1][0])*x
|
927 |
+(-calpha*rot[0][1]+calpha*rot[1][1])*y
|
928 |
+(-calpha*rot[0][2]+calpha*rot[1][2])*z;
|
929 |
yy=(salpha*rot[0][0]+salpha*rot[1][0]-rot[2][0])*x
|
930 |
+(salpha*rot[0][1]+salpha*rot[1][1]-rot[2][1])*y
|
931 |
+(salpha*rot[0][2]+salpha*rot[1][2]-rot[2][2])*z;
|
932 |
}
|
933 |
if (VueXY1->Checked==true)
|
934 |
{
|
935 |
xx=rot[0][0]*x+rot[1][0]*y+rot[2][0]*z;
|
936 |
yy=(-(rot[0][1]*x+rot[1][1]*y+rot[2][1]*z));
|
937 |
}
|
938 |
if (VueXZ1->Checked==true)
|
939 |
{
|
940 |
xx=rot[0][0]*x+rot[1][0]*y+rot[2][0]*z;
|
941 |
yy=(-(rot[0][2]*x+rot[1][2]*y+rot[2][2]*z));
|
942 |
}
|
943 |
if (VueYZ1->Checked==true)
|
944 |
{
|
945 |
xx=rot[0][1]*x+rot[1][1]*y+rot[2][1]*z;
|
946 |
yy=(-(rot[0][2]*x+rot[1][2]*y+rot[2][2]*z));
|
947 |
}
|
948 |
if (complete==1)
|
949 |
{
|
950 |
xx=xx*zoom+xcentre;
|
951 |
yy=yy*zoom+ycentre;
|
952 |
}
|
953 |
if (complete==2)
|
954 |
{
|
955 |
xx=xx*zoom_p+xcentre_p;
|
956 |
yy=yy*zoom_p+ycentre_p;
|
957 |
}
|
958 |
*xc=(int)xx;
|
959 |
*yc=(int)yy;
|
960 |
}
|
961 |
//---------------------------------------------------------------------------
|
962 |
|
963 |
void __fastcall TFenp::FormResize(TObject *Sender)
|
964 |
{
|
965 |
if (Aucun1->Checked==false)
|
966 |
{
|
967 |
norme();
|
968 |
Invalidate();
|
969 |
}
|
970 |
}
|
971 |
//---------------------------------------------------------------------------
|
972 |
void __fastcall TFenp::affiche_geo(void)
|
973 |
{
|
974 |
int i,n1,n2;
|
975 |
float x1,x2,y1,y2,z1,z2;
|
976 |
int xc1,xc2,yc1,yc2;
|
977 |
|
978 |
Fenp->Canvas->Pen->Color=clWhite;
|
979 |
for (i=0;i<nb_segment;i++)
|
980 |
{
|
981 |
n1=segment[i].n1;
|
982 |
n2=segment[i].n2;
|
983 |
x1=point[n1].x;
|
984 |
y1=point[n1].y;
|
985 |
z1=point[n1].z;
|
986 |
x2=point[n2].x;
|
987 |
y2=point[n2].y;
|
988 |
z2=point[n2].z;
|
989 |
projection(x1,y1,z1,&xc1,&yc1,1);
|
990 |
projection(x2,y2,z2,&xc2,&yc2,1);
|
991 |
Fenp->Canvas->MoveTo(xc1,yc1);
|
992 |
Fenp->Canvas->LineTo(xc2,yc2);
|
993 |
}
|
994 |
}
|
995 |
//---------------------------------------------------------------------------
|
996 |
void __fastcall TFenp::affiche_1D(void)
|
997 |
{
|
998 |
int i,n1,n2;
|
999 |
float x1,x2,y1,y2,z1,z2;
|
1000 |
int xc1,xc2,yc1,yc2;
|
1001 |
char mess[20];
|
1002 |
|
1003 |
Fenp->Canvas->Pen->Color=clRed;
|
1004 |
Fenp->Canvas->Font->Color=clFuchsia;
|
1005 |
for (i=0;i<nb_point;i++)
|
1006 |
{
|
1007 |
x1=point[i].x;
|
1008 |
y1=point[i].y;
|
1009 |
z1=point[i].z;
|
1010 |
projection(x1,y1,z1,&xc1,&yc1,1);
|
1011 |
Fenp->Canvas->MoveTo(xc1-2,yc1);
|
1012 |
Fenp->Canvas->LineTo(xc1+2,yc1);
|
1013 |
Fenp->Canvas->MoveTo(xc1,yc1-2);
|
1014 |
Fenp->Canvas->LineTo(xc1,yc1+2);
|
1015 |
SetBkMode(Fenp->Canvas->Handle,TRANSPARENT);
|
1016 |
if (Noeud1->Checked==true)
|
1017 |
{
|
1018 |
sprintf(mess,"%d",i);
|
1019 |
Fenp->Canvas->TextOut(xc1+2,yc1+2,mess);
|
1020 |
}
|
1021 |
}
|
1022 |
Fenp->Canvas->Font->Color=clYellow;
|
1023 |
for (i=0;i<nb_segment;i++)
|
1024 |
{
|
1025 |
if ((segment[i].select==0)&& (Debug1->Checked)) continue;
|
1026 |
n1=segment[i].n1;
|
1027 |
n2=segment[i].n2;
|
1028 |
x1=point[n1].x;
|
1029 |
y1=point[n1].y;
|
1030 |
z1=point[n1].z;
|
1031 |
x2=point[n2].x;
|
1032 |
y2=point[n2].y;
|
1033 |
z2=point[n2].z;
|
1034 |
projection(x1,y1,z1,&xc1,&yc1,1);
|
1035 |
projection(x2,y2,z2,&xc2,&yc2,1);
|
1036 |
Fenp->Canvas->MoveTo(xc1,yc1);
|
1037 |
Fenp->Canvas->LineTo(xc2,yc2);
|
1038 |
SetBkMode(Fenp->Canvas->Handle,TRANSPARENT);
|
1039 |
if (Maille2->Checked==true)
|
1040 |
{
|
1041 |
sprintf(mess,"%d",i);
|
1042 |
Fenp->Canvas->TextOut((int)((xc1+xc2)*0.5),(int)((yc1+yc2)*0.5),mess);
|
1043 |
}
|
1044 |
}
|
1045 |
if (numero_noeud>=0)
|
1046 |
{
|
1047 |
Fenp->Canvas->Font->Color=clWhite;
|
1048 |
x1=point[numero_noeud].x;
|
1049 |
y1=point[numero_noeud].y;
|
1050 |
z1=point[numero_noeud].z;
|
1051 |
projection(x1,y1,z1,&xc1,&yc1,1);
|
1052 |
sprintf(mess,"%d",numero_noeud);
|
1053 |
Fenp->Canvas->TextOut(xc1+2,yc1+2,mess);
|
1054 |
}
|
1055 |
if (numero_maille>=0)
|
1056 |
{
|
1057 |
Fenp->Canvas->Font->Color=clWhite;
|
1058 |
n1=segment[numero_maille].n1;
|
1059 |
n2=segment[numero_maille].n2;
|
1060 |
x1=point[n1].x;
|
1061 |
y1=point[n1].y;
|
1062 |
z1=point[n1].z;
|
1063 |
x2=point[n2].x;
|
1064 |
y2=point[n2].y;
|
1065 |
z2=point[n2].z;
|
1066 |
projection(x1,y1,z1,&xc1,&yc1,1);
|
1067 |
projection(x2,y2,z2,&xc2,&yc2,1);
|
1068 |
sprintf(mess,"%d",numero_maille);
|
1069 |
Fenp->Canvas->TextOut((int)((xc1+xc2)*0.5),(int)((yc1+yc2)*0.5),mess);
|
1070 |
}
|
1071 |
}
|
1072 |
//---------------------------------------------------------------------------
|
1073 |
void __fastcall TFenp::affiche_2D(void)
|
1074 |
{
|
1075 |
int i,n1,n2,n3;
|
1076 |
float x1,x2,y1,y2,z1,z2,x3,y3,z3;
|
1077 |
float ab[3],ac[3],g[3],crit;
|
1078 |
int xc1,xc2,yc1,yc2,xc3,yc3;
|
1079 |
TRect r;
|
1080 |
char mess[20];
|
1081 |
|
1082 |
if (fc==1)
|
1083 |
{
|
1084 |
affiche_reel();
|
1085 |
return;
|
1086 |
}
|
1087 |
Fenp->Canvas->Pen->Color=clRed;
|
1088 |
if (Eclatee1->Checked==true) Fenp->Canvas->Pen->Color=clOlive;
|
1089 |
for (i=0;i<nb_triangle;i++)
|
1090 |
{
|
1091 |
if ((triangle[i].num_ent==numface) || (numface==(-1)))
|
1092 |
{
|
1093 |
if ((triangle[i].select==0) && (Debug1->Checked)) continue;
|
1094 |
n1=triangle[i].n1;
|
1095 |
n2=triangle[i].n2;
|
1096 |
n3=triangle[i].n3;
|
1097 |
x1=point[n1].x;
|
1098 |
y1=point[n1].y;
|
1099 |
z1=point[n1].z;
|
1100 |
x2=point[n2].x;
|
1101 |
y2=point[n2].y;
|
1102 |
z2=point[n2].z;
|
1103 |
x3=point[n3].x;
|
1104 |
y3=point[n3].y;
|
1105 |
z3=point[n3].z;
|
1106 |
if (Normal1->Checked==false)
|
1107 |
{
|
1108 |
if (Qualite1->Checked==true)
|
1109 |
{
|
1110 |
crit=crit_cal2d(n1,n2,n3);
|
1111 |
if (crit>0.5) Fenp->Canvas->Pen->Color=clLime;
|
1112 |
else if (crit>0.2) Fenp->Canvas->Pen->Color=clBlue;
|
1113 |
else if (crit>0.1) Fenp->Canvas->Pen->Color=clRed;
|
1114 |
else Fenp->Canvas->Pen->Color=clMaroon;
|
1115 |
}
|
1116 |
ab[0]=x2-x1;ab[1]=y2-y1;ab[2]=z2-z1;
|
1117 |
ac[0]=x3-x1;ac[1]=y3-y1;ac[2]=z3-z1;
|
1118 |
g[0]=x1+0.33333*(ab[0]+ac[0]);
|
1119 |
g[1]=y1+0.33333*(ab[1]+ac[1]);
|
1120 |
g[2]=z1+0.33333*(ab[2]+ac[2]);
|
1121 |
x1=g[0]+homo*(x1-g[0]);y1=g[1]+homo*(y1-g[1]);z1=g[2]+homo*(z1-g[2]);
|
1122 |
x2=g[0]+homo*(x2-g[0]);y2=g[1]+homo*(y2-g[1]);z2=g[2]+homo*(z2-g[2]);
|
1123 |
x3=g[0]+homo*(x3-g[0]);y3=g[1]+homo*(y3-g[1]);z3=g[2]+homo*(z3-g[2]);
|
1124 |
}
|
1125 |
projection(x1,y1,z1,&xc1,&yc1,1);
|
1126 |
projection(x2,y2,z2,&xc2,&yc2,1);
|
1127 |
projection(x3,y3,z3,&xc3,&yc3,1);
|
1128 |
Fenp->Canvas->MoveTo(xc1,yc1);
|
1129 |
Fenp->Canvas->LineTo(xc2,yc2);
|
1130 |
Fenp->Canvas->LineTo(xc3,yc3);
|
1131 |
Fenp->Canvas->LineTo(xc1,yc1);
|
1132 |
Fenp->Canvas->Font->Color=clFuchsia;
|
1133 |
SetBkMode(Fenp->Canvas->Handle,TRANSPARENT);
|
1134 |
if (Noeud1->Checked==true)
|
1135 |
{
|
1136 |
sprintf(mess,"%d",n1);
|
1137 |
projection(point[n1].x,point[n1].y,point[n1].z,&xc1,&yc1,1);
|
1138 |
Fenp->Canvas->TextOut(xc1+2,yc1+2,mess);
|
1139 |
sprintf(mess,"%d",n2);
|
1140 |
projection(point[n2].x,point[n2].y,point[n2].z,&xc2,&yc2,1);
|
1141 |
Fenp->Canvas->TextOut(xc2+2,yc2+2,mess);
|
1142 |
sprintf(mess,"%d",n3);
|
1143 |
projection(point[n3].x,point[n3].y,point[n3].z,&xc3,&yc3,1);
|
1144 |
Fenp->Canvas->TextOut(xc3+2,yc3+2,mess);
|
1145 |
}
|
1146 |
Fenp->Canvas->Font->Color=clYellow;
|
1147 |
if (Maille2->Checked==true)
|
1148 |
{
|
1149 |
sprintf(mess,"%d",i);
|
1150 |
Fenp->Canvas->TextOut((int)((xc1+xc2+xc3)*0.333333),(int)((yc1+yc2+yc3)*0.33333333),mess);
|
1151 |
}
|
1152 |
}
|
1153 |
}
|
1154 |
if (Qualite1->Checked==true)
|
1155 |
{
|
1156 |
Fenp->Canvas->TextOut(10,95,"Qualite");
|
1157 |
Fenp->Canvas->Brush->Color=clLime;
|
1158 |
r.Left=5;r.Top=113;r.Bottom=120;r.Right=15;
|
1159 |
Fenp->Canvas->FillRect(r);
|
1160 |
Fenp->Canvas->Brush->Color=clBlue;
|
1161 |
r.Left=5;r.Top=125;r.Bottom=132;r.Right=15;
|
1162 |
Fenp->Canvas->FillRect(r);
|
1163 |
Fenp->Canvas->Brush->Color=clRed;
|
1164 |
r.Left=5;r.Top=137;r.Bottom=144;r.Right=15;
|
1165 |
Fenp->Canvas->FillRect(r);
|
1166 |
Fenp->Canvas->Brush->Color=clMaroon;
|
1167 |
r.Left=5;r.Top=149;r.Bottom=156;r.Right=15;
|
1168 |
Fenp->Canvas->FillRect(r);
|
1169 |
Fenp->Canvas->Brush->Color=clBlack;
|
1170 |
Fenp->Canvas->TextOut(20,110,"Bonne");
|
1171 |
Fenp->Canvas->TextOut(20,122,"Moyenne");
|
1172 |
Fenp->Canvas->TextOut(20,134,"Passable");
|
1173 |
Fenp->Canvas->TextOut(20,146,"Mediocre");
|
1174 |
}
|
1175 |
if (numero_noeud>=0)
|
1176 |
{
|
1177 |
Fenp->Canvas->Font->Color=clWhite;
|
1178 |
x1=point[numero_noeud].x;
|
1179 |
y1=point[numero_noeud].y;
|
1180 |
z1=point[numero_noeud].z;
|
1181 |
projection(x1,y1,z1,&xc1,&yc1,1);
|
1182 |
sprintf(mess,"%d",numero_noeud);
|
1183 |
Fenp->Canvas->TextOut(xc1+2,yc1+2,mess);
|
1184 |
}
|
1185 |
if (numero_maille>=0)
|
1186 |
{
|
1187 |
Fenp->Canvas->Font->Color=clWhite;
|
1188 |
n1=triangle[numero_maille].n1;
|
1189 |
n2=triangle[numero_maille].n2;
|
1190 |
n3=triangle[numero_maille].n3;
|
1191 |
x1=point[n1].x;
|
1192 |
y1=point[n1].y;
|
1193 |
z1=point[n1].z;
|
1194 |
x2=point[n2].x;
|
1195 |
y2=point[n2].y;
|
1196 |
z2=point[n2].z;
|
1197 |
x3=point[n3].x;
|
1198 |
y3=point[n3].y;
|
1199 |
z3=point[n3].z;
|
1200 |
projection(x1,y1,z1,&xc1,&yc1,1);
|
1201 |
projection(x2,y2,z2,&xc2,&yc2,1);
|
1202 |
projection(x3,y3,z3,&xc3,&yc3,1);
|
1203 |
sprintf(mess,"%d",numero_maille);
|
1204 |
Fenp->Canvas->TextOut((int)((xc1+xc2+xc3)*0.333333),(int)((yc1+yc2+yc3)*0.33333333),mess);
|
1205 |
}
|
1206 |
|
1207 |
}
|
1208 |
//---------------------------------------------------------------------------
|
1209 |
void __fastcall TFenp::affiche_3D(void)
|
1210 |
{
|
1211 |
int i,n1,n2,n3,n4;
|
1212 |
float x1,x2,y1,y2,z1,z2,x3,y3,z3,x4,y4,z4;
|
1213 |
float ab[3],ac[3],ad[3],g[3],crit;
|
1214 |
int xc1,xc2,yc1,yc2,xc3,yc3,xc4,yc4;
|
1215 |
char mess[20];
|
1216 |
TRect r;
|
1217 |
|
1218 |
if ((Activerlerendu3D1->Checked==true)&&(fc==1))
|
1219 |
{
|
1220 |
affiche_reel();
|
1221 |
return;
|
1222 |
}
|
1223 |
Fenp->Canvas->Pen->Color=clRed;
|
1224 |
if (Eclatee1->Checked==true) Fenp->Canvas->Pen->Color=clOlive;
|
1225 |
for (i=0;i<nb_tetra;i++)
|
1226 |
{
|
1227 |
if ((tetra[i].select==0)&& (Debug1->Checked)) continue;
|
1228 |
n1=tetra[i].n1;
|
1229 |
n2=tetra[i].n2;
|
1230 |
n3=tetra[i].n3;
|
1231 |
n4=tetra[i].n4;
|
1232 |
x1=point[n1].x;
|
1233 |
y1=point[n1].y;
|
1234 |
z1=point[n1].z;
|
1235 |
x2=point[n2].x;
|
1236 |
y2=point[n2].y;
|
1237 |
z2=point[n2].z;
|
1238 |
x3=point[n3].x;
|
1239 |
y3=point[n3].y;
|
1240 |
z3=point[n3].z;
|
1241 |
x4=point[n4].x;
|
1242 |
y4=point[n4].y;
|
1243 |
z4=point[n4].z;
|
1244 |
if (Normal1->Checked==false)
|
1245 |
{
|
1246 |
if (Qualite1->Checked==true)
|
1247 |
{
|
1248 |
crit=crit_cal3d(n1,n2,n3,n4);
|
1249 |
if (crit>0.5) Fenp->Canvas->Pen->Color=clLime;
|
1250 |
else if (crit>0.2) Fenp->Canvas->Pen->Color=clBlue;
|
1251 |
else if (crit>0.1) Fenp->Canvas->Pen->Color=clRed;
|
1252 |
else Fenp->Canvas->Pen->Color=clMaroon;
|
1253 |
}
|
1254 |
ab[0]=x2-x1;ab[1]=y2-y1;ab[2]=z2-z1;
|
1255 |
ac[0]=x3-x1;ac[1]=y3-y1;ac[2]=z3-z1;
|
1256 |
ad[0]=x4-x1;ad[1]=y4-y1;ad[2]=z4-z1;
|
1257 |
g[0]=x1+0.25*(ab[0]+ac[0]+ad[0]);
|
1258 |
g[1]=y1+0.25*(ab[1]+ac[1]+ad[1]);
|
1259 |
g[2]=z1+0.25*(ab[2]+ac[2]+ad[2]);
|
1260 |
x1=g[0]+homo*(x1-g[0]);y1=g[1]+homo*(y1-g[1]);z1=g[2]+homo*(z1-g[2]);
|
1261 |
x2=g[0]+homo*(x2-g[0]);y2=g[1]+homo*(y2-g[1]);z2=g[2]+homo*(z2-g[2]);
|
1262 |
x3=g[0]+homo*(x3-g[0]);y3=g[1]+homo*(y3-g[1]);z3=g[2]+homo*(z3-g[2]);
|
1263 |
x4=g[0]+homo*(x4-g[0]);y4=g[1]+homo*(y4-g[1]);z4=g[2]+homo*(z4-g[2]);
|
1264 |
}
|
1265 |
projection(x1,y1,z1,&xc1,&yc1,1);
|
1266 |
projection(x2,y2,z2,&xc2,&yc2,1);
|
1267 |
projection(x3,y3,z3,&xc3,&yc3,1);
|
1268 |
projection(x4,y4,z4,&xc4,&yc4,1);
|
1269 |
Fenp->Canvas->MoveTo(xc1,yc1);
|
1270 |
Fenp->Canvas->LineTo(xc2,yc2);
|
1271 |
Fenp->Canvas->LineTo(xc3,yc3);
|
1272 |
Fenp->Canvas->LineTo(xc1,yc1);
|
1273 |
Fenp->Canvas->MoveTo(xc4,yc4);
|
1274 |
Fenp->Canvas->LineTo(xc1,yc1);
|
1275 |
Fenp->Canvas->MoveTo(xc4,yc4);
|
1276 |
Fenp->Canvas->LineTo(xc2,yc2);
|
1277 |
Fenp->Canvas->MoveTo(xc4,yc4);
|
1278 |
Fenp->Canvas->LineTo(xc3,yc3);
|
1279 |
Fenp->Canvas->Font->Color=clFuchsia;
|
1280 |
SetBkMode(Fenp->Canvas->Handle,TRANSPARENT);
|
1281 |
if (Noeud1->Checked==true)
|
1282 |
{
|
1283 |
sprintf(mess,"%d",n1);
|
1284 |
Fenp->Canvas->TextOut(xc1+2,yc1+2,mess);
|
1285 |
sprintf(mess,"%d",n2);
|
1286 |
Fenp->Canvas->TextOut(xc2+2,yc2+2,mess);
|
1287 |
sprintf(mess,"%d",n3);
|
1288 |
Fenp->Canvas->TextOut(xc3+2,yc3+2,mess);
|
1289 |
sprintf(mess,"%d",n4);
|
1290 |
Fenp->Canvas->TextOut(xc4+2,yc4+2,mess);
|
1291 |
}
|
1292 |
Fenp->Canvas->Font->Color=clYellow;
|
1293 |
if (Maille2->Checked==true)
|
1294 |
{
|
1295 |
sprintf(mess,"%d",i);
|
1296 |
Fenp->Canvas->TextOut((int)((xc1+xc2+xc3+xc4)*0.25),(int)((yc1+yc2+yc3+yc4)*0.25),mess);
|
1297 |
}
|
1298 |
}
|
1299 |
if (Qualite1->Checked==true)
|
1300 |
{
|
1301 |
Fenp->Canvas->TextOut(10,95,"Qualite");
|
1302 |
Fenp->Canvas->Brush->Color=clLime;
|
1303 |
r.Left=5;r.Top=113;r.Bottom=120;r.Right=15;
|
1304 |
Fenp->Canvas->FillRect(r);
|
1305 |
Fenp->Canvas->Brush->Color=clBlue;
|
1306 |
r.Left=5;r.Top=125;r.Bottom=132;r.Right=15;
|
1307 |
Fenp->Canvas->FillRect(r);
|
1308 |
Fenp->Canvas->Brush->Color=clRed;
|
1309 |
r.Left=5;r.Top=137;r.Bottom=144;r.Right=15;
|
1310 |
Fenp->Canvas->FillRect(r);
|
1311 |
Fenp->Canvas->Brush->Color=clMaroon;
|
1312 |
r.Left=5;r.Top=149;r.Bottom=156;r.Right=15;
|
1313 |
Fenp->Canvas->FillRect(r);
|
1314 |
Fenp->Canvas->Brush->Color=clBlack;
|
1315 |
Fenp->Canvas->TextOut(20,110,"Bonne");
|
1316 |
Fenp->Canvas->TextOut(20,122,"Moyenne");
|
1317 |
Fenp->Canvas->TextOut(20,134,"Passable");
|
1318 |
Fenp->Canvas->TextOut(20,146,"Mediocre");
|
1319 |
}
|
1320 |
if (numero_noeud>=0)
|
1321 |
{
|
1322 |
Fenp->Canvas->Font->Color=clWhite;
|
1323 |
x1=point[numero_noeud].x;
|
1324 |
y1=point[numero_noeud].y;
|
1325 |
z1=point[numero_noeud].z;
|
1326 |
projection(x1,y1,z1,&xc1,&yc1,1);
|
1327 |
sprintf(mess,"%d",numero_noeud);
|
1328 |
Fenp->Canvas->TextOut(xc1+2,yc1+2,mess);
|
1329 |
}
|
1330 |
if (numero_maille>=0)
|
1331 |
{
|
1332 |
Fenp->Canvas->Font->Color=clWhite;
|
1333 |
n1=tetra[numero_maille].n1;
|
1334 |
n2=tetra[numero_maille].n2;
|
1335 |
n3=tetra[numero_maille].n3;
|
1336 |
n4=tetra[numero_maille].n4;
|
1337 |
x1=point[n1].x;
|
1338 |
y1=point[n1].y;
|
1339 |
z1=point[n1].z;
|
1340 |
x2=point[n2].x;
|
1341 |
y2=point[n2].y;
|
1342 |
z2=point[n2].z;
|
1343 |
x3=point[n3].x;
|
1344 |
y3=point[n3].y;
|
1345 |
z3=point[n3].z;
|
1346 |
x4=point[n4].x;
|
1347 |
y4=point[n4].y;
|
1348 |
z4=point[n4].z;
|
1349 |
projection(x1,y1,z1,&xc1,&yc1,1);
|
1350 |
projection(x2,y2,z2,&xc2,&yc2,1);
|
1351 |
projection(x3,y3,z3,&xc3,&yc3,1);
|
1352 |
projection(x4,y4,z4,&xc4,&yc4,1);
|
1353 |
sprintf(mess,"%d",numero_maille);
|
1354 |
Fenp->Canvas->TextOut((int)((xc1+xc2+xc3+xc4)*0.25),(int)((yc1+yc2+yc3+yc4)*0.25),mess);
|
1355 |
}
|
1356 |
|
1357 |
|
1358 |
}
|
1359 |
//---------------------------------------------------------------------------
|
1360 |
void __fastcall TFenp::affiche_reel(void)
|
1361 |
{
|
1362 |
int *iordre;
|
1363 |
float *distance;
|
1364 |
int xpoint[8];
|
1365 |
TPoint ypoint[8];
|
1366 |
float xe,ye,ze,xee,yee,zee;
|
1367 |
float xa,ya,za;
|
1368 |
float xb,yb,zb;
|
1369 |
float xc,yc,zc;
|
1370 |
float xg,yg,zg;
|
1371 |
float nx,ny,nz;
|
1372 |
float g[4];
|
1373 |
char mess[20];
|
1374 |
struct s_triangle *tri;
|
1375 |
static float dismin,dismax;
|
1376 |
float diff;
|
1377 |
static float arot[3][3]={{-1.,-1.,-1.},{-1.,-1.,-1.},{-1.,-1.,-1.}};
|
1378 |
int i;
|
1379 |
int pareil,color;
|
1380 |
|
1381 |
pareil=0;
|
1382 |
if (tete!=NULL)
|
1383 |
if (arot[0][0]==rot[0][0])
|
1384 |
if (arot[1][0]==rot[1][0])
|
1385 |
if (arot[2][0]==rot[2][0])
|
1386 |
if (arot[0][1]==rot[0][1])
|
1387 |
if (arot[1][1]==rot[1][1])
|
1388 |
if (arot[2][1]==rot[2][1])
|
1389 |
if (arot[0][2]==rot[0][2])
|
1390 |
if (arot[1][2]==rot[1][2])
|
1391 |
if (arot[2][2]==rot[2][2]) pareil=1;
|
1392 |
|
1393 |
if (pareil==0)
|
1394 |
{
|
1395 |
tete=NULL;
|
1396 |
arot[0][0]=rot[0][0];
|
1397 |
arot[1][0]=rot[1][0];
|
1398 |
arot[2][0]=rot[2][0];
|
1399 |
arot[0][1]=rot[0][1];
|
1400 |
arot[1][1]=rot[1][1];
|
1401 |
arot[2][1]=rot[2][1];
|
1402 |
arot[0][2]=rot[0][2];
|
1403 |
arot[1][2]=rot[1][2];
|
1404 |
arot[2][2]=rot[2][2];
|
1405 |
/* oeuil */
|
1406 |
xe=1000.*maxcoord-0.5*(xmin+xmax);
|
1407 |
ye=1000.*maxcoord-0.5*(ymin+ymax);
|
1408 |
ze=1000.*maxcoord-0.5*(zmin+zmax);
|
1409 |
/* oeuil dans le repere local */
|
1410 |
xee=rot[0][0]*xe+rot[1][0]*ye+rot[2][0]*ze;
|
1411 |
yee=rot[0][1]*xe+rot[1][1]*ye+rot[2][1]*ze;
|
1412 |
zee=rot[0][2]*xe+rot[1][2]*ye+rot[2][2]*ze;
|
1413 |
iordre=(int *)calloc(nb_triangle+1,sizeof(int));
|
1414 |
distance=(float *)calloc(nb_triangle+1,sizeof(float));
|
1415 |
for (i=0;i<nb_triangle;i++)
|
1416 |
{
|
1417 |
triangle[i].dis=0.;
|
1418 |
triangle[i].suivant=NULL;
|
1419 |
xa=point[triangle[i].n1].x;
|
1420 |
ya=point[triangle[i].n1].y;
|
1421 |
za=point[triangle[i].n1].z;
|
1422 |
xb=point[triangle[i].n2].x;
|
1423 |
yb=point[triangle[i].n2].y;
|
1424 |
zb=point[triangle[i].n2].z;
|
1425 |
xc=point[triangle[i].n3].x;
|
1426 |
yc=point[triangle[i].n3].y;
|
1427 |
zc=point[triangle[i].n3].z;
|
1428 |
xg=0.333333*(xa+xb+xc);
|
1429 |
yg=0.333333*(ya+yb+yc);
|
1430 |
zg=0.333333*(za+zb+zc);
|
1431 |
triangle[i].dis=(xee-xg)*(xee-xg)+(yee-yg)*(yee-yg)+(zee-zg)*(zee-zg);
|
1432 |
if (i==0)
|
1433 |
{
|
1434 |
dismin=triangle[i].dis;
|
1435 |
dismax=triangle[i].dis;
|
1436 |
}
|
1437 |
else
|
1438 |
{
|
1439 |
if (triangle[i].dis<dismin) dismin=triangle[i].dis;
|
1440 |
if (triangle[i].dis>dismax) dismax=triangle[i].dis;
|
1441 |
}
|
1442 |
nx=(yb-ya)*(zc-za)-(zb-za)*(yc-ya);
|
1443 |
ny=(xc-xa)*(zb-za)-(xb-xa)*(zc-za);
|
1444 |
nz=(xb-xa)*(yc-ya)-(yb-ya)*(xc-xa);
|
1445 |
triangle[i].angle=(float)((nx*(xee-xg)+ny*(yee-yg)+nz*(zee-zg))/sqrt((double)((nx*nx+ny*ny+nz*nz)*((xee-xg)*(xee-xg)+(yee-yg)*(yee-yg)+(zee-zg)*(zee-zg)))));
|
1446 |
if (triangle[i].angle>=1.) triangle[i].angle=0.99999999;
|
1447 |
if (triangle[i].angle<=(-1.)) triangle[i].angle=(-0.99999999);
|
1448 |
distance[i]=triangle[i].dis;
|
1449 |
iordre[i]=i+1;
|
1450 |
}
|
1451 |
trirea(distance,&(nb_triangle),iordre);
|
1452 |
diff=dismax-dismin;
|
1453 |
dismin=dismin-0.025*diff;
|
1454 |
dismax=dismax+0.025*diff;
|
1455 |
}
|
1456 |
Fenp->Canvas->Pen->Color=Cshade[0];
|
1457 |
if (ContourInactif1->Checked==true) Fenp->Canvas->Pen->Style=psClear;
|
1458 |
Fenp->Canvas->Brush->Color=Cshade[1];
|
1459 |
for (i=nb_triangle-1;i>(-1);i--)
|
1460 |
{
|
1461 |
tri=&(triangle[iordre[i]-1]);
|
1462 |
if ((tri->select==0)&& (Debug1->Checked)) continue;
|
1463 |
|
1464 |
if (((tri->num_ent==numface) || (numface==(-1))&&(tri->dis-dismin*loin-(1.-loin)*dismax>0.)))
|
1465 |
{
|
1466 |
xa=point[tri->n1].x;
|
1467 |
ya=point[tri->n1].y;
|
1468 |
za=point[tri->n1].z;
|
1469 |
xb=point[tri->n2].x;
|
1470 |
yb=point[tri->n2].y;
|
1471 |
zb=point[tri->n2].z;
|
1472 |
xc=point[tri->n3].x;
|
1473 |
yc=point[tri->n3].y;
|
1474 |
zc=point[tri->n3].z;
|
1475 |
if (Normal1->Checked==false)
|
1476 |
{
|
1477 |
g[0]=0.33333*(xa+xb+xc);
|
1478 |
g[1]=0.33333*(ya+yb+yc);
|
1479 |
g[2]=0.33333*(za+zb+zc);
|
1480 |
xa=g[0]+homo*(xa-g[0]);ya=g[1]+homo*(ya-g[1]);za=g[2]+homo*(za-g[2]);
|
1481 |
xb=g[0]+homo*(xb-g[0]);yb=g[1]+homo*(yb-g[1]);zb=g[2]+homo*(zb-g[2]);
|
1482 |
xc=g[0]+homo*(xc-g[0]);yc=g[1]+homo*(yc-g[1]);zc=g[2]+homo*(zc-g[2]);
|
1483 |
}
|
1484 |
projection(xa,ya,za,&xpoint[0],&xpoint[1],1);
|
1485 |
projection(xb,yb,zb,&xpoint[2],&xpoint[3],1);
|
1486 |
projection(xc,yc,zc,&xpoint[4],&xpoint[5],1);
|
1487 |
ypoint[0].x=xpoint[0];
|
1488 |
ypoint[0].y=xpoint[1];
|
1489 |
ypoint[1].x=xpoint[2];
|
1490 |
ypoint[1].y=xpoint[3];
|
1491 |
ypoint[2].x=xpoint[4];
|
1492 |
ypoint[2].y=xpoint[5];
|
1493 |
color=(int)(-10*fabs((double)(tri->angle))+10);
|
1494 |
if (color>10) color=10;
|
1495 |
if (color<1) color=1;
|
1496 |
Fenp->Canvas->Brush->Color=Cshade[color];
|
1497 |
Fenp->Canvas->Polygon(ypoint,2);
|
1498 |
Fenp->Canvas->Font->Color=clFuchsia;
|
1499 |
SetBkMode(Fenp->Canvas->Handle,TRANSPARENT);
|
1500 |
if (Noeud1->Checked==true)
|
1501 |
{
|
1502 |
sprintf(mess,"%d",tri->n1);
|
1503 |
Fenp->Canvas->TextOut(xpoint[0]+2,xpoint[1]+2,mess);
|
1504 |
sprintf(mess,"%d",tri->n2);
|
1505 |
Fenp->Canvas->TextOut(xpoint[2]+2,xpoint[3]+2,mess);
|
1506 |
sprintf(mess,"%d",tri->n3);
|
1507 |
Fenp->Canvas->TextOut(xpoint[4]+2,xpoint[5]+2,mess);
|
1508 |
}
|
1509 |
if (tri->n1==numero_noeud)
|
1510 |
{
|
1511 |
Fenp->Canvas->Font->Color=clWhite;
|
1512 |
sprintf(mess,"%d",tri->n1);
|
1513 |
Fenp->Canvas->TextOut(xpoint[0]+2,xpoint[1]+2,mess);
|
1514 |
}
|
1515 |
if (tri->n2==numero_noeud)
|
1516 |
{
|
1517 |
Fenp->Canvas->Font->Color=clWhite;
|
1518 |
sprintf(mess,"%d",tri->n2);
|
1519 |
Fenp->Canvas->TextOut(xpoint[2]+2,xpoint[3]+2,mess);
|
1520 |
}
|
1521 |
if (tri->n3==numero_noeud)
|
1522 |
{
|
1523 |
Fenp->Canvas->Font->Color=clWhite;
|
1524 |
sprintf(mess,"%d",tri->n3);
|
1525 |
Fenp->Canvas->TextOut(xpoint[4]+2,xpoint[5]+2,mess);
|
1526 |
}
|
1527 |
if (tri->num!=numero_maille) Fenp->Canvas->Font->Color=clYellow;
|
1528 |
else
|
1529 |
{
|
1530 |
Fenp->Canvas->Font->Color=clWhite;
|
1531 |
sprintf(mess,"%d",tri->num);
|
1532 |
Fenp->Canvas->TextOut((int)((xpoint[0]+xpoint[2]+xpoint[4])*0.333333),(int)((xpoint[1]+xpoint[3]+xpoint[5])*0.33333333),mess);
|
1533 |
}
|
1534 |
if (Maille2->Checked==true)
|
1535 |
{
|
1536 |
sprintf(mess,"%d",tri->num);
|
1537 |
Fenp->Canvas->TextOut((int)((xpoint[0]+xpoint[2]+xpoint[4])*0.333333),(int)((xpoint[1]+xpoint[3]+xpoint[5])*0.33333333),mess);
|
1538 |
}
|
1539 |
}
|
1540 |
}
|
1541 |
Fenp->Canvas->Pen->Style=psSolid;
|
1542 |
free(iordre);
|
1543 |
free(distance);
|
1544 |
}
|
1545 |
//---------------------------------------------------------------------------
|
1546 |
void __fastcall TFenp::FormKeyDown(TObject *Sender, WORD &Key,TShiftState Shift)
|
1547 |
{
|
1548 |
char mess[100];
|
1549 |
float val;
|
1550 |
int nb_maille;
|
1551 |
|
1552 |
if (Key==112)
|
1553 |
{
|
1554 |
zoom=zoom*1.1;
|
1555 |
xcentre=(Fenp->ClientWidth/2.-1.1*(Fenp->ClientWidth/2.-xcentre));
|
1556 |
ycentre=(Fenp->ClientHeight/2.-1.1*(Fenp->ClientHeight/2.-ycentre));
|
1557 |
Invalidate();
|
1558 |
}
|
1559 |
if (Key==113)
|
1560 |
{
|
1561 |
zoom=zoom*0.90909090;
|
1562 |
xcentre=(Fenp->ClientWidth/2.-0.90909090*(Fenp->ClientWidth/2.-xcentre));
|
1563 |
ycentre=(Fenp->ClientHeight/2.-0.90909090*(Fenp->ClientHeight/2.-ycentre));
|
1564 |
Invalidate();
|
1565 |
}
|
1566 |
if (Key==114)
|
1567 |
{
|
1568 |
rot[0][0]=1.0;rot[1][0]=0.0;rot[2][0]=0.0;
|
1569 |
rot[0][1]=0.0;rot[1][1]=1.0;rot[2][1]=0.0;
|
1570 |
rot[0][2]=0.0;rot[1][2]=0.0;rot[2][2]=1.0;
|
1571 |
norme();
|
1572 |
Invalidate();
|
1573 |
}
|
1574 |
if (Key==115)
|
1575 |
{
|
1576 |
norme();
|
1577 |
Invalidate();
|
1578 |
}
|
1579 |
if (Key==116)
|
1580 |
{
|
1581 |
if (fc==1) fc=0; else fc=1;
|
1582 |
Invalidate();
|
1583 |
}
|
1584 |
if (Key==37)
|
1585 |
{
|
1586 |
xcentre=xcentre-4;
|
1587 |
Invalidate();
|
1588 |
}
|
1589 |
if (Key==39)
|
1590 |
{
|
1591 |
xcentre=xcentre+4;
|
1592 |
Invalidate();
|
1593 |
}
|
1594 |
if (Key==38)
|
1595 |
{
|
1596 |
ycentre=ycentre-4;
|
1597 |
Invalidate();
|
1598 |
}
|
1599 |
if (Key==40)
|
1600 |
{
|
1601 |
ycentre=ycentre+4;
|
1602 |
Invalidate();
|
1603 |
}
|
1604 |
if (Key==45)
|
1605 |
{
|
1606 |
rotation(0.1,1);
|
1607 |
Invalidate();
|
1608 |
}
|
1609 |
if (Key==46)
|
1610 |
{
|
1611 |
rotation(-0.1,1);
|
1612 |
Invalidate();
|
1613 |
}
|
1614 |
if (Key==36)
|
1615 |
{
|
1616 |
rotation(0.1,2);
|
1617 |
Invalidate();
|
1618 |
}
|
1619 |
if (Key==35)
|
1620 |
{
|
1621 |
rotation(-0.1,2);
|
1622 |
Invalidate();
|
1623 |
}
|
1624 |
if (Key==33)
|
1625 |
{
|
1626 |
rotation(0.1,3);
|
1627 |
Invalidate();
|
1628 |
}
|
1629 |
if (Key==34)
|
1630 |
{
|
1631 |
rotation(-0.1,3);
|
1632 |
Invalidate();
|
1633 |
}
|
1634 |
if (Key==109)
|
1635 |
{
|
1636 |
homo=homo/1.1;
|
1637 |
if (homo<0.0001) homo=0.0001;
|
1638 |
Invalidate();
|
1639 |
}
|
1640 |
if (Key==107)
|
1641 |
{
|
1642 |
homo=homo*1.1;
|
1643 |
if (homo>1.) homo=1.;
|
1644 |
Invalidate();
|
1645 |
}
|
1646 |
if (Key==105)
|
1647 |
{
|
1648 |
loin=1.;
|
1649 |
Toolbar->TrackBar1->Position=(int)(loin*100.);
|
1650 |
Invalidate();
|
1651 |
}
|
1652 |
if (Key==106)
|
1653 |
{
|
1654 |
loin=loin+0.01;
|
1655 |
if (loin>1.2) loin=1.2;
|
1656 |
else
|
1657 |
{
|
1658 |
if (existetool==1)
|
1659 |
{
|
1660 |
Toolbar->TrackBar1->Position=(int)(loin*100.);
|
1661 |
}
|
1662 |
Invalidate();
|
1663 |
}
|
1664 |
}
|
1665 |
if (Key==111)
|
1666 |
{
|
1667 |
loin=loin-0.01;
|
1668 |
if (loin<0.) loin=0.;
|
1669 |
else
|
1670 |
{
|
1671 |
if (existetool==1)
|
1672 |
{
|
1673 |
Toolbar->TrackBar1->Position=(int)(loin*100.);
|
1674 |
}
|
1675 |
Invalidate();
|
1676 |
}
|
1677 |
}
|
1678 |
if (Key==120)
|
1679 |
{
|
1680 |
strcpy(info,"Valeur du zoom ?");
|
1681 |
Valeur->ShowModal();
|
1682 |
strcpy(mess,Valeur->Edit1->Text.c_str());
|
1683 |
sscanf(mess,"%f",&val);
|
1684 |
zoom=zoom*val;
|
1685 |
xcentre=(Fenp->ClientWidth/2.-val*(Fenp->ClientWidth/2.-xcentre));
|
1686 |
ycentre=(Fenp->ClientHeight/2.-val*(Fenp->ClientHeight/2.-ycentre));
|
1687 |
Invalidate();
|
1688 |
}
|
1689 |
if (Key==121)
|
1690 |
{
|
1691 |
strcpy(info,"Valeur de la rotation suivant x ?");
|
1692 |
Valeur->ShowModal();
|
1693 |
strcpy(mess,Valeur->Edit1->Text.c_str());
|
1694 |
sscanf(mess,"%f",&val);
|
1695 |
rotation(val/180.*PI,1);
|
1696 |
Invalidate();
|
1697 |
}
|
1698 |
if (Key==122)
|
1699 |
{
|
1700 |
strcpy(info,"Valeur de la rotation suivant y ?");
|
1701 |
Valeur->ShowModal();
|
1702 |
strcpy(mess,Valeur->Edit1->Text.c_str());
|
1703 |
sscanf(mess,"%f",&val);
|
1704 |
rotation(val/180.*PI,2);
|
1705 |
Invalidate();
|
1706 |
}
|
1707 |
if (Key==123)
|
1708 |
{
|
1709 |
strcpy(info,"Valeur de la rotation suivant z ?");
|
1710 |
Valeur->ShowModal();
|
1711 |
strcpy(mess,Valeur->Edit1->Text.c_str());
|
1712 |
sscanf(mess,"%f",&val);
|
1713 |
rotation(val/180.*PI,3);
|
1714 |
Invalidate();
|
1715 |
}
|
1716 |
if (Key==117)
|
1717 |
{
|
1718 |
sprintf(info,"numero de noeud a afficher (0-%d)?",nb_point);
|
1719 |
Valeur->ShowModal();
|
1720 |
strcpy(mess,Valeur->Edit1->Text.c_str());
|
1721 |
sscanf(mess,"%d",&numero_noeud);
|
1722 |
if (numero_noeud>=nb_point) numero_noeud=nb_point;
|
1723 |
Invalidate();
|
1724 |
}
|
1725 |
if (Key==118)
|
1726 |
{
|
1727 |
nb_maille=nb_segment+nb_triangle+nb_tetra;
|
1728 |
sprintf(info,"numero de maille a afficher (0-%d)?",nb_maille);
|
1729 |
Valeur->ShowModal();
|
1730 |
strcpy(mess,Valeur->Edit1->Text.c_str());
|
1731 |
sscanf(mess,"%d",&numero_maille);
|
1732 |
if (numero_maille>=nb_maille) numero_maille=nb_maille;
|
1733 |
Invalidate();
|
1734 |
}
|
1735 |
if (Key==119)
|
1736 |
{
|
1737 |
strcpy(info,"Valeur de l'echelle ?");
|
1738 |
sprintf(mess,"%f",zoom);
|
1739 |
Valeur->Edit1->Text=mess;
|
1740 |
Valeur->ShowModal();
|
1741 |
strcpy(mess,Valeur->Edit1->Text.c_str());
|
1742 |
sscanf(mess,"%f",&zoom);
|
1743 |
Invalidate();
|
1744 |
}
|
1745 |
|
1746 |
|
1747 |
}
|
1748 |
//---------------------------------------------------------------------------
|
1749 |
void __fastcall TFenp::rotation(float angle,int type)
|
1750 |
{
|
1751 |
float resut[3][3],mrot[3][3],cangle,sangle;
|
1752 |
int xtmp,ytmp,xtmp2,ytmp2;
|
1753 |
|
1754 |
cangle=(float)cos((double)angle);
|
1755 |
sangle=(float)sin((double)angle);
|
1756 |
|
1757 |
projection(xpiece,ypiece,zpiece,&xtmp,&ytmp,1);
|
1758 |
if (type==1)
|
1759 |
{
|
1760 |
mrot[0][0]=1.;mrot[0][1]=0.;mrot[0][2]=0.;
|
1761 |
mrot[1][0]=0.;mrot[1][1]=cangle;mrot[1][2]=(-sangle);
|
1762 |
mrot[2][0]=0.;mrot[2][1]=sangle;mrot[2][2]=cangle;
|
1763 |
}
|
1764 |
if (type==2)
|
1765 |
{
|
1766 |
mrot[0][0]=cangle;mrot[0][1]=0.;mrot[0][2]=sangle;
|
1767 |
mrot[1][0]=0.;mrot[1][1]=1.;mrot[1][2]=0.;
|
1768 |
mrot[2][0]=(-sangle);mrot[2][1]=0.;mrot[2][2]=cangle;
|
1769 |
}
|
1770 |
if (type==3)
|
1771 |
{
|
1772 |
mrot[0][0]=cangle;mrot[0][1]=(-sangle);mrot[0][2]=0.;
|
1773 |
mrot[1][0]=sangle;mrot[1][1]=cangle;mrot[1][2]=0.;
|
1774 |
mrot[2][0]=0.;mrot[2][1]=0.;mrot[2][2]=1.;
|
1775 |
}
|
1776 |
resut[0][0]=rot[0][0]*mrot[0][0]+rot[0][1]*mrot[1][0]+rot[0][2]*mrot[2][0];
|
1777 |
resut[0][1]=rot[0][0]*mrot[0][1]+rot[0][1]*mrot[1][1]+rot[0][2]*mrot[2][1];
|
1778 |
resut[0][2]=rot[0][0]*mrot[0][2]+rot[0][1]*mrot[1][2]+rot[0][2]*mrot[2][2];
|
1779 |
resut[1][0]=rot[1][0]*mrot[0][0]+rot[1][1]*mrot[1][0]+rot[1][2]*mrot[2][0];
|
1780 |
resut[1][1]=rot[1][0]*mrot[0][1]+rot[1][1]*mrot[1][1]+rot[1][2]*mrot[2][1];
|
1781 |
resut[1][2]=rot[1][0]*mrot[0][2]+rot[1][1]*mrot[1][2]+rot[1][2]*mrot[2][2];
|
1782 |
resut[2][0]=rot[2][0]*mrot[0][0]+rot[2][1]*mrot[1][0]+rot[2][2]*mrot[2][0];
|
1783 |
resut[2][1]=rot[2][0]*mrot[0][1]+rot[2][1]*mrot[1][1]+rot[2][2]*mrot[2][1];
|
1784 |
resut[2][2]=rot[2][0]*mrot[0][2]+rot[2][1]*mrot[1][2]+rot[2][2]*mrot[2][2];
|
1785 |
rot[0][0]=resut[0][0];
|
1786 |
rot[1][0]=resut[1][0];
|
1787 |
rot[2][0]=resut[2][0];
|
1788 |
rot[0][1]=resut[0][1];
|
1789 |
rot[1][1]=resut[1][1];
|
1790 |
rot[2][1]=resut[2][1];
|
1791 |
rot[0][2]=resut[0][2];
|
1792 |
rot[1][2]=resut[1][2];
|
1793 |
rot[2][2]=resut[2][2];
|
1794 |
projection(xpiece,ypiece,zpiece,&xtmp2,&ytmp2,1);
|
1795 |
xcentre=xcentre+xtmp-xtmp2;
|
1796 |
ycentre=ycentre+ytmp-ytmp2;
|
1797 |
}
|
1798 |
|
1799 |
void __fastcall TFenp::Normal1Click(TObject *Sender)
|
1800 |
{
|
1801 |
Normal1->Checked=true;
|
1802 |
Eclatee1->Checked=false;
|
1803 |
Qualite1->Checked=false;
|
1804 |
Invalidate();
|
1805 |
}
|
1806 |
//---------------------------------------------------------------------------
|
1807 |
void __fastcall TFenp::Eclatee1Click(TObject *Sender)
|
1808 |
{
|
1809 |
Normal1->Checked=false;
|
1810 |
Eclatee1->Checked=true;
|
1811 |
Qualite1->Checked=false;
|
1812 |
Invalidate();
|
1813 |
|
1814 |
}
|
1815 |
//---------------------------------------------------------------------------
|
1816 |
void __fastcall TFenp::Qualite1Click(TObject *Sender)
|
1817 |
{
|
1818 |
Normal1->Checked=false;
|
1819 |
Eclatee1->Checked=false;
|
1820 |
Qualite1->Checked=true;
|
1821 |
Invalidate();
|
1822 |
}
|
1823 |
//---------------------------------------------------------------------------
|
1824 |
float __fastcall TFenp::crit_cal2d(int n1,int n2,int n3)
|
1825 |
{
|
1826 |
float x1,y1,z1,x2,y2,z2,x3,y3,z3,crits;
|
1827 |
double p,ab[3],ac[3],cb[3],dac,dab,dcb,dmax,crit;
|
1828 |
|
1829 |
x1=point[n1].x;y1=point[n1].y;z1=point[n1].z;
|
1830 |
x2=point[n2].x;y2=point[n2].y;z2=point[n2].z;
|
1831 |
x3=point[n3].x;y3=point[n3].y;z3=point[n3].z;
|
1832 |
ab[0]=x2-x1;ab[1]=y2-y1;ab[2]=z2-z1;
|
1833 |
ac[0]=x3-x1;ac[1]=y3-y1;ac[2]=z3-z1;
|
1834 |
cb[0]=x2-x3;cb[1]=y2-y3;cb[2]=z2-z3;
|
1835 |
dab=sqrt(ab[0]*ab[0]+ab[1]*ab[1]+ab[2]*ab[2]);
|
1836 |
dac=sqrt(ac[0]*ac[0]+ac[1]*ac[1]+ac[2]*ac[2]);
|
1837 |
dcb=sqrt(cb[0]*cb[0]+cb[1]*cb[1]+cb[2]*cb[2]);
|
1838 |
dmax=dab;
|
1839 |
if (dac>dmax)dmax=dac;
|
1840 |
if (dcb>dmax)dmax=dcb;
|
1841 |
p=0.5*(dac+dab+dcb);
|
1842 |
crit = (p-dac)*(p-dab)*(p-dcb)/p ;
|
1843 |
crit = sqrt(crit) ;
|
1844 |
crit = crit /dmax ;
|
1845 |
crit = crit * 3.464101614 ;
|
1846 |
crits=(float)crit;
|
1847 |
return(crits);
|
1848 |
}
|
1849 |
//---------------------------------------------------------------------------
|
1850 |
float __fastcall TFenp::crit_cal3d(int n1,int n2,int n3,int n4)
|
1851 |
{
|
1852 |
float x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4,crits;
|
1853 |
double ab[4],ac[4],cb[4],dac,dab,dcb,dmax,crit;
|
1854 |
double db[4],da[4],dc[4],dda,ddb,ddc,pvec[4],vol,som;
|
1855 |
|
1856 |
x1=point[n1].x;y1=point[n1].y;z1=point[n1].z;
|
1857 |
x2=point[n2].x;y2=point[n2].y;z2=point[n2].z;
|
1858 |
x3=point[n3].x;y3=point[n3].y;z3=point[n3].z;
|
1859 |
x4=point[n4].x;y4=point[n4].y;z4=point[n4].z;
|
1860 |
ab[0]=x2-x1;ab[1]=y2-y1;ab[2]=z2-z1;
|
1861 |
ac[0]=x3-x1;ac[1]=y3-y1;ac[2]=z3-z1;
|
1862 |
cb[0]=x2-x3;cb[1]=y2-y3;cb[2]=z2-z3;
|
1863 |
db[0]=x2-x4;db[1]=y2-y4;db[2]=z2-z4;
|
1864 |
da[0]=x1-x4;da[1]=y1-y4;da[2]=z1-z4;
|
1865 |
dc[0]=x3-x4;dc[1]=y3-y4;dc[2]=z3-z4;
|
1866 |
dab=sqrt(ab[0]*ab[0]+ab[1]*ab[1]+ab[2]*ab[2]);
|
1867 |
dac=sqrt(ac[0]*ac[0]+ac[1]*ac[1]+ac[2]*ac[2]);
|
1868 |
dcb=sqrt(cb[0]*cb[0]+cb[1]*cb[1]+cb[2]*cb[2]);
|
1869 |
ddb=sqrt(db[0]*db[0]+db[1]*db[1]+db[2]*db[2]);
|
1870 |
dda=sqrt(da[0]*da[0]+da[1]*da[1]+da[2]*da[2]);
|
1871 |
ddc=sqrt(dc[0]*dc[0]+dc[1]*dc[1]+dc[2]*dc[2]);
|
1872 |
dmax=dab;
|
1873 |
if (dac>dmax)dmax=dac;
|
1874 |
if (dcb>dmax)dmax=dcb;
|
1875 |
if (ddb>dmax)dmax=ddb;
|
1876 |
if (dda>dmax)dmax=dda;
|
1877 |
if (ddc>dmax)dmax=ddc;
|
1878 |
PVEC(pvec,ab,ac);
|
1879 |
vol=pvec[0]*da[0]+pvec[1]*da[1]+pvec[2]*da[2];
|
1880 |
if (vol>0.) return(0.);
|
1881 |
vol=fabs(vol);
|
1882 |
NORME(pvec);
|
1883 |
som=pvec[3]/2.;
|
1884 |
PVEC(pvec,ab,da);
|
1885 |
NORME(pvec);
|
1886 |
som=som+pvec[3]/2.;
|
1887 |
PVEC(pvec,ac,dc);
|
1888 |
NORME(pvec);
|
1889 |
som=som+pvec[3]/2.;
|
1890 |
PVEC(pvec,cb,db);
|
1891 |
NORME(pvec);
|
1892 |
som=som+pvec[3]/2.;
|
1893 |
crit = vol/som ;
|
1894 |
crit = (crit/dmax)/0.408249 ;
|
1895 |
crits=(float)crit;
|
1896 |
return(crits) ;
|
1897 |
}
|
1898 |
//---------------------------------------------------------------------------
|
1899 |
void __fastcall TFenp::affiche_axe(void)
|
1900 |
{
|
1901 |
int xc,yc;
|
1902 |
|
1903 |
Fenp->Canvas->Pen->Color=clBlue;
|
1904 |
projection(25.,0.,0.,&xc,&yc,0);
|
1905 |
Fenp->Canvas->MoveTo(45,45);
|
1906 |
Fenp->Canvas->LineTo(45+xc,45+yc);
|
1907 |
Fenp->Canvas->Pen->Color=clRed;
|
1908 |
projection(0.,25.,0.,&xc,&yc,0);
|
1909 |
Fenp->Canvas->MoveTo(45,45);
|
1910 |
Fenp->Canvas->LineTo(45+xc,45+yc);
|
1911 |
Fenp->Canvas->Pen->Color=clWhite;
|
1912 |
projection(0.,0.,25.,&xc,&yc,0);
|
1913 |
Fenp->Canvas->MoveTo(45,45);
|
1914 |
Fenp->Canvas->LineTo(45+xc,45+yc);
|
1915 |
}
|
1916 |
//---------------------------------------------------------------------------
|
1917 |
|
1918 |
void __fastcall TFenp::FormMouseDown(TObject *Sender, TMouseButton Button,
|
1919 |
TShiftState Shift, int X, int Y)
|
1920 |
{
|
1921 |
if (Button==mbRight)
|
1922 |
{
|
1923 |
trans=1;
|
1924 |
xtmp=X;
|
1925 |
ytmp=Y;
|
1926 |
}
|
1927 |
}
|
1928 |
//---------------------------------------------------------------------------
|
1929 |
void __fastcall TFenp::FormMouseUp(TObject *Sender, TMouseButton Button,
|
1930 |
TShiftState Shift, int X, int Y)
|
1931 |
{
|
1932 |
if (Button==mbRight)
|
1933 |
{
|
1934 |
if (trans==1)
|
1935 |
{
|
1936 |
xcentre=xcentre+X-xtmp;
|
1937 |
ycentre=ycentre+Y-ytmp;
|
1938 |
Invalidate();
|
1939 |
}
|
1940 |
trans=0;
|
1941 |
}
|
1942 |
}
|
1943 |
//---------------------------------------------------------------------------
|
1944 |
void __fastcall TFenp::Noeud1Click(TObject *Sender)
|
1945 |
{
|
1946 |
if (Noeud1->Checked==true) Noeud1->Checked=false; else Noeud1->Checked=true;
|
1947 |
Invalidate();
|
1948 |
}
|
1949 |
//---------------------------------------------------------------------------
|
1950 |
void __fastcall TFenp::Maille2Click(TObject *Sender)
|
1951 |
{
|
1952 |
if (Maille2->Checked==true) Maille2->Checked=false; else Maille2->Checked=true;
|
1953 |
Invalidate();
|
1954 |
}
|
1955 |
//---------------------------------------------------------------------------
|
1956 |
void __fastcall TFenp::ancien1Click(TObject *Sender)
|
1957 |
{
|
1958 |
Ouvre(ancien_fichier[0]);
|
1959 |
Invalidate();
|
1960 |
}
|
1961 |
//---------------------------------------------------------------------------
|
1962 |
void __fastcall TFenp::ancien2Click(TObject *Sender)
|
1963 |
{
|
1964 |
Ouvre(ancien_fichier[1]);
|
1965 |
Invalidate();
|
1966 |
}
|
1967 |
//---------------------------------------------------------------------------
|
1968 |
void __fastcall TFenp::ancien3Click(TObject *Sender)
|
1969 |
{
|
1970 |
Ouvre(ancien_fichier[2]);
|
1971 |
Invalidate();
|
1972 |
}
|
1973 |
//---------------------------------------------------------------------------
|
1974 |
void __fastcall TFenp::ancien4Click(TObject *Sender)
|
1975 |
{
|
1976 |
Ouvre(ancien_fichier[3]);
|
1977 |
Invalidate();
|
1978 |
}
|
1979 |
//---------------------------------------------------------------------------
|
1980 |
void __fastcall TFenp::Acismesh1Click(TObject *Sender)
|
1981 |
{
|
1982 |
char mess[255];
|
1983 |
char arg1[255];
|
1984 |
char arg2[255];
|
1985 |
char arg3[255];
|
1986 |
char arg4[255];
|
1987 |
char arg5[255];
|
1988 |
char arg6[255];
|
1989 |
char arg7[255];
|
1990 |
char arg8[255];
|
1991 |
char arg9[255];
|
1992 |
char arg10[255];
|
1993 |
float dens,epsilon;
|
1994 |
int opt=5;
|
1995 |
|
1996 |
epsilon=0.;
|
1997 |
Igsoption->Edit2->Text="5";
|
1998 |
Igsoption->GroupBox1->Caption=Fichier;
|
1999 |
Igsoption->Label3->Enabled=true;
|
2000 |
Igsoption->Edit3->Enabled=true;
|
2001 |
Igsoption->RadioButton1->Enabled=true;
|
2002 |
Igsoption->RadioButton2->Enabled=true;
|
2003 |
Igsoption->ShowModal();
|
2004 |
if (Igsoption->ok==1)
|
2005 |
{
|
2006 |
dens=0.;
|
2007 |
strcpy(mess,Igsoption->Edit1->Text.c_str());
|
2008 |
sscanf(mess,"%f",&dens);
|
2009 |
strcpy(mess,Igsoption->Edit2->Text.c_str());
|
2010 |
sscanf(mess,"%d",&opt);
|
2011 |
strcpy(mess,Igsoption->Edit3->Text.c_str());
|
2012 |
sscanf(mess,"%f",&epsilon);
|
2013 |
if (Igsoption->CheckBox1->Checked==true) strcpy(arg10,"-analyse"); else strcpy(arg10,"");
|
2014 |
if (Igsoption->RadioButton1->Checked==true) epsilon=(-epsilon);
|
2015 |
sprintf(arg1,"%s\\acismesh.exe",home);
|
2016 |
strcpy(arg2,"-fich");
|
2017 |
sprintf(arg3,"%s",Fichier);
|
2018 |
strcpy(arg4,"-dens");
|
2019 |
sprintf(arg5,"%f",dens);
|
2020 |
strcpy(arg6,"-opti2d");
|
2021 |
sprintf(arg7,"%d",opt);
|
2022 |
strcpy(arg8,"-epsilon");
|
2023 |
sprintf(arg9,"%f",epsilon);
|
2024 |
if ((epsilon<0.0001)&&(Igsoption->RadioButton2->Checked==true)) MessageBox(Handle,"Mauvaise valeur de epsilon","Erreur",0);
|
2025 |
else if ((epsilon>(-0.0001))&&(Igsoption->RadioButton1->Checked==true)) MessageBox(Handle,"Mauvaise valeur de epsilon","Erreur",0);
|
2026 |
else if (dens<0.0001) MessageBox(Handle,"Mauvaise valeur de densite","Erreur",0);
|
2027 |
else if (batch==false) spawnl(P_NOWAIT,arg1,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,NULL);
|
2028 |
else fprintf(f_batch,"%s %s %s %s %s %s %s %s %s %s\n",arg1,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
|
2029 |
}
|
2030 |
}
|
2031 |
//---------------------------------------------------------------------------
|
2032 |
void __fastcall TFenp::Acismesh2Click(TObject *Sender)
|
2033 |
{
|
2034 |
char mess[255];
|
2035 |
char arg1[255];
|
2036 |
char arg2[255];
|
2037 |
char arg3[255];
|
2038 |
char arg4[255];
|
2039 |
char arg5[255];
|
2040 |
char arg6[255];
|
2041 |
char arg7[255];
|
2042 |
char arg8[255];
|
2043 |
char arg9[255];
|
2044 |
char arg10[255];
|
2045 |
int opt=5;
|
2046 |
float zone;
|
2047 |
|
2048 |
zone=0.;
|
2049 |
Rigsoption->Label3->Enabled=true;
|
2050 |
Rigsoption->Edit3->Enabled=true;
|
2051 |
Rigsoption->CheckBox1->Enabled=true;
|
2052 |
Rigsoption->Edit3->Text="1";
|
2053 |
Rigsoption->Edit2->Text="5";
|
2054 |
Rigsoption->GroupBox1->Caption=Fichier;
|
2055 |
Rigsoption->ShowModal();
|
2056 |
if (Rigsoption->ok==1)
|
2057 |
{
|
2058 |
strcpy(mess,Rigsoption->Edit2->Text.c_str());
|
2059 |
sscanf(mess,"%d",&opt);
|
2060 |
strcpy(mess,Rigsoption->Edit3->Text.c_str());
|
2061 |
sscanf(mess,"%f",&zone);
|
2062 |
if (Rigsoption->CheckBox1->Checked==true) strcpy(arg10,"-analyse"); else strcpy(arg10,"");
|
2063 |
mess[0]=0;
|
2064 |
strcpy(mess,Rigsoption->Edit1->Text.c_str());
|
2065 |
sprintf(arg1,"%s\\acismesh.exe",home);
|
2066 |
strcpy(arg2,"-fich");
|
2067 |
sprintf(arg3,"%s",Fichier);
|
2068 |
strcpy(arg4,"-mesh");
|
2069 |
strcpy(arg5,mess);
|
2070 |
strcpy(arg6,"-opti2d");
|
2071 |
sprintf(arg7,"%d",opt);
|
2072 |
strcpy(arg8,"-zone");
|
2073 |
sprintf(arg9,"%f",zone);
|
2074 |
chdir(home);
|
2075 |
if (zone<=0.0001) MessageBox(Handle,"Mauvaise valeur de zone","Erreur",0);
|
2076 |
else if (mess[0]==0) MessageBox(Handle,"Pas de fichier modele","Erreur",0);
|
2077 |
else if (batch==false) spawnl(P_NOWAIT,arg1,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,NULL);
|
2078 |
else fprintf(f_batch,"%s %s %s %s %s %s %s %s %s %s \n",arg1,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
|
2079 |
}
|
2080 |
|
2081 |
}
|
2082 |
//---------------------------------------------------------------------------
|
2083 |
void __fastcall TFenp::Face1Click(TObject *Sender)
|
2084 |
{
|
2085 |
Face->ShowModal();
|
2086 |
Invalidate();
|
2087 |
}
|
2088 |
//---------------------------------------------------------------------------
|
2089 |
void __fastcall TFenp::Mailleur1Click(TObject *Sender)
|
2090 |
{
|
2091 |
char fich[255],mess[255];
|
2092 |
FILE *fic;
|
2093 |
|
2094 |
Diamesh1->Enabled=false;
|
2095 |
if (batch==true) Diamesh1->Enabled=true;
|
2096 |
if (Acismesh1->Enabled==true)
|
2097 |
{
|
2098 |
strcpy(fich,Fichier);
|
2099 |
fich[strlen(fich)-4]=0;
|
2100 |
strcpy(mess,fich);
|
2101 |
strcat(mess,"_2D.mai");
|
2102 |
fic=fopen(mess,"rt");
|
2103 |
if (fic!=NULL)
|
2104 |
{
|
2105 |
Diamesh1->Enabled=true;
|
2106 |
fclose(fic);
|
2107 |
}
|
2108 |
}
|
2109 |
}
|
2110 |
//---------------------------------------------------------------------------
|
2111 |
void __fastcall TFenp::Diamesh1Click(TObject *Sender)
|
2112 |
{
|
2113 |
char arg1[255];
|
2114 |
char arg2[255];
|
2115 |
char arg3[255];
|
2116 |
char arg4[255];
|
2117 |
char arg5[255];
|
2118 |
|
2119 |
Diaoption->GroupBox1->Caption=Fichier;
|
2120 |
Diaoption->CheckBox1->Enabled=true;
|
2121 |
Diaoption->ShowModal();
|
2122 |
if (Diaoption->ok==1)
|
2123 |
{
|
2124 |
sprintf(arg1,"%s\\diamesh.exe",home);
|
2125 |
strcpy(arg2,"-file");
|
2126 |
sprintf(arg3,"%s",Fichier);
|
2127 |
arg3[strlen(arg3)-4]=0;
|
2128 |
strcat(arg3,"_2D.mai");
|
2129 |
if (Diaoption->CheckBox1->Checked==true) strcpy(arg4,"-skin"); else strcpy(arg4,"");
|
2130 |
if (Diaoption->CheckBox2->Checked==true) strcpy(arg5,"-nosmooth"); else strcpy(arg5,"");
|
2131 |
if (batch==false) spawnl(P_NOWAIT,arg1,arg1,arg2,arg3,arg4,arg5,NULL);
|
2132 |
else fprintf(f_batch,"%s %s %s %s %s\n",arg1,arg1,arg2,arg3,arg4,arg5);
|
2133 |
}
|
2134 |
|
2135 |
}
|
2136 |
//---------------------------------------------------------------------------
|
2137 |
void __fastcall TFenp::Aproposde2Click(TObject *Sender)
|
2138 |
{
|
2139 |
Application->CreateForm(__classid(Tsignature), &signature);
|
2140 |
signature->Left=Fenp->Left+29;
|
2141 |
signature->Top=Fenp->Top+37;
|
2142 |
signature->ShowModal();
|
2143 |
|
2144 |
}
|
2145 |
//---------------------------------------------------------------------------
|
2146 |
void __fastcall TFenp::ConfigureShade1Click(TObject *Sender)
|
2147 |
{
|
2148 |
Application->CreateForm(__classid(TCcolor), &Ccolor);
|
2149 |
Ccolor->Left=(int)((Screen->Width-Ccolor->Width)/2.);
|
2150 |
Ccolor->Top=(int)((Screen->Height-Ccolor->Height)/2.);
|
2151 |
Ccolor->ShowModal();
|
2152 |
Invalidate();
|
2153 |
}
|
2154 |
//---------------------------------------------------------------------------
|
2155 |
void __fastcall TFenp::Toolbar1Click(TObject *Sender)
|
2156 |
{
|
2157 |
Affichetoolbar();
|
2158 |
}
|
2159 |
//---------------------------------------------------------------------------
|
2160 |
void __fastcall TFenp::Affichetoolbar(void)
|
2161 |
{
|
2162 |
if (existetool==0)
|
2163 |
{
|
2164 |
Application->CreateForm(__classid(TToolbar), &Toolbar);
|
2165 |
Toolbar->Show();
|
2166 |
}
|
2167 |
}
|
2168 |
|
2169 |
void __fastcall TFenp::FormShow(TObject *Sender)
|
2170 |
{
|
2171 |
static pass=0;
|
2172 |
if ((tool==1) && (pass==0))
|
2173 |
{
|
2174 |
pass=1;
|
2175 |
Affichetoolbar();
|
2176 |
}
|
2177 |
}
|
2178 |
//---------------------------------------------------------------------------
|
2179 |
void __fastcall TFenp::Enregistrerconfiguration1Click(TObject *Sender)
|
2180 |
{
|
2181 |
wininit();
|
2182 |
}
|
2183 |
//---------------------------------------------------------------------------
|
2184 |
void __fastcall TFenp::Remaillage3D1Click(TObject *Sender)
|
2185 |
{
|
2186 |
int i,j;
|
2187 |
FILE *fic;
|
2188 |
char fich[255];
|
2189 |
char mess[255];
|
2190 |
|
2191 |
Geometrie1->Checked=false;
|
2192 |
Front3D1->Checked=false;
|
2193 |
Maillage1D1->Checked=false;
|
2194 |
Maillage2D1->Checked=false;
|
2195 |
Remaillage2D1->Checked=false;
|
2196 |
Maillage3D1->Checked=false;
|
2197 |
Maillage3D2->Checked=false;
|
2198 |
Remaillage3D1->Checked=true;
|
2199 |
Face1->Enabled=false;
|
2200 |
Aucun1->Checked=false;
|
2201 |
Activerlerendu3D1->Enabled=true;
|
2202 |
Activerlerendu3D1->Checked=false;
|
2203 |
if (point!=NULL) free(point);
|
2204 |
if (segment!=NULL) free(segment);
|
2205 |
if (triangle!=NULL) free(triangle);
|
2206 |
if (tetra!=NULL) free(tetra);
|
2207 |
nb_point=0;point=NULL;
|
2208 |
nb_segment=0;segment=NULL;
|
2209 |
nb_triangle=0;triangle=NULL;
|
2210 |
nb_tetra=0;tetra=NULL;
|
2211 |
tete=NULL;
|
2212 |
strcpy(fich,Fichier);
|
2213 |
fich[strlen(fich)-4]=0;
|
2214 |
strcat(fich,"r_3D.mai");
|
2215 |
fic=fopen(fich,"rt");
|
2216 |
fgets(mess,255,fic);
|
2217 |
sscanf(mess,"%d %d",&nb_point,&nb_tetra);
|
2218 |
point=(struct s_point *)calloc(nb_point,sizeof(struct s_point));
|
2219 |
tetra=(struct s_tetra *)calloc(nb_tetra,sizeof(struct s_tetra));
|
2220 |
xpiece=0.;ypiece=0.;zpiece=0.;
|
2221 |
for (i=0;i<nb_point;i++)
|
2222 |
{
|
2223 |
fgets(mess,255,fic);
|
2224 |
sscanf(mess,"%d %f %f %f",&j,&point[i].x,&point[i].y,&point[i].z);
|
2225 |
if (i==0)
|
2226 |
{
|
2227 |
xmin=point[i].x;
|
2228 |
xmax=point[i].x;
|
2229 |
ymin=point[i].y;
|
2230 |
ymax=point[i].y;
|
2231 |
zmin=point[i].z;
|
2232 |
zmax=point[i].z;
|
2233 |
maxcoord=point[i].x;
|
2234 |
}
|
2235 |
if (point[i].x<xmin) xmin=point[i].x;
|
2236 |
if (point[i].x>xmax) xmax=point[i].x;
|
2237 |
if (point[i].y<ymin) ymin=point[i].y;
|
2238 |
if (point[i].y>ymax) ymax=point[i].y;
|
2239 |
if (point[i].z<zmin) zmin=point[i].z;
|
2240 |
if (point[i].z>zmax) zmax=point[i].z;
|
2241 |
if (fabs((double)point[i].x)>maxcoord) maxcoord=(float)fabs((double)point[i].x);
|
2242 |
if (fabs((double)point[i].y)>maxcoord) maxcoord=(float)fabs((double)point[i].y);
|
2243 |
if (fabs((double)point[i].z)>maxcoord) maxcoord=(float)fabs((double)point[i].z);
|
2244 |
xpiece=xpiece+point[i].x;
|
2245 |
ypiece=ypiece+point[i].y;
|
2246 |
zpiece=zpiece+point[i].z;
|
2247 |
}
|
2248 |
xpiece=xpiece/nb_point;
|
2249 |
ypiece=ypiece/nb_point;
|
2250 |
zpiece=zpiece/nb_point;
|
2251 |
for (i=0;i<nb_tetra;i++)
|
2252 |
{
|
2253 |
fgets(mess,255,fic);
|
2254 |
sscanf(mess,"%d %d %d %d %d",&j,&tetra[i].n1,&tetra[i].n2,&tetra[i].n3,&tetra[i].n4);
|
2255 |
tetra[i].n1=tetra[i].n1-1;
|
2256 |
tetra[i].n2=tetra[i].n2-1;
|
2257 |
tetra[i].n3=tetra[i].n3-1;
|
2258 |
tetra[i].n4=tetra[i].n4-1;
|
2259 |
tetra[i].num=i;
|
2260 |
point[tetra[i].n1].tetra[point[tetra[i].n1].nb_tetra]=&(tetra[i]);
|
2261 |
point[tetra[i].n1].nb_tetra++;
|
2262 |
point[tetra[i].n2].tetra[point[tetra[i].n2].nb_tetra]=&(tetra[i]);
|
2263 |
point[tetra[i].n2].nb_tetra++;
|
2264 |
point[tetra[i].n3].tetra[point[tetra[i].n3].nb_tetra]=&(tetra[i]);
|
2265 |
point[tetra[i].n3].nb_tetra++;
|
2266 |
point[tetra[i].n4].tetra[point[tetra[i].n4].nb_tetra]=&(tetra[i]);
|
2267 |
point[tetra[i].n4].nb_tetra++;
|
2268 |
}
|
2269 |
fclose(fic);
|
2270 |
if (passe_norme==0)
|
2271 |
{
|
2272 |
norme();
|
2273 |
passe_norme=1;
|
2274 |
}
|
2275 |
Invalidate();
|
2276 |
|
2277 |
}
|
2278 |
//---------------------------------------------------------------------------
|
2279 |
void __fastcall TFenp::Remaillage2D1Click(TObject *Sender)
|
2280 |
{
|
2281 |
int i,j;
|
2282 |
FILE *fic;
|
2283 |
int *test_face,maxface;
|
2284 |
char fich[255];
|
2285 |
char mess[255];
|
2286 |
|
2287 |
Geometrie1->Checked=false;
|
2288 |
Front3D1->Checked=false;
|
2289 |
Maillage1D1->Checked=false;
|
2290 |
Maillage2D1->Checked=false;
|
2291 |
Remaillage2D1->Checked=true;
|
2292 |
Maillage3D1->Checked=false;
|
2293 |
Maillage3D2->Checked=false;
|
2294 |
Remaillage3D1->Checked=false;
|
2295 |
Activerlerendu3D1->Enabled=false;
|
2296 |
Activerlerendu3D1->Checked=false;
|
2297 |
Aucun1->Checked=false;
|
2298 |
Face1->Enabled=true;
|
2299 |
Face->ListBox1->Items->Clear();
|
2300 |
Face->ListBox1->Items->Add("Toutes");
|
2301 |
Face->ListBox1->ItemIndex=0;
|
2302 |
Fenp->numface=(-1);
|
2303 |
if (point!=NULL) free(point);
|
2304 |
if (segment!=NULL) free(segment);
|
2305 |
if (triangle!=NULL) free(triangle);
|
2306 |
if (tetra!=NULL) free(tetra);
|
2307 |
nb_point=0;point=NULL;
|
2308 |
nb_segment=0;segment=NULL;
|
2309 |
nb_triangle=0;triangle=NULL;
|
2310 |
nb_tetra=0;tetra=NULL;
|
2311 |
tete=NULL;
|
2312 |
strcpy(fich,Fichier);
|
2313 |
fich[strlen(fich)-4]=0;
|
2314 |
strcat(fich,"r_2D.mai");
|
2315 |
fic=fopen(fich,"rt");
|
2316 |
fgets(mess,255,fic);
|
2317 |
sscanf(mess,"%d %d",&nb_point,&nb_triangle);
|
2318 |
point=(struct s_point *)calloc(nb_point,sizeof(struct s_point));
|
2319 |
triangle=(struct s_triangle *)calloc(nb_triangle,sizeof(struct s_triangle));
|
2320 |
xpiece=0.;ypiece=0.;zpiece=0.;
|
2321 |
for (i=0;i<nb_point;i++)
|
2322 |
{
|
2323 |
fgets(mess,255,fic);
|
2324 |
sscanf(mess,"%d %f %f %f",&j,&point[i].x,&point[i].y,&point[i].z);
|
2325 |
if (i==0)
|
2326 |
{
|
2327 |
xmin=point[i].x;
|
2328 |
xmax=point[i].x;
|
2329 |
ymin=point[i].y;
|
2330 |
ymax=point[i].y;
|
2331 |
zmin=point[i].z;
|
2332 |
zmax=point[i].z;
|
2333 |
maxcoord=point[i].x;
|
2334 |
}
|
2335 |
if (point[i].x<xmin) xmin=point[i].x;
|
2336 |
if (point[i].x>xmax) xmax=point[i].x;
|
2337 |
if (point[i].y<ymin) ymin=point[i].y;
|
2338 |
if (point[i].y>ymax) ymax=point[i].y;
|
2339 |
if (point[i].z<zmin) zmin=point[i].z;
|
2340 |
if (point[i].z>zmax) zmax=point[i].z;
|
2341 |
if (fabs((double)point[i].x)>maxcoord) maxcoord=(float)fabs((double)point[i].x);
|
2342 |
if (fabs((double)point[i].y)>maxcoord) maxcoord=(float)fabs((double)point[i].y);
|
2343 |
if (fabs((double)point[i].z)>maxcoord) maxcoord=(float)fabs((double)point[i].z);
|
2344 |
xpiece=xpiece+point[i].x;
|
2345 |
ypiece=ypiece+point[i].y;
|
2346 |
zpiece=zpiece+point[i].z;
|
2347 |
}
|
2348 |
xpiece=xpiece/nb_point;
|
2349 |
ypiece=ypiece/nb_point;
|
2350 |
zpiece=zpiece/nb_point;
|
2351 |
maxface=0;
|
2352 |
for (i=0;i<nb_triangle;i++)
|
2353 |
{
|
2354 |
fgets(mess,255,fic);
|
2355 |
sscanf(mess,"%d %d %d %d %s %d",&j,&triangle[i].n1,&triangle[i].n2,&triangle[i].n3,&triangle[i].type,&triangle[i].num_ent);
|
2356 |
triangle[i].n1=triangle[i].n1-1;
|
2357 |
triangle[i].n2=triangle[i].n2-1;
|
2358 |
triangle[i].n3=triangle[i].n3-1;
|
2359 |
triangle[i].num=i;
|
2360 |
if (triangle[i].num_ent>maxface) maxface=triangle[i].num_ent;
|
2361 |
point[triangle[i].n1].triangle[point[triangle[i].n1].nb_triangle]=&(triangle[i]);
|
2362 |
point[triangle[i].n1].nb_triangle++;
|
2363 |
point[triangle[i].n2].triangle[point[triangle[i].n2].nb_triangle]=&(triangle[i]);
|
2364 |
point[triangle[i].n2].nb_triangle++;
|
2365 |
point[triangle[i].n3].triangle[point[triangle[i].n3].nb_triangle]=&(triangle[i]);
|
2366 |
point[triangle[i].n3].nb_triangle++;
|
2367 |
}
|
2368 |
fclose(fic);
|
2369 |
test_face=(int *)calloc(maxface+1,sizeof(int));
|
2370 |
for (i=0;i<nb_triangle;i++)
|
2371 |
test_face[triangle[i].num_ent]=1;
|
2372 |
for (i=0;i<maxface+1;i++)
|
2373 |
if (test_face[i]==1)
|
2374 |
{
|
2375 |
sprintf(mess,"%d",i);
|
2376 |
Face->ListBox1->Items->Add(mess);
|
2377 |
}
|
2378 |
free(test_face);
|
2379 |
if (passe_norme==0)
|
2380 |
{
|
2381 |
norme();
|
2382 |
passe_norme=1;
|
2383 |
}
|
2384 |
Invalidate();
|
2385 |
}
|
2386 |
//---------------------------------------------------------------------------
|
2387 |
void __fastcall TFenp::Imprimer1Click(TObject *Sender)
|
2388 |
{
|
2389 |
char mess[255];
|
2390 |
|
2391 |
strcpy(info,"Entrez la dimension du graphique en pourcentage de la feuille ?");
|
2392 |
Valeur->Edit1->Text="100";
|
2393 |
Valeur->ShowModal();
|
2394 |
strcpy(mess,Valeur->Edit1->Text.c_str());
|
2395 |
sscanf(mess,"%f",&rapport);
|
2396 |
rapport=rapport/100.;
|
2397 |
if (PrintDialog1->Execute()) imprime();
|
2398 |
}
|
2399 |
//---------------------------------------------------------------------------
|
2400 |
void __fastcall TFenp::Configurationdelimpression1Click(TObject *Sender)
|
2401 |
{
|
2402 |
PrinterSetupDialog1->Execute();
|
2403 |
}
|
2404 |
//---------------------------------------------------------------------------
|
2405 |
void __fastcall TFenp::Activerlerendu3D1Click(TObject *Sender)
|
2406 |
{
|
2407 |
int i,j,nb_tri=0,nb_tri2,gtrouve1,gtrouve2,gtrouve3,gtrouve4;
|
2408 |
struct s_triangle *tri,*tr;
|
2409 |
|
2410 |
Fenp->Cursor=crHourGlass;
|
2411 |
if (Activerlerendu3D1->Checked==false)
|
2412 |
{
|
2413 |
Activerlerendu3D1->Checked=true;
|
2414 |
tri=(struct s_triangle *)calloc(nb_tetra*4,sizeof(struct s_triangle));
|
2415 |
for (i=0;i<nb_tetra;i++)
|
2416 |
{
|
2417 |
gtrouve1=(-1);
|
2418 |
gtrouve2=(-1);
|
2419 |
gtrouve3=(-1);
|
2420 |
gtrouve4=(-1);
|
2421 |
for (j=0;j<point[tetra[i].n1].nb_triangle;j++)
|
2422 |
{
|
2423 |
tr=point[tetra[i].n1].triangle[j];
|
2424 |
if (((tr->n1==tetra[i].n1) && (tr->n2==tetra[i].n2) && (tr->n3==tetra[i].n3))
|
2425 |
|| ((tr->n1==tetra[i].n1) && (tr->n3==tetra[i].n2) && (tr->n2==tetra[i].n3))
|
2426 |
|| ((tr->n2==tetra[i].n1) && (tr->n1==tetra[i].n2) && (tr->n3==tetra[i].n3))
|
2427 |
|| ((tr->n2==tetra[i].n1) && (tr->n3==tetra[i].n2) && (tr->n1==tetra[i].n3))
|
2428 |
|| ((tr->n3==tetra[i].n1) && (tr->n1==tetra[i].n2) && (tr->n2==tetra[i].n3))
|
2429 |
|| ((tr->n3==tetra[i].n1) && (tr->n2==tetra[i].n2) && (tr->n1==tetra[i].n3)))
|
2430 |
gtrouve1=tr->num;
|
2431 |
if (((tr->n1==tetra[i].n1) && (tr->n2==tetra[i].n2) && (tr->n3==tetra[i].n4))
|
2432 |
|| ((tr->n1==tetra[i].n1) && (tr->n3==tetra[i].n2) && (tr->n2==tetra[i].n4))
|
2433 |
|| ((tr->n2==tetra[i].n1) && (tr->n1==tetra[i].n2) && (tr->n3==tetra[i].n4))
|
2434 |
|| ((tr->n2==tetra[i].n1) && (tr->n3==tetra[i].n2) && (tr->n1==tetra[i].n4))
|
2435 |
|| ((tr->n3==tetra[i].n1) && (tr->n1==tetra[i].n2) && (tr->n2==tetra[i].n4))
|
2436 |
|| ((tr->n3==tetra[i].n1) && (tr->n2==tetra[i].n2) && (tr->n1==tetra[i].n4)))
|
2437 |
gtrouve3=tr->num;
|
2438 |
if (((tr->n1==tetra[i].n1) && (tr->n2==tetra[i].n3) && (tr->n3==tetra[i].n4))
|
2439 |
|| ((tr->n1==tetra[i].n1) && (tr->n3==tetra[i].n3) && (tr->n2==tetra[i].n4))
|
2440 |
|| ((tr->n2==tetra[i].n1) && (tr->n1==tetra[i].n3) && (tr->n3==tetra[i].n4))
|
2441 |
|| ((tr->n2==tetra[i].n1) && (tr->n3==tetra[i].n3) && (tr->n1==tetra[i].n4))
|
2442 |
|| ((tr->n3==tetra[i].n1) && (tr->n1==tetra[i].n3) && (tr->n2==tetra[i].n4))
|
2443 |
|| ((tr->n3==tetra[i].n1) && (tr->n2==tetra[i].n3) && (tr->n1==tetra[i].n4)))
|
2444 |
gtrouve4=tr->num;
|
2445 |
}
|
2446 |
if (gtrouve1==(-1))
|
2447 |
{
|
2448 |
tri[nb_tri].n1=tetra[i].n1;
|
2449 |
tri[nb_tri].n2=tetra[i].n2;
|
2450 |
tri[nb_tri].n3=tetra[i].n3;
|
2451 |
tri[nb_tri].num_ent=1;
|
2452 |
tri[nb_tri].num=nb_tri;
|
2453 |
point[tri[nb_tri].n1].triangle[point[tri[nb_tri].n1].nb_triangle]=&tri[nb_tri];
|
2454 |
(point[tri[nb_tri].n1].nb_triangle)++;
|
2455 |
point[tri[nb_tri].n2].triangle[point[tri[nb_tri].n2].nb_triangle]=&tri[nb_tri];
|
2456 |
(point[tri[nb_tri].n2].nb_triangle)++;
|
2457 |
point[tri[nb_tri].n3].triangle[point[tri[nb_tri].n3].nb_triangle]=&tri[nb_tri];
|
2458 |
(point[tri[nb_tri].n3].nb_triangle)++;
|
2459 |
nb_tri++;
|
2460 |
}
|
2461 |
else tri[gtrouve1].num_ent++;
|
2462 |
if (gtrouve3==(-1))
|
2463 |
{
|
2464 |
tri[nb_tri].n1=tetra[i].n1;
|
2465 |
tri[nb_tri].n2=tetra[i].n2;
|
2466 |
tri[nb_tri].n3=tetra[i].n4;
|
2467 |
tri[nb_tri].num=nb_tri;
|
2468 |
tri[nb_tri].num_ent=1;
|
2469 |
point[tri[nb_tri].n1].triangle[point[tri[nb_tri].n1].nb_triangle]=&tri[nb_tri];
|
2470 |
(point[tri[nb_tri].n1].nb_triangle)++;
|
2471 |
point[tri[nb_tri].n2].triangle[point[tri[nb_tri].n2].nb_triangle]=&tri[nb_tri];
|
2472 |
(point[tri[nb_tri].n2].nb_triangle)++;
|
2473 |
point[tri[nb_tri].n3].triangle[point[tri[nb_tri].n3].nb_triangle]=&tri[nb_tri];
|
2474 |
(point[tri[nb_tri].n3].nb_triangle)++;
|
2475 |
nb_tri++;
|
2476 |
}
|
2477 |
else tri[gtrouve3].num_ent++;
|
2478 |
if (gtrouve4==(-1))
|
2479 |
{
|
2480 |
tri[nb_tri].n1=tetra[i].n1;
|
2481 |
tri[nb_tri].n2=tetra[i].n3;
|
2482 |
tri[nb_tri].n3=tetra[i].n4;
|
2483 |
tri[nb_tri].num=nb_tri;
|
2484 |
tri[nb_tri].num_ent=1;
|
2485 |
point[tri[nb_tri].n1].triangle[point[tri[nb_tri].n1].nb_triangle]=&tri[nb_tri];
|
2486 |
(point[tri[nb_tri].n1].nb_triangle)++;
|
2487 |
point[tri[nb_tri].n2].triangle[point[tri[nb_tri].n2].nb_triangle]=&tri[nb_tri];
|
2488 |
(point[tri[nb_tri].n2].nb_triangle)++;
|
2489 |
point[tri[nb_tri].n3].triangle[point[tri[nb_tri].n3].nb_triangle]=&tri[nb_tri];
|
2490 |
(point[tri[nb_tri].n3].nb_triangle)++;
|
2491 |
nb_tri++;
|
2492 |
}
|
2493 |
else tri[gtrouve4].num_ent++;
|
2494 |
for (j=0;j<point[tetra[i].n2].nb_triangle;j++)
|
2495 |
{
|
2496 |
tr=point[tetra[i].n2].triangle[j];
|
2497 |
if (((tr->n1==tetra[i].n2) && (tr->n2==tetra[i].n3) && (tr->n3==tetra[i].n4))
|
2498 |
|| ((tr->n1==tetra[i].n2) && (tr->n3==tetra[i].n3) && (tr->n2==tetra[i].n4))
|
2499 |
|| ((tr->n2==tetra[i].n2) && (tr->n1==tetra[i].n3) && (tr->n3==tetra[i].n4))
|
2500 |
|| ((tr->n2==tetra[i].n2) && (tr->n3==tetra[i].n3) && (tr->n1==tetra[i].n4))
|
2501 |
|| ((tr->n3==tetra[i].n2) && (tr->n1==tetra[i].n3) && (tr->n2==tetra[i].n4))
|
2502 |
|| ((tr->n3==tetra[i].n2) && (tr->n2==tetra[i].n3) && (tr->n1==tetra[i].n4)))
|
2503 |
gtrouve2=tr->num;
|
2504 |
}
|
2505 |
if (gtrouve2==(-1))
|
2506 |
{
|
2507 |
tri[nb_tri].n1=tetra[i].n2;
|
2508 |
tri[nb_tri].n2=tetra[i].n3;
|
2509 |
tri[nb_tri].n3=tetra[i].n4;
|
2510 |
tri[nb_tri].num=nb_tri;
|
2511 |
tri[nb_tri].num_ent=1;
|
2512 |
point[tri[nb_tri].n1].triangle[point[tri[nb_tri].n1].nb_triangle]=&tri[nb_tri];
|
2513 |
(point[tri[nb_tri].n1].nb_triangle)++;
|
2514 |
point[tri[nb_tri].n2].triangle[point[tri[nb_tri].n2].nb_triangle]=&tri[nb_tri];
|
2515 |
(point[tri[nb_tri].n2].nb_triangle)++;
|
2516 |
point[tri[nb_tri].n3].triangle[point[tri[nb_tri].n3].nb_triangle]=&tri[nb_tri];
|
2517 |
(point[tri[nb_tri].n3].nb_triangle)++;
|
2518 |
nb_tri++;
|
2519 |
}
|
2520 |
else tri[gtrouve2].num_ent++;
|
2521 |
|
2522 |
}
|
2523 |
|
2524 |
nb_triangle=0;nb_tri2=0;
|
2525 |
for (i=0;i<nb_tri;i++)
|
2526 |
if (tri[i].num_ent==1) nb_triangle++;
|
2527 |
triangle=(struct s_triangle *)calloc(nb_triangle,sizeof(struct s_triangle));
|
2528 |
for (i=0;i<nb_point;i++)
|
2529 |
point[i].nb_triangle=0;
|
2530 |
for (i=0;i<nb_tri;i++)
|
2531 |
if (tri[i].num_ent==1)
|
2532 |
{
|
2533 |
triangle[nb_tri2].n1=tri[i].n1;
|
2534 |
triangle[nb_tri2].n2=tri[i].n2;
|
2535 |
triangle[nb_tri2].n3=tri[i].n3;
|
2536 |
triangle[nb_tri2].num=nb_tri2;
|
2537 |
point[triangle[nb_tri2].n1].triangle[point[triangle[nb_tri2].n1].nb_triangle]=&(triangle[nb_tri2]);
|
2538 |
(point[triangle[nb_tri2].n1].nb_triangle)++;
|
2539 |
point[triangle[nb_tri2].n2].triangle[point[triangle[nb_tri2].n2].nb_triangle]=&(triangle[nb_tri2]);
|
2540 |
(point[triangle[nb_tri2].n2].nb_triangle)++;
|
2541 |
point[triangle[nb_tri2].n3].triangle[point[triangle[nb_tri2].n3].nb_triangle]=&(triangle[nb_tri2]);
|
2542 |
(point[triangle[nb_tri2].n3].nb_triangle)++;
|
2543 |
nb_tri2++;
|
2544 |
}
|
2545 |
free(tri);
|
2546 |
}
|
2547 |
Fenp->Cursor=crDefault;
|
2548 |
Invalidate();
|
2549 |
}
|
2550 |
//---------------------------------------------------------------------------
|
2551 |
void __fastcall TFenp::Purgerletude1Click(TObject *Sender)
|
2552 |
{
|
2553 |
char fich[500],mess[500];
|
2554 |
|
2555 |
strcpy(fich,Fichier);
|
2556 |
fich[strlen(fich)-4]=0;
|
2557 |
|
2558 |
strcpy(mess,fich);
|
2559 |
strcat(mess,".oct");
|
2560 |
remove(mess);
|
2561 |
strcpy(mess,fich);
|
2562 |
strcat(mess,".qua");
|
2563 |
remove(mess);
|
2564 |
strcpy(mess,fich);
|
2565 |
strcat(mess,".geo");
|
2566 |
remove(mess);
|
2567 |
strcpy(mess,fich);
|
2568 |
strcat(mess,".res");
|
2569 |
remove(mess);
|
2570 |
strcpy(mess,fich);
|
2571 |
strcat(mess,"_1D.mai");
|
2572 |
remove(mess);
|
2573 |
strcpy(mess,fich);
|
2574 |
strcat(mess,"_2D.mai");
|
2575 |
remove(mess);
|
2576 |
strcpy(mess,fich);
|
2577 |
strcat(mess,"_3D.mai");
|
2578 |
remove(mess);
|
2579 |
strcpy(mess,fich);
|
2580 |
strcat(mess,"_2D.skin");
|
2581 |
remove(mess);
|
2582 |
strcpy(mess,fich);
|
2583 |
strcat(mess,"_2D.res");
|
2584 |
remove(mess);
|
2585 |
strcpy(mess,fich);
|
2586 |
strcat(mess,"r_2D.mai");
|
2587 |
remove(mess);
|
2588 |
strcpy(mess,fich);
|
2589 |
strcat(mess,"r_3D.mai");
|
2590 |
remove(mess);
|
2591 |
strcpy(mess,fich);
|
2592 |
strcat(mess,"c_3D.mai");
|
2593 |
remove(mess);
|
2594 |
strcpy(mess,fich);
|
2595 |
strcat(mess,"r_2D.skin");
|
2596 |
remove(mess);
|
2597 |
strcpy(mess,fich);
|
2598 |
strcat(mess,"r_2D.res");
|
2599 |
remove(mess);
|
2600 |
strcpy(mess,fich);
|
2601 |
strcat(mess,"_2D.REC");
|
2602 |
remove(mess);
|
2603 |
strcpy(mess,fich);
|
2604 |
strcat(mess,"r_2D.REC");
|
2605 |
remove(mess);
|
2606 |
strcpy(mess,fich);
|
2607 |
strcat(mess,"f_2D.REC");
|
2608 |
remove(mess);
|
2609 |
}
|
2610 |
//---------------------------------------------------------------------------
|
2611 |
void __fastcall TFenp::CreerunesessionClick(TObject *Sender)
|
2612 |
{
|
2613 |
char mess[255];
|
2614 |
|
2615 |
OpenDialog2->InitialDir=dir_defaut;
|
2616 |
if (OpenDialog2->Execute()==true)
|
2617 |
{
|
2618 |
Creerunesession->Enabled=false;
|
2619 |
Fermerlasession1->Enabled=true;
|
2620 |
batch=true;
|
2621 |
strcpy(mess,OpenDialog2->FileName.c_str());
|
2622 |
strcat(mess,".ses");
|
2623 |
f_batch=fopen(mess,"wt");
|
2624 |
}
|
2625 |
}
|
2626 |
//---------------------------------------------------------------------------
|
2627 |
void __fastcall TFenp::Fermerlasession1Click(TObject *Sender)
|
2628 |
{
|
2629 |
Creerunesession->Enabled=true;
|
2630 |
Fermerlasession1->Enabled=false;
|
2631 |
batch=false;
|
2632 |
fclose(f_batch);
|
2633 |
}
|
2634 |
//---------------------------------------------------------------------------
|
2635 |
void __fastcall TFenp::Lancerunesession1Click(TObject *Sender)
|
2636 |
{
|
2637 |
Application->CreateForm(__classid(Tcsession), &csession);
|
2638 |
|
2639 |
csession->ShowModal();
|
2640 |
}
|
2641 |
//---------------------------------------------------------------------------
|
2642 |
void __fastcall TFenp::Paramesh1Click(TObject *Sender)
|
2643 |
{
|
2644 |
char mess[255];
|
2645 |
char arg1[255];
|
2646 |
char arg2[255];
|
2647 |
char arg3[255];
|
2648 |
char arg4[255];
|
2649 |
char arg5[255];
|
2650 |
char arg6[255];
|
2651 |
char arg7[255];
|
2652 |
char arg8[255];
|
2653 |
char arg9[255];
|
2654 |
char arg10[255];
|
2655 |
int opt=5;
|
2656 |
|
2657 |
Rigsoption->Label3->Enabled=false;
|
2658 |
Rigsoption->Edit3->Enabled=false;
|
2659 |
Rigsoption->Edit2->Text="5";
|
2660 |
Rigsoption->CheckBox1->Enabled=true;
|
2661 |
Rigsoption->GroupBox1->Caption=Fichier;
|
2662 |
Rigsoption->ShowModal();
|
2663 |
if (Rigsoption->ok==1)
|
2664 |
{
|
2665 |
strcpy(mess,Rigsoption->Edit2->Text.c_str());
|
2666 |
sscanf(mess,"%d",&opt);
|
2667 |
mess[0]=0;
|
2668 |
strcpy(mess,Rigsoption->Edit1->Text.c_str());
|
2669 |
sprintf(arg1,"%s\\paramesh.exe",home);
|
2670 |
strcpy(arg2,"-fich");
|
2671 |
sprintf(arg3,"%s",Fichier);
|
2672 |
strcpy(arg4,"-mesh");
|
2673 |
strcpy(arg5,mess);
|
2674 |
strcpy(arg6,"-opti2d");
|
2675 |
sprintf(arg7,"%d",opt);
|
2676 |
if (Rigsoption->CheckBox1->Checked==true) strcpy(arg8,"-analyse"); else strcpy(arg8,"");
|
2677 |
chdir(home);
|
2678 |
if (mess[0]==0) MessageBox(Handle,"Pas de fichier modele","Erreur",0);
|
2679 |
else if (batch==false) spawnl(P_NOWAIT,arg1,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,NULL);
|
2680 |
else fprintf(f_batch,"%s %s %s %s %s %s %s %s %s %s \n",arg1,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
|
2681 |
}
|
2682 |
|
2683 |
}
|
2684 |
//---------------------------------------------------------------------------
|
2685 |
void __fastcall TFenp::Maillage3D2Click(TObject *Sender)
|
2686 |
{
|
2687 |
int i,j;
|
2688 |
FILE *fic;
|
2689 |
char fich[255];
|
2690 |
char mess[255];
|
2691 |
|
2692 |
Geometrie1->Checked=false;
|
2693 |
Maillage1D1->Checked=false;
|
2694 |
Front3D1->Checked=false;
|
2695 |
Maillage2D1->Checked=false;
|
2696 |
Remaillage2D1->Checked=false;
|
2697 |
Maillage3D1->Checked=false;
|
2698 |
Maillage3D2->Checked=true;
|
2699 |
Remaillage3D1->Checked=false;
|
2700 |
Activerlerendu3D1->Enabled=true;
|
2701 |
Activerlerendu3D1->Checked=false;
|
2702 |
Face1->Enabled=false;
|
2703 |
Aucun1->Checked=false;
|
2704 |
if (point!=NULL) free(point);
|
2705 |
if (segment!=NULL) free(segment);
|
2706 |
if (triangle!=NULL) free(triangle);
|
2707 |
if (tetra!=NULL) free(tetra);
|
2708 |
nb_point=0;point=NULL;
|
2709 |
nb_segment=0;segment=NULL;
|
2710 |
nb_triangle=0;triangle=NULL;
|
2711 |
nb_tetra=0;tetra=NULL;
|
2712 |
tete=NULL;
|
2713 |
strcpy(fich,Fichier);
|
2714 |
fich[strlen(fich)-4]=0;
|
2715 |
strcat(fich,"c_3D.mai");
|
2716 |
fic=fopen(fich,"rt");
|
2717 |
fgets(mess,255,fic);
|
2718 |
sscanf(mess,"%d %d",&nb_point,&nb_tetra);
|
2719 |
point=(struct s_point *)calloc(nb_point,sizeof(struct s_point));
|
2720 |
tetra=(struct s_tetra *)calloc(nb_tetra,sizeof(struct s_tetra));
|
2721 |
xpiece=0.;ypiece=0.;zpiece=0.;
|
2722 |
for (i=0;i<nb_point;i++)
|
2723 |
{
|
2724 |
fgets(mess,255,fic);
|
2725 |
sscanf(mess,"%d %f %f %f",&j,&point[i].x,&point[i].y,&point[i].z);
|
2726 |
if (i==0)
|
2727 |
{
|
2728 |
xmin=point[i].x;
|
2729 |
xmax=point[i].x;
|
2730 |
ymin=point[i].y;
|
2731 |
ymax=point[i].y;
|
2732 |
zmin=point[i].z;
|
2733 |
zmax=point[i].z;
|
2734 |
maxcoord=point[i].x;
|
2735 |
}
|
2736 |
if (point[i].x<xmin) xmin=point[i].x;
|
2737 |
if (point[i].x>xmax) xmax=point[i].x;
|
2738 |
if (point[i].y<ymin) ymin=point[i].y;
|
2739 |
if (point[i].y>ymax) ymax=point[i].y;
|
2740 |
if (point[i].z<zmin) zmin=point[i].z;
|
2741 |
if (point[i].z>zmax) zmax=point[i].z;
|
2742 |
if (fabs((double)point[i].x)>maxcoord) maxcoord=(float)fabs((double)point[i].x);
|
2743 |
if (fabs((double)point[i].y)>maxcoord) maxcoord=(float)fabs((double)point[i].y);
|
2744 |
if (fabs((double)point[i].z)>maxcoord) maxcoord=(float)fabs((double)point[i].z);
|
2745 |
xpiece=xpiece+point[i].x;
|
2746 |
ypiece=ypiece+point[i].y;
|
2747 |
zpiece=zpiece+point[i].z;
|
2748 |
}
|
2749 |
xpiece=xpiece/nb_point;
|
2750 |
ypiece=ypiece/nb_point;
|
2751 |
zpiece=zpiece/nb_point;
|
2752 |
for (i=0;i<nb_tetra;i++)
|
2753 |
{
|
2754 |
fgets(mess,255,fic);
|
2755 |
sscanf(mess,"%d %d %d %d %d",&j,&tetra[i].n1,&tetra[i].n2,&tetra[i].n3,&tetra[i].n4);
|
2756 |
tetra[i].n1=tetra[i].n1-1;
|
2757 |
tetra[i].n2=tetra[i].n2-1;
|
2758 |
tetra[i].n3=tetra[i].n3-1;
|
2759 |
tetra[i].n4=tetra[i].n4-1;
|
2760 |
tetra[i].num=i;
|
2761 |
point[tetra[i].n1].tetra[point[tetra[i].n1].nb_tetra]=&(tetra[i]);
|
2762 |
point[tetra[i].n1].nb_tetra++;
|
2763 |
point[tetra[i].n2].tetra[point[tetra[i].n2].nb_tetra]=&(tetra[i]);
|
2764 |
point[tetra[i].n2].nb_tetra++;
|
2765 |
point[tetra[i].n3].tetra[point[tetra[i].n3].nb_tetra]=&(tetra[i]);
|
2766 |
point[tetra[i].n3].nb_tetra++;
|
2767 |
point[tetra[i].n4].tetra[point[tetra[i].n4].nb_tetra]=&(tetra[i]);
|
2768 |
point[tetra[i].n4].nb_tetra++;
|
2769 |
}
|
2770 |
fclose(fic);
|
2771 |
if (passe_norme==0)
|
2772 |
{
|
2773 |
norme();
|
2774 |
passe_norme=1;
|
2775 |
}
|
2776 |
Invalidate();
|
2777 |
}
|
2778 |
//---------------------------------------------------------------------------
|
2779 |
void __fastcall TFenp::Editeur1Click(TObject *Sender)
|
2780 |
{
|
2781 |
Application->CreateForm(__classid(TEditeur), &Editeur);
|
2782 |
Editeur->Show();
|
2783 |
}
|
2784 |
//---------------------------------------------------------------------------
|
2785 |
void __fastcall TFenp::Transsat1Click(TObject *Sender)
|
2786 |
{
|
2787 |
char arg1[255];
|
2788 |
|
2789 |
sprintf(arg1,"%s\\transsat.exe",home);
|
2790 |
spawnl(P_NOWAIT,arg1,arg1,NULL);
|
2791 |
}
|
2792 |
//---------------------------------------------------------------------------
|
2793 |
void __fastcall TFenp::ContourInactif1Click(TObject *Sender)
|
2794 |
{
|
2795 |
if (ContourInactif1->Checked==true) ContourInactif1->Checked=false;
|
2796 |
else ContourInactif1->Checked=true;
|
2797 |
Invalidate();
|
2798 |
}
|
2799 |
//---------------------------------------------------------------------------
|
2800 |
void __fastcall TFenp::Barrevisible1Click(TObject *Sender)
|
2801 |
{
|
2802 |
if (Barrevisible1->Checked==false) Barrevisible1->Checked=true;
|
2803 |
else Barrevisible1->Checked=false;
|
2804 |
if (existetool!=0)
|
2805 |
if (Barrevisible1->Checked==false) Toolbar->FormStyle=fsNormal;
|
2806 |
else Toolbar->FormStyle=fsStayOnTop;
|
2807 |
}
|
2808 |
//---------------------------------------------------------------------------
|
2809 |
void __fastcall TFenp::Front3D1Click(TObject *Sender)
|
2810 |
{
|
2811 |
int i,j;
|
2812 |
FILE *fic;
|
2813 |
int *test_face,maxface;
|
2814 |
char fich[255];
|
2815 |
char mess[255];
|
2816 |
|
2817 |
Geometrie1->Checked=false;
|
2818 |
Maillage1D1->Checked=false;
|
2819 |
Front3D1->Checked=true;
|
2820 |
Maillage2D1->Checked=false;
|
2821 |
Remaillage2D1->Checked=false;
|
2822 |
Maillage3D1->Checked=false;
|
2823 |
Maillage3D2->Checked=false;
|
2824 |
Remaillage3D1->Checked=false;
|
2825 |
Activerlerendu3D1->Enabled=false;
|
2826 |
Activerlerendu3D1->Checked=false;
|
2827 |
Aucun1->Checked=false;
|
2828 |
Face1->Enabled=true;
|
2829 |
Face->ListBox1->Items->Clear();
|
2830 |
Face->ListBox1->Items->Add("Toutes");
|
2831 |
Face->ListBox1->ItemIndex=0;
|
2832 |
Fenp->numface=(-1);
|
2833 |
if (point!=NULL) free(point);
|
2834 |
if (segment!=NULL) free(segment);
|
2835 |
if (triangle!=NULL) free(triangle);
|
2836 |
if (tetra!=NULL) free(tetra);
|
2837 |
nb_point=0;point=NULL;
|
2838 |
nb_segment=0;segment=NULL;
|
2839 |
nb_triangle=0;triangle=NULL;
|
2840 |
nb_tetra=0;tetra=NULL;
|
2841 |
tete=NULL;
|
2842 |
strcpy(fich,Fichier);
|
2843 |
fich[strlen(fich)-4]=0;
|
2844 |
strcat(fich,"f_2D.mai");
|
2845 |
fic=fopen(fich,"rt");
|
2846 |
fgets(mess,255,fic);
|
2847 |
sscanf(mess,"%d %d",&nb_point,&nb_triangle);
|
2848 |
point=(struct s_point *)calloc(nb_point,sizeof(struct s_point));
|
2849 |
triangle=(struct s_triangle *)calloc(nb_triangle,sizeof(struct s_triangle));
|
2850 |
xpiece=0.;ypiece=0.;zpiece=0.;
|
2851 |
for (i=0;i<nb_point;i++)
|
2852 |
{
|
2853 |
fgets(mess,255,fic);
|
2854 |
sscanf(mess,"%d %f %f %f",&j,&point[i].x,&point[i].y,&point[i].z);
|
2855 |
if (i==0)
|
2856 |
{
|
2857 |
xmin=point[i].x;
|
2858 |
xmax=point[i].x;
|
2859 |
ymin=point[i].y;
|
2860 |
ymax=point[i].y;
|
2861 |
zmin=point[i].z;
|
2862 |
zmax=point[i].z;
|
2863 |
maxcoord=point[i].x;
|
2864 |
}
|
2865 |
if (point[i].x<xmin) xmin=point[i].x;
|
2866 |
if (point[i].x>xmax) xmax=point[i].x;
|
2867 |
if (point[i].y<ymin) ymin=point[i].y;
|
2868 |
if (point[i].y>ymax) ymax=point[i].y;
|
2869 |
if (point[i].z<zmin) zmin=point[i].z;
|
2870 |
if (point[i].z>zmax) zmax=point[i].z;
|
2871 |
if (fabs((double)point[i].x)>maxcoord) maxcoord=(float)fabs((double)point[i].x);
|
2872 |
if (fabs((double)point[i].y)>maxcoord) maxcoord=(float)fabs((double)point[i].y);
|
2873 |
if (fabs((double)point[i].z)>maxcoord) maxcoord=(float)fabs((double)point[i].z);
|
2874 |
xpiece=xpiece+point[i].x;
|
2875 |
ypiece=ypiece+point[i].y;
|
2876 |
zpiece=zpiece+point[i].z;
|
2877 |
}
|
2878 |
xpiece=xpiece/nb_point;
|
2879 |
ypiece=ypiece/nb_point;
|
2880 |
zpiece=zpiece/nb_point;
|
2881 |
maxface=0;
|
2882 |
for (i=0;i<nb_triangle;i++)
|
2883 |
{
|
2884 |
fgets(mess,255,fic);
|
2885 |
sscanf(mess,"%d %d %d %d %s %d",&j,&triangle[i].n1,&triangle[i].n2,&triangle[i].n3,&triangle[i].type,&triangle[i].num_ent);
|
2886 |
triangle[i].n1=triangle[i].n1-1;
|
2887 |
triangle[i].n2=triangle[i].n2-1;
|
2888 |
triangle[i].n3=triangle[i].n3-1;
|
2889 |
triangle[i].num=i;
|
2890 |
if (triangle[i].num_ent>maxface) maxface=triangle[i].num_ent;
|
2891 |
point[triangle[i].n1].triangle[point[triangle[i].n1].nb_triangle]=&(triangle[i]);
|
2892 |
point[triangle[i].n1].nb_triangle++;
|
2893 |
point[triangle[i].n2].triangle[point[triangle[i].n2].nb_triangle]=&(triangle[i]);
|
2894 |
point[triangle[i].n2].nb_triangle++;
|
2895 |
point[triangle[i].n3].triangle[point[triangle[i].n3].nb_triangle]=&(triangle[i]);
|
2896 |
point[triangle[i].n3].nb_triangle++;
|
2897 |
}
|
2898 |
fclose(fic);
|
2899 |
test_face=(int *)calloc(maxface+1,sizeof(int));
|
2900 |
for (i=0;i<nb_triangle;i++)
|
2901 |
test_face[triangle[i].num_ent]=1;
|
2902 |
for (i=0;i<maxface+1;i++)
|
2903 |
if (test_face[i]==1)
|
2904 |
{
|
2905 |
sprintf(mess,"%d",i);
|
2906 |
Face->ListBox1->Items->Add(mess);
|
2907 |
}
|
2908 |
free(test_face);
|
2909 |
if (passe_norme==0)
|
2910 |
{
|
2911 |
norme();
|
2912 |
passe_norme=1;
|
2913 |
}
|
2914 |
Invalidate();
|
2915 |
}
|
2916 |
//---------------------------------------------------------------------------
|
2917 |
void __fastcall TFenp::Enregistrerlhistoriquedesrotations1Click(TObject *Sender)
|
2918 |
{
|
2919 |
char mess[255];
|
2920 |
FILE *out;
|
2921 |
|
2922 |
OpenDialog3->InitialDir=home;
|
2923 |
if (OpenDialog3->Execute()==true)
|
2924 |
{
|
2925 |
strcpy(mess,OpenDialog3->FileName.c_str());
|
2926 |
strcat(mess,".ori");
|
2927 |
out=fopen(mess,"wt");
|
2928 |
fprintf(out,"%f\n",rot[0][0]);
|
2929 |
fprintf(out,"%f\n",rot[0][1]);
|
2930 |
fprintf(out,"%f\n",rot[0][2]);
|
2931 |
fprintf(out,"%f\n",rot[1][0]);
|
2932 |
fprintf(out,"%f\n",rot[1][1]);
|
2933 |
fprintf(out,"%f\n",rot[1][2]);
|
2934 |
fprintf(out,"%f\n",rot[2][0]);
|
2935 |
fprintf(out,"%f\n",rot[2][1]);
|
2936 |
fprintf(out,"%f\n",rot[2][2]);
|
2937 |
fclose(out);
|
2938 |
}
|
2939 |
|
2940 |
}
|
2941 |
//---------------------------------------------------------------------------
|
2942 |
void __fastcall TFenp::Chargeruneorientation1Click(TObject *Sender)
|
2943 |
{
|
2944 |
char mess[255];
|
2945 |
FILE *out;
|
2946 |
|
2947 |
OpenDialog3->InitialDir=home;
|
2948 |
if (OpenDialog3->Execute()==true)
|
2949 |
{
|
2950 |
strcpy(mess,OpenDialog3->FileName.c_str());
|
2951 |
out=fopen(mess,"rt");
|
2952 |
fgets(mess,255,out);
|
2953 |
sscanf(mess,"%f",&(rot[0][0]));
|
2954 |
fgets(mess,255,out);
|
2955 |
sscanf(mess,"%f",&(rot[0][1]));
|
2956 |
fgets(mess,255,out);
|
2957 |
sscanf(mess,"%f",&(rot[0][2]));
|
2958 |
fgets(mess,255,out);
|
2959 |
sscanf(mess,"%f",&(rot[1][0]));
|
2960 |
fgets(mess,255,out);
|
2961 |
sscanf(mess,"%f",&(rot[1][1]));
|
2962 |
fgets(mess,255,out);
|
2963 |
sscanf(mess,"%f",&(rot[1][2]));
|
2964 |
fgets(mess,255,out);
|
2965 |
sscanf(mess,"%f",&(rot[2][0]));
|
2966 |
fgets(mess,255,out);
|
2967 |
sscanf(mess,"%f",&(rot[2][1]));
|
2968 |
fgets(mess,255,out);
|
2969 |
sscanf(mess,"%f",&(rot[2][2]));
|
2970 |
fclose(out);
|
2971 |
Invalidate();
|
2972 |
}
|
2973 |
|
2974 |
}
|
2975 |
//---------------------------------------------------------------------------
|
2976 |
void __fastcall TFenp::InfoPice1Click(TObject *Sender)
|
2977 |
{
|
2978 |
Application->CreateForm(__classid(TInfo_piece), &Info_piece);
|
2979 |
Info_piece->Left=Fenp->Left+29;
|
2980 |
Info_piece->Top=Fenp->Top+37;
|
2981 |
Info_piece->ShowModal();
|
2982 |
}
|
2983 |
//---------------------------------------------------------------------------
|
2984 |
void __fastcall TFenp::Normal2Click(TObject *Sender)
|
2985 |
{
|
2986 |
int i;
|
2987 |
if (Fenp->Normal2->Checked==false)
|
2988 |
{
|
2989 |
Fenp->Normal2->Checked=true;
|
2990 |
Fenp->Debug1->Checked=false;
|
2991 |
Fendebug->Close();
|
2992 |
Fenp->Left=posx;
|
2993 |
Fenp->Top=posy;
|
2994 |
Fenp->Width=posdx;
|
2995 |
Fenp->Height=posdy;
|
2996 |
Mai1->Enabled=true;
|
2997 |
Fichier1->Enabled=true;
|
2998 |
for (i=0;i<nb_segment;i++) segment[i].select=0;
|
2999 |
for (i=0;i<nb_triangle;i++) triangle[i].select=0;
|
3000 |
for (i=0;i<nb_tetra;i++) tetra[i].select=0;
|
3001 |
}
|
3002 |
}
|
3003 |
//---------------------------------------------------------------------------
|
3004 |
|
3005 |
void __fastcall TFenp::Debug1Click(TObject *Sender)
|
3006 |
{
|
3007 |
if (Geometrie1->Checked==true)
|
3008 |
{
|
3009 |
MessageBox(Handle,"Option interdite sur la geometrie","Erreur",0);
|
3010 |
return;
|
3011 |
}
|
3012 |
if (Fenp->Debug1->Checked==false)
|
3013 |
{
|
3014 |
Fenp->Normal2->Checked=false;
|
3015 |
Fenp->Debug1->Checked=true;
|
3016 |
Application->CreateForm(__classid(TFendebug), &Fendebug);
|
3017 |
posx=Fenp->Left;
|
3018 |
posy=Fenp->Top;
|
3019 |
posdx=Fenp->Width;
|
3020 |
posdy=Fenp->Height;
|
3021 |
Fenp->Top=0;
|
3022 |
Fenp->Height=(int)(0.5*Screen->Height);
|
3023 |
Fendebug->Left=Fenp->Left;
|
3024 |
Fendebug->Top=Fenp->Height+1;
|
3025 |
Fendebug->Height=Screen->Height-Fendebug->Top;
|
3026 |
Fendebug->Width=Screen->Width-Fendebug->Left;
|
3027 |
Fendebug->Show();
|
3028 |
Mai1->Enabled=false;
|
3029 |
Fichier1->Enabled=false;
|
3030 |
}
|
3031 |
}
|
3032 |
//---------------------------------------------------------------------------
|
3033 |
|