ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/app/VMM/VMM/win32/visuwin.cpp
Revision: 101
Committed: Fri May 16 21:35:36 2008 UTC (17 years, 3 months ago) by francois
File size: 253554 byte(s)
Log Message:
Afficher les solides en geometrie

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