| 51 | 
  | 
  readHeader();   | 
| 52 | 
  | 
} | 
| 53 | 
  | 
 | 
| 54 | 
+ | 
ZConsReader::ZConsReader(const string& filename){ | 
| 55 | 
+ | 
  istream = new ifstream(zconsFileName.c_str()); | 
| 56 | 
+ | 
 | 
| 57 | 
+ | 
  if (!istream){ | 
| 58 | 
+ | 
    cerr << "open " << filename << "error" << endl; | 
| 59 | 
+ | 
    exit(1); | 
| 60 | 
+ | 
  } | 
| 61 | 
+ | 
   | 
| 62 | 
+ | 
  readHeader();   | 
| 63 | 
+ | 
} | 
| 64 | 
+ | 
 | 
| 65 | 
  | 
ZConsReader::~ZConsReader(){ | 
| 66 | 
  | 
  istream->close(); | 
| 67 | 
  | 
} | 
| 129 | 
  | 
    zconsPos.push_back(zmolPos); | 
| 130 | 
  | 
  } | 
| 131 | 
  | 
 | 
| 132 | 
+ | 
  curZPos.resize(nZMol); | 
| 133 | 
+ | 
  curFZ.resize(nZMol); | 
| 134 | 
  | 
} | 
| 135 | 
  | 
 | 
| 136 | 
  | 
void ZConsReader::readNextFrame(){ | 
| 137 | 
  | 
  const int MAXBUFFERSIZE = 2000; | 
| 138 | 
  | 
  char line[MAXBUFFERSIZE];   | 
| 139 | 
  | 
  int tempNZMol; | 
| 127 | 
– | 
  int zmolIndex; | 
| 128 | 
– | 
  float zmolPos; | 
| 129 | 
– | 
  float zmolForce; | 
| 140 | 
  | 
  int sscanfCount; | 
| 141 | 
< | 
 | 
| 141 | 
> | 
  int tempIndex; | 
| 142 | 
> | 
  float tempCurTime; | 
| 143 | 
> | 
  float tempFZ; | 
| 144 | 
> | 
  float tempCurZPos; | 
| 145 | 
> | 
  float tempZconsPos; | 
| 146 | 
> | 
   | 
| 147 | 
  | 
  istream->getline(line, MAXBUFFERSIZE); | 
| 148 | 
< | 
  sscanfCount = sscanf(line, "%lf", &curTime); | 
| 148 | 
> | 
  sscanfCount = sscanf(line, "%f", &tempCurTime); | 
| 149 | 
  | 
  if (sscanfCount != 1){ | 
| 150 | 
  | 
    cerr << "ZConsReader Error : reading file error" << endl; | 
| 151 | 
  | 
    exit(1); | 
| 152 | 
  | 
  } | 
| 153 | 
+ | 
  curTime = tempCurTime; | 
| 154 | 
  | 
   | 
| 155 | 
  | 
  istream->getline(line, MAXBUFFERSIZE); | 
| 156 | 
  | 
  sscanfCount = sscanf(line, "%d", &tempNZMol); | 
| 166 | 
  | 
 | 
| 167 | 
  | 
  for(int i = 0; i < nZMol; i++){ | 
| 168 | 
  | 
    istream->getline(line, MAXBUFFERSIZE); | 
| 169 | 
< | 
    sscanfCount = sscanf(line, "%d\t%f\t%f", &zmolIndex, &zmolForce, &zmolPos); | 
| 170 | 
< | 
    if (sscanfCount != 3){ | 
| 169 | 
> | 
    sscanfCount = sscanf(line, "%d\t%f\t%f\t%f", &tempIndex, &tempFZ, &tempCurZPos,&tempZconsPos); | 
| 170 | 
> | 
    if (sscanfCount != 4){ | 
| 171 | 
  | 
      cerr << "ZConsReader Error : reading file error" << endl; | 
| 172 | 
  | 
      exit(1); | 
| 173 | 
  | 
    } | 
| 174 | 
+ | 
 | 
| 175 | 
+ | 
    index[i] = tempIndex; | 
| 176 | 
+ | 
    curFZ[i] = tempFZ; | 
| 177 | 
+ | 
    curZPos[i]= tempCurZPos; | 
| 178 | 
+ | 
    zconsPos[i] = tempZconsPos; | 
| 179 | 
  | 
  } | 
| 180 | 
  | 
 | 
| 181 | 
  | 
} |