ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/app/VMM/VMM/win32/visuwin.cpp
Revision: 62
Committed: Fri Nov 16 16:46:00 2007 UTC (17 years, 9 months ago) by francois
File size: 212454 byte(s)
Log Message:
Nouvelle version de VMM avec couleur configurable et affichage de l 'origine des mailles
Nouveau prog de transfert
Nouvelle version de mailleur avec toutes les options disponibles

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