[bcf653] | 1 | /*
|
---|
| 2 | * Project: MoleCuilder
|
---|
| 3 | * Description: creates and alters molecular systems
|
---|
[0aa122] | 4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
---|
[94d5ac6] | 5 | *
|
---|
| 6 | *
|
---|
| 7 | * This file is part of MoleCuilder.
|
---|
| 8 | *
|
---|
| 9 | * MoleCuilder is free software: you can redistribute it and/or modify
|
---|
| 10 | * it under the terms of the GNU General Public License as published by
|
---|
| 11 | * the Free Software Foundation, either version 2 of the License, or
|
---|
| 12 | * (at your option) any later version.
|
---|
| 13 | *
|
---|
| 14 | * MoleCuilder is distributed in the hope that it will be useful,
|
---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 17 | * GNU General Public License for more details.
|
---|
| 18 | *
|
---|
| 19 | * You should have received a copy of the GNU General Public License
|
---|
| 20 | * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
|
---|
[bcf653] | 21 | */
|
---|
| 22 |
|
---|
[5d1611] | 23 | /*
|
---|
| 24 | * World.cpp
|
---|
| 25 | *
|
---|
| 26 | * Created on: Feb 3, 2010
|
---|
| 27 | * Author: crueger
|
---|
| 28 | */
|
---|
| 29 |
|
---|
[bf3817] | 30 | // include config.h
|
---|
| 31 | #ifdef HAVE_CONFIG_H
|
---|
| 32 | #include <config.h>
|
---|
| 33 | #endif
|
---|
| 34 |
|
---|
[ad011c] | 35 | #include "CodePatterns/MemDebug.hpp"
|
---|
[112b09] | 36 |
|
---|
[5d1611] | 37 | #include "World.hpp"
|
---|
| 38 |
|
---|
[90c4280] | 39 | #include <functional>
|
---|
[5d1611] | 40 |
|
---|
[3139b2] | 41 | #include "Actions/ActionTrait.hpp"
|
---|
[d297a3] | 42 | #include "Actions/ManipulateAtomsProcess.hpp"
|
---|
[6f0841] | 43 | #include "Atom/atom.hpp"
|
---|
[5dfabd] | 44 | #include "Atom/AtomObserver.hpp"
|
---|
[d297a3] | 45 | #include "Box.hpp"
|
---|
| 46 | #include "CodePatterns/Assert.hpp"
|
---|
[8e1f7af] | 47 | #include "config.hpp"
|
---|
[fc1b24] | 48 | #include "Descriptors/AtomDescriptor.hpp"
|
---|
[865a945] | 49 | #include "Descriptors/AtomDescriptor_impl.hpp"
|
---|
[ebc499] | 50 | #include "Descriptors/AtomSelectionDescriptor.hpp"
|
---|
[1c51c8] | 51 | #include "Descriptors/MoleculeDescriptor.hpp"
|
---|
| 52 | #include "Descriptors/MoleculeDescriptor_impl.hpp"
|
---|
[ebc499] | 53 | #include "Descriptors/MoleculeSelectionDescriptor.hpp"
|
---|
[feb5d0] | 54 | #include "Descriptors/SelectiveConstIterator_impl.hpp"
|
---|
[6e97e5] | 55 | #include "Descriptors/SelectiveIterator_impl.hpp"
|
---|
[42127c] | 56 | #include "Element/periodentafel.hpp"
|
---|
[3139b2] | 57 | #include "Graph/BondGraph.hpp"
|
---|
[4b8630] | 58 | #include "Graph/DepthFirstSearchAnalysis.hpp"
|
---|
[e4fe8d] | 59 | #include "Helpers/defs.hpp"
|
---|
[d297a3] | 60 | #include "LinearAlgebra/RealSpaceMatrix.hpp"
|
---|
[4834f4] | 61 | #include "LinkedCell/LinkedCell_Controller.hpp"
|
---|
| 62 | #include "LinkedCell/PointCloudAdaptor.hpp"
|
---|
[d297a3] | 63 | #include "molecule.hpp"
|
---|
[42127c] | 64 | #include "MoleculeListClass.hpp"
|
---|
[ab26c3] | 65 | #include "Thermostats/ThermoStatContainer.hpp"
|
---|
[d297a3] | 66 | #include "WorldTime.hpp"
|
---|
[d346b6] | 67 |
|
---|
[3e4fb6] | 68 | #include "IdPool_impl.hpp"
|
---|
| 69 |
|
---|
[4834f4] | 70 | #include "CodePatterns/IteratorAdaptors.hpp"
|
---|
[ad011c] | 71 | #include "CodePatterns/Singleton_impl.hpp"
|
---|
[02ce36] | 72 | #include "CodePatterns/Observer/Channels.hpp"
|
---|
| 73 | #include "CodePatterns/Observer/ObservedContainer_impl.hpp"
|
---|
[23b547] | 74 |
|
---|
[ce7fdc] | 75 | using namespace MoleCuilder;
|
---|
[4d9c01] | 76 |
|
---|
[7188b1] | 77 | /******************************* Notifications ************************/
|
---|
| 78 |
|
---|
| 79 |
|
---|
| 80 | atom* World::_lastchangedatom = NULL;
|
---|
| 81 | molecule* World::_lastchangedmol = NULL;
|
---|
| 82 |
|
---|
[5d1611] | 83 | /******************************* getter and setter ************************/
|
---|
[f71baf] | 84 | periodentafel *&World::getPeriode()
|
---|
| 85 | {
|
---|
[5d1611] | 86 | return periode;
|
---|
| 87 | }
|
---|
| 88 |
|
---|
[f71baf] | 89 | BondGraph *&World::getBondGraph()
|
---|
| 90 | {
|
---|
| 91 | return BG;
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | void World::setBondGraph(BondGraph *_BG){
|
---|
| 95 | delete (BG);
|
---|
| 96 | BG = _BG;
|
---|
| 97 | }
|
---|
| 98 |
|
---|
[8e1f7af] | 99 | config *&World::getConfig(){
|
---|
| 100 | return configuration;
|
---|
| 101 | }
|
---|
| 102 |
|
---|
[1c51c8] | 103 | // Atoms
|
---|
| 104 |
|
---|
[7a1ce5] | 105 | atom* World::getAtom(AtomDescriptor descriptor){
|
---|
[fc1b24] | 106 | return descriptor.find();
|
---|
| 107 | }
|
---|
| 108 |
|
---|
[4d72e4] | 109 | World::AtomComposite World::getAllAtoms(AtomDescriptor descriptor){
|
---|
[fc1b24] | 110 | return descriptor.findAll();
|
---|
| 111 | }
|
---|
| 112 |
|
---|
[4d72e4] | 113 | World::AtomComposite World::getAllAtoms(){
|
---|
[0e2a47] | 114 | return getAllAtoms(AllAtoms());
|
---|
| 115 | }
|
---|
| 116 |
|
---|
[354859] | 117 | int World::numAtoms(){
|
---|
| 118 | return atoms.size();
|
---|
| 119 | }
|
---|
| 120 |
|
---|
[1c51c8] | 121 | // Molecules
|
---|
| 122 |
|
---|
| 123 | molecule *World::getMolecule(MoleculeDescriptor descriptor){
|
---|
| 124 | return descriptor.find();
|
---|
| 125 | }
|
---|
| 126 |
|
---|
| 127 | std::vector<molecule*> World::getAllMolecules(MoleculeDescriptor descriptor){
|
---|
| 128 | return descriptor.findAll();
|
---|
| 129 | }
|
---|
| 130 |
|
---|
[97ebf8] | 131 | std::vector<molecule*> World::getAllMolecules(){
|
---|
| 132 | return getAllMolecules(AllMolecules());
|
---|
| 133 | }
|
---|
| 134 |
|
---|
[354859] | 135 | int World::numMolecules(){
|
---|
| 136 | return molecules_deprecated->ListOfMolecules.size();
|
---|
| 137 | }
|
---|
| 138 |
|
---|
[5f612ee] | 139 | // system
|
---|
| 140 |
|
---|
[84c494] | 141 | Box& World::getDomain() {
|
---|
| 142 | return *cell_size;
|
---|
| 143 | }
|
---|
| 144 |
|
---|
[cca9ef] | 145 | void World::setDomain(const RealSpaceMatrix &mat){
|
---|
[be97a8] | 146 | OBSERVE;
|
---|
[84c494] | 147 | *cell_size = mat;
|
---|
[5f612ee] | 148 | }
|
---|
| 149 |
|
---|
| 150 | void World::setDomain(double * matrix)
|
---|
| 151 | {
|
---|
[b9c847] | 152 | OBSERVE;
|
---|
[cca9ef] | 153 | RealSpaceMatrix M = ReturnFullMatrixforSymmetric(matrix);
|
---|
[84c494] | 154 | cell_size->setM(M);
|
---|
[5f612ee] | 155 | }
|
---|
| 156 |
|
---|
[03abd0] | 157 | LinkedCell::LinkedCell_View World::getLinkedCell(double distance)
|
---|
[4834f4] | 158 | {
|
---|
[03abd0] | 159 | ASSERT( distance > 0,
|
---|
| 160 | "World::getLinkedCell() - distance is not positive.");
|
---|
| 161 | if (distance < 1.) {
|
---|
| 162 | ELOG(2, "Linked cell grid with length less than 1. is very memory-intense!");
|
---|
| 163 | distance = 1.;
|
---|
| 164 | }
|
---|
[4834f4] | 165 | // we have to grope past the ObservedContainer mechanism and transmorph the map
|
---|
| 166 | // into a traversable list for the adaptor
|
---|
| 167 | PointCloudAdaptor< AtomSet::set_t, MapValueIterator<AtomSet::set_t::iterator> > atomset(
|
---|
| 168 | &(atoms.getContent()),
|
---|
| 169 | std::string("WorldsAtoms"));
|
---|
| 170 | return LCcontroller->getView(distance, atomset);
|
---|
| 171 | }
|
---|
| 172 |
|
---|
[d297a3] | 173 | void World::setTime(const unsigned int _step)
|
---|
| 174 | {
|
---|
[76163d] | 175 | if (_step != WorldTime::getTime()) {
|
---|
| 176 | // set new time
|
---|
[040a5c] | 177 | WorldTime::getInstance().setTime(_step);
|
---|
[4b8630] | 178 | // TODO: removed when BondGraph creates the adjacency
|
---|
| 179 | // 1. remove all of World's molecules
|
---|
| 180 | for (MoleculeIterator iter = getMoleculeIter();
|
---|
| 181 | getMoleculeIter() != moleculeEnd();
|
---|
| 182 | iter = getMoleculeIter()) {
|
---|
| 183 | getMolecules()->erase(*iter);
|
---|
| 184 | destroyMolecule(*iter);
|
---|
| 185 | }
|
---|
| 186 | // 2. (re-)create bondgraph
|
---|
| 187 | AtomComposite Set = getAllAtoms();
|
---|
| 188 | BG->CreateAdjacency(Set);
|
---|
| 189 |
|
---|
| 190 | // 3. scan for connected subgraphs => molecules
|
---|
| 191 | DepthFirstSearchAnalysis DFS;
|
---|
| 192 | DFS();
|
---|
| 193 | DFS.UpdateMoleculeStructure();
|
---|
[76163d] | 194 | }
|
---|
[d297a3] | 195 | }
|
---|
| 196 |
|
---|
[387b36] | 197 | std::string World::getDefaultName() {
|
---|
[5f612ee] | 198 | return defaultName;
|
---|
| 199 | }
|
---|
| 200 |
|
---|
[387b36] | 201 | void World::setDefaultName(std::string name)
|
---|
[5f612ee] | 202 | {
|
---|
[be97a8] | 203 | OBSERVE;
|
---|
[387b36] | 204 | defaultName = name;
|
---|
[5f612ee] | 205 | };
|
---|
| 206 |
|
---|
[43dad6] | 207 | class ThermoStatContainer * World::getThermostats()
|
---|
| 208 | {
|
---|
| 209 | return Thermostats;
|
---|
| 210 | }
|
---|
| 211 |
|
---|
| 212 |
|
---|
[e4b5de] | 213 | int World::getExitFlag() {
|
---|
| 214 | return ExitFlag;
|
---|
| 215 | }
|
---|
| 216 |
|
---|
| 217 | void World::setExitFlag(int flag) {
|
---|
| 218 | if (ExitFlag < flag)
|
---|
| 219 | ExitFlag = flag;
|
---|
| 220 | }
|
---|
[5f612ee] | 221 |
|
---|
[afb47f] | 222 | /******************** Methods to change World state *********************/
|
---|
| 223 |
|
---|
[354859] | 224 | molecule* World::createMolecule(){
|
---|
| 225 | OBSERVE;
|
---|
| 226 | molecule *mol = NULL;
|
---|
[cbc5fb] | 227 | mol = NewMolecule();
|
---|
[3e4fb6] | 228 | moleculeId_t id = moleculeIdPool.getNextId();
|
---|
[127a8e] | 229 | ASSERT(!molecules.count(id),"proposed id did not specify an unused ID");
|
---|
| 230 | mol->setId(id);
|
---|
[244d26] | 231 | // store the molecule by ID
|
---|
[cbc5fb] | 232 | molecules[mol->getId()] = mol;
|
---|
[354859] | 233 | mol->signOn(this);
|
---|
[7188b1] | 234 | _lastchangedmol = mol;
|
---|
| 235 | NOTIFY(MoleculeInserted);
|
---|
[354859] | 236 | return mol;
|
---|
| 237 | }
|
---|
| 238 |
|
---|
[cbc5fb] | 239 | void World::destroyMolecule(molecule* mol){
|
---|
| 240 | OBSERVE;
|
---|
[fa7989] | 241 | ASSERT(mol,"Molecule that was meant to be destroyed did not exist");
|
---|
[cbc5fb] | 242 | destroyMolecule(mol->getId());
|
---|
| 243 | }
|
---|
| 244 |
|
---|
| 245 | void World::destroyMolecule(moleculeId_t id){
|
---|
| 246 | molecule *mol = molecules[id];
|
---|
[6d574a] | 247 | ASSERT(mol,"Molecule id that was meant to be destroyed did not exist");
|
---|
[38f991] | 248 | // give notice about immediate removal
|
---|
| 249 | {
|
---|
| 250 | OBSERVE;
|
---|
| 251 | _lastchangedmol = mol;
|
---|
| 252 | NOTIFY(MoleculeRemoved);
|
---|
| 253 | }
|
---|
[7d82a5] | 254 | mol->signOff(this);
|
---|
[cbc5fb] | 255 | DeleteMolecule(mol);
|
---|
[38f991] | 256 | if (isMoleculeSelected(id))
|
---|
| 257 | selectedMolecules.erase(id);
|
---|
[cbc5fb] | 258 | molecules.erase(id);
|
---|
[3e4fb6] | 259 | moleculeIdPool.releaseId(id);
|
---|
[cbc5fb] | 260 | }
|
---|
| 261 |
|
---|
[46d958] | 262 | atom *World::createAtom(){
|
---|
| 263 | OBSERVE;
|
---|
[3e4fb6] | 264 | atomId_t id = atomIdPool.getNextId();
|
---|
[127a8e] | 265 | ASSERT(!atoms.count(id),"proposed id did not specify an unused ID");
|
---|
[88d586] | 266 | atom *res = NewAtom(id);
|
---|
[46d958] | 267 | res->setWorld(this);
|
---|
[5dfabd] | 268 | // sign on to global atom change tracker
|
---|
| 269 | AtomObserver::getInstance().AtomInserted(res);
|
---|
[244d26] | 270 | // store the atom by ID
|
---|
[46d958] | 271 | atoms[res->getId()] = res;
|
---|
[7188b1] | 272 | _lastchangedatom = res;
|
---|
| 273 | NOTIFY(AtomInserted);
|
---|
[46d958] | 274 | return res;
|
---|
| 275 | }
|
---|
| 276 |
|
---|
[5f612ee] | 277 |
|
---|
[46d958] | 278 | int World::registerAtom(atom *atom){
|
---|
| 279 | OBSERVE;
|
---|
[3e4fb6] | 280 | atomId_t id = atomIdPool.getNextId();
|
---|
[88d586] | 281 | atom->setId(id);
|
---|
[46d958] | 282 | atom->setWorld(this);
|
---|
| 283 | atoms[atom->getId()] = atom;
|
---|
[65d7ca] | 284 | _lastchangedatom = atom;
|
---|
| 285 | NOTIFY(AtomInserted);
|
---|
[46d958] | 286 | return atom->getId();
|
---|
| 287 | }
|
---|
| 288 |
|
---|
| 289 | void World::destroyAtom(atom* atom){
|
---|
| 290 | int id = atom->getId();
|
---|
| 291 | destroyAtom(id);
|
---|
| 292 | }
|
---|
| 293 |
|
---|
[cbc5fb] | 294 | void World::destroyAtom(atomId_t id) {
|
---|
[46d958] | 295 | atom *atom = atoms[id];
|
---|
[6d574a] | 296 | ASSERT(atom,"Atom ID that was meant to be destroyed did not exist");
|
---|
[ab4a33] | 297 | // give notice about immediate removal
|
---|
| 298 | {
|
---|
| 299 | OBSERVE;
|
---|
| 300 | _lastchangedatom = atom;
|
---|
| 301 | NOTIFY(AtomRemoved);
|
---|
| 302 | }
|
---|
[46d958] | 303 | DeleteAtom(atom);
|
---|
[38f991] | 304 | if (isAtomSelected(id))
|
---|
| 305 | selectedAtoms.erase(id);
|
---|
[46d958] | 306 | atoms.erase(id);
|
---|
[3e4fb6] | 307 | atomIdPool.releaseId(id);
|
---|
[88d586] | 308 | }
|
---|
| 309 |
|
---|
| 310 | bool World::changeAtomId(atomId_t oldId, atomId_t newId, atom* target){
|
---|
| 311 | OBSERVE;
|
---|
| 312 | // in case this call did not originate from inside the atom, we redirect it,
|
---|
| 313 | // to also let it know that it has changed
|
---|
| 314 | if(!target){
|
---|
| 315 | target = atoms[oldId];
|
---|
[6d574a] | 316 | ASSERT(target,"Atom with that ID not found");
|
---|
[88d586] | 317 | return target->changeId(newId);
|
---|
| 318 | }
|
---|
| 319 | else{
|
---|
[3e4fb6] | 320 | if(atomIdPool.reserveId(newId)){
|
---|
[88d586] | 321 | atoms.erase(oldId);
|
---|
| 322 | atoms.insert(pair<atomId_t,atom*>(newId,target));
|
---|
| 323 | return true;
|
---|
| 324 | }
|
---|
| 325 | else{
|
---|
| 326 | return false;
|
---|
| 327 | }
|
---|
| 328 | }
|
---|
[46d958] | 329 | }
|
---|
| 330 |
|
---|
[a7a087] | 331 | bool World::changeMoleculeId(moleculeId_t oldId, moleculeId_t newId, molecule* target){
|
---|
| 332 | OBSERVE;
|
---|
| 333 | // in case this call did not originate from inside the atom, we redirect it,
|
---|
| 334 | // to also let it know that it has changed
|
---|
| 335 | if(!target){
|
---|
| 336 | target = molecules[oldId];
|
---|
| 337 | ASSERT(target,"Molecule with that ID not found");
|
---|
| 338 | return target->changeId(newId);
|
---|
| 339 | }
|
---|
| 340 | else{
|
---|
[3e4fb6] | 341 | if(moleculeIdPool.reserveId(newId)){
|
---|
[a7a087] | 342 | molecules.erase(oldId);
|
---|
| 343 | molecules.insert(pair<moleculeId_t,molecule*>(newId,target));
|
---|
| 344 | return true;
|
---|
| 345 | }
|
---|
| 346 | else{
|
---|
| 347 | return false;
|
---|
| 348 | }
|
---|
| 349 | }
|
---|
| 350 | }
|
---|
| 351 |
|
---|
[7c4e29] | 352 | ManipulateAtomsProcess* World::manipulateAtoms(boost::function<void(atom*)> op,std::string name,AtomDescriptor descr){
|
---|
[3139b2] | 353 | ActionTrait manipulateTrait(name);
|
---|
[e4afb4] | 354 | return new ManipulateAtomsProcess(op, descr,manipulateTrait,false);
|
---|
[7c4e29] | 355 | }
|
---|
| 356 |
|
---|
[0e2a47] | 357 | ManipulateAtomsProcess* World::manipulateAtoms(boost::function<void(atom*)> op,std::string name){
|
---|
| 358 | return manipulateAtoms(op,name,AllAtoms());
|
---|
| 359 | }
|
---|
| 360 |
|
---|
[afb47f] | 361 | /********************* Internal Change methods for double Callback and Observer mechanism ********/
|
---|
| 362 |
|
---|
| 363 | void World::doManipulate(ManipulateAtomsProcess *proc){
|
---|
| 364 | proc->signOn(this);
|
---|
| 365 | {
|
---|
| 366 | OBSERVE;
|
---|
| 367 | proc->doManipulate(this);
|
---|
| 368 | }
|
---|
| 369 | proc->signOff(this);
|
---|
| 370 | }
|
---|
[865a945] | 371 | /******************************* Iterators ********************************/
|
---|
| 372 |
|
---|
[fa0b18] | 373 | // external parts with observers
|
---|
| 374 |
|
---|
[feb5d0] | 375 | CONSTRUCT_SELECTIVE_ITERATOR(atom*,World::AtomSet,AtomDescriptor)
|
---|
| 376 |
|
---|
| 377 | CONSTRUCT_SELECTIVE_CONST_ITERATOR(atom*,World::AtomSet,AtomDescriptor)
|
---|
[6e97e5] | 378 |
|
---|
[fa0b18] | 379 | World::AtomIterator
|
---|
| 380 | World::getAtomIter(AtomDescriptor descr){
|
---|
| 381 | return AtomIterator(descr,atoms);
|
---|
| 382 | }
|
---|
[865a945] | 383 |
|
---|
[feb5d0] | 384 | World::AtomConstIterator
|
---|
| 385 | World::getAtomIter(AtomDescriptor descr) const{
|
---|
| 386 | return AtomConstIterator(descr,atoms);
|
---|
| 387 | }
|
---|
| 388 |
|
---|
[fa0b18] | 389 | World::AtomIterator
|
---|
| 390 | World::getAtomIter(){
|
---|
| 391 | return AtomIterator(AllAtoms(),atoms);
|
---|
[865a945] | 392 | }
|
---|
[354859] | 393 |
|
---|
[feb5d0] | 394 | World::AtomConstIterator
|
---|
| 395 | World::getAtomIter() const{
|
---|
| 396 | return AtomConstIterator(AllAtoms(),atoms);
|
---|
| 397 | }
|
---|
| 398 |
|
---|
[fa0b18] | 399 | World::AtomIterator
|
---|
| 400 | World::atomEnd(){
|
---|
[6e97e5] | 401 | return AtomIterator(AllAtoms(),atoms,atoms.end());
|
---|
[7c4e29] | 402 | }
|
---|
| 403 |
|
---|
[feb5d0] | 404 | World::AtomConstIterator
|
---|
| 405 | World::atomEnd() const{
|
---|
| 406 | return AtomConstIterator(AllAtoms(),atoms,atoms.end());
|
---|
| 407 | }
|
---|
| 408 |
|
---|
| 409 | CONSTRUCT_SELECTIVE_ITERATOR(molecule*,World::MoleculeSet,MoleculeDescriptor)
|
---|
| 410 |
|
---|
| 411 | CONSTRUCT_SELECTIVE_CONST_ITERATOR(molecule*,World::MoleculeSet,MoleculeDescriptor)
|
---|
[6e97e5] | 412 |
|
---|
[5d880e] | 413 | World::MoleculeIterator
|
---|
| 414 | World::getMoleculeIter(MoleculeDescriptor descr){
|
---|
| 415 | return MoleculeIterator(descr,molecules);
|
---|
| 416 | }
|
---|
| 417 |
|
---|
[feb5d0] | 418 | World::MoleculeConstIterator
|
---|
| 419 | World::getMoleculeIter(MoleculeDescriptor descr) const{
|
---|
| 420 | return MoleculeConstIterator(descr,molecules);
|
---|
| 421 | }
|
---|
| 422 |
|
---|
[5d880e] | 423 | World::MoleculeIterator
|
---|
| 424 | World::getMoleculeIter(){
|
---|
| 425 | return MoleculeIterator(AllMolecules(),molecules);
|
---|
[1c51c8] | 426 | }
|
---|
| 427 |
|
---|
[feb5d0] | 428 | World::MoleculeConstIterator
|
---|
| 429 | World::getMoleculeIter() const{
|
---|
| 430 | return MoleculeConstIterator(AllMolecules(),molecules);
|
---|
| 431 | }
|
---|
| 432 |
|
---|
[5d880e] | 433 | World::MoleculeIterator
|
---|
| 434 | World::moleculeEnd(){
|
---|
[6e97e5] | 435 | return MoleculeIterator(AllMolecules(),molecules,molecules.end());
|
---|
[1c51c8] | 436 | }
|
---|
| 437 |
|
---|
[feb5d0] | 438 | World::MoleculeConstIterator
|
---|
| 439 | World::moleculeEnd() const{
|
---|
| 440 | return MoleculeConstIterator(AllMolecules(),molecules,molecules.end());
|
---|
| 441 | }
|
---|
| 442 |
|
---|
[fa0b18] | 443 | // Internal parts, without observers
|
---|
| 444 |
|
---|
| 445 | // Build the AtomIterator from template
|
---|
| 446 | CONSTRUCT_SELECTIVE_ITERATOR(atom*,World::AtomSet::set_t,AtomDescriptor);
|
---|
| 447 |
|
---|
| 448 |
|
---|
| 449 | World::internal_AtomIterator
|
---|
| 450 | World::getAtomIter_internal(AtomDescriptor descr){
|
---|
| 451 | return internal_AtomIterator(descr,atoms.getContent());
|
---|
| 452 | }
|
---|
| 453 |
|
---|
| 454 | World::internal_AtomIterator
|
---|
| 455 | World::atomEnd_internal(){
|
---|
| 456 | return internal_AtomIterator(AllAtoms(),atoms.getContent(),atoms.end_internal());
|
---|
| 457 | }
|
---|
| 458 |
|
---|
[6e97e5] | 459 | // build the MoleculeIterator from template
|
---|
[e3d865] | 460 | CONSTRUCT_SELECTIVE_ITERATOR(molecule*,World::MoleculeSet::set_t,MoleculeDescriptor);
|
---|
[6e97e5] | 461 |
|
---|
[e3d865] | 462 | World::internal_MoleculeIterator World::getMoleculeIter_internal(MoleculeDescriptor descr){
|
---|
| 463 | return internal_MoleculeIterator(descr,molecules.getContent());
|
---|
[1c51c8] | 464 | }
|
---|
| 465 |
|
---|
[e3d865] | 466 | World::internal_MoleculeIterator World::moleculeEnd_internal(){
|
---|
| 467 | return internal_MoleculeIterator(AllMolecules(),molecules.getContent(),molecules.end_internal());
|
---|
[1c51c8] | 468 | }
|
---|
| 469 |
|
---|
[90c4280] | 470 | /************************** Selection of Atoms and molecules ******************/
|
---|
| 471 |
|
---|
| 472 | // Atoms
|
---|
| 473 |
|
---|
| 474 | void World::clearAtomSelection(){
|
---|
[69643a] | 475 | OBSERVE;
|
---|
| 476 | NOTIFY(SelectionChanged);
|
---|
[90c4280] | 477 | selectedAtoms.clear();
|
---|
| 478 | }
|
---|
| 479 |
|
---|
[ebc499] | 480 | void World::invertAtomSelection(){
|
---|
| 481 | // get all atoms not selected
|
---|
| 482 | AtomComposite invertedSelection(getAllAtoms());
|
---|
| 483 | bool (World::*predicate)(const atom*) const = &World::isSelected; // needed for type resolution of overloaded function
|
---|
| 484 | AtomComposite::iterator iter =
|
---|
| 485 | std::remove_if(invertedSelection.begin(), invertedSelection.end(),
|
---|
| 486 | std::bind1st(std::mem_fun(predicate), this));
|
---|
| 487 | invertedSelection.erase(iter, invertedSelection.end());
|
---|
| 488 | // apply new selection
|
---|
| 489 | selectedAtoms.clear();
|
---|
| 490 | void (World::*selector)(const atom*) = &World::selectAtom; // needed for type resolution of overloaded function
|
---|
| 491 | std::for_each(invertedSelection.begin(),invertedSelection.end(),
|
---|
| 492 | std::bind1st(std::mem_fun(selector),this)); // func is select... see above
|
---|
| 493 | }
|
---|
| 494 |
|
---|
[e4afb4] | 495 | void World::selectAtom(const atom *_atom){
|
---|
[69643a] | 496 | OBSERVE;
|
---|
| 497 | NOTIFY(SelectionChanged);
|
---|
[e4afb4] | 498 | // atom * is unchanged in this function, but we do store entity as changeable
|
---|
| 499 | ASSERT(_atom,"Invalid pointer in selection of atom");
|
---|
| 500 | selectedAtoms[_atom->getId()]=const_cast<atom *>(_atom);
|
---|
[90c4280] | 501 | }
|
---|
| 502 |
|
---|
[e4afb4] | 503 | void World::selectAtom(const atomId_t id){
|
---|
[69643a] | 504 | OBSERVE;
|
---|
| 505 | NOTIFY(SelectionChanged);
|
---|
[90c4280] | 506 | ASSERT(atoms.count(id),"Atom Id selected that was not in the world");
|
---|
| 507 | selectedAtoms[id]=atoms[id];
|
---|
| 508 | }
|
---|
| 509 |
|
---|
| 510 | void World::selectAllAtoms(AtomDescriptor descr){
|
---|
[69643a] | 511 | OBSERVE;
|
---|
| 512 | NOTIFY(SelectionChanged);
|
---|
[90c4280] | 513 | internal_AtomIterator begin = getAtomIter_internal(descr);
|
---|
| 514 | internal_AtomIterator end = atomEnd_internal();
|
---|
[e4afb4] | 515 | void (World::*func)(const atom*) = &World::selectAtom; // needed for type resolution of overloaded function
|
---|
[90c4280] | 516 | for_each(begin,end,bind1st(mem_fun(func),this)); // func is select... see above
|
---|
| 517 | }
|
---|
| 518 |
|
---|
[e4afb4] | 519 | void World::selectAtomsOfMolecule(const molecule *_mol){
|
---|
[69643a] | 520 | OBSERVE;
|
---|
| 521 | NOTIFY(SelectionChanged);
|
---|
[90c4280] | 522 | ASSERT(_mol,"Invalid pointer to molecule in selection of Atoms of Molecule");
|
---|
| 523 | // need to make it const to get the fast iterators
|
---|
| 524 | const molecule *mol = _mol;
|
---|
[e4afb4] | 525 | void (World::*func)(const atom*) = &World::selectAtom; // needed for type resolution of overloaded function
|
---|
[90c4280] | 526 | for_each(mol->begin(),mol->end(),bind1st(mem_fun(func),this)); // func is select... see above
|
---|
| 527 | }
|
---|
| 528 |
|
---|
[e4afb4] | 529 | void World::selectAtomsOfMolecule(const moleculeId_t id){
|
---|
[69643a] | 530 | OBSERVE;
|
---|
| 531 | NOTIFY(SelectionChanged);
|
---|
[90c4280] | 532 | ASSERT(molecules.count(id),"No molecule with the given id upon Selection of atoms from molecule");
|
---|
| 533 | selectAtomsOfMolecule(molecules[id]);
|
---|
| 534 | }
|
---|
| 535 |
|
---|
[e4afb4] | 536 | void World::unselectAtom(const atom *_atom){
|
---|
[69643a] | 537 | OBSERVE;
|
---|
| 538 | NOTIFY(SelectionChanged);
|
---|
[e4afb4] | 539 | ASSERT(_atom,"Invalid pointer in unselection of atom");
|
---|
| 540 | unselectAtom(_atom->getId());
|
---|
[61d655e] | 541 | }
|
---|
| 542 |
|
---|
[e4afb4] | 543 | void World::unselectAtom(const atomId_t id){
|
---|
[69643a] | 544 | OBSERVE;
|
---|
| 545 | NOTIFY(SelectionChanged);
|
---|
[61d655e] | 546 | ASSERT(atoms.count(id),"Atom Id unselected that was not in the world");
|
---|
| 547 | selectedAtoms.erase(id);
|
---|
| 548 | }
|
---|
| 549 |
|
---|
| 550 | void World::unselectAllAtoms(AtomDescriptor descr){
|
---|
[69643a] | 551 | OBSERVE;
|
---|
| 552 | NOTIFY(SelectionChanged);
|
---|
[61d655e] | 553 | internal_AtomIterator begin = getAtomIter_internal(descr);
|
---|
| 554 | internal_AtomIterator end = atomEnd_internal();
|
---|
[e4afb4] | 555 | void (World::*func)(const atom*) = &World::unselectAtom; // needed for type resolution of overloaded function
|
---|
[61d655e] | 556 | for_each(begin,end,bind1st(mem_fun(func),this)); // func is unselect... see above
|
---|
| 557 | }
|
---|
| 558 |
|
---|
[e4afb4] | 559 | void World::unselectAtomsOfMolecule(const molecule *_mol){
|
---|
[69643a] | 560 | OBSERVE;
|
---|
| 561 | NOTIFY(SelectionChanged);
|
---|
[61d655e] | 562 | ASSERT(_mol,"Invalid pointer to molecule in selection of Atoms of Molecule");
|
---|
| 563 | // need to make it const to get the fast iterators
|
---|
| 564 | const molecule *mol = _mol;
|
---|
[e4afb4] | 565 | void (World::*func)(const atom*) = &World::unselectAtom; // needed for type resolution of overloaded function
|
---|
[992bd5] | 566 | for_each(mol->begin(),mol->end(),bind1st(mem_fun(func),this)); // func is unselect... see above
|
---|
[61d655e] | 567 | }
|
---|
| 568 |
|
---|
[e4afb4] | 569 | void World::unselectAtomsOfMolecule(const moleculeId_t id){
|
---|
[69643a] | 570 | OBSERVE;
|
---|
| 571 | NOTIFY(SelectionChanged);
|
---|
[61d655e] | 572 | ASSERT(molecules.count(id),"No molecule with the given id upon Selection of atoms from molecule");
|
---|
| 573 | unselectAtomsOfMolecule(molecules[id]);
|
---|
| 574 | }
|
---|
| 575 |
|
---|
[e472eab] | 576 | size_t World::countSelectedAtoms() const {
|
---|
[eacc3b] | 577 | size_t count = 0;
|
---|
[e472eab] | 578 | for (AtomSet::const_iterator iter = selectedAtoms.begin(); iter != selectedAtoms.end(); ++iter)
|
---|
[eacc3b] | 579 | count++;
|
---|
| 580 | return count;
|
---|
| 581 | }
|
---|
| 582 |
|
---|
[e4afb4] | 583 | bool World::isSelected(const atom *_atom) const {
|
---|
[89643d] | 584 | return isAtomSelected(_atom->getId());
|
---|
| 585 | }
|
---|
| 586 |
|
---|
| 587 | bool World::isAtomSelected(const atomId_t no) const {
|
---|
| 588 | return selectedAtoms.find(no) != selectedAtoms.end();
|
---|
[e0e156] | 589 | }
|
---|
| 590 |
|
---|
[e472eab] | 591 | const std::vector<atom *> World::getSelectedAtoms() const {
|
---|
| 592 | std::vector<atom *> returnAtoms;
|
---|
| 593 | returnAtoms.resize(countSelectedAtoms());
|
---|
| 594 | int count = 0;
|
---|
| 595 | for (AtomSet::const_iterator iter = selectedAtoms.begin(); iter != selectedAtoms.end(); ++iter)
|
---|
| 596 | returnAtoms[count++] = iter->second;
|
---|
| 597 | return returnAtoms;
|
---|
| 598 | }
|
---|
| 599 |
|
---|
| 600 |
|
---|
[90c4280] | 601 | // Molecules
|
---|
| 602 |
|
---|
| 603 | void World::clearMoleculeSelection(){
|
---|
[69643a] | 604 | OBSERVE;
|
---|
| 605 | NOTIFY(SelectionChanged);
|
---|
[90c4280] | 606 | selectedMolecules.clear();
|
---|
| 607 | }
|
---|
| 608 |
|
---|
[ebc499] | 609 | void World::invertMoleculeSelection(){
|
---|
| 610 | // get all molecules not selected
|
---|
| 611 | typedef std::vector<molecule *> MoleculeVector_t;
|
---|
| 612 | MoleculeVector_t invertedSelection(getAllMolecules());
|
---|
| 613 | bool (World::*predicate)(const molecule*) const = &World::isSelected; // needed for type resolution of overloaded function
|
---|
| 614 | MoleculeVector_t::iterator iter =
|
---|
| 615 | std::remove_if(invertedSelection.begin(), invertedSelection.end(),
|
---|
| 616 | std::bind1st(std::mem_fun(predicate), this));
|
---|
| 617 | invertedSelection.erase(iter, invertedSelection.end());
|
---|
| 618 | // apply new selection
|
---|
| 619 | selectedMolecules.clear();
|
---|
| 620 | void (World::*selector)(const molecule*) = &World::selectMolecule; // needed for type resolution of overloaded function
|
---|
| 621 | std::for_each(invertedSelection.begin(),invertedSelection.end(),
|
---|
| 622 | std::bind1st(std::mem_fun(selector),this)); // func is select... see above
|
---|
| 623 | }
|
---|
| 624 |
|
---|
[e4afb4] | 625 | void World::selectMolecule(const molecule *_mol){
|
---|
[69643a] | 626 | OBSERVE;
|
---|
| 627 | NOTIFY(SelectionChanged);
|
---|
[e4afb4] | 628 | // molecule * is unchanged in this function, but we do store entity as changeable
|
---|
| 629 | ASSERT(_mol,"Invalid pointer to molecule in selection");
|
---|
| 630 | selectedMolecules[_mol->getId()]=const_cast<molecule *>(_mol);
|
---|
[90c4280] | 631 | }
|
---|
| 632 |
|
---|
[e4afb4] | 633 | void World::selectMolecule(const moleculeId_t id){
|
---|
[69643a] | 634 | OBSERVE;
|
---|
| 635 | NOTIFY(SelectionChanged);
|
---|
[90c4280] | 636 | ASSERT(molecules.count(id),"Molecule Id selected that was not in the world");
|
---|
| 637 | selectedMolecules[id]=molecules[id];
|
---|
| 638 | }
|
---|
| 639 |
|
---|
[e472eab] | 640 | void World::selectAllMolecules(MoleculeDescriptor descr){
|
---|
[69643a] | 641 | OBSERVE;
|
---|
| 642 | NOTIFY(SelectionChanged);
|
---|
[90c4280] | 643 | internal_MoleculeIterator begin = getMoleculeIter_internal(descr);
|
---|
| 644 | internal_MoleculeIterator end = moleculeEnd_internal();
|
---|
[e4afb4] | 645 | void (World::*func)(const molecule*) = &World::selectMolecule; // needed for type resolution of overloaded function
|
---|
[90c4280] | 646 | for_each(begin,end,bind1st(mem_fun(func),this)); // func is select... see above
|
---|
| 647 | }
|
---|
| 648 |
|
---|
[e4afb4] | 649 | void World::selectMoleculeOfAtom(const atom *_atom){
|
---|
[69643a] | 650 | OBSERVE;
|
---|
| 651 | NOTIFY(SelectionChanged);
|
---|
[e4afb4] | 652 | ASSERT(_atom,"Invalid atom pointer in selection of MoleculeOfAtom");
|
---|
| 653 | molecule *mol=_atom->getMolecule();
|
---|
[90c4280] | 654 | // the atom might not be part of a molecule
|
---|
| 655 | if(mol){
|
---|
| 656 | selectMolecule(mol);
|
---|
| 657 | }
|
---|
| 658 | }
|
---|
| 659 |
|
---|
[e4afb4] | 660 | void World::selectMoleculeOfAtom(const atomId_t id){
|
---|
[69643a] | 661 | OBSERVE;
|
---|
| 662 | NOTIFY(SelectionChanged);
|
---|
[90c4280] | 663 | ASSERT(atoms.count(id),"No such atom with given ID in selection of Molecules of Atom");\
|
---|
| 664 | selectMoleculeOfAtom(atoms[id]);
|
---|
| 665 | }
|
---|
| 666 |
|
---|
[e4afb4] | 667 | void World::unselectMolecule(const molecule *_mol){
|
---|
[69643a] | 668 | OBSERVE;
|
---|
| 669 | NOTIFY(SelectionChanged);
|
---|
[e4afb4] | 670 | ASSERT(_mol,"invalid pointer in unselection of molecule");
|
---|
| 671 | unselectMolecule(_mol->getId());
|
---|
[61d655e] | 672 | }
|
---|
| 673 |
|
---|
[e4afb4] | 674 | void World::unselectMolecule(const moleculeId_t id){
|
---|
[69643a] | 675 | OBSERVE;
|
---|
| 676 | NOTIFY(SelectionChanged);
|
---|
[61d655e] | 677 | ASSERT(molecules.count(id),"No such molecule with ID in unselection");
|
---|
| 678 | selectedMolecules.erase(id);
|
---|
| 679 | }
|
---|
| 680 |
|
---|
[e472eab] | 681 | void World::unselectAllMolecules(MoleculeDescriptor descr){
|
---|
[69643a] | 682 | OBSERVE;
|
---|
| 683 | NOTIFY(SelectionChanged);
|
---|
[61d655e] | 684 | internal_MoleculeIterator begin = getMoleculeIter_internal(descr);
|
---|
| 685 | internal_MoleculeIterator end = moleculeEnd_internal();
|
---|
[e4afb4] | 686 | void (World::*func)(const molecule*) = &World::unselectMolecule; // needed for type resolution of overloaded function
|
---|
[61d655e] | 687 | for_each(begin,end,bind1st(mem_fun(func),this)); // func is unselect... see above
|
---|
| 688 | }
|
---|
| 689 |
|
---|
[e4afb4] | 690 | void World::unselectMoleculeOfAtom(const atom *_atom){
|
---|
[69643a] | 691 | OBSERVE;
|
---|
| 692 | NOTIFY(SelectionChanged);
|
---|
[e4afb4] | 693 | ASSERT(_atom,"Invalid atom pointer in selection of MoleculeOfAtom");
|
---|
| 694 | molecule *mol=_atom->getMolecule();
|
---|
[61d655e] | 695 | // the atom might not be part of a molecule
|
---|
| 696 | if(mol){
|
---|
| 697 | unselectMolecule(mol);
|
---|
| 698 | }
|
---|
| 699 | }
|
---|
| 700 |
|
---|
[e4afb4] | 701 | void World::unselectMoleculeOfAtom(const atomId_t id){
|
---|
[69643a] | 702 | OBSERVE;
|
---|
| 703 | NOTIFY(SelectionChanged);
|
---|
[61d655e] | 704 | ASSERT(atoms.count(id),"No such atom with given ID in selection of Molecules of Atom");\
|
---|
| 705 | unselectMoleculeOfAtom(atoms[id]);
|
---|
| 706 | }
|
---|
| 707 |
|
---|
[e472eab] | 708 | size_t World::countSelectedMolecules() const {
|
---|
[eacc3b] | 709 | size_t count = 0;
|
---|
[e472eab] | 710 | for (MoleculeSet::const_iterator iter = selectedMolecules.begin(); iter != selectedMolecules.end(); ++iter)
|
---|
[eacc3b] | 711 | count++;
|
---|
| 712 | return count;
|
---|
| 713 | }
|
---|
| 714 |
|
---|
[e4afb4] | 715 | bool World::isSelected(const molecule *_mol) const {
|
---|
[89643d] | 716 | return isMoleculeSelected(_mol->getId());
|
---|
| 717 | }
|
---|
| 718 |
|
---|
| 719 | bool World::isMoleculeSelected(const moleculeId_t no) const {
|
---|
| 720 | return selectedMolecules.find(no) != selectedMolecules.end();
|
---|
[e0e156] | 721 | }
|
---|
| 722 |
|
---|
[e472eab] | 723 | const std::vector<molecule *> World::getSelectedMolecules() const {
|
---|
| 724 | std::vector<molecule *> returnMolecules;
|
---|
| 725 | returnMolecules.resize(countSelectedMolecules());
|
---|
| 726 | int count = 0;
|
---|
| 727 | for (MoleculeSet::const_iterator iter = selectedMolecules.begin(); iter != selectedMolecules.end(); ++iter)
|
---|
| 728 | returnMolecules[count++] = iter->second;
|
---|
| 729 | return returnMolecules;
|
---|
| 730 | }
|
---|
| 731 |
|
---|
[3839e5] | 732 | /******************* Iterators over Selection *****************************/
|
---|
| 733 | World::AtomSelectionIterator World::beginAtomSelection(){
|
---|
| 734 | return selectedAtoms.begin();
|
---|
| 735 | }
|
---|
| 736 |
|
---|
| 737 | World::AtomSelectionIterator World::endAtomSelection(){
|
---|
| 738 | return selectedAtoms.end();
|
---|
| 739 | }
|
---|
| 740 |
|
---|
[38f991] | 741 | World::AtomSelectionConstIterator World::beginAtomSelection() const{
|
---|
| 742 | return selectedAtoms.begin();
|
---|
| 743 | }
|
---|
| 744 |
|
---|
| 745 | World::AtomSelectionConstIterator World::endAtomSelection() const{
|
---|
| 746 | return selectedAtoms.end();
|
---|
| 747 | }
|
---|
| 748 |
|
---|
[3839e5] | 749 |
|
---|
| 750 | World::MoleculeSelectionIterator World::beginMoleculeSelection(){
|
---|
| 751 | return selectedMolecules.begin();
|
---|
| 752 | }
|
---|
| 753 |
|
---|
| 754 | World::MoleculeSelectionIterator World::endMoleculeSelection(){
|
---|
| 755 | return selectedMolecules.end();
|
---|
| 756 | }
|
---|
| 757 |
|
---|
[38f991] | 758 | World::MoleculeSelectionConstIterator World::beginMoleculeSelection() const{
|
---|
| 759 | return selectedMolecules.begin();
|
---|
| 760 | }
|
---|
| 761 |
|
---|
| 762 | World::MoleculeSelectionConstIterator World::endMoleculeSelection() const{
|
---|
| 763 | return selectedMolecules.end();
|
---|
| 764 | }
|
---|
| 765 |
|
---|
[5d1611] | 766 | /******************************* Singleton Stuff **************************/
|
---|
| 767 |
|
---|
[7a1ce5] | 768 | World::World() :
|
---|
[cd5047] | 769 | Observable("World"),
|
---|
[f71baf] | 770 | BG(new BondGraph(true)), // assume Angstroem for the moment
|
---|
[4ae823] | 771 | periode(new periodentafel(true)),
|
---|
[8e1f7af] | 772 | configuration(new config),
|
---|
[43dad6] | 773 | Thermostats(new ThermoStatContainer),
|
---|
[e4b5de] | 774 | ExitFlag(0),
|
---|
[fa0b18] | 775 | atoms(this),
|
---|
[90c4280] | 776 | selectedAtoms(this),
|
---|
[3e4fb6] | 777 | atomIdPool(0, 20, 100),
|
---|
[51be2a] | 778 | molecules(this),
|
---|
[90c4280] | 779 | selectedMolecules(this),
|
---|
[3e4fb6] | 780 | moleculeIdPool(0, 20,100),
|
---|
[24a5e0] | 781 | molecules_deprecated(new MoleculeListClass(this))
|
---|
[7dad10] | 782 | {
|
---|
[84c494] | 783 | cell_size = new Box;
|
---|
[cca9ef] | 784 | RealSpaceMatrix domain;
|
---|
[84c494] | 785 | domain.at(0,0) = 20;
|
---|
| 786 | domain.at(1,1) = 20;
|
---|
| 787 | domain.at(2,2) = 20;
|
---|
| 788 | cell_size->setM(domain);
|
---|
[4834f4] | 789 | LCcontroller = new LinkedCell::LinkedCell_Controller(*cell_size);
|
---|
[387b36] | 790 | defaultName = "none";
|
---|
[02ce36] | 791 | Channels *OurChannel = new Channels;
|
---|
| 792 | NotificationChannels.insert( std::make_pair( this, OurChannel) );
|
---|
[7188b1] | 793 | for (size_t type = 0; type < (size_t)NotificationType_MAX; ++type)
|
---|
[02ce36] | 794 | OurChannel->addChannel(type);
|
---|
[7dad10] | 795 | molecules_deprecated->signOn(this);
|
---|
| 796 | }
|
---|
[5d1611] | 797 |
|
---|
| 798 | World::~World()
|
---|
[354859] | 799 | {
|
---|
[028c2e] | 800 | molecules_deprecated->signOff(this);
|
---|
[4834f4] | 801 | delete LCcontroller;
|
---|
[84c494] | 802 | delete cell_size;
|
---|
[46d958] | 803 | delete molecules_deprecated;
|
---|
[cbc5fb] | 804 | MoleculeSet::iterator molIter;
|
---|
| 805 | for(molIter=molecules.begin();molIter!=molecules.end();++molIter){
|
---|
| 806 | DeleteMolecule((*molIter).second);
|
---|
| 807 | }
|
---|
| 808 | molecules.clear();
|
---|
| 809 | AtomSet::iterator atIter;
|
---|
| 810 | for(atIter=atoms.begin();atIter!=atoms.end();++atIter){
|
---|
| 811 | DeleteAtom((*atIter).second);
|
---|
[46d958] | 812 | }
|
---|
| 813 | atoms.clear();
|
---|
[7188b1] | 814 |
|
---|
| 815 | // empty notifications
|
---|
[02ce36] | 816 | std::map<Observable *, Channels*>::iterator iter = NotificationChannels.find(this);
|
---|
| 817 | ASSERT(iter != NotificationChannels.end(),
|
---|
| 818 | "World::~World() - cannot find our Channels in NotificationChannels.");
|
---|
| 819 | delete iter->second;
|
---|
| 820 | NotificationChannels.erase(iter);
|
---|
[7188b1] | 821 |
|
---|
[f71baf] | 822 | delete BG;
|
---|
[6cb9c76] | 823 | delete periode;
|
---|
| 824 | delete configuration;
|
---|
| 825 | delete Thermostats;
|
---|
[354859] | 826 | }
|
---|
[5d1611] | 827 |
|
---|
[23b547] | 828 | // Explicit instantiation of the singleton mechanism at this point
|
---|
[5d1611] | 829 |
|
---|
[3e4fb6] | 830 | // moleculeId_t und atomId_t sind gleicher Basistyp, deswegen nur einen von beiden konstruieren
|
---|
[b97a60] | 831 | CONSTRUCT_IDPOOL(atomId_t, uniqueId)
|
---|
| 832 | CONSTRUCT_IDPOOL(moleculeId_t, continuousId)
|
---|
[3e4fb6] | 833 |
|
---|
[23b547] | 834 | CONSTRUCT_SINGLETON(World)
|
---|
[5d1611] | 835 |
|
---|
[5f1d5b8] | 836 | CONSTRUCT_OBSERVEDCONTAINER(World::AtomSTLSet)
|
---|
| 837 |
|
---|
| 838 | CONSTRUCT_OBSERVEDCONTAINER(World::MoleculeSTLSet)
|
---|
| 839 |
|
---|
[5d1611] | 840 | /******************************* deprecated Legacy Stuff ***********************/
|
---|
| 841 |
|
---|
[354859] | 842 | MoleculeListClass *&World::getMolecules() {
|
---|
| 843 | return molecules_deprecated;
|
---|
[5d1611] | 844 | }
|
---|