1 |
francois |
1156 |
//####//------------------------------------------------------------ |
2 |
|
|
//####//------------------------------------------------------------ |
3 |
|
|
//####// MAGiC |
4 |
|
|
//####// Jean Christophe Cuilliere et Vincent FRANCOIS |
5 |
|
|
//####// Departement de Genie Mecanique - UQTR |
6 |
|
|
//####//------------------------------------------------------------ |
7 |
|
|
//####// MAGIC est un projet de recherche de l equipe ERICCA |
8 |
|
|
//####// du departement de genie mecanique de l Universite du Quebec a Trois Rivieres |
9 |
|
|
//####// http://www.uqtr.ca/ericca |
10 |
|
|
//####// http://www.uqtr.ca/ |
11 |
|
|
//####//------------------------------------------------------------ |
12 |
|
|
//####//------------------------------------------------------------ |
13 |
|
|
//####// |
14 |
|
|
//####// st_gestionnaire.cpp |
15 |
|
|
//####// |
16 |
|
|
//####//------------------------------------------------------------ |
17 |
|
|
//####//------------------------------------------------------------ |
18 |
|
|
//####// COPYRIGHT 2000-2024 |
19 |
|
|
//####// jeu 13 jun 2024 11:53:59 EDT |
20 |
|
|
//####//------------------------------------------------------------ |
21 |
|
|
//####//------------------------------------------------------------ |
22 |
francois |
283 |
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
#include <stdio.h> |
26 |
|
|
|
27 |
|
|
#include <stdlib.h> |
28 |
|
|
#include <string.h> |
29 |
|
|
#include "st_gestionnaire.h" |
30 |
|
|
#include "parse.h" |
31 |
|
|
#include "pars_argument.h" |
32 |
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
template<class Y,class X> void ajouter(Y& y,X x,ST_GESTIONNAIRE& gest) |
39 |
|
|
{ |
40 |
|
|
y.ajouter(x); |
41 |
|
|
gest.lst_entity.ajouter(x); |
42 |
|
|
} |
43 |
|
|
|
44 |
|
|
template<class Y,class X>void libere(Y& y) |
45 |
|
|
{ |
46 |
|
|
for (long i=0;i<y.get_nb();i++) |
47 |
|
|
{ |
48 |
|
|
X* x=y.get(i); |
49 |
|
|
delete x; |
50 |
|
|
} |
51 |
|
|
y.vide(); |
52 |
|
|
} |
53 |
|
|
|
54 |
|
|
ST_GESTIONNAIRE::ST_GESTIONNAIRE(char *path):nom(NULL) |
55 |
|
|
{ |
56 |
|
|
int num=strlen(path); |
57 |
|
|
nom=new char[num+1]; |
58 |
|
|
strcpy(nom,path); |
59 |
|
|
init(); |
60 |
|
|
} |
61 |
|
|
|
62 |
|
|
ST_GESTIONNAIRE::ST_GESTIONNAIRE():nom(NULL) |
63 |
|
|
{ |
64 |
|
|
init(); |
65 |
|
|
} |
66 |
|
|
|
67 |
|
|
|
68 |
|
|
void ST_GESTIONNAIRE::init(void) |
69 |
|
|
{ |
70 |
|
|
for (int i=0;i<25;i++) tabentite[i]=0; |
71 |
|
|
entitenom.insert(entitenom.end(),"VERTEX_POINT"); |
72 |
|
|
entitenom.insert(entitenom.end(),"VECTOR"); |
73 |
|
|
entitenom.insert(entitenom.end(),"LINE"); |
74 |
|
|
entitenom.insert(entitenom.end(),"EDGE_CURVE"); |
75 |
|
|
entitenom.insert(entitenom.end(),"ORIENTED_EDGE"); |
76 |
|
|
entitenom.insert(entitenom.end(),"EDGE_LOOP"); |
77 |
|
|
entitenom.insert(entitenom.end(),"FACE_BOUND"); |
78 |
|
|
entitenom.insert(entitenom.end(),"FACE_OUTER_BOUND"); |
79 |
|
|
entitenom.insert(entitenom.end(),"ADVANCED_FACE"); |
80 |
|
|
entitenom.insert(entitenom.end(),"AXIS2_PLACEMENT_3D"); |
81 |
|
|
entitenom.insert(entitenom.end(),"PLANE"); |
82 |
|
|
entitenom.insert(entitenom.end(),"CYLINDRICAL_SURFACE"); |
83 |
|
|
entitenom.insert(entitenom.end(),"TOROIDAL_SURFACE"); |
84 |
|
|
entitenom.insert(entitenom.end(),"CONICAL_SURFACE"); |
85 |
|
|
entitenom.insert(entitenom.end(),"SPHERICAL_SURFACE"); |
86 |
|
|
entitenom.insert(entitenom.end(),"CLOSED_SHELL"); |
87 |
|
|
entitenom.insert(entitenom.end(),"ORIENTED_CLOSED_SHELL"); |
88 |
|
|
entitenom.insert(entitenom.end(),"MANIFOLD_SOLID_BREP"); |
89 |
|
|
entitenom.insert(entitenom.end(),"BREP_WITH_VOIDS"); |
90 |
|
|
entitenom.insert(entitenom.end(),"CIRCLE"); |
91 |
|
|
entitenom.insert(entitenom.end(),"ELLIPSE"); |
92 |
|
|
entitenom.insert(entitenom.end(),"DIRECTION"); |
93 |
|
|
entitenom.insert(entitenom.end(),"CARTESIAN_POINT"); |
94 |
|
|
entitenom.insert(entitenom.end(),"B_SPLINE_CURVE_WITH_KNOTS"); |
95 |
|
|
entitenom.insert(entitenom.end(),"B_SPLINE_SURFACE_WITH_KNOTS"); |
96 |
|
|
} |
97 |
|
|
|
98 |
|
|
ST_GESTIONNAIRE::~ST_GESTIONNAIRE() |
99 |
|
|
{ |
100 |
|
|
libere<TPL_MAP_ENTITE<class ST_VECTOR*>,ST_VECTOR>(lst_vector); |
101 |
|
|
libere<TPL_MAP_ENTITE<class ST_EDGE_CURVE*>,ST_EDGE_CURVE>(lst_edgecurve); |
102 |
|
|
libere<TPL_MAP_ENTITE<class ST_ORIENTED_EDGE*>,ST_ORIENTED_EDGE>(lst_oriedge); |
103 |
|
|
libere<TPL_MAP_ENTITE<class ST_LINE*>,ST_LINE>(lst_line); |
104 |
|
|
libere<TPL_MAP_ENTITE<class ST_FACE_BOUND*>,ST_FACE_BOUND>(lst_facebound); |
105 |
|
|
libere<TPL_MAP_ENTITE<class ST_VERTEX*>,ST_VERTEX>(lst_vertex); |
106 |
|
|
libere<TPL_MAP_ENTITE<class ST_PLANE*>,ST_PLANE>(lst_plane); |
107 |
|
|
libere<TPL_MAP_ENTITE<class ST_CYLINDRICAL*>,ST_CYLINDRICAL>(lst_cylindrical); |
108 |
|
|
libere<TPL_MAP_ENTITE<class ST_SPHERICAL*>,ST_SPHERICAL>(lst_spherical); |
109 |
|
|
libere<TPL_MAP_ENTITE<class ST_TOROIDAL*>,ST_TOROIDAL>(lst_toroidal); |
110 |
|
|
libere<TPL_MAP_ENTITE<class ST_CONICAL*>,ST_CONICAL>(lst_conical); |
111 |
|
|
libere<TPL_MAP_ENTITE<class ST_AXIS2_PLACEMENT_3D*>,ST_AXIS2_PLACEMENT_3D>(lst_axis2_placement_3d); |
112 |
|
|
libere<TPL_MAP_ENTITE<class ST_CLOSED_SHELL*>,ST_CLOSED_SHELL>(lst_closed_shell); |
113 |
|
|
libere<TPL_MAP_ENTITE<class ST_ORIENTED_CLOSED_SHELL*>,ST_ORIENTED_CLOSED_SHELL>(lst_oriented_closed_shell); |
114 |
|
|
libere<TPL_MAP_ENTITE<class ST_ADVANCED_FACE*>,ST_ADVANCED_FACE>(lst_advanced_face); |
115 |
|
|
libere<TPL_MAP_ENTITE<class ST_EDGE_LOOP*>,ST_EDGE_LOOP>(lst_edge_loop); |
116 |
|
|
libere<TPL_MAP_ENTITE<class ST_MANIFOLD_BREP*>,ST_MANIFOLD_BREP>(lst_manifold_brep); |
117 |
|
|
libere<TPL_MAP_ENTITE<class ST_BREP_WITH_VOIDS*>,ST_BREP_WITH_VOIDS>(lst_brep_with_voids); |
118 |
|
|
libere<TPL_MAP_ENTITE<class ST_CIRCLE*>,ST_CIRCLE>(lst_circle); |
119 |
|
|
libere<TPL_MAP_ENTITE<class ST_ELLIPSE*>,ST_ELLIPSE>(lst_ellipse); |
120 |
|
|
libere<TPL_MAP_ENTITE<class ST_DIRECTION*>,ST_DIRECTION>(lst_direction); |
121 |
|
|
libere<TPL_MAP_ENTITE<class ST_POINT*>,ST_POINT>(lst_point); |
122 |
|
|
libere<TPL_MAP_ENTITE<class ST_B_SPLINE*>,ST_B_SPLINE>(lst_bspline); |
123 |
|
|
libere<TPL_MAP_ENTITE<class ST_B_SPLINE_SURF*>,ST_B_SPLINE_SURF>(lst_bsplines); |
124 |
|
|
lst_entity.vide(); |
125 |
|
|
if (nom!=NULL) delete [] nom; |
126 |
|
|
} |
127 |
|
|
|
128 |
|
|
|
129 |
|
|
void ST_GESTIONNAIRE::change_nom(char *path) |
130 |
|
|
{ |
131 |
|
|
if (nom!=NULL) delete [] nom; |
132 |
|
|
int num=strlen(path); |
133 |
|
|
nom=new char[num+1]; |
134 |
|
|
strcpy(nom,path); |
135 |
|
|
} |
136 |
|
|
|
137 |
|
|
|
138 |
|
|
|
139 |
|
|
|
140 |
|
|
char* ST_GESTIONNAIRE::get_nom(void) |
141 |
|
|
{ |
142 |
|
|
return nom; |
143 |
|
|
} |
144 |
|
|
|
145 |
|
|
long ST_GESTIONNAIRE::cid(std::string str) |
146 |
|
|
{ |
147 |
|
|
return atol(str.c_str()+1); |
148 |
|
|
} |
149 |
|
|
|
150 |
|
|
|
151 |
|
|
|
152 |
|
|
int ST_GESTIONNAIRE::cbool(std::string str) |
153 |
|
|
{ |
154 |
|
|
if (str==".T.") return 1; |
155 |
|
|
if (str==".F.") return -1; |
156 |
|
|
return 0; |
157 |
|
|
} |
158 |
|
|
|
159 |
|
|
|
160 |
|
|
int ST_GESTIONNAIRE::lire(void) |
161 |
|
|
{ |
162 |
|
|
FILE *in; |
163 |
|
|
|
164 |
|
|
|
165 |
|
|
in=fopen(nom,"rt"); |
166 |
|
|
if (in==NULL) return 0; |
167 |
|
|
|
168 |
|
|
|
169 |
|
|
PARS_ARGUMENT param[20]; |
170 |
|
|
PARSE parse; |
171 |
|
|
do |
172 |
|
|
{ |
173 |
|
|
int ierr; |
174 |
|
|
std::string ligne=parse.lire(in,';',&ierr); |
175 |
|
|
if (ierr!=0) return 0; |
176 |
|
|
parse.decode(ligne.c_str(),"@;",param); |
177 |
|
|
} |
178 |
|
|
while (param[0].argument[0]!="DATA"); |
179 |
|
|
|
180 |
|
|
do |
181 |
|
|
{ |
182 |
|
|
int ierr; |
183 |
|
|
std::string ligne=parse.lire(in,';',&ierr); |
184 |
|
|
int nbcar=ligne.length(); |
185 |
|
|
for (int i=nbcar-1;i>=0;i--) |
186 |
|
|
if (ligne[i]==' ') ligne.erase(i,1); |
187 |
|
|
parse.decode(ligne.c_str(),"@;",param); |
188 |
|
|
if (param[0].argument[0]!="ENDSEC") |
189 |
|
|
{ |
190 |
|
|
parse.decode(ligne.c_str(),"#@=@(@);",param); |
191 |
|
|
std::string entite=param[1].argument[0]; |
192 |
|
|
if (entite=="") |
193 |
|
|
{ |
194 |
|
|
parse.decode(ligne.c_str(),"#@=(@);",param); |
195 |
|
|
entite=param[1].argument[0]; |
196 |
|
|
} |
197 |
|
|
long id=atol(param[0].argument[0].c_str()); |
198 |
|
|
std::string data=param[2].argument[0] ; |
199 |
|
|
if (entite=="VERTEX_POINT") |
200 |
|
|
{ |
201 |
|
|
parse.decode(data.c_str(),"'@',@",param+2); |
202 |
|
|
long id_point=cid(param[3].argument[0].c_str()); |
203 |
|
|
ST_VERTEX *vertex=new ST_VERTEX(id,param[2].argument[0],id_point); |
204 |
|
|
ajouter<TPL_MAP_ENTITE<ST_VERTEX*>,ST_VERTEX*>(lst_vertex,vertex,*this); |
205 |
|
|
tabentite[VERTEX_POINT]++; |
206 |
|
|
} |
207 |
|
|
else if (entite=="VECTOR") |
208 |
|
|
{ |
209 |
|
|
parse.decode(data.c_str(),"'@',@,@",param+2); |
210 |
|
|
long iddirection=cid(param[3].argument[0]); |
211 |
|
|
double magnitude=atof(param[4].argument[0].c_str()); |
212 |
|
|
ST_VECTOR* vector=new ST_VECTOR(id,param[2].argument[0],iddirection,magnitude); |
213 |
|
|
ajouter<TPL_MAP_ENTITE<ST_VECTOR*>,ST_VECTOR*>(lst_vector,vector,*this); |
214 |
|
|
tabentite[VECTOR]++; |
215 |
|
|
} |
216 |
|
|
else if (entite=="LINE") |
217 |
|
|
{ |
218 |
|
|
parse.decode(data.c_str(),"'@',@,@",param+2); |
219 |
|
|
long id_point=cid(param[3].argument[0].c_str()); |
220 |
|
|
long id_vector=cid(param[4].argument[0].c_str()); |
221 |
|
|
ST_LINE *line=new ST_LINE(id,param[2].argument[0],id_point,id_vector); |
222 |
|
|
ajouter<TPL_MAP_ENTITE<ST_LINE*>,ST_LINE*>(lst_line,line,*this); |
223 |
|
|
ajouter<TPL_MAP_ENTITE<ST_COURBE*>,ST_COURBE*>(lst_courbe,line,*this); |
224 |
|
|
tabentite[LINE]++; |
225 |
|
|
} |
226 |
|
|
else if (entite=="EDGE_CURVE") |
227 |
|
|
{ |
228 |
|
|
parse.decode(data.c_str(),"'@',@,@,@,@",param+2); |
229 |
|
|
long idvertex1=cid(param[3].argument[0]); |
230 |
|
|
long idvertex2=cid(param[4].argument[0]); |
231 |
|
|
long idcurve=cid(param[5].argument[0]); |
232 |
|
|
int sens=cbool(param[6].argument[0]); |
233 |
|
|
ST_EDGE_CURVE *edgecurve=new ST_EDGE_CURVE(id,param[2].argument[0],idvertex1,idvertex2,idcurve,sens); |
234 |
|
|
ajouter<TPL_MAP_ENTITE<ST_EDGE_CURVE*>,ST_EDGE_CURVE*>(lst_edgecurve,edgecurve,*this); |
235 |
|
|
tabentite[EDGE_CURVE]++; |
236 |
|
|
} |
237 |
|
|
else if (entite=="ORIENTED_EDGE") |
238 |
|
|
{ |
239 |
|
|
parse.decode(data.c_str(),"'@',@,@,@,@",param+2); |
240 |
|
|
long id_edge_curve=cid(param[5].argument[0].c_str()); |
241 |
|
|
int sens=cbool(param[6].argument[0]); |
242 |
|
|
ST_ORIENTED_EDGE *oriedge=new ST_ORIENTED_EDGE(id,param[2].argument[0],id_edge_curve,sens); |
243 |
|
|
ajouter<TPL_MAP_ENTITE<ST_ORIENTED_EDGE*>,ST_ORIENTED_EDGE*>(lst_oriedge,oriedge,*this); |
244 |
|
|
tabentite[ORIENTED_EDGE]++; |
245 |
|
|
} |
246 |
|
|
else if (entite=="EDGE_LOOP") |
247 |
|
|
{ |
248 |
|
|
parse.decode(data.c_str(),"'@',(&)",param+2); |
249 |
|
|
std::vector<long> liste_tmp; |
250 |
|
|
long nb=param[3].get_nombre(); |
251 |
|
|
for (long i=0;i<nb;i++) |
252 |
|
|
liste_tmp.insert(liste_tmp.end(),cid(param[3].argument[i])); |
253 |
|
|
ST_EDGE_LOOP *edge_loop=new ST_EDGE_LOOP(id,param[2].argument[0],&liste_tmp); |
254 |
|
|
ajouter<TPL_MAP_ENTITE<ST_EDGE_LOOP*>,ST_EDGE_LOOP*>(lst_edge_loop,edge_loop,*this); |
255 |
|
|
tabentite[EDGE_LOOP]++; |
256 |
|
|
} |
257 |
|
|
else if ((entite=="FACE_BOUND") || (entite=="FACE_OUTER_BOUND")) |
258 |
|
|
{ |
259 |
|
|
parse.decode(data.c_str(),"'@',@,@",param+2); |
260 |
|
|
long id_edge_loop=cid(param[3].argument[0].c_str()); |
261 |
|
|
int sens=cbool(param[4].argument[0]); |
262 |
|
|
ST_FACE_BOUND *facebound=new ST_FACE_BOUND(id,param[2].argument[0],id_edge_loop,sens); |
263 |
|
|
ajouter<TPL_MAP_ENTITE<ST_FACE_BOUND*>,ST_FACE_BOUND*>(lst_facebound,facebound,*this); |
264 |
|
|
if (entite=="FACE_BOUND") tabentite[FACE_BOUND]++; |
265 |
|
|
if (entite=="FACE_OUTER_BOUND") tabentite[FACE_OUTER_BOUND]++; |
266 |
|
|
} |
267 |
|
|
else if (entite=="ADVANCED_FACE") |
268 |
|
|
{ |
269 |
|
|
parse.decode(data.c_str(),"'@',(&),@,@",param+2); |
270 |
|
|
std::vector<long> liste_tmp; |
271 |
|
|
long nb=param[3].get_nombre(); |
272 |
|
|
for (long i=0;i<nb;i++) |
273 |
|
|
liste_tmp.insert(liste_tmp.end(),cid(param[3].argument[i])); |
274 |
|
|
long id_surface=cid(param[4].argument[0].c_str()); |
275 |
|
|
int sens=cbool(param[5].argument[0]); |
276 |
|
|
ST_ADVANCED_FACE *advanced_face=new ST_ADVANCED_FACE(id,param[2].argument[0],&liste_tmp,id_surface,sens); |
277 |
|
|
ajouter<TPL_MAP_ENTITE<ST_ADVANCED_FACE*>,ST_ADVANCED_FACE*>(lst_advanced_face,advanced_face,*this); |
278 |
|
|
tabentite[ADVANCED_FACE]++; |
279 |
|
|
} |
280 |
|
|
else if (entite=="AXIS2_PLACEMENT_3D") |
281 |
|
|
{ |
282 |
|
|
parse.decode(data.c_str(),"'@',@,@,@",param+2); |
283 |
|
|
long id_point=cid(param[3].argument[0].c_str()); |
284 |
|
|
long id_direction1=cid(param[4].argument[0].c_str()); |
285 |
|
|
long id_direction2; |
286 |
|
|
if (param[5].argument[0].c_str()=="$") |
287 |
|
|
{ |
288 |
|
|
id_direction2=-1; |
289 |
|
|
} |
290 |
|
|
else |
291 |
|
|
{ |
292 |
|
|
id_direction2=cid(param[5].argument[0].c_str()); |
293 |
|
|
} |
294 |
|
|
ST_AXIS2_PLACEMENT_3D *axis2_placement_3d=new ST_AXIS2_PLACEMENT_3D(id,param[2].argument[0],id_point,id_direction1,id_direction2); |
295 |
|
|
ajouter<TPL_MAP_ENTITE<ST_AXIS2_PLACEMENT_3D*>,ST_AXIS2_PLACEMENT_3D*>(lst_axis2_placement_3d,axis2_placement_3d,*this); |
296 |
|
|
tabentite[AXIS2_PLACEMENT_3D]++; |
297 |
|
|
} |
298 |
|
|
else if (entite=="PLANE") |
299 |
|
|
{ |
300 |
|
|
parse.decode(data.c_str(),"'@',@",param+2); |
301 |
|
|
long id_axis2_placement_3d=cid(param[3].argument[0].c_str()); |
302 |
|
|
ST_PLANE *plane=new ST_PLANE(id,param[2].argument[0],id_axis2_placement_3d); |
303 |
|
|
ajouter<TPL_MAP_ENTITE<ST_PLANE*>,ST_PLANE*>(lst_plane,plane,*this); |
304 |
|
|
ajouter<TPL_MAP_ENTITE<ST_SURFACE*>,ST_SURFACE*>(lst_surface,plane,*this); |
305 |
|
|
tabentite[PLANE]++; |
306 |
|
|
} |
307 |
|
|
else if (entite=="CYLINDRICAL_SURFACE") |
308 |
|
|
{ |
309 |
|
|
parse.decode(data.c_str(),"'@',@,@",param+2); |
310 |
|
|
long id_axis2_placement_3d=cid(param[3].argument[0].c_str()); |
311 |
|
|
double rayon=atof(param[4].argument[0].c_str()); |
312 |
|
|
ST_CYLINDRICAL *cylindrical=new ST_CYLINDRICAL(id,param[2].argument[0],id_axis2_placement_3d,rayon); |
313 |
|
|
ajouter<TPL_MAP_ENTITE<ST_CYLINDRICAL*>,ST_CYLINDRICAL*>(lst_cylindrical,cylindrical,*this); |
314 |
|
|
ajouter<TPL_MAP_ENTITE<ST_SURFACE*>,ST_SURFACE*>(lst_surface,cylindrical,*this); |
315 |
|
|
tabentite[CYLINDRICAL_SURFACE]++; |
316 |
|
|
} |
317 |
|
|
else if (entite=="TOROIDAL_SURFACE") |
318 |
|
|
{ |
319 |
|
|
parse.decode(data.c_str(),"'@',@,@,@",param+2); |
320 |
|
|
long id_axis2_placement_3d=cid(param[3].argument[0].c_str()); |
321 |
|
|
double grandray=atof(param[4].argument[0].c_str()); |
322 |
|
|
double petitray=atof(param[5].argument[0].c_str()); |
323 |
|
|
ST_TOROIDAL *toroidal=new ST_TOROIDAL(id,param[2].argument[0],id_axis2_placement_3d,grandray,petitray); |
324 |
|
|
ajouter<TPL_MAP_ENTITE<ST_TOROIDAL*>,ST_TOROIDAL*>(lst_toroidal,toroidal,*this); |
325 |
|
|
ajouter<TPL_MAP_ENTITE<ST_SURFACE*>,ST_SURFACE*>(lst_surface,toroidal,*this); |
326 |
|
|
tabentite[TOROIDAL_SURFACE]++; |
327 |
|
|
} |
328 |
|
|
else if (entite=="CONICAL_SURFACE") |
329 |
|
|
{ |
330 |
|
|
parse.decode(data.c_str(),"'@',@,@,@",param+2); |
331 |
|
|
long id_axis2_placement_3d=cid(param[3].argument[0].c_str()); |
332 |
|
|
double rayon=atof(param[4].argument[0].c_str()); |
333 |
|
|
double angle=atof(param[5].argument[0].c_str()); |
334 |
|
|
ST_CONICAL *conical=new ST_CONICAL(id,param[2].argument[0],id_axis2_placement_3d,rayon,angle); |
335 |
|
|
ajouter<TPL_MAP_ENTITE<ST_CONICAL*>,ST_CONICAL*>(lst_conical,conical,*this); |
336 |
|
|
ajouter<TPL_MAP_ENTITE<ST_SURFACE*>,ST_SURFACE*>(lst_surface,conical,*this); |
337 |
|
|
tabentite[CONICAL_SURFACE]++; |
338 |
|
|
} |
339 |
|
|
else if (entite=="SPHERICAL_SURFACE") |
340 |
|
|
{ |
341 |
|
|
parse.decode(data.c_str(),"'@',@,@",param+2); |
342 |
|
|
long id_axis2_placement_3d=cid(param[3].argument[0].c_str()); |
343 |
|
|
double rayon=atof(param[4].argument[0].c_str()); |
344 |
|
|
ST_SPHERICAL *spherical=new ST_SPHERICAL(id,param[2].argument[0],id_axis2_placement_3d,rayon); |
345 |
|
|
ajouter<TPL_MAP_ENTITE<ST_SPHERICAL*>,ST_SPHERICAL*>(lst_spherical,spherical,*this); |
346 |
|
|
ajouter<TPL_MAP_ENTITE<ST_SURFACE*>,ST_SURFACE*>(lst_surface,spherical,*this); |
347 |
|
|
tabentite[SPHERICAL_SURFACE]++; |
348 |
|
|
} |
349 |
|
|
else if (entite=="CLOSED_SHELL") |
350 |
|
|
{ |
351 |
|
|
parse.decode(data.c_str(),"'@',(&)",param+2); |
352 |
|
|
std::vector<long> liste_tmp; |
353 |
|
|
long nb=param[3].get_nombre(); |
354 |
|
|
for (long i=0;i<nb;i++) |
355 |
|
|
liste_tmp.insert(liste_tmp.end(),cid(param[3].argument[i])); |
356 |
|
|
ST_CLOSED_SHELL *closed_shell=new ST_CLOSED_SHELL(id,param[2].argument[0],&liste_tmp); |
357 |
|
|
ajouter<TPL_MAP_ENTITE<ST_CLOSED_SHELL*>,ST_CLOSED_SHELL*>(lst_closed_shell,closed_shell,*this); |
358 |
|
|
tabentite[CLOSED_SHELL]++; |
359 |
|
|
} |
360 |
|
|
else if (entite=="ORIENTED_CLOSED_SHELL") |
361 |
|
|
{ |
362 |
|
|
parse.decode(data.c_str(),"'@',@,@,@",param+2); |
363 |
|
|
long id_closed_shell=cid(param[4].argument[0].c_str()); |
364 |
|
|
int sens=cbool(param[5].argument[0]); |
365 |
|
|
ST_ORIENTED_CLOSED_SHELL *oriented_closed_shell=new ST_ORIENTED_CLOSED_SHELL(id,param[2].argument[0],id_closed_shell,sens); |
366 |
|
|
ajouter<TPL_MAP_ENTITE<ST_ORIENTED_CLOSED_SHELL*>,ST_ORIENTED_CLOSED_SHELL*>(lst_oriented_closed_shell,oriented_closed_shell,*this); |
367 |
|
|
tabentite[ORIENTED_CLOSED_SHELL]++; |
368 |
|
|
} |
369 |
|
|
else if (entite=="MANIFOLD_SOLID_BREP") |
370 |
|
|
{ |
371 |
|
|
parse.decode(data.c_str(),"'@',@",param+2); |
372 |
|
|
long id_closed_shell=cid(param[3].argument[0].c_str()); |
373 |
|
|
ST_MANIFOLD_BREP *manifold_brep=new ST_MANIFOLD_BREP(id,param[2].argument[0],id_closed_shell); |
374 |
|
|
ajouter<TPL_MAP_ENTITE<ST_MANIFOLD_BREP*>,ST_MANIFOLD_BREP*>(lst_manifold_brep,manifold_brep,*this); |
375 |
|
|
tabentite[MANIFOLD_SOLID_BREP]++; |
376 |
|
|
} |
377 |
|
|
else if (entite=="BREP_WITH_VOIDS") |
378 |
|
|
{ |
379 |
|
|
parse.decode(data.c_str(),"'@',@,(&)",param+2); |
380 |
|
|
long id_closed_shell=cid(param[3].argument[0].c_str()); |
381 |
|
|
std::vector<long> liste_tmp; |
382 |
|
|
long nb=param[4].get_nombre(); |
383 |
|
|
for (long i=0;i<nb;i++) |
384 |
|
|
liste_tmp.insert(liste_tmp.end(),cid(param[4].argument[i])); |
385 |
|
|
ST_BREP_WITH_VOIDS *brep_with_voids=new ST_BREP_WITH_VOIDS(id,param[2].argument[0],id_closed_shell,&liste_tmp); |
386 |
|
|
ajouter<TPL_MAP_ENTITE<ST_BREP_WITH_VOIDS*>,ST_BREP_WITH_VOIDS*>(lst_brep_with_voids,brep_with_voids,*this); |
387 |
|
|
tabentite[BREP_WITH_VOIDS]++; |
388 |
|
|
} |
389 |
|
|
else if (entite=="CIRCLE") |
390 |
|
|
{ |
391 |
|
|
parse.decode(data.c_str(),"'@',@,@",param+2); |
392 |
|
|
long id_axis2_placement_3d=cid(param[3].argument[0].c_str()); |
393 |
|
|
double rayon=atof(param[4].argument[0].c_str()); |
394 |
|
|
ST_CIRCLE *circle=new ST_CIRCLE(id,param[2].argument[0],id_axis2_placement_3d,rayon); |
395 |
|
|
ajouter<TPL_MAP_ENTITE<ST_CIRCLE*>,ST_CIRCLE*>(lst_circle,circle,*this); |
396 |
|
|
ajouter<TPL_MAP_ENTITE<ST_COURBE*>,ST_COURBE*>(lst_courbe,circle,*this); |
397 |
|
|
tabentite[CIRCLE]++; |
398 |
|
|
} |
399 |
|
|
else if (entite=="ELLIPSE") |
400 |
|
|
{ |
401 |
|
|
parse.decode(data.c_str(),"'@',@,@,@",param+2); |
402 |
|
|
long id_axis2_placement_3d=cid(param[3].argument[0].c_str()); |
403 |
|
|
double a=atof(param[4].argument[0].c_str()); |
404 |
|
|
double b=atof(param[5].argument[0].c_str()); |
405 |
|
|
ST_ELLIPSE *ellipse=new ST_ELLIPSE(id,param[2].argument[0],id_axis2_placement_3d,a,b); |
406 |
|
|
ajouter<TPL_MAP_ENTITE<ST_ELLIPSE*>,ST_ELLIPSE*>(lst_ellipse,ellipse,*this); |
407 |
|
|
ajouter<TPL_MAP_ENTITE<ST_COURBE*>,ST_COURBE*>(lst_courbe,ellipse,*this); |
408 |
|
|
tabentite[ELLIPSE]++; |
409 |
|
|
} |
410 |
|
|
else if (entite=="DIRECTION") |
411 |
|
|
{ |
412 |
|
|
parse.decode(data.c_str(),"'@',(&)",param+2); |
413 |
|
|
int nb=param[3].get_nombre(); |
414 |
|
|
nb++; |
415 |
|
|
nb--; |
416 |
|
|
double x=atof(param[3].argument[0].c_str()); |
417 |
|
|
double y=atof(param[3].argument[1].c_str()); |
418 |
|
|
double z=atof(param[3].argument[2].c_str()); |
419 |
|
|
ST_DIRECTION *direction=new ST_DIRECTION(id,param[2].argument[0],x,y,z); |
420 |
|
|
ajouter<TPL_MAP_ENTITE<ST_DIRECTION*>,ST_DIRECTION*>(lst_direction,direction,*this); |
421 |
|
|
tabentite[DIRECTION]++; |
422 |
|
|
} |
423 |
|
|
else if (entite=="CARTESIAN_POINT") |
424 |
|
|
{ |
425 |
|
|
parse.decode(data.c_str(),"'@',(&)",param+2); |
426 |
|
|
double x=atof(param[3].argument[0].c_str()); |
427 |
|
|
double y=atof(param[3].argument[1].c_str()); |
428 |
|
|
double z=atof(param[3].argument[2].c_str()); |
429 |
|
|
ST_POINT *point=new ST_POINT(id,param[2].argument[0],x,y,z); |
430 |
|
|
ajouter<TPL_MAP_ENTITE<ST_POINT*>,ST_POINT*>(lst_point,point,*this); |
431 |
|
|
tabentite[CARTESIAN_POINT]++; |
432 |
|
|
} |
433 |
|
|
else if (entite=="B_SPLINE_CURVE_WITH_KNOTS") |
434 |
|
|
{ |
435 |
|
|
parse.decode(data.c_str(),"'@',@,(&),@,@,@,(&),(&),@",param+2); |
436 |
|
|
int bs_degre=atoi(param[3].argument[0].c_str()); |
437 |
|
|
std::vector<int> liste_tmp_1; |
438 |
|
|
int nb_1=param[4].get_nombre(); |
439 |
|
|
for (int i=0;i<nb_1;i++) |
440 |
|
|
liste_tmp_1.insert(liste_tmp_1.end(),cid(param[4].argument[i])); |
441 |
|
|
std::vector<int> liste_tmp_2; |
442 |
|
|
int nb_2=param[8].get_nombre(); |
443 |
|
|
for (int j=0;j<nb_2;j++) |
444 |
|
|
liste_tmp_2.insert(liste_tmp_2.end(),atoi(param[8].argument[j].c_str())); |
445 |
|
|
std::vector<double> liste_tmp_3; |
446 |
|
|
long nb_3=param[9].get_nombre(); |
447 |
|
|
for (long k=0;k<nb_3;k++) |
448 |
|
|
liste_tmp_3.insert(liste_tmp_3.end(),atof(param[9].argument[k].c_str())); |
449 |
|
|
ST_B_SPLINE *bspline=new ST_B_SPLINE(id,param[2].argument[0],bs_degre,liste_tmp_1,liste_tmp_2,liste_tmp_3); |
450 |
|
|
ajouter<TPL_MAP_ENTITE<ST_B_SPLINE*>,ST_B_SPLINE*>(lst_bspline,bspline,*this); |
451 |
|
|
ajouter<TPL_MAP_ENTITE<ST_COURBE*>,ST_COURBE*>(lst_courbe,bspline,*this); |
452 |
|
|
tabentite[B_SPLINE_CURVE_WITH_KNOTS]++; |
453 |
|
|
} |
454 |
|
|
else if (entite=="B_SPLINE_SURFACE_WITH_KNOTS") |
455 |
|
|
{ |
456 |
|
|
parse.decode(data.c_str(),"'@',@,@,(&),@,@,@,@,(&),(&),(&),(&),@",param+2); |
457 |
|
|
int bs_degre_u=atoi(param[3].argument[0].c_str()); |
458 |
|
|
int bs_degre_v=atoi(param[4].argument[0].c_str()); |
459 |
|
|
int nb_1=param[5].get_nombre(); |
460 |
|
|
std::vector<int> liste_tmp_1; |
461 |
|
|
for (int i=0;i<nb_1;i++) |
462 |
|
|
{ |
463 |
|
|
PARS_ARGUMENT param2; |
464 |
|
|
parse.decode(param[5].argument[i].c_str(),"(&)", ¶m2); |
465 |
|
|
int nb_11=param2.get_nombre(); |
466 |
|
|
for (int j=0;j<nb_11;j++) |
467 |
|
|
liste_tmp_1.insert(liste_tmp_1.end(),cid(param2.argument[j].c_str())); |
468 |
|
|
} |
469 |
|
|
std::vector<int> liste_tmp_2; |
470 |
|
|
int nb_2=param[10].get_nombre(); |
471 |
|
|
for (int j=0;j<nb_2;j++) |
472 |
|
|
liste_tmp_2.insert(liste_tmp_2.end(),atoi(param[10].argument[j].c_str())); |
473 |
|
|
std::vector<int> liste_tmp_3; |
474 |
|
|
int nb_3=param[11].get_nombre(); |
475 |
|
|
for (int j=0;j<nb_3;j++) |
476 |
|
|
liste_tmp_3.insert(liste_tmp_3.end(),atoi(param[11].argument[j].c_str())); |
477 |
|
|
std::vector<double> liste_tmp_4; |
478 |
|
|
long nb_4=param[12].get_nombre(); |
479 |
|
|
for (long k=0;k<nb_4;k++) |
480 |
|
|
liste_tmp_4.insert(liste_tmp_4.end(),atof(param[12].argument[k].c_str())); |
481 |
|
|
std::vector<double> liste_tmp_5; |
482 |
|
|
long nb_5=param[13].get_nombre(); |
483 |
|
|
for (long k=0;k<nb_5;k++) |
484 |
|
|
liste_tmp_5.insert(liste_tmp_5.end(),atof(param[13].argument[k].c_str())); |
485 |
|
|
ST_B_SPLINE_SURF *bsplines=new ST_B_SPLINE_SURF(id,param[2].argument[0],bs_degre_u,bs_degre_v,liste_tmp_1,liste_tmp_2,liste_tmp_3,liste_tmp_4,liste_tmp_5); |
486 |
|
|
ajouter<TPL_MAP_ENTITE<ST_B_SPLINE_SURF*>,ST_B_SPLINE_SURF*>(lst_bsplines,bsplines,*this); |
487 |
|
|
ajouter<TPL_MAP_ENTITE<ST_SURFACE*>,ST_SURFACE*>(lst_surface,bsplines,*this); |
488 |
|
|
tabentite[B_SPLINE_SURFACE_WITH_KNOTS]++; |
489 |
|
|
} |
490 |
|
|
else entitenontraite.insert(entitenontraite.end(),entite); |
491 |
|
|
} |
492 |
|
|
} |
493 |
|
|
while (param[0].argument[0]!="ENDSEC"); |
494 |
|
|
fclose(in); |
495 |
|
|
initialiser(); |
496 |
|
|
return 1; |
497 |
|
|
} |
498 |
|
|
|
499 |
|
|
|
500 |
|
|
|
501 |
|
|
void ST_GESTIONNAIRE::initialiser(void) |
502 |
|
|
{ |
503 |
|
|
long nb_ligne=lst_line.get_nb(); |
504 |
|
|
for (long i=0;i<nb_ligne;i++) |
505 |
|
|
{ |
506 |
|
|
ST_LINE* ligne=lst_line.get(i); |
507 |
|
|
ligne->initialiser(this); |
508 |
|
|
} |
509 |
|
|
long nb_cercle=lst_circle.get_nb(); |
510 |
|
|
for (long i=0;i<nb_cercle;i++) |
511 |
|
|
{ |
512 |
|
|
ST_CIRCLE* cercle=lst_circle.get(i); |
513 |
|
|
cercle->initialiser(this); |
514 |
|
|
} |
515 |
|
|
long nb_ellipse=lst_ellipse.get_nb(); |
516 |
|
|
for (long i=0;i<nb_ellipse;i++) |
517 |
|
|
{ |
518 |
|
|
ST_ELLIPSE* ellipse=lst_ellipse.get(i); |
519 |
|
|
ellipse->initialiser(this); |
520 |
|
|
} |
521 |
|
|
long nb_plane=lst_plane.get_nb(); |
522 |
|
|
for (long i=0;i<nb_plane;i++) |
523 |
|
|
{ |
524 |
|
|
ST_PLANE* plane=lst_plane.get(i); |
525 |
|
|
plane->initialiser(this); |
526 |
|
|
} |
527 |
|
|
long nb_cylindrical=lst_cylindrical.get_nb(); |
528 |
|
|
for (long i=0;i<nb_cylindrical;i++) |
529 |
|
|
{ |
530 |
|
|
ST_CYLINDRICAL* cylindrical=lst_cylindrical.get(i); |
531 |
|
|
cylindrical->initialiser(this); |
532 |
|
|
} |
533 |
|
|
long nb_conical=lst_conical.get_nb(); |
534 |
|
|
for (long i=0;i<nb_conical;i++) |
535 |
|
|
{ |
536 |
|
|
ST_CONICAL* conical=lst_conical.get(i); |
537 |
|
|
conical->initialiser(this); |
538 |
|
|
} |
539 |
|
|
long nb_spherical=lst_spherical.get_nb(); |
540 |
|
|
for (long i=0;i<nb_spherical;i++) |
541 |
|
|
{ |
542 |
|
|
ST_SPHERICAL* spherical=lst_spherical.get(i); |
543 |
|
|
spherical->initialiser(this); |
544 |
|
|
} |
545 |
|
|
long nb_toroidal=lst_toroidal.get_nb(); |
546 |
|
|
for (long i=0;i<nb_toroidal;i++) |
547 |
|
|
{ |
548 |
|
|
ST_TOROIDAL* toroidal=lst_toroidal.get(i); |
549 |
|
|
toroidal->initialiser(this); |
550 |
|
|
} |
551 |
|
|
long nb_bspline=lst_bspline.get_nb(); |
552 |
|
|
for (long i=0;i<nb_bspline;i++) |
553 |
|
|
{ |
554 |
|
|
ST_B_SPLINE* bspline=lst_bspline.get(i); |
555 |
|
|
bspline->initialiser(this); |
556 |
|
|
} |
557 |
|
|
long nb_bsplines=lst_bsplines.get_nb(); |
558 |
|
|
for (long i=0;i<nb_bsplines;i++) |
559 |
|
|
{ |
560 |
|
|
ST_B_SPLINE_SURF* bsplines=lst_bsplines.get(i); |
561 |
|
|
bsplines->initialiser(this); |
562 |
|
|
} |
563 |
|
|
} |
564 |
|
|
|