ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-4/src/io/ZConsReader.cpp
Revision: 1911
Committed: Mon Jan 10 18:05:45 2005 UTC (19 years, 5 months ago) by tim
File size: 1801 byte(s)
Log Message:
more work in zconstraint

File Contents

# Content
1 #include "io/ZConsReader.hpp"
2 #include "utils/simError.h"
3 #include "utils/StringUtils.hpp"
4 namespace oopse {
5
6 ZConsReader::ZConsReader(SimInfo* info) : info_(info){
7
8 std::string zconsFileName_ = getPrefix(info_->getFinalConfigFileName()) + ".fz";
9 istream_.open(zconsFileName_.c_str());
10
11 if (!istream_){
12 std::cerr << "open " << zconsFileName_ << "error" << std::endl;
13 exit(1);
14 }
15
16 Globals* simParam = info_->getSimParams();
17 int nZconstraints = simParam->getNzConstraints();
18 ZconStamp** stamp = simParam->getZconStamp();
19 for (int i = 0; i < nZconstraints; i++){
20 allZmols_.push_back(stamp[i]->getMolIndex());
21 }
22 }
23
24 ZConsReader::~ZConsReader(){
25 istream_.close();
26 }
27
28 void ZConsReader::readNextFrame(){
29 char line[MAXBUFFERSIZE];
30 int nFixedZmol;
31 int sscanfCount;
32
33 fixedZmolData_.clear();
34
35 istream_.getline(line, MAXBUFFERSIZE);
36 sscanfCount = sscanf(line, "%lf", &curTime_);
37 if (sscanfCount != 1){
38 std::cerr << "ZConsReader Error : reading file error" << std::endl;
39 exit(1);
40 }
41
42 istream_.getline(line, MAXBUFFERSIZE);
43 sscanfCount = sscanf(line, "%d", &nFixedZmol);
44 if (sscanfCount != 1){
45 std::cerr << "ZConsReader Error : reading file error" << std::endl;
46 exit(1);
47 }
48
49 ZconsData data;
50 for(int i = 0; i < nFixedZmol; i++){
51 istream_.getline(line, MAXBUFFERSIZE);
52 sscanfCount = sscanf(line, "%d\t%lf\t%lf\t%lf", &data.zmolIndex, &data.zforce, &data.zpos,&data.zconsPos);
53 if (sscanfCount != 4){
54 std::cerr << "ZConsReader Error : reading file error" << std::endl;
55 exit(1);
56 }
57
58 fixedZmolData_.push_back(data);
59 }
60
61 }
62
63 bool ZConsReader::hasNextFrame(){
64 return istream_.peek() != EOF ? true : false;
65 }
66
67 }

Properties

Name Value
svn:executable *