1 |
tim |
1492 |
#include "visitors/OtherVisitor.hpp" |
2 |
|
|
#include "primitives/DirectionalAtom.hpp" |
3 |
|
|
#include "primitives/RigidBody.hpp" |
4 |
|
|
#include "primitives/Molecule.hpp" |
5 |
|
|
#include "brains/SimInfo.hpp" |
6 |
tim |
1625 |
namespace oopse { |
7 |
|
|
|
8 |
gezelter |
1490 |
//----------------------------------------------------------------------------// |
9 |
tim |
1818 |
void IgnoreVisitor::visit(Atom *atom) { |
10 |
|
|
if (isIgnoreType(atom->getType())) |
11 |
|
|
internalVisit(atom); |
12 |
gezelter |
1490 |
} |
13 |
|
|
|
14 |
tim |
1818 |
void IgnoreVisitor::visit(DirectionalAtom *datom) { |
15 |
|
|
if (isIgnoreType(datom->getType())) |
16 |
|
|
internalVisit(datom); |
17 |
gezelter |
1490 |
} |
18 |
|
|
|
19 |
tim |
1818 |
void IgnoreVisitor::visit(RigidBody *rb) { |
20 |
|
|
std::vector<Atom *> myAtoms; |
21 |
|
|
std::vector<Atom *>::iterator atomIter; |
22 |
|
|
AtomInfo * atomInfo; |
23 |
gezelter |
1490 |
|
24 |
tim |
1818 |
if (isIgnoreType(rb->getType())) { |
25 |
|
|
internalVisit(rb); |
26 |
gezelter |
1490 |
|
27 |
tim |
1818 |
myAtoms = rb->getAtoms(); |
28 |
|
|
|
29 |
|
|
for( atomIter = myAtoms.begin(); atomIter != myAtoms.end(); ++atomIter ) |
30 |
|
|
internalVisit(*atomIter); |
31 |
|
|
} |
32 |
gezelter |
1490 |
} |
33 |
|
|
|
34 |
tim |
1818 |
bool IgnoreVisitor::isIgnoreType(const std::string&name) { |
35 |
|
|
return itList.find(name) != itList.end() ? true : false; |
36 |
gezelter |
1490 |
} |
37 |
|
|
|
38 |
tim |
1818 |
void IgnoreVisitor::internalVisit(StuntDouble *sd) { |
39 |
|
|
GenericData *data; |
40 |
|
|
data = sd->getPropertyByName("IGNORE"); |
41 |
gezelter |
1490 |
|
42 |
tim |
1818 |
//if this stuntdoulbe is already marked as ignore just skip it |
43 |
|
|
if (data == NULL) { |
44 |
|
|
data = new GenericData; |
45 |
|
|
data->setID("IGNORE"); |
46 |
|
|
sd->addProperty(data); |
47 |
|
|
} |
48 |
gezelter |
1490 |
} |
49 |
|
|
|
50 |
tim |
1818 |
const std::string IgnoreVisitor::toString() { |
51 |
|
|
char buffer[65535]; |
52 |
|
|
std::string result; |
53 |
|
|
std::set<std::string>::iterator i; |
54 |
gezelter |
1490 |
|
55 |
tim |
1818 |
sprintf(buffer, |
56 |
|
|
"------------------------------------------------------------------\n"); |
57 |
|
|
result += buffer; |
58 |
gezelter |
1490 |
|
59 |
tim |
1818 |
sprintf(buffer, "Visitor name: %s\n", visitorName.c_str()); |
60 |
|
|
result += buffer; |
61 |
gezelter |
1490 |
|
62 |
tim |
1818 |
sprintf(buffer, "Visitor Description: ignore stuntdoubles\n"); |
63 |
|
|
result += buffer; |
64 |
gezelter |
1490 |
|
65 |
tim |
1818 |
//print the ignore type list |
66 |
|
|
sprintf(buffer, "Ignore type list contains below types:\n"); |
67 |
gezelter |
1490 |
result += buffer; |
68 |
|
|
|
69 |
tim |
1818 |
for( i = itList.begin(); i != itList.end(); ++i ) { |
70 |
|
|
sprintf(buffer, "%s\t", i->c_str()); |
71 |
|
|
result += buffer; |
72 |
|
|
} |
73 |
gezelter |
1490 |
|
74 |
tim |
1818 |
sprintf(buffer, "\n"); |
75 |
|
|
result += buffer; |
76 |
gezelter |
1490 |
|
77 |
tim |
1818 |
sprintf(buffer, |
78 |
|
|
"------------------------------------------------------------------\n"); |
79 |
|
|
result += buffer; |
80 |
|
|
|
81 |
|
|
return result; |
82 |
gezelter |
1490 |
} |
83 |
|
|
|
84 |
|
|
//----------------------------------------------------------------------------// |
85 |
|
|
|
86 |
tim |
1818 |
void WrappingVisitor::visit(Atom *atom) { |
87 |
|
|
internalVisit(atom); |
88 |
gezelter |
1490 |
} |
89 |
tim |
1818 |
|
90 |
|
|
void WrappingVisitor::visit(DirectionalAtom *datom) { |
91 |
|
|
internalVisit(datom); |
92 |
gezelter |
1490 |
} |
93 |
|
|
|
94 |
tim |
1818 |
void WrappingVisitor::visit(RigidBody *rb) { |
95 |
|
|
internalVisit(rb); |
96 |
gezelter |
1490 |
} |
97 |
|
|
|
98 |
tim |
1818 |
void WrappingVisitor::internalVisit(StuntDouble *sd) { |
99 |
|
|
GenericData * data; |
100 |
|
|
AtomData * atomData; |
101 |
|
|
AtomInfo * atomInfo; |
102 |
|
|
std::vector<AtomInfo *>::iterator i; |
103 |
gezelter |
1490 |
|
104 |
tim |
1818 |
data = sd->getPropertyByName("ATOMDATA"); |
105 |
gezelter |
1490 |
|
106 |
tim |
1818 |
if (data != NULL) { |
107 |
|
|
atomData = dynamic_cast<AtomData *>(data); |
108 |
gezelter |
1490 |
|
109 |
tim |
1818 |
if (atomData == NULL) |
110 |
|
|
return; |
111 |
|
|
} else |
112 |
|
|
return; |
113 |
|
|
|
114 |
|
|
Snapshot* currSnapshot = info->getSnapshotManager()->getCurrentSnapshot(); |
115 |
|
|
|
116 |
|
|
for( atomInfo = atomData->beginAtomInfo(i); atomInfo; atomInfo = atomData->nextAtomInfo(i) ) { |
117 |
|
|
currSnapshot->wrapVector(atomInfo->pos); |
118 |
|
|
} |
119 |
gezelter |
1490 |
} |
120 |
|
|
|
121 |
tim |
1818 |
const std::string WrappingVisitor::toString() { |
122 |
|
|
char buffer[65535]; |
123 |
|
|
std::string result; |
124 |
gezelter |
1490 |
|
125 |
tim |
1818 |
sprintf(buffer, |
126 |
|
|
"------------------------------------------------------------------\n"); |
127 |
|
|
result += buffer; |
128 |
gezelter |
1490 |
|
129 |
tim |
1818 |
sprintf(buffer, "Visitor name: %s\n", visitorName.c_str()); |
130 |
|
|
result += buffer; |
131 |
gezelter |
1490 |
|
132 |
tim |
1818 |
sprintf(buffer, |
133 |
|
|
"Visitor Description: wrapping atoms back to periodic box\n"); |
134 |
|
|
result += buffer; |
135 |
|
|
|
136 |
|
|
sprintf(buffer, |
137 |
|
|
"------------------------------------------------------------------\n"); |
138 |
|
|
result += buffer; |
139 |
|
|
|
140 |
|
|
return result; |
141 |
gezelter |
1490 |
} |
142 |
|
|
|
143 |
|
|
//----------------------------------------------------------------------------// |
144 |
|
|
|
145 |
tim |
1818 |
ReplicateVisitor::ReplicateVisitor(SimInfo *info, Vector3i opt) : |
146 |
|
|
BaseVisitor() { |
147 |
|
|
this->info = info; |
148 |
|
|
visitorName = "ReplicateVisitor"; |
149 |
|
|
this->replicateOpt = opt; |
150 |
|
|
|
151 |
|
|
//generate the replicate directions |
152 |
|
|
for( int i = 0; i <= replicateOpt[0]; i++ ) { |
153 |
|
|
for( int j = 0; j <= replicateOpt[1]; j++ ) { |
154 |
|
|
for( int k = 0; k <= replicateOpt[2]; k++ ) { |
155 |
|
|
//skip original frame |
156 |
|
|
if (i == 0 && j == 0 && k == 0) { |
157 |
|
|
continue; |
158 |
|
|
} else { |
159 |
|
|
dir.push_back(Vector3i(i, j, k)); |
160 |
|
|
} |
161 |
|
|
} |
162 |
|
|
} |
163 |
|
|
} |
164 |
|
|
|
165 |
gezelter |
1490 |
} |
166 |
tim |
1818 |
|
167 |
|
|
void ReplicateVisitor::visit(Atom *atom) { |
168 |
|
|
internalVisit(atom); |
169 |
gezelter |
1490 |
} |
170 |
tim |
1818 |
|
171 |
|
|
void ReplicateVisitor::visit(DirectionalAtom *datom) { |
172 |
|
|
internalVisit(datom); |
173 |
gezelter |
1490 |
} |
174 |
|
|
|
175 |
tim |
1818 |
void ReplicateVisitor::visit(RigidBody *rb) { |
176 |
|
|
internalVisit(rb); |
177 |
gezelter |
1490 |
} |
178 |
|
|
|
179 |
tim |
1818 |
void ReplicateVisitor::internalVisit(StuntDouble *sd) { |
180 |
|
|
GenericData * data; |
181 |
|
|
AtomData * atomData; |
182 |
gezelter |
1490 |
|
183 |
tim |
1818 |
//if there is not atom data, just skip it |
184 |
|
|
data = sd->getPropertyByName("ATOMDATA"); |
185 |
gezelter |
1490 |
|
186 |
tim |
1818 |
if (data != NULL) { |
187 |
|
|
atomData = dynamic_cast<AtomData *>(data); |
188 |
gezelter |
1490 |
|
189 |
tim |
1818 |
if (atomData == NULL) { |
190 |
|
|
return; |
191 |
|
|
} |
192 |
|
|
} else { |
193 |
|
|
return; |
194 |
|
|
} |
195 |
|
|
|
196 |
|
|
Snapshot* currSnapshot = info->getSnapshotManager()->getCurrentSnapshot(); |
197 |
|
|
Mat3x3d box = currSnapshot->getHmat(); |
198 |
|
|
|
199 |
|
|
std::vector<AtomInfo *> atomInfoList = atomData->getData(); |
200 |
|
|
|
201 |
|
|
replicate(atomInfoList, atomData, box); |
202 |
gezelter |
1490 |
} |
203 |
|
|
|
204 |
tim |
1818 |
void ReplicateVisitor::replicate(std::vector<AtomInfo *>&infoList, AtomData *data, const Mat3x3d& box) { |
205 |
|
|
AtomInfo* newAtomInfo; |
206 |
|
|
std::vector<Vector3i>::iterator dirIter; |
207 |
|
|
std::vector<AtomInfo *>::iterator i; |
208 |
gezelter |
1490 |
|
209 |
tim |
1818 |
for( dirIter = dir.begin(); dirIter != dir.end(); ++dirIter ) { |
210 |
|
|
for( i = infoList.begin(); i != infoList.end(); i++ ) { |
211 |
|
|
newAtomInfo = new AtomInfo(); |
212 |
|
|
*newAtomInfo = *(*i); |
213 |
gezelter |
1490 |
|
214 |
tim |
1818 |
for( int j = 0; j < 3; j++ ) |
215 |
|
|
newAtomInfo->pos[j] += (*dirIter)[0]*box(j, 0) + (*dirIter)[1]*box(j, 1) + (*dirIter)[2]*box(j, 2); |
216 |
|
|
|
217 |
|
|
data->addAtomInfo(newAtomInfo); |
218 |
|
|
} |
219 |
|
|
} // end for(dirIter) |
220 |
gezelter |
1490 |
} |
221 |
|
|
|
222 |
tim |
1818 |
const std::string ReplicateVisitor::toString() { |
223 |
|
|
char buffer[65535]; |
224 |
|
|
std::string result; |
225 |
|
|
std::set<std::string>::iterator i; |
226 |
gezelter |
1490 |
|
227 |
tim |
1818 |
sprintf(buffer, |
228 |
|
|
"------------------------------------------------------------------\n"); |
229 |
|
|
result += buffer; |
230 |
gezelter |
1490 |
|
231 |
tim |
1818 |
sprintf(buffer, "Visitor name: %s\n", visitorName.c_str()); |
232 |
|
|
result += buffer; |
233 |
gezelter |
1490 |
|
234 |
tim |
1818 |
sprintf(buffer, |
235 |
|
|
"Visitor Description: replicate the atoms in different direction\n"); |
236 |
|
|
result += buffer; |
237 |
gezelter |
1490 |
|
238 |
tim |
1818 |
//print the replicate direction |
239 |
|
|
sprintf(buffer, "repeatX = %d:\n", replicateOpt[0]); |
240 |
|
|
result += buffer; |
241 |
gezelter |
1490 |
|
242 |
tim |
1818 |
sprintf(buffer, "repeatY = %d:\n", replicateOpt[1]); |
243 |
|
|
result += buffer; |
244 |
gezelter |
1490 |
|
245 |
tim |
1818 |
sprintf(buffer, "repeatZ = %d:\n", replicateOpt[2]); |
246 |
|
|
result += buffer; |
247 |
gezelter |
1490 |
|
248 |
tim |
1818 |
sprintf(buffer, |
249 |
|
|
"------------------------------------------------------------------\n"); |
250 |
|
|
result += buffer; |
251 |
|
|
|
252 |
|
|
return result; |
253 |
gezelter |
1490 |
} |
254 |
|
|
|
255 |
|
|
//----------------------------------------------------------------------------// |
256 |
|
|
|
257 |
tim |
1818 |
XYZVisitor::XYZVisitor(SimInfo *info, bool printDipole) : |
258 |
|
|
BaseVisitor() { |
259 |
|
|
this->info = info; |
260 |
|
|
visitorName = "XYZVisitor"; |
261 |
|
|
this->printDipole = printDipole; |
262 |
gezelter |
1490 |
} |
263 |
|
|
|
264 |
tim |
1818 |
void XYZVisitor::visit(Atom *atom) { |
265 |
|
|
if (!isIgnore(atom)) |
266 |
|
|
internalVisit(atom); |
267 |
gezelter |
1490 |
} |
268 |
|
|
|
269 |
tim |
1818 |
void XYZVisitor::visit(DirectionalAtom *datom) { |
270 |
|
|
if (!isIgnore(datom)) |
271 |
|
|
internalVisit(datom); |
272 |
gezelter |
1490 |
} |
273 |
|
|
|
274 |
tim |
1818 |
void XYZVisitor::visit(RigidBody *rb) { |
275 |
|
|
if (!isIgnore(rb)) |
276 |
|
|
internalVisit(rb); |
277 |
gezelter |
1490 |
} |
278 |
|
|
|
279 |
tim |
1818 |
void XYZVisitor::internalVisit(StuntDouble *sd) { |
280 |
|
|
GenericData * data; |
281 |
|
|
AtomData * atomData; |
282 |
|
|
AtomInfo * atomInfo; |
283 |
|
|
std::vector<AtomInfo *>::iterator i; |
284 |
|
|
char buffer[1024]; |
285 |
gezelter |
1490 |
|
286 |
tim |
1818 |
//if there is not atom data, just skip it |
287 |
|
|
data = sd->getPropertyByName("ATOMDATA"); |
288 |
gezelter |
1490 |
|
289 |
tim |
1818 |
if (data != NULL) { |
290 |
|
|
atomData = dynamic_cast<AtomData *>(data); |
291 |
gezelter |
1490 |
|
292 |
tim |
1818 |
if (atomData == NULL) |
293 |
|
|
return; |
294 |
|
|
} else |
295 |
|
|
return; |
296 |
gezelter |
1490 |
|
297 |
tim |
1818 |
for( atomInfo = atomData->beginAtomInfo(i); atomInfo; |
298 |
|
|
atomInfo = atomData->nextAtomInfo(i) ) { |
299 |
|
|
if (printDipole) |
300 |
|
|
sprintf(buffer, |
301 |
|
|
"%s%15.8f%15.8f%15.8f%15.8f%15.8f%15.8f", |
302 |
|
|
atomInfo->AtomType.c_str(), |
303 |
|
|
atomInfo->pos[0], |
304 |
|
|
atomInfo->pos[1], |
305 |
|
|
atomInfo->pos[2], |
306 |
|
|
atomInfo->dipole[0], |
307 |
|
|
atomInfo->dipole[1], |
308 |
|
|
atomInfo->dipole[2]); else |
309 |
|
|
sprintf(buffer, "%s%15.8f%15.8f%15.8f", |
310 |
|
|
atomInfo->AtomType.c_str(), atomInfo->pos[0], |
311 |
|
|
atomInfo->pos[1], atomInfo->pos[2]); |
312 |
|
|
|
313 |
|
|
frame.push_back(buffer); |
314 |
|
|
} |
315 |
gezelter |
1490 |
} |
316 |
|
|
|
317 |
tim |
1818 |
bool XYZVisitor::isIgnore(StuntDouble *sd) { |
318 |
|
|
GenericData *data; |
319 |
|
|
|
320 |
|
|
data = sd->getPropertyByName("IGNORE"); |
321 |
|
|
return data == NULL ? false : true; |
322 |
gezelter |
1490 |
} |
323 |
|
|
|
324 |
tim |
1818 |
void XYZVisitor::writeFrame(ostream &outStream) { |
325 |
|
|
std::vector<std::string>::iterator i; |
326 |
|
|
char buffer[1024]; |
327 |
gezelter |
1490 |
|
328 |
tim |
1818 |
if (frame.size() == 0) |
329 |
|
|
cerr << "Current Frame does not contain any atoms" << endl; |
330 |
gezelter |
1490 |
|
331 |
tim |
1818 |
//total number of atoms |
332 |
|
|
outStream << frame.size() << endl; |
333 |
gezelter |
1490 |
|
334 |
tim |
1818 |
//write comment line |
335 |
|
|
Snapshot* currSnapshot = info->getSnapshotManager()->getCurrentSnapshot(); |
336 |
|
|
Mat3x3d box = currSnapshot->getHmat(); |
337 |
|
|
|
338 |
|
|
sprintf(buffer, |
339 |
|
|
"%15.8f;%15.8f%15.8f%15.8f;%15.8f%15.8f%15.8f;%15.8f%15.8f%15.8f", |
340 |
|
|
currSnapshot->getTime(), |
341 |
|
|
box(0, 0), box(0, 1), box(0, 2), |
342 |
|
|
box(1, 0), box(1, 1), box(1, 2), |
343 |
|
|
box(2, 0), box(2, 1), box(2, 2)); |
344 |
gezelter |
1490 |
|
345 |
tim |
1818 |
outStream << buffer << endl; |
346 |
gezelter |
1490 |
|
347 |
tim |
1818 |
for( i = frame.begin(); i != frame.end(); ++i ) |
348 |
|
|
outStream << *i << endl; |
349 |
gezelter |
1490 |
} |
350 |
|
|
|
351 |
tim |
1818 |
const std::string XYZVisitor::toString() { |
352 |
|
|
char buffer[65535]; |
353 |
|
|
std::string result; |
354 |
gezelter |
1490 |
|
355 |
tim |
1818 |
sprintf(buffer, |
356 |
|
|
"------------------------------------------------------------------\n"); |
357 |
|
|
result += buffer; |
358 |
gezelter |
1490 |
|
359 |
tim |
1818 |
sprintf(buffer, "Visitor name: %s\n", visitorName.c_str()); |
360 |
|
|
result += buffer; |
361 |
gezelter |
1490 |
|
362 |
tim |
1818 |
sprintf(buffer, |
363 |
|
|
"Visitor Description: assemble the atom data and output xyz file\n"); |
364 |
|
|
result += buffer; |
365 |
|
|
|
366 |
|
|
sprintf(buffer, |
367 |
|
|
"------------------------------------------------------------------\n"); |
368 |
|
|
result += buffer; |
369 |
|
|
|
370 |
|
|
return result; |
371 |
gezelter |
1490 |
} |
372 |
|
|
|
373 |
|
|
//----------------------------------------------------------------------------// |
374 |
|
|
|
375 |
tim |
1818 |
void PrepareVisitor::internalVisit(Atom *atom) { |
376 |
|
|
GenericData *data; |
377 |
|
|
AtomData * atomData; |
378 |
gezelter |
1490 |
|
379 |
tim |
1818 |
//if visited property is existed, remove it |
380 |
|
|
data = atom->getPropertyByName("VISITED"); |
381 |
gezelter |
1490 |
|
382 |
tim |
1818 |
if (data != NULL) { |
383 |
|
|
atom->removeProperty("VISITED"); |
384 |
|
|
} |
385 |
|
|
|
386 |
|
|
//remove atomdata |
387 |
|
|
data = atom->getPropertyByName("ATOMDATA"); |
388 |
|
|
|
389 |
|
|
if (data != NULL) { |
390 |
|
|
atomData = dynamic_cast<AtomData *>(data); |
391 |
|
|
|
392 |
|
|
if (atomData != NULL) |
393 |
|
|
atom->removeProperty("ATOMDATA"); |
394 |
|
|
} |
395 |
gezelter |
1490 |
} |
396 |
|
|
|
397 |
tim |
1818 |
void PrepareVisitor::internalVisit(RigidBody *rb) { |
398 |
|
|
GenericData* data; |
399 |
|
|
AtomData* atomData; |
400 |
|
|
std::vector<Atom *> myAtoms; |
401 |
|
|
std::vector<Atom *>::iterator atomIter; |
402 |
gezelter |
1490 |
|
403 |
tim |
1818 |
//if visited property is existed, remove it |
404 |
|
|
data = rb->getPropertyByName("VISITED"); |
405 |
gezelter |
1490 |
|
406 |
tim |
1818 |
if (data != NULL) { |
407 |
|
|
rb->removeProperty("VISITED"); |
408 |
|
|
} |
409 |
|
|
|
410 |
|
|
//remove atomdata |
411 |
|
|
data = rb->getPropertyByName("ATOMDATA"); |
412 |
|
|
|
413 |
|
|
if (data != NULL) { |
414 |
|
|
atomData = dynamic_cast<AtomData *>(data); |
415 |
|
|
|
416 |
|
|
if (atomData != NULL) |
417 |
|
|
rb->removeProperty("ATOMDATA"); |
418 |
|
|
} |
419 |
|
|
|
420 |
|
|
myAtoms = rb->getAtoms(); |
421 |
|
|
|
422 |
|
|
for( atomIter = myAtoms.begin(); atomIter != myAtoms.end(); ++atomIter ) |
423 |
|
|
internalVisit(*atomIter); |
424 |
gezelter |
1490 |
} |
425 |
|
|
|
426 |
tim |
1818 |
const std::string PrepareVisitor::toString() { |
427 |
|
|
char buffer[65535]; |
428 |
|
|
std::string result; |
429 |
gezelter |
1490 |
|
430 |
tim |
1818 |
sprintf(buffer, |
431 |
|
|
"------------------------------------------------------------------\n"); |
432 |
|
|
result += buffer; |
433 |
gezelter |
1490 |
|
434 |
tim |
1818 |
sprintf(buffer, "Visitor name: %s", visitorName.c_str()); |
435 |
|
|
result += buffer; |
436 |
gezelter |
1490 |
|
437 |
tim |
1818 |
sprintf(buffer, |
438 |
|
|
"Visitor Description: prepare for operation of other vistors\n"); |
439 |
|
|
result += buffer; |
440 |
gezelter |
1490 |
|
441 |
tim |
1818 |
sprintf(buffer, |
442 |
|
|
"------------------------------------------------------------------\n"); |
443 |
|
|
result += buffer; |
444 |
|
|
|
445 |
|
|
return result; |
446 |
gezelter |
1490 |
} |
447 |
|
|
|
448 |
|
|
//----------------------------------------------------------------------------// |
449 |
|
|
|
450 |
tim |
1818 |
WaterTypeVisitor::WaterTypeVisitor() { |
451 |
|
|
visitorName = "WaterTypeVisitor"; |
452 |
|
|
waterTypeList.insert("TIP3P_RB_0"); |
453 |
|
|
waterTypeList.insert("TIP4P_RB_0"); |
454 |
|
|
waterTypeList.insert("TIP5P_RB_0"); |
455 |
|
|
waterTypeList.insert("SPCE_RB_0"); |
456 |
gezelter |
1490 |
} |
457 |
|
|
|
458 |
tim |
1818 |
void WaterTypeVisitor::visit(RigidBody *rb) { |
459 |
|
|
std::string rbName; |
460 |
|
|
std::vector<Atom *> myAtoms; |
461 |
|
|
std::vector<Atom *>::iterator atomIter; |
462 |
|
|
GenericData* data; |
463 |
|
|
AtomData* atomData; |
464 |
|
|
AtomInfo* atomInfo; |
465 |
|
|
std::vector<AtomInfo *>::iterator i; |
466 |
gezelter |
1490 |
|
467 |
tim |
1818 |
rbName = rb->getType(); |
468 |
gezelter |
1490 |
|
469 |
tim |
1818 |
if (waterTypeList.find(rbName) != waterTypeList.end()) { |
470 |
|
|
myAtoms = rb->getAtoms(); |
471 |
gezelter |
1490 |
|
472 |
tim |
1818 |
for( atomIter = myAtoms.begin(); atomIter != myAtoms.end(); |
473 |
|
|
++atomIter ) { |
474 |
|
|
data = (*atomIter)->getPropertyByName("ATOMDATA"); |
475 |
gezelter |
1490 |
|
476 |
tim |
1818 |
if (data != NULL) { |
477 |
|
|
atomData = dynamic_cast<AtomData *>(data); |
478 |
gezelter |
1490 |
|
479 |
tim |
1818 |
if (atomData == NULL) |
480 |
|
|
continue; |
481 |
|
|
} else |
482 |
|
|
continue; |
483 |
|
|
|
484 |
|
|
for( atomInfo = atomData->beginAtomInfo(i); atomInfo; |
485 |
|
|
atomInfo = atomData->nextAtomInfo(i) ) { |
486 |
|
|
replaceType(atomInfo->AtomType); |
487 |
|
|
} //end for(atomInfo) |
488 |
|
|
} //end for(atomIter) |
489 |
|
|
} //end if (waterTypeList.find(rbName) != waterTypeList.end()) |
490 |
gezelter |
1490 |
} |
491 |
|
|
|
492 |
tim |
1818 |
void WaterTypeVisitor::replaceType(std::string&atomType) { |
493 |
|
|
atomType = atomType.substr(0, atomType.find('_')); |
494 |
gezelter |
1490 |
} |
495 |
|
|
|
496 |
tim |
1818 |
const std::string WaterTypeVisitor::toString() { |
497 |
|
|
char buffer[65535]; |
498 |
|
|
std::string result; |
499 |
gezelter |
1490 |
|
500 |
tim |
1818 |
sprintf(buffer, |
501 |
|
|
"------------------------------------------------------------------\n"); |
502 |
|
|
result += buffer; |
503 |
gezelter |
1490 |
|
504 |
tim |
1818 |
sprintf(buffer, "Visitor name: %s\n", visitorName.c_str()); |
505 |
|
|
result += buffer; |
506 |
gezelter |
1490 |
|
507 |
tim |
1818 |
sprintf(buffer, |
508 |
|
|
"Visitor Description: Replace the atom type in water model\n"); |
509 |
|
|
result += buffer; |
510 |
gezelter |
1490 |
|
511 |
tim |
1818 |
sprintf(buffer, |
512 |
|
|
"------------------------------------------------------------------\n"); |
513 |
|
|
result += buffer; |
514 |
|
|
|
515 |
|
|
return result; |
516 |
gezelter |
1490 |
} |
517 |
|
|
|
518 |
tim |
1818 |
} //namespace oopse |