ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/app/VMM/win32/visuwin.cpp
Revision: 188
Committed: Wed Jul 8 20:53:35 2009 UTC (16 years, 2 months ago) by francois
Original Path: magic/app/VMM/VMM/win32/visuwin.cpp
File size: 280254 byte(s)
Log Message:
Compilation des derniers changements sous Borland et Slection possible dans VMM

File Contents

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