| 45 |
|
#include "primitives/Molecule.hpp" |
| 46 |
|
#include "brains/SimInfo.hpp" |
| 47 |
|
namespace oopse { |
| 48 |
– |
|
| 49 |
– |
//----------------------------------------------------------------------------// |
| 50 |
– |
void IgnoreVisitor::visit(Atom *atom) { |
| 51 |
– |
if (isIgnoreType(atom->getType())) |
| 52 |
– |
internalVisit(atom); |
| 53 |
– |
} |
| 54 |
– |
|
| 55 |
– |
void IgnoreVisitor::visit(DirectionalAtom *datom) { |
| 56 |
– |
if (isIgnoreType(datom->getType())) |
| 57 |
– |
internalVisit(datom); |
| 58 |
– |
} |
| 59 |
– |
|
| 60 |
– |
void IgnoreVisitor::visit(RigidBody *rb) { |
| 61 |
– |
std::vector<Atom *> myAtoms; |
| 62 |
– |
std::vector<Atom *>::iterator atomIter; |
| 63 |
– |
AtomInfo * atomInfo; |
| 64 |
– |
|
| 65 |
– |
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 |
– |
} |
| 48 |
|
|
| 116 |
– |
sprintf(buffer, "\n"); |
| 117 |
– |
result += buffer; |
| 118 |
– |
|
| 119 |
– |
sprintf(buffer, |
| 120 |
– |
"------------------------------------------------------------------\n"); |
| 121 |
– |
result += buffer; |
| 122 |
– |
|
| 123 |
– |
return result; |
| 124 |
– |
} |
| 125 |
– |
|
| 126 |
– |
//----------------------------------------------------------------------------// |
| 127 |
– |
|
| 49 |
|
void WrappingVisitor::visit(Atom *atom) { |
| 50 |
|
internalVisit(atom); |
| 51 |
|
} |
| 217 |
|
|
| 218 |
|
//----------------------------------------------------------------------------// |
| 219 |
|
|
| 220 |
< |
XYZVisitor::XYZVisitor(SimInfo *info, bool printDipole) : |
| 221 |
< |
BaseVisitor() { |
| 220 |
> |
XYZVisitor::XYZVisitor(SimInfo *info) : |
| 221 |
> |
BaseVisitor(), seleMan(info), evaluator(info){ |
| 222 |
|
this->info = info; |
| 223 |
|
visitorName = "XYZVisitor"; |
| 224 |
< |
this->printDipole = printDipole; |
| 224 |
> |
|
| 225 |
> |
evaluator.loadScriptString("select all"); |
| 226 |
> |
|
| 227 |
> |
if (!evaluator.isDynamic()) { |
| 228 |
> |
seleMan.setSelectionSet(evaluator.evaluate()); |
| 229 |
> |
} |
| 230 |
> |
|
| 231 |
|
} |
| 232 |
+ |
|
| 233 |
+ |
XYZVisitor::XYZVisitor(SimInfo *info, const std::string& script) : |
| 234 |
+ |
BaseVisitor(), seleMan(info), evaluator(info) { |
| 235 |
+ |
this->info = info; |
| 236 |
+ |
visitorName = "XYZVisitor"; |
| 237 |
|
|
| 238 |
+ |
evaluator.loadScriptString(script); |
| 239 |
+ |
|
| 240 |
+ |
if (!evaluator.isDynamic()) { |
| 241 |
+ |
seleMan.setSelectionSet(evaluator.evaluate()); |
| 242 |
+ |
} |
| 243 |
+ |
|
| 244 |
+ |
} |
| 245 |
+ |
|
| 246 |
|
void XYZVisitor::visit(Atom *atom) { |
| 247 |
|
if (isSelected(atom)) |
| 248 |
|
internalVisit(atom); |
| 256 |
|
void XYZVisitor::visit(RigidBody *rb) { |
| 257 |
|
if (isSelected(rb)) |
| 258 |
|
internalVisit(rb); |
| 259 |
+ |
} |
| 260 |
+ |
|
| 261 |
+ |
void XYZVisitor::update() { |
| 262 |
+ |
//if dynamic, we need to re-evaluate the selection |
| 263 |
+ |
if (evaluator.isDynamic()) { |
| 264 |
+ |
seleMan.setSelectionSet(evaluator.evaluate()); |
| 265 |
+ |
} |
| 266 |
|
} |
| 267 |
|
|
| 268 |
|
void XYZVisitor::internalVisit(StuntDouble *sd) { |
| 285 |
|
|
| 286 |
|
for( atomInfo = atomData->beginAtomInfo(i); atomInfo; |
| 287 |
|
atomInfo = atomData->nextAtomInfo(i) ) { |
| 341 |
– |
printf("SD type is %s\n", sd->getType().c_str()); |
| 342 |
– |
printf("XYZVisitor thinks %s\n", atomInfo->atomTypeName.c_str()); |
| 343 |
– |
if (printDipole) { |
| 288 |
|
sprintf(buffer, |
| 289 |
|
"%s%15.8f%15.8f%15.8f%15.8f%15.8f%15.8f", |
| 290 |
|
atomInfo->atomTypeName.c_str(), |
| 294 |
|
atomInfo->dipole[0], |
| 295 |
|
atomInfo->dipole[1], |
| 296 |
|
atomInfo->dipole[2]); |
| 353 |
– |
} else { |
| 354 |
– |
sprintf(buffer, "%s%15.8f%15.8f%15.8f", |
| 355 |
– |
atomInfo->atomTypeName.c_str(), atomInfo->pos[0], |
| 356 |
– |
atomInfo->pos[1], atomInfo->pos[2]); |
| 357 |
– |
} |
| 358 |
– |
|
| 297 |
|
frame.push_back(buffer); |
| 298 |
|
} |
| 299 |
|
} |
| 300 |
|
|
| 301 |
|
bool XYZVisitor::isSelected(StuntDouble *sd) { |
| 302 |
< |
return info->getSelectionManager()->isSelected(sd); |
| 302 |
> |
return seleMan.isSelected(sd); |
| 303 |
|
} |
| 304 |
|
|
| 305 |
|
void XYZVisitor::writeFrame(std::ostream &outStream) { |