- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/WorldAction/RemoveSphereOfAtomsAction.cpp
re2b47c r112b09 6 6 */ 7 7 8 #include "Helpers/MemDebug.hpp" 9 8 10 #include "Actions/WorldAction/RemoveSphereOfAtomsAction.hpp" 11 #include "CommandLineParser.hpp" 9 12 #include "atom.hpp" 10 13 #include "Descriptors/AtomDescriptor.hpp" 11 14 #include "log.hpp" 12 #include "molecule.hpp"13 15 #include "vector.hpp" 14 16 #include "verbose.hpp" … … 36 38 Dialog *dialog = UIFactory::getInstance().makeDialog(); 37 39 double radius = 0.; 38 Vector point;40 atom *first = NULL; 39 41 40 42 dialog->queryDouble(NAME, &radius, MapOfActions::getInstance().getDescription(NAME)); 41 dialog->query Vector("position", &point, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription("position"));43 dialog->queryAtom("atom-by-id", &first, MapOfActions::getInstance().getDescription("atom-by-id")); 42 44 43 45 if(dialog->display()) { 44 46 delete dialog; 45 DoLog(1) && (Log() << Verbose(1) << "Removing atoms around " << point<< " with radius " << radius << "." << endl);47 DoLog(1) && (Log() << Verbose(1) << "Removing atoms around " << first->nr << " with radius " << radius << "." << endl); 46 48 vector<atom*> AllAtoms = World::getInstance().getAllAtoms(); 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 } 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); 55 55 } 56 World::getInstance().destroyAtom(first); 56 57 return Action::success; 57 58 } else {
Note:
See TracChangeset
for help on using the changeset viewer.