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 |
|
|
// tmaille.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 <time.h>
|
29 |
|
|
#pragma hdrstop
|
30 |
|
|
|
31 |
|
|
#include "tmaille.h"
|
32 |
|
|
#include "fct_taille.h"
|
33 |
|
|
#include "fct_generateur_3d.h"
|
34 |
|
|
#include "magicform.h"
|
35 |
|
|
#include "mailleur.h"
|
36 |
|
|
#include "mailleur0d.h"
|
37 |
|
|
#include "mailleur1d.h"
|
38 |
|
|
#include "mailleur2d.h"
|
39 |
|
|
#include "mailleur3d.h"
|
40 |
|
|
#include "mailleur3d_dia.h"
|
41 |
|
|
#include "mg_file.h"
|
42 |
|
|
|
43 |
|
|
#pragma package(smart_init)
|
44 |
|
|
//---------------------------------------------------------------------------
|
45 |
|
|
|
46 |
|
|
// Important: Methods and properties of objects in VCL can only be
|
47 |
|
|
// used in a method called using Synchronize, for example:
|
48 |
|
|
//
|
49 |
|
|
// Synchronize(UpdateCaption);
|
50 |
|
|
//
|
51 |
|
|
// where UpdateCaption could look like:
|
52 |
|
|
//
|
53 |
|
|
// void __fastcall Unit1::UpdateCaption()
|
54 |
|
|
// {
|
55 |
|
|
// Form1->Caption = "Updated in a thread";
|
56 |
|
|
// }
|
57 |
|
|
//---------------------------------------------------------------------------
|
58 |
|
|
|
59 |
|
|
__fastcall Thread_maille::Thread_maille(TVisuMagicform* f,int type)
|
60 |
|
|
: TThread(false),form(f),mgmai(NULL),etat(0),snb_segment(0),snb_tri(0),snb_tetra(0),type_maillage(type)
|
61 |
|
|
{
|
62 |
|
|
this->FreeOnTerminate=true;
|
63 |
|
|
}
|
64 |
|
|
//---------------------------------------------------------------------------
|
65 |
|
|
void __fastcall Thread_maille::Execute()
|
66 |
|
|
{
|
67 |
|
|
Priority=tpNormal;
|
68 |
|
|
form->Button1->Enabled=false;
|
69 |
|
|
form->Button2->Caption="Annuler" ;
|
70 |
|
|
form->Font->Color=clWindowText;
|
71 |
|
|
form->Memo1->Lines->Add("----------------------------");
|
72 |
|
|
form->Memo1->Lines->Add("Lecture MAGiC");
|
73 |
|
|
long cpu_avant=clock();
|
74 |
|
|
MG_FILE gest(form->Caption.c_str());
|
75 |
|
|
if (form->CheckBox1->Checked==true)
|
76 |
|
|
{
|
77 |
|
|
form->Memo1->Lines->Add("Copie du modèle");
|
78 |
|
|
string chemin=form->Caption.c_str();
|
79 |
|
|
chemin=chemin+".copie";
|
80 |
|
|
gest.enregistrer(chemin.c_str());
|
81 |
|
|
}
|
82 |
|
|
MG_GEOMETRIE* mggeo=gest.get_mg_geometrie(0);
|
83 |
|
|
mgmai=new MG_MAILLAGE(mggeo);
|
84 |
|
|
gest.ajouter_mg_maillage(mgmai);
|
85 |
|
|
FCT_GENERATEUR_3D<4> carte;
|
86 |
|
|
FCT_TAILLE* metrique;
|
87 |
|
|
if (type_maillage==1)
|
88 |
|
|
{
|
89 |
|
|
metrique=NULL;
|
90 |
|
|
}
|
91 |
|
|
if (type_maillage==2)
|
92 |
|
|
{
|
93 |
|
|
form->Memo1->Lines->Add("Lecture carte de taille");
|
94 |
|
|
carte.lire(form->Edit1->Text.c_str());
|
95 |
|
|
metrique=&carte;
|
96 |
|
|
}
|
97 |
|
|
form->Memo1->Lines->Add("MAILLAGE 0D");
|
98 |
|
|
MAILLEUR0D m0d(mgmai,mggeo);
|
99 |
|
|
m0d.maille();
|
100 |
|
|
form->Memo1->Lines->Add("MAILLAGE 1D");
|
101 |
|
|
etat=1;
|
102 |
|
|
int nb=mggeo->get_nb_mg_arete();
|
103 |
|
|
for (int i=0;i<nb;i++)
|
104 |
|
|
{
|
105 |
|
|
MG_ARETE* arete=mggeo->get_mg_arete(i);
|
106 |
|
|
MAILLEUR1D m1d(mgmai,mggeo,arete,metrique);
|
107 |
|
|
m1d.maille();
|
108 |
|
|
}
|
109 |
|
|
if ( (form->RadioButton3->Checked==true) || (form->RadioButton4->Checked==true) || (form->RadioButton5->Checked==true))
|
110 |
|
|
{
|
111 |
|
|
form->Memo1->Lines->Add("MAILLAGE 2D");
|
112 |
|
|
etat=2;
|
113 |
|
|
snb_segment=mgmai->get_nb_mg_segment();
|
114 |
|
|
int nb=mggeo->get_nb_mg_face();
|
115 |
|
|
for (int i=0;i<nb;i++)
|
116 |
|
|
{
|
117 |
|
|
char affiche[100];
|
118 |
|
|
sprintf(affiche," face %d",i);
|
119 |
|
|
form->Memo1->Lines->Add(affiche);
|
120 |
|
|
MG_FACE* mgface=mggeo->get_mg_face(i);
|
121 |
|
|
MAILLEUR2D m2d(mgmai,mggeo,mgface,metrique);
|
122 |
|
|
m2d.maille();
|
123 |
|
|
}
|
124 |
|
|
}
|
125 |
|
|
if (form->RadioButton4->Checked==true)
|
126 |
|
|
{
|
127 |
|
|
etat=3;
|
128 |
|
|
snb_tri=mgmai->get_nb_mg_triangle();
|
129 |
|
|
form->Memo1->Lines->Add("MAILLAGE 3D");
|
130 |
|
|
MAILLEUR3D m3d(mgmai,mggeo);
|
131 |
|
|
if (form->CheckBox2->Checked==true) m3d.active_log(form->Caption.c_str());
|
132 |
|
|
m3d.maille();
|
133 |
|
|
}
|
134 |
|
|
if (form->RadioButton5->Checked==true)
|
135 |
|
|
{
|
136 |
|
|
etat=3;
|
137 |
|
|
snb_tri=mgmai->get_nb_mg_triangle();
|
138 |
|
|
form->Memo1->Lines->Add("MAILLAGE 3D");
|
139 |
|
|
MAILLEUR3D_DIA m3d(mgmai,mggeo,mggeo->get_mg_volume(0));
|
140 |
|
|
m3d.maille();
|
141 |
|
|
}
|
142 |
|
|
form->Memo1->Lines->Add("Enregistrement MAGIC");
|
143 |
|
|
gest.enregistrer(form->Caption.c_str());
|
144 |
|
|
form->Memo1->Lines->Add("----------------------------");
|
145 |
|
|
long cpu=clock();
|
146 |
|
|
double res=((double)(cpu-cpu_avant)/CLK_TCK);
|
147 |
|
|
char affiche[300];
|
148 |
|
|
sprintf(affiche," CPU 3D total : %lf", res);
|
149 |
|
|
form->Memo1->Lines->Add(affiche);
|
150 |
|
|
form->Memo1->Lines->Add("----------------------------");
|
151 |
|
|
form->Button2->Caption="Quitter" ;
|
152 |
|
|
form->Button1->Enabled=true;
|
153 |
|
|
mgmai=NULL;
|
154 |
|
|
form->maille_process=NULL;
|
155 |
|
|
}
|
156 |
|
|
//---------------------------------------------------------------------------
|
157 |
|
|
int Thread_maille::get_info(long &nb_noeud,long &nb_segment,long &nb_triangle,long &nb_tetra)
|
158 |
|
|
{
|
159 |
|
|
if (mgmai!=NULL)
|
160 |
|
|
{
|
161 |
|
|
nb_noeud=mgmai->get_nb_mg_noeud();
|
162 |
|
|
if (etat==1) snb_segment=mgmai->get_nb_mg_segment();
|
163 |
|
|
if (etat==2) snb_tri=mgmai->get_nb_mg_triangle();
|
164 |
|
|
if (etat==3) snb_tetra=mgmai->get_nb_mg_tetra();
|
165 |
|
|
nb_segment=snb_segment;
|
166 |
|
|
nb_triangle=snb_tri;
|
167 |
|
|
nb_tetra=snb_tetra;
|
168 |
|
|
return 1;
|
169 |
|
|
}
|
170 |
|
|
return 0;
|
171 |
|
|
}
|
172 |
|
|
|