ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/mesh/debug.cpp
Revision: 3
Committed: Tue Jun 12 12:42:51 2007 UTC (17 years, 11 months ago)
File size: 19481 byte(s)
Log Message:

File Contents

# User Rev Content
1 3 //---------------------------------------------------------------------------
2     #include <vcl.h>
3     #pragma hdrstop
4    
5     #include "debug.h"
6     #include "fenetre.h"
7     #include "edition.h"
8     #include "prop.h"
9     #include "s_valeur.h"
10     #include "infopiece.h"
11    
12     //---------------------------------------------------------------------------
13     #pragma package(smart_init)
14     #pragma resource "*.dfm"
15     TFendebug *Fendebug;
16     //---------------------------------------------------------------------------
17     __fastcall TFendebug::TFendebug(TComponent* Owner)
18     : TForm(Owner)
19     {
20     }
21     //---------------------------------------------------------------------------
22     void __fastcall TFendebug::FormClose(TObject *Sender, TCloseAction &Action)
23     {
24     Action=caFree;
25     }
26     //---------------------------------------------------------------------------
27     void __fastcall TFendebug::FormResize(TObject *Sender)
28     {
29     GroupBox1->Top=15;
30     GroupBox1->Left=(int)(0.01*Fendebug->ClientWidth);
31     GroupBox1->Height=(int)(0.99*Fendebug->ClientHeight-GroupBox1->Top);
32     GroupBox1->Width=(int)(0.32*Fendebug->ClientWidth-GroupBox1->Left);
33     GroupBox2->Top=15;
34     GroupBox2->Left=(int)(GroupBox1->Left+GroupBox1->Width+0.01*Fendebug->ClientWidth);
35     GroupBox2->Height=GroupBox1->Height;
36     GroupBox2->Width=GroupBox1->Width;
37     GroupBox3->Top=15;
38     GroupBox3->Left=(int)(GroupBox2->Left+GroupBox2->Width+0.01*Fendebug->ClientWidth);
39     GroupBox3->Height=GroupBox1->Height;
40     GroupBox3->Width=GroupBox1->Width;
41    
42     ListBox1->Top=GroupBox1->Top+2;
43     ListBox1->Left=GroupBox1->Left+2;
44     ListBox1->Height=GroupBox1->Height-5-ListBox1->Top;
45     ListBox1->Width=(int)(0.33333*GroupBox1->Width-4);
46    
47     ListBox2->Width=ListBox1->Width;
48     ListBox2->Top=ListBox1->Top;
49     ListBox2->Left=(int)(GroupBox1->Left+1.8*ListBox1->Width);
50     ListBox2->Height=ListBox1->Height;
51    
52     ListBox3->Top=ListBox1->Top;
53     ListBox3->Left=ListBox1->Left;
54     ListBox3->Height=ListBox1->Height;
55     ListBox3->Width=ListBox1->Width;
56    
57     ListBox4->Top=ListBox1->Top;
58     ListBox4->Left=ListBox2->Left;
59     ListBox4->Height=ListBox1->Height;
60     ListBox4->Width=ListBox1->Width;
61    
62     ListBox5->Top=ListBox1->Top;
63     ListBox5->Left=ListBox1->Left;
64     ListBox5->Height=ListBox1->Height;
65     ListBox5->Width=ListBox1->Width;
66    
67     ListBox6->Top=ListBox1->Top;
68     ListBox6->Left=ListBox2->Left;
69     ListBox6->Height=ListBox1->Height;
70     ListBox6->Width=ListBox1->Width;
71    
72     SpeedButton1->Left=(int)(GroupBox1->Width/2.-22);
73     SpeedButton1->Top=ListBox1->Top;
74    
75     SpeedButton2->Left=SpeedButton1->Left;
76     SpeedButton2->Top=SpeedButton1->Top+2*SpeedButton2->Height;
77    
78     SpeedButton3->Left=SpeedButton2->Left;
79     SpeedButton3->Top=SpeedButton2->Top;
80    
81     SpeedButton4->Left=SpeedButton1->Left;
82     SpeedButton4->Top=SpeedButton1->Top;
83    
84    
85     SpeedButton5->Left=SpeedButton2->Left;
86     SpeedButton5->Top=SpeedButton2->Top;
87    
88     SpeedButton6->Left=SpeedButton1->Left;
89     SpeedButton6->Top=SpeedButton1->Top;
90    
91     SpeedButton7->Left=SpeedButton2->Left;
92     SpeedButton7->Top=SpeedButton1->Top+4*SpeedButton2->Height;
93    
94     SpeedButton8->Left=SpeedButton7->Left;
95     SpeedButton8->Top=SpeedButton7->Top;
96    
97     SpeedButton9->Left=SpeedButton7->Left;
98     SpeedButton9->Top=SpeedButton7->Top;
99    
100     SpeedButton11->Left=(int)(SpeedButton2->Left+0.625*SpeedButton11->Width);
101     SpeedButton11->Top=SpeedButton1->Top+6*SpeedButton2->Height;
102    
103     SpeedButton10->Left=SpeedButton11->Left;
104     SpeedButton10->Top=SpeedButton11->Top;
105    
106     SpeedButton12->Left=SpeedButton11->Left;
107     SpeedButton12->Top=SpeedButton11->Top;
108    
109    
110     SpeedButton14->Left=(int)(SpeedButton11->Left-1.25*SpeedButton14->Width);
111     SpeedButton14->Top=SpeedButton11->Top;
112    
113     SpeedButton13->Left=SpeedButton14->Left;
114     SpeedButton13->Top=SpeedButton14->Top;
115    
116     SpeedButton15->Left=SpeedButton14->Left;
117     SpeedButton15->Top=SpeedButton14->Top;
118    
119     }
120     //---------------------------------------------------------------------------
121     void __fastcall TFendebug::FormCreate(TObject *Sender)
122     {
123     int i;
124     char mess[255];
125    
126     for (i=0;i<Fenp->nb_segment;i++)
127     {
128     sprintf(mess,"%d",i);
129     ListBox1->Items->Add(mess);
130     }
131     for (i=0;i<Fenp->nb_triangle;i++)
132     {
133     sprintf(mess,"%d",i);
134     ListBox3->Items->Add(mess);
135     }
136     for (i=0;i<Fenp->nb_tetra;i++)
137     {
138     sprintf(mess,"%d",i);
139     ListBox5->Items->Add(mess);
140     }
141     }
142     //---------------------------------------------------------------------------
143     void __fastcall TFendebug::SpeedButton4Click(TObject *Sender)
144     {
145     int i,nb_sel,n,num;
146     char mess[255];
147    
148     nb_sel=ListBox3->SelCount;
149     for (i=0,n=0;n<nb_sel;i++)
150     if (ListBox3->Selected[i])
151     {
152     n++;
153     strcpy(mess,ListBox3->Items->Strings[i].c_str());
154     ajoute(ListBox4,mess);
155     sscanf(mess,"%d",&num);
156     Fenp->triangle[num].select=1;
157     }
158     Fenp->Invalidate();
159     }
160     //---------------------------------------------------------------------------
161     void __fastcall TFendebug::SpeedButton3Click(TObject *Sender)
162     {
163     int i,nb_sel,n,num;
164     char mess[255];
165    
166    
167     nb_sel=ListBox4->SelCount;
168     for (i=ListBox4->Items->Count-1,n=0;n<nb_sel;i--)
169     if (ListBox4->Selected[i])
170     {
171     n++;
172     strcpy(mess,ListBox4->Items->Strings[i].c_str());
173     sscanf(mess,"%d",&num);
174     Fenp->triangle[num].select=0;
175     ListBox4->Items->Delete(i);
176     }
177    
178     Fenp->Invalidate();
179     }
180     //---------------------------------------------------------------------------
181     void __fastcall TFendebug::ajoute(TListBox *box,char *mess)
182     {
183     int i;
184     char mess2[255];
185    
186    
187     for (i=0;i<box->Items->Count;i++)
188     {
189     strcpy(mess2,box->Items->Strings[i].c_str());
190     if (strcmp(mess,mess2)==0) return;
191     }
192     box->Items->Add(mess);
193     }
194     //---------------------------------------------------------------------------
195     void __fastcall TFendebug::SpeedButton7Click(TObject *Sender)
196     {
197     int i,j,k,nb_sel,n,num;
198     char mess[255];
199     struct s_triangle *tri,*tri1,*tri2;
200    
201     nb_sel=ListBox4->SelCount;
202     for (i=0,n=0;n<nb_sel;i++)
203     if (ListBox4->Selected[i])
204     {
205     n++;
206     strcpy(mess,ListBox4->Items->Strings[i].c_str());
207     sscanf(mess,"%d",&num);
208     tri=&(Fenp->triangle[num]);
209     for (j=0;j<Fenp->point[Fenp->triangle[num].n1].nb_triangle;j++)
210     for (k=0;k<Fenp->point[Fenp->triangle[num].n2].nb_triangle;k++)
211     {
212     tri1=Fenp->point[Fenp->triangle[num].n1].triangle[j];
213     tri2=Fenp->point[Fenp->triangle[num].n2].triangle[k];
214     sprintf(mess,"%d",tri1->num);
215     if ((tri!=tri1)&& (tri1==tri2))
216     {
217     ajoute(ListBox4,mess);
218     Fenp->triangle[tri1->num].select=1;
219     }
220     }
221     for (j=0;j<Fenp->point[Fenp->triangle[num].n1].nb_triangle;j++)
222     for (k=0;k<Fenp->point[Fenp->triangle[num].n3].nb_triangle;k++)
223     {
224     tri1=Fenp->point[Fenp->triangle[num].n1].triangle[j];
225     tri2=Fenp->point[Fenp->triangle[num].n3].triangle[k];
226     sprintf(mess,"%d",tri1->num);
227     if ((tri!=tri1)&& (tri1==tri2))
228     {
229     ajoute(ListBox4,mess);
230     Fenp->triangle[tri1->num].select=1;
231     }
232    
233     }
234     for (j=0;j<Fenp->point[Fenp->triangle[num].n2].nb_triangle;j++)
235     for (k=0;k<Fenp->point[Fenp->triangle[num].n3].nb_triangle;k++)
236     {
237     tri1=Fenp->point[Fenp->triangle[num].n2].triangle[j];
238     tri2=Fenp->point[Fenp->triangle[num].n3].triangle[k];
239     sprintf(mess,"%d",tri1->num);
240     if ((tri!=tri1)&& (tri1==tri2))
241     {
242     ajoute(ListBox4,mess);
243     Fenp->triangle[tri1->num].select=1;
244     }
245     }
246    
247     }
248     Fenp->Invalidate();
249    
250     }
251     //---------------------------------------------------------------------------
252     void __fastcall TFendebug::SpeedButton8Click(TObject *Sender)
253     {
254     int i,j,nb_sel,n,num;
255     char mess[255];
256     struct s_segment *seg1;
257    
258     nb_sel=ListBox2->SelCount;
259     for (i=0,n=0;n<nb_sel;i++)
260     if (ListBox2->Selected[i])
261     {
262     n++;
263     strcpy(mess,ListBox2->Items->Strings[i].c_str());
264     sscanf(mess,"%d",&num);
265     for (j=0;j<Fenp->point[Fenp->segment[num].n1].nb_segment;j++)
266     {
267     seg1=Fenp->point[Fenp->segment[num].n1].segment[j];
268     sprintf(mess,"%d",seg1->num);
269     ajoute(ListBox2,mess);
270     Fenp->segment[seg1->num].select=1;
271     }
272     for (j=0;j<Fenp->point[Fenp->segment[num].n2].nb_segment;j++)
273     {
274     seg1=Fenp->point[Fenp->segment[num].n2].segment[j];
275     sprintf(mess,"%d",seg1->num);
276     ajoute(ListBox2,mess);
277     Fenp->segment[seg1->num].select=1;
278     }
279     }
280    
281     Fenp->Invalidate();
282     }
283     //---------------------------------------------------------------------------
284    
285     void __fastcall TFendebug::SpeedButton1Click(TObject *Sender)
286     {
287     int i,nb_sel,n,num;
288     char mess[255];
289    
290     nb_sel=ListBox1->SelCount;
291     for (i=0,n=0;n<nb_sel;i++)
292     if (ListBox1->Selected[i])
293     {
294     n++;
295     strcpy(mess,ListBox1->Items->Strings[i].c_str());
296     ajoute(ListBox2,mess);
297     sscanf(mess,"%d",&num);
298     Fenp->segment[num].select=1;
299     }
300     Fenp->Invalidate();
301     }
302     //---------------------------------------------------------------------------
303    
304     void __fastcall TFendebug::SpeedButton2Click(TObject *Sender)
305     {
306     int i,nb_sel,n,num;
307     char mess[255];
308    
309     nb_sel=ListBox2->SelCount;
310     for (i=ListBox2->Items->Count-1,n=0;n<nb_sel;i--)
311     if (ListBox2->Selected[i])
312     {
313     n++;
314     strcpy(mess,ListBox2->Items->Strings[i].c_str());
315     sscanf(mess,"%d",&num);
316     Fenp->segment[num].select=0;
317     ListBox2->Items->Delete(i);
318     }
319    
320    
321     Fenp->Invalidate();
322     }
323     //---------------------------------------------------------------------------
324    
325     void __fastcall TFendebug::SpeedButton6Click(TObject *Sender)
326     {
327     int i,nb_sel,n,num;
328     char mess[255];
329    
330     nb_sel=ListBox5->SelCount;
331     for (i=0,n=0;n<nb_sel;i++)
332     if (ListBox5->Selected[i])
333     {
334     n++;
335     strcpy(mess,ListBox5->Items->Strings[i].c_str());
336     ajoute(ListBox6,mess);
337     sscanf(mess,"%d",&num);
338     Fenp->tetra[num].select=1;
339     }
340    
341     Fenp->Invalidate();
342     }
343     //---------------------------------------------------------------------------
344    
345     void __fastcall TFendebug::SpeedButton5Click(TObject *Sender)
346     {
347     int i,nb_sel,n,num;
348     char mess[255];
349    
350    
351     nb_sel=ListBox6->SelCount;
352     for (i=ListBox6->Items->Count-1,n=0;n<nb_sel;i--)
353     if (ListBox6->Selected[i])
354     {
355     n++;
356     strcpy(mess,ListBox6->Items->Strings[i].c_str());
357     sscanf(mess,"%d",&num);
358     Fenp->tetra[num].select=0;
359     ListBox6->Items->Delete(i);
360     }
361    
362    
363     Fenp->Invalidate();
364     }
365     //---------------------------------------------------------------------------
366    
367     void __fastcall TFendebug::SpeedButton9Click(TObject *Sender)
368     {
369     int i,j,k,l,nb_sel,n,num;
370     char mess[255];
371     struct s_tetra *tet,*tet1,*tet2,*tet3;
372    
373     nb_sel=ListBox6->SelCount;
374     for (i=0,n=0;n<nb_sel;i++)
375     if (ListBox6->Selected[i])
376     {
377     n++;
378     strcpy(mess,ListBox6->Items->Strings[i].c_str());
379     sscanf(mess,"%d",&num);
380     tet=&(Fenp->tetra[num]);
381     for (j=0;j<Fenp->point[Fenp->tetra[num].n1].nb_tetra;j++)
382     for (k=0;k<Fenp->point[Fenp->tetra[num].n2].nb_tetra;k++)
383     for (l=0;l<Fenp->point[Fenp->tetra[num].n3].nb_tetra;l++)
384     {
385     tet1=Fenp->point[Fenp->tetra[num].n1].tetra[j];
386     tet2=Fenp->point[Fenp->tetra[num].n2].tetra[k];
387     tet3=Fenp->point[Fenp->tetra[num].n3].tetra[l];
388     sprintf(mess,"%d",tet1->num);
389     if ((tet!=tet1)&& (tet1==tet2) && (tet1==tet3))
390     {
391     ajoute(ListBox6,mess);
392     Fenp->tetra[tet1->num].select=1;
393     }
394     }
395     for (j=0;j<Fenp->point[Fenp->tetra[num].n1].nb_tetra;j++)
396     for (k=0;k<Fenp->point[Fenp->tetra[num].n2].nb_tetra;k++)
397     for (l=0;l<Fenp->point[Fenp->tetra[num].n4].nb_tetra;l++)
398     {
399     tet1=Fenp->point[Fenp->tetra[num].n1].tetra[j];
400     tet2=Fenp->point[Fenp->tetra[num].n2].tetra[k];
401     tet3=Fenp->point[Fenp->tetra[num].n4].tetra[l];
402     sprintf(mess,"%d",tet1->num);
403     if ((tet!=tet1)&& (tet1==tet2) && (tet1==tet3))
404     {
405     ajoute(ListBox6,mess);
406     Fenp->tetra[tet1->num].select=1;
407     }
408     }
409     for (j=0;j<Fenp->point[Fenp->tetra[num].n1].nb_tetra;j++)
410     for (k=0;k<Fenp->point[Fenp->tetra[num].n3].nb_tetra;k++)
411     for (l=0;l<Fenp->point[Fenp->tetra[num].n4].nb_tetra;l++)
412     {
413     tet1=Fenp->point[Fenp->tetra[num].n1].tetra[j];
414     tet2=Fenp->point[Fenp->tetra[num].n3].tetra[k];
415     tet3=Fenp->point[Fenp->tetra[num].n4].tetra[l];
416     sprintf(mess,"%d",tet1->num);
417     if ((tet!=tet1)&& (tet1==tet2) && (tet1==tet3))
418     {
419     ajoute(ListBox6,mess);
420     Fenp->tetra[tet1->num].select=1;
421     }
422     }
423     for (j=0;j<Fenp->point[Fenp->tetra[num].n2].nb_tetra;j++)
424     for (k=0;k<Fenp->point[Fenp->tetra[num].n3].nb_tetra;k++)
425     for (l=0;l<Fenp->point[Fenp->tetra[num].n4].nb_tetra;l++)
426     {
427     tet1=Fenp->point[Fenp->tetra[num].n2].tetra[j];
428     tet2=Fenp->point[Fenp->tetra[num].n3].tetra[k];
429     tet3=Fenp->point[Fenp->tetra[num].n4].tetra[l];
430     sprintf(mess,"%d",tet1->num);
431     if ((tet!=tet1)&& (tet1==tet2) && (tet1==tet3))
432     {
433     ajoute(ListBox6,mess);
434     Fenp->tetra[tet1->num].select=1;
435     }
436     }
437    
438     }
439    
440     Fenp->Invalidate();
441     }
442     //---------------------------------------------------------------------------
443    
444     void __fastcall TFendebug::Editeur1Click(TObject *Sender)
445     {
446     Application->CreateForm(__classid(TEditeur), &Editeur);
447     Editeur->Show();
448    
449     }
450     //---------------------------------------------------------------------------
451    
452    
453    
454     void __fastcall TFendebug::SpeedButton11Click(TObject *Sender)
455     {
456    
457    
458     if (ListBox4->SelCount<1)
459     {
460     MessageBox(Handle,"Selection Vide", "Erreur !!!!", 0);
461     }
462     else
463     {
464     type=3;
465     type2=2;
466     Application->CreateForm(__classid(TPropriete), &Propriete);
467     Propriete->Left=(int)(0.5*Screen->Width-0.5*Propriete->Width);
468     Propriete->Top=(int)(0.5*Screen->Height-0.5*Propriete->Height);
469     Propriete->ShowModal();
470     }
471     }
472     //---------------------------------------------------------------------------
473    
474     void __fastcall TFendebug::SpeedButton12Click(TObject *Sender)
475     {
476     if (ListBox6->SelCount<1)
477     {
478     MessageBox(Handle,"Selection Vide", "Erreur !!!!", 0);
479     }
480     else
481     {
482     type=4;
483     type2=2;
484     Application->CreateForm(__classid(TPropriete), &Propriete);
485     Propriete->Left=(int)(0.5*Screen->Width-0.5*Propriete->Width);
486     Propriete->Top=(int)(0.5*Screen->Height-0.5*Propriete->Height);
487     Propriete->ShowModal();
488     }
489    
490     }
491     //---------------------------------------------------------------------------
492    
493     void __fastcall TFendebug::SpeedButton10Click(TObject *Sender)
494     {
495     if (ListBox2->SelCount<1)
496     {
497     MessageBox(Handle,"Selection Vide", "Erreur !!!!", 0);
498     }
499     else
500     {
501     type=2;
502     type2=2;
503     Application->CreateForm(__classid(TPropriete), &Propriete);
504     Propriete->Left=(int)(0.5*Screen->Width-0.5*Propriete->Width);
505     Propriete->Top=(int)(0.5*Screen->Height-0.5*Propriete->Height);
506     Propriete->ShowModal();
507     }
508    
509     }
510     //---------------------------------------------------------------------------
511    
512     void __fastcall TFendebug::SpeedButton13Click(TObject *Sender)
513     {
514     if (ListBox1->SelCount<1)
515     {
516     MessageBox(Handle,"Selection Vide", "Erreur !!!!", 0);
517     }
518     else
519     {
520     type=2;
521     type2=1;
522     Application->CreateForm(__classid(TPropriete), &Propriete);
523     Propriete->Left=(int)(0.5*Screen->Width-0.5*Propriete->Width);
524     Propriete->Top=(int)(0.5*Screen->Height-0.5*Propriete->Height);
525     Propriete->ShowModal();
526     }
527    
528     }
529     //---------------------------------------------------------------------------
530    
531     void __fastcall TFendebug::SpeedButton14Click(TObject *Sender)
532     {
533     if (ListBox3->SelCount<1)
534     {
535     MessageBox(Handle,"Selection Vide", "Erreur !!!!", 0);
536     }
537     else
538     {
539     type=3;
540     type2=1;
541     Application->CreateForm(__classid(TPropriete), &Propriete);
542     Propriete->Left=(int)(0.5*Screen->Width-0.5*Propriete->Width);
543     Propriete->Top=(int)(0.5*Screen->Height-0.5*Propriete->Height);
544     Propriete->ShowModal();
545     }
546     }
547     //---------------------------------------------------------------------------
548    
549     void __fastcall TFendebug::SpeedButton15Click(TObject *Sender)
550     {
551     if (ListBox5->SelCount<1)
552     {
553     MessageBox(Handle,"Selection Vide", "Erreur !!!!", 0);
554     }
555     else
556     {
557     type=4;
558     type2=1;
559     Application->CreateForm(__classid(TPropriete), &Propriete);
560     Propriete->Left=(int)(0.5*Screen->Width-0.5*Propriete->Width);
561     Propriete->Top=(int)(0.5*Screen->Height-0.5*Propriete->Height);
562     Propriete->ShowModal();
563     }
564    
565     }
566     //---------------------------------------------------------------------------
567    
568     void __fastcall TFendebug::caractristiquedelapice1Click(TObject *Sender)
569     {
570     Application->CreateForm(__classid(TInfo_piece), &Info_piece);
571     Info_piece->Left=Fenp->Left+29;
572     Info_piece->Top=Fenp->Top+37;
573     Info_piece->ShowModal();
574     }
575     //---------------------------------------------------------------------------
576    
577    
578     void __fastcall TFendebug::Imprimer1Click(TObject *Sender)
579     {
580     char mess[255];
581    
582     strcpy(Fenp->info,"Entrez la dimension du graphique en pourcentage de la feuille ?");
583     Valeur->Edit1->Text="100";
584     Valeur->ShowModal();
585     strcpy(mess,Valeur->Edit1->Text.c_str());
586     sscanf(mess,"%f",&(Fenp->rapport));
587     Fenp->rapport=Fenp->rapport/100.;
588     if (PrintDialog1->Execute()) Fenp->imprime();
589     }
590     //---------------------------------------------------------------------------
591    
592     void __fastcall TFendebug::Configuration1Click(TObject *Sender)
593     {
594     PrinterSetupDialog1->Execute();
595     }
596     //---------------------------------------------------------------------------
597