| 86 |  | } | 
| 87 |  |  | 
| 88 |  | void SelectionEvaluator::clearState() { | 
| 89 | – | //for (int i = scriptLevelMax; --i >= 0; ) | 
| 90 | – | //    stack[i].clear(); | 
| 91 | – | //scriptLevel = 0; | 
| 89 |  | error = false; | 
| 90 |  | errorMessage = ""; | 
| 91 |  | } | 
| 227 |  | compareProperty(atom, bs, property, comparator, comparisonValue); | 
| 228 |  | } | 
| 229 |  |  | 
| 233 | – | //change the positions of atoms which belong to the rigidbodies | 
| 230 |  | for (rb = mol->beginRigidBody(rbIter); rb != NULL; rb = mol->nextRigidBody(rbIter)) { | 
| 231 |  | compareProperty(rb, bs, property, comparator, comparisonValue); | 
| 232 |  | } | 
| 236 |  | } | 
| 237 |  |  | 
| 238 |  | void SelectionEvaluator::compareProperty(StuntDouble* sd, BitSet& bs, int property, int comparator, float comparisonValue) { | 
| 239 | < | double propertyValue; | 
| 239 | > | double propertyValue = 0.0; | 
| 240 |  | switch (property) { | 
| 241 |  | case Token::mass: | 
| 242 |  | propertyValue = sd->getMass(); | 
| 243 |  | break; | 
| 244 |  | case Token::charge: | 
| 245 | < | return; | 
| 246 | < | //break; | 
| 247 | < | case Token::dipole: | 
| 248 | < | return; | 
| 249 | < | //break; | 
| 245 | > | if (sd->isAtom()){ | 
| 246 | > | Atom* atom = static_cast<Atom*>(sd); | 
| 247 | > | propertyValue = getCharge(atom); | 
| 248 | > | } else if (sd->isRigidBody()) { | 
| 249 | > | RigidBody* rb = static_cast<RigidBody*>(sd); | 
| 250 | > | RigidBody::AtomIterator ai; | 
| 251 | > | Atom* atom; | 
| 252 | > | for (atom = rb->beginAtom(ai); atom != NULL; atom = rb->nextAtom(ai)) { | 
| 253 | > | propertyValue+=  getCharge(atom); | 
| 254 | > | } | 
| 255 | > | } | 
| 256 | > | break; | 
| 257 |  | default: | 
| 258 |  | unrecognizedAtomProperty(property); | 
| 259 |  | } | 
| 419 |  | } | 
| 420 |  |  | 
| 421 |  | return bs; | 
| 422 | + | } | 
| 423 | + |  | 
| 424 | + |  | 
| 425 | + | double SelectionEvaluator::getCharge(Atom* atom) { | 
| 426 | + | double charge =0.0; | 
| 427 | + | AtomType* atomType = atom->getAtomType(); | 
| 428 | + | if (atomType->isCharge()) { | 
| 429 | + | GenericData* data = atomType->getPropertyByName("Charge"); | 
| 430 | + | if (data != NULL) { | 
| 431 | + | DoubleGenericData* doubleData= dynamic_cast<DoubleGenericData*>(data); | 
| 432 | + |  | 
| 433 | + | if (doubleData != NULL) { | 
| 434 | + | charge = doubleData->getData(); | 
| 435 | + |  | 
| 436 | + | } else { | 
| 437 | + | sprintf( painCave.errMsg, | 
| 438 | + | "Can not cast GenericData to DoubleGenericData\n"); | 
| 439 | + | painCave.severity = OOPSE_ERROR; | 
| 440 | + | painCave.isFatal = 1; | 
| 441 | + | simError(); | 
| 442 | + | } | 
| 443 | + | } | 
| 444 | + | } | 
| 445 | + |  | 
| 446 | + | return charge; | 
| 447 |  | } | 
| 448 |  |  | 
| 449 |  | } |