Trisurf Monte Carlo simulator
Samo Penic
2014-11-12 ee84bde159fa91d6f1907cf3d8c39cfe50638444
commit | author | age
ee84bd 1 #include <string.h>
SP 2 #include "general.h"
3 #include <stdio.h>
4 #include "initial_distribution.h"
5 #include "vesicle.h"
6 #include "dumpstate.h"
7 #include <libxml/parser.h>
8 #include <libxml/tree.h>
9
10 ts_vesicle *vtk2vesicle(char *filename, ts_tape *tape){
11
12     ts_uint nshell=tape->nshell;
13     ts_uint ncmax1=tape->ncxmax;
14     ts_uint ncmax2=tape->ncymax;
15     ts_uint ncmax3=tape->nczmax;
16     ts_double stepsize=tape->stepsize;
17
18     ts_uint no_vertices=5*nshell*nshell+2;
19     ts_vesicle *vesicle=init_vesicle(no_vertices,ncmax1,ncmax2,ncmax3,stepsize);
20     vesicle->nshell=nshell;
21     parse_vtk(filename, vesicle);
22     exit(1);
23     return vesicle;
24 }
25
26
27 ts_bool parse_vtk(char *filename, ts_vesicle *vesicle){
28     xmlDoc *doc;
29     xmlNode *root_element=NULL;
30     xmlNode *cur_node = NULL;
31     doc = xmlReadFile(filename, NULL, 0);
32     root_element=xmlDocGetRootElement(doc);
33     cur_node=root_element->children;
34     while(cur_node!=NULL){
35 //        fprintf(stderr,"Node name is: %s\n",cur_node->name);
36         if(strcmp((char *)cur_node->name,"UnstructuredGrid")==0) break;
37         cur_node=cur_node->next;
38     }
39
40     cur_node=cur_node->children;
41     while(cur_node!=NULL){
42 //        fprintf(stderr,"Node name is: %s\n",cur_node->name);
43         cur_node=cur_node->next;
44         if(strcmp((char *)cur_node->name,"Piece")==0) break;
45     }
46
47     cur_node=cur_node->children;
48     while(cur_node!=NULL){
49         fprintf(stderr,"Node name is: %s\n",cur_node->name);
50         cur_node=cur_node->next;
51         if(strcmp((char *)cur_node->name,"PointData")==0) vtk_index2vesicle(cur_node->children->next->children, vesicle);
52         if(strcmp((char *)cur_node->name,"Points")==0) break;
53         if(strcmp((char *)cur_node->name,"Cells")==0) break;
54         
55     }
56
57
58
59     return TS_SUCCESS;
60 }
61
62
63 ts_bool vtk_index2vesicle(xmlNode *node, ts_vesicle *vesicle){
64     //fprintf(stderr, "vsebina: %s\n",node->content);
65     ts_uint i;
66     char *token;
67     token = strtok((char *)node->content, " ");
68     for(i=0;i<vesicle->vlist->n;i++){
69         vesicle->vlist->vtx[i]->idx=atoi(token);
70         token=strtok(NULL," ");
71     }
72     //fprintf(stderr,"idx[11]=%d\n",vesicle->vlist->vtx[11]->idx);
73     return TS_SUCCESS;
74 }