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 |
|
|
// transform.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 |
|
|
#pragma hdrstop
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
#include "mg_gestionnaire.h"
|
32 |
|
|
#include "step_import.h"
|
33 |
|
|
#include "acis_import.h"
|
34 |
|
|
#include "sld_import.h"
|
35 |
|
|
#include "stl_import.h"
|
36 |
|
|
#include "main.h"
|
37 |
|
|
#include "transform.h"
|
38 |
francois |
98 |
#include "vct_multi_modele.h"
|
39 |
|
5 |
//---------------------------------------------------------------------------
|
40 |
|
|
#pragma package(smart_init)
|
41 |
|
|
#pragma resource "*.dfm"
|
42 |
|
|
Twintransform *wintransform;
|
43 |
|
|
//---------------------------------------------------------------------------
|
44 |
|
|
__fastcall Twintransform::Twintransform(TComponent* Owner)
|
45 |
|
|
: TForm(Owner)
|
46 |
|
|
{
|
47 |
|
|
}
|
48 |
|
|
//---------------------------------------------------------------------------
|
49 |
|
|
void __fastcall Twintransform::FormClose(TObject *Sender,
|
50 |
|
|
TCloseAction &Action)
|
51 |
|
|
{
|
52 |
|
|
Action = caFree;
|
53 |
|
|
}
|
54 |
|
|
//---------------------------------------------------------------------------
|
55 |
|
|
void __fastcall Twintransform::Button1Click(TObject *Sender)
|
56 |
|
|
{
|
57 |
|
|
if (OpenDialog1->Execute())
|
58 |
|
|
{
|
59 |
|
|
Edit1->Text=OpenDialog1->FileName;
|
60 |
|
|
AnsiString temp=Edit1->Text;
|
61 |
|
|
int nb=temp.Length();
|
62 |
|
|
int i=nb;
|
63 |
|
|
int ok=0;
|
64 |
|
|
while (ok==0)
|
65 |
|
|
{
|
66 |
|
|
if (temp[i]=='.') ok=1;
|
67 |
|
|
if (i==0) ok=2;
|
68 |
|
|
i--;
|
69 |
|
|
}
|
70 |
|
|
if (ok==1) temp.Delete(i+1,nb);
|
71 |
|
|
Edit2->Text=temp+".magic";
|
72 |
|
|
}
|
73 |
|
|
}
|
74 |
|
|
//---------------------------------------------------------------------------
|
75 |
|
|
void __fastcall Twintransform::Button3Click(TObject *Sender)
|
76 |
|
|
{
|
77 |
|
|
CheckBox1->Checked=false;
|
78 |
|
|
CheckBox2->Checked=false;
|
79 |
|
|
ProgressBar1->Position=0;
|
80 |
|
|
MG_GESTIONNAIRE gest;
|
81 |
|
|
ProgressBar1->Position=2;
|
82 |
|
|
if (GroupBox1->Caption=="Fichier STEP")
|
83 |
|
|
{
|
84 |
|
|
STEP_IMPORT stepmagic;
|
85 |
|
|
ProgressBar1->Position=5;
|
86 |
|
|
stepmagic.importer(gest,Edit1->Text.c_str());
|
87 |
|
|
stat();
|
88 |
|
|
ListBox1->Items->Add("");
|
89 |
|
|
ListBox1->Items->Add("");
|
90 |
|
|
ListBox1->Items->Add("Entités non utilisées par l'importation");
|
91 |
|
|
ListBox1->Items->Add("-----------------------------------------------------------------");
|
92 |
|
|
int num=gest.get_gest_step().lst_entity.get_nb();
|
93 |
|
|
for (int i=0;i<num;i++)
|
94 |
|
|
{
|
95 |
|
|
ST_IDENTIFICATEUR* st=gest.get_gest_step().lst_entity.get(i);
|
96 |
|
|
if (st->get_util()==false)
|
97 |
|
|
{
|
98 |
|
|
char mess[255];
|
99 |
|
|
sprintf(mess," Entité step numero %lu",st->get_id());
|
100 |
|
|
ListBox1->Items->Add(mess);
|
101 |
|
|
}
|
102 |
|
|
}
|
103 |
francois |
98 |
ListBox1->Items->Add("");
|
104 |
|
|
ListBox1->Items->Add("");
|
105 |
|
|
ListBox1->Items->Add("");
|
106 |
|
|
ListBox1->Items->Add("");
|
107 |
|
5 |
}
|
108 |
|
|
if (GroupBox1->Caption=="Fichier SAT")
|
109 |
|
|
{
|
110 |
|
|
ACIS_IMPORT satmagic;
|
111 |
|
|
ProgressBar1->Position=5;
|
112 |
|
|
satmagic.importer(gest,Edit1->Text.c_str());
|
113 |
|
|
}
|
114 |
|
|
if (GroupBox1->Caption=="Fichier STL")
|
115 |
|
|
{
|
116 |
|
|
STL_IMPORT stlmagic;
|
117 |
|
|
ProgressBar1->Position=5;
|
118 |
|
|
stlmagic.importer(gest,Edit1->Text.c_str());
|
119 |
|
|
}
|
120 |
|
|
if (GroupBox1->Caption=="Fichier SolidWorks")
|
121 |
|
|
{
|
122 |
|
|
#ifdef BREP_SLD
|
123 |
|
|
SLD_IMPORT sldmagic;
|
124 |
|
|
ProgressBar1->Position=5;
|
125 |
|
|
sldmagic.importer(gest,Edit1->Text.c_str());
|
126 |
|
|
#endif
|
127 |
|
|
}
|
128 |
|
|
int nbgeo=gest.get_nb_mg_geometrie();
|
129 |
|
|
for (int i=0;i<nbgeo;i++)
|
130 |
|
|
{
|
131 |
|
|
MG_GEOMETRIE* geo=gest.get_mg_geometrie(i);
|
132 |
|
|
double coef;
|
133 |
|
|
if (RadioButton1->Checked) coef=1e-3;
|
134 |
|
|
if (RadioButton2->Checked) coef=1;
|
135 |
|
|
if (RadioButton3->Checked) coef=25.4e-3;
|
136 |
|
|
if (RadioButton4->Checked) coef=304.8e-3;
|
137 |
|
|
if (RadioButton5->Checked) coef=1e-2;
|
138 |
|
|
geo->change_valeur_unite(coef);
|
139 |
|
|
}
|
140 |
|
|
ProgressBar1->Position=47;
|
141 |
|
|
CheckBox1->Checked=true;
|
142 |
|
|
ProgressBar1->Position=57;
|
143 |
francois |
98 |
if (CheckBox3->Checked)
|
144 |
|
|
{
|
145 |
|
|
ListBox1->Items->Add("Fusion d'entité");
|
146 |
|
|
ListBox1->Items->Add("---------------");
|
147 |
|
|
for (int i=0;i<nbgeo;i++)
|
148 |
|
|
{
|
149 |
|
|
MG_GEOMETRIE* geo=gest.get_mg_geometrie(i);
|
150 |
|
|
int nbface=geo->get_nb_mg_face();
|
151 |
|
|
int nbarete=geo->get_nb_mg_arete();
|
152 |
|
|
int nbsommet=geo->get_nb_mg_sommet();
|
153 |
|
|
VCT_MULTI_MODELE mv(geo);
|
154 |
|
|
mv.recherche_identite();
|
155 |
|
|
nbface=nbface-geo->get_nb_mg_face();
|
156 |
|
|
nbarete=nbarete-geo->get_nb_mg_arete();
|
157 |
|
|
nbsommet=nbsommet-geo->get_nb_mg_sommet();
|
158 |
|
|
char mess[255];
|
159 |
|
|
sprintf(mess," Géometrie numero %lu",geo->get_id());
|
160 |
|
|
ListBox1->Items->Add(mess);
|
161 |
|
|
sprintf(mess," Sommet fusionné : %d",nbsommet);
|
162 |
|
|
ListBox1->Items->Add(mess);
|
163 |
|
|
sprintf(mess," Arete fusionnée : %d",nbarete);
|
164 |
|
|
ListBox1->Items->Add(mess);
|
165 |
|
|
sprintf(mess," Face fusionnée : %d",nbface);
|
166 |
|
|
ListBox1->Items->Add(mess);
|
167 |
|
|
}
|
168 |
|
|
}
|
169 |
|
|
ProgressBar1->Position=69;
|
170 |
|
5 |
gest.enregistrer(Edit2->Text.c_str());
|
171 |
|
|
ProgressBar1->Position=95;
|
172 |
|
|
CheckBox2->Checked=true;
|
173 |
|
|
ProgressBar1->Position=100;
|
174 |
|
|
|
175 |
|
|
}
|
176 |
|
|
//---------------------------------------------------------------------------
|
177 |
|
|
void __fastcall Twintransform::Button2Click(TObject *Sender)
|
178 |
|
|
{
|
179 |
|
|
Close();
|
180 |
|
|
}
|
181 |
|
|
//---------------------------------------------------------------------------
|
182 |
|
|
|
183 |
|
|
void __fastcall Twintransform::Button4Click(TObject *Sender)
|
184 |
|
|
{
|
185 |
|
|
stat();
|
186 |
|
|
}
|
187 |
|
|
//---------------------------------------------------------------------------
|
188 |
|
|
void __fastcall Twintransform::stat(void)
|
189 |
|
|
{
|
190 |
|
|
if (GroupBox1->Caption=="Fichier STEP")
|
191 |
|
|
{
|
192 |
|
|
|
193 |
|
|
GroupBox4->Caption="Verification du fichier step";
|
194 |
|
|
GroupBox4->Visible=true;
|
195 |
|
|
ST_GESTIONNAIRE fich(Edit1->Text.c_str());
|
196 |
|
|
fich.lire();
|
197 |
|
|
ListBox1->Clear();
|
198 |
|
|
ListBox1->Items->Add("Entités lues");
|
199 |
|
|
ListBox1->Items->Add("-----------------------------------------------------------------");
|
200 |
|
|
for (int i=0;i<25;i++)
|
201 |
|
|
{
|
202 |
|
|
char mess[255];
|
203 |
|
|
sprintf(mess,"%s %d",fich.entitenom[i].c_str(),fich.tabentite[i]);
|
204 |
|
|
if (fich.tabentite[i]>0) ListBox1->Items->Add(mess);
|
205 |
|
|
}
|
206 |
|
|
ListBox1->Items->Add("");
|
207 |
|
|
ListBox1->Items->Add("");
|
208 |
|
|
ListBox1->Items->Add("Entités non lues");
|
209 |
|
|
ListBox1->Items->Add("-----------------------------------------------------------------");
|
210 |
|
|
int num=fich.entitenontraite.size();
|
211 |
|
|
for (int i=0;i<num;i++)
|
212 |
|
|
ListBox1->Items->Add(fich.entitenontraite[i].c_str());
|
213 |
|
|
|
214 |
|
|
}
|
215 |
|
|
}
|
216 |
|
|
//---------------------------------------------------------------------------
|
217 |
|
|
|
218 |
|
|
void __fastcall Twintransform::ListBox1Click(TObject *Sender)
|
219 |
|
|
{
|
220 |
|
|
ListBox1->Hint=ListBox1->Items->Strings[ListBox1->ItemIndex];
|
221 |
|
|
}
|
222 |
|
|
//---------------------------------------------------------------------------
|
223 |
|
|
|
224 |
|
|
void __fastcall Twintransform::Button5Click(TObject *Sender)
|
225 |
|
|
{
|
226 |
|
|
MainForm->CreateMDIChildVisu(Sender,Edit2->Text);
|
227 |
|
|
Close();
|
228 |
|
|
}
|
229 |
|
|
//---------------------------------------------------------------------------
|
230 |
|
|
|