ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/app/VMM/VMM/win32/visuwin.cpp
Revision: 56
Committed: Fri Sep 28 20:22:10 2007 UTC (17 years, 11 months ago) by francois
File size: 209158 byte(s)
Log Message:
version des executables a la fin de l ete 2007 ---> mailleur adaptatif + mailleur 3d + zone de maille actif

File Contents

# Content
1 //------------------------------------------------------------
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 // visuwin.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 <io.h>
29 #pragma hdrstop
30 #include "magicform.h"
31 #include "main.h"
32 #include "visuwin.h"
33 #include "veriwin.h"
34 #include "visuctt.h"
35 #include "visuarbre.h"
36 #include "config.h"
37 #include "ccfwin.h"
38 #include "carte3dform.h"
39 #include "matwin.h"
40 #include "importcosmos.h"
41 #include "importcarte.h"
42 #include "tpl_grille.h"
43 #include "ot_boite_3d.h"
44 #include "visuparametrique.h"
45 #include "solveur.h"
46 #include "recons.h"
47 #include "mg_export.h"
48
49 //---------------------------------------------------------------------------
50 #pragma package(smart_init)
51 #pragma resource "*.dfm"
52 TVisuWinform *VisuWinform;
53 //---------------------------------------------------------------------------
54 __fastcall TVisuWinform::TVisuWinform(TComponent* Owner)
55 : TForm(Owner),zoom(0),dx(0.0),dy(0.0),debut_trans(false),shrink(0),facteur_shrink(0.8),qualite(0),render(0),axe(0),noeud(0),affnoeud(0),affmaille(0),maille(7),debut_rot(0)
56 {
57 }
58 //---------------------------------------------------------------------------
59 void __fastcall TVisuWinform::FormClose(TObject *Sender,
60 TCloseAction &Action)
61 {
62 MainForm->ToolBar1->Visible=false;
63 MainForm->ToolBar3->Visible=false;
64 lst_visu.clear();
65 if (gest!=NULL) delete gest;
66 MainForm->StatusBar->Panels->Items[3]->Text="";
67 MainForm->StatusBar->Panels->Items[4]->Text="";
68 Action=caFree;
69 }
70 //---------------------------------------------------------------------------
71
72 void __fastcall TVisuWinform::FormActivate(TObject *Sender)
73 {
74 MainForm->ToolBar1->Visible=true;
75 MainForm->ToolBar3->Visible=true;
76 MainForm->activewinform=this;
77 MainForm->ToolButton6->ImageIndex=iconeactive;
78 FILE* in=fopen(Caption.c_str(),"rt");
79 if (in!=NULL)
80 {
81 std::ftime ft;
82 getftime(fileno(in), &ft);
83 char mess[1000];
84 sprintf(mess,"Heure fichier: %02u:%02u:%02u\n",ft.ft_hour, ft.ft_min,ft.ft_tsec * 2);
85 MainForm->StatusBar->Panels->Items[3]->Text=mess;
86 sprintf(mess,"Jour fichier: %02u/%02u/%02u\n",ft.ft_day, ft.ft_month,ft.ft_year+1980);
87 MainForm->StatusBar->Panels->Items[4]->Text=mess;
88 fclose(in);
89 }
90 }
91 //---------------------------------------------------------------------------
92
93 void __fastcall TVisuWinform::FormDeactivate(TObject *Sender)
94 {
95 MainForm->ToolBar1->Visible=false;
96 MainForm->ToolBar3->Visible=false;
97 MainForm->activewinform=NULL;
98 iconeactive=MainForm->ToolButton6->ImageIndex;
99 MainForm->StatusBar->Panels->Items[3]->Text="";
100 MainForm->StatusBar->Panels->Items[4]->Text="";
101 }
102 //---------------------------------------------------------------------------
103
104
105 void __fastcall TVisuWinform::lancermagicExecute(TObject *Sender)
106 {
107 TVisuMagicform *Child;
108 Child = new TVisuMagicform(Application,MainForm);
109 Child->Caption=Caption;
110 FILE* in=fopen(Caption.c_str(),"rt");
111 if (in!=NULL)
112 {
113 std::ftime ft;
114 getftime(fileno(in), &ft);
115 char mess[1000];
116 sprintf(mess,"Heure fichier: %02u:%02u:%02u\n",ft.ft_hour, ft.ft_min,ft.ft_tsec * 2);
117 MainForm->StatusBar->Panels->Items[3]->Text=mess;
118 sprintf(mess,"Jour fichier: %02u/%02u/%02u\n",ft.ft_day, ft.ft_month,ft.ft_year+1980);
119 MainForm->StatusBar->Panels->Items[4]->Text=mess;
120 fclose(in);
121 }
122 }
123 //---------------------------------------------------------------------------
124
125
126 void __fastcall TVisuWinform::miseajourarbre(void)
127 {
128 int nb_geometrie=gest->get_nb_mg_geometrie();
129 int nb_maillage=gest->get_nb_mg_maillage();
130 int nb_fem_maillage=gest->get_nb_fem_maillage();
131 TreeView1->Items->Clear();
132 TreeView1->Items->Add(NULL,"Modèle MAGiC");
133 TTreeNode *root = TreeView1->Items->Item[0];
134 root->ImageIndex=7;
135 root->SelectedIndex=7;
136 root->StateIndex=7;
137 TTreeNode *rootg= TreeView1->Items->AddChild(root,"Géométrie");
138 rootg->ImageIndex=7;
139 rootg->SelectedIndex=7;
140 rootg->StateIndex=7;
141 for (int i=0;i<nb_geometrie;i++)
142 {
143 MG_GEOMETRIE* mggeo=gest->get_mg_geometrie(i);
144 char mess[100];
145 sprintf(mess,"%lu",mggeo->get_id());
146 TTreeNode* georoot=TreeView1->Items->AddChild(rootg,mess);
147 georoot->ImageIndex=7;
148 georoot->SelectedIndex=7;
149 georoot->StateIndex=7;
150 TTreeNode* nodvol=TreeView1->Items->AddChild(georoot,"Volume");
151 nodvol->ImageIndex=7;
152 nodvol->SelectedIndex=7;
153 nodvol->StateIndex=7;
154 int nbvol=mggeo->get_nb_mg_volume();
155 for (int j=0;j<nbvol;j++)
156 {
157 MG_VOLUME* mgvol=mggeo->get_mg_volume(j);
158 char mess[100];
159 sprintf(mess,"%lu",mgvol->get_id());
160 TTreeNode* node=TreeView1->Items->AddChild(nodvol,mess);
161 node->ImageIndex=-1;
162 node->SelectedIndex=-1;
163 node->StateIndex=-1;
164 }
165 TTreeNode* nodfac=TreeView1->Items->AddChild(georoot,"Face");
166 nodfac->ImageIndex=7;
167 nodfac->SelectedIndex=7;
168 nodfac->StateIndex=7;
169 int nbface=mggeo->get_nb_mg_face();
170 for (int j=0;j<nbface;j++)
171 {
172 MG_FACE* mgface=mggeo->get_mg_face(j);
173 char mess[100];
174 sprintf(mess,"%lu",mgface->get_id());
175 TTreeNode* node=TreeView1->Items->AddChild(nodfac,mess);
176 node->ImageIndex=-1;
177 node->SelectedIndex=-1;
178 node->StateIndex=-1;
179 }
180 TTreeNode* nodare=TreeView1->Items->AddChild(georoot,"Arête");
181 nodare->ImageIndex=7;
182 nodare->SelectedIndex=7;
183 nodare->StateIndex=7;
184 int nbare=mggeo->get_nb_mg_arete();
185 for (int j=0;j<nbare;j++)
186 {
187 MG_ARETE* mgare=mggeo->get_mg_arete(j);
188 char mess[100];
189 sprintf(mess,"%lu",mgare->get_id());
190 TTreeNode* node=TreeView1->Items->AddChild(nodare,mess);
191 node->ImageIndex=-1;
192 node->SelectedIndex=-1;
193 node->StateIndex=-1;
194 }
195 TTreeNode* nodsom=TreeView1->Items->AddChild(georoot,"Sommet");
196 nodsom->ImageIndex=7;
197 nodsom->SelectedIndex=7;
198 nodsom->StateIndex=7;
199 int nbsommet=mggeo->get_nb_mg_sommet();
200 for (int j=0;j<nbsommet;j++)
201 {
202 MG_SOMMET* mgsom=mggeo->get_mg_sommet(j);
203 char mess[100];
204 sprintf(mess,"%lu",mgsom->get_id());
205 TTreeNode* node=TreeView1->Items->AddChild(nodsom,mess);
206 node->ImageIndex=-1;
207 node->SelectedIndex=-1;
208 node->StateIndex=-1;
209 }
210 }
211 TTreeNode *rootm= TreeView1->Items->AddChild(root,"Maillage géométrique");
212 rootm->ImageIndex=7;
213 rootm->SelectedIndex=7;
214 rootm->StateIndex=7;
215 for (int i=0;i<nb_maillage;i++)
216 {
217 MG_MAILLAGE* mgmai=gest->get_mg_maillage(i);
218 char mess[100];
219 sprintf(mess,"%lu",mgmai->get_id());
220 TTreeNode* mairoot=TreeView1->Items->AddChild(rootm,mess);
221 mairoot->ImageIndex=7;
222 mairoot->SelectedIndex=7;
223 mairoot->StateIndex=7;
224 TTreeNode* node=TreeView1->Items->AddChild(mairoot,"Maillage 1D");
225 node->ImageIndex=-1;
226 node->SelectedIndex=-1;
227 node->StateIndex=-1;
228 node=TreeView1->Items->AddChild(mairoot,"Maillage 2D");
229 node->ImageIndex=-1;
230 node->SelectedIndex=-1;
231 node->StateIndex=-1;
232 node=TreeView1->Items->AddChild(mairoot,"Maillage 3D");
233 node->ImageIndex=-1;
234 node->SelectedIndex=-1;
235 node->StateIndex=-1;
236 }
237 TTreeNode *rootmfem=TreeView1->Items->AddChild(root,"Maillage FEM");
238 rootmfem->ImageIndex=7;
239 rootmfem->SelectedIndex=7;
240 rootmfem->StateIndex=7;
241 for (int i=0;i<nb_fem_maillage;i++)
242 {
243 FEM_MAILLAGE* femmai=gest->get_fem_maillage(i);
244 char mess[100];
245 sprintf(mess,"%lu",femmai->get_id());
246 TTreeNode* mairoot=TreeView1->Items->AddChild(rootmfem,mess);
247 mairoot->ImageIndex=7;
248 mairoot->SelectedIndex=7;
249 mairoot->StateIndex=7;
250 TTreeNode* node=TreeView1->Items->AddChild(mairoot,"Maillage 1D");
251 node->ImageIndex=-1;
252 node->SelectedIndex=-1;
253 node->StateIndex=-1;
254 node=TreeView1->Items->AddChild(mairoot,"Maillage 2D");
255 node->ImageIndex=-1;
256 node->SelectedIndex=-1;
257 node->StateIndex=-1;
258 node=TreeView1->Items->AddChild(mairoot,"Maillage 3D");
259 node->ImageIndex=-1;
260 node->SelectedIndex=-1;
261 node->StateIndex=-1;
262 }
263 changeimage(rootg,46);
264 initliste();
265 ComboBox1->Clear();
266 int nb=gest->get_nb_mg_solution();
267 for (int i=0;i<nb;i++)
268 {
269 MG_SOLUTION* sol=gest->get_mg_solution(i);
270 ComboBox1->Items->Add(sol->get_nom().c_str());
271 }
272 nb=gest->get_nb_fem_solution();
273 for (int i=0;i<nb;i++)
274 {
275 FEM_SOLUTION* sol=gest->get_fem_solution(i);
276 ComboBox1->Items->Add(sol->get_nom().c_str());
277 }
278 }
279
280 void __fastcall TVisuWinform::initliste(void)
281 {
282 lst_face.vide();
283 lst_arete.vide();
284 lst_sommet.vide();
285 lst_volume.vide();
286 lst_m1d.vide();
287 lst_m2d.vide();
288 lst_m3d.vide();
289 lst_segment.clear();
290 lst_triangle.clear();
291 lst_tetra.clear();
292 lst_noeud.clear();
293 lst_m1d_fem.vide();
294 lst_m2d_fem.vide();
295 lst_m3d_fem.vide();
296 lst_segment_fem.clear();
297 lst_triangle_fem.clear();
298 lst_tetra_fem.clear();
299 lst_noeud_fem.clear();
300 TTreeNode *root = TreeView1->Items->Item[0];
301 TTreeNode *rootg = root->Item[0];
302 int nb_geo=rootg->Count;
303 if (nb_geo>0)
304 {
305 for (int i=0;i<nb_geo;i++)
306 {
307 TTreeNode *geo = rootg->Item[i];
308 MG_GEOMETRIE* mggeo=gest->get_mg_geometrieid(atol(geo->Text.c_str()));
309 TTreeNode *geovol = geo->Item[0];
310 int nb=geovol->Count;
311 for (int j=0;j<nb;j++)
312 {
313 TTreeNode *node=geovol->Item[j];
314 if (node->ImageIndex==46)
315 {
316 MG_VOLUME* mgvol=mggeo->get_mg_volumeid(atol(node->Text.c_str()));
317 lst_volume.ajouter(mgvol);
318 }
319 }
320 TTreeNode *geoface = geo->Item[1];
321 nb=geoface->Count;
322 for (int j=0;j<nb;j++)
323 {
324 TTreeNode *node=geoface->Item[j];
325 if (node->ImageIndex==46)
326 {
327 MG_FACE* mgfac=mggeo->get_mg_faceid(atol(node->Text.c_str()));
328 lst_face.ajouter(mgfac);
329 }
330 }
331 TTreeNode *geoarete = geo->Item[2];
332 nb=geoarete->Count;
333 for (int j=0;j<nb;j++)
334 {
335 TTreeNode *node=geoarete->Item[j];
336 if (node->ImageIndex==46)
337 {
338 MG_ARETE* mgarete=mggeo->get_mg_areteid(atol(node->Text.c_str()));
339 lst_arete.ajouter(mgarete);
340 }
341 }
342 TTreeNode *geosommet = geo->Item[3];
343 nb=geosommet->Count;
344 for (int j=0;j<nb;j++)
345 {
346 TTreeNode *node=geosommet->Item[j];
347 if (node->ImageIndex==46)
348 {
349 MG_SOMMET* mgsommet=mggeo->get_mg_sommetid(atol(node->Text.c_str()));
350 lst_sommet.ajouter(mgsommet);
351 }
352 }
353
354 }
355
356 TTreeNode *rootm = root->Item[1];
357 int nb_mai=rootm->Count;
358 for (int i=0;i<nb_mai;i++)
359 {
360 TTreeNode *mai = rootm->Item[i];
361 MG_MAILLAGE* mgmai=gest->get_mg_maillageid(atol(mai->Text.c_str()));
362 if ((ListBox1->ItemIndex!=-1) && (CheckBox1->Checked==true) )
363 {
364 MG_SOLUTION* sol=gest->get_mg_solution(ComboBox1->ItemIndex);
365 if (sol==NULL) continue;
366 unsigned long idmai=sol->get_maillage()->get_id();
367 if (mgmai->get_id()!=idmai) continue;
368 }
369 TTreeNode *mai1d = mai->Item[0];
370 if (mai1d->ImageIndex==46) lst_m1d.ajouter(mgmai);
371 TTreeNode *mai2d = mai->Item[1];
372 if (mai2d->ImageIndex==46) lst_m2d.ajouter(mgmai);
373 TTreeNode *mai3d = mai->Item[2];
374 if (mai3d->ImageIndex==46) lst_m3d.ajouter(mgmai);
375 }
376
377 TTreeNode *rootmfem = root->Item[2];
378 int nb_mai_fem=rootmfem->Count;
379 for (int i=0;i<nb_mai_fem;i++)
380 {
381 TTreeNode *mai = rootmfem->Item[i];
382 FEM_MAILLAGE* femmai=gest->get_fem_maillageid(atol(mai->Text.c_str()));
383 if ((ListBox1->ItemIndex!=-1) && (CheckBox1->Checked==true) )
384 {
385 FEM_SOLUTION* sol=gest->get_fem_solution(ComboBox1->ItemIndex-gest->get_nb_mg_solution());
386 if (sol==NULL) continue;
387 unsigned long idmai=sol->get_maillage()->get_id();
388 if (femmai->get_id()!=idmai) continue;
389 }
390 TTreeNode *mai1d = mai->Item[0];
391 if (mai1d->ImageIndex==46) lst_m1d_fem.ajouter(femmai);
392 TTreeNode *mai2d = mai->Item[1];
393 if (mai2d->ImageIndex==46) lst_m2d_fem.ajouter(femmai);
394 TTreeNode *mai3d = mai->Item[2];
395 if (mai3d->ImageIndex==46) lst_m3d_fem.ajouter(femmai);
396 }
397
398 for (int i=0;i<lst_volume.get_nb();i++)
399 {
400 MG_VOLUME* mgvol=lst_volume.get(i);
401 int nb_m3d=lst_m3d.get_nb();
402 TPL_SET<MG_ELEMENT_MAILLAGE*>::ITERATEUR it_tet;
403 for (MG_TETRA* mgtet=(MG_TETRA*)mgvol->get_lien_maillage()->get_premier(it_tet);mgtet;mgtet=(MG_TETRA*)mgvol->get_lien_maillage()->get_suivant(it_tet))
404 {
405 int ok=0;
406 for (int k=0;k<nb_m3d;k++)
407 {
408 MG_MAILLAGE* mgmai=lst_m3d.get(k);
409 MG_TETRA* tetemp=mgmai->get_mg_tetraid(mgtet->get_id());
410 if (tetemp!=NULL) ok=1;
411 }
412 if (ok==1)
413 {
414 lst_tetra.insert(lst_tetra.end(),mgtet);
415 MG_NOEUD* noeud1=mgtet->get_noeud1();
416 MG_NOEUD* noeud2=mgtet->get_noeud2();
417 MG_NOEUD* noeud3=mgtet->get_noeud3();
418 MG_NOEUD* noeud4=mgtet->get_noeud4();
419 lst_noeud.insert(lst_noeud.end(),noeud1);
420 lst_noeud.insert(lst_noeud.end(),noeud2);
421 lst_noeud.insert(lst_noeud.end(),noeud3);
422 lst_noeud.insert(lst_noeud.end(),noeud4);
423 }
424 }
425 int nb_tet_fem=mgvol->get_lien_fem_maillage()->get_nb();
426 int nb_m3d_fem=lst_m3d_fem.get_nb();
427 for (int j=0;j<nb_tet_fem;j++)
428 {
429 FEM_TETRA* femtet=(FEM_TETRA*)mgvol->get_lien_fem_maillage()->get(j);
430 int ok=0;
431 for (int k=0;k<nb_m3d_fem;k++)
432 {
433 FEM_MAILLAGE* femmai=lst_m3d_fem.get(k);
434 FEM_TETRA* tetemp=femmai->get_fem_tetraid(femtet->get_id());
435 if (tetemp!=NULL) ok=1;
436 }
437 if (ok==1)
438 {
439 lst_tetra_fem.insert(lst_tetra_fem.end(),femtet);
440 int nb_noeud=femtet->get_nb_fem_noeud();
441 for (int k=0;k<nb_noeud;k++)
442 {
443 FEM_NOEUD* noeud=femtet->get_fem_noeud(k);
444 lst_noeud_fem.insert(lst_noeud_fem.end(),noeud);
445 }
446 }
447 }
448 }
449 for (int i=0;i<lst_face.get_nb();i++)
450 {
451 MG_FACE* mgface=lst_face.get(i);
452 int nb_m2d=lst_m2d.get_nb();
453 TPL_SET<MG_ELEMENT_MAILLAGE*>::ITERATEUR it_tri;
454 for (MG_TRIANGLE* mgtri=(MG_TRIANGLE*)mgface->get_lien_maillage()->get_premier(it_tri);mgtri;mgtri=(MG_TRIANGLE*)mgface->get_lien_maillage()->get_suivant(it_tri))
455 {
456
457 int ok=0;
458 for (int k=0;k<nb_m2d;k++)
459 {
460 MG_MAILLAGE* mgmai=lst_m2d.get(k);
461 MG_TRIANGLE* tritemp=mgmai->get_mg_triangleid(mgtri->get_id());
462 if (tritemp!=NULL) ok=1;
463 }
464 if (ok==1)
465 {
466 lst_triangle.insert(lst_triangle.end(),mgtri);
467 MG_NOEUD* noeud1=mgtri->get_noeud1();
468 MG_NOEUD* noeud2=mgtri->get_noeud2();
469 MG_NOEUD* noeud3=mgtri->get_noeud3();
470 lst_noeud.insert(lst_noeud.end(),noeud1);
471 lst_noeud.insert(lst_noeud.end(),noeud2);
472 lst_noeud.insert(lst_noeud.end(),noeud3);
473 }
474 }
475 int nb_tri_fem=mgface->get_lien_fem_maillage()->get_nb();
476 int nb_m2d_fem=lst_m2d_fem.get_nb();
477 for (int j=0;j<nb_tri_fem;j++)
478 {
479 FEM_TRIANGLE* femtri=(FEM_TRIANGLE*)mgface->get_lien_fem_maillage()->get(j);
480 int ok=0;
481 for (int k=0;k<nb_m2d_fem;k++)
482 {
483 FEM_MAILLAGE* femmai=lst_m2d_fem.get(k);
484 FEM_TRIANGLE* tritemp=femmai->get_fem_triangleid(femtri->get_id());
485 if (tritemp!=NULL) ok=1;
486 }
487 if (ok==1)
488 {
489 lst_triangle_fem.insert(lst_triangle_fem.end(),femtri);
490 int nb_noeud=femtri->get_nb_fem_noeud();
491 for (int k=0;k<nb_noeud;k++)
492 {
493 FEM_NOEUD* noeud=femtri->get_fem_noeud(k);
494 lst_noeud_fem.insert(lst_noeud_fem.end(),noeud);
495 }
496 }
497 }
498 }
499 for (int i=0;i<lst_arete.get_nb();i++)
500 {
501 MG_ARETE* mgarete=lst_arete.get(i);
502 int nb_m1d=lst_m1d.get_nb();
503 TPL_SET<MG_ELEMENT_MAILLAGE*>::ITERATEUR it_are;
504 for (MG_SEGMENT* mgsegment=(MG_SEGMENT*)mgarete->get_lien_maillage()->get_premier(it_are);mgsegment;mgsegment=(MG_SEGMENT*)mgarete->get_lien_maillage()->get_suivant(it_are))
505 {
506 int ok=0;
507 for (int k=0;k<nb_m1d;k++)
508 {
509 MG_MAILLAGE* mgmai=lst_m1d.get(k);
510 MG_SEGMENT* segtemp=mgmai->get_mg_segmentid(mgsegment->get_id());
511 if (segtemp!=NULL) ok=1;
512 }
513 if (ok==1)
514 {
515 lst_segment.insert(lst_segment.end(),mgsegment);
516 MG_NOEUD* noeud1=mgsegment->get_noeud1();
517 MG_NOEUD* noeud2=mgsegment->get_noeud2();
518 lst_noeud.insert(lst_noeud.end(),noeud1);
519 lst_noeud.insert(lst_noeud.end(),noeud2);
520 }
521 }
522 int nb_seg_fem=mgarete->get_lien_fem_maillage()->get_nb();
523 int nb_m1d_fem=lst_m1d_fem.get_nb();
524 for (int j=0;j<nb_seg_fem;j++)
525 {
526 FEM_SEGMENT* femseg=(FEM_SEGMENT*)mgarete->get_lien_fem_maillage()->get(j);
527 int ok=0;
528 for (int k=0;k<nb_m1d_fem;k++)
529 {
530 FEM_MAILLAGE* femmai=lst_m1d_fem.get(k);
531 FEM_SEGMENT* segtemp=femmai->get_fem_segmentid(femseg->get_id());
532 if (segtemp!=NULL) ok=1;
533 }
534 if (ok==1)
535 {
536 lst_segment_fem.insert(lst_segment_fem.end(),femseg);
537 int nb_noeud=femseg->get_nb_fem_noeud();
538 for (int k=0;k<nb_noeud;k++)
539 {
540 FEM_NOEUD* noeud=femseg->get_fem_noeud(k);
541 lst_noeud_fem.insert(lst_noeud_fem.end(),noeud);
542 }
543 }
544 }
545 }
546 }
547 else
548 {
549 TTreeNode *rootm = root->Item[1];
550 int nb_mai=rootm->Count;
551 for (int i=0;i<nb_mai;i++)
552 {
553 TTreeNode *mai = rootm->Item[i];
554 MG_MAILLAGE* mgmai=gest->get_mg_maillageid(atol(mai->Text.c_str()));
555 if ((ListBox1->ItemIndex!=-1) && (CheckBox1->Checked==true) )
556 {
557 MG_SOLUTION* sol=gest->get_mg_solution(ComboBox1->ItemIndex);
558 if (sol==NULL) continue;
559 unsigned long idmai=sol->get_maillage()->get_id();
560 if (mgmai->get_id()!=idmai) continue;
561 }
562 TTreeNode *mai1d = mai->Item[0];
563 if (mai1d->ImageIndex==46)
564 {
565 int nbseg=mgmai->get_nb_mg_segment();
566 for (int k=0;k<nbseg;k++)
567 {
568 MG_SEGMENT* seg=mgmai->get_mg_segment(k);
569 MG_NOEUD* noeud1=seg->get_noeud1();
570 MG_NOEUD* noeud2=seg->get_noeud2();
571 lst_noeud.insert(lst_noeud.end(),noeud1);
572 lst_noeud.insert(lst_noeud.end(),noeud2);
573 lst_segment.insert(lst_segment.end(),seg);
574 }
575 }
576 TTreeNode *mai2d = mai->Item[1];
577 if (mai2d->ImageIndex==46)
578 {
579 int nbtri=mgmai->get_nb_mg_triangle();
580 for (int k=0;k<nbtri;k++)
581 {
582 MG_TRIANGLE* tri=mgmai->get_mg_triangle(k);
583 MG_NOEUD* noeud1=tri->get_noeud1();
584 MG_NOEUD* noeud2=tri->get_noeud2();
585 MG_NOEUD* noeud3=tri->get_noeud3();
586 lst_noeud.insert(lst_noeud.end(),noeud1);
587 lst_noeud.insert(lst_noeud.end(),noeud2);
588 lst_noeud.insert(lst_noeud.end(),noeud3);
589 lst_triangle.insert(lst_triangle.end(),tri);
590 }
591 }
592 TTreeNode *mai3d = mai->Item[2];
593 if (mai3d->ImageIndex==46)
594 {
595 int nbtet=mgmai->get_nb_mg_tetra();
596 for (int k=0;k<nbtet;k++)
597 {
598 MG_TETRA* tet=mgmai->get_mg_tetra(k);
599 MG_NOEUD* noeud1=tet->get_noeud1();
600 MG_NOEUD* noeud2=tet->get_noeud2();
601 MG_NOEUD* noeud3=tet->get_noeud3();
602 MG_NOEUD* noeud4=tet->get_noeud4();
603 lst_noeud.insert(lst_noeud.end(),noeud1);
604 lst_noeud.insert(lst_noeud.end(),noeud2);
605 lst_noeud.insert(lst_noeud.end(),noeud3);
606 lst_noeud.insert(lst_noeud.end(),noeud4);
607 lst_tetra.insert(lst_tetra.end(),tet);
608 }
609 }
610 }
611 TTreeNode *rootmfem = root->Item[2];
612 int nb_mai_fem=rootmfem->Count;
613 for (int i=0;i<nb_mai_fem;i++)
614 {
615 TTreeNode *mai = rootm->Item[i];
616 FEM_MAILLAGE* femmai=gest->get_fem_maillageid(atol(mai->Text.c_str()));
617 if ((ListBox1->ItemIndex!=-1) && (CheckBox1->Checked==true) )
618 {
619 FEM_SOLUTION* sol=gest->get_fem_solution(ComboBox1->ItemIndex-gest->get_nb_mg_solution());
620 if (sol==NULL) continue;
621 unsigned long idmai=sol->get_maillage()->get_id();
622 if (femmai->get_id()!=idmai) continue;
623 }
624 TTreeNode *mai1d = mai->Item[0];
625 if (mai1d->ImageIndex==46)
626 {
627 int nbseg=femmai->get_nb_fem_segment();
628 for (int k=0;k<nbseg;k++)
629 {
630 FEM_SEGMENT* seg=femmai->get_fem_segment(k);
631 lst_segment_fem.insert(lst_segment_fem.end(),seg);
632 int nb_noeud=seg->get_nb_fem_noeud();
633 for (int l=0;l<nb_noeud;l++)
634 {
635 FEM_NOEUD* noeud=seg->get_fem_noeud(l);
636 lst_noeud_fem.insert(lst_noeud_fem.end(),noeud);
637 }
638 }
639 }
640 TTreeNode *mai2d = mai->Item[1];
641 if (mai2d->ImageIndex==46)
642 {
643 int nbtri=femmai->get_nb_fem_triangle();
644 for (int k=0;k<nbtri;k++)
645 {
646 FEM_TRIANGLE* tri=femmai->get_fem_triangle(k);
647 lst_triangle_fem.insert(lst_triangle_fem.end(),tri);
648 int nb_noeud=tri->get_nb_fem_noeud();
649 for (int l=0;l<nb_noeud;l++)
650 {
651 FEM_NOEUD* noeud=tri->get_fem_noeud(l);
652 lst_noeud_fem.insert(lst_noeud_fem.end(),noeud);
653 }
654 }
655 }
656 TTreeNode *mai3d = mai->Item[2];
657 if (mai3d->ImageIndex==46)
658 {
659 int nbtet=femmai->get_nb_fem_tetra();
660 for (int k=0;k<nbtet;k++)
661 {
662 FEM_TETRA* tet=femmai->get_fem_tetra(k);
663 lst_tetra_fem.insert(lst_tetra_fem.end(),tet);
664 int nb_noeud=tet->get_nb_fem_noeud();
665 for (int l=0;l<nb_noeud;l++)
666 {
667 FEM_NOEUD* noeud=tet->get_fem_noeud(l);
668 lst_noeud_fem.insert(lst_noeud_fem.end(),noeud);
669 }
670 }
671
672 }
673 }
674 }
675 }
676 //---------------------------------------------------------------------------
677
678 void __fastcall TVisuWinform::Slectionner1Click(TObject *Sender)
679 {
680 TTreeNode* node=TreeView1->Selected;
681 changeimage(node,46);
682 initliste();
683 redess();
684 TreeView1->Enabled=false;
685 TreeView1->Enabled=true;
686 }
687 //---------------------------------------------------------------------------
688
689
690 void __fastcall TVisuWinform::changeimage(TTreeNode* node,int num)
691 {
692 if (node==NULL) return;
693 if (node->Count==0)
694 {
695 node->ImageIndex=num;
696 node->SelectedIndex=num;
697 node->StateIndex=num;
698 }
699 else
700 {
701 int nb=node->Count;
702 for (int i=0;i<nb;i++)
703 changeimage(node->Item[i],num);
704 }
705 }
706 //---------------------------------------------------------------------------
707
708 void __fastcall TVisuWinform::Dselectionner1Click(TObject *Sender)
709 {
710 TTreeNode* node=TreeView1->Selected;
711 changeimage(node,-1);
712 initliste();
713 redess();
714 TreeView1->Enabled=false;
715 TreeView1->Enabled=true;
716 }
717 //---------------------------------------------------------------------------
718
719 void __fastcall TVisuWinform::InverserSelection1Click(TObject *Sender)
720 {
721 TTreeNode* node=TreeView1->Selected;
722 inverseimage(node,-1,46);
723 initliste();
724 redess();
725 TreeView1->Enabled=false;
726 TreeView1->Enabled=true;
727 }
728 //---------------------------------------------------------------------------
729 void __fastcall TVisuWinform::inverseimage(TTreeNode* node,int num1,int num2)
730 {
731 if (node==NULL) return;
732 if (node->Count==0)
733 {
734 int num;
735 if (node->ImageIndex==num1) num=num2; else num=num1;
736 node->ImageIndex=num;
737 node->SelectedIndex=num;
738 node->StateIndex=num;
739 }
740 else
741 {
742 int nb=node->Count;
743 for (int i=0;i<nb;i++)
744 inverseimage(node->Item[i],num1,num2);
745 }
746 }
747 //---------------------------------------------------------------------------
748
749 void __fastcall TVisuWinform::Etendre1Click(TObject *Sender)
750 {
751 TreeView1->FullExpand();
752 TreeView1->Enabled=false;
753 TreeView1->Enabled=true;
754 }
755 //---------------------------------------------------------------------------
756
757 void __fastcall TVisuWinform::Rduire1Click(TObject *Sender)
758 {
759 TreeView1->FullCollapse();
760 TreeView1->Enabled=false;
761 TreeView1->Enabled=true;
762 }
763 //---------------------------------------------------------------------------
764
765 void __fastcall TVisuWinform::miseajourmodeleExecute(TObject *Sender)
766 {
767 Screen->Cursor=crHourGlass;
768 Invalidate();
769 if (gest!=NULL) delete gest;
770 gest=new MG_FILE(Caption.c_str());
771 if (gest->get_code_de_lecture()==0)
772 {
773 MessageBox(Handle,"Erreur de lecture du fichier","Erreur", MB_OK);
774 delete gest;
775 gest=NULL;
776 Screen->Cursor=crDefault;
777 Invalidate();
778 Close();
779 return;
780 }
781 lst_visu.clear();
782 miseajourarbre();
783 Screen->Cursor=crDefault;
784 TreeView1->FullCollapse();
785 Invalidate();
786 ChangemodeExecute(Sender);
787 ChangemodeExecute(Sender);
788 TrackBar1->Min=0;
789 TrackBar1->Max=100;
790 TrackBar1->Position=0;
791 TrackBar2->Min=0;
792 TrackBar2->Max=100;
793 TrackBar2->Position=100;
794 TrackBar3->Min=0;
795 TrackBar3->Max=100;
796 TrackBar3->Position=0;
797 TrackBar4->Min=0;
798 TrackBar4->Max=100;
799 TrackBar4->Position=100;
800 TrackBar5->Min=0;
801 TrackBar5->Max=100;
802 TrackBar5->Position=0;
803 TrackBar6->Min=0;
804 TrackBar6->Max=100;
805 TrackBar6->Position=100;
806 FILE* in=fopen(Caption.c_str(),"rt");
807 if (in!=NULL)
808 {
809 std::ftime ft;
810 getftime(fileno(in), &ft);
811 char mess[1000];
812 sprintf(mess,"Heure fichier: %u:%u:%u\n",ft.ft_hour, ft.ft_min,ft.ft_tsec * 2);
813 MainForm->StatusBar->Panels->Items[3]->Text=mess;
814 sprintf(mess,"Jour fichier: %u/%u/%u\n",ft.ft_month, ft.ft_day,ft.ft_year+1980);
815 MainForm->StatusBar->Panels->Items[4]->Text=mess;
816 fclose(in);
817 }
818
819 }
820 //---------------------------------------------------------------------------
821
822 void __fastcall TVisuWinform::lancerverimeshExecute(TObject *Sender)
823 {
824 Tverimesh *Child;
825 Child = new Tverimesh(Application,*gest,boite,*this);
826 Child->Caption=Caption;
827 }
828 //---------------------------------------------------------------------------
829
830 void __fastcall TVisuWinform::FormCreate(TObject *Sender)
831 {
832 hdc = GetDC(Handle);
833 SetPixelFormatDescriptor();
834 hrc = wglCreateContext(hdc);
835 if (hrc == NULL)
836 ShowMessage(":-)~ hrc == NULL");
837 if(wglMakeCurrent(hdc, hrc) == false)
838 ShowMessage("Could not MakeCurrent");
839 wglMakeCurrent (hdc, hrc);
840 SelectObject (hdc, GetStockObject (SYSTEM_FONT));
841 wglUseFontBitmaps (hdc, 0, 255, 1000);
842 glClearColor(MainForm->valeurconfig[11],MainForm->valeurconfig[12],MainForm->valeurconfig[13], 0.0f);
843 ListBox1->Height=TabSheet2->ClientHeight-ListBox1->Top-Label2->Height-Button3->Height;
844 ListBox3->Height=TabSheet6->ClientHeight-ListBox3->Top-5*Button3->Height;
845 Button6->Top=ListBox3->Top+ListBox3->Height+Button6->Height;
846 Button7->Top=ListBox3->Top+ListBox3->Height+3*Button6->Height;
847 Button3->Top=ListBox1->Top+ListBox1->Height;
848 RGB_r[0]=0;RGB_g[0]=0;RGB_b[0]=255;
849 RGB_r[1]=0;RGB_g[1]=100;RGB_b[1]=255;
850 RGB_r[2]=0;RGB_g[2]=200;RGB_b[2]=255;
851 RGB_r[3]=0;RGB_g[3]=255;RGB_b[3]=255;
852 RGB_r[4]=0;RGB_g[4]=255;RGB_b[4]=200;
853 RGB_r[5]=0;RGB_g[5]=255;RGB_b[5]=100;
854 RGB_r[6]=0;RGB_g[6]=255;RGB_b[6]=0;
855 RGB_r[7]=100;RGB_g[7]=255;RGB_b[7]=0;
856 RGB_r[8]=200;RGB_g[8]=255;RGB_b[8]=0;
857 RGB_r[9]=255;RGB_g[9]=255;RGB_b[9]=0;
858 RGB_r[10]=255;RGB_g[10]=150;RGB_b[10]=0;
859 RGB_r[11]=255;RGB_g[11]=0;RGB_b[11]=0;
860 RGB_r[12]=255;RGB_g[12]=0;RGB_b[12]=0;
861 RGB_r[13]=255;RGB_g[13]=137;RGB_b[13]=255;
862 TabSheet3->TabVisible=false;
863 TabSheet6->TabVisible=false;
864 TabSheet7->TabVisible=false;
865 PageControl1->ActivePage=TabSheet1;
866 TrackBar1->Min=0;
867 TrackBar1->Max=100;
868 TrackBar1->Position=0;
869 TrackBar2->Min=0;
870 TrackBar2->Max=100;
871 TrackBar2->Position=100;
872 TrackBar3->Min=0;
873 TrackBar3->Max=100;
874 TrackBar3->Position=0;
875 TrackBar4->Min=0;
876 TrackBar4->Max=100;
877 TrackBar4->Position=100;
878 TrackBar5->Min=0;
879 TrackBar5->Max=100;
880 TrackBar5->Position=0;
881 TrackBar6->Min=0;
882 TrackBar6->Max=100;
883 TrackBar6->Position=100;
884 }
885 //---------------------------------------------------------------------------
886 void __fastcall TVisuWinform::SetPixelFormatDescriptor(void)
887 {
888 PIXELFORMATDESCRIPTOR pfd = {
889 sizeof(PIXELFORMATDESCRIPTOR),
890 1,
891 PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
892 PFD_TYPE_RGBA,
893 24,
894 0,0,0,0,0,0,
895 0,0,
896 0,0,0,0,0,
897 32,
898 0,
899 0,
900 PFD_MAIN_PLANE,
901 0,
902 0,0,
903 };
904 int PixelFormat = ChoosePixelFormat(hdc, &pfd);
905 SetPixelFormat(hdc, PixelFormat, &pfd);
906 }
907 //---------------------------------------------------------------------------
908 void __fastcall TVisuWinform::FormPaint(TObject *Sender)
909 {
910 wglMakeCurrent(hdc,hrc);
911 glClearColor(MainForm->valeurconfig[11],MainForm->valeurconfig[12],MainForm->valeurconfig[13], 0.0f);
912 redess();
913 }
914 //---------------------------------------------------------------------------
915
916 void __fastcall TVisuWinform::FormResize(TObject *Sender)
917 {
918 int w=ClientWidth-PageControl1->Width;
919 int h=ClientHeight;
920 while(w==0)
921 {
922 Width++;
923 w=ClientWidth-PageControl1->Width;
924 }
925 while(h==0)
926 {
927 Height++;
928 h=ClientHeight;
929 }
930
931 recadre(dx,dy,0);
932 redess();
933 ListBox1->Height=TabSheet2->ClientHeight-ListBox1->Top-Label2->Height-Button3->Height;
934 Button3->Top=ListBox1->Top+ListBox1->Height;
935 ListBox3->Height=TabSheet6->ClientHeight-ListBox3->Top-5*Button3->Height;
936 Button6->Top=ListBox3->Top+ListBox3->Height+Button6->Height;
937 Button7->Top=ListBox3->Top+ListBox3->Height+3*Button6->Height;
938 }
939 //---------------------------------------------------------------------------
940
941 void __fastcall TVisuWinform::ChangemodeExecute(TObject *Sender)
942 {
943 int passe2=0;
944 double xmin,xmax;
945 double ymin,ymax;
946 double zmin,zmax;
947 int passe=lst_visu.size();
948 if (passe==0)
949 {
950 int nbgeo=gest->get_nb_mg_geometrie();
951 //if (nbgeo>0)
952 for (int i=0;i<nbgeo;i++)
953 {
954 MG_GEOMETRIE* mggeo=gest->get_mg_geometrie(i);
955 mggeo->cree_entite_visuel();
956 long nb=mggeo->get_nb_mg_visu_courbe();
957 for (long j=0;j<nb;j++)
958 {
959 double xyz1[3],xyz2[3];
960 MG_VISU_COURBE* mgvcrb=mggeo->get_mg_visu_courbe(j);
961 lst_visu.insert(lst_visu.end(),mgvcrb);
962 mgvcrb->get_coord(xyz1,xyz2);
963 if (passe2==0)
964 {
965 xmin=xyz1[0];
966 xmax=xyz1[0];
967 ymin=xyz1[1];
968 ymax=xyz1[1];
969 zmin=xyz1[2];
970 zmax=xyz1[2];
971 passe2=1;
972 }
973 if (xyz1[0]<xmin) xmin=xyz1[0];
974 if (xyz1[0]>xmax) xmax=xyz1[0];
975 if (xyz1[1]<ymin) ymin=xyz1[1];
976 if (xyz1[1]>ymax) ymax=xyz1[1];
977 if (xyz1[2]<zmin) zmin=xyz1[2];
978 if (xyz1[2]>zmax) zmax=xyz1[2];
979 }
980 // boite.reinit(xmin,ymin,zmin,xmax,ymax,zmax);
981 }
982 //else
983 for (unsigned long i=0;i<gest->get_nb_mg_maillage();i++)
984 {
985 MG_MAILLAGE* mai=gest->get_mg_maillage(i);
986 LISTE_MG_NOEUD::iterator it;
987 for (MG_NOEUD* noeud=mai->get_premier_noeud(it);noeud;noeud=mai->get_suivant_noeud(it))
988 {
989 double *xyz=noeud->get_coord();
990 if (xyz[0]<xmin) xmin=xyz[0];
991 if (xyz[0]>xmax) xmax=xyz[0];
992 if (xyz[1]<ymin) ymin=xyz[1];
993 if (xyz[1]>ymax) ymax=xyz[1];
994 if (xyz[2]<zmin) zmin=xyz[2];
995 if (xyz[2]>zmax) zmax=xyz[2];
996 }
997
998 }
999 for (unsigned long i=0;i<gest->get_nb_fem_maillage();i++)
1000 {
1001 FEM_MAILLAGE* mai=gest->get_fem_maillage(i);
1002 LISTE_FEM_NOEUD::iterator it;
1003 for (FEM_NOEUD* noeud=mai->get_premier_noeud(it);noeud;noeud=mai->get_suivant_noeud(it))
1004 {
1005 double *xyz=noeud->get_coord();
1006 if (xyz[0]<xmin) xmin=xyz[0];
1007 if (xyz[0]>xmax) xmax=xyz[0];
1008 if (xyz[1]<ymin) ymin=xyz[1];
1009 if (xyz[1]>ymax) ymax=xyz[1];
1010 if (xyz[2]<zmin) zmin=xyz[2];
1011 if (xyz[2]>zmax) zmax=xyz[2];
1012 }
1013
1014 }
1015 boite.reinit(xmin,ymin,zmin,xmax,ymax,zmax);
1016
1017 }
1018 if (TreeView1->Enabled==true)
1019 {
1020 TreeView1->Enabled=false;
1021 MainForm->ToolButton6->ImageIndex=48;
1022 }
1023 else
1024 {
1025 TreeView1->Enabled=true;
1026 MainForm->ToolButton6->ImageIndex=43;
1027 }
1028 recadre(dx,dy,0);
1029 if (passe==0) initvue();
1030 redess();
1031 }
1032 //---------------------------------------------------------------------------
1033 void __fastcall TVisuWinform::dessinegeo(void)
1034 {
1035 glLineWidth(MainForm->valeurconfig[29]);
1036
1037 glBegin(GL_LINES);
1038 glColor3f(MainForm->valeurconfig[26],MainForm->valeurconfig[27],MainForm->valeurconfig[28] );
1039 double x1=boite.get_xmin()+TrackBar1->Position*(boite.get_xmax()-boite.get_xmin())/100.;
1040 double y1=boite.get_ymin()+TrackBar3->Position*(boite.get_ymax()-boite.get_ymin())/100.;
1041 double z1=boite.get_zmin()+TrackBar5->Position*(boite.get_zmax()-boite.get_zmin())/100.;
1042 double x2=boite.get_xmin()+TrackBar2->Position*(boite.get_xmax()-boite.get_xmin())/100.;
1043 double y2=boite.get_ymin()+TrackBar4->Position*(boite.get_ymax()-boite.get_ymin())/100.;
1044 double z2=boite.get_zmin()+TrackBar6->Position*(boite.get_zmax()-boite.get_zmin())/100.;
1045 double dx=(x2-x1)*1.01;
1046 double dy=(y2-y1)*1.01;
1047 double dz=(z2-z1)*1.01;
1048 double xm=(x1+x2)/2.;
1049 x1=xm-dx/2.;x2=xm+dx/2.;
1050 double ym=(y1+y2)/2.;
1051 y1=ym-dy/2.;y2=ym+dy/2.;
1052 double zm=(z1+z2)/2.;
1053 z1=zm-dz/2.;z2=zm+dz/2.;
1054 BOITE_3D boite2(x1,y1,z1,x2,y2,z2);
1055 int nb=lst_visu.size();
1056 for (int i=0;i<nb;i++)
1057 {
1058 MG_VISU_COURBE* mgvcrb=lst_visu[i];
1059 double xyz1[3];
1060 double xyz2[3];
1061 mgvcrb->get_coord(xyz1,xyz2);
1062 BOITE_3D boitmp=mgvcrb->get_boite_3D();
1063 if (boite2*boitmp)
1064 {
1065 glVertex3f(xyz1[0],xyz1[1],xyz1[2]);
1066 glVertex3f(xyz2[0],xyz2[1],xyz2[2]);
1067 }
1068 }
1069 glEnd();
1070 }
1071 //---------------------------------------------------------------------------
1072 void __fastcall TVisuWinform::dessinemai(void)
1073 {
1074 glLineWidth(1.);
1075 double x1=boite.get_xmin()+TrackBar1->Position*(boite.get_xmax()-boite.get_xmin())/100.;
1076 double y1=boite.get_ymin()+TrackBar3->Position*(boite.get_ymax()-boite.get_ymin())/100.;
1077 double z1=boite.get_zmin()+TrackBar5->Position*(boite.get_zmax()-boite.get_zmin())/100.;
1078 double x2=boite.get_xmin()+TrackBar2->Position*(boite.get_xmax()-boite.get_xmin())/100.;
1079 double y2=boite.get_ymin()+TrackBar4->Position*(boite.get_ymax()-boite.get_ymin())/100.;
1080 double z2=boite.get_zmin()+TrackBar6->Position*(boite.get_zmax()-boite.get_zmin())/100.;
1081 double dx=(x2-x1)*1.01;
1082 double dy=(y2-y1)*1.01;
1083 double dz=(z2-z1)*1.01;
1084 double xm=(x1+x2)/2.;
1085 x1=xm-dx/2.;x2=xm+dx/2.;
1086 double ym=(y1+y2)/2.;
1087 y1=ym-dy/2.;y2=ym+dy/2.;
1088 double zm=(z1+z2)/2.;
1089 z1=zm-dz/2.;z2=zm+dz/2.;
1090 BOITE_3D boite2(x1,y1,z1,x2+1e-8,y2+1e-8,z2+1e-8);
1091
1092 if (noeud)
1093 {
1094 glColor3f(MainForm->valeurconfig[30],MainForm->valeurconfig[31],MainForm->valeurconfig[32]);
1095 glPointSize(MainForm->valeurconfig[33]);
1096 glBegin(GL_POINTS);
1097 int nb=lst_noeud.size();
1098 for (int i=0;i<nb;i++)
1099 {
1100 MG_NOEUD* noeud1=lst_noeud[i];
1101 if (N12->Checked)
1102 if (!estdansfiltre(noeud1->get_id())) continue;
1103 BOITE_3D boitmp=noeud1->get_boite_3D();
1104 if (!(boitmp*boite2)) continue;
1105 int dim;
1106 if (noeud1->get_lien_topologie()==NULL) dim=-1;
1107 else dim=noeud1->get_lien_topologie()->get_dimension();
1108 /*if (dim==0) dim=1;
1109 dim--;*/
1110 if (dim>-1)
1111 {
1112 int binoeud[4];
1113 binoeud[0]=noeud%2;
1114 binoeud[1]=(noeud/2)%2;
1115 binoeud[2]=(noeud/4)%2;
1116 binoeud[3]=(noeud/8)%2;
1117 if (binoeud[dim])
1118 {
1119 double *xyz1=noeud1->get_coord();
1120 glVertex3f(xyz1[0],xyz1[1],xyz1[2]);
1121 }
1122 }
1123 else
1124 {
1125 double *xyz1=noeud1->get_coord();
1126 glVertex3f(xyz1[0],xyz1[1],xyz1[2]);
1127 }
1128 }
1129 glEnd();
1130 if (affnoeud)
1131 {
1132 for (int i=0;i<nb;i++)
1133 {
1134 MG_NOEUD* noeud1=lst_noeud[i];
1135 if (N12->Checked)
1136 if (!estdansfiltre(noeud1->get_id())) continue;
1137 BOITE_3D boitmp=noeud1->get_boite_3D();
1138 if (!(boitmp*boite2)) continue;
1139 int dim;
1140 if (noeud1->get_lien_topologie()==NULL) dim=-1;
1141 else dim=noeud1->get_lien_topologie()->get_dimension();
1142 /*if (dim==0) dim=1;
1143 dim--;*/
1144 int binoeud[4];
1145 binoeud[0]=noeud%2;
1146 binoeud[1]=(noeud/2)%2;
1147 binoeud[2]=(noeud/4)%2;
1148 binoeud[3]=(noeud/8)%2;
1149 if (dim>-1)
1150 {
1151 if (binoeud[dim])
1152 {
1153 unsigned long id=noeud1->get_id();
1154 double *xyz=noeud1->get_coord();
1155 char mess[30];
1156 sprintf(mess,"%lu",id);
1157 glRasterPos3f(xyz[0],xyz[1],xyz[2]);
1158 glListBase (1000);
1159 glCallLists (strlen(mess), GL_UNSIGNED_BYTE, mess);
1160 }
1161
1162 }
1163 else
1164 {
1165 unsigned long id=noeud1->get_id();
1166 double *xyz=noeud1->get_coord();
1167 char mess[30];
1168 sprintf(mess,"%lu",id);
1169 glRasterPos3f(xyz[0],xyz[1],xyz[2]);
1170 glListBase (1000);
1171 glCallLists (strlen(mess), GL_UNSIGNED_BYTE, mess);
1172 }
1173 }
1174
1175 }
1176 }
1177 int bmaille[3];
1178 bmaille[0]=maille%2;
1179 bmaille[1]=(maille/2)%2;
1180 bmaille[2]=(maille/4)%2;
1181 if (bmaille[0])
1182 {
1183 glLineWidth(MainForm->valeurconfig[17]);
1184 glColor3f(MainForm->valeurconfig[14],MainForm->valeurconfig[15],MainForm->valeurconfig[16]);
1185 glBegin(GL_LINES);
1186 int nb=lst_segment.size();
1187 for (int i=0;i<nb;i++)
1188 {
1189 glColor3f(MainForm->valeurconfig[14],MainForm->valeurconfig[15],MainForm->valeurconfig[16]);
1190 MG_SEGMENT* mgsegment=lst_segment[i];
1191 if (N12->Checked)
1192 if (!estdansfiltre(mgsegment->get_id())) continue;
1193 BOITE_3D boitmp=mgsegment->get_boite_3D();
1194 if (!(boitmp*boite2)) continue;
1195 MG_NOEUD* noeud1=mgsegment->get_noeud1();
1196 MG_NOEUD* noeud2=mgsegment->get_noeud2();
1197 double *xyz1=noeud1->get_coord();
1198 double *xyz2=noeud2->get_coord();
1199 if (qualite==2)
1200 {
1201 int pos=(int) ((mgsegment->get_origine()-1000)/10);
1202 if (pos>11) pos=11;
1203 if (pos<0) pos=0;
1204 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1205 }
1206 if ((mgsegment->get_lien_topologie()==toposel) && (mgsegment->get_lien_topologie()!=NULL) )
1207 glColor3f(RGB_r[13]/255.,RGB_g[13]/255.,RGB_b[13]/255.);
1208 if (CheckBox1->Checked==true)
1209 {
1210 int pos=(int) ((noeud1->get_solution()-lmin)*12./(lmax-lmin));
1211 if (pos>11) pos=11;
1212 if (pos<0) pos=0;
1213 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1214 }
1215 glVertex3f(xyz1[0],xyz1[1],xyz1[2]);
1216 if (CheckBox1->Checked==true)
1217 {
1218 int pos=(int) ((noeud2->get_solution()-lmin)*12./(lmax-lmin));
1219 if (pos>11) pos=11;
1220 if (pos<0) pos=0;
1221 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1222 }
1223 glVertex3f(xyz2[0],xyz2[1],xyz2[2]);
1224 }
1225 glEnd();
1226 if (affmaille)
1227 {
1228 for (int i=0;i<nb;i++)
1229 {
1230 MG_SEGMENT* mgsegment=lst_segment[i];
1231 if (N12->Checked)
1232 if (!estdansfiltre(mgsegment->get_id())) continue;
1233 BOITE_3D boitmp=mgsegment->get_boite_3D();
1234 if (!(boitmp*boite2)) continue;
1235 MG_NOEUD* noeud1=mgsegment->get_noeud1();
1236 MG_NOEUD* noeud2=mgsegment->get_noeud2();
1237 if (qualite==2)
1238 {
1239 int pos=(int) ((mgsegment->get_origine()-1000)/10);
1240 if (pos>11) pos=11;
1241 if (pos<0) pos=0;
1242 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1243 }
1244 unsigned long id=mgsegment->get_id();
1245 double *xyz1=noeud1->get_coord();
1246 double *xyz2=noeud2->get_coord();
1247 char mess[30];
1248 sprintf(mess,"%lu",id);
1249 glRasterPos3f(0.5*(xyz1[0]+xyz2[0]),0.5*(xyz1[1]+xyz2[1]),0.5*(xyz1[2]+xyz2[2]));
1250 glListBase (1000);
1251 glCallLists (strlen(mess), GL_UNSIGNED_BYTE, mess);
1252 }
1253 }
1254 }
1255 //triangle
1256 if (bmaille[1])
1257 {
1258 if (render>0)
1259 {
1260 if (render>1) InitShading();
1261 glColor3f(MainForm->valeurconfig[34],MainForm->valeurconfig[35],MainForm->valeurconfig[36]);
1262 glEnable(GL_DEPTH_TEST);
1263 glEnable(GL_POLYGON_OFFSET_FILL);
1264 glPolygonOffset(1.0,1.0);
1265 glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
1266 glBegin(GL_TRIANGLES);
1267 glEdgeFlag(GL_TRUE);
1268 int nb=lst_triangle.size();
1269 for (int i=0;i<nb;i++)
1270 {
1271 glColor3f(MainForm->valeurconfig[34],MainForm->valeurconfig[35],MainForm->valeurconfig[36]);
1272 MG_TRIANGLE* mgtri=lst_triangle[i];
1273 if (N12->Checked)
1274 if (!estdansfiltre(mgtri->get_id())) continue;
1275 BOITE_3D boitmp=mgtri->get_boite_3D();
1276 if (!(boitmp*boite2)) continue;
1277 MG_NOEUD* noeud1=mgtri->get_noeud1();
1278 MG_NOEUD* noeud2=mgtri->get_noeud2();
1279 MG_NOEUD* noeud3=mgtri->get_noeud3();
1280 double *xyz1=noeud1->get_coord();
1281 double *xyz2=noeud2->get_coord();
1282 double *xyz3=noeud3->get_coord();
1283 if ((mgtri->get_lien_topologie()==toposel) && (mgtri->get_lien_topologie()!=NULL) )
1284 glColor3f(RGB_r[13]/255.,RGB_g[13]/255.,RGB_b[13]/255.);
1285 if (qualite==1)
1286 {
1287 double qual=OPERATEUR::qualite_triangle(xyz1,xyz2,xyz3);
1288 if (qual>MainForm->valeurconfig[53]) glColor3f(MainForm->valeurconfig[41],MainForm->valeurconfig[42],MainForm->valeurconfig[43]);
1289 else if (qual>MainForm->valeurconfig[54]) glColor3f(MainForm->valeurconfig[44],MainForm->valeurconfig[45],MainForm->valeurconfig[46]);
1290 else if (qual>MainForm->valeurconfig[55]) glColor3f(MainForm->valeurconfig[47],MainForm->valeurconfig[48],MainForm->valeurconfig[49]);
1291 else glColor3f(MainForm->valeurconfig[50],MainForm->valeurconfig[51],MainForm->valeurconfig[52]);
1292 }
1293 if (qualite==2)
1294 {
1295 int pos=(int) ((mgtri->get_origine()-1000)/10);
1296 if (pos>11) pos=11;
1297 if (pos<0) pos=0;
1298 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1299 }
1300 if (shrink)
1301 {
1302 double xg=0.33333333333333*(xyz1[0]+xyz2[0]+xyz3[0]);
1303 double yg=0.33333333333333*(xyz1[1]+xyz2[1]+xyz3[1]);
1304 double zg=0.33333333333333*(xyz1[2]+xyz2[2]+xyz3[2]);
1305 double x1=xg+facteur_shrink*(xyz1[0]-xg);
1306 double y1=yg+facteur_shrink*(xyz1[1]-yg);
1307 double z1=zg+facteur_shrink*(xyz1[2]-zg);
1308 double x2=xg+facteur_shrink*(xyz2[0]-xg);
1309 double y2=yg+facteur_shrink*(xyz2[1]-yg);
1310 double z2=zg+facteur_shrink*(xyz2[2]-zg);
1311 double x3=xg+facteur_shrink*(xyz3[0]-xg);
1312 double y3=yg+facteur_shrink*(xyz3[1]-yg);
1313 double z3=zg+facteur_shrink*(xyz3[2]-zg);
1314 if (CheckBox1->Checked==true)
1315 {
1316 int pos=(int) ((noeud1->get_solution()-lmin)*12./(lmax-lmin));
1317 if (pos>11) pos=11;
1318 if (pos<0) pos=0;
1319 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1320 }
1321 glVertex3f(x1,y1,z1);
1322 if (CheckBox1->Checked==true)
1323 {
1324 int pos=(int) ((noeud3->get_solution()-lmin)*12./(lmax-lmin));
1325 if (pos>11) pos=11;
1326 if (pos<0) pos=0;
1327 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1328 }
1329 glVertex3f(x3,y3,z3);
1330 if (CheckBox1->Checked==true)
1331 {
1332 int pos=(int) ((noeud2->get_solution()-lmin)*12./(lmax-lmin));
1333 if (pos>11) pos=11;
1334 if (pos<0) pos=0;
1335 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1336 }
1337 glVertex3f(x2,y2,z2);
1338 }
1339 else
1340 {
1341 if (CheckBox1->Checked==true)
1342 {
1343 int pos=(int) ((noeud1->get_solution()-lmin)*12./(lmax-lmin));
1344 if (pos>11) pos=11;
1345 if (pos<0) pos=0;
1346 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1347 }
1348 glVertex3f(xyz1[0],xyz1[1],xyz1[2]);
1349 if (CheckBox1->Checked==true)
1350 {
1351 int pos=(int) ((noeud3->get_solution()-lmin)*12./(lmax-lmin));
1352 if (pos>11) pos=11;
1353 if (pos<0) pos=0;
1354 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1355 }
1356 glVertex3f(xyz3[0],xyz3[1],xyz3[2]);
1357 if (CheckBox1->Checked==true)
1358 {
1359 int pos=(int) ((noeud2->get_solution()-lmin)*12./(lmax-lmin));
1360 if (pos>11) pos=11;
1361 if (pos<0) pos=0;
1362 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1363 }
1364 glVertex3f(xyz2[0],xyz2[1],xyz2[2]);
1365 }
1366 }
1367 glEnd();
1368 }
1369
1370 glFlush();
1371 if (render>0)
1372 {
1373 glColor3f(MainForm->valeurconfig[37],MainForm->valeurconfig[38],MainForm->valeurconfig[39]);
1374 glLineWidth(MainForm->valeurconfig[40]);
1375 if (render>1) InitShading();
1376 }
1377 else
1378 {
1379 glColor3f(MainForm->valeurconfig[18],MainForm->valeurconfig[19],MainForm->valeurconfig[20]);
1380 glLineWidth(MainForm->valeurconfig[21]);
1381 }
1382 glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
1383 glBegin(GL_TRIANGLES);
1384 glEdgeFlag(GL_TRUE);
1385 int nb=lst_triangle.size();
1386 for (int i=0;i<nb;i++)
1387 {
1388 if (render>0)
1389 glColor3f(MainForm->valeurconfig[37],MainForm->valeurconfig[38],MainForm->valeurconfig[39]);
1390 else
1391 glColor3f(MainForm->valeurconfig[18],MainForm->valeurconfig[19],MainForm->valeurconfig[20]);
1392 MG_TRIANGLE* mgtri=lst_triangle[i];
1393 if (N12->Checked)
1394 if (!estdansfiltre(mgtri->get_id())) continue;
1395 BOITE_3D boitmp=mgtri->get_boite_3D();
1396 if (!(boitmp*boite2)) continue;
1397 MG_NOEUD* noeud1=mgtri->get_noeud1();
1398 MG_NOEUD* noeud2=mgtri->get_noeud2();
1399 MG_NOEUD* noeud3=mgtri->get_noeud3();
1400 double *xyz1=noeud1->get_coord();
1401 double *xyz2=noeud2->get_coord();
1402 double *xyz3=noeud3->get_coord();
1403 if ( ((mgtri->get_lien_topologie()==toposel)&& (mgtri->get_lien_topologie()!=NULL) && (render==0)) || ((mgtri->get_lien_topologie()==toposel)&&(render==1) && (mgtri->get_lien_topologie()!=NULL) && (MainForm->valeurconfig[56]==0.)))
1404 glColor3f(RGB_r[13]/255.,RGB_g[13]/255.,RGB_b[13]/255.);
1405 if ( ((qualite==1)&&(render==0)) || ((qualite==1)&&(render==1) && (MainForm->valeurconfig[56]==0.)))
1406 {
1407 double qual=OPERATEUR::qualite_triangle(xyz1,xyz2,xyz3);
1408 if (qual>MainForm->valeurconfig[53]) glColor3f(MainForm->valeurconfig[41],MainForm->valeurconfig[42],MainForm->valeurconfig[43]);
1409 else if (qual>MainForm->valeurconfig[54]) glColor3f(MainForm->valeurconfig[44],MainForm->valeurconfig[45],MainForm->valeurconfig[46]);
1410 else if (qual>MainForm->valeurconfig[55]) glColor3f(MainForm->valeurconfig[47],MainForm->valeurconfig[48],MainForm->valeurconfig[49]);
1411 else glColor3f(MainForm->valeurconfig[50],MainForm->valeurconfig[51],MainForm->valeurconfig[52]);
1412 }
1413 if ( ((qualite==2)&&(render==0)) || ((qualite==2)&&(render==1) && (MainForm->valeurconfig[56]==0.)))
1414 {
1415 int pos=(int) ((mgtri->get_origine()-1000)/10);
1416 if (pos>11) pos=11;
1417 if (pos<0) pos=0;
1418 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1419 }
1420
1421 if (shrink)
1422 {
1423 double xg=0.33333333333333*(xyz1[0]+xyz2[0]+xyz3[0]);
1424 double yg=0.33333333333333*(xyz1[1]+xyz2[1]+xyz3[1]);
1425 double zg=0.33333333333333*(xyz1[2]+xyz2[2]+xyz3[2]);
1426 double x1=xg+facteur_shrink*(xyz1[0]-xg);
1427 double y1=yg+facteur_shrink*(xyz1[1]-yg);
1428 double z1=zg+facteur_shrink*(xyz1[2]-zg);
1429 double x2=xg+facteur_shrink*(xyz2[0]-xg);
1430 double y2=yg+facteur_shrink*(xyz2[1]-yg);
1431 double z2=zg+facteur_shrink*(xyz2[2]-zg);
1432 double x3=xg+facteur_shrink*(xyz3[0]-xg);
1433 double y3=yg+facteur_shrink*(xyz3[1]-yg);
1434 double z3=zg+facteur_shrink*(xyz3[2]-zg);
1435 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
1436 {
1437 int pos=(int) ((noeud1->get_solution()-lmin)*12./(lmax-lmin));
1438 if (pos>11) pos=11;
1439 if (pos<0) pos=0;
1440 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1441 }
1442 glVertex3f(x1,y1,z1);
1443 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
1444 {
1445 int pos=(int) ((noeud3->get_solution()-lmin)*12./(lmax-lmin));
1446 if (pos>11) pos=11;
1447 if (pos<0) pos=0;
1448 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1449 }
1450 glVertex3f(x3,y3,z3);
1451 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
1452 {
1453 int pos=(int) ((noeud2->get_solution()-lmin)*12./(lmax-lmin));
1454 if (pos>11) pos=11;
1455 if (pos<0) pos=0;
1456 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1457 }
1458 glVertex3f(x2,y2,z2);
1459 }
1460 else
1461 {
1462 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
1463 {
1464 int pos=(int) ((noeud1->get_solution()-lmin)*12./(lmax-lmin));
1465 if (pos>11) pos=11;
1466 if (pos<0) pos=0;
1467 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1468 }
1469 glVertex3f(xyz1[0],xyz1[1],xyz1[2]);
1470 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
1471 {
1472 int pos=(int) ((noeud3->get_solution()-lmin)*12./(lmax-lmin));
1473 if (pos>11) pos=11;
1474 if (pos<0) pos=0;
1475 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1476 }
1477 glVertex3f(xyz3[0],xyz3[1],xyz3[2]);
1478 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
1479 {
1480 int pos=(int) ((noeud2->get_solution()-lmin)*12./(lmax-lmin));
1481 if (pos>11) pos=11;
1482 if (pos<0) pos=0;
1483 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1484 }
1485 glVertex3f(xyz2[0],xyz2[1],xyz2[2]);
1486 }
1487 }
1488 glEnd();
1489 if (affmaille)
1490 {
1491 for (int i=0;i<nb;i++)
1492 {
1493 MG_TRIANGLE* mgtri=lst_triangle[i];
1494 if (N12->Checked)
1495 if (!estdansfiltre(mgtri->get_id())) continue;
1496 BOITE_3D boitmp=mgtri->get_boite_3D();
1497 if (!(boitmp*boite2)) continue;
1498 MG_NOEUD* noeud1=mgtri->get_noeud1();
1499 MG_NOEUD* noeud2=mgtri->get_noeud2();
1500 MG_NOEUD* noeud3=mgtri->get_noeud3();
1501 double *xyz1=noeud1->get_coord();
1502 double *xyz2=noeud2->get_coord();
1503 double *xyz3=noeud3->get_coord();
1504 unsigned long id=mgtri->get_id();
1505 char mess[30];
1506 sprintf(mess,"%lu",id);
1507 if ( ((qualite==1)&&(render==0)) || ((qualite==1)&&(render==1) && (MainForm->valeurconfig[56]==0.)))
1508 {
1509 double qual=OPERATEUR::qualite_triangle(xyz1,xyz2,xyz3);
1510 if (qual>MainForm->valeurconfig[53]) glColor3f(MainForm->valeurconfig[41],MainForm->valeurconfig[42],MainForm->valeurconfig[43]);
1511 else if (qual>MainForm->valeurconfig[54]) glColor3f(MainForm->valeurconfig[44],MainForm->valeurconfig[45],MainForm->valeurconfig[46]);
1512 else if (qual>MainForm->valeurconfig[55]) glColor3f(MainForm->valeurconfig[47],MainForm->valeurconfig[48],MainForm->valeurconfig[49]);
1513 else glColor3f(MainForm->valeurconfig[50],MainForm->valeurconfig[51],MainForm->valeurconfig[52]);
1514 }
1515 if ( ((qualite==2)&&(render==0)) || ((qualite==2)&&(render==1) && (MainForm->valeurconfig[56]==0.)))
1516 {
1517 int pos=(int) ((mgtri->get_origine()-1000)/10);
1518 if (pos>11) pos=11;
1519 if (pos<0) pos=0;
1520 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1521 }
1522 glRasterPos3f((xyz1[0]+xyz2[0]+xyz3[0])/3.,(xyz1[1]+xyz2[1]+xyz3[1])/3.,(xyz1[2]+xyz2[2]+xyz3[2])/3.);
1523 glListBase (1000);
1524 glCallLists (strlen(mess), GL_UNSIGNED_BYTE, mess);
1525 }
1526 }
1527 if (render==2)
1528 {
1529 glDisable(GL_LIGHTING);
1530 glDisable(GL_LIGHT0);
1531 glDisable(GL_LIGHT1);
1532 }
1533 }
1534 //tetra
1535 if (bmaille[2])
1536 {
1537 if (render==1)
1538 {
1539 glColor3f(MainForm->valeurconfig[34],MainForm->valeurconfig[35],MainForm->valeurconfig[36]);
1540 glEnable(GL_DEPTH_TEST);
1541 glEnable(GL_POLYGON_OFFSET_FILL);
1542 glPolygonOffset(1.0,1.0);
1543 glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
1544 glBegin(GL_TRIANGLES);
1545 glEdgeFlag(GL_TRUE);
1546 int nb=lst_tetra.size();
1547 for (int i=0;i<nb;i++)
1548 {
1549 MG_TETRA* mgtri=lst_tetra[i];
1550 if (N12->Checked)
1551 if (!estdansfiltre(mgtri->get_id())) continue;
1552 BOITE_3D boitmp=mgtri->get_boite_3D();
1553 if (!(boitmp*boite2)) continue;
1554 MG_NOEUD* noeud1=mgtri->get_noeud1();
1555 MG_NOEUD* noeud2=mgtri->get_noeud2();
1556 MG_NOEUD* noeud3=mgtri->get_noeud3();
1557 MG_NOEUD* noeud4=mgtri->get_noeud4();
1558 double *xyz1=noeud1->get_coord();
1559 double *xyz2=noeud2->get_coord();
1560 double *xyz3=noeud3->get_coord();
1561 double *xyz4=noeud4->get_coord();
1562 if ((mgtri->get_lien_topologie()==toposel) && (mgtri->get_lien_topologie()!=NULL) )
1563 glColor3f(RGB_r[13]/255.,RGB_g[13]/255.,RGB_b[13]/255.);
1564 if (qualite==1)
1565 {
1566 double qual=OPERATEUR::qualite_tetra(xyz1,xyz2,xyz3,xyz4);
1567 if (qual>MainForm->valeurconfig[53]) glColor3f(MainForm->valeurconfig[41],MainForm->valeurconfig[42],MainForm->valeurconfig[43]);
1568 else if (qual>MainForm->valeurconfig[54]) glColor3f(MainForm->valeurconfig[44],MainForm->valeurconfig[45],MainForm->valeurconfig[46]);
1569 else if (qual>MainForm->valeurconfig[55]) glColor3f(MainForm->valeurconfig[47],MainForm->valeurconfig[48],MainForm->valeurconfig[49]);
1570 else glColor3f(MainForm->valeurconfig[50],MainForm->valeurconfig[51],MainForm->valeurconfig[52]);
1571 }
1572 if (qualite==2)
1573 {
1574 int pos=(int) ((mgtri->get_origine()-1000)/10);
1575 if (pos>11) pos=11;
1576 if (pos<0) pos=0;
1577 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1578 }
1579 if (shrink)
1580 {
1581 double xg=0.25*(xyz1[0]+xyz2[0]+xyz3[0]+xyz4[0]);
1582 double yg=0.25*(xyz1[1]+xyz2[1]+xyz3[1]+xyz4[1]);
1583 double zg=0.25*(xyz1[2]+xyz2[2]+xyz3[2]+xyz4[2]);
1584 double x1=xg+facteur_shrink*(xyz1[0]-xg);
1585 double y1=yg+facteur_shrink*(xyz1[1]-yg);
1586 double z1=zg+facteur_shrink*(xyz1[2]-zg);
1587 double x2=xg+facteur_shrink*(xyz2[0]-xg);
1588 double y2=yg+facteur_shrink*(xyz2[1]-yg);
1589 double z2=zg+facteur_shrink*(xyz2[2]-zg);
1590 double x3=xg+facteur_shrink*(xyz3[0]-xg);
1591 double y3=yg+facteur_shrink*(xyz3[1]-yg);
1592 double z3=zg+facteur_shrink*(xyz3[2]-zg);
1593 double x4=xg+facteur_shrink*(xyz4[0]-xg);
1594 double y4=yg+facteur_shrink*(xyz4[1]-yg);
1595 double z4=zg+facteur_shrink*(xyz4[2]-zg);
1596 if (CheckBox1->Checked==true)
1597 {
1598 int pos=(int) ((noeud1->get_solution()-lmin)*12./(lmax-lmin));
1599 if (pos>11) pos=11;
1600 if (pos<0) pos=0;
1601 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1602 }
1603 glVertex3f(x1,y1,z1);
1604 if (CheckBox1->Checked==true)
1605 {
1606 int pos=(int) ((noeud3->get_solution()-lmin)*12./(lmax-lmin));
1607 if (pos>11) pos=11;
1608 if (pos<0) pos=0;
1609 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1610 }
1611 glVertex3f(x3,y3,z3);
1612 if (CheckBox1->Checked==true)
1613 {
1614 int pos=(int) ((noeud2->get_solution()-lmin)*12./(lmax-lmin));
1615 if (pos>11) pos=11;
1616 if (pos<0) pos=0;
1617 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1618 }
1619 glVertex3f(x2,y2,z2);
1620 if (CheckBox1->Checked==true)
1621 {
1622 int pos=(int) ((noeud1->get_solution()-lmin)*12./(lmax-lmin));
1623 if (pos>11) pos=11;
1624 if (pos<0) pos=0;
1625 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1626 }
1627 glVertex3f(x1,y1,z1);
1628 if (CheckBox1->Checked==true)
1629 {
1630 int pos=(int) ((noeud2->get_solution()-lmin)*12./(lmax-lmin));
1631 if (pos>11) pos=11;
1632 if (pos<0) pos=0;
1633 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1634 }
1635 glVertex3f(x2,y2,z2);
1636 if (CheckBox1->Checked==true)
1637 {
1638 int pos=(int) ((noeud4->get_solution()-lmin)*12./(lmax-lmin));
1639 if (pos>11) pos=11;
1640 if (pos<0) pos=0;
1641 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1642 }
1643 glVertex3f(x4,y4,z4);
1644 if (CheckBox1->Checked==true)
1645 {
1646 int pos=(int) ((noeud2->get_solution()-lmin)*12./(lmax-lmin));
1647 if (pos>11) pos=11;
1648 if (pos<0) pos=0;
1649 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1650 }
1651 glVertex3f(x2,y2,z2);
1652 if (CheckBox1->Checked==true)
1653 {
1654 int pos=(int) ((noeud3->get_solution()-lmin)*12./(lmax-lmin));
1655 if (pos>11) pos=11;
1656 if (pos<0) pos=0;
1657 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1658 }
1659 glVertex3f(x3,y3,z3);
1660 if (CheckBox1->Checked==true)
1661 {
1662 int pos=(int) ((noeud4->get_solution()-lmin)*12./(lmax-lmin));
1663 if (pos>11) pos=11;
1664 if (pos<0) pos=0;
1665 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1666 }
1667 glVertex3f(x4,y4,z4);
1668 if (CheckBox1->Checked==true)
1669 {
1670 int pos=(int) ((noeud1->get_solution()-lmin)*12./(lmax-lmin));
1671 if (pos>11) pos=11;
1672 if (pos<0) pos=0;
1673 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1674 }
1675 glVertex3f(x1,y1,z1);
1676 if (CheckBox1->Checked==true)
1677 {
1678 int pos=(int) ((noeud4->get_solution()-lmin)*12./(lmax-lmin));
1679 if (pos>11) pos=11;
1680 if (pos<0) pos=0;
1681 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1682 }
1683 glVertex3f(x4,y4,z4);
1684 if (CheckBox1->Checked==true)
1685 {
1686 int pos=(int) ((noeud3->get_solution()-lmin)*12./(lmax-lmin));
1687 if (pos>11) pos=11;
1688 if (pos<0) pos=0;
1689 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1690 }
1691 glVertex3f(x3,y3,z3);
1692 }
1693 else
1694 {
1695 if (CheckBox1->Checked==true)
1696 {
1697 int pos=(int) ((noeud1->get_solution()-lmin)*12./(lmax-lmin));
1698 if (pos>11) pos=11;
1699 if (pos<0) pos=0;
1700 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1701 }
1702 glVertex3f(xyz1[0],xyz1[1],xyz1[2]);
1703 if (CheckBox1->Checked==true)
1704 {
1705 int pos=(int) ((noeud3->get_solution()-lmin)*12./(lmax-lmin));
1706 if (pos>11) pos=11;
1707 if (pos<0) pos=0;
1708 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1709 }
1710 glVertex3f(xyz3[0],xyz3[1],xyz3[2]);
1711 if (CheckBox1->Checked==true)
1712 {
1713 int pos=(int) ((noeud2->get_solution()-lmin)*12./(lmax-lmin));
1714 if (pos>11) pos=11;
1715 if (pos<0) pos=0;
1716 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1717 }
1718 glVertex3f(xyz2[0],xyz2[1],xyz2[2]);
1719 if (CheckBox1->Checked==true)
1720 {
1721 int pos=(int) ((noeud1->get_solution()-lmin)*12./(lmax-lmin));
1722 if (pos>11) pos=11;
1723 if (pos<0) pos=0;
1724 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1725 }
1726 glVertex3f(xyz1[0],xyz1[1],xyz1[2]);
1727 if (CheckBox1->Checked==true)
1728 {
1729 int pos=(int) ((noeud2->get_solution()-lmin)*12./(lmax-lmin));
1730 if (pos>11) pos=11;
1731 if (pos<0) pos=0;
1732 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1733 }
1734 glVertex3f(xyz2[0],xyz2[1],xyz2[2]);
1735 if (CheckBox1->Checked==true)
1736 {
1737 int pos=(int) ((noeud4->get_solution()-lmin)*12./(lmax-lmin));
1738 if (pos>11) pos=11;
1739 if (pos<0) pos=0;
1740 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1741 }
1742 glVertex3f(xyz4[0],xyz4[1],xyz4[2]);
1743 if (CheckBox1->Checked==true)
1744 {
1745 int pos=(int) ((noeud2->get_solution()-lmin)*12./(lmax-lmin));
1746 if (pos>11) pos=11;
1747 if (pos<0) pos=0;
1748 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1749 }
1750 glVertex3f(xyz2[0],xyz2[1],xyz2[2]);
1751 if (CheckBox1->Checked==true)
1752 {
1753 int pos=(int) ((noeud3->get_solution()-lmin)*12./(lmax-lmin));
1754 if (pos>11) pos=11;
1755 if (pos<0) pos=0;
1756 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1757 }
1758 glVertex3f(xyz3[0],xyz3[1],xyz3[2]);
1759 if (CheckBox1->Checked==true)
1760 {
1761 int pos=(int) ((noeud4->get_solution()-lmin)*12./(lmax-lmin));
1762 if (pos>11) pos=11;
1763 if (pos<0) pos=0;
1764 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1765 }
1766 glVertex3f(xyz4[0],xyz4[1],xyz4[2]);
1767 if (CheckBox1->Checked==true)
1768 {
1769 int pos=(int) ((noeud1->get_solution()-lmin)*12./(lmax-lmin));
1770 if (pos>11) pos=11;
1771 if (pos<0) pos=0;
1772 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1773 }
1774 glVertex3f(xyz1[0],xyz1[1],xyz1[2]);
1775 if (CheckBox1->Checked==true)
1776 {
1777 int pos=(int) ((noeud4->get_solution()-lmin)*12./(lmax-lmin));
1778 if (pos>11) pos=11;
1779 if (pos<0) pos=0;
1780 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1781 }
1782 glVertex3f(xyz4[0],xyz4[1],xyz4[2]);
1783 if (CheckBox1->Checked==true)
1784 {
1785 int pos=(int) ((noeud3->get_solution()-lmin)*12./(lmax-lmin));
1786 if (pos>11) pos=11;
1787 if (pos<0) pos=0;
1788 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1789 }
1790 glVertex3f(xyz3[0],xyz3[1],xyz3[2]);
1791 }
1792 }
1793 glEnd();
1794 }
1795
1796 glFlush();
1797 if (render==1)
1798 {
1799 glColor3f(MainForm->valeurconfig[37],MainForm->valeurconfig[38],MainForm->valeurconfig[39]);
1800 glLineWidth(MainForm->valeurconfig[40]);
1801 }
1802 else
1803 {
1804 glColor3f(MainForm->valeurconfig[22],MainForm->valeurconfig[23],MainForm->valeurconfig[24]);
1805 glLineWidth(MainForm->valeurconfig[25]);
1806 }
1807 glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
1808 glBegin(GL_TRIANGLES);
1809 glEdgeFlag(GL_TRUE);
1810 int nb=lst_tetra.size();
1811 for (int i=0;i<nb;i++)
1812 {
1813 if (render==1)
1814 glColor3f(MainForm->valeurconfig[37],MainForm->valeurconfig[38],MainForm->valeurconfig[39]);
1815 else
1816 glColor3f(MainForm->valeurconfig[22],MainForm->valeurconfig[23],MainForm->valeurconfig[24]);
1817 MG_TETRA* mgtri=lst_tetra[i];
1818 if (N12->Checked)
1819 if (!estdansfiltre(mgtri->get_id())) continue;
1820 BOITE_3D boitmp=mgtri->get_boite_3D();
1821 if (!(boitmp*boite2)) continue;
1822 MG_NOEUD* noeud1=mgtri->get_noeud1();
1823 MG_NOEUD* noeud2=mgtri->get_noeud2();
1824 MG_NOEUD* noeud3=mgtri->get_noeud3();
1825 MG_NOEUD* noeud4=mgtri->get_noeud4();
1826 double *xyz1=noeud1->get_coord();
1827 double *xyz2=noeud2->get_coord();
1828 double *xyz3=noeud3->get_coord();
1829 double *xyz4=noeud4->get_coord();
1830 if ( ((mgtri->get_lien_topologie()==toposel) && (mgtri->get_lien_topologie()!=NULL) && (render==0)) || ((mgtri->get_lien_topologie()==toposel)&& (mgtri->get_lien_topologie()!=NULL) &&(render==1) && (MainForm->valeurconfig[56]==0.)))
1831 glColor3f(RGB_r[13]/255.,RGB_g[13]/255.,RGB_b[13]/255.);
1832 if ( ((qualite==1)&&(render==0)) || ((qualite==1)&&(render==1) && (MainForm->valeurconfig[56]==0.)))
1833 {
1834 double qual=OPERATEUR::qualite_tetra(xyz1,xyz2,xyz3,xyz4);
1835 if (qual>MainForm->valeurconfig[53]) glColor3f(MainForm->valeurconfig[41],MainForm->valeurconfig[42],MainForm->valeurconfig[43]);
1836 else if (qual>MainForm->valeurconfig[54]) glColor3f(MainForm->valeurconfig[44],MainForm->valeurconfig[45],MainForm->valeurconfig[46]);
1837 else if (qual>MainForm->valeurconfig[55]) glColor3f(MainForm->valeurconfig[47],MainForm->valeurconfig[48],MainForm->valeurconfig[49]);
1838 else glColor3f(MainForm->valeurconfig[50],MainForm->valeurconfig[51],MainForm->valeurconfig[52]);
1839 }
1840 if ( ((qualite==2)&&(render==0)) || ((qualite==2)&&(render==1) && (MainForm->valeurconfig[56]==0.)))
1841 {
1842 int pos=(int) ((mgtri->get_origine()-1000)/10);
1843 if (pos>11) pos=11;
1844 if (pos<0) pos=0;
1845 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1846 }
1847 if (shrink)
1848 {
1849 double xg=0.25*(xyz1[0]+xyz2[0]+xyz3[0]+xyz4[0]);
1850 double yg=0.25*(xyz1[1]+xyz2[1]+xyz3[1]+xyz4[1]);
1851 double zg=0.25*(xyz1[2]+xyz2[2]+xyz3[2]+xyz4[2]);
1852 double x1=xg+facteur_shrink*(xyz1[0]-xg);
1853 double y1=yg+facteur_shrink*(xyz1[1]-yg);
1854 double z1=zg+facteur_shrink*(xyz1[2]-zg);
1855 double x2=xg+facteur_shrink*(xyz2[0]-xg);
1856 double y2=yg+facteur_shrink*(xyz2[1]-yg);
1857 double z2=zg+facteur_shrink*(xyz2[2]-zg);
1858 double x3=xg+facteur_shrink*(xyz3[0]-xg);
1859 double y3=yg+facteur_shrink*(xyz3[1]-yg);
1860 double z3=zg+facteur_shrink*(xyz3[2]-zg);
1861 double x4=xg+facteur_shrink*(xyz4[0]-xg);
1862 double y4=yg+facteur_shrink*(xyz4[1]-yg);
1863 double z4=zg+facteur_shrink*(xyz4[2]-zg);
1864 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
1865 {
1866 int pos=(int) ((noeud1->get_solution()-lmin)*12./(lmax-lmin));
1867 if (pos>11) pos=11;
1868 if (pos<0) pos=0;
1869 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1870 }
1871 glVertex3f(x1,y1,z1);
1872 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
1873 {
1874 int pos=(int) ((noeud3->get_solution()-lmin)*12./(lmax-lmin));
1875 if (pos>11) pos=11;
1876 if (pos<0) pos=0;
1877 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1878 }
1879 glVertex3f(x3,y3,z3);
1880 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
1881 {
1882 int pos=(int) ((noeud2->get_solution()-lmin)*12./(lmax-lmin));
1883 if (pos>11) pos=11;
1884 if (pos<0) pos=0;
1885 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1886 }
1887 glVertex3f(x2,y2,z2);
1888 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
1889 {
1890 int pos=(int) ((noeud1->get_solution()-lmin)*12./(lmax-lmin));
1891 if (pos>11) pos=11;
1892 if (pos<0) pos=0;
1893 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1894 }
1895 glVertex3f(x1,y1,z1);
1896 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
1897 {
1898 int pos=(int) ((noeud2->get_solution()-lmin)*12./(lmax-lmin));
1899 if (pos>11) pos=11;
1900 if (pos<0) pos=0;
1901 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1902 }
1903 glVertex3f(x2,y2,z2);
1904 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
1905 {
1906 int pos=(int) ((noeud4->get_solution()-lmin)*12./(lmax-lmin));
1907 if (pos>11) pos=11;
1908 if (pos<0) pos=0;
1909 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1910 }
1911 glVertex3f(x4,y4,z4);
1912 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
1913 {
1914 int pos=(int) ((noeud2->get_solution()-lmin)*12./(lmax-lmin));
1915 if (pos>11) pos=11;
1916 if (pos<0) pos=0;
1917 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1918 }
1919 glVertex3f(x2,y2,z2);
1920 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
1921 {
1922 int pos=(int) ((noeud3->get_solution()-lmin)*12./(lmax-lmin));
1923 if (pos>11) pos=11;
1924 if (pos<0) pos=0;
1925 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1926 }
1927 glVertex3f(x3,y3,z3);
1928 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
1929 {
1930 int pos=(int) ((noeud4->get_solution()-lmin)*12./(lmax-lmin));
1931 if (pos>11) pos=11;
1932 if (pos<0) pos=0;
1933 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1934 }
1935 glVertex3f(x4,y4,z4);
1936 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
1937 {
1938 int pos=(int) ((noeud1->get_solution()-lmin)*12./(lmax-lmin));
1939 if (pos>11) pos=11;
1940 if (pos<0) pos=0;
1941 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1942 }
1943 glVertex3f(x1,y1,z1);
1944 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
1945 {
1946 int pos=(int) ((noeud4->get_solution()-lmin)*12./(lmax-lmin));
1947 if (pos>11) pos=11;
1948 if (pos<0) pos=0;
1949 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1950 }
1951 glVertex3f(x4,y4,z4);
1952 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
1953 {
1954 int pos=(int) ((noeud3->get_solution()-lmin)*12./(lmax-lmin));
1955 if (pos>11) pos=11;
1956 if (pos<0) pos=0;
1957 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1958 }
1959 glVertex3f(x3,y3,z3);
1960 }
1961 else
1962 {
1963 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
1964 {
1965 int pos=(int) ((noeud1->get_solution()-lmin)*12./(lmax-lmin));
1966 if (pos>11) pos=11;
1967 if (pos<0) pos=0;
1968 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1969 }
1970 glVertex3f(xyz1[0],xyz1[1],xyz1[2]);
1971 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
1972 {
1973 int pos=(int) ((noeud3->get_solution()-lmin)*12./(lmax-lmin));
1974 if (pos>11) pos=11;
1975 if (pos<0) pos=0;
1976 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1977 }
1978 glVertex3f(xyz3[0],xyz3[1],xyz3[2]);
1979 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
1980 {
1981 int pos=(int) ((noeud2->get_solution()-lmin)*12./(lmax-lmin));
1982 if (pos>11) pos=11;
1983 if (pos<0) pos=0;
1984 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1985 }
1986 glVertex3f(xyz2[0],xyz2[1],xyz2[2]);
1987 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
1988 {
1989 int pos=(int) ((noeud1->get_solution()-lmin)*12./(lmax-lmin));
1990 if (pos>11) pos=11;
1991 if (pos<0) pos=0;
1992 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
1993 }
1994 glVertex3f(xyz1[0],xyz1[1],xyz1[2]);
1995 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
1996 {
1997 int pos=(int) ((noeud2->get_solution()-lmin)*12./(lmax-lmin));
1998 if (pos>11) pos=11;
1999 if (pos<0) pos=0;
2000 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
2001 }
2002 glVertex3f(xyz2[0],xyz2[1],xyz2[2]);
2003 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
2004 {
2005 int pos=(int) ((noeud4->get_solution()-lmin)*12./(lmax-lmin));
2006 if (pos>11) pos=11;
2007 if (pos<0) pos=0;
2008 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
2009 }
2010 glVertex3f(xyz4[0],xyz4[1],xyz4[2]);
2011 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
2012 {
2013 int pos=(int) ((noeud2->get_solution()-lmin)*12./(lmax-lmin));
2014 if (pos>11) pos=11;
2015 if (pos<0) pos=0;
2016 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
2017 }
2018 glVertex3f(xyz2[0],xyz2[1],xyz2[2]);
2019 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
2020 {
2021 int pos=(int) ((noeud3->get_solution()-lmin)*12./(lmax-lmin));
2022 if (pos>11) pos=11;
2023 if (pos<0) pos=0;
2024 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
2025 }
2026 glVertex3f(xyz3[0],xyz3[1],xyz3[2]);
2027 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
2028 {
2029 int pos=(int) ((noeud4->get_solution()-lmin)*12./(lmax-lmin));
2030 if (pos>11) pos=11;
2031 if (pos<0) pos=0;
2032 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
2033 }
2034 glVertex3f(xyz4[0],xyz4[1],xyz4[2]);
2035 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
2036 {
2037 int pos=(int) ((noeud1->get_solution()-lmin)*12./(lmax-lmin));
2038 if (pos>11) pos=11;
2039 if (pos<0) pos=0;
2040 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
2041 }
2042 glVertex3f(xyz1[0],xyz1[1],xyz1[2]);
2043 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
2044 {
2045 int pos=(int) ((noeud4->get_solution()-lmin)*12./(lmax-lmin));
2046 if (pos>11) pos=11;
2047 if (pos<0) pos=0;
2048 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
2049 }
2050 glVertex3f(xyz4[0],xyz4[1],xyz4[2]);
2051 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
2052 {
2053 int pos=(int) ((noeud3->get_solution()-lmin)*12./(lmax-lmin));
2054 if (pos>11) pos=11;
2055 if (pos<0) pos=0;
2056 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
2057 }
2058 glVertex3f(xyz3[0],xyz3[1],xyz3[2]);
2059 }
2060 }
2061 glEnd();
2062 if (affmaille)
2063 {
2064 for (int i=0;i<nb;i++)
2065 {
2066 MG_TETRA* mgtri=lst_tetra[i];
2067 if (N12->Checked)
2068 if (!estdansfiltre(mgtri->get_id())) continue;
2069 BOITE_3D boitmp=mgtri->get_boite_3D();
2070 if (!(boitmp*boite2)) continue;
2071 MG_NOEUD* noeud1=mgtri->get_noeud1();
2072 MG_NOEUD* noeud2=mgtri->get_noeud2();
2073 MG_NOEUD* noeud3=mgtri->get_noeud3();
2074 MG_NOEUD* noeud4=mgtri->get_noeud4();
2075 double *xyz1=noeud1->get_coord();
2076 double *xyz2=noeud2->get_coord();
2077 double *xyz3=noeud3->get_coord();
2078 double *xyz4=noeud4->get_coord();
2079 unsigned long id=mgtri->get_id();
2080 char mess[30];
2081 sprintf(mess,"%lu",id);
2082 if ( ((qualite==1)&&(render==0)) || ((qualite==1)&&(render==1) && (MainForm->valeurconfig[56]==0.)))
2083 {
2084 double qual=OPERATEUR::qualite_tetra(xyz1,xyz2,xyz3,xyz4);
2085 if (qual>MainForm->valeurconfig[53]) glColor3f(MainForm->valeurconfig[41],MainForm->valeurconfig[42],MainForm->valeurconfig[43]);
2086 else if (qual>MainForm->valeurconfig[54]) glColor3f(MainForm->valeurconfig[44],MainForm->valeurconfig[45],MainForm->valeurconfig[46]);
2087 else if (qual>MainForm->valeurconfig[55]) glColor3f(MainForm->valeurconfig[47],MainForm->valeurconfig[48],MainForm->valeurconfig[49]);
2088 else glColor3f(MainForm->valeurconfig[50],MainForm->valeurconfig[51],MainForm->valeurconfig[52]);
2089 }
2090 if ( ((qualite==2)&&(render==0)) || ((qualite==2)&&(render==1) && (MainForm->valeurconfig[56]==0.)))
2091 {
2092 int pos=(int) ((mgtri->get_origine()-1000)/10);
2093 if (pos>11) pos=11;
2094 if (pos<0) pos=0;
2095 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
2096 }
2097 glRasterPos3f((xyz1[0]+xyz2[0]+xyz3[0]+xyz4[0])/4.,(xyz1[1]+xyz2[1]+xyz3[1]+xyz4[1])/4.,(xyz1[2]+xyz2[2]+xyz3[2]+xyz4[2])/4.);
2098 glListBase (1000);
2099 glCallLists (strlen(mess), GL_UNSIGNED_BYTE, mess);
2100 }
2101 }
2102 if (render==2)
2103 {
2104 glDisable(GL_LIGHTING);
2105 glDisable(GL_LIGHT0);
2106 glDisable(GL_LIGHT1);
2107 }
2108 }
2109 }
2110 //---------------------------------------------------------------------------
2111 void __fastcall TVisuWinform::dessineaxe(void)
2112 {
2113 double d=max(boite.get_xmax()-boite.get_xmin(),boite.get_ymax()-boite.get_ymin());
2114 d=max(d,boite.get_zmax()-boite.get_zmin());
2115 d=d*MainForm->valeurconfig[10];
2116 glLineWidth(MainForm->valeurconfig[9]);
2117 glBegin(GL_LINES);
2118 glColor3f(MainForm->valeurconfig[0],MainForm->valeurconfig[1],MainForm->valeurconfig[2]);
2119 glVertex3f(0.0,0.0,0.0);
2120 glVertex3f(d,0.0,0.0);
2121 glColor3f(MainForm->valeurconfig[3],MainForm->valeurconfig[4],MainForm->valeurconfig[5]);
2122 glVertex3f(0.0,0.0,0.0);
2123 glVertex3f(0.0,d,0.0);
2124 glColor3f(MainForm->valeurconfig[6],MainForm->valeurconfig[7],MainForm->valeurconfig[8]);
2125 glVertex3f(0.0,0.0,0.0);
2126 glVertex3f(0.0,0.0,d);
2127 glEnd();
2128
2129 }
2130 //---------------------------------------------------------------------------
2131
2132 void __fastcall TVisuWinform::FormKeyDown(TObject *Sender, WORD &Key,
2133 TShiftState Shift)
2134 {
2135 transformation(Sender,Key,Shift);
2136 }
2137 //---------------------------------------------------------------------------
2138 void __fastcall TVisuWinform::redess(void)
2139 {
2140 wglMakeCurrent(hdc,hrc);
2141 glClearColor(MainForm->valeurconfig[11],MainForm->valeurconfig[12],MainForm->valeurconfig[13], 0.0f);
2142 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
2143 if (TreeView1->Enabled==false) dessinegeo(); else {dessinemai();dessinemaifem();}
2144 if (axe==1) dessineaxe();
2145 glFlush();
2146 SwapBuffers(hdc);
2147 }
2148
2149 //---------------------------------------------------------------------------
2150 void __fastcall TVisuWinform::recadre(double dx,double dy,int etat)
2151 {
2152 wglMakeCurrent(hdc,hrc);
2153 GLfloat w = ClientWidth-PageControl1->Width;
2154 GLfloat h = ClientHeight;
2155 char mess[255];
2156 if (etat==0) glViewport(0, 0, w, h);
2157 glMatrixMode(GL_PROJECTION);
2158 glLoadIdentity();
2159 double d=max(boite.get_xmax()-boite.get_xmin(),boite.get_ymax()-boite.get_ymin());
2160 d=max(d,boite.get_zmax()-boite.get_zmin());
2161 d=d*1.5/2.;
2162 double aspect=w/h;
2163 double xmin,ymin,xmax,ymax;
2164 if (w<h) xmin=boite.get_xcentre()-d+dx; else xmin=boite.get_xcentre()-d*aspect+dx;
2165 if (w<h) ymin=boite.get_ycentre()-d/aspect+dy; else ymin=boite.get_ycentre()-d+dy;
2166 double zmin=boite.get_zcentre()-100*d;
2167 if (w<h) xmax=xmin+2.*d; else xmax=xmin+2.*d*aspect;
2168 if (w<h) ymax=ymin+2.*d/aspect; else ymax=ymin+2.*d;
2169 double zmax=zmin+200.*d;
2170 glOrtho(xmin,xmax,ymin,ymax,zmin,zmax);
2171 }
2172 //---------------------------------------------------------------------------
2173
2174 void __fastcall TVisuWinform::initvue(void)
2175 {
2176 wglMakeCurrent(hdc,hrc);
2177 glMatrixMode(GL_MODELVIEW);
2178 glLoadIdentity();
2179 glTranslated(boite.get_xcentre(),boite.get_ycentre(),boite.get_zcentre());
2180 /*glRotatef(-90., 0.0, 1.0, 0.0);
2181 glRotatef(-90., 1.0, 0.0, 0.0);
2182 glRotatef(45., 0.0, 1.0, 0.0);
2183 glRotatef(-45., 0.0, 0.0, 1.0);*/
2184 glRotatef(35.26, 1.0, 0.0, 0.0);
2185 glRotatef(45., 0.0, 1.0, 0.0);
2186 glRotatef(-90., 1.0, 0.0, 0.0);
2187 glRotatef(180., 0.0, 0.0, 1.0);
2188
2189
2190 glTranslated(-boite.get_xcentre(),-boite.get_ycentre(),-boite.get_zcentre());
2191 }
2192
2193
2194 void __fastcall TVisuWinform::FormMouseWheelDown(TObject *Sender,
2195 TShiftState Shift, TPoint &MousePos, bool &Handled)
2196 {
2197 wglMakeCurrent(hdc,hrc);
2198 glMatrixMode(GL_MODELVIEW);
2199 zoom++;
2200 glTranslated(boite.get_xcentre(),boite.get_ycentre(),boite.get_zcentre());
2201 glScalef(1.1,1.1,1.1);
2202 glTranslated(-boite.get_xcentre(),-boite.get_ycentre(),-boite.get_zcentre());
2203 redess();
2204 }
2205 //---------------------------------------------------------------------------
2206
2207
2208 void __fastcall TVisuWinform::FormMouseWheelUp(TObject *Sender,
2209 TShiftState Shift, TPoint &MousePos, bool &Handled)
2210 {
2211 wglMakeCurrent(hdc,hrc);
2212 glMatrixMode(GL_MODELVIEW);
2213 zoom--;
2214 glTranslated(boite.get_xcentre(),boite.get_ycentre(),boite.get_zcentre());
2215 glScalef(1./1.1,1./1.1,1./1.1);
2216 glTranslated(-boite.get_xcentre(),-boite.get_ycentre(),-boite.get_zcentre());
2217 redess();
2218 }
2219 //---------------------------------------------------------------------------
2220
2221 void __fastcall TVisuWinform::Fermer1Click(TObject *Sender)
2222 {
2223 Close();
2224 }
2225 //---------------------------------------------------------------------------
2226
2227
2228 void __fastcall TVisuWinform::FormMouseDown(TObject *Sender,
2229 TMouseButton Button, TShiftState Shift, int X, int Y)
2230 {
2231 if (Button==mbRight)
2232 {
2233 if (Shift.Contains(ssCtrl))
2234 {
2235 TPoint pt(X,Y);
2236 TPoint pt2=ClientToScreen(pt);
2237 PopupMenu2->Popup(pt2.x,pt2.y);
2238 }
2239 else if (debut_trans==false)
2240 {
2241 debut_trans=true;
2242 xdepart=X;
2243 ydepart=Y;
2244 }
2245 }
2246 if (Button==mbMiddle)
2247 if (debut_rot==false)
2248 {
2249 debut_rot=true;
2250 xrot=X;
2251 yrot=Y;
2252 }
2253
2254 }
2255 //---------------------------------------------------------------------------
2256
2257 void __fastcall TVisuWinform::FormMouseUp(TObject *Sender,
2258 TMouseButton Button, TShiftState Shift, int X, int Y)
2259 {
2260 if (Button==mbRight)
2261 if (debut_trans==true)
2262 {
2263 GLfloat w = ClientWidth-PageControl1->Width;
2264 GLfloat h = ClientHeight;
2265 double aspect=w/h;
2266 debut_trans=false;
2267 double d=max(boite.get_xmax()-boite.get_xmin(),boite.get_ymax()-boite.get_ymin());
2268 d=max(d,boite.get_zmax()-boite.get_zmin());
2269 d=d*1.5;
2270 double xmin,ymin,xmax,ymax;
2271 if (w<h) xmin=boite.get_xcentre()-d+dx; else xmin=boite.get_xcentre()-d*aspect+dx;
2272 if (w<h) ymin=boite.get_ycentre()-d/aspect+dy; else ymin=boite.get_ycentre()-d+dy;
2273 if (w<h) xmax=xmin+2.*d; else xmax=xmin+2.*d*aspect;
2274 if (w<h) ymax=ymin+2.*d/aspect; else ymax=ymin+2.*d;
2275 dx=dx+(xdepart-X)/2./w*(xmax-xmin);
2276 dy=dy-(ydepart-Y)/2./h*(ymax-ymin);
2277 recadre(dx,dy,1);
2278 redess();
2279 xdepart=X;
2280 ydepart=Y;
2281 }
2282
2283 if (Button==mbMiddle) debut_rot=false;
2284 }
2285 //---------------------------------------------------------------------------
2286
2287 void __fastcall TVisuWinform::FormMouseMove(TObject *Sender,
2288 TShiftState Shift, int X, int Y)
2289 {
2290 if (debut_trans==true)
2291 {
2292 GLfloat w = ClientWidth-PageControl1->Width;
2293 GLfloat h = ClientHeight;
2294 double aspect=w/h;
2295 double d=max(boite.get_xmax()-boite.get_xmin(),boite.get_ymax()-boite.get_ymin());
2296 d=max(d,boite.get_zmax()-boite.get_zmin());
2297 d=d*1.5;
2298 double xmin,ymin,xmax,ymax;
2299 if (w<h) xmin=boite.get_xcentre()-d+dx; else xmin=boite.get_xcentre()-d*aspect+dx;
2300 if (w<h) ymin=boite.get_ycentre()-d/aspect+dy; else ymin=boite.get_ycentre()-d+dy;
2301 if (w<h) xmax=xmin+2.*d; else xmax=xmin+2.*d*aspect;
2302 if (w<h) ymax=ymin+2.*d/aspect; else ymax=ymin+2.*d;
2303 dx=dx+(xdepart-X)/2./w*(xmax-xmin);
2304 dy=dy-(ydepart-Y)/2./h*(ymax-ymin);
2305 recadre(dx,dy,1);
2306 redess();
2307 xdepart=X;
2308 ydepart=Y;
2309 }
2310 if (debut_rot==true)
2311 {
2312 GLfloat w = ClientWidth-PageControl1->Width;
2313 GLfloat h = ClientHeight;
2314 double deltax=X-xrot;
2315 double deltay=Y-yrot;
2316 double norme=deltax*deltax+deltay*deltay;
2317 norme=sqrt(norme);
2318 if (norme>=1.)
2319 {
2320 glMatrixMode(GL_MODELVIEW);
2321 deltax=deltax*1.0/norme;
2322 deltay=deltay*1.0/norme;
2323 GLdouble matriceproj[16],matricevue[16];
2324 GLint matriceport[4];
2325 glGetIntegerv(GL_VIEWPORT,matriceport);
2326 glGetDoublev(GL_MODELVIEW_MATRIX,matricevue);
2327 glGetDoublev(GL_PROJECTION_MATRIX,matriceproj);
2328 double orx,ory,orz;
2329 double rx,ry,rz;
2330 gluUnProject((GLdouble)xrot,(GLdouble)yrot,0.,matricevue,matriceproj,matriceport,&orx,&ory,&orz);
2331 gluUnProject(xrot+deltay,yrot+deltax,0.,matricevue,matriceproj,matriceport,&rx,&ry,&rz);
2332 rx=rx-orx;
2333 ry=ry-ory;
2334 rz=rz-orz;
2335 double norme2=sqrt(rx*rx+ry*ry+rz*rz);
2336 rx=rx/norme2;
2337 ry=ry/norme2;
2338 rz=rz/norme2;
2339 glTranslated(boite.get_xcentre(),boite.get_ycentre(),boite.get_zcentre());
2340 glRotatef(norme/sqrt(w*h)*360, rx, ry, rz);
2341 glTranslated(-boite.get_xcentre(),-boite.get_ycentre(),-boite.get_zcentre());
2342 redess();
2343 }
2344 xrot=X;
2345 yrot=Y;
2346 }
2347
2348 }
2349 //---------------------------------------------------------------------------
2350
2351
2352
2353
2354
2355 void __fastcall TVisuWinform::TreeView1KeyDown(TObject *Sender, WORD &Key,
2356 TShiftState Shift)
2357 {
2358 transformation(Sender,Key,Shift);
2359 }
2360 //---------------------------------------------------------------------------
2361 void __fastcall TVisuWinform::transformation(TObject *Sender, WORD &Key,TShiftState Shift)
2362 {
2363 wglMakeCurrent(hdc,hrc);
2364 GLfloat w = ClientWidth-PageControl1->Width;
2365 GLfloat h = ClientHeight;
2366 glMatrixMode(GL_MODELVIEW);
2367 double un=0.005*min(w,h);
2368 if (Key==VK_LEFT)
2369 {
2370 dx=dx+un;
2371 recadre(dx,dy,1);
2372 }
2373 if (Key==VK_RIGHT)
2374 {
2375 dx=dx-un;
2376 recadre(dx,dy,1);
2377 }
2378 if (Key==VK_UP)
2379 {
2380 dy=dy-un;
2381 recadre(dx,dy,1);
2382 }
2383 if (Key==VK_DOWN)
2384 {
2385 dy=dy+un;
2386 recadre(dx,dy,1);
2387 }
2388 if(Key == VK_F1)
2389 {
2390 zoom++;
2391 glTranslated(boite.get_xcentre(),boite.get_ycentre(),boite.get_zcentre());
2392 glScalef(1.1,1.1,1.1);
2393 glTranslated(-boite.get_xcentre(),-boite.get_ycentre(),-boite.get_zcentre());
2394 }
2395 if(Key == VK_F2)
2396 {
2397 zoom--;
2398 glTranslated(boite.get_xcentre(),boite.get_ycentre(),boite.get_zcentre());
2399 glScalef(1./1.1,1./1.1,1./1.1);
2400 glTranslated(-boite.get_xcentre(),-boite.get_ycentre(),-boite.get_zcentre());
2401 }
2402 if(Key == VK_F3)
2403 {
2404 dx=0.;
2405 dy=0.;
2406 zoom=0;
2407 recadre(dx,dy,1);
2408 initvue();
2409 }
2410 if(Key == VK_F4)
2411 {
2412 if (zoom>0)
2413 glScalef(1./pow(1.1,zoom),1./pow(1.1,zoom),1./pow(1.1,zoom));
2414 if (zoom<0)
2415 glScalef(pow(1.1,-zoom),pow(1.1,-zoom),pow(1.1,-zoom));
2416 zoom=0;
2417 dx=0;
2418 dy=0;
2419 recadre(dx,dy,1);
2420 }
2421 if(Key == VK_HOME)
2422 {
2423 glTranslated(boite.get_xcentre(),boite.get_ycentre(),boite.get_zcentre());
2424 glRotatef(-5, 0.0, 1.0, 0.0);
2425 glTranslated(-boite.get_xcentre(),-boite.get_ycentre(),-boite.get_zcentre());
2426 }
2427 if(Key == VK_END)
2428 {
2429 glTranslated(boite.get_xcentre(),boite.get_ycentre(),boite.get_zcentre());
2430 glRotatef(5, 0.0, 1.0, 0.0);
2431 glTranslated(-boite.get_xcentre(),-boite.get_ycentre(),-boite.get_zcentre());
2432 }
2433 if(Key == VK_INSERT)
2434 {
2435 glTranslated(boite.get_xcentre(),boite.get_ycentre(),boite.get_zcentre());
2436 glRotatef(-5, 1.0, 0.0, 0.0);
2437 glTranslated(-boite.get_xcentre(),-boite.get_ycentre(),-boite.get_zcentre());
2438 }
2439 if(Key == VK_DELETE)
2440 {
2441 glTranslated(boite.get_xcentre(),boite.get_ycentre(),boite.get_zcentre());
2442 glRotatef(5, 1.0, 0.0, 0.0);
2443 glTranslated(-boite.get_xcentre(),-boite.get_ycentre(),-boite.get_zcentre());
2444 }
2445 if(Key == VK_PRIOR)
2446 {
2447 glTranslated(boite.get_xcentre(),boite.get_ycentre(),boite.get_zcentre());
2448 glRotatef(-5, 0.0, 0.0, 1.0);
2449 glTranslated(-boite.get_xcentre(),-boite.get_ycentre(),-boite.get_zcentre());
2450 }
2451 if(Key == VK_NEXT)
2452 {
2453 glTranslated(boite.get_xcentre(),boite.get_ycentre(),boite.get_zcentre());
2454 glRotatef(5, 0.0, 0.0, 1.0);
2455 glTranslated(-boite.get_xcentre(),-boite.get_ycentre(),-boite.get_zcentre());
2456 }
2457 if (Key==VK_ADD)
2458 {
2459 facteur_shrink=facteur_shrink+0.05;
2460 if (facteur_shrink>1.) facteur_shrink=1;
2461 }
2462 if (Key==VK_SUBTRACT)
2463 {
2464 facteur_shrink=facteur_shrink-0.05;
2465 if (facteur_shrink<0.) facteur_shrink=0.;
2466 }
2467
2468 redess();
2469 }
2470 //---------------------------------------------------------------------------
2471
2472
2473
2474 void __fastcall TVisuWinform::shrinkonExecute(TObject *Sender)
2475 {
2476 shrink=1;
2477 redess();
2478 }
2479 //---------------------------------------------------------------------------
2480
2481 void __fastcall TVisuWinform::shrinkoffExecute(TObject *Sender)
2482 {
2483 shrink=0;
2484 redess();
2485 }
2486 //---------------------------------------------------------------------------
2487
2488 void __fastcall TVisuWinform::renderfilExecute(TObject *Sender)
2489 {
2490 render=0;
2491 redess();
2492 }
2493 //---------------------------------------------------------------------------
2494
2495 void __fastcall TVisuWinform::rendershadeExecute(TObject *Sender)
2496 {
2497 render=1;
2498 redess();
2499 }
2500 //---------------------------------------------------------------------------
2501
2502 void __fastcall TVisuWinform::axeonExecute(TObject *Sender)
2503 {
2504 axe=1;
2505 redess();
2506 }
2507 //---------------------------------------------------------------------------
2508
2509 void __fastcall TVisuWinform::axeoffExecute(TObject *Sender)
2510 {
2511 axe=0;
2512 redess();
2513 }
2514 //---------------------------------------------------------------------------
2515
2516 void __fastcall TVisuWinform::qualiteonExecute(TObject *Sender)
2517 {
2518 qualite=1;
2519 redess();
2520 }
2521 //---------------------------------------------------------------------------
2522
2523 void __fastcall TVisuWinform::qualiteoffExecute(TObject *Sender)
2524 {
2525 qualite=0;
2526 redess();
2527 }
2528 //---------------------------------------------------------------------------
2529
2530 void __fastcall TVisuWinform::renderlightExecute(TObject *Sender)
2531 {
2532 render=2;
2533 redess();
2534 }
2535 //---------------------------------------------------------------------------
2536
2537 void __fastcall TVisuWinform::noeudonExecute(TObject *Sender)
2538 {
2539 noeud=1;
2540 redess();
2541 }
2542 //---------------------------------------------------------------------------
2543
2544 void __fastcall TVisuWinform::noeudoffExecute(TObject *Sender)
2545 {
2546 noeud=0;
2547 redess();
2548 }
2549 //---------------------------------------------------------------------------
2550
2551 void __fastcall TVisuWinform::configExecute(TObject *Sender)
2552 {
2553 configwin->ShowModal();
2554 }
2555 //---------------------------------------------------------------------------
2556
2557 void __fastcall TVisuWinform::FileExitItemClick(TObject *Sender)
2558 {
2559 TerminateProcess(GetCurrentProcess(),0);
2560 }
2561 //---------------------------------------------------------------------------
2562
2563 void __fastcall TVisuWinform::f3Execute(TObject *Sender)
2564 {
2565 dx=0.;
2566 dy=0.;
2567 zoom=0;
2568 recadre(dx,dy,1);
2569 initvue();
2570 redess();
2571 }
2572 //---------------------------------------------------------------------------
2573
2574 void __fastcall TVisuWinform::f4Execute(TObject *Sender)
2575 {
2576 glMatrixMode(GL_MODELVIEW);
2577 if (zoom>0)
2578 glScalef(1./pow(1.1,zoom),1./pow(1.1,zoom),1./pow(1.1,zoom));
2579 if (zoom<0)
2580 glScalef(pow(1.1,-zoom),pow(1.1,-zoom),pow(1.1,-zoom));
2581 zoom=0;
2582 dx=0;
2583 dy=0;
2584 recadre(dx,dy,1);
2585 redess();
2586 }
2587 //---------------------------------------------------------------------------
2588
2589 void __fastcall TVisuWinform::xmExecute(TObject *Sender)
2590 {
2591 glMatrixMode(GL_MODELVIEW);
2592 glTranslated(boite.get_xcentre(),boite.get_ycentre(),boite.get_zcentre());
2593 glRotatef(-5, 1.0, 0.0, 0.0);
2594 glTranslated(-boite.get_xcentre(),-boite.get_ycentre(),-boite.get_zcentre());
2595 redess();
2596 }
2597 //---------------------------------------------------------------------------
2598
2599 void __fastcall TVisuWinform::xpExecute(TObject *Sender)
2600 {
2601 glMatrixMode(GL_MODELVIEW);
2602 glTranslated(boite.get_xcentre(),boite.get_ycentre(),boite.get_zcentre());
2603 glRotatef(5, 1.0, 0.0, 0.0);
2604 glTranslated(-boite.get_xcentre(),-boite.get_ycentre(),-boite.get_zcentre());
2605 redess();
2606 }
2607 //---------------------------------------------------------------------------
2608
2609 void __fastcall TVisuWinform::ymExecute(TObject *Sender)
2610 {
2611 glMatrixMode(GL_MODELVIEW);
2612 glTranslated(boite.get_xcentre(),boite.get_ycentre(),boite.get_zcentre());
2613 glRotatef(-5, 0.0, 1.0, 0.0);
2614 glTranslated(-boite.get_xcentre(),-boite.get_ycentre(),-boite.get_zcentre());
2615 redess();
2616 }
2617 //---------------------------------------------------------------------------
2618
2619 void __fastcall TVisuWinform::ypExecute(TObject *Sender)
2620 {
2621 glMatrixMode(GL_MODELVIEW);
2622 glTranslated(boite.get_xcentre(),boite.get_ycentre(),boite.get_zcentre());
2623 glRotatef(5, 0.0, 1.0, 0.0);
2624 glTranslated(-boite.get_xcentre(),-boite.get_ycentre(),-boite.get_zcentre());
2625 redess();
2626 }
2627 //---------------------------------------------------------------------------
2628
2629 void __fastcall TVisuWinform::zmExecute(TObject *Sender)
2630 {
2631 glMatrixMode(GL_MODELVIEW);
2632 glTranslated(boite.get_xcentre(),boite.get_ycentre(),boite.get_zcentre());
2633 glRotatef(-5, 0.0, 0.0, 1.0);
2634 glTranslated(-boite.get_xcentre(),-boite.get_ycentre(),-boite.get_zcentre());
2635 redess();
2636 }
2637 //---------------------------------------------------------------------------
2638
2639 void __fastcall TVisuWinform::zpExecute(TObject *Sender)
2640 {
2641 glMatrixMode(GL_MODELVIEW);
2642 glTranslated(boite.get_xcentre(),boite.get_ycentre(),boite.get_zcentre());
2643 glRotatef(5, 0.0, 0.0, 1.0);
2644 glTranslated(-boite.get_xcentre(),-boite.get_ycentre(),-boite.get_zcentre());
2645 redess();
2646 }
2647 //---------------------------------------------------------------------------
2648
2649 void __fastcall TVisuWinform::afnoeudonExecute(TObject *Sender)
2650 {
2651 affnoeud=1;
2652 redess();
2653 }
2654 //---------------------------------------------------------------------------
2655
2656 void __fastcall TVisuWinform::afnoeudoffExecute(TObject *Sender)
2657 {
2658 affnoeud=0;
2659 redess();
2660 }
2661 //---------------------------------------------------------------------------
2662
2663 void __fastcall TVisuWinform::afmailleonExecute(TObject *Sender)
2664 {
2665 affmaille=1;
2666 redess();
2667 }
2668 //---------------------------------------------------------------------------
2669
2670 void __fastcall TVisuWinform::afmailleoffExecute(TObject *Sender)
2671 {
2672 affmaille=0;
2673 redess();
2674 }
2675 //---------------------------------------------------------------------------
2676 void __fastcall TVisuWinform::InitShading(void)
2677 {
2678 /*GLfloat infinite[] = { 1000.0, 1000.0, 1000.0, 1.0 };
2679 GLfloat infinite2[] = { 0.0, 0.0, -0.7, 0.0 };
2680 GLfloat ambient[] = { 0.5, 0.5, 0.5, 0.5 };
2681 GLfloat diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
2682 GLfloat specular[] = { 1.0, 1.0, 1.0, 1.0 };
2683 GLfloat mat_spec[]= {1.0,1.0,1.0,1.0};
2684 GLfloat mat_shi[]= {50.};
2685 diffuse[0]=MainForm->valeurconfig[34];
2686 diffuse[1]=MainForm->valeurconfig[35];
2687 diffuse[2]=MainForm->valeurconfig[36];
2688
2689
2690
2691 glShadeModel(GL_SMOOTH);
2692
2693 // glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
2694 glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
2695 //glLightfv(GL_LIGHT0, GL_SPECULAR, diffuse);;
2696 glLightfv(GL_LIGHT0, GL_POSITION, infinite);
2697 glMaterialfv(GL_FRONT,GL_SPECULAR,mat_spec);
2698 glMaterialfv(GL_FRONT,GL_SHININESS,mat_shi);
2699 glEnable(GL_LIGHTING);
2700 glEnable(GL_LIGHT0);
2701 //glEnable(GL_LIGHT1);
2702 glDepthFunc(GL_LESS);
2703 glEnable(GL_DEPTH_TEST);
2704 glEnable(GL_NORMALIZE);
2705 //glColorMaterial(GL_FRONT, GL_DIFFUSE);
2706 //glEnable(GL_COLOR_MATERIAL);*/
2707 }
2708 //---------------------------------------------------------------------------
2709
2710
2711 void __fastcall TVisuWinform::ComboBox1Change(TObject *Sender)
2712 {
2713 MG_SOLUTION* sol=NULL;
2714 FEM_SOLUTION* sol2=NULL;
2715 if ((unsigned int)ComboBox1->ItemIndex<gest->get_nb_mg_solution()) sol=gest->get_mg_solution(ComboBox1->ItemIndex);
2716 else sol2=gest->get_fem_solution(ComboBox1->ItemIndex-gest->get_nb_mg_solution());
2717 if (sol!=NULL)
2718 {
2719 ListBox1->Clear();
2720 int nb=sol->get_nb_champ();
2721 for (int i=0;i<nb;i++)
2722 ListBox1->Items->Add(sol->get_legende(i).c_str());
2723 if (ListBox1->ItemIndex==-1) CheckBox1->Checked=false;
2724 unsigned long idmai=sol->get_maillage()->get_id();
2725 char mess[30];
2726 sprintf(mess,"du maillage %lu",idmai) ;
2727 Label3->Caption=mess;
2728 if (CheckBox1->Checked==false)
2729 TabSheet3->TabVisible=false;
2730 }
2731 if (sol2!=NULL)
2732 {
2733 ListBox1->Clear();
2734 int nb=sol2->get_nb_champ();
2735 for (int i=0;i<nb;i++)
2736 ListBox1->Items->Add(sol2->get_legende(i).c_str());
2737 if (ListBox1->ItemIndex==-1) CheckBox1->Checked=false;
2738 unsigned long idmai=sol2->get_maillage()->get_id();
2739 char mess[30];
2740 sprintf(mess,"du maillage fem %lu",idmai) ;
2741 Label3->Caption=mess;
2742 if (CheckBox1->Checked==false)
2743 TabSheet3->TabVisible=false;
2744 }
2745 }
2746 //---------------------------------------------------------------------------
2747
2748 void __fastcall TVisuWinform::CheckBox1Click(TObject *Sender)
2749 {
2750 if (ListBox1->ItemIndex==-1)
2751 {
2752 CheckBox1->Checked=false;
2753 TabSheet3->TabVisible=false;
2754 }
2755 if ((ListBox1->ItemIndex!=-1) && (CheckBox1->Checked==true) )
2756 {
2757 MG_SOLUTION* sol=NULL;
2758 FEM_SOLUTION* sol2=NULL;
2759 if ((unsigned int)ComboBox1->ItemIndex<gest->get_nb_mg_solution()) sol=gest->get_mg_solution(ComboBox1->ItemIndex);
2760 else sol2=gest->get_fem_solution(ComboBox1->ItemIndex-gest->get_nb_mg_solution());
2761 if (sol!=NULL)
2762 {
2763 sol->active_solution(ListBox1->ItemIndex);
2764 lmin=sol->get_legende_min();
2765 lmax=sol->get_legende_max();
2766 TabSheet3->TabVisible=true;
2767 dessine_legende();
2768 }
2769 if (sol2!=NULL)
2770 {
2771 sol2->active_solution(ListBox1->ItemIndex);
2772 lmin=sol2->get_legende_min();
2773 lmax=sol2->get_legende_max();
2774 TabSheet3->TabVisible=true;
2775 dessine_legende();
2776 }
2777
2778 }
2779 if (CheckBox1->Checked==false)
2780 TabSheet3->TabVisible=false;
2781 if (CheckBox1->Checked==false) Button3->Visible=false; else Button3->Visible=true;
2782 initliste();
2783 redess();
2784 }
2785 //---------------------------------------------------------------------------
2786 void __fastcall TVisuWinform::ListBox1Click(TObject *Sender)
2787 {
2788 if ((ListBox1->ItemIndex!=-1) && (CheckBox1->Checked==true) )
2789 {
2790 MG_SOLUTION* sol=gest->get_mg_solution(ComboBox1->ItemIndex);
2791 FEM_SOLUTION* sol2=gest->get_fem_solution(ComboBox1->ItemIndex-gest->get_nb_mg_solution());
2792 if (sol!=NULL)
2793 {
2794 sol->active_solution(ListBox1->ItemIndex);
2795 lmin=sol->get_legende_min();
2796 lmax=sol->get_legende_max();
2797 TabSheet3->TabVisible=true;
2798 dessine_legende();
2799 redess();
2800 }
2801 if (sol2!=NULL)
2802 {
2803 sol2->active_solution(ListBox1->ItemIndex);
2804 lmin=sol2->get_legende_min();
2805 lmax=sol2->get_legende_max();
2806 TabSheet3->TabVisible=true;
2807 dessine_legende();
2808 redess();
2809 }
2810 }
2811
2812 }
2813 //---------------------------------------------------------------------------
2814 void __fastcall TVisuWinform::dessine_legende(void)
2815 {
2816 Label4->Color=(TColor)(RGB_r[11]+(RGB_g[11]<<8)+(RGB_b[11]<<16));
2817 Label5->Color=(TColor)(RGB_r[10]+(RGB_g[10]<<8)+(RGB_b[10]<<16));
2818 Label6->Color=(TColor)(RGB_r[9]+(RGB_g[9]<<8)+(RGB_b[9]<<16));
2819 Label7->Color=(TColor)(RGB_r[8]+(RGB_g[8]<<8)+(RGB_b[8]<<16));
2820 Label8->Color=(TColor)(RGB_r[7]+(RGB_g[7]<<8)+(RGB_b[7]<<16));
2821 Label9->Color=(TColor)(RGB_r[6]+(RGB_g[6]<<8)+(RGB_b[6]<<16));
2822 Label10->Color=(TColor)(RGB_r[5]+(RGB_g[5]<<8)+(RGB_b[5]<<16));
2823 Label11->Color=(TColor)(RGB_r[4]+(RGB_g[4]<<8)+(RGB_b[4]<<16));
2824 Label12->Color=(TColor)(RGB_r[3]+(RGB_g[3]<<8)+(RGB_b[3]<<16));
2825 Label13->Color=(TColor)(RGB_r[2]+(RGB_g[2]<<8)+(RGB_b[2]<<16));
2826 Label14->Color=(TColor)(RGB_r[1]+(RGB_g[1]<<8)+(RGB_b[1]<<16));
2827 Label15->Color=(TColor)(RGB_r[0]+(RGB_g[0]<<8)+(RGB_b[0]<<16));
2828
2829 Label4->Width=18;
2830 Label4->Height=18;
2831 Label5->Width=18;
2832 Label5->Height=18;
2833 Label5->Top=Label4->Top+Label4->Height;
2834 Label5->Left=Label4->Left;
2835 Label6->Width=18;
2836 Label6->Height=18;
2837 Label6->Top=Label5->Top+Label4->Height;
2838 Label6->Left=Label4->Left;
2839 Label7->Width=18;
2840 Label7->Height=18;
2841 Label7->Top=Label6->Top+Label4->Height;
2842 Label7->Left=Label4->Left;
2843 Label8->Width=18;
2844 Label8->Height=18;
2845 Label8->Top=Label7->Top+Label4->Height;
2846 Label8->Left=Label4->Left;
2847 Label9->Width=18;
2848 Label9->Height=18;
2849 Label9->Top=Label8->Top+Label4->Height;
2850 Label9->Left=Label4->Left;
2851 Label10->Width=18;
2852 Label10->Height=18;
2853 Label10->Top=Label9->Top+Label4->Height;
2854 Label10->Left=Label4->Left;
2855 Label11->Width=18;
2856 Label11->Height=18;
2857 Label11->Top=Label10->Top+Label4->Height;
2858 Label11->Left=Label4->Left;
2859 Label12->Width=18;
2860 Label12->Height=18;
2861 Label12->Top=Label11->Top+Label4->Height;
2862 Label12->Left=Label4->Left;
2863 Label13->Width=18;
2864 Label13->Height=18;
2865 Label13->Top=Label12->Top+Label4->Height;
2866 Label13->Left=Label4->Left;
2867 Label14->Width=18;
2868 Label14->Height=18;
2869 Label14->Top=Label13->Top+Label4->Height;
2870 Label14->Left=Label4->Left;
2871 Label15->Width=18;
2872 Label15->Height=18;
2873 Label15->Top=Label14->Top+Label4->Height;
2874 Label15->Left=Label4->Left;
2875
2876 Label16->Left=Label4->Left+2*Label4->Width;
2877 Label16->Top=Label4->Top-9;
2878 Label17->Left=Label4->Left+2*Label4->Width;
2879 Label17->Top=Label5->Top-9;
2880 Label18->Left=Label4->Left+2*Label4->Width;
2881 Label18->Top=Label6->Top-9;
2882 Label19->Left=Label4->Left+2*Label4->Width;
2883 Label19->Top=Label7->Top-9;
2884 Label20->Left=Label4->Left+2*Label4->Width;
2885 Label20->Top=Label8->Top-9;
2886 Label21->Left=Label4->Left+2*Label4->Width;
2887 Label21->Top=Label9->Top-9;
2888 Label22->Left=Label4->Left+2*Label4->Width;
2889 Label22->Top=Label10->Top-9;
2890 Label23->Left=Label4->Left+2*Label4->Width;
2891 Label23->Top=Label11->Top-9;
2892 Label24->Left=Label4->Left+2*Label4->Width;
2893 Label24->Top=Label12->Top-9;
2894 Label25->Left=Label4->Left+2*Label4->Width;
2895 Label25->Top=Label13->Top-9;
2896 Label26->Left=Label4->Left+2*Label4->Width;
2897 Label26->Top=Label14->Top-9;
2898 Label27->Left=Label4->Left+2*Label4->Width;
2899 Label27->Top=Label15->Top-9;
2900 Label28->Left=Label4->Left+2*Label4->Width;
2901 Label28->Top=Label15->Top+Label15->Height-9;
2902 char mess[30];
2903 sprintf(mess,"%le",lmin+12.*(lmax-lmin)/12.);
2904 Label16->Caption=mess;
2905 sprintf(mess,"%le",lmin+11.*(lmax-lmin)/12.);
2906 Label17->Caption=mess;
2907 sprintf(mess,"%le",lmin+10.*(lmax-lmin)/12.);
2908 Label18->Caption=mess;
2909 sprintf(mess,"%le",lmin+9.*(lmax-lmin)/12.);
2910 Label19->Caption=mess;
2911 sprintf(mess,"%le",lmin+8.*(lmax-lmin)/12.);
2912 Label20->Caption=mess;
2913 sprintf(mess,"%le",lmin+7.*(lmax-lmin)/12.);
2914 Label21->Caption=mess;
2915 sprintf(mess,"%le",lmin+6.*(lmax-lmin)/12.);
2916 Label22->Caption=mess;
2917 sprintf(mess,"%le",lmin+5.*(lmax-lmin)/12.);
2918 Label23->Caption=mess;
2919 sprintf(mess,"%le",lmin+4.*(lmax-lmin)/12.);
2920 Label24->Caption=mess;
2921 sprintf(mess,"%le",lmin+3.*(lmax-lmin)/12.);
2922 Label25->Caption=mess;
2923 sprintf(mess,"%le",lmin+2.*(lmax-lmin)/12.);
2924 Label26->Caption=mess;
2925 sprintf(mess,"%le",lmin+1.*(lmax-lmin)/12.);
2926 Label27->Caption=mess;
2927 sprintf(mess,"%le",lmin+0.*(lmax-lmin)/12.);
2928 Label28->Caption=mess;
2929 Label29->Caption=ListBox1->Items->Strings[ListBox1->ItemIndex];
2930
2931 }
2932 //---------------------------------------------------------------------------
2933
2934 void __fastcall TVisuWinform::CheckBox2Click(TObject *Sender)
2935 {
2936 CheckBox3->Checked=CheckBox2->Checked;
2937 redess();
2938 }
2939 //---------------------------------------------------------------------------
2940
2941
2942 void __fastcall TVisuWinform::CheckBox2KeyDown(TObject *Sender, WORD &Key,
2943 TShiftState Shift)
2944 {
2945 transformation(Sender,Key,Shift);
2946 }
2947 //---------------------------------------------------------------------------
2948
2949 void __fastcall TVisuWinform::ComboBox1KeyDown(TObject *Sender, WORD &Key,
2950 TShiftState Shift)
2951 {
2952 transformation(Sender,Key,Shift);
2953 }
2954 //---------------------------------------------------------------------------
2955
2956 void __fastcall TVisuWinform::CheckBox1KeyDown(TObject *Sender, WORD &Key,
2957 TShiftState Shift)
2958 {
2959 transformation(Sender,Key,Shift);
2960 }
2961 //---------------------------------------------------------------------------
2962
2963 void __fastcall TVisuWinform::ListBox1KeyDown(TObject *Sender, WORD &Key,
2964 TShiftState Shift)
2965 {
2966 transformation(Sender,Key,Shift);
2967 }
2968 //---------------------------------------------------------------------------
2969
2970 void __fastcall TVisuWinform::CheckBox3Click(TObject *Sender)
2971 {
2972 CheckBox2->Checked=CheckBox3->Checked;
2973 redess();
2974 }
2975 //---------------------------------------------------------------------------
2976
2977
2978
2979 void __fastcall TVisuWinform::Temprature2Click(TObject *Sender)
2980 {
2981 ajouterccf("Saisie d'une température","Tp",true,true,true,true,true) ;
2982 }
2983 //---------------------------------------------------------------------------
2984
2985 void __fastcall TVisuWinform::Montrerlaslection1Click(TObject *Sender)
2986 {
2987 if (Montrerlaslection1->Checked==true) Montrerlaslection1->Checked=false;
2988 else Montrerlaslection1->Checked=true;
2989 TreeView1Change(Sender,NULL);
2990 }
2991 //---------------------------------------------------------------------------
2992
2993 void __fastcall TVisuWinform::TreeView1Change(TObject *Sender,
2994 TTreeNode *Node)
2995 {
2996 if (Montrerlaslection1->Checked==false) {toposel=NULL;redess();MainForm->StatusBar->Panels->Items[2]->Text="";return;}
2997 TTreeNode* node=TreeView1->Selected;
2998 int nb=node->Count;
2999 MG_VOLUME* mgvol=NULL;
3000 MG_FACE* mgface=NULL;
3001 MG_ARETE* mgarete=NULL;
3002 int nb_geo=gest->get_nb_mg_geometrie();
3003 for (int i=0;i<nb_geo;i++)
3004 {
3005 MG_GEOMETRIE* mggeo=gest->get_mg_geometrie(i);
3006 if (nb==0)
3007 {
3008 TTreeNode* node_parent=node->Parent;
3009 mgvol=mggeo->get_mg_volumeid(atol(node->Text.c_str()));
3010 mgface=mggeo->get_mg_faceid(atol(node->Text.c_str()));
3011 mgarete=mggeo->get_mg_areteid(atol(node->Text.c_str()));
3012 MainForm->StatusBar->Panels->Items[2]->Text=node_parent->Text+" "+node->Text;;
3013 }
3014 }
3015 toposel=NULL;
3016 if (mgvol!=NULL) toposel=mgvol;
3017 if (mgface!=NULL) toposel=mgface;
3018 if (mgarete!=NULL) toposel=mgarete;
3019 redess();
3020 ActiveControl=NULL;
3021 }
3022 //---------------------------------------------------------------------------
3023
3024 void __fastcall TVisuWinform::TreeView1Click(TObject *Sender)
3025 {
3026 ActiveControl=NULL;
3027 }
3028 //---------------------------------------------------------------------------
3029
3030
3031
3032 void __fastcall TVisuWinform::Mesh9820001Click(TObject *Sender)
3033 {
3034 int nb=gest->get_nb_mg_maillage();
3035 char chaine[500];
3036 for (int i=0;i<nb;i++)
3037 {
3038 MG_MAILLAGE* mai=gest->get_mg_maillage(i);
3039 if (i==0) sprintf(chaine,"Maillage %lu|*.*", mai->get_id());
3040 else
3041 {
3042 char chaine2[200];
3043 sprintf(chaine2,"|Maillage %lu|*.*", mai->get_id());
3044 strcat(chaine,chaine2);
3045 }
3046 }
3047 SaveDialog1->Filter=chaine;
3048 if (SaveDialog1->Execute())
3049 {
3050 MG_MAILLAGE* mai=gest->get_mg_maillage(SaveDialog1->FilterIndex-1);
3051 string namefic=SaveDialog1->FileName.c_str();
3052 mai->exporter_mesh(namefic);
3053
3054 }
3055 }
3056 //---------------------------------------------------------------------------
3057
3058 void __fastcall TVisuWinform::Giref1Click(TObject *Sender)
3059 {
3060 int nb=gest->get_nb_mg_maillage();
3061 if (nb==0)
3062 {
3063 MessageBox(Handle,"Pas de maillage","Erreur",MB_OK);
3064 return ;
3065 }
3066 char chaine[500];
3067 for (int i=0;i<nb;i++)
3068 {
3069 MG_MAILLAGE* mai=gest->get_mg_maillage(i);
3070 if (i==0) sprintf(chaine,"Maillage %lu|*.*", mai->get_id());
3071 else
3072 {
3073 char chaine2[200];
3074 sprintf(chaine2,"|Maillage %lu|*.*", mai->get_id());
3075 strcat(chaine,chaine2);
3076 }
3077 }
3078 SaveDialog1->Filter=chaine;
3079 if (SaveDialog1->Execute())
3080 {
3081 MG_MAILLAGE* mai=gest->get_mg_maillage(SaveDialog1->FilterIndex-1);
3082 string namefic=SaveDialog1->FileName.c_str();
3083 mai->exporter_giref(namefic);
3084 }
3085
3086 }
3087 //---------------------------------------------------------------------------
3088
3089
3090
3091
3092
3093 void __fastcall TVisuWinform::ajouterccf(char* cap,char *type,int val,int sommet,int arete,int face,int volume)
3094 {
3095 ccfwinform->Caption=cap;
3096 int nb_geo=gest->get_nb_mg_geometrie();
3097 ccfwinform->ComboBox5->Clear();
3098 ccfwinform->ComboBox1->Clear();
3099 ccfwinform->ComboBox2->Clear();
3100 ccfwinform->ComboBox3->Clear();
3101 ccfwinform->ComboBox4->Clear();
3102 if (sommet)
3103 {
3104 ccfwinform->RadioButton1->Visible=true;
3105 ccfwinform->ComboBox1->Visible=true;
3106 }
3107 else
3108 {
3109 ccfwinform->RadioButton1->Visible=false;
3110 ccfwinform->ComboBox1->Visible=false;
3111 }
3112 if (arete)
3113 {
3114 ccfwinform->RadioButton2->Visible=true;
3115 ccfwinform->ComboBox2->Visible=true;
3116 }
3117 else
3118 {
3119 ccfwinform->RadioButton2->Visible=false;
3120 ccfwinform->ComboBox2->Visible=false;
3121 }
3122 if (face)
3123 {
3124 ccfwinform->RadioButton3->Visible=true;
3125 ccfwinform->ComboBox3->Visible=true;
3126 }
3127 else
3128 {
3129 ccfwinform->RadioButton3->Visible=false;
3130 ccfwinform->ComboBox3->Visible=false;
3131 }
3132 if (volume)
3133 {
3134 ccfwinform->RadioButton4->Visible=true;
3135 ccfwinform->ComboBox4->Visible=true;
3136 }
3137 else
3138 {
3139 ccfwinform->RadioButton4->Visible=false;
3140 ccfwinform->ComboBox4->Visible=false;
3141 }
3142 ccfwinform->CheckBox1->Visible=ccfwinform->ComboBox2->Visible;
3143 ccfwinform->CheckBox2->Visible=ccfwinform->ComboBox3->Visible;
3144 ccfwinform->CheckBox3->Visible=ccfwinform->ComboBox4->Visible;
3145
3146 for (int i=0;i<nb_geo;i++)
3147 {
3148 MG_GEOMETRIE* mggeo=gest->get_mg_geometrie(i);
3149 char mess[30];
3150 sprintf(mess,"%lu",mggeo->get_id());
3151 ccfwinform->ComboBox5->Items->Add(mess);
3152 }
3153 ccfwinform->active(gest,type);
3154 ccfwinform->Label4->Caption=Caption;
3155 ccfwinform->Edit1->ReadOnly=false;
3156 ccfwinform->Edit1->Text="";
3157 if (val==false)
3158 {
3159 ccfwinform->Edit1->Text="0";
3160 ccfwinform->Edit1->ReadOnly=true;
3161 }
3162 ccfwinform->ShowModal();
3163 }
3164 void __fastcall TVisuWinform::X1Click(TObject *Sender)
3165 {
3166 ajouterccf("Saisie d'un blocage selon l'axe x","Dx",false,true,true,true,true) ;
3167 }
3168 //---------------------------------------------------------------------------
3169
3170 void __fastcall TVisuWinform::Y1Click(TObject *Sender)
3171 {
3172 ajouterccf("Saisie d'un blocage selon l'axe y","Dy",false,true,true,true,true) ;
3173
3174 }
3175 //---------------------------------------------------------------------------
3176
3177 void __fastcall TVisuWinform::Z1Click(TObject *Sender)
3178 {
3179 ajouterccf("Saisie d'un blocage selon l'axe z","Dz",false,true,true,true,true) ;
3180
3181 }
3182 //---------------------------------------------------------------------------
3183
3184 void __fastcall TVisuWinform::Tous1Click(TObject *Sender)
3185 {
3186 ajouterccf("Saisie d'un blocage dans toutes les directions","Da",false,true,true,true,true) ;
3187
3188 }
3189 //---------------------------------------------------------------------------
3190
3191 void __fastcall TVisuWinform::X2Click(TObject *Sender)
3192 {
3193 ajouterccf("Saisie d'une force selon l'axe x","Fx",true,true,false,false,false) ;
3194
3195 }
3196 //---------------------------------------------------------------------------
3197
3198 void __fastcall TVisuWinform::Y2Click(TObject *Sender)
3199 {
3200 ajouterccf("Saisie d'une force selon l'axe y","Fy",true,true,false,false,false) ;
3201
3202 }
3203 //---------------------------------------------------------------------------
3204
3205 void __fastcall TVisuWinform::Z2Click(TObject *Sender)
3206 {
3207 ajouterccf("Saisie d'une force selon l'axe z","Fz",true,true,false,false,false) ;
3208
3209 }
3210 //---------------------------------------------------------------------------
3211
3212 void __fastcall TVisuWinform::Matriaux1Click(TObject *Sender)
3213 {
3214 Tmatwinform *Child;
3215 Child = new Tmatwinform(Application);
3216 Child->Caption=Caption;
3217 Child->gest=gest;
3218 Child->Label6->Caption=Caption;
3219 Child->ShowModal();
3220 }
3221 //---------------------------------------------------------------------------
3222
3223
3224 void __fastcall TVisuWinform::mailleonExecute(TObject *Sender)
3225 {
3226 maille=1;
3227 redess();
3228 }
3229 //---------------------------------------------------------------------------
3230
3231 void __fastcall TVisuWinform::mailleoffExecute(TObject *Sender)
3232 {
3233 maille=0;
3234 redess();
3235 }
3236 //---------------------------------------------------------------------------
3237
3238 void __fastcall TVisuWinform::N1D1Click(TObject *Sender)
3239 {
3240 N1D1->Checked=!N1D1->Checked;
3241 noeud=0;
3242 if (N0D1->Checked) noeud=noeud+1;
3243 if (N1D1->Checked) noeud=noeud+2;
3244 if (N2D1->Checked) noeud=noeud+4;
3245 if (N3D1->Checked) noeud=noeud+8;
3246 redess();
3247 }
3248 //---------------------------------------------------------------------------
3249
3250 void __fastcall TVisuWinform::N2D1Click(TObject *Sender)
3251 {
3252 N2D1->Checked=!N2D1->Checked;
3253 noeud=0;
3254 if (N0D1->Checked) noeud=noeud+1;
3255 if (N1D1->Checked) noeud=noeud+2;
3256 if (N2D1->Checked) noeud=noeud+4;
3257 if (N3D1->Checked) noeud=noeud+8;
3258 redess();
3259 }
3260 //---------------------------------------------------------------------------
3261
3262 void __fastcall TVisuWinform::N3D1Click(TObject *Sender)
3263 {
3264 N3D1->Checked=!N3D1->Checked;
3265 noeud=0;
3266 if (N0D1->Checked) noeud=noeud+1;
3267 if (N1D1->Checked) noeud=noeud+2;
3268 if (N2D1->Checked) noeud=noeud+4;
3269 if (N3D1->Checked) noeud=noeud+8;
3270 redess();
3271 }
3272 //---------------------------------------------------------------------------
3273
3274
3275
3276 void __fastcall TVisuWinform::Tous2Click(TObject *Sender)
3277 {
3278 N1D1->Checked=true;
3279 N2D1->Checked=true;
3280 N3D1->Checked=true;
3281 noeud=15;
3282 redess();
3283 }
3284 //---------------------------------------------------------------------------
3285
3286
3287 void __fastcall TVisuWinform::N1D2Click(TObject *Sender)
3288 {
3289 N1D2->Checked=!N1D2->Checked;
3290 maille=0;
3291 if (N1D2->Checked) maille=maille+1;
3292 if (N2D2->Checked) maille=maille+2;
3293 if (N3D2->Checked) maille=maille+4;
3294 redess();
3295 }
3296 //---------------------------------------------------------------------------
3297
3298 void __fastcall TVisuWinform::N2D2Click(TObject *Sender)
3299 {
3300 N2D2->Checked=!N2D2->Checked;
3301 maille=0;
3302 if (N1D2->Checked) maille=maille+1;
3303 if (N2D2->Checked) maille=maille+2;
3304 if (N3D2->Checked) maille=maille+4;
3305 redess();
3306 }
3307 //---------------------------------------------------------------------------
3308
3309 void __fastcall TVisuWinform::N3D2Click(TObject *Sender)
3310 {
3311 N3D2->Checked=!N3D2->Checked;
3312 maille=0;
3313 if (N1D2->Checked) maille=maille+1;
3314 if (N2D2->Checked) maille=maille+2;
3315 if (N3D2->Checked) maille=maille+4;
3316 redess();
3317 }
3318 //---------------------------------------------------------------------------
3319
3320 void __fastcall TVisuWinform::Tous3Click(TObject *Sender)
3321 {
3322 N1D2->Checked=true;
3323 N2D2->Checked=true;
3324 N3D2->Checked=true;
3325 maille=7;
3326 redess();
3327 }
3328 //---------------------------------------------------------------------------
3329
3330 void __fastcall TVisuWinform::Aucun1Click(TObject *Sender)
3331 {
3332 N0D1->Checked=false;
3333 N1D1->Checked=false;
3334 N2D1->Checked=false;
3335 N3D1->Checked=false;
3336 noeud=0;
3337 redess();
3338 }
3339 //---------------------------------------------------------------------------
3340
3341 void __fastcall TVisuWinform::Aucun2Click(TObject *Sender)
3342 {
3343 N1D2->Checked=false;
3344 N2D2->Checked=false;
3345 N3D2->Checked=false;
3346 maille=0;
3347 redess();
3348 }
3349
3350 //---------------------------------------------------------------------------
3351
3352 void __fastcall TVisuWinform::X3Click(TObject *Sender)
3353 {
3354 ajouterccf("Saisie d'une pression selon l'axe x","Px",true,false,true,true,false) ;
3355
3356 }
3357 //---------------------------------------------------------------------------
3358
3359 void __fastcall TVisuWinform::Y3Click(TObject *Sender)
3360 {
3361 ajouterccf("Saisie d'une pression selon l'axe y","Py",true,false,true,true,false) ;
3362
3363 }
3364 //---------------------------------------------------------------------------
3365
3366 void __fastcall TVisuWinform::Z3Click(TObject *Sender)
3367 {
3368 ajouterccf("Saisie d'une pression selon l'axe z","Pz",true,false,true,true,false) ;
3369
3370 }
3371 //---------------------------------------------------------------------------
3372
3373 void __fastcall TVisuWinform::Normal1Click(TObject *Sender)
3374 {
3375 ajouterccf("Saisie d'une pression normale","Pn",true,false,false,true,false) ;
3376
3377 }
3378 //---------------------------------------------------------------------------
3379
3380
3381 void __fastcall TVisuWinform::ResultatCosmosM1Click(TObject *Sender)
3382 {
3383 int nb=gest->get_nb_fem_maillage();
3384 if (nb==0)
3385 {
3386 MessageBox(Handle,"Pas de maillage FEM","Erreur",MB_OK);
3387 return ;
3388 }
3389 TCosmosWin *fen=new TCosmosWin(Owner);
3390
3391 fen->ComboBox1->Clear();
3392 for (int i=0;i<nb;i++)
3393 {
3394 char chaine[500];
3395 FEM_MAILLAGE* mai=gest->get_fem_maillage(i);
3396 sprintf(chaine,"%lu", mai->get_id());
3397 fen->ComboBox1->Items->Add(chaine);
3398 }
3399 fen->Label2->Caption=Caption;
3400 fen->changegestionnaire(gest);
3401 fen->Show();
3402 }
3403 //---------------------------------------------------------------------------
3404
3405
3406 void __fastcall TVisuWinform::lancerg3dExecute(TObject *Sender)
3407 {
3408 Twincarte *Child;
3409 Child = new Twincarte(Application,*gest);
3410 Child->Caption=Caption;
3411 }
3412 //---------------------------------------------------------------------------
3413
3414
3415
3416 void __fastcall TVisuWinform::TrackBar2Change(TObject *Sender)
3417 {
3418 if (TrackBar2->Position<TrackBar1->Position) TrackBar1->Position=TrackBar2->Position;
3419 ActiveControl=NULL;
3420 redess();
3421 }
3422 //---------------------------------------------------------------------------
3423
3424 void __fastcall TVisuWinform::TrackBar1Change(TObject *Sender)
3425 {
3426 if (TrackBar2->Position<TrackBar1->Position) TrackBar2->Position=TrackBar1->Position;
3427 ActiveControl=NULL;
3428 redess();
3429 }
3430 //---------------------------------------------------------------------------
3431
3432 void __fastcall TVisuWinform::TrackBar3Change(TObject *Sender)
3433 {
3434 if (TrackBar4->Position<TrackBar3->Position) TrackBar4->Position=TrackBar3->Position;
3435 ActiveControl=NULL;
3436 redess();
3437 }
3438 //---------------------------------------------------------------------------
3439
3440 void __fastcall TVisuWinform::TrackBar4Change(TObject *Sender)
3441 {
3442 if (TrackBar4->Position<TrackBar3->Position) TrackBar3->Position=TrackBar4->Position;
3443 ActiveControl=NULL;
3444 redess();
3445
3446 }
3447 //---------------------------------------------------------------------------
3448
3449 void __fastcall TVisuWinform::TrackBar5Change(TObject *Sender)
3450 {
3451 if (TrackBar6->Position<TrackBar5->Position) TrackBar6->Position=TrackBar5->Position;
3452 ActiveControl=NULL;
3453 redess();
3454
3455 }
3456 //---------------------------------------------------------------------------
3457
3458 void __fastcall TVisuWinform::TrackBar6Change(TObject *Sender)
3459 {
3460 if (TrackBar6->Position<TrackBar5->Position) TrackBar5->Position=TrackBar6->Position;
3461 ActiveControl=NULL;
3462 redess();
3463 }
3464 //---------------------------------------------------------------------------
3465
3466 void __fastcall TVisuWinform::Button1Click(TObject *Sender)
3467 {
3468 AnsiString InputString = InputBox("Information","Entrez la valeur maximale de la legende ?", "");
3469 double val=atof(InputString.c_str());
3470 if (val>lmin) lmax=val;
3471 dessine_legende();
3472 redess();
3473 }
3474 //---------------------------------------------------------------------------
3475 void __fastcall TVisuWinform::Button2Click(TObject *Sender)
3476 {
3477 AnsiString InputString = InputBox("Information","Entrez la valeur minimale de la legende ?", "");
3478 double val=atof(InputString.c_str());
3479 if (val<lmax) lmin=val;
3480 dessine_legende();
3481 redess();
3482 }
3483 //---------------------------------------------------------------------------
3484
3485 void __fastcall TVisuWinform::Button3Click(TObject *Sender)
3486 {
3487 PageControl1->Enabled=false;
3488 PageControl2->Visible=true;
3489 TabSheet5->TabVisible=true;
3490 ComboBox2->Clear();
3491 ListBox2->Clear();
3492 Label35->Caption="Champs";
3493 Edit1->Visible=false;
3494 ListBox2->Visible=true;
3495 MG_SOLUTION* sol=gest->get_mg_solution(ComboBox1->ItemIndex);
3496 MG_MAILLAGE* mai=NULL;
3497 if (sol!=NULL) mai=sol->get_maillage();
3498 int nb=gest->get_nb_mg_solution();
3499 for (int i=0;i<nb;i++)
3500 {
3501 MG_SOLUTION* sol=gest->get_mg_solution(i);
3502 MG_MAILLAGE* maitmp=sol->get_maillage();
3503 if (maitmp!=mai)
3504 {
3505 ComboBox2->Items->Add("Solution incompatible");
3506 continue;
3507 }
3508 char chaine[1000];
3509 sprintf(chaine,"%s",sol->get_nom().c_str());
3510 ComboBox2->Items->Add(chaine);
3511 }
3512 FEM_SOLUTION* femsol=gest->get_fem_solution(ComboBox1->ItemIndex-gest->get_nb_mg_solution());
3513 FEM_MAILLAGE* femmai=NULL;
3514 if (femsol!=NULL) femmai=femsol->get_maillage();
3515 nb=gest->get_nb_fem_solution();
3516 for (int i=0;i<nb;i++)
3517 {
3518 FEM_SOLUTION* sol=gest->get_fem_solution(i);
3519 FEM_MAILLAGE* maitmp=sol->get_maillage();
3520 if (maitmp!=femmai)
3521 {
3522 ComboBox2->Items->Add("Solution incompatible");
3523 continue;
3524 }
3525 char chaine[1000];
3526 sprintf(chaine,"%s",sol->get_nom().c_str());
3527 ComboBox2->Items->Add(chaine);
3528 }
3529
3530 ComboBox2->Items->Add("Constante");
3531 ComboBox2->Items->Add("Fonction");
3532 ListBox3->Clear();
3533 char chaine[100];
3534 sprintf(chaine,"%s@%s",ListBox1->Items->Strings[ListBox1->ItemIndex].c_str(),ComboBox1->Text.c_str());
3535 ListBox3->Items->Add(chaine);
3536 }
3537 //---------------------------------------------------------------------------
3538
3539 void __fastcall TVisuWinform::Button4Click(TObject *Sender)
3540 {
3541 PageControl2->Visible=false;
3542 TabSheet5->TabVisible=false;
3543 PageControl1->Enabled=true;
3544 }
3545 //---------------------------------------------------------------------------
3546
3547 void __fastcall TVisuWinform::Button5Click(TObject *Sender)
3548 {
3549 PageControl2->Visible=false;
3550 TabSheet5->TabVisible=false;
3551 PageControl1->Enabled=true;
3552 TabSheet6->TabVisible=true;
3553 TabSheet2->TabVisible=false;
3554 PageControl1->ActivePage=TabSheet6;
3555 MG_SOLUTION* sol=gest->get_mg_solution(ComboBox2->ItemIndex);
3556 if (((ListBox2->ItemIndex!=-1) || (ComboBox2->Text=="Constante") || (ComboBox2->Text=="Fonction") )&& (ComboBox3->Text!=""))
3557 {
3558 if (gest->get_mg_solution(ComboBox1->ItemIndex)!=NULL)
3559 {
3560 MG_MAILLAGE* mai=gest->get_mg_solution(ComboBox1->ItemIndex)->get_maillage();
3561 int nb=mai->get_nb_mg_noeud();
3562 lmin=1e308;
3563 lmax=-1e308;
3564 for (int i=0;i<nb;i++)
3565 {
3566 MG_NOEUD* noeud=mai->get_mg_noeud(i);
3567 double val=noeud->get_solution();
3568 double val2;
3569 if (ComboBox2->Text=="Constante") val2=atof(Edit1->Text.c_str()); else if (ComboBox2->Text!="Fonction") val2=sol->lire(i,ListBox2->ItemIndex);
3570 if (ComboBox3->Text=="+") val=val+val2;
3571 if (ComboBox3->Text=="-") val=val-val2;
3572 if (ComboBox3->Text=="*") val=val*val2;
3573 if (ComboBox3->Text=="/")
3574 if (fabs(val2)>1e-10) val=val/val2; else val=val/fabs(val)*1e308;
3575 if (ComboBox3->Text=="|x|") val=fabs(val);
3576 if (val<lmin) lmin=val;
3577 if (val>lmax) lmax=val;
3578 noeud->change_solution(val);
3579 }
3580 if (!(lmax>lmin)) lmax=lmin+1e-6;
3581 char chaine[100];
3582 if (ComboBox3->Text=="|x|") strcpy(chaine,"|x|");
3583 else if (ComboBox2->Text=="Constante") sprintf(chaine,"%s %s",ComboBox3->Text.c_str(),Edit1->Text.c_str());
3584 else sprintf(chaine,"%s %s@%s",ComboBox3->Text.c_str(),ListBox2->Items->Strings[ListBox2->ItemIndex].c_str(),ComboBox2->Text.c_str());
3585 ListBox3->Items->Add(chaine);
3586 dessine_legende();
3587 redess();
3588 }
3589 }
3590 FEM_SOLUTION* femsol=gest->get_fem_solution(ComboBox2->ItemIndex-gest->get_nb_mg_solution());
3591 if (((ListBox2->ItemIndex!=-1) || (ComboBox2->Text=="Constante") || (ComboBox2->Text=="Fonction") )&& (ComboBox3->Text!="") )
3592 {
3593 if (gest->get_fem_solution(ComboBox1->ItemIndex-gest->get_nb_mg_solution())!=NULL)
3594 {
3595 FEM_MAILLAGE* mai=gest->get_fem_solution(ComboBox1->ItemIndex-gest->get_nb_mg_solution())->get_maillage();
3596 int nb=mai->get_nb_fem_noeud();
3597 lmin=1e308;
3598 lmax=-1e308;
3599 for (int i=0;i<nb;i++)
3600 {
3601 FEM_NOEUD* noeud=mai->get_fem_noeud(i);
3602 double val=noeud->get_solution();
3603 double val2;
3604 if (ComboBox2->Text=="Constante") val2=atof(Edit1->Text.c_str()); else if (ComboBox2->Text!="Fonction") val2=femsol->lire(i,ListBox2->ItemIndex);
3605 if (ComboBox3->Text=="+") val=val+val2;
3606 if (ComboBox3->Text=="-") val=val-val2;
3607 if (ComboBox3->Text=="*") val=val*val2;
3608 if (ComboBox3->Text=="/")
3609 if (fabs(val2)>1e-10) val=val/val2; else val=val/fabs(val)*1e308;
3610 if (ComboBox3->Text=="|x|") val=fabs(val);
3611 if (val<lmin) lmin=val;
3612 if (val>lmax) lmax=val;
3613 noeud->change_solution(val);
3614 }
3615 if (!(lmax>lmin)) lmax=lmin+1e-6;
3616 char chaine[100];
3617 if (ComboBox3->Text=="|x|") strcpy(chaine,"|x|");
3618 else if (ComboBox2->Text=="Constante") sprintf(chaine,"%s %s",ComboBox3->Text.c_str(),Edit1->Text.c_str());
3619 else sprintf(chaine,"%s %s@%s",ComboBox3->Text.c_str(),ListBox2->Items->Strings[ListBox2->ItemIndex].c_str(),ComboBox2->Text.c_str());
3620 ListBox3->Items->Add(chaine);
3621 dessine_legende();
3622 redess();
3623 }
3624 }
3625
3626 }
3627 //---------------------------------------------------------------------------
3628
3629 void __fastcall TVisuWinform::ComboBox2Change(TObject *Sender)
3630 {
3631 ComboBox3->Clear();
3632 ComboBox3->Items->Add("+");
3633 ComboBox3->Items->Add("-");
3634 ComboBox3->Items->Add("*");
3635 ComboBox3->Items->Add("/");
3636 if (ComboBox2->Text=="Solution incompatible")
3637 {
3638 ComboBox2->ItemIndex=-1;
3639 return;
3640 }
3641 if (ComboBox2->Text=="Fonction")
3642 {
3643 ComboBox3->Clear();
3644 ComboBox3->Items->Add("|x|");
3645 return;
3646 }
3647 if (ComboBox2->Text=="Constante")
3648 {
3649 ListBox2->Visible=false;
3650 Label35->Caption="Valeur";
3651 Edit1->Visible=true;
3652 return;
3653 }
3654 Label35->Caption="Champs";
3655 Edit1->Visible=false;
3656 ListBox2->Visible=true;
3657 MG_SOLUTION* sol=gest->get_mg_solution(ComboBox2->ItemIndex);
3658 if (sol!=NULL)
3659 {
3660 ListBox2->Clear();
3661 int nb=sol->get_nb_champ();
3662 for (int i=0;i<nb;i++)
3663 ListBox2->Items->Add(sol->get_legende(i).c_str());
3664 }
3665 FEM_SOLUTION* femsol=gest->get_fem_solution(ComboBox2->ItemIndex-gest->get_nb_mg_solution());
3666 if (femsol!=NULL)
3667 {
3668 ListBox2->Clear();
3669 int nb=femsol->get_nb_champ();
3670 for (int i=0;i<nb;i++)
3671 ListBox2->Items->Add(femsol->get_legende(i).c_str());
3672 }
3673
3674 }
3675 //---------------------------------------------------------------------------
3676
3677 void __fastcall TVisuWinform::Button6Click(TObject *Sender)
3678 {
3679 PageControl1->Enabled=false;
3680 PageControl2->Visible=true;
3681 TabSheet5->TabVisible=true;
3682 ComboBox2->Clear();
3683 ListBox2->Clear();
3684 Label35->Caption="Champs";
3685 Edit1->Visible=false;
3686 ListBox2->Visible=true;
3687 MG_SOLUTION* sol=gest->get_mg_solution(ComboBox1->ItemIndex);
3688 MG_MAILLAGE* mai=NULL;
3689 if (sol!=NULL) mai=sol->get_maillage();
3690 int nb=gest->get_nb_mg_solution();
3691 for (int i=0;i<nb;i++)
3692 {
3693 MG_SOLUTION* sol=gest->get_mg_solution(i);
3694 MG_MAILLAGE* maitmp=sol->get_maillage();
3695 if (maitmp!=mai)
3696 {
3697 ComboBox2->Items->Add("Solution incompatible");
3698 continue;
3699 }
3700 char chaine[1000];
3701 sprintf(chaine,"%s",sol->get_nom().c_str());
3702 ComboBox2->Items->Add(chaine);
3703 }
3704 FEM_SOLUTION* femsol=gest->get_fem_solution(ComboBox1->ItemIndex-gest->get_nb_mg_solution());
3705 FEM_MAILLAGE* femmai=NULL;
3706 if (femsol!=NULL) femmai=femsol->get_maillage();
3707 nb=gest->get_nb_fem_solution();
3708 for (int i=0;i<nb;i++)
3709 {
3710 FEM_SOLUTION* femsol=gest->get_fem_solution(i);
3711 FEM_MAILLAGE* maitmp=femsol->get_maillage();
3712 if (maitmp!=femmai)
3713 {
3714 ComboBox2->Items->Add("Solution incompatible");
3715 continue;
3716 }
3717 char chaine[1000];
3718 sprintf(chaine,"%s",femsol->get_nom().c_str());
3719 ComboBox2->Items->Add(chaine);
3720 }
3721 ComboBox2->Items->Add("Constante");
3722 ComboBox2->Items->Add("Fonction");
3723 }
3724 //---------------------------------------------------------------------------
3725
3726 void __fastcall TVisuWinform::Button7Click(TObject *Sender)
3727 {
3728 TabSheet2->TabVisible=true;
3729 MG_SOLUTION* sol=gest->get_mg_solution(ComboBox1->ItemIndex);
3730 if (sol!=NULL)
3731 {
3732 sol->active_solution(ListBox1->ItemIndex);
3733 lmin=sol->get_legende_min();
3734 lmax=sol->get_legende_max();
3735 }
3736 FEM_SOLUTION* femsol=gest->get_fem_solution(ComboBox1->ItemIndex-gest->get_nb_mg_solution());
3737 if (femsol!=NULL)
3738 {
3739 femsol->active_solution(ListBox1->ItemIndex);
3740 lmin=femsol->get_legende_min();
3741 lmax=femsol->get_legende_max();
3742 }
3743 TabSheet6->TabVisible=false;
3744 PageControl1->ActivePage=TabSheet2;
3745 dessine_legende();
3746 redess();
3747 }
3748 //---------------------------------------------------------------------------
3749
3750
3751 void __fastcall TVisuWinform::Vu1Click(TObject *Sender)
3752 {
3753 Tvisupara *Child;
3754 Child = new Tvisupara(Application);
3755 Child->gest=gest;
3756 int nbmai=gest->get_nb_mg_maillage();
3757 for (int i=0;i<nbmai;i++)
3758 {
3759 MG_MAILLAGE* mai=gest->get_mg_maillage(i);
3760 long id=mai->get_id();
3761 Child->ListBox1->Items->Add(id);
3762 }
3763 int nbgeo=gest->get_nb_mg_geometrie();
3764 for (int i=0;i<nbgeo;i++)
3765 {
3766 MG_GEOMETRIE* geo=gest->get_mg_geometrie(i);
3767 long id=geo->get_id();
3768 Child->ListBox3->Items->Add(id);
3769 }
3770 Child->Caption=Caption;
3771 }
3772 //---------------------------------------------------------------------------
3773
3774 void __fastcall TVisuWinform::X4Click(TObject *Sender)
3775 {
3776 ajouterccf("Saisie d'un déplacement imposé selon l'axe x","Dx",true,true,true,true,false) ;
3777 }
3778 //---------------------------------------------------------------------------
3779
3780 void __fastcall TVisuWinform::Y4Click(TObject *Sender)
3781 {
3782 ajouterccf("Saisie d'un déplacement imposé selon l'axe y","Dy",true,true,true,true,false) ;
3783 }
3784 //---------------------------------------------------------------------------
3785
3786 void __fastcall TVisuWinform::Z4Click(TObject *Sender)
3787 {
3788 ajouterccf("Saisie d'un déplacement imposé selon l'axe z","Dz",true,true,true,true,false) ;
3789 }
3790 //---------------------------------------------------------------------------
3791
3792
3793
3794 void __fastcall TVisuWinform::Resolution1Click(TObject *Sender)
3795 {
3796 Tfsolve *fsolve=new Tfsolve(Application,gest);
3797 fsolve->Caption=Caption;
3798 fsolve->ComboBox1->Clear();
3799 int nbmai=gest->get_nb_mg_maillage();
3800 for (int i=0;i<nbmai;i++)
3801 {
3802 MG_MAILLAGE* mai=gest->get_mg_maillage(i);
3803 fsolve->ComboBox1->Items->Add(mai->get_id());
3804 }
3805 fsolve->Show();
3806 }
3807 //---------------------------------------------------------------------------
3808
3809 //---------------------------------------------------------------------------
3810 void __fastcall TVisuWinform::dessinemaifem(void)
3811 {
3812 glLineWidth(1.);
3813 double x1=boite.get_xmin()+TrackBar1->Position*(boite.get_xmax()-boite.get_xmin())/100.;
3814 double y1=boite.get_ymin()+TrackBar3->Position*(boite.get_ymax()-boite.get_ymin())/100.;
3815 double z1=boite.get_zmin()+TrackBar5->Position*(boite.get_zmax()-boite.get_zmin())/100.;
3816 double x2=boite.get_xmin()+TrackBar2->Position*(boite.get_xmax()-boite.get_xmin())/100.;
3817 double y2=boite.get_ymin()+TrackBar4->Position*(boite.get_ymax()-boite.get_ymin())/100.;
3818 double z2=boite.get_zmin()+TrackBar6->Position*(boite.get_zmax()-boite.get_zmin())/100.;
3819 double dx=(x2-x1)*1.01;
3820 double dy=(y2-y1)*1.01;
3821 double dz=(z2-z1)*1.01;
3822 double xm=(x1+x2)/2.;
3823 x1=xm-dx/2.;x2=xm+dx/2.;
3824 double ym=(y1+y2)/2.;
3825 y1=ym-dy/2.;y2=ym+dy/2.;
3826 double zm=(z1+z2)/2.;
3827 z1=zm-dz/2.;z2=zm+dz/2.;
3828 BOITE_3D boite2(x1,y1,z1,x2+1e-8,y2+1e-8,z2+1e-8);
3829
3830 if (noeud)
3831 {
3832 glColor3f(MainForm->valeurconfig[30],MainForm->valeurconfig[31],MainForm->valeurconfig[32]);
3833 glPointSize(MainForm->valeurconfig[33]);
3834 glBegin(GL_POINTS);
3835 int nb=lst_noeud_fem.size();
3836 for (int i=0;i<nb;i++)
3837 {
3838 FEM_NOEUD* noeud1=lst_noeud_fem[i];
3839 if (N12->Checked)
3840 if (!estdansfiltre(noeud1->get_id())) continue;
3841 BOITE_3D boitmp=noeud1->get_boite_3D();
3842 if (!(boitmp*boite2)) continue;
3843 int dim;
3844 if (noeud1->get_lien_topologie()==NULL) dim=-1;
3845 else dim=noeud1->get_lien_topologie()->get_dimension();
3846 /*if (dim==0) dim=1;
3847 dim--;*/
3848 if (dim>-1)
3849 {
3850 int binoeud[4];
3851 binoeud[0]=noeud%2;
3852 binoeud[1]=(noeud/2)%2;
3853 binoeud[2]=(noeud/4)%2;
3854 binoeud[3]=(noeud/8)%2;
3855 if (binoeud[dim])
3856 {
3857 double *xyz1=noeud1->get_coord();
3858 glVertex3f(xyz1[0],xyz1[1],xyz1[2]);
3859 }
3860 }
3861 else
3862 {
3863 double *xyz1=noeud1->get_coord();
3864 glVertex3f(xyz1[0],xyz1[1],xyz1[2]);
3865 }
3866 }
3867 glEnd();
3868 if (affnoeud)
3869 {
3870 for (int i=0;i<nb;i++)
3871 {
3872 FEM_NOEUD* noeud1=lst_noeud_fem[i];
3873 if (N12->Checked)
3874 if (!estdansfiltre(noeud1->get_id())) continue;
3875 BOITE_3D boitmp=noeud1->get_boite_3D();
3876 if (!(boitmp*boite2)) continue;
3877 int dim;
3878 if (noeud1->get_lien_topologie()==NULL) dim=-1;
3879 else dim=noeud1->get_lien_topologie()->get_dimension();
3880 /*if (dim==0) dim=1;
3881 dim--;*/
3882 int binoeud[4];
3883 binoeud[0]=noeud%2;
3884 binoeud[1]=(noeud/2)%2;
3885 binoeud[2]=(noeud/4)%2;
3886 binoeud[3]=(noeud/8)%2;
3887 if (dim>-1)
3888 {
3889 if (binoeud[dim])
3890 {
3891 char mess[30];
3892 if (Id1->Checked)
3893 {
3894 unsigned long id=noeud1->get_id();
3895 sprintf(mess,"%lu",id);
3896 }
3897 if (Numero1->Checked)
3898 {
3899 int num=noeud1->get_numero();
3900 sprintf(mess,"%d",num);
3901 }
3902 if (NumeroOptimise1->Checked)
3903 {
3904 int num=noeud1->get_numero_opt();
3905 sprintf(mess,"%d",num);
3906 }
3907 double *xyz=noeud1->get_coord();
3908 glRasterPos3f(xyz[0],xyz[1],xyz[2]);
3909 glListBase (1000);
3910 glCallLists (strlen(mess), GL_UNSIGNED_BYTE, mess);
3911 }
3912
3913 }
3914 else
3915 {
3916 double *xyz=noeud1->get_coord();
3917 char mess[30];
3918 if (Id1->Checked)
3919 {
3920 unsigned long id=noeud1->get_id();
3921 sprintf(mess,"%lu",id);
3922 }
3923 if (Numero1->Checked)
3924 {
3925 int num=noeud1->get_numero();
3926 sprintf(mess,"%d",num);
3927 }
3928 if (NumeroOptimise1->Checked)
3929 {
3930 int num=noeud1->get_numero_opt();
3931 sprintf(mess,"%d",num);
3932 }
3933 glRasterPos3f(xyz[0],xyz[1],xyz[2]);
3934 glListBase (1000);
3935 glCallLists (strlen(mess), GL_UNSIGNED_BYTE, mess);
3936 }
3937 }
3938
3939 }
3940 }
3941 int bmaille[3];
3942 bmaille[0]=maille%2;
3943 bmaille[1]=(maille/2)%2;
3944 bmaille[2]=(maille/4)%2;
3945 if (bmaille[0])
3946 {
3947 glLineWidth(MainForm->valeurconfig[17]);
3948 glColor3f(MainForm->valeurconfig[14],MainForm->valeurconfig[15],MainForm->valeurconfig[16]);
3949 glBegin(GL_LINES);
3950 int nb=lst_segment_fem.size();
3951 for (int i=0;i<nb;i++)
3952 {
3953 glColor3f(MainForm->valeurconfig[14],MainForm->valeurconfig[15],MainForm->valeurconfig[16]);
3954 FEM_SEGMENT* femsegment=lst_segment_fem[i];
3955 if (N12->Checked)
3956 if (!estdansfiltre(femsegment->get_id())) continue;
3957 BOITE_3D boitmp=femsegment->get_boite_3D();
3958 if (!(boitmp*boite2)) continue;
3959 int nbnoeud=femsegment->get_nb_fem_noeud();
3960 FEM_NOEUD* noeud1=femsegment->get_fem_noeud(0);
3961 FEM_NOEUD* noeud2=femsegment->get_fem_noeud(1);
3962 double *xyz1=noeud1->get_coord();
3963 double *xyz2=noeud2->get_coord();
3964 if ((femsegment->get_lien_topologie()==toposel) && (femsegment->get_lien_topologie()!=NULL) )
3965 glColor3f(RGB_r[13]/255.,RGB_g[13]/255.,RGB_b[13]/255.);
3966 if (qualite==2)
3967 {
3968 int pos=(int) ((femsegment->get_mg_element_maillage()->get_origine()-1000)/10);
3969 if (pos>11) pos=11;
3970 if (pos<0) pos=0;
3971 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
3972 }
3973 if (CheckBox1->Checked==true)
3974 {
3975 int pos=(int) ((noeud1->get_solution()-lmin)*12./(lmax-lmin));
3976 if (pos>11) pos=11;
3977 if (pos<0) pos=0;
3978 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
3979 }
3980 glVertex3f(xyz1[0],xyz1[1],xyz1[2]);
3981 if (CheckBox1->Checked==true)
3982 {
3983 int pos=(int) ((noeud2->get_solution()-lmin)*12./(lmax-lmin));
3984 if (pos>11) pos=11;
3985 if (pos<0) pos=0;
3986 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
3987 }
3988 glVertex3f(xyz2[0],xyz2[1],xyz2[2]);
3989 if (nbnoeud==3)
3990 {
3991 FEM_NOEUD* noeud1=femsegment->get_fem_noeud(1);
3992 FEM_NOEUD* noeud2=femsegment->get_fem_noeud(2);
3993 double *xyz1=noeud1->get_coord();
3994 double *xyz2=noeud2->get_coord();
3995 if ((femsegment->get_lien_topologie()==toposel) && (femsegment->get_lien_topologie()!=NULL) )
3996 glColor3f(RGB_r[13]/255.,RGB_g[13]/255.,RGB_b[13]/255.);
3997 if (CheckBox1->Checked==true)
3998 {
3999 int pos=(int) ((noeud1->get_solution()-lmin)*12./(lmax-lmin));
4000 if (pos>11) pos=11;
4001 if (pos<0) pos=0;
4002 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
4003 }
4004 glVertex3f(xyz1[0],xyz1[1],xyz1[2]);
4005 if (CheckBox1->Checked==true)
4006 {
4007 int pos=(int) ((noeud2->get_solution()-lmin)*12./(lmax-lmin));
4008 if (pos>11) pos=11;
4009 if (pos<0) pos=0;
4010 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
4011 }
4012 glVertex3f(xyz2[0],xyz2[1],xyz2[2]);
4013 }
4014 }
4015 glEnd();
4016
4017 if (affmaille)
4018 {
4019 for (int i=0;i<nb;i++)
4020 {
4021 FEM_SEGMENT* femsegment=lst_segment_fem[i];
4022 if (N12->Checked)
4023 if (!estdansfiltre(femsegment->get_id())) continue;
4024 BOITE_3D boitmp=femsegment->get_boite_3D();
4025 if (!(boitmp*boite2)) continue;
4026 if (qualite==2)
4027 {
4028 int pos=(int) ((femsegment->get_mg_element_maillage()->get_origine()-1000)/10);
4029 if (pos>11) pos=11;
4030 if (pos<0) pos=0;
4031 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
4032 }
4033 FEM_NOEUD* noeud1=femsegment->get_fem_noeud(0);
4034 FEM_NOEUD* noeud2=femsegment->get_fem_noeud(femsegment->get_nb_fem_noeud()-1);
4035 unsigned long id=femsegment->get_id();
4036 double *xyz1=noeud1->get_coord();
4037 double *xyz2=noeud2->get_coord();
4038 char mess[30];
4039 sprintf(mess,"%lu",id);
4040 glRasterPos3f(0.5*(xyz1[0]+xyz2[0]),0.5*(xyz1[1]+xyz2[1]),0.5*(xyz1[2]+xyz2[2]));
4041 glListBase (1000);
4042 glCallLists (strlen(mess), GL_UNSIGNED_BYTE, mess);
4043 }
4044 }
4045 }
4046
4047 //triangle
4048 if (bmaille[1])
4049 {
4050 if (render>0)
4051 {
4052 if (render>1) InitShading();
4053 glColor3f(MainForm->valeurconfig[34],MainForm->valeurconfig[35],MainForm->valeurconfig[36]);
4054 glEnable(GL_DEPTH_TEST);
4055 glEnable(GL_POLYGON_OFFSET_FILL);
4056 glPolygonOffset(1.0,1.0);
4057 glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
4058 glBegin(GL_TRIANGLES);
4059 glEdgeFlag(GL_TRUE);
4060 int nb=lst_triangle_fem.size();
4061 for (int i=0;i<nb;i++)
4062 {
4063 glColor3f(MainForm->valeurconfig[34],MainForm->valeurconfig[35],MainForm->valeurconfig[36]);
4064 FEM_TRIANGLE* femtri=lst_triangle_fem[i];
4065 if (N12->Checked)
4066 if (!estdansfiltre(femtri->get_id())) continue;
4067 BOITE_3D boitmp=femtri->get_boite_3D();
4068 if (!(boitmp*boite2)) continue;
4069 int nbfemnoeud=femtri->get_nb_fem_noeud();
4070 if (nbfemnoeud==3) dessinetrifem(femtri,femtri->get_fem_noeud(0),femtri->get_fem_noeud(1),femtri->get_fem_noeud(2));
4071 if (nbfemnoeud==6)
4072 {
4073 dessinetrifem(femtri,femtri->get_fem_noeud(0),femtri->get_fem_noeud(1),femtri->get_fem_noeud(5));
4074 dessinetrifem(femtri,femtri->get_fem_noeud(1),femtri->get_fem_noeud(2),femtri->get_fem_noeud(3));
4075 dessinetrifem(femtri,femtri->get_fem_noeud(1),femtri->get_fem_noeud(3),femtri->get_fem_noeud(5));
4076 dessinetrifem(femtri,femtri->get_fem_noeud(5),femtri->get_fem_noeud(3),femtri->get_fem_noeud(4));
4077 }
4078 }
4079 glEnd();
4080 }
4081
4082 glFlush();
4083 if (render>0)
4084 {
4085 glColor3f(MainForm->valeurconfig[37],MainForm->valeurconfig[38],MainForm->valeurconfig[39]);
4086 glLineWidth(MainForm->valeurconfig[40]);
4087 if (render>1) InitShading();
4088 }
4089 else
4090 {
4091 glColor3f(MainForm->valeurconfig[18],MainForm->valeurconfig[19],MainForm->valeurconfig[20]);
4092 glLineWidth(MainForm->valeurconfig[21]);
4093 }
4094 glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
4095 glBegin(GL_LINES);
4096 glEdgeFlag(GL_TRUE);
4097 int nb=lst_triangle_fem.size();
4098 for (int i=0;i<nb;i++)
4099 {
4100 if (render>0)
4101 glColor3f(MainForm->valeurconfig[37],MainForm->valeurconfig[38],MainForm->valeurconfig[39]);
4102 else
4103 glColor3f(MainForm->valeurconfig[18],MainForm->valeurconfig[19],MainForm->valeurconfig[20]);
4104 FEM_TRIANGLE* femtri=lst_triangle_fem[i];
4105 if (N12->Checked)
4106 if (!estdansfiltre(femtri->get_id())) continue;
4107 BOITE_3D boitmp=femtri->get_boite_3D();
4108 if (!(boitmp*boite2)) continue;
4109 int nb_fem_noeud=femtri->get_nb_fem_noeud();
4110 double xg=0.;
4111 double yg=0.;
4112 double zg=0.;
4113 for (int j=0;j<nb_fem_noeud;j++)
4114 {
4115 FEM_NOEUD* no=femtri->get_fem_noeud(j);
4116 xg=xg+no->get_x();
4117 yg=yg+no->get_y();
4118 zg=zg+no->get_z();
4119 }
4120 xg=xg/nb_fem_noeud;
4121 yg=yg/nb_fem_noeud;
4122 zg=zg/nb_fem_noeud;
4123 for (int j=0;j<nb_fem_noeud;j++)
4124 {
4125 FEM_NOEUD* no1=femtri->get_fem_noeud(j);
4126 FEM_NOEUD* no2;
4127 if (j+1!=nb_fem_noeud) no2=femtri->get_fem_noeud(j+1); else no2=femtri->get_fem_noeud(0);
4128 double *xyz1=no1->get_coord();
4129 double *xyz2=no2->get_coord();
4130 if ( ((femtri->get_lien_topologie()==toposel)&& (femtri->get_lien_topologie()!=NULL) && (render==0)) || ((femtri->get_lien_topologie()==toposel)&&(render==1) && (femtri->get_lien_topologie()!=NULL) && (MainForm->valeurconfig[56]==0.)))
4131 glColor3f(RGB_r[13]/255.,RGB_g[13]/255.,RGB_b[13]/255.);
4132 if ( ((qualite==1)&&(render==0)) || ((qualite==1)&&(render==1) && (MainForm->valeurconfig[56]==0.)))
4133 {
4134 double qual;
4135 if (femtri->get_nb_fem_noeud()==3) qual=OPERATEUR::qualite_triangle(femtri->get_fem_noeud(0)->get_coord(),femtri->get_fem_noeud(1)->get_coord(),femtri->get_fem_noeud(2)->get_coord());
4136 if (femtri->get_nb_fem_noeud()==6) qual=OPERATEUR::qualite_triangle(femtri->get_fem_noeud(0)->get_coord(),femtri->get_fem_noeud(2)->get_coord(),femtri->get_fem_noeud(4)->get_coord());
4137 if (qual>MainForm->valeurconfig[53]) glColor3f(MainForm->valeurconfig[41],MainForm->valeurconfig[42],MainForm->valeurconfig[43]);
4138 else if (qual>MainForm->valeurconfig[54]) glColor3f(MainForm->valeurconfig[44],MainForm->valeurconfig[45],MainForm->valeurconfig[46]);
4139 else if (qual>MainForm->valeurconfig[55]) glColor3f(MainForm->valeurconfig[47],MainForm->valeurconfig[48],MainForm->valeurconfig[49]);
4140 else glColor3f(MainForm->valeurconfig[50],MainForm->valeurconfig[51],MainForm->valeurconfig[52]);
4141 }
4142 if ( ((qualite==2)&&(render==0)) || ((qualite==2)&&(render==1) && (MainForm->valeurconfig[56]==0.)))
4143 {
4144 int pos=(int) ((femtri->get_mg_element_maillage()->get_origine()-1000)/10);
4145 if (pos>11) pos=11;
4146 if (pos<0) pos=0;
4147 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
4148 }
4149 if (shrink)
4150 {
4151 double x1=xg+facteur_shrink*(xyz1[0]-xg);
4152 double y1=yg+facteur_shrink*(xyz1[1]-yg);
4153 double z1=zg+facteur_shrink*(xyz1[2]-zg);
4154 double x2=xg+facteur_shrink*(xyz2[0]-xg);
4155 double y2=yg+facteur_shrink*(xyz2[1]-yg);
4156 double z2=zg+facteur_shrink*(xyz2[2]-zg);
4157 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
4158 {
4159 int pos=(int) ((no1->get_solution()-lmin)*12./(lmax-lmin));
4160 if (pos>11) pos=11;
4161 if (pos<0) pos=0;
4162 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
4163 }
4164 glVertex3f(x1,y1,z1);
4165 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
4166 {
4167 int pos=(int) ((no2->get_solution()-lmin)*12./(lmax-lmin));
4168 if (pos>11) pos=11;
4169 if (pos<0) pos=0;
4170 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
4171 }
4172 glVertex3f(x2,y2,z2);
4173
4174 }
4175 else
4176 {
4177 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
4178 {
4179 int pos=(int) ((no1->get_solution()-lmin)*12./(lmax-lmin));
4180 if (pos>11) pos=11;
4181 if (pos<0) pos=0;
4182 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
4183 }
4184 glVertex3f(xyz1[0],xyz1[1],xyz1[2]);
4185 if ((CheckBox1->Checked==true) && ( (CheckBox2->Checked==false) || ( (CheckBox2->Checked==true) && (render==0) )) )
4186 {
4187 int pos=(int) ((no2->get_solution()-lmin)*12./(lmax-lmin));
4188 if (pos>11) pos=11;
4189 if (pos<0) pos=0;
4190 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
4191 }
4192 glVertex3f(xyz2[0],xyz2[1],xyz2[2]);
4193 }
4194 }
4195 }
4196 glEnd();
4197 if (affmaille)
4198 {
4199 for (int i=0;i<nb;i++)
4200 {
4201 FEM_TRIANGLE* femtri=lst_triangle_fem[i];
4202 if (N12->Checked)
4203 if (!estdansfiltre(femtri->get_id())) continue;
4204 BOITE_3D boitmp=femtri->get_boite_3D();
4205 if (!(boitmp*boite2)) continue;
4206 int n1,n2,n3;
4207 int nb=femtri->get_nb_fem_noeud();
4208 if (nb==3) {n1=0;n2=1;n3=2;}
4209 if (nb==6) {n1=0;n2=2;n3=4;}
4210 FEM_NOEUD* noeud1=femtri->get_fem_noeud(n1);
4211 FEM_NOEUD* noeud2=femtri->get_fem_noeud(n2);
4212 FEM_NOEUD* noeud3=femtri->get_fem_noeud(n3);
4213 double *xyz1=noeud1->get_coord();
4214 double *xyz2=noeud2->get_coord();
4215 double *xyz3=noeud3->get_coord();
4216 unsigned long id=femtri->get_id();
4217 char mess[30];
4218 sprintf(mess,"%lu",id);
4219 if ( ((qualite==1)&&(render==0)) || ((qualite==1)&&(render==1) && (MainForm->valeurconfig[56]==0.)))
4220 {
4221 double qual=OPERATEUR::qualite_triangle(xyz1,xyz2,xyz3);
4222 if (qual>MainForm->valeurconfig[53]) glColor3f(MainForm->valeurconfig[41],MainForm->valeurconfig[42],MainForm->valeurconfig[43]);
4223 else if (qual>MainForm->valeurconfig[54]) glColor3f(MainForm->valeurconfig[44],MainForm->valeurconfig[45],MainForm->valeurconfig[46]);
4224 else if (qual>MainForm->valeurconfig[55]) glColor3f(MainForm->valeurconfig[47],MainForm->valeurconfig[48],MainForm->valeurconfig[49]);
4225 else glColor3f(MainForm->valeurconfig[50],MainForm->valeurconfig[51],MainForm->valeurconfig[52]);
4226 }
4227 if ( ((qualite==2)&&(render==0)) || ((qualite==2)&&(render==1) && (MainForm->valeurconfig[56]==0.)))
4228 {
4229 int pos=(int) ((femtri->get_mg_element_maillage()->get_origine()-1000)/10);
4230 if (pos>11) pos=11;
4231 if (pos<0) pos=0;
4232 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
4233 }
4234 glRasterPos3f((xyz1[0]+xyz2[0]+xyz3[0])/3.,(xyz1[1]+xyz2[1]+xyz3[1])/3.,(xyz1[2]+xyz2[2]+xyz3[2])/3.);
4235 glListBase (1000);
4236 glCallLists (strlen(mess), GL_UNSIGNED_BYTE, mess);
4237 }
4238 }
4239 if (render==2)
4240 {
4241 glDisable(GL_LIGHTING);
4242 glDisable(GL_LIGHT0);
4243 glDisable(GL_LIGHT1);
4244 }
4245 }
4246 //tetra
4247 if (bmaille[2])
4248 {
4249 if (render==1)
4250 {
4251 glColor3f(MainForm->valeurconfig[34],MainForm->valeurconfig[35],MainForm->valeurconfig[36]);
4252 glEnable(GL_DEPTH_TEST);
4253 glEnable(GL_POLYGON_OFFSET_FILL);
4254 glPolygonOffset(1.0,1.0);
4255 glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
4256 glBegin(GL_TRIANGLES);
4257 glEdgeFlag(GL_TRUE);
4258 int nb=lst_tetra_fem.size();
4259 for (int i=0;i<nb;i++)
4260 {
4261 FEM_TETRA* femtet=lst_tetra_fem[i];
4262 if (N12->Checked)
4263 if (!estdansfiltre(femtet->get_id())) continue;
4264 BOITE_3D boitmp=femtet->get_boite_3D();
4265 if (!(boitmp*boite2)) continue;
4266 int nb_noeud=femtet->get_nb_fem_noeud();
4267 if (nb_noeud==4)
4268 {
4269 dessinetritetfem(femtet,femtet->get_fem_noeud(0),femtet->get_fem_noeud(1),femtet->get_fem_noeud(2));
4270 dessinetritetfem(femtet,femtet->get_fem_noeud(0),femtet->get_fem_noeud(1),femtet->get_fem_noeud(3));
4271 dessinetritetfem(femtet,femtet->get_fem_noeud(1),femtet->get_fem_noeud(2),femtet->get_fem_noeud(3));
4272 dessinetritetfem(femtet,femtet->get_fem_noeud(2),femtet->get_fem_noeud(0),femtet->get_fem_noeud(3));
4273 }
4274 if (nb_noeud==10)
4275 {
4276 dessinetritetfem(femtet,femtet->get_fem_noeud(0),femtet->get_fem_noeud(1),femtet->get_fem_noeud(5));
4277 dessinetritetfem(femtet,femtet->get_fem_noeud(1),femtet->get_fem_noeud(2),femtet->get_fem_noeud(3));
4278 dessinetritetfem(femtet,femtet->get_fem_noeud(3),femtet->get_fem_noeud(4),femtet->get_fem_noeud(5));
4279 dessinetritetfem(femtet,femtet->get_fem_noeud(1),femtet->get_fem_noeud(3),femtet->get_fem_noeud(5));
4280 dessinetritetfem(femtet,femtet->get_fem_noeud(9),femtet->get_fem_noeud(7),femtet->get_fem_noeud(6));
4281 dessinetritetfem(femtet,femtet->get_fem_noeud(7),femtet->get_fem_noeud(2),femtet->get_fem_noeud(1));
4282 dessinetritetfem(femtet,femtet->get_fem_noeud(1),femtet->get_fem_noeud(0),femtet->get_fem_noeud(6));
4283 dessinetritetfem(femtet,femtet->get_fem_noeud(7),femtet->get_fem_noeud(1),femtet->get_fem_noeud(6));
4284 dessinetritetfem(femtet,femtet->get_fem_noeud(9),femtet->get_fem_noeud(8),femtet->get_fem_noeud(7));
4285 dessinetritetfem(femtet,femtet->get_fem_noeud(8),femtet->get_fem_noeud(4),femtet->get_fem_noeud(3));
4286 dessinetritetfem(femtet,femtet->get_fem_noeud(3),femtet->get_fem_noeud(2),femtet->get_fem_noeud(7));
4287 dessinetritetfem(femtet,femtet->get_fem_noeud(3),femtet->get_fem_noeud(7),femtet->get_fem_noeud(8));
4288 dessinetritetfem(femtet,femtet->get_fem_noeud(9),femtet->get_fem_noeud(6),femtet->get_fem_noeud(8));
4289 dessinetritetfem(femtet,femtet->get_fem_noeud(6),femtet->get_fem_noeud(0),femtet->get_fem_noeud(5));
4290 dessinetritetfem(femtet,femtet->get_fem_noeud(5),femtet->get_fem_noeud(4),femtet->get_fem_noeud(8));
4291 dessinetritetfem(femtet,femtet->get_fem_noeud(5),femtet->get_fem_noeud(8),femtet->get_fem_noeud(6));
4292 }
4293 }
4294 glEnd();
4295 }
4296
4297 glFlush();
4298 if (render==1)
4299 {
4300 glColor3f(MainForm->valeurconfig[37],MainForm->valeurconfig[38],MainForm->valeurconfig[39]);
4301 glLineWidth(MainForm->valeurconfig[40]);
4302 }
4303 else
4304 {
4305 glColor3f(MainForm->valeurconfig[22],MainForm->valeurconfig[23],MainForm->valeurconfig[24]);
4306 glLineWidth(MainForm->valeurconfig[25]);
4307 }
4308 glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
4309 glBegin(GL_LINES);
4310 glEdgeFlag(GL_TRUE);
4311 int nb=lst_tetra_fem.size();
4312 for (int i=0;i<nb;i++)
4313 {
4314 if (render==1)
4315 glColor3f(MainForm->valeurconfig[37],MainForm->valeurconfig[38],MainForm->valeurconfig[39]);
4316 else
4317 glColor3f(MainForm->valeurconfig[22],MainForm->valeurconfig[23],MainForm->valeurconfig[24]);
4318 FEM_TETRA* femtet=lst_tetra_fem[i];
4319 BOITE_3D boitmp=femtet->get_boite_3D();
4320 if (N12->Checked)
4321 if (!estdansfiltre(femtet->get_id())) continue;
4322 if (!(boitmp*boite2)) continue;
4323 int nb_noeud=femtet->get_nb_fem_noeud();
4324 if (nb_noeud==4)
4325 {
4326 dessinesegtetfem(femtet,femtet->get_fem_noeud(0),femtet->get_fem_noeud(1));
4327 dessinesegtetfem(femtet,femtet->get_fem_noeud(1),femtet->get_fem_noeud(2));
4328 dessinesegtetfem(femtet,femtet->get_fem_noeud(2),femtet->get_fem_noeud(3));
4329 dessinesegtetfem(femtet,femtet->get_fem_noeud(3),femtet->get_fem_noeud(0));
4330 dessinesegtetfem(femtet,femtet->get_fem_noeud(2),femtet->get_fem_noeud(0));
4331 dessinesegtetfem(femtet,femtet->get_fem_noeud(3),femtet->get_fem_noeud(1));
4332 }
4333 if (nb_noeud==10)
4334 {
4335 dessinesegtetfem(femtet,femtet->get_fem_noeud(0),femtet->get_fem_noeud(1));
4336 dessinesegtetfem(femtet,femtet->get_fem_noeud(1),femtet->get_fem_noeud(2));
4337 dessinesegtetfem(femtet,femtet->get_fem_noeud(2),femtet->get_fem_noeud(3));
4338 dessinesegtetfem(femtet,femtet->get_fem_noeud(3),femtet->get_fem_noeud(4));
4339 dessinesegtetfem(femtet,femtet->get_fem_noeud(4),femtet->get_fem_noeud(5));
4340 dessinesegtetfem(femtet,femtet->get_fem_noeud(5),femtet->get_fem_noeud(0));
4341 dessinesegtetfem(femtet,femtet->get_fem_noeud(0),femtet->get_fem_noeud(6));
4342 dessinesegtetfem(femtet,femtet->get_fem_noeud(6),femtet->get_fem_noeud(9));
4343 dessinesegtetfem(femtet,femtet->get_fem_noeud(2),femtet->get_fem_noeud(7));
4344 dessinesegtetfem(femtet,femtet->get_fem_noeud(7),femtet->get_fem_noeud(9));
4345 dessinesegtetfem(femtet,femtet->get_fem_noeud(4),femtet->get_fem_noeud(8));
4346 dessinesegtetfem(femtet,femtet->get_fem_noeud(8),femtet->get_fem_noeud(9));
4347 }
4348 }
4349 glEnd();
4350 if (affmaille)
4351 {
4352 for (int i=0;i<nb;i++)
4353 {
4354 FEM_TETRA* femtet=lst_tetra_fem[i];
4355 if (N12->Checked)
4356 if (!estdansfiltre(femtet->get_id())) continue;
4357 BOITE_3D boitmp=femtet->get_boite_3D();
4358 if (!(boitmp*boite2)) continue;
4359 FEM_NOEUD *noeud1,*noeud2,*noeud3,*noeud4;
4360 int nb_noeud=femtet->get_nb_fem_noeud();
4361 if (nb_noeud==4)
4362 {
4363 noeud1=femtet->get_fem_noeud(0);
4364 noeud2=femtet->get_fem_noeud(1);
4365 noeud3=femtet->get_fem_noeud(2);
4366 noeud4=femtet->get_fem_noeud(3);
4367 }
4368 if (nb_noeud==10)
4369 {
4370 noeud1=femtet->get_fem_noeud(0);
4371 noeud2=femtet->get_fem_noeud(2);
4372 noeud3=femtet->get_fem_noeud(4);
4373 noeud4=femtet->get_fem_noeud(9);
4374 }
4375 double *xyz1=noeud1->get_coord();
4376 double *xyz2=noeud2->get_coord();
4377 double *xyz3=noeud3->get_coord();
4378 double *xyz4=noeud4->get_coord();
4379 unsigned long id=femtet->get_id();
4380 char mess[30];
4381 sprintf(mess,"%lu",id);
4382 if ( ((qualite==1)&&(render==0)) || ((qualite==1)&&(render==1) && (MainForm->valeurconfig[56]==0.)))
4383 {
4384 double qual=OPERATEUR::qualite_tetra(xyz1,xyz2,xyz3,xyz4);
4385 if (qual>MainForm->valeurconfig[53]) glColor3f(MainForm->valeurconfig[41],MainForm->valeurconfig[42],MainForm->valeurconfig[43]);
4386 else if (qual>MainForm->valeurconfig[54]) glColor3f(MainForm->valeurconfig[44],MainForm->valeurconfig[45],MainForm->valeurconfig[46]);
4387 else if (qual>MainForm->valeurconfig[55]) glColor3f(MainForm->valeurconfig[47],MainForm->valeurconfig[48],MainForm->valeurconfig[49]);
4388 else glColor3f(MainForm->valeurconfig[50],MainForm->valeurconfig[51],MainForm->valeurconfig[52]);
4389 }
4390 glRasterPos3f((xyz1[0]+xyz2[0]+xyz3[0]+xyz4[0])/4.,(xyz1[1]+xyz2[1]+xyz3[1]+xyz4[1])/4.,(xyz1[2]+xyz2[2]+xyz3[2]+xyz4[2])/4.);
4391 glListBase (1000);
4392 glCallLists (strlen(mess), GL_UNSIGNED_BYTE, mess);
4393 }
4394 }
4395 if (render==2)
4396 {
4397 glDisable(GL_LIGHTING);
4398 glDisable(GL_LIGHT0);
4399 glDisable(GL_LIGHT1);
4400 }
4401 }
4402 }
4403
4404
4405
4406 void __fastcall TVisuWinform::dessinetrifem(FEM_TRIANGLE* femtri,FEM_NOEUD* no1,FEM_NOEUD* no2,FEM_NOEUD* no3)
4407 {
4408 double *xyz1=no1->get_coord();
4409 double *xyz2=no2->get_coord();
4410 double *xyz3=no3->get_coord();
4411 if ((femtri->get_lien_topologie()==toposel) && (femtri->get_lien_topologie()!=NULL) )
4412 glColor3f(RGB_r[13]/255.,RGB_g[13]/255.,RGB_b[13]/255.);
4413 if (qualite==1)
4414 {
4415 double qual;
4416 if (femtri->get_nb_fem_noeud()==3) qual=OPERATEUR::qualite_triangle(femtri->get_fem_noeud(0)->get_coord(),femtri->get_fem_noeud(1)->get_coord(),femtri->get_fem_noeud(2)->get_coord());
4417 if (femtri->get_nb_fem_noeud()==6) qual=OPERATEUR::qualite_triangle(femtri->get_fem_noeud(0)->get_coord(),femtri->get_fem_noeud(2)->get_coord(),femtri->get_fem_noeud(4)->get_coord());
4418 if (qual>MainForm->valeurconfig[53]) glColor3f(MainForm->valeurconfig[41],MainForm->valeurconfig[42],MainForm->valeurconfig[43]);
4419 else if (qual>MainForm->valeurconfig[54]) glColor3f(MainForm->valeurconfig[44],MainForm->valeurconfig[45],MainForm->valeurconfig[46]);
4420 else if (qual>MainForm->valeurconfig[55]) glColor3f(MainForm->valeurconfig[47],MainForm->valeurconfig[48],MainForm->valeurconfig[49]);
4421 else glColor3f(MainForm->valeurconfig[50],MainForm->valeurconfig[51],MainForm->valeurconfig[52]);
4422 }
4423 if (qualite==2)
4424 {
4425 int pos=(int) ((femtri->get_mg_element_maillage()->get_origine()-1000)/10);
4426 if (pos>11) pos=11;
4427 if (pos<0) pos=0;
4428 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
4429 }
4430 if (shrink)
4431 {
4432 int nb=femtri->get_nb_fem_noeud();
4433 double xg=0.;
4434 double yg=0.;
4435 double zg=0.;
4436 for (int i=0;i<nb;i++)
4437 {
4438 FEM_NOEUD* no=femtri->get_fem_noeud(i);
4439 xg=xg+no->get_x();
4440 yg=yg+no->get_y();
4441 zg=zg+no->get_z();
4442 }
4443 xg=xg/nb;
4444 yg=yg/nb;
4445 zg=zg/nb;
4446 double x1=xg+facteur_shrink*(xyz1[0]-xg);
4447 double y1=yg+facteur_shrink*(xyz1[1]-yg);
4448 double z1=zg+facteur_shrink*(xyz1[2]-zg);
4449 double x2=xg+facteur_shrink*(xyz2[0]-xg);
4450 double y2=yg+facteur_shrink*(xyz2[1]-yg);
4451 double z2=zg+facteur_shrink*(xyz2[2]-zg);
4452 double x3=xg+facteur_shrink*(xyz3[0]-xg);
4453 double y3=yg+facteur_shrink*(xyz3[1]-yg);
4454 double z3=zg+facteur_shrink*(xyz3[2]-zg);
4455 if (CheckBox1->Checked==true)
4456 {
4457 int pos=(int) ((no1->get_solution()-lmin)*12./(lmax-lmin));
4458 if (pos>11) pos=11;
4459 if (pos<0) pos=0;
4460 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
4461 }
4462 glVertex3f(x1,y1,z1);
4463 if (CheckBox1->Checked==true)
4464 {
4465 int pos=(int) ((no3->get_solution()-lmin)*12./(lmax-lmin));
4466 if (pos>11) pos=11;
4467 if (pos<0) pos=0;
4468 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
4469 }
4470 glVertex3f(x3,y3,z3);
4471 if (CheckBox1->Checked==true)
4472 {
4473 int pos=(int) ((no2->get_solution()-lmin)*12./(lmax-lmin));
4474 if (pos>11) pos=11;
4475 if (pos<0) pos=0;
4476 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
4477 }
4478 glVertex3f(x2,y2,z2);
4479 }
4480 else
4481 {
4482 if (CheckBox1->Checked==true)
4483 {
4484 int pos=(int) ((no1->get_solution()-lmin)*12./(lmax-lmin));
4485 if (pos>11) pos=11;
4486 if (pos<0) pos=0;
4487 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
4488 }
4489 glVertex3f(xyz1[0],xyz1[1],xyz1[2]);
4490 if (CheckBox1->Checked==true)
4491 {
4492 int pos=(int) ((no3->get_solution()-lmin)*12./(lmax-lmin));
4493 if (pos>11) pos=11;
4494 if (pos<0) pos=0;
4495 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
4496 }
4497 glVertex3f(xyz3[0],xyz3[1],xyz3[2]);
4498 if (CheckBox1->Checked==true)
4499 {
4500 int pos=(int) ((no2->get_solution()-lmin)*12./(lmax-lmin));
4501 if (pos>11) pos=11;
4502 if (pos<0) pos=0;
4503 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
4504 }
4505 glVertex3f(xyz2[0],xyz2[1],xyz2[2]);
4506 }
4507 }
4508
4509 void __fastcall TVisuWinform::dessinetritetfem(FEM_TETRA* femtet,FEM_NOEUD* no1,FEM_NOEUD* no2,FEM_NOEUD* no3)
4510 {
4511 double *xyz1=no1->get_coord();
4512 double *xyz2=no2->get_coord();
4513 double *xyz3=no3->get_coord();
4514 if ((femtet->get_lien_topologie()==toposel) && (femtet->get_lien_topologie()!=NULL) )
4515 glColor3f(RGB_r[13]/255.,RGB_g[13]/255.,RGB_b[13]/255.);
4516 if (qualite==1)
4517 {
4518 double qual;
4519 if (femtet->get_nb_fem_noeud()==4) qual=OPERATEUR::qualite_tetra(femtet->get_fem_noeud(0)->get_coord(),femtet->get_fem_noeud(1)->get_coord(),femtet->get_fem_noeud(2)->get_coord(),femtet->get_fem_noeud(3)->get_coord());
4520 if (femtet->get_nb_fem_noeud()==10) qual=OPERATEUR::qualite_tetra(femtet->get_fem_noeud(0)->get_coord(),femtet->get_fem_noeud(2)->get_coord(),femtet->get_fem_noeud(4)->get_coord(),femtet->get_fem_noeud(9)->get_coord());
4521 if (qual>MainForm->valeurconfig[53]) glColor3f(MainForm->valeurconfig[41],MainForm->valeurconfig[42],MainForm->valeurconfig[43]);
4522 else if (qual>MainForm->valeurconfig[54]) glColor3f(MainForm->valeurconfig[44],MainForm->valeurconfig[45],MainForm->valeurconfig[46]);
4523 else if (qual>MainForm->valeurconfig[55]) glColor3f(MainForm->valeurconfig[47],MainForm->valeurconfig[48],MainForm->valeurconfig[49]);
4524 else glColor3f(MainForm->valeurconfig[50],MainForm->valeurconfig[51],MainForm->valeurconfig[52]);
4525 }
4526 if (qualite==2)
4527 {
4528 int pos=(int) ((femtet->get_mg_element_maillage()->get_origine()-1000)/10);
4529 if (pos>11) pos=11;
4530 if (pos<0) pos=0;
4531 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
4532 }
4533
4534 if (shrink)
4535 {
4536 int nb=femtet->get_nb_fem_noeud();
4537 double xg=0.;
4538 double yg=0.;
4539 double zg=0.;
4540 for (int i=0;i<nb;i++)
4541 {
4542 FEM_NOEUD* no=femtet->get_fem_noeud(i);
4543 xg=xg+no->get_x();
4544 yg=yg+no->get_y();
4545 zg=zg+no->get_z();
4546 }
4547 xg=xg/nb;
4548 yg=yg/nb;
4549 zg=zg/nb;
4550 double x1=xg+facteur_shrink*(xyz1[0]-xg);
4551 double y1=yg+facteur_shrink*(xyz1[1]-yg);
4552 double z1=zg+facteur_shrink*(xyz1[2]-zg);
4553 double x2=xg+facteur_shrink*(xyz2[0]-xg);
4554 double y2=yg+facteur_shrink*(xyz2[1]-yg);
4555 double z2=zg+facteur_shrink*(xyz2[2]-zg);
4556 double x3=xg+facteur_shrink*(xyz3[0]-xg);
4557 double y3=yg+facteur_shrink*(xyz3[1]-yg);
4558 double z3=zg+facteur_shrink*(xyz3[2]-zg);
4559 if (CheckBox1->Checked==true)
4560 {
4561 int pos=(int) ((no1->get_solution()-lmin)*12./(lmax-lmin));
4562 if (pos>11) pos=11;
4563 if (pos<0) pos=0;
4564 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
4565 }
4566 glVertex3f(x1,y1,z1);
4567 if (CheckBox1->Checked==true)
4568 {
4569 int pos=(int) ((no3->get_solution()-lmin)*12./(lmax-lmin));
4570 if (pos>11) pos=11;
4571 if (pos<0) pos=0;
4572 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
4573 }
4574 glVertex3f(x3,y3,z3);
4575 if (CheckBox1->Checked==true)
4576 {
4577 int pos=(int) ((no2->get_solution()-lmin)*12./(lmax-lmin));
4578 if (pos>11) pos=11;
4579 if (pos<0) pos=0;
4580 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
4581 }
4582 glVertex3f(x2,y2,z2);
4583 }
4584 else
4585 {
4586 if (CheckBox1->Checked==true)
4587 {
4588 int pos=(int) ((no1->get_solution()-lmin)*12./(lmax-lmin));
4589 if (pos>11) pos=11;
4590 if (pos<0) pos=0;
4591 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
4592 }
4593 glVertex3f(xyz1[0],xyz1[1],xyz1[2]);
4594 if (CheckBox1->Checked==true)
4595 {
4596 int pos=(int) ((no3->get_solution()-lmin)*12./(lmax-lmin));
4597 if (pos>11) pos=11;
4598 if (pos<0) pos=0;
4599 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
4600 }
4601 glVertex3f(xyz3[0],xyz3[1],xyz3[2]);
4602 if (CheckBox1->Checked==true)
4603 {
4604 int pos=(int) ((no2->get_solution()-lmin)*12./(lmax-lmin));
4605 if (pos>11) pos=11;
4606 if (pos<0) pos=0;
4607 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
4608 }
4609 glVertex3f(xyz2[0],xyz2[1],xyz2[2]);
4610 }
4611 }
4612 void __fastcall TVisuWinform::dessinesegtetfem(FEM_TETRA* femtet,FEM_NOEUD* no1,FEM_NOEUD* no2)
4613 {
4614 double *xyz1=no1->get_coord();
4615 double *xyz2=no2->get_coord();
4616 if ((femtet->get_lien_topologie()==toposel) && (femtet->get_lien_topologie()!=NULL) )
4617 glColor3f(RGB_r[13]/255.,RGB_g[13]/255.,RGB_b[13]/255.);
4618 if ( ((qualite==1)&&(render==0)) || ((qualite==1)&&(render==1) && (MainForm->valeurconfig[56]==0.)))
4619 {
4620 double qual;
4621 if (femtet->get_nb_fem_noeud()==4) qual=OPERATEUR::qualite_tetra(femtet->get_fem_noeud(0)->get_coord(),femtet->get_fem_noeud(1)->get_coord(),femtet->get_fem_noeud(2)->get_coord(),femtet->get_fem_noeud(3)->get_coord());
4622 if (femtet->get_nb_fem_noeud()==10) qual=OPERATEUR::qualite_tetra(femtet->get_fem_noeud(0)->get_coord(),femtet->get_fem_noeud(2)->get_coord(),femtet->get_fem_noeud(4)->get_coord(),femtet->get_fem_noeud(9)->get_coord());
4623 if (qual>MainForm->valeurconfig[53]) glColor3f(MainForm->valeurconfig[41],MainForm->valeurconfig[42],MainForm->valeurconfig[43]);
4624 else if (qual>MainForm->valeurconfig[54]) glColor3f(MainForm->valeurconfig[44],MainForm->valeurconfig[45],MainForm->valeurconfig[46]);
4625 else if (qual>MainForm->valeurconfig[55]) glColor3f(MainForm->valeurconfig[47],MainForm->valeurconfig[48],MainForm->valeurconfig[49]);
4626 else glColor3f(MainForm->valeurconfig[50],MainForm->valeurconfig[51],MainForm->valeurconfig[52]);
4627 }
4628 if ( ((qualite==2)&&(render==0)) || ((qualite==2)&&(render==1) && (MainForm->valeurconfig[56]==0.)))
4629 {
4630 int pos=(int) ((femtet->get_mg_element_maillage()->get_origine()-1000)/10);
4631 if (pos>11) pos=11;
4632 if (pos<0) pos=0;
4633 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
4634 }
4635 if (shrink)
4636 {
4637 int nb=femtet->get_nb_fem_noeud();
4638 double xg=0.;
4639 double yg=0.;
4640 double zg=0.;
4641 for (int i=0;i<nb;i++)
4642 {
4643 FEM_NOEUD* no=femtet->get_fem_noeud(i);
4644 xg=xg+no->get_x();
4645 yg=yg+no->get_y();
4646 zg=zg+no->get_z();
4647 }
4648 xg=xg/nb;
4649 yg=yg/nb;
4650 zg=zg/nb;
4651 double x1=xg+facteur_shrink*(xyz1[0]-xg);
4652 double y1=yg+facteur_shrink*(xyz1[1]-yg);
4653 double z1=zg+facteur_shrink*(xyz1[2]-zg);
4654 double x2=xg+facteur_shrink*(xyz2[0]-xg);
4655 double y2=yg+facteur_shrink*(xyz2[1]-yg);
4656 double z2=zg+facteur_shrink*(xyz2[2]-zg);
4657 if ((CheckBox1->Checked==true) && (CheckBox2->Checked==false))
4658 {
4659 int pos=(int) ((no1->get_solution()-lmin)*12./(lmax-lmin));
4660 if (pos>11) pos=11;
4661 if (pos<0) pos=0;
4662 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
4663 }
4664 glVertex3f(x1,y1,z1);
4665 if ((CheckBox1->Checked==true) && (CheckBox2->Checked==false))
4666 {
4667 int pos=(int) ((no2->get_solution()-lmin)*12./(lmax-lmin));
4668 if (pos>11) pos=11;
4669 if (pos<0) pos=0;
4670 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
4671 }
4672 glVertex3f(x2,y2,z2);
4673 }
4674 else
4675 {
4676 if ((CheckBox1->Checked==true) && (CheckBox2->Checked==false))
4677 {
4678 int pos=(int) ((no1->get_solution()-lmin)*12./(lmax-lmin));
4679 if (pos>11) pos=11;
4680 if (pos<0) pos=0;
4681 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
4682 }
4683 glVertex3f(xyz1[0],xyz1[1],xyz1[2]);
4684 if ((CheckBox1->Checked==true) && (CheckBox2->Checked==false))
4685 {
4686 int pos=(int) ((no2->get_solution()-lmin)*12./(lmax-lmin));
4687 if (pos>11) pos=11;
4688 if (pos<0) pos=0;
4689 glColor3f(RGB_r[pos]/255.,RGB_g[pos]/255.,RGB_b[pos]/255.);
4690 }
4691 glVertex3f(xyz2[0],xyz2[1],xyz2[2]);
4692 }
4693 }
4694 void __fastcall TVisuWinform::Id1Click(TObject *Sender)
4695 {
4696 Id1->Checked=true;
4697 Numero1->Checked=false;
4698 NumeroOptimise1->Checked=false;
4699 }
4700 //---------------------------------------------------------------------------
4701
4702 void __fastcall TVisuWinform::Numero1Click(TObject *Sender)
4703 {
4704 Id1->Checked=false;
4705 Numero1->Checked=true;
4706 NumeroOptimise1->Checked=false;
4707 }
4708 //---------------------------------------------------------------------------
4709
4710 void __fastcall TVisuWinform::NumeroOptimise1Click(TObject *Sender)
4711 {
4712 Id1->Checked=false;
4713 Numero1->Checked=false;
4714 NumeroOptimise1->Checked=true;
4715 }
4716 //---------------------------------------------------------------------------
4717
4718
4719 void __fastcall TVisuWinform::Cartedetaille3Click(TObject *Sender)
4720 {
4721 Tfimcarte *fimcarte=new Tfimcarte(Application,gest);
4722 fimcarte->Caption=Caption;
4723 fimcarte->ComboBox1->Clear();
4724 fimcarte->ComboBox2->Clear();
4725 int nbmai=gest->get_nb_mg_maillage();
4726 for (int i=0;i<nbmai;i++)
4727 {
4728 MG_MAILLAGE* mai=gest->get_mg_maillage(i);
4729 fimcarte->ComboBox1->Items->Add(mai->get_id());
4730 }
4731 int nbmaifem=gest->get_nb_fem_maillage();
4732 for (int i=0;i<nbmaifem;i++)
4733 {
4734 FEM_MAILLAGE* mai=gest->get_fem_maillage(i);
4735 fimcarte->ComboBox2->Items->Add(mai->get_id());
4736 }
4737 fimcarte->Show();
4738 }
4739 //---------------------------------------------------------------------------
4740
4741
4742
4743
4744
4745 void __fastcall TVisuWinform::voirarbreExecute(TObject *Sender)
4746 {
4747 Tfvisuarbre *Child;
4748 Child = new Tfvisuarbre(Application,gest);
4749 Child->Caption=Caption;
4750 }
4751 //---------------------------------------------------------------------------
4752
4753 void __fastcall TVisuWinform::Reconstruction1Click(TObject *Sender)
4754 {
4755 Tfrecons *frecons=new Tfrecons(Application,gest);
4756 frecons->Caption=Caption;
4757 frecons->ListBox1->Clear();
4758 int nbmai=gest->get_nb_fem_maillage();
4759 for (int i=0;i<nbmai;i++)
4760 {
4761 FEM_MAILLAGE* mai=gest->get_fem_maillage(i);
4762 frecons->ListBox1->Items->Add(mai->get_id());
4763 }
4764 frecons->Show();
4765 }
4766 //---------------------------------------------------------------------------
4767
4768 void __fastcall TVisuWinform::N0D1Click(TObject *Sender)
4769 {
4770 N0D1->Checked=!N0D1->Checked;
4771 noeud=0;
4772 if (N0D1->Checked) noeud=noeud+1;
4773 if (N1D1->Checked) noeud=noeud+2;
4774 if (N2D1->Checked) noeud=noeud+4;
4775 if (N3D1->Checked) noeud=noeud+8;
4776 redess();
4777
4778 }
4779 //---------------------------------------------------------------------------
4780
4781
4782 void __fastcall TVisuWinform::maillagegeometrique1Click(TObject *Sender)
4783 {
4784 int nb=gest->get_nb_mg_maillage();
4785 if (nb==0)
4786 {
4787 MessageBox(Handle,"Pas de maillage","Erreur",MB_OK);
4788 return ;
4789 }
4790 char chaine[500];
4791 for (int i=0;i<nb;i++)
4792 {
4793 MG_MAILLAGE* mai=gest->get_mg_maillage(i);
4794 if (i==0) sprintf(chaine,"Maillage %lu|*.*", mai->get_id());
4795 else
4796 {
4797 char chaine2[200];
4798 sprintf(chaine2,"|Maillage %lu|*.*", mai->get_id());
4799 strcat(chaine,chaine2);
4800 }
4801 }
4802 SaveDialog1->Filter=chaine;
4803 if (SaveDialog1->Execute())
4804 {
4805 MG_MAILLAGE* mai=gest->get_mg_maillage(SaveDialog1->FilterIndex-1);
4806 string namefic=SaveDialog1->FileName.c_str();
4807 MG_EXPORT exp;
4808 exp.gmsh(mai,namefic) ;
4809 }
4810 }
4811 //---------------------------------------------------------------------------
4812
4813 void __fastcall TVisuWinform::MaillageEF1Click(TObject *Sender)
4814 {
4815 int nb=gest->get_nb_fem_maillage();
4816 if (nb==0)
4817 {
4818 MessageBox(Handle,"Pas de maillage","Erreur",MB_OK);
4819 return ;
4820 }
4821 char chaine[500];
4822 for (int i=0;i<nb;i++)
4823 {
4824 FEM_MAILLAGE* mai=gest->get_fem_maillage(i);
4825 if (i==0) sprintf(chaine,"Maillage %lu|*.*", mai->get_id());
4826 else
4827 {
4828 char chaine2[200];
4829 sprintf(chaine2,"|Maillage %lu|*.*", mai->get_id());
4830 strcat(chaine,chaine2);
4831 }
4832 }
4833 SaveDialog1->Filter=chaine;
4834 if (SaveDialog1->Execute())
4835 {
4836 FEM_MAILLAGE* mai=gest->get_fem_maillage(SaveDialog1->FilterIndex-1);
4837 string namefic=SaveDialog1->FileName.c_str();
4838 MG_EXPORT exp;
4839 exp.gmsh(mai,namefic) ;
4840 }
4841 }
4842 //---------------------------------------------------------------------------
4843
4844 void __fastcall TVisuWinform::N12Click(TObject *Sender)
4845 {
4846 N12->Checked=!N12->Checked;
4847 TabSheet7->TabVisible=N12->Checked;
4848 redess();
4849 }
4850 //---------------------------------------------------------------------------
4851
4852 void __fastcall TVisuWinform::Button10Click(TObject *Sender)
4853 {
4854 ListBox4->Clear();
4855 filtreid.clear();
4856 redess();
4857 }
4858 //---------------------------------------------------------------------------
4859
4860 void __fastcall TVisuWinform::Button9Click(TObject *Sender)
4861 {
4862 if (ListBox4->ItemIndex==-1) return;
4863 ListBox4->Items->Delete(ListBox4->ItemIndex);
4864 vector<unsigned long>::iterator it=filtreid.begin();
4865 for (int i=0;i<ListBox4->ItemIndex;i++) it++;
4866 filtreid.erase(it);
4867 redess();
4868 }
4869 //---------------------------------------------------------------------------
4870
4871 void __fastcall TVisuWinform::Button8Click(TObject *Sender)
4872 {
4873 static AnsiString InputString = "";
4874 AnsiString InputString2=InputBox("Filtre ID", "ID de l'élément à afficher ?", InputString);
4875 if (InputString2!=InputString)
4876 {
4877 InputString=InputString2;
4878 ListBox4->Items->Add(InputString);
4879 unsigned long id;
4880 sscanf(InputString.c_str(),"%lu",&id);
4881 filtreid.insert(filtreid.end(),id);
4882 redess();
4883 }
4884 }
4885 //---------------------------------------------------------------------------
4886 int __fastcall TVisuWinform::estdansfiltre(unsigned long id)
4887 {
4888 for (vector<unsigned long>::iterator it=filtreid.begin();it!=filtreid.end();it++)
4889 if (*it==id) return 1;
4890 return 0;
4891 }
4892
4893 void __fastcall TVisuWinform::qualiteorigineExecute(TObject *Sender)
4894 {
4895 qualite=2;
4896 redess();
4897 }
4898 //---------------------------------------------------------------------------
4899