5 |
|
* non-exclusive, royalty free, license to use, modify and |
6 |
|
* redistribute this software in source and binary code form, provided |
7 |
|
* that the following conditions are met: |
8 |
– |
* |
8 |
|
* 1. Acknowledgement of the program authors must be made in any |
9 |
|
* publication of scientific results based in part on use of the |
10 |
|
* program. An acceptable form of acknowledgement is citation of |
45 |
|
#include "brains/SimInfo.hpp" |
46 |
|
namespace oopse { |
47 |
|
|
48 |
< |
//----------------------------------------------------------------------------// |
49 |
< |
void IgnoreVisitor::visit(Atom *atom) { |
50 |
< |
if (isIgnoreType(atom->getType())) |
52 |
< |
internalVisit(atom); |
53 |
< |
} |
48 |
> |
void WrappingVisitor::visit(Atom *atom) { |
49 |
> |
internalVisit(atom); |
50 |
> |
} |
51 |
|
|
52 |
< |
void IgnoreVisitor::visit(DirectionalAtom *datom) { |
53 |
< |
if (isIgnoreType(datom->getType())) |
54 |
< |
internalVisit(datom); |
58 |
< |
} |
52 |
> |
void WrappingVisitor::visit(DirectionalAtom *datom) { |
53 |
> |
internalVisit(datom); |
54 |
> |
} |
55 |
|
|
56 |
< |
void IgnoreVisitor::visit(RigidBody *rb) { |
57 |
< |
std::vector<Atom *> myAtoms; |
58 |
< |
std::vector<Atom *>::iterator atomIter; |
63 |
< |
AtomInfo * atomInfo; |
56 |
> |
void WrappingVisitor::visit(RigidBody *rb) { |
57 |
> |
internalVisit(rb); |
58 |
> |
} |
59 |
|
|
60 |
< |
if (isIgnoreType(rb->getType())) { |
66 |
< |
internalVisit(rb); |
67 |
< |
|
68 |
< |
myAtoms = rb->getAtoms(); |
69 |
< |
|
70 |
< |
for( atomIter = myAtoms.begin(); atomIter != myAtoms.end(); ++atomIter ) |
71 |
< |
internalVisit(*atomIter); |
72 |
< |
} |
73 |
< |
} |
74 |
< |
|
75 |
< |
bool IgnoreVisitor::isIgnoreType(const std::string&name) { |
76 |
< |
return itList.find(name) != itList.end() ? true : false; |
77 |
< |
} |
78 |
< |
|
79 |
< |
void IgnoreVisitor::internalVisit(StuntDouble *sd) { |
80 |
< |
info->getSelectionManager()->clearSelection(sd); |
81 |
< |
//GenericData *data; |
82 |
< |
//data = sd->getPropertyByName("IGNORE"); |
83 |
< |
// |
84 |
< |
////if this stuntdoulbe is already marked as ignore just skip it |
85 |
< |
//if (data == NULL) { |
86 |
< |
// data = new GenericData; |
87 |
< |
// data->setID("IGNORE"); |
88 |
< |
// sd->addProperty(data); |
89 |
< |
//} |
90 |
< |
} |
91 |
< |
|
92 |
< |
const std::string IgnoreVisitor::toString() { |
93 |
< |
char buffer[65535]; |
94 |
< |
std::string result; |
95 |
< |
std::set<std::string>::iterator i; |
96 |
< |
|
97 |
< |
sprintf(buffer, |
98 |
< |
"------------------------------------------------------------------\n"); |
99 |
< |
result += buffer; |
100 |
< |
|
101 |
< |
sprintf(buffer, "Visitor name: %s\n", visitorName.c_str()); |
102 |
< |
result += buffer; |
103 |
< |
|
104 |
< |
sprintf(buffer, "Visitor Description: ignore stuntdoubles\n"); |
105 |
< |
result += buffer; |
106 |
< |
|
107 |
< |
//print the ignore type list |
108 |
< |
sprintf(buffer, "Ignore type list contains below types:\n"); |
109 |
< |
result += buffer; |
110 |
< |
|
111 |
< |
for( i = itList.begin(); i != itList.end(); ++i ) { |
112 |
< |
sprintf(buffer, "%s\t", i->c_str()); |
113 |
< |
result += buffer; |
114 |
< |
} |
115 |
< |
|
116 |
< |
sprintf(buffer, "\n"); |
117 |
< |
result += buffer; |
118 |
< |
|
119 |
< |
sprintf(buffer, |
120 |
< |
"------------------------------------------------------------------\n"); |
121 |
< |
result += buffer; |
122 |
< |
|
123 |
< |
return result; |
124 |
< |
} |
125 |
< |
|
126 |
< |
//----------------------------------------------------------------------------// |
127 |
< |
|
128 |
< |
void WrappingVisitor::visit(Atom *atom) { |
129 |
< |
internalVisit(atom); |
130 |
< |
} |
131 |
< |
|
132 |
< |
void WrappingVisitor::visit(DirectionalAtom *datom) { |
133 |
< |
internalVisit(datom); |
134 |
< |
} |
135 |
< |
|
136 |
< |
void WrappingVisitor::visit(RigidBody *rb) { |
137 |
< |
internalVisit(rb); |
138 |
< |
} |
139 |
< |
|
140 |
< |
void WrappingVisitor::internalVisit(StuntDouble *sd) { |
60 |
> |
void WrappingVisitor::internalVisit(StuntDouble *sd) { |
61 |
|
GenericData * data; |
62 |
|
AtomData * atomData; |
63 |
|
AtomInfo * atomInfo; |
66 |
|
data = sd->getPropertyByName("ATOMDATA"); |
67 |
|
|
68 |
|
if (data != NULL) { |
69 |
< |
atomData = dynamic_cast<AtomData *>(data); |
69 |
> |
atomData = dynamic_cast<AtomData *>(data); |
70 |
|
|
71 |
< |
if (atomData == NULL) |
72 |
< |
return; |
71 |
> |
if (atomData == NULL) |
72 |
> |
return; |
73 |
|
} else |
74 |
< |
return; |
74 |
> |
return; |
75 |
|
|
76 |
|
Snapshot* currSnapshot = info->getSnapshotManager()->getCurrentSnapshot(); |
77 |
|
|
78 |
|
for( atomInfo = atomData->beginAtomInfo(i); atomInfo; atomInfo = atomData->nextAtomInfo(i) ) { |
79 |
< |
currSnapshot->wrapVector(atomInfo->pos); |
79 |
> |
Vector3d newPos = atomInfo->pos - origin_; |
80 |
> |
currSnapshot->wrapVector(newPos); |
81 |
> |
atomInfo->pos = newPos; |
82 |
|
} |
83 |
< |
} |
83 |
> |
} |
84 |
|
|
85 |
< |
const std::string WrappingVisitor::toString() { |
85 |
> |
void WrappingVisitor::update() { |
86 |
> |
if (useCom_){ |
87 |
> |
origin_ = info->getCom(); |
88 |
> |
} |
89 |
> |
} |
90 |
> |
|
91 |
> |
const std::string WrappingVisitor::toString() { |
92 |
|
char buffer[65535]; |
93 |
|
std::string result; |
94 |
|
|
108 |
|
result += buffer; |
109 |
|
|
110 |
|
return result; |
111 |
< |
} |
111 |
> |
} |
112 |
|
|
113 |
< |
//----------------------------------------------------------------------------// |
113 |
> |
//----------------------------------------------------------------------------// |
114 |
|
|
115 |
< |
ReplicateVisitor::ReplicateVisitor(SimInfo *info, Vector3i opt) : |
115 |
> |
ReplicateVisitor::ReplicateVisitor(SimInfo *info, Vector3i opt) : |
116 |
|
BaseVisitor() { |
117 |
< |
this->info = info; |
118 |
< |
visitorName = "ReplicateVisitor"; |
119 |
< |
this->replicateOpt = opt; |
117 |
> |
this->info = info; |
118 |
> |
visitorName = "ReplicateVisitor"; |
119 |
> |
this->replicateOpt = opt; |
120 |
|
|
121 |
< |
//generate the replicate directions |
122 |
< |
for( int i = 0; i <= replicateOpt[0]; i++ ) { |
121 |
> |
//generate the replicate directions |
122 |
> |
for( int i = 0; i <= replicateOpt[0]; i++ ) { |
123 |
|
for( int j = 0; j <= replicateOpt[1]; j++ ) { |
124 |
< |
for( int k = 0; k <= replicateOpt[2]; k++ ) { |
125 |
< |
//skip original frame |
126 |
< |
if (i == 0 && j == 0 && k == 0) { |
127 |
< |
continue; |
128 |
< |
} else { |
129 |
< |
dir.push_back(Vector3i(i, j, k)); |
130 |
< |
} |
131 |
< |
} |
124 |
> |
for( int k = 0; k <= replicateOpt[2]; k++ ) { |
125 |
> |
//skip original frame |
126 |
> |
if (i == 0 && j == 0 && k == 0) { |
127 |
> |
continue; |
128 |
> |
} else { |
129 |
> |
dir.push_back(Vector3i(i, j, k)); |
130 |
> |
} |
131 |
> |
} |
132 |
|
} |
133 |
< |
} |
133 |
> |
} |
134 |
|
|
135 |
< |
} |
135 |
> |
} |
136 |
|
|
137 |
< |
void ReplicateVisitor::visit(Atom *atom) { |
138 |
< |
internalVisit(atom); |
139 |
< |
} |
137 |
> |
void ReplicateVisitor::visit(Atom *atom) { |
138 |
> |
internalVisit(atom); |
139 |
> |
} |
140 |
|
|
141 |
< |
void ReplicateVisitor::visit(DirectionalAtom *datom) { |
142 |
< |
internalVisit(datom); |
143 |
< |
} |
141 |
> |
void ReplicateVisitor::visit(DirectionalAtom *datom) { |
142 |
> |
internalVisit(datom); |
143 |
> |
} |
144 |
|
|
145 |
< |
void ReplicateVisitor::visit(RigidBody *rb) { |
146 |
< |
internalVisit(rb); |
147 |
< |
} |
145 |
> |
void ReplicateVisitor::visit(RigidBody *rb) { |
146 |
> |
internalVisit(rb); |
147 |
> |
} |
148 |
|
|
149 |
< |
void ReplicateVisitor::internalVisit(StuntDouble *sd) { |
149 |
> |
void ReplicateVisitor::internalVisit(StuntDouble *sd) { |
150 |
|
GenericData * data; |
151 |
|
AtomData * atomData; |
152 |
|
|
154 |
|
data = sd->getPropertyByName("ATOMDATA"); |
155 |
|
|
156 |
|
if (data != NULL) { |
157 |
< |
atomData = dynamic_cast<AtomData *>(data); |
157 |
> |
atomData = dynamic_cast<AtomData *>(data); |
158 |
|
|
159 |
< |
if (atomData == NULL) { |
160 |
< |
return; |
161 |
< |
} |
159 |
> |
if (atomData == NULL) { |
160 |
> |
return; |
161 |
> |
} |
162 |
|
} else { |
163 |
< |
return; |
163 |
> |
return; |
164 |
|
} |
165 |
|
|
166 |
|
Snapshot* currSnapshot = info->getSnapshotManager()->getCurrentSnapshot(); |
169 |
|
std::vector<AtomInfo *> atomInfoList = atomData->getData(); |
170 |
|
|
171 |
|
replicate(atomInfoList, atomData, box); |
172 |
< |
} |
172 |
> |
} |
173 |
|
|
174 |
< |
void ReplicateVisitor::replicate(std::vector<AtomInfo *>&infoList, AtomData *data, const Mat3x3d& box) { |
174 |
> |
void ReplicateVisitor::replicate(std::vector<AtomInfo *>&infoList, AtomData *data, const Mat3x3d& box) { |
175 |
|
AtomInfo* newAtomInfo; |
176 |
|
std::vector<Vector3i>::iterator dirIter; |
177 |
|
std::vector<AtomInfo *>::iterator i; |
178 |
|
|
179 |
|
for( dirIter = dir.begin(); dirIter != dir.end(); ++dirIter ) { |
180 |
< |
for( i = infoList.begin(); i != infoList.end(); i++ ) { |
181 |
< |
newAtomInfo = new AtomInfo(); |
182 |
< |
*newAtomInfo = *(*i); |
180 |
> |
for( i = infoList.begin(); i != infoList.end(); i++ ) { |
181 |
> |
newAtomInfo = new AtomInfo(); |
182 |
> |
*newAtomInfo = *(*i); |
183 |
|
|
184 |
< |
for( int j = 0; j < 3; j++ ) |
185 |
< |
newAtomInfo->pos[j] += (*dirIter)[0]*box(j, 0) + (*dirIter)[1]*box(j, 1) + (*dirIter)[2]*box(j, 2); |
184 |
> |
for( int j = 0; j < 3; j++ ) |
185 |
> |
newAtomInfo->pos[j] += (*dirIter)[0]*box(j, 0) + (*dirIter)[1]*box(j, 1) + (*dirIter)[2]*box(j, 2); |
186 |
|
|
187 |
< |
data->addAtomInfo(newAtomInfo); |
188 |
< |
} |
187 |
> |
data->addAtomInfo(newAtomInfo); |
188 |
> |
} |
189 |
|
} // end for(dirIter) |
190 |
< |
} |
190 |
> |
} |
191 |
|
|
192 |
< |
const std::string ReplicateVisitor::toString() { |
192 |
> |
const std::string ReplicateVisitor::toString() { |
193 |
|
char buffer[65535]; |
194 |
|
std::string result; |
195 |
|
std::set<std::string>::iterator i; |
220 |
|
result += buffer; |
221 |
|
|
222 |
|
return result; |
223 |
< |
} |
223 |
> |
} |
224 |
|
|
225 |
< |
//----------------------------------------------------------------------------// |
225 |
> |
//----------------------------------------------------------------------------// |
226 |
|
|
227 |
< |
XYZVisitor::XYZVisitor(SimInfo *info, bool printDipole) : |
228 |
< |
BaseVisitor() { |
229 |
< |
this->info = info; |
230 |
< |
visitorName = "XYZVisitor"; |
303 |
< |
this->printDipole = printDipole; |
304 |
< |
} |
227 |
> |
XYZVisitor::XYZVisitor(SimInfo *info) : |
228 |
> |
BaseVisitor(), seleMan(info), evaluator(info){ |
229 |
> |
this->info = info; |
230 |
> |
visitorName = "XYZVisitor"; |
231 |
|
|
232 |
< |
void XYZVisitor::visit(Atom *atom) { |
232 |
> |
evaluator.loadScriptString("select all"); |
233 |
> |
|
234 |
> |
if (!evaluator.isDynamic()) { |
235 |
> |
seleMan.setSelectionSet(evaluator.evaluate()); |
236 |
> |
} |
237 |
> |
posOnly_ = false; |
238 |
> |
} |
239 |
> |
|
240 |
> |
XYZVisitor::XYZVisitor(SimInfo *info, const std::string& script) : |
241 |
> |
BaseVisitor(), seleMan(info), evaluator(info) { |
242 |
> |
this->info = info; |
243 |
> |
visitorName = "XYZVisitor"; |
244 |
> |
|
245 |
> |
evaluator.loadScriptString(script); |
246 |
> |
|
247 |
> |
if (!evaluator.isDynamic()) { |
248 |
> |
seleMan.setSelectionSet(evaluator.evaluate()); |
249 |
> |
} |
250 |
> |
posOnly_ = false; |
251 |
> |
} |
252 |
> |
|
253 |
> |
void XYZVisitor::visit(Atom *atom) { |
254 |
|
if (isSelected(atom)) |
255 |
< |
internalVisit(atom); |
256 |
< |
} |
255 |
> |
internalVisit(atom); |
256 |
> |
} |
257 |
|
|
258 |
< |
void XYZVisitor::visit(DirectionalAtom *datom) { |
258 |
> |
void XYZVisitor::visit(DirectionalAtom *datom) { |
259 |
|
if (isSelected(datom)) |
260 |
< |
internalVisit(datom); |
261 |
< |
} |
260 |
> |
internalVisit(datom); |
261 |
> |
} |
262 |
|
|
263 |
< |
void XYZVisitor::visit(RigidBody *rb) { |
263 |
> |
void XYZVisitor::visit(RigidBody *rb) { |
264 |
|
if (isSelected(rb)) |
265 |
< |
internalVisit(rb); |
266 |
< |
} |
265 |
> |
internalVisit(rb); |
266 |
> |
} |
267 |
|
|
268 |
< |
void XYZVisitor::internalVisit(StuntDouble *sd) { |
268 |
> |
void XYZVisitor::update() { |
269 |
> |
//if dynamic, we need to re-evaluate the selection |
270 |
> |
if (evaluator.isDynamic()) { |
271 |
> |
seleMan.setSelectionSet(evaluator.evaluate()); |
272 |
> |
} |
273 |
> |
} |
274 |
> |
|
275 |
> |
void XYZVisitor::internalVisit(StuntDouble *sd) { |
276 |
|
GenericData * data; |
277 |
|
AtomData * atomData; |
278 |
|
AtomInfo * atomInfo; |
283 |
|
data = sd->getPropertyByName("ATOMDATA"); |
284 |
|
|
285 |
|
if (data != NULL) { |
286 |
< |
atomData = dynamic_cast<AtomData *>(data); |
286 |
> |
atomData = dynamic_cast<AtomData *>(data); |
287 |
|
|
288 |
< |
if (atomData == NULL) |
289 |
< |
return; |
288 |
> |
if (atomData == NULL) |
289 |
> |
return; |
290 |
|
} else |
291 |
< |
return; |
291 |
> |
return; |
292 |
|
|
293 |
< |
for( atomInfo = atomData->beginAtomInfo(i); atomInfo; |
294 |
< |
atomInfo = atomData->nextAtomInfo(i) ) { |
295 |
< |
printf("SD type is %s\n", sd->getType().c_str()); |
296 |
< |
printf("XYZVisitor thinks %s\n", atomInfo->atomTypeName.c_str()); |
297 |
< |
if (printDipole) { |
298 |
< |
sprintf(buffer, |
299 |
< |
"%s%15.8f%15.8f%15.8f%15.8f%15.8f%15.8f", |
300 |
< |
atomInfo->atomTypeName.c_str(), |
301 |
< |
atomInfo->pos[0], |
302 |
< |
atomInfo->pos[1], |
303 |
< |
atomInfo->pos[2], |
304 |
< |
atomInfo->dipole[0], |
305 |
< |
atomInfo->dipole[1], |
306 |
< |
atomInfo->dipole[2]); |
307 |
< |
} else { |
308 |
< |
sprintf(buffer, "%s%15.8f%15.8f%15.8f", |
309 |
< |
atomInfo->atomTypeName.c_str(), atomInfo->pos[0], |
310 |
< |
atomInfo->pos[1], atomInfo->pos[2]); |
293 |
> |
AtomType* at = dynamic_cast<Atom *>(sd)->getAtomType(); |
294 |
> |
std::string bn = baseTypeName(at); |
295 |
> |
|
296 |
> |
if (posOnly_){ |
297 |
> |
for( atomInfo = atomData->beginAtomInfo(i); atomInfo; |
298 |
> |
atomInfo = atomData->nextAtomInfo(i) ) { |
299 |
> |
if (atomInfo->hasCharge) { |
300 |
> |
sprintf(buffer, |
301 |
> |
"%s%15.8f%15.8f%15.8f%15.8f", |
302 |
> |
bn.c_str(), |
303 |
> |
atomInfo->pos[0], |
304 |
> |
atomInfo->pos[1], |
305 |
> |
atomInfo->pos[2], |
306 |
> |
atomInfo->charge); |
307 |
> |
} else { |
308 |
> |
sprintf(buffer, |
309 |
> |
"%s%15.8f%15.8f%15.8f", |
310 |
> |
bn.c_str(), |
311 |
> |
atomInfo->pos[0], |
312 |
> |
atomInfo->pos[1], |
313 |
> |
atomInfo->pos[2]); |
314 |
> |
} |
315 |
> |
frame.push_back(buffer); |
316 |
|
} |
317 |
< |
|
318 |
< |
frame.push_back(buffer); |
317 |
> |
}else{ |
318 |
> |
for( atomInfo = atomData->beginAtomInfo(i); atomInfo; |
319 |
> |
atomInfo = atomData->nextAtomInfo(i) ) { |
320 |
> |
if (atomInfo->hasCharge) { |
321 |
> |
sprintf(buffer, |
322 |
> |
"%s%15.8f%15.8f%15.8f%15.8f%15.8f%15.8f%15.8f", |
323 |
> |
bn.c_str(), |
324 |
> |
atomInfo->pos[0], |
325 |
> |
atomInfo->pos[1], |
326 |
> |
atomInfo->pos[2], |
327 |
> |
atomInfo->charge, |
328 |
> |
atomInfo->dipole[0], |
329 |
> |
atomInfo->dipole[1], |
330 |
> |
atomInfo->dipole[2]); |
331 |
> |
} else { |
332 |
> |
sprintf(buffer, |
333 |
> |
"%s%15.8f%15.8f%15.8f%15.8f%15.8f%15.8f", |
334 |
> |
bn.c_str(), |
335 |
> |
atomInfo->pos[0], |
336 |
> |
atomInfo->pos[1], |
337 |
> |
atomInfo->pos[2], |
338 |
> |
atomInfo->dipole[0], |
339 |
> |
atomInfo->dipole[1], |
340 |
> |
atomInfo->dipole[2]); |
341 |
> |
} |
342 |
> |
frame.push_back(buffer); |
343 |
> |
} |
344 |
|
} |
345 |
< |
} |
345 |
> |
} |
346 |
|
|
347 |
< |
bool XYZVisitor::isSelected(StuntDouble *sd) { |
348 |
< |
return info->getSelectionManager()->isSelected(sd); |
349 |
< |
} |
347 |
> |
bool XYZVisitor::isSelected(StuntDouble *sd) { |
348 |
> |
return seleMan.isSelected(sd); |
349 |
> |
} |
350 |
|
|
351 |
< |
void XYZVisitor::writeFrame(std::ostream &outStream) { |
351 |
> |
void XYZVisitor::writeFrame(std::ostream &outStream) { |
352 |
|
std::vector<std::string>::iterator i; |
353 |
|
char buffer[1024]; |
354 |
|
|
355 |
|
if (frame.size() == 0) |
356 |
< |
std::cerr << "Current Frame does not contain any atoms" << std::endl; |
356 |
> |
std::cerr << "Current Frame does not contain any atoms" << std::endl; |
357 |
|
|
358 |
|
//total number of atoms |
359 |
|
outStream << frame.size() << std::endl; |
372 |
|
outStream << buffer << std::endl; |
373 |
|
|
374 |
|
for( i = frame.begin(); i != frame.end(); ++i ) |
375 |
< |
outStream << *i << std::endl; |
376 |
< |
} |
375 |
> |
outStream << *i << std::endl; |
376 |
> |
} |
377 |
|
|
378 |
< |
const std::string XYZVisitor::toString() { |
378 |
> |
std::string XYZVisitor::trimmedName(const std::string&atomTypeName) { |
379 |
> |
return atomTypeName.substr(0, atomTypeName.find('-')); |
380 |
> |
} |
381 |
> |
|
382 |
> |
std::string XYZVisitor::baseTypeName(AtomType* at) { |
383 |
> |
std::vector<AtomType*> ayb = at->allYourBase(); |
384 |
> |
return ayb[ayb.size()-1]->getName(); |
385 |
> |
} |
386 |
> |
|
387 |
> |
const std::string XYZVisitor::toString() { |
388 |
|
char buffer[65535]; |
389 |
|
std::string result; |
390 |
|
|
404 |
|
result += buffer; |
405 |
|
|
406 |
|
return result; |
407 |
< |
} |
407 |
> |
} |
408 |
|
|
409 |
< |
//----------------------------------------------------------------------------// |
409 |
> |
//----------------------------------------------------------------------------// |
410 |
|
|
411 |
< |
void PrepareVisitor::internalVisit(Atom *atom) { |
411 |
> |
void PrepareVisitor::internalVisit(Atom *atom) { |
412 |
|
GenericData *data; |
413 |
|
AtomData * atomData; |
414 |
|
|
416 |
|
data = atom->getPropertyByName("VISITED"); |
417 |
|
|
418 |
|
if (data != NULL) { |
419 |
< |
atom->removeProperty("VISITED"); |
419 |
> |
atom->removeProperty("VISITED"); |
420 |
|
} |
421 |
|
|
422 |
|
//remove atomdata |
423 |
|
data = atom->getPropertyByName("ATOMDATA"); |
424 |
|
|
425 |
|
if (data != NULL) { |
426 |
< |
atomData = dynamic_cast<AtomData *>(data); |
426 |
> |
atomData = dynamic_cast<AtomData *>(data); |
427 |
|
|
428 |
< |
if (atomData != NULL) |
429 |
< |
atom->removeProperty("ATOMDATA"); |
428 |
> |
if (atomData != NULL) |
429 |
> |
atom->removeProperty("ATOMDATA"); |
430 |
|
} |
431 |
< |
} |
431 |
> |
} |
432 |
|
|
433 |
< |
void PrepareVisitor::internalVisit(RigidBody *rb) { |
433 |
> |
void PrepareVisitor::internalVisit(RigidBody *rb) { |
434 |
|
GenericData* data; |
435 |
|
AtomData* atomData; |
436 |
|
std::vector<Atom *> myAtoms; |
440 |
|
data = rb->getPropertyByName("VISITED"); |
441 |
|
|
442 |
|
if (data != NULL) { |
443 |
< |
rb->removeProperty("VISITED"); |
443 |
> |
rb->removeProperty("VISITED"); |
444 |
|
} |
445 |
|
|
446 |
|
//remove atomdata |
447 |
|
data = rb->getPropertyByName("ATOMDATA"); |
448 |
|
|
449 |
|
if (data != NULL) { |
450 |
< |
atomData = dynamic_cast<AtomData *>(data); |
450 |
> |
atomData = dynamic_cast<AtomData *>(data); |
451 |
|
|
452 |
< |
if (atomData != NULL) |
453 |
< |
rb->removeProperty("ATOMDATA"); |
452 |
> |
if (atomData != NULL) |
453 |
> |
rb->removeProperty("ATOMDATA"); |
454 |
|
} |
455 |
|
|
456 |
|
myAtoms = rb->getAtoms(); |
457 |
|
|
458 |
|
for( atomIter = myAtoms.begin(); atomIter != myAtoms.end(); ++atomIter ) |
459 |
< |
internalVisit(*atomIter); |
460 |
< |
} |
459 |
> |
internalVisit(*atomIter); |
460 |
> |
} |
461 |
|
|
462 |
< |
const std::string PrepareVisitor::toString() { |
463 |
< |
char buffer[65535]; |
464 |
< |
std::string result; |
462 |
> |
const std::string PrepareVisitor::toString() { |
463 |
> |
char buffer[65535]; |
464 |
> |
std::string result; |
465 |
|
|
466 |
< |
sprintf(buffer, |
467 |
< |
"------------------------------------------------------------------\n"); |
468 |
< |
result += buffer; |
466 |
> |
sprintf(buffer, |
467 |
> |
"------------------------------------------------------------------\n"); |
468 |
> |
result += buffer; |
469 |
|
|
470 |
< |
sprintf(buffer, "Visitor name: %s", visitorName.c_str()); |
471 |
< |
result += buffer; |
470 |
> |
sprintf(buffer, "Visitor name: %s", visitorName.c_str()); |
471 |
> |
result += buffer; |
472 |
|
|
473 |
< |
sprintf(buffer, |
474 |
< |
"Visitor Description: prepare for operation of other vistors\n"); |
475 |
< |
result += buffer; |
473 |
> |
sprintf(buffer, |
474 |
> |
"Visitor Description: prepare for operation of other vistors\n"); |
475 |
> |
result += buffer; |
476 |
|
|
477 |
< |
sprintf(buffer, |
478 |
< |
"------------------------------------------------------------------\n"); |
479 |
< |
result += buffer; |
477 |
> |
sprintf(buffer, |
478 |
> |
"------------------------------------------------------------------\n"); |
479 |
> |
result += buffer; |
480 |
|
|
481 |
< |
return result; |
482 |
< |
} |
481 |
> |
return result; |
482 |
> |
} |
483 |
|
|
484 |
< |
//----------------------------------------------------------------------------// |
484 |
> |
//----------------------------------------------------------------------------// |
485 |
|
|
486 |
< |
WaterTypeVisitor::WaterTypeVisitor() { |
486 |
> |
WaterTypeVisitor::WaterTypeVisitor() { |
487 |
|
visitorName = "WaterTypeVisitor"; |
488 |
|
waterTypeList.insert("TIP3P_RB_0"); |
489 |
|
waterTypeList.insert("TIP4P_RB_0"); |
490 |
|
waterTypeList.insert("TIP5P_RB_0"); |
491 |
|
waterTypeList.insert("SPCE_RB_0"); |
492 |
< |
} |
492 |
> |
} |
493 |
|
|
494 |
< |
void WaterTypeVisitor::visit(RigidBody *rb) { |
494 |
> |
void WaterTypeVisitor::visit(RigidBody *rb) { |
495 |
|
std::string rbName; |
496 |
|
std::vector<Atom *> myAtoms; |
497 |
|
std::vector<Atom *>::iterator atomIter; |
503 |
|
rbName = rb->getType(); |
504 |
|
|
505 |
|
if (waterTypeList.find(rbName) != waterTypeList.end()) { |
506 |
< |
myAtoms = rb->getAtoms(); |
506 |
> |
myAtoms = rb->getAtoms(); |
507 |
|
|
508 |
< |
for( atomIter = myAtoms.begin(); atomIter != myAtoms.end(); |
509 |
< |
++atomIter ) { |
510 |
< |
data = (*atomIter)->getPropertyByName("ATOMDATA"); |
508 |
> |
for( atomIter = myAtoms.begin(); atomIter != myAtoms.end(); |
509 |
> |
++atomIter ) { |
510 |
> |
data = (*atomIter)->getPropertyByName("ATOMDATA"); |
511 |
|
|
512 |
< |
if (data != NULL) { |
513 |
< |
atomData = dynamic_cast<AtomData *>(data); |
512 |
> |
if (data != NULL) { |
513 |
> |
atomData = dynamic_cast<AtomData *>(data); |
514 |
|
|
515 |
< |
if (atomData == NULL) |
516 |
< |
continue; |
517 |
< |
} else |
518 |
< |
continue; |
515 |
> |
if (atomData == NULL) |
516 |
> |
continue; |
517 |
> |
} else |
518 |
> |
continue; |
519 |
|
|
520 |
< |
for( atomInfo = atomData->beginAtomInfo(i); atomInfo; |
521 |
< |
atomInfo = atomData->nextAtomInfo(i) ) { |
522 |
< |
atomInfo->atomTypeName = trimmedName(atomInfo->atomTypeName); |
523 |
< |
} //end for(atomInfo) |
524 |
< |
} //end for(atomIter) |
520 |
> |
for( atomInfo = atomData->beginAtomInfo(i); atomInfo; |
521 |
> |
atomInfo = atomData->nextAtomInfo(i) ) { |
522 |
> |
atomInfo->atomTypeName = trimmedName(atomInfo->atomTypeName); |
523 |
> |
} //end for(atomInfo) |
524 |
> |
} //end for(atomIter) |
525 |
|
} //end if (waterTypeList.find(rbName) != waterTypeList.end()) |
526 |
< |
} |
526 |
> |
} |
527 |
|
|
528 |
|
std::string WaterTypeVisitor::trimmedName(const std::string&atomTypeName) { |
529 |
|
return atomTypeName.substr(0, atomTypeName.find('_')); |
530 |
|
} |
531 |
|
|
532 |
< |
const std::string WaterTypeVisitor::toString() { |
532 |
> |
const std::string WaterTypeVisitor::toString() { |
533 |
|
char buffer[65535]; |
534 |
|
std::string result; |
535 |
|
|
549 |
|
result += buffer; |
550 |
|
|
551 |
|
return result; |
552 |
< |
} |
552 |
> |
} |
553 |
|
|
554 |
|
} //namespace oopse |