ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/app/VMM/win32/visuwin.cpp
Revision: 196
Committed: Fri Jul 17 19:31:14 2009 UTC (16 years, 1 month ago) by francois
Original Path: magic/app/VMM/VMM/win32/visuwin.cpp
File size: 284832 byte(s)
Log Message:
Resolution bug windows de la precedente mise a jour

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