- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/WorldAction/RemoveSphereOfAtomsAction.cpp
r112b09 re2b47c 6 6 */ 7 7 8 #include "Helpers/MemDebug.hpp"9 10 8 #include "Actions/WorldAction/RemoveSphereOfAtomsAction.hpp" 11 #include "CommandLineParser.hpp"12 9 #include "atom.hpp" 13 10 #include "Descriptors/AtomDescriptor.hpp" 14 11 #include "log.hpp" 12 #include "molecule.hpp" 15 13 #include "vector.hpp" 16 14 #include "verbose.hpp" … … 38 36 Dialog *dialog = UIFactory::getInstance().makeDialog(); 39 37 double radius = 0.; 40 atom *first = NULL;38 Vector point; 41 39 42 40 dialog->queryDouble(NAME, &radius, MapOfActions::getInstance().getDescription(NAME)); 43 dialog->query Atom("atom-by-id", &first, MapOfActions::getInstance().getDescription("atom-by-id"));41 dialog->queryVector("position", &point, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription("position")); 44 42 45 43 if(dialog->display()) { 46 44 delete dialog; 47 DoLog(1) && (Log() << Verbose(1) << "Removing atoms around " << first->nr<< " with radius " << radius << "." << endl);45 DoLog(1) && (Log() << Verbose(1) << "Removing atoms around " << point << " with radius " << radius << "." << endl); 48 46 vector<atom*> AllAtoms = World::getInstance().getAllAtoms(); 49 vector<atom*>::iterator AtomAdvancer = AllAtoms.begin(); 50 for (vector<atom*>::iterator AtomRunner = AtomAdvancer; AtomRunner != AllAtoms.end(); ) { 51 ++AtomAdvancer; 52 if (first != *AtomRunner) // dont't destroy reference ... 53 if (first->x.DistanceSquared((*AtomRunner)->x) > radius*radius) // distance to first above radius ... 54 World::getInstance().destroyAtom(*AtomRunner); 47 vector<molecule *> molecules = World::getInstance().getAllMolecules(); 48 for (vector<atom*>::iterator AtomRunner = AllAtoms.begin(); AtomRunner != AllAtoms.end(); ++AtomRunner) { 49 if (point.DistanceSquared((*AtomRunner)->x) > radius*radius) { // distance to first above radius ... 50 // TODO: This is not necessary anymore when atoms are completely handled by World (create/destroy and load/save) 51 for (vector<molecule *>::iterator iter = molecules.begin();iter != molecules.end();++iter) 52 (*iter)->erase(*AtomRunner); 53 World::getInstance().destroyAtom(*AtomRunner); 54 } 55 55 } 56 World::getInstance().destroyAtom(first);57 56 return Action::success; 58 57 } else {
Note:
See TracChangeset
for help on using the changeset viewer.