Changes in / [0c7ed8:1dc9ec]


Ignore:
Files:
219 added
51 deleted
138 edited

Legend:

Unmodified
Added
Removed
  • configure.ac

    r0c7ed8 r1dc9ec  
    2727
    2828# Boost libraries
    29 AX_BOOST_BASE([1.33.1])
    30 #AX_BOOST_PROGRAM_OPTIONS
     29AX_BOOST_BASE([1.40])
     30AX_BOOST_PROGRAM_OPTIONS
    3131#AX_BOOST_FOREACH
    3232#AX_BOOST_FILESYSTEM
    3333AX_BOOST_THREAD
    34 #AX_BOOST_PROGRAM_OPTIONS
    3534#AX_BOOST_SERIALIZATION
    3635
     
    9392
    9493# test suite
    95 AC_CONFIG_TESTDIR(tests)
    96 AC_CONFIG_FILES([tests/atlocal tests/Makefile])
    97 AC_CONFIG_FILES([tests/Tesselations/Makefile tests/Tesselations/defs])
    98 AC_CONFIG_FILES([tests/molecuilder], [chmod +x tests/molecuilder])
    99 AC_CONFIG_FILES([doc/molecuilder.xml])
    100 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile src/unittests/Makefile])
     94AC_CONFIG_TESTDIR(tests/regression)
     95AC_CONFIG_FILES([
     96        tests/Makefile
     97        tests/regression/atlocal
     98        tests/regression/Makefile])
     99AC_CONFIG_FILES([tests/regression/molecuilder], [chmod +x tests/regression/molecuilder])
     100AC_CONFIG_FILES([
     101        tests/Tesselations/Makefile
     102        tests/Tesselations/defs])
     103AC_CONFIG_FILES([
     104        doc/molecuilder.xml])
     105AC_CONFIG_FILES([
     106        Makefile
     107        doc/Makefile
     108        src/Makefile
     109        src/Actions/Makefile
     110        src/UIElements/Makefile
     111        src/unittests/Makefile])
    101112AC_OUTPUT
  • src/Actions/Action.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include <string>
     
    1517using namespace std;
    1618
     19Action::state_ptr getEmptyState() {
     20  return Action::state_ptr(Memory::ignore(new ActionState()));
     21}
     22
    1723// An empty state to indicate success
    18 Action::state_ptr Action::success = Action::state_ptr(Memory::ignore(new ActionState()));
    19 Action::state_ptr Action::failure = Action::state_ptr(Memory::ignore(new ActionState()));
     24Action::state_ptr Action::success = getEmptyState();
     25Action::state_ptr Action::failure = getEmptyState();
    2026
    2127Action::Action(std::string _name,bool _doRegister) :
  • src/Actions/ActionHistory.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "ActionHistory.hpp"
  • src/Actions/ActionRegistry.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "Actions/ActionRegistry.hpp"
     
    3739}
    3840
     41bool ActionRegistry::isActionByNamePresent(const std::string name){
     42  map<const string,Action*>::iterator iter;
     43  iter = actionMap.find(name);
     44  return iter!=actionMap.end();
     45}
     46
    3947void ActionRegistry::registerAction(Action* action){
    4048  pair<map<const string,Action*>::iterator,bool> ret;
     
    4351}
    4452
     53void ActionRegistry::unregisterAction(Action* action){
     54  actionMap.erase(action->getName());
     55}
     56
     57std::map<const std::string,Action*>::iterator ActionRegistry::getBeginIter()
     58{
     59  return actionMap.begin();
     60}
     61
     62std::map<const std::string,Action*>::iterator ActionRegistry::getEndIter()
     63{
     64  return actionMap.end();
     65}
     66
    4567CONSTRUCT_SINGLETON(ActionRegistry)
  • src/Actions/ActionRegistry.hpp

    r0c7ed8 r1dc9ec  
    2121public:
    2222  Action* getActionByName(const std::string);
     23  bool isActionByNamePresent(const std::string name);
    2324  void registerAction(Action*);
     25  void unregisterAction(Action*);
     26
     27  std::map<const std::string,Action*>::iterator getBeginIter();
     28  std::map<const std::string,Action*>::iterator getEndIter();
    2429
    2530private:
  • src/Actions/ActionSequence.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "Actions/ActionSequence.hpp"
  • src/Actions/ErrorAction.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include <iostream>
  • src/Actions/MakroAction.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include <string>
  • src/Actions/ManipulateAtomsProcess.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "ManipulateAtomsProcess.hpp"
  • src/Actions/MethodAction.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include <iostream>
  • src/Actions/Process.cpp

    r0c7ed8 r1dc9ec  
    66 */
    77
     8#include "Helpers/MemDebug.hpp"
     9
    810#include "Process.hpp"
    911
     
    1113
    1214Process::Process(int _maxSteps, std::string _name, bool _doRegister) :
     15  Observable("Process"),
    1316  Action(_name,_doRegister),
    1417  maxSteps(_maxSteps),
  • src/Descriptors/AtomDescriptor.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "Descriptors/AtomDescriptor.hpp"
  • src/Descriptors/AtomIdDescriptor.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "AtomIdDescriptor.hpp"
  • src/Descriptors/AtomTypeDescriptor.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "Descriptors/AtomTypeDescriptor.hpp"
  • src/Descriptors/MoleculeDescriptor.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "Descriptors/MoleculeDescriptor.hpp"
  • src/Descriptors/MoleculeIdDescriptor.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "MoleculeIdDescriptor.hpp"
  • src/Exceptions/CustomException.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "CustomException.hpp"
  • src/Exceptions/LinearDependenceException.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "LinearDependenceException.hpp"
  • src/Exceptions/MathException.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "MathException.hpp"
  • src/Exceptions/SkewException.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "SkewException.hpp"
  • src/Exceptions/ZeroVectorException.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "ZeroVectorException.hpp"
  • src/Helpers/Assert.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "Helpers/Assert.hpp"
     
    4648using namespace Assert;
    4749
     50#ifndef NDEBUG
     51
    4852Action _my_assert::defaultAction = Ask;
    4953std::vector<Assert::hook_t> _my_assert::hooks;
     
    5256const char* _wrapper::message_ptr = "source pointer did not point to object of desired type";
    5357const char* _wrapper::message_ref = "source reference did not contain object of desired type";
    54 
    5558
    5659
     
    6366{
    6467  if(!res){
    65     cout << "Assertion " << condition << " failed in file " << filename << " at line " << line << endl;
     68    cout << "Assertion \"" << condition << "\" failed in file " << filename << " at line " << line << endl;
    6669    cout << "Assertion Message: " << message << std::endl;
    6770    while(true){
     
    123126  return ActionNames[defaultAction];
    124127}
     128
     129#endif
     130
  • src/Helpers/MemDebug.cpp

    r0c7ed8 r1dc9ec  
    66 */
    77
     8#ifndef NDBEGUG
     9#ifndef NO_MEMDEBUG
     10
    811#include <iostream>
    912#include <cstdlib>
     
    1114#include <boost/thread.hpp>
    1215
     16#ifdef __GNUC__
     17#include <execinfo.h>
     18#include <cxxabi.h>
     19#endif
     20
    1321using namespace std;
    1422
    15 #ifndef NDBEGUG
    16 #ifndef NO_MEMDEBUG
     23// we need our own low level mutexex, since we cannot assure the time of construction and destruction
     24// otherwise
     25#if defined(unix) || defined(__unix)
     26
     27#include <pthread.h>
     28#include <cassert>
     29#define mutex_t    pthread_mutex_t
     30#define mutex_init PTHREAD_MUTEX_INITIALIZER
     31#define mutex_lock(mtx) \
     32  do{\
     33    int res = pthread_mutex_lock(&(mtx));\
     34    assert(!res && "Could not lock mutex!");\
     35  }while(0)
     36
     37#define mutex_unlock(mtx) \
     38  do{\
     39    int res = pthread_mutex_unlock(&(mtx));\
     40    assert(!res && "Could not unlock mutex!");\
     41  }while(0)
     42
     43#else
     44# error "No thread structure defined for this plattform..."
     45#endif
    1746
    1847namespace Memory {
     
    3463      char file[length+1];
    3564      int line;
     65#ifdef __GNUC__  // function tracking only works with GCC
     66      // function names can get looooong
     67      enum {length2 = 256};
     68      char function[length2+1];
     69#endif
    3670      size_t nbytes;
    3771      bool isUsed;
     
    4478  };
    4579
    46   boost::mutex memorylock;
     80
     81  mutex_t memorylock = mutex_init;
    4782
    4883  // start and end of the doubly-linked list
     
    96131    for(entry_t *pos=begin;pos;pos=pos->next){
    97132      cout << "\nChunk of " << pos->info.nbytes << " bytes" << " still available" << endl;
     133#ifdef __GNUC__
     134      cout << "Chunk reserved at: " << pos->info.function
     135           << " (" << pos->info.file << ":" << pos->info.line  << ")" << endl;
     136#else
    98137      cout << "Chunk reserved at: " << pos->info.file << ":" << pos->info.line << endl;
    99     }
     138#endif
     139    }
     140  }
     141
     142  // Adds an entry to the linked list
     143  void addEntry(entry_t *entry){
     144    // check if the entry is already in the list
     145    if(!entry->isIgnored)
     146      return;
     147
     148    mutex_lock(Memory::memorylock);
     149
     150    entry->next=0;            // the created block is last in the list
     151    entry->prev=Memory::end;  // the created block is last in the list
     152    if(!Memory::begin){
     153      // the list was empty... start a new one
     154      Memory::begin=entry;
     155    }
     156    else {
     157      // other blocks present... we can add to the last one
     158      Memory::end->next=entry;
     159    }
     160    Memory::end=entry;
     161
     162    // update some global info
     163    Memory::state  += entry->info.nbytes;
     164    if(Memory::state>Memory::max){
     165        Memory::max = Memory::state;
     166    }
     167    ++Memory::allocs;
     168    // done with the list... it is safe to unlock now
     169    mutex_unlock(Memory::memorylock);
     170    entry->isIgnored = false;
    100171  }
    101172
     
    105176      return;
    106177
     178    mutex_lock(memorylock);
    107179    if(entry->prev){
    108180      entry->prev->next = entry->next;
     
    120192      end = entry->prev;
    121193    }
     194    Memory::state  -= entry->info.nbytes;
     195    mutex_unlock(memorylock);
    122196    entry->isIgnored = true;
    123     Memory::state  -= entry->info.nbytes;
     197
    124198  }
    125199
     
    130204    deleteEntry(entry);
    131205  }
    132 }
    133 
    134 void *operator new(size_t nbytes,const char* file, int line) throw(std::bad_alloc) {
    135 
    136   // we need to lock, so that no one changes the linked list while we are here
    137   boost::mutex::scoped_lock guard(Memory::memorylock);
     206
     207#ifdef __GNUC__
     208  // this function let's us find the caller's name
     209  char* getCaller(){
     210    // stack looks like this:
     211    // getCaller();
     212    // operator new();
     213    // function_we_are_looking_for(); <-
     214    const size_t max_depth = 3;
     215    void* stack_addrs[max_depth];
     216    size_t stack_depth;
     217    char **stack_strings=0;
     218    const char *func_name=0;
     219    const char *toplevel = "Global scope";
     220    char *retval=0;
     221
     222    // get the backtrace, depth three
     223    stack_depth   = backtrace(stack_addrs,max_depth);
     224    stack_strings = backtrace_symbols(stack_addrs, stack_depth);
     225    // used later for demangling
     226    // reserved here, so we can free it unconditionally
     227    char *dm_function = static_cast<char*>(malloc(entry_t::info_t::length2));
     228    if(!dm_function){
     229      // malloc failed... we are out of luck
     230      throw std::bad_alloc();
     231    }
     232
     233    // see if we found our function name
     234    if(stack_depth==max_depth){
     235      // find the mangled function name
     236      char *begin = stack_strings[max_depth-1];
     237      // function name starts with a (
     238      while(*begin && *begin!='(') ++begin;
     239      char *end=begin;
     240      while(*end && *end!='+') ++end;
     241
     242      // see if we found our function name
     243      if(*begin && *end){
     244        *begin++ = 0;
     245        *end = 0;
     246        // use the C++ demangler
     247
     248        size_t sz = entry_t::info_t::length2;
     249        int status;
     250        char *func_ret = abi::__cxa_demangle(begin, dm_function, &sz, &status);
     251        if(func_ret){
     252          // abi might have realloced...
     253          dm_function = func_ret;
     254          func_name = dm_function;
     255        }
     256        else{
     257          // demangling failed... get the function name without demangling
     258          func_name = begin;
     259        }
     260      }
     261      else{
     262        // function name not found... get the whole line
     263        func_name = stack_strings[max_depth-1];
     264      }
     265
     266    }
     267    else{
     268      func_name = toplevel;
     269    }
     270
     271    // now we copy the desired function name
     272    if((retval = static_cast<char*>(malloc(strlen(func_name)+1)))){
     273      // we know that the string will fit, so strcpy is safe here
     274      strcpy(retval,func_name);
     275    }
     276    else{
     277      free(stack_strings); // malloc()ed by backtrace_symbols
     278      free(dm_function);
     279      // uh-uh ... seems we are out of luck for allocations now
     280      throw std::bad_alloc();
     281    }
     282    free(dm_function);
     283    free(stack_strings); // malloc()ed by backtrace_symbols
     284    return retval;
     285  }
     286#endif
     287}
     288
     289#ifdef __GNUC__
     290
     291void *operator new(size_t nbytes,const char* file, int line, const char* func) throw(std::bad_alloc) {
    138292
    139293  // to avoid allocations of 0 bytes if someone screws up
     
    153307  }
    154308
    155   // we got the space, so update the global info
    156   Memory::state += nbytes;
    157   if(Memory::state>Memory::max){
    158     Memory::max = Memory::state;
    159   }
    160   Memory::allocs++;
     309  // build the entry in front of the space
     310  Memory::entry_t *entry = (Memory::entry_t*) res;
     311  memset(res,0,entrySpace);
     312  entry->info.nbytes = nbytes;
     313  entry->info.isUsed = true;
     314  strncpy(entry->info.file,file,Memory::entry_t::info_t::length);
     315  entry->info.file[Memory::entry_t::info_t::length] = '\0';
     316  entry->info.line=line;
     317  strncpy(entry->info.function,func,Memory::entry_t::info_t::length2);
     318  entry->info.function[Memory::entry_t::info_t::length2] = '\0';
     319  // the space starts behind the info
     320  entry->info.location = (char*)res + entrySpace;
     321
     322  // mark the block as not in the list (will be changed by addEntry)
     323  entry->isIgnored = true;
     324  Memory::addEntry(entry);
     325
     326  // get the checksum...
     327  entry->checksum = Memory::calcChecksum(&entry->info);
     328
     329  // ok, space is prepared... the user can have it.
     330  // the rest (constructor, deleting when something is thrown etc)
     331  // is handled automatically
     332  return entry->info.location;
     333}
     334
     335#else
     336
     337void *operator new(size_t nbytes,const char* file, int line) throw(std::bad_alloc) {
     338
     339  // to avoid allocations of 0 bytes if someone screws up
     340  // allocation with 0 byte size are undefined behavior, so we are
     341  // free to handle it this way
     342  if(!nbytes) {
     343    nbytes = 1;
     344  }
     345
     346  // get the size of the entry, including alignment
     347  static const size_t entrySpace = Memory::doAlign(sizeof(Memory::entry_t));
     348
     349  void *res;
     350  if(!(res=malloc(entrySpace + nbytes))){
     351    // new must throw, when space is low
     352    throw std::bad_alloc();
     353  }
    161354
    162355  // build the entry in front of the space
     
    171364  entry->info.location = (char*)res + entrySpace;
    172365
    173   // add the entry at the end of the list
    174   entry->next=0;            // the created block is last in the list
    175   entry->prev=Memory::end;  // the created block is last in the list
    176   if(!Memory::begin){
    177     // the list was empty... start a new one
    178     Memory::begin=entry;
    179   }
    180   else {
    181     // other blocks present... we can add to the last one
    182     Memory::end->next=entry;
    183   }
    184   Memory::end=entry;
     366  // mark the block as not in the list (will be changed by addEntry)
     367  entry->isIgnored = true;
     368  Memory::addEntry(entry);
    185369
    186370  // get the checksum...
     
    196380}
    197381
     382#endif
     383
    198384void *operator new(size_t nbytes) throw(std::bad_alloc) {
    199385  // Just forward to the other operator, when we do not know from
    200386  // where the allocation came
     387#ifdef __GNUC__
     388  // this might throw bad_alloc
     389  char *caller = Memory::getCaller();
     390  void* retval = 0;
     391
     392  // if this throws, we have to clean up the caller anyway
     393  try{
     394    retval = operator new(nbytes,"Unknown",0,caller);
     395  }
     396  catch(...)
     397  {
     398    free(caller); // malloc()ed by Memory::getCaller();
     399    throw;
     400  }
     401  free(caller); // malloc()ed by Memory::getCaller();
     402  return retval;
     403#else
    201404  return operator new(nbytes,"Unknown",0);
    202 }
     405#endif
     406}
     407
     408#ifdef __GNUC__
     409
     410void *operator new[] (size_t nbytes,const char* file, int line, const char* func) throw(std::bad_alloc) {
     411  // The difference between new and new[] is just for compiler bookkeeping.
     412  return operator new(nbytes,file,line,func);
     413}
     414
     415#else
    203416
    204417void *operator new[] (size_t nbytes,const char* file, int line) throw(std::bad_alloc) {
     
    207420}
    208421
     422#endif
     423
    209424void *operator new[] (size_t nbytes) throw(std::bad_alloc) {
    210425  // Forward again
     426#ifdef __GNUC__
     427  // this might throw bad_alloc
     428    char *caller = Memory::getCaller();
     429    void *retval=0;
     430
     431    // if this throws, we have to clean up the caller anyway
     432    try{
     433      retval = operator new[] (nbytes,"Unknown",0,caller);
     434    }
     435    catch(...)
     436    {
     437      free(caller); // malloc()ed by Memory::getCaller();
     438      throw;
     439    }
     440    free(caller); // malloc()ed by Memory::getCaller();
     441    return retval;
     442#else
    211443  return operator new[] (nbytes,"Unknown",0);
     444#endif
    212445}
    213446
     
    217450    return;
    218451  }
    219 
    220   // we need to lock, so the linked list does not changed while we are in here
    221   boost::mutex::scoped_lock guard(Memory::memorylock);
    222452
    223453  // get the size for the entry, including alignment
  • src/Helpers/MemDebug.hpp

    r0c7ed8 r1dc9ec  
    2828#endif
    2929
     30#include <new>
     31
     32// some light header files, that do weird new stuff and therefore need
     33// to be loaded before the define
     34#include <string>
     35#include <boost/optional.hpp>
     36#include <boost/shared_ptr.hpp>
     37#include <boost/function.hpp>
     38#include <boost/program_options.hpp>
     39
     40
    3041namespace Memory {
    3142
     
    5061  }
    5162}
    52 
     63#ifdef __GNUC__
     64void *operator new   (size_t nbytes,const char* file, int line, const char* func) throw(std::bad_alloc);
     65void *operator new[] (size_t nbytes,const char* file, int line, const char* func) throw(std::bad_alloc);
     66#else
    5367void *operator new   (size_t nbytes,const char* file, int line) throw(std::bad_alloc);
    5468void *operator new[] (size_t nbytes,const char* file, int line) throw(std::bad_alloc);
     69#endif
    5570void operator delete   (void *ptr,const char*, int) throw();
    5671void operator delete[] (void *ptr,const char*, int) throw();
     72
     73
    5774
    5875/**
     
    6077 * version that allows tracking.
    6178 */
     79#ifdef __GNUC__
     80#define new new(__FILE__,__LINE__,__PRETTY_FUNCTION__)
     81#else
    6282#define new new(__FILE__,__LINE__)
     83#endif
    6384
    6485#endif
    6586#endif
    6687
     88
     89#ifdef NDEBUG
     90#undef MEMDEBUG
     91#endif
    6792
    6893#ifndef MEMDEBUG
  • src/Legacy/oldmenu.cpp

    r0c7ed8 r1dc9ec  
    66 *
    77 */
     8
     9#include "Helpers/MemDebug.hpp"
    810
    911#include "Legacy/oldmenu.hpp"
     
    3638#include "Menu/DisplayMenuItem.hpp"
    3739#include "Menu/SubMenuItem.hpp"
     40#include "Actions/MapOfActions.hpp"
    3841#include "Actions/MethodAction.hpp"
    3942#include "Actions/ErrorAction.hpp"
     
    8487        Dialog *dialog = UIFactory::getInstance().makeDialog();
    8588        first = World::getInstance().createAtom();
     89        std::vector<element *> elements;
    8690        dialog->queryVector("Please enter coordinates: ",&first->x,World::getInstance().getDomain(), false);
    87         dialog->queryElement("Please choose element: ",&first->type);
     91        dialog->queryElement("Please choose element: ",&elements);
    8892        if(dialog->display()){
    89           mol->AddAtom(first);  // add to molecule
     93          if (elements.size() == 1) {
     94            first->type = elements.at(0);
     95            mol->AddAtom(first);  // add to molecule
     96          } else {
     97            DoeLog(1) && (eLog() << Verbose(1) << "Unequal to one element given for element of new atom." << endl);
     98          }
    9099        }
    91100        else{
     
    424433void oldmenu::RemoveAtoms(molecule *mol)
    425434{
    426   atom *first, *second;
     435  atom *second;
    427436  int axis;
    428437  double tmp1, tmp2;
     
    447456      break;
    448457    case 'b':
    449       second = mol->AskAtom("Enter number of atom as reference point: ");
    450       Log() << Verbose(0) << "Enter radius: ";
    451       cin >> tmp1;
    452       first = mol->start;
    453       second = first->next;
    454       while(second != mol->end) {
    455         first = second;
    456         second = first->next;
    457         if (first->x.DistanceSquared(second->x) > tmp1*tmp1) // distance to first above radius ...
    458           mol->RemoveAtom(first);
     458      {
     459        second = mol->AskAtom("Enter number of atom as reference point: ");
     460        Log() << Verbose(0) << "Enter radius: ";
     461        cin >> tmp1;
     462        molecule::iterator runner;
     463        for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) {
     464          runner = iter++;
     465          if ((*runner)->x.DistanceSquared((*runner)->x) > tmp1*tmp1) // distance to first above radius ...
     466            mol->RemoveAtom((*runner));
     467        }
    459468      }
    460469      break;
     
    466475      Log() << Verbose(0) << "Upper boundary: ";
    467476      cin >> tmp2;
    468       first = mol->start;
    469       second = first->next;
    470       while(second != mol->end) {
    471         first = second;
    472         second = first->next;
    473         if ((first->x[axis] < tmp1) || (first->x[axis] > tmp2)) {// out of boundary ...
    474           //Log() << Verbose(0) << "Atom " << *first << " with " << first->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
    475           mol->RemoveAtom(first);
     477      molecule::iterator runner;
     478      for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) {
     479        runner = iter++;
     480        if (((*runner)->x[axis] < tmp1) || ((*runner)->x[axis] > tmp2)) {// out of boundary ...
     481          //Log() << Verbose(0) << "Atom " << *(*runner) << " with " << (*runner)->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
     482          mol->RemoveAtom((*runner));
    476483        }
    477484      }
     
    516523        min[i] = 0.;
    517524
    518       second = mol->start;
    519       while ((second->next != mol->end)) {
    520         second = second->next; // advance
    521         Z = second->type->Z;
     525      for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     526        Z = (*iter)->type->Z;
    522527        tmp1 = 0.;
    523         if (first != second) {
    524           x = first->x - second->x;
     528        if (first != (*iter)) {
     529          x = first->x - (*iter)->x;
    525530          tmp1 = x.Norm();
    526531        }
    527532        if ((tmp1 != 0.) && ((min[Z] == 0.) || (tmp1 < min[Z]))) min[Z] = tmp1;
    528         //Log() << Verbose(0) << "Bond length between Atom " << first->nr << " and " << second->nr << ": " << tmp1 << " a.u." << endl;
     533        //Log() << Verbose(0) << "Bond length between Atom " << first->nr << " and " << ((*iter)->nr << ": " << tmp1 << " a.u." << endl;
    529534      }
    530535      for (int i=MAX_ELEMENTS;i--;)
     
    609614  Log() << Verbose(0) << "What's the desired bond order: ";
    610615  cin >> Order1;
    611   if (mol->first->next != mol->last) {  // there are bonds
     616  if (mol->hasBondStructure()) {
    612617    start = clock();
    613618    mol->FragmentMolecule(Order1, configuration);
     
    755760    Log() << Verbose(0) << "State the factor: ";
    756761    cin >> faktor;
    757 
    758     mol->CountAtoms(); // recount atoms
    759     if (mol->AtomCount != 0) {  // if there is more than none
    760       count = mol->AtomCount;  // is changed becausing of adding, thus has to be stored away beforehand
     762    if (mol->getAtomCount() != 0) {  // if there is more than none
     763      count = mol->getAtomCount();  // is changed becausing of adding, thus has to be stored away beforehand
    761764      Elements = new const element *[count];
    762765      vectors = new Vector *[count];
    763766      j = 0;
    764       first = mol->start;
    765       while (first->next != mol->end) { // make a list of all atoms with coordinates and element
    766         first = first->next;
    767         Elements[j] = first->type;
    768         vectors[j] = &first->x;
     767      for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     768        Elements[j] = (*iter)->type;
     769        vectors[j] = &(*iter)->x;
    769770        j++;
    770771      }
     
    783784        }
    784785      }
    785       if (mol->first->next != mol->last) // if connect matrix is present already, redo it
     786      if (mol->hasBondStructure())
    786787        mol->CreateAdjacencyList(mol->BondDistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
    787788      // free memory
     
    909910  molecule *srcmol = NULL, *destmol = NULL;
    910911  Dialog *dialog = UIFactory::getInstance().makeDialog();
    911   dialog->queryMolecule("Enter index of destination molecule: ",&destmol, molecules);
    912   dialog->queryMolecule("Enter index of source molecule to add from: ",&srcmol, molecules);
     912  dialog->queryMolecule("molecule-by-id",&destmol, MapOfActions::getInstance().getDescription("molecule-by-id"));
     913  dialog->queryMolecule("molecule-by-id",&srcmol, MapOfActions::getInstance().getDescription("molecule-by-id"));
    913914  if(dialog->display()) {
    914915    molecules->SimpleAdd(srcmol, destmol);
     
    923924  molecule *srcmol = NULL, *destmol = NULL;
    924925  Dialog *dialog = UIFactory::getInstance().makeDialog();
    925   dialog->queryMolecule("Enter index of matrix molecule (the variable one): ",&srcmol,molecules);
    926   dialog->queryMolecule("Enter index of molecule to merge into (the fixed one): ",&destmol,molecules);
     926  dialog->queryMolecule("molecule-by-id",&destmol, MapOfActions::getInstance().getDescription("molecule-by-id"));
     927  dialog->queryMolecule("molecule-by-id",&srcmol, MapOfActions::getInstance().getDescription("molecule-by-id"));
    927928  if(dialog->display()) {
    928929    molecules->EmbedMerge(destmol, srcmol);
     
    10251026    return;
    10261027  }
    1027   atom *Walker = mol->start;
    10281028
    10291029  // generate some KeySets
    10301030  Log() << Verbose(0) << "Generating KeySets." << endl;
    1031   KeySet TestSets[mol->AtomCount+1];
     1031  KeySet TestSets[mol->getAtomCount()+1];
    10321032  i=1;
    1033   while (Walker->next != mol->end) {
    1034     Walker = Walker->next;
     1033  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
    10351034    for (int j=0;j<i;j++) {
    1036       TestSets[j].insert(Walker->nr);
     1035      TestSets[j].insert((*iter)->nr);
    10371036    }
    10381037    i++;
     
    10401039  Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl;
    10411040  KeySetTestPair test;
    1042   test = TestSets[mol->AtomCount-1].insert(Walker->nr);
    1043   if (test.second) {
    1044     Log() << Verbose(1) << "Insertion worked?!" << endl;
     1041  molecule::const_iterator iter = mol->begin();
     1042  if (iter != mol->end()) {
     1043    test = TestSets[mol->getAtomCount()-1].insert((*iter)->nr);
     1044    if (test.second) {
     1045      Log() << Verbose(1) << "Insertion worked?!" << endl;
     1046    } else {
     1047      Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl;
     1048    }
    10451049  } else {
    1046     Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl;
    1047   }
    1048   TestSets[mol->AtomCount].insert(mol->end->previous->nr);
    1049   TestSets[mol->AtomCount].insert(mol->end->previous->previous->previous->nr);
     1050    eLog() << Verbose(1) << "No atoms to test double insertion." << endl;
     1051  }
    10501052
    10511053  // constructing Graph structure
     
    10551057  // insert KeySets into Subgraphs
    10561058  Log() << Verbose(0) << "Inserting KeySets into Subgraph class." << endl;
    1057   for (int j=0;j<mol->AtomCount;j++) {
     1059  for (int j=0;j<mol->getAtomCount();j++) {
    10581060    Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.)));
    10591061  }
    10601062  Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl;
    10611063  GraphTestPair test2;
    1062   test2 = Subgraphs.insert(GraphPair (TestSets[mol->AtomCount],pair<int, double>(counter++, 1.)));
     1064  test2 = Subgraphs.insert(GraphPair (TestSets[mol->getAtomCount()],pair<int, double>(counter++, 1.)));
    10631065  if (test2.second) {
    10641066    Log() << Verbose(1) << "Insertion worked?!" << endl;
  • src/Line.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "Line.hpp"
  • src/Makefile.am

    r0c7ed8 r1dc9ec  
     1# PLEASE adhere to the alphabetical ordering in this Makefile!
     2# Also indentation by a single tab
     3
     4SUBDIRS = Actions UIElements
     5
    16# this includes source files that need to be present at multiple points
    2 HELPERSOURCE =  Helpers/Assert.cpp \
    3                                 Helpers/MemDebug.cpp
     7HELPERSOURCE =  \
     8  Helpers/Assert.cpp \
     9  Helpers/MemDebug.cpp
    410                       
    5 ATOMSOURCE = atom.cpp atom_atominfo.cpp atom_bondedparticle.cpp atom_bondedparticleinfo.cpp atom_graphnode.cpp atom_graphnodeinfo.cpp atom_particleinfo.cpp atom_trajectoryparticle.cpp atom_trajectoryparticleinfo.cpp
    6 ATOMHEADER = atom.hpp atom_atominfo.hpp atom_bondedparticle.hpp atom_bondedparticleinfo.hpp atom_graphnode.hpp atom_graphnodeinfo.hpp atom_particleinfo.hpp atom_trajectoryparticle.hpp atom_trajectoryparticleinfo.hpp
    7 
    8 LINALGSOURCE = ${HELPERSOURCE} \
    9                gslmatrix.cpp \
    10                            gslvector.cpp \
    11                            linearsystemofequations.cpp \
    12                            Space.cpp \
    13                            vector.cpp
     11ATOMSOURCE = \
     12  atom.cpp \
     13  atom_atominfo.cpp \
     14  atom_bondedparticle.cpp \
     15  atom_bondedparticleinfo.cpp \
     16  atom_graphnode.cpp \
     17  atom_graphnodeinfo.cpp \
     18  atom_particleinfo.cpp \
     19  atom_trajectoryparticle.cpp \
     20  atom_trajectoryparticleinfo.cpp
     21ATOMHEADER = \
     22  atom.hpp \
     23  atom_atominfo.hpp \
     24  atom_bondedparticle.hpp \
     25  atom_bondedparticleinfo.hpp \
     26  atom_graphnode.hpp \
     27  atom_graphnodeinfo.hpp \
     28  atom_particleinfo.hpp \
     29  atom_trajectoryparticle.hpp \
     30  atom_trajectoryparticleinfo.hpp
     31
     32LINALGSOURCE = \
     33  ${HELPERSOURCE} \
     34  gslmatrix.cpp \
     35  gslvector.cpp \
     36  linearsystemofequations.cpp \
     37  Space.cpp \
     38  vector.cpp
    1439                           
    1540LINALGHEADER = gslmatrix.hpp \
    16                            gslvector.hpp \
    17                            linearsystemofequations.hpp \
    18                            Space.hpp \
    19                            vector.hpp
     41  gslvector.hpp \
     42  linearsystemofequations.hpp \
     43  Space.hpp \
     44  vector.hpp
    2045                           
    21 
    22 ANALYSISSOURCE = analysis_bonds.cpp analysis_correlation.cpp
    23 ANALYSISHEADER = analysis_bonds.hpp analysis_correlation.hpp
    24 
    25 ACTIONSSOURCE = Actions/Action.cpp \
    26                                 Actions/ActionHistory.cpp \
    27                                 Actions/ActionRegistry.cpp \
    28                                 Actions/ActionSequence.cpp \
    29                                 Actions/ErrorAction.cpp \
    30                                 Actions/MakroAction.cpp \
    31                                 Actions/ManipulateAtomsProcess.cpp \
    32                                 Actions/MethodAction.cpp \
    33                 Actions/Process.cpp \
    34                 Actions/small_actions.cpp
    35                
    36                  
    37 ACTIONSHEADER = Actions/Action.hpp \
    38                                 Actions/ActionHistory.hpp \
    39                                 Actions/ActionRegistry.hpp \
    40                                 Actions/ActionSequence.hpp \
    41                             Actions/Calculation.hpp \
    42                             Actions/Calculation_impl.hpp \
    43                             Actions/ErrorAction.hpp \
    44                             Actions/MakroAction.hpp \
    45                             Actions/ManipulateAtomsProcess.hpp \
    46                             Actions/MethodAction.hpp \
    47                             Actions/Process.hpp \
    48                             Actions/small_actions.hpp
    49                            
    50                            
    51 
    52 PATTERNSOURCE = Patterns/Observer.cpp
    53 PATTERNHEADER = Patterns/Cacheable.hpp \
    54                                 Patterns/Observer.hpp \
    55                 Patterns/Singleton.hpp
    56 
    57 VIEWSOURCE = Views/View.cpp Views/StringView.cpp Views/MethodStringView.cpp Views/StreamStringView.cpp
    58 VIEWHEADER = Views/View.hpp Views/StringView.hpp Views/MethodStringView.hpp Views/StreamStringView.hpp
    59 
    60 MENUSOURCE = Menu/Menu.cpp Menu/TextMenu.cpp Menu/MenuItem.cpp Menu/SubMenuItem.cpp Menu/ActionMenuItem.cpp Menu/SeperatorItem.cpp Menu/DisplayMenuItem.cpp
    61 MENUHEADER = Menu/Menu.hpp Menu/TextMenu.hpp Menu/MenuItem.hpp Menu/SubMenuItem.hpp Menu/ActionMenuItem.hpp Menu/SeperatorItem.hpp Menu/DisplayMenuItem.hpp
    62 
    63 UISOURCE = ${ACTIONSSOURCE} ${VIEWSOURCE} ${MENUSOURCE} UIElements/UIFactory.cpp UIElements/TextUIFactory.cpp UIElements/MainWindow.cpp UIElements/TextWindow.cpp UIElements/TextStatusIndicator.cpp UIElements/Dialog.cpp UIElements/TextDialog.cpp
    64 UIHEADER = ${ACTIONSHEADER} ${VIEWHEADER} ${MENUHEADER} UIElements/UIFactory.hpp UIElements/TextUIFactory.hpp UIElements/MainWindow.hpp UIElements/TextWindow.hpp UIElements/TextStatusIndicator.hpp UIElements/Dialog.hpp UIElements/TextDialog.hpp
     46ANALYSISSOURCE = \
     47  analysis_bonds.cpp \
     48  analysis_correlation.cpp
     49ANALYSISHEADER = \
     50  analysis_bonds.hpp \
     51  analysis_correlation.hpp
     52
     53ACTIONSSOURCE = \
     54  Actions/Action.cpp \
     55  Actions/ActionHistory.cpp \
     56  Actions/ActionRegistry.cpp \
     57  Actions/ActionSequence.cpp \
     58  Actions/ErrorAction.cpp \
     59  Actions/MakroAction.cpp \
     60  Actions/ManipulateAtomsProcess.cpp \
     61  Actions/MethodAction.cpp \
     62  Actions/Process.cpp
     63
     64ACTIONSHEADER = \
     65  ${ANALYSISACTIONHEADER} \
     66  ${ATOMACTIONHEADER} \
     67  ${CMDACTIONHEADER} \
     68  ${FRAGMENTATIONACTIONHEADER} \
     69  ${MOLECULEACTIONHEADER} \
     70  ${PARSERACTIONHEADER} \
     71  ${TESSELATIONACTIONHEADER} \
     72  ${WORLDACTIONHEADER} \
     73  Actions/Action.hpp \
     74  Actions/ActionHistory.hpp \
     75  Actions/ActionRegistry.hpp \
     76  Actions/ActionSequence.hpp \
     77  Actions/Calculation.hpp \
     78  Actions/Calculation_impl.hpp \
     79  Actions/ErrorAction.hpp \
     80  Actions/MakroAction.hpp \
     81  Actions/ManipulateAtomsProcess.hpp \
     82  Actions/MapOfActions.hpp \
     83  Actions/MethodAction.hpp \
     84  Actions/Process.hpp
     85 
     86
     87PARSERSOURCE = \
     88  Parser/ChangeTracker.cpp \
     89  Parser/FormatParser.cpp \
     90  Parser/TremoloParser.cpp \
     91  Parser/XyzParser.cpp
     92PARSERHEADER = \
     93  Parser/ChangeTracker.hpp \
     94  Parser/FormatParser.hpp \
     95  Parser/TremoloParser.hpp \
     96  Parser/XyzParser.hpp
     97
     98PATTERNSOURCE = \
     99  Patterns/Observer.cpp
     100PATTERNHEADER = \
     101  Patterns/Cacheable.hpp \
     102  Patterns/Observer.hpp \
     103  Patterns/Singleton.hpp
    65104
    66105# all these files are only used for legacy reasons while the transition is in progress
     
    71110
    72111DESCRIPTORSOURCE = Descriptors/AtomDescriptor.cpp \
    73                                    Descriptors/AtomIdDescriptor.cpp \
    74                                    Descriptors/AtomTypeDescriptor.cpp \
    75                                    Descriptors/MoleculeDescriptor.cpp \
    76                                    Descriptors/MoleculeIdDescriptor.cpp
     112  Descriptors/AtomIdDescriptor.cpp \
     113  Descriptors/AtomTypeDescriptor.cpp \
     114  Descriptors/MoleculeDescriptor.cpp \
     115  Descriptors/MoleculeIdDescriptor.cpp \
     116  Descriptors/MoleculeNameDescriptor.cpp \
     117  Descriptors/MoleculePtrDescriptor.cpp
    77118                                   
     119
     120DESCRIPTORHEADER = Descriptors/AtomDescriptor.hpp \
     121  Descriptors/AtomIdDescriptor.hpp \
     122  Descriptors/AtomTypeDescriptor.hpp \
     123  Descriptors/MoleculeDescriptor.hpp \
     124  Descriptors/MoleculeIdDescriptor.hpp \
     125  Descriptors/MoleculeNameDescriptor.hpp \
     126  Descriptors/MoleculePtrDescriptor.hpp
    78127                                   
    79 DESCRIPTORHEADER = Descriptors/AtomDescriptor.hpp \
    80                                    Descriptors/AtomIdDescriptor.hpp \
    81                                    Descriptors/AtomTypeDescriptor.hpp \
    82                                    Descriptors/MoleculeDescriptor.hpp \
    83                                    Descriptors/MoleculeIdDescriptor.hpp
    84                                    
    85 
    86 
    87128EXCEPTIONSOURCE = Exceptions/CustomException.cpp \
    88129                                  Exceptions/LinearDependenceException.cpp \
     
    97138                                  Exceptions/ZeroVectorException.hpp
    98139
    99 SOURCE = ${ANALYSISSOURCE} \
    100                  ${ATOMSOURCE} \
    101                  ${PATTERNSOURCE} \
    102                  ${UISOURCE} \
    103                  ${DESCRIPTORSOURCE} \
    104                  ${HELPERSOURCE} \
    105                  ${LEGACYSOURCE} \
    106                  ${EXCEPTIONSOURCE} \
    107                  bond.cpp \
    108                  bondgraph.cpp \
    109                  boundary.cpp \
    110                  config.cpp \
    111                  element.cpp \
    112                  ellipsoid.cpp \
    113                  errorlogger.cpp \
    114                  graph.cpp \
    115                  helpers.cpp \
    116                  info.cpp \
    117                  leastsquaremin.cpp \
    118                  Line.cpp \
    119                  linkedcell.cpp \
    120                  lists.cpp \
    121                  log.cpp \
    122                  logger.cpp \
    123                  memoryusageobserver.cpp \
    124                  moleculelist.cpp \
    125                  molecule.cpp \
    126                  molecule_dynamics.cpp \
    127                  molecule_fragmentation.cpp \
    128                  molecule_geometry.cpp \
    129                  molecule_graph.cpp \
    130                  molecule_pointcloud.cpp \
    131                  parser.cpp \
    132                  periodentafel.cpp \
    133                  Plane.cpp \
    134                  tesselation.cpp \
    135                  tesselationhelpers.cpp \
    136                  triangleintersectionlist.cpp \
    137                  verbose.cpp \
    138                  vector_ops.cpp \
    139                  World.cpp
     140SOURCE = \
     141  ${ANALYSISSOURCE} \
     142  ${ACTIONSSOURCE} \
     143  ${ATOMSOURCE} \
     144  ${PATTERNSOURCE} \
     145  ${PARSERSOURCE} \
     146  ${DESCRIPTORSOURCE} \
     147  ${HELPERSOURCE} \
     148  ${LEGACYSOURCE} \
     149  ${EXCEPTIONSOURCE} \
     150  bond.cpp \
     151  bondgraph.cpp \
     152  boundary.cpp \
     153  CommandLineParser.cpp \
     154  config.cpp \
     155  element.cpp \
     156  elements_db.cpp \
     157  ellipsoid.cpp \
     158  errorlogger.cpp \
     159  graph.cpp \
     160  helpers.cpp \
     161  info.cpp \
     162  leastsquaremin.cpp \
     163  Line.cpp \
     164  linkedcell.cpp \
     165  log.cpp \
     166  logger.cpp \
     167  moleculelist.cpp \
     168  molecule.cpp \
     169  molecule_dynamics.cpp \
     170  molecule_fragmentation.cpp \
     171  molecule_geometry.cpp \
     172  molecule_graph.cpp \
     173  molecule_pointcloud.cpp \
     174  parser.cpp \
     175  periodentafel.cpp \
     176  Plane.cpp \
     177  Space.cpp \
     178  tesselation.cpp \
     179  tesselationhelpers.cpp \
     180  triangleintersectionlist.cpp \
     181  vector.cpp \
     182  vector_ops.cpp \
     183  verbose.cpp \
     184  World.cpp
    140185
    141186HEADER = \
    142           ${ANALYSISHEADER} \
    143           ${ATOMHEADER} \
    144           ${PATTERNHEADER} \
    145           ${UIHEADER} \
    146           ${DESCRIPTORHEADER} \
    147           ${EXCEPTIONHEADER} \
    148           ${LEGACYHEADER} \
    149           bond.hpp \
    150           bondgraph.hpp \
    151           boundary.hpp \
    152           config.hpp \
    153           defs.hpp \
    154           element.hpp \
    155           ellipsoid.hpp \
    156           errorlogger.hpp \
    157           graph.hpp \
    158           helpers.hpp \
    159           info.hpp \
    160           leastsquaremin.hpp \
    161           Line.hpp \
    162           linkedcell.hpp \
    163           lists.hpp \
    164           log.hpp \
    165           logger.hpp \
    166           memoryallocator.hpp \
    167           memoryusageobserver.hpp \
    168           molecule.hpp \
    169           molecule_template.hpp \
    170           parser.hpp \
    171           periodentafel.hpp \
    172           Plane.hpp \
    173           stackclass.hpp \
    174           tesselation.hpp \
    175           tesselationhelpers.hpp \
    176           triangleintersectionlist.hpp \
    177           verbose.hpp \
    178           vector_ops.hpp \
    179           World.hpp
     187  ${ANALYSISHEADER} \
     188  ${ACTIONSHEADER} \
     189  ${ATOMHEADER} \
     190  ${PARSERHEADER} \
     191  ${PATTERNHEADER} \
     192  ${DESCRIPTORHEADER} \
     193  ${EXCEPTIONHEADER} \
     194  ${LEGACYHEADER} \
     195  bond.hpp \
     196  bondgraph.hpp \
     197  boundary.hpp \
     198  CommandLineParser.hpp \
     199  config.hpp \
     200  defs.hpp \
     201  element.hpp \
     202  elements_db.hpp \
     203  ellipsoid.hpp \
     204  errorlogger.hpp \
     205  graph.hpp \
     206  helpers.hpp \
     207  info.hpp \
     208  leastsquaremin.hpp \
     209  Line.hpp \
     210  linkedcell.hpp \
     211  lists.hpp \
     212  log.hpp \
     213  logger.hpp \
     214  molecule.hpp \
     215  molecule_template.hpp \
     216  parser.hpp \
     217  periodentafel.hpp \
     218  Plane.hpp \
     219  stackclass.hpp \
     220  tesselation.hpp \
     221  tesselationhelpers.hpp \
     222  triangleintersectionlist.hpp \
     223  verbose.hpp \
     224  vector_ops.hpp \
     225  World.hpp
     226
     227# the following files are no longer used:
     228#  memoryallocator.hpp \
     229#  memoryallocator.cpp \
     230#  memoryusageobserver.hpp \
     231#  memoryusageobserver.cpp
    180232
    181233BOOST_LIB = $(BOOST_LDFLAGS) $(BOOST_MPL_LIB)
    182 INCLUDES = -I$(top_srcdir)/src/unittests
     234INCLUDES = -I$(top_srcdir)/src/unittests -I$(top_srcdir)/src/Actions -I$(top_srcdir)/src/UIElements
    183235
    184236noinst_LIBRARIES = libmolecuilder.a libgslwrapper.a
     
    190242molecuilder_LDFLAGS = $(BOOST_LDFLAGS)
    191243molecuilder_SOURCES = builder.cpp
    192 molecuilder_LDADD = libmolecuilder.a libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB}
     244molecuilder_LDADD =  UIElements/libMolecuilderUI.a Actions/libMolecuilderActions.a libmolecuilder.a libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB} ${BOOST_PROGRAM_OPTIONS_LIB}
    193245joiner_SOURCES = joiner.cpp datacreator.cpp parser.cpp datacreator.hpp helpers.hpp parser.hpp periodentafel.hpp
    194246joiner_LDADD = libmolecuilder.a $(BOOST_LIB) ${BOOST_THREAD_LIB}
    195247analyzer_SOURCES = analyzer.cpp datacreator.cpp parser.cpp helpers.hpp periodentafel.hpp parser.hpp datacreator.hpp
    196248analyzer_LDADD = libmolecuilder.a $(BOOST_LIB) ${BOOST_THREAD_LIB}
    197 
    198 #EXTRA_DIST = ${molecuilder_DATA}
    199249
    200250FORCE:
  • src/Patterns/Cacheable.hpp

    r0c7ed8 r1dc9ec  
    2828        owner(_owner)
    2929        {}
    30       virtual T getValue()=0;
     30      virtual T& getValue()=0;
    3131      virtual void invalidate()=0;
    3232      virtual bool isValid()=0;
     
    3535        return busy;
    3636      }
     37    virtual std::string getName()=0;
    3738    protected:
    3839      bool busy;
     
    4647        {}
    4748
    48       virtual T getValue(){
     49      virtual T& getValue(){
    4950        // set the state to valid
    5051        State::owner->switchState(State::owner->validState);
     
    6465        // nothing to do when entering this
    6566      }
     67
     68      virtual std::string getName(){
     69        return "invalid";
     70      }
    6671    };
    6772
     
    7277        {}
    7378
    74       virtual T getValue(){
     79      virtual T& getValue(){
    7580        return content;
    7681      }
     
    9095        State::busy = false;
    9196      }
     97
     98      virtual std::string getName(){
     99        return "valid";
     100      }
    92101    private:
    93102      T content;
     
    100109        {}
    101110
    102       virtual T getValue(){
     111      virtual T& getValue(){
    103112        ASSERT(0,"Cannot get a value from a Cacheable after it's Observable has died");
    104113        // we have to return a grossly invalid reference, because no value can be produced anymore
     
    118127        // nothing to do when entering this state
    119128      }
     129
     130      virtual std::string getName(){
     131        return "destroyed";
     132      }
    120133    };
    121134
     
    124137
    125138  public:
    126     Cacheable(Observable *_owner, boost::function<T()> _recalcMethod);
     139    Cacheable(Observable *_owner, boost::function<T()> _recalcMethod, std::string name);
    127140    virtual ~Cacheable();
    128141
     
    134147    void subjectKilled(Observable *subject);
    135148  private:
    136 
    137149    void switchState(state_ptr newState);
    138150
     
    144156
    145157    Observable *owner;
    146 
    147158    boost::function<T()> recalcMethod;
    148159
     
    153164
    154165  template<typename T>
    155   Cacheable<T>::Cacheable(Observable *_owner, boost::function<T()> _recalcMethod) :
     166  Cacheable<T>::Cacheable(Observable *_owner, boost::function<T()> _recalcMethod, std::string name) :
     167    Observer(name + "(Cached)"),
    156168    owner(_owner),
    157169    recalcMethod(_recalcMethod)
     
    208220  void Cacheable<T>::switchState(state_ptr newState){
    209221    ASSERT(!state->isBusy(),"LOOP DETECTED: Cacheable state switched while recalculating.\nDid the recalculation trigger the Observable?");
     222#ifdef LOG_OBSERVER
     223    observerLog().addMessage() << "## Cacheable " << observerLog().getName(this) << " changed state (" << state->getName()
     224                               << "->" << newState->getName() << ")" << std::endl;
     225#endif
    210226    state = newState;
    211227    state->enter();
     
    217233  {
    218234  public:
    219     Cacheable(Observable *_owner, boost::function<T()> _recalcMethod);
     235    Cacheable(Observable *_owner, boost::function<T()> _recalcMethod,std::string name);
    220236    virtual ~Cacheable();
    221237
     
    232248
    233249  template<typename T>
    234   Cacheable<T>::Cacheable(Observable *_owner, boost::function<T()> _recalcMethod) :
     250  Cacheable<T>::Cacheable(Observable *_owner, boost::function<T()> _recalcMethod, std::string name) :
     251    Observer(name),
    235252    recalcMethod(_recalcMethod)
    236253  {}
  • src/Patterns/Observer.cpp

    r0c7ed8 r1dc9ec  
    66 */
    77
     8#include "Helpers/MemDebug.hpp"
     9
    810#include "Observer.hpp"
    911
     
    1214
    1315#include "Helpers/Assert.hpp"
     16#include "Helpers/MemDebug.hpp"
    1417
    1518using namespace std;
     
    4346  // if no entry for this observable is found, an new one is created
    4447  // by the STL and initialized to 0 (see STL documentation)
     48#ifdef LOG_OBSERVER
     49  observerLog().addMessage(depth[publisher]) << ">> Locking " << observerLog().getName(publisher) << endl;
     50#endif
    4551  depth[publisher]++;
    4652}
     
    6066  // if zero is reached all observed blocks are done and we can
    6167  // start to notify our observers
    62   if(--(depth[publisher])){}
     68  --depth[publisher];
     69#ifdef LOG_OBSERVER
     70  observerLog().addMessage(depth[publisher]) << "<< Unlocking " << observerLog().getName(publisher) << endl;
     71#endif
     72  if(depth[publisher]){}
    6373  else{
    6474    publisher->notifyAll();
     
    8292Observable::_Observable_protector::_Observable_protector(Observable *_protege) :
    8393  protege(_protege)
     94{
     95  start_observer_internal(protege);
     96}
     97
     98Observable::_Observable_protector::_Observable_protector(const _Observable_protector &dest) :
     99    protege(dest.protege)
    84100{
    85101  start_observer_internal(protege);
     
    117133      callees_t::iterator iter;
    118134      for(iter=callees.begin();iter!=callees.end();++iter){
     135#ifdef LOG_OBSERVER
     136        observerLog().addMessage() << "-> Sending update from " << observerLog().getName(this)
     137                                   << " to " << observerLog().getName((*iter).second)
     138                                   << " (priority=" << (*iter).first << ")"<< endl;
     139#endif
    119140        (*iter).second->update(this);
    120141      }
     
    159180    // we do not need to publish all the changes at each time we are called
    160181    if(depth.find(this)==depth.end()) {
     182#ifdef LOG_OBSERVER
     183      observerLog().addMessage() << "-* Update from " << observerLog().getName(publisher)
     184                                 << " propagated by " << observerLog().getName(this) << endl;
     185#endif
    161186      notifyAll();
     187    }
     188    else{
     189#ifdef LOG_OBSERVER
     190      observerLog().addMessage() << "-| Update from " <<  observerLog().getName(publisher)
     191                                 << " not propagated by " << observerLog().getName(this) << endl;
     192#endif
    162193    }
    163194  }
     
    171202void Observable::signOn(Observer *target,int priority) {
    172203  ASSERT(priority>=-20 && priority<=+20, "Priority out of range [-20:+20] when signing on Observer");
     204#ifdef LOG_OBSERVER
     205  observerLog().addMessage() << "@@ Signing on " << observerLog().getName(target) << " to " << observerLog().getName(this) << endl;
     206#endif
    173207  bool res = false;
    174208  callees_t &callees = callTable[this];
     
    188222void Observable::signOff(Observer *target) {
    189223  ASSERT(callTable.count(this),"SignOff called for an Observable without Observers.");
     224#ifdef LOG_OBSERVER
     225  observerLog().addMessage() << "** Signing off " << observerLog().getName(target) << " from " << observerLog().getName(this) << endl;
     226#endif
    190227  callees_t &callees = callTable[this];
     228
    191229  callees_t::iterator iter;
    192230  callees_t::iterator deliter;
     
    231269/** Constructor for class Observable.
    232270 */
    233 Observable::Observable()
    234 {}
     271Observable::Observable(string name) :
     272  Observer(Observer::BaseConstructor())
     273{
     274#ifdef LOG_OBSERVER
     275  observerLog().addName(this,name);
     276  observerLog().addMessage() << "++ Creating Observable " << observerLog().getName(this) << endl;
     277#endif
     278}
    235279
    236280/** Destructor for class Observable.
     
    239283Observable::~Observable()
    240284{
     285#ifdef LOG_OBSERVER
     286  observerLog().addMessage() << "-- Destroying Observable " << observerLog().getName(this) << endl;
     287#endif
    241288  if(callTable.count(this)) {
    242289    // delete all entries for this observable
     
    252299/** Constructor for class Observer.
    253300 */
    254 Observer::Observer()
    255 {}
     301Observer::Observer(string name)
     302{
     303#ifdef LOG_OBSERVER
     304  observerLog().addName(this,name);
     305  observerLog().addMessage() << "++ Creating Observer " << observerLog().getName(this) << endl;
     306#endif
     307}
     308
     309/**
     310 * Base Constructor for class Observer
     311 *
     312 * only called from Observable Constructor
     313 */
     314Observer::Observer(Observer::BaseConstructor){
     315#ifdef LOG_OBSERVER
     316  observerLog().addObservable(this);
     317#endif
     318}
    256319
    257320/** Destructor for class Observer.
    258321 */
    259322Observer::~Observer()
    260 {}
     323{
     324#ifdef LOG_OBSERVER
     325  if(!observerLog().isObservable(this)){
     326    observerLog().addMessage() << "-- Destroying Observer " << observerLog().getName(this) << endl;
     327  }
     328#endif
     329}
    261330
    262331/**
     
    289358  }
    290359}
     360
     361#ifdef LOG_OBSERVER
     362
     363/************************* Methods to do logging of the Observer Mechanism *********/
     364
     365// The log needs to exist fairly early, so we make it construct on first use,
     366// and never destroy it
     367ObserverLog &observerLog(){
     368  // yes, this memory is never freed... we need it around for the whole programm,
     369  // so no freeing is possible
     370  static ObserverLog *theLog = Memory::ignore(new ObserverLog());
     371  return *theLog;
     372}
     373
     374
     375ObserverLog::ObserverLog() :
     376  count (0)
     377{}
     378
     379ObserverLog::~ObserverLog(){}
     380
     381string ObserverLog::getLog(){return log.str();}
     382
     383std::string ObserverLog::getName(void* obj){
     384  return names[obj];
     385}
     386
     387bool ObserverLog::isObservable(void* obj){
     388  return observables.count(obj);
     389}
     390
     391void ObserverLog::addName(void* obj , string name){
     392  stringstream sstr;
     393  sstr << name << "_" << count++;
     394  names[obj] = sstr.str();
     395}
     396
     397void ObserverLog::addObservable(void* obj){
     398  observables.insert(obj);
     399}
     400
     401void ObserverLog::deleteName(void* obj){
     402  names.erase(obj);
     403}
     404
     405void ObserverLog::deleteObservable(void* obj){
     406  observables.erase(obj);
     407}
     408
     409stringstream &ObserverLog::addMessage(int depth){
     410  for(int i=depth;i--;)
     411    log << "  ";
     412  return log;
     413}
     414
     415#endif
  • src/Patterns/Observer.hpp

    r0c7ed8 r1dc9ec  
    1111#include <map>
    1212#include <set>
     13#include <string>
     14#include <sstream>
    1315
    1416/**
     
    2830 */
    2931
     32// Deactivate any logging when we are not in debug mode
     33#ifdef NDEBUG
     34#undef LOG_OBSERVER
     35#endif
     36
    3037class Observable;
    3138class Notification;
     
    3542// identification process
    3643typedef Notification *const Notification_ptr;
     44
     45template<class _Set>
     46class ObservedIterator;
    3747
    3848/**
     
    5363  friend class Observable;
    5464  friend class Notification;
    55 public:
    56   Observer();
     65  template<class> friend class ObservedIterator;
     66
     67  // indicates the constructor called from Observables
     68  struct BaseConstructor{};
     69
     70public:
     71  Observer(BaseConstructor);
     72  Observer(std::string);
    5773  virtual ~Observer();
    5874
     
    86102class Observable : public Observer {
    87103public:
    88   Observable();
     104  Observable(std::string _name);
    89105  virtual ~Observable();
    90106
     
    152168  static std::set<Observable*> busyObservables;
    153169
    154 
    155170  //! @cond
    156171  // Structure for RAII-Style notification
     
    164179  public:
    165180    _Observable_protector(Observable *);
     181    _Observable_protector(const _Observable_protector&);
    166182    ~_Observable_protector();
    167183  private:
     
    187203};
    188204
     205#ifdef LOG_OBSERVER
     206
     207/**
     208 * This class is used to log the working of the observer mechanism
     209 *
     210 * TODO: make this conditional dependent on compiler Flag.
     211 */
     212class ObserverLog{
     213  friend class Observable;
     214  friend class Observer;
     215  template <typename> friend class Cacheable;
     216public:
     217  ObserverLog();
     218  ~ObserverLog();
     219  std::string getLog();                        // get everything that has been logged
     220  std::string getName(void*);                  // get the name of an actor
     221  bool isObservable(void*);
     222private:
     223  int count;                                   // number to reference each actor in this framework
     224  std::map<void*,std::string> names;           // List of names assigned to actors
     225  std::set<void*> observables;                 // List of pointers to Observables. Needed to distinguish Observers and Observables
     226  void addName(void*, std::string);            // Assign a name to an Actor
     227  void addObservable(void*);
     228  void deleteName(void*);                      // delete the name of an Actor
     229  void deleteObservable(void*);
     230  std::stringstream &addMessage(int depth=0);  // Add a Message to the logging
     231  std::stringstream log;                       // The internal log object
     232};
     233
     234ObserverLog &observerLog();
     235
     236#endif
     237
    189238// extra macro is necessary to work with __LINE__
    190239#define PASTE(a,b) PASTE_HELPER(a,b)
  • src/Plane.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "Plane.hpp"
  • src/Space.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "Space.hpp"
  • src/UIElements/Dialog.cpp

    r0c7ed8 r1dc9ec  
    66 */
    77
     8#include "Helpers/MemDebug.hpp"
     9
    810#include <cassert>
    911
    10 #include "UIElements/Dialog.hpp"
    11 
     12#include "Dialog.hpp"
     13
     14#include "atom.hpp"
     15#include "element.hpp"
     16#include "molecule.hpp"
    1217#include "vector.hpp"
    1318
     
    3641    retval &= (*iter)->handle();
    3742    // if any query fails (is canceled), we can end the handling process
    38     if(!retval)
     43    if(!retval) {
     44      DoeLog(1) && (eLog() << Verbose(1) << "The following query failed: " << (**iter).getTitle() << "." << endl);
    3945      break;
     46    }
    4047  }
    4148  if (retval){
     
    5158
    5259// Base class
    53 Dialog::Query::Query(string _title) :
    54     title(_title)
     60Dialog::Query::Query(string _title, string _description) :
     61    title(_title),
     62    description(_description)
    5563{}
    5664
     
    6169}
    6270
     71const std::string Dialog::Query::getDescription() const{
     72  return description;
     73}
     74// empty Queries
     75
     76Dialog::EmptyQuery::EmptyQuery(string title, std::string description) :
     77    Query(title, description)
     78{}
     79
     80Dialog::EmptyQuery::~EmptyQuery() {}
     81
     82void Dialog::EmptyQuery::setResult() {
     83}
     84
    6385// Int Queries
    6486
    65 Dialog::IntQuery::IntQuery(string title,int *_target) :
    66     Query(title), target(_target)
     87Dialog::IntQuery::IntQuery(string title,int *_target, std::string description) :
     88    Query(title, description), target(_target)
    6789{}
    6890
     
    7395}
    7496
     97// Int Queries
     98
     99Dialog::BooleanQuery::BooleanQuery(string title,bool *_target, std::string description) :
     100    Query(title, description), target(_target)
     101{}
     102
     103Dialog::BooleanQuery::~BooleanQuery() {}
     104
     105void Dialog::BooleanQuery::setResult() {
     106  *target = tmp;
     107}
     108
    75109// String Queries
    76110
    77 Dialog::StringQuery::StringQuery(string title,string *_target) :
    78     Query(title), target(_target)
     111Dialog::StringQuery::StringQuery(string title,string *_target, std::string _description) :
     112    Query(title, _description), target(_target)
    79113{}
    80114
     
    87121// Double Queries
    88122
    89 Dialog::DoubleQuery::DoubleQuery(string title,double *_target) :
    90     Query(title), target(_target)
     123Dialog::DoubleQuery::DoubleQuery(string title,double *_target, std::string _description) :
     124    Query(title, _description), target(_target)
    91125{}
    92126
     
    98132
    99133
     134// Atom Queries
     135
     136Dialog::AtomQuery::AtomQuery(string title, atom **_target, std::string _description) :
     137    Query(title, _description),
     138    tmp(0),
     139    target(_target)
     140
     141{}
     142
     143Dialog::AtomQuery::~AtomQuery() {}
     144
     145void Dialog::AtomQuery::setResult() {
     146  *target = tmp;
     147}
     148
    100149// Molecule Queries
    101150
    102 Dialog::MoleculeQuery::MoleculeQuery(string title, molecule **_target, MoleculeListClass *_molecules) :
    103     Query(title),
     151Dialog::MoleculeQuery::MoleculeQuery(string title, molecule **_target, std::string _description) :
     152    Query(title, _description),
    104153    tmp(0),
    105     molecules(_molecules),
    106154    target(_target)
    107155
     
    116164// Vector Queries
    117165
    118 Dialog::VectorQuery::VectorQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check) :
    119   Query(title),
     166Dialog::VectorQuery::VectorQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check, std::string _description) :
     167  Query(title, _description),
    120168  cellSize(_cellSize),
    121169  check(_check),
    122170  target(_target)
    123171{
    124 tmp = new Vector();
     172  tmp = new Vector();
    125173}
    126174
     
    134182}
    135183
     184// Box Queries
     185
     186Dialog::BoxQuery::BoxQuery(std::string title, double ** const _cellSize, std::string _description) :
     187  Query(title, _description),
     188  target(_cellSize)
     189{
     190    tmp = new double[6];
     191}
     192
     193Dialog::BoxQuery::~BoxQuery()
     194{
     195  delete[] tmp;
     196}
     197
     198void Dialog::BoxQuery::setResult() {
     199  for (int i=0;i<6;i++) {
     200    (*target)[i] = tmp[i];
     201  }
     202}
     203
    136204// Element Queries
    137 Dialog::ElementQuery::ElementQuery(std::string title, const element **_target) :
    138   Query(title),
    139   tmp(0),
     205Dialog::ElementQuery::ElementQuery(std::string title, std::vector<element *> *_target, std::string _description) :
     206  Query(title, _description),
    140207  target(_target)
    141208  {}
     
    144211
    145212void Dialog::ElementQuery::setResult(){
    146   *target=tmp;
    147 }
     213  *target=elements;
     214}
  • src/UIElements/Dialog.hpp

    r0c7ed8 r1dc9ec  
    1111#include<string>
    1212#include<list>
     13#include<vector>
    1314
    14 class MoleculeListClass;
     15class atom;
     16class element;
    1517class molecule;
    1618class Vector;
    17 class element;
    1819
    1920class Dialog
     
    2324  virtual ~Dialog();
    2425
    25   virtual void queryInt(const char *, int *)=0;
    26   virtual void queryDouble(const char*,double *)=0;
    27   virtual void queryString(const char*, std::string *)=0;
    28   virtual void queryMolecule(const char*,molecule**,MoleculeListClass*)=0;
    29   virtual void queryVector(const char*,Vector *,const double *const,bool)=0;
    30   virtual void queryElement(const char*,const element **)=0;
     26  virtual void queryEmpty(const char *, std::string = "")=0;
     27  virtual void queryBoolean(const char *, bool *, std::string = "")=0;
     28  virtual void queryInt(const char *, int *, std::string = "")=0;
     29  virtual void queryDouble(const char*,double *, std::string = "")=0;
     30  virtual void queryString(const char*, std::string *, std::string = "")=0;
     31  virtual void queryAtom(const char*,atom**,std::string = "")=0;
     32  virtual void queryMolecule(const char*,molecule**, std::string = "")=0;
     33  virtual void queryVector(const char*,Vector *,const double *const,bool, std::string = "")=0;
     34  virtual void queryBox(const char*,double ** const, std::string = "")=0;
     35  virtual void queryElement(const char*, std::vector<element *> *, std::string = "")=0;
    3136
    3237  virtual bool display();
     
    4550  //base class for all queries
    4651  class Query {
     52    friend class Dialog;
    4753  public:
    48     Query(std::string _title);
     54    Query(std::string _title, std::string _description = "");
    4955    virtual ~Query();
    5056    virtual bool handle()=0;
     
    5258  protected:
    5359    const std::string getTitle() const;
     60    const std::string getDescription() const;
    5461  private:
    55     std::string title;
     62    std::string title;  //!< short title of the query
     63    std::string description; //!< longer description for tooltips or for help
     64  };
     65
     66  // Empty Query is just meant for showing text, such as version, help, initial message or alike
     67  class EmptyQuery : public Query {
     68  public:
     69    EmptyQuery(std::string title, std::string _description = "");
     70    virtual ~EmptyQuery();
     71    virtual bool handle()=0;
     72    virtual void setResult();
    5673  };
    5774
    5875  //Specialized classes for certain types. GUI-Types are not specialized at this time
     76  class BooleanQuery : public Query {
     77  public:
     78    BooleanQuery(std::string title,bool *_target, std::string _description = "");
     79    virtual ~BooleanQuery();
     80    virtual bool handle()=0;
     81    virtual void setResult();
     82  protected:
     83    bool tmp;
     84  private:
     85    bool *target;
     86  };
     87
    5988  class IntQuery : public Query {
    6089  public:
    61     IntQuery(std::string title,int *_target);
     90    IntQuery(std::string title,int *_target, std::string _description = "");
    6291    virtual ~IntQuery();
    6392    virtual bool handle()=0;
     
    71100  class DoubleQuery : public Query {
    72101  public:
    73     DoubleQuery(std::string title,double *_target);
     102    DoubleQuery(std::string title,double *_target, std::string _description = "");
    74103    virtual ~DoubleQuery();
    75104    virtual bool handle()=0;
     
    83112  class StringQuery : public Query {
    84113  public:
    85     StringQuery(std::string title,std::string *_target);
     114    StringQuery(std::string title,std::string *_target, std::string _description = "");
    86115    virtual ~StringQuery();
    87116    virtual bool handle()=0;
     
    93122  };
    94123
    95 
    96124  class MoleculeQuery : public Query {
    97125  public:
    98     MoleculeQuery(std::string title, molecule **_target, MoleculeListClass *_molecules);
     126    MoleculeQuery(std::string title, molecule **_target, std::string _description = "");
    99127    virtual ~MoleculeQuery();
    100128    virtual bool handle()=0;
     
    102130  protected:
    103131    molecule *tmp;
    104     MoleculeListClass *molecules;
    105132  private:
    106133    molecule **target;
    107134  };
    108135
     136  class AtomQuery : public Query {
     137  public:
     138    AtomQuery(std::string title, atom **_target, std::string _description = "");
     139    virtual ~AtomQuery();
     140    virtual bool handle()=0;
     141    virtual void setResult();
     142  protected:
     143    atom *tmp;
     144  private:
     145    atom **target;
     146  };
     147
    109148  class VectorQuery : public Query {
    110149  public:
    111       VectorQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check);
     150      VectorQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check, std::string _description = "");
    112151      virtual ~VectorQuery();
    113152      virtual bool handle()=0;
     
    121160  };
    122161
     162  class BoxQuery : public Query {
     163  public:
     164      BoxQuery(std::string title,double ** const _cellSize, std::string _description = "");
     165      virtual ~BoxQuery();
     166      virtual bool handle()=0;
     167      virtual void setResult();
     168    protected:
     169      double *tmp;
     170    private:
     171      double **target;
     172  };
     173
    123174  class ElementQuery : public Query {
    124175  public:
    125     ElementQuery(std::string title, const element**_target);
     176    ElementQuery(std::string title, std::vector<element *> *_target, std::string _description = "");
    126177    virtual ~ElementQuery();
    127178    virtual bool handle()=0;
    128179    virtual void setResult();
    129180  protected:
    130     const element *tmp;
     181    std::vector<element *> elements;
    131182  private:
    132     const element **target;
     183    std::vector<element *> * const target;
    133184  };
    134185
     
    140191};
    141192
     193
    142194#endif /* DIALOG_HPP_ */
  • src/UIElements/MainWindow.cpp

    r0c7ed8 r1dc9ec  
    66 */
    77
    8 #include "UIElements/MainWindow.hpp"
     8#include "Helpers/MemDebug.hpp"
     9
     10#include "MainWindow.hpp"
    911
    1012MainWindow::MainWindow()
  • src/UIElements/MainWindow.hpp

    r0c7ed8 r1dc9ec  
    2525};
    2626
    27 /**
    28  * The type of menuPopulators
    29  */
    30 typedef void (*MenuMaker)(Menu*,MoleculeListClass*, config*, periodentafel*);
    31 
    32 /**
    33  * This contains all Functions that are used to create the menus.
    34  * Needs a specific funtion for each menu. All populators will be called
    35  * by the UIFactory upon creation of the main menu. Thus the actuall construction
    36  * of the Menus can be kept independent of the concrete type of UI that is being
    37  * built.
    38  */
    39 struct menuPopulaters{
    40   MenuMaker MakeEditMoleculesMenu;
    41 };
    4227
    4328#endif /* MAINWINDOW_HPP_ */
  • src/UIElements/UIFactory.cpp

    r0c7ed8 r1dc9ec  
    66 */
    77
     8#include "Helpers/MemDebug.hpp"
    89
    9 #include <cassert>
     10#include <utility>
    1011#include "Patterns/Singleton_impl.hpp"
    1112#include "UIElements/UIFactory.hpp"
     13#include "Helpers/Assert.hpp"
    1214
    13 // all factories that can be used:
    14 #include "UIElements/TextUIFactory.hpp"
     15using namespace std;
     16
     17std::map<std::string,boost::shared_ptr<UIFactory::factoryDescription> > UIFactory::factories;
    1518
    1619UIFactory::UIFactory()
    17 {
    18   // TODO Auto-generated constructor stub
     20{}
    1921
     22UIFactory::~UIFactory()
     23{}
     24
     25void UIFactory::makeUserInterface(std::string type) {
     26  ASSERT(factories.count(type),"Selected factory was not registered before creation.");
     27  // call the factory factory
     28  setInstance(factories[type]->makeFactory());
    2029}
    2130
    22 UIFactory::~UIFactory()
    23 {
    24   // TODO Auto-generated destructor stub
    25 }
    26 
    27 void UIFactory::makeUserInterface(InterfaceTypes type) {
    28   switch(type) {
    29     case Text :
    30       setInstance(new TextUIFactory());
    31       break;
    32 
    33     default:
    34       assert(0 && "No such Factory in stock");
    35       break;
    36   }
     31void UIFactory::registerFactory(factoryDescription *factoryDesc) {
     32  ASSERT(!factories.count(factoryDesc->name),"Trying to re-register an already registered factory.");
     33  factories.insert(make_pair(factoryDesc->name,
     34                             boost::shared_ptr<factoryDescription>(factoryDesc)));
    3735}
    3836
    3937CONSTRUCT_SINGLETON(UIFactory)
     38
     39UIFactory::factoryDescription::factoryDescription(string _name) :
     40  name(_name)
     41{}
     42
     43UIFactory::factoryDescription::~factoryDescription()
     44{}
  • src/UIElements/UIFactory.hpp

    r0c7ed8 r1dc9ec  
    1111class MainWindow;
    1212class Dialog;
    13 
    14 class MoleculeListClass;
    15 class config;
    16 class periodentafel;
    17 
    18 struct menuPopulaters;
     13class DialogDescription;
    1914
    2015#include "Patterns/Singleton.hpp"
     16
     17#include <string>
     18#include <map>
     19#include <boost/smart_ptr.hpp>
    2120
    2221/**
     
    2928class UIFactory : public Singleton<UIFactory,false>
    3029{
    31 
     30  friend class Singleton<UIFactory,false>;
    3231public:
    33   enum InterfaceTypes {Text};
    34   virtual ~UIFactory();
    35 
    3632  /**
    3733   * Produce some kind of main window, of whichever type was chosen when the factory was created
    3834   */
    39   virtual MainWindow* makeMainWindow(menuPopulaters,MoleculeListClass *, config *, periodentafel *, char *)=0;
     35  virtual MainWindow* makeMainWindow()=0;
    4036
    4137  /**
     
    4743protected:
    4844  UIFactory();
     45  virtual ~UIFactory();
    4946
    5047public:
     48  struct factoryDescription {
     49    factoryDescription(std::string _name);
     50    virtual ~factoryDescription();
     51
     52    const std::string name;
     53    // yes this method really is a factory factory, to allow insertion of
     54    // arbitrary factories
     55    virtual UIFactory* makeFactory()=0;
     56  };
    5157  /**
    5258   * create a Factory of a certain type. From that moment on only those UIElements can be produced by the factory
    5359   */
    54   static void makeUserInterface(InterfaceTypes type);
    55 
     60  static void makeUserInterface(std::string type);
     61  static void registerFactory(factoryDescription *factoryDesc);
     62protected:
     63private:
     64  static std::map<std::string,boost::shared_ptr<factoryDescription> > factories;
    5665};
    5766
  • src/World.cpp

    r0c7ed8 r1dc9ec  
    66 */
    77
     8#include "Helpers/MemDebug.hpp"
     9
    810#include "World.hpp"
    911
    1012#include "atom.hpp"
     13#include "config.hpp"
    1114#include "molecule.hpp"
    1215#include "periodentafel.hpp"
     
    2730}
    2831
     32config *&World::getConfig(){
     33  return configuration;
     34}
     35
    2936// Atoms
    3037
     
    5562}
    5663
     64std::vector<molecule*> World::getAllMolecules(){
     65  return getAllMolecules(AllMolecules());
     66}
     67
    5768int World::numMolecules(){
    5869  return molecules_deprecated->ListOfMolecules.size();
     
    7081}
    7182
    72 char * World::getDefaultName() {
     83std::string World::getDefaultName() {
    7384  return defaultName;
    7485}
    7586
    76 void World::setDefaultName(char * name)
     87void World::setDefaultName(std::string name)
    7788{
    78   delete[](defaultName);
    79   const int length = strlen(name);
    80   defaultName = new char[length+2];
    81   if (length < MAXSTRINGSIZE)
    82     strncpy(defaultName, name, length);
    83   else
    84     strcpy(defaultName, "none");
     89  defaultName = name;
    8590};
    8691
     92int World::getExitFlag() {
     93  return ExitFlag;
     94}
     95
     96void World::setExitFlag(int flag) {
     97  if (ExitFlag < flag)
     98    ExitFlag = flag;
     99}
    87100
    88101/******************** Methods to change World state *********************/
     
    114127
    115128double *World::cell_size = NULL;
    116 char *World::defaultName = NULL;
    117129
    118130atom *World::createAtom(){
     
    266278
    267279World::World() :
     280    Observable("World"),
    268281    periode(new periodentafel),
     282    configuration(new config),
     283    ExitFlag(0),
    269284    atoms(),
    270285    currAtomId(0),
     
    280295  cell_size[4] = 0.;
    281296  cell_size[5] = 20.;
    282   defaultName = new char[MAXSTRINGSIZE];
    283   strcpy(defaultName, "none");
     297  defaultName = "none";
    284298  molecules_deprecated->signOn(this);
    285299}
     
    289303  molecules_deprecated->signOff(this);
    290304  delete[] cell_size;
    291   delete[] defaultName;
    292305  delete molecules_deprecated;
    293306  delete periode;
     307  delete configuration;
    294308  MoleculeSet::iterator molIter;
    295309  for(molIter=molecules.begin();molIter!=molecules.end();++molIter){
  • src/World.hpp

    r0c7ed8 r1dc9ec  
    3030
    3131// forward declarations
     32class config;
    3233class periodentafel;
    3334class MoleculeListClass;
     
    7576
    7677  /**
     78   * returns the configuration for the world.
     79   */
     80  config *&getConfig();
     81
     82  /**
    7783   * returns the first atom that matches a given descriptor.
    7884   * Do not rely on ordering for descriptors that match more than one atom.
     
    109115   */
    110116  std::vector<molecule*> getAllMolecules(MoleculeDescriptor descriptor);
     117  std::vector<molecule*> getAllMolecules();
    111118
    112119  /**
     
    128135   * get the default name
    129136   */
    130   char * getDefaultName();
     137  std::string getDefaultName();
    131138
    132139  /**
    133140   * set the default name
    134141   */
    135   void setDefaultName(char * name);
     142  void setDefaultName(std::string name);
     143
     144  /*
     145   * get the ExitFlag
     146   */
     147  int getExitFlag();
     148
     149  /*
     150   * set the ExitFlag
     151   */
     152  void setExitFlag(int flag);
    136153
    137154  /***** Methods to work with the World *****/
     
    234251
    235252  periodentafel *periode;
     253  config *configuration;
    236254  static double *cell_size;
    237   static char *defaultName;
     255  std::string defaultName;
     256  int ExitFlag;
    238257public:
    239258  AtomSet atoms;
  • src/analysis_bonds.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "analysis_bonds.hpp"
     
    2628  Mean = 0.;
    2729
    28   atom *Walker = mol->start;
    2930  int AtomCount = 0;
    30   while (Walker->next != mol->end) {
    31     Walker = Walker->next;
    32     const int count = Walker->ListOfBonds.size();
     31  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     32    const int count = (*iter)->ListOfBonds.size();
    3333    if (Max < count)
    3434      Max = count;
     
    5151 * \param &Max maximum distance on return, 0 if no bond between the two elements
    5252 */
    53 void MinMeanMaxBondDistanceBetweenElements(const molecule *mol, element *type1, element *type2, double &Min, double &Mean, double &Max)
     53void MinMeanMaxBondDistanceBetweenElements(const molecule *mol, const element *type1, const element *type2, double &Min, double &Mean, double &Max)
    5454{
    5555  Min = 2e+6;
     
    5858
    5959  int AtomNo = 0;
    60   atom *Walker = mol->start;
    61   while (Walker->next != mol->end) {
    62     Walker = Walker->next;
    63     if (Walker->type == type1)
    64       for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++)
    65         if ((*BondRunner)->GetOtherAtom(Walker)->type == type2) {
     60  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     61    if ((*iter)->type == type1)
     62      for (BondList::const_iterator BondRunner = (*iter)->ListOfBonds.begin(); BondRunner != (*iter)->ListOfBonds.end(); BondRunner++)
     63        if ((*BondRunner)->GetOtherAtom((*iter))->type == type2) {
    6664          const double distance = (*BondRunner)->GetDistanceSquared();
    6765          if (Min > distance)
     
    124122 * \param *InterfaceElement or NULL
    125123 */
    126 int CountHydrogenBridgeBonds(MoleculeListClass *molecules, element * InterfaceElement = NULL)
    127 {
    128   atom *Walker = NULL;
    129   atom *Runner = NULL;
     124int CountHydrogenBridgeBonds(MoleculeListClass *molecules, const element * InterfaceElement = NULL)
     125{
    130126  int count = 0;
    131127  int OtherHydrogens = 0;
     
    133129  bool InterfaceFlag = false;
    134130  bool OtherHydrogenFlag = true;
    135   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) {
    136     Walker = (*MolWalker)->start;
    137     while (Walker->next != (*MolWalker)->end) {
    138       Walker = Walker->next;
    139       for (MoleculeList::const_iterator MolRunner = molecules->ListOfMolecules.begin();MolRunner != molecules->ListOfMolecules.end(); MolRunner++) {
    140         Runner = (*MolRunner)->start;
    141         while (Runner->next != (*MolRunner)->end) {
    142           Runner = Runner->next;
    143           if ((Walker->type->Z  == 8) && (Runner->type->Z  == 8)) {
     131  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); ++MolWalker) {
     132    molecule::iterator Walker = (*MolWalker)->begin();
     133    for(;Walker!=(*MolWalker)->end();++Walker){
     134      for (MoleculeList::const_iterator MolRunner = molecules->ListOfMolecules.begin();MolRunner != molecules->ListOfMolecules.end(); ++MolRunner) {
     135        molecule::iterator Runner = (*MolRunner)->begin();
     136        for(;Runner!=(*MolRunner)->end();++Runner){
     137          if (((*Walker)->type->Z  == 8) && ((*Runner)->type->Z  == 8)) {
    144138            // check distance
    145             const double distance = Runner->x.DistanceSquared(Walker->x);
     139            const double distance = (*Runner)->x.DistanceSquared((*Walker)->x);
    146140            if ((distance > MYEPSILON) && (distance < HBRIDGEDISTANCE*HBRIDGEDISTANCE)) { // distance >0 means  different atoms
    147141              // on other atom(Runner) we check for bond to interface element and
     
    151145              OtherHydrogens = 0;
    152146              InterfaceFlag = (InterfaceElement == NULL);
    153               for (BondList::const_iterator BondRunner = Runner->ListOfBonds.begin(); BondRunner != Runner->ListOfBonds.end(); BondRunner++) {
    154                 atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Runner);
     147              for (BondList::const_iterator BondRunner = (*Runner)->ListOfBonds.begin(); BondRunner != (*Runner)->ListOfBonds.end(); BondRunner++) {
     148                atom * const OtherAtom = (*BondRunner)->GetOtherAtom(*Runner);
    155149                // if hydrogen, check angle to be greater(!) than 30 degrees
    156150                if (OtherAtom->type->Z == 1) {
    157                   const double angle = CalculateAngle(&OtherAtom->x, &Runner->x, &Walker->x);
     151                  const double angle = CalculateAngle(&OtherAtom->x, &(*Runner)->x, &(*Walker)->x);
    158152                  OtherHydrogenFlag = OtherHydrogenFlag && (angle > M_PI*(30./180.) + MYEPSILON);
    159153                  Otherangle += angle;
     
    176170              if (InterfaceFlag && OtherHydrogenFlag) {
    177171                // on this element (Walker) we check for bond to hydrogen, i.e. part of water molecule
    178                 for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) {
    179                   atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Walker);
     172                for (BondList::const_iterator BondRunner = (*Walker)->ListOfBonds.begin(); BondRunner != (*Walker)->ListOfBonds.end(); BondRunner++) {
     173                  atom * const OtherAtom = (*BondRunner)->GetOtherAtom(*Walker);
    180174                  if (OtherAtom->type->Z == 1) {
    181175                    // check angle
    182                     if (CheckHydrogenBridgeBondAngle(Walker, OtherAtom, Runner)) {
    183                       DoLog(1) && (Log() << Verbose(1) << Walker->getName() << ", " << OtherAtom->getName() << " and " << Runner->getName() << " has a hydrogen bridge bond with distance " << sqrt(distance) << " and angle " << CalculateAngle(&OtherAtom->x, &Walker->x, &Runner->x)*(180./M_PI) << "." << endl);
     176                    if (CheckHydrogenBridgeBondAngle(*Walker, OtherAtom, *Runner)) {
     177                      DoLog(1) && (Log() << Verbose(1) << (*Walker)->getName() << ", " << OtherAtom->getName() << " and " << (*Runner)->getName() << " has a hydrogen bridge bond with distance " << sqrt(distance) << " and angle " << CalculateAngle(&OtherAtom->x, &(*Walker)->x, &(*Runner)->x)*(180./M_PI) << "." << endl);
    184178                      count++;
    185179                      break;
     
    205199int CountBondsOfTwo(MoleculeListClass * const molecules, const element * const first, const element * const second)
    206200{
    207   atom *Walker = NULL;
    208201  int count = 0;
    209202
    210203  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) {
    211     Walker = (*MolWalker)->start;
    212     while (Walker->next != (*MolWalker)->end) {
    213       Walker = Walker->next;
    214       if ((Walker->type == first) || (Walker->type == second)) {  // first element matches
    215         for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) {
    216           atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Walker);
    217           if (((OtherAtom->type == first) || (OtherAtom->type == second)) && (Walker->nr < OtherAtom->nr)) {
     204    molecule::iterator Walker = (*MolWalker)->begin();
     205    for(;Walker!=(*MolWalker)->end();++Walker){
     206      atom * theAtom = *Walker;
     207      if ((theAtom->type == first) || (theAtom->type == second)) {  // first element matches
     208        for (BondList::const_iterator BondRunner = theAtom->ListOfBonds.begin(); BondRunner != theAtom->ListOfBonds.end(); BondRunner++) {
     209          atom * const OtherAtom = (*BondRunner)->GetOtherAtom(theAtom);
     210          if (((OtherAtom->type == first) || (OtherAtom->type == second)) && (theAtom->nr < OtherAtom->nr)) {
    218211            count++;
    219212            DoLog(1) && (Log() << Verbose(1) << first->name << "-" << second->name << " bond found between " << *Walker << " and " << *OtherAtom << "." << endl);
     
    240233  bool MatchFlag[2];
    241234  bool result = false;
    242   atom *Walker = NULL;
    243235  const element * ElementArray[2];
    244236  ElementArray[0] = first;
     
    246238
    247239  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) {
    248     Walker = (*MolWalker)->start;
    249     while (Walker->next != (*MolWalker)->end) {
    250       Walker = Walker->next;
    251       if (Walker->type == second) {  // first element matches
     240    molecule::iterator Walker = (*MolWalker)->begin();
     241    for(;Walker!=(*MolWalker)->end();++Walker){
     242      atom *theAtom = *Walker;
     243      if (theAtom->type == second) {  // first element matches
    252244        for (int i=0;i<2;i++)
    253245          MatchFlag[i] = false;
    254         for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) {
    255           atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Walker);
     246        for (BondList::const_iterator BondRunner = theAtom->ListOfBonds.begin(); BondRunner != theAtom->ListOfBonds.end(); BondRunner++) {
     247          atom * const OtherAtom = (*BondRunner)->GetOtherAtom(theAtom);
    256248          for (int i=0;i<2;i++)
    257249            if ((!MatchFlag[i]) && (OtherAtom->type == ElementArray[i])) {
  • src/analysis_bonds.hpp

    r0c7ed8 r1dc9ec  
    3131
    3232void GetMaxMinMeanBondCount(const molecule * const mol, double &Min, double &Mean, double &Max);
    33 void MinMeanMaxBondDistanceBetweenElements(const molecule *mol, element *type1, element *type2, double &Min, double &Mean, double &Max);
     33void MinMeanMaxBondDistanceBetweenElements(const molecule *mol, const element *type1, const element *type2, double &Min, double &Mean, double &Max);
    3434
    35 int CountHydrogenBridgeBonds(MoleculeListClass * const molecules, element * InterfaceElement);
     35int CountHydrogenBridgeBonds(MoleculeListClass * const molecules, const element * InterfaceElement);
    3636int CountBondsOfTwo(MoleculeListClass * const molecules, const element * const first, const element * const second);
    3737int CountBondsOfThree(MoleculeListClass * const molecules, const element * const first, const element * const second, const element * const third);
  • src/analysis_correlation.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include <iostream>
     
    2325/** Calculates the pair correlation between given elements.
    2426 * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si))
    25  * \param *out output stream for debugging
    26  * \param *molecules list of molecules structure
    27  * \param *type1 first element or NULL (if any element)
    28  * \param *type2 second element or NULL (if any element)
     27 * \param *molecules list of molecules structure
     28 * \param &elements vector of elements to correlate
    2929 * \return Map of doubles with values the pair of the two atoms.
    3030 */
    31 PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const element * const type1, const element * const type2 )
     31PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements)
    3232{
    3333  Info FunctionInfo(__func__);
    3434  PairCorrelationMap *outmap = NULL;
    3535  double distance = 0.;
     36  double *domain = World::getInstance().getDomain();
    3637
    3738  if (molecules->ListOfMolecules.empty()) {
     
    3940    return outmap;
    4041  }
     42  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     43    (*MolWalker)->doCountAtoms();
     44
     45  // create all possible pairs of elements
     46  set <pair<element *, element *> > PairsOfElements;
     47  if (elements.size() >= 2) {
     48    for (vector<element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1)
     49      for (vector<element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2)
     50        if (type1 != type2) {
     51          PairsOfElements.insert( pair<element *, element*>(*type1,*type2) );
     52          DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << (*type1)->symbol << " and " << (*type2)->symbol << "." << endl);
     53        }
     54  } else if (elements.size() == 1) { // one to all are valid
     55    element *elemental = *elements.begin();
     56    PairsOfElements.insert( pair<element *, element*>(elemental,(element *)NULL) );
     57    PairsOfElements.insert( pair<element *, element*>((element *)NULL,elemental) );
     58  } else { // all elements valid
     59    PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) );
     60  }
     61
    4162  outmap = new PairCorrelationMap;
    42   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     63  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++){
    4364    if ((*MolWalker)->ActiveFlag) {
    4465      DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    45       atom *Walker = (*MolWalker)->start;
    46       while (Walker->next != (*MolWalker)->end) {
    47         Walker = Walker->next;
    48         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);
    49         if ((type1 == NULL) || (Walker->type == type1)) {
    50           for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++)
    51             if ((*MolOtherWalker)->ActiveFlag) {
    52               DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
    53               atom *OtherWalker = (*MolOtherWalker)->start;
    54               while (OtherWalker->next != (*MolOtherWalker)->end) { // only go up to Walker
    55                 OtherWalker = OtherWalker->next;
    56                 DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl);
    57                 if (Walker->nr < OtherWalker->nr)
    58                   if ((type2 == NULL) || (OtherWalker->type == type2)) {
    59                     distance = Walker->node->PeriodicDistance(*OtherWalker->node, World::getInstance().getDomain());
    60                     //Log() << Verbose(1) <<"Inserting " << *Walker << " and " << *OtherWalker << endl;
    61                     outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> (Walker, OtherWalker) ) );
     66      eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
     67      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     68        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
     69        for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++){
     70          if ((*MolOtherWalker)->ActiveFlag) {
     71            DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
     72            for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
     73              DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
     74              if ((*iter)->getId() < (*runner)->getId()){
     75                for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
     76                  if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) {
     77                    distance = (*iter)->node->PeriodicDistance(*(*runner)->node,  domain);
     78                    //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
     79                    outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
    6280                  }
    6381              }
     82            }
    6483          }
    6584        }
    6685      }
    6786    }
    68 
     87  }
    6988  return outmap;
    7089};
     
    7291/** Calculates the pair correlation between given elements.
    7392 * Note given element order is unimportant (i.e. g(Si, O) === g(O, Si))
    74  * \param *out output stream for debugging
    75  * \param *molecules list of molecules structure
    76  * \param *type1 first element or NULL (if any element)
    77  * \param *type2 second element or NULL (if any element)
     93 * \param *molecules list of molecules structure
     94 * \param &elements vector of elements to correlate
    7895 * \param ranges[NDIM] interval boundaries for the periodic images to scan also
    7996 * \return Map of doubles with values the pair of the two atoms.
    8097 */
    81 PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const element * const type1, const element * const type2, const int ranges[NDIM] )
     98PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const int ranges[NDIM] )
    8299{
    83100  Info FunctionInfo(__func__);
     
    95112    return outmap;
    96113  }
     114  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     115    (*MolWalker)->doCountAtoms();
     116
     117  // create all possible pairs of elements
     118  set <pair<element *, element *> > PairsOfElements;
     119  if (elements.size() >= 2) {
     120    for (vector<element *>::const_iterator type1 = elements.begin(); type1 != elements.end(); ++type1)
     121      for (vector<element *>::const_iterator type2 = elements.begin(); type2 != elements.end(); ++type2)
     122        if (type1 != type2) {
     123          PairsOfElements.insert( pair<element *, element*>(*type1,*type2) );
     124          DoLog(1) && (Log() << Verbose(1) << "Creating element pair " << (*type1)->symbol << " and " << (*type2)->symbol << "." << endl);
     125        }
     126  } else if (elements.size() == 1) { // one to all are valid
     127    element *elemental = *elements.begin();
     128    PairsOfElements.insert( pair<element *, element*>(elemental,(element *)NULL) );
     129    PairsOfElements.insert( pair<element *, element*>((element *)NULL,elemental) );
     130  } else { // all elements valid
     131    PairsOfElements.insert( pair<element *, element*>((element *)NULL, (element *)NULL) );
     132  }
     133
    97134  outmap = new PairCorrelationMap;
    98   for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     135  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++){
    99136    if ((*MolWalker)->ActiveFlag) {
    100137      double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain());
    101138      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    102139      DoeLog(2) && (eLog()<< Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    103       atom *Walker = (*MolWalker)->start;
    104       while (Walker->next != (*MolWalker)->end) {
    105         Walker = Walker->next;
    106         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);
    107         if ((type1 == NULL) || (Walker->type == type1)) {
    108           periodicX = *(Walker->node);
    109           periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    110           // go through every range in xyz and get distance
    111           for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
    112             for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
    113               for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
    114                 checkX = Vector(n[0], n[1], n[2]) + periodicX;
    115                 checkX.MatrixMultiplication(FullMatrix);
    116                 for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++)
    117                   if ((*MolOtherWalker)->ActiveFlag) {
    118                     DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
    119                     atom *OtherWalker = (*MolOtherWalker)->start;
    120                     while (OtherWalker->next != (*MolOtherWalker)->end) { // only go up to Walker
    121                       OtherWalker = OtherWalker->next;
    122                       DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl);
    123                       if (Walker->nr < OtherWalker->nr)
    124                         if ((type2 == NULL) || (OtherWalker->type == type2)) {
    125                           periodicOtherX = *(OtherWalker->node);
     140      eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
     141      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     142        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
     143        periodicX = *(*iter)->node;
     144        periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
     145        // go through every range in xyz and get distance
     146        for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
     147          for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
     148            for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
     149              checkX = Vector(n[0], n[1], n[2]) + periodicX;
     150              checkX.MatrixMultiplication(FullMatrix);
     151              for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++){
     152                if ((*MolOtherWalker)->ActiveFlag) {
     153                  DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
     154                  for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
     155                    DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << **runner << "." << endl);
     156                    if ((*iter)->getId() < (*runner)->getId()){
     157                      for (set <pair<element *, element *> >::iterator PairRunner = PairsOfElements.begin(); PairRunner != PairsOfElements.end(); ++PairRunner)
     158                        if ((PairRunner->first == (**iter).type) && (PairRunner->second == (**runner).type)) {
     159                          periodicOtherX = *(*runner)->node;
    126160                          periodicOtherX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    127161                          // go through every range in xyz and get distance
     
    132166                                checkOtherX.MatrixMultiplication(FullMatrix);
    133167                                distance = checkX.distance(checkOtherX);
    134                                 //Log() << Verbose(1) <<"Inserting " << *Walker << " and " << *OtherWalker << endl;
    135                                 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> (Walker, OtherWalker) ) );
     168                                //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
     169                                outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
    136170                              }
    137171                        }
     172                    }
    138173                  }
     174                }
    139175              }
    140176            }
    141         }
    142       }
    143       Free(&FullMatrix);
    144       Free(&FullInverseMatrix);
    145     }
     177      }
     178      delete[](FullMatrix);
     179      delete[](FullInverseMatrix);
     180    }
     181  }
    146182
    147183  return outmap;
     
    149185
    150186/** Calculates the distance (pair) correlation between a given element and a point.
    151  * \param *out output stream for debugging
    152  * \param *molecules list of molecules structure
    153  * \param *type element or NULL (if any element)
     187 * \param *molecules list of molecules structure
     188 * \param &elements vector of elements to correlate with point
    154189 * \param *point vector to the correlation point
    155190 * \return Map of dobules with values as pairs of atom and the vector
    156191 */
    157 CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point )
     192CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point )
    158193{
    159194  Info FunctionInfo(__func__);
    160195  CorrelationToPointMap *outmap = NULL;
    161196  double distance = 0.;
     197  double *cell_size = World::getInstance().getDomain();
    162198
    163199  if (molecules->ListOfMolecules.empty()) {
     
    165201    return outmap;
    166202  }
     203  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     204    (*MolWalker)->doCountAtoms();
    167205  outmap = new CorrelationToPointMap;
    168206  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    169207    if ((*MolWalker)->ActiveFlag) {
    170208      DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    171       atom *Walker = (*MolWalker)->start;
    172       while (Walker->next != (*MolWalker)->end) {
    173         Walker = Walker->next;
    174         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);
    175         if ((type == NULL) || (Walker->type == type)) {
    176           distance = Walker->node->PeriodicDistance(*point, World::getInstance().getDomain());
    177           DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
    178           outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) );
    179         }
     209      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     210        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
     211        for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     212          if ((*type == NULL) || ((*iter)->type == *type)) {
     213            distance = (*iter)->node->PeriodicDistance(*point, cell_size);
     214            DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
     215            outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) );
     216          }
    180217      }
    181218    }
     
    185222
    186223/** Calculates the distance (pair) correlation between a given element, all its periodic images and a point.
    187  * \param *out output stream for debugging
    188  * \param *molecules list of molecules structure
    189  * \param *type element or NULL (if any element)
     224 * \param *molecules list of molecules structure
     225 * \param &elements vector of elements to correlate to point
    190226 * \param *point vector to the correlation point
    191227 * \param ranges[NDIM] interval boundaries for the periodic images to scan also
    192228 * \return Map of dobules with values as pairs of atom and the vector
    193229 */
    194 CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point, const int ranges[NDIM] )
     230CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] )
    195231{
    196232  Info FunctionInfo(__func__);
     
    205241    return outmap;
    206242  }
     243  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     244    (*MolWalker)->doCountAtoms();
    207245  outmap = new CorrelationToPointMap;
    208246  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     
    211249      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    212250      DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    213       atom *Walker = (*MolWalker)->start;
    214       while (Walker->next != (*MolWalker)->end) {
    215         Walker = Walker->next;
    216         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);
    217         if ((type == NULL) || (Walker->type == type)) {
    218           periodicX = *(Walker->node);
    219           periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    220           // go through every range in xyz and get distance
    221           for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
    222             for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
    223               for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
    224                 checkX = Vector(n[0], n[1], n[2]) + periodicX;
    225                 checkX.MatrixMultiplication(FullMatrix);
    226                 distance = checkX.distance(*point);
    227                 DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
    228                 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) );
    229               }
    230         }
    231       }
    232       Free(&FullMatrix);
    233       Free(&FullInverseMatrix);
     251      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     252        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
     253        for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     254          if ((*type == NULL) || ((*iter)->type == *type)) {
     255            periodicX = *(*iter)->node;
     256            periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
     257            // go through every range in xyz and get distance
     258            for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
     259              for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
     260                for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
     261                  checkX = Vector(n[0], n[1], n[2]) + periodicX;
     262                  checkX.MatrixMultiplication(FullMatrix);
     263                  distance = checkX.distance(*point);
     264                  DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
     265                  outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (*iter, point) ) );
     266                }
     267          }
     268      }
     269      delete[](FullMatrix);
     270      delete[](FullInverseMatrix);
    234271    }
    235272
     
    238275
    239276/** Calculates the distance (pair) correlation between a given element and a surface.
    240  * \param *out output stream for debugging
    241  * \param *molecules list of molecules structure
    242  * \param *type element or NULL (if any element)
     277 * \param *molecules list of molecules structure
     278 * \param &elements vector of elements to correlate to surface
    243279 * \param *Surface pointer to Tesselation class surface
    244280 * \param *LC LinkedCell structure to quickly find neighbouring atoms
    245281 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest
    246282 */
    247 CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC )
     283CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC )
    248284{
    249285  Info FunctionInfo(__func__);
     
    257293    return outmap;
    258294  }
     295  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     296    (*MolWalker)->doCountAtoms();
    259297  outmap = new CorrelationToSurfaceMap;
    260298  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    261299    if ((*MolWalker)->ActiveFlag) {
    262300      DoLog(1) && (Log() << Verbose(1) << "Current molecule is " << (*MolWalker)->name << "." << endl);
    263       atom *Walker = (*MolWalker)->start;
    264       while (Walker->next != (*MolWalker)->end) {
    265         Walker = Walker->next;
    266         //Log() << Verbose(1) << "Current atom is " << *Walker << "." << endl;
    267         if ((type == NULL) || (Walker->type == type)) {
    268           TriangleIntersectionList Intersections(Walker->node,Surface,LC);
    269           distance = Intersections.GetSmallestDistance();
    270           triangle = Intersections.GetClosestTriangle();
    271           outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> (Walker, triangle) ) );
    272         }
    273       }
    274     } else
     301      if ((*MolWalker)->empty())
     302        DoLog(1) && (1) && (Log() << Verbose(1) << "\t is empty." << endl);
     303      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     304        DoLog(1) && (Log() << Verbose(1) << "\tCurrent atom is " << *(*iter) << "." << endl);
     305        for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     306          if ((*type == NULL) || ((*iter)->type == *type)) {
     307            TriangleIntersectionList Intersections((*iter)->node,Surface,LC);
     308            distance = Intersections.GetSmallestDistance();
     309            triangle = Intersections.GetClosestTriangle();
     310            outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> ((*iter), triangle) ) );
     311          }
     312      }
     313    } else {
    275314      DoLog(1) && (Log() << Verbose(1) << "molecule " << (*MolWalker)->name << " is not active." << endl);
     315    }
    276316
    277317  return outmap;
     
    283323 * axis an integer from [ -ranges[i], ranges[i] ] onto it and multiply with the domain matrix to bring it back into
    284324 * the real space. Then, we Tesselation::FindClosestTriangleToPoint() and DistanceToTrianglePlane().
    285  * \param *out output stream for debugging
    286  * \param *molecules list of molecules structure
    287  * \param *type element or NULL (if any element)
     325 * \param *molecules list of molecules structure
     326 * \param &elements vector of elements to correlate to surface
    288327 * \param *Surface pointer to Tesselation class surface
    289328 * \param *LC LinkedCell structure to quickly find neighbouring atoms
     
    291330 * \return Map of doubles with values as pairs of atom and the BoundaryTriangleSet that's closest
    292331 */
    293 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )
     332CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )
    294333{
    295334  Info FunctionInfo(__func__);
     
    306345    return outmap;
    307346  }
     347  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
     348    (*MolWalker)->doCountAtoms();
    308349  outmap = new CorrelationToSurfaceMap;
    309350  double ShortestDistance = 0.;
     
    314355      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    315356      DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
    316       atom *Walker = (*MolWalker)->start;
    317       while (Walker->next != (*MolWalker)->end) {
    318         Walker = Walker->next;
    319         DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);
    320         if ((type == NULL) || (Walker->type == type)) {
    321           periodicX = *(Walker->node);
    322           periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    323           // go through every range in xyz and get distance
    324           ShortestDistance = -1.;
    325           for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
    326             for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
    327               for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
    328                 checkX = Vector(n[0], n[1], n[2]) + periodicX;
    329                 checkX.MatrixMultiplication(FullMatrix);
    330                 TriangleIntersectionList Intersections(&checkX,Surface,LC);
    331                 distance = Intersections.GetSmallestDistance();
    332                 triangle = Intersections.GetClosestTriangle();
    333                 if ((ShortestDistance == -1.) || (distance < ShortestDistance)) {
    334                   ShortestDistance = distance;
    335                   ShortestTriangle = triangle;
     357      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     358        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << **iter << "." << endl);
     359        for (vector<element *>::const_iterator type = elements.begin(); type != elements.end(); ++type)
     360          if ((*type == NULL) || ((*iter)->type == *type)) {
     361            periodicX = *(*iter)->node;
     362            periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
     363            // go through every range in xyz and get distance
     364            ShortestDistance = -1.;
     365            for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
     366              for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
     367                for (n[2]=-ranges[2]; n[2] <= ranges[2]; n[2]++) {
     368                  checkX = Vector(n[0], n[1], n[2]) + periodicX;
     369                  checkX.MatrixMultiplication(FullMatrix);
     370                  TriangleIntersectionList Intersections(&checkX,Surface,LC);
     371                  distance = Intersections.GetSmallestDistance();
     372                  triangle = Intersections.GetClosestTriangle();
     373                  if ((ShortestDistance == -1.) || (distance < ShortestDistance)) {
     374                    ShortestDistance = distance;
     375                    ShortestTriangle = triangle;
     376                  }
    336377                }
    337               }
    338           // insert
    339           outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (Walker, ShortestTriangle) ) );
    340           //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl;
    341         }
    342       }
    343       Free(&FullMatrix);
    344       Free(&FullInverseMatrix);
     378            // insert
     379            outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (*iter, ShortestTriangle) ) );
     380            //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl;
     381          }
     382      }
     383      delete[](FullMatrix);
     384      delete[](FullInverseMatrix);
    345385    }
    346386
  • src/analysis_correlation.hpp

    r0c7ed8 r1dc9ec  
    4545/********************************************** declarations *******************************/
    4646
    47 PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const element * const type1, const element * const  type2 );
    48 CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point );
    49 CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC );
    50 PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const element * const type1, const element * const  type2, const int ranges[NDIM] );
    51 CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point, const int ranges[NDIM] );
    52 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] );
     47PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements);
     48CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point );
     49CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC );
     50PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const int ranges[NDIM] );
     51CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Vector *point, const int ranges[NDIM] );
     52CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const std::vector<element *> &elements, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] );
    5353int GetBin ( const double value, const double BinWidth, const double BinStart );
    5454void OutputCorrelation( ofstream * const file, const BinPairMap * const map );
  • src/analyzer.cpp

    r0c7ed8 r1dc9ec  
    77
    88//============================ INCLUDES ===========================
     9
     10#include "Helpers/MemDebug.hpp"
    911
    1012#include <cstring>
     
    7577    return 1;
    7678  } else {
    77     dir = Malloc<char>(strlen(argv[2]) + 2, "main: *dir");
     79    dir = new char[strlen(argv[2]) + 2];
    7880    strcpy(dir, "/");
    7981    strcat(dir, argv[2]);
     
    8284  if (argc > 4) {
    8385    DoLog(0) && (Log() << Verbose(0) << "Loading periodentafel." << endl);
    84     periode = Malloc<periodentafel>(1, "main - periode");
     86    periode = new periodentafel;
    8587    periode->LoadPeriodentafel(argv[4]);
    8688  }
     
    558560  // ++++++++++++++++ exit ++++++++++++++++++++++++++++++++++
    559561  delete(periode);
    560   Free(&dir);
     562  delete[](dir);
    561563  DoLog(0) && (Log() << Verbose(0) << "done." << endl);
    562564  return 0;
  • src/atom.cpp

    r0c7ed8 r1dc9ec  
    44 *
    55 */
     6
     7#include "Helpers/MemDebug.hpp"
    68
    79#include "atom.hpp"
     
    1416#include "vector.hpp"
    1517#include "World.hpp"
     18#include "molecule.hpp"
    1619
    1720/************************************* Functions for class atom *************************************/
     
    2124 */
    2225atom::atom() :
    23   previous(NULL), next(NULL), father(this), sort(&nr)
     26  father(this), sort(&nr), mol(0)
    2427{
    2528  node = &x;  // TesselPoint::x can only be referenced from here
     
    2932 */
    3033atom::atom(atom *pointer) :
    31     ParticleInfo(pointer),
    32     previous(NULL), next(NULL), father(pointer), sort(&nr)
     34    ParticleInfo(pointer),father(pointer), sort(&nr)
    3335{
    3436  type = pointer->type;  // copy element of atom
     
    3739  FixedIon = pointer->FixedIon;
    3840  node = &x;
     41  mol = 0;
    3942};
    4043
    4144atom *atom::clone(){
    4245  atom *res = new atom(this);
    43   res->previous=0;
    44   res->next=0;
    4546  res->father = this;
    4647  res->sort = &res->nr;
     
    5051  res->FixedIon = FixedIon;
    5152  res->node = &x;
     53  res->mol = 0;
    5254  World::getInstance().registerAtom(res);
    5355  return res;
     
    5961atom::~atom()
    6062{
    61   unlink(this);
     63  removeFromMolecule();
     64  for(BondList::iterator iter=ListOfBonds.begin(); iter!=ListOfBonds.end();){
     65    // deleting the bond will invalidate the iterator !!!
     66    bond *bond =*(iter++);
     67    delete(bond);
     68  }
    6269};
    6370
     
    272279{
    273280  if (ComponentNr != NULL)
    274     Free(&ComponentNr);
    275   ComponentNr = Malloc<int>(ListOfBonds.size()+1, "atom::InitComponentNumbers: *ComponentNr");
     281    delete[](ComponentNr);
     282  ComponentNr = new int[ListOfBonds.size()+1];
    276283  for (int i=ListOfBonds.size()+1;i--;)
    277284    ComponentNr[i] = -1;
     
    312319}
    313320
     321void atom::setMolecule(molecule *_mol){
     322  // take this atom from the old molecule
     323  removeFromMolecule();
     324  mol = _mol;
     325  if(!mol->containsAtom(this)){
     326    mol->AddAtom(this);
     327  }
     328}
     329
     330void atom::removeFromMolecule(){
     331  if(mol){
     332    if(mol->containsAtom(this)){
     333      mol->erase(this);
     334    }
     335    mol=0;
     336  }
     337}
     338
     339
    314340atom* NewAtom(atomId_t _id){
    315341  atom * res =new atom();
  • src/atom.hpp

    r0c7ed8 r1dc9ec  
    3434class Vector;
    3535class World;
     36class molecule;
    3637
    3738/********************************************** declarations *******************************/
     
    4445  friend void  DeleteAtom(atom*);
    4546  public:
    46     atom *previous; //!< previous atom in molecule list
    47     atom *next;     //!< next atom in molecule list
    4847    atom *father;   //!< In many-body bond order fragmentations points to originating atom
    4948    int *sort;      //!< sort criteria
     
    8988   virtual void setId(atomId_t);
    9089
     90   void setMolecule(molecule*);
     91   void removeFromMolecule();
     92
    9193  protected:
     94
    9295    /**
    9396     * Protected constructor to ensure construction of atoms through the world.
     
    108111    virtual ~atom();
    109112  private:
     113    molecule *mol; // !< the molecule this atom belongs to
    110114    World* world;
    111115    atomId_t id;
  • src/atom_atominfo.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "periodentafel.hpp"
  • src/atom_bondedparticle.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "atom.hpp"
     
    7476      *BondFile << nr << "\t" << (*Runner)->GetOtherAtom(this)->nr << "\n";
    7577};
     78
     79/**
     80 * Adds a bond between this bonded particle and another. Does nothing if this
     81 * bond already exists.
     82 *
     83 * \param bonding partner
     84 */
     85void BondedParticle::addBond(BondedParticle* Partner) {
     86  if (IsBondedTo(Partner)) {
     87    return;
     88  }
     89
     90  bond* newBond = new bond((atom*) this, (atom*) Partner, 1, 0);
     91  RegisterBond(newBond);
     92  Partner->RegisterBond(newBond);
     93}
    7694
    7795/** Puts a given bond into atom::ListOfBonds.
  • src/atom_bondedparticle.hpp

    r0c7ed8 r1dc9ec  
    3737  virtual ~BondedParticle();
    3838
     39  void addBond(BondedParticle* Partner);
    3940  bool RegisterBond(bond *Binder);
    4041  bool UnregisterBond(bond *Binder);
  • src/atom_bondedparticleinfo.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "atom_bondedparticleinfo.hpp"
  • src/atom_graphnode.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "atom_graphnode.hpp"
  • src/atom_graphnodeinfo.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "atom_graphnodeinfo.hpp"
     
    1719GraphNodeInfo::~GraphNodeInfo()
    1820{
    19   Free<int>(&ComponentNr, "atom::~atom: *ComponentNr");
     21  delete[](ComponentNr);
    2022};
  • src/atom_particleinfo.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "atom_particleinfo.hpp"
  • src/atom_trajectoryparticle.cpp

    r0c7ed8 r1dc9ec  
    66 */
    77
     8#include "Helpers/MemDebug.hpp"
     9
    810#include "atom.hpp"
    911#include "atom_trajectoryparticle.hpp"
    1012#include "config.hpp"
    1113#include "element.hpp"
     14#include "info.hpp"
    1215#include "log.hpp"
    1316#include "parser.hpp"
     
    7174void TrajectoryParticle::ResizeTrajectory(int MaxSteps)
    7275{
     76  Info FunctionInfo(__func__);
    7377  if (Trajectory.R.size() <= (unsigned int)(MaxSteps)) {
    74     //Log() << Verbose(0) << "Increasing size for trajectory array of " << keyword << " to " << (MaxSteps+1) << "." << endl;
     78    DoLog(0) && (Log() << Verbose(0) << "Increasing size for trajectory array of " << nr << " from " << Trajectory.R.size() << " to " << (MaxSteps+1) << "." << endl);
    7579    Trajectory.R.resize(MaxSteps+1);
    7680    Trajectory.U.resize(MaxSteps+1);
  • src/atom_trajectoryparticleinfo.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "atom_trajectoryparticleinfo.hpp"
  • src/bond.cpp

    r0c7ed8 r1dc9ec  
    44 *
    55 */
     6
     7#include "Helpers/MemDebug.hpp"
    68
    79#include "atom.hpp"
     
    1517/** Empty Constructor for class bond.
    1618 */
    17 bond::bond() : leftatom(NULL), rightatom(NULL), previous(NULL), next(NULL), HydrogenBond(0), BondDegree(0), nr(-1), Cyclic(false), Type(Undetermined), Used(white)
     19bond::bond()
     20  : leftatom(NULL), rightatom(NULL), previous(NULL), next(NULL), HydrogenBond(0),
     21    BondDegree(0), nr(-1), Cyclic(false), Type(Undetermined), Used(white)
    1822{
    1923};
     
    2529 * \param number increasing index
    2630 */
    27 bond::bond(atom *left, atom *right, const int degree, const int number) : leftatom(left), rightatom(right), previous(NULL), next(NULL), HydrogenBond(0), BondDegree(degree), nr(number), Cyclic(false), Type(Undetermined), Used(white)
     31bond::bond(atom *left, atom *right, const int degree, const int number)
     32  : leftatom(left), rightatom(right), previous(NULL), next(NULL), HydrogenBond(0),
     33    BondDegree(degree), nr(number), Cyclic(false), Type(Undetermined), Used(white)
    2834{
    2935  if ((left != NULL) && (right != NULL)) {
  • src/bondgraph.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include <iostream>
     
    8890{
    8991  Info FunctionInfo(__func__);
    90 bool status = true;
     92  bool status = true;
    9193
    92   if (mol->start->next == mol->end) // only construct if molecule is not empty
     94  if (mol->empty()) // only construct if molecule is not empty
    9395    return false;
    9496
     
    124126  max_distance = 0.;
    125127
    126   atom *Runner = mol->start;
    127   while (Runner->next != mol->end) {
    128     Runner = Runner->next;
    129     if (Runner->type->CovalentRadius > max_distance)
    130       max_distance = Runner->type->CovalentRadius;
     128  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     129    if ((*iter)->type->CovalentRadius > max_distance)
     130      max_distance = (*iter)->type->CovalentRadius;
    131131  }
    132132  max_distance *= 2.;
  • src/bondgraph.hpp

    r0c7ed8 r1dc9ec  
    2727
    2828class molecule;
    29 class periodentafel;
     29class BondedParticle;
    3030class MatrixContainer;
    3131
  • src/boundary.cpp

    r0c7ed8 r1dc9ec  
    33 * Implementations and super-function for envelopes
    44 */
     5
     6#include "Helpers/MemDebug.hpp"
    57
    68#include "World.hpp"
     
    139141{
    140142        Info FunctionInfo(__func__);
    141   atom *Walker = NULL;
    142143  PointMap PointsOnBoundary;
    143144  LineMap LinesOnBoundary;
     
    165166
    166167    // 3b. construct set of all points, transformed into cylindrical system and with left and right neighbours
    167     Walker = mol->start;
    168     while (Walker->next != mol->end) {
    169       Walker = Walker->next;
    170       ProjectedVector = Walker->x - (*MolCenter);
     168    for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     169      ProjectedVector = (*iter)->x - (*MolCenter);
    171170      ProjectedVector.ProjectOntoPlane(AxisVector);
    172171
     
    182181        angle = 2. * M_PI - angle;
    183182      }
    184       DoLog(1) && (Log() << Verbose(1) << "Inserting " << *Walker << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl);
    185       BoundaryTestPair = BoundaryPoints[axis].insert(BoundariesPair(angle, DistancePair (radius, Walker)));
     183    DoLog(1) && (Log() << Verbose(1) << "Inserting " << **iter << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl);
     184      BoundaryTestPair = BoundaryPoints[axis].insert(BoundariesPair(angle, DistancePair (radius, (*iter))));
    186185      if (!BoundaryTestPair.second) { // same point exists, check first r, then distance of original vectors to center of gravity
    187186        DoLog(2) && (Log() << Verbose(2) << "Encountered two vectors whose projection onto axis " << axis << " is equal: " << endl);
    188187        DoLog(2) && (Log() << Verbose(2) << "Present vector: " << *BoundaryTestPair.first->second.second << endl);
    189         DoLog(2) && (Log() << Verbose(2) << "New vector: " << *Walker << endl);
     188        DoLog(2) && (Log() << Verbose(2) << "New vector: " << **iter << endl);
    190189        const double ProjectedVectorNorm = ProjectedVector.NormSquared();
    191190        if ((ProjectedVectorNorm - BoundaryTestPair.first->second.first) > MYEPSILON) {
    192191          BoundaryTestPair.first->second.first = ProjectedVectorNorm;
    193           BoundaryTestPair.first->second.second = Walker;
     192          BoundaryTestPair.first->second.second = (*iter);
    194193          DoLog(2) && (Log() << Verbose(2) << "Keeping new vector due to larger projected distance " << ProjectedVectorNorm << "." << endl);
    195194        } else if (fabs(ProjectedVectorNorm - BoundaryTestPair.first->second.first) < MYEPSILON) {
    196           helper = Walker->x - (*MolCenter);
     195          helper = (*iter)->x;
     196          helper -= *MolCenter;
    197197          const double oldhelperNorm = helper.NormSquared();
    198198          helper = BoundaryTestPair.first->second.second->x - (*MolCenter);
    199199          if (helper.NormSquared() < oldhelperNorm) {
    200             BoundaryTestPair.first->second.second = Walker;
     200            BoundaryTestPair.first->second.second = (*iter);
    201201            DoLog(2) && (Log() << Verbose(2) << "Keeping new vector due to larger distance to molecule center " << helper.NormSquared() << "." << endl);
    202202          } else {
     
    226226    do { // do as long as we still throw one out per round
    227227      flag = false;
    228       Boundaries::iterator left = BoundaryPoints[axis].end();
    229       Boundaries::iterator right = BoundaryPoints[axis].end();
    230       for (Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) {
     228      Boundaries::iterator left = BoundaryPoints[axis].begin();
     229      Boundaries::iterator right = BoundaryPoints[axis].begin();
     230      Boundaries::iterator runner = BoundaryPoints[axis].begin();
     231      bool LoopOnceDone = false;
     232      while (!LoopOnceDone) {
     233        runner = right;
     234        right++;
    231235        // set neighbours correctly
    232236        if (runner == BoundaryPoints[axis].begin()) {
     
    236240        }
    237241        left--;
    238         right = runner;
    239         right++;
    240242        if (right == BoundaryPoints[axis].end()) {
    241243          right = BoundaryPoints[axis].begin();
     244          LoopOnceDone = true;
    242245        }
    243246        // check distance
     
    279282            DoLog(1) && (Log() << Verbose(1) << "Throwing out " << *runner->second.second << "." << endl);
    280283            BoundaryPoints[axis].erase(runner);
     284            runner = right;
    281285            flag = true;
    282286          }
     
    359363
    360364  // 4. Store triangles in tecplot file
    361   if (filename != NULL) {
    362     if (DoTecplotOutput) {
    363       string OutputName(filename);
    364       OutputName.append("_intermed");
    365       OutputName.append(TecplotSuffix);
    366       ofstream *tecplot = new ofstream(OutputName.c_str());
    367       WriteTecplotFile(tecplot, TesselStruct, mol, 0);
    368       tecplot->close();
    369       delete(tecplot);
    370     }
    371     if (DoRaster3DOutput) {
    372       string OutputName(filename);
    373       OutputName.append("_intermed");
    374       OutputName.append(Raster3DSuffix);
    375       ofstream *rasterplot = new ofstream(OutputName.c_str());
    376       WriteRaster3dFile(rasterplot, TesselStruct, mol);
    377       rasterplot->close();
    378       delete(rasterplot);
    379     }
    380   }
     365  StoreTrianglesinFile(mol, TesselStruct, filename, "_intermed");
    381366
    382367  // 3d. check all baselines whether the peaks of the two adjacent triangles with respect to center of baseline are convex, if not, make the baseline between the two peaks and baseline endpoints become the new peaks
     
    397382          TesselStruct->FlipBaseline(line);
    398383          DoLog(1) && (Log() << Verbose(1) << "INFO: Correction of concave baselines worked." << endl);
     384          LineRunner = TesselStruct->LinesOnBoundary.begin(); // LineRunner may have been erase if line was deleted from LinesOnBoundary
    399385        }
    400386      }
     
    409395
    410396  // 4. Store triangles in tecplot file
    411   if (filename != NULL) {
    412     if (DoTecplotOutput) {
    413       string OutputName(filename);
    414       OutputName.append(TecplotSuffix);
    415       ofstream *tecplot = new ofstream(OutputName.c_str());
    416       WriteTecplotFile(tecplot, TesselStruct, mol, 0);
    417       tecplot->close();
    418       delete(tecplot);
    419     }
    420     if (DoRaster3DOutput) {
    421       string OutputName(filename);
    422       OutputName.append(Raster3DSuffix);
    423       ofstream *rasterplot = new ofstream(OutputName.c_str());
    424       WriteRaster3dFile(rasterplot, TesselStruct, mol);
    425       rasterplot->close();
    426       delete(rasterplot);
    427     }
    428   }
    429 
     397  StoreTrianglesinFile(mol, TesselStruct, filename, "");
    430398
    431399  // free reference lists
     
    678646/** Creates multiples of the by \a *mol given cluster and suspends them in water with a given final density.
    679647 * We get cluster volume by VolumeOfConvexEnvelope() and its diameters by GetDiametersOfCluster()
     648 * TODO: Here, we need a VolumeOfGeneralEnvelope (i.e. non-convex one)
    680649 * \param *out output stream for debugging
    681650 * \param *configuration needed for path to store convex envelope file
     
    695664  int repetition[NDIM] = { 1, 1, 1 };
    696665  int TotalNoClusters = 1;
    697   atom *Walker = NULL;
    698666  double totalmass = 0.;
    699667  double clustervolume = 0.;
     
    706674  GreatestDiameter = GetDiametersOfCluster(BoundaryPoints, mol, TesselStruct, IsAngstroem);
    707675  BoundaryPoints = GetBoundaryPoints(mol, TesselStruct);
    708   LinkedCell LCList(mol, 10.);
    709   FindConvexBorder(mol, TesselStruct, &LCList, NULL);
     676  LinkedCell *LCList = new LinkedCell(mol, 10.);
     677  FindConvexBorder(mol, TesselStruct, (const LinkedCell *&)LCList, NULL);
     678  delete (LCList);
     679
    710680
    711681  // some preparations beforehand
     
    719689
    720690  // sum up the atomic masses
    721   Walker = mol->start;
    722   while (Walker->next != mol->end) {
    723       Walker = Walker->next;
    724       totalmass += Walker->type->mass;
     691  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     692      totalmass += (*iter)->type->mass;
    725693  }
    726694  DoLog(0) && (Log() << Verbose(0) << "RESULT: The summed mass is " << setprecision(10) << totalmass << " atomicmassunit." << endl);
     
    804772  Vector Inserter;
    805773  double FillIt = false;
    806   atom *Walker = NULL;
    807774  bond *Binder = NULL;
    808775  double phi[NDIM];
     
    811778
    812779  for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++)
    813     if ((*ListRunner)->AtomCount > 0) {
     780    if ((*ListRunner)->getAtomCount() > 0) {
    814781      DoLog(1) && (Log() << Verbose(1) << "Pre-creating linked cell lists for molecule " << *ListRunner << "." << endl);
    815782      LCList[(*ListRunner)] = new LinkedCell((*ListRunner), 10.); // get linked cell list
     
    822789  filler->CenterEdge(&Inserter);
    823790  filler->Center.Zero();
     791  const int FillerCount = filler->getAtomCount();
    824792  DoLog(2) && (Log() << Verbose(2) << "INFO: Filler molecule has the following bonds:" << endl);
    825   Binder = filler->first;
    826   while(Binder->next != filler->last) {
    827     Binder = Binder->next;
    828     DoLog(2) && (Log() << Verbose(2) << "  " << *Binder << endl);
    829   }
    830 
    831   filler->CountAtoms();
    832   atom * CopyAtoms[filler->AtomCount];
     793  for(molecule::iterator AtomRunner = filler->begin(); AtomRunner != filler->end(); ++AtomRunner)
     794    for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     795      if ((*BondRunner)->leftatom == *AtomRunner)
     796        DoLog(2) && (Log() << Verbose(2) << "  " << *(*BondRunner) << endl);
     797
     798  atom * CopyAtoms[FillerCount];
    833799
    834800  // calculate filler grid in [0,1]^3
     
    855821
    856822        // go through all atoms
    857         for (int i=0;i<filler->AtomCount;i++)
     823        for (int i=0;i<FillerCount;i++)
    858824          CopyAtoms[i] = NULL;
    859         Walker = filler->start;
    860         while (Walker->next != filler->end) {
    861           Walker = Walker->next;
     825        for(molecule::const_iterator iter = filler->begin(); iter !=filler->end();++iter){
    862826
    863827          // create atomic random translation vector ...
     
    883847
    884848          // ... and put at new position
    885           Inserter = Walker->x;
     849          Inserter = (*iter)->x;
    886850          if (DoRandomRotation)
    887851            Inserter.MatrixMultiplication(Rotations);
     
    907871            DoLog(1) && (Log() << Verbose(1) << "INFO: Position at " << Inserter << " is outer point." << endl);
    908872            // copy atom ...
    909             CopyAtoms[Walker->nr] = Walker->clone();
    910             CopyAtoms[Walker->nr]->x = Inserter;
    911             Filling->AddAtom(CopyAtoms[Walker->nr]);
    912             DoLog(4) && (Log() << Verbose(4) << "Filling atom " << *Walker << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[Walker->nr]->x) << "." << endl);
     873            CopyAtoms[(*iter)->nr] = (*iter)->clone();
     874            CopyAtoms[(*iter)->nr]->x = Inserter;
     875            Filling->AddAtom(CopyAtoms[(*iter)->nr]);
     876            DoLog(4) && (Log() << Verbose(4) << "Filling atom " << **iter << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[(*iter)->nr]->x) << "." << endl);
    913877          } else {
    914878            DoLog(1) && (Log() << Verbose(1) << "INFO: Position at " << Inserter << " is inner point, within boundary or outside of MaxDistance." << endl);
    915             CopyAtoms[Walker->nr] = NULL;
     879            CopyAtoms[(*iter)->nr] = NULL;
    916880            continue;
    917881          }
    918882        }
    919883        // go through all bonds and add as well
    920         Binder = filler->first;
    921         while(Binder->next != filler->last) {
    922           Binder = Binder->next;
    923           if ((CopyAtoms[Binder->leftatom->nr] != NULL) && (CopyAtoms[Binder->rightatom->nr] != NULL)) {
    924             Log()  << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl;
    925             Filling->AddBond(CopyAtoms[Binder->leftatom->nr], CopyAtoms[Binder->rightatom->nr], Binder->BondDegree);
    926           }
    927         }
     884        for(molecule::iterator AtomRunner = filler->begin(); AtomRunner != filler->end(); ++AtomRunner)
     885          for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     886            if ((*BondRunner)->leftatom == *AtomRunner) {
     887              Binder = (*BondRunner);
     888              if ((CopyAtoms[Binder->leftatom->nr] != NULL) && (CopyAtoms[Binder->rightatom->nr] != NULL)) {
     889                Log()  << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl;
     890                Filling->AddBond(CopyAtoms[Binder->leftatom->nr], CopyAtoms[Binder->rightatom->nr], Binder->BondDegree);
     891              }
     892            }
    928893      }
    929   Free(&M);
    930   Free(&MInverse);
     894  delete[](M);
     895  delete[](MInverse);
    931896
    932897  return Filling;
     
    952917  bool TesselationFailFlag = false;
    953918
     919  mol->getAtomCount();
     920
    954921  if (TesselStruct == NULL) {
    955922    DoLog(1) && (Log() << Verbose(1) << "Allocating Tesselation struct ..." << endl);
     
    1023990//  // look whether all points are inside of the convex envelope, otherwise add them via degenerated triangles
    1024991//  //->InsertStraddlingPoints(mol, LCList);
    1025 //  mol->GoToFirst();
     992//  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
    1026993//  class TesselPoint *Runner = NULL;
    1027 //  while (!mol->IsEnd()) {
    1028 //    Runner = mol->GetPoint();
     994//    Runner = *iter;
    1029995//    Log() << Verbose(1) << "Checking on " << Runner->Name << " ... " << endl;
    1030996//    if (!->IsInnerPoint(Runner, LCList)) {
     
    10341000//      Log() << Verbose(2) << Runner->Name << " is inside of or on envelope." << endl;
    10351001//    }
    1036 //    mol->GoToNext();
    10371002//  }
    10381003
     
    10431008  status = CheckListOfBaselines(TesselStruct);
    10441009
     1010  cout << "before correction" << endl;
     1011
    10451012  // store before correction
    1046   StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, "");
     1013  StoreTrianglesinFile(mol, TesselStruct, filename, "");
    10471014
    10481015//  // correct degenerated polygons
     
    10541021  // write final envelope
    10551022  CalculateConcavityPerBoundaryPoint(TesselStruct);
    1056   StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, "");
     1023  cout << "after correction" << endl;
     1024  StoreTrianglesinFile(mol, TesselStruct, filename, "");
    10571025
    10581026  if (freeLC)
  • src/builder.cpp

    r0c7ed8 r1dc9ec  
    4747 */
    4848
     49#include "Helpers/MemDebug.hpp"
    4950
    5051#include <boost/bind.hpp>
     
    5354
    5455#include <cstring>
     56#include <cstdlib>
    5557
    5658#include "analysis_bonds.hpp"
     
    6062#include "bondgraph.hpp"
    6163#include "boundary.hpp"
     64#include "CommandLineParser.hpp"
    6265#include "config.hpp"
    6366#include "element.hpp"
     
    7174#include "periodentafel.hpp"
    7275#include "UIElements/UIFactory.hpp"
     76#include "UIElements/TextUI/TextUIFactory.hpp"
     77#include "UIElements/CommandLineUI/CommandLineUIFactory.hpp"
    7378#include "UIElements/MainWindow.hpp"
    7479#include "UIElements/Dialog.hpp"
     
    7681#include "Actions/ActionRegistry.hpp"
    7782#include "Actions/ActionHistory.hpp"
     83#include "Actions/MapOfActions.hpp"
    7884#include "Actions/MethodAction.hpp"
    79 #include "Actions/small_actions.hpp"
     85#include "Actions/MoleculeAction/ChangeNameAction.hpp"
    8086#include "World.hpp"
    8187#include "version.h"
    8288#include "World.hpp"
    83 #include "Helpers/MemDebug.hpp"
     89
    8490
    8591/********************************************* Subsubmenu routine ************************************/
     
    862868
    863869        mol->CountAtoms(); // recount atoms
    864         if (mol->AtomCount != 0) {  // if there is more than none
    865           count = mol->AtomCount;  // is changed becausing of adding, thus has to be stored away beforehand
     870        if (mol->getAtomCount() != 0) {  // if there is more than none
     871          count = mol->getAtomCount();  // is changed becausing of adding, thus has to be stored away beforehand
    866872          Elements = new element *[count];
    867873          vectors = new Vector *[count];
     
    12931299  // generate some KeySets
    12941300  DoLog(0) && (Log() << Verbose(0) << "Generating KeySets." << endl);
    1295   KeySet TestSets[mol->AtomCount+1];
     1301  KeySet TestSets[mol->getAtomCount()+1];
    12961302  i=1;
    12971303  while (Walker->next != mol->end) {
     
    13041310  DoLog(0) && (Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl);
    13051311  KeySetTestPair test;
    1306   test = TestSets[mol->AtomCount-1].insert(Walker->nr);
     1312  test = TestSets[mol->getAtomCount()-1].insert(Walker->nr);
    13071313  if (test.second) {
    13081314    DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl);
     
    13101316    DoLog(1) && (Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl);
    13111317  }
    1312   TestSets[mol->AtomCount].insert(mol->end->previous->nr);
    1313   TestSets[mol->AtomCount].insert(mol->end->previous->previous->previous->nr);
     1318  TestSets[mol->getAtomCount()].insert(mol->end->previous->nr);
     1319  TestSets[mol->getAtomCount()].insert(mol->end->previous->previous->previous->nr);
    13141320
    13151321  // constructing Graph structure
     
    13191325  // insert KeySets into Subgraphs
    13201326  DoLog(0) && (Log() << Verbose(0) << "Inserting KeySets into Subgraph class." << endl);
    1321   for (int j=0;j<mol->AtomCount;j++) {
     1327  for (int j=0;j<mol->getAtomCount();j++) {
    13221328    Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.)));
    13231329  }
    13241330  DoLog(0) && (Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl);
    13251331  GraphTestPair test2;
    1326   test2 = Subgraphs.insert(GraphPair (TestSets[mol->AtomCount],pair<int, double>(counter++, 1.)));
     1332  test2 = Subgraphs.insert(GraphPair (TestSets[mol->getAtomCount()],pair<int, double>(counter++, 1.)));
    13271333  if (test2.second) {
    13281334    DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl);
     
    14791485
    14801486/** Parses the command line options.
     1487 * Note that this function is from now on transitional. All commands that are not passed
     1488 * here are handled by CommandLineParser and the actions of CommandLineUIFactory.
    14811489 * \param argc argument count
    14821490 * \param **argv arguments array
     
    14861494 * \param *ConfigFileName pointer to config file name in **argv
    14871495 * \param *PathToDatabases pointer to db's path in **argv
     1496 * \param &ArgcList list of arguments that we do not parse here
    14881497 * \return exit code (0 - successful, all else - something's wrong)
    14891498 */
    1490 static int ParseCommandLineOptions(int argc, char **argv, MoleculeListClass *&molecules, periodentafel *&periode,\
    1491                                    config& configuration, char *&ConfigFileName)
     1499static int ParseCommandLineOptions(int argc, char **argv, MoleculeListClass *&molecules, periodentafel *&periode,
     1500                                   config& configuration, char **ConfigFileName, set<int> &ArgcList)
    14921501{
    14931502  Vector x,y,z,n;  // coordinates for absolute point in cell volume
     
    15071516  molecule *mol = NULL;
    15081517  string BondGraphFileName("\n");
    1509   int verbosity = 0;
    1510   strncpy(configuration.databasepath, LocalPath, MAXSTRINGSIZE-1);
     1518  bool DatabasePathGiven = false;
    15111519
    15121520  if (argc > 1) { // config file specified as option
     
    15211529          case 'H':
    15221530          case '?':
    1523             DoLog(0) && (Log() << Verbose(0) << "MoleCuilder suite" << endl << "==================" << endl << endl);
    1524             DoLog(0) && (Log() << Verbose(0) << "Usage: " << argv[0] << "[config file] [-{acefpsthH?vfrp}] [further arguments]" << endl);
    1525             DoLog(0) && (Log() << Verbose(0) << "or simply " << argv[0] << " without arguments for interactive session." << endl);
    1526             DoLog(0) && (Log() << Verbose(0) << "\t-a Z x1 x2 x3\tAdd new atom of element Z at coordinates (x1,x2,x3)." << endl);
    1527             DoLog(0) && (Log() << Verbose(0) << "\t-A <source>\tCreate adjacency list from bonds parsed from 'dbond'-style file." <<endl);
    1528             DoLog(0) && (Log() << Verbose(0) << "\t-b xx xy xz yy yz zz\tCenter atoms in domain with given symmetric matrix of (xx,xy,xz,yy,yz,zz)." << endl);
    1529             DoLog(0) && (Log() << Verbose(0) << "\t-B xx xy xz yy yz zz\tBound atoms by domain with given symmetric matrix of (xx,xy,xz,yy,yz,zz)." << endl);
    1530             DoLog(0) && (Log() << Verbose(0) << "\t-c x1 x2 x3\tCenter atoms in domain with a minimum distance to boundary of (x1,x2,x3)." << endl);
    1531             DoLog(0) && (Log() << Verbose(0) << "\t-C <type> [params] <output> <bin output> <BinWidth> <BinStart> <BinEnd>\tPair Correlation analysis." << endl);
    1532             DoLog(0) && (Log() << Verbose(0) << "\t-d x1 x2 x3\tDuplicate cell along each axis by given factor." << endl);
    1533             DoLog(0) && (Log() << Verbose(0) << "\t-D <bond distance>\tDepth-First-Search Analysis of the molecule, giving cycles and tree/back edges." << endl);
    1534             DoLog(0) && (Log() << Verbose(0) << "\t-e <file>\tSets the databases path to be parsed (default: ./)." << endl);
    1535             DoLog(0) && (Log() << Verbose(0) << "\t-E <id> <Z>\tChange atom <id>'s element to <Z>, <id> begins at 0." << endl);
    1536             DoLog(0) && (Log() << Verbose(0) << "\t-f <dist> <order>\tFragments the molecule in BOSSANOVA manner (with/out rings compressed) and stores config files in same dir as config (return code 0 - fragmented, 2 - no fragmentation necessary)." << endl);
    1537             DoLog(0) && (Log() << Verbose(0) << "\t-F <xyz of filler> <dist_x> <dist_y> <dist_z> <epsilon> <randatom> <randmol> <DoRotate>\tFilling Box with water molecules." << endl);
    1538             DoLog(0) && (Log() << Verbose(0) << "\t-FF <MaxDistance> <xyz of filler> <dist_x> <dist_y> <dist_z> <epsilon> <randatom> <randmol> <DoRotate>\tFilling Box with water molecules." << endl);
    1539             DoLog(0) && (Log() << Verbose(0) << "\t-g <file>\tParses a bond length table from the given file." << endl);
    1540             DoLog(0) && (Log() << Verbose(0) << "\t-h/-H/-?\tGive this help screen." << endl);
    1541             DoLog(0) && (Log() << Verbose(0) << "\t-I\t Dissect current system of molecules into a set of disconnected (subgraphs of) molecules." << endl);
    1542             DoLog(0) && (Log() << Verbose(0) << "\t-j\t<path> Store all bonds to file." << endl);
    1543             DoLog(0) && (Log() << Verbose(0) << "\t-J\t<path> Store adjacency per atom to file." << endl);
    1544             DoLog(0) && (Log() << Verbose(0) << "\t-L <step0> <step1> <prefix>\tStore a linear interpolation between two configurations <step0> and <step1> into single config files with prefix <prefix> and as Trajectories into the current config file." << endl);
    1545             DoLog(0) && (Log() << Verbose(0) << "\t-m <0/1>\tCalculate (0)/ Align in(1) PAS with greatest EV along z axis." << endl);
    1546             DoLog(0) && (Log() << Verbose(0) << "\t-M <basis>\tSetting basis to store to MPQC config files." << endl);
    1547             DoLog(0) && (Log() << Verbose(0) << "\t-n\tFast parsing (i.e. no trajectories are looked for)." << endl);
    1548             DoLog(0) && (Log() << Verbose(0) << "\t-N <radius> <file>\tGet non-convex-envelope." << endl);
    1549             DoLog(0) && (Log() << Verbose(0) << "\t-o <out>\tGet volume of the convex envelope (and store to tecplot file)." << endl);
    1550             DoLog(0) && (Log() << Verbose(0) << "\t-O\tCenter atoms in origin." << endl);
    1551             DoLog(0) && (Log() << Verbose(0) << "\t-p <file>\tParse given xyz file and create raw config file from it." << endl);
    1552             DoLog(0) && (Log() << Verbose(0) << "\t-P <file>\tParse given forces file and append as an MD step to config file via Verlet." << endl);
    1553             DoLog(0) && (Log() << Verbose(0) << "\t-r <id>\t\tRemove an atom with given id." << endl);
    1554             DoLog(0) && (Log() << Verbose(0) << "\t-R <id> <radius>\t\tRemove all atoms out of sphere around a given one." << endl);
    1555             DoLog(0) && (Log() << Verbose(0) << "\t-s x1 x2 x3\tScale all atom coordinates by this vector (x1,x2,x3)." << endl);
    1556             DoLog(0) && (Log() << Verbose(0) << "\t-S <file> Store temperatures from the config file in <file>." << endl);
    1557             DoLog(0) && (Log() << Verbose(0) << "\t-t x1 x2 x3\tTranslate all atoms by this vector (x1,x2,x3)." << endl);
    1558             DoLog(0) && (Log() << Verbose(0) << "\t-T x1 x2 x3\tTranslate periodically all atoms by this vector (x1,x2,x3)." << endl);
    1559             DoLog(0) && (Log() << Verbose(0) << "\t-u rho\tsuspend in water solution and output necessary cell lengths, average density rho and repetition." << endl);
    1560             DoLog(0) && (Log() << Verbose(0) << "\t-v\t\tsets verbosity (more is more)." << endl);
    1561             DoLog(0) && (Log() << Verbose(0) << "\t-V\t\tGives version information." << endl);
    1562             DoLog(0) && (Log() << Verbose(0) << "\t-X\t\tset default name of a molecule." << endl);
    1563             DoLog(0) && (Log() << Verbose(0) << "Note: config files must not begin with '-' !" << endl);
    1564             return (1);
     1531            ArgcList.insert(argptr-1);
     1532            return(1);
    15651533            break;
    15661534          case 'v':
    1567             while (argv[argptr-1][verbosity+1] == 'v') {
    1568               verbosity++;
     1535            if ((argptr >= argc) || (argv[argptr][0] == '-')) {
     1536              DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for specifying verbosity: -v <level>" << endl);
     1537              performCriticalExit();
     1538            } else {
     1539              setVerbosity(atoi(argv[argptr]));
     1540              ArgcList.insert(argptr-1);
     1541              ArgcList.insert(argptr);
     1542              argptr++;
    15691543            }
    1570             setVerbosity(verbosity);
    1571             DoLog(0) && (Log() << Verbose(0) << "Setting verbosity to " << verbosity << "." << endl);
    15721544            break;
    15731545          case 'V':
    1574             DoLog(0) && (Log() << Verbose(0) << argv[0] << " " << VERSIONSTRING << endl);
    1575             DoLog(0) && (Log() << Verbose(0) << "Build your own molecule position set." << endl);
    1576             return (1);
     1546            ArgcList.insert(argptr-1);
     1547            return(1);
    15771548            break;
    15781549          case 'B':
    15791550            if (ExitFlag == 0) ExitFlag = 1;
    1580             if ((argptr+5 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) ) {
    1581               ExitFlag = 255;
    1582               DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for bounding in box: -B <xx> <xy> <xz> <yy> <yz> <zz>" << endl);
     1551            if ((argptr+5 >= argc)) {
     1552              DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for setting Box: -B <xx> <<xy> <<xz> <yy> <yz> <zz>" << endl);
    15831553              performCriticalExit();
    15841554            } else {
    1585               SaveFlag = true;
    1586               j = -1;
    1587               DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl);
    1588               double * const cell_size = World::getInstance().getDomain();
    1589               for (int i=0;i<6;i++) {
    1590                 cell_size[i] = atof(argv[argptr+i]);
    1591               }
     1555              ArgcList.insert(argptr-1);
     1556              ArgcList.insert(argptr);
     1557              ArgcList.insert(argptr+1);
     1558              ArgcList.insert(argptr+2);
     1559              ArgcList.insert(argptr+3);
     1560              ArgcList.insert(argptr+4);
     1561              ArgcList.insert(argptr+5);
    15921562              argptr+=6;
    15931563            }
     
    15981568              performCriticalExit();
    15991569            } else {
    1600               DoLog(0) && (Log() << Verbose(0) << "Using " << argv[argptr] << " as elements database." << endl);
    1601               strncpy (configuration.databasepath, argv[argptr], MAXSTRINGSIZE-1);
     1570              ArgcList.insert(argptr-1);
     1571              ArgcList.insert(argptr);
    16021572              argptr+=1;
    16031573            }
     
    16081578              performCriticalExit();
    16091579            } else {
    1610               BondGraphFileName = argv[argptr];
    1611               DoLog(0) && (Log() << Verbose(0) << "Using " << BondGraphFileName << " as bond length table." << endl);
     1580              ArgcList.insert(argptr-1);
     1581              ArgcList.insert(argptr);
     1582              argptr+=1;
     1583            }
     1584            break;
     1585          case 'M':
     1586            if ((argptr >= argc) || (argv[argptr][0] == '-')) {
     1587              ExitFlag = 255;
     1588              DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for setting MPQC basis: -M <basis name>" << endl);
     1589              performCriticalExit();
     1590            } else {
     1591              ArgcList.insert(argptr-1);
     1592              ArgcList.insert(argptr);
    16121593              argptr+=1;
    16131594            }
    16141595            break;
    16151596          case 'n':
    1616             DoLog(0) && (Log() << Verbose(0) << "I won't parse trajectories." << endl);
    1617             configuration.FastParsing = true;
     1597            if ((argptr >= argc) || (argv[argptr][0] == '-')) {
     1598              ExitFlag = 255;
     1599              DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for setting fast-parsing: -n <0/1>" << endl);
     1600              performCriticalExit();
     1601            } else {
     1602              ArgcList.insert(argptr-1);
     1603              ArgcList.insert(argptr);
     1604              argptr+=1;
     1605            }
    16181606            break;
    16191607          case 'X':
    1620             {
    1621               World::getInstance().setDefaultName(argv[argptr]);
    1622               DoLog(0) && (Log() << Verbose(0) << "Default name of new molecules set to " << *World::getInstance().getDefaultName() << "." << endl);
     1608            if ((argptr >= argc) || (argv[argptr][0] == '-')) {
     1609              ExitFlag = 255;
     1610              DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for setting default molecule name: -X <name>" << endl);
     1611              performCriticalExit();
     1612            } else {
     1613              ArgcList.insert(argptr-1);
     1614              ArgcList.insert(argptr);
     1615              argptr+=1;
    16231616            }
    16241617            break;
     
    16311624    } while (argptr < argc);
    16321625
    1633     // 3a. Parse the element database
    1634     if (periode->LoadPeriodentafel(configuration.databasepath)) {
    1635       DoLog(0) && (Log() << Verbose(0) << "Element list loaded successfully." << endl);
    1636       //periode->Output();
    1637     } else {
    1638       DoLog(0) && (Log() << Verbose(0) << "Element list loading failed." << endl);
    1639       return 1;
    1640     }
    16411626    // 3b. Find config file name and parse if possible, also BondGraphFileName
    16421627    if (argv[1][0] != '-') {
     
    16521637        } else {
    16531638          DoLog(0) && (Log() << Verbose(0) << "Empty configuration file." << endl);
    1654           ConfigFileName = argv[1];
     1639          strcpy(*ConfigFileName, argv[1]);
    16551640          configPresent = empty;
    16561641          output.close();
     
    16581643      } else {
    16591644        test.close();
    1660         ConfigFileName = argv[1];
     1645        strcpy(*ConfigFileName, argv[1]);
    16611646        DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... ");
    1662         switch (configuration.TestSyntax(ConfigFileName, periode)) {
     1647        switch (configuration.TestSyntax(*ConfigFileName, periode)) {
    16631648          case 1:
    16641649            DoLog(0) && (Log() << Verbose(0) << "new syntax." << endl);
    1665             configuration.Load(ConfigFileName, BondGraphFileName, periode, molecules);
     1650            configuration.Load(*ConfigFileName, BondGraphFileName, periode, molecules);
    16661651            configPresent = present;
    16671652            break;
    16681653          case 0:
    16691654            DoLog(0) && (Log() << Verbose(0) << "old syntax." << endl);
    1670             configuration.LoadOld(ConfigFileName, BondGraphFileName, periode, molecules);
     1655            configuration.LoadOld(*ConfigFileName, BondGraphFileName, periode, molecules);
    16711656            configPresent = present;
    16721657            break;
     
    16891674       mol = World::getInstance().createMolecule();
    16901675       mol->ActiveFlag = true;
    1691        if (ConfigFileName != NULL)
    1692          mol->SetNameFromFilename(ConfigFileName);
     1676       if (*ConfigFileName != NULL)
     1677         mol->SetNameFromFilename(*ConfigFileName);
    16931678       molecules->insert(mol);
    1694      }
    1695      if (configuration.BG == NULL) {
    1696        configuration.BG = new BondGraph(configuration.GetIsAngstroem());
    1697        if ((!BondGraphFileName.empty()) && (configuration.BG->LoadBondLengthTable(BondGraphFileName))) {
    1698          DoLog(0) && (Log() << Verbose(0) << "Bond length table loaded successfully." << endl);
    1699        } else {
    1700          DoeLog(1) && (eLog()<< Verbose(1) << "Bond length table loading failed." << endl);
    1701        }
    17021679     }
    17031680
     
    17291706            case 'a':
    17301707              if (ExitFlag == 0) ExitFlag = 1;
    1731               if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3]))) {
     1708              if ((argptr+4 >= argc) || (argv[argptr][0] == '-')) {
    17321709                ExitFlag = 255;
    1733                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for adding atom: -a <element> <x> <y> <z>" << endl);
     1710                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough arguments for adding atom: -a <Z> --position <x> <y> <z>" << endl);
    17341711                performCriticalExit();
    17351712              } else {
    1736                 SaveFlag = true;
    1737                 Log() << Verbose(1) << "Adding new atom with element " << argv[argptr] << " at (" << argv[argptr+1] << "," << argv[argptr+2] << "," << argv[argptr+3] << "), ";
    1738                 first = World::getInstance().createAtom();
    1739                 first->type = periode->FindElement(atoi(argv[argptr]));
    1740                 if (first->type != NULL)
    1741                   DoLog(2) && (Log() << Verbose(2) << "found element " << first->type->name << endl);
    1742                 for (int i=NDIM;i--;)
    1743                   first->x[i] = atof(argv[argptr+1+i]);
    1744                 if (first->type != NULL) {
    1745                   mol->AddAtom(first);  // add to molecule
    1746                   if ((configPresent == empty) && (mol->AtomCount != 0))
    1747                     configPresent = present;
    1748                 } else
    1749                   DoeLog(1) && (eLog()<< Verbose(1) << "Could not find the specified element." << endl);
    1750                 argptr+=4;
     1713                ArgcList.insert(argptr-1);
     1714                ArgcList.insert(argptr);
     1715                ArgcList.insert(argptr+1);
     1716                ArgcList.insert(argptr+2);
     1717                ArgcList.insert(argptr+3);
     1718                ArgcList.insert(argptr+4);
     1719                argptr+=5;
    17511720              }
    17521721              break;
     
    17571726        if (configPresent == present) {
    17581727          switch(argv[argptr-1][1]) {
    1759             case 'M':
     1728            case 'D':
     1729              if (ExitFlag == 0) ExitFlag = 1;
    17601730              if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    17611731                ExitFlag = 255;
    1762                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for setting MPQC basis: -B <basis name>" << endl);
     1732                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for depth-first-search analysis: -D <max. bond distance>" << endl);
    17631733                performCriticalExit();
    17641734              } else {
    1765                 configuration.basis = argv[argptr];
    1766                 DoLog(1) && (Log() << Verbose(1) << "Setting MPQC basis to " << configuration.basis << "." << endl);
     1735                ArgcList.insert(argptr-1);
     1736                ArgcList.insert(argptr);
    17671737                argptr+=1;
    17681738              }
    1769               break;
    1770             case 'D':
    1771               if (ExitFlag == 0) ExitFlag = 1;
    1772               {
    1773                 DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl);
    1774                 MoleculeLeafClass *Subgraphs = NULL;      // list of subgraphs from DFS analysis
    1775                 int *MinimumRingSize = new int[mol->AtomCount];
    1776                 atom ***ListOfLocalAtoms = NULL;
    1777                 class StackClass<bond *> *BackEdgeStack = NULL;
    1778                 class StackClass<bond *> *LocalBackEdgeStack = NULL;
    1779                 mol->CreateAdjacencyList(atof(argv[argptr]), configuration.GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
    1780                 Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack);
    1781                 if (Subgraphs != NULL) {
    1782                   int FragmentCounter = 0;
    1783                   while (Subgraphs->next != NULL) {
    1784                     Subgraphs = Subgraphs->next;
    1785                     Subgraphs->FillBondStructureFromReference(mol, FragmentCounter, ListOfLocalAtoms, false);  // we want to keep the created ListOfLocalAtoms
    1786                     LocalBackEdgeStack = new StackClass<bond *> (Subgraphs->Leaf->BondCount);
    1787                     Subgraphs->Leaf->PickLocalBackEdges(ListOfLocalAtoms[FragmentCounter], BackEdgeStack, LocalBackEdgeStack);
    1788                     Subgraphs->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize);
    1789                     delete(LocalBackEdgeStack);
    1790                     delete(Subgraphs->previous);
    1791                     FragmentCounter++;
    1792                   }
    1793                   delete(Subgraphs);
    1794                   for (int i=0;i<FragmentCounter;i++)
    1795                     Free(&ListOfLocalAtoms[i]);
    1796                   Free(&ListOfLocalAtoms);
    1797                 }
    1798                 delete(BackEdgeStack);
    1799                 delete[](MinimumRingSize);
    1800               }
    1801               //argptr+=1;
    18021739              break;
    18031740            case 'I':
    18041741              DoLog(1) && (Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl);
    1805               // @TODO rather do the dissection afterwards
    1806               molecules->DissectMoleculeIntoConnectedSubgraphs(periode, &configuration);
    1807               mol = NULL;
    1808               if (molecules->ListOfMolecules.size() != 0) {
    1809                 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
    1810                   if ((*ListRunner)->ActiveFlag) {
    1811                     mol = *ListRunner;
    1812                     break;
    1813                   }
    1814               }
    1815               if ((mol == NULL) && (!molecules->ListOfMolecules.empty())) {
    1816                 mol = *(molecules->ListOfMolecules.begin());
    1817                 if (mol != NULL)
    1818                   mol->ActiveFlag = true;
    1819               }
     1742              ArgcList.insert(argptr-1);
     1743              argptr+=0;
    18201744              break;
    18211745            case 'C':
    18221746              {
    1823                 int ranges[3] = {1, 1, 1};
    1824                 bool periodic = (argv[argptr-1][2] =='p');
    18251747                if (ExitFlag == 0) ExitFlag = 1;
    1826                 if ((argptr >= argc)) {
     1748                if ((argptr+11 >= argc)) {
    18271749                  ExitFlag = 255;
    18281750                  DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C[p] <type: E/P/S> [more params] <output> <bin output> <BinStart> <BinEnd>" << endl);
     
    18311753                  switch(argv[argptr][0]) {
    18321754                    case 'E':
    1833                       {
    1834                         if ((argptr+6 >= argc) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+5])) || (!IsValidNumber(argv[argptr+6])) || (!IsValidNumber(argv[argptr+2])) || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-') || (argv[argptr+3][0] == '-') || (argv[argptr+4][0] == '-')) {
    1835                           ExitFlag = 255;
    1836                           DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C E <Z1> <Z2> <output> <bin output>" << endl);
    1837                           performCriticalExit();
    1838                         } else {
    1839                           ofstream output(argv[argptr+3]);
    1840                           ofstream binoutput(argv[argptr+4]);
    1841                           const double BinStart = atof(argv[argptr+5]);
    1842                           const double BinEnd = atof(argv[argptr+6]);
    1843 
    1844                           const element *elemental = periode->FindElement((const int) atoi(argv[argptr+1]));
    1845                           const element *elemental2 = periode->FindElement((const int) atoi(argv[argptr+2]));
    1846                           PairCorrelationMap *correlationmap = NULL;
    1847                           if (periodic)
    1848                             correlationmap = PeriodicPairCorrelation(molecules, elemental, elemental2, ranges);
    1849                           else
    1850                             correlationmap = PairCorrelation(molecules, elemental, elemental2);
    1851                           //OutputCorrelationToSurface(&output, correlationmap);
    1852                           BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd );
    1853                           OutputCorrelation ( &binoutput, binmap );
    1854                           output.close();
    1855                           binoutput.close();
    1856                           delete(binmap);
    1857                           delete(correlationmap);
    1858                           argptr+=7;
    1859                         }
    1860                       }
     1755                      ArgcList.insert(argptr-1);
     1756                      ArgcList.insert(argptr);
     1757                      ArgcList.insert(argptr+1);
     1758                      ArgcList.insert(argptr+2);
     1759                      ArgcList.insert(argptr+3);
     1760                      ArgcList.insert(argptr+4);
     1761                      ArgcList.insert(argptr+5);
     1762                      ArgcList.insert(argptr+6);
     1763                      ArgcList.insert(argptr+7);
     1764                      ArgcList.insert(argptr+8);
     1765                      ArgcList.insert(argptr+9);
     1766                      ArgcList.insert(argptr+10);
     1767                      ArgcList.insert(argptr+11);
     1768                      argptr+=12;
    18611769                      break;
    18621770
    18631771                    case 'P':
    1864                       {
    1865                         if ((argptr+8 >= argc) || (!IsValidNumber(argv[argptr+1])) ||  (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+7])) || (!IsValidNumber(argv[argptr+8])) || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-') || (argv[argptr+3][0] == '-') || (argv[argptr+4][0] == '-') || (argv[argptr+5][0] == '-') || (argv[argptr+6][0] == '-')) {
    1866                           ExitFlag = 255;
    1867                           DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C P <Z1> <x> <y> <z> <output> <bin output>" << endl);
    1868                           performCriticalExit();
    1869                         } else {
    1870                           ofstream output(argv[argptr+5]);
    1871                           ofstream binoutput(argv[argptr+6]);
    1872                           const double BinStart = atof(argv[argptr+7]);
    1873                           const double BinEnd = atof(argv[argptr+8]);
    1874 
    1875                           const element *elemental = periode->FindElement((const int) atoi(argv[argptr+1]));
    1876                           Vector *Point = new Vector((const double) atof(argv[argptr+1]),(const double) atof(argv[argptr+2]),(const double) atof(argv[argptr+3]));
    1877                           CorrelationToPointMap *correlationmap = NULL;
    1878                           if (periodic)
    1879                             correlationmap  = PeriodicCorrelationToPoint(molecules, elemental, Point, ranges);
    1880                           else
    1881                             correlationmap = CorrelationToPoint(molecules, elemental, Point);
    1882                           //OutputCorrelationToSurface(&output, correlationmap);
    1883                           BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd );
    1884                           OutputCorrelation ( &binoutput, binmap );
    1885                           output.close();
    1886                           binoutput.close();
    1887                           delete(Point);
    1888                           delete(binmap);
    1889                           delete(correlationmap);
    1890                           argptr+=9;
    1891                         }
    1892                       }
     1772                      ArgcList.insert(argptr-1);
     1773                      ArgcList.insert(argptr);
     1774                      ArgcList.insert(argptr+1);
     1775                      ArgcList.insert(argptr+2);
     1776                      ArgcList.insert(argptr+3);
     1777                      ArgcList.insert(argptr+4);
     1778                      ArgcList.insert(argptr+5);
     1779                      ArgcList.insert(argptr+6);
     1780                      ArgcList.insert(argptr+7);
     1781                      ArgcList.insert(argptr+8);
     1782                      ArgcList.insert(argptr+9);
     1783                      ArgcList.insert(argptr+10);
     1784                      ArgcList.insert(argptr+11);
     1785                      ArgcList.insert(argptr+12);
     1786                      ArgcList.insert(argptr+13);
     1787                      ArgcList.insert(argptr+14);
     1788                      argptr+=15;
    18931789                      break;
    18941790
    18951791                    case 'S':
    1896                       {
    1897                         if ((argptr+6 >= argc) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) || (!IsValidNumber(argv[argptr+6])) || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-') || (argv[argptr+3][0] == '-')) {
    1898                           ExitFlag = 255;
    1899                           DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C S <Z> <output> <bin output> <BinWidth> <BinStart> <BinEnd>" << endl);
    1900                           performCriticalExit();
    1901                         } else {
    1902                           ofstream output(argv[argptr+2]);
    1903                           ofstream binoutput(argv[argptr+3]);
    1904                           const double radius = 4.;
    1905                           const double BinWidth = atof(argv[argptr+4]);
    1906                           const double BinStart = atof(argv[argptr+5]);
    1907                           const double BinEnd = atof(argv[argptr+6]);
    1908                           double LCWidth = 20.;
    1909                           if (BinEnd > 0) {
    1910                             if (BinEnd > 2.*radius)
    1911                                 LCWidth = BinEnd;
    1912                             else
    1913                               LCWidth = 2.*radius;
    1914                           }
    1915 
    1916                           // get the boundary
    1917                           class molecule *Boundary = NULL;
    1918                           class Tesselation *TesselStruct = NULL;
    1919                           const LinkedCell *LCList = NULL;
    1920                           // find biggest molecule
    1921                           int counter  = 0;
    1922                           for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
    1923                             if ((Boundary == NULL) || (Boundary->AtomCount < (*BigFinder)->AtomCount)) {
    1924                               Boundary = *BigFinder;
    1925                             }
    1926                             counter++;
    1927                           }
    1928                           bool *Actives = Malloc<bool>(counter, "ParseCommandLineOptions() - case C -- *Actives");
    1929                           counter = 0;
    1930                           for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
    1931                             Actives[counter++] = (*BigFinder)->ActiveFlag;
    1932                             (*BigFinder)->ActiveFlag = (*BigFinder == Boundary) ? false : true;
    1933                           }
    1934                           LCList = new LinkedCell(Boundary, LCWidth);
    1935                           const element *elemental = periode->FindElement((const int) atoi(argv[argptr+1]));
    1936                           FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL);
    1937                           CorrelationToSurfaceMap *surfacemap = NULL;
    1938                           if (periodic)
    1939                             surfacemap = PeriodicCorrelationToSurface( molecules, elemental, TesselStruct, LCList, ranges);
    1940                           else
    1941                             surfacemap = CorrelationToSurface( molecules, elemental, TesselStruct, LCList);
    1942                           OutputCorrelationToSurface(&output, surfacemap);
    1943                           // check whether radius was appropriate
    1944                           {
    1945                             double start; double end;
    1946                             GetMinMax( surfacemap, start, end);
    1947                             if (LCWidth < end)
    1948                               DoeLog(1) && (eLog()<< Verbose(1) << "Linked Cell width is smaller than the found range of values! Bins can only be correct up to: " << radius << "." << endl);
    1949                           }
    1950                           BinPairMap *binmap = BinData( surfacemap, BinWidth, BinStart, BinEnd );
    1951                           OutputCorrelation ( &binoutput, binmap );
    1952                           output.close();
    1953                           binoutput.close();
    1954                           for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++)
    1955                             (*BigFinder)->ActiveFlag = Actives[counter++];
    1956                           Free(&Actives);
    1957                           delete(LCList);
    1958                           delete(TesselStruct);
    1959                           delete(binmap);
    1960                           delete(surfacemap);
    1961                           argptr+=7;
    1962                         }
    1963                       }
     1792                      ArgcList.insert(argptr-1);
     1793                      ArgcList.insert(argptr);
     1794                      ArgcList.insert(argptr+1);
     1795                      ArgcList.insert(argptr+2);
     1796                      ArgcList.insert(argptr+3);
     1797                      ArgcList.insert(argptr+4);
     1798                      ArgcList.insert(argptr+5);
     1799                      ArgcList.insert(argptr+6);
     1800                      ArgcList.insert(argptr+7);
     1801                      ArgcList.insert(argptr+8);
     1802                      ArgcList.insert(argptr+9);
     1803                      ArgcList.insert(argptr+10);
     1804                      ArgcList.insert(argptr+11);
     1805                      ArgcList.insert(argptr+12);
     1806                      ArgcList.insert(argptr+13);
     1807                      ArgcList.insert(argptr+14);
     1808                      argptr+=15;
    19641809                      break;
    19651810
     
    19751820            case 'E':
    19761821              if (ExitFlag == 0) ExitFlag = 1;
    1977               if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (argv[argptr+1][0] == '-')) {
     1822              if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr]))) {
    19781823                ExitFlag = 255;
    1979                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for changing element: -E <atom nr.> <element>" << endl);
     1824                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for changing element: -E <atom nr.> --element <Z>" << endl);
    19801825                performCriticalExit();
    19811826              } else {
    1982                 SaveFlag = true;
    1983                 DoLog(1) && (Log() << Verbose(1) << "Changing atom " << argv[argptr] << " to element " << argv[argptr+1] << "." << endl);
    1984                 first = mol->FindAtom(atoi(argv[argptr]));
    1985                 first->type = periode->FindElement(atoi(argv[argptr+1]));
    1986                 argptr+=2;
     1827                ArgcList.insert(argptr-1);
     1828                ArgcList.insert(argptr);
     1829                ArgcList.insert(argptr+1);
     1830                ArgcList.insert(argptr+2);
     1831                argptr+=3;
    19871832              }
    19881833              break;
    19891834            case 'F':
    19901835              if (ExitFlag == 0) ExitFlag = 1;
    1991               MaxDistance = -1;
    1992               if (argv[argptr-1][2] == 'F') { // option is -FF?
    1993                 // fetch first argument as max distance to surface
    1994                 MaxDistance = atof(argv[argptr++]);
    1995                 DoLog(0) && (Log() << Verbose(0) << "Filling with maximum layer distance of " << MaxDistance << "." << endl);
    1996               }
    1997               if ((argptr+7 >=argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) || (!IsValidNumber(argv[argptr+6])) || (!IsValidNumber(argv[argptr+7]))) {
     1836              if ((argptr+12 >= argc) || (argv[argptr][0] == '-')) {
    19981837                ExitFlag = 255;
    1999                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for filling box with water: -F <xyz of filler> <dist_x> <dist_y> <dist_z> <boundary> <randatom> <randmol> <DoRotate>" << endl);
     1838                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for filling with molecule: -F <filler xyz file> --MaxDistance <distance or -1> --distances <x> <y> <z>  --lengths <surface> <randatm> <randmol> --DoRotate <0/1>" << endl);
    20001839                performCriticalExit();
    20011840              } else {
    2002                 SaveFlag = true;
    2003                 DoLog(1) && (Log() << Verbose(1) << "Filling Box with water molecules." << endl);
    2004                 // construct water molecule
    2005                 molecule *filler = World::getInstance().createMolecule();
    2006                 if (!filler->AddXYZFile(argv[argptr])) {
    2007                   DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse filler molecule from " << argv[argptr] << "." << endl);
    2008                 }
    2009                 filler->SetNameFromFilename(argv[argptr]);
    2010                 configuration.BG->ConstructBondGraph(filler);
    2011                 molecule *Filling = NULL;
    2012                 atom *second = NULL, *third = NULL;
    2013                 first = World::getInstance().createAtom();
    2014                 first->type = periode->FindElement(1);
    2015                 first->x = Vector(0.441, -0.143, 0.);
    2016                 filler->AddAtom(first);
    2017                 second = World::getInstance().createAtom();
    2018                 second->type = periode->FindElement(1);
    2019                 second->x = Vector(-0.464, 1.137, 0.0);
    2020                 filler->AddAtom(second);
    2021                 third = World::getInstance().createAtom();
    2022                 third->type = periode->FindElement(8);
    2023                 third->x = Vector(-0.464, 0.177, 0.);
    2024                 filler->AddAtom(third);
    2025                 filler->AddBond(first, third, 1);
    2026                 filler->AddBond(second, third, 1);
    2027                 // call routine
    2028                 double distance[NDIM];
    2029                 for (int i=0;i<NDIM;i++)
    2030                   distance[i] = atof(argv[argptr+i+1]);
    2031                 Filling = FillBoxWithMolecule(molecules, filler, configuration, MaxDistance, distance, atof(argv[argptr+4]), atof(argv[argptr+5]), atof(argv[argptr+6]), atoi(argv[argptr+7]));
    2032                 if (Filling != NULL) {
    2033                   Filling->ActiveFlag = false;
    2034                   molecules->insert(Filling);
    2035                 }
    2036                 World::getInstance().destroyMolecule(filler);
    2037                 argptr+=6;
     1841                ArgcList.insert(argptr-1);
     1842                ArgcList.insert(argptr);
     1843                ArgcList.insert(argptr+1);
     1844                ArgcList.insert(argptr+2);
     1845                ArgcList.insert(argptr+3);
     1846                ArgcList.insert(argptr+4);
     1847                ArgcList.insert(argptr+5);
     1848                ArgcList.insert(argptr+6);
     1849                ArgcList.insert(argptr+7);
     1850                ArgcList.insert(argptr+8);
     1851                ArgcList.insert(argptr+9);
     1852                ArgcList.insert(argptr+10);
     1853                ArgcList.insert(argptr+11);
     1854                ArgcList.insert(argptr+12);
     1855                argptr+=13;
    20381856              }
    20391857              break;
    20401858            case 'A':
     1859              if (ExitFlag == 0) ExitFlag = 1;
     1860              if ((argptr+2 >= argc) || (argv[argptr][0] == '-')) {
     1861                ExitFlag =255;
     1862                DoeLog(0) && (eLog()<< Verbose(0) << "Missing source file for bonds in molecule: -A <bond sourcefile> --molecule-by-id <molecule_id>" << endl);
     1863                performCriticalExit();
     1864              } else {
     1865                ArgcList.insert(argptr-1);
     1866                ArgcList.insert(argptr);
     1867                ArgcList.insert(argptr+1);
     1868                ArgcList.insert(argptr+2);
     1869                argptr+=3;
     1870              }
     1871              break;
     1872
     1873            case 'J':
     1874              if (ExitFlag == 0) ExitFlag = 1;
     1875              if ((argptr+2 >= argc) || (argv[argptr][0] == '-')) {
     1876                ExitFlag =255;
     1877                DoeLog(0) && (eLog()<< Verbose(0) << "Missing path of adjacency file: -J <path> --molecule-by-id <molecule_id>" << endl);
     1878                performCriticalExit();
     1879              } else {
     1880                ArgcList.insert(argptr-1);
     1881                ArgcList.insert(argptr);
     1882                ArgcList.insert(argptr+1);
     1883                ArgcList.insert(argptr+2);
     1884                argptr+=3;
     1885              }
     1886              break;
     1887
     1888            case 'j':
    20411889              if (ExitFlag == 0) ExitFlag = 1;
    20421890              if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    20431891                ExitFlag =255;
    2044                 DoeLog(0) && (eLog()<< Verbose(0) << "Missing source file for bonds in molecule: -A <bond sourcefile>" << endl);
     1892                DoeLog(0) && (eLog()<< Verbose(0) << "Missing path of bonds file: -j <path> --molecule-by-id <molecule_id>" << endl);
    20451893                performCriticalExit();
    20461894              } else {
    2047                 DoLog(0) && (Log() << Verbose(0) << "Parsing bonds from " << argv[argptr] << "." << endl);
    2048                 ifstream *input = new ifstream(argv[argptr]);
    2049                 mol->CreateAdjacencyListFromDbondFile(input);
    2050                 input->close();
    2051                 argptr+=1;
    2052               }
    2053               break;
    2054 
    2055             case 'J':
    2056               if (ExitFlag == 0) ExitFlag = 1;
    2057               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    2058                 ExitFlag =255;
    2059                 DoeLog(0) && (eLog()<< Verbose(0) << "Missing path of adjacency file: -j <path>" << endl);
     1895                ArgcList.insert(argptr-1);
     1896                ArgcList.insert(argptr);
     1897                ArgcList.insert(argptr+1);
     1898                ArgcList.insert(argptr+2);
     1899                argptr+=3;
     1900              }
     1901              break;
     1902
     1903            case 'N':
     1904              if (ExitFlag == 0) ExitFlag = 1;
     1905              if ((argptr+4 >= argc) || (argv[argptr][0] == '-')){
     1906                ExitFlag = 255;
     1907                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for non-convex envelope: -N <molecule_id> --sphere-radius <radius> --nonconvex-file <output prefix>" << endl);
    20601908                performCriticalExit();
    20611909              } else {
    2062                 DoLog(0) && (Log() << Verbose(0) << "Storing adjacency to path " << argv[argptr] << "." << endl);
    2063                 configuration.BG->ConstructBondGraph(mol);
    2064                 mol->StoreAdjacencyToFile(NULL, argv[argptr]);
    2065                 argptr+=1;
    2066               }
    2067               break;
    2068 
    2069             case 'j':
    2070               if (ExitFlag == 0) ExitFlag = 1;
    2071               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    2072                 ExitFlag =255;
    2073                 DoeLog(0) && (eLog()<< Verbose(0) << "Missing path of bonds file: -j <path>" << endl);
     1910                ArgcList.insert(argptr-1);
     1911                ArgcList.insert(argptr);
     1912                ArgcList.insert(argptr+1);
     1913                ArgcList.insert(argptr+2);
     1914                ArgcList.insert(argptr+3);
     1915                ArgcList.insert(argptr+4);
     1916                argptr+=5;
     1917              }
     1918              break;
     1919            case 'S':
     1920              if (ExitFlag == 0) ExitFlag = 1;
     1921              if ((argptr+2 >= argc) || (argv[argptr][0] == '-')) {
     1922                ExitFlag = 255;
     1923                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for storing tempature: -S <temperature file> --molecule-by-id 0" << endl);
    20741924                performCriticalExit();
    20751925              } else {
    2076                 DoLog(0) && (Log() << Verbose(0) << "Storing bonds to path " << argv[argptr] << "." << endl);
    2077                 configuration.BG->ConstructBondGraph(mol);
    2078                 mol->StoreBondsToFile(NULL, argv[argptr]);
    2079                 argptr+=1;
    2080               }
    2081               break;
    2082 
    2083             case 'N':
    2084               if (ExitFlag == 0) ExitFlag = 1;
    2085               if ((argptr+1 >= argc) || (argv[argptr+1][0] == '-')){
     1926                ArgcList.insert(argptr-1);
     1927                ArgcList.insert(argptr);
     1928                ArgcList.insert(argptr+1);
     1929                ArgcList.insert(argptr+2);
     1930                argptr+=3;
     1931              }
     1932              break;
     1933            case 'L':
     1934              if (ExitFlag == 0) ExitFlag = 1;
     1935              if ((argptr+8 >= argc) || (argv[argptr][0] == '-')) {
    20861936                ExitFlag = 255;
    2087                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for non-convex envelope: -o <radius> <tecplot output file>" << endl);
     1937                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for linear interpolation: -L <prefix> --start-step <step0> --end-step <step1> --molecule-by-id 0 --id-mapping <0/1>" << endl);
    20881938                performCriticalExit();
    20891939              } else {
    2090                 class Tesselation *T = NULL;
    2091                 const LinkedCell *LCList = NULL;
    2092                 molecule * Boundary = NULL;
    2093                 //string filename(argv[argptr+1]);
    2094                 //filename.append(".csv");
    2095                 DoLog(0) && (Log() << Verbose(0) << "Evaluating non-convex envelope of biggest molecule.");
    2096                 DoLog(1) && (Log() << Verbose(1) << "Using rolling ball of radius " << atof(argv[argptr]) << " and storing tecplot data in " << argv[argptr+1] << "." << endl);
    2097                 // find biggest molecule
    2098                 int counter  = 0;
    2099                 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
    2100                   (*BigFinder)->CountAtoms();
    2101                   if ((Boundary == NULL) || (Boundary->AtomCount < (*BigFinder)->AtomCount)) {
    2102                     Boundary = *BigFinder;
    2103                   }
    2104                   counter++;
    2105                 }
    2106                 DoLog(1) && (Log() << Verbose(1) << "Biggest molecule has " << Boundary->AtomCount << " atoms." << endl);
    2107                 start = clock();
    2108                 LCList = new LinkedCell(Boundary, atof(argv[argptr])*2.);
    2109                 if (!FindNonConvexBorder(Boundary, T, LCList, atof(argv[argptr]), argv[argptr+1]))
    2110                   ExitFlag = 255;
    2111                 //FindDistributionOfEllipsoids(T, &LCList, N, number, filename.c_str());
    2112                 end = clock();
    2113                 DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);
    2114                 delete(LCList);
    2115                 delete(T);
    2116                 argptr+=2;
    2117               }
    2118               break;
    2119             case 'S':
    2120               if (ExitFlag == 0) ExitFlag = 1;
    2121               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
     1940                ArgcList.insert(argptr-1);
     1941                ArgcList.insert(argptr);
     1942                ArgcList.insert(argptr+1);
     1943                ArgcList.insert(argptr+2);
     1944                ArgcList.insert(argptr+3);
     1945                ArgcList.insert(argptr+4);
     1946                ArgcList.insert(argptr+5);
     1947                ArgcList.insert(argptr+6);
     1948                ArgcList.insert(argptr+7);
     1949                ArgcList.insert(argptr+8);
     1950                argptr+=9;
     1951              }
     1952              break;
     1953            case 'P':
     1954              if (ExitFlag == 0) ExitFlag = 1;
     1955              if ((argptr+2 >= argc) || (argv[argptr][0] == '-')) {
    21221956                ExitFlag = 255;
    2123                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for storing tempature: -S <temperature file>" << endl);
     1957                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for parsing and integrating forces: -P <forces file> --molecule-by-id <molecule_id>" << endl);
    21241958                performCriticalExit();
    21251959              } else {
    2126                 DoLog(1) && (Log() << Verbose(1) << "Storing temperatures in " << argv[argptr] << "." << endl);
    2127                 ofstream *output = new ofstream(argv[argptr], ios::trunc);
    2128                 if (!mol->OutputTemperatureFromTrajectories(output, 0, mol->MDSteps))
    2129                   DoLog(2) && (Log() << Verbose(2) << "File could not be written." << endl);
    2130                 else
    2131                   DoLog(2) && (Log() << Verbose(2) << "File stored." << endl);
    2132                 output->close();
    2133                 delete(output);
    2134                 argptr+=1;
    2135               }
    2136               break;
    2137             case 'L':
    2138               if (ExitFlag == 0) ExitFlag = 1;
    2139               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
     1960                ArgcList.insert(argptr-1);
     1961                ArgcList.insert(argptr);
     1962                ArgcList.insert(argptr+1);
     1963                ArgcList.insert(argptr+2);
     1964                argptr+=3;
     1965              }
     1966              break;
     1967            case 'R':
     1968              if (ExitFlag == 0) ExitFlag = 1;
     1969              if ((argptr+4 >= argc) || (argv[argptr][0] == '-'))  {
    21401970                ExitFlag = 255;
    2141                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for storing tempature: -L <step0> <step1> <prefix> <identity mapping?>" << endl);
     1971                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for removing atoms: -R <distance> --position <x> <y> <z>" << endl);
    21421972                performCriticalExit();
    21431973              } else {
    2144                 SaveFlag = true;
    2145                 DoLog(1) && (Log() << Verbose(1) << "Linear interpolation between configuration " << argv[argptr] << " and " << argv[argptr+1] << "." << endl);
    2146                 if (atoi(argv[argptr+3]) == 1)
    2147                   DoLog(1) && (Log() << Verbose(1) << "Using Identity for the permutation map." << endl);
    2148                 if (!mol->LinearInterpolationBetweenConfiguration(atoi(argv[argptr]), atoi(argv[argptr+1]), argv[argptr+2], configuration, atoi(argv[argptr+3])) == 1 ? true : false)
    2149                   DoLog(2) && (Log() << Verbose(2) << "Could not store " << argv[argptr+2] << " files." << endl);
    2150                 else
    2151                   DoLog(2) && (Log() << Verbose(2) << "Steps created and " << argv[argptr+2] << " files stored." << endl);
    2152                 argptr+=4;
    2153               }
    2154               break;
    2155             case 'P':
    2156               if (ExitFlag == 0) ExitFlag = 1;
    2157               if ((argptr >= argc) || (argv[argptr][0] == '-')) {
     1974                ArgcList.insert(argptr-1);
     1975                ArgcList.insert(argptr);
     1976                ArgcList.insert(argptr+1);
     1977                ArgcList.insert(argptr+2);
     1978                ArgcList.insert(argptr+3);
     1979                ArgcList.insert(argptr+4);
     1980                argptr+=5;
     1981              }
     1982              break;
     1983            case 't':
     1984              if (ExitFlag == 0) ExitFlag = 1;
     1985              if ((argptr+4 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
    21581986                ExitFlag = 255;
    2159                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for parsing and integrating forces: -P <forces file>" << endl);
     1987                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for translation: -t <x> <y> <z> --molecule-by-id <molecule_id> --periodic <0/1>" << endl);
    21601988                performCriticalExit();
    21611989              } else {
    2162                 SaveFlag = true;
    2163                 DoLog(1) && (Log() << Verbose(1) << "Parsing forces file and Verlet integrating." << endl);
    2164                 if (!mol->VerletForceIntegration(argv[argptr], configuration))
    2165                   DoLog(2) && (Log() << Verbose(2) << "File not found." << endl);
    2166                 else
    2167                   DoLog(2) && (Log() << Verbose(2) << "File found and parsed." << endl);
    2168                 argptr+=1;
    2169               }
    2170               break;
    2171             case 'R':
    2172               if (ExitFlag == 0) ExitFlag = 1;
    2173               if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])))  {
    2174                 ExitFlag = 255;
    2175                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for removing atoms: -R <id> <distance>" << endl);
    2176                 performCriticalExit();
    2177               } else {
    2178                 SaveFlag = true;
    2179                 DoLog(1) && (Log() << Verbose(1) << "Removing atoms around " << argv[argptr] << " with radius " << argv[argptr+1] << "." << endl);
    2180                 double tmp1 = atof(argv[argptr+1]);
    2181                 atom *third = mol->FindAtom(atoi(argv[argptr]));
    2182                 atom *first = mol->start;
    2183                 if ((third != NULL) && (first != mol->end)) {
    2184                   atom *second = first->next;
    2185                   while(second != mol->end) {
    2186                     first = second;
    2187                     second = first->next;
    2188                     if (first->x.DistanceSquared(third->x) > tmp1*tmp1) // distance to first above radius ...
    2189                       mol->RemoveAtom(first);
    2190                   }
    2191                 } else {
    2192                   DoeLog(1) && (eLog()<< Verbose(1) << "Removal failed due to missing atoms on molecule or wrong id." << endl);
    2193                 }
    2194                 argptr+=2;
    2195               }
    2196               break;
    2197             case 't':
     1990                ArgcList.insert(argptr-1);
     1991                ArgcList.insert(argptr);
     1992                ArgcList.insert(argptr+1);
     1993                ArgcList.insert(argptr+2);
     1994                ArgcList.insert(argptr+3);
     1995                ArgcList.insert(argptr+4);
     1996                ArgcList.insert(argptr+5);
     1997                ArgcList.insert(argptr+6);
     1998                argptr+=7;
     1999              }
     2000              break;
     2001            case 's':
    21982002              if (ExitFlag == 0) ExitFlag = 1;
    21992003              if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
    2200                 ExitFlag = 255;
    2201                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for translation: -t <x> <y> <z>" << endl);
    2202                 performCriticalExit();
    2203               } else {
    2204                 if (ExitFlag == 0) ExitFlag = 1;
    2205                 SaveFlag = true;
    2206                 DoLog(1) && (Log() << Verbose(1) << "Translating all ions by given vector." << endl);
    2207                 for (int i=NDIM;i--;)
    2208                   x[i] = atof(argv[argptr+i]);
    2209                 mol->Translate((const Vector *)&x);
    2210                 argptr+=3;
    2211               }
    2212               break;
    2213             case 'T':
    2214               if (ExitFlag == 0) ExitFlag = 1;
    2215               if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
    2216                 ExitFlag = 255;
    2217                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for periodic translation: -T <x> <y> <z>" << endl);
    2218                 performCriticalExit();
    2219               } else {
    2220                 if (ExitFlag == 0) ExitFlag = 1;
    2221                 SaveFlag = true;
    2222                 DoLog(1) && (Log() << Verbose(1) << "Translating all ions periodically by given vector." << endl);
    2223                 for (int i=NDIM;i--;)
    2224                   x[i] = atof(argv[argptr+i]);
    2225                 mol->TranslatePeriodically((const Vector *)&x);
    2226                 argptr+=3;
    2227               }
    2228               break;
    2229             case 's':
    2230               if (ExitFlag == 0) ExitFlag = 1;
    2231               if ((argptr >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
    22322004                ExitFlag = 255;
    22332005                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for scaling: -s <factor_x> [factor_y] [factor_z]" << endl);
    22342006                performCriticalExit();
    22352007              } else {
    2236                 SaveFlag = true;
    2237                 j = -1;
    2238                 DoLog(1) && (Log() << Verbose(1) << "Scaling all ion positions by factor." << endl);
    2239                 factor = new double[NDIM];
    2240                 factor[0] = atof(argv[argptr]);
    2241                 factor[1] = atof(argv[argptr+1]);
    2242                 factor[2] = atof(argv[argptr+2]);
    2243                 mol->Scale((const double ** const)&factor);
    2244                 double * const cell_size = World::getInstance().getDomain();
    2245                 for (int i=0;i<NDIM;i++) {
    2246                   j += i+1;
    2247                   x[i] = atof(argv[NDIM+i]);
    2248                   cell_size[j]*=factor[i];
    2249                 }
    2250                 delete[](factor);
     2008                ArgcList.insert(argptr-1);
     2009                ArgcList.insert(argptr);
     2010                ArgcList.insert(argptr+1);
     2011                ArgcList.insert(argptr+2);
    22512012                argptr+=3;
    22522013              }
     
    22592020                performCriticalExit();
    22602021              } else {
    2261                 SaveFlag = true;
    2262                 j = -1;
    2263                 DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl);
    2264                 double * const cell_size = World::getInstance().getDomain();
    2265                 for (int i=0;i<6;i++) {
    2266                   cell_size[i] = atof(argv[argptr+i]);
    2267                 }
    2268                 // center
    2269                 mol->CenterInBox();
     2022                ArgcList.insert(argptr-1);
     2023                ArgcList.insert(argptr);
     2024                ArgcList.insert(argptr+1);
     2025                ArgcList.insert(argptr+2);
     2026                ArgcList.insert(argptr+3);
     2027                ArgcList.insert(argptr+4);
     2028                ArgcList.insert(argptr+5);
    22702029                argptr+=6;
    22712030              }
     
    22782037                performCriticalExit();
    22792038              } else {
    2280                 SaveFlag = true;
    2281                 j = -1;
    2282                 DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl);
    2283                 double * const cell_size = World::getInstance().getDomain();
    2284                 for (int i=0;i<6;i++) {
    2285                   cell_size[i] = atof(argv[argptr+i]);
    2286                 }
    2287                 // center
    2288                 mol->BoundInBox();
     2039                ArgcList.insert(argptr-1);
     2040                ArgcList.insert(argptr);
     2041                ArgcList.insert(argptr+1);
     2042                ArgcList.insert(argptr+2);
     2043                ArgcList.insert(argptr+3);
     2044                ArgcList.insert(argptr+4);
     2045                ArgcList.insert(argptr+5);
    22892046                argptr+=6;
    22902047              }
     
    22972054                performCriticalExit();
    22982055              } else {
    2299                 SaveFlag = true;
    2300                 j = -1;
    2301                 DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given additional boundary." << endl);
    2302                 // make every coordinate positive
    2303                 mol->CenterEdge(&x);
    2304                 // update Box of atoms by boundary
    2305                 mol->SetBoxDimension(&x);
    2306                 // translate each coordinate by boundary
    2307                 double * const cell_size = World::getInstance().getDomain();
    2308                 j=-1;
    2309                 for (int i=0;i<NDIM;i++) {
    2310                   j += i+1;
    2311                   x[i] = atof(argv[argptr+i]);
    2312                   cell_size[j] += x[i]*2.;
    2313                 }
    2314                 mol->Translate((const Vector *)&x);
     2056                ArgcList.insert(argptr-1);
     2057                ArgcList.insert(argptr);
     2058                ArgcList.insert(argptr+1);
     2059                ArgcList.insert(argptr+2);
    23152060                argptr+=3;
    23162061              }
     
    23182063            case 'O':
    23192064              if (ExitFlag == 0) ExitFlag = 1;
    2320               SaveFlag = true;
    2321               DoLog(1) && (Log() << Verbose(1) << "Centering atoms on edge and setting box dimensions." << endl);
    2322               x.Zero();
    2323               mol->CenterEdge(&x);
    2324               mol->SetBoxDimension(&x);
     2065              ArgcList.insert(argptr-1);
    23252066              argptr+=0;
    23262067              break;
     
    23322073                performCriticalExit();
    23332074              } else {
    2334                 SaveFlag = true;
    2335                 DoLog(1) && (Log() << Verbose(1) << "Removing atom " << argv[argptr] << "." << endl);
    2336                 atom *first = mol->FindAtom(atoi(argv[argptr]));
    2337                 mol->RemoveAtom(first);
     2075                ArgcList.insert(argptr-1);
     2076                ArgcList.insert(argptr);
    23382077                argptr+=1;
    23392078              }
     
    23412080            case 'f':
    23422081              if (ExitFlag == 0) ExitFlag = 1;
    2343               if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1]))) {
     2082              if ((argptr+1 >= argc) || (argv[argptr][0] == '-')) {
    23442083                ExitFlag = 255;
    23452084                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for fragmentation: -f <max. bond distance> <bond order>" << endl);
    23462085                performCriticalExit();
    23472086              } else {
    2348                 DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with bond distance " << argv[argptr] << " angstroem, order of " << argv[argptr+1] << "." << endl);
    2349                 DoLog(0) && (Log() << Verbose(0) << "Creating connection matrix..." << endl);
    2350                 start = clock();
    2351                 mol->CreateAdjacencyList(atof(argv[argptr]), configuration.GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
    2352                 DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl);
    2353                 if (mol->first->next != mol->last) {
    2354                   ExitFlag = mol->FragmentMolecule(atoi(argv[argptr+1]), &configuration);
    2355                 }
    2356                 end = clock();
    2357                 DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);
    2358                 argptr+=2;
     2087                ArgcList.insert(argptr-1);
     2088                ArgcList.insert(argptr);
     2089                ArgcList.insert(argptr+1);
     2090                ArgcList.insert(argptr+2);
     2091                ArgcList.insert(argptr+3);
     2092                ArgcList.insert(argptr+4);
     2093                argptr+=5;
    23592094              }
    23602095              break;
     
    23692104                SaveFlag = true;
    23702105                DoLog(0) && (Log() << Verbose(0) << "Converting to prinicipal axis system." << endl);
     2106                mol->PrincipalAxisSystem((bool)j);
    23712107              } else
    2372                 DoLog(0) && (Log() << Verbose(0) << "Evaluating prinicipal axis." << endl);
    2373               mol->PrincipalAxisSystem((bool)j);
     2108                ArgcList.insert(argptr-1);
     2109                argptr+=0;
    23742110              break;
    23752111            case 'o':
    23762112              if (ExitFlag == 0) ExitFlag = 1;
    2377               if ((argptr+1 >= argc) || (argv[argptr][0] == '-')){
     2113              if ((argptr+4 >= argc) || (argv[argptr][0] == '-')){
    23782114                ExitFlag = 255;
    2379                 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for convex envelope: -o <convex output file> <non-convex output file>" << endl);
     2115                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for convex envelope: -o <molecule_id> --output-file <output file> --output-file <binned output file>" << endl);
    23802116                performCriticalExit();
    23812117              } else {
    2382                 class Tesselation *TesselStruct = NULL;
    2383                 const LinkedCell *LCList = NULL;
    2384                 DoLog(0) && (Log() << Verbose(0) << "Evaluating volume of the convex envelope.");
    2385                 DoLog(1) && (Log() << Verbose(1) << "Storing tecplot convex data in " << argv[argptr] << "." << endl);
    2386                 DoLog(1) && (Log() << Verbose(1) << "Storing tecplot non-convex data in " << argv[argptr+1] << "." << endl);
    2387                 LCList = new LinkedCell(mol, 10.);
    2388                 //FindConvexBorder(mol, LCList, argv[argptr]);
    2389                 FindNonConvexBorder(mol, TesselStruct, LCList, 5., argv[argptr+1]);
    2390 //                RemoveAllBoundaryPoints(TesselStruct, mol, argv[argptr]);
    2391                 double volumedifference = ConvexizeNonconvexEnvelope(TesselStruct, mol, argv[argptr]);
    2392                 double clustervolume = VolumeOfConvexEnvelope(TesselStruct, &configuration);
    2393                 DoLog(0) && (Log() << Verbose(0) << "The tesselated volume area is " << clustervolume << " " << (configuration.GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl);
    2394                 DoLog(0) && (Log() << Verbose(0) << "The non-convex tesselated volume area is " << clustervolume-volumedifference << " " << (configuration.GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl);
    2395                 delete(TesselStruct);
    2396                 delete(LCList);
    2397                 argptr+=2;
     2118                ArgcList.insert(argptr-1);
     2119                ArgcList.insert(argptr);
     2120                ArgcList.insert(argptr+1);
     2121                ArgcList.insert(argptr+2);
     2122                ArgcList.insert(argptr+3);
     2123                ArgcList.insert(argptr+4);
     2124                argptr+=5;
    23982125              }
    23992126              break;
     
    24162143                  performCriticalExit();
    24172144              } else {
    2418                 double density;
    2419                 SaveFlag = true;
    2420                 DoLog(0) && (Log() << Verbose(0) << "Evaluating necessary cell volume for a cluster suspended in water.");
    2421                 density = atof(argv[argptr++]);
    2422                 if (density < 1.0) {
    2423                   DoeLog(1) && (eLog()<< Verbose(1) << "Density must be greater than 1.0g/cm^3 !" << endl);
    2424                   density = 1.3;
    2425                 }
    2426 //                for(int i=0;i<NDIM;i++) {
    2427 //                  repetition[i] = atoi(argv[argptr++]);
    2428 //                  if (repetition[i] < 1)
    2429 //                    DoeLog(1) && (eLog()<< Verbose(1) << "repetition value must be greater 1!" << endl);
    2430 //                  repetition[i] = 1;
    2431 //                }
    2432                 PrepareClustersinWater(&configuration, mol, volume, density);  // if volume == 0, will calculate from ConvexEnvelope
     2145                ArgcList.insert(argptr-1);
     2146                ArgcList.insert(argptr);
     2147                argptr+=1;
    24332148              }
    24342149              break;
     
    24402155                performCriticalExit();
    24412156              } else {
    2442                 SaveFlag = true;
    2443                 double * const cell_size = World::getInstance().getDomain();
    2444                 for (int axis = 1; axis <= NDIM; axis++) {
    2445                   int faktor = atoi(argv[argptr++]);
    2446                   int count;
    2447                   const element ** Elements;
    2448                   Vector ** vectors;
    2449                   if (faktor < 1) {
    2450                     DoeLog(1) && (eLog()<< Verbose(1) << "Repetition factor mus be greater than 1!" << endl);
    2451                     faktor = 1;
    2452                   }
    2453                   mol->CountAtoms();  // recount atoms
    2454                   if (mol->AtomCount != 0) {  // if there is more than none
    2455                     count = mol->AtomCount;   // is changed becausing of adding, thus has to be stored away beforehand
    2456                     Elements = new const element *[count];
    2457                     vectors = new Vector *[count];
    2458                     j = 0;
    2459                     first = mol->start;
    2460                     while (first->next != mol->end) {  // make a list of all atoms with coordinates and element
    2461                       first = first->next;
    2462                       Elements[j] = first->type;
    2463                       vectors[j] = &first->x;
    2464                       j++;
    2465                     }
    2466                     if (count != j)
    2467                       DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl);
    2468                     x.Zero();
    2469                     y.Zero();
    2470                     y[abs(axis)-1] = cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
    2471                     for (int i=1;i<faktor;i++) {  // then add this list with respective translation factor times
    2472                       x += y; // per factor one cell width further
    2473                       for (int k=count;k--;) { // go through every atom of the original cell
    2474                         first = World::getInstance().createAtom(); // create a new body
    2475                         first->x = (*vectors[k]) + x;
    2476                         first->type = Elements[k];  // insert original element
    2477                         mol->AddAtom(first);        // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
    2478                       }
    2479                     }
    2480                     // free memory
    2481                     delete[](Elements);
    2482                     delete[](vectors);
    2483                     // correct cell size
    2484                     if (axis < 0) { // if sign was negative, we have to translate everything
    2485                       x =(-(faktor-1)) * y;
    2486                       mol->Translate(&x);
    2487                     }
    2488                     cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
    2489                   }
    2490                 }
     2157                ArgcList.insert(argptr-1);
     2158                ArgcList.insert(argptr);
     2159                ArgcList.insert(argptr+1);
     2160                ArgcList.insert(argptr+2);
     2161                argptr+=3;
    24912162              }
    24922163              break;
     
    25002171    } while (argptr < argc);
    25012172    if (SaveFlag)
    2502       configuration.SaveAll(ConfigFileName, periode, molecules);
     2173      configuration.SaveAll(*ConfigFileName, periode, molecules);
    25032174  } else {  // no arguments, hence scan the elements db
    25042175    if (periode->LoadPeriodentafel(configuration.databasepath))
     
    25112182};
    25122183
    2513 /***************************************** Functions used to build all menus **********************/
    2514 
    2515 void populateEditMoleculesMenu(Menu* editMoleculesMenu,MoleculeListClass *molecules, config *configuration, periodentafel *periode){
    2516   // build the EditMoleculesMenu
    2517   Action *createMoleculeAction = new MethodAction("createMoleculeAction",boost::bind(&MoleculeListClass::createNewMolecule,molecules,periode));
    2518   new ActionMenuItem('c',"create new molecule",editMoleculesMenu,createMoleculeAction);
    2519 
    2520   Action *loadMoleculeAction = new MethodAction("loadMoleculeAction",boost::bind(&MoleculeListClass::loadFromXYZ,molecules,periode));
    2521   new ActionMenuItem('l',"load molecule from xyz file",editMoleculesMenu,loadMoleculeAction);
    2522 
    2523   Action *changeFilenameAction = new ChangeMoleculeNameAction(molecules);
    2524   new ActionMenuItem('n',"change molecule's name",editMoleculesMenu,changeFilenameAction);
    2525 
    2526   Action *giveFilenameAction = new MethodAction("giveFilenameAction",boost::bind(&MoleculeListClass::setMoleculeFilename,molecules));
    2527   new ActionMenuItem('N',"give molecules filename",editMoleculesMenu,giveFilenameAction);
    2528 
    2529   Action *parseAtomsAction = new MethodAction("parseAtomsAction",boost::bind(&MoleculeListClass::parseXYZIntoMolecule,molecules));
    2530   new ActionMenuItem('p',"parse atoms in xyz file into molecule",editMoleculesMenu,parseAtomsAction);
    2531 
    2532   Action *eraseMoleculeAction = new MethodAction("eraseMoleculeAction",boost::bind(&MoleculeListClass::eraseMolecule,molecules));
    2533   new ActionMenuItem('r',"remove a molecule",editMoleculesMenu,eraseMoleculeAction);
    2534 
    2535 }
    2536 
    2537 
    25382184/********************************************** Main routine **************************************/
    25392185
    2540 void cleanUp(config *configuration){
    2541   UIFactory::purgeInstance();
     2186void cleanUp(){
    25422187  World::purgeInstance();
    2543   delete(configuration);
    2544   Log() << Verbose(0) <<  "Maximum of allocated memory: "
    2545     << MemoryUsageObserver::getInstance()->getMaximumUsedMemory() << endl;
    2546   Log() << Verbose(0) <<  "Remaining non-freed memory: "
    2547     << MemoryUsageObserver::getInstance()->getUsedMemorySize() << endl;
    2548   MemoryUsageObserver::purgeInstance();
    25492188  logger::purgeInstance();
    25502189  errorLogger::purgeInstance();
     2190  UIFactory::purgeInstance();
     2191  MapOfActions::purgeInstance();
     2192  CommandLineParser::purgeInstance();
    25512193  ActionRegistry::purgeInstance();
    25522194  ActionHistory::purgeInstance();
     2195#ifdef LOG_OBSERVER
     2196  cout << observerLog().getLog();
     2197#endif
    25532198  Memory::getState();
    25542199}
     
    25562201int main(int argc, char **argv)
    25572202{
     2203    config *configuration = World::getInstance().getConfig();
     2204    // while we are non interactive, we want to abort from asserts
     2205    //ASSERT_DO(Assert::Abort);
    25582206    molecule *mol = NULL;
    2559     config *configuration = new config;
    25602207    Vector x, y, z, n;
    25612208    ifstream test;
    25622209    ofstream output;
    25632210    string line;
    2564     char *ConfigFileName = NULL;
    2565     int j;
    2566 
     2211    char **Arguments = NULL;
     2212    int ArgcSize = 0;
     2213    int ExitFlag = 0;
     2214    bool ArgumentsCopied = false;
     2215    char *ConfigFileName = new char[MAXSTRINGSIZE];
     2216
     2217    // print version check whether arguments are present at all
    25672218    cout << ESPACKVersion << endl;
     2219    if (argc < 2) {
     2220      cout << "Obtain help with " << argv[0] << " -h." << endl;
     2221      cleanUp();
     2222      Memory::getState();
     2223      return(1);
     2224    }
     2225
    25682226
    25692227    setVerbosity(0);
    25702228    // need to init the history before any action is created
    25712229    ActionHistory::init();
    2572     /* structure of ParseCommandLineOptions will be refactored later */
    2573     j = ParseCommandLineOptions(argc, argv,  World::getInstance().getMolecules(), World::getInstance().getPeriode(), *configuration, ConfigFileName);
    2574     switch (j){
    2575         case 255:
    2576         case 2:
    2577         case 1:
    2578             cleanUp(configuration);
    2579             return (j == 1 ? 0 : j);
    2580         default:
    2581             break;
     2230
     2231    // In the interactive mode, we can leave the user the choice in case of error
     2232    ASSERT_DO(Assert::Ask);
     2233
     2234    // from this moment on, we need to be sure to deeinitialize in the correct order
     2235    // this is handled by the cleanup function
     2236    atexit(cleanUp);
     2237
     2238    // Parse command line options and if present create respective UI
     2239    {
     2240      set<int> ArgcList;
     2241      ArgcList.insert(0); // push back program!
     2242      ArgcList.insert(1); // push back config file name
     2243      // handle arguments by ParseCommandLineOptions()
     2244      ExitFlag = ParseCommandLineOptions(argc,argv,World::getInstance().getMolecules(),World::getInstance().getPeriode(),*World::getInstance().getConfig(), &ConfigFileName, ArgcList);
     2245      World::getInstance().setExitFlag(ExitFlag);
     2246      // copy all remaining arguments to a new argv
     2247      Arguments = new char *[ArgcList.size()];
     2248      cout << "The following arguments are handled by CommandLineParser: ";
     2249      for (set<int>::iterator ArgcRunner = ArgcList.begin(); ArgcRunner != ArgcList.end(); ++ArgcRunner) {
     2250        Arguments[ArgcSize] = new char[strlen(argv[*ArgcRunner])+2];
     2251        strcpy(Arguments[ArgcSize], argv[*ArgcRunner]);
     2252        cout << " " << argv[*ArgcRunner];
     2253        ArgcSize++;
     2254      }
     2255      cout << endl;
     2256      ArgumentsCopied = true;
     2257      // handle remaining arguments by CommandLineParser
     2258      MapOfActions::getInstance().AddOptionsToParser();
     2259      map <std::string, std::string> ShortFormToActionMap = MapOfActions::getInstance().getShortFormToActionMap();
     2260      CommandLineParser::getInstance().Run(ArgcSize,Arguments, ShortFormToActionMap);
     2261      if (!CommandLineParser::getInstance().isEmpty()) {
     2262        DoLog(0) && (Log() << Verbose(0) << "Setting UI to CommandLine." << endl);
     2263        UIFactory::registerFactory(new CommandLineUIFactory::description());
     2264        UIFactory::makeUserInterface("CommandLine");
     2265      } else {
     2266        DoLog(0) && (Log() << Verbose(0) << "Setting UI to Text." << endl);
     2267        UIFactory::registerFactory(new TextUIFactory::description());
     2268        UIFactory::makeUserInterface("Text");
     2269      }
    25822270    }
    2583     if(World::getInstance().numMolecules() == 0){
    2584         mol = World::getInstance().createMolecule();
    2585         World::getInstance().getMolecules()->insert(mol);
    2586         cout << "Molecule created" << endl;
    2587         if(World::getInstance().getDomain()[0] == 0.){
    2588             Log() << Verbose(0) << "enter lower tridiagonal form of basis matrix" << endl << endl;
    2589             for(int i = 0;i < 6;i++){
    2590                 Log() << Verbose(1) << "Cell size" << i << ": ";
    2591                 cin >> World::getInstance().getDomain()[i];
    2592             }
    2593         }
    2594         mol->ActiveFlag = true;
    2595     }
    25962271
    25972272    {
    2598       cout << ESPACKVersion << endl;
    2599 
    2600       setVerbosity(0);
    2601 
    2602       menuPopulaters populaters;
    2603       populaters.MakeEditMoleculesMenu = populateEditMoleculesMenu;
    2604 
    2605       UIFactory::makeUserInterface(UIFactory::Text);
    2606       MainWindow *mainWindow = UIFactory::getInstance().makeMainWindow(populaters,World::getInstance().getMolecules(), configuration, World::getInstance().getPeriode(), ConfigFileName);
     2273      MainWindow *mainWindow = UIFactory::getInstance().makeMainWindow();
    26072274      mainWindow->display();
    26082275      delete mainWindow;
    26092276    }
    26102277
    2611     if(World::getInstance().getPeriode()->StorePeriodentafel(configuration->databasepath))
    2612         Log() << Verbose(0) << "Saving of elements.db successful." << endl;
    2613 
    2614     else
    2615         Log() << Verbose(0) << "Saving of elements.db failed." << endl;
    2616 
    2617   cleanUp(configuration);
    2618 
    2619   return (0);
     2278    Log() << Verbose(0) << "Saving to " << ConfigFileName << "." << endl;
     2279    World::getInstance().getConfig()->SaveAll(ConfigFileName, World::getInstance().getPeriode(), World::getInstance().getMolecules());
     2280
     2281  // free the new argv
     2282  if (ArgumentsCopied) {
     2283    for (int i=0; i<ArgcSize;i++)
     2284      delete[](Arguments[i]);
     2285    delete[](Arguments);
     2286  }
     2287  delete[](ConfigFileName);
     2288
     2289  ExitFlag = World::getInstance().getExitFlag();
     2290  return (ExitFlag == 1 ? 0 : ExitFlag);
    26202291}
    26212292
  • src/config.cpp

    r0c7ed8 r1dc9ec  
    44 *
    55 */
     6
     7#include "Helpers/MemDebug.hpp"
    68
    79#include <stdio.h>
     
    1416#include "element.hpp"
    1517#include "helpers.hpp"
     18#include "info.hpp"
    1619#include "lists.hpp"
    1720#include "log.hpp"
     
    9396    return;
    9497  } else
    95     buffer = Malloc<char*>(NoLines, "ConfigFileBuffer::ConfigFileBuffer: **buffer");
     98    buffer = new char *[NoLines];
    9699
    97100  // scan each line and put into buffer
     
    99102  int i;
    100103  do {
    101     buffer[lines] = Malloc<char>(MAXSTRINGSIZE, "ConfigFileBuffer::ConfigFileBuffer: *buffer[]");
     104    buffer[lines] = new char[MAXSTRINGSIZE];
    102105    file->getline(buffer[lines], MAXSTRINGSIZE-1);
    103106    i = strlen(buffer[lines]);
     
    119122{
    120123  for(int i=0;i<NoLines;++i)
    121     Free(&buffer[i]);
    122   Free(&buffer);
    123   Free(&LineMapping);
     124    delete[](buffer[i]);
     125  delete[](buffer);
     126  delete[](LineMapping);
    124127}
    125128
     
    129132void ConfigFileBuffer::InitMapping()
    130133{
    131   LineMapping = Malloc<int>(NoLines, "ConfigFileBuffer::InitMapping: *LineMapping");
     134  LineMapping = new int[NoLines];
    132135  for (int i=0;i<NoLines;i++)
    133136    LineMapping[i] = i;
     
    179182    MaxLevel(5), RiemannTensor(0), LevRFactor(0), RiemannLevel(0), Lev0Factor(2), RTActualUse(0), AddPsis(0), RCut(20.), StructOpt(0), IsAngstroem(1), RelativeCoord(0),
    180183    MaxTypes(0) {
    181   mainname = Malloc<char>(MAXSTRINGSIZE,"config constructor: mainname");
    182   defaultpath = Malloc<char>(MAXSTRINGSIZE,"config constructor: defaultpath");
    183   pseudopotpath = Malloc<char>(MAXSTRINGSIZE,"config constructor: pseudopotpath");
    184   databasepath = Malloc<char>(MAXSTRINGSIZE,"config constructor: databasepath");
    185   configpath = Malloc<char>(MAXSTRINGSIZE,"config constructor: configpath");
    186   configname = Malloc<char>(MAXSTRINGSIZE,"config constructor: configname");
     184  mainname = new char[MAXSTRINGSIZE];
     185  defaultpath = new char[MAXSTRINGSIZE];
     186  pseudopotpath = new char[MAXSTRINGSIZE];
     187  databasepath = new char[MAXSTRINGSIZE];
     188  configpath = new char[MAXSTRINGSIZE];
     189  configname = new char[MAXSTRINGSIZE];
    187190  strcpy(mainname,"pcp");
    188191  strcpy(defaultpath,"not specified");
     
    199202config::~config()
    200203{
    201   Free(&mainname);
    202   Free(&defaultpath);
    203   Free(&pseudopotpath);
    204   Free(&databasepath);
    205   Free(&configpath);
    206   Free(&configname);
    207   Free(&ThermostatImplemented);
     204  delete[](mainname);
     205  delete[](defaultpath);
     206  delete[](pseudopotpath);
     207  delete[](databasepath);
     208  delete[](configpath);
     209  delete[](configname);
     210  delete[](ThermostatImplemented);
    208211  for (int j=0;j<MaxThermostats;j++)
    209     Free(&ThermostatNames[j]);
    210   Free(&ThermostatNames);
     212    delete[](ThermostatNames[j]);
     213  delete[](ThermostatNames);
    211214
    212215  if (BG != NULL)
     
    218221void config::InitThermostats()
    219222{
    220   ThermostatImplemented = Malloc<int>(MaxThermostats, "config constructor: *ThermostatImplemented");
    221   ThermostatNames = Malloc<char*>(MaxThermostats, "config constructor: *ThermostatNames");
     223  ThermostatImplemented = new int[MaxThermostats];
     224  ThermostatNames = new char *[MaxThermostats];
    222225  for (int j=0;j<MaxThermostats;j++)
    223     ThermostatNames[j] = Malloc<char>(12, "config constructor: ThermostatNames[]");
     226    ThermostatNames[j] = new char[12];
    224227
    225228  strcpy(ThermostatNames[0],"None");
     
    242245void config::ParseThermostats(class ConfigFileBuffer * const fb)
    243246{
    244   char * const thermo = Malloc<char>(12, "IonsInitRead: thermo");
     247  char * const thermo = new char[12];
    245248  const int verbose = 0;
    246249
     
    309312    Thermostat = None;
    310313  }
    311   Free(thermo);
     314  delete[](thermo);
    312315};
    313316
     
    15471550  int AtomNo = -1;
    15481551  int MolNo = 0;
    1549   atom *Walker = NULL;
    15501552  FILE *f = NULL;
    15511553
     
    15601562  fprintf(f, "# Created by MoleCuilder\n");
    15611563
    1562   for (MoleculeList::const_iterator Runner = MolList->ListOfMolecules.begin(); Runner != MolList->ListOfMolecules.end(); Runner++) {
    1563     Walker = (*Runner)->start;
    1564     int *elementNo = Calloc<int>(MAX_ELEMENTS, "config::SavePDB - elementNo");
     1564  for (MoleculeList::const_iterator MolRunner = MolList->ListOfMolecules.begin(); MolRunner != MolList->ListOfMolecules.end(); MolRunner++) {
     1565    int *elementNo = new int[MAX_ELEMENTS];
     1566    for (int i=0;i<MAX_ELEMENTS;i++)
     1567      elementNo[i] = 0;
    15651568    AtomNo = 0;
    1566     while (Walker->next != (*Runner)->end) {
    1567       Walker = Walker->next;
    1568       sprintf(name, "%2s%2d",Walker->type->symbol, elementNo[Walker->type->Z]);
    1569       elementNo[Walker->type->Z] = (elementNo[Walker->type->Z]+1) % 100;   // confine to two digits
     1569    for (molecule::const_iterator iter = (*MolRunner)->begin(); iter != (*MolRunner)->end(); ++iter) {
     1570      sprintf(name, "%2s%2d",(*iter)->type->symbol, elementNo[(*iter)->type->Z]);
     1571      elementNo[(*iter)->type->Z] = (elementNo[(*iter)->type->Z]+1) % 100;   // confine to two digits
    15701572      fprintf(f,
    15711573             "ATOM %6u %-4s %4s%c%4u    %8.3f%8.3f%8.3f%6.2f%6.2f      %4s%2s%2s\n",
    1572              Walker->nr,                /* atom serial number */
     1574             (*iter)->nr,                /* atom serial number */
    15731575             name,         /* atom name */
    1574              (*Runner)->name,      /* residue name */
     1576             (*MolRunner)->name,      /* residue name */
    15751577             'a'+(unsigned char)(AtomNo % 26),           /* letter for chain */
    15761578             MolNo,         /* residue sequence number */
    1577              Walker->node->at(0),                 /* position X in Angstroem */
    1578              Walker->node->at(1),                 /* position Y in Angstroem */
    1579              Walker->node->at(2),                 /* position Z in Angstroem */
    1580              (double)Walker->type->Valence,         /* occupancy */
    1581              (double)Walker->type->NoValenceOrbitals,          /* temperature factor */
     1579             (*iter)->node->at(0),                 /* position X in Angstroem */
     1580             (*iter)->node->at(1),                 /* position Y in Angstroem */
     1581             (*iter)->node->at(2),                 /* position Z in Angstroem */
     1582             (double)(*iter)->type->Valence,         /* occupancy */
     1583             (double)(*iter)->type->NoValenceOrbitals,          /* temperature factor */
    15821584             "0",            /* segment identifier */
    1583              Walker->type->symbol,    /* element symbol */
     1585             (*iter)->type->symbol,    /* element symbol */
    15841586             "0");           /* charge */
    15851587      AtomNo++;
    15861588    }
    1587     Free(&elementNo);
     1589    delete[](elementNo);
    15881590    MolNo++;
    15891591  }
     
    16011603{
    16021604  int AtomNo = -1;
    1603   atom *Walker = NULL;
    16041605  FILE *f = NULL;
    16051606
    1606   int *elementNo = Calloc<int>(MAX_ELEMENTS, "config::SavePDB - elementNo");
     1607  int *elementNo = new int[MAX_ELEMENTS];
     1608  for (int i=0;i<MAX_ELEMENTS;i++)
     1609    elementNo[i] = 0;
    16071610  char name[MAXSTRINGSIZE];
    16081611  strncpy(name, filename, MAXSTRINGSIZE-1);
     
    16111614  if (f == NULL) {
    16121615    DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open pdb output file:" << name << endl);
    1613     Free(&elementNo);
     1616    delete[](elementNo);
    16141617    return false;
    16151618  }
    16161619  fprintf(f, "# Created by MoleCuilder\n");
    16171620
    1618   Walker = mol->start;
    16191621  AtomNo = 0;
    1620   while (Walker->next != mol->end) {
    1621     Walker = Walker->next;
    1622     sprintf(name, "%2s%2d",Walker->type->symbol, elementNo[Walker->type->Z]);
    1623     elementNo[Walker->type->Z] = (elementNo[Walker->type->Z]+1) % 100;   // confine to two digits
     1622  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     1623    sprintf(name, "%2s%2d",(*iter)->type->symbol, elementNo[(*iter)->type->Z]);
     1624    elementNo[(*iter)->type->Z] = (elementNo[(*iter)->type->Z]+1) % 100;   // confine to two digits
    16241625    fprintf(f,
    16251626           "ATOM %6u %-4s %4s%c%4u    %8.3f%8.3f%8.3f%6.2f%6.2f      %4s%2s%2s\n",
    1626            Walker->nr,                /* atom serial number */
     1627           (*iter)->nr,                /* atom serial number */
    16271628           name,         /* atom name */
    16281629           mol->name,      /* residue name */
    16291630           'a'+(unsigned char)(AtomNo % 26),           /* letter for chain */
    16301631           0,         /* residue sequence number */
    1631            Walker->node->at(0),                 /* position X in Angstroem */
    1632            Walker->node->at(1),                 /* position Y in Angstroem */
    1633            Walker->node->at(2),                 /* position Z in Angstroem */
    1634            (double)Walker->type->Valence,         /* occupancy */
    1635            (double)Walker->type->NoValenceOrbitals,          /* temperature factor */
     1632           (*iter)->node->at(0),                 /* position X in Angstroem */
     1633           (*iter)->node->at(1),                 /* position Y in Angstroem */
     1634           (*iter)->node->at(2),                 /* position Z in Angstroem */
     1635           (double)(*iter)->type->Valence,         /* occupancy */
     1636           (double)(*iter)->type->NoValenceOrbitals,          /* temperature factor */
    16361637           "0",            /* segment identifier */
    1637            Walker->type->symbol,    /* element symbol */
     1638           (*iter)->type->symbol,    /* element symbol */
    16381639           "0");           /* charge */
    16391640    AtomNo++;
    16401641  }
    16411642  fclose(f);
    1642   Free(&elementNo);
     1643  delete[](elementNo);
    16431644
    16441645  return true;
     
    16531654bool config::SaveTREMOLO(const char * const filename, const molecule * const mol) const
    16541655{
    1655   atom *Walker = NULL;
    16561656  ofstream *output = NULL;
    16571657  stringstream * const fname = new stringstream;
     
    16661666
    16671667  // scan maximum number of neighbours
    1668   Walker = mol->start;
    16691668  int MaxNeighbours = 0;
    1670   while (Walker->next != mol->end) {
    1671     Walker = Walker->next;
    1672     const int count = Walker->ListOfBonds.size();
     1669  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     1670    const int count = (*iter)->ListOfBonds.size();
    16731671    if (MaxNeighbours < count)
    16741672      MaxNeighbours = count;
    16751673  }
    1676   *output << "# ATOMDATA Id name resName resSeq x=3 charge type neighbors=" << MaxNeighbours << endl;
    1677 
    1678   Walker = mol->start;
    1679   while (Walker->next != mol->end) {
    1680     Walker = Walker->next;
    1681     *output << Walker->nr << "\t";
    1682     *output << Walker->getName() << "\t";
     1674  *output << "# ATOMDATA Id name resName resSeq x=3 Charge type neighbors=" << MaxNeighbours << endl;
     1675
     1676  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     1677    *output << (*iter)->nr << "\t";
     1678    *output << (*iter)->getName() << "\t";
    16831679    *output << mol->name << "\t";
    16841680    *output << 0 << "\t";
    1685     *output << Walker->node->at(0) << "\t" << Walker->node->at(1) << "\t" << Walker->node->at(2) << "\t";
    1686     *output << static_cast<double>(Walker->type->Valence) << "\t";
    1687     *output << Walker->type->symbol << "\t";
    1688     for (BondList::iterator runner = Walker->ListOfBonds.begin(); runner != Walker->ListOfBonds.end(); runner++)
    1689       *output << (*runner)->GetOtherAtom(Walker)->nr << "\t";
    1690     for(int i=Walker->ListOfBonds.size(); i < MaxNeighbours; i++)
     1681    *output << (*iter)->node->at(0) << "\t" << (*iter)->node->at(1) << "\t" << (*iter)->node->at(2) << "\t";
     1682    *output << static_cast<double>((*iter)->type->Valence) << "\t";
     1683    *output << (*iter)->type->symbol << "\t";
     1684    for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++)
     1685      *output << (*runner)->GetOtherAtom(*iter)->nr << "\t";
     1686    for(int i=(*iter)->ListOfBonds.size(); i < MaxNeighbours; i++)
    16911687      *output << "-\t";
    16921688    *output << endl;
     
    17081704bool config::SaveTREMOLO(const char * const filename, const MoleculeListClass * const MolList) const
    17091705{
    1710   atom *Walker = NULL;
     1706  Info FunctionInfo(__func__);
    17111707  ofstream *output = NULL;
    17121708  stringstream * const fname = new stringstream;
     
    17231719  int MaxNeighbours = 0;
    17241720  for (MoleculeList::const_iterator MolWalker = MolList->ListOfMolecules.begin(); MolWalker != MolList->ListOfMolecules.end(); MolWalker++) {
    1725     Walker = (*MolWalker)->start;
    1726     while (Walker->next != (*MolWalker)->end) {
    1727       Walker = Walker->next;
    1728       const int count = Walker->ListOfBonds.size();
     1721    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     1722      const int count = (*iter)->ListOfBonds.size();
    17291723      if (MaxNeighbours < count)
    17301724        MaxNeighbours = count;
    17311725    }
    17321726  }
    1733   *output << "# ATOMDATA Id name resName resSeq x=3 charge type neighbors=" << MaxNeighbours << endl;
     1727  *output << "# ATOMDATA Id name resName resSeq x=3 Charge type neighbors=" << MaxNeighbours << endl;
    17341728
    17351729  // create global to local id map
    1736   int **LocalNotoGlobalNoMap = Calloc<int *>(MolList->ListOfMolecules.size(), "config::SaveTREMOLO - **LocalNotoGlobalNoMap");
     1730  map<int, int> LocalNotoGlobalNoMap;
    17371731  {
    1738     int MolCounter = 0;
    1739     int AtomNo = 0;
     1732    unsigned int MolCounter = 0;
     1733    int AtomNo = 1;
    17401734    for (MoleculeList::const_iterator MolWalker = MolList->ListOfMolecules.begin(); MolWalker != MolList->ListOfMolecules.end(); MolWalker++) {
    1741       LocalNotoGlobalNoMap[MolCounter] = Calloc<int>(MolList->CountAllAtoms(), "config::SaveTREMOLO - *LocalNotoGlobalNoMap[]");
    1742 
    1743       (*MolWalker)->SetIndexedArrayForEachAtomTo( LocalNotoGlobalNoMap[MolCounter], &atom::nr, IncrementalAbsoluteValue, &AtomNo);
    1744 
     1735      for(molecule::iterator AtomRunner = (*MolWalker)->begin(); AtomRunner != (*MolWalker)->end(); ++AtomRunner) {
     1736        LocalNotoGlobalNoMap.insert( pair<int,int>((*AtomRunner)->getId(), AtomNo++) );
     1737      }
    17451738      MolCounter++;
    17461739    }
     1740    ASSERT(MolCounter == MolList->ListOfMolecules.size(), "SaveTREMOLO: LocalNotoGlobalNoMap[] has not been correctly initialized for each molecule");
    17471741  }
    17481742
     
    17521746    int AtomNo = 0;
    17531747    for (MoleculeList::const_iterator MolWalker = MolList->ListOfMolecules.begin(); MolWalker != MolList->ListOfMolecules.end(); MolWalker++) {
    1754       Walker = (*MolWalker)->start;
    1755       while (Walker->next != (*MolWalker)->end) {
    1756         Walker = Walker->next;
    1757         *output << AtomNo+1 << "\t";
    1758         *output << Walker->getName() << "\t";
     1748      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     1749        *output << LocalNotoGlobalNoMap[ (*iter)->getId() ] << "\t";
     1750        *output << (*iter)->getName() << "\t";
    17591751        *output << (*MolWalker)->name << "\t";
    17601752        *output << MolCounter+1 << "\t";
    1761         *output << Walker->node->at(0) << "\t" << Walker->node->at(1) << "\t" << Walker->node->at(2) << "\t";
    1762         *output << (double)Walker->type->Valence << "\t";
    1763         *output << Walker->type->symbol << "\t";
    1764         for (BondList::iterator runner = Walker->ListOfBonds.begin(); runner != Walker->ListOfBonds.end(); runner++)
    1765           *output << LocalNotoGlobalNoMap[MolCounter][ (*runner)->GetOtherAtom(Walker)->nr ]+1 << "\t";
    1766         for(int i=Walker->ListOfBonds.size(); i < MaxNeighbours; i++)
     1753        *output << (*iter)->node->at(0) << "\t" << (*iter)->node->at(1) << "\t" << (*iter)->node->at(2) << "\t";
     1754        *output << (double)(*iter)->type->Valence << "\t";
     1755        *output << (*iter)->type->symbol << "\t";
     1756        for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++)
     1757          *output << LocalNotoGlobalNoMap[ (*runner)->GetOtherAtom((*iter))->getId() ] << "\t";
     1758        for(int i=(*iter)->ListOfBonds.size(); i < MaxNeighbours; i++)
    17671759          *output << "-\t";
    17681760        *output << endl;
     
    17781770  delete(output);
    17791771  delete(fname);
    1780   for(size_t i=0;i<MolList->ListOfMolecules.size(); i++)
    1781     Free(&LocalNotoGlobalNoMap[i]);
    1782   Free(&LocalNotoGlobalNoMap);
    17831772
    17841773  return true;
     
    18081797  if (output == NULL)
    18091798    strcpy(filename,"main_pcp_linux");
    1810   Log() << Verbose(0) << "Saving as pdb input ";
     1799  Log() << Verbose(0) << "Saving as pdb input ... " << endl;
    18111800  if (SavePDB(filename, molecules))
    1812     Log() << Verbose(0) << "done." << endl;
     1801    Log() << Verbose(0) << "\t... done." << endl;
    18131802  else
    1814     Log() << Verbose(0) << "failed." << endl;
     1803    Log() << Verbose(0) << "\t... failed." << endl;
    18151804
    18161805  // then save as tremolo data file
     
    18191808  if (output == NULL)
    18201809    strcpy(filename,"main_pcp_linux");
    1821   Log() << Verbose(0) << "Saving as tremolo data input ";
     1810  Log() << Verbose(0) << "Saving as tremolo data input ... " << endl;
    18221811  if (SaveTREMOLO(filename, molecules))
    1823     Log() << Verbose(0) << "done." << endl;
     1812    Log() << Verbose(0) << "\t... done." << endl;
    18241813  else
    1825     Log() << Verbose(0) << "failed." << endl;
     1814    Log() << Verbose(0) << "\t... failed." << endl;
    18261815
    18271816  // translate each to its center and merge all molecules in MoleculeListClass into this molecule
     
    18591848  output.close();
    18601849  output.clear();
    1861   Log() << Verbose(0) << "Saving of config file ";
     1850  Log() << Verbose(0) << "Saving of config file ... " << endl;
    18621851  if (Save(filename, periode, mol))
    1863     Log() << Verbose(0) << "successful." << endl;
     1852    Log() << Verbose(0) << "\t... successful." << endl;
    18641853  else
    1865     Log() << Verbose(0) << "failed." << endl;
     1854    Log() << Verbose(0) << "\t... failed." << endl;
    18661855
    18671856  // and save to xyz file
     
    18761865    output.open(filename, ios::trunc);
    18771866  }
    1878   Log() << Verbose(0) << "Saving of XYZ file ";
     1867  Log() << Verbose(0) << "Saving of XYZ file ... " << endl;
    18791868  if (mol->MDSteps <= 1) {
    18801869    if (mol->OutputXYZ(&output))
    1881       Log() << Verbose(0) << "successful." << endl;
     1870      Log() << Verbose(0) << "\t... successful." << endl;
    18821871    else
    1883       Log() << Verbose(0) << "failed." << endl;
     1872      Log() << Verbose(0) << "\t... failed." << endl;
    18841873  } else {
    18851874    if (mol->OutputTrajectoriesXYZ(&output))
    1886       Log() << Verbose(0) << "successful." << endl;
     1875      Log() << Verbose(0) << "\t... successful." << endl;
    18871876    else
    1888       Log() << Verbose(0) << "failed." << endl;
     1877      Log() << Verbose(0) << "\t... failed." << endl;
    18891878  }
    18901879  output.close();
     
    18961885  if (output == NULL)
    18971886    strcpy(filename,"main_pcp_linux");
    1898   Log() << Verbose(0) << "Saving as mpqc input ";
     1887  Log() << Verbose(0) << "Saving as mpqc input .. " << endl;
    18991888  if (SaveMPQC(filename, mol))
    1900     Log() << Verbose(0) << "done." << endl;
     1889    Log() << Verbose(0) << "\t... done." << endl;
    19011890  else
    1902     Log() << Verbose(0) << "failed." << endl;
     1891    Log() << Verbose(0) << "\t... failed." << endl;
    19031892
    19041893  if (!strcmp(configpath, GetDefaultPath())) {
     
    19381927  char *dummy1 = NULL;
    19391928  char *dummy = NULL;
    1940   char * const free_dummy = Malloc<char>(256, "config::ParseForParameter: *free_dummy");    // pointers in the line that is read in per step
     1929  char free_dummy[MAXSTRINGSIZE];    // pointers in the line that is read in per step
    19411930  dummy1 = free_dummy;
    19421931
     
    19541943      if (file->eof()) {
    19551944        if ((critical) && (found == 0)) {
    1956           Free(free_dummy);
    19571945          //Error(InitReading, name);
    19581946          fprintf(stderr,"Error:InitReading, critical %s not found\n", name);
     
    19621950          file->clear();
    19631951          file->seekg(file_position, ios::beg);  // rewind to start position
    1964           Free(free_dummy);
    19651952          return 0;
    19661953        }
     
    19931980        dummy = strchr(dummy1, '\n'); // set on line end then (whole line = keyword)
    19941981        //fprintf(stderr,"Error: Cannot find tabs or spaces on line %i in search for %s\n", line, name);
    1995         //Free((void **)&free_dummy);
    19961982        //Error(FileOpenParams, NULL);
    19971983      } else {
     
    20142000              if (file->eof()) {
    20152001                if ((critical) && (found == 0)) {
    2016                   Free(free_dummy);
    20172002                  //Error(InitReading, name);
    20182003                  fprintf(stderr,"Error:InitReading, critical %s not found\n", name);
     
    20222007                  file->clear();
    20232008                  file->seekg(file_position, ios::beg);  // rewind to start position
    2024                   Free(free_dummy);
    20252009                  return 0;
    20262010                }
     
    20632047                  if (critical) {
    20642048                    if (verbose) fprintf(stderr,"Error: EoL at %i and still missing %i value(s) for parameter %s\n", line, yth-j, name);
    2065                     Free(free_dummy);
    20662049                    //return 0;
    20672050                    exit(255);
     
    20712054                    file->clear();
    20722055                    file->seekg(file_position, ios::beg);  // rewind to start position
    2073                     Free(free_dummy);
    20742056                    return 0;
    20752057                  }
     
    20842066                  file->seekg(file_position, ios::beg);  // rewind to start position
    20852067                }
    2086                 Free(free_dummy);
    20872068                return 0;
    20882069              }
     
    21402121  if ((type >= row_int) && (verbose))
    21412122    fprintf(stderr,"\n");
    2142   Free(free_dummy);
    21432123  if (!sequential) {
    21442124    file->clear();
     
    22212201        dummy = strchr(dummy1, '\n'); // set on line end then (whole line = keyword)
    22222202        //fprintf(stderr,"Error: Cannot find tabs or spaces on line %i in search for %s\n", line, name);
    2223         //Free(&free_dummy);
    22242203        //Error(FileOpenParams, NULL);
    22252204      } else {
  • src/datacreator.cpp

    r0c7ed8 r1dc9ec  
    66
    77//============================ INCLUDES ===========================
     8
     9#include "Helpers/MemDebug.hpp"
    810
    911#include "datacreator.hpp"
  • src/element.cpp

    r0c7ed8 r1dc9ec  
    44 *
    55 */
     6
     7#include "Helpers/MemDebug.hpp"
    68
    79#include <iomanip>
  • src/elements.db

    • Property mode changed from 100755 to 100644
    r0c7ed8 r1dc9ec  
    22#Element        Name    Symbol  Period  Group   Block   Atomic  Number  AtomicWeight    Covalent        Radius  vdW     Radius
    33Hydrogen        H       1       1       s       1       1.008   0.23    1.09
    4 Helium  He      1       18      p       2       4.003   1.50    1.40
     4Helium  He      1       18      p       2       4.003   1.5     1.4
    55Lithium Li      2       1       s       3       6.941   0.68    1.82
    6 Beryllium       Be      2       2       s       4       9.012   0.35    2.00
    7 Boron   B       2       13      p       5       10.811  0.83    2.00
    8 Carbon  C       2       14      p       6       12.011  0.68    1.70
     6Beryllium       Be      2       2       s       4       9.012   0.35    2
     7Boron   B       2       13      p       5       10.811  0.83    2
     8Carbon  C       2       14      p       6       12.011  0.68    1.7
    99Nitrogen        N       2       15      p       7       14.007  0.68    1.55
    1010Oxygen  O       2       16      p       8       15.999  0.68    1.52
    1111Fluorine        F       2       17      p       9       18.998  0.64    1.47
    12 Neon    Ne      2       18      p       10      20.180  1.50    1.54
     12Neon    Ne      2       18      p       10      20.18   1.5     1.54
    1313Sodium  Na      3       1       s       11      22.991  0.97    2.27
    14 Magnesium       Mg      3       2       s       12      24.305  1.10    1.73
    15 Aluminium       Al      3       13      p       13      26.982  1.35    2.00
    16 Silicon Si      3       14      p       14      28.086  1.20    2.10
    17 Phosphorus      P       3       15      p       15      30.974  1.05    1.80
    18 Sulphur S       3       16      p       16      32.066  1.02    1.80
     14Magnesium       Mg      3       2       s       12      24.305  1.1     1.73
     15Aluminium       Al      3       13      p       13      26.982  1.35    2
     16Silicon Si      3       14      p       14      28.086  1.2     2.1
     17Phosphorus      P       3       15      p       15      30.974  1.05    1.8
     18Sulphur S       3       16      p       16      32.066  1.02    1.8
    1919Chlorine        Cl      3       17      p       17      35.453  0.99    1.75
    2020Argon   Ar      3       18      p       18      39.948  1.51    1.88
    2121Potassium       K       4       1       s       19      39.098  1.33    2.75
    22 Calcium Ca      4       2       s       20      40.078  0.99    2.00
    23 Scandium        Sc      4       3       d       21      44.956  1.44    2.00
    24 Titanium        Ti      4       4       d       22      47.867  1.47    2.00
    25 Vanadium        V       4       5       d       23      50.942  1.33    2.00
    26 Chromium        Cr      4       6       d       24      51.996  1.35    2.00
    27 Manganese       Mn      4       7       d       25      54.938  1.35    2.00
    28 Iron    Fe      4       8       d       26      55.845  1.34    2.00
    29 Cobalt  Co      4       9       d       27      58.933  1.33    2.00
    30 Nickel  Ni      4       10      d       28      58.693  1.50    1.63
    31 Copper  Cu      4       11      d       29      63.546  1.52    1.40
    32 Zinc    Zn      4       12      d       30      65.390  1.45    1.39
     22Calcium Ca      4       2       s       20      40.078  0.99    2
     23Scandium        Sc      4       3       d       21      44.956  1.44    2
     24Titanium        Ti      4       4       d       22      47.867  1.47    2
     25Vanadium        V       4       5       d       23      50.942  1.33    2
     26Chromium        Cr      4       6       d       24      51.996  1.35    2
     27Manganese       Mn      4       7       d       25      54.938  1.35    2
     28Iron    Fe      4       8       d       26      55.845  1.34    2
     29Cobalt  Co      4       9       d       27      58.933  1.33    2
     30Nickel  Ni      4       10      d       28      58.693  1.5     1.63
     31Copper  Cu      4       11      d       29      63.546  1.52    1.4
     32Zinc    Zn      4       12      d       30      65.39   1.45    1.39
    3333Gallium Ga      4       13      p       31      69.723  1.22    1.87
    34 Germanium       Ge      4       14      p       32      72.610  1.17    2.00
     34Germanium       Ge      4       14      p       32      72.61   1.17    2
    3535Arsenic As      4       15      p       33      74.922  1.21    1.85
    36 Selenium        Se      4       16      p       34      78.960  1.22    1.90
     36Selenium        Se      4       16      p       34      78.96   1.22    1.9
    3737Bromine Br      4       17      p       35      79.904  1.21    1.85
    38 Krypton Kr      4       18      p       36      83.800  1.50    2.02
    39 Rubidium        Rb      5       1       s       37      85.468  1.47    2.00
    40 Strontium       Sr      5       2       s       38      87.620  1.12    2.00
    41 Yttrium Y       5       3       d       39      88.906  1.78    2.00
    42 Zirconium       Zr      5       4       d       40      91.224  1.56    2.00
    43 Niobium Nb      5       5       d       41      92.906  1.48    2.00
    44 Molybdenum      Mo      5       6       d       42      95.940  1.47    2.00
    45 Technetium      Tc      5       7       d       43      98      1.35    2.00
    46 Ruthenium       Ru      5       8       d       44      101.070 1.40    2.00
    47 Rhodium Rh      5       9       d       45      102.906 1.45    2.00
    48 Palladium       Pd      5       10      d       46      106.420 1.50    1.63
     38Krypton Kr      4       18      p       36      83.8    1.5     2.02
     39Rubidium        Rb      5       1       s       37      85.468  1.47    2
     40Strontium       Sr      5       2       s       38      87.62   1.12    2
     41Yttrium Y       5       3       d       39      88.906  1.78    2
     42Zirconium       Zr      5       4       d       40      91.224  1.56    2
     43Niobium Nb      5       5       d       41      92.906  1.48    2
     44Molybdenum      Mo      5       6       d       42      95.94   1.47    2
     45Technetium      Tc      5       7       d       43      98      1.35    2
     46Ruthenium       Ru      5       8       d       44      101.07  1.4     2
     47Rhodium Rh      5       9       d       45      102.906 1.45    2
     48Palladium       Pd      5       10      d       46      106.42  1.5     1.63
    4949Silver  Ag      5       11      d       47      107.868 1.59    1.72
    5050Cadmium Cd      5       12      d       48      112.411 1.69    1.58
    5151Indium  In      5       13      p       49      114.818 1.63    1.93
    5252Tin     Sn      5       14      p       50      118.71  1.46    2.17
    53 Antimony        Sb      5       15      p       51      121.760 1.46    2.00
    54 Tellurium       Te      5       16      p       52      127.600 1.47    2.06
    55 Iodine  I       5       17      p       53      126.904 1.40    1.98
    56 Xenon   Xe      5       18      p       54      131.290 1.50    2.16
    57 Caesium Cs      6       1       s       55      132.905 1.67    2.00
    58 Barium  Ba      6       2       s       56      137.327 1.34    2.00
    59 Lutetium        Lu      6       3       d       71      174.967 1.72    2.00
    60 Hafnium Hf      6       4       d       72      178.490 1.57    2.00
    61 Tantalum        Ta      6       5       d       73      180.948 1.43    2.00
    62 Tungsten        W       6       6       d       74      183.840 1.37    2.00
    63 Rhenium Re      6       7       d       75      186.207 1.35    2.00
    64 Osmium  Os      6       8       d       76      190.230 1.37    2.00
    65 Iridium Ir      6       9       d       77      192.217 1.32    2.00
    66 Platinum        Pt      6       10      d       78      195.078 1.50    1.72
    67 Gold    Au      6       11      d       79      196.967 1.50    1.66
    68 Mercury Hg      6       12      d       80      200.590 1.70    1.55
     53Antimony        Sb      5       15      p       51      121.76  1.46    2
     54Tellurium       Te      5       16      p       52      127.6   1.47    2.06
     55Iodine  I       5       17      p       53      126.904 1.4     1.98
     56Xenon   Xe      5       18      p       54      131.29  1.5     2.16
     57Caesium Cs      6       1       s       55      132.905 1.67    2
     58Barium  Ba      6       2       s       56      137.327 1.34    2
     59Lanthanum       La      6Lan    19      f       57      138.906 1.87    2
     60Cerium  Ce      6Lan    19      f       58      140.116 1.83    2
     61Praseodymium    Pr      6Lan    19      f       59      140.908 1.82    2
     62Neodymium       Nd      6Lan    19      f       60      144.24  1.81    2
     63Promethium      Pm      6Lan    19      f       61      145     1.8     2
     64Samarium        Sm      6Lan    19      f       62      150.36  1.8     2
     65Europium        Eu      6Lan    19      f       63      151.964 1.99    2
     66Gadolinium      Gd      6Lan    19      f       64      157.25  1.79    2
     67Terbium Tb      6Lan    19      f       65      158.925 1.76    2
     68Dysprosium      Dy      6Lan    19      f       66      162.5   1.75    2
     69Holmium Ho      6Lan    19      f       67      164.93  1.74    2
     70Erbium  Er      6Lan    19      f       68      167.26  1.73    2
     71Thulium Tm      6Lan    19      f       69      168.934 1.72    2
     72Ytterbium       Yb      6Lan    19      f       70      173.04  1.94    2
     73Lutetium        Lu      6       3       d       71      174.967 1.72    2
     74Hafnium Hf      6       4       d       72      178.49  1.57    2
     75Tantalum        Ta      6       5       d       73      180.948 1.43    2
     76Tungsten        W       6       6       d       74      183.84  1.37    2
     77Rhenium Re      6       7       d       75      186.207 1.35    2
     78Osmium  Os      6       8       d       76      190.23  1.37    2
     79Iridium Ir      6       9       d       77      192.217 1.32    2
     80Platinum        Pt      6       10      d       78      195.078 1.5     1.72
     81Gold    Au      6       11      d       79      196.967 1.5     1.66
     82Mercury Hg      6       12      d       80      200.59  1.7     1.55
    6983Thallium        Tl      6       13      p       81      204.383 1.55    1.96
    70 Lead    Pb      6       14      p       82      207.200 1.54    2.02
    71 Bismuth Bi      6       15      p       83      208.980 1.54    2.00
    72 Polonium        Po      6       16      p       84      210     1.68    2.00
    73 Astatine        At      6       17      p       85      210     1.21    2.00
    74 Radon   Rn      6       18      p       86      222     1.50    2.00
    75 Cerium  Ce      6Lan    19      f       58      140.116 1.83    2.00
    76 Dysprosium      Dy      6Lan    19      f       66      162.500 1.75    2.00
    77 Erbium  Er      6Lan    19      f       68      167.260 1.73    2.00
    78 Europium        Eu      6Lan    19      f       63      151.964 1.99    2.00
    79 Gadolinium      Gd      6Lan    19      f       64      157.250 1.79    2.00
    80 Holmium Ho      6Lan    19      f       67      164.930 1.74    2.00
    81 Lanthanum       La      6Lan    19      f       57      138.906 1.87    2.00
    82 Neodymium       Nd      6Lan    19      f       60      144.240 1.81    2.00
    83 Promethium      Pm      6Lan    19      f       61      145     1.80    2.00
    84 Praseodymium    Pr      6Lan    19      f       59      140.908 1.82    2.00
    85 Samarium        Sm      6Lan    19      f       62      150.360 1.80    2.00
    86 Terbium Tb      6Lan    19      f       65      158.925 1.76    2.00
    87 Thulium Tm      6Lan    19      f       69      168.934 1.72    2.00
    88 Ytterbium       Yb      6Lan    19      f       70      173.040 1.94    2.00
    89 Francium        Fr      7       1       s       87      223     1.50    2.00
    90 Radium  Ra      7       2       s       88      226     1.90    2.00
    91 Lawrencium      Lr      7       3       d       103     262     1.50    2.00
    92 Rutherfordium   Rf      7       4       d       104     261     1.50    2.00
    93 Dubnium Db      7       5       d       105     262     1.50    2.00
    94 Seaborgium      Sg      7       6       d       106     266     1.50    2.00
    95 Bohrium Bh      7       7       d       107     264     1.50    2.00
    96 Hassium Hs      7       8       d       108     269     1.50    2.00
    97 Meitnerium      Mt      7       9       d       109     268     1.50    2.00
    98 Darmstadtium    Ds      7       10      d       110     271     1.50    2.00
    99 Actinium        Ac      7Act    20      f       89      227     1.88    2.00
    100 Americium       Am      7Act    20      f       95      243     1.51    2.00
    101 Berkelium       Bk      7Act    20      f       97      247     1.54    2.00
    102 Californium     Cf      7Act    20      f       98      251     1.83    2.00
    103 Curium  Cm      7Act    20      f       96      247     0.99    2.00
    104 Einsteinium     Es      7Act    20      f       99      252     1.50    2.00
    105 Fermium Fm      7Act    20      f       100     257     1.50    2.00
    106 Mendelevium     Md      7Act    20      f       101     258     1.50    2.00
    107 Nobelium        No      7Act    20      f       102     259     1.50    2.00
    108 Neptunium       Np      7Act    20      f       93      237     1.55    2.00
    109 Protactinium    Pa      7Act    20      f       91      231.036 1.61    2.00
    110 Plutonium       Pu      7Act    20      f       94      244     1.53    2.00
    111 Thorium Th      7Act    20      f       90      232.038 1.79    2.00
     84Lead    Pb      6       14      p       82      207.2   1.54    2.02
     85Bismuth Bi      6       15      p       83      208.98  1.54    2
     86Polonium        Po      6       16      p       84      210     1.68    2
     87Astatine        At      6       17      p       85      210     1.21    2
     88Radon   Rn      6       18      p       86      222     1.5     2
     89Francium        Fr      7       1       s       87      223     1.5     2
     90Radium  Ra      7       2       s       88      226     1.9     2
     91Actinium        Ac      7Act    20      f       89      227     1.88    2
     92Thorium Th      7Act    20      f       90      232.038 1.79    2
     93Protactinium    Pa      7Act    20      f       91      231.036 1.61    2
    11294Uranium U       7Act    20      f       92      238.029 1.58    1.86
     95Neptunium       Np      7Act    20      f       93      237     1.55    2
     96Plutonium       Pu      7Act    20      f       94      244     1.53    2
     97Americium       Am      7Act    20      f       95      243     1.51    2
     98Curium  Cm      7Act    20      f       96      247     0.99    2
     99Berkelium       Bk      7Act    20      f       97      247     1.54    2
     100Californium     Cf      7Act    20      f       98      251     1.83    2
     101Einsteinium     Es      7Act    20      f       99      252     1.5     2
     102Fermium Fm      7Act    20      f       100     257     1.5     2
     103Mendelevium     Md      7Act    20      f       101     258     1.5     2
     104Nobelium        No      7Act    20      f       102     259     1.5     2
     105Lawrencium      Lr      7       3       d       103     262     1.5     2
     106Rutherfordium   Rf      7       4       d       104     261     1.5     2
     107Dubnium Db      7       5       d       105     262     1.5     2
     108Seaborgium      Sg      7       6       d       106     266     1.5     2
     109Bohrium Bh      7       7       d       107     264     1.5     2
     110Hassium Hs      7       8       d       108     269     1.5     2
     111Meitnerium      Mt      7       9       d       109     268     1.5     2
     112Darmstadtium    Ds      7       10      d       110     271     1.5     2
  • src/ellipsoid.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include <gsl/gsl_multimin.h>
  • src/errorlogger.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: metzler
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include <fstream>
  • src/graph.cpp

    r0c7ed8 r1dc9ec  
    44 *
    55 */
     6
     7#include "Helpers/MemDebug.hpp"
    68
    79using namespace std;
  • src/gslmatrix.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810using namespace std;
  • src/gslvector.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include <cassert>
  • src/helpers.cpp

    r0c7ed8 r1dc9ec  
    44 */
    55
     6#include "Helpers/MemDebug.hpp"
    67
    78#include "helpers.hpp"
     
    5859int CountLinesinFile(ifstream &InputFile)
    5960{
    60   char *buffer = Malloc<char>(MAXSTRINGSIZE, "CountLinesinFile: *buffer");
     61  char *buffer = new char[MAXSTRINGSIZE];
    6162  int lines=0;
    6263
     
    7071  }
    7172  InputFile.seekg(PositionMarker, ios::beg);
    72   Free(&buffer);
     73  delete[](buffer);
    7374  return lines;
    7475};
     
    9091  }
    9192  // allocate string
    92   returnstring = Malloc<char>(order + 2, "FixedDigitNumber: *returnstring");
     93  returnstring = new char[order + 2];
    9394  // terminate  and fill string array from end backward
    9495  returnstring[order] = '\0';
     
    122123double * ReturnFullMatrixforSymmetric(const double * const symm)
    123124{
    124   double *matrix = Malloc<double>(NDIM * NDIM, "molecule::ReturnFullMatrixforSymmetric: *matrix");
     125  double *matrix = new double[NDIM * NDIM];
    125126  matrix[0] = symm[0];
    126127  matrix[1] = symm[1];
     
    140141double * InverseMatrix( const double * const A)
    141142{
    142   double *B = Malloc<double>(NDIM * NDIM, "Vector::InverseMatrix: *B");
     143  double *B = new double[NDIM * NDIM];
    143144  double detA = RDET3(A);
    144145  double detAReci;
     
    180181
    181182
    182 /** Allocates a memory range using malloc().
    183  * Prints the provided error message in case of a failure.
    184  *
    185  * \param number of memory slices of type X to allocate
    186  * \param failure message which is printed if the allocation fails
    187  * \return pointer to the allocated memory range, will be NULL if a failure occurred
    188  */
    189 template <> char* Malloc<char>(size_t size, const char* output)
    190 {
    191   char* buffer = NULL;
    192   buffer = (char*) malloc(sizeof(char) * (size + 1));
    193   for (size_t i = size; i--;)
    194     buffer[i] = (i % 2 == 0) ? 'p': 'c';
    195   buffer[size] = '\0';
    196 
    197   if (buffer != NULL) {
    198     MemoryUsageObserver::getInstance()->addMemory(buffer, size);
    199   } else {
    200     Log() << Verbose(0) << "Malloc for datatype " << typeid(char).name()
    201       << " failed - pointer is NULL: " << output << endl;
    202   }
    203 
    204   return buffer;
    205 };
    206 
    207183/**
    208  * Frees all memory registered by the memory observer and calls exit(225) afterwards.
     184 * Calls exit(255).
    209185 */
    210186void performCriticalExit() {
    211   map<void*, size_t> pointers = MemoryUsageObserver::getInstance()->getPointersToAllocatedMemory();
    212   for (map<void*, size_t>::iterator runner = pointers.begin(); runner != pointers.end(); runner++) {
    213     Free(((void**) &runner->first));
    214   }
    215 
    216187  exit(255);
    217188}
  • src/helpers.hpp

    r0c7ed8 r1dc9ec  
    9797
    9898  if (LookupTable != NULL) {
    99     DoLog(0) && (Log() << Verbose(0) << "Pointer for Lookup table is not NULL! Aborting ..." <<endl);
     99    DoeLog(0) && (eLog() << Verbose(0) << "Pointer for Lookup table is not NULL! Aborting ..." <<endl);
    100100    return false;
    101101  }
     
    110110  }
    111111  if (count <= 0) {
    112     DoLog(0) && (Log() << Verbose(0) << "Count of lookup list is 0 or less." << endl);
     112    DoeLog(1) && (eLog() << Verbose(1) << "Count of lookup list is 0 or less." << endl);
    113113    return false;
    114114  }
    115115
    116116  // allocate and fill
    117   LookupTable = Calloc<T*>(count, "CreateFatherLookupTable - **LookupTable");
     117  LookupTable = new T*[count];
    118118  if (LookupTable == NULL) {
    119119    DoeLog(0) && (eLog()<< Verbose(0) << "LookupTable memory allocation failed!" << endl);
     
    129129        LookupTable[AtomNo] = Walker;
    130130      } else {
    131         DoLog(0) && (Log() << Verbose(0) << "Walker " << *Walker << " exceeded range of nuclear ids [0, " << count << ")." << endl);
     131        DoeLog(2) && (eLog() << Verbose(2) << "Walker " << *Walker << " exceeded range of nuclear ids [0, " << count << ")." << endl);
    132132        status = false;
    133133        break;
     
    138138  return status;
    139139};
     140
    140141
    141142/** Frees a two-dimensional array.
  • src/info.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "info.hpp"
  • src/joiner.cpp

    r0c7ed8 r1dc9ec  
    77
    88//============================ INCLUDES ===========================
     9
     10#include "Helpers/MemDebug.hpp"
    911
    1012#include <cstring>
     
    5860    return 1;
    5961  } else {
    60     dir = Malloc<char>(strlen(argv[2]) + 2, "main: *dir");
     62    dir = new char[strlen(argv[2]) + 2];
    6163    strcpy(dir, "/");
    6264    strcat(dir, argv[2]);
     
    243245  // exit
    244246  delete(periode);
    245   Free(&dir);
     247  delete[](dir);
    246248  DoLog(0) && (Log() << Verbose(0) << "done." << endl);
    247249  return 0;
  • src/leastsquaremin.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include <iostream>
  • src/linearsystemofequations.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "defs.hpp"
  • src/linkedcell.cpp

    r0c7ed8 r1dc9ec  
    55 */
    66
     7#include "Helpers/MemDebug.hpp"
    78
    89#include "atom.hpp"
  • src/lists.hpp

    r0c7ed8 r1dc9ec  
    134134};
    135135
    136 /** Returns the first marker in a chain list.
    137  * \param *me one arbitrary item in chain list
    138  * \return poiner to first marker
    139  */
    140 template <typename X> X *GetFirst(X *me)
    141 {
    142   X *Binder = me;
    143   while(Binder->previous != 0)
    144     Binder = Binder->previous;
    145   return Binder;
    146 };
    147 
    148 /** Returns the last marker in a chain list.
    149  * \param *me one arbitrary item in chain list
    150  * \return poiner to last marker
    151  */
    152 template <typename X> X *GetLast(X *me)
    153 {
    154   X *Binder = me;
    155   while(Binder->next != 0)
    156     Binder = Binder->next;
    157   return Binder;
    158 };
    159 
    160136#endif /* LISTS_HPP_ */
  • src/log.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: metzler
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "logger.hpp"
  • src/logger.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: metzler
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include <fstream>
  • src/memoryusageobserver.cpp

    r0c7ed8 r1dc9ec  
    44 * This class represents a Singleton for observing memory usage.
    55 */
     6
     7#include "Helpers/MemDebug.hpp"
    68
    79#include <cstdlib>
  • src/molecule.cpp

    r0c7ed8 r1dc9ec  
    44 *
    55 */
     6
     7#include "Helpers/MemDebug.hpp"
    68
    79#include <cstring>
     
    3537 * Initialises molecule list with correctly referenced start and end, and sets molecule::last_atom to zero.
    3638 */
    37 molecule::molecule(const periodentafel * const teil) : elemente(teil), start(World::getInstance().createAtom()), end(World::getInstance().createAtom()),
    38   first(new bond(start, end, 1, -1)), last(new bond(start, end, 1, -1)), MDSteps(0), AtomCount(0),
    39   BondCount(0), ElementCount(0), NoNonHydrogen(0), NoNonBonds(0), NoCyclicBonds(0), BondDistance(0.),
    40   ActiveFlag(false), IndexNr(-1),
    41   formula(this,boost::bind(&molecule::calcFormula,this)),
    42   last_atom(0),
    43   InternalPointer(start)
    44 {
    45   // init atom chain list
    46   start->father = NULL;
    47   end->father = NULL;
    48   link(start,end);
    49 
    50   // init bond chain list
    51   link(first,last);
     39molecule::molecule(const periodentafel * const teil) :
     40  Observable("molecule"),
     41  elemente(teil),  MDSteps(0),  BondCount(0), ElementCount(0), NoNonHydrogen(0), NoNonBonds(0),
     42  NoCyclicBonds(0), BondDistance(0.),  ActiveFlag(false), IndexNr(-1),
     43  formula(this,boost::bind(&molecule::calcFormula,this),"formula"),
     44  AtomCount(this,boost::bind(&molecule::doCountAtoms,this),"AtomCount"), last_atom(0),  InternalPointer(begin())
     45{
    5246
    5347  // other stuff
    5448  for(int i=MAX_ELEMENTS;i--;)
    5549    ElementsInMolecule[i] = 0;
    56   strcpy(name,World::getInstance().getDefaultName());
     50  strcpy(name,World::getInstance().getDefaultName().c_str());
    5751};
    5852
     
    6761{
    6862  CleanupMolecule();
    69   delete(first);
    70   delete(last);
    71   end->getWorld()->destroyAtom(end);
    72   start->getWorld()->destroyAtom(start);
    7363};
    7464
     
    8171const std::string molecule::getName(){
    8272  return std::string(name);
     73}
     74
     75int molecule::getAtomCount() const{
     76  return *AtomCount;
    8377}
    8478
     
    10498  stringstream sstr;
    10599  periodentafel *periode = World::getInstance().getPeriode();
    106   for(atom *Walker = start; Walker != end; Walker = Walker->next) {
    107     counts[Walker->type->getNumber()]++;
     100  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     101    counts[(*iter)->type->getNumber()]++;
    108102  }
    109103  std::map<atomicNumber_t,unsigned int>::reverse_iterator iter;
     
    115109}
    116110
     111/************************** Access to the List of Atoms ****************/
     112
     113
     114molecule::iterator molecule::begin(){
     115  return molecule::iterator(atoms.begin(),this);
     116}
     117
     118molecule::const_iterator molecule::begin() const{
     119  return atoms.begin();
     120}
     121
     122molecule::iterator molecule::end(){
     123  return molecule::iterator(atoms.end(),this);
     124}
     125
     126molecule::const_iterator molecule::end() const{
     127  return atoms.end();
     128}
     129
     130bool molecule::empty() const
     131{
     132  return (begin() == end());
     133}
     134
     135size_t molecule::size() const
     136{
     137  size_t counter = 0;
     138  for (molecule::const_iterator iter = begin(); iter != end (); ++iter)
     139    counter++;
     140  return counter;
     141}
     142
     143molecule::const_iterator molecule::erase( const_iterator loc )
     144{
     145  molecule::const_iterator iter = loc;
     146  iter--;
     147  atom* atom = *loc;
     148  atoms.erase( loc );
     149  atom->removeFromMolecule();
     150  return iter;
     151}
     152
     153molecule::const_iterator molecule::erase( atom * key )
     154{
     155  cout << "trying to erase atom" << endl;
     156  molecule::const_iterator iter = find(key);
     157  if (iter != end()){
     158    atoms.erase( iter++ );
     159    key->removeFromMolecule();
     160  }
     161  return iter;
     162}
     163
     164molecule::const_iterator molecule::find ( atom * key ) const
     165{
     166  return atoms.find( key );
     167}
     168
     169pair<molecule::iterator,bool> molecule::insert ( atom * const key )
     170{
     171  pair<atomSet::iterator,bool> res = atoms.insert(key);
     172  return pair<iterator,bool>(iterator(res.first,this),res.second);
     173}
     174
     175bool molecule::containsAtom(atom* key){
     176  return atoms.count(key);
     177}
    117178
    118179/** Adds given atom \a *pointer from molecule list.
     
    123184bool molecule::AddAtom(atom *pointer)
    124185{
    125   bool retval = false;
    126186  OBSERVE;
    127187  if (pointer != NULL) {
    128188    pointer->sort = &pointer->nr;
    129     pointer->nr = last_atom++;  // increase number within molecule
    130     AtomCount++;
    131189    if (pointer->type != NULL) {
    132190      if (ElementsInMolecule[pointer->type->Z] == 0)
     
    141199      }
    142200    }
    143     retval = add(pointer, end);
    144   }
    145   return retval;
     201    insert(pointer);
     202    pointer->setMolecule(this);
     203  }
     204  return true;
    146205};
    147206
     
    157216  if (pointer != NULL) {
    158217    atom *walker = pointer->clone();
    159     stringstream sstr;
    160     sstr << pointer->getName();
    161     walker->setName(sstr.str());
     218    walker->setName(pointer->getName());
    162219    walker->nr = last_atom++;  // increase number within molecule
    163     add(walker, end);
     220    insert(walker);
    164221    if ((pointer->type != NULL) && (pointer->type->Z != 1))
    165222      NoNonHydrogen++;
    166     AtomCount++;
    167223    retval=walker;
    168224  }
     
    242298    Orthovector1.MatrixMultiplication(matrix);
    243299    InBondvector -= Orthovector1; // subtract just the additional translation
    244     Free(&matrix);
     300    delete[](matrix);
    245301    bondlength = InBondvector.Norm();
    246302//    Log() << Verbose(4) << "Corrected InBondvector is now: ";
     
    251307  InBondvector.Normalize();
    252308  // get typical bond length and store as scale factor for later
     309  ASSERT(TopOrigin->type != NULL, "AddHydrogenReplacementAtom: element of TopOrigin is not given.");
    253310  BondRescale = TopOrigin->type->HBondDistance[TopBond->BondDegree-1];
    254311  if (BondRescale == -1) {
     
    472529      break;
    473530  }
    474   Free(&matrix);
     531  delete[](matrix);
    475532
    476533//  Log() << Verbose(3) << "End of AddHydrogenReplacementAtom." << endl;
     
    555612
    556613  // copy all bonds
    557   bond *Binder = first;
     614  bond *Binder = NULL;
    558615  bond *NewBond = NULL;
    559   while(Binder->next != last) {
    560     Binder = Binder->next;
    561 
    562     // get the pendant atoms of current bond in the copy molecule
    563     copy->ActOnAllAtoms( &atom::EqualsFather, (const atom *)Binder->leftatom, (const atom **)&LeftAtom );
    564     copy->ActOnAllAtoms( &atom::EqualsFather, (const atom *)Binder->rightatom, (const atom **)&RightAtom );
    565 
    566     NewBond = copy->AddBond(LeftAtom, RightAtom, Binder->BondDegree);
    567     NewBond->Cyclic = Binder->Cyclic;
    568     if (Binder->Cyclic)
    569       copy->NoCyclicBonds++;
    570     NewBond->Type = Binder->Type;
    571   }
     616  for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
     617    for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin())
     618      if ((*BondRunner)->leftatom == *AtomRunner) {
     619        Binder = (*BondRunner);
     620
     621        // get the pendant atoms of current bond in the copy molecule
     622        copy->ActOnAllAtoms( &atom::EqualsFather, (const atom *)Binder->leftatom, (const atom **)&LeftAtom );
     623        copy->ActOnAllAtoms( &atom::EqualsFather, (const atom *)Binder->rightatom, (const atom **)&RightAtom );
     624
     625        NewBond = copy->AddBond(LeftAtom, RightAtom, Binder->BondDegree);
     626        NewBond->Cyclic = Binder->Cyclic;
     627        if (Binder->Cyclic)
     628          copy->NoCyclicBonds++;
     629        NewBond->Type = Binder->Type;
     630      }
    572631  // correct fathers
    573632  ActOnAllAtoms( &atom::CorrectFather );
    574633
    575634  // copy values
    576   copy->CountAtoms();
    577635  copy->CountElements();
    578   if (first->next != last) {  // if adjaceny list is present
     636  if (hasBondStructure()) {  // if adjaceny list is present
    579637    copy->BondDistance = BondDistance;
    580638  }
     
    608666bond * molecule::AddBond(atom *atom1, atom *atom2, int degree)
    609667{
     668  OBSERVE;
    610669  bond *Binder = NULL;
    611   if ((atom1 != NULL) && (FindAtom(atom1->nr) != NULL) && (atom2 != NULL) && (FindAtom(atom2->nr) != NULL)) {
    612     Binder = new bond(atom1, atom2, degree, BondCount++);
    613     atom1->RegisterBond(Binder);
    614     atom2->RegisterBond(Binder);
    615     if ((atom1->type != NULL) && (atom1->type->Z != 1) && (atom2->type != NULL) && (atom2->type->Z != 1))
    616       NoNonBonds++;
    617     add(Binder, last);
    618   } else {
    619     DoeLog(1) && (eLog()<< Verbose(1) << "Could not add bond between " << atom1->getName() << " and " << atom2->getName() << " as one or both are not present in the molecule." << endl);
    620   }
     670
     671  // some checks to make sure we are able to create the bond
     672  ASSERT(atom1, "First atom in bond-creation was an invalid pointer");
     673  ASSERT(atom2, "Second atom in bond-creation was an invalid pointer");
     674  ASSERT(FindAtom(atom1->nr),"First atom in bond-creation was not part of molecule");
     675  ASSERT(FindAtom(atom2->nr),"Second atom in bond-creation was not parto of molecule");
     676
     677  Binder = new bond(atom1, atom2, degree, BondCount++);
     678  atom1->RegisterBond(Binder);
     679  atom2->RegisterBond(Binder);
     680  if ((atom1->type != NULL) && (atom1->type->Z != 1) && (atom2->type != NULL) && (atom2->type->Z != 1))
     681    NoNonBonds++;
     682
    621683  return Binder;
    622684};
     
    630692{
    631693  //DoeLog(1) && (eLog()<< Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl);
    632   pointer->leftatom->RegisterBond(pointer);
    633   pointer->rightatom->RegisterBond(pointer);
    634   removewithoutcheck(pointer);
     694  delete(pointer);
    635695  return true;
    636696};
     
    692752bool molecule::RemoveAtom(atom *pointer)
    693753{
     754  ASSERT(pointer, "Null pointer passed to molecule::RemoveAtom().");
     755  OBSERVE;
    694756  if (ElementsInMolecule[pointer->type->Z] != 0)  { // this would indicate an error
    695757    ElementsInMolecule[pointer->type->Z]--;  // decrease number of atom of this element
    696     AtomCount--;
    697758  } else
    698759    DoeLog(1) && (eLog()<< Verbose(1) << "Atom " << pointer->getName() << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl);
     
    700761    ElementCount--;
    701762  RemoveBonds(pointer);
    702   return remove(pointer, start, end);
     763  erase(pointer);
     764  return true;
    703765};
    704766
     
    717779  if (ElementsInMolecule[pointer->type->Z] == 0)  // was last atom of this element?
    718780    ElementCount--;
    719   unlink(pointer);
     781  erase(pointer);
    720782  return true;
    721783};
     
    726788bool molecule::CleanupMolecule()
    727789{
    728   return (cleanup(first,last) && cleanup(start,end));
     790  for (molecule::iterator iter = begin(); !empty(); iter = begin())
     791      erase(iter);
    729792};
    730793
     
    733796 * \return pointer to atom or NULL
    734797 */
    735 atom * molecule::FindAtom(int Nr)  const{
    736   atom * walker = find(&Nr, start,end);
    737   if (walker != NULL) {
     798atom * molecule::FindAtom(int Nr)  const
     799{
     800  molecule::const_iterator iter = begin();
     801  for (; iter != end(); ++iter)
     802    if ((*iter)->nr == Nr)
     803      break;
     804  if (iter != end()) {
    738805    //Log() << Verbose(0) << "Found Atom Nr. " << walker->nr << endl;
    739     return walker;
     806    return (*iter);
    740807  } else {
    741808    DoLog(0) && (Log() << Verbose(0) << "Atom not found in list." << endl);
     
    867934    now = time((time_t *)NULL);   // Get the system time and put it into 'now' as 'calender time'
    868935    for (int step=0;step<MDSteps;step++) {
    869       *output << AtomCount << "\n\tCreated by molecuilder, step " << step << ", on " << ctime(&now);
     936      *output << getAtomCount() << "\n\tCreated by molecuilder, step " << step << ", on " << ctime(&now);
    870937      ActOnAllAtoms( &atom::OutputTrajectoryXYZ, output, step );
    871938    }
     
    884951  if (output != NULL) {
    885952    now = time((time_t *)NULL);   // Get the system time and put it into 'now' as 'calender time'
    886     *output << AtomCount << "\n\tCreated by molecuilder on " << ctime(&now);
     953    *output << getAtomCount() << "\n\tCreated by molecuilder on " << ctime(&now);
    887954    ActOnAllAtoms( &atom::OutputXYZLine, output );
    888955    return true;
     
    894961 * \param *out output stream for debugging
    895962 */
    896 void molecule::CountAtoms()
    897 {
     963int molecule::doCountAtoms()
     964{
     965  int res = size();
    898966  int i = 0;
    899   atom *Walker = start;
    900   while (Walker->next != end) {
    901     Walker = Walker->next;
     967  NoNonHydrogen = 0;
     968  for (molecule::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter) {
     969    (*iter)->nr = i;   // update number in molecule (for easier referencing in FragmentMolecule lateron)
     970    if ((*iter)->type->Z != 1) // count non-hydrogen atoms whilst at it
     971      NoNonHydrogen++;
     972    stringstream sstr;
     973    sstr << (*iter)->type->symbol << (*iter)->nr+1;
     974    (*iter)->setName(sstr.str());
     975    DoLog(3) && (Log() << Verbose(3) << "Naming atom nr. " << (*iter)->nr << " " << (*iter)->getName() << "." << endl);
    902976    i++;
    903977  }
    904   if ((AtomCount == 0) || (i != AtomCount)) {
    905     DoLog(3) && (Log() << Verbose(3) << "Mismatch in AtomCount " << AtomCount << " and recounted number " << i << ", renaming all." << endl);
    906     AtomCount = i;
    907 
    908     // count NonHydrogen atoms and give each atom a unique name
    909     if (AtomCount != 0) {
    910       i=0;
    911       NoNonHydrogen = 0;
    912       Walker = start;
    913       while (Walker->next != end) {
    914         Walker = Walker->next;
    915         Walker->nr = i;   // update number in molecule (for easier referencing in FragmentMolecule lateron)
    916         if (Walker->type->Z != 1) // count non-hydrogen atoms whilst at it
    917           NoNonHydrogen++;
    918         stringstream sstr;
    919         sstr << Walker->type->symbol << Walker->nr+1;
    920         Walker->setName(sstr.str());
    921         DoLog(3) && (Log() << Verbose(3) << "Naming atom nr. " << Walker->nr << " " << Walker->getName() << "." << endl);
    922         i++;
    923       }
    924     } else
    925       DoLog(3) && (Log() << Verbose(3) << "AtomCount is still " << AtomCount << ", thus counting nothing." << endl);
    926   }
     978  return res;
    927979};
    928980
     
    9861038  /// first count both their atoms and elements and update lists thereby ...
    9871039  //Log() << Verbose(0) << "Counting atoms, updating list" << endl;
    988   CountAtoms();
    989   OtherMolecule->CountAtoms();
    9901040  CountElements();
    9911041  OtherMolecule->CountElements();
     
    9941044  /// -# AtomCount
    9951045  if (result) {
    996     if (AtomCount != OtherMolecule->AtomCount) {
    997       DoLog(4) && (Log() << Verbose(4) << "AtomCounts don't match: " << AtomCount << " == " << OtherMolecule->AtomCount << endl);
     1046    if (getAtomCount() != OtherMolecule->getAtomCount()) {
     1047      DoLog(4) && (Log() << Verbose(4) << "AtomCounts don't match: " << getAtomCount() << " == " << OtherMolecule->getAtomCount() << endl);
    9981048      result = false;
    999     } else Log() << Verbose(4) << "AtomCounts match: " << AtomCount << " == " << OtherMolecule->AtomCount << endl;
     1049    } else Log() << Verbose(4) << "AtomCounts match: " << getAtomCount() << " == " << OtherMolecule->getAtomCount() << endl;
    10001050  }
    10011051  /// -# ElementCount
     
    10341084  if (result) {
    10351085    DoLog(5) && (Log() << Verbose(5) << "Calculating distances" << endl);
    1036     Distances = Calloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: Distances");
    1037     OtherDistances = Calloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: OtherDistances");
     1086    Distances = new double[getAtomCount()];
     1087    OtherDistances = new double[getAtomCount()];
    10381088    SetIndexedArrayForEachAtomTo ( Distances, &atom::nr, &atom::DistanceSquaredToVector, (const Vector &)CenterOfGravity);
    10391089    SetIndexedArrayForEachAtomTo ( OtherDistances, &atom::nr, &atom::DistanceSquaredToVector, (const Vector &)CenterOfGravity);
     1090    for(int i=0;i<getAtomCount();i++) {
     1091      Distances[i] = 0.;
     1092      OtherDistances[i] = 0.;
     1093    }
    10401094
    10411095    /// ... sort each list (using heapsort (o(N log N)) from GSL)
    10421096    DoLog(5) && (Log() << Verbose(5) << "Sorting distances" << endl);
    1043     PermMap = Calloc<size_t>(AtomCount, "molecule::IsEqualToWithinThreshold: *PermMap");
    1044     OtherPermMap = Calloc<size_t>(AtomCount, "molecule::IsEqualToWithinThreshold: *OtherPermMap");
    1045     gsl_heapsort_index (PermMap, Distances, AtomCount, sizeof(double), CompareDoubles);
    1046     gsl_heapsort_index (OtherPermMap, OtherDistances, AtomCount, sizeof(double), CompareDoubles);
    1047     PermutationMap = Calloc<int>(AtomCount, "molecule::IsEqualToWithinThreshold: *PermutationMap");
     1097    PermMap = new size_t[getAtomCount()];
     1098    OtherPermMap = new size_t[getAtomCount()];
     1099    for(int i=0;i<getAtomCount();i++) {
     1100      PermMap[i] = 0;
     1101      OtherPermMap[i] = 0;
     1102    }
     1103    gsl_heapsort_index (PermMap, Distances, getAtomCount(), sizeof(double), CompareDoubles);
     1104    gsl_heapsort_index (OtherPermMap, OtherDistances, getAtomCount(), sizeof(double), CompareDoubles);
     1105    PermutationMap = new int[getAtomCount()];
     1106    for(int i=0;i<getAtomCount();i++)
     1107      PermutationMap[i] = 0;
    10481108    DoLog(5) && (Log() << Verbose(5) << "Combining Permutation Maps" << endl);
    1049     for(int i=AtomCount;i--;)
     1109    for(int i=getAtomCount();i--;)
    10501110      PermutationMap[PermMap[i]] = (int) OtherPermMap[i];
    10511111
     
    10531113    DoLog(4) && (Log() << Verbose(4) << "Comparing distances" << endl);
    10541114    flag = 0;
    1055     for (int i=0;i<AtomCount;i++) {
     1115    for (int i=0;i<getAtomCount();i++) {
    10561116      DoLog(5) && (Log() << Verbose(5) << "Distances squared: |" << Distances[PermMap[i]] << " - " << OtherDistances[OtherPermMap[i]] << "| = " << fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) << " ?<? " <<  threshold << endl);
    10571117      if (fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) > threshold*threshold)
     
    10601120
    10611121    // free memory
    1062     Free(&PermMap);
    1063     Free(&OtherPermMap);
    1064     Free(&Distances);
    1065     Free(&OtherDistances);
     1122    delete[](PermMap);
     1123    delete[](OtherPermMap);
     1124    delete[](Distances);
     1125    delete[](OtherDistances);
    10661126    if (flag) { // if not equal
    1067       Free(&PermutationMap);
     1127      delete[](PermutationMap);
    10681128      result = false;
    10691129    }
     
    10891149int * molecule::GetFatherSonAtomicMap(molecule *OtherMolecule)
    10901150{
    1091   atom *Walker = NULL, *OtherWalker = NULL;
    10921151  DoLog(3) && (Log() << Verbose(3) << "Begin of GetFatherAtomicMap." << endl);
    1093   int *AtomicMap = Malloc<int>(AtomCount, "molecule::GetAtomicMap: *AtomicMap");
    1094   for (int i=AtomCount;i--;)
     1152  int *AtomicMap = new int[getAtomCount()];
     1153  for (int i=getAtomCount();i--;)
    10951154    AtomicMap[i] = -1;
    10961155  if (OtherMolecule == this) {  // same molecule
    1097     for (int i=AtomCount;i--;) // no need as -1 means already that there is trivial correspondence
     1156    for (int i=getAtomCount();i--;) // no need as -1 means already that there is trivial correspondence
    10981157      AtomicMap[i] = i;
    10991158    DoLog(4) && (Log() << Verbose(4) << "Map is trivial." << endl);
    11001159  } else {
    11011160    DoLog(4) && (Log() << Verbose(4) << "Map is ");
    1102     Walker = start;
    1103     while (Walker->next != end) {
    1104       Walker = Walker->next;
    1105       if (Walker->father == NULL) {
    1106         AtomicMap[Walker->nr] = -2;
     1161    for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     1162      if ((*iter)->father == NULL) {
     1163        AtomicMap[(*iter)->nr] = -2;
    11071164      } else {
    1108         OtherWalker = OtherMolecule->start;
    1109         while (OtherWalker->next != OtherMolecule->end) {
    1110           OtherWalker = OtherWalker->next;
     1165        for (molecule::const_iterator runner = OtherMolecule->begin(); runner != OtherMolecule->end(); ++runner) {
    11111166      //for (int i=0;i<AtomCount;i++) { // search atom
    1112         //for (int j=0;j<OtherMolecule->AtomCount;j++) {
    1113           //Log() << Verbose(4) << "Comparing father " << Walker->father << " with the other one " << OtherWalker->father << "." << endl;
    1114           if (Walker->father == OtherWalker)
    1115             AtomicMap[Walker->nr] = OtherWalker->nr;
     1167        //for (int j=0;j<OtherMolecule->getAtomCount();j++) {
     1168          //Log() << Verbose(4) << "Comparing father " << (*iter)->father << " with the other one " << (*runner)->father << "." << endl;
     1169          if ((*iter)->father == (*runner))
     1170            AtomicMap[(*iter)->nr] = (*runner)->nr;
    11161171        }
    11171172      }
    1118       DoLog(0) && (Log() << Verbose(0) << AtomicMap[Walker->nr] << "\t");
     1173      DoLog(0) && (Log() << Verbose(0) << AtomicMap[(*iter)->nr] << "\t");
    11191174    }
    11201175    DoLog(0) && (Log() << Verbose(0) << endl);
     
    11501205void molecule::SetIndexedArrayForEachAtomTo ( atom **array, int ParticleInfo::*index) const
    11511206{
    1152   atom *Walker = start;
    1153   while (Walker->next != end) {
    1154     Walker = Walker->next;
    1155     array[(Walker->*index)] = Walker;
     1207  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     1208    array[((*iter)->*index)] = (*iter);
    11561209  }
    11571210};
  • src/molecule.hpp

    r0c7ed8 r1dc9ec  
    3434#include "tesselation.hpp"
    3535#include "Patterns/Observer.hpp"
     36#include "Patterns/ObservedIterator.hpp"
    3637#include "Patterns/Cacheable.hpp"
     38
     39#include "Descriptors/MoleculeDescriptor_impl.hpp"
    3740
    3841/****************************************** forward declarations *****************************/
     
    8891  friend molecule *NewMolecule();
    8992  friend void DeleteMolecule(molecule *);
     93
    9094  public:
     95    typedef std::set<atom*> atomSet;
     96    typedef ObservedIterator<atomSet> iterator;
     97    typedef atomSet::const_iterator const_iterator;
     98
    9199    const periodentafel * const elemente; //!< periodic table with each element
    92     atom *start;        //!< start of atom list
    93     atom *end;          //!< end of atom list
    94     bond *first;        //!< start of bond list
    95     bond *last;         //!< end of bond list
     100    // old deprecated atom handling
     101    //atom *start;        //!< start of atom list
     102    //atom *end;          //!< end of atom list
     103    //bond *first;        //!< start of bond list
     104    //bond *last;         //!< end of bond list
    96105    int MDSteps;        //!< The number of MD steps in Trajectories
    97     int AtomCount;          //!< number of atoms, brought up-to-date by CountAtoms()
     106    //int AtomCount;          //!< number of atoms, brought up-to-date by CountAtoms()
    98107    int BondCount;          //!< number of atoms, brought up-to-date by CountBonds()
    99108    int ElementCount;       //!< how many unique elements are therein
     
    110119  private:
    111120    Cacheable<string> formula;
     121    Cacheable<int>    AtomCount;
    112122    moleculeId_t id;
     123    atomSet atoms; //<!set of atoms
    113124  protected:
     125    //void CountAtoms();
     126    /**
     127     * this iterator type should be used for internal variables, \
     128     * since it will not lock
     129     */
     130    typedef atomSet::iterator internal_iterator;
     131
     132
    114133    molecule(const periodentafel * const teil);
    115134    virtual ~molecule();
     
    119138  //getter and setter
    120139  const std::string getName();
     140  int getAtomCount() const;
     141  int doCountAtoms();
    121142  moleculeId_t getId();
    122143  void setId(moleculeId_t);
     
    125146  std::string calcFormula();
    126147
     148  iterator begin();
     149  const_iterator begin() const;
     150  iterator end();
     151  const_iterator end() const;
     152  bool empty() const;
     153  size_t size() const;
     154  const_iterator erase( const_iterator loc );
     155  const_iterator erase( atom * key );
     156  const_iterator find (  atom * key ) const;
     157  pair<iterator,bool> insert ( atom * const key );
     158  bool containsAtom(atom* key);
     159
    127160
    128161  // re-definition of virtual functions from PointCloud
     
    130163  Vector *GetCenter() const ;
    131164  TesselPoint *GetPoint() const ;
    132   TesselPoint *GetTerminalPoint() const ;
    133165  int GetMaxId() const;
    134166  void GoToNext() const ;
    135   void GoToPrevious() const ;
    136167  void GoToFirst() const ;
    137   void GoToLast() const ;
    138168  bool IsEmpty() const ;
    139169  bool IsEnd() const ;
     
    224254  bool RemoveBond(bond *pointer);
    225255  bool RemoveBonds(atom *BondPartner);
     256  bool hasBondStructure();
     257  unsigned int CountBonds() const;
    226258
    227259  /// Find atoms.
     
    230262
    231263  /// Count and change present atoms' coordination.
    232   void CountAtoms();
    233264  void CountElements();
    234265  void CalculateOrbitals(class config &configuration);
     
    247278  Vector * DetermineCenterOfGravity();
    248279  Vector * DetermineCenterOfAll() const;
     280  Vector * DetermineCenterOfBox() const;
    249281  void SetNameFromFilename(const char *filename);
    250282  void SetBoxDimension(Vector *dim);
     
    299331  bool StoreForcesFile(MoleculeListClass *BondFragments, char *path, int *SortIndex);
    300332  bool CreateMappingLabelsToConfigSequence(int *&SortIndex);
     333  bool CreateFatherLookupTable(atom **&LookupTable, int count = 0);
    301334  void BreadthFirstSearchAdd(molecule *Mol, atom **&AddedAtomList, bond **&AddedBondList, atom *Root, bond *Bond, int BondOrder, bool IsAngstroem);
    302335  /// -# BOSSANOVA
     
    327360  private:
    328361  int last_atom;      //!< number given to last atom
    329   mutable atom *InternalPointer;  //!< internal pointer for PointCloud
     362  mutable internal_iterator InternalPointer;  //!< internal pointer for PointCloud
    330363};
    331364
     
    348381  bool StoreForcesFile(char *path, int *SortIndex);
    349382  void insert(molecule *mol);
     383  void erase(molecule *mol);
    350384  molecule * ReturnIndex(int index);
    351385  bool OutputConfigForListOfFragments(config *configuration, int *SortIndex);
  • src/molecule_dynamics.cpp

    r0c7ed8 r1dc9ec  
    66 */
    77
     8#include "Helpers/MemDebug.hpp"
     9
    810#include "World.hpp"
    911#include "atom.hpp"
    1012#include "config.hpp"
    1113#include "element.hpp"
     14#include "info.hpp"
    1215#include "log.hpp"
    1316#include "memoryallocator.hpp"
     
    2831  gsl_matrix *A = gsl_matrix_alloc(NDIM,NDIM);
    2932  gsl_vector *x = gsl_vector_alloc(NDIM);
    30   atom * Runner = mol->start;
    3133  atom *Sprinter = NULL;
    3234  Vector trajectory1, trajectory2, normal, TestVector;
    3335  double Norm1, Norm2, tmp, result = 0.;
    3436
    35   while (Runner->next != mol->end) {
    36     Runner = Runner->next;
    37     if (Runner == Walker) // hence, we only go up to the Walker, not beyond (similar to i=0; i<j; i++)
     37  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     38    if ((*iter) == Walker) // hence, we only go up to the Walker, not beyond (similar to i=0; i<j; i++)
    3839      break;
    3940    // determine normalized trajectories direction vector (n1, n2)
     
    4243    trajectory1.Normalize();
    4344    Norm1 = trajectory1.Norm();
    44     Sprinter = Params.PermutationMap[Runner->nr];   // find second target point
    45     trajectory2 = Sprinter->Trajectory.R.at(Params.endstep) - Runner->Trajectory.R.at(Params.startstep);
     45    Sprinter = Params.PermutationMap[(*iter)->nr];   // find second target point
     46    trajectory2 = Sprinter->Trajectory.R.at(Params.endstep) - (*iter)->Trajectory.R.at(Params.startstep);
    4647    trajectory2.Normalize();
    4748    Norm2 = trajectory1.Norm();
    4849    // check whether either is zero()
    4950    if ((Norm1 < MYEPSILON) && (Norm2 < MYEPSILON)) {
    50       tmp = Walker->Trajectory.R.at(Params.startstep).distance(Runner->Trajectory.R.at(Params.startstep));
     51      tmp = Walker->Trajectory.R.at(Params.startstep).distance((*iter)->Trajectory.R.at(Params.startstep));
    5152    } else if (Norm1 < MYEPSILON) {
    5253      Sprinter = Params.PermutationMap[Walker->nr];   // find first target point
    53       trajectory1 = Sprinter->Trajectory.R.at(Params.endstep) - Runner->Trajectory.R.at(Params.startstep);
     54      trajectory1 = Sprinter->Trajectory.R.at(Params.endstep) - (*iter)->Trajectory.R.at(Params.startstep);
    5455      trajectory2 *= trajectory1.ScalarProduct(trajectory2); // trajectory2 is scaled to unity, hence we don't need to divide by anything
    5556      trajectory1 -= trajectory2;   // project the part in norm direction away
    5657      tmp = trajectory1.Norm();  // remaining norm is distance
    5758    } else if (Norm2 < MYEPSILON) {
    58       Sprinter = Params.PermutationMap[Runner->nr];   // find second target point
     59      Sprinter = Params.PermutationMap[(*iter)->nr];   // find second target point
    5960      trajectory2 = Sprinter->Trajectory.R.at(Params.endstep) - Walker->Trajectory.R.at(Params.startstep);  // copy second offset
    6061      trajectory1 *= trajectory2.ScalarProduct(trajectory1); // trajectory1 is scaled to unity, hence we don't need to divide by anything
     
    6667  //        Log() << Verbose(0) << " and ";
    6768  //        Log() << Verbose(0) << trajectory2;
    68       tmp = Walker->Trajectory.R.at(Params.startstep).distance(Runner->Trajectory.R.at(Params.startstep));
     69      tmp = Walker->Trajectory.R.at(Params.startstep).distance((*iter)->Trajectory.R.at(Params.startstep));
    6970  //        Log() << Verbose(0) << " with distance " << tmp << "." << endl;
    7071    } else { // determine distance by finding minimum distance
    71   //        Log() << Verbose(3) << "Both trajectories of " << *Walker << " and " << *Runner << " are linear independent ";
     72  //        Log() << Verbose(3) << "Both trajectories of " << *Walker << " and " << *(*iter) << " are linear independent ";
    7273  //        Log() << Verbose(0) << endl;
    7374  //        Log() << Verbose(0) << "First Trajectory: ";
     
    8586        gsl_matrix_set(A, 1, i, trajectory2[i]);
    8687        gsl_matrix_set(A, 2, i, normal[i]);
    87         gsl_vector_set(x,i, (Walker->Trajectory.R.at(Params.startstep)[i] - Runner->Trajectory.R.at(Params.startstep)[i]));
     88        gsl_vector_set(x,i, (Walker->Trajectory.R.at(Params.startstep)[i] - (*iter)->Trajectory.R.at(Params.startstep)[i]));
    8889      }
    8990      // solve the linear system by Householder transformations
     
    9697      trajectory2.Scale(gsl_vector_get(x,1));
    9798      normal.Scale(gsl_vector_get(x,2));
    98       TestVector = Runner->Trajectory.R.at(Params.startstep) + trajectory2 + normal
     99      TestVector = (*iter)->Trajectory.R.at(Params.startstep) + trajectory2 + normal
    99100                   - (Walker->Trajectory.R.at(Params.startstep) + trajectory1);
    100101      if (TestVector.Norm() < MYEPSILON) {
     
    125126{
    126127  double result = 0.;
    127   atom * Runner = mol->start;
    128   while (Runner->next != mol->end) {
    129     Runner = Runner->next;
    130     if ((Params.PermutationMap[Walker->nr] == Params.PermutationMap[Runner->nr]) && (Walker->nr < Runner->nr)) {
     128  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     129    if ((Params.PermutationMap[Walker->nr] == Params.PermutationMap[(*iter)->nr]) && (Walker->nr < (*iter)->nr)) {
    131130  //    atom *Sprinter = PermutationMap[Walker->nr];
    132   //        Log() << Verbose(0) << *Walker << " and " << *Runner << " are heading to the same target at ";
     131  //        Log() << Verbose(0) << *Walker << " and " << *(*iter) << " are heading to the same target at ";
    133132  //        Log() << Verbose(0) << Sprinter->Trajectory.R.at(endstep);
    134133  //        Log() << Verbose(0) << ", penalting." << endl;
     
    161160  // go through every atom
    162161  atom *Runner = NULL;
    163   atom *Walker = start;
    164   while (Walker->next != end) {
    165     Walker = Walker->next;
     162  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    166163    // first term: distance to target
    167     Runner = Params.PermutationMap[Walker->nr];   // find target point
    168     tmp = (Walker->Trajectory.R.at(Params.startstep).distance(Runner->Trajectory.R.at(Params.endstep)));
     164    Runner = Params.PermutationMap[(*iter)->nr];   // find target point
     165    tmp = ((*iter)->Trajectory.R.at(Params.startstep).distance(Runner->Trajectory.R.at(Params.endstep)));
    169166    tmp *= Params.IsAngstroem ? 1. : 1./AtomicLengthToAngstroem;
    170167    result += Params.PenaltyConstants[0] * tmp;
     
    172169
    173170    // second term: sum of distances to other trajectories
    174     result += SumDistanceOfTrajectories(Walker, this, Params);
     171    result += SumDistanceOfTrajectories((*iter), this, Params);
    175172
    176173    // third term: penalty for equal targets
    177     result += PenalizeEqualTargets(Walker, this, Params);
     174    result += PenalizeEqualTargets((*iter), this, Params);
    178175  }
    179176
     
    189186{
    190187  stringstream zeile1, zeile2;
    191   int *DoubleList = Calloc<int>(AtomCount, "PrintPermutationMap: *DoubleList");
     188  int *DoubleList = new int[AtomCount];
     189  for(int i=0;i<AtomCount;i++)
     190    DoubleList[i] = 0;
    192191  int doubles = 0;
    193192  zeile1 << "PermutationMap: ";
     
    203202  if (doubles >0)
    204203    DoLog(2) && (Log() << Verbose(2) << "Found " << doubles << " Doubles." << endl);
    205   Free(&DoubleList);
     204  delete[](DoubleList);
    206205//  Log() << Verbose(2) << zeile1.str() << endl << zeile2.str() << endl;
    207206};
     
    213212void FillDistanceList(molecule *mol, struct EvaluatePotential &Params)
    214213{
    215   for (int i=mol->AtomCount; i--;) {
     214  for (int i=mol->getAtomCount(); i--;) {
    216215    Params.DistanceList[i] = new DistanceMap;    // is the distance sorted target list per atom
    217216    Params.DistanceList[i]->clear();
    218217  }
    219218
    220   atom *Runner = NULL;
    221   atom *Walker = mol->start;
    222   while (Walker->next != mol->end) {
    223     Walker = Walker->next;
    224     Runner = mol->start;
    225     while(Runner->next != mol->end) {
    226       Runner = Runner->next;
    227       Params.DistanceList[Walker->nr]->insert( DistancePair(Walker->Trajectory.R.at(Params.startstep).distance(Runner->Trajectory.R.at(Params.endstep)), Runner) );
     219  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     220    for (molecule::const_iterator runner = mol->begin(); runner != mol->end(); ++runner) {
     221      Params.DistanceList[(*iter)->nr]->insert( DistancePair((*iter)->Trajectory.R.at(Params.startstep).distance((*runner)->Trajectory.R.at(Params.endstep)), (*runner)) );
    228222    }
    229223  }
     
    237231void CreateInitialLists(molecule *mol, struct EvaluatePotential &Params)
    238232{
    239   atom *Walker = mol->start;
    240   while (Walker->next != mol->end) {
    241     Walker = Walker->next;
    242     Params.StepList[Walker->nr] = Params.DistanceList[Walker->nr]->begin();    // stores the step to the next iterator that could be a possible next target
    243     Params.PermutationMap[Walker->nr] = Params.DistanceList[Walker->nr]->begin()->second;   // always pick target with the smallest distance
    244     Params.DoubleList[Params.DistanceList[Walker->nr]->begin()->second->nr]++;            // increase this target's source count (>1? not injective)
    245     Params.DistanceIterators[Walker->nr] = Params.DistanceList[Walker->nr]->begin();    // and remember which one we picked
    246     DoLog(2) && (Log() << Verbose(2) << *Walker << " starts with distance " << Params.DistanceList[Walker->nr]->begin()->first << "." << endl);
     233  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     234    Params.StepList[(*iter)->nr] = Params.DistanceList[(*iter)->nr]->begin();    // stores the step to the next iterator that could be a possible next target
     235    Params.PermutationMap[(*iter)->nr] = Params.DistanceList[(*iter)->nr]->begin()->second;   // always pick target with the smallest distance
     236    Params.DoubleList[Params.DistanceList[(*iter)->nr]->begin()->second->nr]++;            // increase this target's source count (>1? not injective)
     237    Params.DistanceIterators[(*iter)->nr] = Params.DistanceList[(*iter)->nr]->begin();    // and remember which one we picked
     238    DoLog(2) && (Log() << Verbose(2) << **iter << " starts with distance " << Params.DistanceList[(*iter)->nr]->begin()->first << "." << endl);
    247239  }
    248240};
     
    285277void MakeInjectivePermutation(molecule *mol, struct EvaluatePotential &Params)
    286278{
    287   atom *Walker = mol->start;
     279  molecule::const_iterator iter = mol->begin();
    288280  DistanceMap::iterator NewBase;
    289281  double Potential = fabs(mol->ConstrainedPotential(Params));
    290282
     283  if (mol->empty()) {
     284    eLog() << Verbose(1) << "Molecule is empty." << endl;
     285    return;
     286  }
    291287  while ((Potential) > Params.PenaltyConstants[2]) {
    292     PrintPermutationMap(mol->AtomCount, Params);
    293     Walker = Walker->next;
    294     if (Walker == mol->end) // round-robin at the end
    295       Walker = mol->start->next;
    296     if (Params.DoubleList[Params.DistanceIterators[Walker->nr]->second->nr] <= 1)  // no need to make those injective that aren't
     288    PrintPermutationMap(mol->getAtomCount(), Params);
     289    iter++;
     290    if (iter == mol->end()) // round-robin at the end
     291      iter = mol->begin();
     292    if (Params.DoubleList[Params.DistanceIterators[(*iter)->nr]->second->nr] <= 1)  // no need to make those injective that aren't
    297293      continue;
    298294    // now, try finding a new one
    299     Potential = TryNextNearestNeighbourForInjectivePermutation(mol, Walker, Potential, Params);
    300   }
    301   for (int i=mol->AtomCount; i--;) // now each single entry in the DoubleList should be <=1
     295    Potential = TryNextNearestNeighbourForInjectivePermutation(mol, (*iter), Potential, Params);
     296  }
     297  for (int i=mol->getAtomCount(); i--;) // now each single entry in the DoubleList should be <=1
    302298    if (Params.DoubleList[i] > 1) {
    303299      DoeLog(0) && (eLog()<< Verbose(0) << "Failed to create an injective PermutationMap!" << endl);
     
    338334  double Potential, OldPotential, OlderPotential;
    339335  struct EvaluatePotential Params;
    340   Params.PermutationMap = Calloc<atom*>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.**PermutationMap");
    341   Params.DistanceList = Malloc<DistanceMap*>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.**DistanceList");
    342   Params.DistanceIterators = Malloc<DistanceMap::iterator>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.*DistanceIterators");
    343   Params.DoubleList = Calloc<int>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.*DoubleList");
    344   Params.StepList = Malloc<DistanceMap::iterator>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.*StepList");
     336  Params.PermutationMap = new atom *[getAtomCount()];
     337  Params.DistanceList = new DistanceMap *[getAtomCount()];
     338  Params.DistanceIterators = new DistanceMap::iterator[getAtomCount()];
     339  Params.DoubleList = new int[getAtomCount()];
     340  Params.StepList = new DistanceMap::iterator[getAtomCount()];
    345341  int round;
    346   atom *Walker = NULL, *Runner = NULL, *Sprinter = NULL;
     342  atom *Sprinter = NULL;
    347343  DistanceMap::iterator Rider, Strider;
     344
     345  // set to zero
     346  for (int i=0;i<getAtomCount();i++) {
     347    Params.PermutationMap[i] = NULL;
     348    Params.DoubleList[i] = 0;
     349  }
    348350
    349351  /// Minimise the potential
     
    362364  DoLog(1) && (Log() << Verbose(1) << "Making the PermutationMap injective ... " << endl);
    363365  MakeInjectivePermutation(this, Params);
    364   Free(&Params.DoubleList);
     366  delete[](Params.DoubleList);
    365367
    366368  // argument minimise the constrained potential in this injective PermutationMap
     
    371373    DoLog(2) && (Log() << Verbose(2) << "Starting round " << ++round << ", at current potential " << OldPotential << " ... " << endl);
    372374    OlderPotential = OldPotential;
     375    molecule::const_iterator iter;
    373376    do {
    374       Walker = start;
    375       while (Walker->next != end) { // pick one
    376         Walker = Walker->next;
    377         PrintPermutationMap(AtomCount, Params);
    378         Sprinter = Params.DistanceIterators[Walker->nr]->second;   // store initial partner
    379         Strider = Params.DistanceIterators[Walker->nr];  //remember old iterator
    380         Params.DistanceIterators[Walker->nr] = Params.StepList[Walker->nr];
    381         if (Params.DistanceIterators[Walker->nr] == Params.DistanceList[Walker->nr]->end()) {// stop, before we run through the list and still on
    382           Params.DistanceIterators[Walker->nr] == Params.DistanceList[Walker->nr]->begin();
     377      iter = begin();
     378      for (; iter != end(); ++iter) {
     379        PrintPermutationMap(getAtomCount(), Params);
     380        Sprinter = Params.DistanceIterators[(*iter)->nr]->second;   // store initial partner
     381        Strider = Params.DistanceIterators[(*iter)->nr];  //remember old iterator
     382        Params.DistanceIterators[(*iter)->nr] = Params.StepList[(*iter)->nr];
     383        if (Params.DistanceIterators[(*iter)->nr] == Params.DistanceList[(*iter)->nr]->end()) {// stop, before we run through the list and still on
     384          Params.DistanceIterators[(*iter)->nr] == Params.DistanceList[(*iter)->nr]->begin();
    383385          break;
    384386        }
    385         //Log() << Verbose(2) << "Current Walker: " << *Walker << " with old/next candidate " << *Sprinter << "/" << *DistanceIterators[Walker->nr]->second << "." << endl;
     387        //Log() << Verbose(2) << "Current Walker: " << *(*iter) << " with old/next candidate " << *Sprinter << "/" << *DistanceIterators[(*iter)->nr]->second << "." << endl;
    386388        // find source of the new target
    387         Runner = start->next;
    388         while(Runner != end) { // find the source whose toes we might be stepping on (Walker's new target should be in use by another already)
    389           if (Params.PermutationMap[Runner->nr] == Params.DistanceIterators[Walker->nr]->second) {
    390             //Log() << Verbose(2) << "Found the corresponding owner " << *Runner << " to " << *PermutationMap[Runner->nr] << "." << endl;
     389        molecule::const_iterator runner = begin();
     390        for (; runner != end(); ++runner) { // find the source whose toes we might be stepping on (Walker's new target should be in use by another already)
     391          if (Params.PermutationMap[(*runner)->nr] == Params.DistanceIterators[(*iter)->nr]->second) {
     392            //Log() << Verbose(2) << "Found the corresponding owner " << *(*runner) << " to " << *PermutationMap[(*runner)->nr] << "." << endl;
    391393            break;
    392394          }
    393           Runner = Runner->next;
    394395        }
    395         if (Runner != end) { // we found the other source
     396        if (runner != end()) { // we found the other source
    396397          // then look in its distance list for Sprinter
    397           Rider = Params.DistanceList[Runner->nr]->begin();
    398           for (; Rider != Params.DistanceList[Runner->nr]->end(); Rider++)
     398          Rider = Params.DistanceList[(*runner)->nr]->begin();
     399          for (; Rider != Params.DistanceList[(*runner)->nr]->end(); Rider++)
    399400            if (Rider->second == Sprinter)
    400401              break;
    401           if (Rider != Params.DistanceList[Runner->nr]->end()) { // if we have found one
    402             //Log() << Verbose(2) << "Current Other: " << *Runner << " with old/next candidate " << *PermutationMap[Runner->nr] << "/" << *Rider->second << "." << endl;
     402          if (Rider != Params.DistanceList[(*runner)->nr]->end()) { // if we have found one
     403            //Log() << Verbose(2) << "Current Other: " << *(*runner) << " with old/next candidate " << *PermutationMap[(*runner)->nr] << "/" << *Rider->second << "." << endl;
    403404            // exchange both
    404             Params.PermutationMap[Walker->nr] = Params.DistanceIterators[Walker->nr]->second; // put next farther distance into PermutationMap
    405             Params.PermutationMap[Runner->nr] = Sprinter;  // and hand the old target to its respective owner
    406             PrintPermutationMap(AtomCount, Params);
     405            Params.PermutationMap[(*iter)->nr] = Params.DistanceIterators[(*iter)->nr]->second; // put next farther distance into PermutationMap
     406            Params.PermutationMap[(*runner)->nr] = Sprinter;  // and hand the old target to its respective owner
     407            PrintPermutationMap(getAtomCount(), Params);
    407408            // calculate the new potential
    408409            //Log() << Verbose(2) << "Checking new potential ..." << endl;
     
    410411            if (Potential > OldPotential) { // we made everything worse! Undo ...
    411412              //Log() << Verbose(3) << "Nay, made the potential worse: " << Potential << " vs. " << OldPotential << "!" << endl;
    412               //Log() << Verbose(3) << "Setting " << *Runner << "'s source to " << *Params.DistanceIterators[Runner->nr]->second << "." << endl;
     413              //Log() << Verbose(3) << "Setting " << *(*runner) << "'s source to " << *Params.DistanceIterators[(*runner)->nr]->second << "." << endl;
    413414              // Undo for Runner (note, we haven't moved the iteration yet, we may use this)
    414               Params.PermutationMap[Runner->nr] = Params.DistanceIterators[Runner->nr]->second;
     415              Params.PermutationMap[(*runner)->nr] = Params.DistanceIterators[(*runner)->nr]->second;
    415416              // Undo for Walker
    416               Params.DistanceIterators[Walker->nr] = Strider;  // take next farther distance target
    417               //Log() << Verbose(3) << "Setting " << *Walker << "'s source to " << *Params.DistanceIterators[Walker->nr]->second << "." << endl;
    418               Params.PermutationMap[Walker->nr] = Params.DistanceIterators[Walker->nr]->second;
     417              Params.DistanceIterators[(*iter)->nr] = Strider;  // take next farther distance target
     418              //Log() << Verbose(3) << "Setting " << *(*iter) << "'s source to " << *Params.DistanceIterators[(*iter)->nr]->second << "." << endl;
     419              Params.PermutationMap[(*iter)->nr] = Params.DistanceIterators[(*iter)->nr]->second;
    419420            } else {
    420               Params.DistanceIterators[Runner->nr] = Rider;  // if successful also move the pointer in the iterator list
     421              Params.DistanceIterators[(*runner)->nr] = Rider;  // if successful also move the pointer in the iterator list
    421422              DoLog(3) && (Log() << Verbose(3) << "Found a better permutation, new potential is " << Potential << " vs." << OldPotential << "." << endl);
    422423              OldPotential = Potential;
     
    428429            //Log() << Verbose(0) << endl;
    429430          } else {
    430             DoeLog(1) && (eLog()<< Verbose(1) << *Runner << " was not the owner of " << *Sprinter << "!" << endl);
     431            DoeLog(1) && (eLog()<< Verbose(1) << **runner << " was not the owner of " << *Sprinter << "!" << endl);
    431432            exit(255);
    432433          }
    433434        } else {
    434           Params.PermutationMap[Walker->nr] = Params.DistanceIterators[Walker->nr]->second; // new target has no source!
     435          Params.PermutationMap[(*iter)->nr] = Params.DistanceIterators[(*iter)->nr]->second; // new target has no source!
    435436        }
    436         Params.StepList[Walker->nr]++; // take next farther distance target
     437        Params.StepList[(*iter)->nr]++; // take next farther distance target
    437438      }
    438     } while (Walker->next != end);
     439    } while (++iter != end());
    439440  } while ((OlderPotential - OldPotential) > 1e-3);
    440441  DoLog(1) && (Log() << Verbose(1) << "done." << endl);
     
    442443
    443444  /// free memory and return with evaluated potential
    444   for (int i=AtomCount; i--;)
     445  for (int i=getAtomCount(); i--;)
    445446    Params.DistanceList[i]->clear();
    446   Free(&Params.DistanceList);
    447   Free(&Params.DistanceIterators);
     447  delete[](Params.DistanceList);
     448  delete[](Params.DistanceIterators);
    448449  return ConstrainedPotential(Params);
    449450};
     
    483484  // Get the Permutation Map by MinimiseConstrainedPotential
    484485  atom **PermutationMap = NULL;
    485   atom *Walker = NULL, *Sprinter = NULL;
     486  atom *Sprinter = NULL;
    486487  if (!MapByIdentity)
    487488    MinimiseConstrainedPotential(PermutationMap, startstep, endstep, configuration.GetIsAngstroem());
    488489  else {
    489     PermutationMap = Malloc<atom *>(AtomCount, "molecule::LinearInterpolationBetweenConfiguration: **PermutationMap");
     490    PermutationMap = new atom *[getAtomCount()];
    490491    SetIndexedArrayForEachAtomTo( PermutationMap, &atom::nr );
    491492  }
     
    502503    mol = World::getInstance().createMolecule();
    503504    MoleculePerStep->insert(mol);
    504     Walker = start;
    505     while (Walker->next != end) {
    506       Walker = Walker->next;
     505    for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    507506      // add to molecule list
    508       Sprinter = mol->AddCopyAtom(Walker);
     507      Sprinter = mol->AddCopyAtom((*iter));
    509508      for (int n=NDIM;n--;) {
    510         Sprinter->x[n] = Walker->Trajectory.R.at(startstep)[n] + (PermutationMap[Walker->nr]->Trajectory.R.at(endstep)[n] - Walker->Trajectory.R.at(startstep)[n])*((double)step/(double)MaxSteps);
     509        Sprinter->x[n] = (*iter)->Trajectory.R.at(startstep)[n] + (PermutationMap[(*iter)->nr]->Trajectory.R.at(endstep)[n] - (*iter)->Trajectory.R.at(startstep)[n])*((double)step/(double)MaxSteps);
    511510        // add to Trajectories
    512511        //Log() << Verbose(3) << step << ">=" << MDSteps-1 << endl;
    513512        if (step < MaxSteps) {
    514           Walker->Trajectory.R.at(step)[n] = Walker->Trajectory.R.at(startstep)[n] + (PermutationMap[Walker->nr]->Trajectory.R.at(endstep)[n] - Walker->Trajectory.R.at(startstep)[n])*((double)step/(double)MaxSteps);
    515           Walker->Trajectory.U.at(step)[n] = 0.;
    516           Walker->Trajectory.F.at(step)[n] = 0.;
     513          (*iter)->Trajectory.R.at(step)[n] = (*iter)->Trajectory.R.at(startstep)[n] + (PermutationMap[(*iter)->nr]->Trajectory.R.at(endstep)[n] - (*iter)->Trajectory.R.at(startstep)[n])*((double)step/(double)MaxSteps);
     514          (*iter)->Trajectory.U.at(step)[n] = 0.;
     515          (*iter)->Trajectory.F.at(step)[n] = 0.;
    517516        }
    518517      }
     
    522521
    523522  // store the list to single step files
    524   int *SortIndex = Malloc<int>(AtomCount, "molecule::LinearInterpolationBetweenConfiguration: *SortIndex");
    525   for (int i=AtomCount; i--; )
     523  int *SortIndex = new int[getAtomCount()];
     524  for (int i=getAtomCount(); i--; )
    526525    SortIndex[i] = i;
    527526  status = MoleculePerStep->OutputConfigForListOfFragments(&configuration, SortIndex);
     527  delete[](SortIndex);
    528528
    529529  // free and return
    530   Free(&PermutationMap);
     530  delete[](PermutationMap);
    531531  delete(MoleculePerStep);
    532532  return status;
     
    548548bool molecule::VerletForceIntegration(char *file, config &configuration)
    549549{
     550  Info FunctionInfo(__func__);
    550551  ifstream input(file);
    551552  string token;
     
    567568      return false;
    568569    }
    569     if (Force.RowCounter[0] != AtomCount) {
    570       DoeLog(0) && (eLog()<< Verbose(0) << "Mismatch between number of atoms in file " << Force.RowCounter[0] << " and in molecule " << AtomCount << "." << endl);
     570    if (Force.RowCounter[0] != getAtomCount()) {
     571      DoeLog(0) && (eLog()<< Verbose(0) << "Mismatch between number of atoms in file " << Force.RowCounter[0] << " and in molecule " << getAtomCount() << "." << endl);
    571572      performCriticalExit();
    572573      return false;
     
    574575    // correct Forces
    575576    Velocity.Zero();
    576     for(int i=0;i<AtomCount;i++)
     577    for(int i=0;i<getAtomCount();i++)
    577578      for(int d=0;d<NDIM;d++) {
    578579        Velocity[d] += Force.Matrix[0][i][d+5];
    579580      }
    580     for(int i=0;i<AtomCount;i++)
     581    for(int i=0;i<getAtomCount();i++)
    581582      for(int d=0;d<NDIM;d++) {
    582         Force.Matrix[0][i][d+5] -= Velocity[d]/(double)AtomCount;
     583        Force.Matrix[0][i][d+5] -= Velocity[d]/static_cast<double>(getAtomCount());
    583584      }
    584585    // solve a constrained potential if we are meant to
     
    588589      ConstrainedPotentialEnergy = MinimiseConstrainedPotential(PermutationMap,configuration.DoConstrainedMD, 0, configuration.GetIsAngstroem());
    589590      EvaluateConstrainedForces(configuration.DoConstrainedMD, 0, PermutationMap, &Force);
    590       Free(&PermutationMap);
     591      delete[](PermutationMap);
    591592    }
    592593
    593594    // and perform Verlet integration for each atom with position, velocity and force vector
    594595    // check size of vectors
    595     ActOnAllAtoms( &atom::ResizeTrajectory, MDSteps+10 );
    596 
    597     ActOnAllAtoms( &atom::VelocityVerletUpdate, MDSteps, &configuration, &Force);
     596    //ActOnAllAtoms( &atom::ResizeTrajectory, MDSteps+10 );
     597
     598    ActOnAllAtoms( &atom::VelocityVerletUpdate, MDSteps+1, &configuration, &Force);
    598599  }
    599600  // correct velocities (rather momenta) so that center of mass remains motionless
    600601  Velocity.Zero();
    601602  IonMass = 0.;
    602   ActOnAllAtoms ( &atom::SumUpKineticEnergy, MDSteps, &IonMass, &Velocity );
     603  ActOnAllAtoms ( &atom::SumUpKineticEnergy, MDSteps+1, &IonMass, &Velocity );
    603604
    604605  // correct velocities (rather momenta) so that center of mass remains motionless
    605606  Velocity.Scale(1./IonMass);
    606607  ActualTemp = 0.;
    607   ActOnAllAtoms ( &atom::CorrectVelocity, &ActualTemp, MDSteps, &Velocity );
     608  ActOnAllAtoms ( &atom::CorrectVelocity, &ActualTemp, MDSteps+1, &Velocity );
    608609  Thermostats(configuration, ActualTemp, Berendsen);
    609610  MDSteps++;
     
    683684      delta_alpha = 0.;
    684685      ActOnAllAtoms( &atom::Thermostat_NoseHoover_init, MDSteps, &delta_alpha );
    685       delta_alpha = (delta_alpha - (3.*AtomCount+1.) * configuration.TargetTemp)/(configuration.HooverMass*Units2Electronmass);
     686      delta_alpha = (delta_alpha - (3.*getAtomCount()+1.) * configuration.TargetTemp)/(configuration.HooverMass*Units2Electronmass);
    686687      configuration.alpha += delta_alpha*configuration.Deltat;
    687688      DoLog(3) && (Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration.alpha << "." << endl);
  • src/molecule_fragmentation.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include <cstring>
     
    3941  int FragmentCount;
    4042  // get maximum bond degree
    41   atom *Walker = start;
    42   while (Walker->next != end) {
    43     Walker = Walker->next;
    44     c = (Walker->ListOfBonds.size() > c) ? Walker->ListOfBonds.size() : c;
     43  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     44    c = ((*iter)->ListOfBonds.size() > c) ? (*iter)->ListOfBonds.size() : c;
    4545  }
    4646  FragmentCount = NoNonHydrogen*(1 << (c*order));
     
    9494  GraphTestPair testGraphInsert;
    9595  int NumberOfFragments = 0;
    96   char *filename = Malloc<char>(MAXSTRINGSIZE, "molecule::ParseKeySetFile - filename");
     96  char filename[MAXSTRINGSIZE];
    9797
    9898  if (FragmentList == NULL) { // check list pointer
     
    106106  if (InputFile != NULL) {
    107107    // each line represents a new fragment
    108     char *buffer = Malloc<char>(MAXSTRINGSIZE, "molecule::ParseKeySetFile - *buffer");
     108    char buffer[MAXSTRINGSIZE];
    109109    // 1. parse keysets and insert into temp. graph
    110110    while (!InputFile.eof()) {
     
    122122    InputFile.close();
    123123    InputFile.clear();
    124     Free(&buffer);
    125     DoLog(1) && (Log() << Verbose(1) << "done." << endl);
     124    DoLog(1) && (Log() << Verbose(1) << "\t ... done." << endl);
    126125  } else {
    127     DoLog(1) && (Log() << Verbose(1) << "File " << filename << " not found." << endl);
     126    DoLog(1) && (Log() << Verbose(1) << "\t ... File " << filename << " not found." << endl);
    128127    status = false;
    129128  }
    130129
    131   Free(&filename);
    132130  return status;
    133131};
     
    148146  int NumberOfFragments = 0;
    149147  double TEFactor;
    150   char *filename = Malloc<char>(MAXSTRINGSIZE, "molecule::ParseTEFactorsFile - filename");
     148  char filename[MAXSTRINGSIZE];
    151149
    152150  if (FragmentList == NULL) { // check list pointer
     
    179177  }
    180178
    181   // free memory
    182   Free(&filename);
    183 
    184179  return status;
    185180};
     
    317312  int No = 0, FragOrder = 0;
    318313  double Value = 0.;
    319   char *buffer = Malloc<char>(MAXSTRINGSIZE, "molecule::CheckOrderAtSite: *buffer");
     314  char buffer[MAXSTRINGSIZE];
    320315  sprintf(buffer, "%s/%s%s.dat", path, FRAGMENTPREFIX, ENERGYPERFRAGMENT);
    321316  ifstream InputFile(buffer, ios::in);
     
    345340    InputFile.clear();
    346341  }
    347   Free(&buffer);
    348342
    349343  return AdaptiveCriteriaList;
     
    359353map<double, pair<int,int> >  * ReMapAdaptiveCriteriaListToValue(map<int, pair<double,int> > *AdaptiveCriteriaList, molecule *mol)
    360354{
    361   atom *Walker = mol->start;
     355  atom *Walker = NULL;
    362356  map<double, pair<int,int> > *FinalRootCandidates = new map<double, pair<int,int> > ;
    363357  DoLog(1) && (Log() << Verbose(1) << "Root candidate list is: " << endl);
     
    391385bool MarkUpdateCandidates(bool *AtomMask, map<double, pair<int,int> > &FinalRootCandidates, int Order, molecule *mol)
    392386{
    393   atom *Walker = mol->start;
     387  atom *Walker = NULL;
    394388  int No = -1;
    395389  bool status = false;
     
    435429bool molecule::CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, char *path)
    436430{
    437   atom *Walker = start;
    438431  bool status = false;
    439432
    440433  // initialize mask list
    441   for(int i=AtomCount;i--;)
     434  for(int i=getAtomCount();i--;)
    442435    AtomMask[i] = false;
    443436
    444437  if (Order < 0) { // adaptive increase of BondOrder per site
    445     if (AtomMask[AtomCount] == true)  // break after one step
     438    if (AtomMask[getAtomCount()] == true)  // break after one step
    446439      return false;
    447440
     
    457450    if (AdaptiveCriteriaList->empty()) {
    458451      DoeLog(2) && (eLog()<< Verbose(2) << "Unable to parse file, incrementing all." << endl);
    459       while (Walker->next != end) {
    460         Walker = Walker->next;
     452      for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    461453    #ifdef ADDHYDROGEN
    462         if (Walker->type->Z != 1) // skip hydrogen
     454        if ((*iter)->type->Z != 1) // skip hydrogen
    463455    #endif
    464456        {
    465           AtomMask[Walker->nr] = true;  // include all (non-hydrogen) atoms
     457          AtomMask[(*iter)->nr] = true;  // include all (non-hydrogen) atoms
    466458          status = true;
    467459        }
     
    474466    MarkUpdateCandidates(AtomMask, *FinalRootCandidates, Order, this);
    475467
    476     Free(&IndexKeySetList);
    477     Free(&AdaptiveCriteriaList);
    478     Free(&FinalRootCandidates);
     468    delete[](IndexKeySetList);
     469    delete[](AdaptiveCriteriaList);
     470    delete[](FinalRootCandidates);
    479471  } else { // global increase of Bond Order
    480     while (Walker->next != end) {
    481       Walker = Walker->next;
     472    for(molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    482473  #ifdef ADDHYDROGEN
    483       if (Walker->type->Z != 1) // skip hydrogen
     474      if ((*iter)->type->Z != 1) // skip hydrogen
    484475  #endif
    485476      {
    486         AtomMask[Walker->nr] = true;  // include all (non-hydrogen) atoms
    487         if ((Order != 0) && (Walker->AdaptiveOrder < Order)) // && (Walker->AdaptiveOrder < MinimumRingSize[Walker->nr]))
     477        AtomMask[(*iter)->nr] = true;  // include all (non-hydrogen) atoms
     478        if ((Order != 0) && ((*iter)->AdaptiveOrder < Order)) // && ((*iter)->AdaptiveOrder < MinimumRingSize[(*iter)->nr]))
    488479          status = true;
    489480      }
    490481    }
    491     if ((Order == 0) && (AtomMask[AtomCount] == false))  // single stepping, just check
     482    if ((!Order) && (!AtomMask[getAtomCount()]))  // single stepping, just check
    492483      status = true;
    493484
     
    500491  }
    501492
    502   PrintAtomMask(AtomMask, AtomCount); // for debugging
     493  PrintAtomMask(AtomMask, getAtomCount()); // for debugging
    503494
    504495  return status;
     
    516507    return false;
    517508  }
    518   SortIndex = Malloc<int>(AtomCount, "molecule::CreateMappingLabelsToConfigSequence: *SortIndex");
    519   for(int i=AtomCount;i--;)
     509  SortIndex = new int[getAtomCount()];
     510  for(int i=getAtomCount();i--;)
    520511    SortIndex[i] = -1;
    521512
     
    524515
    525516  return true;
     517};
     518
     519
     520
     521/** Creates a lookup table for true father's Atom::Nr -> atom ptr.
     522 * \param *start begin of list (STL iterator, i.e. first item)
     523 * \paran *end end of list (STL iterator, i.e. one past last item)
     524 * \param **Lookuptable pointer to return allocated lookup table (should be NULL on start)
     525 * \param count optional predetermined size for table (otherwise we set the count to highest true father id)
     526 * \return true - success, false - failure
     527 */
     528bool molecule::CreateFatherLookupTable(atom **&LookupTable, int count)
     529{
     530  bool status = true;
     531  int AtomNo;
     532
     533  if (LookupTable != NULL) {
     534    Log() << Verbose(0) << "Pointer for Lookup table is not NULL! Aborting ..." <<endl;
     535    return false;
     536  }
     537
     538  // count them
     539  if (count == 0) {
     540    for (molecule::iterator iter = begin(); iter != end(); ++iter) { // create a lookup table (Atom::nr -> atom) used as a marker table lateron
     541      count = (count < (*iter)->GetTrueFather()->nr) ? (*iter)->GetTrueFather()->nr : count;
     542    }
     543  }
     544  if (count <= 0) {
     545    Log() << Verbose(0) << "Count of lookup list is 0 or less." << endl;
     546    return false;
     547  }
     548
     549  // allocate and fill
     550  LookupTable = new atom *[count];
     551  if (LookupTable == NULL) {
     552    eLog() << Verbose(0) << "LookupTable memory allocation failed!" << endl;
     553    performCriticalExit();
     554    status = false;
     555  } else {
     556    for (int i=0;i<count;i++)
     557      LookupTable[i] = NULL;
     558    for (molecule::iterator iter = begin(); iter != end(); ++iter) {
     559      AtomNo = (*iter)->GetTrueFather()->nr;
     560      if ((AtomNo >= 0) && (AtomNo < count)) {
     561        //*out << "Setting LookupTable[" << AtomNo << "] to " << *(*iter) << endl;
     562        LookupTable[AtomNo] = (*iter);
     563      } else {
     564        Log() << Verbose(0) << "Walker " << *(*iter) << " exceeded range of nuclear ids [0, " << count << ")." << endl;
     565        status = false;
     566        break;
     567      }
     568    }
     569  }
     570
     571  return status;
    526572};
    527573
     
    547593{
    548594  MoleculeListClass *BondFragments = NULL;
    549   int *SortIndex = NULL;
    550   int *MinimumRingSize = new int[AtomCount];
     595  int *MinimumRingSize = new int[getAtomCount()];
    551596  int FragmentCounter;
    552597  MoleculeLeafClass *MolecularWalker = NULL;
     
    576621
    577622  // create lookup table for Atom::nr
    578   FragmentationToDo = FragmentationToDo && CreateFatherLookupTable(start, end, ListOfAtoms, AtomCount);
     623  FragmentationToDo = FragmentationToDo && CreateFatherLookupTable(ListOfAtoms, getAtomCount());
    579624
    580625  // === compare it with adjacency file ===
    581626  FragmentationToDo = FragmentationToDo && CheckAdjacencyFileAgainstMolecule(configuration->configpath, ListOfAtoms);
    582   Free(&ListOfAtoms);
     627  delete[](ListOfAtoms);
    583628
    584629  // ===== 2. perform a DFS analysis to gather info on cyclic structure and a list of disconnected subgraphs =====
     
    586631
    587632  // analysis of the cycles (print rings, get minimum cycle length) for each subgraph
    588   for(int i=AtomCount;i--;)
    589     MinimumRingSize[i] = AtomCount;
     633  for(int i=getAtomCount();i--;)
     634    MinimumRingSize[i] = getAtomCount();
    590635  MolecularWalker = Subgraphs;
    591636  FragmentCounter = 0;
     
    598643//    // check the list of local atoms for debugging
    599644//    Log() << Verbose(0) << "ListOfLocalAtoms for this subgraph is:" << endl;
    600 //    for (int i=0;i<AtomCount;i++)
     645//    for (int i=0;i<getAtomCount();i++)
    601646//      if (ListOfLocalAtoms[FragmentCounter][i] == NULL)
    602647//        Log() << Verbose(0) << "\tNULL";
     
    624669  // ===== 6b. prepare and go into the adaptive (Order<0), single-step (Order==0) or incremental (Order>0) cycle
    625670  KeyStack *RootStack = new KeyStack[Subgraphs->next->Count()];
    626   AtomMask = new bool[AtomCount+1];
    627   AtomMask[AtomCount] = false;
     671  AtomMask = new bool[getAtomCount()+1];
     672  AtomMask[getAtomCount()] = false;
    628673  FragmentationToDo = false;  // if CheckOrderAtSite just ones recommends fragmentation, we will save fragments afterwards
    629674  while ((CheckOrder = CheckOrderAtSite(AtomMask, ParsedFragmentList, Order, MinimumRingSize, configuration->configpath))) {
    630675    FragmentationToDo = FragmentationToDo || CheckOrder;
    631     AtomMask[AtomCount] = true;   // last plus one entry is used as marker that we have been through this loop once already in CheckOrderAtSite()
     676    AtomMask[getAtomCount()] = true;   // last plus one entry is used as marker that we have been through this loop once already in CheckOrderAtSite()
    632677    // ===== 6b. fill RootStack for each subgraph (second adaptivity check) =====
    633678    Subgraphs->next->FillRootStackForSubgraphs(RootStack, AtomMask, (FragmentCounter = 0));
     
    640685      DoLog(1) && (Log() << Verbose(1) << "Fragmenting subgraph " << MolecularWalker << "." << endl);
    641686      //MolecularWalker->Leaf->OutputListOfBonds(out);  // output atom::ListOfBonds for debugging
    642       if (MolecularWalker->Leaf->first->next != MolecularWalker->Leaf->last) {
     687      if (MolecularWalker->Leaf->hasBondStructure()) {
    643688        // call BOSSANOVA method
    644689        DoLog(0) && (Log() << Verbose(0) << endl << " ========== BOND ENERGY of subgraph " << FragmentCounter << " ========================= " << endl);
     
    672717    delete(Subgraphs);
    673718  }
    674   Free(&FragmentList);
     719  delete[](FragmentList);
    675720
    676721  // ===== 8b. gather keyset lists (graphs) from all subgraphs and transform into MoleculeListClass =====
     
    690735  if (BondFragments->ListOfMolecules.size() != 0) {
    691736    // create the SortIndex from BFS labels to order in the config file
     737    int *SortIndex = NULL;
    692738    CreateMappingLabelsToConfigSequence(SortIndex);
    693739
     
    704750    StoreKeySetFile(TotalGraph, configuration->configpath);
    705751
    706     // store Adjacency file
    707     char *filename = Malloc<char> (MAXSTRINGSIZE, "molecule::FragmentMolecule - *filename");
    708     strcpy(filename, FRAGMENTPREFIX);
    709     strcat(filename, ADJACENCYFILE);
    710     StoreAdjacencyToFile(configuration->configpath, filename);
    711     Free(&filename);
     752    {
     753      // store Adjacency file
     754      char filename[MAXSTRINGSIZE];
     755      strcpy(filename, FRAGMENTPREFIX);
     756      strcat(filename, ADJACENCYFILE);
     757      StoreAdjacencyToFile(configuration->configpath, filename);
     758    }
    712759
    713760    // store Hydrogen saturation correction file
     
    722769    // free memory for bond part
    723770    DoLog(1) && (Log() << Verbose(1) << "Freeing bond memory" << endl);
    724     Free(&FragmentList); // remove bond molecule from memory
    725     Free(&SortIndex);
     771    delete[](SortIndex);
    726772  } else {
    727773    DoLog(1) && (Log() << Verbose(1) << "FragmentList is zero on return, splitting failed." << endl);
     
    768814bool molecule::ParseOrderAtSiteFromFile(char *path)
    769815{
    770   unsigned char *OrderArray = Calloc<unsigned char>(AtomCount, "molecule::ParseOrderAtSiteFromFile - *OrderArray");
    771   bool *MaxArray = Calloc<bool>(AtomCount, "molecule::ParseOrderAtSiteFromFile - *MaxArray");
     816  unsigned char *OrderArray = new unsigned char[getAtomCount()];
     817  bool *MaxArray = new bool[getAtomCount()];
    772818  bool status;
    773819  int AtomNr, value;
    774820  stringstream line;
    775821  ifstream file;
     822
     823  for(int i=0;i<getAtomCount();i++) {
     824    OrderArray[i] = 0;
     825    MaxArray[i] = false;
     826  }
    776827
    777828  DoLog(1) && (Log() << Verbose(1) << "Begin of ParseOrderAtSiteFromFile" << endl);
     
    796847    SetAtomValueToIndexedArray( MaxArray, &atom::nr, &atom::MaxOrder );
    797848
    798     DoLog(1) && (Log() << Verbose(1) << "done." << endl);
     849    DoLog(1) && (Log() << Verbose(1) << "\t ... done." << endl);
    799850    status = true;
    800851  } else {
    801     DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl);
     852    DoLog(1) && (Log() << Verbose(1) << "\t ... failed to open file " << line.str() << "." << endl);
    802853    status = false;
    803854  }
    804   Free(&OrderArray);
    805   Free(&MaxArray);
     855  delete[](OrderArray);
     856  delete[](MaxArray);
    806857
    807858  DoLog(1) && (Log() << Verbose(1) << "End of ParseOrderAtSiteFromFile" << endl);
     
    872923  atom *OtherFather = NULL;
    873924  atom *FatherOfRunner = NULL;
    874   Leaf->CountAtoms();
    875 
    876   atom *Runner = Leaf->start;
    877   while (Runner->next != Leaf->end) {
    878     Runner = Runner->next;
     925
     926#ifdef ADDHYDROGEN
     927  molecule::const_iterator runner;
     928#endif
     929  // we increment the iter just before skipping the hydrogen
     930  for (molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end();) {
    879931    LonelyFlag = true;
    880     FatherOfRunner = Runner->father;
     932    FatherOfRunner = (*iter)->father;
     933    ASSERT(FatherOfRunner,"Atom without father found");
    881934    if (SonList[FatherOfRunner->nr] != NULL)  {  // check if this, our father, is present in list
    882935      // create all bonds
     
    889942//            Log() << Verbose(3) << "Adding Bond: ";
    890943//            Log() << Verbose(0) <<
    891             Leaf->AddBond(Runner, SonList[OtherFather->nr], (*BondRunner)->BondDegree);
     944            Leaf->AddBond((*iter), SonList[OtherFather->nr], (*BondRunner)->BondDegree);
    892945//            Log() << Verbose(0) << "." << endl;
    893             //NumBonds[Runner->nr]++;
     946            //NumBonds[(*iter)->nr]++;
    894947          } else {
    895948//            Log() << Verbose(3) << "Not adding bond, labels in wrong order." << endl;
     
    899952//          Log() << Verbose(0) << ", who has no son in this fragment molecule." << endl;
    900953#ifdef ADDHYDROGEN
    901           //Log() << Verbose(3) << "Adding Hydrogen to " << Runner->Name << " and a bond in between." << endl;
    902           if(!Leaf->AddHydrogenReplacementAtom((*BondRunner), Runner, FatherOfRunner, OtherFather, IsAngstroem))
     954          //Log() << Verbose(3) << "Adding Hydrogen to " << (*iter)->Name << " and a bond in between." << endl;
     955          if(!Leaf->AddHydrogenReplacementAtom((*BondRunner), (*iter), FatherOfRunner, OtherFather, IsAngstroem))
    903956            exit(1);
    904957#endif
    905           //NumBonds[Runner->nr] += Binder->BondDegree;
     958          //NumBonds[(*iter)->nr] += Binder->BondDegree;
    906959        }
    907960      }
    908961    } else {
    909       DoeLog(1) && (eLog()<< Verbose(1) << "Son " << Runner->getName() << " has father " << FatherOfRunner->getName() << " but its entry in SonList is " << SonList[FatherOfRunner->nr] << "!" << endl);
    910     }
    911     if ((LonelyFlag) && (Leaf->AtomCount > 1)) {
    912       DoLog(0) && (Log() << Verbose(0) << *Runner << "has got bonds only to hydrogens!" << endl);
    913     }
     962    DoeLog(1) && (eLog()<< Verbose(1) << "Son " << (*iter)->getName() << " has father " << FatherOfRunner->getName() << " but its entry in SonList is " << SonList[FatherOfRunner->nr] << "!" << endl);
     963    }
     964    if ((LonelyFlag) && (Leaf->getAtomCount() > 1)) {
     965      DoLog(0) && (Log() << Verbose(0) << **iter << "has got bonds only to hydrogens!" << endl);
     966    }
     967    ++iter;
    914968#ifdef ADDHYDROGEN
    915     while ((Runner->next != Leaf->end) && (Runner->next->type->Z == 1)) // skip added hydrogen
    916       Runner = Runner->next;
     969    while ((iter != Leaf->end()) && ((*iter)->type->Z == 1)){ // skip added hydrogen
     970      iter++;
     971    }
    917972#endif
    918973  }
     
    929984molecule * molecule::StoreFragmentFromKeySet(KeySet &Leaflet, bool IsAngstroem)
    930985{
    931   atom **SonList = Calloc<atom*>(AtomCount, "molecule::StoreFragmentFromStack: **SonList");
     986  atom **SonList = new atom*[getAtomCount()];
    932987  molecule *Leaf = World::getInstance().createMolecule();
     988
     989  for(int i=0;i<getAtomCount();i++)
     990    SonList[i] = NULL;
    933991
    934992//  Log() << Verbose(1) << "Begin of StoreFragmentFromKeyset." << endl;
     
    939997
    940998  //Leaflet->Leaf->ScanForPeriodicCorrection(out);
    941   Free(&SonList);
     999  delete[](SonList);
    9421000//  Log() << Verbose(1) << "End of StoreFragmentFromKeyset." << endl;
    9431001  return Leaf;
     
    10841142  int bits, TouchedIndex, SubSetDimension, SP, Added;
    10851143  int SpaceLeft;
    1086   int *TouchedList = Malloc<int>(SubOrder + 1, "molecule::SPFragmentGenerator: *TouchedList");
    1087   bond **BondsList = NULL;
     1144  int *TouchedList = new int[SubOrder + 1];
    10881145  KeySetTestPair TestKeySetInsert;
    10891146
     
    11241181
    11251182          // then allocate and fill the list
    1126           BondsList = Malloc<bond*>(SubSetDimension, "molecule::SPFragmentGenerator: **BondsList");
     1183          bond *BondsList[SubSetDimension];
    11271184          SubSetDimension = FillBondsList(BondsList, FragmentSearch->BondsPerSPList[2*SP], FragmentSearch->BondsPerSPList[2*SP+1], TouchedList, TouchedIndex);
    11281185
     
    11301187          Log() << Verbose(2+verbosity) << "Calling subset generator " << SP << " away from root " << *FragmentSearch->Root << " with sub set dimension " << SubSetDimension << "." << endl;
    11311188          SPFragmentGenerator(FragmentSearch, SP, BondsList, SubSetDimension, SubOrder-bits);
    1132 
    1133           Free(&BondsList);
    11341189        }
    11351190      } else {
     
    11531208    }
    11541209  }
    1155   Free(&TouchedList);
     1210  delete[](TouchedList);
    11561211  Log() << Verbose(1+verbosity) << "End of SPFragmentGenerator, " << RootDistance << " away from Root " << *FragmentSearch->Root << " and SubOrder is " << SubOrder << "." << endl;
    11571212};
     
    11651220void InitialiseSPList(int Order, struct UniqueFragments &FragmentSearch)
    11661221{
    1167   FragmentSearch.BondsPerSPList = Malloc<bond*>(Order * 2, "molecule::PowerSetGenerator: ***BondsPerSPList");
    1168   FragmentSearch.BondsPerSPCount = Malloc<int>(Order, "molecule::PowerSetGenerator: *BondsPerSPCount");
     1222  FragmentSearch.BondsPerSPList = new bond* [Order * 2];
     1223  FragmentSearch.BondsPerSPCount = new int[Order];
    11691224  for (int i=Order;i--;) {
    11701225    FragmentSearch.BondsPerSPList[2*i] = new bond();    // start node
     
    11841239void FreeSPList(int Order, struct UniqueFragments &FragmentSearch)
    11851240{
    1186   Free(&FragmentSearch.BondsPerSPCount);
     1241  delete[](FragmentSearch.BondsPerSPCount);
    11871242  for (int i=Order;i--;) {
    11881243    delete(FragmentSearch.BondsPerSPList[2*i]);
    11891244    delete(FragmentSearch.BondsPerSPList[2*i+1]);
    11901245  }
    1191   Free(&FragmentSearch.BondsPerSPList);
     1246  delete[](FragmentSearch.BondsPerSPList);
    11921247};
    11931248
     
    13701425int molecule::PowerSetGenerator(int Order, struct UniqueFragments &FragmentSearch, KeySet RestrictedKeySet)
    13711426{
    1372   bond **BondsList = NULL;
    13731427  int Counter = FragmentSearch.FragmentCounter; // mark current value of counter
    13741428
     
    13941448
    13951449    // prepare the subset and call the generator
    1396     BondsList = Calloc<bond*>(FragmentSearch.BondsPerSPCount[0], "molecule::PowerSetGenerator: **BondsList");
     1450    bond* BondsList[FragmentSearch.BondsPerSPCount[0]];
     1451    for(int i=0;i<FragmentSearch.BondsPerSPCount[0];i++)
     1452      BondsList[i] = NULL;
    13971453    BondsList[0] = FragmentSearch.BondsPerSPList[0]->next;  // on SP level 0 there's only the root bond
    13981454
    13991455    SPFragmentGenerator(&FragmentSearch, 0, BondsList, FragmentSearch.BondsPerSPCount[0], Order);
    1400 
    1401     Free(&BondsList);
    14021456  } else {
    14031457    DoLog(0) && (Log() << Verbose(0) << "Not enough total number of edges to build " << Order << "-body fragments." << endl);
     
    15071561      }
    15081562    }
    1509     Free(&FragmentLowerOrdersList[RootNr]);
     1563    delete[](FragmentLowerOrdersList[RootNr]);
    15101564    RootNr++;
    15111565  }
    1512   Free(&FragmentLowerOrdersList);
     1566  delete[](FragmentLowerOrdersList);
    15131567};
    15141568
     
    15491603  // FragmentLowerOrdersList is a 2D-array of pointer to MoleculeListClass objects, one dimension represents the ANOVA expansion of a single order (i.e. 5)
    15501604  // with all needed lower orders that are subtracted, the other dimension is the BondOrder (i.e. from 1 to 5)
    1551   NumMoleculesOfOrder = Calloc<int>(UpgradeCount, "molecule::FragmentBOSSANOVA: *NumMoleculesOfOrder");
    1552   FragmentLowerOrdersList = Calloc<Graph**>(UpgradeCount, "molecule::FragmentBOSSANOVA: ***FragmentLowerOrdersList");
     1605  NumMoleculesOfOrder = new int[UpgradeCount];
     1606  FragmentLowerOrdersList = new Graph**[UpgradeCount];
     1607
     1608  for(int i=0;i<UpgradeCount;i++) {
     1609    NumMoleculesOfOrder[i] = 0;
     1610    FragmentLowerOrdersList[i] = NULL;
     1611  }
    15531612
    15541613  // initialise the fragments structure
     
    15561615  FragmentSearch.FragmentSet = new KeySet;
    15571616  FragmentSearch.Root = FindAtom(RootKeyNr);
    1558   FragmentSearch.ShortestPathList = Malloc<int>(AtomCount, "molecule::PowerSetGenerator: *ShortestPathList");
    1559   for (int i=AtomCount;i--;) {
     1617  FragmentSearch.ShortestPathList = new int[getAtomCount()];
     1618  for (int i=getAtomCount();i--;) {
    15601619    FragmentSearch.ShortestPathList[i] = -1;
    15611620  }
    15621621
    15631622  // Construct the complete KeySet which we need for topmost level only (but for all Roots)
    1564   atom *Walker = start;
    15651623  KeySet CompleteMolecule;
    1566   while (Walker->next != end) {
    1567     Walker = Walker->next;
    1568     CompleteMolecule.insert(Walker->GetTrueFather()->nr);
     1624  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     1625    CompleteMolecule.insert((*iter)->GetTrueFather()->nr);
    15691626  }
    15701627
     
    15771634    RootKeyNr = RootStack.front();
    15781635    RootStack.pop_front();
    1579     Walker = FindAtom(RootKeyNr);
     1636    atom *Walker = FindAtom(RootKeyNr);
    15801637    // check cyclic lengths
    15811638    //if ((MinimumRingSize[Walker->GetTrueFather()->nr] != -1) && (Walker->GetTrueFather()->AdaptiveOrder+1 > MinimumRingSize[Walker->GetTrueFather()->nr])) {
     
    15921649      // allocate memory for all lower level orders in this 1D-array of ptrs
    15931650      NumLevels = 1 << (Order-1); // (int)pow(2,Order);
    1594       FragmentLowerOrdersList[RootNr] = Calloc<Graph*>(NumLevels, "molecule::FragmentBOSSANOVA: **FragmentLowerOrdersList[]");
     1651      FragmentLowerOrdersList[RootNr] = new Graph*[NumLevels];
     1652      for (int i=0;i<NumLevels;i++)
     1653        FragmentLowerOrdersList[RootNr][i] = NULL;
    15951654
    15961655      // create top order where nothing is reduced
     
    16281687
    16291688  // cleanup FragmentSearch structure
    1630   Free(&FragmentSearch.ShortestPathList);
     1689  delete[](FragmentSearch.ShortestPathList);
    16311690  delete(FragmentSearch.FragmentSet);
    16321691
     
    16411700  CombineAllOrderListIntoOne(FragmentList, FragmentLowerOrdersList, RootStack, this);
    16421701  FreeAllOrdersList(FragmentLowerOrdersList, RootStack, this);
    1643   Free(&NumMoleculesOfOrder);
     1702  delete[](NumMoleculesOfOrder);
    16441703
    16451704  DoLog(0) && (Log() << Verbose(0) << "End of FragmentBOSSANOVA." << endl);
     
    16641723  Vector Translationvector;
    16651724  //class StackClass<atom *> *CompStack = NULL;
    1666   class StackClass<atom *> *AtomStack = new StackClass<atom *>(AtomCount);
     1725  class StackClass<atom *> *AtomStack = new StackClass<atom *>(getAtomCount());
    16671726  bool flag = true;
    16681727
    16691728  DoLog(2) && (Log() << Verbose(2) << "Begin of ScanForPeriodicCorrection." << endl);
    16701729
    1671   ColorList = Calloc<enum Shading>(AtomCount, "molecule::ScanForPeriodicCorrection: *ColorList");
     1730  ColorList = new enum Shading[getAtomCount()];
     1731  for (int i=0;i<getAtomCount();i++)
     1732    ColorList[i] = (enum Shading)0;
    16721733  while (flag) {
    16731734    // remove bonds that are beyond bonddistance
    16741735    Translationvector.Zero();
    16751736    // scan all bonds
    1676     Binder = first;
    16771737    flag = false;
    1678     while ((!flag) && (Binder->next != last)) {
    1679       Binder = Binder->next;
    1680       for (int i=NDIM;i--;) {
    1681         tmp = fabs(Binder->leftatom->x[i] - Binder->rightatom->x[i]);
    1682         //Log() << Verbose(3) << "Checking " << i << "th distance of " << *Binder->leftatom << " to " << *Binder->rightatom << ": " << tmp << "." << endl;
    1683         if (tmp > BondDistance) {
    1684           OtherBinder = Binder->next; // note down binding partner for later re-insertion
    1685           unlink(Binder);   // unlink bond
    1686           DoLog(2) && (Log() << Verbose(2) << "Correcting at bond " << *Binder << "." << endl);
    1687           flag = true;
    1688           break;
     1738    for(molecule::iterator AtomRunner = begin(); (!flag) && (AtomRunner != end()); ++AtomRunner)
     1739      for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); (!flag) && (BondRunner != (*AtomRunner)->ListOfBonds.end()); ++BondRunner) {
     1740        Binder = (*BondRunner);
     1741        for (int i=NDIM;i--;) {
     1742          tmp = fabs(Binder->leftatom->x[i] - Binder->rightatom->x[i]);
     1743          //Log() << Verbose(3) << "Checking " << i << "th distance of " << *Binder->leftatom << " to " << *Binder->rightatom << ": " << tmp << "." << endl;
     1744          if (tmp > BondDistance) {
     1745            OtherBinder = Binder->next; // note down binding partner for later re-insertion
     1746            unlink(Binder);   // unlink bond
     1747            DoLog(2) && (Log() << Verbose(2) << "Correcting at bond " << *Binder << "." << endl);
     1748            flag = true;
     1749            break;
     1750          }
    16891751        }
    16901752      }
    1691     }
    16921753    if (flag) {
    16931754      // create translation vector from their periodically modified distance
     
    17011762      Log() << Verbose(0) << Translationvector <<  endl;
    17021763      // apply to all atoms of first component via BFS
    1703       for (int i=AtomCount;i--;)
     1764      for (int i=getAtomCount();i--;)
    17041765        ColorList[i] = white;
    17051766      AtomStack->Push(Binder->leftatom);
     
    17271788  // free allocated space from ReturnFullMatrixforSymmetric()
    17281789  delete(AtomStack);
    1729   Free(&ColorList);
    1730   Free(&matrix);
     1790  delete[](ColorList);
     1791  delete[](matrix);
    17311792  DoLog(2) && (Log() << Verbose(2) << "End of ScanForPeriodicCorrection." << endl);
    17321793};
  • src/molecule_geometry.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "atom.hpp"
     
    1719#include "World.hpp"
    1820#include "Plane.hpp"
     21#include <boost/foreach.hpp>
     22
    1923
    2024/************************************* Functions for class molecule *********************************/
     
    2832  bool status = true;
    2933  const Vector *Center = DetermineCenterOfAll();
     34  const Vector *CenterBox = DetermineCenterOfBox();
    3035  double * const cell_size = World::getInstance().getDomain();
    3136  double *M = ReturnFullMatrixforSymmetric(cell_size);
     
    3439  // go through all atoms
    3540  ActOnAllVectors( &Vector::SubtractVector, *Center);
     41  ActOnAllVectors( &Vector::SubtractVector, *CenterBox);
    3642  ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv);
    3743
    38   Free(&M);
    39   Free(&Minv);
     44  delete[](M);
     45  delete[](Minv);
    4046  delete(Center);
    4147  return status;
     
    5662  ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv);
    5763
    58   Free(&M);
    59   Free(&Minv);
     64  delete[](M);
     65  delete[](Minv);
    6066  return status;
    6167};
     
    7076
    7177//  Log() << Verbose(3) << "Begin of CenterEdge." << endl;
    72   atom *ptr = start->next;  // start at first in list
    73   if (ptr != end) {  //list not empty?
     78  molecule::const_iterator iter = begin();  // start at first in list
     79  if (iter != end()) { //list not empty?
    7480    for (int i=NDIM;i--;) {
    75       max->at(i) = ptr->x[i];
    76       min->at(i) = ptr->x[i];
    77     }
    78     while (ptr->next != end) {  // continue with second if present
    79       ptr = ptr->next;
    80       //ptr->Output(1,1,out);
     81      max->at(i) = (*iter)->x[i];
     82      min->at(i) = (*iter)->x[i];
     83    }
     84    for (; iter != end(); ++iter) {// continue with second if present
     85      //(*iter)->Output(1,1,out);
    8186      for (int i=NDIM;i--;) {
    82         max->at(i) = (max->at(i) < ptr->x[i]) ? ptr->x[i] : max->at(i);
    83         min->at(i) = (min->at(i) > ptr->x[i]) ? ptr->x[i] : min->at(i);
     87        max->at(i) = (max->at(i) < (*iter)->x[i]) ? (*iter)->x[i] : max->at(i);
     88        min->at(i) = (min->at(i) > (*iter)->x[i]) ? (*iter)->x[i] : min->at(i);
    8489      }
    8590    }
     
    105110{
    106111  int Num = 0;
    107   atom *ptr = start;  // start at first in list
     112  molecule::const_iterator iter = begin();  // start at first in list
    108113
    109114  Center.Zero();
    110115
    111   if (ptr->next != end) {   //list not empty?
    112     while (ptr->next != end) {  // continue with second if present
    113       ptr = ptr->next;
     116  if (iter != end()) {   //list not empty?
     117    for (; iter != end(); ++iter) {  // continue with second if present
    114118      Num++;
    115       Center += ptr->x;
     119      Center += (*iter)->x;
    116120    }
    117121    Center.Scale(-1./Num); // divide through total number (and sign for direction)
     
    126130Vector * molecule::DetermineCenterOfAll() const
    127131{
    128   atom *ptr = start->next;  // start at first in list
     132  molecule::const_iterator iter = begin();  // start at first in list
     133  Vector *a = new Vector();
     134  double Num = 0;
     135
     136  a->Zero();
     137
     138  if (iter != end()) {   //list not empty?
     139    for (; iter != end(); ++iter) {  // continue with second if present
     140      Num++;
     141      (*a) += (*iter)->x;
     142    }
     143    a->Scale(1./Num); // divide through total mass (and sign for direction)
     144  }
     145  return a;
     146};
     147
     148/** Returns vector pointing to center of the domain.
     149 * \return pointer to center of the domain
     150 */
     151Vector * molecule::DetermineCenterOfBox() const
     152{
     153  Vector *a = new Vector(0.5,0.5,0.5);
     154
     155  const double *cell_size = World::getInstance().getDomain();
     156  double *M = ReturnFullMatrixforSymmetric(cell_size);
     157  a->MatrixMultiplication(M);
     158  delete[](M);
     159
     160  return a;
     161};
     162
     163/** Returns vector pointing to center of gravity.
     164 * \param *out output stream for debugging
     165 * \return pointer to center of gravity vector
     166 */
     167Vector * molecule::DetermineCenterOfGravity()
     168{
     169  molecule::const_iterator iter = begin();  // start at first in list
    129170  Vector *a = new Vector();
    130171  Vector tmp;
     
    133174  a->Zero();
    134175
    135   if (ptr != end) {   //list not empty?
    136     while (ptr->next != end) {  // continue with second if present
    137       ptr = ptr->next;
    138       Num += 1.;
    139       tmp = ptr->x;
     176  if (iter != end()) {   //list not empty?
     177    for (; iter != end(); ++iter) {  // continue with second if present
     178      Num += (*iter)->type->mass;
     179      tmp = (*iter)->type->mass * (*iter)->x;
    140180      (*a) += tmp;
    141181    }
    142182    a->Scale(1./Num); // divide through total mass (and sign for direction)
    143   }
    144   return a;
    145 };
    146 
    147 /** Returns vector pointing to center of gravity.
    148  * \param *out output stream for debugging
    149  * \return pointer to center of gravity vector
    150  */
    151 Vector * molecule::DetermineCenterOfGravity()
    152 {
    153   atom *ptr = start->next;  // start at first in list
    154   Vector *a = new Vector();
    155   Vector tmp;
    156   double Num = 0;
    157 
    158   a->Zero();
    159 
    160   if (ptr != end) {   //list not empty?
    161     while (ptr->next != end) {  // continue with second if present
    162       ptr = ptr->next;
    163       Num += ptr->type->mass;
    164       tmp = ptr->type->mass * ptr->x;
    165       (*a) += tmp;
    166     }
    167     a->Scale(-1./Num); // divide through total mass (and sign for direction)
    168183  }
    169184//  Log() << Verbose(1) << "Resulting center of gravity: ";
     
    203218void molecule::Scale(const double ** const factor)
    204219{
    205   atom *ptr = start;
    206 
    207   while (ptr->next != end) {
    208     ptr = ptr->next;
     220  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    209221    for (int j=0;j<MDSteps;j++)
    210       ptr->Trajectory.R.at(j).ScaleAll(*factor);
    211     ptr->x.ScaleAll(*factor);
     222      (*iter)->Trajectory.R.at(j).ScaleAll(*factor);
     223    (*iter)->x.ScaleAll(*factor);
    212224  }
    213225};
     
    218230void molecule::Translate(const Vector *trans)
    219231{
    220   atom *ptr = start;
    221 
    222   while (ptr->next != end) {
    223     ptr = ptr->next;
     232  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    224233    for (int j=0;j<MDSteps;j++)
    225       ptr->Trajectory.R.at(j) += (*trans);
    226     ptr->x += (*trans);
     234      (*iter)->Trajectory.R.at(j) += (*trans);
     235    (*iter)->x += (*trans);
    227236  }
    228237};
     
    239248
    240249  // go through all atoms
    241   ActOnAllVectors( &Vector::SubtractVector, *trans);
     250  ActOnAllVectors( &Vector::AddVector, *trans);
    242251  ActOnAllVectors( &Vector::WrapPeriodically, (const double *)M, (const double *)Minv);
    243252
    244   Free(&M);
    245   Free(&Minv);
     253  delete[](M);
     254  delete[](Minv);
    246255};
    247256
     
    252261void molecule::Mirror(const Vector *n)
    253262{
     263  OBSERVE;
    254264  Plane p(*n,0);
    255   // TODO: replace with simpler construct (e.g. Boost::foreach)
    256   // once the structure of the atom list is fully reworked
    257   atom *Walker = start;
    258   while (Walker->next != end) {
    259     Walker = Walker->next;
    260     (*Walker->node) = p.mirrorVector(*Walker->node);
     265  BOOST_FOREACH( atom* iter, atoms ){
     266    (*iter->node) = p.mirrorVector(*iter->node);
    261267  }
    262268};
     
    267273void molecule::DeterminePeriodicCenter(Vector &center)
    268274{
    269   atom *Walker = start;
    270275  double * const cell_size = World::getInstance().getDomain();
    271276  double *matrix = ReturnFullMatrixforSymmetric(cell_size);
    272   double *inversematrix = InverseMatrix(cell_size);
     277  double *inversematrix = InverseMatrix(matrix);
    273278  double tmp;
    274279  bool flag;
     
    278283    Center.Zero();
    279284    flag = true;
    280     while (Walker->next != end) {
    281       Walker = Walker->next;
     285    for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    282286#ifdef ADDHYDROGEN
    283       if (Walker->type->Z != 1) {
     287      if ((*iter)->type->Z != 1) {
    284288#endif
    285         Testvector = Walker->x;
     289        Testvector = (*iter)->x;
    286290        Testvector.MatrixMultiplication(inversematrix);
    287291        Translationvector.Zero();
    288         for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
    289          if (Walker->nr < (*Runner)->GetOtherAtom(Walker)->nr) // otherwise we shift one to, the other fro and gain nothing
     292        for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) {
     293         if ((*iter)->nr < (*Runner)->GetOtherAtom((*iter))->nr) // otherwise we shift one to, the other fro and gain nothing
    290294            for (int j=0;j<NDIM;j++) {
    291               tmp = Walker->x[j] - (*Runner)->GetOtherAtom(Walker)->x[j];
     295              tmp = (*iter)->x[j] - (*Runner)->GetOtherAtom(*iter)->x[j];
    292296              if ((fabs(tmp)) > BondDistance) {
    293297                flag = false;
    294                 DoLog(0) && (Log() << Verbose(0) << "Hit: atom " << Walker->getName() << " in bond " << *(*Runner) << " has to be shifted due to " << tmp << "." << endl);
     298                DoLog(0) && (Log() << Verbose(0) << "Hit: atom " << (*iter)->getName() << " in bond " << *(*Runner) << " has to be shifted due to " << tmp << "." << endl);
    295299                if (tmp > 0)
    296300                  Translationvector[j] -= 1.;
     
    306310#ifdef ADDHYDROGEN
    307311        // now also change all hydrogens
    308         for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
    309           if ((*Runner)->GetOtherAtom(Walker)->type->Z == 1) {
    310             Testvector = (*Runner)->GetOtherAtom(Walker)->x;
     312        for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) {
     313          if ((*Runner)->GetOtherAtom((*iter))->type->Z == 1) {
     314            Testvector = (*Runner)->GetOtherAtom((*iter))->x;
    311315            Testvector.MatrixMultiplication(inversematrix);
    312316            Testvector += Translationvector;
     
    320324    }
    321325  } while (!flag);
    322   Free(&matrix);
    323   Free(&inversematrix);
    324 
    325   Center.Scale(1./(double)AtomCount);
     326  delete[](matrix);
     327  delete[](inversematrix);
     328
     329  Center.Scale(1./static_cast<double>(getAtomCount()));
    326330};
    327331
     
    333337void molecule::PrincipalAxisSystem(bool DoRotate)
    334338{
    335   atom *ptr = start;  // start at first in list
    336339  double InertiaTensor[NDIM*NDIM];
    337340  Vector *CenterOfGravity = DetermineCenterOfGravity();
     
    344347
    345348  // sum up inertia tensor
    346   while (ptr->next != end) {
    347     ptr = ptr->next;
    348     Vector x = ptr->x;
     349  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     350    Vector x = (*iter)->x;
    349351    //x.SubtractVector(CenterOfGravity);
    350     InertiaTensor[0] += ptr->type->mass*(x[1]*x[1] + x[2]*x[2]);
    351     InertiaTensor[1] += ptr->type->mass*(-x[0]*x[1]);
    352     InertiaTensor[2] += ptr->type->mass*(-x[0]*x[2]);
    353     InertiaTensor[3] += ptr->type->mass*(-x[1]*x[0]);
    354     InertiaTensor[4] += ptr->type->mass*(x[0]*x[0] + x[2]*x[2]);
    355     InertiaTensor[5] += ptr->type->mass*(-x[1]*x[2]);
    356     InertiaTensor[6] += ptr->type->mass*(-x[2]*x[0]);
    357     InertiaTensor[7] += ptr->type->mass*(-x[2]*x[1]);
    358     InertiaTensor[8] += ptr->type->mass*(x[0]*x[0] + x[1]*x[1]);
     352    InertiaTensor[0] += (*iter)->type->mass*(x[1]*x[1] + x[2]*x[2]);
     353    InertiaTensor[1] += (*iter)->type->mass*(-x[0]*x[1]);
     354    InertiaTensor[2] += (*iter)->type->mass*(-x[0]*x[2]);
     355    InertiaTensor[3] += (*iter)->type->mass*(-x[1]*x[0]);
     356    InertiaTensor[4] += (*iter)->type->mass*(x[0]*x[0] + x[2]*x[2]);
     357    InertiaTensor[5] += (*iter)->type->mass*(-x[1]*x[2]);
     358    InertiaTensor[6] += (*iter)->type->mass*(-x[2]*x[0]);
     359    InertiaTensor[7] += (*iter)->type->mass*(-x[2]*x[1]);
     360    InertiaTensor[8] += (*iter)->type->mass*(x[0]*x[0] + x[1]*x[1]);
    359361  }
    360362  // print InertiaTensor for debugging
     
    394396
    395397    // sum up inertia tensor
    396     ptr = start;
    397     while (ptr->next != end) {
    398       ptr = ptr->next;
    399       Vector x = ptr->x;
    400       //x.SubtractVector(CenterOfGravity);
    401       InertiaTensor[0] += ptr->type->mass*(x[1]*x[1] + x[2]*x[2]);
    402       InertiaTensor[1] += ptr->type->mass*(-x[0]*x[1]);
    403       InertiaTensor[2] += ptr->type->mass*(-x[0]*x[2]);
    404       InertiaTensor[3] += ptr->type->mass*(-x[1]*x[0]);
    405       InertiaTensor[4] += ptr->type->mass*(x[0]*x[0] + x[2]*x[2]);
    406       InertiaTensor[5] += ptr->type->mass*(-x[1]*x[2]);
    407       InertiaTensor[6] += ptr->type->mass*(-x[2]*x[0]);
    408       InertiaTensor[7] += ptr->type->mass*(-x[2]*x[1]);
    409       InertiaTensor[8] += ptr->type->mass*(x[0]*x[0] + x[1]*x[1]);
     398    for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     399      Vector x = (*iter)->x;
     400      InertiaTensor[0] += (*iter)->type->mass*(x[1]*x[1] + x[2]*x[2]);
     401      InertiaTensor[1] += (*iter)->type->mass*(-x[0]*x[1]);
     402      InertiaTensor[2] += (*iter)->type->mass*(-x[0]*x[2]);
     403      InertiaTensor[3] += (*iter)->type->mass*(-x[1]*x[0]);
     404      InertiaTensor[4] += (*iter)->type->mass*(x[0]*x[0] + x[2]*x[2]);
     405      InertiaTensor[5] += (*iter)->type->mass*(-x[1]*x[2]);
     406      InertiaTensor[6] += (*iter)->type->mass*(-x[2]*x[0]);
     407      InertiaTensor[7] += (*iter)->type->mass*(-x[2]*x[1]);
     408      InertiaTensor[8] += (*iter)->type->mass*(x[0]*x[0] + x[1]*x[1]);
    410409    }
    411410    // print InertiaTensor for debugging
     
    431430void molecule::Align(Vector *n)
    432431{
    433   atom *ptr = start;
    434432  double alpha, tmp;
    435433  Vector z_axis;
     
    442440  alpha = atan(-n->at(0)/n->at(2));
    443441  DoLog(1) && (Log() << Verbose(1) << "Z-X-angle: " << alpha << " ... ");
    444   while (ptr->next != end) {
    445     ptr = ptr->next;
    446     tmp = ptr->x[0];
    447     ptr->x[0] =  cos(alpha) * tmp + sin(alpha) * ptr->x[2];
    448     ptr->x[2] = -sin(alpha) * tmp + cos(alpha) * ptr->x[2];
     442  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     443    tmp = (*iter)->x[0];
     444    (*iter)->x[0] =  cos(alpha) * tmp + sin(alpha) * (*iter)->x[2];
     445    (*iter)->x[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->x[2];
    449446    for (int j=0;j<MDSteps;j++) {
    450       tmp = ptr->Trajectory.R.at(j)[0];
    451       ptr->Trajectory.R.at(j)[0] =  cos(alpha) * tmp + sin(alpha) * ptr->Trajectory.R.at(j)[2];
    452       ptr->Trajectory.R.at(j)[2] = -sin(alpha) * tmp + cos(alpha) * ptr->Trajectory.R.at(j)[2];
     447      tmp = (*iter)->Trajectory.R.at(j)[0];
     448      (*iter)->Trajectory.R.at(j)[0] =  cos(alpha) * tmp + sin(alpha) * (*iter)->Trajectory.R.at(j)[2];
     449      (*iter)->Trajectory.R.at(j)[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->Trajectory.R.at(j)[2];
    453450    }
    454451  }
     
    460457
    461458  // rotate on z-y plane
    462   ptr = start;
    463459  alpha = atan(-n->at(1)/n->at(2));
    464460  DoLog(1) && (Log() << Verbose(1) << "Z-Y-angle: " << alpha << " ... ");
    465   while (ptr->next != end) {
    466     ptr = ptr->next;
    467     tmp = ptr->x[1];
    468     ptr->x[1] =  cos(alpha) * tmp + sin(alpha) * ptr->x[2];
    469     ptr->x[2] = -sin(alpha) * tmp + cos(alpha) * ptr->x[2];
     461  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     462    tmp = (*iter)->x[1];
     463    (*iter)->x[1] =  cos(alpha) * tmp + sin(alpha) * (*iter)->x[2];
     464    (*iter)->x[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->x[2];
    470465    for (int j=0;j<MDSteps;j++) {
    471       tmp = ptr->Trajectory.R.at(j)[1];
    472       ptr->Trajectory.R.at(j)[1] =  cos(alpha) * tmp + sin(alpha) * ptr->Trajectory.R.at(j)[2];
    473       ptr->Trajectory.R.at(j)[2] = -sin(alpha) * tmp + cos(alpha) * ptr->Trajectory.R.at(j)[2];
     466      tmp = (*iter)->Trajectory.R.at(j)[1];
     467      (*iter)->Trajectory.R.at(j)[1] =  cos(alpha) * tmp + sin(alpha) * (*iter)->Trajectory.R.at(j)[2];
     468      (*iter)->Trajectory.R.at(j)[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->Trajectory.R.at(j)[2];
    474469    }
    475470  }
     
    495490  Vector a,b,c,d;
    496491  struct lsq_params *par = (struct lsq_params *)params;
    497   atom *ptr = par->mol->start;
    498492
    499493  // initialize vectors
     
    505499  b[2] = gsl_vector_get(x,5);
    506500  // go through all atoms
    507   while (ptr != par->mol->end) {
    508     ptr = ptr->next;
    509     if (ptr->type == ((struct lsq_params *)params)->type) { // for specific type
    510       c = ptr->x - a;
     501  for (molecule::const_iterator iter = par->mol->begin(); iter != par->mol->end(); ++iter) {
     502    if ((*iter)->type == ((struct lsq_params *)params)->type) { // for specific type
     503      c = (*iter)->x - a;
    511504      t = c.ScalarProduct(b);           // get direction parameter
    512505      d = t*b;       // and create vector
  • src/molecule_graph.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "atom.hpp"
     
    1214#include "element.hpp"
    1315#include "helpers.hpp"
     16#include "info.hpp"
    1417#include "linkedcell.hpp"
    1518#include "lists.hpp"
     
    1922#include "World.hpp"
    2023#include "Helpers/fast_functions.hpp"
     24#include "Helpers/Assert.hpp"
     25
    2126
    2227struct BFSAccounting
     
    5459void molecule::CreateAdjacencyListFromDbondFile(ifstream *input)
    5560{
    56 
     61  Info FunctionInfo(__func__);
    5762  // 1 We will parse bonds out of the dbond file created by tremolo.
    5863  int atom1, atom2;
    5964  atom *Walker, *OtherWalker;
    60 
    61   if (!input) {
    62     DoLog(1) && (Log() << Verbose(1) << "Opening silica failed \n");
     65  char line[MAXSTRINGSIZE];
     66
     67  if (input->fail()) {
     68    DoeLog(0) && (eLog() << Verbose(0) << "Opening of bond file failed \n");
     69    performCriticalExit();
    6370  };
    64 
    65   *input >> ws >> atom1;
    66   *input >> ws >> atom2;
    67   DoLog(1) && (Log() << Verbose(1) << "Scanning file\n");
     71  doCountAtoms();
     72
     73  // skip header
     74  input->getline(line,MAXSTRINGSIZE);
     75  DoLog(1) && (Log() << Verbose(1) << "Scanning file ... \n");
    6876  while (!input->eof()) // Check whether we read everything already
    6977  {
    70     *input >> ws >> atom1;
    71     *input >> ws >> atom2;
    72 
     78    input->getline(line,MAXSTRINGSIZE);
     79    stringstream zeile(line);
     80    zeile >> atom1;
     81    zeile >> atom2;
     82
     83    DoLog(2) && (Log() << Verbose(2) << "Looking for atoms " << atom1 << " and " << atom2 << "." << endl);
    7384    if (atom2 < atom1) //Sort indices of atoms in order
    7485      flip(atom1, atom2);
    7586    Walker = FindAtom(atom1);
     87    ASSERT(Walker,"Could not find an atom with the ID given in dbond file");
    7688    OtherWalker = FindAtom(atom2);
     89    ASSERT(OtherWalker,"Could not find an atom with the ID given in dbond file");
    7790    AddBond(Walker, OtherWalker); //Add the bond between the two atoms with respective indices.
    7891  }
     
    103116  atom *Walker = NULL;
    104117  atom *OtherWalker = NULL;
    105   atom **AtomMap = NULL;
    106118  int n[NDIM];
    107119  double MinDistance, MaxDistance;
     
    118130  DoLog(0) && (Log() << Verbose(0) << "Begin of CreateAdjacencyList." << endl);
    119131  // remove every bond from the list
    120   bond *Binder = NULL;
    121   while (last->previous != first) {
    122     Binder = last->previous;
    123     Binder->leftatom->UnregisterBond(Binder);
    124     Binder->rightatom->UnregisterBond(Binder);
    125     removewithoutcheck(Binder);
    126   }
     132  for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
     133    for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin())
     134      if ((*BondRunner)->leftatom == *AtomRunner)
     135        delete((*BondRunner));
    127136  BondCount = 0;
    128137
    129138  // count atoms in molecule = dimension of matrix (also give each unique name and continuous numbering)
    130   CountAtoms();
    131   DoLog(1) && (Log() << Verbose(1) << "AtomCount " << AtomCount << " and bonddistance is " << bonddistance << "." << endl);
    132 
    133   if ((AtomCount > 1) && (bonddistance > 1.)) {
     139  DoLog(1) && (Log() << Verbose(1) << "AtomCount " << getAtomCount() << " and bonddistance is " << bonddistance << "." << endl);
     140
     141  if ((getAtomCount() > 1) && (bonddistance > 1.)) {
    134142    DoLog(2) && (Log() << Verbose(2) << "Creating Linked Cell structure ... " << endl);
    135143    LC = new LinkedCell(this, bonddistance);
     
    137145    // create a list to map Tesselpoint::nr to atom *
    138146    DoLog(2) && (Log() << Verbose(2) << "Creating TesselPoint to atom map ... " << endl);
    139     AtomMap = Calloc<atom *> (AtomCount, "molecule::CreateAdjacencyList - **AtomCount");
    140     Walker = start;
    141     while (Walker->next != end) {
    142       Walker = Walker->next;
    143       AtomMap[Walker->nr] = Walker;
     147
     148    // set numbers for atoms that can later be used
     149    int i=0;
     150    for(internal_iterator iter = atoms.begin();iter!= atoms.end(); ++iter){
     151      (*iter)->nr = i++;
    144152    }
    145153
     
    153161          if (List != NULL) {
    154162            for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    155               Walker = AtomMap[(*Runner)->nr];
    156 //              Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl;
     163              Walker = dynamic_cast<atom*>(*Runner);
     164              ASSERT(Walker,"Tesselpoint that was not an atom retrieved from LinkedNode");
     165              //Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl;
    157166              // 3c. check for possible bond between each atom in this and every one in the 27 cells
    158167              for (n[0] = -1; n[0] <= 1; n[0]++)
     
    164173                      for (LinkedCell::LinkedNodes::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) {
    165174                        if ((*OtherRunner)->nr > Walker->nr) {
    166                           OtherWalker = AtomMap[(*OtherRunner)->nr];
    167 //                          Log() << Verbose(0) << "Current other Atom is " << *OtherWalker << "." << endl;
    168                           const double distance = OtherWalker->x.PeriodicDistanceSquared(Walker->x, cell_size);
    169 //                          Log() << Verbose(1) << "Checking distance " << distance << " against typical bond length of " << bonddistance*bonddistance << "." << endl;
     175                          OtherWalker = dynamic_cast<atom*>(*OtherRunner);
     176                          ASSERT(OtherWalker,"TesselPoint that was not an atom retrieved from LinkedNode");
     177                          //Log() << Verbose(1) << "Checking distance " << OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size) << " against typical bond length of " << bonddistance*bonddistance << "." << endl;
    170178                          (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem);
     179                          const double distance = OtherWalker->x.PeriodicDistanceSquared(Walker->x,cell_size);
    171180                          const bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance);
    172181//                          Log() << Verbose(1) << "MinDistance is " << MinDistance << " and MaxDistance is " << MaxDistance << "." << endl;
     
    188197          }
    189198        }
    190     Free(&AtomMap);
    191199    delete (LC);
    192200    DoLog(1) && (Log() << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << BondDistance << "." << endl);
     
    199207    ActOnAllAtoms( &atom::OutputBondOfAtom );
    200208  } else
    201     DoLog(1) && (Log() << Verbose(1) << "AtomCount is " << AtomCount << ", thus no bonds, no connections!." << endl);
     209    DoLog(1) && (Log() << Verbose(1) << "AtomCount is " << getAtomCount() << ", thus no bonds, no connections!." << endl);
    202210  DoLog(0) && (Log() << Verbose(0) << "End of CreateAdjacencyList." << endl);
    203211  if (free_BG)
     
    206214;
    207215
     216/** Checks for presence of bonds within atom list.
     217 * TODO: more sophisticated check for bond structure (e.g. connected subgraph, ...)
     218 * \return true - bonds present, false - no bonds
     219 */
     220bool molecule::hasBondStructure()
     221{
     222  for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
     223    if (!(*AtomRunner)->ListOfBonds.empty())
     224      return true;
     225  return false;
     226}
     227
     228/** Counts the number of present bonds.
     229 * \return number of bonds
     230 */
     231unsigned int molecule::CountBonds() const
     232{
     233  unsigned int counter = 0;
     234  for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
     235    for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     236      if ((*BondRunner)->leftatom == *AtomRunner)
     237        counter++;
     238  return counter;
     239}
     240
    208241/** Prints a list of all bonds to \a *out.
    209242 * \param output stream
     
    212245{
    213246  DoLog(1) && (Log() << Verbose(1) << endl << "From contents of bond chain list:");
    214   bond *Binder = first;
    215   while (Binder->next != last) {
    216     Binder = Binder->next;
    217     DoLog(0) && (Log() << Verbose(0) << *Binder << "\t" << endl);
    218   }
     247  for(molecule::const_iterator AtomRunner = molecule::begin(); AtomRunner != molecule::end(); ++AtomRunner)
     248    for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     249      if ((*BondRunner)->leftatom == *AtomRunner) {
     250        DoLog(0) && (Log() << Verbose(0) << *(*BondRunner) << "\t" << endl);
     251      }
    219252  DoLog(0) && (Log() << Verbose(0) << endl);
    220253}
     
    241274    DoLog(0) && (Log() << Verbose(0) << " done." << endl);
    242275  } else {
    243     DoLog(1) && (Log() << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << AtomCount << " atoms." << endl);
     276    DoLog(1) && (Log() << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << getAtomCount() << " atoms." << endl);
    244277  }
    245278  DoLog(0) && (Log() << Verbose(0) << No << " bonds could not be corrected." << endl);
     
    260293  MoleculeLeafClass *Subgraphs = NULL;
    261294  class StackClass<bond *> *BackEdgeStack = NULL;
    262   bond *Binder = first;
    263   if ((Binder->next != last) && (Binder->next->Type == Undetermined)) {
    264     DoLog(0) && (Log() << Verbose(0) << "No Depth-First-Search analysis performed so far, calling ..." << endl);
    265     Subgraphs = DepthFirstSearchAnalysis(BackEdgeStack);
    266     while (Subgraphs->next != NULL) {
    267       Subgraphs = Subgraphs->next;
    268       delete (Subgraphs->previous);
    269     }
    270     delete (Subgraphs);
    271     delete[] (MinimumRingSize);
    272   }
    273   while (Binder->next != last) {
    274     Binder = Binder->next;
    275     if (Binder->Cyclic)
    276       NoCyclicBonds++;
    277   }
     295  for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
     296    if ((!(*AtomRunner)->ListOfBonds.empty()) && ((*(*AtomRunner)->ListOfBonds.begin())->Type == Undetermined)) {
     297      DoLog(0) && (Log() << Verbose(0) << "No Depth-First-Search analysis performed so far, calling ..." << endl);
     298      Subgraphs = DepthFirstSearchAnalysis(BackEdgeStack);
     299      while (Subgraphs->next != NULL) {
     300        Subgraphs = Subgraphs->next;
     301        delete (Subgraphs->previous);
     302      }
     303      delete (Subgraphs);
     304      delete[] (MinimumRingSize);
     305      break;
     306    }
     307  for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
     308    for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     309      if ((*BondRunner)->leftatom == *AtomRunner)
     310        if ((*BondRunner)->Cyclic)
     311          NoCyclicBonds++;
    278312  delete (BackEdgeStack);
    279313  return NoCyclicBonds;
     
    461495void DepthFirstSearchAnalysis_Init(struct DFSAccounting &DFS, const molecule * const mol)
    462496{
    463   DFS.AtomStack = new StackClass<atom *> (mol->AtomCount);
     497  DFS.AtomStack = new StackClass<atom *> (mol->getAtomCount());
    464498  DFS.CurrentGraphNr = 0;
    465499  DFS.ComponentNumber = 0;
     
    502536  bond *Binder = NULL;
    503537
    504   if (AtomCount == 0)
     538  if (getAtomCount() == 0)
    505539    return SubGraphs;
    506540  DoLog(0) && (Log() << Verbose(0) << "Begin of DepthFirstSearchAnalysis" << endl);
    507541  DepthFirstSearchAnalysis_Init(DFS, this);
    508542
    509   DFS.Root = start->next;
    510   while (DFS.Root != end) { // if there any atoms at all
     543  for (molecule::const_iterator iter = begin(); iter != end();) {
     544    DFS.Root = *iter;
    511545    // (1) mark all edges unused, empty stack, set atom->GraphNr = -1 for all
    512546    DFS.AtomStack->ClearStack();
     
    548582
    549583    // step on to next root
    550     while ((DFS.Root != end) && (DFS.Root->GraphNr != -1)) {
    551       //Log() << Verbose(1) << "Current next subgraph root candidate is " << Root->Name << "." << endl;
    552       if (DFS.Root->GraphNr != -1) // if already discovered, step on
    553         DFS.Root = DFS.Root->next;
     584    while ((iter != end()) && ((*iter)->GraphNr != -1)) {
     585      //Log() << Verbose(1) << "Current next subgraph root candidate is " << (*iter)->Name << "." << endl;
     586      if ((*iter)->GraphNr != -1) // if already discovered, step on
     587        iter++;
    554588    }
    555589  }
     
    573607{
    574608  NoCyclicBonds = 0;
    575   bond *Binder = first;
    576   while (Binder->next != last) {
    577     Binder = Binder->next;
    578     if (Binder->rightatom->LowpointNr == Binder->leftatom->LowpointNr) { // cyclic ??
    579       Binder->Cyclic = true;
    580       NoCyclicBonds++;
    581     }
    582   }
     609  for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
     610    for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     611      if ((*BondRunner)->leftatom == *AtomRunner)
     612        if ((*BondRunner)->rightatom->LowpointNr == (*BondRunner)->leftatom->LowpointNr) { // cyclic ??
     613          (*BondRunner)->Cyclic = true;
     614          NoCyclicBonds++;
     615        }
    583616}
    584617;
     
    599632void molecule::OutputGraphInfoPerBond() const
    600633{
     634  bond *Binder = NULL;
    601635  DoLog(1) && (Log() << Verbose(1) << "Final graph info for each bond is:" << endl);
    602   bond *Binder = first;
    603   while (Binder->next != last) {
    604     Binder = Binder->next;
    605     DoLog(2) && (Log() << Verbose(2) << ((Binder->Type == TreeEdge) ? "TreeEdge " : "BackEdge ") << *Binder << ": <");
    606     DoLog(0) && (Log() << Verbose(0) << ((Binder->leftatom->SeparationVertex) ? "SP," : "") << "L" << Binder->leftatom->LowpointNr << " G" << Binder->leftatom->GraphNr << " Comp.");
    607     Binder->leftatom->OutputComponentNumber();
    608     DoLog(0) && (Log() << Verbose(0) << " ===  ");
    609     DoLog(0) && (Log() << Verbose(0) << ((Binder->rightatom->SeparationVertex) ? "SP," : "") << "L" << Binder->rightatom->LowpointNr << " G" << Binder->rightatom->GraphNr << " Comp.");
    610     Binder->rightatom->OutputComponentNumber();
    611     DoLog(0) && (Log() << Verbose(0) << ">." << endl);
    612     if (Binder->Cyclic) // cyclic ??
    613       DoLog(3) && (Log() << Verbose(3) << "Lowpoint at each side are equal: CYCLIC!" << endl);
    614   }
     636  for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
     637    for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     638      if ((*BondRunner)->leftatom == *AtomRunner) {
     639        Binder = *BondRunner;
     640        DoLog(2) && (Log() << Verbose(2) << ((Binder->Type == TreeEdge) ? "TreeEdge " : "BackEdge ") << *Binder << ": <");
     641        DoLog(0) && (Log() << Verbose(0) << ((Binder->leftatom->SeparationVertex) ? "SP," : "") << "L" << Binder->leftatom->LowpointNr << " G" << Binder->leftatom->GraphNr << " Comp.");
     642        Binder->leftatom->OutputComponentNumber();
     643        DoLog(0) && (Log() << Verbose(0) << " ===  ");
     644        DoLog(0) && (Log() << Verbose(0) << ((Binder->rightatom->SeparationVertex) ? "SP," : "") << "L" << Binder->rightatom->LowpointNr << " G" << Binder->rightatom->GraphNr << " Comp.");
     645        Binder->rightatom->OutputComponentNumber();
     646        DoLog(0) && (Log() << Verbose(0) << ">." << endl);
     647        if (Binder->Cyclic) // cyclic ??
     648          DoLog(3) && (Log() << Verbose(3) << "Lowpoint at each side are equal: CYCLIC!" << endl);
     649      }
    615650}
    616651;
     
    624659{
    625660  BFS.AtomCount = AtomCount;
    626   BFS.PredecessorList = Calloc<atom*> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: **PredecessorList");
    627   BFS.ShortestPathList = Malloc<int> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: *ShortestPathList");
    628   BFS.ColorList = Calloc<enum Shading> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: *ColorList");
     661  BFS.PredecessorList = new atom*[AtomCount];
     662  BFS.ShortestPathList = new int[AtomCount];
     663  BFS.ColorList = new enum Shading[AtomCount];
    629664  BFS.BFSStack = new StackClass<atom *> (AtomCount);
    630665
    631   for (int i = AtomCount; i--;)
     666  for (int i = AtomCount; i--;) {
    632667    BFS.ShortestPathList[i] = -1;
     668    BFS.PredecessorList[i] = 0;
     669  }
    633670};
    634671
     
    639676void FinalizeBFSAccounting(struct BFSAccounting &BFS)
    640677{
    641   Free(&BFS.PredecessorList);
    642   Free(&BFS.ShortestPathList);
    643   Free(&BFS.ColorList);
     678  delete[](BFS.PredecessorList);
     679  delete[](BFS.ShortestPathList);
     680  delete[](BFS.ColorList);
    644681  delete (BFS.BFSStack);
    645682  BFS.AtomCount = 0;
     
    854891  if (MinRingSize != -1) { // if rings are present
    855892    // go over all atoms
    856     Root = mol->start;
    857     while (Root->next != mol->end) {
    858       Root = Root->next;
    859 
    860       if (MinimumRingSize[Root->GetTrueFather()->nr] == mol->AtomCount) { // check whether MinimumRingSize is set, if not BFS to next where it is
     893    for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     894      Root = *iter;
     895
     896      if (MinimumRingSize[Root->GetTrueFather()->nr] == mol->getAtomCount()) { // check whether MinimumRingSize is set, if not BFS to next where it is
    861897        Walker = Root;
    862898
    863899        //Log() << Verbose(1) << "---------------------------------------------------------------------------------------------------------" << endl;
    864         CyclicStructureAnalysis_BFSToNextCycle(Root, Walker, MinimumRingSize, mol->AtomCount);
     900        CyclicStructureAnalysis_BFSToNextCycle(Root, Walker, MinimumRingSize, mol->getAtomCount());
    865901
    866902      }
     
    892928  int MinRingSize = -1;
    893929
    894   InitializeBFSAccounting(BFS, AtomCount);
     930  InitializeBFSAccounting(BFS, getAtomCount());
    895931
    896932  //Log() << Verbose(1) << "Back edge list - ";
     
    9661002void molecule::ResetAllBondsToUnused() const
    9671003{
    968   bond *Binder = first;
    969   while (Binder->next != last) {
    970     Binder = Binder->next;
    971     Binder->ResetUsed();
    972   }
     1004  for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
     1005    for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     1006      if ((*BondRunner)->leftatom == *AtomRunner)
     1007        (*BondRunner)->ResetUsed();
    9731008}
    9741009;
     
    10041039    line << filename;
    10051040  AdjacencyFile.open(line.str().c_str(), ios::out);
    1006   DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... ");
     1041  DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... " << endl);
    10071042  if (AdjacencyFile != NULL) {
    10081043    AdjacencyFile << "m\tn" << endl;
    10091044    ActOnAllAtoms(&atom::OutputAdjacency, &AdjacencyFile);
    10101045    AdjacencyFile.close();
    1011     DoLog(1) && (Log() << Verbose(1) << "done." << endl);
     1046    DoLog(1) && (Log() << Verbose(1) << "\t... done." << endl);
    10121047  } else {
    1013     DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl);
     1048    DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line.str() << "." << endl);
    10141049    status = false;
    10151050  }
     
    10361071    line << filename;
    10371072  BondFile.open(line.str().c_str(), ios::out);
    1038   DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... ");
     1073  DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... " << endl);
    10391074  if (BondFile != NULL) {
    10401075    BondFile << "m\tn" << endl;
    10411076    ActOnAllAtoms(&atom::OutputBonds, &BondFile);
    10421077    BondFile.close();
    1043     DoLog(1) && (Log() << Verbose(1) << "done." << endl);
     1078    DoLog(1) && (Log() << Verbose(1) << "\t... done." << endl);
    10441079  } else {
    1045     DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl);
     1080    DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line.str() << "." << endl);
    10461081    status = false;
    10471082  }
     
    10561091  filename << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE;
    10571092  File.open(filename.str().c_str(), ios::out);
    1058   DoLog(1) && (Log() << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... ");
     1093  DoLog(1) && (Log() << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... " << endl);
    10591094  if (File == NULL)
    10601095    return false;
    10611096
    10621097  // allocate storage structure
    1063   CurrentBonds = Calloc<int> (8, "molecule::CheckAdjacencyFileAgainstMolecule - CurrentBonds"); // contains parsed bonds of current atom
     1098  CurrentBonds = new int[8]; // contains parsed bonds of current atom
     1099  for(int i=0;i<8;i++)
     1100    CurrentBonds[i] = 0;
    10641101  return true;
    10651102}
     
    10701107  File.close();
    10711108  File.clear();
    1072   Free(&CurrentBonds);
     1109  delete[](CurrentBonds);
    10731110}
    10741111;
     
    10901127        NonMatchNumber++;
    10911128        status = false;
     1129        DoeLog(2) && (eLog() << Verbose(2) << id << " can not be found in list." << endl);
     1130      } else {
    10921131        //Log() << Verbose(0) << "[" << id << "]\t";
    1093       } else {
    1094         //Log() << Verbose(0) << id << "\t";
    10951132      }
    10961133    }
     
    11141151  bool status = true;
    11151152  atom *Walker = NULL;
    1116   char *buffer = NULL;
    11171153  int *CurrentBonds = NULL;
    11181154  int NonMatchNumber = 0; // will number of atoms with differing bond structure
    11191155  size_t CurrentBondsOfAtom = -1;
     1156  const int AtomCount = getAtomCount();
    11201157
    11211158  if (!CheckAdjacencyFileAgainstMolecule_Init(path, File, CurrentBonds)) {
     
    11241161  }
    11251162
    1126   buffer = Malloc<char> (MAXSTRINGSIZE, "molecule::CheckAdjacencyFileAgainstMolecule: *buffer");
     1163  char buffer[MAXSTRINGSIZE];
    11271164  // Parse the file line by line and count the bonds
    11281165  while (!File.eof()) {
     
    11401177      // compare against present bonds
    11411178      CheckAdjacencyFileAgainstMolecule_CompareBonds(status, NonMatchNumber, Walker, CurrentBondsOfAtom, AtomNr, CurrentBonds, ListOfAtoms);
    1142     }
    1143   }
    1144   Free(&buffer);
     1179    } else {
     1180      if (AtomNr != -1)
     1181        DoeLog(2) && (eLog() << Verbose(2) << AtomNr << " is not valid in the range of ids [" << 0 << "," << AtomCount << ")." << endl);
     1182    }
     1183  }
    11451184  CheckAdjacencyFileAgainstMolecule_Finalize(File, CurrentBonds);
    11461185
     
    11961235  BFS.AtomCount = AtomCount;
    11971236  BFS.BondOrder = BondOrder;
    1198   BFS.PredecessorList = Calloc<atom*> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: **PredecessorList");
    1199   BFS.ShortestPathList = Calloc<int> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: *ShortestPathList");
    1200   BFS.ColorList = Malloc<enum Shading> (AtomCount, "molecule::BreadthFirstSearchAdd_Init: *ColorList");
     1237  BFS.PredecessorList = new atom*[AtomCount];
     1238  BFS.ShortestPathList = new int[AtomCount];
     1239  BFS.ColorList = new enum Shading[AtomCount];
    12011240  BFS.BFSStack = new StackClass<atom *> (AtomCount);
    12021241
     
    12071246  // initialise each vertex as white with no predecessor, empty queue, color Root lightgray
    12081247  for (int i = AtomCount; i--;) {
     1248    BFS.PredecessorList[i] = NULL;
    12091249    BFS.ShortestPathList[i] = -1;
    12101250    if ((AddedAtomList != NULL) && (AddedAtomList[i] != NULL)) // mark already present atoms (i.e. Root and maybe others) as visited
     
    12131253      BFS.ColorList[i] = white;
    12141254  }
    1215   //BFS.ShortestPathList[Root->nr] = 0; //is set due to Calloc()
     1255  //BFS.ShortestPathList[Root->nr] = 0; // done by Calloc
    12161256}
    12171257;
     
    12191259void BreadthFirstSearchAdd_Free(struct BFSAccounting &BFS)
    12201260{
    1221   Free(&BFS.PredecessorList);
    1222   Free(&BFS.ShortestPathList);
    1223   Free(&BFS.ColorList);
     1261  delete[](BFS.PredecessorList);
     1262  delete[](BFS.ShortestPathList);
     1263  delete[](BFS.ColorList);
    12241264  delete (BFS.BFSStack);
    12251265  BFS.AtomCount = 0;
     
    13131353    AddedAtomList[Root->nr] = Mol->AddCopyAtom(Root);
    13141354
    1315   BreadthFirstSearchAdd_Init(BFS, Root, BondOrder, AtomCount, AddedAtomList);
     1355  BreadthFirstSearchAdd_Init(BFS, Root, BondOrder, getAtomCount(), AddedAtomList);
    13161356
    13171357  // and go on ... Queue always contains all lightgray vertices
     
    13601400{
    13611401  // reset parent list
    1362   ParentList = Calloc<atom*> (AtomCount, "molecule::BuildInducedSubgraph_Init: **ParentList");
     1402  ParentList = new atom*[AtomCount];
     1403  for (int i=0;i<AtomCount;i++)
     1404    ParentList[i] = NULL;
    13631405  DoLog(3) && (Log() << Verbose(3) << "Resetting ParentList." << endl);
    13641406}
     
    13691411  // fill parent list with sons
    13701412  DoLog(3) && (Log() << Verbose(3) << "Filling Parent List." << endl);
    1371   atom *Walker = mol->start;
    1372   while (Walker->next != mol->end) {
    1373     Walker = Walker->next;
    1374     ParentList[Walker->father->nr] = Walker;
     1413  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     1414    ParentList[(*iter)->father->nr] = (*iter);
    13751415    // Outputting List for debugging
    1376     DoLog(4) && (Log() << Verbose(4) << "Son[" << Walker->father->nr << "] of " << Walker->father << " is " << ParentList[Walker->father->nr] << "." << endl);
    1377   }
    1378 
    1379 }
    1380 ;
     1416    DoLog(4) && (Log() << Verbose(4) << "Son[" << (*iter)->father->nr << "] of " << (*iter)->father << " is " << ParentList[(*iter)->father->nr] << "." << endl);
     1417  }
     1418};
    13811419
    13821420void BuildInducedSubgraph_Finalize(atom **&ParentList)
    13831421{
    1384   Free(&ParentList);
     1422  delete[](ParentList);
    13851423}
    13861424;
     
    13891427{
    13901428  bool status = true;
    1391   atom *Walker = NULL;
    13921429  atom *OtherAtom = NULL;
    13931430  // check each entry of parent list and if ok (one-to-and-onto matching) create bonds
    13941431  DoLog(3) && (Log() << Verbose(3) << "Creating bonds." << endl);
    1395   Walker = Father->start;
    1396   while (Walker->next != Father->end) {
    1397     Walker = Walker->next;
    1398     if (ParentList[Walker->nr] != NULL) {
    1399       if (ParentList[Walker->nr]->father != Walker) {
     1432  for (molecule::const_iterator iter = Father->begin(); iter != Father->end(); ++iter) {
     1433    if (ParentList[(*iter)->nr] != NULL) {
     1434      if (ParentList[(*iter)->nr]->father != (*iter)) {
    14001435        status = false;
    14011436      } else {
    1402         for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
    1403           OtherAtom = (*Runner)->GetOtherAtom(Walker);
     1437        for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) {
     1438          OtherAtom = (*Runner)->GetOtherAtom((*iter));
    14041439          if (ParentList[OtherAtom->nr] != NULL) { // if otheratom is also a father of an atom on this molecule, create the bond
    1405             DoLog(4) && (Log() << Verbose(4) << "Endpoints of Bond " << (*Runner) << " are both present: " << ParentList[Walker->nr]->getName() << " and " << ParentList[OtherAtom->nr]->getName() << "." << endl);
    1406             mol->AddBond(ParentList[Walker->nr], ParentList[OtherAtom->nr], (*Runner)->BondDegree);
     1440            DoLog(4) && (Log() << Verbose(4) << "Endpoints of Bond " << (*Runner) << " are both present: " << ParentList[(*iter)->nr]->getName() << " and " << ParentList[OtherAtom->nr]->getName() << "." << endl);
     1441            mol->AddBond(ParentList[(*iter)->nr], ParentList[OtherAtom->nr], (*Runner)->BondDegree);
    14071442          }
    14081443        }
     
    14271462  bool status = true;
    14281463  atom **ParentList = NULL;
    1429 
    14301464  DoLog(2) && (Log() << Verbose(2) << "Begin of BuildInducedSubgraph." << endl);
    1431   BuildInducedSubgraph_Init(ParentList, Father->AtomCount);
     1465  BuildInducedSubgraph_Init(ParentList, Father->getAtomCount());
    14321466  BuildInducedSubgraph_FillParentList(this, Father, ParentList);
    14331467  status = BuildInducedSubgraph_CreateBondsFromParent(this, Father, ParentList);
  • src/molecule_pointcloud.cpp

    r0c7ed8 r1dc9ec  
    66 */
    77
     8#include "Helpers/MemDebug.hpp"
     9
    810#include "atom.hpp"
    911#include "config.hpp"
     12#include "info.hpp"
    1013#include "memoryallocator.hpp"
    1114#include "molecule.hpp"
     
    3134};
    3235
    33 /** Return current atom in the list.
    34  * \return pointer to atom or NULL if none present
     36
     37/** PointCloud implementation of GoPoint
     38 * Uses atoms and STL stuff.
    3539 */
    36 TesselPoint *molecule::GetPoint() const
     40TesselPoint* molecule::GetPoint() const
    3741{
    38   if ((InternalPointer != start) && (InternalPointer != end))
    39     return InternalPointer;
    40   else
    41     return NULL;
     42  return (*InternalPointer);
    4243};
    4344
    44 /** Return pointer to one after last atom in the list.
    45  * \return pointer to end marker
    46  */
    47 TesselPoint *molecule::GetTerminalPoint() const
    48 {
    49   return end;
    50 };
    51 
    52 /** Return the greatest index of all atoms in the list.
    53  * \return greatest index
    54  */
    55 int molecule::GetMaxId() const
    56 {
    57   return last_atom;
    58 };
    59 
    60 /** Go to next atom.
    61  * Stops at last one.
     45/** PointCloud implementation of GoToNext.
     46 * Uses atoms and STL stuff.
    6247 */
    6348void molecule::GoToNext() const
    6449{
    65   if (InternalPointer != end)
    66     InternalPointer = InternalPointer->next;
     50  if (InternalPointer != atoms.end())
     51    InternalPointer++;
    6752};
    6853
    69 /** Go to previous atom.
    70  * Stops at first one.
    71  */
    72 void molecule::GoToPrevious() const
    73 {
    74   if (InternalPointer->previous != start)
    75     InternalPointer = InternalPointer->previous;
    76 };
    77 
    78 /** Goes to first atom.
     54/** PointCloud implementation of GoToFirst.
     55 * Uses atoms and STL stuff.
    7956 */
    8057void molecule::GoToFirst() const
    8158{
    82   InternalPointer = start->next;
     59  InternalPointer = atoms.begin();
    8360};
    8461
    85 /** Goes to last atom.
    86  */
    87 void molecule::GoToLast() const
    88 {
    89   InternalPointer = end->previous;
    90 };
    91 
    92 /** Checks whether we have any atoms in molecule.
    93  * \return true - no atoms, false - not empty
     62/** PointCloud implementation of IsEmpty.
     63 * Uses atoms and STL stuff.
    9464 */
    9565bool molecule::IsEmpty() const
    9666{
    97   return (start->next == end);
     67  return (empty());
    9868};
    9969
    100 /** Checks whether we are at the last atom
    101  * \return true - current atom is last one, false - is not last one
     70/** PointCloud implementation of IsLast.
     71 * Uses atoms and STL stuff.
    10272 */
    10373bool molecule::IsEnd() const
    10474{
    105   return (InternalPointer == end);
     75  return (InternalPointer == atoms.end());
    10676};
     77
     78int molecule::GetMaxId() const {
     79  return getAtomCount();
     80}
  • src/molecule_template.hpp

    r0c7ed8 r1dc9ec  
    2424template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() ) const
    2525    {
    26   atom *Walker = start;
    27   while (Walker->next != end) {
    28     Walker = Walker->next;
    29     ((Walker->node)->*f)();
     26  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     27    (((*iter)->node)->*f)();
    3028  }
    3129};
    3230template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() const ) const
    3331    {
    34   atom *Walker = start;
    35   while (Walker->next != end) {
    36     Walker = Walker->next;
    37     ((Walker->node)->*f)();
     32  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     33    (((*iter)->node)->*f)();
    3834  }
    3935};
     
    4137template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T), T t ) const
    4238{
    43   atom *Walker = start;
    44   while (Walker->next != end) {
    45     Walker = Walker->next;
    46     ((Walker->node)->*f)(t);
     39  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     40    (((*iter)->node)->*f)(t);
    4741  }
    4842};
    4943template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T) const, T t ) const
    5044{
    51   atom *Walker = start;
    52   while (Walker->next != end) {
    53     Walker = Walker->next;
    54     ((Walker->node)->*f)(t);
     45  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     46    (((*iter)->node)->*f)(t);
    5547  }
    5648};
    5749template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T&), T &t ) const
    5850{
    59   atom *Walker = start;
    60   while (Walker->next != end) {
    61     Walker = Walker->next;
    62     ((Walker->node)->*f)(t);
     51  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     52    (((*iter)->node)->*f)(t);
    6353  }
    6454};
    6555template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T&) const, T &t ) const
    6656{
    67   atom *Walker = start;
    68   while (Walker->next != end) {
    69     Walker = Walker->next;
    70     ((Walker->node)->*f)(t);
     57  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     58    (((*iter)->node)->*f)(t);
    7159  }
    7260};
     
    7462template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const
    7563{
    76   atom *Walker = start;
    77   while (Walker->next != end) {
    78     Walker = Walker->next;
    79     ((Walker->node)->*f)(t, u);
     64  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     65    (((*iter)->node)->*f)(t, u);
    8066  }
    8167};
    8268template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) const
    8369{
    84   atom *Walker = start;
    85   while (Walker->next != end) {
    86     Walker = Walker->next;
    87     ((Walker->node)->*f)(t, u);
     70  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     71    (((*iter)->node)->*f)(t, u);
    8872  }
    8973};
     
    9175template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) const
    9276{
    93   atom *Walker = start;
    94   while (Walker->next != end) {
    95     Walker = Walker->next;
    96     ((Walker->node)->*f)(t, u, v);
     77  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     78    (((*iter)->node)->*f)(t, u, v);
    9779  }
    9880};
    9981template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V) const, T t, U u, V v) const
    10082{
    101   atom *Walker = start;
    102   while (Walker->next != end) {
    103     Walker = Walker->next;
    104     ((Walker->node)->*f)(t, u, v);
     83  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     84    (((*iter)->node)->*f)(t, u, v);
    10585  }
    10686};
     
    11292{
    11393  res result = 0;
    114   atom *Walker = start;
    115   while (Walker->next != end) {
    116     Walker = Walker->next;
    117     result += (Walker->*f)();
     94  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     95    result += ((*iter)->*f)();
    11896  }
    11997  return result;
     
    122100{
    123101  res result = 0;
    124   atom *Walker = start;
    125   while (Walker->next != end) {
    126     Walker = Walker->next;
    127     result += (Walker->*f)();
     102  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     103    result += ((*iter)->*f)();
    128104  }
    129105  return result;
     
    133109{
    134110  res result = 0;
    135   atom *Walker = start;
    136   while (Walker->next != end) {
    137     Walker = Walker->next;
    138     result += (Walker->*f)(t);
     111  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     112    result += ((*iter)->*f)(t);
    139113  }
    140114  return result;
     
    143117{
    144118  res result = 0;
    145   atom *Walker = start;
    146   while (Walker->next != end) {
    147     Walker = Walker->next;
    148     result += (Walker->*f)(t);
     119  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     120    result += ((*iter)->*f)(t);
    149121  }
    150122  return result;
     
    157129template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *)) const
    158130{
    159   atom *Walker = start;
    160   while (Walker->next != end) {
    161     Walker = Walker->next;
    162     (*f)(Walker);
     131  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     132    (*f)((*iter));
    163133  }
    164134};
    165135template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *) const) const
    166136{
    167   atom *Walker = start;
    168   while (Walker->next != end) {
    169     Walker = Walker->next;
    170     (*f)(Walker);
     137  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     138    (*f)((*iter));
    171139  }
    172140};
     
    177145template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy) const
    178146{
    179   atom *Walker = start;
    180   while (Walker->next != end) {
    181     Walker = Walker->next;
    182     (copy->*f)(Walker);
     147  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     148    (copy->*f)((*iter));
    183149  }
    184150};
    185151template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const, molecule *copy) const
    186152{
    187   atom *Walker = start;
    188   while (Walker->next != end) {
    189     Walker = Walker->next;
    190     (copy->*f)(Walker);
     153  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     154    (copy->*f)((*iter));
    191155  }
    192156};
     
    197161template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () ) const
    198162{
    199   atom *Walker = start;
    200   while (Walker->next != end) {
    201     Walker = Walker->next;
    202     if ((Walker->*condition)())
    203       (copy->*f)(Walker);
     163  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     164    if (((*iter)->*condition)())
     165      (copy->*f)((*iter));
    204166  }
    205167};
    206168template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () const ) const
    207169{
    208   atom *Walker = start;
    209   while (Walker->next != end) {
    210     Walker = Walker->next;
    211     if ((Walker->*condition)())
    212       (copy->*f)(Walker);
     170  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     171    if (((*iter)->*condition)())
     172      (copy->*f)((*iter));
    213173  }
    214174};
    215175template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) () ) const
    216176{
    217   atom *Walker = start;
    218   while (Walker->next != end) {
    219     Walker = Walker->next;
    220     if ((Walker->*condition)())
    221       (copy->*f)(Walker);
     177  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     178    if (((*iter)->*condition)())
     179      (copy->*f)((*iter));
    222180  }
    223181};
    224182template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) () const ) const
    225183{
    226   atom *Walker = start;
    227   while (Walker->next != end) {
    228     Walker = Walker->next;
    229     if ((Walker->*condition)())
    230       (copy->*f)(Walker);
     184  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     185    if (((*iter)->*condition)())
     186      (copy->*f)((*iter));
    231187  }
    232188};
     
    234190template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T), T t ) const
    235191{
    236   atom *Walker = start;
    237   while (Walker->next != end) {
    238     Walker = Walker->next;
    239     if ((Walker->*condition)(t))
    240       (copy->*f)(Walker);
     192  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     193    if (((*iter)->*condition)(t))
     194      (copy->*f)((*iter));
    241195  }
    242196};
    243197template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T) const, T t ) const
    244198{
    245   atom *Walker = start;
    246   while (Walker->next != end) {
    247     Walker = Walker->next;
    248     if ((Walker->*condition)(t))
    249       (copy->*f)(Walker);
     199  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     200    if (((*iter)->*condition)(t))
     201      (copy->*f)((*iter));
    250202  }
    251203};
    252204template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T), T t ) const
    253205{
    254   atom *Walker = start;
    255   while (Walker->next != end) {
    256     Walker = Walker->next;
    257     if ((Walker->*condition)(t))
    258       (copy->*f)(Walker);
     206  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     207    if (((*iter)->*condition)(t))
     208      (copy->*f)((*iter));
    259209  }
    260210};
    261211template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T) const, T t ) const
    262212{
    263   atom *Walker = start;
    264   while (Walker->next != end) {
    265     Walker = Walker->next;
    266     if ((Walker->*condition)(t))
    267       (copy->*f)(Walker);
     213  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     214    if (((*iter)->*condition)(t))
     215      (copy->*f)((*iter));
    268216  }
    269217};
     
    271219template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U), T t, U u ) const
    272220{
    273   atom *Walker = start;
    274   while (Walker->next != end) {
    275     Walker = Walker->next;
    276     if ((Walker->*condition)(t,u))
    277       (copy->*f)(Walker);
     221  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     222    if (((*iter)->*condition)(t,u))
     223      (copy->*f)((*iter));
    278224  }
    279225};
    280226template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U) const, T t, U u ) const
    281227{
    282   atom *Walker = start;
    283   while (Walker->next != end) {
    284     Walker = Walker->next;
    285     if ((Walker->*condition)(t,u))
    286       (copy->*f)(Walker);
     228  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     229    if (((*iter)->*condition)(t,u))
     230      (copy->*f)((*iter));
    287231  }
    288232};
    289233template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U), T t, U u ) const
    290234{
    291   atom *Walker = start;
    292   while (Walker->next != end) {
    293     Walker = Walker->next;
    294     if ((Walker->*condition)(t,u))
    295       (copy->*f)(Walker);
     235  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     236    if (((*iter)->*condition)(t,u))
     237      (copy->*f)((*iter));
    296238  }
    297239};
    298240template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U) const, T t, U u ) const
    299241{
    300   atom *Walker = start;
    301   while (Walker->next != end) {
    302     Walker = Walker->next;
    303     if ((Walker->*condition)(t,u))
    304       (copy->*f)(Walker);
     242  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     243    if (((*iter)->*condition)(t,u))
     244      (copy->*f)((*iter));
    305245  }
    306246};
     
    308248template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ) const
    309249{
    310   atom *Walker = start;
    311   while (Walker->next != end) {
    312     Walker = Walker->next;
    313     if ((Walker->*condition)(t,u,v))
    314       (copy->*f)(Walker);
     250  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     251    if (((*iter)->*condition)(t,u,v))
     252      (copy->*f)((*iter));
    315253  }
    316254};
    317255template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V) const, T t, U u, V v ) const
    318256{
    319   atom *Walker = start;
    320   while (Walker->next != end) {
    321     Walker = Walker->next;
    322     if ((Walker->*condition)(t,u,v))
    323       (copy->*f)(Walker);
     257  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     258    if (((*iter)->*condition)(t,u,v))
     259      (copy->*f)((*iter));
    324260  }
    325261};
    326262template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ) const
    327263{
    328   atom *Walker = start;
    329   while (Walker->next != end) {
    330     Walker = Walker->next;
    331     if ((Walker->*condition)(t,u,v))
    332       (copy->*f)(Walker);
     264  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     265    if (((*iter)->*condition)(t,u,v))
     266      (copy->*f)((*iter));
    333267  }
    334268};
    335269template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U, V) const, T t, U u, V v ) const
    336270{
    337   atom *Walker = start;
    338   while (Walker->next != end) {
    339     Walker = Walker->next;
    340     if ((Walker->*condition)(t,u,v))
    341       (copy->*f)(Walker);
     271  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     272    if (((*iter)->*condition)(t,u,v))
     273      (copy->*f)((*iter));
    342274  }
    343275};
     
    348280template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)()) const
    349281{
    350   atom *Walker = start;
    351   while (Walker->next != end) {
    352     Walker = Walker->next;
    353     (Walker->*f)();
     282  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     283    ((*iter)->*f)();
    354284  }
    355285};
    356286template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)() const) const
    357287{
    358   atom *Walker = start;
    359   while (Walker->next != end) {
    360     Walker = Walker->next;
    361     (Walker->*f)();
     288  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     289    ((*iter)->*f)();
    362290  }
    363291};
     
    365293template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T), T t ) const
    366294{
    367   atom *Walker = start;
    368   while (Walker->next != end) {
    369     Walker = Walker->next;
    370     (Walker->*f)(t);
     295  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     296    ((*iter)->*f)(t);
    371297  }
    372298};
    373299template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T) const, T t ) const
    374300{
    375   atom *Walker = start;
    376   while (Walker->next != end) {
    377     Walker = Walker->next;
    378     (Walker->*f)(t);
     301  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     302    ((*iter)->*f)(t);
    379303  }
    380304};
     
    382306template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) const
    383307{
    384   atom *Walker = start;
    385   while (Walker->next != end) {
    386     Walker = Walker->next;
    387     (Walker->*f)(t, u);
     308  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     309    ((*iter)->*f)(t, u);
    388310  }
    389311};
    390312template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u ) const
    391313{
    392   atom *Walker = start;
    393   while (Walker->next != end) {
    394     Walker = Walker->next;
    395     (Walker->*f)(t, u);
     314  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     315    ((*iter)->*f)(t, u);
    396316  }
    397317};
     
    399319template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V), T t, U u, V v) const
    400320{
    401   atom *Walker = start;
    402   while (Walker->next != end) {
    403     Walker = Walker->next;
    404     (Walker->*f)(t, u, v);
     321  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     322    ((*iter)->*f)(t, u, v);
    405323  }
    406324};
    407325template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V) const, T t, U u, V v) const
    408326{
    409   atom *Walker = start;
    410   while (Walker->next != end) {
    411     Walker = Walker->next;
    412     (Walker->*f)(t, u, v);
     327  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     328    ((*iter)->*f)(t, u, v);
    413329  }
    414330};
     
    416332template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W), T t, U u, V v, W w) const
    417333{
    418   atom *Walker = start;
    419   while (Walker->next != end) {
    420     Walker = Walker->next;
    421     (Walker->*f)(t, u, v, w);
     334  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     335    ((*iter)->*f)(t, u, v, w);
    422336  }
    423337};
    424338template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W) const, T t, U u, V v, W w) const
    425339{
    426   atom *Walker = start;
    427   while (Walker->next != end) {
    428     Walker = Walker->next;
    429     (Walker->*f)(t, u, v, w);
     340  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     341    ((*iter)->*f)(t, u, v, w);
    430342  }
    431343};
     
    436348template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *) ) const
    437349{
    438   atom *Walker = start;
    439350  int inc = 1;
    440   while (Walker->next != end) {
    441     Walker = Walker->next;
    442     (*Setor) (&array[(Walker->*index)], &inc);
     351  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     352    (*Setor) (&array[((*iter)->*index)], &inc);
    443353  }
    444354};
    445355template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T value ) const
    446356{
    447   atom *Walker = start;
    448   while (Walker->next != end) {
    449     Walker = Walker->next;
    450     (*Setor) (&array[(Walker->*index)], &value);
     357  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     358    (*Setor) (&array[((*iter)->*index)], &value);
    451359  }
    452360};
    453361template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T *value ) const
    454362{
    455   atom *Walker = start;
    456   while (Walker->next != end) {
    457     Walker = Walker->next;
    458     (*Setor) (&array[(Walker->*index)], value);
     363  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     364    (*Setor) (&array[((*iter)->*index)], value);
    459365  }
    460366};
     
    462368template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *) ) const
    463369{
    464   atom *Walker = start;
    465370  int inc = 1;
    466   while (Walker->next != end) {
    467     Walker = Walker->next;
    468     (*Setor) (&array[(Walker->type->*index)], &inc);
     371  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     372    (*Setor) (&array[((*iter)->type->*index)], &inc);
    469373  }
    470374};
    471375template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T value ) const
    472376{
    473   atom *Walker = start;
    474   while (Walker->next != end) {
    475     Walker = Walker->next;
    476     (*Setor) (&array[(Walker->type->*index)], &value);
     377  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     378    (*Setor) (&array[((*iter)->type->*index)], &value);
    477379  }
    478380};
    479381template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T *value ) const
    480382{
    481   atom *Walker = start;
    482   while (Walker->next != end) {
    483     Walker = Walker->next;
    484     (*Setor) (&array[(Walker->type->*index)], value);
     383  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     384    (*Setor) (&array[((*iter)->type->*index)], value);
    485385  }
    486386};
     
    488388template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ atom::*value ) const
    489389{
    490   atom *Walker = start;
    491   while (Walker->next != end) {
    492     Walker = Walker->next;
    493     array[(Walker->*index)] = (Walker->*Setor) (Walker->*value);
     390  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     391    array[((*iter)->*index)] = ((*iter)->*Setor) ((*iter)->*value);
    494392  }
    495393};
    496394template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ atom::*value ) const
    497395{
    498   atom *Walker = start;
    499   while (Walker->next != end) {
    500     Walker = Walker->next;
    501     array[(Walker->*index)] = (Walker->*Setor) (Walker->*value);
     396  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     397    array[((*iter)->*index)] = ((*iter)->*Setor) ((*iter)->*value);
    502398  }
    503399};
    504400template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ &vect ) const
    505401{
    506   atom *Walker = start;
    507   while (Walker->next != end) {
    508     Walker = Walker->next;
    509     array[(Walker->*index)] = (Walker->*Setor) (vect);
     402  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     403    array[((*iter)->*index)] = ((*iter)->*Setor) (vect);
    510404  }
    511405};
    512406template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ &vect ) const
    513407{
    514   atom *Walker = start;
    515   while (Walker->next != end) {
    516     Walker = Walker->next;
    517     array[(Walker->*index)] = (Walker->*Setor) (vect);
     408  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     409    array[((*iter)->*index)] = ((*iter)->*Setor) (vect);
    518410  }
    519411};
    520412template <typename T, typename typ, typename typ2> void molecule::SetAtomValueToIndexedArray ( T *array, int typ::*index, T typ2::*value ) const
    521413{
    522   atom *Walker = start;
    523   while (Walker->next != end) {
    524     Walker = Walker->next;
    525     Walker->*value = array[(Walker->*index)];
    526     //Log() << Verbose(2) << *Walker << " gets " << (Walker->*value); << endl;
     414  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     415    (*iter)->*value = array[((*iter)->*index)];
     416    //Log() << Verbose(2) << *(*iter) << " gets " << ((*iter)->*value); << endl;
    527417  }
    528418};
     
    530420template <typename T, typename typ> void molecule::SetAtomValueToValue ( T value, T typ::*ptr ) const
    531421{
    532   atom *Walker = start;
    533   while (Walker->next != end) {
    534     Walker = Walker->next;
    535     Walker->*ptr = value;
    536     //Log() << Verbose(2) << *Walker << " gets " << (Walker->*ptr) << endl;
     422  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     423    (*iter)->*ptr = value;
     424    //Log() << Verbose(2) << *(*iter) << " gets " << ((*iter)->*ptr) << endl;
    537425  }
    538426};
  • src/moleculelist.cpp

    r0c7ed8 r1dc9ec  
    44 *
    55 */
     6
     7#include "Helpers/MemDebug.hpp"
    68
    79#include <cstring>
     
    2022#include "memoryallocator.hpp"
    2123#include "periodentafel.hpp"
    22 #include "World.hpp"
     24#include "Helpers/Assert.hpp"
     25
     26#include "Helpers/Assert.hpp"
    2327
    2428/*********************************** Functions for class MoleculeListClass *************************/
     
    2731 */
    2832MoleculeListClass::MoleculeListClass(World *_world) :
     33  Observable("MoleculeListClass"),
    2934  world(_world)
    3035{
     
    3843MoleculeListClass::~MoleculeListClass()
    3944{
    40   DoLog(3) && (Log() << Verbose(3) << this << ": Freeing ListOfMolcules." << endl);
    41   for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
    42     DoLog(4) && (Log() << Verbose(4) << "ListOfMolecules: Freeing " << *ListRunner << "." << endl);
    43     world->destroyMolecule(*ListRunner);
    44   }
    45   DoLog(4) && (Log() << Verbose(4) << "Freeing ListOfMolecules." << endl);
     45  DoLog(4) && (Log() << Verbose(4) << "Clearing ListOfMolecules." << endl);
     46  for(MoleculeList::iterator MolRunner = ListOfMolecules.begin(); MolRunner != ListOfMolecules.end(); ++MolRunner)
     47    (*MolRunner)->signOff(this);
    4648  ListOfMolecules.clear(); // empty list
    4749};
     
    4951/** Insert a new molecule into the list and set its number.
    5052 * \param *mol molecule to add to list.
    51  * \return true - add successful
    5253 */
    5354void MoleculeListClass::insert(molecule *mol)
     
    5960};
    6061
     62/** Erases a molecule from the list.
     63 * \param *mol molecule to add to list.
     64 */
     65void MoleculeListClass::erase(molecule *mol)
     66{
     67  OBSERVE;
     68  mol->signOff(this);
     69  ListOfMolecules.remove(mol);
     70};
     71
    6172/** Compare whether two molecules are equal.
    6273 * \param *a molecule one
     
    6980  int Count, Counter, aCounter, bCounter;
    7081  int flag;
    71   atom *aWalker = NULL;
    72   atom *bWalker = NULL;
    7382
    7483  // sort each atom list and put the numbers into a list, then go through
    7584  //Log() << Verbose(0) << "Comparing fragment no. " << *(molecule **)a << " to " << *(molecule **)b << "." << endl;
    76   if ((**(molecule **) a).AtomCount < (**(molecule **) b).AtomCount) {
     85  // Yes those types are awkward... but check it for yourself it checks out this way
     86  molecule *const *mol1_ptr= static_cast<molecule *const *>(a);
     87  molecule *mol1 = *mol1_ptr;
     88  molecule *const *mol2_ptr= static_cast<molecule *const *>(b);
     89  molecule *mol2 = *mol2_ptr;
     90  if (mol1->getAtomCount() < mol2->getAtomCount()) {
    7791    return -1;
    7892  } else {
    79     if ((**(molecule **) a).AtomCount > (**(molecule **) b).AtomCount)
     93    if (mol1->getAtomCount() > mol2->getAtomCount())
    8094      return +1;
    8195    else {
    82       Count = (**(molecule **) a).AtomCount;
     96      Count = mol1->getAtomCount();
    8397      aList = new int[Count];
    8498      bList = new int[Count];
    8599
    86100      // fill the lists
    87       aWalker = (**(molecule **) a).start;
    88       bWalker = (**(molecule **) b).start;
    89101      Counter = 0;
    90102      aCounter = 0;
    91103      bCounter = 0;
    92       while ((aWalker->next != (**(molecule **) a).end) && (bWalker->next != (**(molecule **) b).end)) {
    93         aWalker = aWalker->next;
    94         bWalker = bWalker->next;
    95         if (aWalker->GetTrueFather() == NULL)
     104      molecule::const_iterator aiter = mol1->begin();
     105      molecule::const_iterator biter = mol2->begin();
     106      for (;(aiter != mol1->end()) && (biter != mol2->end());
     107          ++aiter, ++biter) {
     108        if ((*aiter)->GetTrueFather() == NULL)
    96109          aList[Counter] = Count + (aCounter++);
    97110        else
    98           aList[Counter] = aWalker->GetTrueFather()->nr;
    99         if (bWalker->GetTrueFather() == NULL)
     111          aList[Counter] = (*aiter)->GetTrueFather()->nr;
     112        if ((*biter)->GetTrueFather() == NULL)
    100113          bList[Counter] = Count + (bCounter++);
    101114        else
    102           bList[Counter] = bWalker->GetTrueFather()->nr;
     115          bList[Counter] = (*biter)->GetTrueFather()->nr;
    103116        Counter++;
    104117      }
    105118      // check if AtomCount was for real
    106119      flag = 0;
    107       if ((aWalker->next == (**(molecule **) a).end) && (bWalker->next != (**(molecule **) b).end)) {
     120      if ((aiter == mol1->end()) && (biter != mol2->end())) {
    108121        flag = -1;
    109122      } else {
    110         if ((aWalker->next != (**(molecule **) a).end) && (bWalker->next == (**(molecule **) b).end))
     123        if ((aiter != mol1->end()) && (biter == mol2->end()))
    111124          flag = 1;
    112125      }
     
    142155void MoleculeListClass::Enumerate(ostream *out)
    143156{
    144   atom *Walker = NULL;
    145157  periodentafel *periode = World::getInstance().getPeriode();
    146158  std::map<atomicNumber_t,unsigned int> counts;
     
    158170      // count atoms per element and determine size of bounding sphere
    159171      size=0.;
    160       Walker = (*ListRunner)->start;
    161       while (Walker->next != (*ListRunner)->end) {
    162         Walker = Walker->next;
    163         counts[Walker->type->getNumber()]++;
    164         if (Walker->x.DistanceSquared(Origin) > size)
    165           size = Walker->x.DistanceSquared(Origin);
     172      for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) {
     173        counts[(*iter)->type->getNumber()]++;
     174        if ((*iter)->x.DistanceSquared(Origin) > size)
     175          size = (*iter)->x.DistanceSquared(Origin);
    166176      }
    167177      // output Index, Name, number of atoms, chemical formula
    168       (*out) << ((*ListRunner)->ActiveFlag ? "*" : " ") << (*ListRunner)->IndexNr << "\t" << (*ListRunner)->name << "\t\t" << (*ListRunner)->AtomCount << "\t";
     178      (*out) << ((*ListRunner)->ActiveFlag ? "*" : " ") << (*ListRunner)->IndexNr << "\t" << (*ListRunner)->name << "\t\t" << (*ListRunner)->getAtomCount() << "\t";
    169179
    170180      std::map<atomicNumber_t,unsigned int>::reverse_iterator iter;
     
    202212
    203213  // put all molecules of src into mol
    204   atom *Walker = srcmol->start;
    205   atom *NextAtom = Walker->next;
    206   while (NextAtom != srcmol->end) {
    207     Walker = NextAtom;
    208     NextAtom = Walker->next;
    209     srcmol->UnlinkAtom(Walker);
    210     mol->AddAtom(Walker);
     214  molecule::iterator runner;
     215  for (molecule::iterator iter = srcmol->begin(); iter != srcmol->end(); ++iter) {
     216    runner = iter++;
     217    srcmol->UnlinkAtom((*runner));
     218    mol->AddAtom((*runner));
    211219  }
    212220
     
    228236
    229237  // put all molecules of src into mol
    230   atom *Walker = srcmol->start;
    231   atom *NextAtom = Walker->next;
    232   while (NextAtom != srcmol->end) {
    233     Walker = NextAtom;
    234     NextAtom = Walker->next;
    235     Walker = mol->AddCopyAtom(Walker);
     238  atom *Walker = NULL;
     239  for (molecule::iterator iter = srcmol->begin(); iter != srcmol->end(); ++iter) {
     240    Walker = mol->AddCopyAtom((*iter));
    236241    Walker->father = Walker;
    237242  }
     
    330335
    331336  // prepare index list for bonds
    332   srcmol->CountAtoms();
    333   atom ** CopyAtoms = new atom*[srcmol->AtomCount];
    334   for(int i=0;i<srcmol->AtomCount;i++)
     337  atom ** CopyAtoms = new atom*[srcmol->getAtomCount()];
     338  for(int i=0;i<srcmol->getAtomCount();i++)
    335339    CopyAtoms[i] = NULL;
    336340
    337341  // for each of the source atoms check whether we are in- or outside and add copy atom
    338   atom *Walker = srcmol->start;
    339342  int nr=0;
    340   while (Walker->next != srcmol->end) {
    341     Walker = Walker->next;
    342     DoLog(2) && (Log() << Verbose(2) << "INFO: Current Walker is " << *Walker << "." << endl);
    343     if (!TesselStruct->IsInnerPoint(Walker->x, LCList)) {
    344       CopyAtoms[Walker->nr] = Walker->clone();
    345       mol->AddAtom(CopyAtoms[Walker->nr]);
     343  for (molecule::const_iterator iter = srcmol->begin(); iter != srcmol->end(); ++iter) {
     344    DoLog(2) && (Log() << Verbose(2) << "INFO: Current Walker is " << **iter << "." << endl);
     345    if (!TesselStruct->IsInnerPoint((*iter)->x, LCList)) {
     346      CopyAtoms[(*iter)->nr] = (*iter)->clone();
     347      mol->AddAtom(CopyAtoms[(*iter)->nr]);
    346348      nr++;
    347349    } else {
     
    349351    }
    350352  }
    351   DoLog(1) && (Log() << Verbose(1) << nr << " of " << srcmol->AtomCount << " atoms have been merged.");
     353  DoLog(1) && (Log() << Verbose(1) << nr << " of " << srcmol->getAtomCount() << " atoms have been merged.");
    352354
    353355  // go through all bonds and add as well
    354   bond *Binder = srcmol->first;
    355   while(Binder->next != srcmol->last) {
    356     Binder = Binder->next;
    357     DoLog(3) && (Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl);
    358     mol->AddBond(CopyAtoms[Binder->leftatom->nr], CopyAtoms[Binder->rightatom->nr], Binder->BondDegree);
    359   }
     356  for(molecule::iterator AtomRunner = srcmol->begin(); AtomRunner != srcmol->end(); ++AtomRunner)
     357    for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     358      if ((*BondRunner)->leftatom == *AtomRunner) {
     359        DoLog(3) && (Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[(*BondRunner)->leftatom->nr] << " and " << *CopyAtoms[(*BondRunner)->rightatom->nr]<< "." << endl);
     360        mol->AddBond(CopyAtoms[(*BondRunner)->leftatom->nr], CopyAtoms[(*BondRunner)->rightatom->nr], (*BondRunner)->BondDegree);
     361      }
    360362  delete(LCList);
    361363  return true;
     
    382384bool MoleculeListClass::AddHydrogenCorrection(char *path)
    383385{
    384   atom *Walker = NULL;
    385   atom *Runner = NULL;
    386386  bond *Binder = NULL;
    387387  double ***FitConstant = NULL, **correction = NULL;
     
    427427
    428428  // 0b. allocate memory for constants
    429   FitConstant = Calloc<double**>(3, "MoleculeListClass::AddHydrogenCorrection: ***FitConstant");
     429  FitConstant = new double**[3];
    430430  for (int k = 0; k < 3; k++) {
    431     FitConstant[k] = Calloc<double*>(a, "MoleculeListClass::AddHydrogenCorrection: **FitConstant[]");
     431    FitConstant[k] = new double*[a];
    432432    for (int i = a; i--;) {
    433       FitConstant[k][i] = Calloc<double>(b, "MoleculeListClass::AddHydrogenCorrection: *FitConstant[][]");
     433      FitConstant[k][i] = new double[b];
     434      for (int j = b; j--;) {
     435        FitConstant[k][i][j] = 0.;
     436      }
    434437    }
    435438  }
     
    477480
    478481  // 0d. allocate final correction matrix
    479   correction = Calloc<double*>(a, "MoleculeListClass::AddHydrogenCorrection: **correction");
     482  correction = new double*[a];
    480483  for (int i = a; i--;)
    481     correction[i] = Calloc<double>(b, "MoleculeListClass::AddHydrogenCorrection: *correction[]");
     484    correction[i] = new double[b];
    482485
    483486  // 1a. go through every molecule in the list
     
    488491        correction[k][j] = 0.;
    489492    // 2. take every hydrogen that is a saturated one
    490     Walker = (*ListRunner)->start;
    491     while (Walker->next != (*ListRunner)->end) {
    492       Walker = Walker->next;
    493       //Log() << Verbose(1) << "Walker: " << *Walker << " with first bond " << *(Walker->ListOfBonds.begin()) << "." << endl;
    494       if ((Walker->type->Z == 1) && ((Walker->father == NULL)
    495           || (Walker->father->type->Z != 1))) { // if it's a hydrogen
    496         Runner = (*ListRunner)->start;
    497         while (Runner->next != (*ListRunner)->end) {
    498           Runner = Runner->next;
    499           //Log() << Verbose(2) << "Runner: " << *Runner << " with first bond " << *(Walker->ListOfBonds.begin()) << "." << endl;
     493    for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) {
     494      //Log() << Verbose(1) << "(*iter): " << *(*iter) << " with first bond " << *((*iter)->ListOfBonds.begin()) << "." << endl;
     495      if (((*iter)->type->Z == 1) && (((*iter)->father == NULL)
     496          || ((*iter)->father->type->Z != 1))) { // if it's a hydrogen
     497        for (molecule::const_iterator runner = (*ListRunner)->begin(); runner != (*ListRunner)->end(); ++runner) {
     498          //Log() << Verbose(2) << "Runner: " << *(*runner) << " with first bond " << *((*iter)->ListOfBonds.begin()) << "." << endl;
    500499          // 3. take every other hydrogen that is the not the first and not bound to same bonding partner
    501           Binder = *(Runner->ListOfBonds.begin());
    502           if ((Runner->type->Z == 1) && (Runner->nr > Walker->nr) && (Binder->GetOtherAtom(Runner) != Binder->GetOtherAtom(Walker))) { // (hydrogens have only one bonding partner!)
     500          Binder = *((*runner)->ListOfBonds.begin());
     501          if (((*runner)->type->Z == 1) && ((*runner)->nr > (*iter)->nr) && (Binder->GetOtherAtom((*runner)) != Binder->GetOtherAtom((*iter)))) { // (hydrogens have only one bonding partner!)
    503502            // 4. evaluate the morse potential for each matrix component and add up
    504             distance = Runner->x.distance(Walker->x);
    505             //Log() << Verbose(0) << "Fragment " << (*ListRunner)->name << ": " << *Runner << "<= " << distance << "=>" << *Walker << ":" << endl;
     503            distance = (*runner)->x.distance((*iter)->x);
     504            //Log() << Verbose(0) << "Fragment " << (*ListRunner)->name << ": " << *(*runner) << "<= " << distance << "=>" << *(*iter) << ":" << endl;
    506505            for (int k = 0; k < a; k++) {
    507506              for (int j = 0; j < b; j++) {
     
    531530    FragmentNumber = FixedDigitNumber(ListOfMolecules.size(), (*ListRunner)->IndexNr);
    532531    line += FragmentNumber;
    533     delete (FragmentNumber);
     532    delete[] (FragmentNumber);
    534533    line += HCORRECTIONSUFFIX;
    535534    output.open(line.c_str());
     
    542541    output.close();
    543542  }
     543  for (int i = a; i--;)
     544    delete[](correction[i]);
     545  delete[](correction);
     546
    544547  line = path;
    545548  line.append("/");
     
    556559  for (int k = 0; k < 3; k++) {
    557560    for (int i = a; i--;) {
    558       Free(&FitConstant[k][i]);
    559     }
    560     Free(&FitConstant[k]);
    561   }
    562   Free(&FitConstant);
     561      delete[](FitConstant[k][i]);
     562    }
     563    delete[](FitConstant[k]);
     564  }
     565  delete[](FitConstant);
    563566  DoLog(0) && (Log() << Verbose(0) << "done." << endl);
    564567  return true;
     
    577580  ofstream ForcesFile;
    578581  stringstream line;
    579   atom *Walker = NULL;
    580582  periodentafel *periode=World::getInstance().getPeriode();
    581583
     
    590592      periodentafel::const_iterator elemIter;
    591593      for(elemIter=periode->begin();elemIter!=periode->end();++elemIter){
    592           if ((*ListRunner)->ElementsInMolecule[(*elemIter).first]) { // if this element got atoms
    593           Walker = (*ListRunner)->start;
    594           while (Walker->next != (*ListRunner)->end) { // go through every atom of this element
    595             Walker = Walker->next;
    596             if (Walker->type->getNumber() == (*elemIter).first) {
    597               if ((Walker->GetTrueFather() != NULL) && (Walker->GetTrueFather() != Walker)) {// if there is a rea
     594        if ((*ListRunner)->ElementsInMolecule[(*elemIter).first]) { // if this element got atoms
     595          for(molecule::iterator atomIter = (*ListRunner)->begin(); atomIter !=(*ListRunner)->end();++atomIter){
     596            if ((*atomIter)->type->getNumber() == (*elemIter).first) {
     597              if (((*atomIter)->GetTrueFather() != NULL) && ((*atomIter)->GetTrueFather() != (*atomIter))) {// if there is a rea
    598598                //Log() << Verbose(0) << "Walker is " << *Walker << " with true father " << *( Walker->GetTrueFather()) << ", it
    599                 ForcesFile << SortIndex[Walker->GetTrueFather()->nr] << "\t";
     599                ForcesFile << SortIndex[(*atomIter)->GetTrueFather()->nr] << "\t";
    600600              } else
    601601                // otherwise a -1 to indicate an added saturation hydrogen
     
    622622 * \param *configuration standard configuration to attach atoms in fragment molecule to.
    623623 * \param *SortIndex Index to map from the BFS labeling to the sequence how of Ion_Type in the config
    624  * \param DoPeriodic true - call ScanForPeriodicCorrection, false - don't
    625  * \param DoCentering true - call molecule::CenterEdge(), false - don't
    626624 * \return true - success (each file was written), false - something went wrong.
    627625 */
     
    633631  bool result = true;
    634632  bool intermediateResult = true;
    635   atom *Walker = NULL;
    636633  Vector BoxDimension;
    637634  char *FragmentNumber = NULL;
     
    674671    // list atoms in fragment for debugging
    675672    DoLog(2) && (Log() << Verbose(2) << "Contained atoms: ");
    676     Walker = (*ListRunner)->start;
    677     while (Walker->next != (*ListRunner)->end) {
    678       Walker = Walker->next;
    679       DoLog(0) && (Log() << Verbose(0) << Walker->getName() << " ");
     673    for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) {
     674      DoLog(0) && (Log() << Verbose(0) << (*iter)->getName() << " ");
    680675    }
    681676    DoLog(0) && (Log() << Verbose(0) << endl);
     
    724719    //outputFragment.close();
    725720    //outputFragment.clear();
    726     Free(&FragmentNumber);
     721    delete[](FragmentNumber);
    727722  }
    728723  DoLog(0) && (Log() << Verbose(0) << " done." << endl);
     
    756751void MoleculeListClass::DissectMoleculeIntoConnectedSubgraphs(const periodentafel * const periode, config * const configuration)
    757752{
     753  // 0a. remove all present molecules
     754  vector<molecule *> allmolecules = World::getInstance().getAllMolecules();
     755  for (vector<molecule *>::iterator MolRunner = allmolecules.begin(); MolRunner != allmolecules.end(); ++MolRunner) {
     756    erase(*MolRunner);
     757    World::getInstance().destroyMolecule(*MolRunner);
     758  }
     759  // 0b. remove all bonds and construct a molecule with all atoms
    758760  molecule *mol = World::getInstance().createMolecule();
    759   atom *Walker = NULL;
    760   atom *Advancer = NULL;
    761   bond *Binder = NULL;
    762   bond *Stepper = NULL;
    763   // 0. gather all atoms into single molecule
    764   for (MoleculeList::iterator MolRunner = ListOfMolecules.begin(); !ListOfMolecules.empty(); MolRunner = ListOfMolecules.begin()) {
    765     // shift all atoms to new molecule
    766     Advancer = (*MolRunner)->start->next;
    767     while (Advancer != (*MolRunner)->end) {
    768       Walker = Advancer;
    769       Advancer = Advancer->next;
    770       DoLog(3) && (Log() << Verbose(3) << "Re-linking " << *Walker << "..." << endl);
    771       unlink(Walker);
    772       Walker->father = Walker;
    773       mol->AddAtom(Walker);    // counting starts at 1
    774     }
    775     // remove all bonds
    776     Stepper = (*MolRunner)->first->next;
    777     while (Stepper != (*MolRunner)->last) {
    778       Binder = Stepper;
    779       Stepper = Stepper->next;
    780       delete(Binder);
    781     }
    782     // remove the molecule
    783     World::getInstance().destroyMolecule(*MolRunner);
    784     ListOfMolecules.erase(MolRunner);
     761  vector <atom *> allatoms = World::getInstance().getAllAtoms();
     762  for(vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) {
     763    for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin())
     764      delete(*BondRunner);
     765    mol->AddAtom(*AtomRunner);
    785766  }
    786767
     
    810791  const int MolCount = Subgraphs->next->Count();
    811792  char number[MAXSTRINGSIZE];
    812   molecule **molecules = Malloc<molecule *>(MolCount, "config::Load() - **molecules");
     793  molecule **molecules = new molecule *[MolCount];
     794  MoleculeLeafClass *MolecularWalker = Subgraphs;
    813795  for (int i=0;i<MolCount;i++) {
     796    MolecularWalker = MolecularWalker->next;
    814797    molecules[i] = World::getInstance().createMolecule();
    815798    molecules[i]->ActiveFlag = true;
     
    819802      strncat(molecules[i]->name, number, MAXSTRINGSIZE - strlen(mol->name) - 1);
    820803    }
    821     DoLog(1) && (Log() << Verbose(1) << "MolName is " << molecules[i]->name << endl);
     804    DoLog(1) && (Log() << Verbose(1) << "MolName is " << molecules[i]->name << ", id is " << molecules[i]->getId() << endl);
     805    for (molecule::iterator iter = MolecularWalker->Leaf->begin(); iter != MolecularWalker->Leaf->end(); ++iter) {
     806      DoLog(1) && (Log() << Verbose(1) << **iter << endl);
     807    }
    822808    insert(molecules[i]);
    823809  }
     
    825811  // 4b. create and fill map of which atom is associated to which connected molecule (note, counting starts at 1)
    826812  int FragmentCounter = 0;
    827   int *MolMap = Calloc<int>(mol->AtomCount, "config::Load() - *MolMap");
    828   MoleculeLeafClass *MolecularWalker = Subgraphs;
    829   Walker = NULL;
     813  map<int, atom *> AtomToFragmentMap;
     814  MolecularWalker = Subgraphs;
    830815  while (MolecularWalker->next != NULL) {
    831816    MolecularWalker = MolecularWalker->next;
    832     Walker = MolecularWalker->Leaf->start;
    833     while (Walker->next != MolecularWalker->Leaf->end) {
    834       Walker = Walker->next;
    835       MolMap[Walker->GetTrueFather()->nr] = FragmentCounter+1;
     817    for (molecule::iterator iter = MolecularWalker->Leaf->begin(); !MolecularWalker->Leaf->empty(); iter = MolecularWalker->Leaf->begin()) {
     818      atom * Walker = *iter;
     819      DoLog(1) && (Log() << Verbose(1) << "Re-linking " << Walker << "..." << endl);
     820      MolecularWalker->Leaf->erase(iter);
     821      molecules[FragmentCounter]->AddAtom(Walker);    // counting starts at 1
    836822    }
    837823    FragmentCounter++;
    838824  }
    839 
    840   // 4c. relocate atoms to new molecules and remove from Leafs
    841   Walker = NULL;
    842   while (mol->start->next != mol->end) {
    843     Walker = mol->start->next;
    844     if ((Walker->nr <0) || (Walker->nr >= mol->AtomCount)) {
    845       DoeLog(0) && (eLog()<< Verbose(0) << "Index of atom " << *Walker << " is invalid!" << endl);
    846       performCriticalExit();
    847     }
    848     FragmentCounter = MolMap[Walker->nr];
    849     if (FragmentCounter != 0) {
    850       DoLog(3) && (Log() << Verbose(3) << "Re-linking " << *Walker << "..." << endl);
    851       unlink(Walker);
    852       molecules[FragmentCounter-1]->AddAtom(Walker);    // counting starts at 1
    853     } else {
    854       DoeLog(0) && (eLog()<< Verbose(0) << "Atom " << *Walker << " not associated to molecule!" << endl);
    855       performCriticalExit();
    856     }
    857   }
     825  World::getInstance().destroyMolecule(mol);
     826
    858827  // 4d. we don't need to redo bonds, as they are connected subgraphs and still maintain their ListOfBonds, but we have to remove them from first..last list
    859   Binder = mol->first;
    860   while (mol->first->next != mol->last) {
    861     Binder = mol->first->next;
    862     Walker = Binder->leftatom;
    863     unlink(Binder);
    864     link(Binder,molecules[MolMap[Walker->nr]-1]->last);   // counting starts at 1
    865   }
     828  // TODO: check whether this is really not needed anymore
    866829  // 4e. free Leafs
    867830  MolecularWalker = Subgraphs;
     
    871834  }
    872835  delete(MolecularWalker);
    873   Free(&MolMap);
    874   Free(&molecules);
     836  delete[](molecules);
    875837  DoLog(1) && (Log() << Verbose(1) << "I scanned " << FragmentCounter << " molecules." << endl);
    876838};
     
    882844int MoleculeListClass::CountAllAtoms() const
    883845{
    884   atom *Walker = NULL;
    885846  int AtomNo = 0;
    886847  for (MoleculeList::const_iterator MolWalker = ListOfMolecules.begin(); MolWalker != ListOfMolecules.end(); MolWalker++) {
    887     Walker = (*MolWalker)->start;
    888     while (Walker->next != (*MolWalker)->end) {
    889       Walker = Walker->next;
    890       AtomNo++;
    891     }
     848    AtomNo += (*MolWalker)->size();
    892849  }
    893850  return AtomNo;
     
    10641021bool MoleculeLeafClass::FillBondStructureFromReference(const molecule * const reference, int &FragmentCounter, atom ***&ListOfLocalAtoms, bool FreeList)
    10651022{
    1066   atom *Walker = NULL;
    10671023  atom *OtherWalker = NULL;
    10681024  atom *Father = NULL;
     
    10721028  DoLog(1) && (Log() << Verbose(1) << "Begin of FillBondStructureFromReference." << endl);
    10731029  // fill ListOfLocalAtoms if NULL was given
    1074   if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->AtomCount, FreeList)) {
     1030  if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->getAtomCount(), FreeList)) {
    10751031    DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl);
    10761032    return false;
     
    10801036    DoLog(1) && (Log() << Verbose(1) << "Creating adjacency list for subgraph " << Leaf << "." << endl);
    10811037    // remove every bond from the list
    1082     bond *Binder = NULL;
    1083     while (Leaf->last->previous != Leaf->first) {
    1084       Binder = Leaf->last->previous;
    1085       Binder->leftatom->UnregisterBond(Binder);
    1086       Binder->rightatom->UnregisterBond(Binder);
    1087       removewithoutcheck(Binder);
    1088     }
    1089 
    1090     Walker = Leaf->start;
    1091     while (Walker->next != Leaf->end) {
    1092       Walker = Walker->next;
    1093       Father = Walker->GetTrueFather();
     1038    for(molecule::iterator AtomRunner = Leaf->begin(); AtomRunner != Leaf->end(); ++AtomRunner)
     1039      for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin())
     1040        if ((*BondRunner)->leftatom == *AtomRunner)
     1041          delete((*BondRunner));
     1042
     1043    for(molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end(); ++iter) {
     1044      Father = (*iter)->GetTrueFather();
    10941045      AtomNo = Father->nr; // global id of the current walker
    10951046      for (BondList::const_iterator Runner = Father->ListOfBonds.begin(); Runner != Father->ListOfBonds.end(); (++Runner)) {
    1096         OtherWalker = ListOfLocalAtoms[FragmentCounter][(*Runner)->GetOtherAtom(Walker->GetTrueFather())->nr]; // local copy of current bond partner of walker
     1047        OtherWalker = ListOfLocalAtoms[FragmentCounter][(*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr]; // local copy of current bond partner of walker
    10971048        if (OtherWalker != NULL) {
    1098           if (OtherWalker->nr > Walker->nr)
    1099             Leaf->AddBond(Walker, OtherWalker, (*Runner)->BondDegree);
     1049          if (OtherWalker->nr > (*iter)->nr)
     1050            Leaf->AddBond((*iter), OtherWalker, (*Runner)->BondDegree);
    11001051        } else {
    1101           DoLog(1) && (Log() << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << FragmentCounter << "][" << (*Runner)->GetOtherAtom(Walker->GetTrueFather())->nr << "] is NULL!" << endl);
     1052          DoLog(1) && (Log() << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << FragmentCounter << "][" << (*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr << "] is NULL!" << endl);
    11021053          status = false;
    11031054        }
     
    11081059  if ((FreeList) && (ListOfLocalAtoms != NULL)) {
    11091060    // free the index lookup list
    1110     Free(&ListOfLocalAtoms[FragmentCounter]);
     1061    delete[](ListOfLocalAtoms[FragmentCounter]);
    11111062    if (FragmentCounter == 0) // first fragments frees the initial pointer to list
    1112       Free(&ListOfLocalAtoms);
     1063      delete[](ListOfLocalAtoms);
    11131064  }
    11141065  DoLog(1) && (Log() << Verbose(1) << "End of FillBondStructureFromReference." << endl);
     
    11261077bool MoleculeLeafClass::FillRootStackForSubgraphs(KeyStack *&RootStack, bool *AtomMask, int &FragmentCounter)
    11271078{
    1128   atom *Walker = NULL, *Father = NULL;
     1079  atom *Father = NULL;
    11291080
    11301081  if (RootStack != NULL) {
     
    11321083    if (&(RootStack[FragmentCounter]) != NULL) {
    11331084      RootStack[FragmentCounter].clear();
    1134       Walker = Leaf->start;
    1135       while (Walker->next != Leaf->end) { // go through all (non-hydrogen) atoms
    1136         Walker = Walker->next;
    1137         Father = Walker->GetTrueFather();
     1085      for(molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end(); ++iter) {
     1086        Father = (*iter)->GetTrueFather();
    11381087        if (AtomMask[Father->nr]) // apply mask
    11391088#ifdef ADDHYDROGEN
    1140           if (Walker->type->Z != 1) // skip hydrogen
     1089          if ((*iter)->type->Z != 1) // skip hydrogen
    11411090#endif
    1142           RootStack[FragmentCounter].push_front(Walker->nr);
     1091          RootStack[FragmentCounter].push_front((*iter)->nr);
    11431092      }
    11441093      if (next != NULL)
     
    11711120    // allocate and set each field to NULL
    11721121    const int Counter = Count();
    1173     ListOfLocalAtoms = Calloc<atom**>(Counter, "MoleculeLeafClass::FillListOfLocalAtoms - ***ListOfLocalAtoms");
     1122    ASSERT(FragmentCounter < Counter, "FillListOfLocalAtoms: FragmenCounter greater than present fragments.");
     1123    ListOfLocalAtoms = new atom**[Counter];
    11741124    if (ListOfLocalAtoms == NULL) {
    11751125      FreeList = FreeList && false;
    11761126      status = false;
    11771127    }
     1128    for (int i=0;i<Counter;i++)
     1129      ListOfLocalAtoms[i] = NULL;
    11781130  }
    11791131
    11801132  if ((ListOfLocalAtoms != NULL) && (ListOfLocalAtoms[FragmentCounter] == NULL)) { // allocate and fill list of this fragment/subgraph
    1181     status = status && CreateFatherLookupTable(Leaf->start, Leaf->end, ListOfLocalAtoms[FragmentCounter], GlobalAtomCount);
     1133    status = status && Leaf->CreateFatherLookupTable(ListOfLocalAtoms[FragmentCounter], GlobalAtomCount);
    11821134    FreeList = FreeList && true;
    11831135  }
     
    12031155  DoLog(1) && (Log() << Verbose(1) << "Begin of AssignKeySetsToFragment." << endl);
    12041156  // fill ListOfLocalAtoms if NULL was given
    1205   if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->AtomCount, FreeList)) {
     1157  if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->getAtomCount(), FreeList)) {
    12061158    DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl);
    12071159    return false;
     
    12111163  if (FragmentList == NULL) {
    12121164    KeySetCounter = Count();
    1213     FragmentList = Calloc<Graph*>(KeySetCounter, "MoleculeLeafClass::AssignKeySetsToFragment - **FragmentList");
     1165    FragmentList = new Graph*[KeySetCounter];
     1166    for (int i=0;i<KeySetCounter;i++)
     1167      FragmentList[i] = NULL;
    12141168    KeySetCounter = 0;
    12151169  }
     
    12451199  if ((FreeList) && (ListOfLocalAtoms != NULL)) {
    12461200    // free the index lookup list
    1247     Free(&ListOfLocalAtoms[FragmentCounter]);
     1201    delete[](ListOfLocalAtoms[FragmentCounter]);
    12481202    if (FragmentCounter == 0) // first fragments frees the initial pointer to list
    1249       Free(&ListOfLocalAtoms);
     1203      delete[](ListOfLocalAtoms);
    12501204  }
    12511205  DoLog(1) && (Log() << Verbose(1) << "End of AssignKeySetsToFragment." << endl);
  • src/parser.cpp

    r0c7ed8 r1dc9ec  
    66
    77// ======================================= INCLUDES ==========================================
     8
     9#include "Helpers/MemDebug.hpp"
    810
    911#include <cstring>
     
    5961MatrixContainer::MatrixContainer() {
    6062  Indices = NULL;
    61   Header = Malloc<char*>(1, "MatrixContainer::MatrixContainer: **Header");
    62   Matrix = Malloc<double**>(1, "MatrixContainer::MatrixContainer: ***Matrix"); // one more each for the total molecule
    63   RowCounter = Malloc<int>(1, "MatrixContainer::MatrixContainer: *RowCounter");
    64   ColumnCounter = Malloc<int>(1, "MatrixContainer::MatrixContainer: *ColumnCounter");
     63  Header = new char*[1];
     64  Matrix = new double**[1]; // one more each for the total molecule
     65  RowCounter = new int[1];
     66  ColumnCounter = new int[1];
    6567  Header[0] = NULL;
    6668  Matrix[0] = NULL;
     
    7779      if ((ColumnCounter != NULL) && (RowCounter != NULL)) {
    7880          for(int j=RowCounter[i]+1;j--;)
    79             Free(&Matrix[i][j]);
    80         Free(&Matrix[i]);
     81            delete[](Matrix[i][j]);
     82          delete[](Matrix[i]);
    8183      }
    8284    }
    8385    if ((ColumnCounter != NULL) && (RowCounter != NULL) && (Matrix[MatrixCounter] != NULL))
    8486      for(int j=RowCounter[MatrixCounter]+1;j--;)
    85         Free(&Matrix[MatrixCounter][j]);
     87        delete[](Matrix[MatrixCounter][j]);
    8688    if (MatrixCounter != 0)
    87       Free(&Matrix[MatrixCounter]);
    88     Free(&Matrix);
     89      delete[](Matrix[MatrixCounter]);
     90    delete[](Matrix);
    8991  }
    9092  if (Indices != NULL)
    9193    for(int i=MatrixCounter+1;i--;) {
    92       Free(&Indices[i]);
    93     }
    94   Free(&Indices);
     94      delete[](Indices[i]);
     95    }
     96  delete[](Indices);
    9597 
    9698  if (Header != NULL)
    9799    for(int i=MatrixCounter+1;i--;)
    98       Free(&Header[i]);
    99   Free(&Header);
    100   Free(&RowCounter);
    101   Free(&ColumnCounter);
     100      delete[](Header[i]);
     101  delete[](Header);
     102  delete[](RowCounter);
     103  delete[](ColumnCounter);
    102104};
    103105
     
    112114  if (Matrix == NULL) {
    113115    DoLog(0) && (Log() << Verbose(0) << " with trivial mapping." << endl);
    114     Indices = Malloc<int*>(MatrixCounter + 1, "MatrixContainer::InitialiseIndices: **Indices");
     116    Indices = new int*[MatrixCounter + 1];
    115117    for(int i=MatrixCounter+1;i--;) {
    116       Indices[i] = Malloc<int>(RowCounter[i], "MatrixContainer::InitialiseIndices: *Indices[]");
     118      Indices[i] = new int[RowCounter[i]];
    117119      for(int j=RowCounter[i];j--;)
    118120        Indices[i][j] = j;
     
    122124    if (MatrixCounter != Matrix->MatrixCounter)
    123125      return false;
    124     Indices = Malloc<int*>(MatrixCounter + 1, "MatrixContainer::InitialiseIndices: **Indices");
     126    Indices = new int*[MatrixCounter + 1];
    125127    for(int i=MatrixCounter+1;i--;) {
    126128      if (RowCounter[i] != Matrix->RowCounter[i])
    127129        return false;
    128       Indices[i] = Malloc<int>(Matrix->RowCounter[i], "MatrixContainer::InitialiseIndices: *Indices[]");
     130      Indices[i] = new int[Matrix->RowCounter[i]];
    129131      for(int j=Matrix->RowCounter[i];j--;) {
    130132        Indices[i][j] = Matrix->Indices[i][j];
     
    166168
    167169  // parse header
    168   Header[MatrixNr] = Malloc<char>(1024, "MatrixContainer::ParseMatrix: *Header[]");
     170  Header[MatrixNr] = new char[1024];
    169171  for (int m=skiplines+1;m--;)
    170172    input.getline(Header[MatrixNr], 1023);
     
    205207  // allocate matrix if it's not zero dimension in one direction
    206208  if ((ColumnCounter[MatrixNr] > 0) && (RowCounter[MatrixNr] > -1)) {
    207     Matrix[MatrixNr] = Malloc<double*>(RowCounter[MatrixNr] + 1, "MatrixContainer::ParseMatrix: **Matrix[]");
     209    Matrix[MatrixNr] = new double*[RowCounter[MatrixNr] + 1];
    208210 
    209211    // parse in each entry for this matrix
     
    217219    strncpy(Header[MatrixNr], line.str().c_str(), 1023); 
    218220    for(int j=0;j<RowCounter[MatrixNr];j++) {
    219       Matrix[MatrixNr][j] = Malloc<double>(ColumnCounter[MatrixNr], "MatrixContainer::ParseMatrix: *Matrix[][]");
     221      Matrix[MatrixNr][j] = new double[ColumnCounter[MatrixNr]];
    220222      input.getline(filename, 1023);
    221223      stringstream lines(filename);
     
    227229        //Log() << Verbose(1) << " " << setprecision(2) << Matrix[MatrixNr][j][k] << endl;
    228230      }
    229       Matrix[MatrixNr][ RowCounter[MatrixNr] ] = Malloc<double>(ColumnCounter[MatrixNr], "MatrixContainer::ParseMatrix: *Matrix[RowCounter[MatrixNr]][]");
     231      Matrix[MatrixNr][ RowCounter[MatrixNr] ] = new double[ColumnCounter[MatrixNr]];
    230232      for(int j=ColumnCounter[MatrixNr];j--;)
    231233        Matrix[MatrixNr][ RowCounter[MatrixNr] ][j] = 0.;
     
    281283
    282284  DoLog(0) && (Log() << Verbose(0) << "Parsing through each fragment and retrieving " << prefix << suffix << "." << endl);
    283   Header = ReAlloc<char*>(Header, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: **Header"); // one more each for the total molecule
    284   Matrix = ReAlloc<double**>(Matrix, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: ***Matrix"); // one more each for the total molecule
    285   RowCounter = ReAlloc<int>(RowCounter, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: *RowCounter");
    286   ColumnCounter = ReAlloc<int>(ColumnCounter, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: *ColumnCounter");
     285  delete[](Header);
     286  delete[](Matrix);
     287  delete[](RowCounter);
     288  delete[](ColumnCounter);
     289  Header = new char*[MatrixCounter + 1]; // one more each for the total molecule
     290  Matrix = new double**[MatrixCounter + 1]; // one more each for the total molecule
     291  RowCounter = new int[MatrixCounter + 1];
     292  ColumnCounter = new int[MatrixCounter + 1];
    287293  for(int i=MatrixCounter+1;i--;) {
    288294    Matrix[i] = NULL;
     
    298304    if (!ParseMatrix(file.str().c_str(), skiplines, skipcolumns, i))
    299305      return false;
    300     Free(&FragmentNumber);
     306    delete[](FragmentNumber);
    301307  }
    302308  return true;
     
    313319{
    314320  MatrixCounter = MCounter;
    315   Header = Malloc<char*>(MatrixCounter + 1, "MatrixContainer::AllocateMatrix: *Header");
    316   Matrix = Malloc<double**>(MatrixCounter + 1, "MatrixContainer::AllocateMatrix: ***Matrix"); // one more each for the total molecule
    317   RowCounter = Malloc<int>(MatrixCounter + 1, "MatrixContainer::AllocateMatrix: *RowCounter");
    318   ColumnCounter = Malloc<int>(MatrixCounter + 1, "MatrixContainer::AllocateMatrix: *ColumnCounter");
     321  Header = new char*[MatrixCounter + 1];
     322  Matrix = new double**[MatrixCounter + 1]; // one more each for the total molecule
     323  RowCounter = new int[MatrixCounter + 1];
     324  ColumnCounter = new int[MatrixCounter + 1];
    319325  for(int i=MatrixCounter+1;i--;) {
    320     Header[i] = Malloc<char>(1024, "MatrixContainer::AllocateMatrix: *Header[i]");
     326    Header[i] = new char[1024];
    321327    strncpy(Header[i], GivenHeader[i], 1023);
    322328    RowCounter[i] = RCounter[i];
    323329    ColumnCounter[i] = CCounter[i];
    324     Matrix[i] = Malloc<double*>(RowCounter[i] + 1, "MatrixContainer::AllocateMatrix: **Matrix[]");
     330    Matrix[i] = new double*[RowCounter[i] + 1];
    325331    for(int j=RowCounter[i]+1;j--;) {
    326       Matrix[i][j] = Malloc<double>(ColumnCounter[i], "MatrixContainer::AllocateMatrix: *Matrix[][]");
     332      Matrix[i][j] = new double[ColumnCounter[i]];
    327333      for(int k=ColumnCounter[i];k--;)
    328334        Matrix[i][j][k] = 0.;
     
    474480    FragmentNumber = FixedDigitNumber(MatrixCounter, i);
    475481    line << name << FRAGMENTPREFIX << FragmentNumber << "/" << prefix;
    476     Free(&FragmentNumber);
     482    delete[](FragmentNumber);
    477483    output.open(line.str().c_str(), ios::out);
    478484    if (output == NULL) {
     
    530536{
    531537  DoLog(0) && (Log() << Verbose(0) << "Parsing energy indices." << endl);
    532   Indices = Malloc<int*>(MatrixCounter + 1, "EnergyMatrix::ParseIndices: **Indices");
     538  Indices = new int*[MatrixCounter + 1];
    533539  for(int i=MatrixCounter+1;i--;) {
    534     Indices[i] = Malloc<int>(RowCounter[i], "EnergyMatrix::ParseIndices: *Indices[]");
     540    Indices[i] = new int[RowCounter[i]];
    535541    for(int j=RowCounter[i];j--;)
    536542      Indices[i][j] = j;
     
    589595    // allocate last plus one matrix
    590596    DoLog(0) && (Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl);
    591     Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]");
     597    Matrix[MatrixCounter] = new double*[RowCounter[MatrixCounter] + 1];
    592598    for(int j=0;j<=RowCounter[MatrixCounter];j++)
    593       Matrix[MatrixCounter][j] = Malloc<double>(ColumnCounter[MatrixCounter], "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");
     599      Matrix[MatrixCounter][j] = new double[ColumnCounter[MatrixCounter]];
    594600   
    595601    // try independently to parse global energysuffix file if present
     
    616622
    617623  DoLog(0) && (Log() << Verbose(0) << "Parsing force indices for " << MatrixCounter << " matrices." << endl);
    618   Indices = Malloc<int*>(MatrixCounter + 1, "ForceMatrix::ParseIndices: **Indices");
     624  Indices = new int*[MatrixCounter + 1];
    619625  line << name << FRAGMENTPREFIX << FORCESFILE;
    620626  input.open(line.str().c_str(), ios::in);
     
    629635    line.str(filename);
    630636    // parse the values
    631     Indices[i] = Malloc<int>(RowCounter[i], "ForceMatrix::ParseIndices: *Indices[]");
     637    Indices[i] = new int[RowCounter[i]];
    632638    FragmentNumber = FixedDigitNumber(MatrixCounter, i);
    633639    //Log() << Verbose(0) << FRAGMENTPREFIX << FragmentNumber << "[" << RowCounter[i] << "]:";
    634     Free(&FragmentNumber);
     640    delete[](FragmentNumber);
    635641    for(int j=0;(j<RowCounter[i]) && (!line.eof());j++) {
    636642      line >> Indices[i][j];
     
    639645    //Log() << Verbose(0) << endl;
    640646  }
    641   Indices[MatrixCounter] = Malloc<int>(RowCounter[MatrixCounter], "ForceMatrix::ParseIndices: *Indices[]");
     647  Indices[MatrixCounter] = new int[RowCounter[MatrixCounter]];
    642648  for(int j=RowCounter[MatrixCounter];j--;) {
    643649    Indices[MatrixCounter][j] = j;
     
    725731    // allocate last plus one matrix
    726732    DoLog(0) && (Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl);
    727     Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]");
     733    Matrix[MatrixCounter] = new double*[RowCounter[MatrixCounter] + 1];
    728734    for(int j=0;j<=RowCounter[MatrixCounter];j++)
    729       Matrix[MatrixCounter][j] = Malloc<double>(ColumnCounter[MatrixCounter], "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");
     735      Matrix[MatrixCounter][j] = new double[ColumnCounter[MatrixCounter]];
    730736
    731737    // try independently to parse global forcesuffix file if present
     
    754760 
    755761  DoLog(0) && (Log() << Verbose(0) << "Parsing hessian indices for " << MatrixCounter << " matrices." << endl);
    756   Indices = Malloc<int*>(MatrixCounter + 1, "HessianMatrix::ParseIndices: **Indices");
     762  Indices = new int*[MatrixCounter + 1];
    757763  line << name << FRAGMENTPREFIX << FORCESFILE;
    758764  input.open(line.str().c_str(), ios::in);
     
    767773    line.str(filename);
    768774    // parse the values
    769     Indices[i] = Malloc<int>(RowCounter[i], "HessianMatrix::ParseIndices: *Indices[]");
     775    Indices[i] = new int[RowCounter[i]];
    770776    FragmentNumber = FixedDigitNumber(MatrixCounter, i);
    771777    //Log() << Verbose(0) << FRAGMENTPREFIX << FragmentNumber << "[" << RowCounter[i] << "]:";
    772     Free(&FragmentNumber);
     778    delete[](FragmentNumber);
    773779    for(int j=0;(j<RowCounter[i]) && (!line.eof());j++) {
    774780      line >> Indices[i][j];
     
    777783    //Log() << Verbose(0) << endl;
    778784  }
    779   Indices[MatrixCounter] = Malloc<int>(RowCounter[MatrixCounter], "HessianMatrix::ParseIndices: *Indices[]");
     785  Indices[MatrixCounter] = new int[RowCounter[MatrixCounter]];
    780786  for(int j=RowCounter[MatrixCounter];j--;) {
    781787    Indices[MatrixCounter][j] = j;
     
    953959    // allocate last plus one matrix
    954960    DoLog(0) && (Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl);
    955     Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]");
     961    Matrix[MatrixCounter] = new double*[RowCounter[MatrixCounter] + 1];
    956962    for(int j=0;j<=RowCounter[MatrixCounter];j++)
    957       Matrix[MatrixCounter][j] = Malloc<double>(ColumnCounter[MatrixCounter], "MatrixContainer::ParseFragmentMatrix: *Matrix[][]");
     963      Matrix[MatrixCounter][j] = new double[ColumnCounter[MatrixCounter]];
    958964
    959965    // try independently to parse global forcesuffix file if present
     
    985991KeySetsContainer::~KeySetsContainer() {
    986992  for(int i=FragmentCounter;i--;)
    987     Free(&KeySets[i]);
     993    delete[](KeySets[i]);
    988994  for(int i=Order;i--;)
    989     Free(&OrderSet[i]);
    990   Free(&KeySets);
    991   Free(&OrderSet);
    992   Free(&AtomCounter);
    993   Free(&FragmentsPerOrder);
     995    delete[](OrderSet[i]);
     996  delete[](KeySets);
     997  delete[](OrderSet);
     998  delete[](AtomCounter);
     999  delete[](FragmentsPerOrder);
    9941000};
    9951001
     
    10081014  FragmentCounter = FCounter;
    10091015  DoLog(0) && (Log() << Verbose(0) << "Parsing key sets." << endl);
    1010   KeySets = Malloc<int*>(FragmentCounter, "KeySetsContainer::ParseKeySets: **KeySets");
     1016  KeySets = new int*[FragmentCounter];
    10111017  for(int i=FragmentCounter;i--;)
    10121018    KeySets[i] = NULL;
     
    10181024  }
    10191025
    1020   AtomCounter = Malloc<int>(FragmentCounter, "KeySetsContainer::ParseKeySets: *RowCounter");
     1026  AtomCounter = new int[FragmentCounter];
    10211027  for(int i=0;(i<FragmentCounter) && (!input.eof());i++) {
    10221028    stringstream line;
    10231029    AtomCounter[i] = ACounter[i];
    10241030    // parse the values
    1025     KeySets[i] = Malloc<int>(AtomCounter[i], "KeySetsContainer::ParseKeySets: *KeySets[]");
     1031    KeySets[i] = new int[AtomCounter[i]];
    10261032    for(int j=AtomCounter[i];j--;)
    10271033      KeySets[i][j] = -1;
    10281034    FragmentNumber = FixedDigitNumber(FragmentCounter, i);
    10291035    //Log() << Verbose(0) << FRAGMENTPREFIX << FragmentNumber << "[" << AtomCounter[i] << "]:";
    1030     Free(&FragmentNumber);
     1036    delete[](FragmentNumber);
    10311037    input.getline(filename, 1023);
    10321038    line.str(filename);
     
    10621068
    10631069  // scan through all to determine fragments per order
    1064   FragmentsPerOrder = Malloc<int>(Order, "KeySetsContainer::ParseManyBodyTerms: *FragmentsPerOrder");
     1070  FragmentsPerOrder = new int[Order];
    10651071  for(int i=Order;i--;)
    10661072    FragmentsPerOrder[i] = 0;
     
    10761082
    10771083  // scan through all to gather indices to each order set
    1078   OrderSet = Malloc<int*>(Order, "KeySetsContainer::ParseManyBodyTerms: **OrderSet");
     1084  OrderSet = new int*[Order];
    10791085  for(int i=Order;i--;)
    1080     OrderSet[i] = Malloc<int>(FragmentsPerOrder[i], "KeySetsContainer::ParseManyBodyTermsKeySetsContainer::ParseManyBodyTerms: *OrderSet[]");
     1086    OrderSet[i] = new int[FragmentsPerOrder[i]];
    10811087  for(int i=Order;i--;)
    10821088    FragmentsPerOrder[i] = 0;
  • src/periodentafel.cpp

    r0c7ed8 r1dc9ec  
    55 */
    66
     7#include "Helpers/MemDebug.hpp"
     8
    79using namespace std;
    810
    911#include <iomanip>
     12#include <iostream>
    1013#include <fstream>
    1114#include <cstring>
    12 #include <cassert>
    13 
     15
     16#include "Helpers/Assert.hpp"
    1417#include "element.hpp"
     18#include "elements_db.hpp"
    1519#include "helpers.hpp"
    1620#include "lists.hpp"
     
    2731 */
    2832periodentafel::periodentafel()
    29 {};
     33{
     34  bool status = true;
     35  status = LoadElementsDatabase(new stringstream(elementsDB,ios_base::in));
     36  ASSERT(status,  "General element initialization failed");
     37  status = LoadValenceDatabase(new stringstream(valenceDB,ios_base::in));
     38  ASSERT(status, "Valence entry of element initialization failed");
     39  status = LoadOrbitalsDatabase(new stringstream(orbitalsDB,ios_base::in));
     40  ASSERT(status, "Orbitals entry of element initialization failed");
     41  status = LoadHBondAngleDatabase(new stringstream(HbondangleDB,ios_base::in));
     42  ASSERT(status, "HBond angle entry of element initialization failed");
     43  status = LoadHBondLengthsDatabase(new stringstream(HbonddistanceDB,ios_base::in));
     44  ASSERT(status, "HBond distance entry of element initialization failed");
     45};
    3046
    3147/** destructor for class periodentafel
    3248 * Removes every element and afterwards deletes start and end of list.
     49 * TODO: Handle when elements have changed and store databases then
    3350 */
    3451periodentafel::~periodentafel()
     
    3956/** Adds element to period table list
    4057 * \param *pointer element to be added
    41  * \return true - succeeded, false - does not occur
     58 * \return iterator to added element
    4259 */
    4360periodentafel::iterator periodentafel::AddElement(element * const pointer)
    4461{
    4562  atomicNumber_t Z = pointer->getNumber();
    46   assert(!elements.count(Z));
     63  ASSERT(!elements.count(Z), "Element is already present.");
    4764  pointer->sort = &pointer->Z;
    4865  if (pointer->getNumber() < 1 && pointer->getNumber() >= MAX_ELEMENTS)
     
    5471/** Removes element from list.
    5572 * \param *pointer element to be removed
    56  * \return true - succeeded, false - element not found
    57  */
    58 void periodentafel::RemoveElement(element * const pointer)
    59 {
    60   atomicNumber_t Z = pointer->getNumber();
    61   elements.erase(Z);
     73 */
     74size_t periodentafel::RemoveElement(element * const pointer)
     75{
     76  return RemoveElement(pointer->getNumber());
     77};
     78
     79/** Removes element from list.
     80 * \param Z element to be removed
     81 */
     82size_t periodentafel::RemoveElement(atomicNumber_t Z)
     83{
     84  return elements.erase(Z);
    6285};
    6386
    6487/** Removes every element from the period table.
    65  * \return true - succeeded, false - does not occur
    6688 */
    6789void periodentafel::CleanupPeriodtable()
     
    78100 * \return pointer to element or NULL if not found
    79101 */
    80 const element * periodentafel::FindElement(atomicNumber_t Z) const
     102element * const periodentafel::FindElement(atomicNumber_t Z) const
    81103{
    82104  const_iterator res = elements.find(Z);
     
    89111 * \return pointer to element
    90112 */
    91 const element * periodentafel::FindElement(const char * const shorthand) const
     113element * const periodentafel::FindElement(const char * const shorthand) const
    92114{
    93115  element *res = 0;
     
    102124
    103125/** Asks for element number and returns pointer to element
    104  */
    105 const element * periodentafel::AskElement() const
    106 {
    107   const element *walker = NULL;
     126 * \return desired element or NULL
     127 */
     128element * const periodentafel::AskElement() const
     129{
     130  element * walker = NULL;
    108131  int Z;
    109132  do {
     
    118141 * \return pointer to either present or newly created element
    119142 */
    120 const element * periodentafel::EnterElement()
    121 {
    122   const element *res = NULL;
     143element * const periodentafel::EnterElement()
     144{
    123145  atomicNumber_t Z = 0;
    124146  DoLog(0) && (Log() << Verbose(0) << "Atomic number: " << Z << endl);
    125147  cin >> Z;
    126   res = FindElement(Z);
     148  element * const res = FindElement(Z);
    127149  if (!res) {
    128150    // TODO: make this using the constructor
    129     element *tmp;
    130151    DoLog(0) && (Log() << Verbose(0) << "Element not found in database, please enter." << endl);
    131     tmp = new element;
     152    element *tmp = new element;
    132153    tmp->Z = Z;
    133154    DoLog(0) && (Log() << Verbose(0) << "Mass: " << endl);
     
    138159    cin >> tmp->symbol;
    139160    AddElement(tmp);
    140     res = tmp;
     161    return tmp;
    141162  }
    142163  return res;
     
    204225bool periodentafel::LoadPeriodentafel(const char *path)
    205226{
    206   ifstream infile;
    207   element *ptr;
    208   map<atomicNumber_t,element*> parsedElems;
     227  ifstream input;
    209228  bool status = true;
    210229  bool otherstatus = true;
     
    212231
    213232  // fill elements DB
    214   snprintf(filename,MAXSTRINGSIZE,"%s/%s",path,STANDARDELEMENTSDB);
    215   infile.open(filename);
    216   if (infile != NULL) {
    217     infile.getline(header1, MAXSTRINGSIZE);
    218     infile.getline(header2, MAXSTRINGSIZE); // skip first two header lines
     233  strncpy(filename, path, MAXSTRINGSIZE);
     234  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
     235  strncat(filename, STANDARDELEMENTSDB, MAXSTRINGSIZE-strlen(filename));
     236  input.open(filename);
     237  if (!input.fail())
     238    DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as elements database." << endl);
     239  status = status && LoadElementsDatabase(&input);
     240  input.close();
     241  input.clear();
     242
     243  // fill valence DB per element
     244  strncpy(filename, path, MAXSTRINGSIZE);
     245  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
     246  strncat(filename, STANDARDVALENCEDB, MAXSTRINGSIZE-strlen(filename));
     247  input.open(filename);
     248  if (!input.fail())
     249    DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as valence database." << endl);
     250  otherstatus = otherstatus && LoadValenceDatabase(&input);
     251  input.close();
     252  input.clear();
     253
     254  // fill orbitals DB per element
     255  strncpy(filename, path, MAXSTRINGSIZE);
     256  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
     257  strncat(filename, STANDARDORBITALDB, MAXSTRINGSIZE-strlen(filename));
     258  input.open(filename);
     259  if (!input.fail())
     260    DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as orbitals database." << endl);
     261  otherstatus = otherstatus && LoadOrbitalsDatabase(&input);
     262  input.close();
     263  input.clear();
     264
     265  // fill H-BondAngle DB per element
     266  strncpy(filename, path, MAXSTRINGSIZE);
     267  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
     268  strncat(filename, STANDARDHBONDANGLEDB, MAXSTRINGSIZE-strlen(filename));
     269  input.open(filename);
     270  if (!input.fail())
     271    DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as H bond angle database." << endl);
     272  otherstatus = otherstatus && LoadHBondAngleDatabase(&input);
     273  input.close();
     274  input.clear();
     275
     276  // fill H-BondDistance DB per element
     277  strncpy(filename, path, MAXSTRINGSIZE);
     278  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
     279  strncat(filename, STANDARDHBONDDISTANCEDB, MAXSTRINGSIZE-strlen(filename));
     280  input.open(filename);
     281  if (!input.fail())
     282    DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as H bond length database." << endl);
     283  otherstatus = otherstatus && LoadHBondLengthsDatabase(&input);
     284  input.close();
     285  input.clear();
     286
     287  if (!otherstatus){
     288    DoeLog(2) && (eLog()<< Verbose(2) << "Something went wrong while parsing the other databases!" << endl);
     289  }
     290
     291  return status;
     292};
     293
     294/** load the element info.
     295 * \param *input stream to parse from
     296 * \return true - parsing successful, false - something went wrong
     297 */
     298bool periodentafel::LoadElementsDatabase(istream *input)
     299{
     300  bool status = true;
     301  int counter = 0;
     302  pair< std::map<atomicNumber_t,element*>::iterator, bool > InserterTest;
     303  if (!(*input).fail()) {
     304    (*input).getline(header1, MAXSTRINGSIZE);
     305    (*input).getline(header2, MAXSTRINGSIZE); // skip first two header lines
    219306    DoLog(0) && (Log() << Verbose(0) <<  "Parsed elements:");
    220     while (!infile.eof()) {
     307    while (!(*input).eof()) {
    221308      element *neues = new element;
    222       infile >> neues->name;
    223       //infile >> ws;
    224       infile >> neues->symbol;
    225       //infile >> ws;
    226       infile >> neues->period;
    227       //infile >> ws;
    228       infile >> neues->group;
    229       //infile >> ws;
    230       infile >> neues->block;
    231       //infile >> ws;
    232       infile >> neues->Z;
    233       //infile >> ws;
    234       infile >> neues->mass;
    235       //infile >> ws;
    236       infile >> neues->CovalentRadius;
    237       //infile >> ws;
    238       infile >> neues->VanDerWaalsRadius;
    239       //infile >> ws;
    240       infile >> ws;
    241       DoLog(0) && (Log() << Verbose(0) << " " << neues->symbol);
     309      (*input) >> neues->name;
     310      //(*input) >> ws;
     311      (*input) >> neues->symbol;
     312      //(*input) >> ws;
     313      (*input) >> neues->period;
     314      //(*input) >> ws;
     315      (*input) >> neues->group;
     316      //(*input) >> ws;
     317      (*input) >> neues->block;
     318      //(*input) >> ws;
     319      (*input) >> neues->Z;
     320      //(*input) >> ws;
     321      (*input) >> neues->mass;
     322      //(*input) >> ws;
     323      (*input) >> neues->CovalentRadius;
     324      //(*input) >> ws;
     325      (*input) >> neues->VanDerWaalsRadius;
     326      //(*input) >> ws;
     327      (*input) >> ws;
    242328      //neues->Output((ofstream *)&cout);
    243       if ((neues->Z > 0) && (neues->Z < MAX_ELEMENTS))
    244         parsedElems[neues->getNumber()] = neues;
    245       else {
    246         DoLog(0) && (Log() << Verbose(0) << "Could not parse element: ");
    247         neues->Output((ofstream *)&cout);
     329      if ((neues->getNumber() > 0) && (neues->getNumber() < MAX_ELEMENTS)) {
     330        if (elements.count(neues->getNumber())) {// if element already present, remove and delete old one (i.e. replace it)
     331          //cout << neues->symbol << " is present already." << endl;
     332          element * const Elemental = FindElement(neues->getNumber());
     333          ASSERT(Elemental != NULL, "element should be present but is not??");
     334          *Elemental = *neues;
     335        } else {
     336          InserterTest = elements.insert(pair <atomicNumber_t,element*> (neues->getNumber(), neues));
     337          ASSERT(InserterTest.second, "Could not insert new element into periodentafel on LoadElementsDatabase().");
     338        }
     339        DoLog(0) && (Log() << Verbose(0) << " " << elements[neues->getNumber()]->symbol);
     340        counter++;
     341      } else {
     342        DoeLog(2) && (eLog() << Verbose(2) << "Detected empty line or invalid element in elements db, discarding." << endl);
     343        DoLog(0) && (Log() << Verbose(0) << " <?>");
    248344        delete(neues);
    249345      }
    250346    }
    251347    DoLog(0) && (Log() << Verbose(0) << endl);
    252     infile.close();
    253     infile.clear();
    254   } else
     348  } else {
     349    DoeLog(1) && (eLog() << Verbose(1) << "Could not open the database." << endl);
    255350    status = false;
    256 
    257   // fill valence DB per element
    258   snprintf(filename,MAXSTRINGSIZE,"%s/%s",path,STANDARDVALENCEDB);
    259   infile.open(filename);
    260   if (infile != NULL) {
    261     while (!infile.eof()) {
     351  }
     352
     353  if (counter == 0)
     354    status = false;
     355
     356  return status;
     357}
     358
     359/** load the valence info.
     360 * \param *input stream to parse from
     361 * \return true - parsing successful, false - something went wrong
     362 */
     363bool periodentafel::LoadValenceDatabase(istream *input)
     364{
     365  char dummy[MAXSTRINGSIZE];
     366  if (!(*input).fail()) {
     367    (*input).getline(dummy, MAXSTRINGSIZE);
     368    while (!(*input).eof()) {
    262369      atomicNumber_t Z;
    263       infile >> Z;
    264       infile >> ws;
    265       infile >> parsedElems[Z]->Valence;
    266       infile >> ws;
     370      (*input) >> Z;
     371      ASSERT(elements.count(Z), "Element not present");
     372      (*input) >> ws;
     373      (*input) >> elements[Z]->Valence;
     374      (*input) >> ws;
    267375      //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->Valence << " valence electrons." << endl;
    268376    }
    269     infile.close();
    270     infile.clear();
    271   } else
    272     otherstatus = false;
    273 
    274   // fill valence DB per element
    275   snprintf(filename,MAXSTRINGSIZE,"%s/%s",path,STANDARDORBITALDB);
    276   infile.open(filename);
    277   if (infile != NULL) {
    278     while (!infile.eof()) {
     377    return true;
     378  } else
     379                return false;
     380}
     381
     382/** load the orbitals info.
     383 * \param *input stream to parse from
     384 * \return true - parsing successful, false - something went wrong
     385 */
     386bool periodentafel::LoadOrbitalsDatabase(istream *input)
     387{
     388  char dummy[MAXSTRINGSIZE];
     389  if (!(*input).fail()) {
     390    (*input).getline(dummy, MAXSTRINGSIZE);
     391    while (!(*input).eof()) {
    279392      atomicNumber_t Z;
    280       infile >> Z;
    281       infile >> ws;
    282       infile >> parsedElems[Z]->NoValenceOrbitals;
    283       infile >> ws;
     393      (*input) >> Z;
     394      ASSERT(elements.count(Z), "Element not present");
     395      (*input) >> ws;
     396      (*input) >> elements[Z]->NoValenceOrbitals;
     397      (*input) >> ws;
    284398      //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->NoValenceOrbitals << " number of singly occupied valence orbitals." << endl;
    285399    }
    286     infile.close();
    287     infile.clear();
    288   } else
    289     otherstatus = false;
    290 
    291   // fill H-BondDistance DB per element
    292   snprintf(filename,MAXSTRINGSIZE,"%s/%s",path,STANDARDHBONDDISTANCEDB);
    293   infile.open(filename);
    294   if (infile != NULL) {
    295     while (!infile.eof()) {
     400    return true;
     401  } else
     402    return false;
     403}
     404
     405/** load the hbond angles info.
     406 * \param *input stream to parse from
     407 * \return true - parsing successful, false - something went wrong
     408 */
     409bool periodentafel::LoadHBondAngleDatabase(istream *input)
     410{
     411  char dummy[MAXSTRINGSIZE];
     412  if (!(*input).fail()) {
     413    (*input).getline(dummy, MAXSTRINGSIZE);
     414    while (!(*input).eof()) {
    296415      atomicNumber_t Z;
    297       infile >> Z;
    298       ptr = parsedElems[Z];
    299       infile >> ws;
    300       infile >> ptr->HBondDistance[0];
    301       infile >> ptr->HBondDistance[1];
    302       infile >> ptr->HBondDistance[2];
    303       infile >> ws;
     416      (*input) >> Z;
     417      ASSERT(elements.count(Z), "Element not present");
     418      (*input) >> ws;
     419      (*input) >> elements[Z]->HBondAngle[0];
     420      (*input) >> elements[Z]->HBondAngle[1];
     421      (*input) >> elements[Z]->HBondAngle[2];
     422      (*input) >> ws;
     423      //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->HBondAngle[0] << ", " << FindElement((int)tmp)->HBondAngle[1] << ", " << FindElement((int)tmp)->HBondAngle[2] << " degrees bond angle for one, two, three connected hydrogens." << endl;
     424    }
     425    return true;
     426  } else
     427                return false;
     428}
     429
     430/** load the hbond lengths info.
     431 * \param *input stream to parse from
     432 * \return true - parsing successful, false - something went wrong
     433 */
     434bool periodentafel::LoadHBondLengthsDatabase(istream *input)
     435{
     436  char dummy[MAXSTRINGSIZE];
     437  if (!(*input).fail()) {
     438    (*input).getline(dummy, MAXSTRINGSIZE);
     439    while (!(*input).eof()) {
     440      atomicNumber_t Z;
     441      (*input) >> Z;
     442      ASSERT(elements.count(Z), "Element not present");
     443      (*input) >> ws;
     444      (*input) >> elements[Z]->HBondDistance[0];
     445      (*input) >> elements[Z]->HBondDistance[1];
     446      (*input) >> elements[Z]->HBondDistance[2];
     447      (*input) >> ws;
    304448      //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->HBondDistance[0] << " Angstrom typical distance to hydrogen." << endl;
    305449    }
    306     infile.close();
    307     infile.clear();
    308   } else
    309     otherstatus = false;
    310 
    311   // fill H-BondAngle DB per element
    312   snprintf(filename,MAXSTRINGSIZE,"%s/%s",path,STANDARDHBONDANGLEDB);
    313   infile.open(filename);
    314   if (infile != NULL) {
    315     while (!infile.eof()) {
    316       atomicNumber_t Z;
    317       infile >> Z;
    318       ptr = parsedElems[Z];
    319       infile >> ws;
    320       infile >> ptr->HBondAngle[0];
    321       infile >> ptr->HBondAngle[1];
    322       infile >> ptr->HBondAngle[2];
    323       infile >> ws;
    324       //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->HBondAngle[0] << ", " << FindElement((int)tmp)->HBondAngle[1] << ", " << FindElement((int)tmp)->HBondAngle[2] << " degrees bond angle for one, two, three connected hydrogens." << endl;
    325     }
    326     infile.close();
    327   } else
    328     otherstatus = false;
    329 
    330   if (otherstatus){
    331     map<atomicNumber_t,element*>::iterator iter;
    332     for(iter=parsedElems.begin();iter!=parsedElems.end();++iter){
    333       AddElement((*iter).second);
    334     }
    335   }
    336   else{
    337     DoeLog(2) && (eLog()<< Verbose(2) << "Something went wrong while parsing the other databases!" << endl);
    338     map<atomicNumber_t,element*>::iterator iter;
    339     for(iter=parsedElems.begin();iter!=parsedElems.end();++iter){
    340       AddElement((*iter).second);
    341     }
    342   }
    343 
    344   return status;
    345 };
     450    return true;
     451  } else
     452                return false;
     453}
    346454
    347455/** Stores element list to file.
     
    353461  char filename[MAXSTRINGSIZE];
    354462
    355   snprintf(filename,MAXSTRINGSIZE,"%s/%s",path,STANDARDELEMENTSDB);
     463  strncpy(filename, path, MAXSTRINGSIZE);
     464  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
     465  strncat(filename, STANDARDELEMENTSDB, MAXSTRINGSIZE-strlen(filename));
    356466  f.open(filename);
    357467  if (f != NULL) {
     
    362472    }
    363473    f.close();
    364   } else
    365     result = false;
    366   return result;
    367 };
     474    return true;
     475  } else
     476    return result;
     477};
  • src/periodentafel.hpp

    r0c7ed8 r1dc9ec  
    1313#include <iterator>
    1414
     15#include "unittests/periodentafelTest.hpp"
    1516#include "defs.hpp"
    1617#include "types.hpp"
     
    2728class periodentafel {
    2829  /******* Types *********/
     30  friend class periodentafelTest;
    2931  private:
    3032    typedef std::map<atomicNumber_t,element*> elementSet;
     
    4244
    4345  iterator AddElement(element * const pointer);
    44   void RemoveElement(element * const pointer);
     46  size_t RemoveElement(element * const pointer);
     47  size_t RemoveElement(atomicNumber_t);
    4548  void CleanupPeriodtable();
    46   const element *FindElement(atomicNumber_t) const;
    47   const element *FindElement(const char * const shorthand) const;
    48   const element *AskElement() const;
    49   const element *EnterElement();
     49  element * const FindElement(atomicNumber_t) const;
     50  element * const FindElement(const char * const shorthand) const;
     51  element * const AskElement() const;
     52  element * const EnterElement();
    5053
    5154  const_iterator begin();
     
    5962
    6063  private:
     64
     65  bool LoadElementsDatabase(std::istream *input);
     66  bool LoadValenceDatabase(std::istream *input);
     67  bool LoadOrbitalsDatabase(std::istream *input);
     68  bool LoadHBondAngleDatabase(std::istream *input);
     69  bool LoadHBondLengthsDatabase(std::istream *input);
     70
    6171    elementSet elements;
    6272};
  • src/stackclass.hpp

    r0c7ed8 r1dc9ec  
    5050template <typename T> StackClass<T>::StackClass(int dimension) : StackList(NULL), EntryCount(dimension), CurrentLastEntry(0), CurrentFirstEntry(0), NextFreeField(0)
    5151{
    52   StackList = Calloc<T>(EntryCount, "StackClass::StackClass: **StackList");
     52  StackList = new T[EntryCount];
     53  for (int i=0;i<EntryCount;i++)
     54    StackList[i] = NULL;
    5355};
    5456
     
    5759template <typename T> StackClass<T>::~StackClass()
    5860{
    59   Free(&StackList);
     61  delete[](StackList);
    6062};
    6163
  • src/tesselation.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include <fstream>
     
    2224#include "Plane.hpp"
    2325#include "Exceptions/LinearDependenceException.hpp"
     26#include "Helpers/Assert.hpp"
     27
    2428#include "Helpers/Assert.hpp"
    2529
     
    359363  // get ascending order of endpoints
    360364  PointMap OrderMap;
    361   for (int i = 0; i < 3; i++)
     365  for (int i = 0; i < 3; i++) {
    362366    // for all three lines
    363367    for (int j = 0; j < 2; j++) { // for both endpoints
     
    365369      // and we don't care whether insertion fails
    366370    }
     371  }
    367372  // set endpoints
    368373  int Counter = 0;
     
    373378    Counter++;
    374379  }
    375   if (Counter < 3) {
    376     DoeLog(0) && (eLog() << Verbose(0) << "We have a triangle with only two distinct endpoints!" << endl);
    377     performCriticalExit();
    378   }
    379 }
    380 ;
     380  ASSERT(Counter >= 3,"We have a triangle with only two distinct endpoints!");
     381};
     382
    381383
    382384/** Destructor of BoundaryTriangleSet.
     
    12251227;
    12261228
    1227 /** PointCloud implementation of GetTerminalPoint.
    1228  * Uses PointsOnBoundary and STL stuff.
    1229  */
    1230 TesselPoint * Tesselation::GetTerminalPoint() const
    1231 {
    1232   Info FunctionInfo(__func__);
    1233   PointMap::const_iterator Runner = PointsOnBoundary.end();
    1234   Runner--;
    1235   return (Runner->second->node);
    1236 }
    1237 ;
    1238 
    12391229/** PointCloud implementation of GoToNext.
    12401230 * Uses PointsOnBoundary and STL stuff.
     
    12481238;
    12491239
    1250 /** PointCloud implementation of GoToPrevious.
    1251  * Uses PointsOnBoundary and STL stuff.
    1252  */
    1253 void Tesselation::GoToPrevious() const
    1254 {
    1255   Info FunctionInfo(__func__);
    1256   if (InternalPointer != PointsOnBoundary.begin())
    1257     InternalPointer--;
    1258 }
    1259 ;
    1260 
    12611240/** PointCloud implementation of GoToFirst.
    12621241 * Uses PointsOnBoundary and STL stuff.
     
    12661245  Info FunctionInfo(__func__);
    12671246  InternalPointer = PointsOnBoundary.begin();
    1268 }
    1269 ;
    1270 
    1271 /** PointCloud implementation of GoToLast.
    1272  * Uses PointsOnBoundary and STL stuff.
    1273  */
    1274 void Tesselation::GoToLast() const
    1275 {
    1276   Info FunctionInfo(__func__);
    1277   InternalPointer = PointsOnBoundary.end();
    1278   InternalPointer--;
    12791247}
    12801248;
     
    19491917        RemoveTesselationLine(triangle->lines[i]);
    19501918      } else {
    1951         DoLog(0) && (Log() << Verbose(0) << *triangle->lines[i] << " is still attached to another triangle: ");
     1919        DoLog(0) && (Log() << Verbose(0) << *triangle->lines[i] << " is still attached to another triangle: " << endl);
    19521920        OpenLines.insert(pair<BoundaryLineSet *, CandidateForTesselation *> (triangle->lines[i], NULL));
    19531921        for (TriangleMap::iterator TriangleRunner = triangle->lines[i]->triangles.begin(); TriangleRunner != triangle->lines[i]->triangles.end(); TriangleRunner++)
    1954           DoLog(0) && (Log() << Verbose(0) << "[" << (TriangleRunner->second)->Nr << "|" << *((TriangleRunner->second)->endpoints[0]) << ", " << *((TriangleRunner->second)->endpoints[1]) << ", " << *((TriangleRunner->second)->endpoints[2]) << "] \t");
     1922          DoLog(0) && (Log() << Verbose(0) << "\t[" << (TriangleRunner->second)->Nr << "|" << *((TriangleRunner->second)->endpoints[0]) << ", " << *((TriangleRunner->second)->endpoints[1]) << ", " << *((TriangleRunner->second)->endpoints[2]) << "] \t");
    19551923        DoLog(0) && (Log() << Verbose(0) << endl);
    19561924        //        for (int j=0;j<2;j++) {
     
    25862554  // fill the set of neighbours
    25872555  TesselPointSet SetOfNeighbours;
     2556
    25882557  SetOfNeighbours.insert(CandidateLine.BaseLine->endpoints[1]->node);
    25892558  for (TesselPointList::iterator Runner = CandidateLine.pointlist.begin(); Runner != CandidateLine.pointlist.end(); Runner++)
     
    30052974  OldBaseLineNr = Base->Nr;
    30062975  m = 0;
    3007   for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) {
    3008     DoLog(0) && (Log() << Verbose(0) << "INFO: Deleting triangle " << *(runner->second) << "." << endl);
    3009     OldTriangleNrs[m++] = runner->second->Nr;
    3010     RemoveTesselationTriangle(runner->second);
     2976  // first obtain all triangle to delete ... (otherwise we pull the carpet (Base) from under the for-loop's feet)
     2977  list <BoundaryTriangleSet *> TrianglesOfBase;
     2978  for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); ++runner)
     2979    TrianglesOfBase.push_back(runner->second);
     2980  // .. then delete each triangle (which deletes the line as well)
     2981  for (list <BoundaryTriangleSet *>::iterator runner = TrianglesOfBase.begin(); !TrianglesOfBase.empty(); runner = TrianglesOfBase.begin()) {
     2982    DoLog(0) && (Log() << Verbose(0) << "INFO: Deleting triangle " << *(*runner) << "." << endl);
     2983    OldTriangleNrs[m++] = (*runner)->Nr;
     2984    RemoveTesselationTriangle((*runner));
     2985    TrianglesOfBase.erase(runner);
    30112986  }
    30122987
  • src/tesselation.hpp

    r0c7ed8 r1dc9ec  
    244244  virtual Vector *GetCenter() const { return NULL; };
    245245  virtual TesselPoint *GetPoint() const { return NULL; };
    246   virtual TesselPoint *GetTerminalPoint() const { return NULL; };
    247246  virtual int GetMaxId() const { return 0; };
    248247  virtual void GoToNext() const {};
    249   virtual void GoToPrevious() const {};
    250248  virtual void GoToFirst() const {};
    251   virtual void GoToLast() const {};
    252249  virtual bool IsEmpty() const { return true; };
    253250  virtual bool IsEnd() const { return true; };
     
    363360    virtual Vector *GetCenter(ofstream *out) const;
    364361    virtual TesselPoint *GetPoint() const;
    365     virtual TesselPoint *GetTerminalPoint() const;
    366362    virtual void GoToNext() const;
    367     virtual void GoToPrevious() const;
    368363    virtual void GoToFirst() const;
    369     virtual void GoToLast() const;
    370364    virtual bool IsEmpty() const;
    371365    virtual bool IsEnd() const;
  • src/tesselationhelpers.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: heber
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include <fstream>
     
    786788      Walker = cloud->GetPoint();
    787789      *rasterfile << "2" << endl << "  ";  // 2 is sphere type
    788       for (i=0;i<NDIM;i++)
    789         *rasterfile << Walker->node->at(i)-center->at(i) << " ";
     790      for (int j=0;j<NDIM;j++) { // and for each node all NDIM coordinates
     791        const double tmp = Walker->node->at(j)-center->at(j);
     792        *rasterfile << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " ";
     793      }
    790794      *rasterfile << "\t0.1\t1. 1. 1." << endl; // radius 0.05 and white as colour
    791795      cloud->GoToNext();
     
    797801      *rasterfile << "1" << endl << "  ";  // 1 is triangle type
    798802      for (i=0;i<3;i++) {  // print each node
    799         for (int j=0;j<NDIM;j++)  // and for each node all NDIM coordinates
    800           *rasterfile << TriangleRunner->second->endpoints[i]->node->node->at(j)-center->at(j) << " ";
     803        for (int j=0;j<NDIM;j++) { // and for each node all NDIM coordinates
     804          const double tmp = TriangleRunner->second->endpoints[i]->node->node->at(j)-center->at(j);
     805          *rasterfile << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " ";
     806        }
    801807        *rasterfile << "\t";
    802808      }
     
    837843    }
    838844    *tecplot << "\", N=" << TesselStruct->PointsOnBoundary.size() << ", E=" << TesselStruct->TrianglesOnBoundary.size() << ", DATAPACKING=POINT, ZONETYPE=FETRIANGLE" << endl;
    839     int i=cloud->GetMaxId();
    840     int *LookupList = new int[i];
    841     for (cloud->GoToFirst(), i=0; !cloud->IsEnd(); cloud->GoToNext(), i++)
     845    const int MaxId=cloud->GetMaxId();
     846    int *LookupList = new int[MaxId];
     847    for (int i=0; i< MaxId ; i++){
    842848      LookupList[i] = -1;
     849    }
    843850
    844851    // print atom coordinates
    845852    int Counter = 1;
    846853    TesselPoint *Walker = NULL;
    847     for (PointMap::const_iterator target = TesselStruct->PointsOnBoundary.begin(); target != TesselStruct->PointsOnBoundary.end(); target++) {
     854    for (PointMap::const_iterator target = TesselStruct->PointsOnBoundary.begin(); target != TesselStruct->PointsOnBoundary.end(); ++target) {
    848855      Walker = target->second->node;
    849856      LookupList[Walker->nr] = Counter++;
    850       *tecplot << Walker->node->at(0) << " " << Walker->node->at(1) << " " << Walker->node->at(2) << " " << target->second->value << endl;
     857      for (int i=0;i<NDIM;i++) {
     858        const double tmp = Walker->node->at(i);
     859        *tecplot << ((fabs(tmp) < MYEPSILON) ? 0 : tmp) << " ";
     860      }
     861      *tecplot << target->second->value << endl;
    851862    }
    852863    *tecplot << endl;
  • src/triangleintersectionlist.cpp

    r0c7ed8 r1dc9ec  
    88 *      Author: heber
    99 */
     10
     11#include "Helpers/MemDebug.hpp"
    1012
    1113#include "triangleintersectionlist.hpp"
  • src/unittests/ActOnAllUnitTest.cpp

    r0c7ed8 r1dc9ec  
    4646  // Ref was copy constructed, hence has to be cleaned, too!
    4747  Ref.EmptyList();
    48   MemoryUsageObserver::purgeInstance();
    4948};
    5049
     
    7776
    7877  // scaling by three values
    79   double *factors = Malloc<double>(NDIM, "ActOnAllTest::ScaleTest - factors");
    80   double *inverses = Malloc<double>(NDIM, "ActOnAllTest::ScaleTest - inverses");
     78  double *factors = new double[NDIM];
     79  double *inverses = new double[NDIM];
    8180  for (int i=0;i<NDIM;++i) {
    8281    factors[i] = 2.;
     
    8887  VL.ActOnAll<Vector,void,const double*>(&Vector::ScaleAll, inverses );
    8988  CPPUNIT_ASSERT_EQUAL( VL == Ref , true );
    90   Free(factors);
    91   Free(inverses);
     89  delete[](factors);
     90  delete[](inverses);
    9291};
    9392
  • src/unittests/AnalysisCorrelationToPointUnitTest.cpp

    r0c7ed8 r1dc9ec  
    1717#include "AnalysisCorrelationToPointUnitTest.hpp"
    1818
    19 #include "World.hpp"
    2019#include "atom.hpp"
    21 #include "boundary.hpp"
    2220#include "element.hpp"
    2321#include "molecule.hpp"
    2422#include "linkedcell.hpp"
    2523#include "periodentafel.hpp"
    26 #include "tesselation.hpp"
    2724#include "World.hpp"
    2825
     
    4340  TestList = NULL;
    4441  TestMolecule = NULL;
    45   hydrogen = NULL;
    46   tafel = NULL;
    4742  pointmap = NULL;
    4843  binmap = NULL;
    4944  point = NULL;
    5045
    51   // construct element
    52   hydrogen = new element;
    53   hydrogen->Z = 1;
    54   strcpy(hydrogen->name, "hydrogen");
    55   strcpy(hydrogen->symbol, "H");
    56 
    57 
    58   // construct periodentafel
    59   tafel = World::getInstance().getPeriode();
    60   tafel->AddElement(hydrogen);
    61 
     46  // construct element list
     47  std::vector<element *> elements;
     48  hydrogen = World::getInstance().getPeriode()->FindElement(1);
     49  CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found");
     50  elements.push_back(hydrogen);
    6251  // construct molecule (tetraeder of hydrogens)
    6352  TestMolecule = World::getInstance().createMolecule();
     
    8069
    8170  // check that TestMolecule was correctly constructed
    82   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
     71  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 );
    8372
    8473  TestList = World::getInstance().getMolecules();
     
    9079
    9180  // init maps
    92   pointmap = CorrelationToPoint( (MoleculeListClass * const)TestList, (const element * const)hydrogen, (const Vector *)point );
     81  pointmap = CorrelationToPoint( (MoleculeListClass * const)TestList, elements, (const Vector *)point );
    9382  binmap = NULL;
    9483
     
    10594  delete(point);
    10695  World::purgeInstance();
    107   MemoryUsageObserver::purgeInstance();
    10896  logger::purgeInstance();
    10997};
  • src/unittests/AnalysisCorrelationToPointUnitTest.hpp

    r0c7ed8 r1dc9ec  
    1212
    1313class element;
    14 class LinkedCell;
    1514class molecule;
    1615class MoleculeListClass;
    17 class periodentafel;
    18 class Tesselation;
    1916class Vector;
    2017
     
    4138      molecule *TestMolecule;
    4239      element *hydrogen;
    43       periodentafel *tafel;
    4440
    4541      CorrelationToPointMap *pointmap;
  • src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp

    r0c7ed8 r1dc9ec  
    1717#include "AnalysisCorrelationToSurfaceUnitTest.hpp"
    1818
    19 #include "World.hpp"
    2019#include "atom.hpp"
    2120#include "boundary.hpp"
     
    2625#include "tesselation.hpp"
    2726#include "World.hpp"
     27#include "Helpers/Assert.hpp"
    2828
    2929#include "Helpers/Assert.hpp"
     
    4040void AnalysisCorrelationToSurfaceUnitTest::setUp()
    4141{
    42   //ASSERT_DO(Assert::Throw);
     42  ASSERT_DO(Assert::Throw);
    4343
    4444  atom *Walker = NULL;
     
    4747  TestList = NULL;
    4848  TestSurfaceMolecule = NULL;
    49   hydrogen = NULL;
    50   tafel = NULL;
    5149  surfacemap = NULL;
    5250  binmap = NULL;
     
    5452  LC = NULL;
    5553
    56   // construct element
    57   hydrogen = new element;
    58   hydrogen->Z = 1;
    59   strcpy(hydrogen->name, "hydrogen");
    60   strcpy(hydrogen->symbol, "H");
    61   carbon = new element;
    62   carbon->Z = 6;
    63   strcpy(carbon->name, "carbon");
    64   strcpy(carbon->symbol, "C");
    65 
    66   // construct periodentafel
    67   tafel = World::getInstance().getPeriode();
    68   tafel->AddElement(hydrogen);
    69   tafel->AddElement(carbon);
     54  // prepare element list
     55  hydrogen = World::getInstance().getPeriode()->FindElement(1);
     56  CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found");
     57  elements.clear();
    7058
    7159  // construct molecule (tetraeder of hydrogens) base
    7260  TestSurfaceMolecule = World::getInstance().createMolecule();
     61
    7362  Walker = World::getInstance().createAtom();
    7463  Walker->type = hydrogen;
    7564  *Walker->node = Vector(1., 0., 1. );
    76 
    77   TestSurfaceMolecule->AddAtom(Walker);
     65  TestSurfaceMolecule->AddAtom(Walker);
     66
    7867  Walker = World::getInstance().createAtom();
    7968  Walker->type = hydrogen;
    8069  *Walker->node = Vector(0., 1., 1. );
    8170  TestSurfaceMolecule->AddAtom(Walker);
     71
    8272  Walker = World::getInstance().createAtom();
    8373  Walker->type = hydrogen;
    8474  *Walker->node = Vector(1., 1., 0. );
    8575  TestSurfaceMolecule->AddAtom(Walker);
     76
    8677  Walker = World::getInstance().createAtom();
    8778  Walker->type = hydrogen;
     
    9081
    9182  // check that TestMolecule was correctly constructed
    92   CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule->AtomCount, 4 );
     83  CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule->getAtomCount(), 4 );
    9384
    9485  TestList = World::getInstance().getMolecules();
     
    10293
    10394  // add outer atoms
     95  carbon = World::getInstance().getPeriode()->FindElement(6);
    10496  TestSurfaceMolecule = World::getInstance().createMolecule();
    10597  Walker = World::getInstance().createAtom();
     
    10799  *Walker->node = Vector(4., 0., 4. );
    108100  TestSurfaceMolecule->AddAtom(Walker);
     101
    109102  Walker = World::getInstance().createAtom();
    110103  Walker->type = carbon;
    111104  *Walker->node = Vector(0., 4., 4. );
    112105  TestSurfaceMolecule->AddAtom(Walker);
     106
    113107  Walker = World::getInstance().createAtom();
    114108  Walker->type = carbon;
    115109  *Walker->node = Vector(4., 4., 0. );
    116110  TestSurfaceMolecule->AddAtom(Walker);
     111
    117112  // add inner atoms
    118113  Walker = World::getInstance().createAtom();
     
    120115  *Walker->node = Vector(0.5, 0.5, 0.5 );
    121116  TestSurfaceMolecule->AddAtom(Walker);
     117
    122118  TestSurfaceMolecule->ActiveFlag = true;
    123119  TestList->insert(TestSurfaceMolecule);
     
    141137  delete(LC);
    142138  World::purgeInstance();
    143   MemoryUsageObserver::purgeInstance();
    144139  logger::purgeInstance();
    145140};
     
    150145void AnalysisCorrelationToSurfaceUnitTest::SurfaceTest()
    151146{
    152   CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule->AtomCount );
     147  CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule->getAtomCount() );
    153148  CPPUNIT_ASSERT_EQUAL( (size_t)2, TestList->ListOfMolecules.size() );
    154149  CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() );
     
    160155{
    161156  // do the pair correlation
    162   surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC );
     157  elements.push_back(hydrogen);
     158  surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
    163159//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    164160  CPPUNIT_ASSERT( surfacemap != NULL );
     
    169165{
    170166  BinPairMap::iterator tester;
    171   surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC );
     167  elements.push_back(hydrogen);
     168  surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
    172169  // put pair correlation into bins and check with no range
    173170//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
     
    184181{
    185182  BinPairMap::iterator tester;
    186   surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC );
     183  elements.push_back(hydrogen);
     184  surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
    187185//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    188186  // ... and check with [0., 2.] range
     
    202200{
    203201  BinPairMap::iterator tester;
    204   surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC );
     202  elements.push_back(carbon);
     203  surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
    205204//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    206205  // put pair correlation into bins and check with no range
     
    221220{
    222221  BinPairMap::iterator tester;
    223   surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC );
     222  elements.push_back(carbon);
     223  surfacemap = CorrelationToSurface( TestList, elements, Surface, LC );
    224224//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    225225  // ... and check with [0., 2.] range
  • src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp

    r0c7ed8 r1dc9ec  
    4747      element *hydrogen;
    4848      element *carbon;
    49       periodentafel *tafel;
     49      std::vector<element *> elements;
    5050
    5151      CorrelationToSurfaceMap *surfacemap;
  • src/unittests/AnalysisPairCorrelationUnitTest.cpp

    r0c7ed8 r1dc9ec  
    4444  TestList = NULL;
    4545  TestMolecule = NULL;
    46   hydrogen = NULL;
    47   tafel = NULL;
    4846  correlationmap = NULL;
    4947  binmap = NULL;
    5048
    51   // construct element
    52   hydrogen = new element;
    53   hydrogen->Z = 1;
    54   strcpy(hydrogen->name, "hydrogen");
    55   strcpy(hydrogen->symbol, "H");
    56 
    57   // construct periodentafel
    58   tafel = World::getInstance().getPeriode();
    59   tafel->AddElement(hydrogen);
     49  // construct element list
     50  std::vector<element *> elements;
     51  hydrogen = World::getInstance().getPeriode()->FindElement(1);
     52  CPPUNIT_ASSERT(hydrogen != NULL && "hydrogen element not found");
     53  elements.push_back(hydrogen);
     54  elements.push_back(hydrogen);
    6055
    6156  // construct molecule (tetraeder of hydrogens)
     
    7974
    8075  // check that TestMolecule was correctly constructed
    81   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
     76  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 );
    8277
    8378  TestList = World::getInstance().getMolecules();
     
    8681
    8782  // init maps
    88   correlationmap = PairCorrelation( TestList, hydrogen, hydrogen );
     83  correlationmap = PairCorrelation( TestList, elements);
    8984  binmap = NULL;
    9085
     
    10196  // note that all the atoms are cleaned by TestMolecule
    10297  World::purgeInstance();
    103   MemoryUsageObserver::purgeInstance();
    10498  logger::purgeInstance();
    10599  errorLogger::purgeInstance();
  • src/unittests/AnalysisPairCorrelationUnitTest.hpp

    r0c7ed8 r1dc9ec  
    1212
    1313class element;
    14 class LinkedCell;
    1514class molecule;
    1615class MoleculeListClass;
    17 class periodentafel;
    18 class Tesselation;
    1916class Vector;
    2017
     
    4138      molecule *TestMolecule;
    4239      element *hydrogen;
    43       periodentafel *tafel;
    4440
    4541      PairCorrelationMap *correlationmap;
  • src/unittests/CacheableTest.cpp

    r0c7ed8 r1dc9ec  
    5555
    5656  threeNumbers(int _x,int _y, int _z) :
     57    Observable("threeNumbers"),
    5758    x(_x),y(_y),z(_z),
    58     sum(this,boost::bind(&threeNumbers::calcSum,this)),
     59    sum(this,boost::bind(&threeNumbers::calcSum,this),"sum"),
    5960    hasRecalced(false)
    6061  {}
     
    8182  CPPUNIT_ASSERT_EQUAL( 9, *(numbers->sum));
    8283  CPPUNIT_ASSERT_EQUAL( true, numbers->hasRecalced);
     84  numbers->hasRecalced=false;
     85  CPPUNIT_ASSERT_EQUAL( 9, *(numbers->sum));
     86#ifndef NO_CACHING
     87  CPPUNIT_ASSERT_EQUAL( false, numbers->hasRecalced);
     88#else
     89  CPPUNIT_ASSERT_EQUAL( true, numbers->hasRecalced);
     90#endif
    8391}
  • src/unittests/CountBondsUnitTest.cpp

    r0c7ed8 r1dc9ec  
    1616#include <stdio.h>
    1717#include <cstring>
     18
     19#include "Helpers/Assert.hpp"
    1820
    1921#include "analysis_bonds.hpp"
     
    4042{
    4143  atom *Walker = NULL;
    42   BG = NULL;
    43   filename = NULL;
    44 
    45   // init private all pointers to zero
    46   molecules = NULL;
    47   TestMolecule1 = NULL;
    48   TestMolecule2 = NULL;
    49   hydrogen = NULL;
    50   oxygen = NULL;
    51   tafel = NULL;
    5244
    5345  // construct element
    54   hydrogen = new element;
    55   hydrogen->Z = 1;
    56   hydrogen->CovalentRadius = 0.23;
    57   strcpy(hydrogen->name, "hydrogen");
    58   strcpy(hydrogen->symbol, "H");
    59   oxygen = new element;
    60   oxygen->Z = 8;
    61   oxygen->CovalentRadius = 0.68;
    62   strcpy(oxygen->name, "oxygen");
    63   strcpy(oxygen->symbol, "O");
    64 
    65   // construct periodentafel
    66   tafel = World::getInstance().getPeriode();
    67   tafel->AddElement(hydrogen);
    68   tafel->AddElement(oxygen);
     46  hydrogen = World::getInstance().getPeriode()->FindElement(1);
     47  oxygen = World::getInstance().getPeriode()->FindElement(8);
     48  CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen");
     49  CPPUNIT_ASSERT(oxygen != NULL && "could not find element oxygen");
    6950
    7051  // construct molecule (water molecule)
    7152  TestMolecule1 = World::getInstance().createMolecule();
    72   Walker = World::getInstance().createAtom();
     53  CPPUNIT_ASSERT(TestMolecule1 != NULL && "could not create first molecule");
     54  Walker = World::getInstance().createAtom();
     55  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7356  Walker->type = hydrogen;
    7457  *Walker->node = Vector(-0.2418, 0.9350, 0. );
    7558  TestMolecule1->AddAtom(Walker);
    7659  Walker = World::getInstance().createAtom();
     60  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7761  Walker->type = hydrogen;
    7862  *Walker->node = Vector(0.9658, 0., 0. );
    7963  TestMolecule1->AddAtom(Walker);
    8064  Walker = World::getInstance().createAtom();
     65  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    8166  Walker->type = oxygen;
    8267  *Walker->node = Vector(0., 0., 0. );
     
    8469
    8570  TestMolecule2 = World::getInstance().createMolecule();
    86   Walker = World::getInstance().createAtom();
     71  CPPUNIT_ASSERT(TestMolecule2 != NULL && "could not create second molecule");
     72  Walker = World::getInstance().createAtom();
     73  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    8774  Walker->type = hydrogen;
    8875  *Walker->node = Vector(-0.2418, 0.9350, 0. );
    8976  TestMolecule2->AddAtom(Walker);
    9077  Walker = World::getInstance().createAtom();
     78  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    9179  Walker->type = hydrogen;
    9280  *Walker->node = Vector(0.9658, 0., 0. );
    9381  TestMolecule2->AddAtom(Walker);
    9482  Walker = World::getInstance().createAtom();
     83  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    9584  Walker->type = oxygen;
    9685  *Walker->node = Vector(0., 0., 0. );
     
    9887
    9988  molecules = World::getInstance().getMolecules();
     89  CPPUNIT_ASSERT(molecules != NULL && "could not obtain list of molecules");
    10090  molecules->insert(TestMolecule1);
    10191  molecules->insert(TestMolecule2);
    10292
    10393  // check that TestMolecule was correctly constructed
    104   CPPUNIT_ASSERT_EQUAL( TestMolecule1->AtomCount, 3 );
    105   Walker = TestMolecule1->start->next;
    106   CPPUNIT_ASSERT( TestMolecule1->end != Walker );
    107   CPPUNIT_ASSERT_EQUAL( TestMolecule2->AtomCount, 3 );
    108   Walker = TestMolecule2->start->next;
    109   CPPUNIT_ASSERT( TestMolecule2->end != Walker );
     94  CPPUNIT_ASSERT_EQUAL( TestMolecule1->getAtomCount(), 3 );
     95  CPPUNIT_ASSERT_EQUAL( TestMolecule2->getAtomCount(), 3 );
    11096
    11197  // create a small file with table
    11298  BG = new BondGraph(true);
     99  CPPUNIT_ASSERT(BG != NULL && "could not create BondGraph");
    113100
    114101  // construct bond graphs
     
    126113
    127114  World::purgeInstance();
    128   MemoryUsageObserver::purgeInstance();
    129115};
    130116
     
    158144{
    159145  double *mirror = new double[3];
     146  CPPUNIT_ASSERT(mirror != NULL && "could not create array of doubles");
    160147  for (int i=0;i<3;i++)
    161148    mirror[i] = -1.;
  • src/unittests/CountBondsUnitTest.hpp

    r0c7ed8 r1dc9ec  
    3939      molecule *TestMolecule1;
    4040      molecule *TestMolecule2;
    41       element *hydrogen;
    42       element *oxygen;
    43       periodentafel *tafel;
     41      const element *hydrogen;
     42      const element *oxygen;
    4443
    4544      BondGraph *BG;
  • src/unittests/LinkedCellUnitTest.cpp

    r0c7ed8 r1dc9ec  
    3838  atom *Walker = NULL;
    3939
    40   // init private all pointers to zero
    41   TestMolecule = NULL;
    42   hydrogen = NULL;
    43   tafel = NULL;
    44 
    4540  // construct element
    46   hydrogen = new element;
    47   hydrogen->Z = 1;
    48   hydrogen->CovalentRadius = 0.23;
    49   strcpy(hydrogen->name, "hydrogen");
    50   strcpy(hydrogen->symbol, "H");
    51 
    52   // construct periodentafel
    53   tafel = World::getInstance().getPeriode();
    54   tafel->AddElement(hydrogen);
     41  hydrogen = World::getInstance().getPeriode()->FindElement(1);
     42  CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen");
    5543
    5644  // construct molecule (water molecule)
    5745  TestMolecule = World::getInstance().createMolecule();
     46  CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule");
    5847  for (double x=0.5;x<3;x+=1.)
    5948    for (double y=0.5;y<3;y+=1.)
    6049      for (double z=0.5;z<3;z+=1.) {
    6150        Walker = World::getInstance().createAtom();
     51        CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    6252        Walker->type = hydrogen;
    6353        *Walker->node = Vector(x, y, z );
     
    6757  // construct linked cell
    6858  LC = new LinkedCell (TestMolecule, 1.);
     59  CPPUNIT_ASSERT(LC != NULL && "could not create LinkedCell");
    6960
    7061  // check that TestMolecule was correctly constructed
    71   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 3*3*3 );
    72   Walker = TestMolecule->start->next;
    73   CPPUNIT_ASSERT( TestMolecule->end != Walker );
     62  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 3*3*3 );
    7463};
    7564
     
    7968  delete(LC);
    8069  World::purgeInstance();
    81   MemoryUsageObserver::purgeInstance();
    8270};
    8371
     
    197185{
    198186  // check all atoms
    199   atom *Walker = TestMolecule->start;
    200   while (Walker->next != TestMolecule->end) {
    201     Walker = Walker->next;
    202     CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToNode(Walker) );
     187  for(molecule::iterator iter = TestMolecule->begin(); iter != TestMolecule->end();++iter){
     188    CPPUNIT_ASSERT_EQUAL( true, LC->SetIndexToNode(*iter) );
    203189  }
    204190
    205191  // check internal vectors, returns false, because this atom is not in LC-list!
    206   Walker = World::getInstance().createAtom();
    207   Walker->setName("test");
    208   Walker->x= Vector(1,1,1);
    209   CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(Walker) );
    210   World::getInstance().destroyAtom(Walker);
     192  atom *newAtom = World::getInstance().createAtom();
     193  newAtom->setName("test");
     194  newAtom->x= Vector(1,1,1);
     195  CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(newAtom) );
     196  World::getInstance().destroyAtom(newAtom);
    211197
    212198  // check out of bounds vectors
    213   Walker = World::getInstance().createAtom();
    214   Walker->setName("test");
    215   Walker->x = Vector(0,-1,0);
    216   CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(Walker) );
    217   World::getInstance().destroyAtom(Walker);
     199  newAtom = World::getInstance().createAtom();
     200  newAtom->setName("test");
     201  newAtom->x = Vector(0,-1,0);
     202  CPPUNIT_ASSERT_EQUAL( false, LC->SetIndexToNode(newAtom) );
     203  World::getInstance().destroyAtom(newAtom);
    218204};
    219205
     
    287273  size = ListOfPoints->size();
    288274  CPPUNIT_ASSERT_EQUAL( (size_t)27, size );
    289   Walker = TestMolecule->start;
    290   Walker = TestMolecule->start;
    291   while (Walker->next != TestMolecule->end) {
    292     Walker = Walker->next;
    293     ListOfPoints->remove(Walker);
     275
     276  for(molecule::iterator iter = TestMolecule->begin(); iter != TestMolecule->end(); ++iter){
     277    ListOfPoints->remove((*iter));
    294278    size--;
    295279    CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
     
    306290  size=ListOfPoints->size();
    307291  CPPUNIT_ASSERT_EQUAL( (size_t)8, size );
    308   Walker = TestMolecule->start;
    309   while (Walker->next != TestMolecule->end) {
    310     Walker = Walker->next;
    311     if ((Walker->x[0] <2) && (Walker->x[1] <2) && (Walker->x[2] <2)) {
    312       ListOfPoints->remove(Walker);
     292  for(molecule::iterator iter = TestMolecule->begin(); iter != TestMolecule->end(); ++iter){
     293    if (((*iter)->x[0] <2) && ((*iter)->x[1] <2) && ((*iter)->x[2] <2)) {
     294      ListOfPoints->remove(*iter);
    313295      size--;
    314296      CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
     
    326308  size=ListOfPoints->size();
    327309  CPPUNIT_ASSERT_EQUAL( (size_t)27, size );
    328   Walker = TestMolecule->start;
    329   while (Walker->next != TestMolecule->end) {
    330     Walker = Walker->next;
    331     ListOfPoints->remove(Walker);
     310  for(molecule::iterator iter = TestMolecule->begin(); iter!=TestMolecule->end();++iter){
     311    ListOfPoints->remove(*iter);
    332312    size--;
    333313    CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
     
    355335  size = ListOfPoints->size();
    356336  CPPUNIT_ASSERT_EQUAL( (size_t)7, size );
    357   Walker = TestMolecule->start;
    358   while (Walker->next != TestMolecule->end) {
    359     Walker = Walker->next;
    360     if ((Walker->x.DistanceSquared(tester) - 1.) < MYEPSILON ) {
    361       ListOfPoints->remove(Walker);
     337  for(molecule::iterator iter = TestMolecule->begin(); iter!=TestMolecule->end();++iter){
     338    if (((*iter)->x.DistanceSquared(tester) - 1.) < MYEPSILON ) {
     339      ListOfPoints->remove(*iter);
    362340      size--;
    363341      CPPUNIT_ASSERT_EQUAL( size, ListOfPoints->size() );
  • src/unittests/LinkedCellUnitTest.hpp

    r0c7ed8 r1dc9ec  
    4848
    4949      molecule *TestMolecule;
    50       element *hydrogen;
    51       periodentafel *tafel;
     50      const element *hydrogen;
    5251      LinkedCell *LC;
    5352};
  • src/unittests/Makefile.am

    r0c7ed8 r1dc9ec  
     1# PLEASE adhere to the alphabetical ordering in this Makefile!
     2# Also indentation by a single tab
     3
    14INCLUDES = -I$(top_srcdir)/src
    25
     
    3134  MemoryAllocatorUnitTest \
    3235  MoleculeDescriptorTest \
     36  ObserverTest \
     37  ParserUnitTest \
     38  periodentafelTest \
    3339  PlaneUnittest \
    34   ObserverTest \
    3540  SingletonTest \
    3641  StackClassUnitTest \
     
    7378  memoryusageobserverunittest.cpp \
    7479  MoleculeDescriptorTest.cpp \
     80  ObserverTest.cpp \
     81  ParserUnitTest.cpp \
     82  periodentafelTest.cpp \
    7583  PlaneUnittest.cpp \
    76   ObserverTest.cpp \
    7784  SingletonTest.cpp \
    7885  stackclassunittest.cpp \
     
    107114  memoryusageobserverunittest.hpp \
    108115  MoleculeDescriptorTest.hpp \
     116  periodentafelTest.hpp \
    109117  PlaneUnittest.hpp \
    110118  ObserverTest.hpp \
     
    117125 
    118126
     127ActionSequenceTest_SOURCES = UnitTestMain.cpp ../../../TestRunnerClient.hpp ActionSequenceTest.cpp ActionSequenceTest.hpp
     128ActionSequenceTest_LDADD = ${ALLLIBS}
     129
    119130ActOnAllUnitTest_SOURCES = UnitTestMain.cpp ../test/ActOnAllTest.hpp ActOnAllUnitTest.cpp ActOnAllUnitTest.hpp
    120131ActOnAllUnitTest_LDADD = ${ALLLIBS}
     
    135146atomsCalculationTest_LDADD = ${ALLLIBS}
    136147
     148AtomDescriptorTest_SOURCES = UnitTestMain.cpp AtomDescriptorTest.cpp AtomDescriptorTest.hpp
     149AtomDescriptorTest_LDADD = ${ALLLIBS}
     150
    137151BondGraphUnitTest_SOURCES = UnitTestMain.cpp bondgraphunittest.cpp bondgraphunittest.hpp
    138152BondGraphUnitTest_LDADD = ${ALLLIBS}
    139153
     154CacheableTest_SOURCES = UnitTestMain.cpp CacheableTest.cpp CacheableTest.hpp
     155CacheableTest_LDADD = ${ALLLIBS}
     156
    140157CountBondsUnitTest_SOURCES = UnitTestMain.cpp CountBondsUnitTest.cpp CountBondsUnitTest.hpp
    141158CountBondsUnitTest_LDADD = ${ALLLIBS}
     
    168185LogUnitTest_LDADD = ${ALLLIBS}
    169186
    170 MemoryAllocatorUnitTest_SOURCES = UnitTestMain.cpp memoryallocatorunittest.cpp memoryallocatorunittest.hpp
     187manipulateAtomsTest_SOURCES = UnitTestMain.cpp manipulateAtomsTest.cpp manipulateAtomsTest.hpp
     188manipulateAtomsTest_LDADD = ${ALLLIBS}
     189
     190MemoryAllocatorUnitTest_SOURCES = UnitTestMain.cpp ../memoryallocator.hpp ../memoryallocator.cpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp memoryallocatorunittest.cpp memoryallocatorunittest.hpp
    171191MemoryAllocatorUnitTest_LDADD = ${ALLLIBS}
    172192
    173 MemoryUsageObserverUnitTest_SOURCES = UnitTestMain.cpp memoryusageobserverunittest.cpp memoryusageobserverunittest.hpp
     193MemoryUsageObserverUnitTest_SOURCES = UnitTestMain.cpp ../memoryallocator.hpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp memoryusageobserverunittest.cpp memoryusageobserverunittest.hpp
    174194MemoryUsageObserverUnitTest_LDADD = ${ALLLIBS}
    175195
     
    177197MoleculeDescriptorTest_LDADD = ${ALLLIBS}
    178198
     199ObserverTest_SOURCES = UnitTestMain.cpp ObserverTest.cpp ObserverTest.hpp
     200ObserverTest_LDADD = ${ALLLIBS}
     201
     202ParserUnitTest_SOURCES = UnitTestMain.cpp ParserUnitTest.cpp ParserUnitTest.hpp
     203ParserUnitTest_LDADD = ${ALLLIBS}
     204
     205periodentafelTest_SOURCES = UnitTestMain.cpp periodentafelTest.cpp periodentafelTest.hpp
     206periodentafelTest_LDADD = ${ALLLIBS}
     207
    179208PlaneUnittest_SOURCES = UnitTestMain.cpp PlaneUnittest.cpp PlaneUnittest.hpp
    180209PlaneUnittest_LDADD = ${ALLLIBS}
     
    195224Tesselation_InOutsideUnitTest_LDADD = ${ALLLIBS}
    196225
     226TestRunner_SOURCES = TestRunnerMain.cpp ../memoryallocator.hpp ../memoryallocator.cpp ../memoryusageobserver.cpp ../memoryusageobserver.hpp $(TESTSOURCES) $(TESTHEADERS)
     227TestRunner_LDADD = ${ALLLIBS}
     228
    197229VectorUnitTest_SOURCES = UnitTestMain.cpp vectorunittest.cpp vectorunittest.hpp
    198230VectorUnitTest_LDADD = ${ALLLIBS}
    199231
    200 ActionSequenceTest_SOURCES = UnitTestMain.cpp ../../../TestRunnerClient.hpp ActionSequenceTest.cpp ActionSequenceTest.hpp
    201 ActionSequenceTest_LDADD = ${ALLLIBS}
    202 
    203 ObserverTest_SOURCES = UnitTestMain.cpp ObserverTest.cpp ObserverTest.hpp
    204 ObserverTest_LDADD = ${ALLLIBS}
    205 
    206 CacheableTest_SOURCES = UnitTestMain.cpp CacheableTest.cpp CacheableTest.hpp
    207 CacheableTest_LDADD = ${ALLLIBS}
    208 
    209 AtomDescriptorTest_SOURCES = UnitTestMain.cpp AtomDescriptorTest.cpp AtomDescriptorTest.hpp
    210 AtomDescriptorTest_LDADD = ${ALLLIBS}
    211 
    212 manipulateAtomsTest_SOURCES = UnitTestMain.cpp manipulateAtomsTest.cpp manipulateAtomsTest.hpp
    213 manipulateAtomsTest_LDADD = ${ALLLIBS}
    214 
    215 TestRunner_SOURCES = TestRunnerMain.cpp $(TESTSOURCES) $(TESTHEADERS)
    216 TestRunner_LDADD = ${ALLLIBS}
    217 
    218232#AUTOMAKE_OPTIONS = parallel-tests
    219 
  • src/unittests/ObserverTest.cpp

    r0c7ed8 r1dc9ec  
    1111#include <cppunit/extensions/TestFactoryRegistry.h>
    1212#include <cppunit/ui/text/TestRunner.h>
     13#include <set>
    1314
    1415#include "Patterns/Observer.hpp"
     16#include "Patterns/ObservedIterator.hpp"
    1517#include "Helpers/Assert.hpp"
    1618
     
    3133public:
    3234  UpdateCountObserver() :
     35    Observer("UpdateCountObserver"),
    3336    updates(0)
    3437  {};
     
    4346class SimpleObservable : public Observable {
    4447public:
     48  SimpleObservable() :
     49    Observable("SimpleObservable")
     50  {}
     51
    4552  void changeMethod() {
    4653    OBSERVE;
     
    5259class CallObservable : public Observable {
    5360public:
     61  CallObservable() :
     62    Observable("CallObservable")
     63  {}
     64
    5465  void changeMethod1() {
    5566    OBSERVE;
     
    6879class BlockObservable : public Observable {
    6980public:
     81  BlockObservable() :
     82    Observable("BlockObservable")
     83  {}
     84
    7085  void changeMethod1(){
    7186    OBSERVE;
     
    102117class SuperObservable : public Observable {
    103118public:
    104   SuperObservable(){
     119  SuperObservable():
     120    Observable("SuperObservable")
     121  {
    105122    subObservable = new SimpleObservable();
    106123    subObservable->signOn(this);
     
    121138public:
    122139  NotificationObservable() :
    123       notification1(new Notification(this)),
    124       notification2(new Notification(this))
     140    Observable("NotificationObservable"),
     141    notification1(new Notification(this)),
     142    notification2(new Notification(this))
    125143  {}
    126144
     
    147165public:
    148166  NotificationObserver(Notification_ptr notification) :
     167    Observer("NotificationObserver"),
    149168    requestedNotification(notification),
    150169    wasNotified(false)
     
    162181  bool wasNotified;
    163182};
     183
     184class ObservableCollection : public Observable {
     185public:
     186  typedef std::set<SimpleObservable*> set;
     187  typedef ObservedIterator<set> iterator;
     188  typedef set::const_iterator const_iterator;
     189
     190  ObservableCollection(int _num) :
     191    Observable("ObservableCollection"),
     192    num(_num)
     193  {
     194    for(int i=0; i<num; ++i){
     195      SimpleObservable *content = new SimpleObservable();
     196      content->signOn(this);
     197      theSet.insert(content);
     198    }
     199  }
     200
     201  ~ObservableCollection(){
     202    set::iterator iter;
     203    for(iter=theSet.begin(); iter!=theSet.end(); ++iter ){
     204      delete (*iter);
     205    }
     206  }
     207
     208  iterator begin(){
     209    return iterator(theSet.begin(),this);
     210  }
     211
     212  iterator end(){
     213    return iterator(theSet.end(),this);
     214  }
     215
     216  const int num;
     217
     218private:
     219  set theSet;
     220};
     221
    164222
    165223/******************* actuall tests ***************/
     
    173231  blockObservable = new BlockObservable();
    174232  notificationObservable = new NotificationObservable();
     233  collection = new ObservableCollection(5);
    175234
    176235  observer1 = new UpdateCountObserver();
     
    181240  notificationObserver1 = new NotificationObserver(notificationObservable->notification1);
    182241  notificationObserver2 = new NotificationObserver(notificationObservable->notification2);
    183 
    184242}
    185243
     
    191249  delete blockObservable;
    192250  delete notificationObservable;
     251  delete collection;
    193252
    194253  delete observer1;
     
    277336  blockObservable->changeMethod2();
    278337  blockObservable->noChangeMethod();
     338}
     339
     340void ObserverTest::iteratorTest(){
     341  int i = 0;
     342  // test the general iterator methods
     343  for(ObservableCollection::iterator iter=collection->begin(); iter!=collection->end();++iter){
     344    CPPUNIT_ASSERT(i< collection->num);
     345    i++;
     346  }
     347
     348  i=0;
     349  for(ObservableCollection::const_iterator iter=collection->begin(); iter!=collection->end();++iter){
     350    CPPUNIT_ASSERT(i<collection->num);
     351    i++;
     352  }
     353
     354  collection->signOn(observer1);
     355  {
     356    // we construct this out of the loop, so the iterator dies at the end of
     357    // the scope and not the end of the loop (allows more testing)
     358    ObservableCollection::iterator iter;
     359    for(iter=collection->begin(); iter!=collection->end(); ++iter){
     360      (*iter)->changeMethod();
     361    }
     362    // At this point no change should have been propagated
     363    CPPUNIT_ASSERT_EQUAL( 0, observer1->updates);
     364  }
     365  // After the Iterator has died the propagation should take place
     366  CPPUNIT_ASSERT_EQUAL( 1, observer1->updates);
     367
     368  // when using a const_iterator no changes should be propagated
     369  for(ObservableCollection::const_iterator iter = collection->begin(); iter!=collection->end();++iter);
     370  CPPUNIT_ASSERT_EQUAL( 1, observer1->updates);
     371  collection->signOff(observer1);
    279372}
    280373
  • src/unittests/ObserverTest.hpp

    r0c7ed8 r1dc9ec  
    1717class CallObservable;
    1818class SuperObservable;
     19class ObservableCollection;
    1920class BlockObservable;
    2021class NotificationObservable;
    21 
    2222
    2323class ObserverTest :  public CppUnit::TestFixture
     
    2929  CPPUNIT_TEST ( doesNotifyTest );
    3030  CPPUNIT_TEST ( doesReportTest );
     31  CPPUNIT_TEST ( iteratorTest );
    3132  CPPUNIT_TEST ( CircleDetectionTest );
    3233  CPPUNIT_TEST_SUITE_END();
     
    4142  void doesNotifyTest();
    4243  void doesReportTest();
     44  void iteratorTest();
    4345  void CircleDetectionTest();
    4446
     
    5860  SuperObservable *superObservable;
    5961  NotificationObservable *notificationObservable;
     62  ObservableCollection *collection;
     63
    6064};
    6165
  • src/unittests/SingletonTest.cpp

    r0c7ed8 r1dc9ec  
    5252    count1++;
    5353  }
    54   // explicit copy constructor to catch if thsi is ever called
     54  // explicit copy constructor to catch if this is ever called
    5555  SingletonStub2(const SingletonStub2&){
    5656    CPPUNIT_FAIL    ( "Copy constructor of Singleton called" );
  • src/unittests/TestRunnerMain.cpp

    r0c7ed8 r1dc9ec  
    66 */
    77
     8// include config.h
     9#ifdef HAVE_CONFIG_H
     10#include <config.h>
     11#endif
     12
     13#ifdef HAVE_ECUT
    814// give the main function its correct name
    915#define CPPUNIT_MAIN main
    10 
    1116// include the TestRunnerClient file containing the main class
    1217#include "../../../TestRunnerClient.h"
    1318#include "../../../TestRunnerClient.cpp"
     19#else
     20#include "UnitTestMain.cpp"
     21#endif
     22
  • src/unittests/analysisbondsunittest.cpp

    r0c7ed8 r1dc9ec  
    2525#include "molecule.hpp"
    2626#include "periodentafel.hpp"
     27#include "World.hpp"
    2728
    2829#ifdef HAVE_TESTRUNNER
     
    4041  atom *Walker = NULL;
    4142
    42   // init private all pointers to zero
    43   TestMolecule = NULL;
    44   hydrogen = NULL;
    45   tafel = NULL;
    46 
    47   // construct element
    48   hydrogen = new element;
    49   hydrogen->Z = 1;
    50   hydrogen->Valence = 1;
    51   hydrogen->NoValenceOrbitals = 1;
    52   strcpy(hydrogen->name, "hydrogen");
    53   strcpy(hydrogen->symbol, "H");
    54   carbon = new element;
    55   carbon->Z = 2;
    56   carbon->Valence = 4;
    57   carbon->NoValenceOrbitals = 4;
    58   strcpy(carbon->name, "carbon");
    59   strcpy(carbon->symbol, "C");
    60 
    61 
    62   // construct periodentafel
    63   tafel = World::getInstance().getPeriode();
    64   tafel->AddElement(hydrogen);
    65   tafel->AddElement(carbon);
     43  // get elements
     44  hydrogen = World::getInstance().getPeriode()->FindElement(1);
     45  carbon = World::getInstance().getPeriode()->FindElement(6);
     46  CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen");
     47  CPPUNIT_ASSERT(carbon != NULL && "could not find element carbon");
    6648
    6749  // construct molecule (tetraeder of hydrogens)
    6850  TestMolecule = World::getInstance().createMolecule();
     51  CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule");
    6952  Walker = World::getInstance().createAtom();
     53  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7054  Walker->type = hydrogen;
    7155  *Walker->node = Vector(1.5, 0., 1.5 );
    7256  TestMolecule->AddAtom(Walker);
    7357  Walker = World::getInstance().createAtom();
     58  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7459  Walker->type = hydrogen;
    7560  *Walker->node = Vector(0., 1.5, 1.5 );
    7661  TestMolecule->AddAtom(Walker);
    7762  Walker = World::getInstance().createAtom();
     63  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7864  Walker->type = hydrogen;
    7965  *Walker->node = Vector(1.5, 1.5, 0. );
    8066  TestMolecule->AddAtom(Walker);
    8167  Walker = World::getInstance().createAtom();
     68  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    8269  Walker->type = hydrogen;
    8370  *Walker->node = Vector(0., 0., 0. );
    8471  TestMolecule->AddAtom(Walker);
    8572  Walker = World::getInstance().createAtom();
     73  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    8674  Walker->type = carbon;
    8775  *Walker->node = Vector(0.5, 0.5, 0.5 );
     
    8977
    9078  // check that TestMolecule was correctly constructed
    91   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 5 );
     79  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 5 );
    9280
    9381  // create a small file with table
    9482  filename = new string("test.dat");
     83  CPPUNIT_ASSERT(filename != NULL && "could not create string");
    9584  ofstream test(filename->c_str());
    96   test << ".\tH\tC\n";
    97   test << "H\t1.\t1.2\n";
    98   test << "C\t1.2\t1.5\n";
     85  test << ".\tH\tHe\tLi\tBe\tB\tC\n";
     86  test << "H\t1.\t1.\t1.\t1.\t1.\t1.2\n";
     87  test << "He\t1.\t1.\t1.\t1.\t1.\t1.\n";
     88  test << "Li\t1.\t1.\t1.\t1.\t1.\t1.\n";
     89  test << "Be\t1.\t1.\t1.\t1.\t1.\t1.\n";
     90  test << "B\t1.\t1.\t1.\t1.\t1.\t1.\n";
     91  test << "C\t1.2\t1.\t1.\t1.\t1.\t1.5\n";
    9992  test.close();
    10093  BG = new BondGraph(true);
     94  CPPUNIT_ASSERT(BG != NULL && "could not create BondGraph");
    10195
    10296  CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) );
    10397  CPPUNIT_ASSERT_EQUAL( 1., BG->GetBondLength(0,0) );
    104   CPPUNIT_ASSERT_EQUAL( 1.2, BG->GetBondLength(0,1) );
    105   CPPUNIT_ASSERT_EQUAL( 1.5, BG->GetBondLength(1,1) );
     98  CPPUNIT_ASSERT_EQUAL( 1.2, BG->GetBondLength(0,5) );
     99  CPPUNIT_ASSERT_EQUAL( 1.5, BG->GetBondLength(5,5) );
    106100
    107101  BG->ConstructBondGraph(TestMolecule);
  • src/unittests/analysisbondsunittest.hpp

    r0c7ed8 r1dc9ec  
    3434
    3535      molecule *TestMolecule;
    36       element *hydrogen;
    37       element *carbon;
    38       periodentafel *tafel;
     36      const element *hydrogen;
     37      const element *carbon;
    3938
    4039      BondGraph *BG;
  • src/unittests/bondgraphunittest.cpp

    r0c7ed8 r1dc9ec  
    1515#include <stdio.h>
    1616#include <cstring>
     17
     18#include "Helpers/Assert.hpp"
    1719
    1820#include "World.hpp"
     
    4143  atom *Walker = NULL;
    4244
    43   // init private all pointers to zero
    44   TestMolecule = NULL;
    45   hydrogen = NULL;
    46   tafel = NULL;
    47 
    4845  // construct element
    49   hydrogen = new element;
    50   hydrogen->Z = 1;
    51   hydrogen->CovalentRadius = 0.23;
    52   hydrogen->VanDerWaalsRadius = 1.09;
    53   strcpy(hydrogen->name, "hydrogen");
    54   strcpy(hydrogen->symbol, "H");
    55   carbon = new element;
    56   carbon->Z = 2;
    57   carbon->CovalentRadius = 0.68;
    58   carbon->VanDerWaalsRadius = 1.7;
    59   strcpy(carbon->name, "carbon");
    60   strcpy(carbon->symbol, "C");
    61 
    62 
    63   // construct periodentafel
    64   tafel = World::getInstance().getPeriode();
    65   tafel->AddElement(hydrogen);
    66   tafel->AddElement(carbon);
     46  hydrogen = World::getInstance().getPeriode()->FindElement(1);
     47  carbon = World::getInstance().getPeriode()->FindElement(6);
     48  CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen");
     49  CPPUNIT_ASSERT(carbon != NULL && "could not find element carbon");
    6750
    6851  // construct molecule (tetraeder of hydrogens)
    6952  TestMolecule = World::getInstance().createMolecule();
     53  CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule");
    7054  Walker = World::getInstance().createAtom();
     55  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7156  Walker->type = carbon;
    7257  *Walker->node = Vector(1., 0., 1. );
     
    7459
    7560  Walker = World::getInstance().createAtom();
     61  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7662  Walker->type = carbon;
    7763  *Walker->node = Vector(0., 1., 1. );
     
    7965
    8066  Walker = World::getInstance().createAtom();
     67  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    8168  Walker->type = carbon;
    8269  *Walker->node = Vector(1., 1., 0. );
     
    8471
    8572  Walker = World::getInstance().createAtom();
     73  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    8674  Walker->type = carbon;
    8775  *Walker->node = Vector(0., 0., 0. );
     
    8977
    9078  // check that TestMolecule was correctly constructed
    91   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
     79  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 );
    9280
    9381  // create a small file with table
    9482  dummyname = new string("dummy.dat");
     83  CPPUNIT_ASSERT(dummyname != NULL && "could not create string");
    9584  filename = new string("test.dat");
     85  CPPUNIT_ASSERT(filename != NULL && "could not create string");
    9686  ofstream test(filename->c_str());
    97   test << ".\tH\tC\n";
    98   test << "H\t1.\t1.2\n";
    99   test << "C\t1.2\t1.5\n";
     87  test << ".\tH\tHe\tLi\tBe\tB\tC\n";
     88  test << "H\t1.\t1.\t1.\t1.\t1.\t1.2\n";
     89  test << "He\t1.\t1.\t1.\t1.\t1.\t1.\n";
     90  test << "Li\t1.\t1.\t1.\t1.\t1.\t1.\n";
     91  test << "Be\t1.\t1.\t1.\t1.\t1.\t1.\n";
     92  test << "B\t1.\t1.\t1.\t1.\t1.\t1.\n";
     93  test << "C\t1.2\t1.\t1.\t1.\t1.\t1.5\n";
    10094  test.close();
    10195  BG = new BondGraph(true);
     96  CPPUNIT_ASSERT(BG != NULL && "could not create BondGraph");
    10297};
    10398
     
    116111  // are all cleaned when the world is destroyed
    117112  World::purgeInstance();
    118   MemoryUsageObserver::purgeInstance();
    119113  logger::purgeInstance();
     114};
     115
     116/** Tests whether setup worked.
     117 */
     118void BondGraphTest::SetupTest()
     119{
     120  CPPUNIT_ASSERT_EQUAL (false, TestMolecule->empty());
     121  CPPUNIT_ASSERT_EQUAL ((size_t)4, TestMolecule->size());
    120122};
    121123
     
    126128  CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) );
    127129  CPPUNIT_ASSERT_EQUAL( 1., BG->GetBondLength(0,0) );
    128   CPPUNIT_ASSERT_EQUAL( 1.2, BG->GetBondLength(0,1) );
    129   CPPUNIT_ASSERT_EQUAL( 1.5, BG->GetBondLength(1,1) );
     130  CPPUNIT_ASSERT_EQUAL( 1.2, BG->GetBondLength(0,5) );
     131  CPPUNIT_ASSERT_EQUAL( 1.5, BG->GetBondLength(5,5) );
    130132};
    131133
     
    134136void BondGraphTest::ConstructGraphFromTableTest()
    135137{
    136   atom *Walker = TestMolecule->start->next;
    137   atom *Runner = TestMolecule->end->previous;
    138   CPPUNIT_ASSERT( TestMolecule->end != Walker );
     138  molecule::iterator Walker = TestMolecule->begin();
     139  molecule::iterator Runner = TestMolecule->begin();
     140  Runner++;
    139141  CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) );
    140142  CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) );
    141   CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );
     143  CPPUNIT_ASSERT_EQUAL( true , (*Walker)->IsBondedTo((*Runner)) );
    142144};
    143145
     
    146148void BondGraphTest::ConstructGraphFromCovalentRadiiTest()
    147149{
    148   atom *Walker = TestMolecule->start->next;
    149   atom *Runner = TestMolecule->end->previous;
    150   CPPUNIT_ASSERT( TestMolecule->end != Walker );
     150
     151  //atom *Walker = TestMolecule->start->next;
     152  //atom *Runner = TestMolecule->end->previous;
     153  //CPPUNIT_ASSERT( TestMolecule->end != Walker );
    151154  CPPUNIT_ASSERT_EQUAL( false , BG->LoadBondLengthTable(*dummyname) );
    152155  CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) );
    153   CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );
     156
     157  // this cannot be assured using dynamic IDs
     158  //CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );
    154159};
    155160
  • src/unittests/bondgraphunittest.hpp

    r0c7ed8 r1dc9ec  
    2222{
    2323    CPPUNIT_TEST_SUITE( BondGraphTest) ;
     24    CPPUNIT_TEST ( SetupTest );
    2425    CPPUNIT_TEST ( LoadTableTest );
    2526    CPPUNIT_TEST ( ConstructGraphFromTableTest );
     
    3031      void setUp();
    3132      void tearDown();
     33      void SetupTest();
    3234      void LoadTableTest();
    3335      void ConstructGraphFromTableTest();
     
    3739
    3840      molecule *TestMolecule;
    39       element *hydrogen;
    40       element *carbon;
    41       periodentafel *tafel;
     41      const element *hydrogen;
     42      const element *carbon;
    4243
    4344      BondGraph *BG;
  • src/unittests/listofbondsunittest.cpp

    r0c7ed8 r1dc9ec  
    3838  atom *Walker = NULL;
    3939
    40   // init private all pointers to zero
    41   TestMolecule = NULL;
    42   hydrogen = NULL;
    43   tafel = NULL;
    44 
    4540  // construct element
    46   hydrogen = new element;
    47   hydrogen->Z = 1;
    48   strcpy(hydrogen->name, "hydrogen");
    49   strcpy(hydrogen->symbol, "H");
    50 
    51 
    52   // construct periodentafel
    53   tafel = World::getInstance().getPeriode();
    54   tafel->AddElement(hydrogen);
     41  hydrogen = World::getInstance().getPeriode()->FindElement(1);
     42  CPPUNIT_ASSERT(hydrogen != NULL && "could not find element hydrogen");
    5543
    5644  // construct molecule (tetraeder of hydrogens)
    5745  TestMolecule = World::getInstance().createMolecule();
    58   Walker = World::getInstance().createAtom();
     46  CPPUNIT_ASSERT(TestMolecule != NULL && "could not create molecule");
     47  Walker = World::getInstance().createAtom();
     48  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    5949  Walker->type = hydrogen;
    6050  *Walker->node = Vector(1., 0., 1. );
    6151  TestMolecule->AddAtom(Walker);
    6252  Walker = World::getInstance().createAtom();
     53  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    6354  Walker->type = hydrogen;
    6455  *Walker->node = Vector(0., 1., 1. );
    6556  TestMolecule->AddAtom(Walker);
    6657  Walker = World::getInstance().createAtom();
     58  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    6759  Walker->type = hydrogen;
    6860  *Walker->node = Vector(1., 1., 0. );
    6961  TestMolecule->AddAtom(Walker);
    7062  Walker = World::getInstance().createAtom();
     63  CPPUNIT_ASSERT(Walker != NULL && "could not create atom");
    7164  Walker->type = hydrogen;
    7265  *Walker->node = Vector(0., 0., 0. );
     
    7467
    7568  // check that TestMolecule was correctly constructed
    76   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
    77 
     69  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 );
    7870};
    7971
     
    8678  // are all cleaned when the world is destroyed
    8779  World::purgeInstance();
    88   MemoryUsageObserver::purgeInstance();
    8980  logger::purgeInstance();
    9081};
    9182
     83/** Tests whether setup worked correctly.
     84 *
     85 */
     86void ListOfBondsTest::SetupTest()
     87{
     88  CPPUNIT_ASSERT_EQUAL( false, TestMolecule->empty() );
     89  CPPUNIT_ASSERT_EQUAL( (size_t)4, TestMolecule->size() );
     90};
     91
    9292/** Unit Test of molecule::AddBond()
    9393 *
     
    9696{
    9797  bond *Binder = NULL;
    98   atom *atom1 = TestMolecule->start->next;
    99   atom *atom2 = atom1->next;
    100   CPPUNIT_ASSERT( atom1 != NULL );
    101   CPPUNIT_ASSERT( atom2 != NULL );
    102 
    103   // add bond
    104   Binder = TestMolecule->AddBond(atom1, atom2, 1);
    105   CPPUNIT_ASSERT( Binder != NULL );
    106   bond *TestBond = TestMolecule->first->next;
    107   CPPUNIT_ASSERT_EQUAL ( TestBond, Binder );
     98  molecule::iterator iter = TestMolecule->begin();
     99  atom *atom1 = *iter;
     100  iter++;
     101  atom *atom2 = *iter;
     102  CPPUNIT_ASSERT( atom1 != NULL );
     103  CPPUNIT_ASSERT( atom2 != NULL );
     104
     105  // add bond
     106  Binder = TestMolecule->AddBond(atom1, atom2, 1);
     107  CPPUNIT_ASSERT( Binder != NULL );
     108  CPPUNIT_ASSERT_EQUAL ( true, TestMolecule->hasBondStructure() );
    108109
    109110  // check that bond contains the two atoms
     
    124125{
    125126  bond *Binder = NULL;
    126   atom *atom1 = TestMolecule->start->next;
    127   atom *atom2 = atom1->next;
     127  molecule::iterator iter = TestMolecule->begin();
     128  atom *atom1 = *iter;
     129  iter++;
     130  atom *atom2 = *iter;
    128131  CPPUNIT_ASSERT( atom1 != NULL );
    129132  CPPUNIT_ASSERT( atom2 != NULL );
     
    141144
    142145  // check if removed from molecule
    143   CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last );
     146  CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() );
    144147};
    145148
     
    150153{
    151154  bond *Binder = NULL;
    152   atom *atom1 = TestMolecule->start->next;
    153   atom *atom2 = atom1->next;
    154   atom *atom3 = atom2->next;
     155  molecule::iterator iter = TestMolecule->begin();
     156  atom *atom1 = *iter;
     157  iter++;
     158  atom *atom2 = *iter;
     159  iter++;
     160  atom *atom3 = *iter;
    155161  CPPUNIT_ASSERT( atom1 != NULL );
    156162  CPPUNIT_ASSERT( atom2 != NULL );
     
    179185
    180186  // check if removed from molecule
    181   CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, Binder );
    182   CPPUNIT_ASSERT_EQUAL( Binder->next, TestMolecule->last );
     187  CPPUNIT_ASSERT_EQUAL( true, TestMolecule->hasBondStructure() );
     188  CPPUNIT_ASSERT_EQUAL( (unsigned int)1, TestMolecule->CountBonds() );
    183189};
    184190
     
    189195{
    190196  bond *Binder = NULL;
    191   atom *atom1 = TestMolecule->start->next;
    192   atom *atom2 = atom1->next;
     197  molecule::iterator iter = TestMolecule->begin();
     198  atom *atom1 = *iter;
     199  iter++;
     200  atom *atom2 = *iter;
    193201  CPPUNIT_ASSERT( atom1 != NULL );
    194202  CPPUNIT_ASSERT( atom2 != NULL );
     
    206214
    207215  // check if removed from molecule
    208   CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last );
     216  CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() );
    209217};
    210218
     
    215223{
    216224  bond *Binder = NULL;
    217   atom *atom1 = TestMolecule->start->next;
    218   atom *atom2 = atom1->next;
     225  molecule::iterator iter = TestMolecule->begin();
     226  atom *atom1 = *iter;
     227  iter++;
     228  atom *atom2 = *iter;
    219229  CPPUNIT_ASSERT( atom1 != NULL );
    220230  CPPUNIT_ASSERT( atom2 != NULL );
     
    231241
    232242  // check if removed from molecule
    233   CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last );
     243  CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() );
    234244};
    235245
     
    239249void ListOfBondsTest::DeleteAtomTest()
    240250{
    241   bond *Binder = NULL;
    242   atom *atom1 = TestMolecule->start->next;
    243   atom *atom2 = atom1->next;
    244   CPPUNIT_ASSERT( atom1 != NULL );
    245   CPPUNIT_ASSERT( atom2 != NULL );
    246 
    247   // add bond
    248   Binder = TestMolecule->AddBond(atom1, atom2, 1);
    249   CPPUNIT_ASSERT( Binder != NULL );
     251  atom *atom1 = NULL;
     252  atom *atom2 = NULL;
     253  bond *Binder = NULL;
     254  {
     255    molecule::iterator iter = TestMolecule->begin();
     256    atom1 = *iter;
     257    iter++;
     258    atom2 = *iter;
     259  }
     260  CPPUNIT_ASSERT( atom1 != NULL );
     261  CPPUNIT_ASSERT( atom2 != NULL );
     262
     263  // add bond
     264  Binder = TestMolecule->AddBond(atom1, atom2, 1);
     265  CPPUNIT_ASSERT( Binder != NULL );
     266
     267  CPPUNIT_ASSERT_EQUAL( (size_t) 1, atom1->ListOfBonds.size() );
     268  CPPUNIT_ASSERT_EQUAL( (size_t) 1, atom2->ListOfBonds.size() );
     269
     270  CPPUNIT_ASSERT_EQUAL( true, TestMolecule->hasBondStructure() );
    250271
    251272  // remove atom2
     
    256277
    257278  // check if removed from molecule
    258   CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last );
    259 };
     279  CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() );
     280};
  • src/unittests/listofbondsunittest.hpp

    r0c7ed8 r1dc9ec  
    2020{
    2121    CPPUNIT_TEST_SUITE( ListOfBondsTest) ;
     22    CPPUNIT_TEST ( SetupTest );
    2223    CPPUNIT_TEST ( AddingBondTest );
    2324    CPPUNIT_TEST ( RemovingBondTest );
     
    3132      void setUp();
    3233      void tearDown();
     34      void SetupTest();
    3335      void AddingBondTest();
    3436      void RemovingBondTest();
     
    4143
    4244      molecule *TestMolecule;
    43       element *hydrogen;
    44       periodentafel *tafel;
     45      const element *hydrogen;
    4546};
    4647
  • src/unittests/manipulateAtomsTest.cpp

    r0c7ed8 r1dc9ec  
    5555public:
    5656  countObserver() :
     57    Observer("countObserver"),
    5758    count(0)
    5859    {}
  • src/unittests/memoryallocatorunittest.cpp

    r0c7ed8 r1dc9ec  
    1212#include "memoryallocator.hpp"
    1313#include "memoryallocatorunittest.hpp"
     14#include "memoryusageobserver.hpp"
    1415#include "helpers.hpp"
    1516#include "log.hpp"
  • src/unittests/stackclassunittest.cpp

    r0c7ed8 r1dc9ec  
    3737  Stack->ClearStack();
    3838  delete(Stack);
    39   MemoryUsageObserver::purgeInstance();
    4039  logger::purgeInstance();
    4140};
  • src/unittests/tesselation_boundarytriangleunittest.cpp

    r0c7ed8 r1dc9ec  
    7070    delete tesselpoints[i];
    7171  }
    72   MemoryUsageObserver::purgeInstance();
    7372  logger::purgeInstance();
    7473  errorLogger::purgeInstance();
  • src/unittests/tesselation_insideoutsideunittest.cpp

    r0c7ed8 r1dc9ec  
    134134  }
    135135  Corners.clear();
    136   MemoryUsageObserver::purgeInstance();
    137136  logger::purgeInstance();
    138137  errorLogger::purgeInstance();
  • src/unittests/tesselationunittest.cpp

    r0c7ed8 r1dc9ec  
    106106  }
    107107  Corners.clear();
    108   MemoryUsageObserver::purgeInstance();
    109108  logger::purgeInstance();
    110109  errorLogger::purgeInstance();
  • src/unittests/vectorunittest.cpp

    r0c7ed8 r1dc9ec  
    4949void VectorTest::tearDown()
    5050{
    51   MemoryUsageObserver::purgeInstance();
    5251  logger::purgeInstance();
    5352  errorLogger::purgeInstance();
  • src/vector.cpp

    r0c7ed8 r1dc9ec  
    55 */
    66
     7#include "Helpers/MemDebug.hpp"
    78
    89#include "vector.hpp"
     
    520521  // truncate to [0,1] for each axis
    521522  for (int i=0;i<NDIM;i++) {
    522     at(i) += 0.5;  // set to center of box
     523    //at(i) += 0.5;  // set to center of box
    523524    while (at(i) >= 1.)
    524525      at(i) -= 1.;
  • src/vector_ops.cpp

    r0c7ed8 r1dc9ec  
    55 *      Author: crueger
    66 */
     7
     8#include "Helpers/MemDebug.hpp"
    79
    810#include "vector.hpp"
  • src/verbose.cpp

    r0c7ed8 r1dc9ec  
    11using namespace std;
     2
     3#include "Helpers/MemDebug.hpp"
    24
    35#include "info.hpp"
  • tests/Makefile.am

    r0c7ed8 r1dc9ec  
    1 AUTOM4TE = autom4te
    2 EXTRA_DIST = testsuite.at $(TESTSUITE) atlocal.in regression
    3 TESTSUITE = $(srcdir)/testsuite
     1SUBDIRS = regression Tesselations
    42
    5 SUBDIRS = Tesselations
    6 
    7 check-local: atconfig atlocal package.m4 $(TESTSUITE)
    8                 $(SHELL) '$(TESTSUITE)' $(TESTSUITEFLAGS)
    9 
    10 installcheck-local: atconfig atlocal $(TESTSUITE)
    11                 $(SHELL) '$(TESTSUITE)' AUTOTEST_PATH='$(bindir)' \
    12                 $(TESTSUITEFLAGS)
    13      
    14 clean-local:
    15                 test ! -f '$(TESTSUITE)' || \
    16                 $(SHELL) '$(TESTSUITE)' --clean
    17 
    18 AUTOTEST = $(AUTOM4TE) --language=autotest
    19 $(TESTSUITE): $(srcdir)/testsuite.at
    20                 $(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at
    21                 mv $@.tmp $@
    22 
    23 # The `:;' works around a Bash 3.2 bug when the output is not writeable.
    24 $(srcdir)/package.m4: $(top_srcdir)/configure.ac
    25                         :;{ \
    26                                         echo '# Signature of the current package.' && \
    27                                         echo 'm4_define([AT_PACKAGE_NAME],      [@PACKAGE_NAME@])' && \
    28                                         echo 'm4_define([AT_PACKAGE_TARNAME],   [@PACKAGE_TARNAME@])' && \
    29                                         echo 'm4_define([AT_PACKAGE_VERSION],   [@PACKAGE_VERSION@])' && \
    30                                         echo 'm4_define([AT_PACKAGE_STRING],    [@PACKAGE_STRING@])' && \
    31                                         echo 'm4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])'; \
    32                                 } >'$(srcdir)/package.m4'
  • tests/Tesselations/defs.in

    r0c7ed8 r1dc9ec  
    3030        CLEANUP="$CLEANUP; rm -rf $testdir"
    3131        cp -r @srcdir@/$testdir/* $testdir/
    32         cd $testdir
    3332        CLEANUP="rm -f stderr stdout diffstderr diffstdout; cd ..; $CLEANUP"
    3433        CLEANUP="rm -f *.conf*; rm -f NonConvexEnvelope*; rm -f ${testdir}.xyz; rm -f ${testdir}.dbond; $CLEANUP"
     
    5251        FILENAME="NonConvexEnvelope"
    5352        exitcode=0
    54         cd $RADIUS
     53        cd $testdir/$RADIUS
    5554        #echo "Current dir is `pwd`, calling $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -N $RADIUS $FILENAME."
    5655        if [ -e $mol.dbond ]; then
    57                 $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -A $mol.dbond -N $RADIUS $FILENAME 2>stderr >stdout || exitcode=$?
     56                $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -A $mol.dbond -N 0 --sphere-radius $RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$?
    5857        else
    59                 $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -N $RADIUS $FILENAME 2>stderr >stdout || exitcode=$?
     58                $MOLECUILDER $mol.conf -e $exec_prefix -p ../$mol.xyz -N 0 --sphere-radius $RADIUS --nonconvex-file $FILENAME 2>stderr >stdout || exitcode=$?
    6059        fi
    6160        #echo "Molecuilder done with exitcode $exitcode."
    6261        #cat stderr
    6362        #cat stdout
    64         diff ${FILENAME}.dat ../@srcdir@/$mol/$2/${FILENAME}-$mol.dat 2>diffstderr >diffstdout || exitcode=$?
     63        grep -E "^[0-9]* [0-9]* [0-9]*$" ../../../../../molecuilder/tests/Tesselations/$mol/$2/${FILENAME}-$mol.dat | sort -n >reference-triangles.dat
     64        grep -E "^[0-9]* [0-9]* [0-9]*$" ${FILENAME}.dat | sort -n >new-triangles.dat
     65        diff reference-triangles.dat new-triangles.dat 2>diffstderr >diffstdout || exitcode=$?
    6566        #echo "Diff done with exitcode $exitcode."
    6667        #cat diffstderr
    6768        #cat diffstdout
    68         cd ..
     69        cd ../..
    6970        test $exitcode = $expected_exitcode || exit 1
    7071}
  • tests/regression/Tesselation/1/post/NonConvexEnvelope.r3d

    r0c7ed8 r1dc9ec  
    33# All atoms as spheres
    442
    5   1.37419 -0.26503 -4.44089e-16         0.1     1. 1. 1.
     5  1.24926 -0.870237 -0.89       0.1     1. 1. 1.
    662
    7   0.12489 0.61837 -4.44089e-16  0.1     1. 1. 1.
     7  1.24926 -0.870237 0.89        0.1     1. 1. 1.
    882
    9   -1.12431 -0.26503 -4.44089e-16        0.1     1. 1. 1.
     9  2.13922 0.388414 0    0.1     1. 1. 1.
    10102
    11   1.37419 -0.89433 -0.89        0.1     1. 1. 1.
     11  -3.63639e-05 1.27176 -0.89    0.1     1. 1. 1.
    12122
    13   1.37419 -0.89433 0.89         0.1     1. 1. 1.
     13  -3.63639e-05 1.27176 0.89     0.1     1. 1. 1.
    14142
    15   2.26414 0.364321 -4.44089e-16         0.1     1. 1. 1.
     15  -2.13919 0.388414 0   0.1     1. 1. 1.
    16162
    17   0.12489 1.24767 -0.89         0.1     1. 1. 1.
     17  -1.24924 -0.870237 -0.89      0.1     1. 1. 1.
    18182
    19   0.12489 1.24767 0.89  0.1     1. 1. 1.
     19  -1.24924 -0.870237 0.89       0.1     1. 1. 1.
    20202
    21   -2.01426 0.364321 -4.44089e-16        0.1     1. 1. 1.
     21  1.24926 -0.240937 0   0.1     1. 1. 1.
    22222
    23   -1.12431 -0.89433 -0.89       0.1     1. 1. 1.
     23  -3.63639e-05 0.642463 0       0.1     1. 1. 1.
    24242
    25   -1.12431 -0.89433 0.89        0.1     1. 1. 1.
     25  -1.24924 -0.240937 0  0.1     1. 1. 1.
    2626# All tesselation triangles
    27278
     
    3030  BACKFACE  0.3 0.3 1.0   0 0
    31311
    32   1.37419 -0.89433 -0.89        2.26414 0.364321 -4.44089e-16   0.12489 1.24767 -0.89   1. 0. 0.
     32  1.24926 -0.870237 -0.89       2.13922 0.388414 0      -3.63639e-05 1.27176 -0.89      1. 0. 0.
    33331
    34   1.37419 -0.89433 -0.89        0.12489 1.24767 -0.89   -1.12431 -0.89433 -0.89         1. 0. 0.
     34  1.24926 -0.870237 -0.89       -3.63639e-05 1.27176 -0.89      -1.24924 -0.870237 -0.89        1. 0. 0.
    35351
    36   0.12489 1.24767 -0.89         -2.01426 0.364321 -4.44089e-16  -1.12431 -0.89433 -0.89         1. 0. 0.
     36  -3.63639e-05 1.27176 -0.89    -2.13919 0.388414 0     -1.24924 -0.870237 -0.89        1. 0. 0.
    37371
    38   2.26414 0.364321 -4.44089e-16         0.12489 1.24767 -0.89   0.12489 1.24767 0.89    1. 0. 0.
     38  2.13922 0.388414 0    -3.63639e-05 1.27176 -0.89      -3.63639e-05 1.27176 0.89       1. 0. 0.
    39391
    40   0.12489 1.24767 -0.89         0.12489 1.24767 0.89    -2.01426 0.364321 -4.44089e-16  1. 0. 0.
     40  -3.63639e-05 1.27176 -0.89    -3.63639e-05 1.27176 0.89       -2.13919 0.388414 0     1. 0. 0.
    41411
    42   1.37419 -0.89433 0.89         2.26414 0.364321 -4.44089e-16   0.12489 1.24767 0.89    1. 0. 0.
     42  1.24926 -0.870237 0.89        2.13922 0.388414 0      -3.63639e-05 1.27176 0.89       1. 0. 0.
    43431
    44   1.37419 -0.89433 0.89         0.12489 1.24767 0.89    -1.12431 -0.89433 0.89  1. 0. 0.
     44  1.24926 -0.870237 0.89        -3.63639e-05 1.27176 0.89       -1.24924 -0.870237 0.89         1. 0. 0.
    45451
    46   0.12489 1.24767 0.89  -2.01426 0.364321 -4.44089e-16  -1.12431 -0.89433 0.89  1. 0. 0.
     46  -3.63639e-05 1.27176 0.89     -2.13919 0.388414 0     -1.24924 -0.870237 0.89         1. 0. 0.
    47471
    48   -2.01426 0.364321 -4.44089e-16        -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.89  1. 0. 0.
     48  -2.13919 0.388414 0   -1.24924 -0.870237 -0.89        -1.24924 -0.870237 0.89         1. 0. 0.
    49491
    50   1.37419 -0.89433 0.89         -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.89  1. 0. 0.
     50  1.24926 -0.870237 0.89        -1.24924 -0.870237 -0.89        -1.24924 -0.870237 0.89         1. 0. 0.
    51511
    52   1.37419 -0.89433 -0.89        1.37419 -0.89433 0.89   -1.12431 -0.89433 -0.89         1. 0. 0.
     52  1.24926 -0.870237 -0.89       1.24926 -0.870237 0.89  -1.24924 -0.870237 -0.89        1. 0. 0.
    53531
    54   1.37419 -0.89433 -0.89        1.37419 -0.89433 0.89   2.26414 0.364321 -4.44089e-16   1. 0. 0.
     54  1.24926 -0.870237 -0.89       1.24926 -0.870237 0.89  2.13922 0.388414 0      1. 0. 0.
    55559
    5656#  terminating special property
     
    5959  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0
    60602
    61   1.67084 -0.47478 -8.88178e-16 5       1 0 0
     61  1.54591 -0.450686 -4.44089e-16        5       1 0 0
    62629
    6363  terminating special property
  • tests/regression/Tesselation/2/post/ConvexEnvelope.r3d

    r0c7ed8 r1dc9ec  
    33# All atoms as spheres
    442
    5   1.37419 -0.26503 -4.44089e-16         0.1     1. 1. 1.
     5  1.24926 -0.870237 -0.89       0.1     1. 1. 1.
    662
    7   0.12489 0.61837 -4.44089e-16  0.1     1. 1. 1.
     7  1.24926 -0.870237 0.89        0.1     1. 1. 1.
    882
    9   -1.12431 -0.26503 -4.44089e-16        0.1     1. 1. 1.
     9  2.13922 0.388414 0    0.1     1. 1. 1.
    10102
    11   1.37419 -0.89433 -0.89        0.1     1. 1. 1.
     11  -3.63639e-05 1.27176 -0.89    0.1     1. 1. 1.
    12122
    13   1.37419 -0.89433 0.89         0.1     1. 1. 1.
     13  -3.63639e-05 1.27176 0.89     0.1     1. 1. 1.
    14142
    15   2.26414 0.364321 -4.44089e-16         0.1     1. 1. 1.
     15  -2.13919 0.388414 0   0.1     1. 1. 1.
    16162
    17   0.12489 1.24767 -0.89         0.1     1. 1. 1.
     17  -1.24924 -0.870237 -0.89      0.1     1. 1. 1.
    18182
    19   0.12489 1.24767 0.89  0.1     1. 1. 1.
     19  -1.24924 -0.870237 0.89       0.1     1. 1. 1.
    20202
    21   -2.01426 0.364321 -4.44089e-16        0.1     1. 1. 1.
     21  1.24926 -0.240937 0   0.1     1. 1. 1.
    22222
    23   -1.12431 -0.89433 -0.89       0.1     1. 1. 1.
     23  -3.63639e-05 0.642463 0       0.1     1. 1. 1.
    24242
    25   -1.12431 -0.89433 0.89        0.1     1. 1. 1.
     25  -1.24924 -0.240937 0  0.1     1. 1. 1.
    2626# All tesselation triangles
    27278
     
    3030  BACKFACE  0.3 0.3 1.0   0 0
    31311
    32   1.37419 -0.89433 -0.89        2.26414 0.364321 -4.44089e-16   0.12489 1.24767 -0.89   1. 0. 0.
     32  1.24926 -0.870237 -0.89       2.13922 0.388414 0      -3.63639e-05 1.27176 -0.89      1. 0. 0.
    33331
    34   1.37419 -0.89433 -0.89        0.12489 1.24767 -0.89   -1.12431 -0.89433 -0.89         1. 0. 0.
     34  1.24926 -0.870237 -0.89       -3.63639e-05 1.27176 -0.89      -1.24924 -0.870237 -0.89        1. 0. 0.
    35351
    36   0.12489 1.24767 -0.89         -2.01426 0.364321 -4.44089e-16  -1.12431 -0.89433 -0.89         1. 0. 0.
     36  -3.63639e-05 1.27176 -0.89    -2.13919 0.388414 0     -1.24924 -0.870237 -0.89        1. 0. 0.
    37371
    38   2.26414 0.364321 -4.44089e-16         0.12489 1.24767 -0.89   0.12489 1.24767 0.89    1. 0. 0.
     38  2.13922 0.388414 0    -3.63639e-05 1.27176 -0.89      -3.63639e-05 1.27176 0.89       1. 0. 0.
    39391
    40   0.12489 1.24767 -0.89         0.12489 1.24767 0.89    -2.01426 0.364321 -4.44089e-16  1. 0. 0.
     40  -3.63639e-05 1.27176 -0.89    -3.63639e-05 1.27176 0.89       -2.13919 0.388414 0     1. 0. 0.
    41411
    42   1.37419 -0.89433 0.89         2.26414 0.364321 -4.44089e-16   0.12489 1.24767 0.89    1. 0. 0.
     42  1.24926 -0.870237 0.89        2.13922 0.388414 0      -3.63639e-05 1.27176 0.89       1. 0. 0.
    43431
    44   1.37419 -0.89433 0.89         0.12489 1.24767 0.89    -1.12431 -0.89433 0.89  1. 0. 0.
     44  1.24926 -0.870237 0.89        -3.63639e-05 1.27176 0.89       -1.24924 -0.870237 0.89         1. 0. 0.
    45451
    46   0.12489 1.24767 0.89  -2.01426 0.364321 -4.44089e-16  -1.12431 -0.89433 0.89  1. 0. 0.
     46  -3.63639e-05 1.27176 0.89     -2.13919 0.388414 0     -1.24924 -0.870237 0.89         1. 0. 0.
    47471
    48   -2.01426 0.364321 -4.44089e-16        -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.89  1. 0. 0.
     48  -2.13919 0.388414 0   -1.24924 -0.870237 -0.89        -1.24924 -0.870237 0.89         1. 0. 0.
    49491
    50   1.37419 -0.89433 0.89         -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.89  1. 0. 0.
     50  1.24926 -0.870237 0.89        -1.24924 -0.870237 -0.89        -1.24924 -0.870237 0.89         1. 0. 0.
    51511
    52   1.37419 -0.89433 -0.89        1.37419 -0.89433 0.89   -1.12431 -0.89433 -0.89         1. 0. 0.
     52  1.24926 -0.870237 -0.89       1.24926 -0.870237 0.89  -1.24924 -0.870237 -0.89        1. 0. 0.
    53531
    54   1.37419 -0.89433 -0.89        1.37419 -0.89433 0.89   2.26414 0.364321 -4.44089e-16   1. 0. 0.
     54  1.24926 -0.870237 -0.89       1.24926 -0.870237 0.89  2.13922 0.388414 0      1. 0. 0.
    55559
    5656#  terminating special property
     
    5959  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0
    60602
    61   1.67084 -0.47478 -8.88178e-16 5       1 0 0
     61  1.54591 -0.450686 -4.44089e-16        5       1 0 0
    62629
    6363  terminating special property
  • tests/regression/Tesselation/2/post/NonConvexEnvelope.r3d

    r0c7ed8 r1dc9ec  
    33# All atoms as spheres
    442
    5   1.37419 -0.26503 -4.44089e-16         0.1     1. 1. 1.
     5  1.24926 -0.870237 -0.89       0.1     1. 1. 1.
    662
    7   0.12489 0.61837 -4.44089e-16  0.1     1. 1. 1.
     7  1.24926 -0.870237 0.89        0.1     1. 1. 1.
    882
    9   -1.12431 -0.26503 -4.44089e-16        0.1     1. 1. 1.
     9  2.13922 0.388414 0    0.1     1. 1. 1.
    10102
    11   1.37419 -0.89433 -0.89        0.1     1. 1. 1.
     11  -3.63639e-05 1.27176 -0.89    0.1     1. 1. 1.
    12122
    13   1.37419 -0.89433 0.89         0.1     1. 1. 1.
     13  -3.63639e-05 1.27176 0.89     0.1     1. 1. 1.
    14142
    15   2.26414 0.364321 -4.44089e-16         0.1     1. 1. 1.
     15  -2.13919 0.388414 0   0.1     1. 1. 1.
    16162
    17   0.12489 1.24767 -0.89         0.1     1. 1. 1.
     17  -1.24924 -0.870237 -0.89      0.1     1. 1. 1.
    18182
    19   0.12489 1.24767 0.89  0.1     1. 1. 1.
     19  -1.24924 -0.870237 0.89       0.1     1. 1. 1.
    20202
    21   -2.01426 0.364321 -4.44089e-16        0.1     1. 1. 1.
     21  1.24926 -0.240937 0   0.1     1. 1. 1.
    22222
    23   -1.12431 -0.89433 -0.89       0.1     1. 1. 1.
     23  -3.63639e-05 0.642463 0       0.1     1. 1. 1.
    24242
    25   -1.12431 -0.89433 0.89        0.1     1. 1. 1.
     25  -1.24924 -0.240937 0  0.1     1. 1. 1.
    2626# All tesselation triangles
    27278
     
    3030  BACKFACE  0.3 0.3 1.0   0 0
    31311
    32   1.37419 -0.89433 -0.89        2.26414 0.364321 -4.44089e-16   0.12489 1.24767 -0.89   1. 0. 0.
     32  1.24926 -0.870237 -0.89       2.13922 0.388414 0      -3.63639e-05 1.27176 -0.89      1. 0. 0.
    33331
    34   1.37419 -0.89433 -0.89        0.12489 1.24767 -0.89   -1.12431 -0.89433 -0.89         1. 0. 0.
     34  1.24926 -0.870237 -0.89       -3.63639e-05 1.27176 -0.89      -1.24924 -0.870237 -0.89        1. 0. 0.
    35351
    36   0.12489 1.24767 -0.89         -2.01426 0.364321 -4.44089e-16  -1.12431 -0.89433 -0.89         1. 0. 0.
     36  -3.63639e-05 1.27176 -0.89    -2.13919 0.388414 0     -1.24924 -0.870237 -0.89        1. 0. 0.
    37371
    38   2.26414 0.364321 -4.44089e-16         0.12489 1.24767 -0.89   0.12489 1.24767 0.89    1. 0. 0.
     38  2.13922 0.388414 0    -3.63639e-05 1.27176 -0.89      -3.63639e-05 1.27176 0.89       1. 0. 0.
    39391
    40   0.12489 1.24767 -0.89         0.12489 1.24767 0.89    -2.01426 0.364321 -4.44089e-16  1. 0. 0.
     40  -3.63639e-05 1.27176 -0.89    -3.63639e-05 1.27176 0.89       -2.13919 0.388414 0     1. 0. 0.
    41411
    42   1.37419 -0.89433 0.89         2.26414 0.364321 -4.44089e-16   0.12489 1.24767 0.89    1. 0. 0.
     42  1.24926 -0.870237 0.89        2.13922 0.388414 0      -3.63639e-05 1.27176 0.89       1. 0. 0.
    43431
    44   1.37419 -0.89433 0.89         0.12489 1.24767 0.89    -1.12431 -0.89433 0.89  1. 0. 0.
     44  1.24926 -0.870237 0.89        -3.63639e-05 1.27176 0.89       -1.24924 -0.870237 0.89         1. 0. 0.
    45451
    46   0.12489 1.24767 0.89  -2.01426 0.364321 -4.44089e-16  -1.12431 -0.89433 0.89  1. 0. 0.
     46  -3.63639e-05 1.27176 0.89     -2.13919 0.388414 0     -1.24924 -0.870237 0.89         1. 0. 0.
    47471
    48   -2.01426 0.364321 -4.44089e-16        -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.89  1. 0. 0.
     48  -2.13919 0.388414 0   -1.24924 -0.870237 -0.89        -1.24924 -0.870237 0.89         1. 0. 0.
    49491
    50   1.37419 -0.89433 0.89         -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.89  1. 0. 0.
     50  1.24926 -0.870237 0.89        -1.24924 -0.870237 -0.89        -1.24924 -0.870237 0.89         1. 0. 0.
    51511
    52   1.37419 -0.89433 -0.89        1.37419 -0.89433 0.89   -1.12431 -0.89433 -0.89         1. 0. 0.
     52  1.24926 -0.870237 -0.89       1.24926 -0.870237 0.89  -1.24924 -0.870237 -0.89        1. 0. 0.
    53531
    54   1.37419 -0.89433 -0.89        1.37419 -0.89433 0.89   2.26414 0.364321 -4.44089e-16   1. 0. 0.
     54  1.24926 -0.870237 -0.89       1.24926 -0.870237 0.89  2.13922 0.388414 0      1. 0. 0.
    55559
    5656#  terminating special property
     
    5959  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0
    60602
    61   1.67084 -0.47478 -8.88178e-16 5       1 0 0
     61  1.54591 -0.450686 -4.44089e-16        5       1 0 0
    62629
    6363  terminating special property
  • tests/regression/Tesselation/3/post/NonConvexEnvelope.dat

    r0c7ed8 r1dc9ec  
    22VARIABLES = "X" "Y" "Z" "U"
    33ZONE T="test", N=44, E=86, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4 6.9077 1.1106 0.1214 1
    540.3612 -3.628 1.323 1
    650.4884 -3.5983 -0.4521 3
     
    4645-6.8554 1.8134 -0.9499 1
    47467.1391 2.0447 0.0264 0
     476.9077 1.1106 0.1214 1
    4848
    49 1 32 44
    50 1 32 35
    51 1 34 35
    52 23 32 35
    53 17 23 35
    54 8 17 35
    55 8 10 17
    56 3 8 10
    57 3 8 35
    58 3 4 35
    59 4 29 35
    60 29 34 35
    61 2 3 4
    62 2 4 29
    63 2 15 29
    64 15 28 29
    65 28 29 34
    66 2 7 15
    67 7 14 15
    68 14 15 28
    69 14 25 28
    70 25 28 37
    71 28 34 37
    72 1 34 37
    73 1 37 44
    74 25 26 37
    75 25 26 27
    76 26 27 33
    77 26 33 44
    78 26 37 44
    79 14 25 27
    80 14 27 30
    81 6 14 30
    82 6 24 30
    83 24 30 36
    84 30 36 39
    85 27 30 39
    86 27 30 39
    87 16 27 30
    88 16 18 30
    89 16 18 27
    90 18 27 33
    91 18 23 33
    92 6 7 24
    93 6 7 14
    94 7 11 24
    95 11 20 24
    96 20 24 41
    97 24 36 41
    98 36 41 42
    99 11 20 22
    100 5 11 22
    101 5 7 11
    102 2 5 7
    103 36 38 39
    104 36 38 42
    105 18 30 31
    106 30 31 39
    107 31 39 40
    108 9 18 31
    109 9 17 18
    110 17 18 23
    111 9 19 31
    112 9 13 19
    113 13 19 31
    114 13 21 31
    115 21 31 43
    116 31 40 43
    117 9 12 13
    118 9 10 12
    119 9 10 17
    120 12 13 21
    121 12 21 22
    122 5 12 22
    123 3 5 12
    124 2 3 5
    125 3 10 12
    126 20 21 22
    127 20 21 41
    128 21 41 43
    129 41 42 43
    130 23 32 33
    131 32 33 44
    132 40 42 43
    133 38 40 42
    134 38 39 40
     4931 43 44
     5031 34 44
     5133 34 44
     5222 31 34
     5316 22 34
     547 16 34
     557 9 16
     562 7 9
     572 7 34
     582 3 34
     593 28 34
     6028 33 34
     611 2 3
     621 3 28
     631 14 28
     6414 27 28
     6527 28 33
     661 6 14
     676 13 14
     6813 14 27
     6913 24 27
     7024 27 36
     7127 33 36
     7233 36 44
     7336 43 44
     7424 25 36
     7524 25 26
     7625 26 32
     7725 32 43
     7825 36 43
     7913 24 26
     8013 26 29
     815 13 29
     825 23 29
     8323 29 35
     8429 35 38
     8526 29 38
     8626 29 38
     8715 26 29
     8815 17 29
     8915 17 26
     9017 26 32
     9117 22 32
     925 6 23
     935 6 13
     946 10 23
     9510 19 23
     9619 23 40
     9723 35 40
     9835 40 41
     9910 19 21
     1004 10 21
     1014 6 10
     1021 4 6
     10335 37 38
     10435 37 41
     10517 29 30
     10629 30 38
     10730 38 39
     1088 17 30
     1098 16 17
     11016 17 22
     1118 18 30
     1128 12 18
     11312 18 30
     11412 20 30
     11520 30 42
     11630 39 42
     1178 11 12
     1188 9 11
     1198 9 16
     12011 12 20
     12111 20 21
     1224 11 21
     1232 4 11
     1241 2 4
     1252 9 11
     12619 20 21
     12719 20 40
     12820 40 42
     12940 41 42
     13022 31 32
     13131 32 43
     13239 41 42
     13337 39 41
     13437 38 39
  • tests/regression/Tesselation/3/post/NonConvexEnvelope.r3d

    r0c7ed8 r1dc9ec  
    33# All atoms as spheres
    442
    5   0.952534 -3.05798 0.420171    0.1     1. 1. 1.
    6 2
    7   -0.139866 -1.98848 0.359771   0.1     1. 1. 1.
    8 2
    9   0.0788342 -1.07508 -0.875229  0.1     1. 1. 1.
    10 2
    11   -1.49147 -2.63828 0.0780712   0.1     1. 1. 1.
    12 2
    13   -0.0588658 -1.09478 1.58347   0.1     1. 1. 1.
    14 2
    15   1.53473 -0.644479 -0.868129   0.1     1. 1. 1.
    16 2
    17   -0.333166 -2.00128 -2.02443   0.1     1. 1. 1.
    18 2
    19   -2.62147 -1.78218 0.653571    0.1     1. 1. 1.
    20 2
    21   -1.60077 -2.70398 -1.46563    0.1     1. 1. 1.
    22 2
    23   1.37913 -0.560579 1.65607     0.1     1. 1. 1.
    24 2
    25   1.75933 0.205421 0.395371     0.1     1. 1. 1.
    26 2
    27   1.79893 0.246421 -2.08883     0.1     1. 1. 1.
    28 2
    29   -2.64037 -0.423279 -0.0491288         0.1     1. 1. 1.
    30 2
    31   -3.96017 -2.48928 0.432671    0.1     1. 1. 1.
    32 2
    33   3.23013 0.593821 0.484471     0.1     1. 1. 1.
    34 2
    35   3.14803 0.889821 -1.96833     0.1     1. 1. 1.
    36 2
    37   -3.79507 0.418021 0.498371    0.1     1. 1. 1.
    38 2
    39   3.36023 1.76962 1.45487       0.1     1. 1. 1.
    40 2
    41   3.78273 1.01752 -0.849429     0.1     1. 1. 1.
    42 2
    43   4.07093 -0.563879 1.01767     0.1     1. 1. 1.
    44 2
    45   -3.81397 1.77692 -0.204329    0.1     1. 1. 1.
    46 2
    47   5.17783 1.62112 -0.842829     0.1     1. 1. 1.
    48 2
    49   5.49863 -0.464179 0.482071    0.1     1. 1. 1.
    50 2
    51   -4.96867 2.61822 0.343171     0.1     1. 1. 1.
    52 2
    53   5.93083 0.990421 0.337371     0.1     1. 1. 1.
    54 2
    55   -4.98757 3.97722 -0.359529    0.1     1. 1. 1.
    56 2
    57   -6.29237 1.89422 0.0890712    0.1     1. 1. 1.
    58 2
    59   7.33693 1.04442 0.0886712     0.1     1. 1. 1.
    60 2
    61   0.790434 -3.69418 1.29027     0.1     1. 1. 1.
    62 2
    63   0.917634 -3.66448 -0.484829   0.1     1. 1. 1.
    64 2
    65   1.92773 -2.57738 0.498071     0.1     1. 1. 1.
    66 2
    67   -0.574266 -0.203779 -0.824729         0.1     1. 1. 1.
    68 2
    69   -1.52417 -3.64138 0.503471    0.1     1. 1. 1.
    70 2
    71   -0.759066 -0.265179 1.48487   0.1     1. 1. 1.
    72 2
    73   -0.287266 -1.67078 2.48017    0.1     1. 1. 1.
    74 2
    75   2.19193 -1.51408 -0.867629    0.1     1. 1. 1.
    76 2
    77   -0.573766 -1.42458 -2.91753   0.1     1. 1. 1.
    78 2
    79   0.450934 -2.72908 -2.23353    0.1     1. 1. 1.
    80 2
    81   -2.45927 -1.63678 1.72157     0.1     1. 1. 1.
    82 2
    83   -1.62867 -3.74268 -1.79493    0.1     1. 1. 1.
    84 2
    85   -2.49667 -2.18078 -1.79993    0.1     1. 1. 1.
    86 2
    87   1.46453 0.112321 2.50927      0.1     1. 1. 1.
    88 2
    89   2.06173 -1.39848 1.79787      0.1     1. 1. 1.
    90 2
    91   1.15633 1.11082 0.326671      0.1     1. 1. 1.
    92 2
    93   1.76663 -0.360379 -2.99373    0.1     1. 1. 1.
    94 2
    95   1.03283 1.01972 -2.14533      0.1     1. 1. 1.
    96 2
    97   -1.69727 0.0925205 0.131971   0.1     1. 1. 1.
    98 2
    99   -2.77417 -0.570279 -1.12083   0.1     1. 1. 1.
    100 2
    101   -4.75167 -1.93408 0.935971    0.1     1. 1. 1.
    102 2
    103   -4.17327 -2.53828 -0.635229   0.1     1. 1. 1.
    104 2
    105   -3.90927 -3.49908 0.839771    0.1     1. 1. 1.
    106 2
    107   3.62023 1.25552 -2.86813      0.1     1. 1. 1.
    108 2
    109   -4.73807 -0.0977795 0.317371  0.1     1. 1. 1.
    110 2
    111   -3.66127 0.565021 1.57007     0.1     1. 1. 1.
    112 2
    113   3.24233 1.41142 2.47757       0.1     1. 1. 1.
    114 2
    115   4.34293 2.22742 1.34117       0.1     1. 1. 1.
    116 2
    117   2.58823 2.50762 1.23707       0.1     1. 1. 1.
    118 2
    119   4.08983 -0.525479 2.10687     0.1     1. 1. 1.
    120 2
    121   3.62993 -1.50808 0.698371     0.1     1. 1. 1.
    122 2
    123   -2.87097 2.29272 -0.0233288   0.1     1. 1. 1.
    124 2
    125   -3.94777 1.63002 -1.27603     0.1     1. 1. 1.
    126 2
    127   5.68853 1.38852 -1.77723      0.1     1. 1. 1.
    128 2
    129   5.11553 2.70122 -0.710229     0.1     1. 1. 1.
    130 2
    131   6.17523 -0.969279 1.17127     0.1     1. 1. 1.
    132 2
    133   5.55043 -0.952879 -0.490929   0.1     1. 1. 1.
    134 2
    135   -4.83487 2.76522 1.41487      0.1     1. 1. 1.
    136 2
    137   5.70193 1.54062 1.25007       0.1     1. 1. 1.
    138 2
    139   -5.81017 4.57652 0.0304712    0.1     1. 1. 1.
    140 2
    141   -4.04457 4.49292 -0.178529    0.1     1. 1. 1.
    142 2
    143   -5.12137 3.83022 -1.43123     0.1     1. 1. 1.
    144 2
    145   -6.27887 0.926121 0.589671    0.1     1. 1. 1.
    146 2
    147   -7.11497 2.49352 0.479071     0.1     1. 1. 1.
    148 2
    149   -6.42617 1.74722 -0.982629    0.1     1. 1. 1.
    150 2
    151   7.56833 1.97852 -0.00632877   0.1     1. 1. 1.
     5  0.777562 -3.65286 1.28459     0.1     1. 1. 1.
     62
     7  0.904762 -3.62316 -0.490507   0.1     1. 1. 1.
     82
     9  1.91486 -2.53606 0.492393     0.1     1. 1. 1.
     102
     11  -0.587138 -0.162455 -0.830407         0.1     1. 1. 1.
     122
     13  -1.53704 -3.60006 0.497793    0.1     1. 1. 1.
     142
     15  -0.771938 -0.223855 1.47919   0.1     1. 1. 1.
     162
     17  -0.300138 -1.62946 2.47449    0.1     1. 1. 1.
     182
     19  2.17906 -1.47276 -0.873307    0.1     1. 1. 1.
     202
     21  -0.586638 -1.38326 -2.92321   0.1     1. 1. 1.
     222
     23  0.438062 -2.68776 -2.23921    0.1     1. 1. 1.
     242
     25  -2.47214 -1.59546 1.71589     0.1     1. 1. 1.
     262
     27  -1.64154 -3.70136 -1.80061    0.1     1. 1. 1.
     282
     29  -2.50954 -2.13946 -1.80561    0.1     1. 1. 1.
     302
     31  1.45166 0.153645 2.50359      0.1     1. 1. 1.
     322
     33  2.04886 -1.35716 1.79219      0.1     1. 1. 1.
     342
     35  1.14346 1.15214 0.320993      0.1     1. 1. 1.
     362
     37  1.75376 -0.319055 -2.99941    0.1     1. 1. 1.
     382
     39  1.01996 1.06104 -2.15101      0.1     1. 1. 1.
     402
     41  -1.71014 0.133845 0.126293    0.1     1. 1. 1.
     422
     43  -2.78704 -0.528955 -1.12651   0.1     1. 1. 1.
     442
     45  -4.76454 -1.89276 0.930293    0.1     1. 1. 1.
     462
     47  -4.18614 -2.49696 -0.640907   0.1     1. 1. 1.
     482
     49  -3.92214 -3.45776 0.834093    0.1     1. 1. 1.
     502
     51  3.60736 1.29684 -2.87381      0.1     1. 1. 1.
     522
     53  -4.75094 -0.0564554 0.311693  0.1     1. 1. 1.
     542
     55  -3.67414 0.606345 1.56439     0.1     1. 1. 1.
     562
     57  3.22946 1.45274 2.47189       0.1     1. 1. 1.
     582
     59  4.33006 2.26874 1.33549       0.1     1. 1. 1.
     602
     61  2.57536 2.54894 1.23139       0.1     1. 1. 1.
     622
     63  4.07696 -0.484155 2.10119     0.1     1. 1. 1.
     642
     65  3.61706 -1.46676 0.692693     0.1     1. 1. 1.
     662
     67  -2.88384 2.33404 -0.0290068   0.1     1. 1. 1.
     682
     69  -3.96064 1.67134 -1.28171     0.1     1. 1. 1.
     702
     71  5.67566 1.42984 -1.78291      0.1     1. 1. 1.
     722
     73  5.10266 2.74254 -0.715907     0.1     1. 1. 1.
     742
     75  6.16236 -0.927955 1.16559     0.1     1. 1. 1.
     762
     77  5.53756 -0.911555 -0.496607   0.1     1. 1. 1.
     782
     79  -4.84774 2.80654 1.40919      0.1     1. 1. 1.
     802
     81  5.68906 1.58194 1.24439       0.1     1. 1. 1.
     822
     83  -5.82304 4.61784 0.0247932    0.1     1. 1. 1.
     842
     85  -4.05744 4.53424 -0.184207    0.1     1. 1. 1.
     862
     87  -5.13424 3.87154 -1.43691     0.1     1. 1. 1.
     882
     89  -6.29174 0.967445 0.583993    0.1     1. 1. 1.
     902
     91  -7.12784 2.53484 0.473393     0.1     1. 1. 1.
     922
     93  -6.43904 1.78854 -0.988307    0.1     1. 1. 1.
     942
     95  7.55546 2.01984 -0.0120068    0.1     1. 1. 1.
     962
     97  0.939662 -3.01666 0.414493    0.1     1. 1. 1.
     982
     99  -0.152738 -1.94716 0.354093   0.1     1. 1. 1.
     1002
     101  0.0659622 -1.03376 -0.880907  0.1     1. 1. 1.
     1022
     103  -1.50434 -2.59696 0.0723932   0.1     1. 1. 1.
     1042
     105  -0.0717378 -1.05346 1.57779   0.1     1. 1. 1.
     1062
     107  1.52186 -0.603155 -0.873807   0.1     1. 1. 1.
     1082
     109  -0.346038 -1.95996 -2.03011   0.1     1. 1. 1.
     1102
     111  -2.63434 -1.74086 0.647893    0.1     1. 1. 1.
     1122
     113  -1.61364 -2.66266 -1.47131    0.1     1. 1. 1.
     1142
     115  1.36626 -0.519255 1.65039     0.1     1. 1. 1.
     1162
     117  1.74646 0.246745 0.389693     0.1     1. 1. 1.
     1182
     119  1.78606 0.287745 -2.09451     0.1     1. 1. 1.
     1202
     121  -2.65324 -0.381955 -0.0548068         0.1     1. 1. 1.
     1222
     123  -3.97304 -2.44796 0.426993    0.1     1. 1. 1.
     1242
     125  3.21726 0.635145 0.478793     0.1     1. 1. 1.
     1262
     127  3.13516 0.931145 -1.97401     0.1     1. 1. 1.
     1282
     129  -3.80794 0.459345 0.492693    0.1     1. 1. 1.
     1302
     131  3.34736 1.81094 1.44919       0.1     1. 1. 1.
     1322
     133  3.76986 1.05884 -0.855107     0.1     1. 1. 1.
     1342
     135  4.05806 -0.522555 1.01199     0.1     1. 1. 1.
     1362
     137  -3.82684 1.81824 -0.210007    0.1     1. 1. 1.
     1382
     139  5.16496 1.66244 -0.848507     0.1     1. 1. 1.
     1402
     141  5.48576 -0.422855 0.476393    0.1     1. 1. 1.
     1422
     143  -4.98154 2.65954 0.337493     0.1     1. 1. 1.
     1442
     145  5.91796 1.03174 0.331693      0.1     1. 1. 1.
     1462
     147  -5.00044 4.01854 -0.365207    0.1     1. 1. 1.
     1482
     149  -6.30524 1.93554 0.0833932    0.1     1. 1. 1.
     1502
     151  7.32406 1.08574 0.0829932     0.1     1. 1. 1.
    152152# All tesselation triangles
    1531538
     
    156156  BACKFACE  0.3 0.3 1.0   0 0
    1571571
    158   7.33693 1.04442 0.0886712     5.68853 1.38852 -1.77723        7.56833 1.97852 -0.00632877     1. 0. 0.
    159 1
    160   7.33693 1.04442 0.0886712     5.68853 1.38852 -1.77723        5.55043 -0.952879 -0.490929     1. 0. 0.
    161 1
    162   7.33693 1.04442 0.0886712     6.17523 -0.969279 1.17127       5.55043 -0.952879 -0.490929     1. 0. 0.
    163 1
    164   3.62023 1.25552 -2.86813      5.68853 1.38852 -1.77723        5.55043 -0.952879 -0.490929     1. 0. 0.
    165 1
    166   1.76663 -0.360379 -2.99373    3.62023 1.25552 -2.86813        5.55043 -0.952879 -0.490929     1. 0. 0.
    167 1
    168   2.19193 -1.51408 -0.867629    1.76663 -0.360379 -2.99373      5.55043 -0.952879 -0.490929     1. 0. 0.
    169 1
    170   2.19193 -1.51408 -0.867629    0.450934 -2.72908 -2.23353      1.76663 -0.360379 -2.99373      1. 0. 0.
    171 1
    172   0.917634 -3.66448 -0.484829   2.19193 -1.51408 -0.867629      0.450934 -2.72908 -2.23353      1. 0. 0.
    173 1
    174   0.917634 -3.66448 -0.484829   2.19193 -1.51408 -0.867629      5.55043 -0.952879 -0.490929     1. 0. 0.
    175 1
    176   0.917634 -3.66448 -0.484829   1.92773 -2.57738 0.498071       5.55043 -0.952879 -0.490929     1. 0. 0.
    177 1
    178   1.92773 -2.57738 0.498071     3.62993 -1.50808 0.698371       5.55043 -0.952879 -0.490929     1. 0. 0.
    179 1
    180   3.62993 -1.50808 0.698371     6.17523 -0.969279 1.17127       5.55043 -0.952879 -0.490929     1. 0. 0.
    181 1
    182   0.790434 -3.69418 1.29027     0.917634 -3.66448 -0.484829     1.92773 -2.57738 0.498071       1. 0. 0.
    183 1
    184   0.790434 -3.69418 1.29027     1.92773 -2.57738 0.498071       3.62993 -1.50808 0.698371       1. 0. 0.
    185 1
    186   0.790434 -3.69418 1.29027     2.06173 -1.39848 1.79787        3.62993 -1.50808 0.698371       1. 0. 0.
    187 1
    188   2.06173 -1.39848 1.79787      4.08983 -0.525479 2.10687       3.62993 -1.50808 0.698371       1. 0. 0.
    189 1
    190   4.08983 -0.525479 2.10687     3.62993 -1.50808 0.698371       6.17523 -0.969279 1.17127       1. 0. 0.
    191 1
    192   0.790434 -3.69418 1.29027     -0.287266 -1.67078 2.48017      2.06173 -1.39848 1.79787        1. 0. 0.
    193 1
    194   -0.287266 -1.67078 2.48017    1.46453 0.112321 2.50927        2.06173 -1.39848 1.79787        1. 0. 0.
    195 1
    196   1.46453 0.112321 2.50927      2.06173 -1.39848 1.79787        4.08983 -0.525479 2.10687       1. 0. 0.
    197 1
    198   1.46453 0.112321 2.50927      3.24233 1.41142 2.47757         4.08983 -0.525479 2.10687       1. 0. 0.
    199 1
    200   3.24233 1.41142 2.47757       4.08983 -0.525479 2.10687       5.70193 1.54062 1.25007         1. 0. 0.
    201 1
    202   4.08983 -0.525479 2.10687     6.17523 -0.969279 1.17127       5.70193 1.54062 1.25007         1. 0. 0.
    203 1
    204   7.33693 1.04442 0.0886712     6.17523 -0.969279 1.17127       5.70193 1.54062 1.25007         1. 0. 0.
    205 1
    206   7.33693 1.04442 0.0886712     5.70193 1.54062 1.25007         7.56833 1.97852 -0.00632877     1. 0. 0.
    207 1
    208   3.24233 1.41142 2.47757       4.34293 2.22742 1.34117         5.70193 1.54062 1.25007         1. 0. 0.
    209 1
    210   3.24233 1.41142 2.47757       4.34293 2.22742 1.34117         2.58823 2.50762 1.23707         1. 0. 0.
    211 1
    212   4.34293 2.22742 1.34117       2.58823 2.50762 1.23707         5.11553 2.70122 -0.710229       1. 0. 0.
    213 1
    214   4.34293 2.22742 1.34117       5.11553 2.70122 -0.710229       7.56833 1.97852 -0.00632877     1. 0. 0.
    215 1
    216   4.34293 2.22742 1.34117       5.70193 1.54062 1.25007         7.56833 1.97852 -0.00632877     1. 0. 0.
    217 1
    218   1.46453 0.112321 2.50927      3.24233 1.41142 2.47757         2.58823 2.50762 1.23707         1. 0. 0.
    219 1
    220   1.46453 0.112321 2.50927      2.58823 2.50762 1.23707         -2.87097 2.29272 -0.0233288     1. 0. 0.
    221 1
    222   -0.759066 -0.265179 1.48487   1.46453 0.112321 2.50927        -2.87097 2.29272 -0.0233288     1. 0. 0.
    223 1
    224   -0.759066 -0.265179 1.48487   -3.66127 0.565021 1.57007       -2.87097 2.29272 -0.0233288     1. 0. 0.
    225 1
    226   -3.66127 0.565021 1.57007     -2.87097 2.29272 -0.0233288     -4.83487 2.76522 1.41487        1. 0. 0.
    227 1
    228   -2.87097 2.29272 -0.0233288   -4.83487 2.76522 1.41487        -4.04457 4.49292 -0.178529      1. 0. 0.
    229 1
    230   2.58823 2.50762 1.23707       -2.87097 2.29272 -0.0233288     -4.04457 4.49292 -0.178529      1. 0. 0.
    231 1
    232   2.58823 2.50762 1.23707       -2.87097 2.29272 -0.0233288     -4.04457 4.49292 -0.178529      1. 0. 0.
    233 1
    234   1.15633 1.11082 0.326671      2.58823 2.50762 1.23707         -2.87097 2.29272 -0.0233288     1. 0. 0.
    235 1
    236   1.15633 1.11082 0.326671      1.03283 1.01972 -2.14533        -2.87097 2.29272 -0.0233288     1. 0. 0.
    237 1
    238   1.15633 1.11082 0.326671      1.03283 1.01972 -2.14533        2.58823 2.50762 1.23707         1. 0. 0.
    239 1
    240   1.03283 1.01972 -2.14533      2.58823 2.50762 1.23707         5.11553 2.70122 -0.710229       1. 0. 0.
    241 1
    242   1.03283 1.01972 -2.14533      3.62023 1.25552 -2.86813        5.11553 2.70122 -0.710229       1. 0. 0.
    243 1
    244   -0.759066 -0.265179 1.48487   -0.287266 -1.67078 2.48017      -3.66127 0.565021 1.57007       1. 0. 0.
    245 1
    246   -0.759066 -0.265179 1.48487   -0.287266 -1.67078 2.48017      1.46453 0.112321 2.50927        1. 0. 0.
    247 1
    248   -0.287266 -1.67078 2.48017    -2.45927 -1.63678 1.72157       -3.66127 0.565021 1.57007       1. 0. 0.
    249 1
    250   -2.45927 -1.63678 1.72157     -4.75167 -1.93408 0.935971      -3.66127 0.565021 1.57007       1. 0. 0.
    251 1
    252   -4.75167 -1.93408 0.935971    -3.66127 0.565021 1.57007       -6.27887 0.926121 0.589671      1. 0. 0.
    253 1
    254   -3.66127 0.565021 1.57007     -4.83487 2.76522 1.41487        -6.27887 0.926121 0.589671      1. 0. 0.
    255 1
    256   -4.83487 2.76522 1.41487      -6.27887 0.926121 0.589671      -7.11497 2.49352 0.479071       1. 0. 0.
    257 1
    258   -2.45927 -1.63678 1.72157     -4.75167 -1.93408 0.935971      -3.90927 -3.49908 0.839771      1. 0. 0.
    259 1
    260   -1.52417 -3.64138 0.503471    -2.45927 -1.63678 1.72157       -3.90927 -3.49908 0.839771      1. 0. 0.
    261 1
    262   -1.52417 -3.64138 0.503471    -0.287266 -1.67078 2.48017      -2.45927 -1.63678 1.72157       1. 0. 0.
    263 1
    264   0.790434 -3.69418 1.29027     -1.52417 -3.64138 0.503471      -0.287266 -1.67078 2.48017      1. 0. 0.
    265 1
    266   -4.83487 2.76522 1.41487      -5.81017 4.57652 0.0304712      -4.04457 4.49292 -0.178529      1. 0. 0.
    267 1
    268   -4.83487 2.76522 1.41487      -5.81017 4.57652 0.0304712      -7.11497 2.49352 0.479071       1. 0. 0.
    269 1
    270   1.03283 1.01972 -2.14533      -2.87097 2.29272 -0.0233288     -3.94777 1.63002 -1.27603       1. 0. 0.
    271 1
    272   -2.87097 2.29272 -0.0233288   -3.94777 1.63002 -1.27603       -4.04457 4.49292 -0.178529      1. 0. 0.
    273 1
    274   -3.94777 1.63002 -1.27603     -4.04457 4.49292 -0.178529      -5.12137 3.83022 -1.43123       1. 0. 0.
    275 1
    276   -0.573766 -1.42458 -2.91753   1.03283 1.01972 -2.14533        -3.94777 1.63002 -1.27603       1. 0. 0.
    277 1
    278   -0.573766 -1.42458 -2.91753   1.76663 -0.360379 -2.99373      1.03283 1.01972 -2.14533        1. 0. 0.
    279 1
    280   1.76663 -0.360379 -2.99373    1.03283 1.01972 -2.14533        3.62023 1.25552 -2.86813        1. 0. 0.
    281 1
    282   -0.573766 -1.42458 -2.91753   -2.77417 -0.570279 -1.12083     -3.94777 1.63002 -1.27603       1. 0. 0.
    283 1
    284   -0.573766 -1.42458 -2.91753   -2.49667 -2.18078 -1.79993      -2.77417 -0.570279 -1.12083     1. 0. 0.
    285 1
    286   -2.49667 -2.18078 -1.79993    -2.77417 -0.570279 -1.12083     -3.94777 1.63002 -1.27603       1. 0. 0.
    287 1
    288   -2.49667 -2.18078 -1.79993    -4.17327 -2.53828 -0.635229     -3.94777 1.63002 -1.27603       1. 0. 0.
    289 1
    290   -4.17327 -2.53828 -0.635229   -3.94777 1.63002 -1.27603       -6.42617 1.74722 -0.982629      1. 0. 0.
    291 1
    292   -3.94777 1.63002 -1.27603     -5.12137 3.83022 -1.43123       -6.42617 1.74722 -0.982629      1. 0. 0.
    293 1
    294   -0.573766 -1.42458 -2.91753   -1.62867 -3.74268 -1.79493      -2.49667 -2.18078 -1.79993      1. 0. 0.
    295 1
    296   -0.573766 -1.42458 -2.91753   0.450934 -2.72908 -2.23353      -1.62867 -3.74268 -1.79493      1. 0. 0.
    297 1
    298   -0.573766 -1.42458 -2.91753   0.450934 -2.72908 -2.23353      1.76663 -0.360379 -2.99373      1. 0. 0.
    299 1
    300   -1.62867 -3.74268 -1.79493    -2.49667 -2.18078 -1.79993      -4.17327 -2.53828 -0.635229     1. 0. 0.
    301 1
    302   -1.62867 -3.74268 -1.79493    -4.17327 -2.53828 -0.635229     -3.90927 -3.49908 0.839771      1. 0. 0.
    303 1
    304   -1.52417 -3.64138 0.503471    -1.62867 -3.74268 -1.79493      -3.90927 -3.49908 0.839771      1. 0. 0.
    305 1
    306   0.917634 -3.66448 -0.484829   -1.52417 -3.64138 0.503471      -1.62867 -3.74268 -1.79493      1. 0. 0.
    307 1
    308   0.790434 -3.69418 1.29027     0.917634 -3.66448 -0.484829     -1.52417 -3.64138 0.503471      1. 0. 0.
    309 1
    310   0.917634 -3.66448 -0.484829   0.450934 -2.72908 -2.23353      -1.62867 -3.74268 -1.79493      1. 0. 0.
    311 1
    312   -4.75167 -1.93408 0.935971    -4.17327 -2.53828 -0.635229     -3.90927 -3.49908 0.839771      1. 0. 0.
    313 1
    314   -4.75167 -1.93408 0.935971    -4.17327 -2.53828 -0.635229     -6.27887 0.926121 0.589671      1. 0. 0.
    315 1
    316   -4.17327 -2.53828 -0.635229   -6.27887 0.926121 0.589671      -6.42617 1.74722 -0.982629      1. 0. 0.
    317 1
    318   -6.27887 0.926121 0.589671    -7.11497 2.49352 0.479071       -6.42617 1.74722 -0.982629      1. 0. 0.
    319 1
    320   3.62023 1.25552 -2.86813      5.68853 1.38852 -1.77723        5.11553 2.70122 -0.710229       1. 0. 0.
    321 1
    322   5.68853 1.38852 -1.77723      5.11553 2.70122 -0.710229       7.56833 1.97852 -0.00632877     1. 0. 0.
    323 1
    324   -5.12137 3.83022 -1.43123     -7.11497 2.49352 0.479071       -6.42617 1.74722 -0.982629      1. 0. 0.
    325 1
    326   -5.81017 4.57652 0.0304712    -5.12137 3.83022 -1.43123       -7.11497 2.49352 0.479071       1. 0. 0.
    327 1
    328   -5.81017 4.57652 0.0304712    -4.04457 4.49292 -0.178529      -5.12137 3.83022 -1.43123       1. 0. 0.
     158  5.67566 1.42984 -1.78291      7.55546 2.01984 -0.0120068      7.32406 1.08574 0.0829932       1. 0. 0.
     1591
     160  5.67566 1.42984 -1.78291      5.53756 -0.911555 -0.496607     7.32406 1.08574 0.0829932       1. 0. 0.
     1611
     162  6.16236 -0.927955 1.16559     5.53756 -0.911555 -0.496607     7.32406 1.08574 0.0829932       1. 0. 0.
     1631
     164  3.60736 1.29684 -2.87381      5.67566 1.42984 -1.78291        5.53756 -0.911555 -0.496607     1. 0. 0.
     1651
     166  1.75376 -0.319055 -2.99941    3.60736 1.29684 -2.87381        5.53756 -0.911555 -0.496607     1. 0. 0.
     1671
     168  2.17906 -1.47276 -0.873307    1.75376 -0.319055 -2.99941      5.53756 -0.911555 -0.496607     1. 0. 0.
     1691
     170  2.17906 -1.47276 -0.873307    0.438062 -2.68776 -2.23921      1.75376 -0.319055 -2.99941      1. 0. 0.
     1711
     172  0.904762 -3.62316 -0.490507   2.17906 -1.47276 -0.873307      0.438062 -2.68776 -2.23921      1. 0. 0.
     1731
     174  0.904762 -3.62316 -0.490507   2.17906 -1.47276 -0.873307      5.53756 -0.911555 -0.496607     1. 0. 0.
     1751
     176  0.904762 -3.62316 -0.490507   1.91486 -2.53606 0.492393       5.53756 -0.911555 -0.496607     1. 0. 0.
     1771
     178  1.91486 -2.53606 0.492393     3.61706 -1.46676 0.692693       5.53756 -0.911555 -0.496607     1. 0. 0.
     1791
     180  3.61706 -1.46676 0.692693     6.16236 -0.927955 1.16559       5.53756 -0.911555 -0.496607     1. 0. 0.
     1811
     182  0.777562 -3.65286 1.28459     0.904762 -3.62316 -0.490507     1.91486 -2.53606 0.492393       1. 0. 0.
     1831
     184  0.777562 -3.65286 1.28459     1.91486 -2.53606 0.492393       3.61706 -1.46676 0.692693       1. 0. 0.
     1851
     186  0.777562 -3.65286 1.28459     2.04886 -1.35716 1.79219        3.61706 -1.46676 0.692693       1. 0. 0.
     1871
     188  2.04886 -1.35716 1.79219      4.07696 -0.484155 2.10119       3.61706 -1.46676 0.692693       1. 0. 0.
     1891
     190  4.07696 -0.484155 2.10119     3.61706 -1.46676 0.692693       6.16236 -0.927955 1.16559       1. 0. 0.
     1911
     192  0.777562 -3.65286 1.28459     -0.300138 -1.62946 2.47449      2.04886 -1.35716 1.79219        1. 0. 0.
     1931
     194  -0.300138 -1.62946 2.47449    1.45166 0.153645 2.50359        2.04886 -1.35716 1.79219        1. 0. 0.
     1951
     196  1.45166 0.153645 2.50359      2.04886 -1.35716 1.79219        4.07696 -0.484155 2.10119       1. 0. 0.
     1971
     198  1.45166 0.153645 2.50359      3.22946 1.45274 2.47189         4.07696 -0.484155 2.10119       1. 0. 0.
     1991
     200  3.22946 1.45274 2.47189       4.07696 -0.484155 2.10119       5.68906 1.58194 1.24439         1. 0. 0.
     2011
     202  4.07696 -0.484155 2.10119     6.16236 -0.927955 1.16559       5.68906 1.58194 1.24439         1. 0. 0.
     2031
     204  6.16236 -0.927955 1.16559     5.68906 1.58194 1.24439         7.32406 1.08574 0.0829932       1. 0. 0.
     2051
     206  5.68906 1.58194 1.24439       7.55546 2.01984 -0.0120068      7.32406 1.08574 0.0829932       1. 0. 0.
     2071
     208  3.22946 1.45274 2.47189       4.33006 2.26874 1.33549         5.68906 1.58194 1.24439         1. 0. 0.
     2091
     210  3.22946 1.45274 2.47189       4.33006 2.26874 1.33549         2.57536 2.54894 1.23139         1. 0. 0.
     2111
     212  4.33006 2.26874 1.33549       2.57536 2.54894 1.23139         5.10266 2.74254 -0.715907       1. 0. 0.
     2131
     214  4.33006 2.26874 1.33549       5.10266 2.74254 -0.715907       7.55546 2.01984 -0.0120068      1. 0. 0.
     2151
     216  4.33006 2.26874 1.33549       5.68906 1.58194 1.24439         7.55546 2.01984 -0.0120068      1. 0. 0.
     2171
     218  1.45166 0.153645 2.50359      3.22946 1.45274 2.47189         2.57536 2.54894 1.23139         1. 0. 0.
     2191
     220  1.45166 0.153645 2.50359      2.57536 2.54894 1.23139         -2.88384 2.33404 -0.0290068     1. 0. 0.
     2211
     222  -0.771938 -0.223855 1.47919   1.45166 0.153645 2.50359        -2.88384 2.33404 -0.0290068     1. 0. 0.
     2231
     224  -0.771938 -0.223855 1.47919   -3.67414 0.606345 1.56439       -2.88384 2.33404 -0.0290068     1. 0. 0.
     2251
     226  -3.67414 0.606345 1.56439     -2.88384 2.33404 -0.0290068     -4.84774 2.80654 1.40919        1. 0. 0.
     2271
     228  -2.88384 2.33404 -0.0290068   -4.84774 2.80654 1.40919        -4.05744 4.53424 -0.184207      1. 0. 0.
     2291
     230  2.57536 2.54894 1.23139       -2.88384 2.33404 -0.0290068     -4.05744 4.53424 -0.184207      1. 0. 0.
     2311
     232  2.57536 2.54894 1.23139       -2.88384 2.33404 -0.0290068     -4.05744 4.53424 -0.184207      1. 0. 0.
     2331
     234  1.14346 1.15214 0.320993      2.57536 2.54894 1.23139         -2.88384 2.33404 -0.0290068     1. 0. 0.
     2351
     236  1.14346 1.15214 0.320993      1.01996 1.06104 -2.15101        -2.88384 2.33404 -0.0290068     1. 0. 0.
     2371
     238  1.14346 1.15214 0.320993      1.01996 1.06104 -2.15101        2.57536 2.54894 1.23139         1. 0. 0.
     2391
     240  1.01996 1.06104 -2.15101      2.57536 2.54894 1.23139         5.10266 2.74254 -0.715907       1. 0. 0.
     2411
     242  1.01996 1.06104 -2.15101      3.60736 1.29684 -2.87381        5.10266 2.74254 -0.715907       1. 0. 0.
     2431
     244  -0.771938 -0.223855 1.47919   -0.300138 -1.62946 2.47449      -3.67414 0.606345 1.56439       1. 0. 0.
     2451
     246  -0.771938 -0.223855 1.47919   -0.300138 -1.62946 2.47449      1.45166 0.153645 2.50359        1. 0. 0.
     2471
     248  -0.300138 -1.62946 2.47449    -2.47214 -1.59546 1.71589       -3.67414 0.606345 1.56439       1. 0. 0.
     2491
     250  -2.47214 -1.59546 1.71589     -4.76454 -1.89276 0.930293      -3.67414 0.606345 1.56439       1. 0. 0.
     2511
     252  -4.76454 -1.89276 0.930293    -3.67414 0.606345 1.56439       -6.29174 0.967445 0.583993      1. 0. 0.
     2531
     254  -3.67414 0.606345 1.56439     -4.84774 2.80654 1.40919        -6.29174 0.967445 0.583993      1. 0. 0.
     2551
     256  -4.84774 2.80654 1.40919      -6.29174 0.967445 0.583993      -7.12784 2.53484 0.473393       1. 0. 0.
     2571
     258  -2.47214 -1.59546 1.71589     -4.76454 -1.89276 0.930293      -3.92214 -3.45776 0.834093      1. 0. 0.
     2591
     260  -1.53704 -3.60006 0.497793    -2.47214 -1.59546 1.71589       -3.92214 -3.45776 0.834093      1. 0. 0.
     2611
     262  -1.53704 -3.60006 0.497793    -0.300138 -1.62946 2.47449      -2.47214 -1.59546 1.71589       1. 0. 0.
     2631
     264  0.777562 -3.65286 1.28459     -1.53704 -3.60006 0.497793      -0.300138 -1.62946 2.47449      1. 0. 0.
     2651
     266  -4.84774 2.80654 1.40919      -5.82304 4.61784 0.0247932      -4.05744 4.53424 -0.184207      1. 0. 0.
     2671
     268  -4.84774 2.80654 1.40919      -5.82304 4.61784 0.0247932      -7.12784 2.53484 0.473393       1. 0. 0.
     2691
     270  1.01996 1.06104 -2.15101      -2.88384 2.33404 -0.0290068     -3.96064 1.67134 -1.28171       1. 0. 0.
     2711
     272  -2.88384 2.33404 -0.0290068   -3.96064 1.67134 -1.28171       -4.05744 4.53424 -0.184207      1. 0. 0.
     2731
     274  -3.96064 1.67134 -1.28171     -4.05744 4.53424 -0.184207      -5.13424 3.87154 -1.43691       1. 0. 0.
     2751
     276  -0.586638 -1.38326 -2.92321   1.01996 1.06104 -2.15101        -3.96064 1.67134 -1.28171       1. 0. 0.
     2771
     278  -0.586638 -1.38326 -2.92321   1.75376 -0.319055 -2.99941      1.01996 1.06104 -2.15101        1. 0. 0.
     2791
     280  1.75376 -0.319055 -2.99941    1.01996 1.06104 -2.15101        3.60736 1.29684 -2.87381        1. 0. 0.
     2811
     282  -0.586638 -1.38326 -2.92321   -2.78704 -0.528955 -1.12651     -3.96064 1.67134 -1.28171       1. 0. 0.
     2831
     284  -0.586638 -1.38326 -2.92321   -2.50954 -2.13946 -1.80561      -2.78704 -0.528955 -1.12651     1. 0. 0.
     2851
     286  -2.50954 -2.13946 -1.80561    -2.78704 -0.528955 -1.12651     -3.96064 1.67134 -1.28171       1. 0. 0.
     2871
     288  -2.50954 -2.13946 -1.80561    -4.18614 -2.49696 -0.640907     -3.96064 1.67134 -1.28171       1. 0. 0.
     2891
     290  -4.18614 -2.49696 -0.640907   -3.96064 1.67134 -1.28171       -6.43904 1.78854 -0.988307      1. 0. 0.
     2911
     292  -3.96064 1.67134 -1.28171     -5.13424 3.87154 -1.43691       -6.43904 1.78854 -0.988307      1. 0. 0.
     2931
     294  -0.586638 -1.38326 -2.92321   -1.64154 -3.70136 -1.80061      -2.50954 -2.13946 -1.80561      1. 0. 0.
     2951
     296  -0.586638 -1.38326 -2.92321   0.438062 -2.68776 -2.23921      -1.64154 -3.70136 -1.80061      1. 0. 0.
     2971
     298  -0.586638 -1.38326 -2.92321   0.438062 -2.68776 -2.23921      1.75376 -0.319055 -2.99941      1. 0. 0.
     2991
     300  -1.64154 -3.70136 -1.80061    -2.50954 -2.13946 -1.80561      -4.18614 -2.49696 -0.640907     1. 0. 0.
     3011
     302  -1.64154 -3.70136 -1.80061    -4.18614 -2.49696 -0.640907     -3.92214 -3.45776 0.834093      1. 0. 0.
     3031
     304  -1.53704 -3.60006 0.497793    -1.64154 -3.70136 -1.80061      -3.92214 -3.45776 0.834093      1. 0. 0.
     3051
     306  0.904762 -3.62316 -0.490507   -1.53704 -3.60006 0.497793      -1.64154 -3.70136 -1.80061      1. 0. 0.
     3071
     308  0.777562 -3.65286 1.28459     0.904762 -3.62316 -0.490507     -1.53704 -3.60006 0.497793      1. 0. 0.
     3091
     310  0.904762 -3.62316 -0.490507   0.438062 -2.68776 -2.23921      -1.64154 -3.70136 -1.80061      1. 0. 0.
     3111
     312  -4.76454 -1.89276 0.930293    -4.18614 -2.49696 -0.640907     -3.92214 -3.45776 0.834093      1. 0. 0.
     3131
     314  -4.76454 -1.89276 0.930293    -4.18614 -2.49696 -0.640907     -6.29174 0.967445 0.583993      1. 0. 0.
     3151
     316  -4.18614 -2.49696 -0.640907   -6.29174 0.967445 0.583993      -6.43904 1.78854 -0.988307      1. 0. 0.
     3171
     318  -6.29174 0.967445 0.583993    -7.12784 2.53484 0.473393       -6.43904 1.78854 -0.988307      1. 0. 0.
     3191
     320  3.60736 1.29684 -2.87381      5.67566 1.42984 -1.78291        5.10266 2.74254 -0.715907       1. 0. 0.
     3211
     322  5.67566 1.42984 -1.78291      5.10266 2.74254 -0.715907       7.55546 2.01984 -0.0120068      1. 0. 0.
     3231
     324  -5.13424 3.87154 -1.43691     -7.12784 2.53484 0.473393       -6.43904 1.78854 -0.988307      1. 0. 0.
     3251
     326  -5.82304 4.61784 0.0247932    -5.13424 3.87154 -1.43691       -7.12784 2.53484 0.473393       1. 0. 0.
     3271
     328  -5.82304 4.61784 0.0247932    -4.05744 4.53424 -0.184207      -5.13424 3.87154 -1.43691       1. 0. 0.
    3293299
    330330#  terminating special property
     
    333333  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0
    3343342
    335   -4.99203 4.29989 -0.526429    5       1 0 0
     335  -5.0049 4.34121 -0.532107     5       1 0 0
    3363369
    337337  terminating special property
Note: See TracChangeset for help on using the changeset viewer.