1 |
< |
#include "visitors/ZconsVisitor.hpp" |
1 |
> |
|
2 |
|
#include <cmath> |
3 |
+ |
#include "visitors/ZconsVisitor.hpp" |
4 |
+ |
#include "primitives/Molecule.hpp" |
5 |
|
|
6 |
|
namespace oopse { |
7 |
|
|
11 |
|
ZConsParaData* zConsParaData; |
12 |
|
StringGenericData* filename; |
13 |
|
DoubleGenericData* sampleTime; |
14 |
< |
vector<ZConsParaItem>* parameters; |
14 |
> |
std::vector<ZConsParaItem>* parameters; |
15 |
|
|
16 |
|
this->info = info; |
17 |
|
visitorName = "ZConsVisitor"; |
80 |
|
parameters = zConsParaData->getData(); |
81 |
|
for(i = parameters->begin(); i != parameters->end(); ++i){ |
82 |
|
|
83 |
< |
mol = findZconsMol(i->zconsIndex); |
83 |
> |
mol = info->getMoleculeByGlobalIndex(i->zconsIndex); |
84 |
|
if(mol != NULL) |
85 |
|
zconsMol.push_back(mol); |
86 |
|
|
131 |
|
} |
132 |
|
|
133 |
|
void ZConsVisitor::visit(Atom* atom){ |
134 |
< |
string prefix; |
134 |
> |
std::string prefix; |
135 |
|
if(isZconstraint(atom->getLocalIndex(), prefix)) |
136 |
|
internalVisit(atom, prefix); |
137 |
|
} |
138 |
|
|
139 |
|
void ZConsVisitor::visit(DirectionalAtom* datom){ |
140 |
< |
string prefix; |
140 |
> |
std::string prefix; |
141 |
|
|
142 |
|
if(isZconstraint(datom->getLocalIndex(), prefix)) |
143 |
|
internalVisit(datom, prefix); |
144 |
|
} |
145 |
|
|
146 |
|
void ZConsVisitor::visit(RigidBody* rb){ |
147 |
< |
string prefix; |
148 |
< |
vector<Atom*> atoms; |
147 |
> |
std::string prefix; |
148 |
> |
std::vector<Atom*> atoms; |
149 |
|
|
150 |
|
atoms = rb->getAtoms(); |
151 |
|
|
153 |
|
internalVisit(rb, prefix); |
154 |
|
} |
155 |
|
|
154 |
– |
Molecule* ZConsVisitor::findZconsMol(int index){ |
155 |
– |
Molecule* mols; |
156 |
– |
mols = info->molecules; |
157 |
– |
for(int i =0; i < info->n_mol; i++) |
158 |
– |
if(index == mols[i].getGlobalIndex()) |
159 |
– |
return &mols[i]; |
160 |
– |
|
161 |
– |
return NULL; |
162 |
– |
} |
163 |
– |
|
156 |
|
void ZConsVisitor::update(){ |
157 |
|
Molecule* mol; |
158 |
|
Vector3d com; |
159 |
|
ZConsState state; |
168 |
– |
//Atom** atoms; |
169 |
– |
//int natoms; |
170 |
– |
|
171 |
– |
getZconsPos(info->currentTime); |
160 |
|
|
161 |
+ |
Snapshot* currSnapshot = info->getSnapshotManager()->getCurrentSnapshot(); |
162 |
+ |
getZconsPos(currSnapshot->getTime()); |
163 |
+ |
|
164 |
|
for(size_t i = 0; i < zconsMol.size(); i++){ |
165 |
|
com = zconsMol[i]->getCom(); |
166 |
|
|
185 |
|
|
186 |
|
void ZConsVisitor::getZconsPos(double time){ |
187 |
|
|
188 |
< |
vector<double> tempPos; |
189 |
< |
vector<double> prevPos; |
188 |
> |
std::vector<double> tempPos; |
189 |
> |
std::vector<double> prevPos; |
190 |
|
double tempTime; |
191 |
|
|
192 |
|
while(true){ |
207 |
|
GenericData* data; |
208 |
|
AtomData* atomData; |
209 |
|
AtomInfo* atomInfo; |
210 |
< |
vector<AtomInfo*>::iterator iter; |
210 |
> |
std::vector<AtomInfo*>::iterator iter; |
211 |
|
|
212 |
|
|
213 |
|
//if there is not atom data, just skip it |
226 |
|
|
227 |
|
|
228 |
|
bool ZConsVisitor::isZconstraint(int index, string& prefix){ |
229 |
< |
map<int, ZConsState>::iterator i; |
230 |
< |
string prefixString[] = {"ZF", "ZM"}; |
229 |
> |
std::map<int, ZConsState>::iterator i; |
230 |
> |
std::string prefixString[] = {"ZF", "ZM"}; |
231 |
|
|
232 |
|
i = zconsState.find(index); |
233 |
|
if(i !=zconsState.end()){ |
240 |
|
} |
241 |
|
} |
242 |
|
|
243 |
< |
const string ZConsVisitor::toString(){ |
243 |
> |
const std::string ZConsVisitor::toString(){ |
244 |
|
char buffer[65535]; |
245 |
< |
string result; |
245 |
> |
std::string result; |
246 |
|
|
247 |
|
sprintf(buffer ,"------------------------------------------------------------------\n"); |
248 |
|
result += buffer; |