6 |
|
|
7 |
|
GenericData* data; |
8 |
|
StringData* filename; |
9 |
– |
|
10 |
– |
assert(info != NULL); |
11 |
– |
|
9 |
|
this->info = info; |
10 |
|
|
11 |
|
//retrieve output filename of z force |
48 |
|
readHeader(); |
49 |
|
} |
50 |
|
|
51 |
+ |
ZConsReader::ZConsReader(const string& filename){ |
52 |
+ |
istream = new ifstream(zconsFileName.c_str()); |
53 |
+ |
|
54 |
+ |
if (!istream){ |
55 |
+ |
cerr << "open " << filename << "error" << endl; |
56 |
+ |
exit(1); |
57 |
+ |
} |
58 |
+ |
|
59 |
+ |
readHeader(); |
60 |
+ |
} |
61 |
+ |
|
62 |
|
ZConsReader::~ZConsReader(){ |
63 |
|
istream->close(); |
64 |
|
} |
126 |
|
zconsPos.push_back(zmolPos); |
127 |
|
} |
128 |
|
|
129 |
+ |
curZPos.resize(nZMol); |
130 |
+ |
curFZ.resize(nZMol); |
131 |
|
} |
132 |
|
|
133 |
|
void ZConsReader::readNextFrame(){ |
134 |
|
const int MAXBUFFERSIZE = 2000; |
135 |
|
char line[MAXBUFFERSIZE]; |
136 |
|
int tempNZMol; |
127 |
– |
int zmolIndex; |
128 |
– |
float zmolPos; |
129 |
– |
float zmolForce; |
137 |
|
int sscanfCount; |
138 |
< |
|
138 |
> |
int tempIndex; |
139 |
> |
float tempCurTime; |
140 |
> |
float tempFZ; |
141 |
> |
float tempCurZPos; |
142 |
> |
float tempZconsPos; |
143 |
> |
|
144 |
|
istream->getline(line, MAXBUFFERSIZE); |
145 |
< |
sscanfCount = sscanf(line, "%f", curTime); |
145 |
> |
sscanfCount = sscanf(line, "%f", &tempCurTime); |
146 |
|
if (sscanfCount != 1){ |
147 |
|
cerr << "ZConsReader Error : reading file error" << endl; |
148 |
|
exit(1); |
149 |
|
} |
150 |
+ |
curTime = tempCurTime; |
151 |
|
|
152 |
|
istream->getline(line, MAXBUFFERSIZE); |
153 |
|
sscanfCount = sscanf(line, "%d", &tempNZMol); |
163 |
|
|
164 |
|
for(int i = 0; i < nZMol; i++){ |
165 |
|
istream->getline(line, MAXBUFFERSIZE); |
166 |
< |
sscanfCount = sscanf(line, "%d\t%f\t%f", &zmolIndex, &zmolForce, &zmolPos); |
167 |
< |
if (sscanfCount != 3){ |
166 |
> |
sscanfCount = sscanf(line, "%d\t%f\t%f\t%f", &tempIndex, &tempFZ, &tempCurZPos,&tempZconsPos); |
167 |
> |
if (sscanfCount != 4){ |
168 |
|
cerr << "ZConsReader Error : reading file error" << endl; |
169 |
|
exit(1); |
170 |
|
} |
171 |
+ |
|
172 |
+ |
index[i] = tempIndex; |
173 |
+ |
curFZ[i] = tempFZ; |
174 |
+ |
curZPos[i]= tempCurZPos; |
175 |
+ |
zconsPos[i] = tempZconsPos; |
176 |
|
} |
177 |
|
|
178 |
|
} |