[bcf653] | 1 | /*
|
---|
| 2 | * Project: MoleCuilder
|
---|
| 3 | * Description: creates and alters molecular systems
|
---|
[0aa122] | 4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
---|
[5aaa43] | 5 | * Copyright (C) 2013 Frederik Heber. All rights reserved.
|
---|
[94d5ac6] | 6 | *
|
---|
| 7 | *
|
---|
| 8 | * This file is part of MoleCuilder.
|
---|
| 9 | *
|
---|
| 10 | * MoleCuilder is free software: you can redistribute it and/or modify
|
---|
| 11 | * it under the terms of the GNU General Public License as published by
|
---|
| 12 | * the Free Software Foundation, either version 2 of the License, or
|
---|
| 13 | * (at your option) any later version.
|
---|
| 14 | *
|
---|
| 15 | * MoleCuilder is distributed in the hope that it will be useful,
|
---|
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 18 | * GNU General Public License for more details.
|
---|
| 19 | *
|
---|
| 20 | * You should have received a copy of the GNU General Public License
|
---|
| 21 | * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
|
---|
[bcf653] | 22 | */
|
---|
| 23 |
|
---|
[5d1611] | 24 | /*
|
---|
| 25 | * World.cpp
|
---|
| 26 | *
|
---|
| 27 | * Created on: Feb 3, 2010
|
---|
| 28 | * Author: crueger
|
---|
| 29 | */
|
---|
| 30 |
|
---|
[bf3817] | 31 | // include config.h
|
---|
| 32 | #ifdef HAVE_CONFIG_H
|
---|
| 33 | #include <config.h>
|
---|
| 34 | #endif
|
---|
| 35 |
|
---|
[ad011c] | 36 | #include "CodePatterns/MemDebug.hpp"
|
---|
[112b09] | 37 |
|
---|
[5d1611] | 38 | #include "World.hpp"
|
---|
| 39 |
|
---|
[90c4280] | 40 | #include <functional>
|
---|
[5d1611] | 41 |
|
---|
[3139b2] | 42 | #include "Actions/ActionTrait.hpp"
|
---|
[d297a3] | 43 | #include "Actions/ManipulateAtomsProcess.hpp"
|
---|
[6f0841] | 44 | #include "Atom/atom.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);
|
---|
[244d26] | 268 | // store the atom by ID
|
---|
[46d958] | 269 | atoms[res->getId()] = res;
|
---|
[7188b1] | 270 | _lastchangedatom = res;
|
---|
| 271 | NOTIFY(AtomInserted);
|
---|
[46d958] | 272 | return res;
|
---|
| 273 | }
|
---|
| 274 |
|
---|
[5f612ee] | 275 |
|
---|
[46d958] | 276 | int World::registerAtom(atom *atom){
|
---|
| 277 | OBSERVE;
|
---|
[3e4fb6] | 278 | atomId_t id = atomIdPool.getNextId();
|
---|
[88d586] | 279 | atom->setId(id);
|
---|
[46d958] | 280 | atom->setWorld(this);
|
---|
| 281 | atoms[atom->getId()] = atom;
|
---|
[65d7ca] | 282 | _lastchangedatom = atom;
|
---|
| 283 | NOTIFY(AtomInserted);
|
---|
[46d958] | 284 | return atom->getId();
|
---|
| 285 | }
|
---|
| 286 |
|
---|
| 287 | void World::destroyAtom(atom* atom){
|
---|
| 288 | int id = atom->getId();
|
---|
| 289 | destroyAtom(id);
|
---|
| 290 | }
|
---|
| 291 |
|
---|
[cbc5fb] | 292 | void World::destroyAtom(atomId_t id) {
|
---|
[46d958] | 293 | atom *atom = atoms[id];
|
---|
[6d574a] | 294 | ASSERT(atom,"Atom ID that was meant to be destroyed did not exist");
|
---|
[ab4a33] | 295 | // give notice about immediate removal
|
---|
| 296 | {
|
---|
| 297 | OBSERVE;
|
---|
| 298 | _lastchangedatom = atom;
|
---|
| 299 | NOTIFY(AtomRemoved);
|
---|
| 300 | }
|
---|
[46d958] | 301 | DeleteAtom(atom);
|
---|
[38f991] | 302 | if (isAtomSelected(id))
|
---|
| 303 | selectedAtoms.erase(id);
|
---|
[46d958] | 304 | atoms.erase(id);
|
---|
[3e4fb6] | 305 | atomIdPool.releaseId(id);
|
---|
[88d586] | 306 | }
|
---|
| 307 |
|
---|
| 308 | bool World::changeAtomId(atomId_t oldId, atomId_t newId, atom* target){
|
---|
| 309 | OBSERVE;
|
---|
| 310 | // in case this call did not originate from inside the atom, we redirect it,
|
---|
| 311 | // to also let it know that it has changed
|
---|
| 312 | if(!target){
|
---|
| 313 | target = atoms[oldId];
|
---|
[6d574a] | 314 | ASSERT(target,"Atom with that ID not found");
|
---|
[88d586] | 315 | return target->changeId(newId);
|
---|
| 316 | }
|
---|
| 317 | else{
|
---|
[3e4fb6] | 318 | if(atomIdPool.reserveId(newId)){
|
---|
[88d586] | 319 | atoms.erase(oldId);
|
---|
| 320 | atoms.insert(pair<atomId_t,atom*>(newId,target));
|
---|
| 321 | return true;
|
---|
| 322 | }
|
---|
| 323 | else{
|
---|
| 324 | return false;
|
---|
| 325 | }
|
---|
| 326 | }
|
---|
[46d958] | 327 | }
|
---|
| 328 |
|
---|
[a7a087] | 329 | bool World::changeMoleculeId(moleculeId_t oldId, moleculeId_t newId, molecule* target){
|
---|
| 330 | OBSERVE;
|
---|
| 331 | // in case this call did not originate from inside the atom, we redirect it,
|
---|
| 332 | // to also let it know that it has changed
|
---|
| 333 | if(!target){
|
---|
| 334 | target = molecules[oldId];
|
---|
| 335 | ASSERT(target,"Molecule with that ID not found");
|
---|
| 336 | return target->changeId(newId);
|
---|
| 337 | }
|
---|
| 338 | else{
|
---|
[3e4fb6] | 339 | if(moleculeIdPool.reserveId(newId)){
|
---|
[a7a087] | 340 | molecules.erase(oldId);
|
---|
| 341 | molecules.insert(pair<moleculeId_t,molecule*>(newId,target));
|
---|
| 342 | return true;
|
---|
| 343 | }
|
---|
| 344 | else{
|
---|
| 345 | return false;
|
---|
| 346 | }
|
---|
| 347 | }
|
---|
| 348 | }
|
---|
| 349 |
|
---|
[7c4e29] | 350 | ManipulateAtomsProcess* World::manipulateAtoms(boost::function<void(atom*)> op,std::string name,AtomDescriptor descr){
|
---|
[3139b2] | 351 | ActionTrait manipulateTrait(name);
|
---|
[e4afb4] | 352 | return new ManipulateAtomsProcess(op, descr,manipulateTrait,false);
|
---|
[7c4e29] | 353 | }
|
---|
| 354 |
|
---|
[0e2a47] | 355 | ManipulateAtomsProcess* World::manipulateAtoms(boost::function<void(atom*)> op,std::string name){
|
---|
| 356 | return manipulateAtoms(op,name,AllAtoms());
|
---|
| 357 | }
|
---|
| 358 |
|
---|
[afb47f] | 359 | /********************* Internal Change methods for double Callback and Observer mechanism ********/
|
---|
| 360 |
|
---|
| 361 | void World::doManipulate(ManipulateAtomsProcess *proc){
|
---|
| 362 | proc->signOn(this);
|
---|
| 363 | {
|
---|
| 364 | OBSERVE;
|
---|
| 365 | proc->doManipulate(this);
|
---|
| 366 | }
|
---|
| 367 | proc->signOff(this);
|
---|
| 368 | }
|
---|
[865a945] | 369 | /******************************* Iterators ********************************/
|
---|
| 370 |
|
---|
[fa0b18] | 371 | // external parts with observers
|
---|
| 372 |
|
---|
[feb5d0] | 373 | CONSTRUCT_SELECTIVE_ITERATOR(atom*,World::AtomSet,AtomDescriptor)
|
---|
| 374 |
|
---|
| 375 | CONSTRUCT_SELECTIVE_CONST_ITERATOR(atom*,World::AtomSet,AtomDescriptor)
|
---|
[6e97e5] | 376 |
|
---|
[fa0b18] | 377 | World::AtomIterator
|
---|
| 378 | World::getAtomIter(AtomDescriptor descr){
|
---|
| 379 | return AtomIterator(descr,atoms);
|
---|
| 380 | }
|
---|
[865a945] | 381 |
|
---|
[feb5d0] | 382 | World::AtomConstIterator
|
---|
| 383 | World::getAtomIter(AtomDescriptor descr) const{
|
---|
| 384 | return AtomConstIterator(descr,atoms);
|
---|
| 385 | }
|
---|
| 386 |
|
---|
[fa0b18] | 387 | World::AtomIterator
|
---|
| 388 | World::getAtomIter(){
|
---|
| 389 | return AtomIterator(AllAtoms(),atoms);
|
---|
[865a945] | 390 | }
|
---|
[354859] | 391 |
|
---|
[feb5d0] | 392 | World::AtomConstIterator
|
---|
| 393 | World::getAtomIter() const{
|
---|
| 394 | return AtomConstIterator(AllAtoms(),atoms);
|
---|
| 395 | }
|
---|
| 396 |
|
---|
[fa0b18] | 397 | World::AtomIterator
|
---|
| 398 | World::atomEnd(){
|
---|
[6e97e5] | 399 | return AtomIterator(AllAtoms(),atoms,atoms.end());
|
---|
[7c4e29] | 400 | }
|
---|
| 401 |
|
---|
[feb5d0] | 402 | World::AtomConstIterator
|
---|
| 403 | World::atomEnd() const{
|
---|
| 404 | return AtomConstIterator(AllAtoms(),atoms,atoms.end());
|
---|
| 405 | }
|
---|
| 406 |
|
---|
| 407 | CONSTRUCT_SELECTIVE_ITERATOR(molecule*,World::MoleculeSet,MoleculeDescriptor)
|
---|
| 408 |
|
---|
| 409 | CONSTRUCT_SELECTIVE_CONST_ITERATOR(molecule*,World::MoleculeSet,MoleculeDescriptor)
|
---|
[6e97e5] | 410 |
|
---|
[5d880e] | 411 | World::MoleculeIterator
|
---|
| 412 | World::getMoleculeIter(MoleculeDescriptor descr){
|
---|
| 413 | return MoleculeIterator(descr,molecules);
|
---|
| 414 | }
|
---|
| 415 |
|
---|
[feb5d0] | 416 | World::MoleculeConstIterator
|
---|
| 417 | World::getMoleculeIter(MoleculeDescriptor descr) const{
|
---|
| 418 | return MoleculeConstIterator(descr,molecules);
|
---|
| 419 | }
|
---|
| 420 |
|
---|
[5d880e] | 421 | World::MoleculeIterator
|
---|
| 422 | World::getMoleculeIter(){
|
---|
| 423 | return MoleculeIterator(AllMolecules(),molecules);
|
---|
[1c51c8] | 424 | }
|
---|
| 425 |
|
---|
[feb5d0] | 426 | World::MoleculeConstIterator
|
---|
| 427 | World::getMoleculeIter() const{
|
---|
| 428 | return MoleculeConstIterator(AllMolecules(),molecules);
|
---|
| 429 | }
|
---|
| 430 |
|
---|
[5d880e] | 431 | World::MoleculeIterator
|
---|
| 432 | World::moleculeEnd(){
|
---|
[6e97e5] | 433 | return MoleculeIterator(AllMolecules(),molecules,molecules.end());
|
---|
[1c51c8] | 434 | }
|
---|
| 435 |
|
---|
[feb5d0] | 436 | World::MoleculeConstIterator
|
---|
| 437 | World::moleculeEnd() const{
|
---|
| 438 | return MoleculeConstIterator(AllMolecules(),molecules,molecules.end());
|
---|
| 439 | }
|
---|
| 440 |
|
---|
[fa0b18] | 441 | // Internal parts, without observers
|
---|
| 442 |
|
---|
| 443 | // Build the AtomIterator from template
|
---|
| 444 | CONSTRUCT_SELECTIVE_ITERATOR(atom*,World::AtomSet::set_t,AtomDescriptor);
|
---|
| 445 |
|
---|
| 446 |
|
---|
| 447 | World::internal_AtomIterator
|
---|
| 448 | World::getAtomIter_internal(AtomDescriptor descr){
|
---|
| 449 | return internal_AtomIterator(descr,atoms.getContent());
|
---|
| 450 | }
|
---|
| 451 |
|
---|
| 452 | World::internal_AtomIterator
|
---|
| 453 | World::atomEnd_internal(){
|
---|
| 454 | return internal_AtomIterator(AllAtoms(),atoms.getContent(),atoms.end_internal());
|
---|
| 455 | }
|
---|
| 456 |
|
---|
[6e97e5] | 457 | // build the MoleculeIterator from template
|
---|
[e3d865] | 458 | CONSTRUCT_SELECTIVE_ITERATOR(molecule*,World::MoleculeSet::set_t,MoleculeDescriptor);
|
---|
[6e97e5] | 459 |
|
---|
[e3d865] | 460 | World::internal_MoleculeIterator World::getMoleculeIter_internal(MoleculeDescriptor descr){
|
---|
| 461 | return internal_MoleculeIterator(descr,molecules.getContent());
|
---|
[1c51c8] | 462 | }
|
---|
| 463 |
|
---|
[e3d865] | 464 | World::internal_MoleculeIterator World::moleculeEnd_internal(){
|
---|
| 465 | return internal_MoleculeIterator(AllMolecules(),molecules.getContent(),molecules.end_internal());
|
---|
[1c51c8] | 466 | }
|
---|
| 467 |
|
---|
[90c4280] | 468 | /************************** Selection of Atoms and molecules ******************/
|
---|
| 469 |
|
---|
| 470 | // Atoms
|
---|
| 471 |
|
---|
| 472 | void World::clearAtomSelection(){
|
---|
[69643a] | 473 | OBSERVE;
|
---|
| 474 | NOTIFY(SelectionChanged);
|
---|
[90c4280] | 475 | selectedAtoms.clear();
|
---|
| 476 | }
|
---|
| 477 |
|
---|
[ebc499] | 478 | void World::invertAtomSelection(){
|
---|
| 479 | // get all atoms not selected
|
---|
| 480 | AtomComposite invertedSelection(getAllAtoms());
|
---|
| 481 | bool (World::*predicate)(const atom*) const = &World::isSelected; // needed for type resolution of overloaded function
|
---|
| 482 | AtomComposite::iterator iter =
|
---|
| 483 | std::remove_if(invertedSelection.begin(), invertedSelection.end(),
|
---|
| 484 | std::bind1st(std::mem_fun(predicate), this));
|
---|
| 485 | invertedSelection.erase(iter, invertedSelection.end());
|
---|
| 486 | // apply new selection
|
---|
| 487 | selectedAtoms.clear();
|
---|
| 488 | void (World::*selector)(const atom*) = &World::selectAtom; // needed for type resolution of overloaded function
|
---|
| 489 | std::for_each(invertedSelection.begin(),invertedSelection.end(),
|
---|
| 490 | std::bind1st(std::mem_fun(selector),this)); // func is select... see above
|
---|
| 491 | }
|
---|
| 492 |
|
---|
[e4afb4] | 493 | void World::selectAtom(const atom *_atom){
|
---|
[69643a] | 494 | OBSERVE;
|
---|
| 495 | NOTIFY(SelectionChanged);
|
---|
[e4afb4] | 496 | // atom * is unchanged in this function, but we do store entity as changeable
|
---|
| 497 | ASSERT(_atom,"Invalid pointer in selection of atom");
|
---|
| 498 | selectedAtoms[_atom->getId()]=const_cast<atom *>(_atom);
|
---|
[90c4280] | 499 | }
|
---|
| 500 |
|
---|
[e4afb4] | 501 | void World::selectAtom(const atomId_t id){
|
---|
[69643a] | 502 | OBSERVE;
|
---|
| 503 | NOTIFY(SelectionChanged);
|
---|
[90c4280] | 504 | ASSERT(atoms.count(id),"Atom Id selected that was not in the world");
|
---|
| 505 | selectedAtoms[id]=atoms[id];
|
---|
| 506 | }
|
---|
| 507 |
|
---|
| 508 | void World::selectAllAtoms(AtomDescriptor descr){
|
---|
[69643a] | 509 | OBSERVE;
|
---|
| 510 | NOTIFY(SelectionChanged);
|
---|
[90c4280] | 511 | internal_AtomIterator begin = getAtomIter_internal(descr);
|
---|
| 512 | internal_AtomIterator end = atomEnd_internal();
|
---|
[e4afb4] | 513 | void (World::*func)(const atom*) = &World::selectAtom; // needed for type resolution of overloaded function
|
---|
[90c4280] | 514 | for_each(begin,end,bind1st(mem_fun(func),this)); // func is select... see above
|
---|
| 515 | }
|
---|
| 516 |
|
---|
[e4afb4] | 517 | void World::selectAtomsOfMolecule(const molecule *_mol){
|
---|
[69643a] | 518 | OBSERVE;
|
---|
| 519 | NOTIFY(SelectionChanged);
|
---|
[90c4280] | 520 | ASSERT(_mol,"Invalid pointer to molecule in selection of Atoms of Molecule");
|
---|
| 521 | // need to make it const to get the fast iterators
|
---|
| 522 | const molecule *mol = _mol;
|
---|
[e4afb4] | 523 | void (World::*func)(const atom*) = &World::selectAtom; // needed for type resolution of overloaded function
|
---|
[90c4280] | 524 | for_each(mol->begin(),mol->end(),bind1st(mem_fun(func),this)); // func is select... see above
|
---|
| 525 | }
|
---|
| 526 |
|
---|
[e4afb4] | 527 | void World::selectAtomsOfMolecule(const moleculeId_t id){
|
---|
[69643a] | 528 | OBSERVE;
|
---|
| 529 | NOTIFY(SelectionChanged);
|
---|
[90c4280] | 530 | ASSERT(molecules.count(id),"No molecule with the given id upon Selection of atoms from molecule");
|
---|
| 531 | selectAtomsOfMolecule(molecules[id]);
|
---|
| 532 | }
|
---|
| 533 |
|
---|
[e4afb4] | 534 | void World::unselectAtom(const atom *_atom){
|
---|
[69643a] | 535 | OBSERVE;
|
---|
| 536 | NOTIFY(SelectionChanged);
|
---|
[e4afb4] | 537 | ASSERT(_atom,"Invalid pointer in unselection of atom");
|
---|
| 538 | unselectAtom(_atom->getId());
|
---|
[61d655e] | 539 | }
|
---|
| 540 |
|
---|
[e4afb4] | 541 | void World::unselectAtom(const atomId_t id){
|
---|
[69643a] | 542 | OBSERVE;
|
---|
| 543 | NOTIFY(SelectionChanged);
|
---|
[61d655e] | 544 | ASSERT(atoms.count(id),"Atom Id unselected that was not in the world");
|
---|
| 545 | selectedAtoms.erase(id);
|
---|
| 546 | }
|
---|
| 547 |
|
---|
| 548 | void World::unselectAllAtoms(AtomDescriptor descr){
|
---|
[69643a] | 549 | OBSERVE;
|
---|
| 550 | NOTIFY(SelectionChanged);
|
---|
[61d655e] | 551 | internal_AtomIterator begin = getAtomIter_internal(descr);
|
---|
| 552 | internal_AtomIterator end = atomEnd_internal();
|
---|
[e4afb4] | 553 | void (World::*func)(const atom*) = &World::unselectAtom; // needed for type resolution of overloaded function
|
---|
[61d655e] | 554 | for_each(begin,end,bind1st(mem_fun(func),this)); // func is unselect... see above
|
---|
| 555 | }
|
---|
| 556 |
|
---|
[e4afb4] | 557 | void World::unselectAtomsOfMolecule(const molecule *_mol){
|
---|
[69643a] | 558 | OBSERVE;
|
---|
| 559 | NOTIFY(SelectionChanged);
|
---|
[61d655e] | 560 | ASSERT(_mol,"Invalid pointer to molecule in selection of Atoms of Molecule");
|
---|
| 561 | // need to make it const to get the fast iterators
|
---|
| 562 | const molecule *mol = _mol;
|
---|
[e4afb4] | 563 | void (World::*func)(const atom*) = &World::unselectAtom; // needed for type resolution of overloaded function
|
---|
[992bd5] | 564 | for_each(mol->begin(),mol->end(),bind1st(mem_fun(func),this)); // func is unselect... see above
|
---|
[61d655e] | 565 | }
|
---|
| 566 |
|
---|
[e4afb4] | 567 | void World::unselectAtomsOfMolecule(const moleculeId_t id){
|
---|
[69643a] | 568 | OBSERVE;
|
---|
| 569 | NOTIFY(SelectionChanged);
|
---|
[61d655e] | 570 | ASSERT(molecules.count(id),"No molecule with the given id upon Selection of atoms from molecule");
|
---|
| 571 | unselectAtomsOfMolecule(molecules[id]);
|
---|
| 572 | }
|
---|
| 573 |
|
---|
[e472eab] | 574 | size_t World::countSelectedAtoms() const {
|
---|
[eacc3b] | 575 | size_t count = 0;
|
---|
[e472eab] | 576 | for (AtomSet::const_iterator iter = selectedAtoms.begin(); iter != selectedAtoms.end(); ++iter)
|
---|
[eacc3b] | 577 | count++;
|
---|
| 578 | return count;
|
---|
| 579 | }
|
---|
| 580 |
|
---|
[e4afb4] | 581 | bool World::isSelected(const atom *_atom) const {
|
---|
[89643d] | 582 | return isAtomSelected(_atom->getId());
|
---|
| 583 | }
|
---|
| 584 |
|
---|
| 585 | bool World::isAtomSelected(const atomId_t no) const {
|
---|
| 586 | return selectedAtoms.find(no) != selectedAtoms.end();
|
---|
[e0e156] | 587 | }
|
---|
| 588 |
|
---|
[e472eab] | 589 | const std::vector<atom *> World::getSelectedAtoms() const {
|
---|
| 590 | std::vector<atom *> returnAtoms;
|
---|
| 591 | returnAtoms.resize(countSelectedAtoms());
|
---|
| 592 | int count = 0;
|
---|
| 593 | for (AtomSet::const_iterator iter = selectedAtoms.begin(); iter != selectedAtoms.end(); ++iter)
|
---|
| 594 | returnAtoms[count++] = iter->second;
|
---|
| 595 | return returnAtoms;
|
---|
| 596 | }
|
---|
| 597 |
|
---|
| 598 |
|
---|
[90c4280] | 599 | // Molecules
|
---|
| 600 |
|
---|
| 601 | void World::clearMoleculeSelection(){
|
---|
[69643a] | 602 | OBSERVE;
|
---|
| 603 | NOTIFY(SelectionChanged);
|
---|
[90c4280] | 604 | selectedMolecules.clear();
|
---|
| 605 | }
|
---|
| 606 |
|
---|
[ebc499] | 607 | void World::invertMoleculeSelection(){
|
---|
| 608 | // get all molecules not selected
|
---|
| 609 | typedef std::vector<molecule *> MoleculeVector_t;
|
---|
| 610 | MoleculeVector_t invertedSelection(getAllMolecules());
|
---|
| 611 | bool (World::*predicate)(const molecule*) const = &World::isSelected; // needed for type resolution of overloaded function
|
---|
| 612 | MoleculeVector_t::iterator iter =
|
---|
| 613 | std::remove_if(invertedSelection.begin(), invertedSelection.end(),
|
---|
| 614 | std::bind1st(std::mem_fun(predicate), this));
|
---|
| 615 | invertedSelection.erase(iter, invertedSelection.end());
|
---|
| 616 | // apply new selection
|
---|
| 617 | selectedMolecules.clear();
|
---|
| 618 | void (World::*selector)(const molecule*) = &World::selectMolecule; // needed for type resolution of overloaded function
|
---|
| 619 | std::for_each(invertedSelection.begin(),invertedSelection.end(),
|
---|
| 620 | std::bind1st(std::mem_fun(selector),this)); // func is select... see above
|
---|
| 621 | }
|
---|
| 622 |
|
---|
[e4afb4] | 623 | void World::selectMolecule(const molecule *_mol){
|
---|
[69643a] | 624 | OBSERVE;
|
---|
| 625 | NOTIFY(SelectionChanged);
|
---|
[e4afb4] | 626 | // molecule * is unchanged in this function, but we do store entity as changeable
|
---|
| 627 | ASSERT(_mol,"Invalid pointer to molecule in selection");
|
---|
| 628 | selectedMolecules[_mol->getId()]=const_cast<molecule *>(_mol);
|
---|
[90c4280] | 629 | }
|
---|
| 630 |
|
---|
[e4afb4] | 631 | void World::selectMolecule(const moleculeId_t id){
|
---|
[69643a] | 632 | OBSERVE;
|
---|
| 633 | NOTIFY(SelectionChanged);
|
---|
[90c4280] | 634 | ASSERT(molecules.count(id),"Molecule Id selected that was not in the world");
|
---|
| 635 | selectedMolecules[id]=molecules[id];
|
---|
| 636 | }
|
---|
| 637 |
|
---|
[e472eab] | 638 | void World::selectAllMolecules(MoleculeDescriptor descr){
|
---|
[69643a] | 639 | OBSERVE;
|
---|
| 640 | NOTIFY(SelectionChanged);
|
---|
[90c4280] | 641 | internal_MoleculeIterator begin = getMoleculeIter_internal(descr);
|
---|
| 642 | internal_MoleculeIterator end = moleculeEnd_internal();
|
---|
[e4afb4] | 643 | void (World::*func)(const molecule*) = &World::selectMolecule; // needed for type resolution of overloaded function
|
---|
[90c4280] | 644 | for_each(begin,end,bind1st(mem_fun(func),this)); // func is select... see above
|
---|
| 645 | }
|
---|
| 646 |
|
---|
[e4afb4] | 647 | void World::selectMoleculeOfAtom(const atom *_atom){
|
---|
[69643a] | 648 | OBSERVE;
|
---|
| 649 | NOTIFY(SelectionChanged);
|
---|
[e4afb4] | 650 | ASSERT(_atom,"Invalid atom pointer in selection of MoleculeOfAtom");
|
---|
| 651 | molecule *mol=_atom->getMolecule();
|
---|
[90c4280] | 652 | // the atom might not be part of a molecule
|
---|
| 653 | if(mol){
|
---|
| 654 | selectMolecule(mol);
|
---|
| 655 | }
|
---|
| 656 | }
|
---|
| 657 |
|
---|
[e4afb4] | 658 | void World::selectMoleculeOfAtom(const atomId_t id){
|
---|
[69643a] | 659 | OBSERVE;
|
---|
| 660 | NOTIFY(SelectionChanged);
|
---|
[90c4280] | 661 | ASSERT(atoms.count(id),"No such atom with given ID in selection of Molecules of Atom");\
|
---|
| 662 | selectMoleculeOfAtom(atoms[id]);
|
---|
| 663 | }
|
---|
| 664 |
|
---|
[e4afb4] | 665 | void World::unselectMolecule(const molecule *_mol){
|
---|
[69643a] | 666 | OBSERVE;
|
---|
| 667 | NOTIFY(SelectionChanged);
|
---|
[e4afb4] | 668 | ASSERT(_mol,"invalid pointer in unselection of molecule");
|
---|
| 669 | unselectMolecule(_mol->getId());
|
---|
[61d655e] | 670 | }
|
---|
| 671 |
|
---|
[e4afb4] | 672 | void World::unselectMolecule(const moleculeId_t id){
|
---|
[69643a] | 673 | OBSERVE;
|
---|
| 674 | NOTIFY(SelectionChanged);
|
---|
[61d655e] | 675 | ASSERT(molecules.count(id),"No such molecule with ID in unselection");
|
---|
| 676 | selectedMolecules.erase(id);
|
---|
| 677 | }
|
---|
| 678 |
|
---|
[e472eab] | 679 | void World::unselectAllMolecules(MoleculeDescriptor descr){
|
---|
[69643a] | 680 | OBSERVE;
|
---|
| 681 | NOTIFY(SelectionChanged);
|
---|
[61d655e] | 682 | internal_MoleculeIterator begin = getMoleculeIter_internal(descr);
|
---|
| 683 | internal_MoleculeIterator end = moleculeEnd_internal();
|
---|
[e4afb4] | 684 | void (World::*func)(const molecule*) = &World::unselectMolecule; // needed for type resolution of overloaded function
|
---|
[61d655e] | 685 | for_each(begin,end,bind1st(mem_fun(func),this)); // func is unselect... see above
|
---|
| 686 | }
|
---|
| 687 |
|
---|
[e4afb4] | 688 | void World::unselectMoleculeOfAtom(const atom *_atom){
|
---|
[69643a] | 689 | OBSERVE;
|
---|
| 690 | NOTIFY(SelectionChanged);
|
---|
[e4afb4] | 691 | ASSERT(_atom,"Invalid atom pointer in selection of MoleculeOfAtom");
|
---|
| 692 | molecule *mol=_atom->getMolecule();
|
---|
[61d655e] | 693 | // the atom might not be part of a molecule
|
---|
| 694 | if(mol){
|
---|
| 695 | unselectMolecule(mol);
|
---|
| 696 | }
|
---|
| 697 | }
|
---|
| 698 |
|
---|
[e4afb4] | 699 | void World::unselectMoleculeOfAtom(const atomId_t id){
|
---|
[69643a] | 700 | OBSERVE;
|
---|
| 701 | NOTIFY(SelectionChanged);
|
---|
[61d655e] | 702 | ASSERT(atoms.count(id),"No such atom with given ID in selection of Molecules of Atom");\
|
---|
| 703 | unselectMoleculeOfAtom(atoms[id]);
|
---|
| 704 | }
|
---|
| 705 |
|
---|
[e472eab] | 706 | size_t World::countSelectedMolecules() const {
|
---|
[eacc3b] | 707 | size_t count = 0;
|
---|
[e472eab] | 708 | for (MoleculeSet::const_iterator iter = selectedMolecules.begin(); iter != selectedMolecules.end(); ++iter)
|
---|
[eacc3b] | 709 | count++;
|
---|
| 710 | return count;
|
---|
| 711 | }
|
---|
| 712 |
|
---|
[e4afb4] | 713 | bool World::isSelected(const molecule *_mol) const {
|
---|
[89643d] | 714 | return isMoleculeSelected(_mol->getId());
|
---|
| 715 | }
|
---|
| 716 |
|
---|
| 717 | bool World::isMoleculeSelected(const moleculeId_t no) const {
|
---|
| 718 | return selectedMolecules.find(no) != selectedMolecules.end();
|
---|
[e0e156] | 719 | }
|
---|
| 720 |
|
---|
[e472eab] | 721 | const std::vector<molecule *> World::getSelectedMolecules() const {
|
---|
| 722 | std::vector<molecule *> returnMolecules;
|
---|
| 723 | returnMolecules.resize(countSelectedMolecules());
|
---|
| 724 | int count = 0;
|
---|
| 725 | for (MoleculeSet::const_iterator iter = selectedMolecules.begin(); iter != selectedMolecules.end(); ++iter)
|
---|
| 726 | returnMolecules[count++] = iter->second;
|
---|
| 727 | return returnMolecules;
|
---|
| 728 | }
|
---|
| 729 |
|
---|
[3839e5] | 730 | /******************* Iterators over Selection *****************************/
|
---|
| 731 | World::AtomSelectionIterator World::beginAtomSelection(){
|
---|
| 732 | return selectedAtoms.begin();
|
---|
| 733 | }
|
---|
| 734 |
|
---|
| 735 | World::AtomSelectionIterator World::endAtomSelection(){
|
---|
| 736 | return selectedAtoms.end();
|
---|
| 737 | }
|
---|
| 738 |
|
---|
[38f991] | 739 | World::AtomSelectionConstIterator World::beginAtomSelection() const{
|
---|
| 740 | return selectedAtoms.begin();
|
---|
| 741 | }
|
---|
| 742 |
|
---|
| 743 | World::AtomSelectionConstIterator World::endAtomSelection() const{
|
---|
| 744 | return selectedAtoms.end();
|
---|
| 745 | }
|
---|
| 746 |
|
---|
[3839e5] | 747 |
|
---|
| 748 | World::MoleculeSelectionIterator World::beginMoleculeSelection(){
|
---|
| 749 | return selectedMolecules.begin();
|
---|
| 750 | }
|
---|
| 751 |
|
---|
| 752 | World::MoleculeSelectionIterator World::endMoleculeSelection(){
|
---|
| 753 | return selectedMolecules.end();
|
---|
| 754 | }
|
---|
| 755 |
|
---|
[38f991] | 756 | World::MoleculeSelectionConstIterator World::beginMoleculeSelection() const{
|
---|
| 757 | return selectedMolecules.begin();
|
---|
| 758 | }
|
---|
| 759 |
|
---|
| 760 | World::MoleculeSelectionConstIterator World::endMoleculeSelection() const{
|
---|
| 761 | return selectedMolecules.end();
|
---|
| 762 | }
|
---|
| 763 |
|
---|
[5d1611] | 764 | /******************************* Singleton Stuff **************************/
|
---|
| 765 |
|
---|
[7a1ce5] | 766 | World::World() :
|
---|
[cd5047] | 767 | Observable("World"),
|
---|
[f71baf] | 768 | BG(new BondGraph(true)), // assume Angstroem for the moment
|
---|
[4ae823] | 769 | periode(new periodentafel(true)),
|
---|
[8e1f7af] | 770 | configuration(new config),
|
---|
[43dad6] | 771 | Thermostats(new ThermoStatContainer),
|
---|
[e4b5de] | 772 | ExitFlag(0),
|
---|
[fa0b18] | 773 | atoms(this),
|
---|
[90c4280] | 774 | selectedAtoms(this),
|
---|
[3e4fb6] | 775 | atomIdPool(0, 20, 100),
|
---|
[51be2a] | 776 | molecules(this),
|
---|
[90c4280] | 777 | selectedMolecules(this),
|
---|
[3e4fb6] | 778 | moleculeIdPool(0, 20,100),
|
---|
[24a5e0] | 779 | molecules_deprecated(new MoleculeListClass(this))
|
---|
[7dad10] | 780 | {
|
---|
[84c494] | 781 | cell_size = new Box;
|
---|
[cca9ef] | 782 | RealSpaceMatrix domain;
|
---|
[84c494] | 783 | domain.at(0,0) = 20;
|
---|
| 784 | domain.at(1,1) = 20;
|
---|
| 785 | domain.at(2,2) = 20;
|
---|
| 786 | cell_size->setM(domain);
|
---|
[4834f4] | 787 | LCcontroller = new LinkedCell::LinkedCell_Controller(*cell_size);
|
---|
[387b36] | 788 | defaultName = "none";
|
---|
[02ce36] | 789 | Channels *OurChannel = new Channels;
|
---|
[708277] | 790 | NotificationChannels.insert( std::make_pair( static_cast<Observable *>(this), OurChannel) );
|
---|
[7188b1] | 791 | for (size_t type = 0; type < (size_t)NotificationType_MAX; ++type)
|
---|
[02ce36] | 792 | OurChannel->addChannel(type);
|
---|
[7dad10] | 793 | molecules_deprecated->signOn(this);
|
---|
| 794 | }
|
---|
[5d1611] | 795 |
|
---|
| 796 | World::~World()
|
---|
[354859] | 797 | {
|
---|
[028c2e] | 798 | molecules_deprecated->signOff(this);
|
---|
[4834f4] | 799 | delete LCcontroller;
|
---|
[84c494] | 800 | delete cell_size;
|
---|
[46d958] | 801 | delete molecules_deprecated;
|
---|
[cbc5fb] | 802 | MoleculeSet::iterator molIter;
|
---|
| 803 | for(molIter=molecules.begin();molIter!=molecules.end();++molIter){
|
---|
| 804 | DeleteMolecule((*molIter).second);
|
---|
| 805 | }
|
---|
| 806 | molecules.clear();
|
---|
| 807 | AtomSet::iterator atIter;
|
---|
| 808 | for(atIter=atoms.begin();atIter!=atoms.end();++atIter){
|
---|
| 809 | DeleteAtom((*atIter).second);
|
---|
[46d958] | 810 | }
|
---|
| 811 | atoms.clear();
|
---|
[7188b1] | 812 |
|
---|
[f71baf] | 813 | delete BG;
|
---|
[6cb9c76] | 814 | delete periode;
|
---|
| 815 | delete configuration;
|
---|
| 816 | delete Thermostats;
|
---|
[354859] | 817 | }
|
---|
[5d1611] | 818 |
|
---|
[23b547] | 819 | // Explicit instantiation of the singleton mechanism at this point
|
---|
[5d1611] | 820 |
|
---|
[3e4fb6] | 821 | // moleculeId_t und atomId_t sind gleicher Basistyp, deswegen nur einen von beiden konstruieren
|
---|
[b97a60] | 822 | CONSTRUCT_IDPOOL(atomId_t, uniqueId)
|
---|
| 823 | CONSTRUCT_IDPOOL(moleculeId_t, continuousId)
|
---|
[3e4fb6] | 824 |
|
---|
[23b547] | 825 | CONSTRUCT_SINGLETON(World)
|
---|
[5d1611] | 826 |
|
---|
[5f1d5b8] | 827 | CONSTRUCT_OBSERVEDCONTAINER(World::AtomSTLSet)
|
---|
| 828 |
|
---|
| 829 | CONSTRUCT_OBSERVEDCONTAINER(World::MoleculeSTLSet)
|
---|
| 830 |
|
---|
[5d1611] | 831 | /******************************* deprecated Legacy Stuff ***********************/
|
---|
| 832 |
|
---|
[354859] | 833 | MoleculeListClass *&World::getMolecules() {
|
---|
| 834 | return molecules_deprecated;
|
---|
[5d1611] | 835 | }
|
---|