1 |
francois |
283 |
//------------------------------------------------------------ |
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 |
|
|
// sat_gestionnaire.cpp |
16 |
|
|
// |
17 |
|
|
//------------------------------------------------------------ |
18 |
|
|
//------------------------------------------------------------ |
19 |
|
|
// COPYRIGHT 2000 |
20 |
|
|
// Version du 02/03/2006 � 11H24 |
21 |
|
|
//------------------------------------------------------------ |
22 |
|
|
//------------------------------------------------------------ |
23 |
|
|
|
24 |
|
|
|
25 |
|
|
#include "gestionversion.h" |
26 |
|
|
#include <stdio.h> |
27 |
|
|
#include <string.h> |
28 |
|
|
|
29 |
|
|
#include "sat_gestionnaire.h" |
30 |
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
//--------------------------------------------------------------------------- |
35 |
|
|
|
36 |
|
|
|
37 |
|
|
template<class Y,class X> void ajouter(Y& y,X x,SAT_GESTIONNAIRE& gest) |
38 |
|
|
{ |
39 |
|
|
y.ajouter(x); |
40 |
|
|
gest.lst_entity.ajouter(x); |
41 |
|
|
} |
42 |
|
|
|
43 |
|
|
template<class Y,class X>void libere(Y& y) |
44 |
|
|
{ |
45 |
|
|
for (long i=0;i<y.get_nb();i++) |
46 |
|
|
{ |
47 |
|
|
X* x=y.get(i); |
48 |
|
|
delete x; |
49 |
|
|
} |
50 |
|
|
y.vide(); |
51 |
|
|
} |
52 |
|
|
|
53 |
|
|
SAT_GESTIONNAIRE::SAT_GESTIONNAIRE():FORWARD(1),REVERSED(-1),DOUBLE(2),SINGLE(1),IS_OUT(10),IS_IN(11),nom(NULL) |
54 |
|
|
{ |
55 |
|
|
} |
56 |
|
|
|
57 |
|
|
SAT_GESTIONNAIRE::SAT_GESTIONNAIRE(char *path):FORWARD(1),REVERSED(-1),DOUBLE(2),SINGLE(1),IS_OUT(10),IS_IN(11),nom(NULL) |
58 |
|
|
{ |
59 |
|
|
int num=strlen(path); |
60 |
|
|
nom=new char[num+1]; |
61 |
|
|
strcpy(nom,path); |
62 |
|
|
} |
63 |
|
|
|
64 |
|
|
SAT_GESTIONNAIRE::~SAT_GESTIONNAIRE() |
65 |
|
|
{ |
66 |
|
|
libere<TPL_MAP_ENTITE<class SAT_ATTRIB*>,SAT_ATTRIB>(lst_attrib); |
67 |
|
|
libere<TPL_MAP_ENTITE<class SAT_BODY*>,SAT_BODY>(lst_body); |
68 |
|
|
libere<TPL_MAP_ENTITE<class SAT_COEDGE*>,SAT_COEDGE>(lst_coedge); |
69 |
|
|
libere<TPL_MAP_ENTITE<class SAT_CONE*>,SAT_CONE>(lst_cone); |
70 |
|
|
libere<TPL_MAP_ENTITE<class SAT_EDGE*>,SAT_EDGE>(lst_edge); |
71 |
|
|
libere<TPL_MAP_ENTITE<class SAT_ELLIPSE*>,SAT_ELLIPSE>(lst_ellipse); |
72 |
|
|
libere<TPL_MAP_ENTITE<class SAT_FACE*>,SAT_FACE>(lst_face); |
73 |
|
|
libere<TPL_MAP_ENTITE<class SAT_LOOP*>,SAT_LOOP>(lst_loop); |
74 |
|
|
libere<TPL_MAP_ENTITE<class SAT_LUMP*>,SAT_LUMP>(lst_lump); |
75 |
|
|
//libere<TPL_MAP_ENTITE<class SAT_PCURVE*>,SAT_PCURVE>(lst_pcurve); |
76 |
|
|
libere<TPL_MAP_ENTITE<class SAT_PLANE*>,SAT_PLANE>(lst_plane); |
77 |
|
|
libere<TPL_MAP_ENTITE<class SAT_POINT*>,SAT_POINT>(lst_point); |
78 |
|
|
libere<TPL_MAP_ENTITE<class SAT_SHELL*>,SAT_SHELL>(lst_shell); |
79 |
|
|
libere<TPL_MAP_ENTITE<class SAT_STRAIGHT*>,SAT_STRAIGHT>(lst_straight); |
80 |
|
|
libere<TPL_MAP_ENTITE<class SAT_SUBSHELL*>,SAT_SUBSHELL>(lst_subshell); |
81 |
|
|
libere<TPL_MAP_ENTITE<class SAT_TRANSFORM*>,SAT_TRANSFORM>(lst_transform); |
82 |
|
|
libere<TPL_MAP_ENTITE<class SAT_VERTEX*>,SAT_VERTEX>(lst_vertex); |
83 |
|
|
libere<TPL_MAP_ENTITE<class SAT_WIRE*>,SAT_WIRE>(lst_wire); |
84 |
|
|
lst_entity.vide(); |
85 |
|
|
if (nom!=NULL) delete [] nom; |
86 |
|
|
} |
87 |
|
|
|
88 |
|
|
void SAT_GESTIONNAIRE::change_nom(char *path) |
89 |
|
|
{ |
90 |
|
|
int num=strlen(path); |
91 |
|
|
nom=new char[num+1]; |
92 |
|
|
strcpy(nom,path); |
93 |
|
|
} |
94 |
|
|
|
95 |
|
|
char* SAT_GESTIONNAIRE::get_nom(void) |
96 |
|
|
{ |
97 |
|
|
return nom; |
98 |
|
|
} |
99 |
|
|
|
100 |
|
|
|
101 |
|
|
int SAT_GESTIONNAIRE::lire(void) |
102 |
|
|
{ |
103 |
|
|
FILE* fic=fopen(nom,"rt"); |
104 |
|
|
if (fic==NULL) |
105 |
|
|
{ |
106 |
|
|
return 0; |
107 |
|
|
} |
108 |
|
|
int num=0; |
109 |
|
|
int version; |
110 |
|
|
char mess[500]; |
111 |
|
|
while (num<100) |
112 |
|
|
{ |
113 |
|
|
char* res=fgets(mess,500,fic); |
114 |
|
|
sscanf(mess,"%d",&num); |
115 |
|
|
} |
116 |
|
|
sscanf(mess,"%d %d",&version,&num); |
117 |
|
|
unsigned long ident=0; |
118 |
|
|
while (feof(fic)==0) |
119 |
|
|
{ |
120 |
|
|
char type_entite[30]; |
121 |
|
|
char* res=fgets(mess,500,fic); |
122 |
|
|
sscanf(mess,"%s",type_entite); |
123 |
|
|
num=strlen(type_entite); |
124 |
|
|
int commentaire=0; |
125 |
|
|
if (num>6) |
126 |
|
|
{ |
127 |
|
|
if (type_entite[num-1]=='b') |
128 |
|
|
if (type_entite[num-2]=='i') |
129 |
|
|
if (type_entite[num-3]=='r') |
130 |
|
|
if (type_entite[num-4]=='t') |
131 |
|
|
if (type_entite[num-5]=='t') |
132 |
|
|
if (type_entite[num-6]=='a') |
133 |
|
|
strcpy(type_entite,"attrib"); |
134 |
|
|
} |
135 |
|
|
if (strcmp(type_entite,"body")==0) |
136 |
|
|
{ |
137 |
|
|
SAT_BODY* body=new SAT_BODY(ident); |
138 |
|
|
ajouter<TPL_MAP_ENTITE<SAT_BODY*>,SAT_BODY*>(lst_body,body,*this); |
139 |
|
|
} |
140 |
|
|
else if (strcmp(type_entite,"attrib")==0) |
141 |
|
|
{ |
142 |
|
|
SAT_ATTRIB* attrib=new SAT_ATTRIB(ident); |
143 |
|
|
ajouter<TPL_MAP_ENTITE<SAT_ATTRIB*>,SAT_ATTRIB*>(lst_attrib,attrib,*this); |
144 |
|
|
} |
145 |
|
|
else if (strcmp(type_entite,"lump")==0) |
146 |
|
|
{ |
147 |
|
|
SAT_LUMP* lump=new SAT_LUMP(ident); |
148 |
|
|
ajouter<TPL_MAP_ENTITE<SAT_LUMP*>,SAT_LUMP*>(lst_lump,lump,*this); |
149 |
|
|
} |
150 |
|
|
else if (strcmp(type_entite,"shell")==0) |
151 |
|
|
{ |
152 |
|
|
SAT_SHELL* shell=new SAT_SHELL(ident); |
153 |
|
|
ajouter<TPL_MAP_ENTITE<SAT_SHELL*>,SAT_SHELL*>(lst_shell,shell,*this); |
154 |
|
|
} |
155 |
|
|
else if (strcmp(type_entite,"face")==0) |
156 |
|
|
{ |
157 |
|
|
SAT_FACE* face=new SAT_FACE(ident); |
158 |
|
|
ajouter<TPL_MAP_ENTITE<SAT_FACE*>,SAT_FACE*>(lst_face,face,*this); |
159 |
|
|
} |
160 |
|
|
else if (strcmp(type_entite,"loop")==0) |
161 |
|
|
{ |
162 |
|
|
SAT_LOOP* loop=new SAT_LOOP(ident); |
163 |
|
|
ajouter<TPL_MAP_ENTITE<SAT_LOOP*>,SAT_LOOP*>(lst_loop,loop,*this); |
164 |
|
|
} |
165 |
|
|
else if (strcmp(type_entite,"subshell")==0) |
166 |
|
|
{ |
167 |
|
|
SAT_SUBSHELL* subshell=new SAT_SUBSHELL(ident); |
168 |
|
|
ajouter<TPL_MAP_ENTITE<SAT_SUBSHELL*>,SAT_SUBSHELL*>(lst_subshell,subshell,*this); |
169 |
|
|
} |
170 |
|
|
else if (strcmp(type_entite,"wire")==0) |
171 |
|
|
{ |
172 |
|
|
SAT_WIRE* wire=new SAT_WIRE(ident); |
173 |
|
|
ajouter<TPL_MAP_ENTITE<SAT_WIRE*>,SAT_WIRE*>(lst_wire,wire,*this); |
174 |
|
|
} |
175 |
|
|
else if (strcmp(type_entite,"coedge")==0) |
176 |
|
|
{ |
177 |
|
|
SAT_COEDGE* coedge=new SAT_COEDGE(ident); |
178 |
|
|
ajouter<TPL_MAP_ENTITE<SAT_COEDGE*>,SAT_COEDGE*>(lst_coedge,coedge,*this); |
179 |
|
|
} |
180 |
|
|
else if (strcmp(type_entite,"edge")==0) |
181 |
|
|
{ |
182 |
|
|
SAT_EDGE* edge=new SAT_EDGE(ident); |
183 |
|
|
ajouter<TPL_MAP_ENTITE<SAT_EDGE*>,SAT_EDGE*>(lst_edge,edge,*this); |
184 |
|
|
} |
185 |
|
|
else if (strcmp(type_entite,"vertex")==0) |
186 |
|
|
{ |
187 |
|
|
SAT_VERTEX* vertex=new SAT_VERTEX(ident); |
188 |
|
|
ajouter<TPL_MAP_ENTITE<SAT_VERTEX*>,SAT_VERTEX*>(lst_vertex,vertex,*this); |
189 |
|
|
} |
190 |
|
|
else if (strcmp(type_entite,"cone-surface")==0) |
191 |
|
|
{ |
192 |
|
|
SAT_CONE* cone=new SAT_CONE(ident); |
193 |
|
|
ajouter<TPL_MAP_ENTITE<SAT_CONE*>,SAT_CONE*>(lst_cone,cone,*this); |
194 |
|
|
ajouter<TPL_MAP_ENTITE<SAT_SURFACE*>,SAT_SURFACE*>(lst_surface,cone,*this); |
195 |
|
|
} |
196 |
|
|
else if (strcmp(type_entite,"ellipse-curve")==0) |
197 |
|
|
{ |
198 |
|
|
SAT_ELLIPSE* ellipse=new SAT_ELLIPSE(ident); |
199 |
|
|
ajouter<TPL_MAP_ENTITE<SAT_ELLIPSE*>,SAT_ELLIPSE*>(lst_ellipse,ellipse,*this); |
200 |
|
|
ajouter<TPL_MAP_ENTITE<SAT_COURBE*>,SAT_COURBE*>(lst_courbe,ellipse,*this); |
201 |
|
|
} |
202 |
|
|
else if (strcmp(type_entite,"plane-surface")==0) |
203 |
|
|
{ |
204 |
|
|
SAT_PLANE* plane=new SAT_PLANE(ident); |
205 |
|
|
ajouter<TPL_MAP_ENTITE<SAT_PLANE*>,SAT_PLANE*>(lst_plane,plane,*this); |
206 |
|
|
ajouter<TPL_MAP_ENTITE<SAT_SURFACE*>,SAT_SURFACE*>(lst_surface,plane,*this); |
207 |
|
|
} |
208 |
|
|
else if (strcmp(type_entite,"point")==0) |
209 |
|
|
{ |
210 |
|
|
SAT_POINT* point=new SAT_POINT(ident); |
211 |
|
|
ajouter<TPL_MAP_ENTITE<SAT_POINT*>,SAT_POINT*>(lst_point,point,*this); |
212 |
|
|
} |
213 |
|
|
else if (strcmp(type_entite,"straight-curve")==0) |
214 |
|
|
{ |
215 |
|
|
SAT_STRAIGHT* straight=new SAT_STRAIGHT(ident); |
216 |
|
|
ajouter<TPL_MAP_ENTITE<SAT_STRAIGHT*>,SAT_STRAIGHT*>(lst_straight,straight,*this); |
217 |
|
|
ajouter<TPL_MAP_ENTITE<SAT_COURBE*>,SAT_COURBE*>(lst_courbe,straight,*this); |
218 |
|
|
} |
219 |
|
|
else if (strcmp(type_entite,"transform")==0) |
220 |
|
|
{ |
221 |
|
|
SAT_TRANSFORM* transform=new SAT_TRANSFORM(ident); |
222 |
|
|
ajouter<TPL_MAP_ENTITE<SAT_TRANSFORM*>,SAT_TRANSFORM*>(lst_transform,transform,*this); |
223 |
|
|
} |
224 |
|
|
|
225 |
|
|
else if (ident==0) commentaire=1; |
226 |
|
|
else |
227 |
|
|
{ |
228 |
|
|
// entite non traite |
229 |
|
|
} |
230 |
|
|
if (commentaire==0) ident++; |
231 |
|
|
} |
232 |
|
|
fclose(fic); |
233 |
|
|
// deuxieme passsage |
234 |
|
|
fic=fopen(nom,"rt"); |
235 |
|
|
if (fic==NULL) |
236 |
|
|
{ |
237 |
|
|
return -1; |
238 |
|
|
} |
239 |
|
|
num=0; |
240 |
|
|
while (num<100) |
241 |
|
|
{ |
242 |
|
|
char* res=fgets(mess,500,fic); |
243 |
|
|
sscanf(mess,"%d",&num); |
244 |
|
|
} |
245 |
|
|
sscanf(mess,"%d %d",&version,&num); |
246 |
|
|
ident=0; |
247 |
|
|
while (feof(fic)==0) |
248 |
|
|
{ |
249 |
|
|
int commentaire=0; |
250 |
|
|
char type_entite[30]; |
251 |
|
|
char* res=fgets(mess,500,fic); |
252 |
|
|
int num; |
253 |
|
|
for (num=0;num<(int)strlen(mess);num++) |
254 |
|
|
if (mess[num]=='I') mess[num]=' '; |
255 |
|
|
sscanf(mess,"%s",type_entite); |
256 |
|
|
num=strlen(type_entite); |
257 |
|
|
if (num>6) |
258 |
|
|
{ |
259 |
|
|
if (type_entite[num-1]=='b') |
260 |
|
|
if (type_entite[num-2]=='i') |
261 |
|
|
if (type_entite[num-3]=='r') |
262 |
|
|
if (type_entite[num-4]=='t') |
263 |
|
|
if (type_entite[num-5]=='t') |
264 |
|
|
if (type_entite[num-6]=='a') |
265 |
|
|
strcpy(type_entite,"attrib"); |
266 |
|
|
} |
267 |
|
|
if (strcmp(type_entite,"body")==0) |
268 |
|
|
{ |
269 |
|
|
int n1,n2,n3,n4; |
270 |
|
|
char c; |
271 |
|
|
sscanf(mess,"%s %c%d %c%d %c%d %c%d",type_entite,&c,&n1,&c,&n2,&c,&n3,&c,&n4); |
272 |
|
|
SAT_BODY* body=(SAT_BODY *)lst_entity.getid(ident); |
273 |
|
|
if (n1!=-1) body->attrib=(SAT_ATTRIB*)lst_entity.getid(n1); |
274 |
|
|
else body->attrib=NULL; |
275 |
|
|
if (n2!=-1) body->first_lump=(SAT_LUMP*)lst_entity.getid(n2); |
276 |
|
|
else body->first_lump=NULL; |
277 |
|
|
if (n3!=-1) body->first_wire=(SAT_WIRE*)lst_entity.getid(n3); |
278 |
|
|
else body->first_wire=NULL; |
279 |
|
|
if (n4!=-1) body->transform=(SAT_TRANSFORM*)lst_entity.getid(n4); |
280 |
|
|
else body->transform=NULL; |
281 |
|
|
} |
282 |
|
|
else if (strcmp(type_entite,"attrib")==0) |
283 |
|
|
{ |
284 |
|
|
} |
285 |
|
|
else if (strcmp(type_entite,"lump")==0) |
286 |
|
|
{ |
287 |
|
|
int n1,n2,n3,n4; |
288 |
|
|
char c; |
289 |
|
|
sscanf(mess,"%s %c%d %c%d %c%d %c%d",type_entite,&c,&n1,&c,&n2,&c,&n3,&c,&n4); |
290 |
|
|
SAT_LUMP* lump=(SAT_LUMP*)lst_entity.getid(ident); |
291 |
|
|
if (n1!=-1) lump->attrib=(SAT_ATTRIB*)lst_entity.getid(n1); |
292 |
|
|
else lump->attrib=NULL; |
293 |
|
|
if (n2!=-1) lump->next_lump=(SAT_LUMP*)lst_entity.getid(n2); |
294 |
|
|
else lump->next_lump=NULL; |
295 |
|
|
if (n3!=-1) lump->first_shell=(SAT_SHELL*)lst_entity.getid(n3); |
296 |
|
|
else lump->first_shell=NULL; |
297 |
|
|
if (n4!=-1) lump->body=(SAT_BODY*)lst_entity.getid(n4); |
298 |
|
|
else lump->body=NULL; |
299 |
|
|
} |
300 |
|
|
else if (strcmp(type_entite,"shell")==0) |
301 |
|
|
{ |
302 |
|
|
int n1,n2,n3,n4,n5; |
303 |
|
|
char c; |
304 |
|
|
sscanf(mess,"%s %c%d %c%d %c%d %c%d %c%d",type_entite,&c,&n1,&c,&n2,&c,&n3,&c,&n4,&c,&n5); |
305 |
|
|
SAT_SHELL* shell=(SAT_SHELL*)lst_entity.getid(ident); |
306 |
|
|
if (n1!=-1) shell->attrib=(SAT_ATTRIB*)lst_entity.getid(n1); |
307 |
|
|
else shell->attrib=NULL; |
308 |
|
|
if (n2!=-1) shell->next_shell=(SAT_SHELL*)lst_entity.getid(n2); |
309 |
|
|
else shell->next_shell=NULL; |
310 |
|
|
if (n3!=-1) shell->first_subshell=(SAT_SUBSHELL*)lst_entity.getid(n3); |
311 |
|
|
else shell->first_subshell=NULL; |
312 |
|
|
if (n4!=-1) shell->first_face=(SAT_FACE*)lst_entity.getid(n4); |
313 |
|
|
else shell->first_face=NULL; |
314 |
|
|
if (n5!=-1) shell->owning_lump=(SAT_LUMP*)lst_entity.getid(n5); |
315 |
|
|
else shell->owning_lump=NULL; |
316 |
|
|
} |
317 |
|
|
else if (strcmp(type_entite,"face")==0) |
318 |
|
|
{ |
319 |
|
|
int n1,n2,n3,n4,n5,n6; |
320 |
|
|
char string1[25]; |
321 |
|
|
char string2[25]; |
322 |
|
|
char string3[25]; |
323 |
|
|
char c; |
324 |
|
|
sscanf(mess,"%s %c%d %c%d %c%d %c%d %c%d %c%d %s %s %s",type_entite,&c,&n1,&c,&n2,&c,&n3,&c,&n4,&c,&n5,&c,&n6,string1,string2,string3); |
325 |
|
|
SAT_FACE* face=(SAT_FACE*)lst_entity.getid(ident); |
326 |
|
|
if (n1!=-1) face->attrib=(SAT_ATTRIB*)lst_entity.getid(n1); |
327 |
|
|
else face->attrib=NULL; |
328 |
|
|
if (n2!=-1) face->next_face=(SAT_FACE*)lst_entity.getid(n2); |
329 |
|
|
else face->next_face=NULL; |
330 |
|
|
if (n3!=-1) face->first_loop=(SAT_LOOP*)lst_entity.getid(n3); |
331 |
|
|
else face->first_loop=NULL; |
332 |
|
|
if (n4!=-1) face->owning_shell=(SAT_SHELL*)lst_entity.getid(n4); |
333 |
|
|
else face->owning_shell=NULL; |
334 |
|
|
if (n5!=-1) face->owning_subshell=(SAT_SUBSHELL*)lst_entity.getid(n5); |
335 |
|
|
else face->owning_subshell=NULL; |
336 |
|
|
if (n6!=-1) face->surface=(SAT_SURFACE*)lst_entity.getid(n6); |
337 |
|
|
else face->surface=NULL; |
338 |
|
|
if (strcmp(string1,"forward")==0) face->sense=FORWARD; |
339 |
|
|
else face->sense=REVERSED; |
340 |
|
|
if (strcmp(string2,"single")==0) face->simple_face=SINGLE; |
341 |
|
|
else face->simple_face=DOUBLE; |
342 |
|
|
if (strcmp(string3,"out")==0) face->exterieur=IS_OUT; |
343 |
|
|
else face->exterieur=IS_IN; |
344 |
|
|
} |
345 |
|
|
else if (strcmp(type_entite,"loop")==0) |
346 |
|
|
{ |
347 |
|
|
int n1,n2,n3,n4; |
348 |
|
|
char c; |
349 |
|
|
sscanf(mess,"%s %c%d %c%d %c%d %c%d",type_entite,&c,&n1,&c,&n2,&c,&n3,&c,&n4); |
350 |
|
|
SAT_LOOP* loop=(SAT_LOOP*)lst_entity.getid(ident); |
351 |
|
|
if (n1!=-1) loop->attrib=(SAT_ATTRIB*)lst_entity.getid(n1); |
352 |
|
|
else loop->attrib=NULL; |
353 |
|
|
if (n2!=-1) loop->next_loop=(SAT_LOOP*)lst_entity.getid(n2); |
354 |
|
|
else loop->next_loop=NULL; |
355 |
|
|
if (n3!=-1) loop->first_coedge=(SAT_COEDGE*)lst_entity.getid(n3); |
356 |
|
|
else loop->first_coedge=NULL; |
357 |
|
|
if (n4!=-1) loop->owning_face=(SAT_FACE*)lst_entity.getid(n4); |
358 |
|
|
else loop->owning_face=NULL; |
359 |
|
|
} |
360 |
|
|
else if (strcmp(type_entite,"subshell")==0) |
361 |
|
|
{ |
362 |
|
|
int n1,n2,n3,n4,n5,n6; |
363 |
|
|
char c; |
364 |
|
|
sscanf(mess,"%s %c%d %c%d %c%d %c%d %c%d %c%d",type_entite,&c,&n1,&c,&n2,&c,&n3,&c,&n4,&c,&n5,&c,&n6); |
365 |
|
|
SAT_SUBSHELL* subshell=(SAT_SUBSHELL*)lst_entity.getid(ident); |
366 |
|
|
if (n1!=-1) subshell->attrib=(SAT_ATTRIB*)lst_entity.getid(n1); |
367 |
|
|
else subshell->attrib=NULL; |
368 |
|
|
if (n2!=-1) subshell->parent_subshell=(SAT_SUBSHELL*)lst_entity.getid(n2); |
369 |
|
|
else subshell->parent_subshell=NULL; |
370 |
|
|
if (n3!=-1) subshell->next_subshell=(SAT_SUBSHELL*)lst_entity.getid(n3); |
371 |
|
|
else subshell->next_subshell=NULL; |
372 |
|
|
if (n4!=-1) subshell->first_subshell=(SAT_SUBSHELL*)lst_entity.getid(n4); |
373 |
|
|
else subshell->first_subshell=NULL; |
374 |
|
|
if (n5!=-1) subshell->first_face=(SAT_FACE*)lst_entity.getid(n5); |
375 |
|
|
else subshell->first_face=NULL; |
376 |
|
|
if (n6!=-1) subshell->owning_wire=(SAT_WIRE*)lst_entity.getid(n6); |
377 |
|
|
else subshell->owning_wire=NULL; |
378 |
|
|
} |
379 |
|
|
else if (strcmp(type_entite,"wire")==0) |
380 |
|
|
{ |
381 |
|
|
int n1,n2,n3,n4; |
382 |
|
|
char c; |
383 |
|
|
sscanf(mess,"%s %c%d %c%d %c%d %c%d",type_entite,&c,&n1,&c,&n2,&c,&n3,&c,&n4); |
384 |
|
|
SAT_WIRE* wire=(SAT_WIRE*)lst_entity.getid(ident); |
385 |
|
|
if (n1!=-1) wire->attrib=(SAT_ATTRIB*)lst_entity.getid(n1); |
386 |
|
|
else wire->attrib=NULL; |
387 |
|
|
if (n2!=-1) wire->next_wire=(SAT_WIRE*)lst_entity.getid(n2); |
388 |
|
|
else wire->next_wire=NULL; |
389 |
|
|
if (n3!=-1) wire->first_coedge=(SAT_COEDGE*)lst_entity.getid(n3); |
390 |
|
|
else wire->first_coedge=NULL; |
391 |
|
|
if (n4!=-1) wire->owning=(void *)lst_entity.getid(n4); |
392 |
|
|
else wire->owning=NULL; |
393 |
|
|
} |
394 |
|
|
else if (strcmp(type_entite,"coedge")==0) |
395 |
|
|
{ |
396 |
|
|
int n1,n2,n3,n4,n5,n6,n7; |
397 |
|
|
int num; |
398 |
|
|
char string1[30]; |
399 |
|
|
char c; |
400 |
|
|
if (version<200) |
401 |
|
|
sscanf(mess,"%s %c%d %c%d %c%d %c%d %c%d %d %c%d %c%d",type_entite,&c,&n1,&c,&n2,&c,&n3,&c,&n4,&c,&n5,&num,&c,&n6,&c,&n7); |
402 |
|
|
else sscanf(mess,"%s %c%d %c%d %c%d %c%d %c%d %s %c%d %c%d",type_entite,&c,&n1,&c,&n2,&c,&n3,&c,&n4,&c,&n5,string1,&c,&n6,&c,&n7); |
403 |
|
|
|
404 |
|
|
SAT_COEDGE* coedge=(SAT_COEDGE*)lst_entity.getid(ident); |
405 |
|
|
if (n1!=-1) coedge->attrib=(SAT_ATTRIB*)lst_entity.getid(n1); |
406 |
|
|
else coedge->attrib=NULL; |
407 |
|
|
if (n2!=-1) coedge->next_coedge=(SAT_COEDGE*)lst_entity.getid(n2); |
408 |
|
|
else coedge->next_coedge=NULL; |
409 |
|
|
if (n3!=-1) coedge->previous_coedge=(SAT_COEDGE*)lst_entity.getid(n3); |
410 |
|
|
else coedge->previous_coedge=NULL; |
411 |
|
|
if (n4!=-1) coedge->partner_coedge=(SAT_COEDGE*)lst_entity.getid(n4); |
412 |
|
|
else coedge->partner_coedge=NULL; |
413 |
|
|
if (n5!=-1) coedge->edge=(SAT_EDGE*)lst_entity.getid(n5); |
414 |
|
|
else coedge->edge=NULL; |
415 |
|
|
if (version<200) coedge->sense=-2*num+1; |
416 |
|
|
else |
417 |
|
|
if (strcmp(string1,"forward")==0) coedge->sense=FORWARD; |
418 |
|
|
else coedge->sense=REVERSED; |
419 |
|
|
if (n6!=-1) coedge->owning_loop=(SAT_LOOP*)lst_entity.getid(n6); |
420 |
|
|
else coedge->owning_loop=NULL; |
421 |
|
|
if (n7!=-1) coedge->pcurve=(SAT_PCURVE*)lst_entity.getid(n7); |
422 |
|
|
else coedge->pcurve=NULL; |
423 |
|
|
} |
424 |
|
|
else if (strcmp(type_entite,"edge")==0) |
425 |
|
|
{ |
426 |
|
|
int n1,n2,n3,n4,n5; |
427 |
|
|
double f1,f2; |
428 |
|
|
int num; |
429 |
|
|
char string1[30]; |
430 |
|
|
char c; |
431 |
|
|
if (version<200) |
432 |
|
|
sscanf(mess,"%s %c%d %c%d %c%d %c%d %c%d %d",type_entite,&c,&n1,&c,&n2,&c,&n3,&c,&n4,&c,&n5,&num); |
433 |
|
|
else if (version<500) |
434 |
|
|
sscanf(mess,"%s %c%d %c%d %c%d %c%d %c%d %s",type_entite,&c,&n1,&c,&n2,&c,&n3,&c,&n4,&c,&n5,string1); |
435 |
|
|
else sscanf(mess,"%s %c%d %c%d %lf %c%d %lf %c%d %c%d %s",type_entite,&c,&n1,&c,&n2,&f1,&c,&n3,&f2,&c,&n4,&c,&n5,string1); |
436 |
|
|
SAT_EDGE* edge=(SAT_EDGE*)lst_entity.getid(ident); |
437 |
|
|
if (n1!=-1) edge->attrib=(SAT_ATTRIB*)lst_entity.getid(n1); |
438 |
|
|
else edge->attrib=NULL; |
439 |
|
|
if (n2!=-1) edge->start_vertex=(SAT_VERTEX*)lst_entity.getid(n2); |
440 |
|
|
else edge->start_vertex=NULL; |
441 |
|
|
if (n3!=-1) edge->end_vertex=(SAT_VERTEX*)lst_entity.getid(n3); |
442 |
|
|
else edge->end_vertex=NULL; |
443 |
|
|
if (n4!=-1) edge->owning_coedge=(SAT_COEDGE*)lst_entity.getid(n4); |
444 |
|
|
else edge->owning_coedge=NULL; |
445 |
|
|
if (n5!=-1) edge->curve=(SAT_COURBE*) lst_entity.getid(n5); |
446 |
|
|
else edge->curve=NULL; |
447 |
|
|
if (version<200) |
448 |
|
|
if (num==0) edge->sense=1; |
449 |
|
|
else edge->sense=-1; |
450 |
|
|
else |
451 |
|
|
if (strcmp(string1,"forward")==0) edge->sense=FORWARD; |
452 |
|
|
else edge->sense=REVERSED; |
453 |
|
|
} |
454 |
|
|
else if (strcmp(type_entite,"vertex")==0) |
455 |
|
|
{ |
456 |
|
|
int n1,n2,n3; |
457 |
|
|
char c; |
458 |
|
|
sscanf(mess,"%s %c%d %c%d %c%d",type_entite,&c,&n1,&c,&n2,&c,&n3); |
459 |
|
|
SAT_VERTEX* vertex=(SAT_VERTEX*)lst_entity.getid(ident); |
460 |
|
|
if (n1!=-1) vertex->attrib=(SAT_ATTRIB*)lst_entity.getid(n1); |
461 |
|
|
else vertex->attrib=NULL; |
462 |
|
|
if (n2!=-1) vertex->owning_edge=(SAT_EDGE*)lst_entity.getid(n2); |
463 |
|
|
else vertex->owning_edge=NULL; |
464 |
|
|
if (n3!=-1) vertex->point=(SAT_POINT*)lst_entity.getid(n3); |
465 |
|
|
else vertex->point=NULL; |
466 |
|
|
} |
467 |
|
|
else if (strcmp(type_entite,"cone-surface")==0) |
468 |
|
|
{ |
469 |
|
|
int n1; |
470 |
|
|
double f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12; |
471 |
|
|
char c; |
472 |
|
|
sscanf(mess,"%s %c%d %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf",type_entite,&c,&n1,&f1,&f2,&f3,&f4,&f5,&f6,&f7,&f8,&f9,&f10,&f11,&f12); |
473 |
|
|
SAT_CONE* cone=(SAT_CONE*)lst_entity.getid(ident); |
474 |
|
|
if (n1!=-1) cone->attrib=(SAT_ATTRIB*)lst_entity.getid(n1); |
475 |
|
|
else cone->attrib=NULL; |
476 |
|
|
cone->center[0]=f1; |
477 |
|
|
cone->center[1]=f2; |
478 |
|
|
cone->center[2]=f3; |
479 |
|
|
cone->normal[0]=f4; |
480 |
|
|
cone->normal[1]=f5; |
481 |
|
|
cone->normal[2]=f6; |
482 |
|
|
cone->major[0]=f7; |
483 |
|
|
cone->major[1]=f8; |
484 |
|
|
cone->major[2]=f9; |
485 |
|
|
cone->ratio=f10; |
486 |
|
|
cone->cosalpha=f12; |
487 |
|
|
cone->sinalpha=f11; |
488 |
|
|
cone->calcule_parametre(); |
489 |
|
|
} |
490 |
|
|
else if (strcmp(type_entite,"ellipse-curve")==0) |
491 |
|
|
{ |
492 |
|
|
int n1; |
493 |
|
|
double f1,f2,f3,f4,f5,f6,f7,f8,f9,f10; |
494 |
|
|
char c; |
495 |
|
|
sscanf(mess,"%s %c%d %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf",type_entite,&c,&n1,&f1,&f2,&f3,&f4,&f5,&f6,&f7,&f8,&f9,&f10); |
496 |
|
|
SAT_ELLIPSE* ellipse=(SAT_ELLIPSE*)lst_entity.getid(ident); |
497 |
|
|
if (n1!=-1) ellipse->attrib=(SAT_ATTRIB*)lst_entity.getid(n1); |
498 |
|
|
else ellipse->attrib=NULL; |
499 |
|
|
ellipse->center[0]=f1; |
500 |
|
|
ellipse->center[1]=f2; |
501 |
|
|
ellipse->center[2]=f3; |
502 |
|
|
ellipse->normal[0]=f4; |
503 |
|
|
ellipse->normal[1]=f5; |
504 |
|
|
ellipse->normal[2]=f6; |
505 |
|
|
ellipse->major[0]=f7; |
506 |
|
|
ellipse->major[1]=f8; |
507 |
|
|
ellipse->major[2]=f9; |
508 |
|
|
ellipse->ratio=f10; |
509 |
|
|
ellipse->calcul_parametre(); |
510 |
|
|
} |
511 |
|
|
else if (strcmp(type_entite,"pcurve")==0) |
512 |
|
|
{ |
513 |
|
|
} |
514 |
|
|
else if (strcmp(type_entite,"plane-surface")==0) |
515 |
|
|
{ |
516 |
|
|
int n1; |
517 |
|
|
double f1,f2,f3,f4,f5,f6,f7,f8,f9; |
518 |
|
|
char c; |
519 |
|
|
sscanf(mess,"%s %c%d %lf %lf %lf %lf %lf %lf %lf %lf %lf",type_entite,&c,&n1,&f1,&f2,&f3,&f4,&f5,&f6,&f7,&f8,&f9); |
520 |
|
|
SAT_PLANE* plane=(SAT_PLANE*)lst_entity.getid(ident); |
521 |
|
|
if (n1!=-1) plane->attrib=(SAT_ATTRIB*)lst_entity.getid(n1); |
522 |
|
|
else plane->attrib=NULL; |
523 |
|
|
plane->root[0]=f1; |
524 |
|
|
plane->root[1]=f2; |
525 |
|
|
plane->root[2]=f3; |
526 |
|
|
plane->normal[0]=f4; |
527 |
|
|
plane->normal[1]=f5; |
528 |
|
|
plane->normal[2]=f6; |
529 |
|
|
plane->u_deriv[0]=f7; |
530 |
|
|
plane->u_deriv[1]=f8; |
531 |
|
|
plane->u_deriv[2]=f9; |
532 |
|
|
plane->calcule_parametre(); |
533 |
|
|
} |
534 |
|
|
else if (strcmp(type_entite,"point")==0) |
535 |
|
|
{ |
536 |
|
|
int n1; |
537 |
|
|
double f1,f2,f3; |
538 |
|
|
char c; |
539 |
|
|
sscanf(mess,"%s %c%d %lf %lf %lf",type_entite,&c,&n1,&f1,&f2,&f3); |
540 |
|
|
SAT_POINT* point=(SAT_POINT*)lst_entity.getid(ident); |
541 |
|
|
if (n1!=-1) point->attrib=(SAT_ATTRIB*)lst_entity.getid(n1); |
542 |
|
|
else point->attrib=NULL; |
543 |
|
|
point->coord[0]=f1; |
544 |
|
|
point->coord[1]=f2; |
545 |
|
|
point->coord[2]=f3; |
546 |
|
|
} |
547 |
|
|
else if (strcmp(type_entite,"straight-curve")==0) |
548 |
|
|
{ |
549 |
|
|
int n1; |
550 |
|
|
double f1,f2,f3,f4,f5,f6; |
551 |
|
|
char c; |
552 |
|
|
sscanf(mess,"%s %c%d %lf %lf %lf %lf %lf %lf ",type_entite,&c,&n1,&f1,&f2,&f3,&f4,&f5,&f6); |
553 |
|
|
SAT_STRAIGHT* straight=(SAT_STRAIGHT*)lst_entity.getid(ident); |
554 |
|
|
if (n1!=-1) straight->attrib=(SAT_ATTRIB*)lst_entity.getid(n1); |
555 |
|
|
else straight->attrib=NULL; |
556 |
|
|
straight->root[0]=f1; |
557 |
|
|
straight->root[1]=f2; |
558 |
|
|
straight->root[2]=f3; |
559 |
|
|
straight->dir[0]=f4; |
560 |
|
|
straight->dir[1]=f5; |
561 |
|
|
straight->dir[2]=f6; |
562 |
|
|
} |
563 |
|
|
else if (strcmp(type_entite,"transform")==0) |
564 |
|
|
{ |
565 |
|
|
int n1,n2,n3,n4; |
566 |
|
|
double f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13; |
567 |
|
|
char c; |
568 |
|
|
sscanf(mess,"%s %c%d %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %d %d %d",type_entite,&c,&n1,&f1,&f2,&f3,&f4,&f5,&f6,&f7,&f8,&f9,&f10,&f11,&f12,&f13,&n2,&n3,&n4); |
569 |
|
|
SAT_TRANSFORM* transform=(SAT_TRANSFORM*)lst_entity.getid(ident); |
570 |
|
|
if (n1!=-1) transform->attrib=(SAT_ATTRIB*)lst_entity.getid(n1); |
571 |
|
|
else transform->attrib=NULL; |
572 |
|
|
transform->rotation[0][0]=f1; |
573 |
|
|
transform->rotation[0][1]=f2; |
574 |
|
|
transform->rotation[0][2]=f3; |
575 |
|
|
transform->rotation[1][0]=f4; |
576 |
|
|
transform->rotation[1][1]=f5; |
577 |
|
|
transform->rotation[1][2]=f6; |
578 |
|
|
transform->rotation[2][0]=f7; |
579 |
|
|
transform->rotation[2][1]=f8; |
580 |
|
|
transform->rotation[2][2]=f9; |
581 |
|
|
transform->trans[0]=f10; |
582 |
|
|
transform->trans[1]=f11; |
583 |
|
|
transform->trans[2]=f12; |
584 |
|
|
transform->scaling_factor=f13; |
585 |
|
|
transform->rotate=n2; |
586 |
|
|
transform->reflection=n3; |
587 |
|
|
transform->shear=n4; |
588 |
|
|
} |
589 |
|
|
else if (ident==0) commentaire=1; |
590 |
|
|
if (commentaire==0) ident++; |
591 |
|
|
} |
592 |
|
|
fclose(fic); |
593 |
|
|
return version; |
594 |
|
|
} |
595 |
|
|
|