commit | author | age
|
7f6076
|
1 |
/* vim: set ts=4 sts=4 sw=4 noet : */ |
8c1bb1
|
2 |
#include <stdio.h> |
SP |
3 |
#include <string.h> |
|
4 |
#include <stdlib.h> |
|
5 |
#include <libxml/xmlmemory.h> |
|
6 |
#include <libxml/parser.h> |
|
7 |
#include <general.h> |
|
8 |
#include <restore.h> |
|
9 |
#include <snapshot.h> |
|
10 |
#include <zlib.h> |
|
11 |
#include "vesicle.h" |
487968
|
12 |
#include "vertex.h" |
a011d2
|
13 |
#include "triangle.h" |
a3dbf0
|
14 |
#include "bond.h" |
SP |
15 |
#include "energy.h" |
bb4033
|
16 |
#include "poly.h" |
a3dbf0
|
17 |
#include "initial_distribution.h" |
698ae1
|
18 |
#include "io.h" |
002513
|
19 |
#include <math.h> |
a011d2
|
20 |
|
ab798b
|
21 |
ts_vesicle *parseDump(char *dumpfname) { |
8c1bb1
|
22 |
xmlDocPtr doc; |
8fa1c0
|
23 |
xmlNodePtr cur, cur1,cur2; |
SP |
24 |
ts_vesicle *vesicle=NULL; |
8c1bb1
|
25 |
doc = xmlParseFile(dumpfname); |
002513
|
26 |
int i; |
8c1bb1
|
27 |
if (doc == NULL ) { |
SP |
28 |
fatal("Dump file could not be found or parsed. It is correct file?",1); |
|
29 |
} |
|
30 |
|
|
31 |
cur = xmlDocGetRootElement(doc); |
|
32 |
|
|
33 |
if (cur == NULL) { |
|
34 |
fatal("Dump file is empty.",1); |
|
35 |
} |
|
36 |
|
|
37 |
if (xmlStrcmp(cur->name, (const xmlChar *) "VTKFile")) { |
|
38 |
fatal("document of the wrong type, root node != story",1); |
|
39 |
} |
|
40 |
|
|
41 |
cur = cur->xmlChildrenNode; |
|
42 |
while (cur != NULL) { |
698ae1
|
43 |
|
SP |
44 |
if ((!xmlStrcmp(cur->name, (const xmlChar *)"tape"))){ |
|
45 |
setGlobalTapeTXTfromTapeTag(doc, cur); |
|
46 |
} |
|
47 |
|
8c1bb1
|
48 |
if ((!xmlStrcmp(cur->name, (const xmlChar *)"trisurf"))){ |
3c772b
|
49 |
vesicle=parseTrisurfTag(doc, cur); |
8c1bb1
|
50 |
} |
8fa1c0
|
51 |
// START Point Position data & Bonds |
SP |
52 |
if ((!xmlStrcmp(cur->name, (const xmlChar *)"UnstructuredGrid"))){ |
|
53 |
cur1 = cur->xmlChildrenNode; |
|
54 |
while(cur1!=NULL){ |
|
55 |
if ((!xmlStrcmp(cur1->name, (const xmlChar *)"Piece"))){ |
|
56 |
cur2=cur1->xmlChildrenNode; |
|
57 |
while(cur2!=NULL){ |
def8b5
|
58 |
if ((!xmlStrcmp(cur2->name, (const xmlChar *)"PointData"))){ |
SP |
59 |
if(vesicle!=NULL) |
|
60 |
parseXMLPointData(vesicle,doc,cur2); |
|
61 |
} |
8fa1c0
|
62 |
if ((!xmlStrcmp(cur2->name, (const xmlChar *)"Points"))){ |
720bd4
|
63 |
//fprintf(stderr,"Found point data\n"); |
8fa1c0
|
64 |
if(vesicle!=NULL) |
f62178
|
65 |
//fprintf(stderr,"Fils: %ld, Nfono: %ld\n", vesicle->tape->nfil, vesicle->tape->nfono); |
28efdb
|
66 |
parseXMLVertexPosition(vesicle, doc, cur2); |
8fa1c0
|
67 |
} |
SP |
68 |
if ((!xmlStrcmp(cur2->name, (const xmlChar *)"Cells"))){ |
720bd4
|
69 |
//fprintf(stderr,"Found cell(Bonds) data\n"); |
a3dbf0
|
70 |
if(vesicle!=NULL) |
28efdb
|
71 |
parseXMLBonds(vesicle, doc, cur2); |
8fa1c0
|
72 |
} |
SP |
73 |
cur2=cur2->next; |
|
74 |
} |
|
75 |
} |
|
76 |
cur1 = cur1->next; |
|
77 |
} |
|
78 |
} |
|
79 |
// END Point Position data & Bonds |
8c1bb1
|
80 |
cur = cur->next; |
SP |
81 |
} |
|
82 |
|
|
83 |
xmlFreeDoc(doc); |
bb4033
|
84 |
|
86b69b
|
85 |
// vesicle->poly_list=init_poly_list(0, 0, vesicle->vlist, vesicle); |
bb4033
|
86 |
|
a3dbf0
|
87 |
init_normal_vectors(vesicle->tlist); |
SP |
88 |
mean_curvature_and_energy(vesicle); |
89434d
|
89 |
sweep_attraction_bond_energy(vesicle); |
002513
|
90 |
if(vesicle->tape->stretchswitch==1){ |
04694f
|
91 |
vesicle->tlist->a0=sqrt(3)/2.0*pow((vesicle->tape->dmax+1.0)/2.0,2); |
002513
|
92 |
for(i=0;i<vesicle->tlist->n;i++){ |
SP |
93 |
stretchenergy(vesicle, vesicle->tlist->tria[i]); |
|
94 |
} |
|
95 |
} |
ab798b
|
96 |
/* TODO: filaments */ |
a3dbf0
|
97 |
|
f4d6ca
|
98 |
// ts_fprintf(stdout,"Restoration completed\n"); |
ab798b
|
99 |
// write_vertex_xml_file(vesicle,999); |
SP |
100 |
// vesicle_free(vesicle); |
|
101 |
// exit(0); |
|
102 |
return vesicle; |
8c1bb1
|
103 |
} |
SP |
104 |
|
698ae1
|
105 |
ts_bool setGlobalTapeTXTfromTapeTag(xmlDocPtr doc, xmlNodePtr cur){ |
SP |
106 |
xmlChar *tape = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
107 |
strcpy(tapetxt,(char *)tape); |
|
108 |
xmlFree(tape); |
|
109 |
return TS_SUCCESS; |
|
110 |
} |
8fa1c0
|
111 |
|
SP |
112 |
|
|
113 |
/* this is a parser of additional data in xml */ |
8c1bb1
|
114 |
ts_vesicle *parseTrisurfTag(xmlDocPtr doc, xmlNodePtr cur){ |
720bd4
|
115 |
//fprintf(stderr,"Parsing trisurf tag\n"); |
487968
|
116 |
xmlNodePtr child; |
SP |
117 |
|
|
118 |
#ifdef COMPRESS |
8c1bb1
|
119 |
/* base64decode */ |
SP |
120 |
size_t cLen; |
|
121 |
/*size_t tLen; |
|
122 |
const unsigned char test[]="Test"; |
|
123 |
char *cTest=base64_encode(test, 4,&tLen); |
|
124 |
unsigned char *cuTest=base64_decode((char *)cTest,tLen,&tLen); |
|
125 |
cuTest[tLen]=0; |
|
126 |
fprintf(stderr,"%s\n",cuTest); |
|
127 |
*/ |
|
128 |
xmlChar *b64=xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
129 |
unsigned char *compressed=base64_decode((char *)b64,strlen((char *)b64)-1,&cLen); |
|
130 |
/* uncompress */ |
|
131 |
unsigned char *subtree=(unsigned char *)malloc(512000*sizeof(unsigned char)); /* TODO: again, the uncompressed string must not exceed this */ |
|
132 |
z_stream infstream; |
|
133 |
infstream.zalloc = Z_NULL; |
|
134 |
infstream.zfree = Z_NULL; |
|
135 |
infstream.opaque = Z_NULL; |
|
136 |
infstream.avail_in = (ts_uint)cLen; // size of input |
|
137 |
infstream.next_in = compressed; // input char array |
|
138 |
infstream.avail_out = (ts_uint)512000; // size of output |
|
139 |
infstream.next_out = subtree; // output char array |
|
140 |
|
|
141 |
// the actual DE-compression work. |
|
142 |
inflateInit(&infstream); |
|
143 |
inflate(&infstream, Z_NO_FLUSH); |
|
144 |
inflateEnd(&infstream); |
720bd4
|
145 |
//fprintf(stderr,"%lu\n",cLen); |
8c1bb1
|
146 |
subtree[infstream.total_out]='\0'; //zero terminate string |
720bd4
|
147 |
//fprintf(stderr,"%s\n",subtree); |
8c1bb1
|
148 |
|
SP |
149 |
free(subtree); |
487968
|
150 |
#endif |
8c1bb1
|
151 |
/*parse xml subtree */ |
86b69b
|
152 |
xmlChar *nvtx, *npoly, *nmono; |
8c1bb1
|
153 |
nvtx = xmlGetProp(cur, (xmlChar *)"nvtx"); |
SP |
154 |
npoly=xmlGetProp(cur, (xmlChar *)"npoly"); |
86b69b
|
155 |
nmono=xmlGetProp(cur, (xmlChar *)"nmono"); |
698ae1
|
156 |
ts_tape *tape=parsetapebuffer(tapetxt); |
SP |
157 |
//fprintf(stderr,"nvtx=%u\n",atoi((char *)nvtx)); |
|
158 |
//TODO: check if nvtx is in agreement with nshell from tape |
|
159 |
ts_vesicle *vesicle=init_vesicle(atoi((char *)nvtx),tape->ncxmax,tape->ncymax,tape->nczmax,tape->stepsize); |
8c1bb1
|
160 |
//vesicle->poly_list=init_poly_list(atoi((char *)npoly),atoi((char *)nmono), vesicle->vlist, vesicle); |
SP |
161 |
xmlFree(nvtx); |
|
162 |
xmlFree(npoly); |
86b69b
|
163 |
xmlFree(nmono); |
487968
|
164 |
|
SP |
165 |
child = cur->xmlChildrenNode; |
|
166 |
while (child != NULL) { |
|
167 |
if ((!xmlStrcmp(child->name, (const xmlChar *)"vtxn"))){ |
|
168 |
parseTrisurfVtxn(vesicle->vlist, doc, child); |
|
169 |
} |
a011d2
|
170 |
if ((!xmlStrcmp(child->name, (const xmlChar *)"tria"))){ |
SP |
171 |
parseTrisurfTria(vesicle, doc, child); |
|
172 |
} |
e9ac7b
|
173 |
if ((!xmlStrcmp(child->name, (const xmlChar *)"trianeigh"))){ |
SP |
174 |
parseTrisurfTriaNeigh(vesicle, doc, child); |
|
175 |
} |
a011d2
|
176 |
if ((!xmlStrcmp(child->name, (const xmlChar *)"tristar"))){ |
SP |
177 |
parseTrisurfTristar(vesicle, doc, child); |
|
178 |
} |
4891eb
|
179 |
if ((!xmlStrcmp(child->name, (const xmlChar *)"nucleus"))){ |
SP |
180 |
parseTrisurfNucleus(vesicle, doc, child); |
|
181 |
} |
49981c
|
182 |
if ((!xmlStrcmp(child->name, (const xmlChar *)"constant_volume"))){ |
SP |
183 |
parseTrisurfConstantVolume(doc, child); |
|
184 |
} |
|
185 |
if ((!xmlStrcmp(child->name, (const xmlChar *)"constant_area"))){ |
|
186 |
parseTrisurfConstantArea(doc, child); |
|
187 |
} |
|
188 |
|
a011d2
|
189 |
|
487968
|
190 |
child = child->next; |
SP |
191 |
} |
|
192 |
|
|
193 |
|
698ae1
|
194 |
vesicle->tape=tape; |
SP |
195 |
set_vesicle_values_from_tape(vesicle); |
8c1bb1
|
196 |
return vesicle; |
SP |
197 |
} |
487968
|
198 |
|
a011d2
|
199 |
|
SP |
200 |
|
|
201 |
/* Low level tags parsers */ |
49981c
|
202 |
ts_bool parseTrisurfConstantVolume(xmlDocPtr doc, xmlNodePtr cur){ |
SP |
203 |
xmlChar *cvol = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
204 |
char *n=(char *)cvol; |
|
205 |
V0=atof(n); |
|
206 |
xmlFree(cvol); |
|
207 |
return TS_SUCCESS; |
|
208 |
} |
|
209 |
ts_bool parseTrisurfConstantArea(xmlDocPtr doc, xmlNodePtr cur){ |
|
210 |
xmlChar *carea = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
211 |
char *n=(char *)carea; |
|
212 |
A0=atof(n); |
|
213 |
xmlFree(carea); |
|
214 |
return TS_SUCCESS; |
|
215 |
} |
|
216 |
|
4891eb
|
217 |
ts_bool parseTrisurfNucleus(ts_vesicle *vesicle, xmlDocPtr doc, xmlNodePtr cur){ |
SP |
218 |
xmlChar *coords = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
219 |
char *n=(char *)coords; |
|
220 |
char *token=strtok(n," "); |
|
221 |
ts_uint i; |
|
222 |
for(i=0;i<3;i++){ |
|
223 |
vesicle->nucleus_center[i]=atof(token); |
|
224 |
token=strtok(NULL," "); |
|
225 |
} |
|
226 |
xmlFree(coords); |
|
227 |
return TS_SUCCESS; |
|
228 |
} |
a011d2
|
229 |
|
SP |
230 |
ts_bool parseTrisurfVtxn(ts_vertex_list *vlist, xmlDocPtr doc, xmlNodePtr cur){ |
487968
|
231 |
|
SP |
232 |
xmlChar *chari; |
|
233 |
xmlChar *neighs; |
|
234 |
char *n; |
|
235 |
char *token; |
|
236 |
ts_uint neighi; |
|
237 |
ts_uint i; |
|
238 |
chari = xmlGetProp(cur, (xmlChar *)"idx"); |
|
239 |
i=atoi((char *)chari); |
|
240 |
xmlFree(chari); |
|
241 |
ts_vertex *vtx=vlist->vtx[i]; |
|
242 |
neighs = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
243 |
//fprintf(stderr,"Found neigh for vtx %u that seems to have index %u with neighs=%s\n",i,vtx->idx,neighs); |
|
244 |
|
|
245 |
n=(char *)neighs; |
|
246 |
token=strtok(n," "); |
|
247 |
while(token!=NULL){ |
|
248 |
neighi=atoi(token); |
|
249 |
//fprintf(stderr,"%u", neighi); |
|
250 |
vtx_add_neighbour(vtx,vlist->vtx[neighi]); |
|
251 |
token=strtok(NULL," "); |
|
252 |
} |
|
253 |
xmlFree(neighs); |
|
254 |
return TS_SUCCESS; |
|
255 |
} |
|
256 |
|
a011d2
|
257 |
ts_bool parseTrisurfTria(ts_vesicle *vesicle, xmlDocPtr doc, xmlNodePtr cur){ |
SP |
258 |
xmlChar *triangles; |
|
259 |
char *tria; |
|
260 |
char *vtx[3]; |
|
261 |
|
e87e4e
|
262 |
ts_uint i,j; |
a011d2
|
263 |
triangles = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
SP |
264 |
tria=(char *)triangles; |
e87e4e
|
265 |
vtx[0]=strtok(tria," "); |
SP |
266 |
for(i=1;i<3;i++) vtx[i]=strtok(NULL," "); |
|
267 |
j=0; |
a011d2
|
268 |
while(vtx[2]!=NULL){ |
SP |
269 |
triangle_add(vesicle->tlist, vesicle->vlist->vtx[atoi(vtx[0])],vesicle->vlist->vtx[atoi(vtx[1])],vesicle->vlist->vtx[atoi(vtx[2])]); |
|
270 |
for(i=0;i<3;i++) vtx[i]=strtok(NULL," "); |
e87e4e
|
271 |
j++; |
a011d2
|
272 |
} |
720bd4
|
273 |
//fprintf(stderr,"Parsing triangles %s j=%d\n",triangles,j); |
a011d2
|
274 |
|
SP |
275 |
xmlFree(triangles); |
|
276 |
return TS_SUCCESS; |
|
277 |
} |
|
278 |
|
|
279 |
|
e9ac7b
|
280 |
ts_bool parseTrisurfTriaNeigh(ts_vesicle *vesicle, xmlDocPtr doc, xmlNodePtr cur){ |
SP |
281 |
xmlChar *triangles; |
|
282 |
char *tria; |
|
283 |
char *ntria[3]; |
|
284 |
ts_uint i,j; |
|
285 |
triangles = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
286 |
tria=(char *)triangles; |
e87e4e
|
287 |
ntria[0]=strtok(tria," "); |
SP |
288 |
for(i=1;i<3;i++) ntria[i]=strtok(NULL," "); |
e9ac7b
|
289 |
j=0; |
SP |
290 |
while(ntria[2]!=NULL){ |
|
291 |
triangle_add_neighbour(vesicle->tlist->tria[j],vesicle->tlist->tria[atoi(ntria[0])]); |
|
292 |
triangle_add_neighbour(vesicle->tlist->tria[j],vesicle->tlist->tria[atoi(ntria[1])]); |
|
293 |
triangle_add_neighbour(vesicle->tlist->tria[j],vesicle->tlist->tria[atoi(ntria[2])]); |
|
294 |
j++; |
|
295 |
for(i=0;i<3;i++) ntria[i]=strtok(NULL," "); |
|
296 |
} |
720bd4
|
297 |
//fprintf(stderr,"Parsing triangle neighbors j=%d\n",j); |
e9ac7b
|
298 |
|
SP |
299 |
xmlFree(triangles); |
|
300 |
return TS_SUCCESS; |
|
301 |
} |
|
302 |
|
|
303 |
|
a011d2
|
304 |
ts_bool parseTrisurfTristar(ts_vesicle *vesicle, xmlDocPtr doc, xmlNodePtr cur){ |
SP |
305 |
|
|
306 |
xmlChar *chari; |
|
307 |
xmlChar *tristar; |
|
308 |
char *t; |
|
309 |
char *token; |
|
310 |
ts_uint neighi; |
|
311 |
ts_uint i; |
|
312 |
chari = xmlGetProp(cur, (xmlChar *)"idx"); |
|
313 |
i=atoi((char *)chari); |
|
314 |
xmlFree(chari); |
|
315 |
ts_vertex *vtx=vesicle->vlist->vtx[i]; |
|
316 |
tristar = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
317 |
// fprintf(stderr,"Found tristar for vtx %u that seems to have index %u with tristar=%s\n",i,vtx->idx,tristar); |
|
318 |
|
|
319 |
t=(char *)tristar; |
|
320 |
token=strtok(t," "); |
|
321 |
while(token!=NULL){ |
|
322 |
neighi=atoi(token); |
|
323 |
//fprintf(stderr,"%u", neighi); |
|
324 |
vertex_add_tristar(vtx,vesicle->tlist->tria[neighi]); |
|
325 |
token=strtok(NULL," "); |
|
326 |
} |
|
327 |
xmlFree(tristar); |
|
328 |
return TS_SUCCESS; |
|
329 |
} |
|
330 |
|
def8b5
|
331 |
/* this parses the data for vertices (like spontaneous curvature, etc.) */ |
SP |
332 |
ts_bool parseXMLPointData(ts_vesicle *vesicle,xmlDocPtr doc, xmlNodePtr cur){ |
|
333 |
xmlNodePtr child = cur->xmlChildrenNode; |
|
334 |
xmlChar *property_name; |
|
335 |
xmlChar *values; |
|
336 |
char *vals; |
|
337 |
char *token; |
|
338 |
int idx, polyidx, monoidx, filidx, fonoidx; |
|
339 |
while (child != NULL) { |
|
340 |
if ((!xmlStrcmp(child->name, (const xmlChar *)"DataArray"))){ |
|
341 |
property_name=xmlGetProp(child, (xmlChar *)"Name"); |
|
342 |
// fprintf(stderr,"Name: %s\n", property_name); |
|
343 |
if(!xmlStrcmp(property_name,(const xmlChar *)"spontaneous_curvature")){ |
|
344 |
values=xmlNodeListGetString(doc,child->xmlChildrenNode,1); |
|
345 |
vals=(char *)values; |
|
346 |
token=strtok(vals," "); |
|
347 |
idx=0; |
|
348 |
while(token!=NULL){ |
|
349 |
if(idx<vesicle->vlist->n){ |
|
350 |
vesicle->vlist->vtx[idx]->c=atof(token); |
|
351 |
} else if(vesicle->tape->nmono && vesicle->tape->npoly && idx<vesicle->vlist->n+vesicle->tape->nmono*vesicle->tape->npoly) { |
|
352 |
polyidx=(idx-vesicle->vlist->n)/vesicle->tape->nmono; |
|
353 |
monoidx=(idx-vesicle->vlist->n)%vesicle->tape->nmono; |
|
354 |
vesicle->poly_list->poly[polyidx]->vlist->vtx[monoidx]->c=atof(token); |
|
355 |
} else { |
|
356 |
filidx=(idx-vesicle->vlist->n-vesicle->tape->nmono*vesicle->tape->npoly)/vesicle->tape->nfono; |
|
357 |
fonoidx=(idx-vesicle->vlist->n-vesicle->tape->nmono*vesicle->tape->npoly)%vesicle->tape->nfono; |
|
358 |
//fprintf(stderr,"filidx=%d, fonoidx=%d, coord=%s,%s,%s\n",filidx,fonoidx,token[0],token[1],token[2]); |
|
359 |
vesicle->filament_list->poly[filidx]->vlist->vtx[fonoidx]->c=atof(token); |
|
360 |
} |
|
361 |
idx++; |
|
362 |
token=strtok(NULL," "); |
|
363 |
} |
|
364 |
xmlFree(values); |
|
365 |
} |
|
366 |
xmlFree(property_name); |
|
367 |
} |
|
368 |
|
|
369 |
child=child->next; |
|
370 |
} |
|
371 |
return TS_SUCCESS; |
|
372 |
} |
8fa1c0
|
373 |
/* this is a parser of vertex positions and bonds from main xml data */ |
SP |
374 |
ts_bool parseXMLVertexPosition(ts_vesicle *vesicle,xmlDocPtr doc, xmlNodePtr cur){ |
|
375 |
xmlNodePtr child = cur->xmlChildrenNode; |
|
376 |
xmlChar *points; |
|
377 |
char *pts; |
301c87
|
378 |
int i, idx, polyidx, monoidx, filidx, fonoidx; |
8fa1c0
|
379 |
char *token[3]; |
SP |
380 |
while (child != NULL) { |
|
381 |
if ((!xmlStrcmp(child->name, (const xmlChar *)"DataArray"))){ |
|
382 |
points = xmlNodeListGetString(doc, child->xmlChildrenNode, 1); |
|
383 |
pts=(char *)points; |
e87e4e
|
384 |
token[0]=strtok(pts," "); |
ecdd71
|
385 |
token[1]=strtok(NULL," "); |
SP |
386 |
token[2]=strtok(NULL,"\n"); |
8fa1c0
|
387 |
idx=0; |
SP |
388 |
while(token[0]!=NULL){ |
86b69b
|
389 |
if(idx<vesicle->vlist->n){ |
SP |
390 |
vesicle->vlist->vtx[idx]->x=atof(token[0]); |
|
391 |
vesicle->vlist->vtx[idx]->y=atof(token[1]); |
|
392 |
vesicle->vlist->vtx[idx]->z=atof(token[2]); |
301c87
|
393 |
} else if(vesicle->tape->nmono && vesicle->tape->npoly && idx<vesicle->vlist->n+vesicle->tape->nmono*vesicle->tape->npoly) { |
86b69b
|
394 |
polyidx=(idx-vesicle->vlist->n)/vesicle->tape->nmono; |
SP |
395 |
monoidx=(idx-vesicle->vlist->n)%vesicle->tape->nmono; |
|
396 |
vesicle->poly_list->poly[polyidx]->vlist->vtx[monoidx]->x=atof(token[0]); |
|
397 |
vesicle->poly_list->poly[polyidx]->vlist->vtx[monoidx]->y=atof(token[1]); |
|
398 |
vesicle->poly_list->poly[polyidx]->vlist->vtx[monoidx]->z=atof(token[2]); |
301c87
|
399 |
} else { |
SP |
400 |
filidx=(idx-vesicle->vlist->n-vesicle->tape->nmono*vesicle->tape->npoly)/vesicle->tape->nfono; |
|
401 |
fonoidx=(idx-vesicle->vlist->n-vesicle->tape->nmono*vesicle->tape->npoly)%vesicle->tape->nfono; |
f62178
|
402 |
//fprintf(stderr,"filidx=%d, fonoidx=%d, coord=%s,%s,%s\n",filidx,fonoidx,token[0],token[1],token[2]); |
301c87
|
403 |
vesicle->filament_list->poly[filidx]->vlist->vtx[fonoidx]->x=atof(token[0]); |
SP |
404 |
vesicle->filament_list->poly[filidx]->vlist->vtx[fonoidx]->y=atof(token[1]); |
|
405 |
vesicle->filament_list->poly[filidx]->vlist->vtx[fonoidx]->z=atof(token[2]); |
86b69b
|
406 |
} |
ecdd71
|
407 |
for(i=0;i<2;i++) token[i]=strtok(NULL," "); |
SP |
408 |
token[2]=strtok(NULL,"\n"); |
8fa1c0
|
409 |
idx++; |
SP |
410 |
} |
|
411 |
xmlFree(points); |
|
412 |
} |
|
413 |
child=child->next; |
|
414 |
} |
f62178
|
415 |
//fprintf(stderr,"Came here\n"); |
720bd4
|
416 |
//fprintf(stderr,"Vertices position j=%d\n",idx); |
28efdb
|
417 |
|
8fa1c0
|
418 |
return TS_SUCCESS; |
SP |
419 |
} |
a3dbf0
|
420 |
ts_bool parseXMLBonds(ts_vesicle *vesicle,xmlDocPtr doc, xmlNodePtr cur){ |
SP |
421 |
xmlNodePtr child = cur->xmlChildrenNode; |
bb4033
|
422 |
xmlChar *bonds, *conname; |
a3dbf0
|
423 |
char *b; |
86b69b
|
424 |
int idx, polyidx; |
a3dbf0
|
425 |
char *token[2]; |
3cd5f4
|
426 |
int temp_cnt=0; |
a3dbf0
|
427 |
while (child != NULL) { |
bb4033
|
428 |
conname=xmlGetProp(child, (xmlChar *)"Name"); |
SP |
429 |
if ((!xmlStrcmp(child->name, (const xmlChar *)"DataArray")) && !xmlStrcmp(conname, (const xmlChar *)"connectivity") ){ |
a3dbf0
|
430 |
bonds = xmlNodeListGetString(doc, child->xmlChildrenNode, 1); |
SP |
431 |
b=(char *)bonds; |
e87e4e
|
432 |
token[0]=strtok(b," "); |
ecdd71
|
433 |
token[1]=strtok(NULL,"\n"); |
a3dbf0
|
434 |
idx=0; |
SP |
435 |
while(token[0]!=NULL){ |
86b69b
|
436 |
if(idx<3*(vesicle->vlist->n-2)){ |
SP |
437 |
bond_add(vesicle->blist, vesicle->vlist->vtx[atoi(token[0])], vesicle->vlist->vtx[atoi(token[1])]); |
3cd5f4
|
438 |
//fprintf(stderr,"Bonds in vesicle count idx=%d\n",idx); |
86b69b
|
439 |
} |
SP |
440 |
else { |
|
441 |
//find grafted vtx |
301c87
|
442 |
if(vesicle->tape->npoly && vesicle->tape->nmono && (vesicle->tape->nmono-1)==(idx-3*(vesicle->vlist->n-2))%(vesicle->tape->nmono) |
3cd5f4
|
443 |
&& idx<(3*vesicle->vlist->n-2+vesicle->tape->nmono*vesicle->tape->npoly)){ |
SP |
444 |
temp_cnt++; |
|
445 |
//fprintf(stderr,"%d: Bonds in poly count idx=%d, t1=%s t2=%s\n",temp_cnt,idx, token[0], token[1]); |
|
446 |
|
86b69b
|
447 |
polyidx=(idx-3*(vesicle->vlist->n-2))/(vesicle->tape->nmono); |
720bd4
|
448 |
//fprintf(stderr,"poly=%d, vertex=%d\n",polyidx,atoi(token[0])); |
86b69b
|
449 |
vesicle->poly_list->poly[polyidx]->grafted_vtx=vesicle->vlist->vtx[atoi(token[0])]; |
SP |
450 |
vesicle->vlist->vtx[atoi(token[0])]->grafted_poly=vesicle->poly_list->poly[polyidx]; |
|
451 |
} |
|
452 |
} |
ecdd71
|
453 |
token[0]=strtok(NULL," "); |
SP |
454 |
token[1]=strtok(NULL,"\n"); |
a3dbf0
|
455 |
idx++; |
SP |
456 |
} |
|
457 |
xmlFree(bonds); |
|
458 |
} |
bb4033
|
459 |
xmlFree(conname); |
a3dbf0
|
460 |
child=child->next; |
SP |
461 |
} |
720bd4
|
462 |
//fprintf(stderr,"Bond data j=%d\n",idx); |
a3dbf0
|
463 |
return TS_SUCCESS; |
SP |
464 |
} |
|
465 |
|
8fa1c0
|
466 |
|
SP |
467 |
|