1 |
|
5 |
//------------------------------------------------------------
|
2 |
|
|
//------------------------------------------------------------
|
3 |
|
|
// MAGiC
|
4 |
|
|
// Jean Christophe Cuillière et Vincent FRANCOIS
|
5 |
|
|
// Département de Génie Mécanique - UQTR
|
6 |
|
|
//------------------------------------------------------------
|
7 |
|
|
// Le projet MAGIC est un projet de recherche du département
|
8 |
|
|
// de génie mécanique de l'Université du Québec à
|
9 |
|
|
// Trois Rivières
|
10 |
|
|
// Les librairies ne peuvent être utilisées sans l'accord
|
11 |
|
|
// des auteurs (contact : francois@uqtr.ca)
|
12 |
|
|
//------------------------------------------------------------
|
13 |
|
|
//------------------------------------------------------------
|
14 |
|
|
//
|
15 |
|
|
// visu.cpp
|
16 |
|
|
//
|
17 |
|
|
//------------------------------------------------------------
|
18 |
|
|
//------------------------------------------------------------
|
19 |
|
|
// COPYRIGHT 2000
|
20 |
|
|
// Version du 02/03/2006 à 11H26
|
21 |
|
|
//------------------------------------------------------------
|
22 |
|
|
//------------------------------------------------------------
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
#include "gestionversion.h"
|
26 |
|
|
|
27 |
|
|
#include <vcl.h>
|
28 |
|
|
#include <stdio.h>
|
29 |
|
|
#include <string.h>
|
30 |
|
|
#include <math.h>
|
31 |
francois |
62 |
#include <io.h>
|
32 |
|
|
#include <sys\timeb.h>
|
33 |
|
5 |
#include <algorithm>
|
34 |
francois |
62 |
#include "main.h"
|
35 |
|
5 |
#pragma hdrstop
|
36 |
|
|
|
37 |
francois |
62 |
|
38 |
|
5 |
using namespace std;
|
39 |
|
|
#include "visu.h"
|
40 |
|
|
//---------------------------------------------------------------------------
|
41 |
|
|
#pragma package(smart_init)
|
42 |
|
|
#pragma resource "*.dfm"
|
43 |
|
|
TVisufront *Visufront;
|
44 |
|
|
//---------------------------------------------------------------------------
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
int TVisufront::nombre=0;
|
48 |
|
|
|
49 |
|
|
__fastcall TVisufront::TVisufront(TComponent* Owner)
|
50 |
francois |
62 |
: TForm(Owner),dx(0.0),dy(0.0),zoom(0),arretdemande(0),lire(0),couche(0)
|
51 |
|
5 |
{
|
52 |
|
|
}
|
53 |
|
|
//---------------------------------------------------------------------------
|
54 |
|
|
void __fastcall TVisufront::FormClose(TObject *Sender, TCloseAction &Action)
|
55 |
|
|
{
|
56 |
francois |
62 |
{TPL_MAP_ENTITE<triangle*>::ITERATEUR it;
|
57 |
|
|
for (triangle* element = lsttriangle.get_premier(it); element; element = lsttriangle.get_suivant(it) )
|
58 |
|
|
delete element;}
|
59 |
|
|
{TPL_MAP_ENTITE<segment*>::ITERATEUR it;
|
60 |
|
|
for (segment* element = lstsegment.get_premier(it); element; element = lstsegment.get_suivant(it) )
|
61 |
|
|
delete element;}
|
62 |
|
|
{TPL_MAP_ENTITE<noeud*>::ITERATEUR it;
|
63 |
|
|
for (noeud* element = lstnoeud.get_premier(it); element; element = lstnoeud.get_suivant(it) )
|
64 |
|
|
delete element;}
|
65 |
|
|
lstnoeud.vide();
|
66 |
|
|
lstsegment.vide();
|
67 |
|
|
lsttriangle.vide();
|
68 |
|
5 |
numsegment=0;
|
69 |
|
|
numnoeud=0;
|
70 |
|
|
numtriangle=0;
|
71 |
francois |
62 |
numtriangle2d=0;
|
72 |
|
5 |
Action=caFree;
|
73 |
|
|
TVisufront::nombre=TVisufront::nombre-1;
|
74 |
|
|
}
|
75 |
|
|
//---------------------------------------------------------------------------
|
76 |
|
|
void __fastcall TVisufront::FormCreate(TObject *Sender)
|
77 |
|
|
{
|
78 |
|
|
hdc = GetDC(Handle);
|
79 |
|
|
SetPixelFormatDescriptor();
|
80 |
|
|
hrc = wglCreateContext(hdc);
|
81 |
|
|
if (hrc == NULL)
|
82 |
|
|
ShowMessage(":-)~ hrc == NULL");
|
83 |
|
|
if(wglMakeCurrent(hdc, hrc) == false)
|
84 |
|
|
ShowMessage("Could not MakeCurrent");
|
85 |
|
|
|
86 |
|
|
}
|
87 |
|
|
//---------------------------------------------------------------------------
|
88 |
|
|
void __fastcall TVisufront::SetPixelFormatDescriptor(void)
|
89 |
|
|
{
|
90 |
|
|
PIXELFORMATDESCRIPTOR pfd = {
|
91 |
|
|
sizeof(PIXELFORMATDESCRIPTOR),
|
92 |
|
|
1,
|
93 |
|
|
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
|
94 |
|
|
PFD_TYPE_RGBA,
|
95 |
|
|
24,
|
96 |
|
|
0,0,0,0,0,0,
|
97 |
|
|
0,0,
|
98 |
|
|
0,0,0,0,0,
|
99 |
|
|
32,
|
100 |
|
|
0,
|
101 |
|
|
0,
|
102 |
|
|
PFD_MAIN_PLANE,
|
103 |
|
|
0,
|
104 |
|
|
0,0,
|
105 |
|
|
};
|
106 |
|
|
int PixelFormat = ChoosePixelFormat(hdc, &pfd);
|
107 |
|
|
SetPixelFormat(hdc, PixelFormat, &pfd);
|
108 |
|
|
}
|
109 |
|
|
//---------------------------------------------------------------------------
|
110 |
|
|
|
111 |
|
|
void __fastcall TVisufront::recadre(double dx,double dy,int etat)
|
112 |
|
|
{
|
113 |
|
|
wglMakeCurrent(hdc,hrc);
|
114 |
|
|
GLfloat w = ClientWidth;
|
115 |
|
|
GLfloat h = ClientHeight;
|
116 |
|
|
if (etat==0) glViewport(0, 0, w, h);
|
117 |
|
|
glMatrixMode(GL_PROJECTION);
|
118 |
|
|
glLoadIdentity();
|
119 |
|
|
double d=max(xmax-xmin,ymax-ymin);
|
120 |
|
|
d=max(d,zmax-zmin);
|
121 |
|
|
d=d*1.75/2.;
|
122 |
|
|
double aspect=w/h;
|
123 |
|
|
double xxmin,yymin,xxmax,yymax;
|
124 |
|
|
double xcentre=0.5*(xmin+xmax);
|
125 |
|
|
double ycentre=0.5*(ymin+ymax);
|
126 |
|
|
double zcentre=0.5*(zmin+zmax);
|
127 |
|
|
if (w<h) xxmin=xcentre-d+dx; else xxmin=xcentre-d*aspect+dx;
|
128 |
|
|
if (w<h) yymin=ycentre-d/aspect+dy; else yymin=ycentre-d+dy;
|
129 |
|
|
double zzmin=zcentre-100*d;
|
130 |
|
|
if (w<h) xxmax=xxmin+2.*d; else xxmax=xxmin+2.*d*aspect;
|
131 |
|
|
if (w<h) yymax=yymin+2.*d/aspect; else yymax=yymin+2.*d;
|
132 |
|
|
double zzmax=zzmin+200.*d;
|
133 |
|
|
glOrtho(xxmin,xxmax,yymin,yymax,zzmin,zzmax);
|
134 |
|
|
}
|
135 |
|
|
//---------------------------------------------------------------------------
|
136 |
|
|
void __fastcall TVisufront::FormResize(TObject *Sender)
|
137 |
|
|
{
|
138 |
|
|
int w=ClientWidth;
|
139 |
|
|
int h=ClientHeight;
|
140 |
|
|
while(w==0)
|
141 |
|
|
{
|
142 |
|
|
Width++;
|
143 |
|
|
w=ClientWidth;
|
144 |
|
|
}
|
145 |
|
|
while(h==0)
|
146 |
|
|
{
|
147 |
|
|
Height++;
|
148 |
|
|
h=ClientHeight;
|
149 |
|
|
}
|
150 |
|
|
|
151 |
|
|
recadre(dx,dy,0);
|
152 |
|
|
redess();
|
153 |
|
|
}
|
154 |
|
|
//---------------------------------------------------------------------------
|
155 |
|
|
void __fastcall TVisufront::initvue(void)
|
156 |
|
|
{
|
157 |
|
|
wglMakeCurrent(hdc,hrc);
|
158 |
|
|
glMatrixMode(GL_MODELVIEW);
|
159 |
|
|
glLoadIdentity();
|
160 |
|
|
double xcentre=0.5*(xmin+xmax);
|
161 |
|
|
double ycentre=0.5*(ymin+ymax);
|
162 |
|
|
double zcentre=0.5*(zmin+zmax);
|
163 |
|
|
glTranslated(xcentre,ycentre,zcentre);
|
164 |
francois |
62 |
glRotatef(35.26, 1.0, 0.0, 0.0);
|
165 |
|
|
glRotatef(45., 0.0, 1.0, 0.0);
|
166 |
|
5 |
glRotatef(-90., 1.0, 0.0, 0.0);
|
167 |
francois |
62 |
glRotatef(180., 0.0, 0.0, 1.0);
|
168 |
|
5 |
glTranslated(-xcentre,-ycentre,-zcentre);
|
169 |
|
|
}
|
170 |
|
|
//---------------------------------------------------------------------------
|
171 |
|
|
void __fastcall TVisufront::redess(void)
|
172 |
|
|
{
|
173 |
francois |
62 |
for (int i=0;i<14;i++)
|
174 |
|
|
{
|
175 |
|
|
RGB_r[i]=MainForm->valeurconfig[66+3*i]*255.;
|
176 |
|
|
RGB_g[i]=MainForm->valeurconfig[67+3*i]*255.;
|
177 |
|
|
RGB_b[i]=MainForm->valeurconfig[68+3*i]*255.;
|
178 |
|
|
}
|
179 |
|
5 |
wglMakeCurrent(hdc,hrc);
|
180 |
francois |
62 |
if (FondBlanc1->Checked)
|
181 |
|
|
glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
|
182 |
|
|
else
|
183 |
|
|
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
184 |
|
|
|
185 |
|
5 |
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
186 |
|
|
if (Axe1->Checked) dessineaxe();
|
187 |
|
|
glEnable(GL_DEPTH_TEST);
|
188 |
|
|
glEnable(GL_POLYGON_OFFSET_FILL);
|
189 |
|
|
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
|
190 |
|
|
glBegin(GL_TRIANGLES);
|
191 |
francois |
62 |
//TPL_MAP_ENTITE<triangle*>::ITERATEUR it;
|
192 |
|
|
int numcolor=couche%12+2;
|
193 |
|
|
for (vector<triangle*>::iterator it=lsttriaff.begin() ; it<lsttriaff.end(); it++ )
|
194 |
|
5 |
{
|
195 |
francois |
62 |
// if (element->active==0) continue;
|
196 |
|
|
glColor3f(RGB_r[numcolor]/255.,RGB_g[numcolor]/255.,RGB_b[numcolor]/255.);
|
197 |
|
|
triangle* element=*it;
|
198 |
|
|
glVertex3f(element->n1->x,element->n1->y,element->n1->z);
|
199 |
|
|
glVertex3f(element->n2->x,element->n2->y,element->n2->z);
|
200 |
|
|
glVertex3f(element->n3->x,element->n3->y,element->n3->z);
|
201 |
|
5 |
}
|
202 |
|
|
glEnd();
|
203 |
|
|
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
|
204 |
|
|
glPolygonOffset(1.0,1.0);
|
205 |
|
|
glBegin(GL_TRIANGLES);
|
206 |
|
|
glEdgeFlag(GL_TRUE);
|
207 |
francois |
62 |
for (vector<triangle*>::iterator it=lsttriaff.begin() ; it<lsttriaff.end(); it++ )
|
208 |
|
5 |
{
|
209 |
francois |
62 |
//if (element->active==0) continue;
|
210 |
|
5 |
glColor3f(0.0f,0.0f,1.0f);
|
211 |
francois |
62 |
triangle* element=*it;
|
212 |
|
|
glVertex3f(element->n1->x,element->n1->y,element->n1->z);
|
213 |
|
|
glVertex3f(element->n2->x,element->n2->y,element->n2->z);
|
214 |
|
|
glVertex3f(element->n3->x,element->n3->y,element->n3->z);
|
215 |
|
5 |
}
|
216 |
|
|
glEnd();
|
217 |
|
|
if (Arte1->Checked)
|
218 |
|
|
{
|
219 |
|
|
glBegin(GL_LINES);
|
220 |
francois |
62 |
TPL_MAP_ENTITE<segment*>::ITERATEUR it;
|
221 |
|
|
for (segment* element = lstsegment.get_premier(it); element; element = lstsegment.get_suivant(it) )
|
222 |
|
5 |
{
|
223 |
|
|
glColor3f(1.0f,0.0f,0.0f);
|
224 |
francois |
62 |
glVertex3f(element->n1->x,element->n1->y,element->n1->z);
|
225 |
|
|
glVertex3f(element->n2->x,element->n2->y,element->n2->z);
|
226 |
|
5 |
}
|
227 |
|
|
glEnd();
|
228 |
|
|
glPointSize(4.0);
|
229 |
|
|
glBegin(GL_POINTS);
|
230 |
francois |
62 |
for (segment* element = lstsegment.get_premier(it); element; element = lstsegment.get_suivant(it) )
|
231 |
|
5 |
{
|
232 |
|
|
glColor3f(1.0f,0.0f,0.0f);
|
233 |
francois |
62 |
glVertex3f(element->n1->x,element->n1->y,element->n1->z);
|
234 |
|
|
glVertex3f(element->n2->x,element->n2->y,element->n2->z);
|
235 |
|
5 |
}
|
236 |
|
|
glEnd();
|
237 |
|
|
}
|
238 |
|
|
glFlush();
|
239 |
|
|
SwapBuffers(hdc);
|
240 |
|
|
}
|
241 |
|
|
//---------------------------------------------------------------------------
|
242 |
|
|
|
243 |
|
|
|
244 |
|
|
void __fastcall TVisufront::dessineaxe(void)
|
245 |
|
|
{
|
246 |
|
|
double d=max(xmax-xmin,ymax-ymin);
|
247 |
|
|
d=max(d,zmax-zmin);
|
248 |
|
|
d=d*0.2;
|
249 |
|
|
glLineWidth(1.0f);
|
250 |
|
|
glBegin(GL_LINES);
|
251 |
|
|
glColor3f(0.0f,0.0f,1.0f);
|
252 |
|
|
glVertex3f(0.0,0.0,0.0);
|
253 |
|
|
glVertex3f(d,0.0,0.0);
|
254 |
|
|
glColor3f(1.0f,0.0f,0.0f);
|
255 |
|
|
glVertex3f(0.0,0.0,0.0);
|
256 |
|
|
glVertex3f(0.0,d,0.0);
|
257 |
|
|
glColor3f(1.0f,1.0f,1.0f);
|
258 |
|
|
glVertex3f(0.0,0.0,0.0);
|
259 |
|
|
glVertex3f(0.0,0.0,d);
|
260 |
|
|
glEnd();
|
261 |
|
|
}
|
262 |
|
|
//---------------------------------------------------------------------------
|
263 |
|
|
|
264 |
|
|
void __fastcall TVisufront::FormPaint(TObject *Sender)
|
265 |
|
|
{
|
266 |
|
|
wglMakeCurrent(hdc,hrc);
|
267 |
|
|
redess();
|
268 |
|
|
}
|
269 |
|
|
//---------------------------------------------------------------------------
|
270 |
|
|
|
271 |
|
|
void __fastcall TVisufront::transformation(TObject *Sender, WORD &Key,TShiftState Shift)
|
272 |
|
|
{
|
273 |
|
|
wglMakeCurrent(hdc,hrc);
|
274 |
|
|
GLfloat w = ClientWidth;
|
275 |
|
|
GLfloat h = ClientHeight;
|
276 |
|
|
glMatrixMode(GL_MODELVIEW);
|
277 |
|
|
double un=0.005*min(w,h);
|
278 |
|
|
double xcentre=0.5*(xmin+xmax);
|
279 |
|
|
double ycentre=0.5*(ymin+ymax);
|
280 |
|
|
double zcentre=0.5*(zmin+zmax);
|
281 |
|
|
if (Key==VK_LEFT)
|
282 |
|
|
{
|
283 |
|
|
dx=dx+un;
|
284 |
|
|
recadre(dx,dy,1);
|
285 |
|
|
}
|
286 |
|
|
if (Key==VK_RIGHT)
|
287 |
|
|
{
|
288 |
|
|
dx=dx-un;
|
289 |
|
|
recadre(dx,dy,1);
|
290 |
|
|
}
|
291 |
|
|
if (Key==VK_UP)
|
292 |
|
|
{
|
293 |
|
|
dy=dy-un;
|
294 |
|
|
recadre(dx,dy,1);
|
295 |
|
|
}
|
296 |
|
|
if (Key==VK_DOWN)
|
297 |
|
|
{
|
298 |
|
|
dy=dy+un;
|
299 |
|
|
recadre(dx,dy,1);
|
300 |
|
|
}
|
301 |
|
|
if(Key == VK_F1)
|
302 |
|
|
{
|
303 |
|
|
zoom++;
|
304 |
|
|
glTranslated(xcentre,ycentre,zcentre);
|
305 |
|
|
glScalef(1.1,1.1,1.1);
|
306 |
|
|
glTranslated(-xcentre,-ycentre,-zcentre);
|
307 |
|
|
}
|
308 |
|
|
if(Key == VK_F2)
|
309 |
|
|
{
|
310 |
|
|
zoom--;
|
311 |
|
|
glTranslated(xcentre,ycentre,zcentre);
|
312 |
|
|
glScalef(1./1.1,1./1.1,1./1.1);
|
313 |
|
|
glTranslated(-xcentre,-ycentre,-zcentre);
|
314 |
|
|
}
|
315 |
|
|
if(Key == VK_F3)
|
316 |
|
|
{
|
317 |
|
|
dx=0.;
|
318 |
|
|
dy=0.;
|
319 |
|
|
zoom=0;
|
320 |
|
|
recadre(dx,dy,1);
|
321 |
|
|
initvue();
|
322 |
|
|
}
|
323 |
|
|
if(Key == VK_F4)
|
324 |
|
|
{
|
325 |
|
|
if (zoom>0)
|
326 |
|
|
glScalef(1./pow(1.1,zoom),1./pow(1.1,zoom),1./pow(1.1,zoom));
|
327 |
|
|
if (zoom<0)
|
328 |
|
|
glScalef(pow(1.1,-zoom),pow(1.1,-zoom),pow(1.1,-zoom));
|
329 |
|
|
zoom=0;
|
330 |
|
|
dx=0;
|
331 |
|
|
dy=0;
|
332 |
|
|
recadre(dx,dy,1);
|
333 |
|
|
}
|
334 |
|
|
if(Key == VK_HOME)
|
335 |
|
|
{
|
336 |
|
|
glTranslated(xcentre,ycentre,zcentre);
|
337 |
|
|
glRotatef(-5, 0.0, 1.0, 0.0);
|
338 |
|
|
glTranslated(-xcentre,-ycentre,-zcentre);
|
339 |
|
|
}
|
340 |
|
|
if(Key == VK_END)
|
341 |
|
|
{
|
342 |
|
|
glTranslated(xcentre,ycentre,zcentre);
|
343 |
|
|
glRotatef(5, 0.0, 1.0, 0.0);
|
344 |
|
|
glTranslated(-xcentre,-ycentre,-zcentre);
|
345 |
|
|
}
|
346 |
|
|
if(Key == VK_INSERT)
|
347 |
|
|
{
|
348 |
|
|
glTranslated(xcentre,ycentre,zcentre);
|
349 |
|
|
glRotatef(-5, 1.0, 0.0, 0.0);
|
350 |
|
|
glTranslated(-xcentre,-ycentre,-zcentre);
|
351 |
|
|
}
|
352 |
|
|
if(Key == VK_DELETE)
|
353 |
|
|
{
|
354 |
|
|
glTranslated(xcentre,ycentre,zcentre);
|
355 |
|
|
glRotatef(5, 1.0, 0.0, 0.0);
|
356 |
|
|
glTranslated(-xcentre,-ycentre,-zcentre);
|
357 |
|
|
}
|
358 |
|
|
if(Key == VK_PRIOR)
|
359 |
|
|
{
|
360 |
|
|
glTranslated(xcentre,ycentre,zcentre);
|
361 |
|
|
glRotatef(-5, 0.0, 0.0, 1.0);
|
362 |
|
|
glTranslated(-xcentre,-ycentre,-zcentre);
|
363 |
|
|
}
|
364 |
|
|
if(Key == VK_NEXT)
|
365 |
|
|
{
|
366 |
|
|
glTranslated(xcentre,ycentre,zcentre);
|
367 |
|
|
glRotatef(5, 0.0, 0.0, 1.0);
|
368 |
|
|
glTranslated(-xcentre,-ycentre,-zcentre);
|
369 |
|
|
}
|
370 |
|
|
redess();
|
371 |
|
|
}
|
372 |
|
|
void __fastcall TVisufront::FormKeyDown(TObject *Sender, WORD &Key,
|
373 |
|
|
TShiftState Shift)
|
374 |
|
|
{
|
375 |
|
|
transformation(Sender,Key,Shift);
|
376 |
|
|
}
|
377 |
|
|
//---------------------------------------------------------------------------
|
378 |
|
|
|
379 |
|
|
void __fastcall TVisufront::Timer1Timer(TObject *Sender)
|
380 |
|
|
{
|
381 |
|
|
static int passe=0;
|
382 |
|
|
char mess[10000];
|
383 |
francois |
62 |
lsttriaff.clear();
|
384 |
|
5 |
if (N3D1->Checked)
|
385 |
|
|
{
|
386 |
|
|
static FILE* in;
|
387 |
|
|
AnsiString nomfich=chemin+".frt2";
|
388 |
francois |
62 |
if (passe==0) in=fopen(nomfich.c_str(),"rb");
|
389 |
|
5 |
if (arretdemande)
|
390 |
|
|
{
|
391 |
|
|
passe=0;
|
392 |
|
|
Timer1->Enabled=false;
|
393 |
francois |
62 |
couche=0;
|
394 |
|
|
fclose(in);
|
395 |
|
5 |
arretdemande=0;
|
396 |
francois |
62 |
TPL_MAP_ENTITE<triangle*>::ITERATEUR it;
|
397 |
|
|
//for (triangle* element = lsttriangle.get_premier(it); element; element = lsttriangle.get_suivant(it) )
|
398 |
|
|
// element->active=0;
|
399 |
|
5 |
redess();
|
400 |
|
|
return;
|
401 |
|
|
}
|
402 |
francois |
62 |
// TPL_MAP_ENTITE<triangle*>::ITERATEUR it;
|
403 |
|
|
//for (triangle* element = lsttriangle.get_premier(it); element; element = lsttriangle.get_suivant(it) )
|
404 |
|
|
// element->active=0;
|
405 |
|
|
unsigned long num;
|
406 |
|
5 |
do
|
407 |
|
|
{
|
408 |
francois |
62 |
fread(&num,sizeof(unsigned long),1,in);
|
409 |
|
|
if (feof(in))
|
410 |
|
|
{
|
411 |
|
|
passe=0;
|
412 |
|
|
fclose(in);
|
413 |
|
|
if (!Continue1->Checked) Timer1->Enabled=false;
|
414 |
|
|
couche=0;
|
415 |
|
|
redess();
|
416 |
|
|
return;
|
417 |
|
|
}
|
418 |
|
|
if (num>1) lsttriaff.insert(lsttriaff.end(),lsttriangle.getid(num));
|
419 |
|
5 |
}
|
420 |
francois |
62 |
while (num>1);
|
421 |
|
|
if (num==1) couche++;
|
422 |
|
|
sprintf(mess,"Visualisateur dynamique de front 3D - %s - Couche %d - Itération %d",chemin.c_str(),couche+1,passe);
|
423 |
|
5 |
}
|
424 |
|
|
if (N2D1->Checked)
|
425 |
|
|
{
|
426 |
|
|
if (passe==numtriangle2d)
|
427 |
|
|
{
|
428 |
|
|
passe=0;
|
429 |
|
|
if (!Continue1->Checked) Timer1->Enabled=false;
|
430 |
|
|
return;
|
431 |
|
|
}
|
432 |
|
|
if (arretdemande)
|
433 |
|
|
{
|
434 |
|
|
passe=0;
|
435 |
|
|
Timer1->Enabled=false;
|
436 |
francois |
62 |
TPL_MAP_ENTITE<triangle*>::ITERATEUR it;
|
437 |
|
|
//for (triangle* element = lsttriangle.get_premier(it); element; element = lsttriangle.get_suivant(it) )
|
438 |
|
|
// element->active=0;
|
439 |
|
5 |
arretdemande=0;
|
440 |
francois |
62 |
couche=0;
|
441 |
|
5 |
redess();
|
442 |
|
|
return;
|
443 |
|
|
}
|
444 |
francois |
62 |
int i=0;
|
445 |
|
|
TPL_MAP_ENTITE<triangle*>::ITERATEUR it;
|
446 |
|
|
for (triangle* element = lsttriangle.get_premier(it); element; element = lsttriangle.get_suivant(it) )
|
447 |
|
5 |
{
|
448 |
francois |
62 |
if (i<=passe)
|
449 |
|
|
lsttriaff.insert(lsttriaff.end(),element);
|
450 |
|
5 |
else
|
451 |
francois |
62 |
break;
|
452 |
|
|
i++;
|
453 |
|
5 |
}
|
454 |
|
|
sprintf(mess,"Visualisateur dynamique de front 2D - %s - Itération %d",chemin.c_str(),passe);
|
455 |
|
|
}
|
456 |
|
|
passe++;
|
457 |
|
|
redess();
|
458 |
|
|
Caption=mess;
|
459 |
|
|
}
|
460 |
|
|
//---------------------------------------------------------------------------
|
461 |
|
|
|
462 |
|
|
|
463 |
|
|
void __fastcall TVisufront::Axe1Click(TObject *Sender)
|
464 |
|
|
{
|
465 |
|
|
Axe1->Checked=!Axe1->Checked;
|
466 |
|
|
redess();
|
467 |
|
|
}
|
468 |
|
|
//---------------------------------------------------------------------------
|
469 |
|
|
|
470 |
|
|
void __fastcall TVisufront::Arte1Click(TObject *Sender)
|
471 |
|
|
{
|
472 |
|
|
Arte1->Checked=!Arte1->Checked;
|
473 |
|
|
redess();
|
474 |
|
|
}
|
475 |
|
|
//---------------------------------------------------------------------------
|
476 |
|
|
|
477 |
|
|
void __fastcall TVisufront::Quitter1Click(TObject *Sender)
|
478 |
|
|
{
|
479 |
|
|
Timer1->Enabled=false;
|
480 |
|
|
Close() ;
|
481 |
|
|
}
|
482 |
|
|
//---------------------------------------------------------------------------
|
483 |
|
|
|
484 |
|
|
void __fastcall TVisufront::rapide1Click(TObject *Sender)
|
485 |
|
|
{
|
486 |
|
|
rapide1->Checked=true;
|
487 |
|
|
moyen1->Checked=false;
|
488 |
|
|
lent1->Checked=false;
|
489 |
|
|
extrementlent1->Checked=false;
|
490 |
|
|
Timer1->Interval=1;
|
491 |
|
|
}
|
492 |
|
|
//---------------------------------------------------------------------------
|
493 |
|
|
|
494 |
|
|
void __fastcall TVisufront::moyen1Click(TObject *Sender)
|
495 |
|
|
{
|
496 |
|
|
rapide1->Checked=false;
|
497 |
|
|
moyen1->Checked=true;
|
498 |
|
|
lent1->Checked=false;
|
499 |
|
|
extrementlent1->Checked=false;
|
500 |
|
|
Timer1->Interval=10;
|
501 |
|
|
}
|
502 |
|
|
//---------------------------------------------------------------------------
|
503 |
|
|
|
504 |
|
|
void __fastcall TVisufront::lent1Click(TObject *Sender)
|
505 |
|
|
{
|
506 |
|
|
rapide1->Checked=false;
|
507 |
|
|
moyen1->Checked=false;
|
508 |
|
|
lent1->Checked=true;
|
509 |
|
|
extrementlent1->Checked=false;
|
510 |
|
|
Timer1->Interval=100;
|
511 |
|
|
}
|
512 |
|
|
//---------------------------------------------------------------------------
|
513 |
|
|
|
514 |
|
|
void __fastcall TVisufront::extrementlent1Click(TObject *Sender)
|
515 |
|
|
{
|
516 |
|
|
rapide1->Checked=false;
|
517 |
|
|
moyen1->Checked=false;
|
518 |
|
|
lent1->Checked=false;
|
519 |
|
|
extrementlent1->Checked=true;
|
520 |
|
|
Timer1->Interval=1000;
|
521 |
|
|
|
522 |
|
|
}
|
523 |
|
|
//---------------------------------------------------------------------------
|
524 |
|
|
|
525 |
|
|
void __fastcall TVisufront::Pause1Click(TObject *Sender)
|
526 |
|
|
{
|
527 |
|
|
Pause1->Checked=!Pause1->Checked;
|
528 |
|
|
if (Pause1->Checked) Timer1->Enabled=false; else Timer1->Enabled=true;
|
529 |
|
|
}
|
530 |
|
|
//---------------------------------------------------------------------------
|
531 |
|
|
|
532 |
|
|
void __fastcall TVisufront::Continue1Click(TObject *Sender)
|
533 |
|
|
{
|
534 |
|
|
Continue1->Checked=!Continue1->Checked;
|
535 |
|
|
}
|
536 |
|
|
//---------------------------------------------------------------------------
|
537 |
|
|
|
538 |
|
|
void __fastcall TVisufront::Reprendre1Click(TObject *Sender)
|
539 |
|
|
{
|
540 |
|
|
if (lire==1)
|
541 |
|
|
if ( (N2D1->Checked==true) || (N3D1->Checked==true) )
|
542 |
|
|
Timer1->Enabled=true;
|
543 |
|
|
}
|
544 |
|
|
//---------------------------------------------------------------------------
|
545 |
|
|
|
546 |
|
|
|
547 |
|
|
void __fastcall TVisufront::Ouvrir1Click(TObject *Sender)
|
548 |
|
|
{
|
549 |
|
|
if (OpenDialog1->Execute())
|
550 |
|
|
{
|
551 |
|
|
chemin=OpenDialog1->FileName;
|
552 |
francois |
62 |
FILE* in=fopen(chemin.c_str(),"rt");
|
553 |
|
|
if (in!=NULL)
|
554 |
|
|
{
|
555 |
|
|
std::ftime ft;
|
556 |
|
|
getftime(fileno(in), &ft);
|
557 |
|
|
char mess[1000];
|
558 |
|
|
sprintf(mess,"Heure fichier: %u:%u:%u\n",ft.ft_hour, ft.ft_min,ft.ft_tsec * 2);
|
559 |
|
|
MainForm->StatusBar->Panels->Items[3]->Text=mess;
|
560 |
|
|
sprintf(mess,"Jour fichier: %u/%u/%u\n",ft.ft_month, ft.ft_day,ft.ft_year+1980);
|
561 |
|
|
MainForm->StatusBar->Panels->Items[4]->Text=mess;
|
562 |
|
|
fclose(in);
|
563 |
|
|
}
|
564 |
|
5 |
chemin.Delete(chemin.Length()-3,4);
|
565 |
|
|
Caption="Visualisateur dynamique de front 3D - " + chemin;
|
566 |
|
|
AnsiString nomfich=chemin+".frt1";
|
567 |
francois |
62 |
in=fopen(nomfich.c_str(),"rb");
|
568 |
|
|
fread(&numnoeud,sizeof(int),1,in);
|
569 |
|
|
fread(&numsegment,sizeof(int),1,in);
|
570 |
|
|
fread(&numtriangle2d,sizeof(int),1,in);
|
571 |
|
|
fread(&numtriangle,sizeof(int),1,in);
|
572 |
|
5 |
for (int i=0;i<numnoeud;i++)
|
573 |
|
|
{
|
574 |
francois |
62 |
unsigned num;
|
575 |
|
|
fread(&num,sizeof(unsigned long),1,in);
|
576 |
|
|
double xyz[3];
|
577 |
|
|
fread(xyz,sizeof(double),3,in);
|
578 |
|
|
noeud *n=new noeud;
|
579 |
|
|
n->id=num;
|
580 |
|
|
n->x=xyz[0];
|
581 |
|
|
n->y=xyz[1];
|
582 |
|
|
n->z=xyz[2];
|
583 |
|
|
lstnoeud.ajouter(n);
|
584 |
|
5 |
if (i==0)
|
585 |
|
|
{
|
586 |
francois |
62 |
xmin=n->x;xmax=n->x;
|
587 |
|
|
ymin=n->y;ymax=n->y;
|
588 |
|
|
zmin=n->z;zmax=n->z;
|
589 |
|
5 |
}
|
590 |
|
|
else
|
591 |
|
|
{
|
592 |
francois |
62 |
if (n->x<xmin) xmin=n->x;
|
593 |
|
|
if (n->y<ymin) ymin=n->y;
|
594 |
|
|
if (n->z<zmin) zmin=n->z;
|
595 |
|
|
if (n->x>xmax) xmax=n->x;
|
596 |
|
|
if (n->y>ymax) ymax=n->y;
|
597 |
|
|
if (n->z>zmax) zmax=n->z;
|
598 |
|
5 |
}
|
599 |
|
|
}
|
600 |
francois |
62 |
for (int i=0;i<numsegment;i++)
|
601 |
|
5 |
{
|
602 |
francois |
62 |
unsigned num[3];
|
603 |
|
|
fread(num,sizeof(unsigned long),3,in);
|
604 |
|
|
segment* s=new segment;
|
605 |
|
|
s->id=num[0];
|
606 |
|
|
s->n1=lstnoeud.getid(num[1]);
|
607 |
|
|
s->n2=lstnoeud.getid(num[2]);
|
608 |
|
|
lstsegment.ajouter(s);
|
609 |
|
5 |
}
|
610 |
francois |
62 |
|
611 |
|
|
for (int i=0;i<numtriangle;i++)
|
612 |
|
5 |
{
|
613 |
francois |
62 |
unsigned num[4];
|
614 |
|
|
fread(num,sizeof(unsigned long),4,in);
|
615 |
|
|
triangle* t=new triangle;
|
616 |
|
|
t->id=num[0];
|
617 |
|
|
t->n1=lstnoeud.getid(num[1]);
|
618 |
|
|
t->n2=lstnoeud.getid(num[2]);
|
619 |
|
|
t->n3=lstnoeud.getid(num[3]);
|
620 |
|
|
t->active=0;
|
621 |
|
|
lsttriangle.ajouter(t);
|
622 |
|
5 |
}
|
623 |
|
|
fclose(in);
|
624 |
|
|
glClearColor(0.0f,0.0f,0.0f,0.0f);
|
625 |
|
|
lire=1;
|
626 |
|
|
recadre(dx,dy,0);
|
627 |
|
|
initvue();
|
628 |
|
|
redess();
|
629 |
|
|
N2D1->Checked=false;
|
630 |
|
|
N3D1->Checked=false;
|
631 |
|
|
Timer1->Enabled=false;
|
632 |
|
|
}
|
633 |
|
|
}
|
634 |
|
|
//---------------------------------------------------------------------------
|
635 |
|
|
|
636 |
|
|
void __fastcall TVisufront::N2D1Click(TObject *Sender)
|
637 |
|
|
{
|
638 |
|
|
if (Timer1->Enabled==false)
|
639 |
|
|
{
|
640 |
|
|
N2D1->Checked=true;
|
641 |
|
|
N3D1->Checked=false;
|
642 |
|
|
}
|
643 |
|
|
}
|
644 |
|
|
//---------------------------------------------------------------------------
|
645 |
|
|
|
646 |
|
|
void __fastcall TVisufront::N3D1Click(TObject *Sender)
|
647 |
|
|
{
|
648 |
|
|
if (Timer1->Enabled==false)
|
649 |
|
|
{
|
650 |
|
|
N2D1->Checked=false;
|
651 |
|
|
N3D1->Checked=true;
|
652 |
|
|
}
|
653 |
|
|
}
|
654 |
|
|
//---------------------------------------------------------------------------
|
655 |
|
|
|
656 |
|
|
void __fastcall TVisufront::Arrt1Click(TObject *Sender)
|
657 |
|
|
{
|
658 |
|
|
arretdemande=1;
|
659 |
|
|
}
|
660 |
|
|
//---------------------------------------------------------------------------
|
661 |
|
|
|
662 |
francois |
62 |
void __fastcall TVisufront::FondBlanc1Click(TObject *Sender)
|
663 |
|
|
{
|
664 |
|
|
FondBlanc1->Checked=!FondBlanc1->Checked;
|
665 |
|
|
redess();
|
666 |
|
|
}
|
667 |
|
|
//---------------------------------------------------------------------------
|
668 |
|
|
|