Changes in / [13d5a9:5f612ee]


Ignore:
Files:
6 added
1 deleted
72 edited

Legend:

Unmodified
Added
Removed
  • src/Legacy/oldmenu.cpp

    r13d5a9 r5f612ee  
    7979        Log() << Verbose(0) << "Enter absolute coordinates." << endl;
    8080        first = World::getInstance().createAtom();
    81         first->x.AskPosition(mol->cell_size, false);
     81        first->x.AskPosition(World::getInstance().getDomain(), false);
    8282        first->type = periode->AskElement();  // give type
    8383        mol->AddAtom(first);  // add to molecule
     
    9090          if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
    9191          Log() << Verbose(0) << "Enter reference coordinates." << endl;
    92           x.AskPosition(mol->cell_size, true);
     92          x.AskPosition(World::getInstance().getDomain(), true);
    9393          Log() << Verbose(0) << "Enter relative coordinates." << endl;
    94           first->x.AskPosition(mol->cell_size, false);
     94          first->x.AskPosition(World::getInstance().getDomain(), false);
    9595          first->x.AddVector((const Vector *)&x);
    9696          Log() << Verbose(0) << "\n";
     
    107107          second = mol->AskAtom("Enter atom number: ");
    108108          Log() << Verbose(0) << "Enter relative coordinates." << endl;
    109           first->x.AskPosition(mol->cell_size, false);
     109          first->x.AskPosition(World::getInstance().getDomain(), false);
    110110          for (int i=NDIM;i--;) {
    111111            first->x.x[i] += second->x.x[i];
     
    334334    case 'b': // normal vector of mirror plane
    335335      Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl;
    336       n.AskPosition(mol->cell_size,0);
     336      n.AskPosition(World::getInstance().getDomain(),0);
    337337      n.Normalize();
    338338      break;
     
    401401    case 'b': // normal vector of mirror plane
    402402      Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl;
    403       n.AskPosition(mol->cell_size,0);
     403      n.AskPosition(World::getInstance().getDomain(),0);
    404404      n.Normalize();
    405405      break;
     
    778778      x.Zero();
    779779      y.Zero();
    780       y.x[abs(axis)-1] = mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
     780      y.x[abs(axis)-1] = World::getInstance().getDomain()[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
    781781      for (int i=1;i<faktor;i++) {  // then add this list with respective translation factor times
    782782        x.AddVector(&y); // per factor one cell width further
     
    801801        mol->Translate(&x);
    802802      }
    803       mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
     803      World::getInstance().getDomain()[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
    804804    }
    805805  }
     
    894894        Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
    895895        Log() << Verbose(0) << "Enter translation vector." << endl;
    896         x.AskPosition(mol->cell_size,0);
     896        x.AskPosition(World::getInstance().getDomain(),0);
    897897        mol->Center.AddVector((const Vector *)&x);
    898898     }
  • src/Makefile.am

    r13d5a9 r5f612ee  
    104104                 tesselation.cpp \
    105105                 tesselationhelpers.cpp \
     106                 triangleintersectionlist.cpp \
    106107                 vector.cpp \
    107108                 verbose.cpp \
    108109                 World.cpp
    109 HEADER = ${ANALYSISHEADER} ${ATOMHEADER} ${PATTERNHEADER} ${UIHEADER} ${DESCRIPTORHEADER} ${LEGACYHEADER} bond.hpp bondgraph.hpp boundary.hpp config.hpp defs.hpp element.hpp ellipsoid.hpp errorlogger.hpp graph.hpp helpers.hpp info.hpp leastsquaremin.hpp linkedcell.hpp lists.hpp log.hpp logger.hpp memoryallocator.hpp memoryusageobserver.hpp molecule.hpp molecule_template.hpp parser.hpp periodentafel.hpp stackclass.hpp tesselation.hpp tesselationhelpers.hpp vector.hpp verbose.hpp World.hpp
     110
     111HEADER = \
     112  ${ANALYSISHEADER} \
     113  ${ATOMHEADER} \
     114  ${PATTERNHEADER} \
     115  ${UIHEADER} \
     116  ${DESCRIPTORHEADER} \
     117  ${LEGACYHEADER} \
     118  bond.hpp \
     119  bondgraph.hpp \
     120  boundary.hpp \
     121  config.hpp \
     122  defs.hpp \
     123  element.hpp \
     124  ellipsoid.hpp \
     125  errorlogger.hpp \
     126  graph.hpp \
     127  helpers.hpp \
     128  info.hpp \
     129  leastsquaremin.hpp \
     130  linkedcell.hpp \
     131  lists.hpp \
     132  log.hpp \
     133  logger.hpp \
     134  memoryallocator.hpp \
     135  memoryusageobserver.hpp \
     136  molecule.hpp \
     137  molecule_template.hpp \
     138  parser.hpp \
     139  periodentafel.hpp \
     140  stackclass.hpp \
     141  tesselation.hpp \
     142  tesselationhelpers.hpp \
     143  triangleintersectionlist.hpp \
     144  vector.hpp \
     145  verbose.hpp \
     146  World.hpp
    110147
    111148BOOST_LIB = $(BOOST_LDFLAGS) $(BOOST_MPL_LIB)
  • src/World.cpp

    r13d5a9 r5f612ee  
    5959}
    6060
     61// system
     62
     63double * World::getDomain() {
     64  return cell_size;
     65}
     66
     67void World::setDomain(double * matrix)
     68{
     69
     70}
     71
     72char * World::getDefaultName() {
     73  return defaultName;
     74}
     75
     76void World::setDefaultName(char * name)
     77{
     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");
     85};
     86
     87
    6188/******************** Methods to change World state *********************/
    6289
     
    86113}
    87114
     115double *World::cell_size = NULL;
     116char *World::defaultName = NULL;
    88117
    89118atom *World::createAtom(){
     
    96125  return res;
    97126}
     127
    98128
    99129int World::registerAtom(atom *atom){
     
    243273    molecules_deprecated(new MoleculeListClass(this))
    244274{
     275  cell_size = new double[6];
     276  cell_size[0] = 20.;
     277  cell_size[1] = 0.;
     278  cell_size[2] = 20.;
     279  cell_size[3] = 0.;
     280  cell_size[4] = 0.;
     281  cell_size[5] = 20.;
     282  defaultName = new char[MAXSTRINGSIZE];
     283  strcpy(defaultName, "none");
    245284  molecules_deprecated->signOn(this);
    246285}
     
    249288{
    250289  molecules_deprecated->signOff(this);
     290  delete[] cell_size;
     291  delete[] defaultName;
    251292  delete molecules_deprecated;
    252293  delete periode;
  • src/World.hpp

    r13d5a9 r5f612ee  
    99#define WORLD_HPP_
    1010
     11/*********************************************** includes ***********************************/
     12
    1113#include <string>
    1214#include <map>
     
    2224#include "Patterns/Singleton.hpp"
    2325
     26// include config.h
     27#ifdef HAVE_CONFIG_H
     28#include <config.h>
     29#endif
    2430
    2531// forward declarations
     
    3642class AtomsCalculation;
    3743
    38 
     44/****************************************** forward declarations *****************************/
     45
     46/********************************************** Class World *******************************/
    3947
    4048class World : public Singleton<World>, public Observable
     
    107115  int numMolecules();
    108116
     117  /**
     118   * get the domain size as a symmetric matrix (6 components)
     119   */
     120  double * getDomain();
     121
     122  /**
     123   * set the domain size as a symmetric matrix (6 components)
     124   */
     125  void setDomain(double * matrix);
     126
     127  /**
     128   * get the default name
     129   */
     130  char * getDefaultName();
     131
     132  /**
     133   * set the default name
     134   */
     135  void setDefaultName(char * name);
     136
    109137  /***** Methods to work with the World *****/
    110138
     
    206234
    207235  periodentafel *periode;
     236  static double *cell_size;
     237  static char *defaultName;
    208238public:
    209239  AtomSet atoms;
  • src/analysis_bonds.cpp

    r13d5a9 r5f612ee  
    99#include "atom.hpp"
    1010#include "bond.hpp"
     11#include "element.hpp"
     12#include "info.hpp"
    1113#include "log.hpp"
    1214#include "molecule.hpp"
     
    3739  }
    3840  if (((int)Mean % 2) != 0)
    39     eLog() << Verbose(1) << "Something is wrong with the bond structure, the number of bonds is not even!" << endl;
     41    DoeLog(1) && (eLog()<< Verbose(1) << "Something is wrong with the bond structure, the number of bonds is not even!" << endl);
    4042  Mean /= (double)AtomCount;
    4143};
     
    7981  }
    8082};
     83
     84/** Calculate the angle between \a *first and \a *origin and \a *second and \a *origin.
     85 * \param *first first Vector
     86 * \param *origin origin of angle taking
     87 * \param *second second Vector
     88 * \return angle between \a *first and \a *second, both relative to origin at \a *origin.
     89 */
     90double CalculateAngle(Vector *first, Vector *central, Vector *second)
     91{
     92  Vector OHBond;
     93  Vector OOBond;
     94
     95  OHBond.CopyVector(first);
     96  OHBond.SubtractVector(central);
     97  OOBond.CopyVector(second);
     98  OOBond.SubtractVector(central);
     99  const double angle = OHBond.Angle(&OOBond);
     100  return angle;
     101};
     102
     103/** Checks whether the angle between \a *Oxygen and \a *Hydrogen and \a *Oxygen and \a *OtherOxygen is less than 30 degrees.
     104 * Note that distance criterion is not checked.
     105 * \param *Oxygen first oxygen atom, bonded to \a *Hydrogen
     106 * \param *Hydrogen hydrogen bonded to \a *Oxygen
     107 * \param *OtherOxygen other oxygen atom
     108 * \return true - angle criteria fulfilled, false - criteria not fulfilled, angle greater than 30 degrees.
     109 */
     110bool CheckHydrogenBridgeBondAngle(atom *Oxygen, atom *Hydrogen, atom *OtherOxygen)
     111{
     112  Info FunctionInfo(__func__);
     113
     114  // check angle
     115  if (CalculateAngle(&Hydrogen->x, &Oxygen->x, &OtherOxygen->x) < M_PI*(30./180.)) {
     116    return true;
     117  } else {
     118    return false;
     119  }
     120};
     121
     122/** Counts the number of hydrogen bridge bonds.
     123 * With \a *InterfaceElement an extra element can be specified that identifies some boundary.
     124 * Then, counting is for the h-bridges that connect to interface only.
     125 * \param *molecules molecules to count bonds
     126 * \param *InterfaceElement or NULL
     127 */
     128int CountHydrogenBridgeBonds(MoleculeListClass *molecules, element * InterfaceElement = NULL)
     129{
     130  atom *Walker = NULL;
     131  atom *Runner = NULL;
     132  int count = 0;
     133  int OtherHydrogens = 0;
     134  double Otherangle = 0.;
     135  bool InterfaceFlag = false;
     136  bool OtherHydrogenFlag = true;
     137  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) {
     138    Walker = (*MolWalker)->start;
     139    while (Walker->next != (*MolWalker)->end) {
     140      Walker = Walker->next;
     141      for (MoleculeList::const_iterator MolRunner = molecules->ListOfMolecules.begin();MolRunner != molecules->ListOfMolecules.end(); MolRunner++) {
     142        Runner = (*MolRunner)->start;
     143        while (Runner->next != (*MolRunner)->end) {
     144          Runner = Runner->next;
     145          if ((Walker->type->Z  == 8) && (Runner->type->Z  == 8)) {
     146            // check distance
     147            const double distance = Runner->x.DistanceSquared(&Walker->x);
     148            if ((distance > MYEPSILON) && (distance < HBRIDGEDISTANCE*HBRIDGEDISTANCE)) { // distance >0 means  different atoms
     149              // on other atom(Runner) we check for bond to interface element and
     150              // check that O-O line is not in between the shanks of the two connected hydrogens (Otherangle > 104.5)
     151              OtherHydrogenFlag = true;
     152              Otherangle = 0.;
     153              OtherHydrogens = 0;
     154              InterfaceFlag = (InterfaceElement == NULL);
     155              for (BondList::const_iterator BondRunner = Runner->ListOfBonds.begin(); BondRunner != Runner->ListOfBonds.end(); BondRunner++) {
     156                atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Runner);
     157                // if hydrogen, check angle to be greater(!) than 30 degrees
     158                if (OtherAtom->type->Z == 1) {
     159                  const double angle = CalculateAngle(&OtherAtom->x, &Runner->x, &Walker->x);
     160                  OtherHydrogenFlag = OtherHydrogenFlag && (angle > M_PI*(30./180.) + MYEPSILON);
     161                  Otherangle += angle;
     162                  OtherHydrogens++;
     163                }
     164                InterfaceFlag = InterfaceFlag || (OtherAtom->type == InterfaceElement);
     165              }
     166              DoLog(1) && (Log() << Verbose(1) << "Otherangle is " << Otherangle << " for " << OtherHydrogens << " hydrogens." << endl);
     167              switch (OtherHydrogens) {
     168                case 0:
     169                case 1:
     170                  break;
     171                case 2:
     172                  OtherHydrogenFlag = OtherHydrogenFlag && (Otherangle > M_PI*(104.5/180.) + MYEPSILON);
     173                  break;
     174                default: // 3 or more hydrogens ...
     175                  OtherHydrogenFlag = false;
     176                  break;
     177              }
     178              if (InterfaceFlag && OtherHydrogenFlag) {
     179                // on this element (Walker) we check for bond to hydrogen, i.e. part of water molecule
     180                for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) {
     181                  atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Walker);
     182                  if (OtherAtom->type->Z == 1) {
     183                    // check angle
     184                    if (CheckHydrogenBridgeBondAngle(Walker, OtherAtom, Runner)) {
     185                      DoLog(1) && (Log() << Verbose(1) << Walker->Name << ", " << OtherAtom->Name << " and " << Runner->Name << " has a hydrogen bridge bond with distance " << sqrt(distance) << " and angle " << CalculateAngle(&OtherAtom->x, &Walker->x, &Runner->x)*(180./M_PI) << "." << endl);
     186                      count++;
     187                      break;
     188                    }
     189                  }
     190                }
     191              }
     192            }
     193          }
     194        }
     195      }
     196    }
     197  }
     198  return count;
     199}
     200
     201/** Counts the number of bonds between two given elements.
     202 * \param *molecules list of molecules with all atoms
     203 * \param *first pointer to first element
     204 * \param *second pointer to second element
     205 * \return number of found bonds (\a *first-\a *second)
     206 */
     207int CountBondsOfTwo(MoleculeListClass * const molecules, const element * const first, const element * const second)
     208{
     209  atom *Walker = NULL;
     210  int count = 0;
     211
     212  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) {
     213    Walker = (*MolWalker)->start;
     214    while (Walker->next != (*MolWalker)->end) {
     215      Walker = Walker->next;
     216      if ((Walker->type == first) || (Walker->type == second)) {  // first element matches
     217        for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) {
     218          atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Walker);
     219          if (((OtherAtom->type == first) || (OtherAtom->type == second)) && (Walker->nr < OtherAtom->nr)) {
     220            count++;
     221            DoLog(1) && (Log() << Verbose(1) << first->name << "-" << second->name << " bond found between " << *Walker << " and " << *OtherAtom << "." << endl);
     222          }
     223        }
     224      }
     225    }
     226  }
     227  return count;
     228};
     229
     230/** Counts the number of bonds between three given elements.
     231 * Note that we do not look for arbitrary sequence of given bonds, but \a *second will be the central atom and we check
     232 * whether it has bonds to both \a *first and \a *third.
     233 * \param *molecules list of molecules with all atoms
     234 * \param *first pointer to first element
     235 * \param *second pointer to second element
     236 * \param *third pointer to third element
     237 * \return number of found bonds (\a *first-\a *second-\a *third, \a *third-\a *second-\a *first, respectively)
     238 */
     239int CountBondsOfThree(MoleculeListClass * const molecules, const element * const first, const element * const second, const element * const third)
     240{
     241  int count = 0;
     242  bool MatchFlag[2];
     243  bool result = false;
     244  atom *Walker = NULL;
     245  const element * ElementArray[2];
     246  ElementArray[0] = first;
     247  ElementArray[1] = third;
     248
     249  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin();MolWalker != molecules->ListOfMolecules.end(); MolWalker++) {
     250    Walker = (*MolWalker)->start;
     251    while (Walker->next != (*MolWalker)->end) {
     252      Walker = Walker->next;
     253      if (Walker->type == second) {  // first element matches
     254        for (int i=0;i<2;i++)
     255          MatchFlag[i] = false;
     256        for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++) {
     257          atom * const OtherAtom = (*BondRunner)->GetOtherAtom(Walker);
     258          for (int i=0;i<2;i++)
     259            if ((!MatchFlag[i]) && (OtherAtom->type == ElementArray[i])) {
     260              MatchFlag[i] = true;
     261              break;  // each bonding atom can match at most one element we are looking for
     262            }
     263        }
     264        result = true;
     265        for (int i=0;i<2;i++) // gather results
     266          result = result && MatchFlag[i];
     267        if (result) { // check results
     268          count++;
     269          DoLog(1) && (Log() << Verbose(1) << first->name << "-" << second->name << "-" << third->name << " bond found at " << *Walker << "." << endl);
     270        }
     271      }
     272    }
     273  }
     274  return count;
     275};
  • src/analysis_bonds.hpp

    r13d5a9 r5f612ee  
    1818#endif
    1919
     20/*********************************************** defines ***********************************/
     21
     22#define HBRIDGEDISTANCE 3.5   //!< HBridge distance from PCCP Vol 10. 4802-4813
    2023
    2124/****************************************** forward declarations *****************************/
    2225
    2326class element;
     27class MoleculeListClass;
    2428class molecule;
    2529
     
    2933void MinMeanMaxBondDistanceBetweenElements(const molecule *mol, element *type1, element *type2, double &Min, double &Mean, double &Max);
    3034
     35int CountHydrogenBridgeBonds(MoleculeListClass * const molecules, element * InterfaceElement);
     36int CountBondsOfTwo(MoleculeListClass * const molecules, const element * const first, const element * const second);
     37int CountBondsOfThree(MoleculeListClass * const molecules, const element * const first, const element * const second, const element * const third);
     38
    3139#endif /* ANALYSIS_BONDS_HPP_ */
  • src/analysis_correlation.cpp

    r13d5a9 r5f612ee  
    1515#include "tesselation.hpp"
    1616#include "tesselationhelpers.hpp"
     17#include "triangleintersectionlist.hpp"
    1718#include "vector.hpp"
    1819#include "verbose.hpp"
     20#include "World.hpp"
    1921
    2022
     
    3436
    3537  if (molecules->ListOfMolecules.empty()) {
    36     eLog() << Verbose(1) <<"No molecule given." << endl;
     38    DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl);
    3739    return outmap;
    3840  }
     
    4042  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    4143    if ((*MolWalker)->ActiveFlag) {
    42       eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    43       atom *Walker = (*MolWalker)->start;
    44       while (Walker->next != (*MolWalker)->end) {
    45         Walker = Walker->next;
    46         Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
     44      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);
    4749        if ((type1 == NULL) || (Walker->type == type1)) {
    4850          for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++)
    4951            if ((*MolOtherWalker)->ActiveFlag) {
    50               Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl;
     52              DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
    5153              atom *OtherWalker = (*MolOtherWalker)->start;
    5254              while (OtherWalker->next != (*MolOtherWalker)->end) { // only go up to Walker
    5355                OtherWalker = OtherWalker->next;
    54                 Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl;
     56                DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl);
    5557                if (Walker->nr < OtherWalker->nr)
    5658                  if ((type2 == NULL) || (OtherWalker->type == type2)) {
    57                     distance = Walker->node->PeriodicDistance(OtherWalker->node, (*MolWalker)->cell_size);
     59                    distance = Walker->node->PeriodicDistance(OtherWalker->node, World::getInstance().getDomain());
    5860                    //Log() << Verbose(1) <<"Inserting " << *Walker << " and " << *OtherWalker << endl;
    5961                    outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> (Walker, OtherWalker) ) );
     
    9092
    9193  if (molecules->ListOfMolecules.empty()) {
    92     eLog() << Verbose(1) <<"No molecule given." << endl;
     94    DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl);
    9395    return outmap;
    9496  }
     
    9698  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    9799    if ((*MolWalker)->ActiveFlag) {
    98       double * FullMatrix = ReturnFullMatrixforSymmetric((*MolWalker)->cell_size);
     100      double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain());
    99101      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    100       eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    101       atom *Walker = (*MolWalker)->start;
    102       while (Walker->next != (*MolWalker)->end) {
    103         Walker = Walker->next;
    104         Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
     102      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);
    105107        if ((type1 == NULL) || (Walker->type == type1)) {
    106108          periodicX.CopyVector(Walker->node);
     
    115117                for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++)
    116118                  if ((*MolOtherWalker)->ActiveFlag) {
    117                     Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl;
     119                    DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
    118120                    atom *OtherWalker = (*MolOtherWalker)->start;
    119121                    while (OtherWalker->next != (*MolOtherWalker)->end) { // only go up to Walker
    120122                      OtherWalker = OtherWalker->next;
    121                       Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl;
     123                      DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl);
    122124                      if (Walker->nr < OtherWalker->nr)
    123125                        if ((type2 == NULL) || (OtherWalker->type == type2)) {
     
    162164
    163165  if (molecules->ListOfMolecules.empty()) {
    164     Log() << Verbose(1) <<"No molecule given." << endl;
     166    DoLog(1) && (Log() << Verbose(1) <<"No molecule given." << endl);
    165167    return outmap;
    166168  }
     
    168170  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    169171    if ((*MolWalker)->ActiveFlag) {
    170       Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    171       atom *Walker = (*MolWalker)->start;
    172       while (Walker->next != (*MolWalker)->end) {
    173         Walker = Walker->next;
    174         Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
     172      DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
     173      atom *Walker = (*MolWalker)->start;
     174      while (Walker->next != (*MolWalker)->end) {
     175        Walker = Walker->next;
     176        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);
    175177        if ((type == NULL) || (Walker->type == type)) {
    176           distance = Walker->node->PeriodicDistance(point, (*MolWalker)->cell_size);
    177           Log() << Verbose(4) << "Current distance is " << distance << "." << endl;
     178          distance = Walker->node->PeriodicDistance(point, World::getInstance().getDomain());
     179          DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
    178180          outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) );
    179181        }
     
    202204
    203205  if (molecules->ListOfMolecules.empty()) {
    204     Log() << Verbose(1) <<"No molecule given." << endl;
     206    DoLog(1) && (Log() << Verbose(1) <<"No molecule given." << endl);
    205207    return outmap;
    206208  }
     
    208210  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    209211    if ((*MolWalker)->ActiveFlag) {
    210       double * FullMatrix = ReturnFullMatrixforSymmetric((*MolWalker)->cell_size);
     212      double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain());
    211213      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    212       Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    213       atom *Walker = (*MolWalker)->start;
    214       while (Walker->next != (*MolWalker)->end) {
    215         Walker = Walker->next;
    216         Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
     214      DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
     215      atom *Walker = (*MolWalker)->start;
     216      while (Walker->next != (*MolWalker)->end) {
     217        Walker = Walker->next;
     218        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);
    217219        if ((type == NULL) || (Walker->type == type)) {
    218220          periodicX.CopyVector(Walker->node);
     
    226228                checkX.MatrixMultiplication(FullMatrix);
    227229                distance = checkX.Distance(point);
    228                 Log() << Verbose(4) << "Current distance is " << distance << "." << endl;
     230                DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
    229231                outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) );
    230232              }
     
    255257
    256258  if ((Surface == NULL) || (LC == NULL) || (molecules->ListOfMolecules.empty())) {
    257     Log() << Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl;
     259    DoeLog(1) && (eLog()<< Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl);
    258260    return outmap;
    259261  }
     
    261263  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    262264    if ((*MolWalker)->ActiveFlag) {
    263       Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    264       atom *Walker = (*MolWalker)->start;
    265       while (Walker->next != (*MolWalker)->end) {
    266         Walker = Walker->next;
    267         Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
     265      DoLog(1) && (Log() << Verbose(1) << "Current molecule is " << (*MolWalker)->name << "." << endl);
     266      atom *Walker = (*MolWalker)->start;
     267      while (Walker->next != (*MolWalker)->end) {
     268        Walker = Walker->next;
     269        //Log() << Verbose(1) << "Current atom is " << *Walker << "." << endl;
    268270        if ((type == NULL) || (Walker->type == type)) {
    269           triangle = Surface->FindClosestTriangleToVector(Walker->node, LC );
    270           if (triangle != NULL) {
    271             distance = DistanceToTrianglePlane(Walker->node, triangle);
    272             outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> (Walker, triangle) ) );
    273           }
    274         }
    275       }
    276     }
     271          TriangleIntersectionList Intersections(Walker->node,Surface,LC);
     272          distance = Intersections.GetSmallestDistance();
     273          triangle = Intersections.GetClosestTriangle();
     274          outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> (Walker, triangle) ) );
     275        }
     276      }
     277    } else
     278      DoLog(1) && (Log() << Verbose(1) << "molecule " << (*MolWalker)->name << " is not active." << endl);
    277279
    278280  return outmap;
     
    304306
    305307  if ((Surface == NULL) || (LC == NULL) || (molecules->ListOfMolecules.empty())) {
    306     Log() << Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl;
     308    DoLog(1) && (Log() << Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl);
    307309    return outmap;
    308310  }
     
    312314  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    313315    if ((*MolWalker)->ActiveFlag) {
    314       double * FullMatrix = ReturnFullMatrixforSymmetric((*MolWalker)->cell_size);
     316      double * FullMatrix = ReturnFullMatrixforSymmetric(World::getInstance().getDomain());
    315317      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    316       Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    317       atom *Walker = (*MolWalker)->start;
    318       while (Walker->next != (*MolWalker)->end) {
    319         Walker = Walker->next;
    320         Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
     318      DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
     319      atom *Walker = (*MolWalker)->start;
     320      while (Walker->next != (*MolWalker)->end) {
     321        Walker = Walker->next;
     322        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);
    321323        if ((type == NULL) || (Walker->type == type)) {
    322324          periodicX.CopyVector(Walker->node);
     
    330332                checkX.AddVector(&periodicX);
    331333                checkX.MatrixMultiplication(FullMatrix);
    332                 triangle = Surface->FindClosestTriangleToVector(&checkX, LC);
    333                 distance = Surface->GetDistanceSquaredToTriangle(checkX, triangle);
     334                TriangleIntersectionList Intersections(&checkX,Surface,LC);
     335                distance = Intersections.GetSmallestDistance();
     336                triangle = Intersections.GetClosestTriangle();
    334337                if ((ShortestDistance == -1.) || (distance < ShortestDistance)) {
    335338                  ShortestDistance = distance;
     
    338341              }
    339342          // insert
    340           ShortestDistance = sqrt(ShortestDistance);
    341343          outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (Walker, ShortestTriangle) ) );
    342344          //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl;
     
    350352};
    351353
    352 /** Returns the start of the bin for a given value.
     354/** Returns the index of the bin for a given value.
    353355 * \param value value whose bin to look for
    354356 * \param BinWidth width of bin
    355357 * \param BinStart first bin
    356358 */
    357 double GetBin ( const double value, const double BinWidth, const double BinStart )
    358 {
    359   Info FunctionInfo(__func__);
    360   double bin =(double) (floor((value - BinStart)/BinWidth));
    361   return (bin*BinWidth+BinStart);
     359int GetBin ( const double value, const double BinWidth, const double BinStart )
     360{
     361  Info FunctionInfo(__func__);
     362  int bin =(int) (floor((value - BinStart)/BinWidth));
     363  return (bin);
    362364};
    363365
     
    372374  *file << "BinStart\tCount" << endl;
    373375  for (BinPairMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
    374     *file << runner->first << "\t" << runner->second << endl;
     376    *file << setprecision(8) << runner->first << "\t" << runner->second << endl;
    375377  }
    376378};
     
    385387  *file << "BinStart\tAtom1\tAtom2" << endl;
    386388  for (PairCorrelationMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
    387     *file << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl;
     389    *file << setprecision(8) << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl;
    388390  }
    389391};
     
    400402    *file << runner->first;
    401403    for (int i=0;i<NDIM;i++)
    402       *file << "\t" << (runner->second.first->node->x[i] - runner->second.second->x[i]);
     404      *file << "\t" << setprecision(8) << (runner->second.first->node->x[i] - runner->second.second->x[i]);
    403405    *file << endl;
    404406  }
     
    413415  Info FunctionInfo(__func__);
    414416  *file << "BinStart\tTriangle" << endl;
    415   for (CorrelationToSurfaceMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
    416     *file << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl;
    417   }
    418 };
    419 
     417  if (!map->empty())
     418    for (CorrelationToSurfaceMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
     419      *file << setprecision(8) << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl;
     420    }
     421};
     422
  • src/analysis_correlation.hpp

    r13d5a9 r5f612ee  
    5151CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point, const int ranges[NDIM] );
    5252CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] );
    53 double GetBin ( const double value, const double BinWidth, const double BinStart );
     53int GetBin ( const double value, const double BinWidth, const double BinStart );
    5454void OutputCorrelation( ofstream * const file, const BinPairMap * const map );
    5555void OutputPairCorrelation( ofstream * const file, const PairCorrelationMap * const map );
     
    7171
    7272  if (map == NULL) {
    73     eLog() << Verbose(0) << "Nothing to min/max, map is NULL!" << endl;
     73    DoeLog(0) && (eLog()<< Verbose(0) << "Nothing to min/max, map is NULL!" << endl);
    7474    performCriticalExit();
    7575    return;
     
    103103{
    104104  BinPairMap *outmap = new BinPairMap;
    105   double bin = 0.;
     105  int bin = 0;
    106106  double start = 0.;
    107107  double end = 0.;
     
    109109
    110110  if (map == NULL) {
    111     eLog() << Verbose(0) << "Nothing to bin, is NULL!" << endl;
     111    DoeLog(0) && (eLog()<< Verbose(0) << "Nothing to bin, is NULL!" << endl);
    112112    performCriticalExit();
    113113    return outmap;
     
    122122    start = BinStart;
    123123    end = BinEnd;
    124     for (double runner = start; runner <= end; runner += BinWidth)
    125       outmap->insert( pair<double, int> (runner, 0) );
    126124  }
     125  for (int runner = 0; runner <= ceil((end-start)/BinWidth); runner++)
     126    outmap->insert( pair<double, int> ((double)runner*BinWidth+start, 0) );
    127127
    128128  for (typename T::iterator runner = map->begin(); runner != map->end(); ++runner) {
    129129    bin = GetBin (runner->first, BinWidth, start);
    130     BinPairMapInserter = outmap->insert ( pair<double, int> (bin, 1) );
     130    BinPairMapInserter = outmap->insert ( pair<double, int> ((double)bin*BinWidth+start, 1) );
    131131    if (!BinPairMapInserter.second) {  // bin already present, increase
    132132      BinPairMapInserter.first->second += 1;
  • src/analyzer.cpp

    r13d5a9 r5f612ee  
    6363  int counter = 0;
    6464
    65   Log() << Verbose(0) << "ANOVA Analyzer" << endl;
    66   Log() << Verbose(0) << "==============" << endl;
     65  DoLog(0) && (Log() << Verbose(0) << "ANOVA Analyzer" << endl);
     66  DoLog(0) && (Log() << Verbose(0) << "==============" << endl);
    6767
    6868  // Get the command line options
    6969  if (argc < 4) {
    70     Log() << Verbose(0) << "Usage: " << argv[0] << " <inputdir> <prefix> <outputdir> [elementsdb]" << endl;
    71     Log() << Verbose(0) << "<inputdir>\ttherein the output of a molecuilder fragmentation is expected, each fragment with a subdir containing an energy.all and a forces.all file." << endl;
    72     Log() << Verbose(0) << "<prefix>\tprefix of energy and forces file." << endl;
    73     Log() << Verbose(0) << "<outputdir>\tcreated plotfiles and datafiles are placed into this directory " << endl;
    74     Log() << Verbose(0) << "[elementsdb]\tpath to elements database, needed for shieldings." << endl;
     70    DoLog(0) && (Log() << Verbose(0) << "Usage: " << argv[0] << " <inputdir> <prefix> <outputdir> [elementsdb]" << endl);
     71    DoLog(0) && (Log() << Verbose(0) << "<inputdir>\ttherein the output of a molecuilder fragmentation is expected, each fragment with a subdir containing an energy.all and a forces.all file." << endl);
     72    DoLog(0) && (Log() << Verbose(0) << "<prefix>\tprefix of energy and forces file." << endl);
     73    DoLog(0) && (Log() << Verbose(0) << "<outputdir>\tcreated plotfiles and datafiles are placed into this directory " << endl);
     74    DoLog(0) && (Log() << Verbose(0) << "[elementsdb]\tpath to elements database, needed for shieldings." << endl);
    7575    return 1;
    7676  } else {
     
    8181
    8282  if (argc > 4) {
    83     Log() << Verbose(0) << "Loading periodentafel." << endl;
     83    DoLog(0) && (Log() << Verbose(0) << "Loading periodentafel." << endl);
    8484    periode = Malloc<periodentafel>(1, "main - periode");
    8585    periode->LoadPeriodentafel(argv[4]);
     
    9696  if (!Hcorrection.ParseFragmentMatrix(argv[1], "", HCORRECTIONSUFFIX,0,0)) {
    9797    NoHCorrection = true;
    98     eLog() << Verbose(2) << "No HCorrection file found, skipping these." << endl;
     98    DoeLog(2) && (eLog()<< Verbose(2) << "No HCorrection file found, skipping these." << endl);
    9999  }
    100100 
     
    102102  if (!Hessian.ParseFragmentMatrix(argv[1], dir, HessianSuffix,0,0)) {
    103103    NoHessian = true;
    104     eLog() << Verbose(2) << "No Hessian file found, skipping these." << endl;
     104    DoeLog(2) && (eLog()<< Verbose(2) << "No Hessian file found, skipping these." << endl);
    105105  }
    106106  if (!Time.ParseFragmentMatrix(argv[1], dir, TimeSuffix, 10,1)) {
    107107    NoTime = true;
    108     eLog() << Verbose(2) << "No speed file found, skipping these." << endl;
     108    DoeLog(2) && (eLog()<< Verbose(2) << "No speed file found, skipping these." << endl);
    109109  }
    110110  if (periode != NULL) { // also look for PAS values
     
    248248  // +++++++++++++++ ANALYZING ++++++++++++++++++++++++++++++
    249249
    250   Log() << Verbose(0) << "Analyzing ..." << endl;
     250  DoLog(0) && (Log() << Verbose(0) << "Analyzing ..." << endl);
    251251
    252252  // ======================================= Creating the data files ==============================================================
     
    559559  delete(periode);
    560560  Free(&dir);
    561   Log() << Verbose(0) << "done." << endl;
     561  DoLog(0) && (Log() << Verbose(0) << "done." << endl);
    562562  return 0;
    563563};
  • src/atom.cpp

    r13d5a9 r5f612ee  
    4444  res->next=0;
    4545  res->father = this;
    46   res->sort = &nr;
     46  res->sort = &res->nr;
    4747  res->type = type;
    4848  res->x.CopyVector(&this->x);
  • src/atom_bondedparticle.cpp

    r13d5a9 r5f612ee  
    4444void BondedParticle::OutputBondOfAtom() const
    4545{
    46   Log() << Verbose(4) << "Atom " << Name << "/" << nr << " with " << ListOfBonds.size() << " bonds: " << endl;
     46  DoLog(4) && (Log() << Verbose(4) << "Atom " << Name << "/" << nr << " with " << ListOfBonds.size() << " bonds: " << endl);
    4747  int TotalDegree = 0;
    4848  for (BondList::const_iterator Runner = ListOfBonds.begin(); Runner != ListOfBonds.end(); ++Runner) {
    49     Log() << Verbose(4) << **Runner << endl;
     49    DoLog(4) && (Log() << Verbose(4) << **Runner << endl);
    5050    TotalDegree += (*Runner)->BondDegree;
    5151  }
    52   Log() << Verbose(4) << " -- TotalDegree: " << TotalDegree << endl;
     52  DoLog(4) && (Log() << Verbose(4) << " -- TotalDegree: " << TotalDegree << endl);
    5353};
    5454
     
    8686      status = true;
    8787    } else {
    88       eLog() << Verbose(1) << *Binder << " does not contain " << *this << "." << endl;
     88      DoeLog(1) && (eLog()<< Verbose(1) << *Binder << " does not contain " << *this << "." << endl);
    8989    }
    9090  } else {
    91     eLog() << Verbose(1) << "Binder is " << Binder << "." << endl;
     91    DoeLog(1) && (eLog()<< Verbose(1) << "Binder is " << Binder << "." << endl);
    9292  }
    9393  return status;
     
    105105      status = true;
    106106    } else {
    107       eLog() << Verbose(1) << *Binder << " does not contain " << *this << "." << endl;
     107      DoeLog(1) && (eLog()<< Verbose(1) << *Binder << " does not contain " << *this << "." << endl);
    108108    }
    109109  } else {
    110     eLog() << Verbose(1) << "Binder is " << Binder << "." << endl;
     110    DoeLog(1) && (eLog()<< Verbose(1) << "Binder is " << Binder << "." << endl);
    111111  }
    112112  return status;
     
    150150      //Log() << Verbose(2) << "Increased bond degree for bond " << *CandidateBond << "." << endl;
    151151    } else {
    152       eLog() << Verbose(2) << "Could not find correct degree for atom " << *this << "." << endl;
     152      DoeLog(2) && (eLog()<< Verbose(2) << "Could not find correct degree for atom " << *this << "." << endl);
    153153      FalseBondDegree++;
    154154    }
  • src/atom_graphnode.cpp

    r13d5a9 r5f612ee  
    2727void GraphNode::OutputGraphInfo() const
    2828{
    29   Log() << Verbose(2) << "Atom " << Name << " is " << ((SeparationVertex) ? "a" : "not a") << " separation vertex, components are ";
     29  DoLog(2) && (Log() << Verbose(2) << "Atom " << Name << " is " << ((SeparationVertex) ? "a" : "not a") << " separation vertex, components are ");
    3030  OutputComponentNumber();
    31   Log() << Verbose(3) << " with Lowpoint " << LowpointNr << " and Graph Nr. " << GraphNr << "." << endl;
     31  DoLog(3) && (Log() << Verbose(3) << " with Lowpoint " << LowpointNr << " and Graph Nr. " << GraphNr << "." << endl);
    3232};
    3333
     
    4040  if (ComponentNr != NULL) {
    4141    for (int i=0; ComponentNr[i] != -1; i++)
    42       Log() << Verbose(2) << ComponentNr[i] << " ";
     42      DoLog(2) && (Log() << Verbose(2) << ComponentNr[i] << " ");
    4343  }
    4444};
  • src/atom_particleinfo.cpp

    r13d5a9 r5f612ee  
    2828ostream & operator << (ostream &ost, const ParticleInfo &a)
    2929{
    30   ost << "[" << a.Name << "|" << &a << "]";
     30  if (a.Name == NULL)
     31    ost << "[NULL]";
     32  else
     33    ost << "[" << a.Name << "|" << &a << "]";
    3134  return ost;
    3235};
     
    3437ostream & ParticleInfo::operator << (ostream &ost) const
    3538{
    36   ost << "[" << Name << "|" << this << "]";
     39  if (Name == NULL)
     40    ost << "[NULL]";
     41  else
     42    ost << "[" << Name << "|" << this << "]";
    3743  return ost;
    3844};
  • src/atom_trajectoryparticle.cpp

    r13d5a9 r5f612ee  
    198198    // throw a dice to determine whether it gets hit by a heat bath particle
    199199    if (((((rand()/(double)RAND_MAX))*configuration->TempFrequency) < 1.)) {
    200       Log() << Verbose(3) << "Particle " << *this << " was hit (sigma " << sigma << "): " << sqrt(U[0]*U[0]+U[1]*U[1]+U[2]*U[2]) << " -> ";
     200      DoLog(3) && (Log() << Verbose(3) << "Particle " << *this << " was hit (sigma " << sigma << "): " << sqrt(U[0]*U[0]+U[1]*U[1]+U[2]*U[2]) << " -> ");
    201201      // pick three random numbers from a Boltzmann distribution around the desired temperature T for each momenta axis
    202202      for (int d=0; d<NDIM; d++) {
    203203        U[d] = gsl_ran_gaussian (r, sigma);
    204204      }
    205       Log() << Verbose(2) << sqrt(U[0]*U[0]+U[1]*U[1]+U[2]*U[2]) << endl;
     205      DoLog(2) && (Log() << Verbose(2) << sqrt(U[0]*U[0]+U[1]*U[1]+U[2]*U[2]) << endl);
    206206    }
    207207    for (int d=0; d<NDIM; d++)
  • src/bond.cpp

    r13d5a9 r5f612ee  
    6363  if(rightatom == Atom)
    6464    return leftatom;
    65   eLog() << Verbose(1) << "Bond " << *this << " does not contain atom " << *Atom << "!" << endl;
     65  DoeLog(1) && (eLog()<< Verbose(1) << "Bond " << *this << " does not contain atom " << *Atom << "!" << endl);
    6666  return NULL;
    6767};
     
    9999bool bond::MarkUsed(const enum Shading color) {
    100100  if (Used == black) {
    101     eLog() << Verbose(1) << "Bond " << this << " was already marked black!." << endl;
     101    DoeLog(1) && (eLog()<< Verbose(1) << "Bond " << this << " was already marked black!." << endl);
    102102    return false;
    103103  } else {
  • src/bondgraph.cpp

    r13d5a9 r5f612ee  
    99
    1010#include "atom.hpp"
     11#include "bond.hpp"
    1112#include "bondgraph.hpp"
    1213#include "element.hpp"
     
    4950  // allocate MatrixContainer
    5051  if (BondLengthMatrix != NULL) {
    51     Log() << Verbose(1) << "MatrixContainer for Bond length already present, removing." << endl;
     52    DoLog(1) && (Log() << Verbose(1) << "MatrixContainer for Bond length already present, removing." << endl);
    5253    delete(BondLengthMatrix);
    5354  }
     
    5556
    5657  // parse in matrix
    57   if (status = TempContainer->ParseMatrix(filename.c_str(), 0, 1, 0)) {
    58     Log() << Verbose(1) << "Parsing bond length matrix successful." << endl;
     58  if ((status = TempContainer->ParseMatrix(filename.c_str(), 0, 1, 0))) {
     59    DoLog(1) && (Log() << Verbose(1) << "Parsing bond length matrix successful." << endl);
    5960  } else {
    60     eLog() << Verbose(1) << "Parsing bond length matrix failed." << endl;
     61    DoeLog(1) && (eLog()<< Verbose(1) << "Parsing bond length matrix failed." << endl);
    6162  }
    6263
     
    8687bool BondGraph::ConstructBondGraph(molecule * const mol)
    8788{
    88   bool status = true;
     89  Info FunctionInfo(__func__);
     90bool status = true;
    8991
    9092  if (mol->start->next == mol->end) // only construct if molecule is not empty
     
    119121double BondGraph::SetMaxDistanceToMaxOfCovalentRadii(const molecule * const mol)
    120122{
     123  Info FunctionInfo(__func__);
    121124  max_distance = 0.;
    122125
     
    159162{
    160163  if (BondLengthMatrix == NULL) {// safety measure if no matrix has been parsed yet
    161     eLog() << Verbose(2) << "BondLengthMatrixMinMaxDistance() called without having parsed the bond length matrix yet!" << endl;
     164    DoeLog(2) && (eLog()<< Verbose(2) << "BondLengthMatrixMinMaxDistance() called without having parsed the bond length matrix yet!" << endl);
    162165    CovalentMinMaxDistance(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem);
    163166  } else {
     
    168171  }
    169172};
    170 
  • src/bondgraph.hpp

    r13d5a9 r5f612ee  
    1919
    2020#include <iostream>
     21
     22/*********************************************** defines ***********************************/
     23
     24#define BONDTHRESHOLD 0.4   //!< CSD threshold in bond check which is the width of the interval whose center is the sum of the covalent radii
    2125
    2226/****************************************** forward declarations *****************************/
  • src/boundary.cpp

    • Property mode changed from 100755 to 100644
    r13d5a9 r5f612ee  
    1818#include "tesselation.hpp"
    1919#include "tesselationhelpers.hpp"
     20#include "World.hpp"
    2021
    2122#include<gsl/gsl_poly.h>
     
    5758  } else {
    5859    BoundaryPoints = BoundaryPtr;
    59     Log() << Verbose(0) << "Using given boundary points set." << endl;
     60    DoLog(0) && (Log() << Verbose(0) << "Using given boundary points set." << endl);
    6061  }
    6162  // determine biggest "diameter" of cluster for each axis
     
    163164    AngleReferenceNormalVector.x[(axis + 2) % NDIM] = 1.;
    164165
    165     Log() << Verbose(1) << "Axisvector is " << AxisVector << " and AngleReferenceVector is " << AngleReferenceVector << ", and AngleReferenceNormalVector is " << AngleReferenceNormalVector << "." << endl;
     166    DoLog(1) && (Log() << Verbose(1) << "Axisvector is " << AxisVector << " and AngleReferenceVector is " << AngleReferenceVector << ", and AngleReferenceNormalVector is " << AngleReferenceNormalVector << "." << endl);
    166167
    167168    // 3b. construct set of all points, transformed into cylindrical system and with left and right neighbours
     
    184185        angle = 2. * M_PI - angle;
    185186      }
    186       Log() << Verbose(1) << "Inserting " << *Walker << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl;
     187      DoLog(1) && (Log() << Verbose(1) << "Inserting " << *Walker << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl);
    187188      BoundaryTestPair = BoundaryPoints[axis].insert(BoundariesPair(angle, DistancePair (radius, Walker)));
    188189      if (!BoundaryTestPair.second) { // same point exists, check first r, then distance of original vectors to center of gravity
    189         Log() << Verbose(2) << "Encountered two vectors whose projection onto axis " << axis << " is equal: " << endl;
    190         Log() << Verbose(2) << "Present vector: " << *BoundaryTestPair.first->second.second << endl;
    191         Log() << Verbose(2) << "New vector: " << *Walker << endl;
     190        DoLog(2) && (Log() << Verbose(2) << "Encountered two vectors whose projection onto axis " << axis << " is equal: " << endl);
     191        DoLog(2) && (Log() << Verbose(2) << "Present vector: " << *BoundaryTestPair.first->second.second << endl);
     192        DoLog(2) && (Log() << Verbose(2) << "New vector: " << *Walker << endl);
    192193        const double ProjectedVectorNorm = ProjectedVector.NormSquared();
    193194        if ((ProjectedVectorNorm - BoundaryTestPair.first->second.first) > MYEPSILON) {
    194195          BoundaryTestPair.first->second.first = ProjectedVectorNorm;
    195196          BoundaryTestPair.first->second.second = Walker;
    196           Log() << Verbose(2) << "Keeping new vector due to larger projected distance " << ProjectedVectorNorm << "." << endl;
     197          DoLog(2) && (Log() << Verbose(2) << "Keeping new vector due to larger projected distance " << ProjectedVectorNorm << "." << endl);
    197198        } else if (fabs(ProjectedVectorNorm - BoundaryTestPair.first->second.first) < MYEPSILON) {
    198199          helper.CopyVector(&Walker->x);
     
    203204          if (helper.NormSquared() < oldhelperNorm) {
    204205            BoundaryTestPair.first->second.second = Walker;
    205             Log() << Verbose(2) << "Keeping new vector due to larger distance to molecule center " << helper.NormSquared() << "." << endl;
     206            DoLog(2) && (Log() << Verbose(2) << "Keeping new vector due to larger distance to molecule center " << helper.NormSquared() << "." << endl);
    206207          } else {
    207             Log() << Verbose(2) << "Keeping present vector due to larger distance to molecule center " << oldhelperNorm << "." << endl;
     208            DoLog(2) && (Log() << Verbose(2) << "Keeping present vector due to larger distance to molecule center " << oldhelperNorm << "." << endl);
    208209          }
    209210        } else {
    210           Log() << Verbose(2) << "Keeping present vector due to larger projected distance " << ProjectedVectorNorm << "." << endl;
     211          DoLog(2) && (Log() << Verbose(2) << "Keeping present vector due to larger projected distance " << ProjectedVectorNorm << "." << endl);
    211212        }
    212213      }
     
    227228    // 3c. throw out points whose distance is less than the mean of left and right neighbours
    228229    bool flag = false;
    229     Log() << Verbose(1) << "Looking for candidates to kick out by convex condition ... " << endl;
     230    DoLog(1) && (Log() << Verbose(1) << "Looking for candidates to kick out by convex condition ... " << endl);
    230231    do { // do as long as we still throw one out per round
    231232      flag = false;
     
    282283          const double MinDistance = a * sin(beta) / (sin(delta)) * (((alpha < M_PI / 2.) || (gamma < M_PI / 2.)) ? 1. : -1.);
    283284          //Log() << Verbose(1) << " I calculated: a = " << a << ", h = " << h << ", beta(" << left->second.second->Name << "," << left->second.second->Name << "-" << right->second.second->Name << ") = " << beta << ", delta(" << left->second.second->Name << "," << runner->second.second->Name << ") = " << delta << ", Min = " << MinDistance << "." << endl;
    284           Log() << Verbose(1) << "Checking CoG distance of runner " << *runner->second.second << " " << h << " against triangle's side length spanned by (" << *left->second.second << "," << *right->second.second << ") of " << MinDistance << "." << endl;
     285          DoLog(1) && (Log() << Verbose(1) << "Checking CoG distance of runner " << *runner->second.second << " " << h << " against triangle's side length spanned by (" << *left->second.second << "," << *right->second.second << ") of " << MinDistance << "." << endl);
    285286          if ((fabs(h / fabs(h) - MinDistance / fabs(MinDistance)) < MYEPSILON) && ((h - MinDistance)) < -MYEPSILON) {
    286287            // throw out point
    287             Log() << Verbose(1) << "Throwing out " << *runner->second.second << "." << endl;
     288            DoLog(1) && (Log() << Verbose(1) << "Throwing out " << *runner->second.second << "." << endl);
    288289            BoundaryPoints[axis].erase(runner);
    289290            flag = true;
     
    320321      BoundaryPoints = GetBoundaryPoints(mol, TesselStruct);
    321322  } else {
    322       Log() << Verbose(0) << "Using given boundary points set." << endl;
     323      DoLog(0) && (Log() << Verbose(0) << "Using given boundary points set." << endl);
    323324  }
    324325
     
    326327  for (int axis=0; axis < NDIM; axis++)
    327328    {
    328       Log() << Verbose(1) << "Printing list of candidates for axis " << axis << " which we have inserted so far." << endl;
     329      DoLog(1) && (Log() << Verbose(1) << "Printing list of candidates for axis " << axis << " which we have inserted so far." << endl);
    329330      int i=0;
    330331      for(Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) {
    331332        if (runner != BoundaryPoints[axis].begin())
    332           Log() << Verbose(0) << ", " << i << ": " << *runner->second.second;
     333          DoLog(0) && (Log() << Verbose(0) << ", " << i << ": " << *runner->second.second);
    333334        else
    334           Log() << Verbose(0) << i << ": " << *runner->second.second;
     335          DoLog(0) && (Log() << Verbose(0) << i << ": " << *runner->second.second);
    335336        i++;
    336337      }
    337       Log() << Verbose(0) << endl;
     338      DoLog(0) && (Log() << Verbose(0) << endl);
    338339    }
    339340
     
    342343    for (Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++)
    343344        if (!TesselStruct->AddBoundaryPoint(runner->second.second, 0))
    344           eLog() << Verbose(2) << "Point " << *(runner->second.second) << " is already present!" << endl;
    345 
    346   Log() << Verbose(0) << "I found " << TesselStruct->PointsOnBoundaryCount << " points on the convex boundary." << endl;
     345          DoeLog(2) && (eLog()<< Verbose(2) << "Point " << *(runner->second.second) << " is already present!" << endl);
     346
     347  DoLog(0) && (Log() << Verbose(0) << "I found " << TesselStruct->PointsOnBoundaryCount << " points on the convex boundary." << endl);
    347348  // now we have the whole set of edge points in the BoundaryList
    348349
     
    362363  // 3c. check whether all atoms lay inside the boundary, if not, add to boundary points, segment triangle into three with the new point
    363364  if (!TesselStruct->InsertStraddlingPoints(mol, LCList))
    364     eLog() << Verbose(1) << "Insertion of straddling points failed!" << endl;
    365 
    366   Log() << Verbose(0) << "I created " << TesselStruct->TrianglesOnBoundary.size() << " intermediate triangles with " << TesselStruct->LinesOnBoundary.size() << " lines and " << TesselStruct->PointsOnBoundary.size() << " points." << endl;
     365    DoeLog(1) && (eLog()<< Verbose(1) << "Insertion of straddling points failed!" << endl);
     366
     367  DoLog(0) && (Log() << Verbose(0) << "I created " << TesselStruct->TrianglesOnBoundary.size() << " intermediate triangles with " << TesselStruct->LinesOnBoundary.size() << " lines and " << TesselStruct->PointsOnBoundary.size() << " points." << endl);
    367368
    368369  // 4. Store triangles in tecplot file
     
    395396    for (LineMap::iterator LineRunner = TesselStruct->LinesOnBoundary.begin(); LineRunner != TesselStruct->LinesOnBoundary.end(); LineRunner++) {
    396397      line = LineRunner->second;
    397       Log() << Verbose(1) << "INFO: Current line is " << *line << "." << endl;
     398      DoLog(1) && (Log() << Verbose(1) << "INFO: Current line is " << *line << "." << endl);
    398399      if (!line->CheckConvexityCriterion()) {
    399         Log() << Verbose(1) << "... line " << *line << " is concave, flipping it." << endl;
     400        DoLog(1) && (Log() << Verbose(1) << "... line " << *line << " is concave, flipping it." << endl);
    400401
    401402        // flip the line
    402403        if (TesselStruct->PickFarthestofTwoBaselines(line) == 0.)
    403           eLog() << Verbose(1) << "Correction of concave baselines failed!" << endl;
     404          DoeLog(1) && (eLog()<< Verbose(1) << "Correction of concave baselines failed!" << endl);
    404405        else {
    405406          TesselStruct->FlipBaseline(line);
    406           Log() << Verbose(1) << "INFO: Correction of concave baselines worked." << endl;
     407          DoLog(1) && (Log() << Verbose(1) << "INFO: Correction of concave baselines worked." << endl);
    407408        }
    408409      }
     
    414415//    Log() << Verbose(1) << "Correction of concave tesselpoints failed!" << endl;
    415416
    416   Log() << Verbose(0) << "I created " << TesselStruct->TrianglesOnBoundary.size() << " triangles with " << TesselStruct->LinesOnBoundary.size() << " lines and " << TesselStruct->PointsOnBoundary.size() << " points." << endl;
     417  DoLog(0) && (Log() << Verbose(0) << "I created " << TesselStruct->TrianglesOnBoundary.size() << " triangles with " << TesselStruct->LinesOnBoundary.size() << " lines and " << TesselStruct->PointsOnBoundary.size() << " points." << endl);
    417418
    418419  // 4. Store triangles in tecplot file
     
    456457
    457458  if ((TesselStruct == NULL) || (TesselStruct->PointsOnBoundary.empty())) {
    458     eLog() << Verbose(1) << "TesselStruct is empty." << endl;
     459    DoeLog(1) && (eLog()<< Verbose(1) << "TesselStruct is empty." << endl);
    459460    return false;
    460461  }
     
    462463  PointMap::iterator PointRunner;
    463464  while (!TesselStruct->PointsOnBoundary.empty()) {
    464     Log() << Verbose(1) << "Remaining points are: ";
     465    DoLog(1) && (Log() << Verbose(1) << "Remaining points are: ");
    465466    for (PointMap::iterator PointSprinter = TesselStruct->PointsOnBoundary.begin(); PointSprinter != TesselStruct->PointsOnBoundary.end(); PointSprinter++)
    466       Log() << Verbose(0) << *(PointSprinter->second) << "\t";
    467     Log() << Verbose(0) << endl;
     467      DoLog(0) && (Log() << Verbose(0) << *(PointSprinter->second) << "\t");
     468    DoLog(0) && (Log() << Verbose(0) << endl);
    468469
    469470    PointRunner = TesselStruct->PointsOnBoundary.begin();
     
    521522  // check whether there is something to work on
    522523  if (TesselStruct == NULL) {
    523     eLog() << Verbose(1) << "TesselStruct is empty!" << endl;
     524    DoeLog(1) && (eLog()<< Verbose(1) << "TesselStruct is empty!" << endl);
    524525    return volume;
    525526  }
     
    537538      PointAdvance++;
    538539      point = PointRunner->second;
    539       Log() << Verbose(1) << "INFO: Current point is " << *point << "." << endl;
     540      DoLog(1) && (Log() << Verbose(1) << "INFO: Current point is " << *point << "." << endl);
    540541      for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) {
    541542        line = LineRunner->second;
    542         Log() << Verbose(1) << "INFO: Current line of point " << *point << " is " << *line << "." << endl;
     543        DoLog(1) && (Log() << Verbose(1) << "INFO: Current line of point " << *point << " is " << *line << "." << endl);
    543544        if (!line->CheckConvexityCriterion()) {
    544545          // remove the point if needed
    545           Log() << Verbose(1) << "... point " << *point << " cannot be on convex envelope." << endl;
     546          DoLog(1) && (Log() << Verbose(1) << "... point " << *point << " cannot be on convex envelope." << endl);
    546547          volume += TesselStruct->RemovePointFromTesselatedSurface(point);
    547548          sprintf(dummy, "-first-%d", ++run);
     
    564565      LineAdvance++;
    565566      line = LineRunner->second;
    566       Log() << Verbose(1) << "INFO: Picking farthest baseline for line is " << *line << "." << endl;
     567      DoLog(1) && (Log() << Verbose(1) << "INFO: Picking farthest baseline for line is " << *line << "." << endl);
    567568      // take highest of both lines
    568569      if (TesselStruct->IsConvexRectangle(line) == NULL) {
     
    605606
    606607  // end
    607   Log() << Verbose(0) << "Volume is " << volume << "." << endl;
     608  DoLog(0) && (Log() << Verbose(0) << "Volume is " << volume << "." << endl);
    608609  return volume;
    609610};
     
    734735      totalmass += Walker->type->mass;
    735736  }
    736   Log() << Verbose(0) << "RESULT: The summed mass is " << setprecision(10) << totalmass << " atomicmassunit." << endl;
    737   Log() << Verbose(0) << "RESULT: The average density is " << setprecision(10) << totalmass / clustervolume << " atomicmassunit/" << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl;
     737  DoLog(0) && (Log() << Verbose(0) << "RESULT: The summed mass is " << setprecision(10) << totalmass << " atomicmassunit." << endl);
     738  DoLog(0) && (Log() << Verbose(0) << "RESULT: The average density is " << setprecision(10) << totalmass / clustervolume << " atomicmassunit/" << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl);
    738739
    739740  // solve cubic polynomial
    740   Log() << Verbose(1) << "Solving equidistant suspension in water problem ..." << endl;
     741  DoLog(1) && (Log() << Verbose(1) << "Solving equidistant suspension in water problem ..." << endl);
    741742  if (IsAngstroem)
    742743    cellvolume = (TotalNoClusters * totalmass / SOLVENTDENSITY_A - (totalmass / clustervolume)) / (celldensity - 1);
    743744  else
    744745    cellvolume = (TotalNoClusters * totalmass / SOLVENTDENSITY_a0 - (totalmass / clustervolume)) / (celldensity - 1);
    745   Log() << Verbose(1) << "Cellvolume needed for a density of " << celldensity << " g/cm^3 is " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl;
     746  DoLog(1) && (Log() << Verbose(1) << "Cellvolume needed for a density of " << celldensity << " g/cm^3 is " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl);
    746747
    747748  double minimumvolume = TotalNoClusters * (GreatestDiameter[0] * GreatestDiameter[1] * GreatestDiameter[2]);
    748   Log() << Verbose(1) << "Minimum volume of the convex envelope contained in a rectangular box is " << minimumvolume << " atomicmassunit/" << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl;
     749  DoLog(1) && (Log() << Verbose(1) << "Minimum volume of the convex envelope contained in a rectangular box is " << minimumvolume << " atomicmassunit/" << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl);
    749750  if (minimumvolume > cellvolume) {
    750     eLog() << Verbose(1) << "the containing box already has a greater volume than the envisaged cell volume!" << endl;
    751     Log() << Verbose(0) << "Setting Box dimensions to minimum possible, the greatest diameters." << endl;
     751    DoeLog(1) && (eLog()<< Verbose(1) << "the containing box already has a greater volume than the envisaged cell volume!" << endl);
     752    DoLog(0) && (Log() << Verbose(0) << "Setting Box dimensions to minimum possible, the greatest diameters." << endl);
    752753    for (int i = 0; i < NDIM; i++)
    753754      BoxLengths.x[i] = GreatestDiameter[i];
     
    761762    double x2 = 0.;
    762763    if (gsl_poly_solve_cubic(BoxLengths.x[0], BoxLengths.x[1], BoxLengths.x[2], &x0, &x1, &x2) == 1) // either 1 or 3 on return
    763       Log() << Verbose(0) << "RESULT: The resulting spacing is: " << x0 << " ." << endl;
     764      DoLog(0) && (Log() << Verbose(0) << "RESULT: The resulting spacing is: " << x0 << " ." << endl);
    764765    else {
    765       Log() << Verbose(0) << "RESULT: The resulting spacings are: " << x0 << " and " << x1 << " and " << x2 << " ." << endl;
     766      DoLog(0) && (Log() << Verbose(0) << "RESULT: The resulting spacings are: " << x0 << " and " << x1 << " and " << x2 << " ." << endl);
    766767      x0 = x2; // sorted in ascending order
    767768    }
     
    774775
    775776    // set new box dimensions
    776     Log() << Verbose(0) << "Translating to box with these boundaries." << endl;
     777    DoLog(0) && (Log() << Verbose(0) << "Translating to box with these boundaries." << endl);
    777778    mol->SetBoxDimension(&BoxLengths);
    778779    mol->CenterInBox();
     
    780781  // update Box of atoms by boundary
    781782  mol->SetBoxDimension(&BoxLengths);
    782   Log() << Verbose(0) << "RESULT: The resulting cell dimensions are: " << BoxLengths.x[0] << " and " << BoxLengths.x[1] << " and " << BoxLengths.x[2] << " with total volume of " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl;
     783  DoLog(0) && (Log() << Verbose(0) << "RESULT: The resulting cell dimensions are: " << BoxLengths.x[0] << " and " << BoxLengths.x[1] << " and " << BoxLengths.x[2] << " with total volume of " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl);
    783784};
    784785
     
    790791 * \param *filler molecule which the box is to be filled with
    791792 * \param configuration contains box dimensions
     793 * \param MaxDistance fills in molecules only up to this distance (set to -1 if whole of the domain)
    792794 * \param distance[NDIM] distance between filling molecules in each direction
    793795 * \param boundary length of boundary zone between molecule and filling mollecules
     
    798800 * \return *mol pointer to new molecule with filled atoms
    799801 */
    800 molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, const double distance[NDIM], const double boundary, const double RandomAtomDisplacement, const double RandomMolDisplacement, const bool DoRandomRotation)
     802molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, const double MaxDistance, const double distance[NDIM], const double boundary, const double RandomAtomDisplacement, const double RandomMolDisplacement, const bool DoRandomRotation)
    801803{
    802804        Info FunctionInfo(__func__);
     
    805807  int N[NDIM];
    806808  int n[NDIM];
    807   double *M =  ReturnFullMatrixforSymmetric(filler->cell_size);
     809  double *M =  ReturnFullMatrixforSymmetric(World::getInstance().getDomain());
    808810  double Rotations[NDIM*NDIM];
     811  double *MInverse = InverseMatrix(M);
    809812  Vector AtomTranslations;
    810813  Vector FillerTranslations;
    811814  Vector FillerDistance;
     815  Vector Inserter;
    812816  double FillIt = false;
    813817  atom *Walker = NULL;
    814818  bond *Binder = NULL;
    815   int i = 0;
    816   LinkedCell *LCList[List->ListOfMolecules.size()];
    817819  double phi[NDIM];
    818   class Tesselation *TesselStruct[List->ListOfMolecules.size()];
    819 
    820   i=0;
    821   for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) {
    822     Log() << Verbose(1) << "Pre-creating linked cell lists for molecule " << *ListRunner << "." << endl;
    823     LCList[i] = new LinkedCell((*ListRunner), 10.); // get linked cell list
    824     Log() << Verbose(1) << "Pre-creating tesselation for molecule " << *ListRunner << "." << endl;
    825     TesselStruct[i] = NULL;
    826     FindNonConvexBorder((*ListRunner), TesselStruct[i], (const LinkedCell *&)LCList[i], 5., NULL);
    827     i++;
    828   }
     820  map<molecule *, Tesselation *> TesselStruct;
     821  map<molecule *, LinkedCell *> LCList;
     822
     823  for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++)
     824    if ((*ListRunner)->AtomCount > 0) {
     825      DoLog(1) && (Log() << Verbose(1) << "Pre-creating linked cell lists for molecule " << *ListRunner << "." << endl);
     826      LCList[(*ListRunner)] = new LinkedCell((*ListRunner), 10.); // get linked cell list
     827      DoLog(1) && (Log() << Verbose(1) << "Pre-creating tesselation for molecule " << *ListRunner << "." << endl);
     828      TesselStruct[(*ListRunner)] = NULL;
     829      FindNonConvexBorder((*ListRunner), TesselStruct[(*ListRunner)], (const LinkedCell *&)LCList[(*ListRunner)], 5., NULL);
     830    }
    829831
    830832  // Center filler at origin
    831   filler->CenterOrigin();
     833  filler->CenterEdge(&Inserter);
    832834  filler->Center.Zero();
     835  DoLog(2) && (Log() << Verbose(2) << "INFO: Filler molecule has the following bonds:" << endl);
     836  Binder = filler->first;
     837  while(Binder->next != filler->last) {
     838    Binder = Binder->next;
     839    DoLog(2) && (Log() << Verbose(2) << "  " << *Binder << endl);
     840  }
    833841
    834842  filler->CountAtoms();
     
    840848  for(int i=0;i<NDIM;i++)
    841849    N[i] = (int) ceil(1./FillerDistance.x[i]);
    842   Log() << Verbose(1) << "INFO: Grid steps are " << N[0] << ", " << N[1] << ", " << N[2] << "." << endl;
     850  DoLog(1) && (Log() << Verbose(1) << "INFO: Grid steps are " << N[0] << ", " << N[1] << ", " << N[2] << "." << endl);
    843851
    844852  // initialize seed of random number generator to current time
     
    852860        CurrentPosition.Init((double)n[0]/(double)N[0], (double)n[1]/(double)N[1], (double)n[2]/(double)N[2]);
    853861        CurrentPosition.MatrixMultiplication(M);
    854         Log() << Verbose(2) << "INFO: Current Position is " << CurrentPosition << "." << endl;
    855         // Check whether point is in- or outside
    856         FillIt = true;
    857         i=0;
    858         for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) {
    859           // get linked cell list
    860           if (TesselStruct[i] == NULL) {
    861             eLog() << Verbose(0) << "TesselStruct of " << (*ListRunner) << " is NULL. Didn't we pre-create it?" << endl;
    862             FillIt = false;
     862        // create molecule random translation vector ...
     863        for (int i=0;i<NDIM;i++)
     864          FillerTranslations.x[i] = RandomMolDisplacement*(rand()/(RAND_MAX/2.) - 1.);
     865        DoLog(2) && (Log() << Verbose(2) << "INFO: Current Position is " << CurrentPosition << "+" << FillerTranslations << "." << endl);
     866
     867        // go through all atoms
     868        for (int i=0;i<filler->AtomCount;i++)
     869          CopyAtoms[i] = NULL;
     870        Walker = filler->start;
     871        while (Walker->next != filler->end) {
     872          Walker = Walker->next;
     873
     874          // create atomic random translation vector ...
     875          for (int i=0;i<NDIM;i++)
     876            AtomTranslations.x[i] = RandomAtomDisplacement*(rand()/(RAND_MAX/2.) - 1.);
     877
     878          // ... and rotation matrix
     879          if (DoRandomRotation) {
     880            for (int i=0;i<NDIM;i++) {
     881              phi[i] = rand()/(RAND_MAX/(2.*M_PI));
     882            }
     883
     884            Rotations[0] =   cos(phi[0])            *cos(phi[2]) + (sin(phi[0])*sin(phi[1])*sin(phi[2]));
     885            Rotations[3] =   sin(phi[0])            *cos(phi[2]) - (cos(phi[0])*sin(phi[1])*sin(phi[2]));
     886            Rotations[6] =               cos(phi[1])*sin(phi[2])                                     ;
     887            Rotations[1] = - sin(phi[0])*cos(phi[1])                                                ;
     888            Rotations[4] =   cos(phi[0])*cos(phi[1])                                                ;
     889            Rotations[7] =               sin(phi[1])                                                ;
     890            Rotations[3] = - cos(phi[0])            *sin(phi[2]) + (sin(phi[0])*sin(phi[1])*cos(phi[2]));
     891            Rotations[5] = - sin(phi[0])            *sin(phi[2]) - (cos(phi[0])*sin(phi[1])*cos(phi[2]));
     892            Rotations[8] =               cos(phi[1])*cos(phi[2])                                     ;
     893          }
     894
     895          // ... and put at new position
     896          Inserter.CopyVector(&(Walker->x));
     897          if (DoRandomRotation)
     898            Inserter.MatrixMultiplication(Rotations);
     899          Inserter.AddVector(&AtomTranslations);
     900          Inserter.AddVector(&FillerTranslations);
     901          Inserter.AddVector(&CurrentPosition);
     902
     903          // check whether inserter is inside box
     904          Inserter.MatrixMultiplication(MInverse);
     905          FillIt = true;
     906          for (int i=0;i<NDIM;i++)
     907            FillIt = FillIt && (Inserter.x[i] >= -MYEPSILON) && ((Inserter.x[i]-1.) <= MYEPSILON);
     908          Inserter.MatrixMultiplication(M);
     909
     910          // Check whether point is in- or outside
     911          for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) {
     912            // get linked cell list
     913            if (TesselStruct[(*ListRunner)] != NULL) {
     914              const double distance = (TesselStruct[(*ListRunner)]->GetDistanceToSurface(Inserter, LCList[(*ListRunner)]));
     915              FillIt = FillIt && (distance > boundary) && ((MaxDistance < 0) || (MaxDistance > distance));
     916            }
     917          }
     918          // insert into Filling
     919          if (FillIt) {
     920            DoLog(1) && (Log() << Verbose(1) << "INFO: Position at " << Inserter << " is outer point." << endl);
     921            // copy atom ...
     922            CopyAtoms[Walker->nr] = Walker->clone();
     923            CopyAtoms[Walker->nr]->x.CopyVector(&Inserter);
     924            Filling->AddAtom(CopyAtoms[Walker->nr]);
     925            DoLog(4) && (Log() << Verbose(4) << "Filling atom " << *Walker << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[Walker->nr]->x) << "." << endl);
    863926          } else {
    864             const double distance = (TesselStruct[i]->GetDistanceSquaredToSurface(CurrentPosition, LCList[i]));
    865             FillIt = FillIt && (distance > boundary*boundary);
    866             if (FillIt) {
    867               Log() << Verbose(1) << "INFO: Position at " << CurrentPosition << " is outer point." << endl;
    868             } else {
    869               Log() << Verbose(1) << "INFO: Position at " << CurrentPosition << " is inner point or within boundary." << endl;
    870               break;
    871             }
    872             i++;
     927            DoLog(1) && (Log() << Verbose(1) << "INFO: Position at " << Inserter << " is inner point, within boundary or outside of MaxDistance." << endl);
     928            CopyAtoms[Walker->nr] = NULL;
     929            continue;
    873930          }
    874931        }
    875 
    876         if (FillIt) {
    877           // fill in Filler
    878           Log() << Verbose(2) << "Space at " << CurrentPosition << " is unoccupied by any molecule, filling in." << endl;
    879 
    880           // create molecule random translation vector ...
    881           for (int i=0;i<NDIM;i++)
    882             FillerTranslations.x[i] = RandomMolDisplacement*(rand()/(RAND_MAX/2.) - 1.);
    883           Log() << Verbose(2) << "INFO: Translating this filler by " << FillerTranslations << "." << endl;
    884 
    885           // go through all atoms
    886           Walker = filler->start;
    887           while (Walker->next != filler->end) {
    888             Walker = Walker->next;
    889             // copy atom ...
    890             CopyAtoms[Walker->nr] = Walker->clone();
    891 
    892             // create atomic random translation vector ...
    893             for (int i=0;i<NDIM;i++)
    894               AtomTranslations.x[i] = RandomAtomDisplacement*(rand()/(RAND_MAX/2.) - 1.);
    895 
    896             // ... and rotation matrix
    897             if (DoRandomRotation) {
    898               for (int i=0;i<NDIM;i++) {
    899                 phi[i] = rand()/(RAND_MAX/(2.*M_PI));
    900               }
    901 
    902               Rotations[0] =   cos(phi[0])            *cos(phi[2]) + (sin(phi[0])*sin(phi[1])*sin(phi[2]));
    903               Rotations[3] =   sin(phi[0])            *cos(phi[2]) - (cos(phi[0])*sin(phi[1])*sin(phi[2]));
    904               Rotations[6] =               cos(phi[1])*sin(phi[2])                                     ;
    905               Rotations[1] = - sin(phi[0])*cos(phi[1])                                                ;
    906               Rotations[4] =   cos(phi[0])*cos(phi[1])                                                ;
    907               Rotations[7] =               sin(phi[1])                                                ;
    908               Rotations[3] = - cos(phi[0])            *sin(phi[2]) + (sin(phi[0])*sin(phi[1])*cos(phi[2]));
    909               Rotations[5] = - sin(phi[0])            *sin(phi[2]) - (cos(phi[0])*sin(phi[1])*cos(phi[2]));
    910               Rotations[8] =               cos(phi[1])*cos(phi[2])                                     ;
    911             }
    912 
    913             // ... and put at new position
    914             if (DoRandomRotation)
    915               CopyAtoms[Walker->nr]->x.MatrixMultiplication(Rotations);
    916             CopyAtoms[Walker->nr]->x.AddVector(&AtomTranslations);
    917             CopyAtoms[Walker->nr]->x.AddVector(&FillerTranslations);
    918             CopyAtoms[Walker->nr]->x.AddVector(&CurrentPosition);
    919 
    920             // insert into Filling
    921 
    922             // FIXME: gives completely different results if CopyAtoms[..] used instead of Walker, why???
    923             Log() << Verbose(4) << "Filling atom " << *Walker << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[Walker->nr]->x) << "." << endl;
    924             Filling->AddAtom(CopyAtoms[Walker->nr]);
    925           }
    926 
    927           // go through all bonds and add as well
    928           Binder = filler->first;
    929           while(Binder->next != filler->last) {
    930             Binder = Binder->next;
    931             Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl;
     932        // go through all bonds and add as well
     933        Binder = filler->first;
     934        while(Binder->next != filler->last) {
     935          Binder = Binder->next;
     936          if ((CopyAtoms[Binder->leftatom->nr] != NULL) && (CopyAtoms[Binder->rightatom->nr] != NULL)) {
     937            Log()  << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl;
    932938            Filling->AddBond(CopyAtoms[Binder->leftatom->nr], CopyAtoms[Binder->rightatom->nr], Binder->BondDegree);
    933939          }
    934         } else {
    935           // leave empty
    936           Log() << Verbose(2) << "Space at " << CurrentPosition << " is occupied." << endl;
    937940        }
    938941      }
    939942  Free(&M);
    940 
    941   // output to file
    942   TesselStruct[0]->LastTriangle = NULL;
    943   StoreTrianglesinFile(Filling, TesselStruct[0], "Tesselated", ".dat");
    944 
    945   for (size_t i=0;i<List->ListOfMolecules.size();i++) {
    946         delete(LCList[i]);
    947         delete(TesselStruct[i]);
    948   }
     943  Free(&MInverse);
     944
    949945  return Filling;
    950946};
     
    965961  bool freeLC = false;
    966962  bool status = false;
    967   CandidateForTesselation *baseline=0;
    968   LineMap::iterator testline;
     963  CandidateForTesselation *baseline = NULL;
    969964  bool OneLoopWithoutSuccessFlag = true;  // marks whether we went once through all baselines without finding any without two triangles
    970965  bool TesselationFailFlag = false;
    971   BoundaryTriangleSet *T = NULL;
    972966
    973967  if (TesselStruct == NULL) {
    974     Log() << Verbose(1) << "Allocating Tesselation struct ..." << endl;
     968    DoLog(1) && (Log() << Verbose(1) << "Allocating Tesselation struct ..." << endl);
    975969    TesselStruct= new Tesselation;
    976970  } else {
    977971    delete(TesselStruct);
    978     Log() << Verbose(1) << "Re-Allocating Tesselation struct ..." << endl;
     972    DoLog(1) && (Log() << Verbose(1) << "Re-Allocating Tesselation struct ..." << endl);
    979973    TesselStruct = new Tesselation;
    980974  }
     
    987981
    988982  // 1. get starting triangle
    989   TesselStruct->FindStartingTriangle(RADIUS, LCList);
     983  if (!TesselStruct->FindStartingTriangle(RADIUS, LCList)) {
     984    DoeLog(0) && (eLog() << Verbose(0) << "No valid starting triangle found." << endl);
     985    //performCriticalExit();
     986  }
     987  if (filename != NULL) {
     988    if ((DoSingleStepOutput && ((TesselStruct->TrianglesOnBoundary.size() % SingleStepWidth == 0)))) { // if we have a new triangle and want to output each new triangle configuration
     989      TesselStruct->Output(filename, mol);
     990    }
     991  }
    990992
    991993  // 2. expand from there
    992994  while ((!TesselStruct->OpenLines.empty()) && (OneLoopWithoutSuccessFlag)) {
    993     // 2a. fill all new OpenLines
    994     Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for candidates:" << endl;
     995    (cerr << "There are " <<  TesselStruct->TrianglesOnBoundary.size() << " triangles and " << TesselStruct->OpenLines.size() << " open lines to scan for candidates." << endl);
     996    // 2a. print OpenLines without candidates
     997    DoLog(1) && (Log() << Verbose(1) << "There are the following open lines to scan for a candidates:" << endl);
    995998    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++)
    996       Log() << Verbose(2) << *(Runner->second) << endl;
    997 
    998     for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
    999       baseline = Runner->second;
    1000       if (baseline->pointlist.empty()) {
    1001         T = (((baseline->BaseLine->triangles.begin()))->second);
    1002         Log() << Verbose(1) << "Finding best candidate for open line " << *baseline->BaseLine << " of triangle " << *T << endl;
    1003         TesselationFailFlag = TesselStruct->FindNextSuitableTriangle(*baseline, *T, RADIUS, LCList); //the line is there, so there is a triangle, but only one.
    1004       }
    1005     }
    1006 
    1007     // 2b. search for smallest ShortestAngle among all candidates
     999      if (Runner->second->pointlist.empty())
     1000        DoLog(1) && (Log() << Verbose(1) << " " << *(Runner->second) << endl);
     1001
     1002    // 2b. find best candidate for each OpenLine
     1003    TesselationFailFlag = TesselStruct->FindCandidatesforOpenLines(RADIUS, LCList);
     1004
     1005    // 2c. print OpenLines with candidates again
     1006    DoLog(1) && (Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for the best candidates:" << endl);
     1007    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++)
     1008      DoLog(1) && (Log() << Verbose(1) << " " << *(Runner->second) << endl);
     1009
     1010    // 2d. search for smallest ShortestAngle among all candidates
    10081011    double ShortestAngle = 4.*M_PI;
    1009     Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for the best candidates:" << endl;
    1010     for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++)
    1011       Log() << Verbose(2) << *(Runner->second) << endl;
    1012 
    10131012    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
    10141013      if (Runner->second->ShortestAngle < ShortestAngle) {
    10151014        baseline = Runner->second;
    10161015        ShortestAngle = baseline->ShortestAngle;
    1017         //Log() << Verbose(1) << "New best candidate is " << *baseline->BaseLine << " with point " << *baseline->point << " and angle " << baseline->ShortestAngle << endl;
     1016        DoLog(1) && (Log() << Verbose(1) << "New best candidate is " << *baseline->BaseLine << " with point " << *(*baseline->pointlist.begin()) << " and angle " << baseline->ShortestAngle << endl);
    10181017      }
    10191018    }
     1019    // 2e. if we found one, add candidate
    10201020    if ((ShortestAngle == 4.*M_PI) || (baseline->pointlist.empty()))
    10211021      OneLoopWithoutSuccessFlag = false;
    10221022    else {
    1023       TesselStruct->AddCandidateTriangle(*baseline);
    1024     }
    1025 
    1026     // write temporary envelope
     1023      TesselStruct->AddCandidatePolygon(*baseline, RADIUS, LCList);
     1024    }
     1025
     1026    // 2f. write temporary envelope
    10271027    if (filename != NULL) {
    10281028      if ((DoSingleStepOutput && ((TesselStruct->TrianglesOnBoundary.size() % SingleStepWidth == 0)))) { // if we have a new triangle and want to output each new triangle configuration
     
    10591059  StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, "");
    10601060
    1061   // correct degenerated polygons
    1062   TesselStruct->CorrectAllDegeneratedPolygons();
    1063 
    1064   // check envelope for consistency
    1065   status = CheckListOfBaselines(TesselStruct);
     1061//  // correct degenerated polygons
     1062//  TesselStruct->CorrectAllDegeneratedPolygons();
     1063//
     1064//  // check envelope for consistency
     1065//  status = CheckListOfBaselines(TesselStruct);
    10661066
    10671067  // write final envelope
  • src/boundary.hpp

    r13d5a9 r5f612ee  
    4949
    5050double ConvexizeNonconvexEnvelope(class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename);
    51 molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, const double distance[NDIM], const double boundary, const double RandomAtomDisplacement, const double RandomMolDisplacement, const bool DoRandomRotation);
     51molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, const double MaxDistance, const double distance[NDIM], const double boundary, const double RandomAtomDisplacement, const double RandomMolDisplacement, const bool DoRandomRotation);
    5252void FindConvexBorder(const molecule* const mol, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename);
    5353Vector* FindEmbeddingHole(MoleculeListClass *mols, molecule *srcmol);
  • src/builder.cpp

    r13d5a9 r5f612ee  
    5454#include <cstring>
    5555
     56#include "analysis_bonds.hpp"
    5657#include "analysis_correlation.hpp"
    5758#include "atom.hpp"
     
    7980#include "World.hpp"
    8081#include "version.h"
     82#include "World.hpp"
    8183
    8284/********************************************* Subsubmenu routine ************************************/
     
    9597  bool valid;
    9698
    97   Log() << Verbose(0) << "===========ADD ATOM============================" << endl;
    98   Log() << Verbose(0) << " a - state absolute coordinates of atom" << endl;
    99   Log() << Verbose(0) << " b - state relative coordinates of atom wrt to reference point" << endl;
    100   Log() << Verbose(0) << " c - state relative coordinates of atom wrt to already placed atom" << endl;
    101   Log() << Verbose(0) << " d - state two atoms, two angles and a distance" << endl;
    102   Log() << Verbose(0) << " e - least square distance position to a set of atoms" << endl;
    103   Log() << Verbose(0) << "all else - go back" << endl;
    104   Log() << Verbose(0) << "===============================================" << endl;
    105   Log() << Verbose(0) << "Note: Specifiy angles in degrees not multiples of Pi!" << endl;
    106   Log() << Verbose(0) << "INPUT: ";
     99  cout << Verbose(0) << "===========ADD ATOM============================" << endl;
     100  cout << Verbose(0) << " a - state absolute coordinates of atom" << endl;
     101  cout << Verbose(0) << " b - state relative coordinates of atom wrt to reference point" << endl;
     102  cout << Verbose(0) << " c - state relative coordinates of atom wrt to already placed atom" << endl;
     103  cout << Verbose(0) << " d - state two atoms, two angles and a distance" << endl;
     104  cout << Verbose(0) << " e - least square distance position to a set of atoms" << endl;
     105  cout << Verbose(0) << "all else - go back" << endl;
     106  cout << Verbose(0) << "===============================================" << endl;
     107  cout << Verbose(0) << "Note: Specifiy angles in degrees not multiples of Pi!" << endl;
     108  cout << Verbose(0) << "INPUT: ";
    107109  cin >> choice;
    108110
    109111  switch (choice) {
    110112    default:
    111       eLog() << Verbose(2) << "Not a valid choice." << endl;
     113      DoeLog(2) && (eLog()<< Verbose(2) << "Not a valid choice." << endl);
    112114      break;
    113115      case 'a': // absolute coordinates of atom
    114         Log() << Verbose(0) << "Enter absolute coordinates." << endl;
     116        cout << Verbose(0) << "Enter absolute coordinates." << endl;
    115117        first = new atom;
    116         first->x.AskPosition(mol->cell_size, false);
     118        first->x.AskPosition(World::getInstance().getDomain(), false);
    117119        first->type = periode->AskElement();  // give type
    118120        mol->AddAtom(first);  // add to molecule
     
    123125        valid = true;
    124126        do {
    125           if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
    126           Log() << Verbose(0) << "Enter reference coordinates." << endl;
    127           x.AskPosition(mol->cell_size, true);
    128           Log() << Verbose(0) << "Enter relative coordinates." << endl;
    129           first->x.AskPosition(mol->cell_size, false);
     127          if (!valid) DoeLog(2) && (eLog()<< Verbose(2) << "Resulting position out of cell." << endl);
     128          cout << Verbose(0) << "Enter reference coordinates." << endl;
     129          x.AskPosition(World::getInstance().getDomain(), true);
     130          cout << Verbose(0) << "Enter relative coordinates." << endl;
     131          first->x.AskPosition(World::getInstance().getDomain(), false);
    130132          first->x.AddVector((const Vector *)&x);
    131           Log() << Verbose(0) << "\n";
     133          cout << Verbose(0) << "\n";
    132134        } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
    133135        first->type = periode->AskElement();  // give type
     
    139141        valid = true;
    140142        do {
    141           if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
     143          if (!valid) DoeLog(2) && (eLog()<< Verbose(2) << "Resulting position out of cell." << endl);
    142144          second = mol->AskAtom("Enter atom number: ");
    143           Log() << Verbose(0) << "Enter relative coordinates." << endl;
    144           first->x.AskPosition(mol->cell_size, false);
     145          DoLog(0) && (Log() << Verbose(0) << "Enter relative coordinates." << endl);
     146          first->x.AskPosition(World::getInstance().getDomain(), false);
    145147          for (int i=NDIM;i--;) {
    146148            first->x.x[i] += second->x.x[i];
     
    156158        do {
    157159          if (!valid) {
    158             eLog() << Verbose(2) << "Resulting coordinates out of cell - " << first->x << endl;
     160            DoeLog(2) && (eLog()<< Verbose(2) << "Resulting coordinates out of cell - " << first->x << endl);
    159161          }
    160           Log() << Verbose(0) << "First, we need two atoms, the first atom is the central, while the second is the outer one." << endl;
     162          cout << Verbose(0) << "First, we need two atoms, the first atom is the central, while the second is the outer one." << endl;
    161163          second = mol->AskAtom("Enter central atom: ");
    162164          third = mol->AskAtom("Enter second atom (specifying the axis for first angle): ");
     
    169171          c *= M_PI/180.;
    170172          bound(&c, -M_PI, M_PI);
    171           Log() << Verbose(0) << "radius: " << a << "\t phi: " << b*180./M_PI << "\t theta: " << c*180./M_PI << endl;
     173          cout << Verbose(0) << "radius: " << a << "\t phi: " << b*180./M_PI << "\t theta: " << c*180./M_PI << endl;
    172174/*
    173175          second->Output(1,1,(ofstream *)&cout);
     
    181183
    182184          if (!z.SolveSystem(&x,&y,&n, b, c, a)) {
    183             Log() << Verbose(0) << "Failure solving self-dependent linear system!" << endl;
     185         coutg() << Verbose(0) << "Failure solving self-dependent linear system!" << endl;
    184186            continue;
    185187          }
    186           Log() << Verbose(0) << "resulting relative coordinates: ";
     188          DoLog(0) && (Log() << Verbose(0) << "resulting relative coordinates: ");
    187189          z.Output();
    188           Log() << Verbose(0) << endl;
     190          DoLog(0) && (Log() << Verbose(0) << endl);
    189191          */
    190192          // calc axis vector
     
    194196          Log() << Verbose(0) << "x: ",
    195197          x.Output();
    196           Log() << Verbose(0) << endl;
     198          DoLog(0) && (Log() << Verbose(0) << endl);
    197199          z.MakeNormalVector(&second->x,&third->x,&fourth->x);
    198200          Log() << Verbose(0) << "z: ",
    199201          z.Output();
    200           Log() << Verbose(0) << endl;
     202          DoLog(0) && (Log() << Verbose(0) << endl);
    201203          y.MakeNormalVector(&x,&z);
    202204          Log() << Verbose(0) << "y: ",
    203205          y.Output();
    204           Log() << Verbose(0) << endl;
     206          DoLog(0) && (Log() << Verbose(0) << endl);
    205207
    206208          // rotate vector around first angle
     
    209211          Log() << Verbose(0) << "Rotated vector: ",
    210212          first->x.Output();
    211           Log() << Verbose(0) << endl;
     213          DoLog(0) && (Log() << Verbose(0) << endl);
    212214          // remove the projection onto the rotation plane of the second angle
    213215          n.CopyVector(&y);
     
    215217          Log() << Verbose(0) << "N1: ",
    216218          n.Output();
    217           Log() << Verbose(0) << endl;
     219          DoLog(0) && (Log() << Verbose(0) << endl);
    218220          first->x.SubtractVector(&n);
    219221          Log() << Verbose(0) << "Subtracted vector: ",
    220222          first->x.Output();
    221           Log() << Verbose(0) << endl;
     223          DoLog(0) && (Log() << Verbose(0) << endl);
    222224          n.CopyVector(&z);
    223225          n.Scale(first->x.ScalarProduct(&z));
    224226          Log() << Verbose(0) << "N2: ",
    225227          n.Output();
    226           Log() << Verbose(0) << endl;
     228          DoLog(0) && (Log() << Verbose(0) << endl);
    227229          first->x.SubtractVector(&n);
    228230          Log() << Verbose(0) << "2nd subtracted vector: ",
    229231          first->x.Output();
    230           Log() << Verbose(0) << endl;
     232          DoLog(0) && (Log() << Verbose(0) << endl);
    231233
    232234          // rotate another vector around second angle
     
    235237          Log() << Verbose(0) << "2nd Rotated vector: ",
    236238          n.Output();
    237           Log() << Verbose(0) << endl;
     239          DoLog(0) && (Log() << Verbose(0) << endl);
    238240
    239241          // add the two linear independent vectors
     
    243245          first->x.AddVector(&second->x);
    244246
    245           Log() << Verbose(0) << "resulting coordinates: ";
     247          DoLog(0) && (Log() << Verbose(0) << "resulting coordinates: ");
    246248          first->x.Output();
    247           Log() << Verbose(0) << endl;
     249          DoLog(0) && (Log() << Verbose(0) << endl);
    248250        } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
    249251        first->type = periode->AskElement();  // give type
     
    258260          atoms[i] = NULL;
    259261        int i=0, j=0;
    260         Log() << Verbose(0) << "Now we need at least three molecules.\n";
     262        cout << Verbose(0) << "Now we need at least three molecules.\n";
    261263        do {
    262           Log() << Verbose(0) << "Enter " << i+1 << "th atom: ";
     264          cout << Verbose(0) << "Enter " << i+1 << "th atom: ";
    263265          cin >> j;
    264266          if (j != -1) {
     
    274276        } else {
    275277          delete first;
    276           Log() << Verbose(0) << "Please enter at least two vectors!\n";
     278          cout << Verbose(0) << "Please enter at least two vectors!\n";
    277279        }
    278280        break;
     
    288290  char choice;  // menu choice char
    289291
    290   Log() << Verbose(0) << "===========CENTER ATOMS=========================" << endl;
    291   Log() << Verbose(0) << " a - on origin" << endl;
    292   Log() << Verbose(0) << " b - on center of gravity" << endl;
    293   Log() << Verbose(0) << " c - within box with additional boundary" << endl;
    294   Log() << Verbose(0) << " d - within given simulation box" << endl;
    295   Log() << Verbose(0) << "all else - go back" << endl;
    296   Log() << Verbose(0) << "===============================================" << endl;
    297   Log() << Verbose(0) << "INPUT: ";
     292  cout << Verbose(0) << "===========CENTER ATOMS=========================" << endl;
     293  cout << Verbose(0) << " a - on origin" << endl;
     294  cout << Verbose(0) << " b - on center of gravity" << endl;
     295  cout << Verbose(0) << " c - within box with additional boundary" << endl;
     296  cout << Verbose(0) << " d - within given simulation box" << endl;
     297  cout << Verbose(0) << "all else - go back" << endl;
     298  cout << Verbose(0) << "===============================================" << endl;
     299  cout << Verbose(0) << "INPUT: ";
    298300  cin >> choice;
    299301
    300302  switch (choice) {
    301303    default:
    302       Log() << Verbose(0) << "Not a valid choice." << endl;
     304      cout << Verbose(0) << "Not a valid choice." << endl;
    303305      break;
    304306    case 'a':
    305       Log() << Verbose(0) << "Centering atoms in config file on origin." << endl;
     307      cout << Verbose(0) << "Centering atoms in config file on origin." << endl;
    306308      mol->CenterOrigin();
    307309      break;
    308310    case 'b':
    309       Log() << Verbose(0) << "Centering atoms in config file on center of gravity." << endl;
     311      cout << Verbose(0) << "Centering atoms in config file on center of gravity." << endl;
    310312      mol->CenterPeriodic();
    311313      break;
    312314    case 'c':
    313       Log() << Verbose(0) << "Centering atoms in config file within given additional boundary." << endl;
     315      cout << Verbose(0) << "Centering atoms in config file within given additional boundary." << endl;
    314316      for (int i=0;i<NDIM;i++) {
    315         Log() << Verbose(0) << "Enter axis " << i << " boundary: ";
     317        cout << Verbose(0) << "Enter axis " << i << " boundary: ";
    316318        cin >> y.x[i];
    317319      }
     
    324326      break;
    325327    case 'd':
    326       Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
     328      cout << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
    327329      for (int i=0;i<NDIM;i++) {
    328         Log() << Verbose(0) << "Enter axis " << i << " boundary: ";
     330        cout << Verbose(0) << "Enter axis " << i << " boundary: ";
    329331        cin >> x.x[i];
    330332      }
     
    347349  char choice;  // menu choice char
    348350
    349   Log() << Verbose(0) << "===========ALIGN ATOMS=========================" << endl;
    350   Log() << Verbose(0) << " a - state three atoms defining align plane" << endl;
    351   Log() << Verbose(0) << " b - state alignment vector" << endl;
    352   Log() << Verbose(0) << " c - state two atoms in alignment direction" << endl;
    353   Log() << Verbose(0) << " d - align automatically by least square fit" << endl;
    354   Log() << Verbose(0) << "all else - go back" << endl;
    355   Log() << Verbose(0) << "===============================================" << endl;
    356   Log() << Verbose(0) << "INPUT: ";
     351  cout << Verbose(0) << "===========ALIGN ATOMS=========================" << endl;
     352  cout << Verbose(0) << " a - state three atoms defining align plane" << endl;
     353  cout << Verbose(0) << " b - state alignment vector" << endl;
     354  cout << Verbose(0) << " c - state two atoms in alignment direction" << endl;
     355  cout << Verbose(0) << " d - align automatically by least square fit" << endl;
     356  cout << Verbose(0) << "all else - go back" << endl;
     357  cout << Verbose(0) << "===============================================" << endl;
     358  cout << Verbose(0) << "INPUT: ";
    357359  cin >> choice;
    358360
     
    367369      break;
    368370    case 'b': // normal vector of mirror plane
    369       Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl;
    370       n.AskPosition(mol->cell_size,0);
     371      cout << Verbose(0) << "Enter normal vector of mirror plane." << endl;
     372      n.AskPosition(World::getInstance().getDomain(),0);
    371373      n.Normalize();
    372374      break;
     
    387389        fscanf(stdin, "%3s", shorthand);
    388390      } while ((param.type = periode->FindElement(shorthand)) == NULL);
    389       Log() << Verbose(0) << "Element is " << param.type->name << endl;
     391      cout << Verbose(0) << "Element is " << param.type->name << endl;
    390392      mol->GetAlignvector(&param);
    391393      for (int i=NDIM;i--;) {
     
    394396      }
    395397      gsl_vector_free(param.x);
    396       Log() << Verbose(0) << "Offset vector: ";
     398      cout << Verbose(0) << "Offset vector: ";
    397399      x.Output();
    398       Log() << Verbose(0) << endl;
     400      DoLog(0) && (Log() << Verbose(0) << endl);
    399401      n.Normalize();
    400402      break;
    401403  };
    402   Log() << Verbose(0) << "Alignment vector: ";
     404  DoLog(0) && (Log() << Verbose(0) << "Alignment vector: ");
    403405  n.Output();
    404   Log() << Verbose(0) << endl;
     406  DoLog(0) && (Log() << Verbose(0) << endl);
    405407  mol->Align(&n);
    406408};
     
    415417  char choice;  // menu choice char
    416418
    417   Log() << Verbose(0) << "===========MIRROR ATOMS=========================" << endl;
    418   Log() << Verbose(0) << " a - state three atoms defining mirror plane" << endl;
    419   Log() << Verbose(0) << " b - state normal vector of mirror plane" << endl;
    420   Log() << Verbose(0) << " c - state two atoms in normal direction" << endl;
    421   Log() << Verbose(0) << "all else - go back" << endl;
    422   Log() << Verbose(0) << "===============================================" << endl;
    423   Log() << Verbose(0) << "INPUT: ";
     419  DoLog(0) && (Log() << Verbose(0) << "===========MIRROR ATOMS=========================" << endl);
     420  DoLog(0) && (Log() << Verbose(0) << " a - state three atoms defining mirror plane" << endl);
     421  DoLog(0) && (Log() << Verbose(0) << " b - state normal vector of mirror plane" << endl);
     422  DoLog(0) && (Log() << Verbose(0) << " c - state two atoms in normal direction" << endl);
     423  DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
     424  DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
     425  DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    424426  cin >> choice;
    425427
     
    434436      break;
    435437    case 'b': // normal vector of mirror plane
    436       Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl;
    437       n.AskPosition(mol->cell_size,0);
     438      DoLog(0) && (Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl);
     439      n.AskPosition(World::getInstance().getDomain(),0);
    438440      n.Normalize();
    439441      break;
     
    447449      break;
    448450  };
    449   Log() << Verbose(0) << "Normal vector: ";
     451  DoLog(0) && (Log() << Verbose(0) << "Normal vector: ");
    450452  n.Output();
    451   Log() << Verbose(0) << endl;
     453  DoLog(0) && (Log() << Verbose(0) << endl);
    452454  mol->Mirror((const Vector *)&n);
    453455};
     
    463465  char choice;  // menu choice char
    464466
    465   Log() << Verbose(0) << "===========REMOVE ATOMS=========================" << endl;
    466   Log() << Verbose(0) << " a - state atom for removal by number" << endl;
    467   Log() << Verbose(0) << " b - keep only in radius around atom" << endl;
    468   Log() << Verbose(0) << " c - remove this with one axis greater value" << endl;
    469   Log() << Verbose(0) << "all else - go back" << endl;
    470   Log() << Verbose(0) << "===============================================" << endl;
    471   Log() << Verbose(0) << "INPUT: ";
     467  DoLog(0) && (Log() << Verbose(0) << "===========REMOVE ATOMS=========================" << endl);
     468  DoLog(0) && (Log() << Verbose(0) << " a - state atom for removal by number" << endl);
     469  DoLog(0) && (Log() << Verbose(0) << " b - keep only in radius around atom" << endl);
     470  DoLog(0) && (Log() << Verbose(0) << " c - remove this with one axis greater value" << endl);
     471  DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
     472  DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
     473  DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    472474  cin >> choice;
    473475
     
    476478    case 'a':
    477479      if (mol->RemoveAtom(mol->AskAtom("Enter number of atom within molecule: ")))
    478         Log() << Verbose(1) << "Atom removed." << endl;
     480        DoLog(1) && (Log() << Verbose(1) << "Atom removed." << endl);
    479481      else
    480         Log() << Verbose(1) << "Atom not found." << endl;
     482        DoLog(1) && (Log() << Verbose(1) << "Atom not found." << endl);
    481483      break;
    482484    case 'b':
    483485      second = mol->AskAtom("Enter number of atom as reference point: ");
    484       Log() << Verbose(0) << "Enter radius: ";
     486      DoLog(0) && (Log() << Verbose(0) << "Enter radius: ");
    485487      cin >> tmp1;
    486488      first = mol->start;
     
    494496      break;
    495497    case 'c':
    496       Log() << Verbose(0) << "Which axis is it: ";
     498      DoLog(0) && (Log() << Verbose(0) << "Which axis is it: ");
    497499      cin >> axis;
    498       Log() << Verbose(0) << "Lower boundary: ";
     500      DoLog(0) && (Log() << Verbose(0) << "Lower boundary: ");
    499501      cin >> tmp1;
    500       Log() << Verbose(0) << "Upper boundary: ";
     502      DoLog(0) && (Log() << Verbose(0) << "Upper boundary: ");
    501503      cin >> tmp2;
    502504      first = mol->start;
     
    528530  char choice;  // menu choice char
    529531
    530   Log() << Verbose(0) << "===========MEASURE ATOMS=========================" << endl;
    531   Log() << Verbose(0) << " a - calculate bond length between one atom and all others" << endl;
    532   Log() << Verbose(0) << " b - calculate bond length between two atoms" << endl;
    533   Log() << Verbose(0) << " c - calculate bond angle" << endl;
    534   Log() << Verbose(0) << " d - calculate principal axis of the system" << endl;
    535   Log() << Verbose(0) << " e - calculate volume of the convex envelope" << endl;
    536   Log() << Verbose(0) << " f - calculate temperature from current velocity" << endl;
    537   Log() << Verbose(0) << " g - output all temperatures per step from velocities" << endl;
    538   Log() << Verbose(0) << "all else - go back" << endl;
    539   Log() << Verbose(0) << "===============================================" << endl;
    540   Log() << Verbose(0) << "INPUT: ";
     532  DoLog(0) && (Log() << Verbose(0) << "===========MEASURE ATOMS=========================" << endl);
     533  DoLog(0) && (Log() << Verbose(0) << " a - calculate bond length between one atom and all others" << endl);
     534  DoLog(0) && (Log() << Verbose(0) << " b - calculate bond length between two atoms" << endl);
     535  DoLog(0) && (Log() << Verbose(0) << " c - calculate bond angle" << endl);
     536  DoLog(0) && (Log() << Verbose(0) << " d - calculate principal axis of the system" << endl);
     537  DoLog(0) && (Log() << Verbose(0) << " e - calculate volume of the convex envelope" << endl);
     538  DoLog(0) && (Log() << Verbose(0) << " f - calculate temperature from current velocity" << endl);
     539  DoLog(0) && (Log() << Verbose(0) << " g - output all temperatures per step from velocities" << endl);
     540  DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
     541  DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
     542  DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    541543  cin >> choice;
    542544
    543545  switch(choice) {
    544546    default:
    545       Log() << Verbose(1) << "Not a valid choice." << endl;
     547      DoLog(1) && (Log() << Verbose(1) << "Not a valid choice." << endl);
    546548      break;
    547549    case 'a':
     
    575577      x.SubtractVector((const Vector *)&second->x);
    576578      tmp1 = x.Norm();
    577       Log() << Verbose(1) << "Distance vector is ";
     579      DoLog(1) && (Log() << Verbose(1) << "Distance vector is ");
    578580      x.Output();
    579       Log() << Verbose(0) << "." << endl << "Norm of distance is " << tmp1 << "." << endl;
     581      DoLog(0) && (Log() << Verbose(0) << "." << endl << "Norm of distance is " << tmp1 << "." << endl);
    580582      break;
    581583
    582584    case 'c':
    583       Log() << Verbose(0) << "Evaluating bond angle between three - first, central, last - atoms." << endl;
     585      DoLog(0) && (Log() << Verbose(0) << "Evaluating bond angle between three - first, central, last - atoms." << endl);
    584586      first = mol->AskAtom("Enter first atom: ");
    585587      second = mol->AskAtom("Enter central atom: ");
     
    590592      y.CopyVector((const Vector *)&third->x);
    591593      y.SubtractVector((const Vector *)&second->x);
    592       Log() << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ";
    593       Log() << Verbose(0) << (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl;
     594      DoLog(0) && (Log() << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ");
     595      DoLog(0) && (Log() << Verbose(0) << (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl);
    594596      break;
    595597    case 'd':
    596       Log() << Verbose(0) << "Evaluating prinicipal axis." << endl;
    597       Log() << Verbose(0) << "Shall we rotate? [0/1]: ";
     598      DoLog(0) && (Log() << Verbose(0) << "Evaluating prinicipal axis." << endl);
     599      DoLog(0) && (Log() << Verbose(0) << "Shall we rotate? [0/1]: ");
    598600      cin >> Z;
    599601      if ((Z >=0) && (Z <=1))
     
    604606    case 'e':
    605607      {
    606         Log() << Verbose(0) << "Evaluating volume of the convex envelope.";
     608        DoLog(0) && (Log() << Verbose(0) << "Evaluating volume of the convex envelope.");
    607609        class Tesselation *TesselStruct = NULL;
    608610        const LinkedCell *LCList = NULL;
     
    610612        FindConvexBorder(mol, TesselStruct, LCList, NULL);
    611613        double clustervolume = VolumeOfConvexEnvelope(TesselStruct, configuration);
    612         Log() << Verbose(0) << "The tesselated surface area is " << clustervolume << "." << endl;\
     614        DoLog(0) && (Log() << Verbose(0) << "The tesselated surface area is " << clustervolume << "." << endl);\
    613615        delete(LCList);
    614616        delete(TesselStruct);
     
    621623      {
    622624        char filename[255];
    623         Log() << Verbose(0) << "Please enter filename: " << endl;
     625        DoLog(0) && (Log() << Verbose(0) << "Please enter filename: " << endl);
    624626        cin >> filename;
    625         Log() << Verbose(1) << "Storing temperatures in " << filename << "." << endl;
     627        DoLog(1) && (Log() << Verbose(1) << "Storing temperatures in " << filename << "." << endl);
    626628        ofstream *output = new ofstream(filename, ios::trunc);
    627629        if (!mol->OutputTemperatureFromTrajectories(output, 0, mol->MDSteps))
    628           Log() << Verbose(2) << "File could not be written." << endl;
     630          DoLog(2) && (Log() << Verbose(2) << "File could not be written." << endl);
    629631        else
    630           Log() << Verbose(2) << "File stored." << endl;
     632          DoLog(2) && (Log() << Verbose(2) << "File stored." << endl);
    631633        output->close();
    632634        delete(output);
     
    645647  clock_t start, end;
    646648
    647   Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl;
    648   Log() << Verbose(0) << "What's the desired bond order: ";
     649  DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl);
     650  DoLog(0) && (Log() << Verbose(0) << "What's the desired bond order: ");
    649651  cin >> Order1;
    650652  if (mol->first->next != mol->last) {  // there are bonds
     
    652654    mol->FragmentMolecule(Order1, configuration);
    653655    end = clock();
    654     Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
     656    DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);
    655657  } else
    656     Log() << Verbose(0) << "Connection matrix has not yet been generated!" << endl;
     658    DoLog(0) && (Log() << Verbose(0) << "Connection matrix has not yet been generated!" << endl);
    657659};
    658660
     
    665667static void ManipulateAtoms(periodentafel *periode, MoleculeListClass *molecules, config *configuration)
    666668{
    667   atom *first, *second;
     669  atom *first, *second, *third;
    668670  molecule *mol = NULL;
    669671  Vector x,y,z,n; // coordinates for absolute point in cell volume
     
    673675  bool valid;
    674676
    675   Log() << Verbose(0) << "=========MANIPULATE ATOMS======================" << endl;
    676   Log() << Verbose(0) << "a - add an atom" << endl;
    677   Log() << Verbose(0) << "r - remove an atom" << endl;
    678   Log() << Verbose(0) << "b - scale a bond between atoms" << endl;
    679   Log() << Verbose(0) << "u - change an atoms element" << endl;
    680   Log() << Verbose(0) << "l - measure lengths, angles, ... for an atom" << endl;
    681   Log() << Verbose(0) << "all else - go back" << endl;
    682   Log() << Verbose(0) << "===============================================" << endl;
     677  DoLog(0) && (Log() << Verbose(0) << "=========MANIPULATE ATOMS======================" << endl);
     678  DoLog(0) && (Log() << Verbose(0) << "a - add an atom" << endl);
     679  DoLog(0) && (Log() << Verbose(0) << "r - remove an atom" << endl);
     680  DoLog(0) && (Log() << Verbose(0) << "b - scale a bond between atoms" << endl);
     681  DoLog(0) && (Log() << Verbose(0) << "t - turn an atom round another bond" << endl);
     682  DoLog(0) && (Log() << Verbose(0) << "u - change an atoms element" << endl);
     683  DoLog(0) && (Log() << Verbose(0) << "l - measure lengths, angles, ... for an atom" << endl);
     684  DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
     685  DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
    683686  if (molecules->NumberOfActiveMolecules() > 1)
    684     eLog() << Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl;
    685   Log() << Verbose(0) << "INPUT: ";
     687    DoeLog(2) && (eLog()<< Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl);
     688  DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    686689  cin >> choice;
    687690
    688691  switch (choice) {
    689692    default:
    690       Log() << Verbose(0) << "Not a valid choice." << endl;
     693      DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl);
    691694      break;
    692695
     
    695698        if ((*ListRunner)->ActiveFlag) {
    696699        mol = *ListRunner;
    697         Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
     700        DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    698701        AddAtoms(periode, mol);
    699702      }
     
    704707        if ((*ListRunner)->ActiveFlag) {
    705708        mol = *ListRunner;
    706         Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
    707         Log() << Verbose(0) << "Scaling bond length between two atoms." << endl;
     709        DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
     710        DoLog(0) && (Log() << Verbose(0) << "Scaling bond length between two atoms." << endl);
    708711        first = mol->AskAtom("Enter first (fixed) atom: ");
    709712        second = mol->AskAtom("Enter second (shifting) atom: ");
     
    712715          minBond += (first->x.x[i]-second->x.x[i])*(first->x.x[i] - second->x.x[i]);
    713716        minBond = sqrt(minBond);
    714         Log() << Verbose(0) << "Current Bond length between " << first->type->name << " Atom " << first->nr << " and " << second->type->name << " Atom " << second->nr << ": " << minBond << " a.u." << endl;
    715         Log() << Verbose(0) << "Enter new bond length [a.u.]: ";
     717        DoLog(0) && (Log() << Verbose(0) << "Current Bond length between " << first->type->name << " Atom " << first->nr << " and " << second->type->name << " Atom " << second->nr << ": " << minBond << " a.u." << endl);
     718        DoLog(0) && (Log() << Verbose(0) << "Enter new bond length [a.u.]: ");
    716719        cin >> bond;
    717720        for (int i=NDIM;i--;) {
     
    727730        if ((*ListRunner)->ActiveFlag) {
    728731        mol = *ListRunner;
    729         Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
    730        Log() << Verbose(0) << "Angstroem -> Bohrradius: 1.8897261\t\tBohrradius -> Angstroem: 0.52917721" << endl;
    731        Log() << Verbose(0) << "Enter three factors: ";
     732        DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
     733       DoLog(0) && (Log() << Verbose(0) << "Angstroem -> Bohrradius: 1.8897261\t\tBohrradius -> Angstroem: 0.52917721" << endl);
     734       DoLog(0) && (Log() << Verbose(0) << "Enter three factors: ");
    732735       factor = new double[NDIM];
    733736       cin >> factor[0];
     
    744747        if ((*ListRunner)->ActiveFlag) {
    745748        mol = *ListRunner;
    746         Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
     749        DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    747750        MeasureAtoms(periode, mol, configuration);
    748751      }
     
    753756        if ((*ListRunner)->ActiveFlag) {
    754757        mol = *ListRunner;
    755         Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
     758        DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    756759        RemoveAtoms(mol);
    757760      }
     761      break;
     762
     763    case 't': // turn/rotate atom
     764      for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
     765        if ((*ListRunner)->ActiveFlag) {
     766          mol = *ListRunner;
     767          DoLog(0) && (Log() << Verbose(0) << "Turning atom around another bond - first is atom to turn, second (central) and third specify bond" << endl);
     768          first = mol->AskAtom("Enter turning atom: ");
     769          second = mol->AskAtom("Enter central atom: ");
     770          third  = mol->AskAtom("Enter bond atom: ");
     771          cout << Verbose(0) << "Enter new angle in degrees: ";
     772          double tmp = 0.;
     773          cin >> tmp;
     774          // calculate old angle
     775          x.CopyVector((const Vector *)&first->x);
     776          x.SubtractVector((const Vector *)&second->x);
     777          y.CopyVector((const Vector *)&third->x);
     778          y.SubtractVector((const Vector *)&second->x);
     779          double alpha = (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.);
     780          cout << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ";
     781          cout << Verbose(0) << alpha << " degrees" << endl;
     782          // rotate
     783          z.MakeNormalVector(&x,&y);
     784          x.RotateVector(&z,(alpha-tmp)*M_PI/180.);
     785          x.AddVector(&second->x);
     786          first->x.CopyVector(&x);
     787          // check new angle
     788          x.CopyVector((const Vector *)&first->x);
     789          x.SubtractVector((const Vector *)&second->x);
     790          alpha = (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.);
     791          cout << Verbose(0) << "new Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ";
     792          cout << Verbose(0) << alpha << " degrees" << endl;
     793        }
    758794      break;
    759795
     
    763799        int Z;
    764800        mol = *ListRunner;
    765         Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
     801        DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    766802        first = NULL;
    767803        do {
    768           Log() << Verbose(0) << "Change the element of which atom: ";
     804          DoLog(0) && (Log() << Verbose(0) << "Change the element of which atom: ");
    769805          cin >> Z;
    770806        } while ((first = mol->FindAtom(Z)) == NULL);
    771         Log() << Verbose(0) << "New element by atomic number Z: ";
     807        DoLog(0) && (Log() << Verbose(0) << "New element by atomic number Z: ");
    772808        cin >> Z;
    773809        first->type = periode->FindElement(Z);
    774         Log() << Verbose(0) << "Atom " << first->nr << "'s element is " << first->type->name << "." << endl;
     810        DoLog(0) && (Log() << Verbose(0) << "Atom " << first->nr << "'s element is " << first->type->name << "." << endl);
    775811      }
    776812      break;
     
    793829  MoleculeLeafClass *Subgraphs = NULL;
    794830
    795   Log() << Verbose(0) << "=========MANIPULATE GLOBALLY===================" << endl;
    796   Log() << Verbose(0) << "c - scale by unit transformation" << endl;
    797   Log() << Verbose(0) << "d - duplicate molecule/periodic cell" << endl;
    798   Log() << Verbose(0) << "f - fragment molecule many-body bond order style" << endl;
    799   Log() << Verbose(0) << "g - center atoms in box" << endl;
    800   Log() << Verbose(0) << "i - realign molecule" << endl;
    801   Log() << Verbose(0) << "m - mirror all molecules" << endl;
    802   Log() << Verbose(0) << "o - create connection matrix" << endl;
    803   Log() << Verbose(0) << "t - translate molecule by vector" << endl;
    804   Log() << Verbose(0) << "all else - go back" << endl;
    805   Log() << Verbose(0) << "===============================================" << endl;
     831  DoLog(0) && (Log() << Verbose(0) << "=========MANIPULATE GLOBALLY===================" << endl);
     832  DoLog(0) && (Log() << Verbose(0) << "c - scale by unit transformation" << endl);
     833  DoLog(0) && (Log() << Verbose(0) << "d - duplicate molecule/periodic cell" << endl);
     834  DoLog(0) && (Log() << Verbose(0) << "f - fragment molecule many-body bond order style" << endl);
     835  DoLog(0) && (Log() << Verbose(0) << "g - center atoms in box" << endl);
     836  DoLog(0) && (Log() << Verbose(0) << "i - realign molecule" << endl);
     837  DoLog(0) && (Log() << Verbose(0) << "m - mirror all molecules" << endl);
     838  DoLog(0) && (Log() << Verbose(0) << "o - create connection matrix" << endl);
     839  DoLog(0) && (Log() << Verbose(0) << "t - translate molecule by vector" << endl);
     840  DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
     841  DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
    806842  if (molecules->NumberOfActiveMolecules() > 1)
    807     eLog() << Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl;
    808   Log() << Verbose(0) << "INPUT: ";
     843    DoeLog(2) && (eLog()<< Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl);
     844  DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    809845  cin >> choice;
    810846
    811847  switch (choice) {
    812848    default:
    813       Log() << Verbose(0) << "Not a valid choice." << endl;
     849      DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl);
    814850      break;
    815851
     
    818854        if ((*ListRunner)->ActiveFlag) {
    819855        mol = *ListRunner;
    820         Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
    821         Log() << Verbose(0) << "State the axis [(+-)123]: ";
     856        DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
     857        DoLog(0) && (Log() << Verbose(0) << "State the axis [(+-)123]: ");
    822858        cin >> axis;
    823         Log() << Verbose(0) << "State the factor: ";
     859        DoLog(0) && (Log() << Verbose(0) << "State the factor: ");
    824860        cin >> faktor;
    825861
     
    838874          }
    839875          if (count != j)
    840             eLog() << Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl;
     876            DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl);
    841877          x.Zero();
    842878          y.Zero();
    843           y.x[abs(axis)-1] = mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
     879          y.x[abs(axis)-1] = World::getInstance().getDomain()[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
    844880          for (int i=1;i<faktor;i++) {  // then add this list with respective translation factor times
    845881            x.AddVector(&y); // per factor one cell width further
     
    864900            mol->Translate(&x);
    865901          }
    866           mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
     902          World::getInstance().getDomain()[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
    867903        }
    868904      }
     
    877913        if ((*ListRunner)->ActiveFlag) {
    878914        mol = *ListRunner;
    879         Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
     915        DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    880916        CenterAtoms(mol);
    881917      }
     
    886922        if ((*ListRunner)->ActiveFlag) {
    887923        mol = *ListRunner;
    888         Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
     924        DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    889925        AlignAtoms(periode, mol);
    890926      }
     
    895931        if ((*ListRunner)->ActiveFlag) {
    896932        mol = *ListRunner;
    897         Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
     933        DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    898934        MirrorAtoms(mol);
    899935      }
     
    906942          double bonddistance;
    907943          clock_t start,end;
    908           Log() << Verbose(0) << "What's the maximum bond distance: ";
     944          DoLog(0) && (Log() << Verbose(0) << "What's the maximum bond distance: ");
    909945          cin >> bonddistance;
    910946          start = clock();
    911947          mol->CreateAdjacencyList(bonddistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
    912948          end = clock();
    913           Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
     949          DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);
    914950        }
    915951      break;
     
    919955        if ((*ListRunner)->ActiveFlag) {
    920956        mol = *ListRunner;
    921         Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
    922         Log() << Verbose(0) << "Enter translation vector." << endl;
    923         x.AskPosition(mol->cell_size,0);
     957        DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
     958        DoLog(0) && (Log() << Verbose(0) << "Enter translation vector." << endl);
     959        x.AskPosition(World::getInstance().getDomain(),0);
    924960        mol->Center.AddVector((const Vector *)&x);
    925961     }
     
    948984  molecule *mol = NULL;
    949985
    950   Log() << Verbose(0) << "==========EDIT MOLECULES=====================" << endl;
    951   Log() << Verbose(0) << "c - create new molecule" << endl;
    952   Log() << Verbose(0) << "l - load molecule from xyz file" << endl;
    953   Log() << Verbose(0) << "n - change molecule's name" << endl;
    954   Log() << Verbose(0) << "N - give molecules filename" << endl;
    955   Log() << Verbose(0) << "p - parse atoms in xyz file into molecule" << endl;
    956   Log() << Verbose(0) << "r - remove a molecule" << endl;
    957   Log() << Verbose(0) << "all else - go back" << endl;
    958   Log() << Verbose(0) << "===============================================" << endl;
    959   Log() << Verbose(0) << "INPUT: ";
     986  DoLog(0) && (Log() << Verbose(0) << "==========EDIT MOLECULES=====================" << endl);
     987  DoLog(0) && (Log() << Verbose(0) << "c - create new molecule" << endl);
     988  DoLog(0) && (Log() << Verbose(0) << "l - load molecule from xyz file" << endl);
     989  DoLog(0) && (Log() << Verbose(0) << "n - change molecule's name" << endl);
     990  DoLog(0) && (Log() << Verbose(0) << "N - give molecules filename" << endl);
     991  DoLog(0) && (Log() << Verbose(0) << "p - parse atoms in xyz file into molecule" << endl);
     992  DoLog(0) && (Log() << Verbose(0) << "r - remove a molecule" << endl);
     993  DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
     994  DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
     995  DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    960996  cin >> choice;
    961997
    962998  switch (choice) {
    963999    default:
    964       Log() << Verbose(0) << "Not a valid choice." << endl;
     1000      DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl);
    9651001      break;
    9661002    case 'c':
    967       mol = new molecule(periode);
     1003      mol = World::getInstance().createMolecule();
    9681004      molecules->insert(mol);
    9691005      break;
     
    9721008      {
    9731009        char filename[MAXSTRINGSIZE];
    974         Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl;
    975         mol = new molecule(periode);
     1010        DoLog(0) && (Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl);
     1011        mol = World::getInstance().createMolecule();
    9761012        do {
    977           Log() << Verbose(0) << "Enter file name: ";
     1013          DoLog(0) && (Log() << Verbose(0) << "Enter file name: ");
    9781014          cin >> filename;
    9791015        } while (!mol->AddXYZFile(filename));
     
    9811017        // center at set box dimensions
    9821018        mol->CenterEdge(&center);
    983         mol->cell_size[0] = center.x[0];
    984         mol->cell_size[1] = 0;
    985         mol->cell_size[2] = center.x[1];
    986         mol->cell_size[3] = 0;
    987         mol->cell_size[4] = 0;
    988         mol->cell_size[5] = center.x[2];
     1019        double * const cell_size = World::getInstance().getDomain();
     1020        cell_size[0] = center.x[0];
     1021        cell_size[1] = 0;
     1022        cell_size[2] = center.x[1];
     1023        cell_size[3] = 0;
     1024        cell_size[4] = 0;
     1025        cell_size[5] = center.x[2];
    9891026        molecules->insert(mol);
    9901027      }
     
    9951032        char filename[MAXSTRINGSIZE];
    9961033        do {
    997           Log() << Verbose(0) << "Enter index of molecule: ";
     1034          DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: ");
    9981035          cin >> nr;
    9991036          mol = molecules->ReturnIndex(nr);
    10001037        } while (mol == NULL);
    1001         Log() << Verbose(0) << "Enter name: ";
     1038        DoLog(0) && (Log() << Verbose(0) << "Enter name: ");
    10021039        cin >> filename;
    10031040        strcpy(mol->name, filename);
     
    10091046        char filename[MAXSTRINGSIZE];
    10101047        do {
    1011           Log() << Verbose(0) << "Enter index of molecule: ";
     1048          DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: ");
    10121049          cin >> nr;
    10131050          mol = molecules->ReturnIndex(nr);
    10141051        } while (mol == NULL);
    1015         Log() << Verbose(0) << "Enter name: ";
     1052        DoLog(0) && (Log() << Verbose(0) << "Enter name: ");
    10161053        cin >> filename;
    10171054        mol->SetNameFromFilename(filename);
     
    10241061        mol = NULL;
    10251062        do {
    1026           Log() << Verbose(0) << "Enter index of molecule: ";
     1063          DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: ");
    10271064          cin >> nr;
    10281065          mol = molecules->ReturnIndex(nr);
    10291066        } while (mol == NULL);
    1030         Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl;
     1067        DoLog(0) && (Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl);
    10311068        do {
    1032           Log() << Verbose(0) << "Enter file name: ";
     1069          DoLog(0) && (Log() << Verbose(0) << "Enter file name: ");
    10331070          cin >> filename;
    10341071        } while (!mol->AddXYZFile(filename));
     
    10381075
    10391076    case 'r':
    1040       Log() << Verbose(0) << "Enter index of molecule: ";
     1077      DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: ");
    10411078      cin >> nr;
    10421079      count = 1;
     
    10611098  char choice;  // menu choice char
    10621099
    1063   Log() << Verbose(0) << "===========MERGE MOLECULES=====================" << endl;
    1064   Log() << Verbose(0) << "a - simple add of one molecule to another" << endl;
    1065   Log() << Verbose(0) << "e - embedding merge of two molecules" << endl;
    1066   Log() << Verbose(0) << "m - multi-merge of all molecules" << endl;
    1067   Log() << Verbose(0) << "s - scatter merge of two molecules" << endl;
    1068   Log() << Verbose(0) << "t - simple merge of two molecules" << endl;
    1069   Log() << Verbose(0) << "all else - go back" << endl;
    1070   Log() << Verbose(0) << "===============================================" << endl;
    1071   Log() << Verbose(0) << "INPUT: ";
     1100  DoLog(0) && (Log() << Verbose(0) << "===========MERGE MOLECULES=====================" << endl);
     1101  DoLog(0) && (Log() << Verbose(0) << "a - simple add of one molecule to another" << endl);
     1102  DoLog(0) && (Log() << Verbose(0) << "b - count the number of bonds of two elements" << endl);
     1103  DoLog(0) && (Log() << Verbose(0) << "B - count the number of bonds of three elements " << endl);
     1104  DoLog(0) && (Log() << Verbose(0) << "e - embedding merge of two molecules" << endl);
     1105  DoLog(0) && (Log() << Verbose(0) << "h - count the number of hydrogen bonds" << endl);
     1106  DoLog(0) && (Log() << Verbose(0) << "b - count the number of hydrogen bonds" << endl);
     1107  DoLog(0) && (Log() << Verbose(0) << "m - multi-merge of all molecules" << endl);
     1108  DoLog(0) && (Log() << Verbose(0) << "s - scatter merge of two molecules" << endl);
     1109  DoLog(0) && (Log() << Verbose(0) << "t - simple merge of two molecules" << endl);
     1110  DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
     1111  DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
     1112  DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    10721113  cin >> choice;
    10731114
    10741115  switch (choice) {
    10751116    default:
    1076       Log() << Verbose(0) << "Not a valid choice." << endl;
     1117      DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl);
    10771118      break;
    10781119
     
    10831124        {
    10841125          do {
    1085             Log() << Verbose(0) << "Enter index of destination molecule: ";
     1126            DoLog(0) && (Log() << Verbose(0) << "Enter index of destination molecule: ");
    10861127            cin >> dest;
    10871128            destmol = molecules->ReturnIndex(dest);
    10881129          } while ((destmol == NULL) && (dest != -1));
    10891130          do {
    1090             Log() << Verbose(0) << "Enter index of source molecule to add from: ";
     1131            DoLog(0) && (Log() << Verbose(0) << "Enter index of source molecule to add from: ");
    10911132            cin >> src;
    10921133            srcmol = molecules->ReturnIndex(src);
     
    10981139      break;
    10991140
     1141    case 'b':
     1142      {
     1143        const int nr = 2;
     1144        char *names[nr] = {"first", "second"};
     1145        int Z[nr];
     1146        element *elements[nr];
     1147        for (int i=0;i<nr;i++) {
     1148          Z[i] = 0;
     1149          do {
     1150            cout << "Enter " << names[i] << " element: ";
     1151            cin >> Z[i];
     1152          } while ((Z[i] <= 0) && (Z[i] > MAX_ELEMENTS));
     1153          elements[i] = periode->FindElement(Z[i]);
     1154        }
     1155        const int count = CountBondsOfTwo(molecules, elements[0], elements[1]);
     1156        cout << endl << "There are " << count << " ";
     1157        for (int i=0;i<nr;i++) {
     1158          if (i==0)
     1159            cout << elements[i]->symbol;
     1160          else
     1161            cout << "-" << elements[i]->symbol;
     1162        }
     1163        cout << " bonds." << endl;
     1164      }
     1165    break;
     1166
     1167    case 'B':
     1168      {
     1169        const int nr = 3;
     1170        char *names[nr] = {"first", "second", "third"};
     1171        int Z[nr];
     1172        element *elements[nr];
     1173        for (int i=0;i<nr;i++) {
     1174          Z[i] = 0;
     1175          do {
     1176            cout << "Enter " << names[i] << " element: ";
     1177            cin >> Z[i];
     1178          } while ((Z[i] <= 0) && (Z[i] > MAX_ELEMENTS));
     1179          elements[i] = periode->FindElement(Z[i]);
     1180        }
     1181        const int count = CountBondsOfThree(molecules, elements[0], elements[1], elements[2]);
     1182        cout << endl << "There are " << count << " ";
     1183        for (int i=0;i<nr;i++) {
     1184          if (i==0)
     1185            cout << elements[i]->symbol;
     1186          else
     1187            cout << "-" << elements[i]->symbol;
     1188        }
     1189        cout << " bonds." << endl;
     1190      }
     1191    break;
     1192
    11001193    case 'e':
    11011194      {
     
    11031196        molecule *srcmol = NULL, *destmol = NULL;
    11041197        do {
    1105           Log() << Verbose(0) << "Enter index of matrix molecule (the variable one): ";
     1198          DoLog(0) && (Log() << Verbose(0) << "Enter index of matrix molecule (the variable one): ");
    11061199          cin >> src;
    11071200          srcmol = molecules->ReturnIndex(src);
    11081201        } while ((srcmol == NULL) && (src != -1));
    11091202        do {
    1110           Log() << Verbose(0) << "Enter index of molecule to merge into (the fixed one): ";
     1203          DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule to merge into (the fixed one): ");
    11111204          cin >> dest;
    11121205          destmol = molecules->ReturnIndex(dest);
     
    11171210      break;
    11181211
     1212    case 'h':
     1213      {
     1214        int Z;
     1215        cout << "Please enter interface element: ";
     1216        cin >> Z;
     1217        element * const InterfaceElement = periode->FindElement(Z);
     1218        cout << endl << "There are " << CountHydrogenBridgeBonds(molecules, InterfaceElement) << " hydrogen bridges with connections to " << (InterfaceElement != 0 ? InterfaceElement->name : "None") << "." << endl;
     1219      }
     1220      break;
     1221
    11191222    case 'm':
    11201223      {
     
    11221225        molecule *mol = NULL;
    11231226        do {
    1124           Log() << Verbose(0) << "Enter index of molecule to merge into: ";
     1227          DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule to merge into: ");
    11251228          cin >> nr;
    11261229          mol = molecules->ReturnIndex(nr);
     
    11391242
    11401243    case 's':
    1141       Log() << Verbose(0) << "Not implemented yet." << endl;
     1244      DoLog(0) && (Log() << Verbose(0) << "Not implemented yet." << endl);
    11421245      break;
    11431246
     
    11481251        {
    11491252          do {
    1150             Log() << Verbose(0) << "Enter index of destination molecule: ";
     1253            DoLog(0) && (Log() << Verbose(0) << "Enter index of destination molecule: ");
    11511254            cin >> dest;
    11521255            destmol = molecules->ReturnIndex(dest);
    11531256          } while ((destmol == NULL) && (dest != -1));
    11541257          do {
    1155             Log() << Verbose(0) << "Enter index of source molecule to merge into: ";
     1258            DoLog(0) && (Log() << Verbose(0) << "Enter index of source molecule to merge into: ");
    11561259            cin >> src;
    11571260            srcmol = molecules->ReturnIndex(src);
     
    11811284    mol = (molecules->ListOfMolecules.front())->CopyMolecule();
    11821285  else {
    1183     eLog() << Verbose(0) << "I don't have anything to test on ... ";
     1286    DoeLog(0) && (eLog()<< Verbose(0) << "I don't have anything to test on ... ");
    11841287    performCriticalExit();
    11851288    return;
     
    11881291
    11891292  // generate some KeySets
    1190   Log() << Verbose(0) << "Generating KeySets." << endl;
     1293  DoLog(0) && (Log() << Verbose(0) << "Generating KeySets." << endl);
    11911294  KeySet TestSets[mol->AtomCount+1];
    11921295  i=1;
     
    11981301    i++;
    11991302  }
    1200   Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl;
     1303  DoLog(0) && (Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl);
    12011304  KeySetTestPair test;
    12021305  test = TestSets[mol->AtomCount-1].insert(Walker->nr);
    12031306  if (test.second) {
    1204     Log() << Verbose(1) << "Insertion worked?!" << endl;
     1307    DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl);
    12051308  } else {
    1206     Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl;
     1309    DoLog(1) && (Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl);
    12071310  }
    12081311  TestSets[mol->AtomCount].insert(mol->end->previous->nr);
     
    12101313
    12111314  // constructing Graph structure
    1212   Log() << Verbose(0) << "Generating Subgraph class." << endl;
     1315  DoLog(0) && (Log() << Verbose(0) << "Generating Subgraph class." << endl);
    12131316  Graph Subgraphs;
    12141317
    12151318  // insert KeySets into Subgraphs
    1216   Log() << Verbose(0) << "Inserting KeySets into Subgraph class." << endl;
     1319  DoLog(0) && (Log() << Verbose(0) << "Inserting KeySets into Subgraph class." << endl);
    12171320  for (int j=0;j<mol->AtomCount;j++) {
    12181321    Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.)));
    12191322  }
    1220   Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl;
     1323  DoLog(0) && (Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl);
    12211324  GraphTestPair test2;
    12221325  test2 = Subgraphs.insert(GraphPair (TestSets[mol->AtomCount],pair<int, double>(counter++, 1.)));
    12231326  if (test2.second) {
    1224     Log() << Verbose(1) << "Insertion worked?!" << endl;
     1327    DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl);
    12251328  } else {
    1226     Log() << Verbose(1) << "Insertion rejected: Present object is " << (*(test2.first)).second.first << "." << endl;
     1329    DoLog(1) && (Log() << Verbose(1) << "Insertion rejected: Present object is " << (*(test2.first)).second.first << "." << endl);
    12271330  }
    12281331
    12291332  // show graphs
    1230   Log() << Verbose(0) << "Showing Subgraph's contents, checking that it's sorted." << endl;
     1333  DoLog(0) && (Log() << Verbose(0) << "Showing Subgraph's contents, checking that it's sorted." << endl);
    12311334  Graph::iterator A = Subgraphs.begin();
    12321335  while (A !=  Subgraphs.end()) {
    1233     Log() << Verbose(0) << (*A).second.first << ": ";
     1336    DoLog(0) && (Log() << Verbose(0) << (*A).second.first << ": ");
    12341337    KeySet::iterator key = (*A).first.begin();
    12351338    comp = -1;
    12361339    while (key != (*A).first.end()) {
    12371340      if ((*key) > comp)
    1238         Log() << Verbose(0) << (*key) << " ";
     1341        DoLog(0) && (Log() << Verbose(0) << (*key) << " ");
    12391342      else
    1240         Log() << Verbose(0) << (*key) << "! ";
     1343        DoLog(0) && (Log() << Verbose(0) << (*key) << "! ");
    12411344      comp = (*key);
    12421345      key++;
    12431346    }
    1244     Log() << Verbose(0) << endl;
     1347    DoLog(0) && (Log() << Verbose(0) << endl);
    12451348    A++;
    12461349  }
     
    12491352
    12501353#endif
     1354
     1355/** Tries given filename or standard on saving the config file.
     1356 * \param *ConfigFileName name of file
     1357 * \param *configuration pointer to configuration structure with all the values
     1358 * \param *periode pointer to periodentafel structure with all the elements
     1359 * \param *molecules list of molecules structure with all the atoms and coordinates
     1360 */
     1361static void SaveConfig(char *ConfigFileName, config *configuration, periodentafel *periode, MoleculeListClass *molecules)
     1362{
     1363  char filename[MAXSTRINGSIZE];
     1364  ofstream output;
     1365  molecule *mol = World::getInstance().createMolecule();
     1366  mol->SetNameFromFilename(ConfigFileName);
     1367
     1368  if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) {
     1369    DoeLog(2) && (eLog()<< Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl);
     1370  }
     1371
     1372
     1373  // first save as PDB data
     1374  if (ConfigFileName != NULL)
     1375    strcpy(filename, ConfigFileName);
     1376  if (output == NULL)
     1377    strcpy(filename,"main_pcp_linux");
     1378  DoLog(0) && (Log() << Verbose(0) << "Saving as pdb input ");
     1379  if (configuration->SavePDB(filename, molecules))
     1380    DoLog(0) && (Log() << Verbose(0) << "done." << endl);
     1381  else
     1382    DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
     1383
     1384  // then save as tremolo data file
     1385  if (ConfigFileName != NULL)
     1386    strcpy(filename, ConfigFileName);
     1387  if (output == NULL)
     1388    strcpy(filename,"main_pcp_linux");
     1389  DoLog(0) && (Log() << Verbose(0) << "Saving as tremolo data input ");
     1390  if (configuration->SaveTREMOLO(filename, molecules))
     1391    DoLog(0) && (Log() << Verbose(0) << "done." << endl);
     1392  else
     1393    DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
     1394
     1395  // translate each to its center and merge all molecules in MoleculeListClass into this molecule
     1396  int N = molecules->ListOfMolecules.size();
     1397  int *src = new int[N];
     1398  N=0;
     1399  for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {
     1400    src[N++] = (*ListRunner)->IndexNr;
     1401    (*ListRunner)->Translate(&(*ListRunner)->Center);
     1402  }
     1403  molecules->SimpleMultiAdd(mol, src, N);
     1404  delete[](src);
     1405
     1406  // ... and translate back
     1407  for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {
     1408    (*ListRunner)->Center.Scale(-1.);
     1409    (*ListRunner)->Translate(&(*ListRunner)->Center);
     1410    (*ListRunner)->Center.Scale(-1.);
     1411  }
     1412
     1413  DoLog(0) && (Log() << Verbose(0) << "Storing configuration ... " << endl);
     1414  // get correct valence orbitals
     1415  mol->CalculateOrbitals(*configuration);
     1416  configuration->InitMaxMinStopStep = configuration->MaxMinStopStep = configuration->MaxPsiDouble;
     1417  if (ConfigFileName != NULL) { // test the file name
     1418    strcpy(filename, ConfigFileName);
     1419    output.open(filename, ios::trunc);
     1420  } else if (strlen(configuration->configname) != 0) {
     1421    strcpy(filename, configuration->configname);
     1422    output.open(configuration->configname, ios::trunc);
     1423    } else {
     1424      strcpy(filename, DEFAULTCONFIG);
     1425      output.open(DEFAULTCONFIG, ios::trunc);
     1426    }
     1427  output.close();
     1428  output.clear();
     1429  DoLog(0) && (Log() << Verbose(0) << "Saving of config file ");
     1430  if (configuration->Save(filename, periode, mol))
     1431    DoLog(0) && (Log() << Verbose(0) << "successful." << endl);
     1432  else
     1433    DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
     1434
     1435  // and save to xyz file
     1436  if (ConfigFileName != NULL) {
     1437    strcpy(filename, ConfigFileName);
     1438    strcat(filename, ".xyz");
     1439    output.open(filename, ios::trunc);
     1440  }
     1441  if (output == NULL) {
     1442    strcpy(filename,"main_pcp_linux");
     1443    strcat(filename, ".xyz");
     1444    output.open(filename, ios::trunc);
     1445  }
     1446  DoLog(0) && (Log() << Verbose(0) << "Saving of XYZ file ");
     1447  if (mol->MDSteps <= 1) {
     1448    if (mol->OutputXYZ(&output))
     1449      DoLog(0) && (Log() << Verbose(0) << "successful." << endl);
     1450    else
     1451      DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
     1452  } else {
     1453    if (mol->OutputTrajectoriesXYZ(&output))
     1454      DoLog(0) && (Log() << Verbose(0) << "successful." << endl);
     1455    else
     1456      DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
     1457  }
     1458  output.close();
     1459  output.clear();
     1460
     1461  // and save as MPQC configuration
     1462  if (ConfigFileName != NULL)
     1463    strcpy(filename, ConfigFileName);
     1464  if (output == NULL)
     1465    strcpy(filename,"main_pcp_linux");
     1466  DoLog(0) && (Log() << Verbose(0) << "Saving as mpqc input ");
     1467  if (configuration->SaveMPQC(filename, mol))
     1468    DoLog(0) && (Log() << Verbose(0) << "done." << endl);
     1469  else
     1470    DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
     1471
     1472  if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) {
     1473    DoeLog(2) && (eLog()<< Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl);
     1474  }
     1475
     1476  World::getInstance().destroyMolecule(mol);
     1477};
    12511478
    12521479/** Parses the command line options.
     
    12751502  enum ConfigStatus configPresent = absent;
    12761503  clock_t start,end;
     1504  double MaxDistance = -1;
    12771505  int argptr;
    12781506  molecule *mol = NULL;
     
    12861514    do {
    12871515      if (argv[argptr][0] == '-') {
    1288         Log() << Verbose(0) << "Recognized command line argument: " << argv[argptr][1] << ".\n";
     1516        DoLog(0) && (Log() << Verbose(0) << "Recognized command line argument: " << argv[argptr][1] << ".\n");
    12891517        argptr++;
    12901518        switch(argv[argptr-1][1]) {
     
    12921520          case 'H':
    12931521          case '?':
    1294             Log() << Verbose(0) << "MoleCuilder suite" << endl << "==================" << endl << endl;
    1295             Log() << Verbose(0) << "Usage: " << argv[0] << "[config file] [-{acefpsthH?vfrp}] [further arguments]" << endl;
    1296             Log() << Verbose(0) << "or simply " << argv[0] << " without arguments for interactive session." << endl;
    1297             Log() << Verbose(0) << "\t-a Z x1 x2 x3\tAdd new atom of element Z at coordinates (x1,x2,x3)." << endl;
    1298             Log() << Verbose(0) << "\t-A <source>\tCreate adjacency list from bonds parsed from 'dbond'-style file." <<endl;
    1299             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;
    1300             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;
    1301             Log() << Verbose(0) << "\t-c x1 x2 x3\tCenter atoms in domain with a minimum distance to boundary of (x1,x2,x3)." << endl;
    1302             Log() << Verbose(0) << "\t-C <Z> <output> <bin output>\tPair Correlation analysis." << endl;
    1303             Log() << Verbose(0) << "\t-d x1 x2 x3\tDuplicate cell along each axis by given factor." << endl;
    1304             Log() << Verbose(0) << "\t-D <bond distance>\tDepth-First-Search Analysis of the molecule, giving cycles and tree/back edges." << endl;
    1305             Log() << Verbose(0) << "\t-e <file>\tSets the databases path to be parsed (default: ./)." << endl;
    1306             Log() << Verbose(0) << "\t-E <id> <Z>\tChange atom <id>'s element to <Z>, <id> begins at 0." << endl;
    1307             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;
    1308             Log() << Verbose(0) << "\t-F <dist_x> <dist_y> <dist_z> <epsilon> <randatom> <randmol> <DoRotate>\tFilling Box with water molecules." << endl;
    1309             Log() << Verbose(0) << "\t-g <file>\tParses a bond length table from the given file." << endl;
    1310             Log() << Verbose(0) << "\t-h/-H/-?\tGive this help screen." << endl;
    1311             Log() << Verbose(0) << "\t-I\t Dissect current system of molecules into a set of disconnected (subgraphs of) molecules." << endl;
    1312             Log() << Verbose(0) << "\t-j\t<path> Store all bonds to file." << endl;
    1313             Log() << Verbose(0) << "\t-J\t<path> Store adjacency per atom to file." << endl;
    1314             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;
    1315             Log() << Verbose(0) << "\t-m <0/1>\tCalculate (0)/ Align in(1) PAS with greatest EV along z axis." << endl;
    1316             Log() << Verbose(0) << "\t-M <basis>\tSetting basis to store to MPQC config files." << endl;
    1317             Log() << Verbose(0) << "\t-n\tFast parsing (i.e. no trajectories are looked for)." << endl;
    1318             Log() << Verbose(0) << "\t-N <radius> <file>\tGet non-convex-envelope." << endl;
    1319             Log() << Verbose(0) << "\t-o <out>\tGet volume of the convex envelope (and store to tecplot file)." << endl;
    1320             Log() << Verbose(0) << "\t-O\tCenter atoms in origin." << endl;
    1321             Log() << Verbose(0) << "\t-p <file>\tParse given xyz file and create raw config file from it." << endl;
    1322             Log() << Verbose(0) << "\t-P <file>\tParse given forces file and append as an MD step to config file via Verlet." << endl;
    1323             Log() << Verbose(0) << "\t-r <id>\t\tRemove an atom with given id." << endl;
    1324             Log() << Verbose(0) << "\t-R <id> <radius>\t\tRemove all atoms out of sphere around a given one." << endl;
    1325             Log() << Verbose(0) << "\t-s x1 x2 x3\tScale all atom coordinates by this vector (x1,x2,x3)." << endl;
    1326             Log() << Verbose(0) << "\t-S <file> Store temperatures from the config file in <file>." << endl;
    1327             Log() << Verbose(0) << "\t-t x1 x2 x3\tTranslate all atoms by this vector (x1,x2,x3)." << endl;
    1328             Log() << Verbose(0) << "\t-T x1 x2 x3\tTranslate periodically all atoms by this vector (x1,x2,x3)." << endl;
    1329             Log() << Verbose(0) << "\t-u rho\tsuspend in water solution and output necessary cell lengths, average density rho and repetition." << endl;
    1330             Log() << Verbose(0) << "\t-v\t\tsets verbosity (more is more)." << endl;
    1331             Log() << Verbose(0) << "\t-V\t\tGives version information." << endl;
    1332             Log() << Verbose(0) << "Note: config files must not begin with '-' !" << endl;
     1522            DoLog(0) && (Log() << Verbose(0) << "MoleCuilder suite" << endl << "==================" << endl << endl);
     1523            DoLog(0) && (Log() << Verbose(0) << "Usage: " << argv[0] << "[config file] [-{acefpsthH?vfrp}] [further arguments]" << endl);
     1524            DoLog(0) && (Log() << Verbose(0) << "or simply " << argv[0] << " without arguments for interactive session." << endl);
     1525            DoLog(0) && (Log() << Verbose(0) << "\t-a Z x1 x2 x3\tAdd new atom of element Z at coordinates (x1,x2,x3)." << endl);
     1526            DoLog(0) && (Log() << Verbose(0) << "\t-A <source>\tCreate adjacency list from bonds parsed from 'dbond'-style file." <<endl);
     1527            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);
     1528            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);
     1529            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);
     1530            DoLog(0) && (Log() << Verbose(0) << "\t-C <type> [params] <output> <bin output> <BinWidth> <BinStart> <BinEnd>\tPair Correlation analysis." << endl);
     1531            DoLog(0) && (Log() << Verbose(0) << "\t-d x1 x2 x3\tDuplicate cell along each axis by given factor." << endl);
     1532            DoLog(0) && (Log() << Verbose(0) << "\t-D <bond distance>\tDepth-First-Search Analysis of the molecule, giving cycles and tree/back edges." << endl);
     1533            DoLog(0) && (Log() << Verbose(0) << "\t-e <file>\tSets the databases path to be parsed (default: ./)." << endl);
     1534            DoLog(0) && (Log() << Verbose(0) << "\t-E <id> <Z>\tChange atom <id>'s element to <Z>, <id> begins at 0." << endl);
     1535            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);
     1536            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);
     1537            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);
     1538            DoLog(0) && (Log() << Verbose(0) << "\t-g <file>\tParses a bond length table from the given file." << endl);
     1539            DoLog(0) && (Log() << Verbose(0) << "\t-h/-H/-?\tGive this help screen." << endl);
     1540            DoLog(0) && (Log() << Verbose(0) << "\t-I\t Dissect current system of molecules into a set of disconnected (subgraphs of) molecules." << endl);
     1541            DoLog(0) && (Log() << Verbose(0) << "\t-j\t<path> Store all bonds to file." << endl);
     1542            DoLog(0) && (Log() << Verbose(0) << "\t-J\t<path> Store adjacency per atom to file." << endl);
     1543            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);
     1544            DoLog(0) && (Log() << Verbose(0) << "\t-m <0/1>\tCalculate (0)/ Align in(1) PAS with greatest EV along z axis." << endl);
     1545            DoLog(0) && (Log() << Verbose(0) << "\t-M <basis>\tSetting basis to store to MPQC config files." << endl);
     1546            DoLog(0) && (Log() << Verbose(0) << "\t-n\tFast parsing (i.e. no trajectories are looked for)." << endl);
     1547            DoLog(0) && (Log() << Verbose(0) << "\t-N <radius> <file>\tGet non-convex-envelope." << endl);
     1548            DoLog(0) && (Log() << Verbose(0) << "\t-o <out>\tGet volume of the convex envelope (and store to tecplot file)." << endl);
     1549            DoLog(0) && (Log() << Verbose(0) << "\t-O\tCenter atoms in origin." << endl);
     1550            DoLog(0) && (Log() << Verbose(0) << "\t-p <file>\tParse given xyz file and create raw config file from it." << endl);
     1551            DoLog(0) && (Log() << Verbose(0) << "\t-P <file>\tParse given forces file and append as an MD step to config file via Verlet." << endl);
     1552            DoLog(0) && (Log() << Verbose(0) << "\t-r <id>\t\tRemove an atom with given id." << endl);
     1553            DoLog(0) && (Log() << Verbose(0) << "\t-R <id> <radius>\t\tRemove all atoms out of sphere around a given one." << endl);
     1554            DoLog(0) && (Log() << Verbose(0) << "\t-s x1 x2 x3\tScale all atom coordinates by this vector (x1,x2,x3)." << endl);
     1555            DoLog(0) && (Log() << Verbose(0) << "\t-S <file> Store temperatures from the config file in <file>." << endl);
     1556            DoLog(0) && (Log() << Verbose(0) << "\t-t x1 x2 x3\tTranslate all atoms by this vector (x1,x2,x3)." << endl);
     1557            DoLog(0) && (Log() << Verbose(0) << "\t-T x1 x2 x3\tTranslate periodically all atoms by this vector (x1,x2,x3)." << endl);
     1558            DoLog(0) && (Log() << Verbose(0) << "\t-u rho\tsuspend in water solution and output necessary cell lengths, average density rho and repetition." << endl);
     1559            DoLog(0) && (Log() << Verbose(0) << "\t-v\t\tsets verbosity (more is more)." << endl);
     1560            DoLog(0) && (Log() << Verbose(0) << "\t-V\t\tGives version information." << endl);
     1561            DoLog(0) && (Log() << Verbose(0) << "\t-X\t\tset default name of a molecule." << endl);
     1562            DoLog(0) && (Log() << Verbose(0) << "Note: config files must not begin with '-' !" << endl);
    13331563            return (1);
    13341564            break;
     
    13381568            }
    13391569            setVerbosity(verbosity);
    1340             Log() << Verbose(0) << "Setting verbosity to " << verbosity << "." << endl;
     1570            DoLog(0) && (Log() << Verbose(0) << "Setting verbosity to " << verbosity << "." << endl);
    13411571            break;
    13421572          case 'V':
    1343             Log() << Verbose(0) << argv[0] << " " << VERSIONSTRING << endl;
    1344             Log() << Verbose(0) << "Build your own molecule position set." << endl;
     1573            DoLog(0) && (Log() << Verbose(0) << argv[0] << " " << VERSIONSTRING << endl);
     1574            DoLog(0) && (Log() << Verbose(0) << "Build your own molecule position set." << endl);
    13451575            return (1);
     1576            break;
     1577          case 'B':
     1578            if (ExitFlag == 0) ExitFlag = 1;
     1579            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])) ) {
     1580              ExitFlag = 255;
     1581              DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for bounding in box: -B <xx> <xy> <xz> <yy> <yz> <zz>" << endl);
     1582              performCriticalExit();
     1583            } else {
     1584              SaveFlag = true;
     1585              j = -1;
     1586              DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl);
     1587              double * const cell_size = World::getInstance().getDomain();
     1588              for (int i=0;i<6;i++) {
     1589                cell_size[i] = atof(argv[argptr+i]);
     1590              }
     1591              argptr+=6;
     1592            }
    13461593            break;
    13471594          case 'e':
    13481595            if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    1349               eLog() << Verbose(0) << "Not enough or invalid arguments for specifying element db: -e <db file>" << endl;
     1596              DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for specifying element db: -e <db file>" << endl);
    13501597              performCriticalExit();
    13511598            } else {
    1352               Log() << Verbose(0) << "Using " << argv[argptr] << " as elements database." << endl;
     1599              DoLog(0) && (Log() << Verbose(0) << "Using " << argv[argptr] << " as elements database." << endl);
    13531600              strncpy (configuration.databasepath, argv[argptr], MAXSTRINGSIZE-1);
    13541601              argptr+=1;
     
    13571604          case 'g':
    13581605            if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    1359               eLog() << Verbose(0) << "Not enough or invalid arguments for specifying bond length table: -g <table file>" << endl;
     1606              DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for specifying bond length table: -g <table file>" << endl);
    13601607              performCriticalExit();
    13611608            } else {
    13621609              BondGraphFileName = argv[argptr];
    1363               Log() << Verbose(0) << "Using " << BondGraphFileName << " as bond length table." << endl;
     1610              DoLog(0) && (Log() << Verbose(0) << "Using " << BondGraphFileName << " as bond length table." << endl);
    13641611              argptr+=1;
    13651612            }
    13661613            break;
    13671614          case 'n':
    1368             Log() << Verbose(0) << "I won't parse trajectories." << endl;
     1615            DoLog(0) && (Log() << Verbose(0) << "I won't parse trajectories." << endl);
    13691616            configuration.FastParsing = true;
     1617            break;
     1618          case 'X':
     1619            {
     1620              World::getInstance().setDefaultName(argv[argptr]);
     1621              DoLog(0) && (Log() << Verbose(0) << "Default name of new molecules set to " << *World::getInstance().getDefaultName() << "." << endl);
     1622            }
    13701623            break;
    13711624          default:   // no match? Step on
     
    13791632    // 3a. Parse the element database
    13801633    if (periode->LoadPeriodentafel(configuration.databasepath)) {
    1381       Log() << Verbose(0) << "Element list loaded successfully." << endl;
     1634      DoLog(0) && (Log() << Verbose(0) << "Element list loaded successfully." << endl);
    13821635      //periode->Output();
    13831636    } else {
    1384       Log() << Verbose(0) << "Element list loading failed." << endl;
     1637      DoLog(0) && (Log() << Verbose(0) << "Element list loading failed." << endl);
    13851638      return 1;
    13861639    }
     
    13881641    if (argv[1][0] != '-') {
    13891642      // simply create a new molecule, wherein the config file is loaded and the manipulation takes place
    1390       Log() << Verbose(0) << "Config file given." << endl;
     1643      DoLog(0) && (Log() << Verbose(0) << "Config file given." << endl);
    13911644      test.open(argv[1], ios::in);
    13921645      if (test == NULL) {
     
    13941647        output.open(argv[1], ios::out);
    13951648        if (output == NULL) {
    1396           Log() << Verbose(1) << "Specified config file " << argv[1] << " not found." << endl;
     1649          DoLog(1) && (Log() << Verbose(1) << "Specified config file " << argv[1] << " not found." << endl);
    13971650          configPresent = absent;
    13981651        } else {
    1399           Log() << Verbose(0) << "Empty configuration file." << endl;
     1652          DoLog(0) && (Log() << Verbose(0) << "Empty configuration file." << endl);
    14001653          ConfigFileName = argv[1];
    14011654          configPresent = empty;
     
    14051658        test.close();
    14061659        ConfigFileName = argv[1];
    1407         Log() << Verbose(1) << "Specified config file found, parsing ... ";
     1660        DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... ");
    14081661        switch (configuration.TestSyntax(ConfigFileName, periode)) {
    14091662          case 1:
    1410             Log() << Verbose(0) << "new syntax." << endl;
     1663            DoLog(0) && (Log() << Verbose(0) << "new syntax." << endl);
    14111664            configuration.Load(ConfigFileName, BondGraphFileName, periode, molecules);
    14121665            configPresent = present;
    14131666            break;
    14141667          case 0:
    1415             Log() << Verbose(0) << "old syntax." << endl;
     1668            DoLog(0) && (Log() << Verbose(0) << "old syntax." << endl);
    14161669            configuration.LoadOld(ConfigFileName, BondGraphFileName, periode, molecules);
    14171670            configPresent = present;
    14181671            break;
    14191672          default:
    1420             Log() << Verbose(0) << "Unknown syntax or empty, yet present file." << endl;
     1673            DoLog(0) && (Log() << Verbose(0) << "Unknown syntax or empty, yet present file." << endl);
    14211674            configPresent = empty;
    14221675       }
     
    14421695       configuration.BG = new BondGraph(configuration.GetIsAngstroem());
    14431696       if ((!BondGraphFileName.empty()) && (configuration.BG->LoadBondLengthTable(BondGraphFileName))) {
    1444          Log() << Verbose(0) << "Bond length table loaded successfully." << endl;
     1697         DoLog(0) && (Log() << Verbose(0) << "Bond length table loaded successfully." << endl);
    14451698       } else {
    1446          eLog() << Verbose(1) << "Bond length table loading failed." << endl;
     1699         DoeLog(1) && (eLog()<< Verbose(1) << "Bond length table loading failed." << endl);
    14471700       }
    14481701     }
     
    14511704    argptr = 1;
    14521705    do {
    1453       Log() << Verbose(0) << "Current Command line argument: " << argv[argptr] << "." << endl;
     1706      DoLog(0) && (Log() << Verbose(0) << "Current Command line argument: " << argv[argptr] << "." << endl);
    14541707      if (argv[argptr][0] == '-') {
    14551708        argptr++;
     
    14601713              if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    14611714                ExitFlag = 255;
    1462                 eLog() << Verbose(0) << "Not enough arguments for parsing: -p <xyz file>" << endl;
     1715                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough arguments for parsing: -p <xyz file>" << endl);
    14631716                performCriticalExit();
    14641717              } else {
    14651718                SaveFlag = true;
    1466                 Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl;
     1719                DoLog(1) && (Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl);
    14671720                if (!mol->AddXYZFile(argv[argptr]))
    1468                   Log() << Verbose(2) << "File not found." << endl;
     1721                  DoLog(2) && (Log() << Verbose(2) << "File not found." << endl);
    14691722                else {
    1470                   Log() << Verbose(2) << "File found and parsed." << endl;
     1723                  DoLog(2) && (Log() << Verbose(2) << "File found and parsed." << endl);
    14711724                  configPresent = present;
    14721725                }
     
    14771730              if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3]))) {
    14781731                ExitFlag = 255;
    1479                 eLog() << Verbose(0) << "Not enough or invalid arguments for adding atom: -a <element> <x> <y> <z>" << endl;
     1732                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for adding atom: -a <element> <x> <y> <z>" << endl);
    14801733                performCriticalExit();
    14811734              } else {
     
    14851738                first->type = periode->FindElement(atoi(argv[argptr]));
    14861739                if (first->type != NULL)
    1487                   Log() << Verbose(2) << "found element " << first->type->name << endl;
     1740                  DoLog(2) && (Log() << Verbose(2) << "found element " << first->type->name << endl);
    14881741                for (int i=NDIM;i--;)
    14891742                  first->x.x[i] = atof(argv[argptr+1+i]);
     
    14931746                    configPresent = present;
    14941747                } else
    1495                   eLog() << Verbose(1) << "Could not find the specified element." << endl;
     1748                  DoeLog(1) && (eLog()<< Verbose(1) << "Could not find the specified element." << endl);
    14961749                argptr+=4;
    14971750              }
     
    15061759              if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    15071760                ExitFlag = 255;
    1508                 eLog() << Verbose(0) << "Not enough or invalid arguments given for setting MPQC basis: -B <basis name>" << endl;
     1761                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for setting MPQC basis: -B <basis name>" << endl);
    15091762                performCriticalExit();
    15101763              } else {
    15111764                configuration.basis = argv[argptr];
    1512                 Log() << Verbose(1) << "Setting MPQC basis to " << configuration.basis << "." << endl;
     1765                DoLog(1) && (Log() << Verbose(1) << "Setting MPQC basis to " << configuration.basis << "." << endl);
    15131766                argptr+=1;
    15141767              }
     
    15171770              if (ExitFlag == 0) ExitFlag = 1;
    15181771              {
    1519                 Log() << Verbose(1) << "Depth-First-Search Analysis." << endl;
     1772                DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl);
    15201773                MoleculeLeafClass *Subgraphs = NULL;      // list of subgraphs from DFS analysis
    15211774                int *MinimumRingSize = new int[mol->AtomCount];
     
    15481801              break;
    15491802            case 'I':
    1550               Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl;
     1803              DoLog(1) && (Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl);
    15511804              // @TODO rather do the dissection afterwards
    15521805              molecules->DissectMoleculeIntoConnectedSubgraphs(periode, &configuration);
     
    15591812                  }
    15601813              }
    1561               if (mol == NULL) {
     1814              if ((mol == NULL) && (!molecules->ListOfMolecules.empty())) {
    15621815                mol = *(molecules->ListOfMolecules.begin());
    1563                 mol->ActiveFlag = true;
     1816                if (mol != NULL)
     1817                  mol->ActiveFlag = true;
    15641818              }
    15651819              break;
    15661820            case 'C':
    1567               if (ExitFlag == 0) ExitFlag = 1;
    1568               if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (argv[argptr][0] == '-') || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-')) {
    1569                 ExitFlag = 255;
    1570                 eLog() << Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C <Z> <output> <bin output>" << endl;
    1571                 performCriticalExit();
    1572               } else {
    1573                 ofstream output(argv[argptr+1]);
    1574                 ofstream binoutput(argv[argptr+2]);
    1575                 const double radius = 5.;
    1576 
    1577                 // get the boundary
    1578                 class molecule *Boundary = NULL;
    1579                 class Tesselation *TesselStruct = NULL;
    1580                 const LinkedCell *LCList = NULL;
    1581                 // find biggest molecule
    1582                 int counter  = 0;
    1583                 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
    1584                   if ((Boundary == NULL) || (Boundary->AtomCount < (*BigFinder)->AtomCount)) {
    1585                     Boundary = *BigFinder;
     1821              {
     1822                int ranges[3] = {1, 1, 1};
     1823                bool periodic = (argv[argptr-1][2] =='p');
     1824                if (ExitFlag == 0) ExitFlag = 1;
     1825                if ((argptr >= argc)) {
     1826                  ExitFlag = 255;
     1827                  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);
     1828                  performCriticalExit();
     1829                } else {
     1830                  switch(argv[argptr][0]) {
     1831                    case 'E':
     1832                      {
     1833                        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] == '-')) {
     1834                          ExitFlag = 255;
     1835                          DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C E <Z1> <Z2> <output> <bin output>" << endl);
     1836                          performCriticalExit();
     1837                        } else {
     1838                          ofstream output(argv[argptr+3]);
     1839                          ofstream binoutput(argv[argptr+4]);
     1840                          const double BinStart = atof(argv[argptr+5]);
     1841                          const double BinEnd = atof(argv[argptr+6]);
     1842
     1843                          const element *elemental = periode->FindElement((const int) atoi(argv[argptr+1]));
     1844                          const element *elemental2 = periode->FindElement((const int) atoi(argv[argptr+2]));
     1845                          PairCorrelationMap *correlationmap = NULL;
     1846                          if (periodic)
     1847                            correlationmap = PeriodicPairCorrelation(molecules, elemental, elemental2, ranges);
     1848                          else
     1849                            correlationmap = PairCorrelation(molecules, elemental, elemental2);
     1850                          //OutputCorrelationToSurface(&output, correlationmap);
     1851                          BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd );
     1852                          OutputCorrelation ( &binoutput, binmap );
     1853                          output.close();
     1854                          binoutput.close();
     1855                          delete(binmap);
     1856                          delete(correlationmap);
     1857                          argptr+=7;
     1858                        }
     1859                      }
     1860                      break;
     1861
     1862                    case 'P':
     1863                      {
     1864                        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] == '-')) {
     1865                          ExitFlag = 255;
     1866                          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);
     1867                          performCriticalExit();
     1868                        } else {
     1869                          ofstream output(argv[argptr+5]);
     1870                          ofstream binoutput(argv[argptr+6]);
     1871                          const double BinStart = atof(argv[argptr+7]);
     1872                          const double BinEnd = atof(argv[argptr+8]);
     1873
     1874                          const element *elemental = periode->FindElement((const int) atoi(argv[argptr+1]));
     1875                          Vector *Point = new Vector((const double) atof(argv[argptr+1]),(const double) atof(argv[argptr+2]),(const double) atof(argv[argptr+3]));
     1876                          CorrelationToPointMap *correlationmap = NULL;
     1877                          if (periodic)
     1878                            correlationmap  = PeriodicCorrelationToPoint(molecules, elemental, Point, ranges);
     1879                          else
     1880                            correlationmap = CorrelationToPoint(molecules, elemental, Point);
     1881                          //OutputCorrelationToSurface(&output, correlationmap);
     1882                          BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd );
     1883                          OutputCorrelation ( &binoutput, binmap );
     1884                          output.close();
     1885                          binoutput.close();
     1886                          delete(Point);
     1887                          delete(binmap);
     1888                          delete(correlationmap);
     1889                          argptr+=9;
     1890                        }
     1891                      }
     1892                      break;
     1893
     1894                    case 'S':
     1895                      {
     1896                        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] == '-')) {
     1897                          ExitFlag = 255;
     1898                          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);
     1899                          performCriticalExit();
     1900                        } else {
     1901                          ofstream output(argv[argptr+2]);
     1902                          ofstream binoutput(argv[argptr+3]);
     1903                          const double radius = 4.;
     1904                          const double BinWidth = atof(argv[argptr+4]);
     1905                          const double BinStart = atof(argv[argptr+5]);
     1906                          const double BinEnd = atof(argv[argptr+6]);
     1907                          double LCWidth = 20.;
     1908                          if (BinEnd > 0) {
     1909                            if (BinEnd > 2.*radius)
     1910                                LCWidth = BinEnd;
     1911                            else
     1912                              LCWidth = 2.*radius;
     1913                          }
     1914
     1915                          // get the boundary
     1916                          class molecule *Boundary = NULL;
     1917                          class Tesselation *TesselStruct = NULL;
     1918                          const LinkedCell *LCList = NULL;
     1919                          // find biggest molecule
     1920                          int counter  = 0;
     1921                          for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
     1922                            if ((Boundary == NULL) || (Boundary->AtomCount < (*BigFinder)->AtomCount)) {
     1923                              Boundary = *BigFinder;
     1924                            }
     1925                            counter++;
     1926                          }
     1927                          bool *Actives = Malloc<bool>(counter, "ParseCommandLineOptions() - case C -- *Actives");
     1928                          counter = 0;
     1929                          for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
     1930                            Actives[counter++] = (*BigFinder)->ActiveFlag;
     1931                            (*BigFinder)->ActiveFlag = (*BigFinder == Boundary) ? false : true;
     1932                          }
     1933                          LCList = new LinkedCell(Boundary, LCWidth);
     1934                          const element *elemental = periode->FindElement((const int) atoi(argv[argptr+1]));
     1935                          FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL);
     1936                          CorrelationToSurfaceMap *surfacemap = NULL;
     1937                          if (periodic)
     1938                            surfacemap = PeriodicCorrelationToSurface( molecules, elemental, TesselStruct, LCList, ranges);
     1939                          else
     1940                            surfacemap = CorrelationToSurface( molecules, elemental, TesselStruct, LCList);
     1941                          OutputCorrelationToSurface(&output, surfacemap);
     1942                          // check whether radius was appropriate
     1943                          {
     1944                            double start; double end;
     1945                            GetMinMax( surfacemap, start, end);
     1946                            if (LCWidth < end)
     1947                              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);
     1948                          }
     1949                          BinPairMap *binmap = BinData( surfacemap, BinWidth, BinStart, BinEnd );
     1950                          OutputCorrelation ( &binoutput, binmap );
     1951                          output.close();
     1952                          binoutput.close();
     1953                          for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++)
     1954                            (*BigFinder)->ActiveFlag = Actives[counter++];
     1955                          Free(&Actives);
     1956                          delete(LCList);
     1957                          delete(TesselStruct);
     1958                          delete(binmap);
     1959                          delete(surfacemap);
     1960                          argptr+=7;
     1961                        }
     1962                      }
     1963                      break;
     1964
     1965                    default:
     1966                      ExitFlag = 255;
     1967                      DoeLog(0) && (eLog()<< Verbose(0) << "Invalid type given for pair correlation analysis: -C <type: E/P/S> [more params] <output> <bin output>" << endl);
     1968                      performCriticalExit();
     1969                      break;
    15861970                  }
    1587                   counter++;
    15881971                }
    1589                 bool *Actives = Malloc<bool>(counter, "ParseCommandLineOptions() - case C -- *Actives");
    1590                 counter = 0;
    1591                 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
    1592                   Actives[counter++] = (*BigFinder)->ActiveFlag;
    1593                   (*BigFinder)->ActiveFlag = (*BigFinder == Boundary) ? false : true;
    1594                 }
    1595                 LCList = new LinkedCell(Boundary, 2.*radius);
    1596                 const element *elemental = periode->FindElement((atomicNumber_t) atoi(argv[argptr]));
    1597                 FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL);
    1598                 int ranges[NDIM] = {1,1,1};
    1599                 CorrelationToSurfaceMap *surfacemap = PeriodicCorrelationToSurface( molecules, elemental, TesselStruct, LCList, ranges );
    1600                 OutputCorrelationToSurface(&output, surfacemap);
    1601                 BinPairMap *binmap = BinData( surfacemap, 0.5, 0., 20. );
    1602                 OutputCorrelation ( &binoutput, binmap );
    1603                 output.close();
    1604                 binoutput.close();
    1605                 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++)
    1606                   (*BigFinder)->ActiveFlag = Actives[counter++];
    1607                 Free(&Actives);
    1608                 delete(LCList);
    1609                 delete(TesselStruct);
    1610                 argptr+=3;
    1611               }
    1612               break;
     1972                break;
     1973              }
    16131974            case 'E':
    16141975              if (ExitFlag == 0) ExitFlag = 1;
    16151976              if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (argv[argptr+1][0] == '-')) {
    16161977                ExitFlag = 255;
    1617                 eLog() << Verbose(0) << "Not enough or invalid arguments given for changing element: -E <atom nr.> <element>" << endl;
     1978                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for changing element: -E <atom nr.> <element>" << endl);
    16181979                performCriticalExit();
    16191980              } else {
    16201981                SaveFlag = true;
    1621                 Log() << Verbose(1) << "Changing atom " << argv[argptr] << " to element " << argv[argptr+1] << "." << endl;
     1982                DoLog(1) && (Log() << Verbose(1) << "Changing atom " << argv[argptr] << " to element " << argv[argptr+1] << "." << endl);
    16221983                first = mol->FindAtom(atoi(argv[argptr]));
    16231984                first->type = periode->FindElement(atoi(argv[argptr+1]));
     
    16271988            case 'F':
    16281989              if (ExitFlag == 0) ExitFlag = 1;
    1629               if (argptr+6 >=argc) {
     1990              MaxDistance = -1;
     1991              if (argv[argptr-1][2] == 'F') { // option is -FF?
     1992                // fetch first argument as max distance to surface
     1993                MaxDistance = atof(argv[argptr++]);
     1994                DoLog(0) && (Log() << Verbose(0) << "Filling with maximum layer distance of " << MaxDistance << "." << endl);
     1995              }
     1996              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]))) {
    16301997                ExitFlag = 255;
    1631                 eLog() << Verbose(0) << "Not enough or invalid arguments given for filling box with water: -F <dist_x> <dist_y> <dist_z> <boundary> <randatom> <randmol> <DoRotate>" << endl;
     1998                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);
    16321999                performCriticalExit();
    16332000              } else {
    16342001                SaveFlag = true;
    1635                 Log() << Verbose(1) << "Filling Box with water molecules." << endl;
     2002                DoLog(1) && (Log() << Verbose(1) << "Filling Box with water molecules." << endl);
    16362003                // construct water molecule
    16372004                molecule *filler = World::getInstance().createMolecule();
     2005                if (!filler->AddXYZFile(argv[argptr])) {
     2006                  DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse filler molecule from " << argv[argptr] << "." << endl);
     2007                }
     2008                filler->SetNameFromFilename(argv[argptr]);
     2009                configuration.BG->ConstructBondGraph(filler);
    16382010                molecule *Filling = NULL;
    16392011                atom *second = NULL, *third = NULL;
    1640 //                first = new atom();
    1641 //                first->type = periode->FindElement(5);
    1642 //                first->x.Zero();
    1643 //                filler->AddAtom(first);
    16442012                first = World::getInstance().createAtom();
    16452013                first->type = periode->FindElement(1);
     
    16592027                double distance[NDIM];
    16602028                for (int i=0;i<NDIM;i++)
    1661                   distance[i] = atof(argv[argptr+i]);
    1662                 Filling = FillBoxWithMolecule(molecules, filler, configuration, distance, atof(argv[argptr+3]), atof(argv[argptr+4]), atof(argv[argptr+5]), atoi(argv[argptr+6]));
     2029                  distance[i] = atof(argv[argptr+i+1]);
     2030                Filling = FillBoxWithMolecule(molecules, filler, configuration, MaxDistance, distance, atof(argv[argptr+4]), atof(argv[argptr+5]), atof(argv[argptr+6]), atoi(argv[argptr+7]));
    16632031                if (Filling != NULL) {
    16642032                  Filling->ActiveFlag = false;
     
    16732041              if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    16742042                ExitFlag =255;
    1675                 eLog() << Verbose(0) << "Missing source file for bonds in molecule: -A <bond sourcefile>" << endl;
     2043                DoeLog(0) && (eLog()<< Verbose(0) << "Missing source file for bonds in molecule: -A <bond sourcefile>" << endl);
    16762044                performCriticalExit();
    16772045              } else {
    1678                 Log() << Verbose(0) << "Parsing bonds from " << argv[argptr] << "." << endl;
     2046                DoLog(0) && (Log() << Verbose(0) << "Parsing bonds from " << argv[argptr] << "." << endl);
    16792047                ifstream *input = new ifstream(argv[argptr]);
    16802048                mol->CreateAdjacencyListFromDbondFile(input);
     
    16882056              if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    16892057                ExitFlag =255;
    1690                 eLog() << Verbose(0) << "Missing path of adjacency file: -j <path>" << endl;
     2058                DoeLog(0) && (eLog()<< Verbose(0) << "Missing path of adjacency file: -j <path>" << endl);
    16912059                performCriticalExit();
    16922060              } else {
    1693                 Log() << Verbose(0) << "Storing adjacency to path " << argv[argptr] << "." << endl;
     2061                DoLog(0) && (Log() << Verbose(0) << "Storing adjacency to path " << argv[argptr] << "." << endl);
    16942062                configuration.BG->ConstructBondGraph(mol);
    1695                 mol->StoreAdjacencyToFile(argv[argptr]);
     2063                mol->StoreAdjacencyToFile(NULL, argv[argptr]);
    16962064                argptr+=1;
    16972065              }
     
    17022070              if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    17032071                ExitFlag =255;
    1704                 eLog() << Verbose(0) << "Missing path of bonds file: -j <path>" << endl;
     2072                DoeLog(0) && (eLog()<< Verbose(0) << "Missing path of bonds file: -j <path>" << endl);
    17052073                performCriticalExit();
    17062074              } else {
    1707                 Log() << Verbose(0) << "Storing bonds to path " << argv[argptr] << "." << endl;
     2075                DoLog(0) && (Log() << Verbose(0) << "Storing bonds to path " << argv[argptr] << "." << endl);
    17082076                configuration.BG->ConstructBondGraph(mol);
    1709                 mol->StoreBondsToFile(argv[argptr]);
     2077                mol->StoreBondsToFile(NULL, argv[argptr]);
    17102078                argptr+=1;
    17112079              }
     
    17162084              if ((argptr+1 >= argc) || (argv[argptr+1][0] == '-')){
    17172085                ExitFlag = 255;
    1718                 eLog() << Verbose(0) << "Not enough or invalid arguments given for non-convex envelope: -o <radius> <tecplot output file>" << endl;
     2086                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for non-convex envelope: -o <radius> <tecplot output file>" << endl);
    17192087                performCriticalExit();
    17202088              } else {
     
    17242092                //string filename(argv[argptr+1]);
    17252093                //filename.append(".csv");
    1726                 Log() << Verbose(0) << "Evaluating non-convex envelope of biggest molecule.";
    1727                 Log() << Verbose(1) << "Using rolling ball of radius " << atof(argv[argptr]) << " and storing tecplot data in " << argv[argptr+1] << "." << endl;
     2094                DoLog(0) && (Log() << Verbose(0) << "Evaluating non-convex envelope of biggest molecule.");
     2095                DoLog(1) && (Log() << Verbose(1) << "Using rolling ball of radius " << atof(argv[argptr]) << " and storing tecplot data in " << argv[argptr+1] << "." << endl);
    17282096                // find biggest molecule
    17292097                int counter  = 0;
     
    17352103                  counter++;
    17362104                }
    1737                 Log() << Verbose(1) << "Biggest molecule has " << Boundary->AtomCount << " atoms." << endl;
     2105                DoLog(1) && (Log() << Verbose(1) << "Biggest molecule has " << Boundary->AtomCount << " atoms." << endl);
    17382106                start = clock();
    17392107                LCList = new LinkedCell(Boundary, atof(argv[argptr])*2.);
     
    17422110                //FindDistributionOfEllipsoids(T, &LCList, N, number, filename.c_str());
    17432111                end = clock();
    1744                 Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
     2112                DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);
    17452113                delete(LCList);
    17462114                delete(T);
     
    17522120              if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    17532121                ExitFlag = 255;
    1754                 eLog() << Verbose(0) << "Not enough or invalid arguments given for storing tempature: -S <temperature file>" << endl;
     2122                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for storing tempature: -S <temperature file>" << endl);
    17552123                performCriticalExit();
    17562124              } else {
    1757                 Log() << Verbose(1) << "Storing temperatures in " << argv[argptr] << "." << endl;
     2125                DoLog(1) && (Log() << Verbose(1) << "Storing temperatures in " << argv[argptr] << "." << endl);
    17582126                ofstream *output = new ofstream(argv[argptr], ios::trunc);
    17592127                if (!mol->OutputTemperatureFromTrajectories(output, 0, mol->MDSteps))
    1760                   Log() << Verbose(2) << "File could not be written." << endl;
     2128                  DoLog(2) && (Log() << Verbose(2) << "File could not be written." << endl);
    17612129                else
    1762                   Log() << Verbose(2) << "File stored." << endl;
     2130                  DoLog(2) && (Log() << Verbose(2) << "File stored." << endl);
    17632131                output->close();
    17642132                delete(output);
     
    17702138              if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    17712139                ExitFlag = 255;
    1772                 eLog() << Verbose(0) << "Not enough or invalid arguments given for storing tempature: -L <step0> <step1> <prefix> <identity mapping?>" << endl;
     2140                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for storing tempature: -L <step0> <step1> <prefix> <identity mapping?>" << endl);
    17732141                performCriticalExit();
    17742142              } else {
    17752143                SaveFlag = true;
    1776                 Log() << Verbose(1) << "Linear interpolation between configuration " << argv[argptr] << " and " << argv[argptr+1] << "." << endl;
     2144                DoLog(1) && (Log() << Verbose(1) << "Linear interpolation between configuration " << argv[argptr] << " and " << argv[argptr+1] << "." << endl);
    17772145                if (atoi(argv[argptr+3]) == 1)
    1778                   Log() << Verbose(1) << "Using Identity for the permutation map." << endl;
     2146                  DoLog(1) && (Log() << Verbose(1) << "Using Identity for the permutation map." << endl);
    17792147                if (!mol->LinearInterpolationBetweenConfiguration(atoi(argv[argptr]), atoi(argv[argptr+1]), argv[argptr+2], configuration, atoi(argv[argptr+3])) == 1 ? true : false)
    1780                   Log() << Verbose(2) << "Could not store " << argv[argptr+2] << " files." << endl;
     2148                  DoLog(2) && (Log() << Verbose(2) << "Could not store " << argv[argptr+2] << " files." << endl);
    17812149                else
    1782                   Log() << Verbose(2) << "Steps created and " << argv[argptr+2] << " files stored." << endl;
     2150                  DoLog(2) && (Log() << Verbose(2) << "Steps created and " << argv[argptr+2] << " files stored." << endl);
    17832151                argptr+=4;
    17842152              }
     
    17882156              if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    17892157                ExitFlag = 255;
    1790                 eLog() << Verbose(0) << "Not enough or invalid arguments given for parsing and integrating forces: -P <forces file>" << endl;
     2158                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for parsing and integrating forces: -P <forces file>" << endl);
    17912159                performCriticalExit();
    17922160              } else {
    17932161                SaveFlag = true;
    1794                 Log() << Verbose(1) << "Parsing forces file and Verlet integrating." << endl;
     2162                DoLog(1) && (Log() << Verbose(1) << "Parsing forces file and Verlet integrating." << endl);
    17952163                if (!mol->VerletForceIntegration(argv[argptr], configuration))
    1796                   Log() << Verbose(2) << "File not found." << endl;
     2164                  DoLog(2) && (Log() << Verbose(2) << "File not found." << endl);
    17972165                else
    1798                   Log() << Verbose(2) << "File found and parsed." << endl;
     2166                  DoLog(2) && (Log() << Verbose(2) << "File found and parsed." << endl);
    17992167                argptr+=1;
    18002168              }
     
    18042172              if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])))  {
    18052173                ExitFlag = 255;
    1806                 eLog() << Verbose(0) << "Not enough or invalid arguments given for removing atoms: -R <id> <distance>" << endl;
     2174                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for removing atoms: -R <id> <distance>" << endl);
    18072175                performCriticalExit();
    18082176              } else {
    18092177                SaveFlag = true;
    1810                 Log() << Verbose(1) << "Removing atoms around " << argv[argptr] << " with radius " << argv[argptr+1] << "." << endl;
     2178                DoLog(1) && (Log() << Verbose(1) << "Removing atoms around " << argv[argptr] << " with radius " << argv[argptr+1] << "." << endl);
    18112179                double tmp1 = atof(argv[argptr+1]);
    18122180                atom *third = mol->FindAtom(atoi(argv[argptr]));
     
    18212189                  }
    18222190                } else {
    1823                   eLog() << Verbose(1) << "Removal failed due to missing atoms on molecule or wrong id." << endl;
     2191                  DoeLog(1) && (eLog()<< Verbose(1) << "Removal failed due to missing atoms on molecule or wrong id." << endl);
    18242192                }
    18252193                argptr+=2;
     
    18302198              if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
    18312199                ExitFlag = 255;
    1832                 eLog() << Verbose(0) << "Not enough or invalid arguments given for translation: -t <x> <y> <z>" << endl;
     2200                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for translation: -t <x> <y> <z>" << endl);
    18332201                performCriticalExit();
    18342202              } else {
    18352203                if (ExitFlag == 0) ExitFlag = 1;
    18362204                SaveFlag = true;
    1837                 Log() << Verbose(1) << "Translating all ions by given vector." << endl;
     2205                DoLog(1) && (Log() << Verbose(1) << "Translating all ions by given vector." << endl);
    18382206                for (int i=NDIM;i--;)
    18392207                  x.x[i] = atof(argv[argptr+i]);
     
    18462214              if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
    18472215                ExitFlag = 255;
    1848                 eLog() << Verbose(0) << "Not enough or invalid arguments given for periodic translation: -T <x> <y> <z>" << endl;
     2216                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for periodic translation: -T <x> <y> <z>" << endl);
    18492217                performCriticalExit();
    18502218              } else {
    18512219                if (ExitFlag == 0) ExitFlag = 1;
    18522220                SaveFlag = true;
    1853                 Log() << Verbose(1) << "Translating all ions periodically by given vector." << endl;
     2221                DoLog(1) && (Log() << Verbose(1) << "Translating all ions periodically by given vector." << endl);
    18542222                for (int i=NDIM;i--;)
    18552223                  x.x[i] = atof(argv[argptr+i]);
     
    18622230              if ((argptr >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
    18632231                ExitFlag = 255;
    1864                 eLog() << Verbose(0) << "Not enough or invalid arguments given for scaling: -s <factor_x> [factor_y] [factor_z]" << endl;
     2232                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for scaling: -s <factor_x> [factor_y] [factor_z]" << endl);
    18652233                performCriticalExit();
    18662234              } else {
    18672235                SaveFlag = true;
    18682236                j = -1;
    1869                 Log() << Verbose(1) << "Scaling all ion positions by factor." << endl;
     2237                DoLog(1) && (Log() << Verbose(1) << "Scaling all ion positions by factor." << endl);
    18702238                factor = new double[NDIM];
    18712239                factor[0] = atof(argv[argptr]);
     
    18732241                factor[2] = atof(argv[argptr+2]);
    18742242                mol->Scale((const double ** const)&factor);
     2243                double * const cell_size = World::getInstance().getDomain();
    18752244                for (int i=0;i<NDIM;i++) {
    18762245                  j += i+1;
    18772246                  x.x[i] = atof(argv[NDIM+i]);
    1878                   mol->cell_size[j]*=factor[i];
     2247                  cell_size[j]*=factor[i];
    18792248                }
    18802249                delete[](factor);
     
    18862255              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])) ) {
    18872256                ExitFlag = 255;
    1888                 eLog() << Verbose(0) << "Not enough or invalid arguments given for centering in box: -b <xx> <xy> <xz> <yy> <yz> <zz>" << endl;
     2257                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for centering in box: -b <xx> <xy> <xz> <yy> <yz> <zz>" << endl);
    18892258                performCriticalExit();
    18902259              } else {
    18912260                SaveFlag = true;
    18922261                j = -1;
    1893                 Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
     2262                DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl);
     2263                double * const cell_size = World::getInstance().getDomain();
    18942264                for (int i=0;i<6;i++) {
    1895                   mol->cell_size[i] = atof(argv[argptr+i]);
     2265                  cell_size[i] = atof(argv[argptr+i]);
    18962266                }
    18972267                // center
     
    19042274              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])) ) {
    19052275                ExitFlag = 255;
    1906                 eLog() << Verbose(0) << "Not enough or invalid arguments given for bounding in box: -B <xx> <xy> <xz> <yy> <yz> <zz>" << endl;
     2276                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for bounding in box: -B <xx> <xy> <xz> <yy> <yz> <zz>" << endl);
    19072277                performCriticalExit();
    19082278              } else {
    19092279                SaveFlag = true;
    19102280                j = -1;
    1911                 Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
     2281                DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl);
     2282                double * const cell_size = World::getInstance().getDomain();
    19122283                for (int i=0;i<6;i++) {
    1913                   mol->cell_size[i] = atof(argv[argptr+i]);
     2284                  cell_size[i] = atof(argv[argptr+i]);
    19142285                }
    19152286                // center
     
    19222293              if ((argptr+2 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
    19232294                ExitFlag = 255;
    1924                 eLog() << Verbose(0) << "Not enough or invalid arguments given for centering with boundary: -c <boundary_x> <boundary_y> <boundary_z>" << endl;
     2295                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for centering with boundary: -c <boundary_x> <boundary_y> <boundary_z>" << endl);
    19252296                performCriticalExit();
    19262297              } else {
    19272298                SaveFlag = true;
    19282299                j = -1;
    1929                 Log() << Verbose(1) << "Centering atoms in config file within given additional boundary." << endl;
     2300                DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given additional boundary." << endl);
    19302301                // make every coordinate positive
    19312302                mol->CenterEdge(&x);
     
    19332304                mol->SetBoxDimension(&x);
    19342305                // translate each coordinate by boundary
     2306                double * const cell_size = World::getInstance().getDomain();
    19352307                j=-1;
    19362308                for (int i=0;i<NDIM;i++) {
    19372309                  j += i+1;
    19382310                  x.x[i] = atof(argv[argptr+i]);
    1939                   mol->cell_size[j] += x.x[i]*2.;
     2311                  cell_size[j] += x.x[i]*2.;
    19402312                }
    19412313                mol->Translate((const Vector *)&x);
     
    19462318              if (ExitFlag == 0) ExitFlag = 1;
    19472319              SaveFlag = true;
    1948               Log() << Verbose(1) << "Centering atoms on edge and setting box dimensions." << endl;
     2320              DoLog(1) && (Log() << Verbose(1) << "Centering atoms on edge and setting box dimensions." << endl);
    19492321              x.Zero();
    19502322              mol->CenterEdge(&x);
     
    19562328              if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])))  {
    19572329                ExitFlag = 255;
    1958                 eLog() << Verbose(0) << "Not enough or invalid arguments given for removing atoms: -r <id>" << endl;
     2330                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for removing atoms: -r <id>" << endl);
    19592331                performCriticalExit();
    19602332              } else {
    19612333                SaveFlag = true;
    1962                 Log() << Verbose(1) << "Removing atom " << argv[argptr] << "." << endl;
     2334                DoLog(1) && (Log() << Verbose(1) << "Removing atom " << argv[argptr] << "." << endl);
    19632335                atom *first = mol->FindAtom(atoi(argv[argptr]));
    19642336                mol->RemoveAtom(first);
     
    19702342              if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1]))) {
    19712343                ExitFlag = 255;
    1972                 eLog() << Verbose(0) << "Not enough or invalid arguments for fragmentation: -f <max. bond distance> <bond order>" << endl;
     2344                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for fragmentation: -f <max. bond distance> <bond order>" << endl);
    19732345                performCriticalExit();
    19742346              } else {
    1975                 Log() << Verbose(0) << "Fragmenting molecule with bond distance " << argv[argptr] << " angstroem, order of " << argv[argptr+1] << "." << endl;
    1976                 Log() << Verbose(0) << "Creating connection matrix..." << endl;
     2347                DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with bond distance " << argv[argptr] << " angstroem, order of " << argv[argptr+1] << "." << endl);
     2348                DoLog(0) && (Log() << Verbose(0) << "Creating connection matrix..." << endl);
    19772349                start = clock();
    1978                 mol->CreateAdjacencyList(atof(argv[argptr++]), configuration.GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
    1979                 Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl;
     2350                mol->CreateAdjacencyList(atof(argv[argptr]), configuration.GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
     2351                DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl);
    19802352                if (mol->first->next != mol->last) {
    1981                   ExitFlag = mol->FragmentMolecule(atoi(argv[argptr]), &configuration);
     2353                  ExitFlag = mol->FragmentMolecule(atoi(argv[argptr+1]), &configuration);
    19822354                }
    19832355                end = clock();
    1984                 Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
     2356                DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);
    19852357                argptr+=2;
    19862358              }
     
    19902362              j = atoi(argv[argptr++]);
    19912363              if ((j<0) || (j>1)) {
    1992                 eLog() << Verbose(1) << "Argument of '-m' should be either 0 for no-rotate or 1 for rotate." << endl;
     2364                DoeLog(1) && (eLog()<< Verbose(1) << "Argument of '-m' should be either 0 for no-rotate or 1 for rotate." << endl);
    19932365                j = 0;
    19942366              }
    19952367              if (j) {
    19962368                SaveFlag = true;
    1997                 Log() << Verbose(0) << "Converting to prinicipal axis system." << endl;
     2369                DoLog(0) && (Log() << Verbose(0) << "Converting to prinicipal axis system." << endl);
    19982370              } else
    1999                 Log() << Verbose(0) << "Evaluating prinicipal axis." << endl;
     2371                DoLog(0) && (Log() << Verbose(0) << "Evaluating prinicipal axis." << endl);
    20002372              mol->PrincipalAxisSystem((bool)j);
    20012373              break;
     
    20042376              if ((argptr+1 >= argc) || (argv[argptr][0] == '-')){
    20052377                ExitFlag = 255;
    2006                 eLog() << Verbose(0) << "Not enough or invalid arguments given for convex envelope: -o <convex output file> <non-convex output file>" << endl;
     2378                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for convex envelope: -o <convex output file> <non-convex output file>" << endl);
    20072379                performCriticalExit();
    20082380              } else {
    20092381                class Tesselation *TesselStruct = NULL;
    20102382                const LinkedCell *LCList = NULL;
    2011                 Log() << Verbose(0) << "Evaluating volume of the convex envelope.";
    2012                 Log() << Verbose(1) << "Storing tecplot convex data in " << argv[argptr] << "." << endl;
    2013                 Log() << Verbose(1) << "Storing tecplot non-convex data in " << argv[argptr+1] << "." << endl;
     2383                DoLog(0) && (Log() << Verbose(0) << "Evaluating volume of the convex envelope.");
     2384                DoLog(1) && (Log() << Verbose(1) << "Storing tecplot convex data in " << argv[argptr] << "." << endl);
     2385                DoLog(1) && (Log() << Verbose(1) << "Storing tecplot non-convex data in " << argv[argptr+1] << "." << endl);
    20142386                LCList = new LinkedCell(mol, 10.);
    20152387                //FindConvexBorder(mol, LCList, argv[argptr]);
     
    20182390                double volumedifference = ConvexizeNonconvexEnvelope(TesselStruct, mol, argv[argptr]);
    20192391                double clustervolume = VolumeOfConvexEnvelope(TesselStruct, &configuration);
    2020                 Log() << Verbose(0) << "The tesselated volume area is " << clustervolume << " " << (configuration.GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl;
    2021                 Log() << Verbose(0) << "The non-convex tesselated volume area is " << clustervolume-volumedifference << " " << (configuration.GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl;
     2392                DoLog(0) && (Log() << Verbose(0) << "The tesselated volume area is " << clustervolume << " " << (configuration.GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl);
     2393                DoLog(0) && (Log() << Verbose(0) << "The non-convex tesselated volume area is " << clustervolume-volumedifference << " " << (configuration.GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl);
    20222394                delete(TesselStruct);
    20232395                delete(LCList);
     
    20292401              if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) ) {
    20302402                ExitFlag = 255;
    2031                 eLog() << Verbose(0) << "Not enough or invalid arguments given for suspension with specified volume: -U <volume> <density>" << endl;
     2403                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for suspension with specified volume: -U <volume> <density>" << endl);
    20322404                performCriticalExit();
    20332405              } else {
    20342406                volume = atof(argv[argptr++]);
    2035                 Log() << Verbose(0) << "Using " << volume << " angstrom^3 as the volume instead of convex envelope one's." << endl;
     2407                DoLog(0) && (Log() << Verbose(0) << "Using " << volume << " angstrom^3 as the volume instead of convex envelope one's." << endl);
    20362408              }
    20372409            case 'u':
     
    20402412                if (volume != -1)
    20412413                  ExitFlag = 255;
    2042                   eLog() << Verbose(0) << "Not enough or invalid arguments given for suspension: -u <density>" << endl;
     2414                  DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for suspension: -u <density>" << endl);
    20432415                  performCriticalExit();
    20442416              } else {
    20452417                double density;
    20462418                SaveFlag = true;
    2047                 Log() << Verbose(0) << "Evaluating necessary cell volume for a cluster suspended in water.";
     2419                DoLog(0) && (Log() << Verbose(0) << "Evaluating necessary cell volume for a cluster suspended in water.");
    20482420                density = atof(argv[argptr++]);
    20492421                if (density < 1.0) {
    2050                   eLog() << Verbose(1) << "Density must be greater than 1.0g/cm^3 !" << endl;
     2422                  DoeLog(1) && (eLog()<< Verbose(1) << "Density must be greater than 1.0g/cm^3 !" << endl);
    20512423                  density = 1.3;
    20522424                }
     
    20542426//                  repetition[i] = atoi(argv[argptr++]);
    20552427//                  if (repetition[i] < 1)
    2056 //                    eLog() << Verbose(1) << "repetition value must be greater 1!" << endl;
     2428//                    DoeLog(1) && (eLog()<< Verbose(1) << "repetition value must be greater 1!" << endl);
    20572429//                  repetition[i] = 1;
    20582430//                }
     
    20642436              if ((argptr+2 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
    20652437                ExitFlag = 255;
    2066                 eLog() << Verbose(0) << "Not enough or invalid arguments given for repeating cells: -d <repeat_x> <repeat_y> <repeat_z>" << endl;
     2438                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for repeating cells: -d <repeat_x> <repeat_y> <repeat_z>" << endl);
    20672439                performCriticalExit();
    20682440              } else {
    20692441                SaveFlag = true;
     2442                double * const cell_size = World::getInstance().getDomain();
    20702443                for (int axis = 1; axis <= NDIM; axis++) {
    20712444                  int faktor = atoi(argv[argptr++]);
     
    20742447                  Vector ** vectors;
    20752448                  if (faktor < 1) {
    2076                     eLog() << Verbose(1) << "Repetition factor must be greater than 1!" << endl;
     2449                    DoeLog(1) && (eLog()<< Verbose(1) << "Repetition factor mus be greater than 1!" << endl);
    20772450                    faktor = 1;
    20782451                  }
     
    20912464                    }
    20922465                    if (count != j)
    2093                       eLog() << Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl;
     2466                      DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl);
    20942467                    x.Zero();
    20952468                    y.Zero();
    2096                     y.x[abs(axis)-1] = mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
     2469                    y.x[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
    20972470                    for (int i=1;i<faktor;i++) {  // then add this list with respective translation factor times
    20982471                      x.AddVector(&y); // per factor one cell width further
     
    21152488                      mol->Translate(&x);
    21162489                    }
    2117                     mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
     2490                    cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
    21182491                  }
    21192492                }
     
    21322505  } else {  // no arguments, hence scan the elements db
    21332506    if (periode->LoadPeriodentafel(configuration.databasepath))
    2134       Log() << Verbose(0) << "Element list loaded successfully." << endl;
     2507      DoLog(0) && (Log() << Verbose(0) << "Element list loaded successfully." << endl);
    21352508    else
    2136       Log() << Verbose(0) << "Element list loading failed." << endl;
     2509      DoLog(0) && (Log() << Verbose(0) << "Element list loading failed." << endl);
    21372510    configuration.RetrieveConfigPathAndName("main_pcp_linux");
    21382511  }
     
    21912564    char *ConfigFileName = NULL;
    21922565    int j;
     2566
     2567    cout << ESPACKVersion << endl;
    21932568
    21942569    setVerbosity(0);
     
    22102585        World::getInstance().getMolecules()->insert(mol);
    22112586        cout << "Molecule created" << endl;
    2212         if(mol->cell_size[0] == 0.){
     2587        if(World::getInstance().getDomain()[0] == 0.){
    22132588            Log() << Verbose(0) << "enter lower tridiagonal form of basis matrix" << endl << endl;
    22142589            for(int i = 0;i < 6;i++){
    22152590                Log() << Verbose(1) << "Cell size" << i << ": ";
    2216                 cin >> mol->cell_size[i];
     2591                cin >> World::getInstance().getDomain()[i];
    22172592            }
    22182593        }
  • src/config.cpp

    r13d5a9 r5f612ee  
    2020#include "molecule.hpp"
    2121#include "periodentafel.hpp"
     22#include "World.hpp"
    2223
    2324/******************************** Functions for class ConfigFileBuffer **********************/
     
    7475  file= new ifstream(filename);
    7576  if (file == NULL) {
    76     eLog() << Verbose(1) << "config file " << filename << " missing!" << endl;
     77    DoeLog(1) && (eLog()<< Verbose(1) << "config file " << filename << " missing!" << endl);
    7778    return;
    7879  }
     
    8586  file->clear();
    8687  file->seekg(file_position, ios::beg);
    87   Log() << Verbose(1) << NoLines-1 << " lines were recognized." << endl;
     88  DoLog(1) && (Log() << Verbose(1) << NoLines-1 << " lines were recognized." << endl);
    8889
    8990  // allocate buffer's 1st dimension
    9091  if (buffer != NULL) {
    91     eLog() << Verbose(1) << "FileBuffer->buffer is not NULL!" << endl;
     92    DoeLog(1) && (eLog()<< Verbose(1) << "FileBuffer->buffer is not NULL!" << endl);
    9293    return;
    9394  } else
     
    105106    lines++;
    106107  } while((!file->eof()) && (lines < NoLines));
    107   Log() << Verbose(1) << lines-1 << " lines were read into the buffer." << endl;
     108  DoLog(1) && (Log() << Verbose(1) << lines-1 << " lines were read into the buffer." << endl);
    108109
    109110  // close and exit
     
    144145  map<const char *, int, IonTypeCompare> IonTypeLineMap;
    145146  if (LineMapping == NULL) {
    146     eLog() << Verbose(0) << "map pointer is NULL: " << LineMapping << endl;
     147    DoeLog(0) && (eLog()<< Verbose(0) << "map pointer is NULL: " << LineMapping << endl);
    147148    performCriticalExit();
    148149    return;
     
    160161      LineMapping[CurrentLine+(nr++)] = runner->second;
    161162    else {
    162       eLog() << Verbose(0) << "config::MapIonTypesInBuffer - NoAtoms is wrong: We are past the end of the file!" << endl;
     163      DoeLog(0) && (eLog()<< Verbose(0) << "config::MapIonTypesInBuffer - NoAtoms is wrong: We are past the end of the file!" << endl);
    163164      performCriticalExit();
    164165    }
     
    250251        Thermostat = None;
    251252      } else {
    252         Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl;
     253        DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    253254        Thermostat = None;
    254255      }
     
    258259        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read scaling frequency
    259260      } else {
    260         Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl;
     261        DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    261262        Thermostat = None;
    262263      }
     
    266267        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read collision rate
    267268      } else {
    268         Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl;
     269        DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    269270        Thermostat = None;
    270271      }
     
    274275        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read gamma
    275276        if (ParseForParameter(verbose,fb,"Thermostat", 0, 3, 1, double_type, &alpha, 1, optional)) {
    276           Log() << Verbose(2) << "Extended Stochastic Thermostat detected with interpolation coefficient " << alpha << "." << endl;
     277          DoLog(2) && (Log() << Verbose(2) << "Extended Stochastic Thermostat detected with interpolation coefficient " << alpha << "." << endl);
    277278        } else {
    278279          alpha = 1.;
    279280        }
    280281      } else {
    281         Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl;
     282        DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    282283        Thermostat = None;
    283284      }
     
    287288        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read \tau_T
    288289      } else {
    289         Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl;
     290        DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    290291        Thermostat = None;
    291292      }
     
    296297        alpha = 0.;
    297298      } else {
    298         Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl;
     299        DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    299300        Thermostat = None;
    300301      }
    301302    } else {
    302       Log() << Verbose(1) << " Warning: thermostat name was not understood!" << endl;
     303      DoLog(1) && (Log() << Verbose(1) << " Warning: thermostat name was not understood!" << endl);
    303304      Thermostat = None;
    304305    }
    305306  } else {
    306307    if ((MaxOuterStep > 0) && (TargetTemp != 0))
    307       Log() << Verbose(2) <<  "No thermostat chosen despite finite temperature MD, falling back to None." << endl;
     308      DoLog(2) && (Log() << Verbose(2) <<  "No thermostat chosen despite finite temperature MD, falling back to None." << endl);
    308309    Thermostat = None;
    309310  }
     
    321322
    322323  do {
    323     Log() << Verbose(0) << "===========EDIT CONFIGURATION============================" << endl;
    324     Log() << Verbose(0) << " A - mainname (prefix for all runtime files)" << endl;
    325     Log() << Verbose(0) << " B - Default path (for runtime files)" << endl;
    326     Log() << Verbose(0) << " C - Path of pseudopotential files" << endl;
    327     Log() << Verbose(0) << " D - Number of coefficient sharing processes" << endl;
    328     Log() << Verbose(0) << " E - Number of wave function sharing processes" << endl;
    329     Log() << Verbose(0) << " F - 0: Don't output density for OpenDX, 1: do" << endl;
    330     Log() << Verbose(0) << " G - 0: Don't output physical data, 1: do" << endl;
    331     Log() << Verbose(0) << " H - 0: Don't output densities of each unperturbed orbital for OpenDX, 1: do" << endl;
    332     Log() << Verbose(0) << " I - 0: Don't output current density for OpenDX, 1: do" << endl;
    333     Log() << Verbose(0) << " J - 0: Don't do the full current calculation, 1: do" << endl;
    334     Log() << Verbose(0) << " K - 0: Don't do perturbation calculation to obtain susceptibility and shielding, 1: do" << endl;
    335     Log() << Verbose(0) << " L - 0: Wannier centres as calculated, 1: common centre for all, 2: unite centres according to spread, 3: cell centre, 4: shifted to nearest grid point" << endl;
    336     Log() << Verbose(0) << " M - Absolute begin of unphysical sawtooth transfer for position operator within cell" << endl;
    337     Log() << Verbose(0) << " N - (0,1,2) x,y,z-plane to do two-dimensional current vector cut" << endl;
    338     Log() << Verbose(0) << " O - Absolute position along vector cut axis for cut plane" << endl;
    339     Log() << Verbose(0) << " P - Additional Gram-Schmidt-Orthonormalization to stabilize numerics" << endl;
    340     Log() << Verbose(0) << " Q - Initial integer value of random number generator" << endl;
    341     Log() << Verbose(0) << " R - for perturbation 0, for structure optimization defines upper limit of iterations" << endl;
    342     Log() << Verbose(0) << " T - Output visual after ...th step" << endl;
    343     Log() << Verbose(0) << " U - Output source densities of wave functions after ...th step" << endl;
    344     Log() << Verbose(0) << " X - minimization iterations per wave function, if unsure leave at default value 0" << endl;
    345     Log() << Verbose(0) << " Y - tolerance value for total spread in iterative Jacobi diagonalization" << endl;
    346     Log() << Verbose(0) << " Z - Maximum number of minimization iterations" << endl;
    347     Log() << Verbose(0) << " a - Relative change in total energy to stop min. iteration" << endl;
    348     Log() << Verbose(0) << " b - Relative change in kinetic energy to stop min. iteration" << endl;
    349     Log() << Verbose(0) << " c - Check stop conditions every ..th step during min. iteration" << endl;
    350     Log() << Verbose(0) << " e - Maximum number of minimization iterations during initial level" << endl;
    351     Log() << Verbose(0) << " f - Relative change in total energy to stop min. iteration during initial level" << endl;
    352     Log() << Verbose(0) << " g - Relative change in kinetic energy to stop min. iteration during initial level" << endl;
    353     Log() << Verbose(0) << " h - Check stop conditions every ..th step during min. iteration during initial level" << endl;
     324    DoLog(0) && (Log() << Verbose(0) << "===========EDIT CONFIGURATION============================" << endl);
     325    DoLog(0) && (Log() << Verbose(0) << " A - mainname (prefix for all runtime files)" << endl);
     326    DoLog(0) && (Log() << Verbose(0) << " B - Default path (for runtime files)" << endl);
     327    DoLog(0) && (Log() << Verbose(0) << " C - Path of pseudopotential files" << endl);
     328    DoLog(0) && (Log() << Verbose(0) << " D - Number of coefficient sharing processes" << endl);
     329    DoLog(0) && (Log() << Verbose(0) << " E - Number of wave function sharing processes" << endl);
     330    DoLog(0) && (Log() << Verbose(0) << " F - 0: Don't output density for OpenDX, 1: do" << endl);
     331    DoLog(0) && (Log() << Verbose(0) << " G - 0: Don't output physical data, 1: do" << endl);
     332    DoLog(0) && (Log() << Verbose(0) << " H - 0: Don't output densities of each unperturbed orbital for OpenDX, 1: do" << endl);
     333    DoLog(0) && (Log() << Verbose(0) << " I - 0: Don't output current density for OpenDX, 1: do" << endl);
     334    DoLog(0) && (Log() << Verbose(0) << " J - 0: Don't do the full current calculation, 1: do" << endl);
     335    DoLog(0) && (Log() << Verbose(0) << " K - 0: Don't do perturbation calculation to obtain susceptibility and shielding, 1: do" << endl);
     336    DoLog(0) && (Log() << Verbose(0) << " L - 0: Wannier centres as calculated, 1: common centre for all, 2: unite centres according to spread, 3: cell centre, 4: shifted to nearest grid point" << endl);
     337    DoLog(0) && (Log() << Verbose(0) << " M - Absolute begin of unphysical sawtooth transfer for position operator within cell" << endl);
     338    DoLog(0) && (Log() << Verbose(0) << " N - (0,1,2) x,y,z-plane to do two-dimensional current vector cut" << endl);
     339    DoLog(0) && (Log() << Verbose(0) << " O - Absolute position along vector cut axis for cut plane" << endl);
     340    DoLog(0) && (Log() << Verbose(0) << " P - Additional Gram-Schmidt-Orthonormalization to stabilize numerics" << endl);
     341    DoLog(0) && (Log() << Verbose(0) << " Q - Initial integer value of random number generator" << endl);
     342    DoLog(0) && (Log() << Verbose(0) << " R - for perturbation 0, for structure optimization defines upper limit of iterations" << endl);
     343    DoLog(0) && (Log() << Verbose(0) << " T - Output visual after ...th step" << endl);
     344    DoLog(0) && (Log() << Verbose(0) << " U - Output source densities of wave functions after ...th step" << endl);
     345    DoLog(0) && (Log() << Verbose(0) << " X - minimization iterations per wave function, if unsure leave at default value 0" << endl);
     346    DoLog(0) && (Log() << Verbose(0) << " Y - tolerance value for total spread in iterative Jacobi diagonalization" << endl);
     347    DoLog(0) && (Log() << Verbose(0) << " Z - Maximum number of minimization iterations" << endl);
     348    DoLog(0) && (Log() << Verbose(0) << " a - Relative change in total energy to stop min. iteration" << endl);
     349    DoLog(0) && (Log() << Verbose(0) << " b - Relative change in kinetic energy to stop min. iteration" << endl);
     350    DoLog(0) && (Log() << Verbose(0) << " c - Check stop conditions every ..th step during min. iteration" << endl);
     351    DoLog(0) && (Log() << Verbose(0) << " e - Maximum number of minimization iterations during initial level" << endl);
     352    DoLog(0) && (Log() << Verbose(0) << " f - Relative change in total energy to stop min. iteration during initial level" << endl);
     353    DoLog(0) && (Log() << Verbose(0) << " g - Relative change in kinetic energy to stop min. iteration during initial level" << endl);
     354    DoLog(0) && (Log() << Verbose(0) << " h - Check stop conditions every ..th step during min. iteration during initial level" << endl);
    354355//    Log() << Verbose(0) << " j - six lower diagonal entries of matrix, defining the unit cell" << endl;
    355     Log() << Verbose(0) << " k - Energy cutoff of plane wave basis in Hartree" << endl;
    356     Log() << Verbose(0) << " l - Maximum number of levels in multi-level-ansatz" << endl;
    357     Log() << Verbose(0) << " m - Factor by which grid nodes increase between standard and upper level" << endl;
    358     Log() << Verbose(0) << " n - 0: Don't use RiemannTensor, 1: Do" << endl;
    359     Log() << Verbose(0) << " o - Factor by which grid nodes increase between Riemann and standard(?) level" << endl;
    360     Log() << Verbose(0) << " p - Number of Riemann levels" << endl;
    361     Log() << Verbose(0) << " r - 0: Don't Use RiemannTensor, 1: Do" << endl;
    362     Log() << Verbose(0) << " s - 0: Doubly occupied orbitals, 1: Up-/Down-Orbitals" << endl;
    363     Log() << Verbose(0) << " t - Number of orbitals (depends pn SpinType)" << endl;
    364     Log() << Verbose(0) << " u - Number of SpinUp orbitals (depends on SpinType)" << endl;
    365     Log() << Verbose(0) << " v - Number of SpinDown orbitals (depends on SpinType)" << endl;
    366     Log() << Verbose(0) << " w - Number of additional, unoccupied orbitals" << endl;
    367     Log() << Verbose(0) << " x - radial cutoff for ewald summation in Bohrradii" << endl;
    368     Log() << Verbose(0) << " y - 0: Don't do structure optimization beforehand, 1: Do" << endl;
    369     Log() << Verbose(0) << " z - 0: Units are in Bohr radii, 1: units are in Aengstrom" << endl;
    370     Log() << Verbose(0) << " i - 0: Coordinates given in file are absolute, 1: ... are relative to unit cell" << endl;
    371     Log() << Verbose(0) << "=========================================================" << endl;
    372     Log() << Verbose(0) << "INPUT: ";
     356    DoLog(0) && (Log() << Verbose(0) << " k - Energy cutoff of plane wave basis in Hartree" << endl);
     357    DoLog(0) && (Log() << Verbose(0) << " l - Maximum number of levels in multi-level-ansatz" << endl);
     358    DoLog(0) && (Log() << Verbose(0) << " m - Factor by which grid nodes increase between standard and upper level" << endl);
     359    DoLog(0) && (Log() << Verbose(0) << " n - 0: Don't use RiemannTensor, 1: Do" << endl);
     360    DoLog(0) && (Log() << Verbose(0) << " o - Factor by which grid nodes increase between Riemann and standard(?) level" << endl);
     361    DoLog(0) && (Log() << Verbose(0) << " p - Number of Riemann levels" << endl);
     362    DoLog(0) && (Log() << Verbose(0) << " r - 0: Don't Use RiemannTensor, 1: Do" << endl);
     363    DoLog(0) && (Log() << Verbose(0) << " s - 0: Doubly occupied orbitals, 1: Up-/Down-Orbitals" << endl);
     364    DoLog(0) && (Log() << Verbose(0) << " t - Number of orbitals (depends pn SpinType)" << endl);
     365    DoLog(0) && (Log() << Verbose(0) << " u - Number of SpinUp orbitals (depends on SpinType)" << endl);
     366    DoLog(0) && (Log() << Verbose(0) << " v - Number of SpinDown orbitals (depends on SpinType)" << endl);
     367    DoLog(0) && (Log() << Verbose(0) << " w - Number of additional, unoccupied orbitals" << endl);
     368    DoLog(0) && (Log() << Verbose(0) << " x - radial cutoff for ewald summation in Bohrradii" << endl);
     369    DoLog(0) && (Log() << Verbose(0) << " y - 0: Don't do structure optimization beforehand, 1: Do" << endl);
     370    DoLog(0) && (Log() << Verbose(0) << " z - 0: Units are in Bohr radii, 1: units are in Aengstrom" << endl);
     371    DoLog(0) && (Log() << Verbose(0) << " i - 0: Coordinates given in file are absolute, 1: ... are relative to unit cell" << endl);
     372    DoLog(0) && (Log() << Verbose(0) << "=========================================================" << endl);
     373    DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    373374    cin >> choice;
    374375
    375376    switch (choice) {
    376377        case 'A': // mainname
    377           Log() << Verbose(0) << "Old: " << config::mainname << "\t new: ";
     378          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::mainname << "\t new: ");
    378379          cin >> config::mainname;
    379380          break;
    380381        case 'B': // defaultpath
    381           Log() << Verbose(0) << "Old: " << config::defaultpath << "\t new: ";
     382          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::defaultpath << "\t new: ");
    382383          cin >> config::defaultpath;
    383384          break;
    384385        case 'C': // pseudopotpath
    385           Log() << Verbose(0) << "Old: " << config::pseudopotpath << "\t new: ";
     386          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::pseudopotpath << "\t new: ");
    386387          cin >> config::pseudopotpath;
    387388          break;
    388389
    389390        case 'D': // ProcPEGamma
    390           Log() << Verbose(0) << "Old: " << config::ProcPEGamma << "\t new: ";
     391          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::ProcPEGamma << "\t new: ");
    391392          cin >> config::ProcPEGamma;
    392393          break;
    393394        case 'E': // ProcPEPsi
    394           Log() << Verbose(0) << "Old: " << config::ProcPEPsi << "\t new: ";
     395          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::ProcPEPsi << "\t new: ");
    395396          cin >> config::ProcPEPsi;
    396397          break;
    397398        case 'F': // DoOutVis
    398           Log() << Verbose(0) << "Old: " << config::DoOutVis << "\t new: ";
     399          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::DoOutVis << "\t new: ");
    399400          cin >> config::DoOutVis;
    400401          break;
    401402        case 'G': // DoOutMes
    402           Log() << Verbose(0) << "Old: " << config::DoOutMes << "\t new: ";
     403          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::DoOutMes << "\t new: ");
    403404          cin >> config::DoOutMes;
    404405          break;
    405406        case 'H': // DoOutOrbitals
    406           Log() << Verbose(0) << "Old: " << config::DoOutOrbitals << "\t new: ";
     407          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::DoOutOrbitals << "\t new: ");
    407408          cin >> config::DoOutOrbitals;
    408409          break;
    409410        case 'I': // DoOutCurrent
    410           Log() << Verbose(0) << "Old: " << config::DoOutCurrent << "\t new: ";
     411          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::DoOutCurrent << "\t new: ");
    411412          cin >> config::DoOutCurrent;
    412413          break;
    413414        case 'J': // DoFullCurrent
    414           Log() << Verbose(0) << "Old: " << config::DoFullCurrent << "\t new: ";
     415          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::DoFullCurrent << "\t new: ");
    415416          cin >> config::DoFullCurrent;
    416417          break;
    417418        case 'K': // DoPerturbation
    418           Log() << Verbose(0) << "Old: " << config::DoPerturbation << "\t new: ";
     419          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::DoPerturbation << "\t new: ");
    419420          cin >> config::DoPerturbation;
    420421          break;
    421422        case 'L': // CommonWannier
    422           Log() << Verbose(0) << "Old: " << config::CommonWannier << "\t new: ";
     423          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::CommonWannier << "\t new: ");
    423424          cin >> config::CommonWannier;
    424425          break;
    425426        case 'M': // SawtoothStart
    426           Log() << Verbose(0) << "Old: " << config::SawtoothStart << "\t new: ";
     427          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::SawtoothStart << "\t new: ");
    427428          cin >> config::SawtoothStart;
    428429          break;
    429430        case 'N': // VectorPlane
    430           Log() << Verbose(0) << "Old: " << config::VectorPlane << "\t new: ";
     431          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::VectorPlane << "\t new: ");
    431432          cin >> config::VectorPlane;
    432433          break;
    433434        case 'O': // VectorCut
    434           Log() << Verbose(0) << "Old: " << config::VectorCut << "\t new: ";
     435          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::VectorCut << "\t new: ");
    435436          cin >> config::VectorCut;
    436437          break;
    437438        case 'P': // UseAddGramSch
    438           Log() << Verbose(0) << "Old: " << config::UseAddGramSch << "\t new: ";
     439          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::UseAddGramSch << "\t new: ");
    439440          cin >> config::UseAddGramSch;
    440441          break;
    441442        case 'Q': // Seed
    442           Log() << Verbose(0) << "Old: " << config::Seed << "\t new: ";
     443          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::Seed << "\t new: ");
    443444          cin >> config::Seed;
    444445          break;
    445446
    446447        case 'R': // MaxOuterStep
    447           Log() << Verbose(0) << "Old: " << config::MaxOuterStep << "\t new: ";
     448          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::MaxOuterStep << "\t new: ");
    448449          cin >> config::MaxOuterStep;
    449450          break;
    450451        case 'T': // OutVisStep
    451           Log() << Verbose(0) << "Old: " << config::OutVisStep << "\t new: ";
     452          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::OutVisStep << "\t new: ");
    452453          cin >> config::OutVisStep;
    453454          break;
    454455        case 'U': // OutSrcStep
    455           Log() << Verbose(0) << "Old: " << config::OutSrcStep << "\t new: ";
     456          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::OutSrcStep << "\t new: ");
    456457          cin >> config::OutSrcStep;
    457458          break;
    458459        case 'X': // MaxPsiStep
    459           Log() << Verbose(0) << "Old: " << config::MaxPsiStep << "\t new: ";
     460          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::MaxPsiStep << "\t new: ");
    460461          cin >> config::MaxPsiStep;
    461462          break;
    462463        case 'Y': // EpsWannier
    463           Log() << Verbose(0) << "Old: " << config::EpsWannier << "\t new: ";
     464          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::EpsWannier << "\t new: ");
    464465          cin >> config::EpsWannier;
    465466          break;
    466467
    467468        case 'Z': // MaxMinStep
    468           Log() << Verbose(0) << "Old: " << config::MaxMinStep << "\t new: ";
     469          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::MaxMinStep << "\t new: ");
    469470          cin >> config::MaxMinStep;
    470471          break;
    471472        case 'a': // RelEpsTotalEnergy
    472           Log() << Verbose(0) << "Old: " << config::RelEpsTotalEnergy << "\t new: ";
     473          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::RelEpsTotalEnergy << "\t new: ");
    473474          cin >> config::RelEpsTotalEnergy;
    474475          break;
    475476        case 'b': // RelEpsKineticEnergy
    476           Log() << Verbose(0) << "Old: " << config::RelEpsKineticEnergy << "\t new: ";
     477          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::RelEpsKineticEnergy << "\t new: ");
    477478          cin >> config::RelEpsKineticEnergy;
    478479          break;
    479480        case 'c': // MaxMinStopStep
    480           Log() << Verbose(0) << "Old: " << config::MaxMinStopStep << "\t new: ";
     481          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::MaxMinStopStep << "\t new: ");
    481482          cin >> config::MaxMinStopStep;
    482483          break;
    483484        case 'e': // MaxInitMinStep
    484           Log() << Verbose(0) << "Old: " << config::MaxInitMinStep << "\t new: ";
     485          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::MaxInitMinStep << "\t new: ");
    485486          cin >> config::MaxInitMinStep;
    486487          break;
    487488        case 'f': // InitRelEpsTotalEnergy
    488           Log() << Verbose(0) << "Old: " << config::InitRelEpsTotalEnergy << "\t new: ";
     489          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::InitRelEpsTotalEnergy << "\t new: ");
    489490          cin >> config::InitRelEpsTotalEnergy;
    490491          break;
    491492        case 'g': // InitRelEpsKineticEnergy
    492           Log() << Verbose(0) << "Old: " << config::InitRelEpsKineticEnergy << "\t new: ";
     493          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::InitRelEpsKineticEnergy << "\t new: ");
    493494          cin >> config::InitRelEpsKineticEnergy;
    494495          break;
    495496        case 'h': // InitMaxMinStopStep
    496           Log() << Verbose(0) << "Old: " << config::InitMaxMinStopStep << "\t new: ";
     497          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::InitMaxMinStopStep << "\t new: ");
    497498          cin >> config::InitMaxMinStopStep;
    498499          break;
     
    500501//        case 'j': // BoxLength
    501502//          Log() << Verbose(0) << "enter lower triadiagonalo form of basis matrix" << endl << endl;
     503//          double * const cell_size = World::getInstance().getDomain();
    502504//          for (int i=0;i<6;i++) {
    503505//            Log() << Verbose(0) << "Cell size" << i << ": ";
    504 //            cin >> mol->cell_size[i];
     506//            cin >> cell_size[i];
    505507//          }
    506508//          break;
    507509
    508510        case 'k': // ECut
    509           Log() << Verbose(0) << "Old: " << config::ECut << "\t new: ";
     511          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::ECut << "\t new: ");
    510512          cin >> config::ECut;
    511513          break;
    512514        case 'l': // MaxLevel
    513           Log() << Verbose(0) << "Old: " << config::MaxLevel << "\t new: ";
     515          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::MaxLevel << "\t new: ");
    514516          cin >> config::MaxLevel;
    515517          break;
    516518        case 'm': // RiemannTensor
    517           Log() << Verbose(0) << "Old: " << config::RiemannTensor << "\t new: ";
     519          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::RiemannTensor << "\t new: ");
    518520          cin >> config::RiemannTensor;
    519521          break;
    520522        case 'n': // LevRFactor
    521           Log() << Verbose(0) << "Old: " << config::LevRFactor << "\t new: ";
     523          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::LevRFactor << "\t new: ");
    522524          cin >> config::LevRFactor;
    523525          break;
    524526        case 'o': // RiemannLevel
    525           Log() << Verbose(0) << "Old: " << config::RiemannLevel << "\t new: ";
     527          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::RiemannLevel << "\t new: ");
    526528          cin >> config::RiemannLevel;
    527529          break;
    528530        case 'p': // Lev0Factor
    529           Log() << Verbose(0) << "Old: " << config::Lev0Factor << "\t new: ";
     531          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::Lev0Factor << "\t new: ");
    530532          cin >> config::Lev0Factor;
    531533          break;
    532534        case 'r': // RTActualUse
    533           Log() << Verbose(0) << "Old: " << config::RTActualUse << "\t new: ";
     535          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::RTActualUse << "\t new: ");
    534536          cin >> config::RTActualUse;
    535537          break;
    536538        case 's': // PsiType
    537           Log() << Verbose(0) << "Old: " << config::PsiType << "\t new: ";
     539          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::PsiType << "\t new: ");
    538540          cin >> config::PsiType;
    539541          break;
    540542        case 't': // MaxPsiDouble
    541           Log() << Verbose(0) << "Old: " << config::MaxPsiDouble << "\t new: ";
     543          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::MaxPsiDouble << "\t new: ");
    542544          cin >> config::MaxPsiDouble;
    543545          break;
    544546        case 'u': // PsiMaxNoUp
    545           Log() << Verbose(0) << "Old: " << config::PsiMaxNoUp << "\t new: ";
     547          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::PsiMaxNoUp << "\t new: ");
    546548          cin >> config::PsiMaxNoUp;
    547549          break;
    548550        case 'v': // PsiMaxNoDown
    549           Log() << Verbose(0) << "Old: " << config::PsiMaxNoDown << "\t new: ";
     551          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::PsiMaxNoDown << "\t new: ");
    550552          cin >> config::PsiMaxNoDown;
    551553          break;
    552554        case 'w': // AddPsis
    553           Log() << Verbose(0) << "Old: " << config::AddPsis << "\t new: ";
     555          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::AddPsis << "\t new: ");
    554556          cin >> config::AddPsis;
    555557          break;
    556558
    557559        case 'x': // RCut
    558           Log() << Verbose(0) << "Old: " << config::RCut << "\t new: ";
     560          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::RCut << "\t new: ");
    559561          cin >> config::RCut;
    560562          break;
    561563        case 'y': // StructOpt
    562           Log() << Verbose(0) << "Old: " << config::StructOpt << "\t new: ";
     564          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::StructOpt << "\t new: ");
    563565          cin >> config::StructOpt;
    564566          break;
    565567        case 'z': // IsAngstroem
    566           Log() << Verbose(0) << "Old: " << config::IsAngstroem << "\t new: ";
     568          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::IsAngstroem << "\t new: ");
    567569          cin >> config::IsAngstroem;
    568570          break;
    569571        case 'i': // RelativeCoord
    570           Log() << Verbose(0) << "Old: " << config::RelativeCoord << "\t new: ";
     572          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::RelativeCoord << "\t new: ");
    571573          cin >> config::RelativeCoord;
    572574          break;
     
    647649  }
    648650  strcpy(configname, ptr);
    649   Log() << Verbose(0) << "Found configpath: " << configpath << ", dir slash was found at " << last << ", config name is " << configname << "." << endl;
     651  DoLog(0) && (Log() << Verbose(0) << "Found configpath: " << configpath << ", dir slash was found at " << last << ", config name is " << configname << "." << endl);
    650652  delete[](buffer);
    651653};
     
    658660{
    659661  if (FileBuffer != NULL) {
    660     eLog() << Verbose(2) << "deleting present FileBuffer in PrepareFileBuffer()." << endl;
     662    DoeLog(2) && (eLog()<< Verbose(2) << "deleting present FileBuffer in PrepareFileBuffer()." << endl);
    661663    delete(FileBuffer);
    662664  }
     
    684686
    685687  if (mol == NULL) {
    686     eLog() << Verbose(0) << "Molecule is not allocated in LoadMolecule(), exit.";
     688    DoeLog(0) && (eLog()<< Verbose(0) << "Molecule is not allocated in LoadMolecule(), exit.");
    687689    performCriticalExit();
    688690  }
     
    690692  ParseForParameter(verbose,FileBuffer,"MaxTypes", 0, 1, 1, int_type, &(MaxTypes), 1, critical);
    691693  if (MaxTypes == 0) {
    692     eLog() << Verbose(0) << "There are no atoms according to MaxTypes in this config file." << endl;
    693     performCriticalExit();
     694    DoeLog(1) && (eLog()<< Verbose(1) << "There are no atoms according to MaxTypes in this config file." << endl);
     695    //performCriticalExit();
    694696  } else {
    695697    // prescan number of ions per type
    696     Log() << Verbose(0) << "Prescanning ions per type: " << endl;
     698    DoLog(0) && (Log() << Verbose(0) << "Prescanning ions per type: " << endl);
    697699    int NoAtoms = 0;
    698700    for (int i=0; i < MaxTypes; i++) {
     
    701703      ParseForParameter(verbose,FileBuffer, name, 0, 2, 1, int_type, &Z, 1, critical);
    702704      elementhash[i] = periode->FindElement(Z);
    703       Log() << Verbose(1) << i << ". Z = " << elementhash[i]->Z << " with " << No[i] << " ions." << endl;
     705      DoLog(1) && (Log() << Verbose(1) << i << ". Z = " << elementhash[i]->Z << " with " << No[i] << " ions." << endl);
    704706      NoAtoms += No[i];
    705707    }
     
    709711    sprintf(name,"Ion_Type%i",MaxTypes);
    710712    if (!ParseForParameter(verbose,FileBuffer, (const char*)name, 1, 1, 1, int_type, &value[0], 1, critical)) {
    711       eLog() << Verbose(0) << "There are no atoms in the config file!" << endl;
     713      DoeLog(0) && (eLog()<< Verbose(0) << "There are no atoms in the config file!" << endl);
    712714      performCriticalExit();
    713715      return;
     
    727729      bool status = true;
    728730      while (status) {
    729         Log() << Verbose(0) << "Currently parsing MD step " << repetition << "." << endl;
     731        DoLog(0) && (Log() << Verbose(0) << "Currently parsing MD step " << repetition << "." << endl);
    730732        for (int i=0; i < MaxTypes; i++) {
    731733          sprintf(name,"Ion_Type%i",i+1);
     
    793795      }
    794796      repetition--;
    795       Log() << Verbose(0) << "Found " << repetition << " trajectory steps." << endl;
     797      DoLog(0) && (Log() << Verbose(0) << "Found " << repetition << " trajectory steps." << endl);
    796798      if (repetition <= 1)  // if onyl one step, desactivate use of trajectories
    797799        mol->MDSteps = 0;
     
    805807              ParseForParameter(verbose,FileBuffer, "Ion_Type1_1", 0, 3, 1, double_type, &value[2], repetition, (repetition == 0) ? critical : optional))
    806808        repetition++;
    807       Log() << Verbose(0) << "I found " << repetition << " times the keyword Ion_Type1_1." << endl;
     809      DoLog(0) && (Log() << Verbose(0) << "I found " << repetition << " times the keyword Ion_Type1_1." << endl);
    808810      // parse in molecule coordinates
    809811      for (int i=0; i < MaxTypes; i++) {
     
    854856  ifstream *file = new ifstream(filename);
    855857  if (file == NULL) {
    856     eLog() << Verbose(1) << "config file " << filename << " missing!" << endl;
     858    DoeLog(1) && (eLog()<< Verbose(1) << "config file " << filename << " missing!" << endl);
    857859    return;
    858860  }
     
    966968  // Unit cell and magnetic field
    967969  ParseForParameter(verbose,FileBuffer, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */
    968   mol->cell_size[0] = BoxLength[0];
    969   mol->cell_size[1] = BoxLength[3];
    970   mol->cell_size[2] = BoxLength[4];
    971   mol->cell_size[3] = BoxLength[6];
    972   mol->cell_size[4] = BoxLength[7];
    973   mol->cell_size[5] = BoxLength[8];
     970  double * const cell_size = World::getInstance().getDomain();
     971  cell_size[0] = BoxLength[0];
     972  cell_size[1] = BoxLength[3];
     973  cell_size[2] = BoxLength[4];
     974  cell_size[3] = BoxLength[6];
     975  cell_size[4] = BoxLength[7];
     976  cell_size[5] = BoxLength[8];
    974977  //if (1) fprintf(stderr,"\n");
    975978
     
    10611064    BG = new BondGraph(IsAngstroem);
    10621065    if (BG->LoadBondLengthTable(BondGraphFileName)) {
    1063       Log() << Verbose(0) << "Bond length table loaded successfully." << endl;
     1066      DoLog(0) && (Log() << Verbose(0) << "Bond length table loaded successfully." << endl);
    10641067    } else {
    1065       eLog() << Verbose(1) << "Bond length table loading failed." << endl;
     1068      DoeLog(1) && (eLog()<< Verbose(1) << "Bond length table loading failed." << endl);
    10661069    }
    10671070  }
     
    10921095  ifstream *file = new ifstream(filename);
    10931096  if (file == NULL) {
    1094     eLog() << Verbose(1) << "config file " << filename << " missing!" << endl;
     1097    DoeLog(1) && (eLog()<< Verbose(1) << "config file " << filename << " missing!" << endl);
    10951098    return;
    10961099  }
     
    11701173
    11711174  ParseForParameter(verbose,file, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */
    1172   mol->cell_size[0] = BoxLength[0];
    1173   mol->cell_size[1] = BoxLength[3];
    1174   mol->cell_size[2] = BoxLength[4];
    1175   mol->cell_size[3] = BoxLength[6];
    1176   mol->cell_size[4] = BoxLength[7];
    1177   mol->cell_size[5] = BoxLength[8];
     1175  double * const cell_size = World::getInstance().getDomain();
     1176  cell_size[0] = BoxLength[0];
     1177  cell_size[1] = BoxLength[3];
     1178  cell_size[2] = BoxLength[4];
     1179  cell_size[3] = BoxLength[6];
     1180  cell_size[4] = BoxLength[7];
     1181  cell_size[5] = BoxLength[8];
    11781182  if (1) fprintf(stderr,"\n");
    11791183  config::DoPerturbation = 0;
     
    12511255  BG = new BondGraph(IsAngstroem);
    12521256  if (BG->LoadBondLengthTable(BondGraphFileName)) {
    1253     Log() << Verbose(0) << "Bond length table loaded successfully." << endl;
     1257    DoLog(0) && (Log() << Verbose(0) << "Bond length table loaded successfully." << endl);
    12541258  } else {
    1255     Log() << Verbose(0) << "Bond length table loading failed." << endl;
     1259    DoLog(0) && (Log() << Verbose(0) << "Bond length table loading failed." << endl);
    12561260  }
    12571261
     
    12601264  for (i=MAX_ELEMENTS;i--;)
    12611265    elementhash[i] = NULL;
    1262   Log() << Verbose(0) << "Parsing Ions ..." << endl;
     1266  DoLog(0) && (Log() << Verbose(0) << "Parsing Ions ..." << endl);
    12631267  No=0;
    12641268  found = 0;
    12651269  while (getline(*file,zeile,'\n')) {
    12661270    if (zeile.find("Ions_Data") == 0) {
    1267       Log() << Verbose(1) << "found Ions_Data...begin parsing" << endl;
     1271      DoLog(1) && (Log() << Verbose(1) << "found Ions_Data...begin parsing" << endl);
    12681272      found ++;
    12691273    }
     
    12791283      input >> b;     // element mass
    12801284      elementhash[No] = periode->FindElement(Z);
    1281       Log() << Verbose(1) << "AtomNo: " << AtomNo << "\tZ: " << Z << "\ta:" << a << "\tl:"  << l << "\b:" << b << "\tElement:" << elementhash[No] << "\t:" << endl;
     1285      DoLog(1) && (Log() << Verbose(1) << "AtomNo: " << AtomNo << "\tZ: " << Z << "\ta:" << a << "\tl:"  << l << "\b:" << b << "\tElement:" << elementhash[No] << "\t:" << endl);
    12821286      for(i=0;i<AtomNo;i++) {
    12831287        if (!getline(*file,zeile,'\n')) {// parse on and on
    1284           Log() << Verbose(2) << "Error: Too few items in ionic list of element" << elementhash[No] << "." << endl << "Exiting." << endl;
     1288          DoLog(2) && (Log() << Verbose(2) << "Error: Too few items in ionic list of element" << elementhash[No] << "." << endl << "Exiting." << endl);
    12851289          // return 1;
    12861290        } else {
     
    13131317  // bring MaxTypes up to date
    13141318  mol->CountElements();
     1319  const double * const cell_size = World::getInstance().getDomain();
    13151320  ofstream * const output = new ofstream(filename, ios::out);
    13161321  if (output != NULL) {
     
    13831388    *output << endl;
    13841389    *output << "BoxLength\t\t\t# (Length of a unit cell)" << endl;
    1385     *output << mol->cell_size[0] << "\t" << endl;
    1386     *output << mol->cell_size[1] << "\t" << mol->cell_size[2] << "\t" << endl;
    1387     *output << mol->cell_size[3] << "\t" << mol->cell_size[4] << "\t" << mol->cell_size[5] << "\t" << endl;
     1390    *output << cell_size[0] << "\t" << endl;
     1391    *output << cell_size[1] << "\t" << cell_size[2] << "\t" << endl;
     1392    *output << cell_size[3] << "\t" << cell_size[4] << "\t" << cell_size[5] << "\t" << endl;
    13881393    // FIXME
    13891394    *output << endl;
     
    14291434    return result;
    14301435  } else {
    1431     eLog() << Verbose(1) << "Cannot open output file:" << filename << endl;
     1436    DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open output file:" << filename << endl);
    14321437    return false;
    14331438  }
     
    14511456    output = new ofstream(fname->str().c_str(), ios::out);
    14521457    if (output == NULL) {
    1453       eLog() << Verbose(1) << "Cannot open mpqc output file:" << fname << endl;
     1458      DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open mpqc output file:" << fname << endl);
    14541459      delete(fname);
    14551460      return false;
     
    14941499    output = new ofstream(fname->str().c_str(), ios::out);
    14951500    if (output == NULL) {
    1496       eLog() << Verbose(1) << "Cannot open mpqc hessian output file:" << fname << endl;
     1501      DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open mpqc hessian output file:" << fname << endl);
    14971502      delete(fname);
    14981503      return false;
     
    15501555  f = fopen(name, "w" );
    15511556  if (f == NULL) {
    1552     eLog() << Verbose(1) << "Cannot open pdb output file:" << name << endl;
     1557    DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open pdb output file:" << name << endl);
    15531558    return false;
    15541559  }
     
    16051610  f = fopen(name, "w" );
    16061611  if (f == NULL) {
    1607     eLog() << Verbose(1) << "Cannot open pdb output file:" << name << endl;
     1612    DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open pdb output file:" << name << endl);
    16081613    Free(&elementNo);
    16091614    return false;
     
    16421647/** Stores all atoms in a TREMOLO data input file.
    16431648 * Note that this format cannot be parsed again.
     1649 * Note that TREMOLO does not like Id starting at 0, but at 1. Atoms with Id 0 are discarded!
    16441650 * \param *filename name of file (without ".in" suffix!)
    16451651 * \param *mol pointer to molecule
     
    16541660  output = new ofstream(fname->str().c_str(), ios::out);
    16551661  if (output == NULL) {
    1656     eLog() << Verbose(1) << "Cannot open tremolo output file:" << fname << endl;
     1662    DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open tremolo output file:" << fname << endl);
    16571663    delete(fname);
    16581664    return false;
     
    16961702/** Stores all atoms from all molecules in a TREMOLO data input file.
    16971703 * Note that this format cannot be parsed again.
     1704 * Note that TREMOLO does not like Id starting at 0, but at 1. Atoms with Id 0 are discarded!
    16981705 * \param *filename name of file (without ".in" suffix!)
    16991706 * \param *MolList pointer to MoleculeListClass containing all atoms
     
    17081715  output = new ofstream(fname->str().c_str(), ios::out);
    17091716  if (output == NULL) {
    1710     eLog() << Verbose(1) << "Cannot open tremolo output file:" << fname << endl;
     1717    DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open tremolo output file:" << fname << endl);
    17111718    delete(fname);
    17121719    return false;
     
    17481755      while (Walker->next != (*MolWalker)->end) {
    17491756        Walker = Walker->next;
    1750         *output << AtomNo << "\t";
     1757        *output << AtomNo+1 << "\t";
    17511758        *output << Walker->Name << "\t";
    17521759        *output << (*MolWalker)->name << "\t";
    1753         *output << MolCounter << "\t";
     1760        *output << MolCounter+1 << "\t";
    17541761        *output << Walker->node->x[0] << "\t" << Walker->node->x[1] << "\t" << Walker->node->x[2] << "\t";
    17551762        *output << (double)Walker->type->Valence << "\t";
    17561763        *output << Walker->type->symbol << "\t";
    17571764        for (BondList::iterator runner = Walker->ListOfBonds.begin(); runner != Walker->ListOfBonds.end(); runner++)
    1758           *output << LocalNotoGlobalNoMap[MolCounter][ (*runner)->GetOtherAtom(Walker)->nr ] << "\t";
     1765          *output << LocalNotoGlobalNoMap[MolCounter][ (*runner)->GetOtherAtom(Walker)->nr ]+1 << "\t";
    17591766        for(int i=Walker->ListOfBonds.size(); i < MaxNeighbours; i++)
    17601767          *output << "-\t";
  • src/datacreator.cpp

    r13d5a9 r5f612ee  
    2525  output.open(name.str().c_str(), ios::out);
    2626  if (output == NULL) {
    27     Log() << Verbose(0) << "Unable to open " << name.str() << " for writing, is directory correct?" << endl;
     27    DoLog(0) && (Log() << Verbose(0) << "Unable to open " << name.str() << " for writing, is directory correct?" << endl);
    2828    return false;
    2929  }
     
    4343  output.open(name.str().c_str(), ios::app);
    4444  if (output == NULL) {
    45     Log() << Verbose(0) << "Unable to open " << name.str() << " for writing, is directory correct?" << endl;
     45    DoLog(0) && (Log() << Verbose(0) << "Unable to open " << name.str() << " for writing, is directory correct?" << endl);
    4646    return false;
    4747  }
     
    6363  filename << prefix << ".dat";
    6464  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
    65   Log() << Verbose(0) << msg << endl;
     65  DoLog(0) && (Log() << Verbose(0) << msg << endl);
    6666  output << "# " << msg << ", created on " << datum;
    6767  output << "#Order\tFrag.No.\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
     
    9696  filename << prefix << ".dat";
    9797  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
    98   Log() << Verbose(0) << msg << endl;
     98  DoLog(0) && (Log() << Verbose(0) << msg << endl);
    9999  output << "# " << msg << ", created on " << datum;
    100100  output << "#Order\tFrag.No.\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
     
    133133  filename << prefix << ".dat";
    134134  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
    135   Log() << Verbose(0) << msg << endl;
     135  DoLog(0) && (Log() << Verbose(0) << msg << endl);
    136136  output << "# " << msg << ", created on " << datum;
    137137  output << "# Order\tFrag.No.\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
     
    165165  filename << prefix << ".dat";
    166166  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
    167   Log() << Verbose(0) << msg << endl;
     167  DoLog(0) && (Log() << Verbose(0) << msg << endl);
    168168  output << "# " << msg << ", created on " << datum;
    169169  output << "# Order\tFrag.No.\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
     
    198198  filename << prefix << ".dat";
    199199  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
    200   Log() << Verbose(0) << msg << endl;
     200  DoLog(0) && (Log() << Verbose(0) << msg << endl);
    201201  output << "# " << msg << ", created on " << datum;
    202202  output << "# AtomNo\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
     
    244244  filename << prefix << ".dat";
    245245  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
    246   Log() << Verbose(0) << msg << endl;
     246  DoLog(0) && (Log() << Verbose(0) << msg << endl);
    247247  output << "# " << msg << ", created on " << datum;
    248248  output << "# AtomNo\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
     
    281281  filename << prefix << ".dat";
    282282  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
    283   Log() << Verbose(0) << msg << endl;
     283  DoLog(0) && (Log() << Verbose(0) << msg << endl);
    284284  output << "# " << msg << ", created on " << datum;
    285285  output << "# AtomNo\t" << Fragments.Header[Fragments.MatrixCounter] << endl;
     
    321321  filename << prefix << ".dat";
    322322  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
    323   Log() << Verbose(0) << msg << endl;
     323  DoLog(0) && (Log() << Verbose(0) << msg << endl);
    324324  output << "# " << msg << ", created on " << datum;
    325325  output << "# AtomNo\t";
     
    363363  filename << prefix << ".dat";
    364364  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
    365   Log() << Verbose(0) << msg << endl;
     365  DoLog(0) && (Log() << Verbose(0) << msg << endl);
    366366  output << "# " << msg << ", created on " << datum;
    367367  output << "# AtomNo\t" << Fragments.Header[ Fragments.MatrixCounter ] << endl;
     
    393393  filename << prefix << ".dat";
    394394  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
    395   Log() << Verbose(0) << msg << endl;
     395  DoLog(0) && (Log() << Verbose(0) << msg << endl);
    396396  output << "# " << msg << ", created on " << datum << endl;
    397397  output << "#Order\tFrag.No.\t" << Fragment.Header[ Fragment.MatrixCounter ] << endl;
     
    458458  filename << prefix << ".dat";
    459459  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
    460   Log() << Verbose(0) << msg << endl;
     460  DoLog(0) && (Log() << Verbose(0) << msg << endl);
    461461  output << "# " << msg << ", created on " << datum;
    462462  output << "#Order\tFrag.No.\t" << Fragment.Header[ Fragment.MatrixCounter ] << endl;
  • src/defs.hpp

    r13d5a9 r5f612ee  
    1212#define MAX_ELEMENTS 128  //!< maximum number of elements for certain lookup tables
    1313#define AtomicLengthToAngstroem  0.52917721 //!< conversion factor from atomic length/bohrradius to angstroem
    14 #define BONDTHRESHOLD 0.5   //!< CSD threshold in bond check which is the width of the interval whose center is the sum of the covalent radii
    1514#define AtomicEnergyToKelvin 315774.67  //!< conversion factor from atomic energy to kelvin via boltzmann factor
    1615#define KelvinToAtomicTemperature 3.1668152e-06    //!< conversion factor for Kelvin to atomic temperature (Hartree over k_B)
  • src/ellipsoid.cpp

    r13d5a9 r5f612ee  
    146146{
    147147  int status = GSL_SUCCESS;
    148   Log() << Verbose(2) << "Begin of FitPointSetToEllipsoid " << endl;
     148  DoLog(2) && (Log() << Verbose(2) << "Begin of FitPointSetToEllipsoid " << endl);
    149149  if (N >= 3) { // check that enough points are given (9 d.o.f.)
    150150    struct EllipsoidMinimisation par;
     
    199199          EllipsoidAngle[i] = gsl_vector_get (s->x, i+6);
    200200        }
    201         Log() << Verbose(4) << setprecision(3) << "Converged fit at: " << *EllipsoidCenter << ", lengths " << EllipsoidLength[0] << ", " << EllipsoidLength[1] << ", " << EllipsoidLength[2] << ", angles " << EllipsoidAngle[0] << ", " << EllipsoidAngle[1] << ", " << EllipsoidAngle[2] << " with summed distance " << s->fval << "." << endl;
     201        DoLog(4) && (Log() << Verbose(4) << setprecision(3) << "Converged fit at: " << *EllipsoidCenter << ", lengths " << EllipsoidLength[0] << ", " << EllipsoidLength[1] << ", " << EllipsoidLength[2] << ", angles " << EllipsoidAngle[0] << ", " << EllipsoidAngle[1] << ", " << EllipsoidAngle[2] << " with summed distance " << s->fval << "." << endl);
    202202      }
    203203
     
    209209
    210210  } else {
    211     Log() << Verbose(3) << "Not enough points provided for fit to ellipsoid." << endl;
     211    DoLog(3) && (Log() << Verbose(3) << "Not enough points provided for fit to ellipsoid." << endl);
    212212    return false;
    213213  }
    214   Log() << Verbose(2) << "End of FitPointSetToEllipsoid" << endl;
     214  DoLog(2) && (Log() << Verbose(2) << "End of FitPointSetToEllipsoid" << endl);
    215215  if (status == GSL_SUCCESS)
    216216    return true;
     
    235235  int index;
    236236  TesselPoint *Candidate = NULL;
    237   Log() << Verbose(2) << "Begin of PickRandomPointSet" << endl;
     237  DoLog(2) && (Log() << Verbose(2) << "Begin of PickRandomPointSet" << endl);
    238238
    239239  // allocate array
     
    241241    x = new Vector[PointsToPick];
    242242  } else {
    243     eLog() << Verbose(2) << "Given pointer to vector array seems already allocated." << endl;
     243    DoeLog(2) && (eLog()<< Verbose(2) << "Given pointer to vector array seems already allocated." << endl);
    244244  }
    245245
     
    247247    for(int i=0;i<NDIM;i++) // pick three random indices
    248248      LC->n[i] = (rand() % LC->N[i]);
    249     Log() << Verbose(2) << "INFO: Center cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " ... ";
     249    DoLog(2) && (Log() << Verbose(2) << "INFO: Center cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " ... ");
    250250    // get random cell
    251     const LinkedNodes *List = LC->GetCurrentCell();
     251    const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
    252252    if (List == NULL) {  // set index to it
    253253      continue;
    254254    }
    255     Log() << Verbose(2) << "with No. " << LC->index << "." << endl;
    256 
    257     Log() << Verbose(2) << "LC Intervals:";
     255    DoLog(2) && (Log() << Verbose(2) << "with No. " << LC->index << "." << endl);
     256
     257    DoLog(2) && (Log() << Verbose(2) << "LC Intervals:");
    258258    for (int i=0;i<NDIM;i++) {
    259259      Nlower[i] = ((LC->n[i]-1) >= 0) ? LC->n[i]-1 : 0;
    260260      Nupper[i] = ((LC->n[i]+1) < LC->N[i]) ? LC->n[i]+1 : LC->N[i]-1;
    261       Log() << Verbose(0) << " [" << Nlower[i] << "," << Nupper[i] << "] ";
    262     }
    263     Log() << Verbose(0) << endl;
     261      DoLog(0) && (Log() << Verbose(0) << " [" << Nlower[i] << "," << Nupper[i] << "] ");
     262    }
     263    DoLog(0) && (Log() << Verbose(0) << endl);
    264264
    265265    // count whether there are sufficient atoms in this cell+neighbors
     
    268268      for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
    269269        for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
    270           const LinkedNodes *List = LC->GetCurrentCell();
     270          const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
    271271          PointsLeft += List->size();
    272272        }
    273     Log() << Verbose(2) << "There are " << PointsLeft << " atoms in this neighbourhood." << endl;
     273    DoLog(2) && (Log() << Verbose(2) << "There are " << PointsLeft << " atoms in this neighbourhood." << endl);
    274274    if (PointsLeft < PointsToPick) {  // ensure that we can pick enough points in its neighbourhood at all.
    275275      continue;
     
    293293      for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
    294294        for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
    295           const LinkedNodes *List = LC->GetCurrentCell();
     295          const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
    296296//          Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;
    297297          if (List != NULL) {
     
    300300//            else
    301301//              Log() << Verbose(2) << "Cell is empty ... " << endl;
    302             for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
     302            for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    303303              if ((current != PickedAtomNrs.end()) && (*current == index)) {
    304304                Candidate = (*Runner);
    305                 Log() << Verbose(2) << "Current picked node is " << **Runner << " with index " << index << "." << endl;
     305                DoLog(2) && (Log() << Verbose(2) << "Current picked node is " << **Runner << " with index " << index << "." << endl);
    306306                x[PointsPicked++].CopyVector(Candidate->node);    // we have one more atom picked
    307307                current++;    // next pre-picked atom
     
    313313          }
    314314        }
    315     Log() << Verbose(2) << "The following points were picked: " << endl;
     315    DoLog(2) && (Log() << Verbose(2) << "The following points were picked: " << endl);
    316316    for (size_t i=0;i<PointsPicked;i++)
    317       Log() << Verbose(2) << x[i] << endl;
     317      DoLog(2) && (Log() << Verbose(2) << x[i] << endl);
    318318    if (PointsPicked == PointsToPick)  // break out of loop if we have all
    319319      break;
    320320  } while(1);
    321321
    322   Log() << Verbose(2) << "End of PickRandomPointSet" << endl;
     322  DoLog(2) && (Log() << Verbose(2) << "End of PickRandomPointSet" << endl);
    323323};
    324324
     
    335335  double value, threshold;
    336336  PointMap *List = &T->PointsOnBoundary;
    337   Log() << Verbose(2) << "Begin of PickRandomPointSet" << endl;
     337  DoLog(2) && (Log() << Verbose(2) << "Begin of PickRandomPointSet" << endl);
    338338
    339339  // allocate array
     
    341341    x = new Vector[PointsToPick];
    342342  } else {
    343     eLog() << Verbose(2) << "Given pointer to vector array seems already allocated." << endl;
     343    DoeLog(2) && (eLog()<< Verbose(2) << "Given pointer to vector array seems already allocated." << endl);
    344344  }
    345345
     
    358358      PointsLeft--;
    359359    }
    360   Log() << Verbose(2) << "The following points were picked: " << endl;
     360  DoLog(2) && (Log() << Verbose(2) << "The following points were picked: " << endl);
    361361  for (size_t i=0;i<PointsPicked;i++)
    362     Log() << Verbose(3) << x[i] << endl;
    363 
    364   Log() << Verbose(2) << "End of PickRandomPointSet" << endl;
     362    DoLog(3) && (Log() << Verbose(3) << x[i] << endl);
     363
     364  DoLog(2) && (Log() << Verbose(2) << "End of PickRandomPointSet" << endl);
    365365};
    366366
     
    382382  double EllipsoidAngle[3];
    383383  double distance, MaxDistance, MinDistance;
    384   Log() << Verbose(0) << "Begin of FindDistributionOfEllipsoids" << endl;
     384  DoLog(0) && (Log() << Verbose(0) << "Begin of FindDistributionOfEllipsoids" << endl);
    385385
    386386  // construct center of gravity of boundary point set for initial ellipsoid center
     
    389389    Center.AddVector(Runner->second->node->node);
    390390  Center.Scale(1./T->PointsOnBoundaryCount);
    391   Log() << Verbose(1) << "Center is at " << Center << "." << endl;
     391  DoLog(1) && (Log() << Verbose(1) << "Center is at " << Center << "." << endl);
    392392
    393393  // Output header
     
    397397  // loop over desired number of parameter sets
    398398  for (;number >0;number--) {
    399     Log() << Verbose(1) << "Determining data set " << number << " ... " << endl;
     399    DoLog(1) && (Log() << Verbose(1) << "Determining data set " << number << " ... " << endl);
    400400    // pick the point set
    401401    x = NULL;
     
    423423    // fit the parameters
    424424    if (FitPointSetToEllipsoid(x, N, &EllipsoidCenter, &EllipsoidLength[0], &EllipsoidAngle[0])) {
    425       Log() << Verbose(1) << "Picking succeeded!" << endl;
     425      DoLog(1) && (Log() << Verbose(1) << "Picking succeeded!" << endl);
    426426      // output obtained parameter set
    427427      output << number << "\t";
     
    434434      output << endl;
    435435    } else { // increase N to pick one more
    436       Log() << Verbose(1) << "Picking failed!" << endl;
     436      DoLog(1) && (Log() << Verbose(1) << "Picking failed!" << endl);
    437437      number++;
    438438    }
     
    442442  output.close();
    443443
    444   Log() << Verbose(0) << "End of FindDistributionOfEllipsoids" << endl;
    445 };
     444  DoLog(0) && (Log() << Verbose(0) << "End of FindDistributionOfEllipsoids" << endl);
     445};
  • src/errorlogger.cpp

    r13d5a9 r5f612ee  
    5656  int verbosityLevel = l.verbosity;
    5757  l.nix->clear();
    58   if (v.DoOutput(verbosityLevel)) {
     58  if (v.DoErrorOutput(verbosityLevel)) {
    5959    switch(v.Verbosity) {
    6060      case 0:
     
    7979  int verbosityLevel = l->verbosity;
    8080  l->nix->clear();
    81   if (v.DoOutput(verbosityLevel)) {
     81  if (v.DoErrorOutput(verbosityLevel)) {
    8282    switch(v.Verbosity) {
    8383      case 0:
     
    8888        break;
    8989      case 2:
     90      default:
    9091        cerr << "WARNING: ";
    91         break;
    92       default:
    9392        break;
    9493    }
  • src/graph.cpp

    r13d5a9 r5f612ee  
    8585  testGraphInsert = Fragment->Leaflet->insert(GraphPair (*Fragment->FragmentSet,pair<int,double>(Fragment->FragmentCounter,Fragment->TEFactor)));  // store fragment number and current factor
    8686  if (testGraphInsert.second) {
    87     Log() << Verbose(2) << "KeySet " << Fragment->FragmentCounter << " successfully inserted." << endl;
     87    DoLog(2) && (Log() << Verbose(2) << "KeySet " << Fragment->FragmentCounter << " successfully inserted." << endl);
    8888    Fragment->FragmentCounter++;
    8989  } else {
    90     Log() << Verbose(2) << "KeySet " << Fragment->FragmentCounter << " failed to insert, present fragment is " << ((*(testGraphInsert.first)).second).first << endl;
     90    DoLog(2) && (Log() << Verbose(2) << "KeySet " << Fragment->FragmentCounter << " failed to insert, present fragment is " << ((*(testGraphInsert.first)).second).first << endl);
    9191    ((*(testGraphInsert.first)).second).second += Fragment->TEFactor;  // increase the "created" counter
    92     Log() << Verbose(2) << "New factor is " << ((*(testGraphInsert.first)).second).second << "." << endl;
     92    DoLog(2) && (Log() << Verbose(2) << "New factor is " << ((*(testGraphInsert.first)).second).second << "." << endl);
    9393  }
    9494};
     
    115115    testGraphInsert = graph1.insert(GraphPair ((*runner).first,pair<int,double>((*counter)++,((*runner).second).second)));  // store fragment number and current factor
    116116    if (testGraphInsert.second) {
    117       Log() << Verbose(2) << "KeySet " << (*counter)-1 << " successfully inserted." << endl;
     117      DoLog(2) && (Log() << Verbose(2) << "KeySet " << (*counter)-1 << " successfully inserted." << endl);
    118118    } else {
    119       Log() << Verbose(2) << "KeySet " << (*counter)-1 << " failed to insert, present fragment is " << ((*(testGraphInsert.first)).second).first << endl;
     119      DoLog(2) && (Log() << Verbose(2) << "KeySet " << (*counter)-1 << " failed to insert, present fragment is " << ((*(testGraphInsert.first)).second).first << endl);
    120120      ((*(testGraphInsert.first)).second).second += (*runner).second.second;
    121       Log() << Verbose(2) << "New factor is " << (*(testGraphInsert.first)).second.second << "." << endl;
     121      DoLog(2) && (Log() << Verbose(2) << "New factor is " << (*(testGraphInsert.first)).second.second << "." << endl);
    122122    }
    123123  }
  • src/gslvector.cpp

    r13d5a9 r5f612ee  
    66 */
    77
     8#include <cassert>
     9#include <cmath>
     10
    811#include "gslvector.hpp"
     12#include "defs.hpp"
    913
    1014/** Constructor of class GSLVector.
     
    2731};
    2832
     33/** Copy constructor of class GSLVector.
     34 * Allocates GSL structures and copies components from \a *src.
     35 * \param *src source vector
     36 */
     37GSLVector::GSLVector(const GSLVector & src) : dimension(src.dimension)
     38{
     39  vector = gsl_vector_alloc(dimension);
     40  gsl_vector_memcpy (vector, src.vector);
     41};
     42
    2943/** Destructor of class GSLVector.
    3044 * Frees GSL structures
     
    3347{
    3448  gsl_vector_free(vector);
    35   dimension = 0;
    3649};
    3750
     
    5265 * \return  m-th element of vector
    5366 */
    54 double GSLVector::Get(size_t m)
     67double GSLVector::Get(size_t m) const
    5568{
    5669  return gsl_vector_get (vector, m);
     
    7285 * \return pointer to \a m-th element
    7386 */
    74 double *GSLVector::Pointer(size_t m)
     87double *GSLVector::Pointer(size_t m) const
    7588{
    7689  return gsl_vector_ptr (vector, m);
     
    8295 * \return const pointer to \a m-th element
    8396 */
    84 const double *GSLVector::const_Pointer(size_t m)
     97const double *GSLVector::const_Pointer(size_t m) const
    8598{
    8699  return gsl_vector_const_ptr (vector, m);
     100};
     101
     102/** Returns the dimension of the vector.
     103 * \return dimension of vector
     104 */
     105#ifdef HAVE_INLINE
     106inline
     107#endif
     108size_t GSLVector::GetDimension() const
     109{
     110  return dimension;
    87111};
    88112
     
    128152  return gsl_vector_reverse (vector);
    129153};
     154
     155
     156/* ========================== Operators =============================== */
     157/** Compares GSLVector \a to GSLVector \a b component-wise.
     158 * \param a base GSLVector
     159 * \param b GSLVector components to add
     160 * \return a == b
     161 */
     162bool operator==(const GSLVector& a, const GSLVector& b)
     163{
     164  bool status = true;
     165  assert(a.GetDimension() == b.GetDimension() && "Dimenions of GSLVectors to compare differ");
     166  for (size_t i=0;i<a.GetDimension();i++)
     167    status = status && (fabs(a.Get(i) - b.Get(i)) < MYEPSILON);
     168  return status;
     169};
     170
     171/** Sums GSLVector \a to this lhs component-wise.
     172 * \param a base GSLVector
     173 * \param b GSLVector components to add
     174 * \return lhs + a
     175 */
     176const GSLVector& operator+=(GSLVector& a, const GSLVector& b)
     177{
     178  assert(a.GetDimension() == b.GetDimension() && "Dimenions of GSLVectors to compare differ");
     179  for (size_t i=0;i<a.GetDimension();i++)
     180    a.Set(i,a.Get(i)+b.Get(i));
     181  return a;
     182};
     183
     184/** Subtracts GSLVector \a from this lhs component-wise.
     185 * \param a base GSLVector
     186 * \param b GSLVector components to add
     187 * \return lhs - a
     188 */
     189const GSLVector& operator-=(GSLVector& a, const GSLVector& b)
     190{
     191  assert(a.GetDimension() == b.GetDimension() && "Dimenions of GSLVectors to compare differ");
     192  for (size_t i=0;i<a.GetDimension();i++)
     193    a.Set(i,a.Get(i)-b.Get(i));
     194  return a;
     195};
     196
     197/** factor each component of \a a times a double \a m.
     198 * \param a base GSLVector
     199 * \param m factor
     200 * \return lhs.Get(i) * m
     201 */
     202const GSLVector& operator*=(GSLVector& a, const double m)
     203{
     204  for (size_t i=0;i<a.GetDimension();i++)
     205    a.Set(i,a.Get(i)*m);
     206  return a;
     207};
     208
     209/** Sums two GSLVectors \a  and \b component-wise.
     210 * \param a first GSLVector
     211 * \param b second GSLVector
     212 * \return a + b
     213 */
     214GSLVector const operator+(const GSLVector& a, const GSLVector& b)
     215{
     216  GSLVector x(a);
     217  for (size_t i=0;i<a.GetDimension();i++)
     218    x.Set(i,a.Get(i)+b.Get(i));
     219  return x;
     220};
     221
     222/** Subtracts GSLVector \a from \b component-wise.
     223 * \param a first GSLVector
     224 * \param b second GSLVector
     225 * \return a - b
     226 */
     227GSLVector const operator-(const GSLVector& a, const GSLVector& b)
     228{
     229  assert(a.GetDimension() == b.GetDimension() && "Dimenions of GSLVectors to compare differ");
     230  GSLVector x(a);
     231  for (size_t i=0;i<a.GetDimension();i++)
     232    x.Set(i,a.Get(i)-b.Get(i));
     233  return x;
     234};
     235
     236/** Factors given GSLVector \a a times \a m.
     237 * \param a GSLVector
     238 * \param m factor
     239 * \return m * a
     240 */
     241GSLVector const operator*(const GSLVector& a, const double m)
     242{
     243  GSLVector x(a);
     244  for (size_t i=0;i<a.GetDimension();i++)
     245    x.Set(i,a.Get(i)*m);
     246  return x;
     247};
     248
     249/** Factors given GSLVector \a a times \a m.
     250 * \param m factor
     251 * \param a GSLVector
     252 * \return m * a
     253 */
     254GSLVector const operator*(const double m, const GSLVector& a )
     255{
     256  GSLVector x(a);
     257  for (size_t i=0;i<a.GetDimension();i++)
     258    x.Set(i,a.Get(i)*m);
     259  return x;
     260};
     261
     262ostream& operator<<(ostream& ost, const GSLVector& m)
     263{
     264  ost << "(";
     265  for (size_t i=0;i<m.GetDimension();i++) {
     266    ost << m.Get(i);
     267    if (i != 2)
     268      ost << ",";
     269  }
     270  ost << ")";
     271  return ost;
     272};
     273
     274/* ====================== Checking State ============================ */
     275/** Checks whether vector has all components zero.
     276 * @return true - vector is zero, false - vector is not
     277 */
     278bool GSLVector::IsZero() const
     279{
     280  return (fabs(Get(0))+fabs(Get(1))+fabs(Get(2)) < MYEPSILON);
     281};
     282
     283/** Checks whether vector has length of 1.
     284 * @return true - vector is normalized, false - vector is not
     285 */
     286bool GSLVector::IsOne() const
     287{
     288  double NormValue = 0.;
     289  for (size_t i=dimension;--i;)
     290    NormValue += Get(i)*Get(i);
     291  return (fabs(NormValue - 1.) < MYEPSILON);
     292};
     293
  • src/gslvector.hpp

    r13d5a9 r5f612ee  
    1818#endif
    1919
     20#include <iostream>
    2021#include <gsl/gsl_vector.h>
    2122
     
    3233  GSLVector(size_t m);
    3334  GSLVector(const GSLVector * const src);
     35  GSLVector(const GSLVector & src);
    3436  ~GSLVector();
    3537
    3638  // Accessing
    3739  void SetFromDoubleArray(double *x);
    38   double Get(size_t m);
     40  double Get(size_t m) const;
    3941  void Set(size_t m, double x);
    40   double *Pointer(size_t m);
    41   const double *const_Pointer(size_t m);
     42  double *Pointer(size_t m) const;
     43  const double *const_Pointer(size_t m) const;
     44  size_t GetDimension() const;
    4245
    4346  // Initializing
     
    5053  int Reverse();
    5154
     55  // checking state
     56  bool IsZero() const;
     57  bool IsOne() const;
     58
    5259private:
    5360  gsl_vector *vector;
    5461
    55   size_t dimension;
     62  const size_t dimension;
    5663};
     64
     65ostream & operator << (ostream& ost, const GSLVector &m);
     66bool operator==(const GSLVector& a, const GSLVector& b);
     67const GSLVector& operator+=(GSLVector& a, const GSLVector& b);
     68const GSLVector& operator-=(GSLVector& a, const GSLVector& b);
     69const GSLVector& operator*=(GSLVector& a, const double m);
     70GSLVector const operator*(const GSLVector& a, const double m);
     71GSLVector const operator*(const double m, const GSLVector& a);
     72GSLVector const operator+(const GSLVector& a, const GSLVector& b);
     73GSLVector const operator-(const GSLVector& a, const GSLVector& b);
     74
    5775
    5876
  • src/helpers.cpp

    r13d5a9 r5f612ee  
    1919  double test = 0.1439851348959832147598734598273456723948652983045928346598365;
    2020  do {
    21     Log() << Verbose(0) << text;
     21    DoLog(0) && (Log() << Verbose(0) << text);
    2222    cin >> test;
    2323  } while (test == 0.1439851348959832147598734598273456723948652983045928346598365);
  • src/helpers.hpp

    r13d5a9 r5f612ee  
    114114
    115115  if (LookupTable != NULL) {
    116     Log() << Verbose(0) << "Pointer for Lookup table is not NULL! Aborting ..." <<endl;
     116    DoLog(0) && (Log() << Verbose(0) << "Pointer for Lookup table is not NULL! Aborting ..." <<endl);
    117117    return false;
    118118  }
     
    127127  }
    128128  if (count <= 0) {
    129     Log() << Verbose(0) << "Count of lookup list is 0 or less." << endl;
     129    DoLog(0) && (Log() << Verbose(0) << "Count of lookup list is 0 or less." << endl);
    130130    return false;
    131131  }
     
    134134  LookupTable = Calloc<T*>(count, "CreateFatherLookupTable - **LookupTable");
    135135  if (LookupTable == NULL) {
    136     eLog() << Verbose(0) << "LookupTable memory allocation failed!" << endl;
     136    DoeLog(0) && (eLog()<< Verbose(0) << "LookupTable memory allocation failed!" << endl);
    137137    performCriticalExit();
    138138    status = false;
     
    146146        LookupTable[AtomNo] = Walker;
    147147      } else {
    148         Log() << Verbose(0) << "Walker " << *Walker << " exceeded range of nuclear ids [0, " << count << ")." << endl;
     148        DoLog(0) && (Log() << Verbose(0) << "Walker " << *Walker << " exceeded range of nuclear ids [0, " << count << ")." << endl);
    149149        status = false;
    150150        break;
  • src/info.cpp

    r13d5a9 r5f612ee  
    2121  verbosity++;
    2222  FunctionName = msg;
    23   Log() << Verbose(0) << "Begin of " << FunctionName << endl;
     23  DoLog(0) && (Log() << Verbose(0) << "Begin of " << FunctionName << endl);
    2424};
    2525
     
    2828 */
    2929Info::~Info() {
    30   Log() << Verbose(0) << "End of " << FunctionName << endl;
     30  DoLog(0) && (Log() << Verbose(0) << "End of " << FunctionName << endl);
    3131  verbosity--;
    3232}
  • src/joiner.cpp

    r13d5a9 r5f612ee  
    4747  bool NoHessian = false;
    4848
    49   Log() << Verbose(0) << "Joiner" << endl;
    50   Log() << Verbose(0) << "======" << endl;
     49  DoLog(0) && (Log() << Verbose(0) << "Joiner" << endl);
     50  DoLog(0) && (Log() << Verbose(0) << "======" << endl);
    5151
    5252  // Get the command line options
    5353  if (argc < 3) {
    54     Log() << Verbose(0) << "Usage: " << argv[0] << " <inputdir> <prefix> [elementsdb]" << endl;
    55     Log() << Verbose(0) << "<inputdir>\ttherein the output of a molecuilder fragmentation is expected, each fragment with a subdir containing an energy.all and a forces.all file." << endl;
    56     Log() << Verbose(0) << "<prefix>\tprefix of energy and forces file." << endl;
    57     Log() << Verbose(0) << "[elementsdb]\tpath to elements database, needed for shieldings." << endl;
     54    DoLog(0) && (Log() << Verbose(0) << "Usage: " << argv[0] << " <inputdir> <prefix> [elementsdb]" << endl);
     55    DoLog(0) && (Log() << Verbose(0) << "<inputdir>\ttherein the output of a molecuilder fragmentation is expected, each fragment with a subdir containing an energy.all and a forces.all file." << endl);
     56    DoLog(0) && (Log() << Verbose(0) << "<prefix>\tprefix of energy and forces file." << endl);
     57    DoLog(0) && (Log() << Verbose(0) << "[elementsdb]\tpath to elements database, needed for shieldings." << endl);
    5858    return 1;
    5959  } else {
     
    7777  if (!Hcorrection.ParseFragmentMatrix(argv[1], "", HCORRECTIONSUFFIX, 0,0)) {
    7878    NoHCorrection = true;
    79     Log() << Verbose(0) << "No HCorrection matrices found, skipping these." << endl;
     79    DoLog(0) && (Log() << Verbose(0) << "No HCorrection matrices found, skipping these." << endl);
    8080  }
    8181  if (!Force.ParseFragmentMatrix(argv[1], dir, ForcesSuffix, 0,0)) return 1;
    8282  if (!Hessian.ParseFragmentMatrix(argv[1], dir, HessianSuffix, 0,0)) {
    8383    NoHessian = true;
    84     Log() << Verbose(0) << "No hessian matrices found, skipping these." << endl;
     84    DoLog(0) && (Log() << Verbose(0) << "No hessian matrices found, skipping these." << endl);
    8585  }
    8686  if (periode != NULL) { // also look for PAS values
     
    146146  for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
    147147    // --------- sum up energy --------------------
    148     Log() << Verbose(0) << "Summing energy of order " << BondOrder+1 << " ..." << endl;
     148    DoLog(0) && (Log() << Verbose(0) << "Summing energy of order " << BondOrder+1 << " ..." << endl);
    149149    if (!EnergyFragments.SumSubManyBodyTerms(Energy, KeySet, BondOrder)) return 1;
    150150    if (!NoHCorrection) {
     
    155155      if (!Energy.SumSubEnergy(EnergyFragments, NULL, KeySet, BondOrder, 1.)) return 1;
    156156    // --------- sum up Forces --------------------
    157     Log() << Verbose(0) << "Summing forces of order " << BondOrder+1 << " ..." << endl;
     157    DoLog(0) && (Log() << Verbose(0) << "Summing forces of order " << BondOrder+1 << " ..." << endl);
    158158    if (!ForceFragments.SumSubManyBodyTerms(Force, KeySet, BondOrder)) return 1;
    159159    if (!Force.SumSubForces(ForceFragments, KeySet, BondOrder, 1.)) return 1;
    160160    // --------- sum up Hessian --------------------
    161161    if (!NoHessian) {
    162       Log() << Verbose(0) << "Summing Hessian of order " << BondOrder+1 << " ..." << endl;
     162      DoLog(0) && (Log() << Verbose(0) << "Summing Hessian of order " << BondOrder+1 << " ..." << endl);
    163163      if (!HessianFragments.SumSubManyBodyTerms(Hessian, KeySet, BondOrder)) return 1;
    164164      if (!Hessian.SumSubHessians(HessianFragments, KeySet, BondOrder, 1.)) return 1;
    165165    }
    166166    if (periode != NULL) { // also look for PAS values
    167       Log() << Verbose(0) << "Summing shieldings and susceptibilities of order " << BondOrder+1 << " ..." << endl;
     167      DoLog(0) && (Log() << Verbose(0) << "Summing shieldings and susceptibilities of order " << BondOrder+1 << " ..." << endl);
    168168      if (!ShieldingFragments.SumSubManyBodyTerms(Shielding, KeySet, BondOrder)) return 1;
    169169      if (!Shielding.SumSubForces(ShieldingFragments, KeySet, BondOrder, 1.)) return 1;
     
    179179    prefix.str(" ");
    180180    prefix << dir << OrderSuffix << (BondOrder+1);
    181     Log() << Verbose(0) << "Writing files " << argv[1] << prefix.str() << ". ..." << endl;
     181    DoLog(0) && (Log() << Verbose(0) << "Writing files " << argv[1] << prefix.str() << ". ..." << endl);
    182182    // energy
    183183    if (!Energy.WriteLastMatrix(argv[1], (prefix.str()).c_str(), EnergySuffix)) return 1;
     
    244244  delete(periode);
    245245  Free(&dir);
    246   Log() << Verbose(0) << "done." << endl;
     246  DoLog(0) && (Log() << Verbose(0) << "done." << endl);
    247247  return 0;
    248248};
  • src/linkedcell.cpp

    r13d5a9 r5f612ee  
    4545  max.Zero();
    4646  min.Zero();
    47   Log() << Verbose(1) << "Begin of LinkedCell" << endl;
    48   if (set->IsEmpty()) {
    49     eLog() << Verbose(1) << "set contains no linked cell nodes!" << endl;
     47  DoLog(1) && (Log() << Verbose(1) << "Begin of LinkedCell" << endl);
     48  if ((set == NULL) || (set->IsEmpty())) {
     49    DoeLog(1) && (eLog()<< Verbose(1) << "set is NULL or contains no linked cell nodes!" << endl);
    5050    return;
    5151  }
     
    6868    set->GoToNext();
    6969  }
    70   Log() << Verbose(2) << "Bounding box is " << min << " and " << max << "." << endl;
     70  DoLog(2) && (Log() << Verbose(2) << "Bounding box is " << min << " and " << max << "." << endl);
    7171
    7272  // 2. find then number of cells per axis
     
    7474    N[i] = (int)floor((max.x[i] - min.x[i])/RADIUS)+1;
    7575  }
    76   Log() << Verbose(2) << "Number of cells per axis are " << N[0] << ", " << N[1] << " and " << N[2] << "." << endl;
     76  DoLog(2) && (Log() << Verbose(2) << "Number of cells per axis are " << N[0] << ", " << N[1] << " and " << N[2] << "." << endl);
    7777
    7878  // 3. allocate the lists
    79   Log() << Verbose(2) << "Allocating cells ... ";
     79  DoLog(2) && (Log() << Verbose(2) << "Allocating cells ... ");
    8080  if (LC != NULL) {
    81     eLog() << Verbose(1) << "Linked Cell list is already allocated, I do nothing." << endl;
     81    DoeLog(1) && (eLog()<< Verbose(1) << "Linked Cell list is already allocated, I do nothing." << endl);
    8282    return;
    8383  }
     
    8686    LC [index].clear();
    8787  }
    88   Log() << Verbose(0) << "done."  << endl;
     88  DoLog(0) && (Log() << Verbose(0) << "done."  << endl);
    8989
    9090  // 4. put each atom into its respective cell
    91   Log() << Verbose(2) << "Filling cells ... ";
     91  DoLog(2) && (Log() << Verbose(2) << "Filling cells ... ");
    9292  set->GoToFirst();
    9393  while (!set->IsEnd()) {
     
    101101    set->GoToNext();
    102102  }
    103   Log() << Verbose(0) << "done."  << endl;
    104   Log() << Verbose(1) << "End of LinkedCell" << endl;
     103  DoLog(0) && (Log() << Verbose(0) << "done."  << endl);
     104  DoLog(1) && (Log() << Verbose(1) << "End of LinkedCell" << endl);
    105105};
    106106
     
    120120  max.Zero();
    121121  min.Zero();
    122   Log() << Verbose(1) << "Begin of LinkedCell" << endl;
     122  DoLog(1) && (Log() << Verbose(1) << "Begin of LinkedCell" << endl);
    123123  if (set->empty()) {
    124     eLog() << Verbose(1) << "set contains no linked cell nodes!" << endl;
     124    DoeLog(1) && (eLog()<< Verbose(1) << "set contains no linked cell nodes!" << endl);
    125125    return;
    126126  }
     
    140140    }
    141141  }
    142   Log() << Verbose(2) << "Bounding box is " << min << " and " << max << "." << endl;
     142  DoLog(2) && (Log() << Verbose(2) << "Bounding box is " << min << " and " << max << "." << endl);
    143143
    144144  // 2. find then number of cells per axis
     
    146146    N[i] = (int)floor((max.x[i] - min.x[i])/RADIUS)+1;
    147147  }
    148   Log() << Verbose(2) << "Number of cells per axis are " << N[0] << ", " << N[1] << " and " << N[2] << "." << endl;
     148  DoLog(2) && (Log() << Verbose(2) << "Number of cells per axis are " << N[0] << ", " << N[1] << " and " << N[2] << "." << endl);
    149149
    150150  // 3. allocate the lists
    151   Log() << Verbose(2) << "Allocating cells ... ";
     151  DoLog(2) && (Log() << Verbose(2) << "Allocating cells ... ");
    152152  if (LC != NULL) {
    153     eLog() << Verbose(1) << "Linked Cell list is already allocated, I do nothing." << endl;
     153    DoeLog(1) && (eLog()<< Verbose(1) << "Linked Cell list is already allocated, I do nothing." << endl);
    154154    return;
    155155  }
     
    158158    LC [index].clear();
    159159  }
    160   Log() << Verbose(0) << "done."  << endl;
     160  DoLog(0) && (Log() << Verbose(0) << "done."  << endl);
    161161
    162162  // 4. put each atom into its respective cell
    163   Log() << Verbose(2) << "Filling cells ... ";
     163  DoLog(2) && (Log() << Verbose(2) << "Filling cells ... ");
    164164  for (LinkedNodes::iterator Runner = set->begin(); Runner != set->end(); Runner++) {
    165165    Walker = *Runner;
     
    171171    //Log() << Verbose(2) << *Walker << " goes into cell " << n[0] << ", " << n[1] << ", " << n[2] << " with No. " << index << "." << endl;
    172172  }
    173   Log() << Verbose(0) << "done."  << endl;
    174   Log() << Verbose(1) << "End of LinkedCell" << endl;
     173  DoLog(0) && (Log() << Verbose(0) << "done."  << endl);
     174  DoLog(1) && (Log() << Verbose(1) << "End of LinkedCell" << endl);
    175175};
    176176
     
    199199    status = status && ((n[i] >=0) && (n[i] < N[i]));
    200200  if (!status)
    201   eLog() << Verbose(1) << "indices are out of bounds!" << endl;
     201  DoeLog(1) && (eLog()<< Verbose(1) << "indices are out of bounds!" << endl);
    202202  return status;
    203203};
     
    220220 * \return LinkedAtoms pointer to current cell, NULL if LinkedCell::n[] are out of bounds.
    221221 */
    222 const LinkedNodes* LinkedCell::GetCurrentCell() const
     222const LinkedCell::LinkedNodes* LinkedCell::GetCurrentCell() const
    223223{
    224224  if (CheckBounds()) {
     
    234234 * \return LinkedAtoms pointer to current cell, NULL if LinkedCell::n[]+relative[] are out of bounds.
    235235 */
    236 const LinkedNodes* LinkedCell::GetRelativeToCurrentCell(const int relative[NDIM]) const
     236const LinkedCell::LinkedNodes* LinkedCell::GetRelativeToCurrentCell(const int relative[NDIM]) const
    237237{
    238238  if (CheckBounds(relative)) {
     
    242242    return NULL;
    243243  }
     244};
     245
     246/** Set the index to the cell containing a given Vector *x.
     247 * \param *x Vector with coordinates
     248 * \return Vector is inside bounding box - true, else - false
     249 */
     250bool LinkedCell::SetIndexToVector(const Vector * const x) const
     251{
     252  for (int i=0;i<NDIM;i++)
     253    n[i] = (int)floor((x->x[i] - min.x[i])/RADIUS);
     254
     255  return CheckBounds();
    244256};
    245257
     
    260272    return status;
    261273  } else {
    262     eLog() << Verbose(1) << "Node at " << *Walker << " is out of bounds." << endl;
     274    DoeLog(1) && (eLog()<< Verbose(1) << "Node at " << *Walker << " is out of bounds." << endl);
    263275    return false;
    264276  }
     
    268280 * \param *lower lower bounds
    269281 * \param *upper upper bounds
    270  */
    271 void LinkedCell::GetNeighbourBounds(int lower[NDIM], int upper[NDIM]) const
    272 {
    273   for (int i=0;i<NDIM;i++) {
    274     lower[i] = ((n[i]-1) >= 0) ? n[i]-1 : 0;
    275     upper[i] = ((n[i]+1) < N[i]) ? n[i]+1 : N[i]-1;
    276     //Log() << Verbose(0) << " [" << Nlower[i] << "," << Nupper[i] << "] ";
    277     // check for this axis whether the point is outside of our grid
     282 * \param step how deep to check the neighbouring cells (i.e. number of layers to check)
     283 */
     284void LinkedCell::GetNeighbourBounds(int lower[NDIM], int upper[NDIM], int step) const
     285{
     286  for (int i=0;i<NDIM;i++) {
     287    lower[i] = n[i];
     288    for (int s=step; s>0;--s)
     289      if ((n[i]-s) >= 0) {
     290        lower[i] = n[i]-s;
     291        break;
     292      }
     293    upper[i] = n[i];
     294    for (int s=step; s>0;--s)
     295      if ((n[i]+s) < N[i]) {
     296        upper[i] = n[i]+s;
     297        break;
     298      }
     299    //Log() << Verbose(0) << "axis " << i << " has bounds [" << lower[i] << "," << upper[i] << "]" << endl;
     300  }
     301};
     302
     303/** Returns a list with all neighbours from the current LinkedCell::index.
     304 * \param distance (if no distance, then adjacent cells are taken)
     305 * \return list of tesselpoints
     306 */
     307LinkedCell::LinkedNodes* LinkedCell::GetallNeighbours(const double distance) const
     308{
     309  int Nlower[NDIM], Nupper[NDIM];
     310  TesselPoint *Walker = NULL;
     311  LinkedNodes *TesselList = new LinkedNodes;
     312
     313  // then go through the current and all neighbouring cells and check the contained points for possible candidates
     314  const int step = (distance == 0) ? 1 : (int)floor(distance/RADIUS + 1.);
     315  GetNeighbourBounds(Nlower, Nupper, step);
     316
     317  //Log() << Verbose(0) << endl;
     318  for (n[0] = Nlower[0]; n[0] <= Nupper[0]; n[0]++)
     319    for (n[1] = Nlower[1]; n[1] <= Nupper[1]; n[1]++)
     320      for (n[2] = Nlower[2]; n[2] <= Nupper[2]; n[2]++) {
     321        const LinkedNodes *List = GetCurrentCell();
     322        //Log() << Verbose(1) << "Current cell is " << n[0] << ", " << n[1] << ", " << n[2] << " with No. " << index << "." << endl;
     323        if (List != NULL) {
     324          for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
     325            Walker = *Runner;
     326            TesselList->push_back(Walker);
     327          }
     328        }
     329      }
     330  return TesselList;
     331};
     332
     333/** Set the index to the cell containing a given Vector *x, which is not inside the LinkedCell's domain
     334 * Note that as we have to check distance from every corner of the closest cell, this function is faw more
     335 * expensive and if Vector is known to be inside LinkedCell's domain, then SetIndexToVector() should be used.
     336 * \param *x Vector with coordinates
     337 * \return minimum squared distance of cell to given vector (if inside of domain, distance is 0)
     338 */
     339double LinkedCell::SetClosestIndexToOutsideVector(const Vector * const x) const
     340{
     341  for (int i=0;i<NDIM;i++) {
     342    n[i] = (int)floor((x->x[i] - min.x[i])/RADIUS);
    278343    if (n[i] < 0)
    279       upper[i] = lower[i];
    280     if (n[i] > N[i])
    281       lower[i] = upper[i];
    282 
    283     //Log() << Verbose(0) << "axis " << i << " has bounds [" << lower[i] << "," << upper[i] << "]" << endl;
    284   }
    285 };
    286 
    287 /** Calculates the index for a given Vector *x.
    288  * \param *x Vector with coordinates
    289  * \return Vector is inside bounding box - true, else - false
    290  */
    291 bool LinkedCell::SetIndexToVector(const Vector * const x) const
    292 {
    293   bool status = true;
    294   for (int i=0;i<NDIM;i++) {
    295     n[i] = (int)floor((x->x[i] - min.x[i])/RADIUS);
    296     if (max.x[i] < x->x[i])
    297       status = false;
    298     if (min.x[i] > x->x[i])
    299       status = false;
    300   }
    301   return status;
    302 };
    303 
     344      n[i] = 0;
     345    if (n[i] >= N[i])
     346      n[i] = N[i]-1;
     347  }
     348
     349  // calculate distance of cell to vector
     350  double distanceSquared = 0.;
     351  bool outside = true;  // flag whether x is found in- or outside of LinkedCell's domain/closest cell
     352  Vector corner; // current corner of closest cell
     353  Vector tester; // Vector pointing from corner to center of closest cell
     354  Vector Distance;  // Vector from corner of closest cell to x
     355
     356  Vector center;  // center of the closest cell
     357  for (int i=0;i<NDIM;i++)
     358    center.x[i] = min.x[i]+((double)n[i]+.5)*RADIUS;
     359
     360  int c[NDIM];
     361  for (c[0]=0;c[0]<=1;c[0]++)
     362    for (c[1]=0; c[1]<=1;c[1]++)
     363      for (c[2]=0; c[2]<=1;c[2]++) {
     364        // set up corner
     365        for (int i=0;i<NDIM;i++)
     366          corner.x[i] = min.x[i]+RADIUS*((double)n[i]+c[i]);
     367        // set up distance vector
     368        Distance.CopyVector(x);
     369        Distance.SubtractVector(&corner);
     370        const double dist = Distance.NormSquared();
     371        // check whether distance is smaller
     372        if (dist< distanceSquared)
     373          distanceSquared = dist;
     374        // check whether distance vector goes inside or outside
     375        tester.CopyVector(&center);
     376        tester.SubtractVector(&corner);
     377        if (tester.ScalarProduct(&Distance) < 0)
     378          outside = false;
     379      }
     380  return (outside ? distanceSquared : 0.);
     381};
     382
     383/** Returns a list of all TesselPoint with distance less than \a radius to \a *Center.
     384 * \param radius radius of sphere
     385 * \param *center center of sphere
     386 * \return list of all points inside sphere
     387 */
     388LinkedCell::LinkedNodes* LinkedCell::GetPointsInsideSphere(const double radius, const Vector * const center) const
     389{
     390  const double radiusSquared = radius*radius;
     391  TesselPoint *Walker = NULL;
     392  LinkedNodes *TesselList = new LinkedNodes;
     393  LinkedNodes *NeighbourList = NULL;
     394
     395  // set index of LC to center of sphere
     396  const double dist = SetClosestIndexToOutsideVector(center);
     397  if (dist > 2.*radius) {
     398    DoeLog(1) && (eLog()<< Verbose(1) << "Vector " << *center << " is too far away from any atom in LinkedCell's bounding box." << endl);
     399    return TesselList;
     400  } else
     401    DoLog(1) && (Log() << Verbose(1) << "Distance of closest cell to center of sphere with radius " << radius << " is " << dist << "." << endl);
     402
     403  // gather all neighbours first, then look who fulfills distance criteria
     404  NeighbourList = GetallNeighbours(2.*radius-dist);
     405  //Log() << Verbose(1) << "I found " << NeighbourList->size() << " neighbours to check." << endl;
     406  if (NeighbourList != NULL) {
     407    for (LinkedNodes::const_iterator Runner = NeighbourList->begin(); Runner != NeighbourList->end(); Runner++) {
     408      Walker = *Runner;
     409      //Log() << Verbose(1) << "Current neighbour is at " << *Walker->node << "." << endl;
     410      if ((center->DistanceSquared(Walker->node) - radiusSquared) < MYEPSILON) {
     411        TesselList->push_back(Walker);
     412      }
     413    }
     414    delete(NeighbourList);
     415  } else
     416    DoeLog(2) && (eLog()<< Verbose(2) << "Around vector " << *center << " there are no atoms." << endl);
     417  return TesselList;
     418};
  • src/linkedcell.hpp

    r13d5a9 r5f612ee  
    3333/********************************************** definitions *********************************/
    3434
    35 #define LinkedNodes list<TesselPoint *>
    3635
    3736/********************************************** declarations *******************************/
     
    4039 */
    4140class LinkedCell {
    42   public:
     41private:
     42
     43public:
     44  typedef list<TesselPoint *> LinkedNodes;
     45
     46
    4347    Vector max;       // upper boundary
    4448    Vector min;       // lower boundary
     
    5357    LinkedCell(LinkedNodes *set, const double radius);
    5458    ~LinkedCell();
    55     const LinkedNodes* GetCurrentCell()const ;
    56     const LinkedNodes* GetRelativeToCurrentCell(const int relative[NDIM])const ;
     59    const LinkedCell::LinkedNodes* GetCurrentCell()const ;
     60    const LinkedCell::LinkedNodes* GetRelativeToCurrentCell(const int relative[NDIM])const ;
    5761    bool SetIndexToNode(const TesselPoint * const Walker)const ;
    5862    bool SetIndexToVector(const Vector * const x)const ;
     63    double SetClosestIndexToOutsideVector(const Vector * const x) const;
    5964    bool CheckBounds()const ;
    6065    bool CheckBounds(const int relative[NDIM])const ;
    61     void GetNeighbourBounds(int lower[NDIM], int upper[NDIM])const ;
     66    void GetNeighbourBounds(int lower[NDIM], int upper[NDIM], int step = 1)const ;
    6267
     68    LinkedCell::LinkedNodes* GetallNeighbours(const double distance = 0) const;
     69    LinkedCell::LinkedNodes* GetPointsInsideSphere(const double radius, const Vector * const center) const;
    6370    // not implemented yet
    6471    bool AddNode(Vector *Walker);
  • src/log.cpp

    r13d5a9 r5f612ee  
    1616void setVerbosity(int verbosityLevel) {
    1717  logger::getInstance().setVerbosity(verbosityLevel);
    18   errorLogger::getInstance().setVerbosity(verbosityLevel);
    1918}
    2019
     
    2827}
    2928
     29/** Checks verbosity for logger.
     30 * Is supposed to be used in construct as this:
     31 * DoLog(2) && (Log() << Verbose(2) << "message." << endl);
     32 * If DoLog does not return true, the right-hand side is not evaluated and we save some time.
     33 * \param verbose verbosity level of this message
     34 * \return true - print, false - don't
     35 */
     36bool DoLog(int verbose) {
     37  return (verbose <= logger::getInstance().verbosity);
     38}
     39
     40/** Checks verbosity for errorlogger.
     41 * Is supposed to be used in construct as this:
     42 * DoLog(2) && (Log() << Verbose(2) << "message." << endl);
     43 * If DoLog does not return true, the right-hand side is not evaluated and we save some time.
     44 * \param verbose verbosity level of this message
     45 * \return true - print, false - don't
     46 */
     47bool DoeLog(int verbose) {
     48  return (verbose <= errorLogger::getInstance().verbosity);
     49}
     50
    3051/**
    3152 * Prints an error log entry.
  • src/log.hpp

    r13d5a9 r5f612ee  
    1515class errorLogger * eLog();
    1616void setVerbosity(int verbosityLevel);
     17bool DoLog(int verbose);
     18bool DoeLog(int verbose);
    1719
    1820#endif /* LOG_HPP_ */
  • src/memoryusageobserver.cpp

    r13d5a9 r5f612ee  
    9393      << pointer << " is not registered by MemoryUsageObserver: ";
    9494    if (msg != NULL)
    95       Log() << Verbose(0) << *msg;
    96     Log() << Verbose(0) << endl;
     95      DoLog(0) && (Log() << Verbose(0) << *msg);
     96    DoLog(0) && (Log() << Verbose(0) << endl);
    9797    return;
    9898  }
  • src/molecule.cpp

    r13d5a9 r5f612ee  
    2525#include "tesselation.hpp"
    2626#include "vector.hpp"
     27#include "World.hpp"
    2728
    2829/************************************* Functions for class molecule *********************************/
     
    5051  for(int i=MAX_ELEMENTS;i--;)
    5152    ElementsInMolecule[i] = 0;
    52   cell_size[0] = cell_size[2] = cell_size[5]= 20.;
    53   cell_size[1] = cell_size[3] = cell_size[4]= 0.;
    54   strcpy(name,"none");
     53  strcpy(name,World::getInstance().getDefaultName());
    5554};
    5655
     
    215214  double *matrix = NULL;
    216215  bond *Binder = NULL;
     216  double * const cell_size = World::getInstance().getDomain();
    217217
    218218//  Log() << Verbose(3) << "Begin of AddHydrogenReplacementAtom." << endl;
     
    250250  BondRescale = TopOrigin->type->HBondDistance[TopBond->BondDegree-1];
    251251  if (BondRescale == -1) {
    252     eLog() << Verbose(1) << "There is no typical hydrogen bond distance in replacing bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") of degree " << TopBond->BondDegree << "!" << endl;
     252    DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond distance in replacing bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") of degree " << TopBond->BondDegree << "!" << endl);
    253253    return false;
    254254    BondRescale = bondlength;
     
    293293            SecondOtherAtom = (*Runner)->GetOtherAtom(TopOrigin);
    294294          } else {
    295             eLog() << Verbose(2) << "Detected more than four bonds for atom " << TopOrigin->Name;
     295            DoeLog(2) && (eLog()<< Verbose(2) << "Detected more than four bonds for atom " << TopOrigin->Name);
    296296          }
    297297        }
     
    330330      bondangle = TopOrigin->type->HBondAngle[1];
    331331      if (bondangle == -1) {
    332         eLog() << Verbose(1) << "There is no typical hydrogen bond angle in replacing bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") of degree " << TopBond->BondDegree << "!" << endl;
     332        DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond angle in replacing bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") of degree " << TopBond->BondDegree << "!" << endl);
    333333        return false;
    334334        bondangle = 0;
     
    452452      break;
    453453    default:
    454       eLog() << Verbose(1) << "BondDegree does not state single, double or triple bond!" << endl;
     454      DoeLog(1) && (eLog()<< Verbose(1) << "BondDegree does not state single, double or triple bond!" << endl);
    455455      AllWentWell = false;
    456456      break;
     
    487487  input = new istringstream(line);
    488488  *input >> NumberOfAtoms;
    489   Log() << Verbose(0) << "Parsing " << NumberOfAtoms << " atoms in file." << endl;
     489  DoLog(0) && (Log() << Verbose(0) << "Parsing " << NumberOfAtoms << " atoms in file." << endl);
    490490  getline(xyzfile,line,'\n'); // Read comment
    491   Log() << Verbose(1) << "Comment: " << line << endl;
     491  DoLog(1) && (Log() << Verbose(1) << "Comment: " << line << endl);
    492492
    493493  if (MDSteps == 0) // no atoms yet present
     
    505505    Walker->type = elemente->FindElement(shorthand);
    506506    if (Walker->type == NULL) {
    507       eLog() << Verbose(1) << "Could not parse the element at line: '" << line << "', setting to H.";
     507      DoeLog(1) && (eLog()<< Verbose(1) << "Could not parse the element at line: '" << line << "', setting to H.");
    508508      Walker->type = elemente->FindElement(1);
    509509    }
     
    532532molecule *molecule::CopyMolecule()
    533533{
    534   molecule *copy = new molecule(elemente);
     534  molecule *copy = World::getInstance().createMolecule();
    535535  atom *LeftAtom = NULL, *RightAtom = NULL;
    536536
     
    575575 */
    576576molecule* molecule::CopyMoleculeFromSubRegion(const Vector offset, const double *parallelepiped) const {
    577   molecule *copy = new molecule(elemente);
     577  molecule *copy = World::getInstance().createMolecule();
    578578
    579579  ActOnCopyWithEachAtomIfTrue ( &molecule::AddCopyAtom, copy, &atom::IsInParallelepiped, offset, parallelepiped );
     
    601601    add(Binder, last);
    602602  } else {
    603     eLog() << Verbose(1) << "Could not add bond between " << atom1->Name << " and " << atom2->Name << " as one or both are not present in the molecule." << endl;
     603    DoeLog(1) && (eLog()<< Verbose(1) << "Could not add bond between " << atom1->Name << " and " << atom2->Name << " as one or both are not present in the molecule." << endl);
    604604  }
    605605  return Binder;
     
    613613bool molecule::RemoveBond(bond *pointer)
    614614{
    615   //eLog() << Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl;
     615  //DoeLog(1) && (eLog()<< Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl);
    616616  pointer->leftatom->RegisterBond(pointer);
    617617  pointer->rightatom->RegisterBond(pointer);
     
    627627bool molecule::RemoveBonds(atom *BondPartner)
    628628{
    629   //eLog() << Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl;
     629  //DoeLog(1) && (eLog()<< Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl);
    630630  BondList::const_iterator ForeRunner;
    631631  while (!BondPartner->ListOfBonds.empty()) {
     
    661661void molecule::SetBoxDimension(Vector *dim)
    662662{
     663  double * const cell_size = World::getInstance().getDomain();
    663664  cell_size[0] = dim->x[0];
    664665  cell_size[1] = 0.;
     
    679680    AtomCount--;
    680681  } else
    681     eLog() << Verbose(1) << "Atom " << pointer->Name << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl;
     682    DoeLog(1) && (eLog()<< Verbose(1) << "Atom " << pointer->Name << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl);
    682683  if (ElementsInMolecule[pointer->type->Z] == 0)  // was last atom of this element?
    683684    ElementCount--;
     
    697698    ElementsInMolecule[pointer->type->Z]--; // decrease number of atom of this element
    698699  else
    699     eLog() << Verbose(1) << "Atom " << pointer->Name << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl;
     700    DoeLog(1) && (eLog()<< Verbose(1) << "Atom " << pointer->Name << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl);
    700701  if (ElementsInMolecule[pointer->type->Z] == 0)  // was last atom of this element?
    701702    ElementCount--;
     
    722723    return walker;
    723724  } else {
    724     Log() << Verbose(0) << "Atom not found in list." << endl;
     725    DoLog(0) && (Log() << Verbose(0) << "Atom not found in list." << endl);
    725726    return NULL;
    726727  }
     
    738739    //mol->Output((ofstream *)&cout);
    739740    //Log() << Verbose(0) << "===============================================" << endl;
    740     Log() << Verbose(0) << text;
     741    DoLog(0) && (Log() << Verbose(0) << text);
    741742    cin >> No;
    742743    ion = this->FindAtom(No);
     
    751752bool molecule::CheckBounds(const Vector *x) const
    752753{
     754  double * const cell_size = World::getInstance().getDomain();
    753755  bool result = true;
    754756  int j =-1;
     
    826828void molecule::OutputListOfBonds() const
    827829{
    828   Log() << Verbose(2) << endl << "From Contents of ListOfBonds, all non-hydrogen atoms:" << endl;
     830  DoLog(2) && (Log() << Verbose(2) << endl << "From Contents of ListOfBonds, all non-hydrogen atoms:" << endl);
    829831  ActOnAllAtoms (&atom::OutputBondOfAtom );
    830   Log() << Verbose(0) << endl;
     832  DoLog(0) && (Log() << Verbose(0) << endl);
    831833};
    832834
     
    885887  }
    886888  if ((AtomCount == 0) || (i != AtomCount)) {
    887     Log() << Verbose(3) << "Mismatch in AtomCount " << AtomCount << " and recounted number " << i << ", renaming all." << endl;
     889    DoLog(3) && (Log() << Verbose(3) << "Mismatch in AtomCount " << AtomCount << " and recounted number " << i << ", renaming all." << endl);
    888890    AtomCount = i;
    889891
     
    901903        Walker->Name = Malloc<char>(6, "molecule::CountAtoms: *walker->Name");
    902904        sprintf(Walker->Name, "%2s%02d", Walker->type->symbol, Walker->nr+1);
    903         Log() << Verbose(3) << "Naming atom nr. " << Walker->nr << " " << Walker->Name << "." << endl;
     905        DoLog(3) && (Log() << Verbose(3) << "Naming atom nr. " << Walker->nr << " " << Walker->Name << "." << endl);
    904906        i++;
    905907      }
    906908    } else
    907       Log() << Verbose(3) << "AtomCount is still " << AtomCount << ", thus counting nothing." << endl;
     909      DoLog(3) && (Log() << Verbose(3) << "AtomCount is still " << AtomCount << ", thus counting nothing." << endl);
    908910  }
    909911};
     
    965967  bool result = true; // status of comparison
    966968
    967   Log() << Verbose(3) << "Begin of IsEqualToWithinThreshold." << endl;
     969  DoLog(3) && (Log() << Verbose(3) << "Begin of IsEqualToWithinThreshold." << endl);
    968970  /// first count both their atoms and elements and update lists thereby ...
    969971  //Log() << Verbose(0) << "Counting atoms, updating list" << endl;
     
    977979  if (result) {
    978980    if (AtomCount != OtherMolecule->AtomCount) {
    979       Log() << Verbose(4) << "AtomCounts don't match: " << AtomCount << " == " << OtherMolecule->AtomCount << endl;
     981      DoLog(4) && (Log() << Verbose(4) << "AtomCounts don't match: " << AtomCount << " == " << OtherMolecule->AtomCount << endl);
    980982      result = false;
    981983    } else Log() << Verbose(4) << "AtomCounts match: " << AtomCount << " == " << OtherMolecule->AtomCount << endl;
     
    984986  if (result) {
    985987    if (ElementCount != OtherMolecule->ElementCount) {
    986       Log() << Verbose(4) << "ElementCount don't match: " << ElementCount << " == " << OtherMolecule->ElementCount << endl;
     988      DoLog(4) && (Log() << Verbose(4) << "ElementCount don't match: " << ElementCount << " == " << OtherMolecule->ElementCount << endl);
    987989      result = false;
    988990    } else Log() << Verbose(4) << "ElementCount match: " << ElementCount << " == " << OtherMolecule->ElementCount << endl;
     
    996998    }
    997999    if (flag < MAX_ELEMENTS) {
    998       Log() << Verbose(4) << "ElementsInMolecule don't match." << endl;
     1000      DoLog(4) && (Log() << Verbose(4) << "ElementsInMolecule don't match." << endl);
    9991001      result = false;
    10001002    } else Log() << Verbose(4) << "ElementsInMolecule match." << endl;
     
    10021004  /// then determine and compare center of gravity for each molecule ...
    10031005  if (result) {
    1004     Log() << Verbose(5) << "Calculating Centers of Gravity" << endl;
     1006    DoLog(5) && (Log() << Verbose(5) << "Calculating Centers of Gravity" << endl);
    10051007    DeterminePeriodicCenter(CenterOfGravity);
    10061008    OtherMolecule->DeterminePeriodicCenter(OtherCenterOfGravity);
    1007     Log() << Verbose(5) << "Center of Gravity: ";
     1009    DoLog(5) && (Log() << Verbose(5) << "Center of Gravity: ");
    10081010    CenterOfGravity.Output();
    1009     Log() << Verbose(0) << endl << Verbose(5) << "Other Center of Gravity: ";
     1011    DoLog(0) && (Log() << Verbose(0) << endl << Verbose(5) << "Other Center of Gravity: ");
    10101012    OtherCenterOfGravity.Output();
    1011     Log() << Verbose(0) << endl;
     1013    DoLog(0) && (Log() << Verbose(0) << endl);
    10121014    if (CenterOfGravity.DistanceSquared(&OtherCenterOfGravity) > threshold*threshold) {
    1013       Log() << Verbose(4) << "Centers of gravity don't match." << endl;
     1015      DoLog(4) && (Log() << Verbose(4) << "Centers of gravity don't match." << endl);
    10141016      result = false;
    10151017    }
     
    10181020  /// ... then make a list with the euclidian distance to this center for each atom of both molecules
    10191021  if (result) {
    1020     Log() << Verbose(5) << "Calculating distances" << endl;
     1022    DoLog(5) && (Log() << Verbose(5) << "Calculating distances" << endl);
    10211023    Distances = Calloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: Distances");
    10221024    OtherDistances = Calloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: OtherDistances");
     
    10251027
    10261028    /// ... sort each list (using heapsort (o(N log N)) from GSL)
    1027     Log() << Verbose(5) << "Sorting distances" << endl;
     1029    DoLog(5) && (Log() << Verbose(5) << "Sorting distances" << endl);
    10281030    PermMap = Calloc<size_t>(AtomCount, "molecule::IsEqualToWithinThreshold: *PermMap");
    10291031    OtherPermMap = Calloc<size_t>(AtomCount, "molecule::IsEqualToWithinThreshold: *OtherPermMap");
     
    10311033    gsl_heapsort_index (OtherPermMap, OtherDistances, AtomCount, sizeof(double), CompareDoubles);
    10321034    PermutationMap = Calloc<int>(AtomCount, "molecule::IsEqualToWithinThreshold: *PermutationMap");
    1033     Log() << Verbose(5) << "Combining Permutation Maps" << endl;
     1035    DoLog(5) && (Log() << Verbose(5) << "Combining Permutation Maps" << endl);
    10341036    for(int i=AtomCount;i--;)
    10351037      PermutationMap[PermMap[i]] = (int) OtherPermMap[i];
    10361038
    10371039    /// ... and compare them step by step, whether the difference is individually(!) below \a threshold for all
    1038     Log() << Verbose(4) << "Comparing distances" << endl;
     1040    DoLog(4) && (Log() << Verbose(4) << "Comparing distances" << endl);
    10391041    flag = 0;
    10401042    for (int i=0;i<AtomCount;i++) {
    1041       Log() << Verbose(5) << "Distances squared: |" << Distances[PermMap[i]] << " - " << OtherDistances[OtherPermMap[i]] << "| = " << fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) << " ?<? " <<  threshold << endl;
     1043      DoLog(5) && (Log() << Verbose(5) << "Distances squared: |" << Distances[PermMap[i]] << " - " << OtherDistances[OtherPermMap[i]] << "| = " << fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) << " ?<? " <<  threshold << endl);
    10421044      if (fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) > threshold*threshold)
    10431045        flag = 1;
     
    10551057  }
    10561058  /// return pointer to map if all distances were below \a threshold
    1057   Log() << Verbose(3) << "End of IsEqualToWithinThreshold." << endl;
     1059  DoLog(3) && (Log() << Verbose(3) << "End of IsEqualToWithinThreshold." << endl);
    10581060  if (result) {
    1059     Log() << Verbose(3) << "Result: Equal." << endl;
     1061    DoLog(3) && (Log() << Verbose(3) << "Result: Equal." << endl);
    10601062    return PermutationMap;
    10611063  } else {
    1062     Log() << Verbose(3) << "Result: Not equal." << endl;
     1064    DoLog(3) && (Log() << Verbose(3) << "Result: Not equal." << endl);
    10631065    return NULL;
    10641066  }
     
    10751077{
    10761078  atom *Walker = NULL, *OtherWalker = NULL;
    1077   Log() << Verbose(3) << "Begin of GetFatherAtomicMap." << endl;
     1079  DoLog(3) && (Log() << Verbose(3) << "Begin of GetFatherAtomicMap." << endl);
    10781080  int *AtomicMap = Malloc<int>(AtomCount, "molecule::GetAtomicMap: *AtomicMap");
    10791081  for (int i=AtomCount;i--;)
     
    10821084    for (int i=AtomCount;i--;) // no need as -1 means already that there is trivial correspondence
    10831085      AtomicMap[i] = i;
    1084     Log() << Verbose(4) << "Map is trivial." << endl;
     1086    DoLog(4) && (Log() << Verbose(4) << "Map is trivial." << endl);
    10851087  } else {
    1086     Log() << Verbose(4) << "Map is ";
     1088    DoLog(4) && (Log() << Verbose(4) << "Map is ");
    10871089    Walker = start;
    10881090    while (Walker->next != end) {
     
    11011103        }
    11021104      }
    1103       Log() << Verbose(0) << AtomicMap[Walker->nr] << "\t";
    1104     }
    1105     Log() << Verbose(0) << endl;
    1106   }
    1107   Log() << Verbose(3) << "End of GetFatherAtomicMap." << endl;
     1105      DoLog(0) && (Log() << Verbose(0) << AtomicMap[Walker->nr] << "\t");
     1106    }
     1107    DoLog(0) && (Log() << Verbose(0) << endl);
     1108  }
     1109  DoLog(3) && (Log() << Verbose(3) << "End of GetFatherAtomicMap." << endl);
    11081110  return AtomicMap;
    11091111};
  • src/molecule.hpp

    r13d5a9 r5f612ee  
    8989  friend void DeleteMolecule(molecule *);
    9090  public:
    91     double cell_size[6];//!< cell size
    9291    const periodentafel * const elemente; //!< periodic table with each element
    9392    atom *start;        //!< start of atom list
     
    291290  int FragmentMolecule(int Order, config *configuration);
    292291  bool CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, char *path = NULL);
    293   bool StoreBondsToFile(char *path);
    294   bool StoreAdjacencyToFile(char *path);
     292  bool StoreBondsToFile(char *path, char *filename);
     293  bool StoreAdjacencyToFile(char *path, char *filename);
    295294  bool CheckAdjacencyFileAgainstMolecule(char *path, atom **ListOfAtoms);
    296295  bool ParseOrderAtSiteFromFile(char *path);
  • src/molecule_dynamics.cpp

    r13d5a9 r5f612ee  
    208208    doubles++;
    209209  if (doubles >0)
    210     Log() << Verbose(2) << "Found " << doubles << " Doubles." << endl;
     210    DoLog(2) && (Log() << Verbose(2) << "Found " << doubles << " Doubles." << endl);
    211211  Free(&DoubleList);
    212212//  Log() << Verbose(2) << zeile1.str() << endl << zeile2.str() << endl;
     
    250250    Params.DoubleList[Params.DistanceList[Walker->nr]->begin()->second->nr]++;            // increase this target's source count (>1? not injective)
    251251    Params.DistanceIterators[Walker->nr] = Params.DistanceList[Walker->nr]->begin();    // and remember which one we picked
    252     Log() << Verbose(2) << *Walker << " starts with distance " << Params.DistanceList[Walker->nr]->begin()->first << "." << endl;
     252    DoLog(2) && (Log() << Verbose(2) << *Walker << " starts with distance " << Params.DistanceList[Walker->nr]->begin()->first << "." << endl);
    253253  }
    254254};
     
    278278      Params.DistanceIterators[Walker->nr] = NewBase;
    279279      OldPotential = Potential;
    280       Log() << Verbose(3) << "Found a new permutation, new potential is " << OldPotential << "." << endl;
     280      DoLog(3) && (Log() << Verbose(3) << "Found a new permutation, new potential is " << OldPotential << "." << endl);
    281281    }
    282282  }
     
    307307  for (int i=mol->AtomCount; i--;) // now each single entry in the DoubleList should be <=1
    308308    if (Params.DoubleList[i] > 1) {
    309       eLog() << Verbose(0) << "Failed to create an injective PermutationMap!" << endl;
     309      DoeLog(0) && (eLog()<< Verbose(0) << "Failed to create an injective PermutationMap!" << endl);
    310310      performCriticalExit();
    311311    }
    312   Log() << Verbose(1) << "done." << endl;
     312  DoLog(1) && (Log() << Verbose(1) << "done." << endl);
    313313};
    314314
     
    359359  Params.PenaltyConstants[2] = 1e+7;    // just a huge penalty
    360360  // generate the distance list
    361   Log() << Verbose(1) << "Allocating, initializting and filling the distance list ... " << endl;
     361  DoLog(1) && (Log() << Verbose(1) << "Allocating, initializting and filling the distance list ... " << endl);
    362362  FillDistanceList(this, Params);
    363363
     
    366366
    367367  // make the PermutationMap injective by checking whether we have a non-zero constants[2] term in it
    368   Log() << Verbose(1) << "Making the PermutationMap injective ... " << endl;
     368  DoLog(1) && (Log() << Verbose(1) << "Making the PermutationMap injective ... " << endl);
    369369  MakeInjectivePermutation(this, Params);
    370370  Free(&Params.DoubleList);
    371371
    372372  // argument minimise the constrained potential in this injective PermutationMap
    373   Log() << Verbose(1) << "Argument minimising the PermutationMap." << endl;
     373  DoLog(1) && (Log() << Verbose(1) << "Argument minimising the PermutationMap." << endl);
    374374  OldPotential = 1e+10;
    375375  round = 0;
    376376  do {
    377     Log() << Verbose(2) << "Starting round " << ++round << ", at current potential " << OldPotential << " ... " << endl;
     377    DoLog(2) && (Log() << Verbose(2) << "Starting round " << ++round << ", at current potential " << OldPotential << " ... " << endl);
    378378    OlderPotential = OldPotential;
    379379    do {
     
    425425            } else {
    426426              Params.DistanceIterators[Runner->nr] = Rider;  // if successful also move the pointer in the iterator list
    427               Log() << Verbose(3) << "Found a better permutation, new potential is " << Potential << " vs." << OldPotential << "." << endl;
     427              DoLog(3) && (Log() << Verbose(3) << "Found a better permutation, new potential is " << Potential << " vs." << OldPotential << "." << endl);
    428428              OldPotential = Potential;
    429429            }
    430430            if (Potential > Params.PenaltyConstants[2]) {
    431               eLog() << Verbose(1) << "The two-step permutation procedure did not maintain injectivity!" << endl;
     431              DoeLog(1) && (eLog()<< Verbose(1) << "The two-step permutation procedure did not maintain injectivity!" << endl);
    432432              exit(255);
    433433            }
    434434            //Log() << Verbose(0) << endl;
    435435          } else {
    436             eLog() << Verbose(1) << *Runner << " was not the owner of " << *Sprinter << "!" << endl;
     436            DoeLog(1) && (eLog()<< Verbose(1) << *Runner << " was not the owner of " << *Sprinter << "!" << endl);
    437437            exit(255);
    438438          }
     
    444444    } while (Walker->next != end);
    445445  } while ((OlderPotential - OldPotential) > 1e-3);
    446   Log() << Verbose(1) << "done." << endl;
     446  DoLog(1) && (Log() << Verbose(1) << "done." << endl);
    447447
    448448
     
    467467{
    468468  /// evaluate forces (only the distance to target dependent part) with the final PermutationMap
    469   Log() << Verbose(1) << "Calculating forces and adding onto ForceMatrix ... " << endl;
     469  DoLog(1) && (Log() << Verbose(1) << "Calculating forces and adding onto ForceMatrix ... " << endl);
    470470  ActOnAllAtoms( &atom::EvaluateConstrainedForce, startstep, endstep, PermutationMap, Force );
    471   Log() << Verbose(1) << "done." << endl;
     471  DoLog(1) && (Log() << Verbose(1) << "done." << endl);
    472472};
    473473
     
    504504
    505505  // go through all steps and add the molecular configuration to the list and to the Trajectories of \a this molecule
    506   Log() << Verbose(1) << "Filling intermediate " << MaxSteps << " steps with MDSteps of " << MDSteps << "." << endl;
     506  DoLog(1) && (Log() << Verbose(1) << "Filling intermediate " << MaxSteps << " steps with MDSteps of " << MDSteps << "." << endl);
    507507  for (int step = 0; step <= MaxSteps; step++) {
    508508    mol = World::getInstance().createMolecule();
     
    569569    // parse file into ForceMatrix
    570570    if (!Force.ParseMatrix(file, 0,0,0)) {
    571       eLog() << Verbose(0) << "Could not parse Force Matrix file " << file << "." << endl;
     571      DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse Force Matrix file " << file << "." << endl);
    572572      performCriticalExit();
    573573      return false;
    574574    }
    575575    if (Force.RowCounter[0] != AtomCount) {
    576       eLog() << Verbose(0) << "Mismatch between number of atoms in file " << Force.RowCounter[0] << " and in molecule " << AtomCount << "." << endl;
     576      DoeLog(0) && (eLog()<< Verbose(0) << "Mismatch between number of atoms in file " << Force.RowCounter[0] << " and in molecule " << AtomCount << "." << endl);
    577577      performCriticalExit();
    578578      return false;
     
    653653  switch(Thermostat) {
    654654     case None:
    655       Log() << Verbose(2) <<  "Applying no thermostat..." << endl;
     655      DoLog(2) && (Log() << Verbose(2) <<  "Applying no thermostat..." << endl);
    656656      break;
    657657     case Woodcock:
    658658      if ((configuration.ScaleTempStep > 0) && ((MDSteps-1) % configuration.ScaleTempStep == 0)) {
    659         Log() << Verbose(2) <<  "Applying Woodcock thermostat..." << endl;
     659        DoLog(2) && (Log() << Verbose(2) <<  "Applying Woodcock thermostat..." << endl);
    660660        ActOnAllAtoms( &atom::Thermostat_Woodcock, sqrt(ScaleTempFactor), MDSteps, &ekin );
    661661      }
    662662      break;
    663663     case Gaussian:
    664       Log() << Verbose(2) <<  "Applying Gaussian thermostat..." << endl;
     664      DoLog(2) && (Log() << Verbose(2) <<  "Applying Gaussian thermostat..." << endl);
    665665      ActOnAllAtoms( &atom::Thermostat_Gaussian_init, MDSteps, &G, &E );
    666666
    667       Log() << Verbose(1) << "Gaussian Least Constraint constant is " << G/E << "." << endl;
     667      DoLog(1) && (Log() << Verbose(1) << "Gaussian Least Constraint constant is " << G/E << "." << endl);
    668668      ActOnAllAtoms( &atom::Thermostat_Gaussian_least_constraint, MDSteps, G/E, &ekin, &configuration);
    669669
    670670      break;
    671671     case Langevin:
    672       Log() << Verbose(2) <<  "Applying Langevin thermostat..." << endl;
     672      DoLog(2) && (Log() << Verbose(2) <<  "Applying Langevin thermostat..." << endl);
    673673      // init random number generator
    674674      gsl_rng_env_setup();
     
    680680
    681681     case Berendsen:
    682       Log() << Verbose(2) <<  "Applying Berendsen-VanGunsteren thermostat..." << endl;
     682      DoLog(2) && (Log() << Verbose(2) <<  "Applying Berendsen-VanGunsteren thermostat..." << endl);
    683683      ActOnAllAtoms( &atom::Thermostat_Berendsen, MDSteps, ScaleTempFactor, &ekin, &configuration );
    684684      break;
    685685
    686686     case NoseHoover:
    687       Log() << Verbose(2) <<  "Applying Nose-Hoover thermostat..." << endl;
     687      DoLog(2) && (Log() << Verbose(2) <<  "Applying Nose-Hoover thermostat..." << endl);
    688688      // dynamically evolve alpha (the additional degree of freedom)
    689689      delta_alpha = 0.;
     
    691691      delta_alpha = (delta_alpha - (3.*AtomCount+1.) * configuration.TargetTemp)/(configuration.HooverMass*Units2Electronmass);
    692692      configuration.alpha += delta_alpha*configuration.Deltat;
    693       Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration.alpha << "." << endl;
     693      DoLog(3) && (Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration.alpha << "." << endl);
    694694      // apply updated alpha as additional force
    695695      ActOnAllAtoms( &atom::Thermostat_NoseHoover_scale, MDSteps, &ekin, &configuration );
    696696      break;
    697697  }
    698   Log() << Verbose(1) << "Kinetic energy is " << ekin << "." << endl;
    699 };
     698  DoLog(1) && (Log() << Verbose(1) << "Kinetic energy is " << ekin << "." << endl);
     699};
  • src/molecule_fragmentation.cpp

    r13d5a9 r5f612ee  
    1919#include "molecule.hpp"
    2020#include "periodentafel.hpp"
     21#include "World.hpp"
    2122
    2223/************************************* Functions for class molecule *********************************/
     
    4445  }
    4546  FragmentCount = NoNonHydrogen*(1 << (c*order));
    46   Log() << Verbose(1) << "Upper limit for this subgraph is " << FragmentCount << " for " << NoNonHydrogen << " non-H atoms with maximum bond degree of " << c << "." << endl;
     47  DoLog(1) && (Log() << Verbose(1) << "Upper limit for this subgraph is " << FragmentCount << " for " << NoNonHydrogen << " non-H atoms with maximum bond degree of " << c << "." << endl);
    4748  return FragmentCount;
    4849};
     
    6869    } // else it's "-1" or else and thus must not be added
    6970  }
    70   Log() << Verbose(1) << "The scanned KeySet is ";
     71  DoLog(1) && (Log() << Verbose(1) << "The scanned KeySet is ");
    7172  for(KeySet::iterator runner = CurrentSet.begin(); runner != CurrentSet.end(); runner++) {
    72     Log() << Verbose(0) << (*runner) << "\t";
    73   }
    74   Log() << Verbose(0) << endl;
     73    DoLog(0) && (Log() << Verbose(0) << (*runner) << "\t");
     74  }
     75  DoLog(0) && (Log() << Verbose(0) << endl);
    7576  return (status != 0);
    7677};
     
    100101
    101102  // 1st pass: open file and read
    102   Log() << Verbose(1) << "Parsing the KeySet file ... " << endl;
     103  DoLog(1) && (Log() << Verbose(1) << "Parsing the KeySet file ... " << endl);
    103104  sprintf(filename, "%s/%s%s", path, FRAGMENTPREFIX, KEYSETFILE);
    104105  InputFile.open(filename);
     
    113114        testGraphInsert = FragmentList->insert(GraphPair (CurrentSet,pair<int,double>(NumberOfFragments++,1)));  // store fragment number and current factor
    114115        if (!testGraphInsert.second) {
    115           eLog() << Verbose(0) << "KeySet file must be corrupt as there are two equal key sets therein!" << endl;
     116          DoeLog(0) && (eLog()<< Verbose(0) << "KeySet file must be corrupt as there are two equal key sets therein!" << endl);
    116117          performCriticalExit();
    117118        }
     
    122123    InputFile.clear();
    123124    Free(&buffer);
    124     Log() << Verbose(1) << "done." << endl;
     125    DoLog(1) && (Log() << Verbose(1) << "done." << endl);
    125126  } else {
    126     Log() << Verbose(1) << "File " << filename << " not found." << endl;
     127    DoLog(1) && (Log() << Verbose(1) << "File " << filename << " not found." << endl);
    127128    status = false;
    128129  }
     
    154155
    155156  // 2nd pass: open TEFactors file and read
    156   Log() << Verbose(1) << "Parsing the TEFactors file ... " << endl;
     157  DoLog(1) && (Log() << Verbose(1) << "Parsing the TEFactors file ... " << endl);
    157158  sprintf(filename, "%s/%s%s", path, FRAGMENTPREFIX, TEFACTORSFILE);
    158159  InputFile.open(filename);
     
    164165        InputFile >> TEFactor;
    165166        (*runner).second.second = TEFactor;
    166         Log() << Verbose(2) << "Setting " << ++NumberOfFragments << " fragment's TEFactor to " << (*runner).second.second << "." << endl;
     167        DoLog(2) && (Log() << Verbose(2) << "Setting " << ++NumberOfFragments << " fragment's TEFactor to " << (*runner).second.second << "." << endl);
    167168      } else {
    168169        status = false;
     
    172173    // 4. Free and done
    173174    InputFile.close();
    174     Log() << Verbose(1) << "done." << endl;
     175    DoLog(1) && (Log() << Verbose(1) << "done." << endl);
    175176  } else {
    176     Log() << Verbose(1) << "File " << filename << " not found." << endl;
     177    DoLog(1) && (Log() << Verbose(1) << "File " << filename << " not found." << endl);
    177178    status = false;
    178179  }
     
    202203  line += KEYSETFILE;
    203204  output.open(line.c_str(), ios::out);
    204   Log() << Verbose(1) << "Saving key sets of the total graph ... ";
     205  DoLog(1) && (Log() << Verbose(1) << "Saving key sets of the total graph ... ");
    205206  if(output != NULL) {
    206207    for(Graph::iterator runner = KeySetList.begin(); runner != KeySetList.end(); runner++) {
     
    212213      output << endl;
    213214    }
    214     Log() << Verbose(0) << "done." << endl;
     215    DoLog(0) && (Log() << Verbose(0) << "done." << endl);
    215216  } else {
    216     eLog() << Verbose(0) << "Unable to open " << line << " for writing keysets!" << endl;
     217    DoeLog(0) && (eLog()<< Verbose(0) << "Unable to open " << line << " for writing keysets!" << endl);
    217218    performCriticalExit();
    218219    status = false;
     
    243244  line += TEFACTORSFILE;
    244245  output.open(line.c_str(), ios::out);
    245   Log() << Verbose(1) << "Saving TEFactors of the total graph ... ";
     246  DoLog(1) && (Log() << Verbose(1) << "Saving TEFactors of the total graph ... ");
    246247  if(output != NULL) {
    247248    for(Graph::iterator runner = KeySetList.begin(); runner != KeySetList.end(); runner++)
    248249      output << (*runner).second.second << endl;
    249     Log() << Verbose(1) << "done." << endl;
     250    DoLog(1) && (Log() << Verbose(1) << "done." << endl);
    250251  } else {
    251     Log() << Verbose(1) << "failed to open " << line << "." << endl;
     252    DoLog(1) && (Log() << Verbose(1) << "failed to open " << line << "." << endl);
    252253    status = false;
    253254  }
     
    293294        (*PresentItem).second.first = fabs(Value);
    294295        (*PresentItem).second.second = FragOrder;
    295         Log() << Verbose(2) << "Updated element (" <<  (*PresentItem).first << ",[" << (*PresentItem).second.first << "," << (*PresentItem).second.second << "])." << endl;
     296        DoLog(2) && (Log() << Verbose(2) << "Updated element (" <<  (*PresentItem).first << ",[" << (*PresentItem).second.first << "," << (*PresentItem).second.second << "])." << endl);
    296297      } else {
    297         Log() << Verbose(2) << "Did not update element " <<  (*PresentItem).first << " as " << FragOrder << " is less than or equal to " << (*PresentItem).second.second << "." << endl;
     298        DoLog(2) && (Log() << Verbose(2) << "Did not update element " <<  (*PresentItem).first << " as " << FragOrder << " is less than or equal to " << (*PresentItem).second.second << "." << endl);
    298299      }
    299300    } else {
    300       Log() << Verbose(2) << "Inserted element (" <<  (*PresentItem).first << ",[" << (*PresentItem).second.first << "," << (*PresentItem).second.second << "])." << endl;
     301      DoLog(2) && (Log() << Verbose(2) << "Inserted element (" <<  (*PresentItem).first << ",[" << (*PresentItem).second.first << "," << (*PresentItem).second.second << "])." << endl);
    301302    }
    302303  } else {
    303     Log() << Verbose(1) << "No Fragment under No. " << No << "found." << endl;
     304    DoLog(1) && (Log() << Verbose(1) << "No Fragment under No. " << No << "found." << endl);
    304305  }
    305306};
     
    360361  atom *Walker = mol->start;
    361362  map<double, pair<int,int> > *FinalRootCandidates = new map<double, pair<int,int> > ;
    362   Log() << Verbose(1) << "Root candidate list is: " << endl;
     363  DoLog(1) && (Log() << Verbose(1) << "Root candidate list is: " << endl);
    363364  for(map<int, pair<double,int> >::iterator runner = AdaptiveCriteriaList->begin(); runner != AdaptiveCriteriaList->end(); runner++) {
    364365    Walker = mol->FindAtom((*runner).first);
     
    366367      //if ((*runner).second.second >= Walker->AdaptiveOrder) { // only insert if this is an "active" root site for the current order
    367368      if (!Walker->MaxOrder) {
    368         Log() << Verbose(2) << "(" << (*runner).first << ",[" << (*runner).second.first << "," << (*runner).second.second << "])" << endl;
     369        DoLog(2) && (Log() << Verbose(2) << "(" << (*runner).first << ",[" << (*runner).second.first << "," << (*runner).second.second << "])" << endl);
    369370        FinalRootCandidates->insert( make_pair( (*runner).second.first, pair<int,int>((*runner).first, (*runner).second.second) ) );
    370371      } else {
    371         Log() << Verbose(2) << "Excluding (" << *Walker << ", " << (*runner).first << ",[" << (*runner).second.first << "," << (*runner).second.second << "]), as it has reached its maximum order." << endl;
     372        DoLog(2) && (Log() << Verbose(2) << "Excluding (" << *Walker << ", " << (*runner).first << ",[" << (*runner).second.first << "," << (*runner).second.second << "]), as it has reached its maximum order." << endl);
    372373      }
    373374    } else {
    374       eLog() << Verbose(0) << "Atom No. " << (*runner).second.first << " was not found in this molecule." << endl;
     375      DoeLog(0) && (eLog()<< Verbose(0) << "Atom No. " << (*runner).second.first << " was not found in this molecule." << endl);
    375376      performCriticalExit();
    376377    }
     
    397398    Walker = mol->FindAtom(No);
    398399    //if (Walker->AdaptiveOrder < MinimumRingSize[Walker->nr]) {
    399       Log() << Verbose(2) << "Root " << No << " is still above threshold (10^{" << Order <<"}: " << runner->first << ", setting entry " << No << " of Atom mask to true." << endl;
     400      DoLog(2) && (Log() << Verbose(2) << "Root " << No << " is still above threshold (10^{" << Order <<"}: " << runner->first << ", setting entry " << No << " of Atom mask to true." << endl);
    400401      AtomMask[No] = true;
    401402      status = true;
     
    413414void PrintAtomMask(bool *AtomMask, int AtomCount)
    414415{
    415   Log() << Verbose(2) << "              ";
     416  DoLog(2) && (Log() << Verbose(2) << "              ");
    416417  for(int i=0;i<AtomCount;i++)
    417     Log() << Verbose(0) << (i % 10);
    418   Log() << Verbose(0) << endl;
    419   Log() << Verbose(2) << "Atom mask is: ";
     418    DoLog(0) && (Log() << Verbose(0) << (i % 10));
     419  DoLog(0) && (Log() << Verbose(0) << endl);
     420  DoLog(2) && (Log() << Verbose(2) << "Atom mask is: ");
    420421  for(int i=0;i<AtomCount;i++)
    421     Log() << Verbose(0) << (AtomMask[i] ? "t" : "f");
    422   Log() << Verbose(0) << endl;
     422    DoLog(0) && (Log() << Verbose(0) << (AtomMask[i] ? "t" : "f"));
     423  DoLog(0) && (Log() << Verbose(0) << endl);
    423424};
    424425
     
    447448    // transmorph graph keyset list into indexed KeySetList
    448449    if (GlobalKeySetList == NULL) {
    449       eLog() << Verbose(1) << "Given global key set list (graph) is NULL!" << endl;
     450      DoeLog(1) && (eLog()<< Verbose(1) << "Given global key set list (graph) is NULL!" << endl);
    450451      return false;
    451452    }
     
    455456    map<int, pair<double,int> > *AdaptiveCriteriaList = ScanAdaptiveFileIntoMap(path, *IndexKeySetList); // (Root No., (Value, Order)) !
    456457    if (AdaptiveCriteriaList->empty()) {
    457       eLog() << Verbose(2) << "Unable to parse file, incrementing all." << endl;
     458      DoeLog(2) && (eLog()<< Verbose(2) << "Unable to parse file, incrementing all." << endl);
    458459      while (Walker->next != end) {
    459460        Walker = Walker->next;
     
    493494    if (!status) {
    494495      if (Order == 0)
    495         Log() << Verbose(1) << "Single stepping done." << endl;
     496        DoLog(1) && (Log() << Verbose(1) << "Single stepping done." << endl);
    496497      else
    497         Log() << Verbose(1) << "Order at every site is already equal or above desired order " << Order << "." << endl;
     498        DoLog(1) && (Log() << Verbose(1) << "Order at every site is already equal or above desired order " << Order << "." << endl);
    498499    }
    499500  }
     
    512513{
    513514  if (SortIndex != NULL) {
    514     Log() << Verbose(1) << "SortIndex is " << SortIndex << " and not NULL as expected." << endl;
     515    DoLog(1) && (Log() << Verbose(1) << "SortIndex is " << SortIndex << " and not NULL as expected." << endl);
    515516    return false;
    516517  }
     
    563564  bool *AtomMask = NULL;
    564565
    565   Log() << Verbose(0) << endl;
     566  DoLog(0) && (Log() << Verbose(0) << endl);
    566567#ifdef ADDHYDROGEN
    567   Log() << Verbose(0) << "I will treat hydrogen special and saturate dangling bonds with it." << endl;
     568  DoLog(0) && (Log() << Verbose(0) << "I will treat hydrogen special and saturate dangling bonds with it." << endl);
    568569#else
    569   Log() << Verbose(0) << "Hydrogen is treated just like the rest of the lot." << endl;
     570  DoLog(0) && (Log() << Verbose(0) << "Hydrogen is treated just like the rest of the lot." << endl);
    570571#endif
    571572
     
    593594    // fill the bond structure of the individually stored subgraphs
    594595  MolecularWalker->FillBondStructureFromReference(this, FragmentCounter, ListOfLocalAtoms, false);  // we want to keep the created ListOfLocalAtoms
    595     Log() << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl;
     596    DoLog(0) && (Log() << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl);
    596597    LocalBackEdgeStack = new StackClass<bond *> (MolecularWalker->Leaf->BondCount);
    597598//    // check the list of local atoms for debugging
     
    602603//      else
    603604//        Log() << Verbose(0) << "\t" << ListOfLocalAtoms[FragmentCounter][i]->Name;
    604     Log() << Verbose(0) << "Gathering local back edges for subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl;
     605    DoLog(0) && (Log() << Verbose(0) << "Gathering local back edges for subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl);
    605606    MolecularWalker->Leaf->PickLocalBackEdges(ListOfLocalAtoms[FragmentCounter++], BackEdgeStack, LocalBackEdgeStack);
    606     Log() << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl;
     607    DoLog(0) && (Log() << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl);
    607608    MolecularWalker->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize);
    608     Log() << Verbose(0) << "Done with Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl;
     609    DoLog(0) && (Log() << Verbose(0) << "Done with Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl);
    609610    delete(LocalBackEdgeStack);
    610611  }
     
    637638    while (MolecularWalker->next != NULL) {
    638639      MolecularWalker = MolecularWalker->next;
    639       Log() << Verbose(1) << "Fragmenting subgraph " << MolecularWalker << "." << endl;
     640      DoLog(1) && (Log() << Verbose(1) << "Fragmenting subgraph " << MolecularWalker << "." << endl);
    640641      //MolecularWalker->Leaf->OutputListOfBonds(out);  // output atom::ListOfBonds for debugging
    641642      if (MolecularWalker->Leaf->first->next != MolecularWalker->Leaf->last) {
    642643        // call BOSSANOVA method
    643         Log() << Verbose(0) << endl << " ========== BOND ENERGY of subgraph " << FragmentCounter << " ========================= " << endl;
     644        DoLog(0) && (Log() << Verbose(0) << endl << " ========== BOND ENERGY of subgraph " << FragmentCounter << " ========================= " << endl);
    644645        MolecularWalker->Leaf->FragmentBOSSANOVA(FragmentList[FragmentCounter], RootStack[FragmentCounter], MinimumRingSize);
    645646      } else {
    646         eLog() << Verbose(1) << "Subgraph " << MolecularWalker << " has no atoms!" << endl;
     647        DoeLog(1) && (eLog()<< Verbose(1) << "Subgraph " << MolecularWalker << " has no atoms!" << endl);
    647648      }
    648649      FragmentCounter++;  // next fragment list
    649650    }
    650651  }
    651   Log() << Verbose(2) << "CheckOrder is " << CheckOrder << "." << endl;
     652  DoLog(2) && (Log() << Verbose(2) << "CheckOrder is " << CheckOrder << "." << endl);
    652653  delete[](RootStack);
    653654  delete[](AtomMask);
     
    680681  for(Graph::iterator runner = TotalGraph.begin(); runner != TotalGraph.end(); runner++) {
    681682    KeySet test = (*runner).first;
    682     Log() << Verbose(0) << "Fragment No." << (*runner).second.first << " with TEFactor " << (*runner).second.second << "." << endl;
     683    DoLog(0) && (Log() << Verbose(0) << "Fragment No." << (*runner).second.first << " with TEFactor " << (*runner).second.second << "." << endl);
    683684    BondFragments->insert(StoreFragmentFromKeySet(test, configuration));
    684685    k++;
    685686  }
    686   Log() << Verbose(0) << k << "/" << BondFragments->ListOfMolecules.size() << " fragments generated from the keysets." << endl;
     687  DoLog(0) && (Log() << Verbose(0) << k << "/" << BondFragments->ListOfMolecules.size() << " fragments generated from the keysets." << endl);
    687688
    688689  // ===== 9. Save fragments' configuration and keyset files et al to disk ===
     
    691692    CreateMappingLabelsToConfigSequence(SortIndex);
    692693
    693     Log() << Verbose(1) << "Writing " << BondFragments->ListOfMolecules.size() << " possible bond fragmentation configs" << endl;
     694    DoLog(1) && (Log() << Verbose(1) << "Writing " << BondFragments->ListOfMolecules.size() << " possible bond fragmentation configs" << endl);
    694695    if (BondFragments->OutputConfigForListOfFragments(configuration, SortIndex))
    695       Log() << Verbose(1) << "All configs written." << endl;
     696      DoLog(1) && (Log() << Verbose(1) << "All configs written." << endl);
    696697    else
    697       Log() << Verbose(1) << "Some config writing failed." << endl;
     698      DoLog(1) && (Log() << Verbose(1) << "Some config writing failed." << endl);
    698699
    699700    // store force index reference file
     
    704705
    705706    // store Adjacency file
    706     StoreAdjacencyToFile(configuration->configpath);
     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);
    707712
    708713    // store Hydrogen saturation correction file
     
    716721
    717722    // free memory for bond part
    718     Log() << Verbose(1) << "Freeing bond memory" << endl;
     723    DoLog(1) && (Log() << Verbose(1) << "Freeing bond memory" << endl);
    719724    delete(FragmentList); // remove bond molecule from memory
    720725    Free(&SortIndex);
    721726  } else {
    722     Log() << Verbose(1) << "FragmentList is zero on return, splitting failed." << endl;
     727    DoLog(1) && (Log() << Verbose(1) << "FragmentList is zero on return, splitting failed." << endl);
    723728  }
    724729  delete(BondFragments);
    725   Log() << Verbose(0) << "End of bond fragmentation." << endl;
     730  DoLog(0) && (Log() << Verbose(0) << "End of bond fragmentation." << endl);
    726731
    727732  return ((int)(!FragmentationToDo)+1);    // 1 - continue, 2 - stop (no fragmentation occured)
     
    742747  line << path << "/" << FRAGMENTPREFIX << ORDERATSITEFILE;
    743748  file.open(line.str().c_str());
    744   Log() << Verbose(1) << "Writing OrderAtSite " << ORDERATSITEFILE << " ... " << endl;
     749  DoLog(1) && (Log() << Verbose(1) << "Writing OrderAtSite " << ORDERATSITEFILE << " ... " << endl);
    745750  if (file != NULL) {
    746751    ActOnAllAtoms( &atom::OutputOrder, &file );
    747752    file.close();
    748     Log() << Verbose(1) << "done." << endl;
     753    DoLog(1) && (Log() << Verbose(1) << "done." << endl);
    749754    return true;
    750755  } else {
    751     Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl;
     756    DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl);
    752757    return false;
    753758  }
     
    770775  ifstream file;
    771776
    772   Log() << Verbose(1) << "Begin of ParseOrderAtSiteFromFile" << endl;
     777  DoLog(1) && (Log() << Verbose(1) << "Begin of ParseOrderAtSiteFromFile" << endl);
    773778  line << path << "/" << FRAGMENTPREFIX << ORDERATSITEFILE;
    774779  file.open(line.str().c_str());
     
    791796    SetAtomValueToIndexedArray( MaxArray, &atom::nr, &atom::MaxOrder );
    792797
    793     Log() << Verbose(1) << "done." << endl;
     798    DoLog(1) && (Log() << Verbose(1) << "done." << endl);
    794799    status = true;
    795800  } else {
    796     Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl;
     801    DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl);
    797802    status = false;
    798803  }
     
    800805  Free(&MaxArray);
    801806
    802   Log() << Verbose(1) << "End of ParseOrderAtSiteFromFile" << endl;
     807  DoLog(1) && (Log() << Verbose(1) << "End of ParseOrderAtSiteFromFile" << endl);
    803808  return status;
    804809};
     
    817822  int SP, Removal;
    818823
    819   Log() << Verbose(2) << "Looking for removal candidate." << endl;
     824  DoLog(2) && (Log() << Verbose(2) << "Looking for removal candidate." << endl);
    820825  SP = -1; //0;  // not -1, so that Root is never removed
    821826  Removal = -1;
     
    844849
    845850  Leaf->BondDistance = mol->BondDistance;
    846   for(int i=NDIM*2;i--;)
    847     Leaf->cell_size[i] = mol->cell_size[i];
    848851
    849852  // first create the minimal set of atoms from the KeySet
     
    904907      }
    905908    } else {
    906       eLog() << Verbose(1) << "Son " << Runner->Name << " has father " << FatherOfRunner->Name << " but its entry in SonList is " << SonList[FatherOfRunner->nr] << "!" << endl;
     909      DoeLog(1) && (eLog()<< Verbose(1) << "Son " << Runner->Name << " has father " << FatherOfRunner->Name << " but its entry in SonList is " << SonList[FatherOfRunner->nr] << "!" << endl);
    907910    }
    908911    if ((LonelyFlag) && (Leaf->AtomCount > 1)) {
    909       Log() << Verbose(0) << *Runner << "has got bonds only to hydrogens!" << endl;
     912      DoLog(0) && (Log() << Verbose(0) << *Runner << "has got bonds only to hydrogens!" << endl);
    910913    }
    911914#ifdef ADDHYDROGEN
     
    10541057    TouchedList[j] = -1;
    10551058  }
    1056   Log() << Verbose(2) << "Remaining local nr.s on snake stack are: ";
     1059  DoLog(2) && (Log() << Verbose(2) << "Remaining local nr.s on snake stack are: ");
    10571060  for(KeySet::iterator runner = FragmentSet->begin(); runner != FragmentSet->end(); runner++)
    1058     Log() << Verbose(0) << (*runner) << " ";
    1059   Log() << Verbose(0) << endl;
     1061    DoLog(0) && (Log() << Verbose(0) << (*runner) << " ");
     1062  DoLog(0) && (Log() << Verbose(0) << endl);
    10601063  TouchedIndex = 0; // set Index to 0 for list of atoms added on this level
    10611064};
     
    11341137        Log() << Verbose(1+verbosity) << "Enough items on stack for a fragment!" << endl;
    11351138        // store fragment as a KeySet
    1136         Log() << Verbose(2) << "Found a new fragment[" << FragmentSearch->FragmentCounter << "], local nr.s are: ";
     1139        DoLog(2) && (Log() << Verbose(2) << "Found a new fragment[" << FragmentSearch->FragmentCounter << "], local nr.s are: ");
    11371140        for(KeySet::iterator runner = FragmentSearch->FragmentSet->begin(); runner != FragmentSearch->FragmentSet->end(); runner++)
    1138           Log() << Verbose(0) << (*runner) << " ";
    1139         Log() << Verbose(0) << endl;
     1141          DoLog(0) && (Log() << Verbose(0) << (*runner) << " ");
     1142        DoLog(0) && (Log() << Verbose(0) << endl);
    11401143        //if (!CheckForConnectedSubgraph(FragmentSearch->FragmentSet))
    1141           //eLog() << Verbose(1) << "The found fragment is not a connected subgraph!" << endl;
     1144          //DoeLog(1) && (eLog()<< Verbose(1) << "The found fragment is not a connected subgraph!" << endl);
    11421145        InsertFragmentIntoGraph(FragmentSearch);
    11431146      }
     
    12191222{
    12201223  bond *Binder = NULL;
    1221   Log() << Verbose(0) << "Free'ing all found lists. and resetting index lists" << endl;
     1224  DoLog(0) && (Log() << Verbose(0) << "Free'ing all found lists. and resetting index lists" << endl);
    12221225  for(int i=Order;i--;) {
    1223     Log() << Verbose(1) << "Current SP level is " << i << ": ";
     1226    DoLog(1) && (Log() << Verbose(1) << "Current SP level is " << i << ": ");
    12241227    Binder = FragmentSearch.BondsPerSPList[2*i];
    12251228    while (Binder->next != FragmentSearch.BondsPerSPList[2*i+1]) {
     
    12321235    cleanup(FragmentSearch.BondsPerSPList[2*i], FragmentSearch.BondsPerSPList[2*i+1]);
    12331236    // also start and end node
    1234     Log() << Verbose(0) << "cleaned." << endl;
     1237    DoLog(0) && (Log() << Verbose(0) << "cleaned." << endl);
    12351238  }
    12361239};
     
    12621265  int SP = -1;
    12631266
    1264   Log() << Verbose(0) << "Starting BFS analysis ..." << endl;
     1267  DoLog(0) && (Log() << Verbose(0) << "Starting BFS analysis ..." << endl);
    12651268  for (SP = 0; SP < (Order-1); SP++) {
    1266     Log() << Verbose(1) << "New SP level reached: " << SP << ", creating new SP list with " << FragmentSearch.BondsPerSPCount[SP] << " item(s)";
     1269    DoLog(1) && (Log() << Verbose(1) << "New SP level reached: " << SP << ", creating new SP list with " << FragmentSearch.BondsPerSPCount[SP] << " item(s)");
    12671270    if (SP > 0) {
    1268       Log() << Verbose(0) << ", old level closed with " << FragmentSearch.BondsPerSPCount[SP-1] << " item(s)." << endl;
     1271      DoLog(0) && (Log() << Verbose(0) << ", old level closed with " << FragmentSearch.BondsPerSPCount[SP-1] << " item(s)." << endl);
    12691272      FragmentSearch.BondsPerSPCount[SP] = 0;
    12701273    } else
    1271       Log() << Verbose(0) << "." << endl;
     1274      DoLog(0) && (Log() << Verbose(0) << "." << endl);
    12721275
    12731276    RemainingWalkers = FragmentSearch.BondsPerSPCount[SP];
     
    12791282      Predecessor = CurrentEdge->leftatom;    // ... and leftatom is predecessor
    12801283      AtomKeyNr = Walker->nr;
    1281       Log() << Verbose(0) << "Current Walker is: " << *Walker << " with nr " << Walker->nr << " and SP of " << SP << ", with " << RemainingWalkers << " remaining walkers on this level." << endl;
     1284      DoLog(0) && (Log() << Verbose(0) << "Current Walker is: " << *Walker << " with nr " << Walker->nr << " and SP of " << SP << ", with " << RemainingWalkers << " remaining walkers on this level." << endl);
    12821285      // check for new sp level
    12831286      // go through all its bonds
    1284       Log() << Verbose(1) << "Going through all bonds of Walker." << endl;
     1287      DoLog(1) && (Log() << Verbose(1) << "Going through all bonds of Walker." << endl);
    12851288      for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
    12861289        OtherWalker = (*Runner)->GetOtherAtom(Walker);
     
    12901293  #endif
    12911294                                                              ) {  // skip hydrogens and restrict to fragment
    1292           Log() << Verbose(2) << "Current partner is " << *OtherWalker << " with nr " << OtherWalker->nr << " in bond " << *(*Runner) << "." << endl;
     1295          DoLog(2) && (Log() << Verbose(2) << "Current partner is " << *OtherWalker << " with nr " << OtherWalker->nr << " in bond " << *(*Runner) << "." << endl);
    12931296          // set the label if not set (and push on root stack as well)
    12941297          if ((OtherWalker != Predecessor) && (OtherWalker->GetTrueFather()->nr > RootKeyNr)) { // only pass through those with label bigger than Root's
    12951298            FragmentSearch.ShortestPathList[OtherWalker->nr] = SP+1;
    1296             Log() << Verbose(3) << "Set Shortest Path to " << FragmentSearch.ShortestPathList[OtherWalker->nr] << "." << endl;
     1299            DoLog(3) && (Log() << Verbose(3) << "Set Shortest Path to " << FragmentSearch.ShortestPathList[OtherWalker->nr] << "." << endl);
    12971300            // add the bond in between to the SP list
    12981301            Binder = new bond(Walker, OtherWalker); // create a new bond in such a manner, that bond::rightatom is always the one more distant
    12991302            add(Binder, FragmentSearch.BondsPerSPList[2*(SP+1)+1]);
    13001303            FragmentSearch.BondsPerSPCount[SP+1]++;
    1301             Log() << Verbose(3) << "Added its bond to SP list, having now " << FragmentSearch.BondsPerSPCount[SP+1] << " item(s)." << endl;
     1304            DoLog(3) && (Log() << Verbose(3) << "Added its bond to SP list, having now " << FragmentSearch.BondsPerSPCount[SP+1] << " item(s)." << endl);
    13021305          } else {
    13031306            if (OtherWalker != Predecessor)
    1304               Log() << Verbose(3) << "Not passing on, as index of " << *OtherWalker << " " << OtherWalker->GetTrueFather()->nr << " is smaller than that of Root " << RootKeyNr << "." << endl;
     1307              DoLog(3) && (Log() << Verbose(3) << "Not passing on, as index of " << *OtherWalker << " " << OtherWalker->GetTrueFather()->nr << " is smaller than that of Root " << RootKeyNr << "." << endl);
    13051308            else
    1306               Log() << Verbose(3) << "This is my predecessor " << *Predecessor << "." << endl;
     1309              DoLog(3) && (Log() << Verbose(3) << "This is my predecessor " << *Predecessor << "." << endl);
    13071310          }
    13081311        } else Log() << Verbose(2) << "Is not in the restricted keyset or skipping hydrogen " << *OtherWalker << "." << endl;
     
    13201323{
    13211324  bond *Binder = NULL;
    1322   Log() << Verbose(0) << "Printing all found lists." << endl;
     1325  DoLog(0) && (Log() << Verbose(0) << "Printing all found lists." << endl);
    13231326  for(int i=1;i<Order;i++) {    // skip the root edge in the printing
    13241327    Binder = FragmentSearch.BondsPerSPList[2*i];
    1325     Log() << Verbose(1) << "Current SP level is " << i << "." << endl;
     1328    DoLog(1) && (Log() << Verbose(1) << "Current SP level is " << i << "." << endl);
    13261329    while (Binder->next != FragmentSearch.BondsPerSPList[2*i+1]) {
    13271330      Binder = Binder->next;
    1328       Log() << Verbose(2) << *Binder << endl;
     1331      DoLog(2) && (Log() << Verbose(2) << *Binder << endl);
    13291332    }
    13301333  }
     
    13701373  int Counter = FragmentSearch.FragmentCounter; // mark current value of counter
    13711374
    1372   Log() << Verbose(0) << endl;
    1373   Log() << Verbose(0) << "Begin of PowerSetGenerator with order " << Order << " at Root " << *FragmentSearch.Root << "." << endl;
     1375  DoLog(0) && (Log() << Verbose(0) << endl);
     1376  DoLog(0) && (Log() << Verbose(0) << "Begin of PowerSetGenerator with order " << Order << " at Root " << *FragmentSearch.Root << "." << endl);
    13741377
    13751378  SetSPList(Order, FragmentSearch);
     
    13831386  // creating fragments with the found edge sets  (may be done in reverse order, faster)
    13841387  int SP = CountNumbersInBondsList(Order, FragmentSearch);
    1385   Log() << Verbose(0) << "Total number of edges is " << SP << "." << endl;
     1388  DoLog(0) && (Log() << Verbose(0) << "Total number of edges is " << SP << "." << endl);
    13861389  if (SP >= (Order-1)) {
    13871390    // start with root (push on fragment stack)
    1388     Log() << Verbose(0) << "Starting fragment generation with " << *FragmentSearch.Root << ", local nr is " << FragmentSearch.Root->nr << "." << endl;
     1391    DoLog(0) && (Log() << Verbose(0) << "Starting fragment generation with " << *FragmentSearch.Root << ", local nr is " << FragmentSearch.Root->nr << "." << endl);
    13891392    FragmentSearch.FragmentSet->clear();
    1390     Log() << Verbose(0) << "Preparing subset for this root and calling generator." << endl;
     1393    DoLog(0) && (Log() << Verbose(0) << "Preparing subset for this root and calling generator." << endl);
    13911394
    13921395    // prepare the subset and call the generator
     
    13981401    Free(&BondsList);
    13991402  } else {
    1400     Log() << Verbose(0) << "Not enough total number of edges to build " << Order << "-body fragments." << endl;
     1403    DoLog(0) && (Log() << Verbose(0) << "Not enough total number of edges to build " << Order << "-body fragments." << endl);
    14011404  }
    14021405
    14031406  // as FragmentSearch structure is used only once, we don't have to clean it anymore
    14041407  // remove root from stack
    1405   Log() << Verbose(0) << "Removing root again from stack." << endl;
     1408  DoLog(0) && (Log() << Verbose(0) << "Removing root again from stack." << endl);
    14061409  FragmentSearch.FragmentSet->erase(FragmentSearch.Root->nr);
    14071410
     
    14101413
    14111414  // return list
    1412   Log() << Verbose(0) << "End of PowerSetGenerator." << endl;
     1415  DoLog(0) && (Log() << Verbose(0) << "End of PowerSetGenerator." << endl);
    14131416  return (FragmentSearch.FragmentCounter - Counter);
    14141417};
     
    14561459  atom *Walker = NULL;
    14571460
    1458   Log() << Verbose(0) << "Combining the lists of all orders per order and finally into a single one." << endl;
     1461  DoLog(0) && (Log() << Verbose(0) << "Combining the lists of all orders per order and finally into a single one." << endl);
    14591462  if (FragmentList == NULL) {
    14601463    FragmentList = new Graph;
     
    14891492void FreeAllOrdersList(Graph ***FragmentLowerOrdersList, KeyStack &RootStack, molecule *mol)
    14901493{
    1491   Log() << Verbose(1) << "Free'ing the lists of all orders per order." << endl;
     1494  DoLog(1) && (Log() << Verbose(1) << "Free'ing the lists of all orders per order." << endl);
    14921495  int RootNr = 0;
    14931496  int RootKeyNr = 0;
     
    15421545  struct UniqueFragments FragmentSearch;
    15431546
    1544   Log() << Verbose(0) << "Begin of FragmentBOSSANOVA." << endl;
     1547  DoLog(0) && (Log() << Verbose(0) << "Begin of FragmentBOSSANOVA." << endl);
    15451548
    15461549  // FragmentLowerOrdersList is a 2D-array of pointer to MoleculeListClass objects, one dimension represents the ANOVA expansion of a single order (i.e. 5)
     
    15921595
    15931596      // create top order where nothing is reduced
    1594       Log() << Verbose(0) << "==============================================================================================================" << endl;
    1595       Log() << Verbose(0) << "Creating KeySets of Bond Order " << Order << " for " << *Walker << ", " << (RootStack.size()-RootNr) << " Roots remaining." << endl; // , NumLevels is " << NumLevels << "
     1597      DoLog(0) && (Log() << Verbose(0) << "==============================================================================================================" << endl);
     1598      DoLog(0) && (Log() << Verbose(0) << "Creating KeySets of Bond Order " << Order << " for " << *Walker << ", " << (RootStack.size()-RootNr) << " Roots remaining." << endl); // , NumLevels is " << NumLevels << "
    15961599
    15971600      // Create list of Graphs of current Bond Order (i.e. F_{ij})
     
    16031606
    16041607      // output resulting number
    1605       Log() << Verbose(1) << "Number of resulting KeySets is: " << NumMoleculesOfOrder[RootNr] << "." << endl;
     1608      DoLog(1) && (Log() << Verbose(1) << "Number of resulting KeySets is: " << NumMoleculesOfOrder[RootNr] << "." << endl);
    16061609      if (NumMoleculesOfOrder[RootNr] != 0) {
    16071610        NumMolecules = 0;
     
    16201623    }
    16211624  }
    1622   Log() << Verbose(0) << "==============================================================================================================" << endl;
    1623   Log() << Verbose(1) << "Total number of resulting molecules is: " << TotalNumMolecules << "." << endl;
    1624   Log() << Verbose(0) << "==============================================================================================================" << endl;
     1625  DoLog(0) && (Log() << Verbose(0) << "==============================================================================================================" << endl);
     1626  DoLog(1) && (Log() << Verbose(1) << "Total number of resulting molecules is: " << TotalNumMolecules << "." << endl);
     1627  DoLog(0) && (Log() << Verbose(0) << "==============================================================================================================" << endl);
    16251628
    16261629  // cleanup FragmentSearch structure
     
    16401643  Free(&NumMoleculesOfOrder);
    16411644
    1642   Log() << Verbose(0) << "End of FragmentBOSSANOVA." << endl;
     1645  DoLog(0) && (Log() << Verbose(0) << "End of FragmentBOSSANOVA." << endl);
    16431646};
    16441647
     
    16551658  atom *Walker = NULL;
    16561659  atom *OtherWalker = NULL;
     1660  double * const cell_size = World::getInstance().getDomain();
    16571661  double *matrix = ReturnFullMatrixforSymmetric(cell_size);
    16581662  enum Shading *ColorList = NULL;
     
    16631667  bool flag = true;
    16641668
    1665   Log() << Verbose(2) << "Begin of ScanForPeriodicCorrection." << endl;
     1669  DoLog(2) && (Log() << Verbose(2) << "Begin of ScanForPeriodicCorrection." << endl);
    16661670
    16671671  ColorList = Calloc<enum Shading>(AtomCount, "molecule::ScanForPeriodicCorrection: *ColorList");
     
    16811685          OtherBinder = Binder->next; // note down binding partner for later re-insertion
    16821686          unlink(Binder);   // unlink bond
    1683           Log() << Verbose(2) << "Correcting at bond " << *Binder << "." << endl;
     1687          DoLog(2) && (Log() << Verbose(2) << "Correcting at bond " << *Binder << "." << endl);
    16841688          flag = true;
    16851689          break;
     
    16971701      //Log() << Verbose(3) << "Translation vector is ";
    16981702      Translationvector.Output();
    1699       Log() << Verbose(0) << endl;
     1703      DoLog(0) && (Log() << Verbose(0) << endl);
    17001704      // apply to all atoms of first component via BFS
    17011705      for (int i=AtomCount;i--;)
     
    17191723      link(Binder, OtherBinder);
    17201724    } else {
    1721       Log() << Verbose(3) << "No corrections for this fragment." << endl;
     1725      DoLog(3) && (Log() << Verbose(3) << "No corrections for this fragment." << endl);
    17221726    }
    17231727    //delete(CompStack);
     
    17281732  Free(&ColorList);
    17291733  Free(&matrix);
    1730   Log() << Verbose(2) << "End of ScanForPeriodicCorrection." << endl;
    1731 };
     1734  DoLog(2) && (Log() << Verbose(2) << "End of ScanForPeriodicCorrection." << endl);
     1735};
  • src/molecule_geometry.cpp

    r13d5a9 r5f612ee  
    1515#include "memoryallocator.hpp"
    1616#include "molecule.hpp"
     17#include "World.hpp"
    1718
    1819/************************************* Functions for class molecule *********************************/
     
    2627  bool status = true;
    2728  const Vector *Center = DetermineCenterOfAll();
     29  double * const cell_size = World::getInstance().getDomain();
    2830  double *M = ReturnFullMatrixforSymmetric(cell_size);
    2931  double *Minv = InverseMatrix(M);
     
    4648{
    4749  bool status = true;
     50  double * const cell_size = World::getInstance().getDomain();
    4851  double *M = ReturnFullMatrixforSymmetric(cell_size);
    4952  double *Minv = InverseMatrix(M);
     
    226229void molecule::TranslatePeriodically(const Vector *trans)
    227230{
     231  double * const cell_size = World::getInstance().getDomain();
    228232  double *M = ReturnFullMatrixforSymmetric(cell_size);
    229233  double *Minv = InverseMatrix(M);
     
    252256{
    253257  atom *Walker = start;
     258  double * const cell_size = World::getInstance().getDomain();
    254259  double *matrix = ReturnFullMatrixforSymmetric(cell_size);
    255260  double *inversematrix = InverseMatrix(cell_size);
     
    275280              if ((fabs(tmp)) > BondDistance) {
    276281                flag = false;
    277                 Log() << Verbose(0) << "Hit: atom " << Walker->Name << " in bond " << *(*Runner) << " has to be shifted due to " << tmp << "." << endl;
     282                DoLog(0) && (Log() << Verbose(0) << "Hit: atom " << Walker->Name << " in bond " << *(*Runner) << " has to be shifted due to " << tmp << "." << endl);
    278283                if (tmp > 0)
    279284                  Translationvector.x[j] -= 1.;
     
    286291        Testvector.MatrixMultiplication(matrix);
    287292        Center.AddVector(&Testvector);
    288         Log() << Verbose(1) << "vector is: ";
     293        DoLog(1) && (Log() << Verbose(1) << "vector is: ");
    289294        Testvector.Output();
    290         Log() << Verbose(0) << endl;
     295        DoLog(0) && (Log() << Verbose(0) << endl);
    291296#ifdef ADDHYDROGEN
    292297        // now also change all hydrogens
     
    298303            Testvector.MatrixMultiplication(matrix);
    299304            Center.AddVector(&Testvector);
    300             Log() << Verbose(1) << "Hydrogen vector is: ";
     305            DoLog(1) && (Log() << Verbose(1) << "Hydrogen vector is: ");
    301306            Testvector.Output();
    302             Log() << Verbose(0) << endl;
     307            DoLog(0) && (Log() << Verbose(0) << endl);
    303308          }
    304309        }
     
    347352  }
    348353  // print InertiaTensor for debugging
    349   Log() << Verbose(0) << "The inertia tensor is:" << endl;
     354  DoLog(0) && (Log() << Verbose(0) << "The inertia tensor is:" << endl);
    350355  for(int i=0;i<NDIM;i++) {
    351356    for(int j=0;j<NDIM;j++)
    352       Log() << Verbose(0) << InertiaTensor[i*NDIM+j] << " ";
    353     Log() << Verbose(0) << endl;
    354   }
    355   Log() << Verbose(0) << endl;
     357      DoLog(0) && (Log() << Verbose(0) << InertiaTensor[i*NDIM+j] << " ");
     358    DoLog(0) && (Log() << Verbose(0) << endl);
     359  }
     360  DoLog(0) && (Log() << Verbose(0) << endl);
    356361
    357362  // diagonalize to determine principal axis system
     
    365370
    366371  for(int i=0;i<NDIM;i++) {
    367     Log() << Verbose(1) << "eigenvalue = " << gsl_vector_get(eval, i);
    368     Log() << Verbose(0) << ", eigenvector = (" << evec->data[i * evec->tda + 0] << "," << evec->data[i * evec->tda + 1] << "," << evec->data[i * evec->tda + 2] << ")" << endl;
     372    DoLog(1) && (Log() << Verbose(1) << "eigenvalue = " << gsl_vector_get(eval, i));
     373    DoLog(0) && (Log() << Verbose(0) << ", eigenvector = (" << evec->data[i * evec->tda + 0] << "," << evec->data[i * evec->tda + 1] << "," << evec->data[i * evec->tda + 2] << ")" << endl);
    369374  }
    370375
    371376  // check whether we rotate or not
    372377  if (DoRotate) {
    373     Log() << Verbose(1) << "Transforming molecule into PAS ... ";
     378    DoLog(1) && (Log() << Verbose(1) << "Transforming molecule into PAS ... ");
    374379    // the eigenvectors specify the transformation matrix
    375380    ActOnAllVectors( &Vector::MatrixMultiplication, (const double *) evec->data );
    376     Log() << Verbose(0) << "done." << endl;
     381    DoLog(0) && (Log() << Verbose(0) << "done." << endl);
    377382
    378383    // summing anew for debugging (resulting matrix has to be diagonal!)
     
    399404    }
    400405    // print InertiaTensor for debugging
    401     Log() << Verbose(0) << "The inertia tensor is:" << endl;
     406    DoLog(0) && (Log() << Verbose(0) << "The inertia tensor is:" << endl);
    402407    for(int i=0;i<NDIM;i++) {
    403408      for(int j=0;j<NDIM;j++)
    404         Log() << Verbose(0) << InertiaTensor[i*NDIM+j] << " ";
    405       Log() << Verbose(0) << endl;
    406     }
    407     Log() << Verbose(0) << endl;
     409        DoLog(0) && (Log() << Verbose(0) << InertiaTensor[i*NDIM+j] << " ");
     410      DoLog(0) && (Log() << Verbose(0) << endl);
     411    }
     412    DoLog(0) && (Log() << Verbose(0) << endl);
    408413  }
    409414
     
    428433
    429434  // rotate on z-x plane
    430   Log() << Verbose(0) << "Begin of Aligning all atoms." << endl;
     435  DoLog(0) && (Log() << Verbose(0) << "Begin of Aligning all atoms." << endl);
    431436  alpha = atan(-n->x[0]/n->x[2]);
    432   Log() << Verbose(1) << "Z-X-angle: " << alpha << " ... ";
     437  DoLog(1) && (Log() << Verbose(1) << "Z-X-angle: " << alpha << " ... ");
    433438  while (ptr->next != end) {
    434439    ptr = ptr->next;
     
    446451  n->x[0] =  cos(alpha) * tmp +  sin(alpha) * n->x[2];
    447452  n->x[2] = -sin(alpha) * tmp +  cos(alpha) * n->x[2];
    448   Log() << Verbose(1) << "alignment vector after first rotation: ";
     453  DoLog(1) && (Log() << Verbose(1) << "alignment vector after first rotation: ");
    449454  n->Output();
    450   Log() << Verbose(0) << endl;
     455  DoLog(0) && (Log() << Verbose(0) << endl);
    451456
    452457  // rotate on z-y plane
    453458  ptr = start;
    454459  alpha = atan(-n->x[1]/n->x[2]);
    455   Log() << Verbose(1) << "Z-Y-angle: " << alpha << " ... ";
     460  DoLog(1) && (Log() << Verbose(1) << "Z-Y-angle: " << alpha << " ... ");
    456461  while (ptr->next != end) {
    457462    ptr = ptr->next;
     
    470475  n->x[2] = -sin(alpha) * tmp +  cos(alpha) * n->x[2];
    471476
    472   Log() << Verbose(1) << "alignment vector after second rotation: ";
     477  DoLog(1) && (Log() << Verbose(1) << "alignment vector after second rotation: ");
    473478  n->Output();
    474   Log() << Verbose(1) << endl;
    475   Log() << Verbose(0) << "End of Aligning all atoms." << endl;
     479  DoLog(1) && (Log() << Verbose(1) << endl);
     480  DoLog(0) && (Log() << Verbose(0) << "End of Aligning all atoms." << endl);
    476481};
    477482
  • src/molecule_graph.cpp

    r13d5a9 r5f612ee  
    1717#include "memoryallocator.hpp"
    1818#include "molecule.hpp"
     19#include "World.hpp"
    1920
    2021struct BFSAccounting
     
    5859
    5960  if (!input) {
    60     Log() << Verbose(1) << "Opening silica failed \n";
     61    DoLog(1) && (Log() << Verbose(1) << "Opening silica failed \n");
    6162  };
    6263
    6364  *input >> ws >> atom1;
    6465  *input >> ws >> atom2;
    65   Log() << Verbose(1) << "Scanning file\n";
     66  DoLog(1) && (Log() << Verbose(1) << "Scanning file\n");
    6667  while (!input->eof()) // Check whether we read everything already
    6768  {
     
    106107  LinkedCell *LC = NULL;
    107108  bool free_BG = false;
     109  double * const cell_size = World::getInstance().getDomain();
    108110
    109111  if (BG == NULL) {
     
    113115
    114116  BondDistance = bonddistance; // * ((IsAngstroem) ? 1. : 1./AtomicLengthToAngstroem);
    115   Log() << Verbose(0) << "Begin of CreateAdjacencyList." << endl;
     117  DoLog(0) && (Log() << Verbose(0) << "Begin of CreateAdjacencyList." << endl);
    116118  // remove every bond from the list
    117119  bond *Binder = NULL;
     
    126128  // count atoms in molecule = dimension of matrix (also give each unique name and continuous numbering)
    127129  CountAtoms();
    128   Log() << Verbose(1) << "AtomCount " << AtomCount << " and bonddistance is " << bonddistance << "." << endl;
     130  DoLog(1) && (Log() << Verbose(1) << "AtomCount " << AtomCount << " and bonddistance is " << bonddistance << "." << endl);
    129131
    130132  if ((AtomCount > 1) && (bonddistance > 1.)) {
    131     Log() << Verbose(2) << "Creating Linked Cell structure ... " << endl;
     133    DoLog(2) && (Log() << Verbose(2) << "Creating Linked Cell structure ... " << endl);
    132134    LC = new LinkedCell(this, bonddistance);
    133135
    134136    // create a list to map Tesselpoint::nr to atom *
    135     Log() << Verbose(2) << "Creating TesselPoint to atom map ... " << endl;
     137    DoLog(2) && (Log() << Verbose(2) << "Creating TesselPoint to atom map ... " << endl);
    136138    AtomMap = Calloc<atom *> (AtomCount, "molecule::CreateAdjacencyList - **AtomCount");
    137139    Walker = start;
     
    142144
    143145    // 3a. go through every cell
    144     Log() << Verbose(2) << "Celling ... " << endl;
     146    DoLog(2) && (Log() << Verbose(2) << "Celling ... " << endl);
    145147    for (LC->n[0] = 0; LC->n[0] < LC->N[0]; LC->n[0]++)
    146148      for (LC->n[1] = 0; LC->n[1] < LC->N[1]; LC->n[1]++)
    147149        for (LC->n[2] = 0; LC->n[2] < LC->N[2]; LC->n[2]++) {
    148           const LinkedNodes *List = LC->GetCurrentCell();
    149           //Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;
     150          const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
     151//          Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;
    150152          if (List != NULL) {
    151             for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
     153            for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    152154              Walker = AtomMap[(*Runner)->nr];
    153               //Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl;
     155//              Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl;
    154156              // 3c. check for possible bond between each atom in this and every one in the 27 cells
    155157              for (n[0] = -1; n[0] <= 1; n[0]++)
    156158                for (n[1] = -1; n[1] <= 1; n[1]++)
    157159                  for (n[2] = -1; n[2] <= 1; n[2]++) {
    158                     const LinkedNodes *OtherList = LC->GetRelativeToCurrentCell(n);
    159                     //Log() << Verbose(2) << "Current relative cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;
     160                    const LinkedCell::LinkedNodes *OtherList = LC->GetRelativeToCurrentCell(n);
     161//                    Log() << Verbose(2) << "Current relative cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;
    160162                    if (OtherList != NULL) {
    161                       for (LinkedNodes::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) {
     163                      for (LinkedCell::LinkedNodes::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) {
    162164                        if ((*OtherRunner)->nr > Walker->nr) {
    163165                          OtherWalker = AtomMap[(*OtherRunner)->nr];
    164                           //Log() << Verbose(1) << "Checking distance " << OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size) << " against typical bond length of " << bonddistance*bonddistance << "." << endl;
     166//                          Log() << Verbose(0) << "Current other Atom is " << *OtherWalker << "." << endl;
     167                          const double distance = OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size);
     168//                          Log() << Verbose(1) << "Checking distance " << distance << " against typical bond length of " << bonddistance*bonddistance << "." << endl;
    165169                          (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem);
    166                           const double distance = OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size);
    167170                          const bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance);
    168                           if ((OtherWalker->father->nr > Walker->father->nr) && (status)) { // create bond if distance is smaller
    169                             //Log() << Verbose(1) << "Adding Bond between " << *Walker << " and " << *OtherWalker << " in distance " << sqrt(distance) << "." << endl;
    170                             AddBond(Walker->father, OtherWalker->father, 1); // also increases molecule::BondCount
     171//                          Log() << Verbose(1) << "MinDistance is " << MinDistance << " and MaxDistance is " << MaxDistance << "." << endl;
     172                          if (OtherWalker->father->nr > Walker->father->nr) {
     173                            if (status) { // create bond if distance is smaller
     174//                              Log() << Verbose(1) << "Adding Bond between " << *Walker << " and " << *OtherWalker << " in distance " << sqrt(distance) << "." << endl;
     175                              AddBond(Walker->father, OtherWalker->father, 1); // also increases molecule::BondCount
     176                            } else {
     177//                              Log() << Verbose(1) << "Not Adding: distance too great." << endl;
     178                            }
    171179                          } else {
    172                             //Log() << Verbose(1) << "Not Adding: Wrong label order or distance too great." << endl;
     180//                            Log() << Verbose(1) << "Not Adding: Wrong order of labels." << endl;
    173181                          }
    174182                        }
     
    181189    Free(&AtomMap);
    182190    delete (LC);
    183     Log() << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << BondDistance << "." << endl;
     191    DoLog(1) && (Log() << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << BondDistance << "." << endl);
    184192
    185193    // correct bond degree by comparing valence and bond degree
    186     Log() << Verbose(2) << "Correcting bond degree ... " << endl;
     194    DoLog(2) && (Log() << Verbose(2) << "Correcting bond degree ... " << endl);
    187195    CorrectBondDegree();
    188196
     
    190198    ActOnAllAtoms( &atom::OutputBondOfAtom );
    191199  } else
    192     Log() << Verbose(1) << "AtomCount is " << AtomCount << ", thus no bonds, no connections!." << endl;
    193   Log() << Verbose(0) << "End of CreateAdjacencyList." << endl;
     200    DoLog(1) && (Log() << Verbose(1) << "AtomCount is " << AtomCount << ", thus no bonds, no connections!." << endl);
     201  DoLog(0) && (Log() << Verbose(0) << "End of CreateAdjacencyList." << endl);
    194202  if (free_BG)
    195203    delete(BG);
     
    202210void molecule::OutputBondsList() const
    203211{
    204   Log() << Verbose(1) << endl << "From contents of bond chain list:";
     212  DoLog(1) && (Log() << Verbose(1) << endl << "From contents of bond chain list:");
    205213  bond *Binder = first;
    206214  while (Binder->next != last) {
    207215    Binder = Binder->next;
    208     Log() << Verbose(0) << *Binder << "\t" << endl;
    209   }
    210   Log() << Verbose(0) << endl;
     216    DoLog(0) && (Log() << Verbose(0) << *Binder << "\t" << endl);
     217  }
     218  DoLog(0) && (Log() << Verbose(0) << endl);
    211219}
    212220;
     
    225233
    226234  if (BondCount != 0) {
    227     Log() << Verbose(1) << "Correcting Bond degree of each bond ... " << endl;
     235    DoLog(1) && (Log() << Verbose(1) << "Correcting Bond degree of each bond ... " << endl);
    228236    do {
    229237      OldNo = No;
    230238      No = SumPerAtom( &atom::CorrectBondDegree );
    231239    } while (OldNo != No);
    232     Log() << Verbose(0) << " done." << endl;
     240    DoLog(0) && (Log() << Verbose(0) << " done." << endl);
    233241  } else {
    234     Log() << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << AtomCount << " atoms." << endl;
    235   }
    236   Log() << Verbose(0) << No << " bonds could not be corrected." << endl;
     242    DoLog(1) && (Log() << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << AtomCount << " atoms." << endl);
     243  }
     244  DoLog(0) && (Log() << Verbose(0) << No << " bonds could not be corrected." << endl);
    237245
    238246  return (No);
     
    253261  bond *Binder = first;
    254262  if ((Binder->next != last) && (Binder->next->Type == Undetermined)) {
    255     Log() << Verbose(0) << "No Depth-First-Search analysis performed so far, calling ..." << endl;
     263    DoLog(0) && (Log() << Verbose(0) << "No Depth-First-Search analysis performed so far, calling ..." << endl);
    256264    Subgraphs = DepthFirstSearchAnalysis(BackEdgeStack);
    257265    while (Subgraphs->next != NULL) {
     
    308316    Walker->GraphNr = DFS.CurrentGraphNr;
    309317    Walker->LowpointNr = DFS.CurrentGraphNr;
    310     Log() << Verbose(1) << "Setting Walker[" << Walker->Name << "]'s number to " << Walker->GraphNr << " with Lowpoint " << Walker->LowpointNr << "." << endl;
     318    DoLog(1) && (Log() << Verbose(1) << "Setting Walker[" << Walker->Name << "]'s number to " << Walker->GraphNr << " with Lowpoint " << Walker->LowpointNr << "." << endl);
    311319    DFS.AtomStack->Push(Walker);
    312320    DFS.CurrentGraphNr++;
     
    335343    if (Binder == NULL)
    336344      break;
    337     Log() << Verbose(2) << "Current Unused Bond is " << *Binder << "." << endl;
     345    DoLog(2) && (Log() << Verbose(2) << "Current Unused Bond is " << *Binder << "." << endl);
    338346    // (4) Mark Binder used, ...
    339347    Binder->MarkUsed(black);
    340348    OtherAtom = Binder->GetOtherAtom(Walker);
    341     Log() << Verbose(2) << "(4) OtherAtom is " << OtherAtom->Name << "." << endl;
     349    DoLog(2) && (Log() << Verbose(2) << "(4) OtherAtom is " << OtherAtom->Name << "." << endl);
    342350    if (OtherAtom->GraphNr != -1) {
    343351      // (4a) ... if "other" atom has been visited (GraphNr != 0), set lowpoint to minimum of both, go to (3)
     
    345353      DFS.BackEdgeStack->Push(Binder);
    346354      Walker->LowpointNr = (Walker->LowpointNr < OtherAtom->GraphNr) ? Walker->LowpointNr : OtherAtom->GraphNr;
    347       Log() << Verbose(3) << "(4a) Visited: Setting Lowpoint of Walker[" << Walker->Name << "] to " << Walker->LowpointNr << "." << endl;
     355      DoLog(3) && (Log() << Verbose(3) << "(4a) Visited: Setting Lowpoint of Walker[" << Walker->Name << "] to " << Walker->LowpointNr << "." << endl);
    348356    } else {
    349357      // (4b) ... otherwise set OtherAtom as Ancestor of Walker and Walker as OtherAtom, go to (2)
     
    351359      OtherAtom->Ancestor = Walker;
    352360      Walker = OtherAtom;
    353       Log() << Verbose(3) << "(4b) Not Visited: OtherAtom[" << OtherAtom->Name << "]'s Ancestor is now " << OtherAtom->Ancestor->Name << ", Walker is OtherAtom " << OtherAtom->Name << "." << endl;
     361      DoLog(3) && (Log() << Verbose(3) << "(4b) Not Visited: OtherAtom[" << OtherAtom->Name << "]'s Ancestor is now " << OtherAtom->Ancestor->Name << ", Walker is OtherAtom " << OtherAtom->Name << "." << endl);
    354362      break;
    355363    }
     
    373381
    374382  // (5) if Ancestor of Walker is ...
    375   Log() << Verbose(1) << "(5) Number of Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "] is " << Walker->Ancestor->GraphNr << "." << endl;
     383  DoLog(1) && (Log() << Verbose(1) << "(5) Number of Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "] is " << Walker->Ancestor->GraphNr << "." << endl);
    376384
    377385  if (Walker->Ancestor->GraphNr != DFS.Root->GraphNr) {
     
    380388      // (6a) set Ancestor's Lowpoint number to minimum of of its Ancestor and itself, go to Step(8)
    381389      Walker->Ancestor->LowpointNr = (Walker->Ancestor->LowpointNr < Walker->LowpointNr) ? Walker->Ancestor->LowpointNr : Walker->LowpointNr;
    382       Log() << Verbose(2) << "(6) Setting Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "]'s Lowpoint to " << Walker->Ancestor->LowpointNr << "." << endl;
     390      DoLog(2) && (Log() << Verbose(2) << "(6) Setting Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "]'s Lowpoint to " << Walker->Ancestor->LowpointNr << "." << endl);
    383391    } else {
    384392      // (7) (Ancestor of Walker is a separating vertex, remove all from stack till Walker (including), these and Ancestor form a component
    385393      Walker->Ancestor->SeparationVertex = true;
    386       Log() << Verbose(2) << "(7) Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "]'s is a separating vertex, creating component." << endl;
     394      DoLog(2) && (Log() << Verbose(2) << "(7) Walker[" << Walker->Name << "]'s Ancestor[" << Walker->Ancestor->Name << "]'s is a separating vertex, creating component." << endl);
    387395      mol->SetNextComponentNumber(Walker->Ancestor, DFS.ComponentNumber);
    388       Log() << Verbose(3) << "(7) Walker[" << Walker->Name << "]'s Ancestor's Compont is " << DFS.ComponentNumber << "." << endl;
     396      DoLog(3) && (Log() << Verbose(3) << "(7) Walker[" << Walker->Name << "]'s Ancestor's Compont is " << DFS.ComponentNumber << "." << endl);
    389397      mol->SetNextComponentNumber(Walker, DFS.ComponentNumber);
    390       Log() << Verbose(3) << "(7) Walker[" << Walker->Name << "]'s Compont is " << DFS.ComponentNumber << "." << endl;
     398      DoLog(3) && (Log() << Verbose(3) << "(7) Walker[" << Walker->Name << "]'s Compont is " << DFS.ComponentNumber << "." << endl);
    391399      do {
    392400        OtherAtom = DFS.AtomStack->PopLast();
    393401        LeafWalker->Leaf->AddCopyAtom(OtherAtom);
    394402        mol->SetNextComponentNumber(OtherAtom, DFS.ComponentNumber);
    395         Log() << Verbose(3) << "(7) Other[" << OtherAtom->Name << "]'s Compont is " << DFS.ComponentNumber << "." << endl;
     403        DoLog(3) && (Log() << Verbose(3) << "(7) Other[" << OtherAtom->Name << "]'s Compont is " << DFS.ComponentNumber << "." << endl);
    396404      } while (OtherAtom != Walker);
    397405      DFS.ComponentNumber++;
    398406    }
    399407    // (8) Walker becomes its Ancestor, go to (3)
    400     Log() << Verbose(2) << "(8) Walker[" << Walker->Name << "] is now its Ancestor " << Walker->Ancestor->Name << ", backstepping. " << endl;
     408    DoLog(2) && (Log() << Verbose(2) << "(8) Walker[" << Walker->Name << "] is now its Ancestor " << Walker->Ancestor->Name << ", backstepping. " << endl);
    401409    Walker = Walker->Ancestor;
    402410    DFS.BackStepping = true;
     
    422430    //DFS.AtomStack->Output(out);
    423431    mol->SetNextComponentNumber(DFS.Root, DFS.ComponentNumber);
    424     Log() << Verbose(3) << "(9) Root[" << DFS.Root->Name << "]'s Component is " << DFS.ComponentNumber << "." << endl;
     432    DoLog(3) && (Log() << Verbose(3) << "(9) Root[" << DFS.Root->Name << "]'s Component is " << DFS.ComponentNumber << "." << endl);
    425433    mol->SetNextComponentNumber(Walker, DFS.ComponentNumber);
    426     Log() << Verbose(3) << "(9) Walker[" << Walker->Name << "]'s Component is " << DFS.ComponentNumber << "." << endl;
     434    DoLog(3) && (Log() << Verbose(3) << "(9) Walker[" << Walker->Name << "]'s Component is " << DFS.ComponentNumber << "." << endl);
    427435    do {
    428436      OtherAtom = DFS.AtomStack->PopLast();
    429437      LeafWalker->Leaf->AddCopyAtom(OtherAtom);
    430438      mol->SetNextComponentNumber(OtherAtom, DFS.ComponentNumber);
    431       Log() << Verbose(3) << "(7) Other[" << OtherAtom->Name << "]'s Compont is " << DFS.ComponentNumber << "." << endl;
     439      DoLog(3) && (Log() << Verbose(3) << "(7) Other[" << OtherAtom->Name << "]'s Compont is " << DFS.ComponentNumber << "." << endl);
    432440    } while (OtherAtom != Walker);
    433441    DFS.ComponentNumber++;
     
    436444    Walker = DFS.Root;
    437445    Binder = mol->FindNextUnused(Walker);
    438     Log() << Verbose(1) << "(10) Walker is Root[" << DFS.Root->Name << "], next Unused Bond is " << Binder << "." << endl;
     446    DoLog(1) && (Log() << Verbose(1) << "(10) Walker is Root[" << DFS.Root->Name << "], next Unused Bond is " << Binder << "." << endl);
    439447    if (Binder != NULL) { // Root is separation vertex
    440       Log() << Verbose(1) << "(11) Root is a separation vertex." << endl;
     448      DoLog(1) && (Log() << Verbose(1) << "(11) Root is a separation vertex." << endl);
    441449      Walker->SeparationVertex = true;
    442450    }
     
    493501  bond *Binder = NULL;
    494502
    495   Log() << Verbose(0) << "Begin of DepthFirstSearchAnalysis" << endl;
     503  if (AtomCount == 0)
     504    return SubGraphs;
     505  DoLog(0) && (Log() << Verbose(0) << "Begin of DepthFirstSearchAnalysis" << endl);
    496506  DepthFirstSearchAnalysis_Init(DFS, this);
    497507
     
    503513    // put into new subgraph molecule and add this to list of subgraphs
    504514    LeafWalker = new MoleculeLeafClass(LeafWalker);
    505     LeafWalker->Leaf = new molecule(elemente);
     515    LeafWalker->Leaf = World::getInstance().createMolecule();
    506516    LeafWalker->Leaf->AddCopyAtom(DFS.Root);
    507517
     
    515525
    516526        if (Binder == NULL) {
    517           Log() << Verbose(2) << "No more Unused Bonds." << endl;
     527          DoLog(2) && (Log() << Verbose(2) << "No more Unused Bonds." << endl);
    518528          break;
    519529        } else
     
    532542
    533543    // From OldGraphNr to CurrentGraphNr ranges an disconnected subgraph
    534     Log() << Verbose(0) << "Disconnected subgraph ranges from " << OldGraphNr << " to " << DFS.CurrentGraphNr << "." << endl;
     544    DoLog(0) && (Log() << Verbose(0) << "Disconnected subgraph ranges from " << OldGraphNr << " to " << DFS.CurrentGraphNr << "." << endl);
    535545    LeafWalker->Leaf->Output((ofstream *)&cout);
    536     Log() << Verbose(0) << endl;
     546    DoLog(0) && (Log() << Verbose(0) << endl);
    537547
    538548    // step on to next root
     
    552562  // free all and exit
    553563  DepthFirstSearchAnalysis_Finalize(DFS);
    554   Log() << Verbose(0) << "End of DepthFirstSearchAnalysis" << endl;
     564  DoLog(0) && (Log() << Verbose(0) << "End of DepthFirstSearchAnalysis" << endl);
    555565  return SubGraphs;
    556566}
     
    578588void molecule::OutputGraphInfoPerAtom() const
    579589{
    580   Log() << Verbose(1) << "Final graph info for each atom is:" << endl;
     590  DoLog(1) && (Log() << Verbose(1) << "Final graph info for each atom is:" << endl);
    581591  ActOnAllAtoms( &atom::OutputGraphInfo );
    582592}
     
    588598void molecule::OutputGraphInfoPerBond() const
    589599{
    590   Log() << Verbose(1) << "Final graph info for each bond is:" << endl;
     600  DoLog(1) && (Log() << Verbose(1) << "Final graph info for each bond is:" << endl);
    591601  bond *Binder = first;
    592602  while (Binder->next != last) {
    593603    Binder = Binder->next;
    594     Log() << Verbose(2) << ((Binder->Type == TreeEdge) ? "TreeEdge " : "BackEdge ") << *Binder << ": <";
    595     Log() << Verbose(0) << ((Binder->leftatom->SeparationVertex) ? "SP," : "") << "L" << Binder->leftatom->LowpointNr << " G" << Binder->leftatom->GraphNr << " Comp.";
     604    DoLog(2) && (Log() << Verbose(2) << ((Binder->Type == TreeEdge) ? "TreeEdge " : "BackEdge ") << *Binder << ": <");
     605    DoLog(0) && (Log() << Verbose(0) << ((Binder->leftatom->SeparationVertex) ? "SP," : "") << "L" << Binder->leftatom->LowpointNr << " G" << Binder->leftatom->GraphNr << " Comp.");
    596606    Binder->leftatom->OutputComponentNumber();
    597     Log() << Verbose(0) << " ===  ";
    598     Log() << Verbose(0) << ((Binder->rightatom->SeparationVertex) ? "SP," : "") << "L" << Binder->rightatom->LowpointNr << " G" << Binder->rightatom->GraphNr << " Comp.";
     607    DoLog(0) && (Log() << Verbose(0) << " ===  ");
     608    DoLog(0) && (Log() << Verbose(0) << ((Binder->rightatom->SeparationVertex) ? "SP," : "") << "L" << Binder->rightatom->LowpointNr << " G" << Binder->rightatom->GraphNr << " Comp.");
    599609    Binder->rightatom->OutputComponentNumber();
    600     Log() << Verbose(0) << ">." << endl;
     610    DoLog(0) && (Log() << Verbose(0) << ">." << endl);
    601611    if (Binder->Cyclic) // cyclic ??
    602       Log() << Verbose(3) << "Lowpoint at each side are equal: CYCLIC!" << endl;
     612      DoLog(3) && (Log() << Verbose(3) << "Lowpoint at each side are equal: CYCLIC!" << endl);
    603613  }
    604614}
     
    674684  do { // look for Root
    675685    Walker = BFS.BFSStack->PopFirst();
    676     Log() << Verbose(2) << "Current Walker is " << *Walker << ", we look for SP to Root " << *BFS.Root << "." << endl;
     686    DoLog(2) && (Log() << Verbose(2) << "Current Walker is " << *Walker << ", we look for SP to Root " << *BFS.Root << "." << endl);
    677687    for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
    678688      if ((*Runner) != BackEdge) { // only walk along DFS spanning tree (otherwise we always find SP of one being backedge Binder)
     
    681691        if (OtherAtom->type->Z != 1) {
    682692#endif
    683         Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->Name << " for bond " << *(*Runner) << "." << endl;
     693        DoLog(2) && (Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->Name << " for bond " << *(*Runner) << "." << endl);
    684694        if (BFS.ColorList[OtherAtom->nr] == white) {
    685695          BFS.TouchedStack->Push(OtherAtom);
     
    687697          BFS.PredecessorList[OtherAtom->nr] = Walker; // Walker is the predecessor
    688698          BFS.ShortestPathList[OtherAtom->nr] = BFS.ShortestPathList[Walker->nr] + 1;
    689           Log() << Verbose(2) << "Coloring OtherAtom " << OtherAtom->Name << " lightgray, its predecessor is " << Walker->Name << " and its Shortest Path is " << BFS.ShortestPathList[OtherAtom->nr] << " egde(s) long." << endl;
     699          DoLog(2) && (Log() << Verbose(2) << "Coloring OtherAtom " << OtherAtom->Name << " lightgray, its predecessor is " << Walker->Name << " and its Shortest Path is " << BFS.ShortestPathList[OtherAtom->nr] << " egde(s) long." << endl);
    690700          //if (BFS.ShortestPathList[OtherAtom->nr] < MinimumRingSize[Walker->GetTrueFather()->nr]) { // Check for maximum distance
    691           Log() << Verbose(3) << "Putting OtherAtom into queue." << endl;
     701          DoLog(3) && (Log() << Verbose(3) << "Putting OtherAtom into queue." << endl);
    692702          BFS.BFSStack->Push(OtherAtom);
    693703          //}
    694704        } else {
    695           Log() << Verbose(3) << "Not Adding, has already been visited." << endl;
     705          DoLog(3) && (Log() << Verbose(3) << "Not Adding, has already been visited." << endl);
    696706        }
    697707        if (OtherAtom == BFS.Root)
     
    699709#ifdef ADDHYDROGEN
    700710      } else {
    701         Log() << Verbose(2) << "Skipping hydrogen atom " << *OtherAtom << "." << endl;
     711        DoLog(2) && (Log() << Verbose(2) << "Skipping hydrogen atom " << *OtherAtom << "." << endl);
    702712        BFS.ColorList[OtherAtom->nr] = black;
    703713      }
    704714#endif
    705715      } else {
    706         Log() << Verbose(2) << "Bond " << *(*Runner) << " not Visiting, is the back edge." << endl;
     716        DoLog(2) && (Log() << Verbose(2) << "Bond " << *(*Runner) << " not Visiting, is the back edge." << endl);
    707717      }
    708718    }
    709719    BFS.ColorList[Walker->nr] = black;
    710     Log() << Verbose(1) << "Coloring Walker " << Walker->Name << " black." << endl;
     720    DoLog(1) && (Log() << Verbose(1) << "Coloring Walker " << Walker->Name << " black." << endl);
    711721    if (OtherAtom == BFS.Root) { // if we have found the root, check whether this cycle wasn't already found beforehand
    712722      // step through predecessor list
     
    718728      }
    719729      if (OtherAtom == BackEdge->rightatom) { // if each atom in found cycle is cyclic, loop's been found before already
    720         Log() << Verbose(3) << "This cycle was already found before, skipping and removing seeker from search." << endl;
     730        DoLog(3) && (Log() << Verbose(3) << "This cycle was already found before, skipping and removing seeker from search." << endl);
    721731        do {
    722732          OtherAtom = BFS.TouchedStack->PopLast();
    723733          if (BFS.PredecessorList[OtherAtom->nr] == Walker) {
    724             Log() << Verbose(4) << "Removing " << *OtherAtom << " from lists and stacks." << endl;
     734            DoLog(4) && (Log() << Verbose(4) << "Removing " << *OtherAtom << " from lists and stacks." << endl);
    725735            BFS.PredecessorList[OtherAtom->nr] = NULL;
    726736            BFS.ShortestPathList[OtherAtom->nr] = -1;
     
    756766    RingSize = 1;
    757767    BFS.Root->GetTrueFather()->IsCyclic = true;
    758     Log() << Verbose(1) << "Found ring contains: ";
     768    DoLog(1) && (Log() << Verbose(1) << "Found ring contains: ");
    759769    Walker = BFS.Root;
    760770    while (Walker != BackEdge->rightatom) {
    761       Log() << Verbose(0) << Walker->Name << " <-> ";
     771      DoLog(0) && (Log() << Verbose(0) << Walker->Name << " <-> ");
    762772      Walker = BFS.PredecessorList[Walker->nr];
    763773      Walker->GetTrueFather()->IsCyclic = true;
    764774      RingSize++;
    765775    }
    766     Log() << Verbose(0) << Walker->Name << "  with a length of " << RingSize << "." << endl << endl;
     776    DoLog(0) && (Log() << Verbose(0) << Walker->Name << "  with a length of " << RingSize << "." << endl << endl);
    767777    // walk through all and set MinimumRingSize
    768778    Walker = BFS.Root;
     
    776786      MinRingSize = RingSize;
    777787  } else {
    778     Log() << Verbose(1) << "No ring containing " << *BFS.Root << " with length equal to or smaller than " << MinimumRingSize[Walker->GetTrueFather()->nr] << " found." << endl;
     788    DoLog(1) && (Log() << Verbose(1) << "No ring containing " << *BFS.Root << " with length equal to or smaller than " << MinimumRingSize[Walker->GetTrueFather()->nr] << " found." << endl);
    779789  }
    780790};
     
    854864
    855865      }
    856       Log() << Verbose(1) << "Minimum ring size of " << *Root << " is " << MinimumRingSize[Root->GetTrueFather()->nr] << "." << endl;
    857     }
    858     Log() << Verbose(1) << "Minimum ring size is " << MinRingSize << ", over " << NumCycles << " cycles total." << endl;
     866      DoLog(1) && (Log() << Verbose(1) << "Minimum ring size of " << *Root << " is " << MinimumRingSize[Root->GetTrueFather()->nr] << "." << endl);
     867    }
     868    DoLog(1) && (Log() << Verbose(1) << "Minimum ring size is " << MinRingSize << ", over " << NumCycles << " cycles total." << endl);
    859869  } else
    860     Log() << Verbose(1) << "No rings were detected in the molecular structure." << endl;
     870    DoLog(1) && (Log() << Verbose(1) << "No rings were detected in the molecular structure." << endl);
    861871}
    862872;
     
    886896  //BackEdgeStack->Output(out);
    887897
    888   Log() << Verbose(1) << "Analysing cycles ... " << endl;
     898  DoLog(1) && (Log() << Verbose(1) << "Analysing cycles ... " << endl);
    889899  NumCycles = 0;
    890900  while (!BackEdgeStack->IsEmpty()) {
     
    897907    ResetBFSAccounting(Walker, BFS);
    898908
    899     Log() << Verbose(1) << "---------------------------------------------------------------------------------------------------------" << endl;
     909    DoLog(1) && (Log() << Verbose(1) << "---------------------------------------------------------------------------------------------------------" << endl);
    900910    OtherAtom = NULL;
    901911    CyclicStructureAnalysis_CyclicBFSFromRootToRoot(BackEdge, BFS);
     
    927937    }
    928938    if (i == vertex->ListOfBonds.size()) {
    929       eLog() << Verbose(0) << "Error: All Component entries are already occupied!" << endl;
     939      DoeLog(0) && (eLog()<< Verbose(0) << "Error: All Component entries are already occupied!" << endl);
    930940      performCriticalExit();
    931941    }
    932942  } else {
    933     eLog() << Verbose(0) << "Error: Given vertex is NULL!" << endl;
     943    DoeLog(0) && (eLog()<< Verbose(0) << "Error: Given vertex is NULL!" << endl);
    934944    performCriticalExit();
    935945  }
     
    969979void OutputAlreadyVisited(int *list)
    970980{
    971   Log() << Verbose(4) << "Already Visited Bonds:\t";
     981  DoLog(4) && (Log() << Verbose(4) << "Already Visited Bonds:\t");
    972982  for (int i = 1; i <= list[0]; i++)
    973     Log() << Verbose(0) << list[i] << "  ";
    974   Log() << Verbose(0) << endl;
     983    DoLog(0) && (Log() << Verbose(0) << list[i] << "  ");
     984  DoLog(0) && (Log() << Verbose(0) << endl);
    975985}
    976986;
     
    978988/** Storing the bond structure of a molecule to file.
    979989 * Simply stores Atom::nr and then the Atom::nr of all bond partners per line.
    980  * \param *out output stream for debugging
    981990 * \param *path path to file
     991 * \param *filename name of file
    982992 * \return true - file written successfully, false - writing failed
    983993 */
    984 bool molecule::StoreAdjacencyToFile(char *path)
     994bool molecule::StoreAdjacencyToFile(char *path, char *filename)
    985995{
    986996  ofstream AdjacencyFile;
     
    988998  bool status = true;
    989999
    990   line << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE;
     1000  if (path != NULL)
     1001    line << path << "/" << filename;
     1002  else
     1003    line << filename;
    9911004  AdjacencyFile.open(line.str().c_str(), ios::out);
    992   Log() << Verbose(1) << "Saving adjacency list ... ";
     1005  DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... ");
    9931006  if (AdjacencyFile != NULL) {
    9941007    AdjacencyFile << "m\tn" << endl;
    9951008    ActOnAllAtoms(&atom::OutputAdjacency, &AdjacencyFile);
    9961009    AdjacencyFile.close();
    997     Log() << Verbose(1) << "done." << endl;
     1010    DoLog(1) && (Log() << Verbose(1) << "done." << endl);
    9981011  } else {
    999     Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl;
     1012    DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl);
    10001013    status = false;
    10011014  }
     
    10071020/** Storing the bond structure of a molecule to file.
    10081021 * Simply stores Atom::nr and then the Atom::nr of all bond partners, one per line.
    1009  * \param *out output stream for debugging
    10101022 * \param *path path to file
     1023 * \param *filename name of file
    10111024 * \return true - file written successfully, false - writing failed
    10121025 */
    1013 bool molecule::StoreBondsToFile(char *path)
     1026bool molecule::StoreBondsToFile(char *path, char *filename)
    10141027{
    10151028  ofstream BondFile;
     
    10171030  bool status = true;
    10181031
    1019   line << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE;
     1032  if (path != NULL)
     1033    line << path << "/" << filename;
     1034  else
     1035    line << filename;
    10201036  BondFile.open(line.str().c_str(), ios::out);
    1021   Log() << Verbose(1) << "Saving adjacency list ... ";
     1037  DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... ");
    10221038  if (BondFile != NULL) {
    10231039    BondFile << "m\tn" << endl;
    10241040    ActOnAllAtoms(&atom::OutputBonds, &BondFile);
    10251041    BondFile.close();
    1026     Log() << Verbose(1) << "done." << endl;
     1042    DoLog(1) && (Log() << Verbose(1) << "done." << endl);
    10271043  } else {
    1028     Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl;
     1044    DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl);
    10291045    status = false;
    10301046  }
     
    10391055  filename << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE;
    10401056  File.open(filename.str().c_str(), ios::out);
    1041   Log() << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... ";
     1057  DoLog(1) && (Log() << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... ");
    10421058  if (File == NULL)
    10431059    return false;
     
    10801096    //Log() << Verbose(0) << endl;
    10811097  } else {
    1082     Log() << Verbose(0) << "Number of bonds for Atom " << *Walker << " does not match, parsed " << CurrentBondsOfAtom << " against " << Walker->ListOfBonds.size() << "." << endl;
     1098    DoLog(0) && (Log() << Verbose(0) << "Number of bonds for Atom " << *Walker << " does not match, parsed " << CurrentBondsOfAtom << " against " << Walker->ListOfBonds.size() << "." << endl);
    10831099    status = false;
    10841100  }
     
    11031119
    11041120  if (!CheckAdjacencyFileAgainstMolecule_Init(path, File, CurrentBonds)) {
    1105     Log() << Verbose(1) << "Adjacency file not found." << endl;
     1121    DoLog(1) && (Log() << Verbose(1) << "Adjacency file not found." << endl);
    11061122    return true;
    11071123  }
     
    11291145
    11301146  if (status) { // if equal we parse the KeySetFile
    1131     Log() << Verbose(1) << "done: Equal." << endl;
     1147    DoLog(1) && (Log() << Verbose(1) << "done: Equal." << endl);
    11321148  } else
    1133     Log() << Verbose(1) << "done: Not equal by " << NonMatchNumber << " atoms." << endl;
     1149    DoLog(1) && (Log() << Verbose(1) << "done: Not equal by " << NonMatchNumber << " atoms." << endl);
    11341150  return status;
    11351151}
     
    11471163  bool status = true;
    11481164  if (ReferenceStack->IsEmpty()) {
    1149     Log() << Verbose(1) << "ReferenceStack is empty!" << endl;
     1165    DoLog(1) && (Log() << Verbose(1) << "ReferenceStack is empty!" << endl);
    11501166    return false;
    11511167  }
     
    11621178        if (OtherAtom == ListOfLocalAtoms[(*Runner)->rightatom->nr]) { // found the bond
    11631179          LocalStack->Push((*Runner));
    1164           Log() << Verbose(3) << "Found local edge " << *(*Runner) << "." << endl;
     1180          DoLog(3) && (Log() << Verbose(3) << "Found local edge " << *(*Runner) << "." << endl);
    11651181          break;
    11661182        }
    11671183      }
    11681184    Binder = ReferenceStack->PopFirst(); // loop the stack for next item
    1169     Log() << Verbose(3) << "Current candidate edge " << Binder << "." << endl;
     1185    DoLog(3) && (Log() << Verbose(3) << "Current candidate edge " << Binder << "." << endl);
    11701186    ReferenceStack->Push(Binder);
    11711187  } while (FirstBond != Binder);
     
    12161232  BFS.PredecessorList[OtherAtom->nr] = Walker; // Walker is the predecessor
    12171233  BFS.ShortestPathList[OtherAtom->nr] = BFS.ShortestPathList[Walker->nr] + 1;
    1218   Log() << Verbose(2) << "Coloring OtherAtom " << OtherAtom->Name << " " << ((BFS.ColorList[OtherAtom->nr] == white) ? "white" : "lightgray") << ", its predecessor is " << Walker->Name << " and its Shortest Path is " << BFS.ShortestPathList[OtherAtom->nr] << " egde(s) long." << endl;
     1234  DoLog(2) && (Log() << Verbose(2) << "Coloring OtherAtom " << OtherAtom->Name << " " << ((BFS.ColorList[OtherAtom->nr] == white) ? "white" : "lightgray") << ", its predecessor is " << Walker->Name << " and its Shortest Path is " << BFS.ShortestPathList[OtherAtom->nr] << " egde(s) long." << endl);
    12191235  if ((((BFS.ShortestPathList[OtherAtom->nr] < BFS.BondOrder) && (Binder != Bond)))) { // Check for maximum distance
    1220     Log() << Verbose(3);
     1236    DoLog(3) && (Log() << Verbose(3));
    12211237    if (AddedAtomList[OtherAtom->nr] == NULL) { // add if it's not been so far
    12221238      AddedAtomList[OtherAtom->nr] = Mol->AddCopyAtom(OtherAtom);
    1223       Log() << Verbose(0) << "Added OtherAtom " << OtherAtom->Name;
     1239      DoLog(0) && (Log() << Verbose(0) << "Added OtherAtom " << OtherAtom->Name);
    12241240      AddedBondList[Binder->nr] = Mol->CopyBond(AddedAtomList[Walker->nr], AddedAtomList[OtherAtom->nr], Binder);
    1225       Log() << Verbose(0) << " and bond " << *(AddedBondList[Binder->nr]) << ", ";
     1241      DoLog(0) && (Log() << Verbose(0) << " and bond " << *(AddedBondList[Binder->nr]) << ", ");
    12261242    } else { // this code should actually never come into play (all white atoms are not yet present in BondMolecule, that's why they are white in the first place)
    1227       Log() << Verbose(0) << "Not adding OtherAtom " << OtherAtom->Name;
     1243      DoLog(0) && (Log() << Verbose(0) << "Not adding OtherAtom " << OtherAtom->Name);
    12281244      if (AddedBondList[Binder->nr] == NULL) {
    12291245        AddedBondList[Binder->nr] = Mol->CopyBond(AddedAtomList[Walker->nr], AddedAtomList[OtherAtom->nr], Binder);
    1230         Log() << Verbose(0) << ", added Bond " << *(AddedBondList[Binder->nr]);
     1246        DoLog(0) && (Log() << Verbose(0) << ", added Bond " << *(AddedBondList[Binder->nr]));
    12311247      } else
    1232         Log() << Verbose(0) << ", not added Bond ";
    1233     }
    1234     Log() << Verbose(0) << ", putting OtherAtom into queue." << endl;
     1248        DoLog(0) && (Log() << Verbose(0) << ", not added Bond ");
     1249    }
     1250    DoLog(0) && (Log() << Verbose(0) << ", putting OtherAtom into queue." << endl);
    12351251    BFS.BFSStack->Push(OtherAtom);
    12361252  } else { // out of bond order, then replace
     
    12381254      BFS.ColorList[OtherAtom->nr] = white; // unmark if it has not been queued/added, to make it available via its other bonds (cyclic)
    12391255    if (Binder == Bond)
    1240       Log() << Verbose(3) << "Not Queueing, is the Root bond";
     1256      DoLog(3) && (Log() << Verbose(3) << "Not Queueing, is the Root bond");
    12411257    else if (BFS.ShortestPathList[OtherAtom->nr] >= BFS.BondOrder)
    1242       Log() << Verbose(3) << "Not Queueing, is out of Bond Count of " << BFS.BondOrder;
     1258      DoLog(3) && (Log() << Verbose(3) << "Not Queueing, is out of Bond Count of " << BFS.BondOrder);
    12431259    if (!Binder->Cyclic)
    1244       Log() << Verbose(0) << ", is not part of a cyclic bond, saturating bond with Hydrogen." << endl;
     1260      DoLog(0) && (Log() << Verbose(0) << ", is not part of a cyclic bond, saturating bond with Hydrogen." << endl);
    12451261    if (AddedBondList[Binder->nr] == NULL) {
    12461262      if ((AddedAtomList[OtherAtom->nr] != NULL)) { // .. whether we add or saturate
     
    12591275void BreadthFirstSearchAdd_VisitedNode(molecule *Mol, struct BFSAccounting &BFS, atom *&Walker, atom *&OtherAtom, bond *&Binder, bond *&Bond, atom **&AddedAtomList, bond **&AddedBondList, bool IsAngstroem)
    12601276{
    1261   Log() << Verbose(3) << "Not Adding, has already been visited." << endl;
     1277  DoLog(3) && (Log() << Verbose(3) << "Not Adding, has already been visited." << endl);
    12621278  // This has to be a cyclic bond, check whether it's present ...
    12631279  if (AddedBondList[Binder->nr] == NULL) {
     
    13051321    // followed by n+1 till top of stack.
    13061322    Walker = BFS.BFSStack->PopFirst(); // pop oldest added
    1307     Log() << Verbose(1) << "Current Walker is: " << Walker->Name << ", and has " << Walker->ListOfBonds.size() << " bonds." << endl;
     1323    DoLog(1) && (Log() << Verbose(1) << "Current Walker is: " << Walker->Name << ", and has " << Walker->ListOfBonds.size() << " bonds." << endl);
    13081324    for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
    13091325      if ((*Runner) != NULL) { // don't look at bond equal NULL
    13101326        Binder = (*Runner);
    13111327        OtherAtom = (*Runner)->GetOtherAtom(Walker);
    1312         Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->Name << " for bond " << *(*Runner) << "." << endl;
     1328        DoLog(2) && (Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->Name << " for bond " << *(*Runner) << "." << endl);
    13131329        if (BFS.ColorList[OtherAtom->nr] == white) {
    13141330          BreadthFirstSearchAdd_UnvisitedNode(Mol, BFS, Walker, OtherAtom, Binder, Bond, AddedAtomList, AddedBondList, IsAngstroem);
     
    13191335    }
    13201336    BFS.ColorList[Walker->nr] = black;
    1321     Log() << Verbose(1) << "Coloring Walker " << Walker->Name << " black." << endl;
     1337    DoLog(1) && (Log() << Verbose(1) << "Coloring Walker " << Walker->Name << " black." << endl);
    13221338  }
    13231339  BreadthFirstSearchAdd_Free(BFS);
     
    13441360  // reset parent list
    13451361  ParentList = Calloc<atom*> (AtomCount, "molecule::BuildInducedSubgraph_Init: **ParentList");
    1346   Log() << Verbose(3) << "Resetting ParentList." << endl;
     1362  DoLog(3) && (Log() << Verbose(3) << "Resetting ParentList." << endl);
    13471363}
    13481364;
     
    13511367{
    13521368  // fill parent list with sons
    1353   Log() << Verbose(3) << "Filling Parent List." << endl;
     1369  DoLog(3) && (Log() << Verbose(3) << "Filling Parent List." << endl);
    13541370  atom *Walker = mol->start;
    13551371  while (Walker->next != mol->end) {
     
    13571373    ParentList[Walker->father->nr] = Walker;
    13581374    // Outputting List for debugging
    1359     Log() << Verbose(4) << "Son[" << Walker->father->nr << "] of " << Walker->father << " is " << ParentList[Walker->father->nr] << "." << endl;
     1375    DoLog(4) && (Log() << Verbose(4) << "Son[" << Walker->father->nr << "] of " << Walker->father << " is " << ParentList[Walker->father->nr] << "." << endl);
    13601376  }
    13611377
     
    13751391  atom *OtherAtom = NULL;
    13761392  // check each entry of parent list and if ok (one-to-and-onto matching) create bonds
    1377   Log() << Verbose(3) << "Creating bonds." << endl;
     1393  DoLog(3) && (Log() << Verbose(3) << "Creating bonds." << endl);
    13781394  Walker = Father->start;
    13791395  while (Walker->next != Father->end) {
     
    13861402          OtherAtom = (*Runner)->GetOtherAtom(Walker);
    13871403          if (ParentList[OtherAtom->nr] != NULL) { // if otheratom is also a father of an atom on this molecule, create the bond
    1388             Log() << Verbose(4) << "Endpoints of Bond " << (*Runner) << " are both present: " << ParentList[Walker->nr]->Name << " and " << ParentList[OtherAtom->nr]->Name << "." << endl;
     1404            DoLog(4) && (Log() << Verbose(4) << "Endpoints of Bond " << (*Runner) << " are both present: " << ParentList[Walker->nr]->Name << " and " << ParentList[OtherAtom->nr]->Name << "." << endl);
    13891405            mol->AddBond(ParentList[Walker->nr], ParentList[OtherAtom->nr], (*Runner)->BondDegree);
    13901406          }
     
    14111427  atom **ParentList = NULL;
    14121428
    1413   Log() << Verbose(2) << "Begin of BuildInducedSubgraph." << endl;
     1429  DoLog(2) && (Log() << Verbose(2) << "Begin of BuildInducedSubgraph." << endl);
    14141430  BuildInducedSubgraph_Init(ParentList, Father->AtomCount);
    14151431  BuildInducedSubgraph_FillParentList(this, Father, ParentList);
    14161432  status = BuildInducedSubgraph_CreateBondsFromParent(this, Father, ParentList);
    14171433  BuildInducedSubgraph_Finalize(ParentList);
    1418   Log() << Verbose(2) << "End of BuildInducedSubgraph." << endl;
     1434  DoLog(2) && (Log() << Verbose(2) << "End of BuildInducedSubgraph." << endl);
    14191435  return status;
    14201436}
     
    14331449  int size;
    14341450
    1435   Log() << Verbose(1) << "Begin of CheckForConnectedSubgraph" << endl;
    1436   Log() << Verbose(2) << "Disconnected atom: ";
     1451  DoLog(1) && (Log() << Verbose(1) << "Begin of CheckForConnectedSubgraph" << endl);
     1452  DoLog(2) && (Log() << Verbose(2) << "Disconnected atom: ");
    14371453
    14381454  // count number of atoms in graph
     
    14561472      }
    14571473      if (!BondStatus) {
    1458         Log() << Verbose(0) << (*Walker) << endl;
     1474        DoLog(0) && (Log() << Verbose(0) << (*Walker) << endl);
    14591475        return false;
    14601476      }
    14611477    }
    14621478  else {
    1463     Log() << Verbose(0) << "none." << endl;
     1479    DoLog(0) && (Log() << Verbose(0) << "none." << endl);
    14641480    return true;
    14651481  }
    1466   Log() << Verbose(0) << "none." << endl;
    1467 
    1468   Log() << Verbose(1) << "End of CheckForConnectedSubgraph" << endl;
     1482  DoLog(0) && (Log() << Verbose(0) << "none." << endl);
     1483
     1484  DoLog(1) && (Log() << Verbose(1) << "End of CheckForConnectedSubgraph" << endl);
    14691485
    14701486  return true;
  • src/moleculelist.cpp

    r13d5a9 r5f612ee  
    2020#include "memoryallocator.hpp"
    2121#include "periodentafel.hpp"
     22#include "World.hpp"
    2223
    2324/*********************************** Functions for class MoleculeListClass *************************/
     
    3738MoleculeListClass::~MoleculeListClass()
    3839{
    39   Log() << Verbose(3) << this << ": Freeing ListOfMolcules." << endl;
     40  DoLog(3) && (Log() << Verbose(3) << this << ": Freeing ListOfMolcules." << endl);
    4041  for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
    41     Log() << Verbose(4) << "ListOfMolecules: Freeing " << *ListRunner << "." << endl;
     42    DoLog(4) && (Log() << Verbose(4) << "ListOfMolecules: Freeing " << *ListRunner << "." << endl);
    4243    world->destroyMolecule(*ListRunner);
    4344  }
    44   Log() << Verbose(4) << "Freeing ListOfMolecules." << endl;
     45  DoLog(4) && (Log() << Verbose(4) << "Freeing ListOfMolecules." << endl);
    4546  ListOfMolecules.clear(); // empty list
    4647};
     
    314315  Tesselation *TesselStruct = NULL;
    315316  if ((srcmol == NULL) || (mol == NULL)) {
    316     eLog() << Verbose(1) << "Either fixed or variable molecule is given as NULL." << endl;
     317    DoeLog(1) && (eLog()<< Verbose(1) << "Either fixed or variable molecule is given as NULL." << endl);
    317318    return false;
    318319  }
     
    322323  FindNonConvexBorder(mol, TesselStruct, (const LinkedCell *&)LCList, 4., NULL);
    323324  if (TesselStruct == NULL) {
    324     eLog() << Verbose(1) << "Could not tesselate the fixed molecule." << endl;
     325    DoeLog(1) && (eLog()<< Verbose(1) << "Could not tesselate the fixed molecule." << endl);
    325326    return false;
    326327  }
     
    339340  while (Walker->next != srcmol->end) {
    340341    Walker = Walker->next;
    341     Log() << Verbose(2) << "INFO: Current Walker is " << *Walker << "." << endl;
     342    DoLog(2) && (Log() << Verbose(2) << "INFO: Current Walker is " << *Walker << "." << endl);
    342343    if (!TesselStruct->IsInnerPoint(Walker->x, LCList)) {
    343344      CopyAtoms[Walker->nr] = Walker->clone();
     
    348349    }
    349350  }
    350   Log() << Verbose(1) << nr << " of " << srcmol->AtomCount << " atoms have been merged.";
     351  DoLog(1) && (Log() << Verbose(1) << nr << " of " << srcmol->AtomCount << " atoms have been merged.");
    351352
    352353  // go through all bonds and add as well
     
    354355  while(Binder->next != srcmol->last) {
    355356    Binder = Binder->next;
    356     Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl;
     357    DoLog(3) && (Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl);
    357358    mol->AddBond(CopyAtoms[Binder->leftatom->nr], CopyAtoms[Binder->rightatom->nr], Binder->BondDegree);
    358359  }
     
    366367void MoleculeListClass::Output(ofstream *out)
    367368{
    368   Log() << Verbose(1) << "MoleculeList: ";
     369  DoLog(1) && (Log() << Verbose(1) << "MoleculeList: ");
    369370  for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++)
    370     Log() << Verbose(0) << *ListRunner << "\t";
    371   Log() << Verbose(0) << endl;
     371    DoLog(0) && (Log() << Verbose(0) << *ListRunner << "\t");
     372  DoLog(0) && (Log() << Verbose(0) << endl);
    372373};
    373374
     
    395396  char *FragmentNumber = NULL;
    396397
    397   Log() << Verbose(1) << "Saving hydrogen saturation correction ... ";
     398  DoLog(1) && (Log() << Verbose(1) << "Saving hydrogen saturation correction ... ");
    398399  // 0. parse in fit constant files that should have the same dimension as the final energy files
    399400  // 0a. find dimension of matrices with constants
     
    405406  input.open(line.c_str());
    406407  if (input == NULL) {
    407     Log() << Verbose(1) << endl << "Unable to open " << line << ", is the directory correct?" << endl;
     408    DoLog(1) && (Log() << Verbose(1) << endl << "Unable to open " << line << ", is the directory correct?" << endl);
    408409    return false;
    409410  }
     
    422423    b++;
    423424  }
    424   Log() << Verbose(0) << "I recognized " << a << " columns and " << b << " rows, ";
     425  DoLog(0) && (Log() << Verbose(0) << "I recognized " << a << " columns and " << b << " rows, ");
    425426  input.close();
    426427
     
    443444    input.open(line.c_str());
    444445    if (input == NULL) {
    445       eLog() << Verbose(0) << endl << "Unable to open " << line << ", is the directory correct?" << endl;
     446      DoeLog(0) && (eLog()<< Verbose(0) << endl << "Unable to open " << line << ", is the directory correct?" << endl);
    446447      performCriticalExit();
    447448      return false;
     
    465466  }
    466467  for (int k = 0; k < 3; k++) {
    467     Log() << Verbose(0) << "Constants " << k << ":" << endl;
     468    DoLog(0) && (Log() << Verbose(0) << "Constants " << k << ":" << endl);
    468469    for (int j = 0; j < b; j++) {
    469470      for (int i = 0; i < a; i++) {
    470         Log() << Verbose(0) << FitConstant[k][i][j] << "\t";
     471        DoLog(0) && (Log() << Verbose(0) << FitConstant[k][i][j] << "\t");
    471472      }
    472       Log() << Verbose(0) << endl;
    473     }
    474     Log() << Verbose(0) << endl;
     473      DoLog(0) && (Log() << Verbose(0) << endl);
     474    }
     475    DoLog(0) && (Log() << Verbose(0) << endl);
    475476  }
    476477
     
    560561  }
    561562  Free(&FitConstant);
    562   Log() << Verbose(0) << "done." << endl;
     563  DoLog(0) && (Log() << Verbose(0) << "done." << endl);
    563564  return true;
    564565};
     
    580581
    581582  // open file for the force factors
    582   Log() << Verbose(1) << "Saving  force factors ... ";
     583  DoLog(1) && (Log() << Verbose(1) << "Saving  force factors ... ");
    583584  line << path << "/" << FRAGMENTPREFIX << FORCESFILE;
    584585  ForcesFile.open(line.str().c_str(), ios::out);
     
    607608    }
    608609    ForcesFile.close();
    609     Log() << Verbose(1) << "done." << endl;
     610    DoLog(1) && (Log() << Verbose(1) << "done." << endl);
    610611  } else {
    611612    status = false;
    612     Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl;
     613    DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl);
    613614  }
    614615  ForcesFile.close();
     
    638639  int FragmentCounter = 0;
    639640  ofstream output;
    640 
     641  double cell_size_backup[6];
     642  double * const cell_size = World::getInstance().getDomain();
     643
     644  // backup cell_size
     645  for (int i=0;i<6;i++)
     646    cell_size_backup[i] = cell_size[i];
    641647  // store the fragments as config and as xyz
    642648  for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
     
    646652      strcpy(PathBackup, path);
    647653    else {
    648       eLog() << Verbose(0) << "OutputConfigForListOfFragments: NULL default path obtained from config!" << endl;
     654      DoeLog(0) && (eLog()<< Verbose(0) << "OutputConfigForListOfFragments: NULL default path obtained from config!" << endl);
    649655      performCriticalExit();
    650656    }
     
    657663    sprintf(FragmentName, "%s/%s%s.conf.xyz", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);
    658664    outputFragment.open(FragmentName, ios::out);
    659     Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as XYZ ...";
     665    DoLog(2) && (Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as XYZ ...");
    660666    if ((intermediateResult = (*ListRunner)->OutputXYZ(&outputFragment)))
    661       Log() << Verbose(0) << " done." << endl;
     667      DoLog(0) && (Log() << Verbose(0) << " done." << endl);
    662668    else
    663       Log() << Verbose(0) << " failed." << endl;
     669      DoLog(0) && (Log() << Verbose(0) << " failed." << endl);
    664670    result = result && intermediateResult;
    665671    outputFragment.close();
     
    667673
    668674    // list atoms in fragment for debugging
    669     Log() << Verbose(2) << "Contained atoms: ";
     675    DoLog(2) && (Log() << Verbose(2) << "Contained atoms: ");
    670676    Walker = (*ListRunner)->start;
    671677    while (Walker->next != (*ListRunner)->end) {
    672678      Walker = Walker->next;
    673       Log() << Verbose(0) << Walker->Name << " ";
    674     }
    675     Log() << Verbose(0) << endl;
     679      DoLog(0) && (Log() << Verbose(0) << Walker->Name << " ");
     680    }
     681    DoLog(0) && (Log() << Verbose(0) << endl);
    676682
    677683    // center on edge
     
    682688      j += k + 1;
    683689      BoxDimension.x[k] = 2.5 * (configuration->GetIsAngstroem() ? 1. : 1. / AtomicLengthToAngstroem);
    684       (*ListRunner)->cell_size[j] += BoxDimension.x[k] * 2.;
     690      cell_size[j] = BoxDimension.x[k] * 2.;
    685691    }
    686692    (*ListRunner)->Translate(&BoxDimension);
     
    697703    // and save as config
    698704    sprintf(FragmentName, "%s/%s%s.conf", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);
    699     Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as config ...";
     705    DoLog(2) && (Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as config ...");
    700706    if ((intermediateResult = configuration->Save(FragmentName, (*ListRunner)->elemente, (*ListRunner))))
    701       Log() << Verbose(0) << " done." << endl;
     707      DoLog(0) && (Log() << Verbose(0) << " done." << endl);
    702708    else
    703       Log() << Verbose(0) << " failed." << endl;
     709      DoLog(0) && (Log() << Verbose(0) << " failed." << endl);
    704710    result = result && intermediateResult;
    705711
     
    709715    // and save as mpqc input file
    710716    sprintf(FragmentName, "%s/%s%s.conf", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);
    711     Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as mpqc input ...";
     717    DoLog(2) && (Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as mpqc input ...");
    712718    if ((intermediateResult = configuration->SaveMPQC(FragmentName, (*ListRunner))))
    713       Log() << Verbose(2) << " done." << endl;
     719      DoLog(2) && (Log() << Verbose(2) << " done." << endl);
    714720    else
    715       Log() << Verbose(0) << " failed." << endl;
     721      DoLog(0) && (Log() << Verbose(0) << " failed." << endl);
    716722
    717723    result = result && intermediateResult;
     
    720726    Free(&FragmentNumber);
    721727  }
    722   Log() << Verbose(0) << " done." << endl;
     728  DoLog(0) && (Log() << Verbose(0) << " done." << endl);
    723729
    724730  // printing final number
    725   Log() << Verbose(2) << "Final number of fragments: " << FragmentCounter << "." << endl;
     731  DoLog(2) && (Log() << Verbose(2) << "Final number of fragments: " << FragmentCounter << "." << endl);
     732
     733  // restore cell_size
     734  for (int i=0;i<6;i++)
     735    cell_size[i] = cell_size_backup[i];
    726736
    727737  return result;
     
    758768      Walker = Advancer;
    759769      Advancer = Advancer->next;
    760       Log() << Verbose(3) << "Re-linking " << *Walker << "..." << endl;
     770      DoLog(3) && (Log() << Verbose(3) << "Re-linking " << *Walker << "..." << endl);
    761771      unlink(Walker);
    762772      Walker->father = Walker;
     
    776786
    777787  // 1. dissect the molecule into connected subgraphs
    778   configuration->BG->ConstructBondGraph(mol);
     788  if (!configuration->BG->ConstructBondGraph(mol)) {
     789    World::getInstance().destroyMolecule(mol);
     790    DoeLog(1) && (eLog()<< Verbose(1) << "There are no bonds." << endl);
     791    return;
     792  }
    779793
    780794  // 2. scan for connected subgraphs
     
    783797  Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack);
    784798  delete(BackEdgeStack);
     799  if ((Subgraphs == NULL) || (Subgraphs->next == NULL)) {
     800    World::getInstance().destroyMolecule(mol);
     801    DoeLog(1) && (eLog()<< Verbose(1) << "There are no atoms." << endl);
     802    return;
     803  }
    785804
    786805  // 3. dissect (the following construct is needed to have the atoms not in the order of the DFS, but in
     
    800819      strncat(molecules[i]->name, number, MAXSTRINGSIZE - strlen(mol->name) - 1);
    801820    }
    802     cout << "MolName is " << molecules[i]->name << endl;
     821    DoLog(1) && (Log() << Verbose(1) << "MolName is " << molecules[i]->name << endl);
    803822    insert(molecules[i]);
    804823  }
     
    824843    Walker = mol->start->next;
    825844    if ((Walker->nr <0) || (Walker->nr >= mol->AtomCount)) {
    826       eLog() << Verbose(0) << "Index of atom " << *Walker << " is invalid!" << endl;
     845      DoeLog(0) && (eLog()<< Verbose(0) << "Index of atom " << *Walker << " is invalid!" << endl);
    827846      performCriticalExit();
    828847    }
    829848    FragmentCounter = MolMap[Walker->nr];
    830849    if (FragmentCounter != 0) {
    831       Log() << Verbose(3) << "Re-linking " << *Walker << "..." << endl;
     850      DoLog(3) && (Log() << Verbose(3) << "Re-linking " << *Walker << "..." << endl);
    832851      unlink(Walker);
    833852      molecules[FragmentCounter-1]->AddAtom(Walker);    // counting starts at 1
    834853    } else {
    835       eLog() << Verbose(0) << "Atom " << *Walker << " not associated to molecule!" << endl;
     854      DoeLog(0) && (eLog()<< Verbose(0) << "Atom " << *Walker << " not associated to molecule!" << endl);
    836855      performCriticalExit();
    837856    }
     
    854873  Free(&MolMap);
    855874  Free(&molecules);
    856   Log() << Verbose(1) << "I scanned " << FragmentCounter << " molecules." << endl;
     875  DoLog(1) && (Log() << Verbose(1) << "I scanned " << FragmentCounter << " molecules." << endl);
    857876};
    858877
     
    908927  // center at set box dimensions
    909928  mol->CenterEdge(&center);
    910   mol->cell_size[0] = center.x[0];
    911   mol->cell_size[1] = 0;
    912   mol->cell_size[2] = center.x[1];
    913   mol->cell_size[3] = 0;
    914   mol->cell_size[4] = 0;
    915   mol->cell_size[5] = center.x[2];
     929  World::getInstance().getDomain()[0] = center.x[0];
     930  World::getInstance().getDomain()[1] = 0;
     931  World::getInstance().getDomain()[2] = center.x[1];
     932  World::getInstance().getDomain()[3] = 0;
     933  World::getInstance().getDomain()[4] = 0;
     934  World::getInstance().getDomain()[5] = center.x[2];
    916935  insert(mol);
    917936}
     
    10511070  int AtomNo;
    10521071
    1053   Log() << Verbose(1) << "Begin of FillBondStructureFromReference." << endl;
     1072  DoLog(1) && (Log() << Verbose(1) << "Begin of FillBondStructureFromReference." << endl);
    10541073  // fill ListOfLocalAtoms if NULL was given
    10551074  if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->AtomCount, FreeList)) {
    1056     Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl;
     1075    DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl);
    10571076    return false;
    10581077  }
    10591078
    10601079  if (status) {
    1061     Log() << Verbose(1) << "Creating adjacency list for subgraph " << Leaf << "." << endl;
     1080    DoLog(1) && (Log() << Verbose(1) << "Creating adjacency list for subgraph " << Leaf << "." << endl);
    10621081    // remove every bond from the list
    10631082    bond *Binder = NULL;
     
    10801099            Leaf->AddBond(Walker, OtherWalker, (*Runner)->BondDegree);
    10811100        } else {
    1082           Log() << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << FragmentCounter << "][" << (*Runner)->GetOtherAtom(Walker->GetTrueFather())->nr << "] is NULL!" << endl;
     1101          DoLog(1) && (Log() << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << FragmentCounter << "][" << (*Runner)->GetOtherAtom(Walker->GetTrueFather())->nr << "] is NULL!" << endl);
    10831102          status = false;
    10841103        }
     
    10931112      Free(&ListOfLocalAtoms);
    10941113  }
    1095   Log() << Verbose(1) << "End of FillBondStructureFromReference." << endl;
     1114  DoLog(1) && (Log() << Verbose(1) << "End of FillBondStructureFromReference." << endl);
    10961115  return status;
    10971116};
     
    11261145        next->FillRootStackForSubgraphs(RootStack, AtomMask, ++FragmentCounter);
    11271146    } else {
    1128       Log() << Verbose(1) << "Rootstack[" << FragmentCounter << "] is NULL." << endl;
     1147      DoLog(1) && (Log() << Verbose(1) << "Rootstack[" << FragmentCounter << "] is NULL." << endl);
    11291148      return false;
    11301149    }
     
    11321151    return true;
    11331152  } else {
    1134     Log() << Verbose(1) << "Rootstack is NULL." << endl;
     1153    DoLog(1) && (Log() << Verbose(1) << "Rootstack is NULL." << endl);
    11351154    return false;
    11361155  }
     
    11821201  int KeySetCounter = 0;
    11831202
    1184   Log() << Verbose(1) << "Begin of AssignKeySetsToFragment." << endl;
     1203  DoLog(1) && (Log() << Verbose(1) << "Begin of AssignKeySetsToFragment." << endl);
    11851204  // fill ListOfLocalAtoms if NULL was given
    11861205  if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->AtomCount, FreeList)) {
    1187     Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl;
     1206    DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl);
    11881207    return false;
    11891208  }
     
    12131232    delete (TempSet);
    12141233    if (KeySetCounter == 0) {// if there are no keysets, delete the list
    1215       Log() << Verbose(1) << "KeySetCounter is zero, deleting FragmentList." << endl;
     1234      DoLog(1) && (Log() << Verbose(1) << "KeySetCounter is zero, deleting FragmentList." << endl);
    12161235      delete (FragmentList[FragmentCounter]);
    12171236    } else
    1218       Log() << Verbose(1) << KeySetCounter << " keysets were assigned to subgraph " << FragmentCounter << "." << endl;
     1237      DoLog(1) && (Log() << Verbose(1) << KeySetCounter << " keysets were assigned to subgraph " << FragmentCounter << "." << endl);
    12191238    FragmentCounter++;
    12201239    if (next != NULL)
     
    12221241    FragmentCounter--;
    12231242  } else
    1224     Log() << Verbose(1) << "KeySetList is NULL or empty." << endl;
     1243    DoLog(1) && (Log() << Verbose(1) << "KeySetList is NULL or empty." << endl);
    12251244
    12261245  if ((FreeList) && (ListOfLocalAtoms != NULL)) {
     
    12301249      Free(&ListOfLocalAtoms);
    12311250  }
    1232   Log() << Verbose(1) << "End of AssignKeySetsToFragment." << endl;
     1251  DoLog(1) && (Log() << Verbose(1) << "End of AssignKeySetsToFragment." << endl);
    12331252  return status;
    12341253};
     
    12431262void MoleculeLeafClass::TranslateIndicesToGlobalIDs(Graph **FragmentList, int &FragmentCounter, int &TotalNumberOfKeySets, Graph &TotalGraph)
    12441263{
    1245   Log() << Verbose(1) << "Begin of TranslateIndicesToGlobalIDs." << endl;
     1264  DoLog(1) && (Log() << Verbose(1) << "Begin of TranslateIndicesToGlobalIDs." << endl);
    12461265  KeySet *TempSet = new KeySet;
    12471266  if (FragmentList[FragmentCounter] != NULL) {
     
    12541273    delete (TempSet);
    12551274  } else {
    1256     Log() << Verbose(1) << "FragmentList is NULL." << endl;
     1275    DoLog(1) && (Log() << Verbose(1) << "FragmentList is NULL." << endl);
    12571276  }
    12581277  if (next != NULL)
    12591278    next->TranslateIndicesToGlobalIDs(FragmentList, ++FragmentCounter, TotalNumberOfKeySets, TotalGraph);
    12601279  FragmentCounter--;
    1261   Log() << Verbose(1) << "End of TranslateIndicesToGlobalIDs." << endl;
     1280  DoLog(1) && (Log() << Verbose(1) << "End of TranslateIndicesToGlobalIDs." << endl);
    12621281};
    12631282
  • src/parser.cpp

    r13d5a9 r5f612ee  
    3232  if (input == NULL) {
    3333    if (!test)
    34       Log() << Verbose(0) << endl << "Unable to open " << filename << ", is the directory correct?" << endl;
     34      DoLog(0) && (Log() << Verbose(0) << endl << "Unable to open " << filename << ", is the directory correct?" << endl);
    3535    return false;
    3636  }
     
    109109bool MatrixContainer::InitialiseIndices(class MatrixContainer *Matrix)
    110110{
    111   Log() << Verbose(0) << "Initialising indices";
     111  DoLog(0) && (Log() << Verbose(0) << "Initialising indices");
    112112  if (Matrix == NULL) {
    113     Log() << Verbose(0) << " with trivial mapping." << endl;
     113    DoLog(0) && (Log() << Verbose(0) << " with trivial mapping." << endl);
    114114    Indices = Malloc<int*>(MatrixCounter + 1, "MatrixContainer::InitialiseIndices: **Indices");
    115115    for(int i=MatrixCounter+1;i--;) {
     
    119119    }
    120120  } else {
    121     Log() << Verbose(0) << " from other MatrixContainer." << endl;
     121    DoLog(0) && (Log() << Verbose(0) << " from other MatrixContainer." << endl);
    122122    if (MatrixCounter != Matrix->MatrixCounter)
    123123      return false;
     
    160160  //Log() << Verbose(1) << "Opening " << name << " ... "  << input << endl;
    161161  if (input == NULL) {
    162     eLog() << Verbose(1) << endl << "Unable to open " << name << ", is the directory correct?" << endl;
     162    DoeLog(1) && (eLog()<< Verbose(1) << endl << "Unable to open " << name << ", is the directory correct?" << endl);
    163163    //performCriticalExit();
    164164    return false;
     
    183183  //Log() << Verbose(1) << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << "." << endl;
    184184  if (ColumnCounter[MatrixNr] == 0) {
    185     eLog() << Verbose(0) << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl;
     185    DoeLog(0) && (eLog()<< Verbose(0) << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl);
    186186    performCriticalExit();
    187187  }
     
    199199  //Log() << Verbose(1) << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << "." << endl;
    200200  if (RowCounter[MatrixNr] == 0) {
    201     eLog() << Verbose(0) << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl;
     201    DoeLog(0) && (eLog()<< Verbose(0) << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl);
    202202    performCriticalExit();
    203203  }
     
    232232    }
    233233  } else {
    234     eLog() << Verbose(1) << "Matrix nr. " << MatrixNr << " has column and row count of (" << ColumnCounter[MatrixNr] << "," << RowCounter[MatrixNr] << "), could not allocate nor parse!" << endl;
     234    DoeLog(1) && (eLog()<< Verbose(1) << "Matrix nr. " << MatrixNr << " has column and row count of (" << ColumnCounter[MatrixNr] << "," << RowCounter[MatrixNr] << "), could not allocate nor parse!" << endl);
    235235  }
    236236  input.close();
     
    269269  input.open(file.str().c_str(), ios::in);
    270270  if (input == NULL) {
    271     Log() << Verbose(0) << endl << "Unable to open " << file.str() << ", is the directory correct?" << endl;
     271    DoLog(0) && (Log() << Verbose(0) << endl << "Unable to open " << file.str() << ", is the directory correct?" << endl);
    272272    return false;
    273273  }
     
    278278  }
    279279  input.close();
    280   Log() << Verbose(0) << "Determined " << MatrixCounter << " fragments." << endl;
    281 
    282   Log() << Verbose(0) << "Parsing through each fragment and retrieving " << prefix << suffix << "." << endl;
     280  DoLog(0) && (Log() << Verbose(0) << "Determined " << MatrixCounter << " fragments." << endl);
     281
     282  DoLog(0) && (Log() << Verbose(0) << "Parsing through each fragment and retrieving " << prefix << suffix << "." << endl);
    283283  Header = ReAlloc<char*>(Header, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: **Header"); // one more each for the total molecule
    284284  Matrix = ReAlloc<double**>(Matrix, MatrixCounter + 1, "MatrixContainer::ParseFragmentMatrix: ***Matrix"); // one more each for the total molecule
     
    433433              //Log() << Verbose(0) << "Corresponding index in CurrentFragment is " << m << "." << endl;
    434434              if (m > RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ]) {
    435                 eLog() << Verbose(0) << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment]   << " current force index " << m << " is greater than " << RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl;
     435                DoeLog(0) && (eLog()<< Verbose(0) << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment]   << " current force index " << m << " is greater than " << RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl);
    436436                performCriticalExit();
    437437                return false;
     
    469469  char *FragmentNumber = NULL;
    470470
    471   Log() << Verbose(0) << "Writing fragment files." << endl;
     471  DoLog(0) && (Log() << Verbose(0) << "Writing fragment files." << endl);
    472472  for(int i=0;i<MatrixCounter;i++) {
    473473    stringstream line;
     
    477477    output.open(line.str().c_str(), ios::out);
    478478    if (output == NULL) {
    479       eLog() << Verbose(0) << "Unable to open output energy file " << line.str() << "!" << endl;
     479      DoeLog(0) && (eLog()<< Verbose(0) << "Unable to open output energy file " << line.str() << "!" << endl);
    480480      performCriticalExit();
    481481      return false;
     
    503503  stringstream line;
    504504
    505   Log() << Verbose(0) << "Writing matrix values of " << suffix << "." << endl;
     505  DoLog(0) && (Log() << Verbose(0) << "Writing matrix values of " << suffix << "." << endl);
    506506  line << name << prefix << suffix;
    507507  output.open(line.str().c_str(), ios::out);
    508508  if (output == NULL) {
    509     eLog() << Verbose(0) << "Unable to open output matrix file " << line.str() << "!" << endl;
     509    DoeLog(0) && (eLog()<< Verbose(0) << "Unable to open output matrix file " << line.str() << "!" << endl);
    510510    performCriticalExit();
    511511    return false;
     
    529529bool EnergyMatrix::ParseIndices()
    530530{
    531   Log() << Verbose(0) << "Parsing energy indices." << endl;
     531  DoLog(0) && (Log() << Verbose(0) << "Parsing energy indices." << endl);
    532532  Indices = Malloc<int*>(MatrixCounter + 1, "EnergyMatrix::ParseIndices: **Indices");
    533533  for(int i=MatrixCounter+1;i--;) {
     
    588588    }
    589589    // allocate last plus one matrix
    590     Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl;
     590    DoLog(0) && (Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl);
    591591    Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]");
    592592    for(int j=0;j<=RowCounter[MatrixCounter];j++)
     
    615615  stringstream line;
    616616
    617   Log() << Verbose(0) << "Parsing force indices for " << MatrixCounter << " matrices." << endl;
     617  DoLog(0) && (Log() << Verbose(0) << "Parsing force indices for " << MatrixCounter << " matrices." << endl);
    618618  Indices = Malloc<int*>(MatrixCounter + 1, "ForceMatrix::ParseIndices: **Indices");
    619619  line << name << FRAGMENTPREFIX << FORCESFILE;
     
    621621  //Log() << Verbose(0) << "Opening " << line.str() << " ... "  << input << endl;
    622622  if (input == NULL) {
    623     Log() << Verbose(0) << endl << "Unable to open " << line.str() << ", is the directory correct?" << endl;
     623    DoLog(0) && (Log() << Verbose(0) << endl << "Unable to open " << line.str() << ", is the directory correct?" << endl);
    624624    return false;
    625625  }
     
    664664      int j = Indices[ FragmentNr ][l];
    665665      if (j > RowCounter[MatrixCounter]) {
    666         eLog() << Verbose(0) << "Current force index " << j << " is greater than " << RowCounter[MatrixCounter] << "!" << endl;
     666        DoeLog(0) && (eLog()<< Verbose(0) << "Current force index " << j << " is greater than " << RowCounter[MatrixCounter] << "!" << endl);
    667667        performCriticalExit();
    668668        return false;
     
    700700    input.open(file.str().c_str(), ios::in);
    701701    if (input == NULL) {
    702       Log() << Verbose(0) << endl << "Unable to open " << file.str() << ", is the directory correct?" << endl;
     702      DoLog(0) && (Log() << Verbose(0) << endl << "Unable to open " << file.str() << ", is the directory correct?" << endl);
    703703      return false;
    704704    }
     
    724724 
    725725    // allocate last plus one matrix
    726     Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl;
     726    DoLog(0) && (Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl);
    727727    Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]");
    728728    for(int j=0;j<=RowCounter[MatrixCounter];j++)
     
    753753  stringstream line;
    754754 
    755   Log() << Verbose(0) << "Parsing hessian indices for " << MatrixCounter << " matrices." << endl;
     755  DoLog(0) && (Log() << Verbose(0) << "Parsing hessian indices for " << MatrixCounter << " matrices." << endl);
    756756  Indices = Malloc<int*>(MatrixCounter + 1, "HessianMatrix::ParseIndices: **Indices");
    757757  line << name << FRAGMENTPREFIX << FORCESFILE;
     
    759759  //Log() << Verbose(0) << "Opening " << line.str() << " ... "  << input << endl;
    760760  if (input == NULL) {
    761     Log() << Verbose(0) << endl << "Unable to open " << line.str() << ", is the directory correct?" << endl;
     761    DoLog(0) && (Log() << Verbose(0) << endl << "Unable to open " << line.str() << ", is the directory correct?" << endl);
    762762    return false;
    763763  }
     
    802802      int j = Indices[ FragmentNr ][l];
    803803      if (j > RowCounter[MatrixCounter]) {
    804         eLog() << Verbose(0) << "Current hessian index " << j << " is greater than " << RowCounter[MatrixCounter] << ", where i=" << i << ", Order=" << Order << ", l=" << l << " and FragmentNr=" << FragmentNr << "!" << endl;
     804        DoeLog(0) && (eLog()<< Verbose(0) << "Current hessian index " << j << " is greater than " << RowCounter[MatrixCounter] << ", where i=" << i << ", Order=" << Order << ", l=" << l << " and FragmentNr=" << FragmentNr << "!" << endl);
    805805        performCriticalExit();
    806806        return false;
     
    810810          int k = Indices[ FragmentNr ][m];
    811811          if (k > ColumnCounter[MatrixCounter]) {
    812             eLog() << Verbose(0) << "Current hessian index " << k << " is greater than " << ColumnCounter[MatrixCounter] << ", where m=" << m << ", j=" << j << ", i=" << i << ", Order=" << Order << ", l=" << l << " and FragmentNr=" << FragmentNr << "!" << endl;
     812            DoeLog(0) && (eLog()<< Verbose(0) << "Current hessian index " << k << " is greater than " << ColumnCounter[MatrixCounter] << ", where m=" << m << ", j=" << j << ", i=" << i << ", Order=" << Order << ", l=" << l << " and FragmentNr=" << FragmentNr << "!" << endl);
    813813            performCriticalExit();
    814814            return false;
     
    863863              //Log() << Verbose(0) << "Corresponding row index for " << k << " in CurrentFragment is " << m << "." << endl;
    864864              if (m > RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ]) {
    865                 eLog() << Verbose(0) << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment]   << " current row index " << m << " is greater than " << RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl;
     865                DoeLog(0) && (eLog()<< Verbose(0) << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment]   << " current row index " << m << " is greater than " << RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl);
    866866                performCriticalExit();
    867867                return false;
     
    881881                  //Log() << Verbose(0) << "Corresponding column index for " << l << " in CurrentFragment is " << n << "." << endl;
    882882                  if (n > ColumnCounter[ KeySets.OrderSet[Order][CurrentFragment] ]) {
    883                     eLog() << Verbose(0) << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment]   << " current column index " << n << " is greater than " << ColumnCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl;
     883                    DoeLog(0) && (eLog()<< Verbose(0) << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment]   << " current column index " << n << " is greater than " << ColumnCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl);
    884884                    performCriticalExit();
    885885                    return false;
     
    930930    input.open(file.str().c_str(), ios::in);
    931931    if (input == NULL) {
    932       Log() << Verbose(0) << endl << "Unable to open " << file.str() << ", is the directory correct?" << endl;
     932      DoLog(0) && (Log() << Verbose(0) << endl << "Unable to open " << file.str() << ", is the directory correct?" << endl);
    933933      return false;
    934934    }
     
    952952 
    953953    // allocate last plus one matrix
    954     Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl;
     954    DoLog(0) && (Log() << Verbose(0) << "Allocating last plus one matrix with " << (RowCounter[MatrixCounter]+1) << " rows and " << ColumnCounter[MatrixCounter] << " columns." << endl);
    955955    Matrix[MatrixCounter] = Malloc<double*>(RowCounter[MatrixCounter] + 1, "MatrixContainer::ParseFragmentMatrix: **Matrix[]");
    956956    for(int j=0;j<=RowCounter[MatrixCounter];j++)
     
    10071007
    10081008  FragmentCounter = FCounter;
    1009   Log() << Verbose(0) << "Parsing key sets." << endl;
     1009  DoLog(0) && (Log() << Verbose(0) << "Parsing key sets." << endl);
    10101010  KeySets = Malloc<int*>(FragmentCounter, "KeySetsContainer::ParseKeySets: **KeySets");
    10111011  for(int i=FragmentCounter;i--;)
     
    10141014  input.open(file.str().c_str(), ios::in);
    10151015  if (input == NULL) {
    1016     Log() << Verbose(0) << endl << "Unable to open " << file.str() << ", is the directory correct?" << endl;
     1016    DoLog(0) && (Log() << Verbose(0) << endl << "Unable to open " << file.str() << ", is the directory correct?" << endl);
    10171017    return false;
    10181018  }
     
    10481048  int Counter;
    10491049
    1050   Log() << Verbose(0) << "Creating Fragment terms." << endl;
     1050  DoLog(0) && (Log() << Verbose(0) << "Creating Fragment terms." << endl);
    10511051  // scan through all to determine maximum order
    10521052  Order=0;
     
    10591059      Order = Counter;
    10601060  }
    1061   Log() << Verbose(0) << "Found Order is " << Order << "." << endl;
     1061  DoLog(0) && (Log() << Verbose(0) << "Found Order is " << Order << "." << endl);
    10621062
    10631063  // scan through all to determine fragments per order
     
    10731073  }
    10741074  for(int i=0;i<Order;i++)
    1075     Log() << Verbose(0) << "Found No. of Fragments of Order " << i+1 << " is " << FragmentsPerOrder[i] << "." << endl;
     1075    DoLog(0) && (Log() << Verbose(0) << "Found No. of Fragments of Order " << i+1 << " is " << FragmentsPerOrder[i] << "." << endl);
    10761076
    10771077  // scan through all to gather indices to each order set
     
    10891089    FragmentsPerOrder[Counter-1]++;
    10901090  }
    1091   Log() << Verbose(0) << "Printing OrderSet." << endl;
     1091  DoLog(0) && (Log() << Verbose(0) << "Printing OrderSet." << endl);
    10921092  for(int i=0;i<Order;i++) {
    10931093    for (int j=0;j<FragmentsPerOrder[i];j++) {
    1094       Log() << Verbose(0) << " " << OrderSet[i][j];
    1095     }
    1096     Log() << Verbose(0) << endl;
    1097   }
    1098   Log() << Verbose(0) << endl;
     1094      DoLog(0) && (Log() << Verbose(0) << " " << OrderSet[i][j]);
     1095    }
     1096    DoLog(0) && (Log() << Verbose(0) << endl);
     1097  }
     1098  DoLog(0) && (Log() << Verbose(0) << endl);
    10991099
    11001100
  • src/periodentafel.cpp

    r13d5a9 r5f612ee  
    4747  pointer->sort = &pointer->Z;
    4848  if (pointer->getNumber() < 1 && pointer->getNumber() >= MAX_ELEMENTS)
    49     Log() << Verbose(0) << "Invalid Z number!\n";
     49    DoeLog(0) && (eLog() << Verbose(0) << "Invalid Z number!\n");
    5050  pair<iterator,bool> res = elements.insert(pair<atomicNumber_t,element*>(Z,pointer));
    5151  return res.first;
     
    108108  int Z;
    109109  do {
    110     Log() << Verbose(0) << "Atomic number Z: ";
     110    DoLog(0) && (Log() << Verbose(0) << "Atomic number Z: ");
    111111    cin >> Z;
    112112    walker = this->FindElement(Z);  // give type
     
    122122  const element *res = NULL;
    123123  atomicNumber_t Z = 0;
    124   Log() << Verbose(0) << "Atomic number: " << Z << endl;
     124  DoLog(0) && (Log() << Verbose(0) << "Atomic number: " << Z << endl);
    125125  cin >> Z;
    126126  res = FindElement(Z);
     
    128128    // TODO: make this using the constructor
    129129    element *tmp;
    130     Log() << Verbose(0) << "Element not found in database, please enter." << endl;
     130    DoLog(0) && (Log() << Verbose(0) << "Element not found in database, please enter." << endl);
    131131    tmp = new element;
    132132    tmp->Z = Z;
    133     Log() << Verbose(0) << "Mass: " << endl;
     133    DoLog(0) && (Log() << Verbose(0) << "Mass: " << endl);
    134134    cin >> tmp->mass;
    135     Log() << Verbose(0) << "Name [max 64 chars]: " << endl;
     135    DoLog(0) && (Log() << Verbose(0) << "Name [max 64 chars]: " << endl);
    136136    cin >> tmp->name;
    137     Log() << Verbose(0) << "Short form [max 3 chars]: " << endl;
     137    DoLog(0) && (Log() << Verbose(0) << "Short form [max 3 chars]: " << endl);
    138138    cin >> tmp->symbol;
    139139    AddElement(tmp);
     
    219219    infile.getline(header1, MAXSTRINGSIZE);
    220220    infile.getline(header2, MAXSTRINGSIZE); // skip first two header lines
    221     Log() << Verbose(0) <<  "Parsed elements:";
     221    DoLog(0) && (Log() << Verbose(0) <<  "Parsed elements:");
    222222    while (!infile.eof()) {
    223223      element *neues = new element;
     
    241241      //infile >> ws;
    242242      infile >> ws;
    243       Log() << Verbose(0) << " " << neues->symbol;
     243      DoLog(0) && (Log() << Verbose(0) << " " << neues->symbol);
    244244      //neues->Output((ofstream *)&cout);
    245245      if ((neues->Z > 0) && (neues->Z < MAX_ELEMENTS))
    246246        parsedElems[neues->getNumber()] = neues;
    247247      else {
    248         Log() << Verbose(0) << "Could not parse element: ";
     248        DoLog(0) && (Log() << Verbose(0) << "Could not parse element: ");
    249249        neues->Output((ofstream *)&cout);
    250250        delete(neues);
    251251      }
    252252    }
    253     Log() << Verbose(0) << endl;
     253    DoLog(0) && (Log() << Verbose(0) << endl);
    254254    infile.close();
    255255    infile.clear();
     
    345345  }
    346346  else{
    347     eLog() << Verbose(2) << "Something went wrong while parsing the other databases!" << endl;
     347    DoeLog(2) && (eLog()<< Verbose(2) << "Something went wrong while parsing the other databases!" << endl);
    348348    map<atomicNumber_t,element*>::iterator iter;
    349349    for(iter=parsedElems.begin();iter!=parsedElems.end();++iter){
  • src/stackclass.hpp

    r13d5a9 r5f612ee  
    7272    return true;
    7373  } else {
    74     eLog() << Verbose(1) << "Stack is full, " << "Stack: CurrentLastEntry " << CurrentLastEntry<< "\tCurrentFirstEntry " << CurrentFirstEntry << "\tNextFreeField " << NextFreeField << "\tEntryCount " << EntryCount << "!" << endl;
     74    DoeLog(1) && (eLog()<< Verbose(1) << "Stack is full, " << "Stack: CurrentLastEntry " << CurrentLastEntry<< "\tCurrentFirstEntry " << CurrentFirstEntry << "\tNextFreeField " << NextFreeField << "\tEntryCount " << EntryCount << "!" << endl);
    7575    return false;
    7676  }
     
    8787    Walker = StackList[CurrentFirstEntry];
    8888    if (Walker == NULL)
    89       eLog() << Verbose(1) << "Stack's field is empty!" << endl;
     89      DoeLog(1) && (eLog()<< Verbose(1) << "Stack's field is empty!" << endl);
    9090    StackList[CurrentFirstEntry] = NULL;
    9191    if (CurrentFirstEntry != CurrentLastEntry) { // hasn't last item been popped as well?
     
    9696    }
    9797  } else
    98     eLog() << Verbose(1) << "Stack is empty!" << endl;
     98    DoeLog(1) && (eLog()<< Verbose(1) << "Stack is empty!" << endl);
    9999  return Walker;
    100100};
     
    111111    StackList[CurrentLastEntry] = NULL;
    112112    if (Walker == NULL)
    113       eLog() << Verbose(1) << "Stack's field is empty!" << endl;
     113      DoeLog(1) && (eLog()<< Verbose(1) << "Stack's field is empty!" << endl);
    114114    NextFreeField = CurrentLastEntry;
    115115    if (CurrentLastEntry != CurrentFirstEntry)  // has there been more than one item on stack
    116116      CurrentLastEntry = (CurrentLastEntry + (EntryCount-1)) % EntryCount; // step back from current free field to last (modulo does not work in -1, thus go EntryCount-1 instead)
    117117  } else {
    118     eLog() << Verbose(1) << "Stack is empty!" << endl;
     118    DoeLog(1) && (eLog()<< Verbose(1) << "Stack is empty!" << endl);
    119119  }
    120120  return Walker;
     
    130130{
    131131  bool found = false;
    132   Log() << Verbose(5) << "First " << CurrentFirstEntry<< "\tLast " << CurrentLastEntry<< "\tNext " << NextFreeField<< "\tCount " << EntryCount<< "." << endl;
     132  DoLog(5) && (Log() << Verbose(5) << "First " << CurrentFirstEntry<< "\tLast " << CurrentLastEntry<< "\tNext " << NextFreeField<< "\tCount " << EntryCount<< "." << endl);
    133133  int i=CurrentFirstEntry;
    134134  if (!IsEmpty())
    135135    do {
    136136      if (StackList[i] == ptr) {  // if item found, remove
    137         Log() << Verbose(5) << "Item " << *ptr << " was number " << i << " on stack, removing it." << endl;
     137        DoLog(5) && (Log() << Verbose(5) << "Item " << *ptr << " was number " << i << " on stack, removing it." << endl);
    138138        found = true;
    139139        StackList[i] = NULL;
     
    141141      if ((found) && (StackList[i] != NULL)) {  // means we have to shift (and not the removed item)
    142142        if (i == 0) { // we are down to first item in stack, have to put onto last item
    143           Log() << Verbose(5) << "Shifting item 0 to place " << EntryCount-1 << "." << endl;
     143          DoLog(5) && (Log() << Verbose(5) << "Shifting item 0 to place " << EntryCount-1 << "." << endl);
    144144          StackList[EntryCount-1] = StackList[0];
    145145        } else {
    146           Log() << Verbose(5) << "Shifting item " << i << " to place " << i-1 << "." << endl;
     146          DoLog(5) && (Log() << Verbose(5) << "Shifting item " << i << " to place " << i-1 << "." << endl);
    147147          StackList[i-1] = StackList[i];
    148148        }
     
    151151    } while (i!=NextFreeField);
    152152  else
    153     eLog() << Verbose(1) << "Stack is already empty!" << endl;
     153    DoeLog(1) && (eLog()<< Verbose(1) << "Stack is already empty!" << endl);
    154154  if (found) {
    155155    NextFreeField = CurrentLastEntry;
  • src/tesselation.cpp

    r13d5a9 r5f612ee  
    77
    88#include <fstream>
     9#include <assert.h>
    910
    1011#include "helpers.hpp"
     
    1415#include "tesselation.hpp"
    1516#include "tesselationhelpers.hpp"
     17#include "triangleintersectionlist.hpp"
    1618#include "vector.hpp"
    1719#include "verbose.hpp"
     
    2426 */
    2527BoundaryPointSet::BoundaryPointSet() :
    26     LinesCount(0),
    27     value(0.),
    28     Nr(-1)
    29 {
    30         Info FunctionInfo(__func__);
    31         Log() << Verbose(1) << "Adding noname." << endl;
    32 };
     28  LinesCount(0), value(0.), Nr(-1)
     29{
     30  Info FunctionInfo(__func__);
     31  DoLog(1) && (Log() << Verbose(1) << "Adding noname." << endl);
     32}
     33;
    3334
    3435/** Constructor of BoundaryPointSet with Tesselpoint.
     
    3637 */
    3738BoundaryPointSet::BoundaryPointSet(TesselPoint * const Walker) :
    38   LinesCount(0),
    39   node(Walker),
    40   value(0.),
    41   Nr(Walker->nr)
    42 {
    43         Info FunctionInfo(__func__);
    44   Log() << Verbose(1) << "Adding Node " << *Walker << endl;
    45 };
     39  LinesCount(0), node(Walker), value(0.), Nr(Walker->nr)
     40{
     41  Info FunctionInfo(__func__);
     42  DoLog(1) && (Log() << Verbose(1) << "Adding Node " << *Walker << endl);
     43}
     44;
    4645
    4746/** Destructor of BoundaryPointSet.
     
    5150BoundaryPointSet::~BoundaryPointSet()
    5251{
    53         Info FunctionInfo(__func__);
     52  Info FunctionInfo(__func__);
    5453  //Log() << Verbose(0) << "Erasing point nr. " << Nr << "." << endl;
    5554  if (!lines.empty())
    56     eLog() << Verbose(2) << "Memory Leak! I " << *this << " am still connected to some lines." << endl;
     55    DoeLog(2) && (eLog() << Verbose(2) << "Memory Leak! I " << *this << " am still connected to some lines." << endl);
    5756  node = NULL;
    58 };
     57}
     58;
    5959
    6060/** Add a line to the LineMap of this point.
     
    6363void BoundaryPointSet::AddLine(BoundaryLineSet * const line)
    6464{
    65         Info FunctionInfo(__func__);
    66   Log() << Verbose(1) << "Adding " << *this << " to line " << *line << "."
    67       << endl;
    68   if (line->endpoints[0] == this)
    69     {
    70       lines.insert(LinePair(line->endpoints[1]->Nr, line));
    71     }
    72   else
    73     {
    74       lines.insert(LinePair(line->endpoints[0]->Nr, line));
    75     }
     65  Info FunctionInfo(__func__);
     66  DoLog(1) && (Log() << Verbose(1) << "Adding " << *this << " to line " << *line << "." << endl);
     67  if (line->endpoints[0] == this) {
     68    lines.insert(LinePair(line->endpoints[1]->Nr, line));
     69  } else {
     70    lines.insert(LinePair(line->endpoints[0]->Nr, line));
     71  }
    7672  LinesCount++;
    77 };
     73}
     74;
    7875
    7976/** output operator for BoundaryPointSet.
     
    9390 */
    9491BoundaryLineSet::BoundaryLineSet() :
    95     Nr(-1)
    96 {
    97         Info FunctionInfo(__func__);
     92  Nr(-1)
     93{
     94  Info FunctionInfo(__func__);
    9895  for (int i = 0; i < 2; i++)
    9996    endpoints[i] = NULL;
    100 };
     97}
     98;
    10199
    102100/** Constructor of BoundaryLineSet with two endpoints.
     
    107105BoundaryLineSet::BoundaryLineSet(BoundaryPointSet * const Point[2], const int number)
    108106{
    109         Info FunctionInfo(__func__);
     107  Info FunctionInfo(__func__);
    110108  // set number
    111109  Nr = number;
     
    118116  skipped = false;
    119117  // clear triangles list
    120   Log() << Verbose(0) << "New Line with endpoints " << *this << "." << endl;
    121 };
     118  DoLog(0) && (Log() << Verbose(0) << "New Line with endpoints " << *this << "." << endl);
     119}
     120;
    122121
    123122/** Constructor of BoundaryLineSet with two endpoints.
     
    140139  skipped = false;
    141140  // clear triangles list
    142   Log() << Verbose(0) << "New Line with endpoints " << *this << "." << endl;
    143 };
     141  DoLog(0) && (Log() << Verbose(0) << "New Line with endpoints " << *this << "." << endl);
     142}
     143;
    144144
    145145/** Destructor for BoundaryLineSet.
     
    149149BoundaryLineSet::~BoundaryLineSet()
    150150{
    151         Info FunctionInfo(__func__);
     151  Info FunctionInfo(__func__);
    152152  int Numbers[2];
    153153
     
    180180        //Log() << Verbose(0) << *endpoints[i] << " has no more lines it's attached to, erasing." << endl;
    181181        if (endpoints[i] != NULL) {
    182           delete(endpoints[i]);
     182          delete (endpoints[i]);
    183183          endpoints[i] = NULL;
    184184        }
     
    187187  }
    188188  if (!triangles.empty())
    189     eLog() << Verbose(2) << "Memory Leak! I " << *this << " am still connected to some triangles." << endl;
    190 };
     189    DoeLog(2) && (eLog() << Verbose(2) << "Memory Leak! I " << *this << " am still connected to some triangles." << endl);
     190}
     191;
    191192
    192193/** Add triangle to TriangleMap of this boundary line.
     
    195196void BoundaryLineSet::AddTriangle(BoundaryTriangleSet * const triangle)
    196197{
    197         Info FunctionInfo(__func__);
    198   Log() << Verbose(0) << "Add " << triangle->Nr << " to line " << *this << "." << endl;
     198  Info FunctionInfo(__func__);
     199  DoLog(0) && (Log() << Verbose(0) << "Add " << triangle->Nr << " to line " << *this << "." << endl);
    199200  triangles.insert(TrianglePair(triangle->Nr, triangle));
    200 };
     201}
     202;
    201203
    202204/** Checks whether we have a common endpoint with given \a *line.
     
    206208bool BoundaryLineSet::IsConnectedTo(const BoundaryLineSet * const line) const
    207209{
    208         Info FunctionInfo(__func__);
     210  Info FunctionInfo(__func__);
    209211  if ((endpoints[0] == line->endpoints[0]) || (endpoints[1] == line->endpoints[0]) || (endpoints[0] == line->endpoints[1]) || (endpoints[1] == line->endpoints[1]))
    210212    return true;
    211213  else
    212214    return false;
    213 };
     215}
     216;
    214217
    215218/** Checks whether the adjacent triangles of a baseline are convex or not.
     
    221224bool BoundaryLineSet::CheckConvexityCriterion() const
    222225{
    223         Info FunctionInfo(__func__);
     226  Info FunctionInfo(__func__);
    224227  Vector BaseLineCenter, BaseLineNormal, BaseLine, helper[2], NormalCheck;
    225228  // get the two triangles
    226229  if (triangles.size() != 2) {
    227     eLog() << Verbose(0) << "Baseline " << *this << " is connected to less than two triangles, Tesselation incomplete!" << endl;
     230    DoeLog(0) && (eLog() << Verbose(0) << "Baseline " << *this << " is connected to less than two triangles, Tesselation incomplete!" << endl);
    228231    return true;
    229232  }
     
    233236  BaseLineCenter.CopyVector(endpoints[0]->node->node);
    234237  BaseLineCenter.AddVector(endpoints[1]->node->node);
    235   BaseLineCenter.Scale(1./2.);
     238  BaseLineCenter.Scale(1. / 2.);
    236239  BaseLine.CopyVector(endpoints[0]->node->node);
    237240  BaseLine.SubtractVector(endpoints[1]->node->node);
     
    241244  NormalCheck.Zero();
    242245  double sign = -1.;
    243   int i=0;
     246  int i = 0;
    244247  class BoundaryPointSet *node = NULL;
    245   for(TriangleMap::const_iterator runner = triangles.begin(); runner != triangles.end(); runner++) {
     248  for (TriangleMap::const_iterator runner = triangles.begin(); runner != triangles.end(); runner++) {
    246249    //Log() << Verbose(0) << "INFO: NormalVector of " << *(runner->second) << " is " << runner->second->NormalVector << "." << endl;
    247250    NormalCheck.AddVector(&runner->second->NormalVector);
     
    249252    sign = -sign;
    250253    if (runner->second->NormalVector.NormSquared() > MYEPSILON)
    251       BaseLineNormal.CopyVector(&runner->second->NormalVector);   // yes, copy second on top of first
     254      BaseLineNormal.CopyVector(&runner->second->NormalVector); // yes, copy second on top of first
    252255    else {
    253       eLog() << Verbose(0) << "Triangle " << *runner->second << " has zero normal vector!" << endl;
     256      DoeLog(0) && (eLog() << Verbose(0) << "Triangle " << *runner->second << " has zero normal vector!" << endl);
    254257    }
    255258    node = runner->second->GetThirdEndpoint(this);
     
    258261      helper[i].CopyVector(node->node->node);
    259262      helper[i].SubtractVector(&BaseLineCenter);
    260       helper[i].MakeNormalVector(&BaseLine);  // we want to compare the triangle's heights' angles!
     263      helper[i].MakeNormalVector(&BaseLine); // we want to compare the triangle's heights' angles!
    261264      //Log() << Verbose(0) << "INFO: Height vector with respect to baseline is " << helper[i] << "." << endl;
    262265      i++;
    263266    } else {
    264       eLog() << Verbose(1) << "I cannot find third node in triangle, something's wrong." << endl;
     267      DoeLog(1) && (eLog() << Verbose(1) << "I cannot find third node in triangle, something's wrong." << endl);
    265268      return true;
    266269    }
     
    268271  //Log() << Verbose(0) << "INFO: BaselineNormal is " << BaseLineNormal << "." << endl;
    269272  if (NormalCheck.NormSquared() < MYEPSILON) {
    270     Log() << Verbose(0) << "ACCEPT: Normalvectors of both triangles are the same: convex." << endl;
     273    DoLog(0) && (Log() << Verbose(0) << "ACCEPT: Normalvectors of both triangles are the same: convex." << endl);
    271274    return true;
    272275  }
     
    274277  double angle = GetAngle(helper[0], helper[1], BaseLineNormal);
    275278  if ((angle - M_PI) > -MYEPSILON) {
    276     Log() << Verbose(0) << "ACCEPT: Angle is greater than pi: convex." << endl;
     279    DoLog(0) && (Log() << Verbose(0) << "ACCEPT: Angle is greater than pi: convex." << endl);
    277280    return true;
    278281  } else {
    279     Log() << Verbose(0) << "REJECT: Angle is less than pi: concave." << endl;
     282    DoLog(0) && (Log() << Verbose(0) << "REJECT: Angle is less than pi: concave." << endl);
    280283    return false;
    281284  }
     
    288291bool BoundaryLineSet::ContainsBoundaryPoint(const BoundaryPointSet * const point) const
    289292{
    290         Info FunctionInfo(__func__);
    291   for(int i=0;i<2;i++)
     293  Info FunctionInfo(__func__);
     294  for (int i = 0; i < 2; i++)
    292295    if (point == endpoints[i])
    293296      return true;
    294297  return false;
    295 };
     298}
     299;
    296300
    297301/** Returns other endpoint of the line.
     
    301305class BoundaryPointSet *BoundaryLineSet::GetOtherEndpoint(const BoundaryPointSet * const point) const
    302306{
    303         Info FunctionInfo(__func__);
     307  Info FunctionInfo(__func__);
    304308  if (endpoints[0] == point)
    305309    return endpoints[1];
     
    308312  else
    309313    return NULL;
    310 };
     314}
     315;
    311316
    312317/** output operator for BoundaryLineSet.
     
    314319 * \param &a boundary line
    315320 */
    316 ostream & operator <<(ostream &ost, const  BoundaryLineSet &a)
     321ostream & operator <<(ostream &ost, const BoundaryLineSet &a)
    317322{
    318323  ost << "[" << a.Nr << "|" << a.endpoints[0]->node->Name << " at " << *a.endpoints[0]->node->node << "," << a.endpoints[1]->node->Name << " at " << *a.endpoints[1]->node->node << "]";
    319324  return ost;
    320 };
     325}
     326;
    321327
    322328// ======================================== Triangles on Boundary =================================
     
    327333  Nr(-1)
    328334{
    329         Info FunctionInfo(__func__);
    330   for (int i = 0; i < 3; i++)
    331     {
    332       endpoints[i] = NULL;
    333       lines[i] = NULL;
    334     }
    335 };
     335  Info FunctionInfo(__func__);
     336  for (int i = 0; i < 3; i++) {
     337    endpoints[i] = NULL;
     338    lines[i] = NULL;
     339  }
     340}
     341;
    336342
    337343/** Constructor for BoundaryTriangleSet with three lines.
     
    342348  Nr(number)
    343349{
    344         Info FunctionInfo(__func__);
     350  Info FunctionInfo(__func__);
    345351  // set number
    346352  // set lines
     
    354360    // for all three lines
    355361    for (int j = 0; j < 2; j++) { // for both endpoints
    356       OrderMap.insert(pair<int, class BoundaryPointSet *> (
    357           line[i]->endpoints[j]->Nr, line[i]->endpoints[j]));
     362      OrderMap.insert(pair<int, class BoundaryPointSet *> (line[i]->endpoints[j]->Nr, line[i]->endpoints[j]));
    358363      // and we don't care whether insertion fails
    359364    }
    360365  // set endpoints
    361366  int Counter = 0;
    362   Log() << Verbose(0) << "New triangle " << Nr << " with end points: " << endl;
     367  DoLog(0) && (Log() << Verbose(0) << "New triangle " << Nr << " with end points: " << endl);
    363368  for (PointMap::iterator runner = OrderMap.begin(); runner != OrderMap.end(); runner++) {
    364369    endpoints[Counter] = runner->second;
    365     Log() << Verbose(0) << " " << *endpoints[Counter] << endl;
     370    DoLog(0) && (Log() << Verbose(0) << " " << *endpoints[Counter] << endl);
    366371    Counter++;
    367372  }
    368373  if (Counter < 3) {
    369     eLog() << Verbose(0) << "We have a triangle with only two distinct endpoints!" << endl;
     374    DoeLog(0) && (eLog() << Verbose(0) << "We have a triangle with only two distinct endpoints!" << endl);
    370375    performCriticalExit();
    371376  }
    372 };
     377}
     378;
    373379
    374380/** Destructor of BoundaryTriangleSet.
     
    378384BoundaryTriangleSet::~BoundaryTriangleSet()
    379385{
    380         Info FunctionInfo(__func__);
     386  Info FunctionInfo(__func__);
    381387  for (int i = 0; i < 3; i++) {
    382388    if (lines[i] != NULL) {
     
    385391      }
    386392      if (lines[i]->triangles.empty()) {
    387           //Log() << Verbose(0) << *lines[i] << " is no more attached to any triangle, erasing." << endl;
    388           delete (lines[i]);
    389           lines[i] = NULL;
     393        //Log() << Verbose(0) << *lines[i] << " is no more attached to any triangle, erasing." << endl;
     394        delete (lines[i]);
     395        lines[i] = NULL;
    390396      }
    391397    }
    392398  }
    393399  //Log() << Verbose(0) << "Erasing triangle Nr." << Nr << " itself." << endl;
    394 };
     400}
     401;
    395402
    396403/** Calculates the normal vector for this triangle.
     
    400407void BoundaryTriangleSet::GetNormalVector(const Vector &OtherVector)
    401408{
    402         Info FunctionInfo(__func__);
     409  Info FunctionInfo(__func__);
    403410  // get normal vector
    404411  NormalVector.MakeNormalVector(endpoints[0]->node->node, endpoints[1]->node->node, endpoints[2]->node->node);
     
    407414  if (NormalVector.ScalarProduct(&OtherVector) > 0.)
    408415    NormalVector.Scale(-1.);
    409   Log() << Verbose(1) << "Normal Vector is " << NormalVector << "." << endl;
    410 };
     416  DoLog(1) && (Log() << Verbose(1) << "Normal Vector is " << NormalVector << "." << endl);
     417}
     418;
    411419
    412420/** Finds the point on the triangle \a *BTS through which the line defined by \a *MolCenter and \a *x crosses.
     
    429437
    430438  if (!Intersection->GetIntersectionWithPlane(&NormalVector, endpoints[0]->node->node, MolCenter, x)) {
    431     eLog() << Verbose(1) << "Alas! Intersection with plane failed - at least numerically - the intersection is not on the plane!" << endl;
     439    DoeLog(1) && (eLog() << Verbose(1) << "Alas! Intersection with plane failed - at least numerically - the intersection is not on the plane!" << endl);
    432440    return false;
    433441  }
    434442
    435   Log() << Verbose(1) << "INFO: Triangle is " << *this << "." << endl;
    436   Log() << Verbose(1) << "INFO: Line is from " << *MolCenter << " to " << *x << "." << endl;
    437   Log() << Verbose(1) << "INFO: Intersection is " << *Intersection << "." << endl;
     443  DoLog(1) && (Log() << Verbose(1) << "INFO: Triangle is " << *this << "." << endl);
     444  DoLog(1) && (Log() << Verbose(1) << "INFO: Line is from " << *MolCenter << " to " << *x << "." << endl);
     445  DoLog(1) && (Log() << Verbose(1) << "INFO: Intersection is " << *Intersection << "." << endl);
    438446
    439447  if (Intersection->DistanceSquared(endpoints[0]->node->node) < MYEPSILON) {
    440     Log() << Verbose(1) << "Intersection coindices with first endpoint." << endl;
     448    DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with first endpoint." << endl);
    441449    return true;
    442   }   else if (Intersection->DistanceSquared(endpoints[1]->node->node) < MYEPSILON) {
    443     Log() << Verbose(1) << "Intersection coindices with second endpoint." << endl;
     450  } else if (Intersection->DistanceSquared(endpoints[1]->node->node) < MYEPSILON) {
     451    DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with second endpoint." << endl);
    444452    return true;
    445   }   else if (Intersection->DistanceSquared(endpoints[2]->node->node) < MYEPSILON) {
    446     Log() << Verbose(1) << "Intersection coindices with third endpoint." << endl;
     453  } else if (Intersection->DistanceSquared(endpoints[2]->node->node) < MYEPSILON) {
     454    DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with third endpoint." << endl);
    447455    return true;
    448456  }
    449457  // Calculate cross point between one baseline and the line from the third endpoint to intersection
    450   int i=0;
     458  int i = 0;
    451459  do {
    452     if (CrossPoint.GetIntersectionOfTwoLinesOnPlane(endpoints[i%3]->node->node, endpoints[(i+1)%3]->node->node, endpoints[(i+2)%3]->node->node, Intersection, &NormalVector)) {
    453       helper.CopyVector(endpoints[(i+1)%3]->node->node);
    454       helper.SubtractVector(endpoints[i%3]->node->node);
    455       CrossPoint.SubtractVector(endpoints[i%3]->node->node); // cross point was returned as absolute vector
    456       const double s = CrossPoint.ScalarProduct(&helper)/helper.NormSquared();
    457       Log() << Verbose(1) << "INFO: Factor s is " << s << "." << endl;
    458       if ((s < -MYEPSILON) || ((s-1.) > MYEPSILON)) {
    459         Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << "outside of triangle." << endl;
    460         i=4;
     460    if (CrossPoint.GetIntersectionOfTwoLinesOnPlane(endpoints[i % 3]->node->node, endpoints[(i + 1) % 3]->node->node, endpoints[(i + 2) % 3]->node->node, Intersection, &NormalVector)) {
     461      helper.CopyVector(endpoints[(i + 1) % 3]->node->node);
     462      helper.SubtractVector(endpoints[i % 3]->node->node);
     463      CrossPoint.SubtractVector(endpoints[i % 3]->node->node); // cross point was returned as absolute vector
     464      const double s = CrossPoint.ScalarProduct(&helper) / helper.NormSquared();
     465      DoLog(1) && (Log() << Verbose(1) << "INFO: Factor s is " << s << "." << endl);
     466      if ((s < -MYEPSILON) || ((s - 1.) > MYEPSILON)) {
     467        DoLog(1) && (Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << "outside of triangle." << endl);
     468        i = 4;
    461469        break;
    462470      }
    463471      i++;
    464     } else 
     472    } else
    465473      break;
    466   } while (i<3);
    467   if (i==3) {
    468     Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << " inside of triangle." << endl;
     474  } while (i < 3);
     475  if (i == 3) {
     476    DoLog(1) && (Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << " inside of triangle." << endl);
    469477    return true;
    470478  } else {
    471     Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << " outside of triangle." << endl;
     479    DoLog(1) && (Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << " outside of triangle." << endl);
    472480    return false;
    473481  }
    474 };
    475 
    476 /** Finds the point on the triangle \a *BTS through which the line defined by \a *MolCenter and \a *x crosses.
    477  * We call Vector::GetIntersectionWithPlane() to receive the intersection point with the plane
     482}
     483;
     484
     485/** Finds the point on the triangle to the point \a *x.
     486 * We call Vector::GetIntersectionWithPlane() with \a * and the center of the triangle to receive an intersection point.
     487 * Then we check the in-plane part (the part projected down onto plane). We check whether it crosses one of the
     488 * boundary lines. If it does, we return this intersection as closest point, otherwise the projected point down.
    478489 * Thus we test if it's really on the plane and whether it's inside the triangle on the plane or not.
    479490 * The latter is done as follows: We calculate the cross point of one of the triangle's baseline with the line
     
    490501
    491502  // 1. get intersection with plane
    492   Log() << Verbose(1) << "INFO: Looking for closest point of triangle " << *this << " to " << *x << "." << endl;
     503  DoLog(1) && (Log() << Verbose(1) << "INFO: Looking for closest point of triangle " << *this << " to " << *x << "." << endl);
    493504  GetCenter(&Direction);
    494505  if (!ClosestPoint->GetIntersectionWithPlane(&NormalVector, endpoints[0]->node->node, x, &Direction)) {
     
    499510  Vector InPlane;
    500511  InPlane.CopyVector(x);
    501   InPlane.SubtractVector(ClosestPoint);  // points from plane intersection to straight-down point
     512  InPlane.SubtractVector(ClosestPoint); // points from plane intersection to straight-down point
    502513  InPlane.ProjectOntoPlane(&NormalVector);
    503514  InPlane.AddVector(ClosestPoint);
    504515
    505   Log() << Verbose(2) << "INFO: Triangle is " << *this << "." << endl;
    506   Log() << Verbose(2) << "INFO: Line is from " << Direction << " to " << *x << "." << endl;
    507   Log() << Verbose(2) << "INFO: In-plane part is " << InPlane << "." << endl;
     516  DoLog(2) && (Log() << Verbose(2) << "INFO: Triangle is " << *this << "." << endl);
     517  DoLog(2) && (Log() << Verbose(2) << "INFO: Line is from " << Direction << " to " << *x << "." << endl);
     518  DoLog(2) && (Log() << Verbose(2) << "INFO: In-plane part is " << InPlane << "." << endl);
    508519
    509520  // Calculate cross point between one baseline and the desired point such that distance is shortest
     
    513524  Vector CrossPoint[3];
    514525  Vector helper;
    515   for (int i=0;i<3;i++) {
     526  for (int i = 0; i < 3; i++) {
    516527    // treat direction of line as normal of a (cut)plane and the desired point x as the plane offset, the intersect line with point
    517     Direction.CopyVector(endpoints[(i+1)%3]->node->node);
    518     Direction.SubtractVector(endpoints[i%3]->node->node);
     528    Direction.CopyVector(endpoints[(i + 1) % 3]->node->node);
     529    Direction.SubtractVector(endpoints[i % 3]->node->node);
    519530    // calculate intersection, line can never be parallel to Direction (is the same vector as PlaneNormal);
    520     CrossPoint[i].GetIntersectionWithPlane(&Direction, &InPlane, endpoints[i%3]->node->node, endpoints[(i+1)%3]->node->node);
     531    CrossPoint[i].GetIntersectionWithPlane(&Direction, &InPlane, endpoints[i % 3]->node->node, endpoints[(i + 1) % 3]->node->node);
    521532    CrossDirection[i].CopyVector(&CrossPoint[i]);
    522533    CrossDirection[i].SubtractVector(&InPlane);
    523     CrossPoint[i].SubtractVector(endpoints[i%3]->node->node); // cross point was returned as absolute vector
    524     const double s = CrossPoint[i].ScalarProduct(&Direction)/Direction.NormSquared();
    525     Log() << Verbose(2) << "INFO: Factor s is " << s << "." << endl;
    526     if ((s >= -MYEPSILON) && ((s-1.) <= MYEPSILON)) {
    527       CrossPoint[i].AddVector(endpoints[i%3]->node->node); // make cross point absolute again
    528       Log() << Verbose(2) << "INFO: Crosspoint is " << CrossPoint[i] << ", intersecting BoundaryLine between " << *endpoints[i%3]->node->node << " and " << *endpoints[(i+1)%3]->node->node << "." << endl;
     534    CrossPoint[i].SubtractVector(endpoints[i % 3]->node->node); // cross point was returned as absolute vector
     535    const double s = CrossPoint[i].ScalarProduct(&Direction) / Direction.NormSquared();
     536    DoLog(2) && (Log() << Verbose(2) << "INFO: Factor s is " << s << "." << endl);
     537    if ((s >= -MYEPSILON) && ((s - 1.) <= MYEPSILON)) {
     538      CrossPoint[i].AddVector(endpoints[i % 3]->node->node); // make cross point absolute again
     539      DoLog(2) && (Log() << Verbose(2) << "INFO: Crosspoint is " << CrossPoint[i] << ", intersecting BoundaryLine between " << *endpoints[i % 3]->node->node << " and " << *endpoints[(i + 1) % 3]->node->node << "." << endl);
    529540      const double distance = CrossPoint[i].DistanceSquared(x);
    530541      if ((ShortestDistance < 0.) || (ShortestDistance > distance)) {
     
    536547  }
    537548  InsideFlag = true;
    538   for (int i=0;i<3;i++) {
    539     const double sign = CrossDirection[i].ScalarProduct(&CrossDirection[(i+1)%3]);
    540     const double othersign = CrossDirection[i].ScalarProduct(&CrossDirection[(i+2)%3]);;
    541     if ((sign > -MYEPSILON) && (othersign > -MYEPSILON))  // have different sign
     549  for (int i = 0; i < 3; i++) {
     550    const double sign = CrossDirection[i].ScalarProduct(&CrossDirection[(i + 1) % 3]);
     551    const double othersign = CrossDirection[i].ScalarProduct(&CrossDirection[(i + 2) % 3]);
     552    ;
     553    if ((sign > -MYEPSILON) && (othersign > -MYEPSILON)) // have different sign
    542554      InsideFlag = false;
    543555  }
     
    545557    ClosestPoint->CopyVector(&InPlane);
    546558    ShortestDistance = InPlane.DistanceSquared(x);
    547   } else {  // also check endnodes
    548     for (int i=0;i<3;i++) {
     559  } else { // also check endnodes
     560    for (int i = 0; i < 3; i++) {
    549561      const double distance = x->DistanceSquared(endpoints[i]->node->node);
    550562      if ((ShortestDistance < 0.) || (ShortestDistance > distance)) {
     
    554566    }
    555567  }
    556   Log() << Verbose(1) << "INFO: Closest Point is " << *ClosestPoint << " with shortest squared distance is " << ShortestDistance << "." << endl;
     568  DoLog(1) && (Log() << Verbose(1) << "INFO: Closest Point is " << *ClosestPoint << " with shortest squared distance is " << ShortestDistance << "." << endl);
    557569  return ShortestDistance;
    558 };
     570}
     571;
    559572
    560573/** Checks whether lines is any of the three boundary lines this triangle contains.
     
    564577bool BoundaryTriangleSet::ContainsBoundaryLine(const BoundaryLineSet * const line) const
    565578{
    566         Info FunctionInfo(__func__);
    567   for(int i=0;i<3;i++)
     579  Info FunctionInfo(__func__);
     580  for (int i = 0; i < 3; i++)
    568581    if (line == lines[i])
    569582      return true;
    570583  return false;
    571 };
     584}
     585;
    572586
    573587/** Checks whether point is any of the three endpoints this triangle contains.
     
    577591bool BoundaryTriangleSet::ContainsBoundaryPoint(const BoundaryPointSet * const point) const
    578592{
    579         Info FunctionInfo(__func__);
    580   for(int i=0;i<3;i++)
     593  Info FunctionInfo(__func__);
     594  for (int i = 0; i < 3; i++)
    581595    if (point == endpoints[i])
    582596      return true;
    583597  return false;
    584 };
     598}
     599;
    585600
    586601/** Checks whether point is any of the three endpoints this triangle contains.
     
    590605bool BoundaryTriangleSet::ContainsBoundaryPoint(const TesselPoint * const point) const
    591606{
    592         Info FunctionInfo(__func__);
    593   for(int i=0;i<3;i++)
     607  Info FunctionInfo(__func__);
     608  for (int i = 0; i < 3; i++)
    594609    if (point == endpoints[i]->node)
    595610      return true;
    596611  return false;
    597 };
     612}
     613;
    598614
    599615/** Checks whether three given \a *Points coincide with triangle's endpoints.
     
    603619bool BoundaryTriangleSet::IsPresentTupel(const BoundaryPointSet * const Points[3]) const
    604620{
    605         Info FunctionInfo(__func__);
    606         Log() << Verbose(1) << "INFO: Checking " << Points[0] << ","  << Points[1] << "," << Points[2] << " against " << endpoints[0] << "," << endpoints[1] << "," << endpoints[2] << "." << endl;
    607   return (((endpoints[0] == Points[0])
    608             || (endpoints[0] == Points[1])
    609             || (endpoints[0] == Points[2])
    610           ) && (
    611             (endpoints[1] == Points[0])
    612             || (endpoints[1] == Points[1])
    613             || (endpoints[1] == Points[2])
    614           ) && (
    615             (endpoints[2] == Points[0])
    616             || (endpoints[2] == Points[1])
    617             || (endpoints[2] == Points[2])
    618 
    619           ));
    620 };
     621  Info FunctionInfo(__func__);
     622  DoLog(1) && (Log() << Verbose(1) << "INFO: Checking " << Points[0] << "," << Points[1] << "," << Points[2] << " against " << endpoints[0] << "," << endpoints[1] << "," << endpoints[2] << "." << endl);
     623  return (((endpoints[0] == Points[0]) || (endpoints[0] == Points[1]) || (endpoints[0] == Points[2])) && ((endpoints[1] == Points[0]) || (endpoints[1] == Points[1]) || (endpoints[1] == Points[2])) && ((endpoints[2] == Points[0]) || (endpoints[2] == Points[1]) || (endpoints[2] == Points[2])
     624
     625  ));
     626}
     627;
    621628
    622629/** Checks whether three given \a *Points coincide with triangle's endpoints.
     
    626633bool BoundaryTriangleSet::IsPresentTupel(const BoundaryTriangleSet * const T) const
    627634{
    628         Info FunctionInfo(__func__);
    629   return (((endpoints[0] == T->endpoints[0])
    630             || (endpoints[0] == T->endpoints[1])
    631             || (endpoints[0] == T->endpoints[2])
    632           ) && (
    633             (endpoints[1] == T->endpoints[0])
    634             || (endpoints[1] == T->endpoints[1])
    635             || (endpoints[1] == T->endpoints[2])
    636           ) && (
    637             (endpoints[2] == T->endpoints[0])
    638             || (endpoints[2] == T->endpoints[1])
    639             || (endpoints[2] == T->endpoints[2])
    640 
    641           ));
    642 };
     635  Info FunctionInfo(__func__);
     636  return (((endpoints[0] == T->endpoints[0]) || (endpoints[0] == T->endpoints[1]) || (endpoints[0] == T->endpoints[2])) && ((endpoints[1] == T->endpoints[0]) || (endpoints[1] == T->endpoints[1]) || (endpoints[1] == T->endpoints[2])) && ((endpoints[2] == T->endpoints[0]) || (endpoints[2] == T->endpoints[1]) || (endpoints[2] == T->endpoints[2])
     637
     638  ));
     639}
     640;
    643641
    644642/** Returns the endpoint which is not contained in the given \a *line.
     
    648646class BoundaryPointSet *BoundaryTriangleSet::GetThirdEndpoint(const BoundaryLineSet * const line) const
    649647{
    650         Info FunctionInfo(__func__);
     648  Info FunctionInfo(__func__);
    651649  // sanity check
    652650  if (!ContainsBoundaryLine(line))
    653651    return NULL;
    654   for(int i=0;i<3;i++)
     652  for (int i = 0; i < 3; i++)
    655653    if (!line->ContainsBoundaryPoint(endpoints[i]))
    656654      return endpoints[i];
    657655  // actually, that' impossible :)
    658656  return NULL;
    659 };
     657}
     658;
    660659
    661660/** Calculates the center point of the triangle.
     
    665664void BoundaryTriangleSet::GetCenter(Vector * const center) const
    666665{
    667         Info FunctionInfo(__func__);
     666  Info FunctionInfo(__func__);
    668667  center->Zero();
    669   for(int i=0;i<3;i++)
     668  for (int i = 0; i < 3; i++)
    670669    center->AddVector(endpoints[i]->node->node);
    671   center->Scale(1./3.);
    672   Log() << Verbose(1) << "INFO: Center is at " << *center << "." << endl;
     670  center->Scale(1. / 3.);
     671  DoLog(1) && (Log() << Verbose(1) << "INFO: Center is at " << *center << "." << endl);
    673672}
    674673
     
    680679{
    681680  ost << "[" << a.Nr << "|" << a.endpoints[0]->node->Name << "," << a.endpoints[1]->node->Name << "," << a.endpoints[2]->node->Name << "]";
    682 //  ost << "[" << a.Nr << "|" << a.endpoints[0]->node->Name << " at " << *a.endpoints[0]->node->node << ","
    683 //      << a.endpoints[1]->node->Name << " at " << *a.endpoints[1]->node->node << "," << a.endpoints[2]->node->Name << " at " << *a.endpoints[2]->node->node << "]";
     681  //  ost << "[" << a.Nr << "|" << a.endpoints[0]->node->Name << " at " << *a.endpoints[0]->node->node << ","
     682  //      << a.endpoints[1]->node->Name << " at " << *a.endpoints[1]->node->node << "," << a.endpoints[2]->node->Name << " at " << *a.endpoints[2]->node->node << "]";
    684683  return ost;
    685 };
     684}
     685;
    686686
    687687// ======================================== Polygons on Boundary =================================
     
    693693{
    694694  Info FunctionInfo(__func__);
    695 };
     695}
     696;
    696697
    697698/** Destructor of BoundaryPolygonSet.
     
    703704  Info FunctionInfo(__func__);
    704705  endpoints.clear();
    705   Log() << Verbose(1) << "Erasing polygon Nr." << Nr << " itself." << endl;
    706 };
     706  DoLog(1) && (Log() << Verbose(1) << "Erasing polygon Nr." << Nr << " itself." << endl);
     707}
     708;
    707709
    708710/** Calculates the normal vector for this triangle.
     
    718720  Vector *TotalNormal = new Vector;
    719721  PointSet::const_iterator Runner[3];
    720   for (int i=0;i<3; i++) {
     722  for (int i = 0; i < 3; i++) {
    721723    Runner[i] = endpoints.begin();
    722     for (int j = 0; j<i; j++) { // go as much further
     724    for (int j = 0; j < i; j++) { // go as much further
    723725      Runner[i]++;
    724726      if (Runner[i] == endpoints.end()) {
    725         eLog() << Verbose(0) << "There are less than three endpoints in the polygon!" << endl;
     727        DoeLog(0) && (eLog() << Verbose(0) << "There are less than three endpoints in the polygon!" << endl);
    726728        performCriticalExit();
    727729      }
     
    729731  }
    730732  TotalNormal->Zero();
    731   int counter=0;
    732   for (; Runner[2] != endpoints.end(); ) {
     733  int counter = 0;
     734  for (; Runner[2] != endpoints.end();) {
    733735    TemporaryNormal.MakeNormalVector((*Runner[0])->node->node, (*Runner[1])->node->node, (*Runner[2])->node->node);
    734     for (int i=0;i<3;i++) // increase each of them
     736    for (int i = 0; i < 3; i++) // increase each of them
    735737      Runner[i]++;
    736738    TotalNormal->AddVector(&TemporaryNormal);
    737739  }
    738   TotalNormal->Scale(1./(double)counter);
     740  TotalNormal->Scale(1. / (double) counter);
    739741
    740742  // make it always point inward (any offset vector onto plane projected onto normal vector suffices)
    741743  if (TotalNormal->ScalarProduct(&OtherVector) > 0.)
    742744    TotalNormal->Scale(-1.);
    743   Log() << Verbose(1) << "Normal Vector is " << *TotalNormal << "." << endl;
     745  DoLog(1) && (Log() << Verbose(1) << "Normal Vector is " << *TotalNormal << "." << endl);
    744746
    745747  return TotalNormal;
    746 };
     748}
     749;
    747750
    748751/** Calculates the center point of the triangle.
     
    755758  center->Zero();
    756759  int counter = 0;
    757   for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) {
     760  for (PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) {
    758761    center->AddVector((*Runner)->node->node);
    759762    counter++;
    760763  }
    761   center->Scale(1./(double)counter);
    762   Log() << Verbose(1) << "Center is at " << *center << "." << endl;
     764  center->Scale(1. / (double) counter);
     765  DoLog(1) && (Log() << Verbose(1) << "Center is at " << *center << "." << endl);
    763766}
    764767
     
    771774  Info FunctionInfo(__func__);
    772775  return ContainsPresentTupel(triangle->endpoints, 3);
    773 };
     776}
     777;
    774778
    775779/** Checks whether the polygons contains both endpoints of the line.
     
    781785  Info FunctionInfo(__func__);
    782786  return ContainsPresentTupel(line->endpoints, 2);
    783 };
     787}
     788;
    784789
    785790/** Checks whether point is any of the three endpoints this triangle contains.
     
    790795{
    791796  Info FunctionInfo(__func__);
    792   for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) {
    793     Log() << Verbose(0) << "Checking against " << **Runner << endl;
     797  for (PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) {
     798    DoLog(0) && (Log() << Verbose(0) << "Checking against " << **Runner << endl);
    794799    if (point == (*Runner)) {
    795       Log() << Verbose(0) << " Contained." << endl;
     800      DoLog(0) && (Log() << Verbose(0) << " Contained." << endl);
    796801      return true;
    797802    }
    798803  }
    799   Log() << Verbose(0) << " Not contained." << endl;
     804  DoLog(0) && (Log() << Verbose(0) << " Not contained." << endl);
    800805  return false;
    801 };
     806}
     807;
    802808
    803809/** Checks whether point is any of the three endpoints this triangle contains.
     
    808814{
    809815  Info FunctionInfo(__func__);
    810   for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++)
     816  for (PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++)
    811817    if (point == (*Runner)->node) {
    812       Log() << Verbose(0) << " Contained." << endl;
     818      DoLog(0) && (Log() << Verbose(0) << " Contained." << endl);
    813819      return true;
    814820    }
    815   Log() << Verbose(0) << " Not contained." << endl;
     821  DoLog(0) && (Log() << Verbose(0) << " Not contained." << endl);
    816822  return false;
    817 };
     823}
     824;
    818825
    819826/** Checks whether given array of \a *Points coincide with polygons's endpoints.
     
    826833  Info FunctionInfo(__func__);
    827834  int counter = 0;
    828   Log() << Verbose(1) << "Polygon is " << *this << endl;
    829   for(int i=0;i<dim;i++) {
    830     Log() << Verbose(1) << " Testing endpoint " << *Points[i] << endl;
     835  DoLog(1) && (Log() << Verbose(1) << "Polygon is " << *this << endl);
     836  for (int i = 0; i < dim; i++) {
     837    DoLog(1) && (Log() << Verbose(1) << " Testing endpoint " << *Points[i] << endl);
    831838    if (ContainsBoundaryPoint(Points[i])) {
    832839      counter++;
     
    838845  else
    839846    return false;
    840 };
     847}
     848;
    841849
    842850/** Checks whether given PointList coincide with polygons's endpoints.
     
    848856  Info FunctionInfo(__func__);
    849857  size_t counter = 0;
    850   Log() << Verbose(1) << "Polygon is " << *this << endl;
    851   for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) {
    852     Log() << Verbose(1) << " Testing endpoint " << **Runner << endl;
     858  DoLog(1) && (Log() << Verbose(1) << "Polygon is " << *this << endl);
     859  for (PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) {
     860    DoLog(1) && (Log() << Verbose(1) << " Testing endpoint " << **Runner << endl);
    853861    if (ContainsBoundaryPoint(*Runner))
    854862      counter++;
     
    859867  else
    860868    return false;
    861 };
     869}
     870;
    862871
    863872/** Checks whether given set of \a *Points coincide with polygons's endpoints.
     
    867876bool BoundaryPolygonSet::ContainsPresentTupel(const BoundaryPolygonSet * const P) const
    868877{
    869   return ContainsPresentTupel((const PointSet)P->endpoints);
    870 };
     878  return ContainsPresentTupel((const PointSet) P->endpoints);
     879}
     880;
    871881
    872882/** Gathers all the endpoints' triangles in a unique set.
     
    876886{
    877887  Info FunctionInfo(__func__);
    878   pair <TriangleSet::iterator, bool> Tester;
     888  pair<TriangleSet::iterator, bool> Tester;
    879889  TriangleSet *triangles = new TriangleSet;
    880890
    881   for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++)
    882     for(LineMap::const_iterator Walker = (*Runner)->lines.begin(); Walker != (*Runner)->lines.end(); Walker++)
    883       for(TriangleMap::const_iterator Sprinter = (Walker->second)->triangles.begin(); Sprinter != (Walker->second)->triangles.end(); Sprinter++) {
     891  for (PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++)
     892    for (LineMap::const_iterator Walker = (*Runner)->lines.begin(); Walker != (*Runner)->lines.end(); Walker++)
     893      for (TriangleMap::const_iterator Sprinter = (Walker->second)->triangles.begin(); Sprinter != (Walker->second)->triangles.end(); Sprinter++) {
    884894        //Log() << Verbose(0) << " Testing triangle " << *(Sprinter->second) << endl;
    885895        if (ContainsBoundaryTriangle(Sprinter->second)) {
    886896          Tester = triangles->insert(Sprinter->second);
    887897          if (Tester.second)
    888             Log() << Verbose(0) << "Adding triangle " << *(Sprinter->second) << endl;
     898            DoLog(0) && (Log() << Verbose(0) << "Adding triangle " << *(Sprinter->second) << endl);
    889899        }
    890900      }
    891901
    892   Log() << Verbose(1) << "The Polygon of " << endpoints.size() << " endpoints has " << triangles->size() << " unique triangles in total." << endl;
     902  DoLog(1) && (Log() << Verbose(1) << "The Polygon of " << endpoints.size() << " endpoints has " << triangles->size() << " unique triangles in total." << endl);
    893903  return triangles;
    894 };
     904}
     905;
    895906
    896907/** Fills the endpoints of this polygon from the triangles attached to \a *line.
     
    901912{
    902913  Info FunctionInfo(__func__);
    903   pair <PointSet::iterator, bool> Tester;
     914  pair<PointSet::iterator, bool> Tester;
    904915  if (line == NULL)
    905916    return false;
    906   Log() << Verbose(1) << "Filling polygon from line " << *line << endl;
    907   for(TriangleMap::const_iterator Runner = line->triangles.begin(); Runner != line->triangles.end(); Runner++) {
    908     for (int i=0;i<3;i++) {
     917  DoLog(1) && (Log() << Verbose(1) << "Filling polygon from line " << *line << endl);
     918  for (TriangleMap::const_iterator Runner = line->triangles.begin(); Runner != line->triangles.end(); Runner++) {
     919    for (int i = 0; i < 3; i++) {
    909920      Tester = endpoints.insert((Runner->second)->endpoints[i]);
    910921      if (Tester.second)
    911         Log() << Verbose(1) << "  Inserting endpoint " << *((Runner->second)->endpoints[i]) << endl;
     922        DoLog(1) && (Log() << Verbose(1) << "  Inserting endpoint " << *((Runner->second)->endpoints[i]) << endl);
    912923    }
    913924  }
    914925
    915926  return true;
    916 };
     927}
     928;
    917929
    918930/** output operator for BoundaryPolygonSet.
     
    923935{
    924936  ost << "[" << a.Nr << "|";
    925   for(PointSet::const_iterator Runner = a.endpoints.begin(); Runner != a.endpoints.end();) {
    926    ost << (*Runner)->node->Name;
    927    Runner++;
    928    if (Runner != a.endpoints.end())
    929      ost << ",";
    930   }
    931   ost<< "]";
     937  for (PointSet::const_iterator Runner = a.endpoints.begin(); Runner != a.endpoints.end();) {
     938    ost << (*Runner)->node->Name;
     939    Runner++;
     940    if (Runner != a.endpoints.end())
     941      ost << ",";
     942  }
     943  ost << "]";
    932944  return ost;
    933 };
     945}
     946;
    934947
    935948// =========================================================== class TESSELPOINT ===========================================
     
    942955  node = NULL;
    943956  nr = -1;
    944   Name =  NULL;
    945 };
     957  Name = NULL;
     958}
     959;
    946960
    947961/** Destructor for class TesselPoint.
     
    950964{
    951965  //Info FunctionInfo(__func__);
    952 };
     966}
     967;
    953968
    954969/** Prints LCNode to screen.
    955970 */
    956 ostream & operator << (ostream &ost, const TesselPoint &a)
     971ostream & operator <<(ostream &ost, const TesselPoint &a)
    957972{
    958973  ost << "[" << (a.Name) << "|" << a.Name << " at " << *a.node << "]";
    959974  return ost;
    960 };
     975}
     976;
    961977
    962978/** Prints LCNode to screen.
    963979 */
    964 ostream & TesselPoint::operator << (ostream &ost)
    965 {
    966         Info FunctionInfo(__func__);
     980ostream & TesselPoint::operator <<(ostream &ost)
     981{
     982  Info FunctionInfo(__func__);
    967983  ost << "[" << (nr) << "|" << this << "]";
    968984  return ost;
    969 };
    970 
     985}
     986;
    971987
    972988// =========================================================== class POINTCLOUD ============================================
     
    976992PointCloud::PointCloud()
    977993{
    978         //Info FunctionInfo(__func__);
    979 };
     994  //Info FunctionInfo(__func__);
     995}
     996;
    980997
    981998/** Destructor for class PointCloud.
     
    9831000PointCloud::~PointCloud()
    9841001{
    985         //Info FunctionInfo(__func__);
    986 };
     1002  //Info FunctionInfo(__func__);
     1003}
     1004;
    9871005
    9881006// ============================ CandidateForTesselation =============================
     
    9901008/** Constructor of class CandidateForTesselation.
    9911009 */
    992 CandidateForTesselation::CandidateForTesselation (BoundaryLineSet* line) :
    993   BaseLine(line),
    994   ShortestAngle(2.*M_PI),
    995   OtherShortestAngle(2.*M_PI)
    996 {
    997         Info FunctionInfo(__func__);
    998 };
    999 
     1010CandidateForTesselation::CandidateForTesselation(BoundaryLineSet* line) :
     1011  BaseLine(line), ThirdPoint(NULL), T(NULL), ShortestAngle(2. * M_PI), OtherShortestAngle(2. * M_PI)
     1012{
     1013  Info FunctionInfo(__func__);
     1014}
     1015;
    10001016
    10011017/** Constructor of class CandidateForTesselation.
    10021018 */
    1003 CandidateForTesselation::CandidateForTesselation (TesselPoint *candidate, BoundaryLineSet* line, Vector OptCandidateCenter, Vector OtherOptCandidateCenter) :
    1004     BaseLine(line),
    1005     ShortestAngle(2.*M_PI),
    1006     OtherShortestAngle(2.*M_PI)
    1007 {
    1008         Info FunctionInfo(__func__);
     1019CandidateForTesselation::CandidateForTesselation(TesselPoint *candidate, BoundaryLineSet* line, BoundaryPointSet* point, Vector OptCandidateCenter, Vector OtherOptCandidateCenter) :
     1020  BaseLine(line), ThirdPoint(point), T(NULL), ShortestAngle(2. * M_PI), OtherShortestAngle(2. * M_PI)
     1021{
     1022  Info FunctionInfo(__func__);
    10091023  OptCenter.CopyVector(&OptCandidateCenter);
    10101024  OtherOptCenter.CopyVector(&OtherOptCandidateCenter);
    1011 };
     1025}
     1026;
    10121027
    10131028/** Destructor for class CandidateForTesselation.
    10141029 */
    1015 CandidateForTesselation::~CandidateForTesselation() {
    1016   BaseLine = NULL;
    1017 };
     1030CandidateForTesselation::~CandidateForTesselation()
     1031{
     1032}
     1033;
     1034
     1035/** Checks validity of a given sphere of a candidate line.
     1036 * Sphere must touch all candidates and the baseline endpoints and there must be no other atoms inside.
     1037 * \param RADIUS radius of sphere
     1038 * \param *LC LinkedCell structure with other atoms
     1039 * \return true - sphere is valid, false - sphere contains other points
     1040 */
     1041bool CandidateForTesselation::CheckValidity(const double RADIUS, const LinkedCell *LC) const
     1042{
     1043  Info FunctionInfo(__func__);
     1044
     1045  const double radiusSquared = RADIUS * RADIUS;
     1046  list<const Vector *> VectorList;
     1047  VectorList.push_back(&OptCenter);
     1048  //VectorList.push_back(&OtherOptCenter);  // don't check the other (wrong) center
     1049
     1050  if (!pointlist.empty())
     1051    DoLog(1) && (Log() << Verbose(1) << "INFO: Checking whether sphere contains candidate list and baseline " << *BaseLine->endpoints[0] << "<->" << *BaseLine->endpoints[1] << " only ..." << endl);
     1052  else
     1053    DoLog(1) && (Log() << Verbose(1) << "INFO: Checking whether sphere with no candidates contains baseline " << *BaseLine->endpoints[0] << "<->" << *BaseLine->endpoints[1] << " only ..." << endl);
     1054  // check baseline for OptCenter and OtherOptCenter being on sphere's surface
     1055  for (list<const Vector *>::const_iterator VRunner = VectorList.begin(); VRunner != VectorList.end(); ++VRunner) {
     1056    for (int i = 0; i < 2; i++) {
     1057      const double distance = fabs((*VRunner)->DistanceSquared(BaseLine->endpoints[i]->node->node) - radiusSquared);
     1058      if (distance > HULLEPSILON) {
     1059        DoeLog(1) && (eLog() << Verbose(1) << "Endpoint " << *BaseLine->endpoints[i] << " is out of sphere at " << *(*VRunner) << " by " << distance << "." << endl);
     1060        return false;
     1061      }
     1062    }
     1063  }
     1064
     1065  // check Candidates for OptCenter and OtherOptCenter being on sphere's surface
     1066  for (TesselPointList::const_iterator Runner = pointlist.begin(); Runner != pointlist.end(); ++Runner) {
     1067    const TesselPoint *Walker = *Runner;
     1068    for (list<const Vector *>::const_iterator VRunner = VectorList.begin(); VRunner != VectorList.end(); ++VRunner) {
     1069      const double distance = fabs((*VRunner)->DistanceSquared(Walker->node) - radiusSquared);
     1070      if (distance > HULLEPSILON) {
     1071        DoeLog(1) && (eLog() << Verbose(1) << "Candidate " << *Walker << " is out of sphere at " << *(*VRunner) << " by " << distance << "." << endl);
     1072        return false;
     1073      } else {
     1074        DoLog(1) && (Log() << Verbose(1) << "Candidate " << *Walker << " is inside by " << distance << "." << endl);
     1075      }
     1076    }
     1077  }
     1078
     1079  DoLog(1) && (Log() << Verbose(1) << "INFO: Checking whether sphere contains no others points ..." << endl);
     1080  bool flag = true;
     1081  for (list<const Vector *>::const_iterator VRunner = VectorList.begin(); VRunner != VectorList.end(); ++VRunner) {
     1082    // get all points inside the sphere
     1083    TesselPointList *ListofPoints = LC->GetPointsInsideSphere(RADIUS, (*VRunner));
     1084
     1085    DoLog(1) && (Log() << Verbose(1) << "The following atoms are inside sphere at " << OtherOptCenter << ":" << endl);
     1086    for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner)
     1087      DoLog(1) && (Log() << Verbose(1) << "  " << *(*Runner) << " with distance " << (*Runner)->node->Distance(&OtherOptCenter) << "." << endl);
     1088
     1089    // remove baseline's endpoints and candidates
     1090    for (int i = 0; i < 2; i++) {
     1091      DoLog(1) && (Log() << Verbose(1) << "INFO: removing baseline tesselpoint " << *BaseLine->endpoints[i]->node << "." << endl);
     1092      ListofPoints->remove(BaseLine->endpoints[i]->node);
     1093    }
     1094    for (TesselPointList::const_iterator Runner = pointlist.begin(); Runner != pointlist.end(); ++Runner) {
     1095      DoLog(1) && (Log() << Verbose(1) << "INFO: removing candidate tesselpoint " << *(*Runner) << "." << endl);
     1096      ListofPoints->remove(*Runner);
     1097    }
     1098    if (!ListofPoints->empty()) {
     1099      DoeLog(1) && (eLog() << Verbose(1) << "CheckValidity: There are still " << ListofPoints->size() << " points inside the sphere." << endl);
     1100      flag = false;
     1101      DoeLog(1) && (eLog() << Verbose(1) << "External atoms inside of sphere at " << *(*VRunner) << ":" << endl);
     1102      for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner)
     1103        DoeLog(1) && (eLog() << Verbose(1) << "  " << *(*Runner) << endl);
     1104    }
     1105    delete (ListofPoints);
     1106
     1107    // check with animate_sphere.tcl VMD script
     1108    if (ThirdPoint != NULL) {
     1109      DoLog(1) && (Log() << Verbose(1) << "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr + 1 << " " << BaseLine->endpoints[1]->Nr + 1 << " " << ThirdPoint->Nr + 1 << " " << RADIUS << " " << OldCenter.x[0] << " " << OldCenter.x[1] << " " << OldCenter.x[2] << " " << (*VRunner)->x[0] << " " << (*VRunner)->x[1] << " " << (*VRunner)->x[2] << endl);
     1110    } else {
     1111      DoLog(1) && (Log() << Verbose(1) << "Check by: ... missing third point ..." << endl);
     1112      DoLog(1) && (Log() << Verbose(1) << "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr + 1 << " " << BaseLine->endpoints[1]->Nr + 1 << " ??? " << RADIUS << " " << OldCenter.x[0] << " " << OldCenter.x[1] << " " << OldCenter.x[2] << " " << (*VRunner)->x[0] << " " << (*VRunner)->x[1] << " " << (*VRunner)->x[2] << endl);
     1113    }
     1114  }
     1115  return flag;
     1116}
     1117;
    10181118
    10191119/** output operator for CandidateForTesselation.
     
    10211121 * \param &a boundary line
    10221122 */
    1023 ostream & operator <<(ostream &ost, const  CandidateForTesselation &a)
     1123ostream & operator <<(ostream &ost, const CandidateForTesselation &a)
    10241124{
    10251125  ost << "[" << a.BaseLine->Nr << "|" << a.BaseLine->endpoints[0]->node->Name << "," << a.BaseLine->endpoints[1]->node->Name << "] with ";
     
    10341134    for (TesselPointList::const_iterator Runner = a.pointlist.begin(); Runner != a.pointlist.end(); Runner++)
    10351135      ost << *(*Runner) << " ";
    1036     ost << " at angle " << (a.ShortestAngle)<< ".";
     1136    ost << " at angle " << (a.ShortestAngle) << ".";
    10371137  }
    10381138
    10391139  return ost;
    1040 };
    1041 
     1140}
     1141;
    10421142
    10431143// =========================================================== class TESSELATION ===========================================
     
    10461146 */
    10471147Tesselation::Tesselation() :
    1048   PointsOnBoundaryCount(0),
    1049   LinesOnBoundaryCount(0),
    1050   TrianglesOnBoundaryCount(0),
    1051   LastTriangle(NULL),
    1052   TriangleFilesWritten(0),
    1053   InternalPointer(PointsOnBoundary.begin())
    1054 {
    1055         Info FunctionInfo(__func__);
     1148  PointsOnBoundaryCount(0), LinesOnBoundaryCount(0), TrianglesOnBoundaryCount(0), LastTriangle(NULL), TriangleFilesWritten(0), InternalPointer(PointsOnBoundary.begin())
     1149{
     1150  Info FunctionInfo(__func__);
    10561151}
    10571152;
     
    10621157Tesselation::~Tesselation()
    10631158{
    1064         Info FunctionInfo(__func__);
    1065   Log() << Verbose(0) << "Free'ing TesselStruct ... " << endl;
     1159  Info FunctionInfo(__func__);
     1160  DoLog(0) && (Log() << Verbose(0) << "Free'ing TesselStruct ... " << endl);
    10661161  for (TriangleMap::iterator runner = TrianglesOnBoundary.begin(); runner != TrianglesOnBoundary.end(); runner++) {
    10671162    if (runner->second != NULL) {
     
    10691164      runner->second = NULL;
    10701165    } else
    1071       eLog() << Verbose(1) << "The triangle " << runner->first << " has already been free'd." << endl;
    1072   }
    1073   Log() << Verbose(0) << "This envelope was written to file " << TriangleFilesWritten << " times(s)." << endl;
     1166      DoeLog(1) && (eLog() << Verbose(1) << "The triangle " << runner->first << " has already been free'd." << endl);
     1167  }
     1168  DoLog(0) && (Log() << Verbose(0) << "This envelope was written to file " << TriangleFilesWritten << " times(s)." << endl);
    10741169}
    10751170;
     
    10771172/** PointCloud implementation of GetCenter
    10781173 * Uses PointsOnBoundary and STL stuff.
    1079  */   
     1174 */
    10801175Vector * Tesselation::GetCenter(ofstream *out) const
    10811176{
    1082         Info FunctionInfo(__func__);
    1083   Vector *Center = new Vector(0.,0.,0.);
    1084   int num=0;
     1177  Info FunctionInfo(__func__);
     1178  Vector *Center = new Vector(0., 0., 0.);
     1179  int num = 0;
    10851180  for (GoToFirst(); (!IsEnd()); GoToNext()) {
    10861181    Center->AddVector(GetPoint()->node);
    10871182    num++;
    10881183  }
    1089   Center->Scale(1./num);
     1184  Center->Scale(1. / num);
    10901185  return Center;
    1091 };
     1186}
     1187;
    10921188
    10931189/** PointCloud implementation of GoPoint
    10941190 * Uses PointsOnBoundary and STL stuff.
    1095  */   
     1191 */
    10961192TesselPoint * Tesselation::GetPoint() const
    10971193{
    1098         Info FunctionInfo(__func__);
     1194  Info FunctionInfo(__func__);
    10991195  return (InternalPointer->second->node);
    1100 };
     1196}
     1197;
    11011198
    11021199/** PointCloud implementation of GetTerminalPoint.
    11031200 * Uses PointsOnBoundary and STL stuff.
    1104  */   
     1201 */
    11051202TesselPoint * Tesselation::GetTerminalPoint() const
    11061203{
    1107         Info FunctionInfo(__func__);
     1204  Info FunctionInfo(__func__);
    11081205  PointMap::const_iterator Runner = PointsOnBoundary.end();
    11091206  Runner--;
    11101207  return (Runner->second->node);
    1111 };
     1208}
     1209;
    11121210
    11131211/** PointCloud implementation of GoToNext.
    11141212 * Uses PointsOnBoundary and STL stuff.
    1115  */   
     1213 */
    11161214void Tesselation::GoToNext() const
    11171215{
    1118         Info FunctionInfo(__func__);
     1216  Info FunctionInfo(__func__);
    11191217  if (InternalPointer != PointsOnBoundary.end())
    11201218    InternalPointer++;
    1121 };
     1219}
     1220;
    11221221
    11231222/** PointCloud implementation of GoToPrevious.
    11241223 * Uses PointsOnBoundary and STL stuff.
    1125  */   
     1224 */
    11261225void Tesselation::GoToPrevious() const
    11271226{
    1128         Info FunctionInfo(__func__);
     1227  Info FunctionInfo(__func__);
    11291228  if (InternalPointer != PointsOnBoundary.begin())
    11301229    InternalPointer--;
    1131 };
     1230}
     1231;
    11321232
    11331233/** PointCloud implementation of GoToFirst.
    11341234 * Uses PointsOnBoundary and STL stuff.
    1135  */   
     1235 */
    11361236void Tesselation::GoToFirst() const
    11371237{
    1138         Info FunctionInfo(__func__);
     1238  Info FunctionInfo(__func__);
    11391239  InternalPointer = PointsOnBoundary.begin();
    1140 };
     1240}
     1241;
    11411242
    11421243/** PointCloud implementation of GoToLast.
     
    11451246void Tesselation::GoToLast() const
    11461247{
    1147         Info FunctionInfo(__func__);
     1248  Info FunctionInfo(__func__);
    11481249  InternalPointer = PointsOnBoundary.end();
    11491250  InternalPointer--;
    1150 };
     1251}
     1252;
    11511253
    11521254/** PointCloud implementation of IsEmpty.
    11531255 * Uses PointsOnBoundary and STL stuff.
    1154  */   
     1256 */
    11551257bool Tesselation::IsEmpty() const
    11561258{
    1157         Info FunctionInfo(__func__);
     1259  Info FunctionInfo(__func__);
    11581260  return (PointsOnBoundary.empty());
    1159 };
     1261}
     1262;
    11601263
    11611264/** PointCloud implementation of IsLast.
    11621265 * Uses PointsOnBoundary and STL stuff.
    1163  */   
     1266 */
    11641267bool Tesselation::IsEnd() const
    11651268{
    1166         Info FunctionInfo(__func__);
     1269  Info FunctionInfo(__func__);
    11671270  return (InternalPointer == PointsOnBoundary.end());
    1168 };
    1169 
     1271}
     1272;
    11701273
    11711274/** Gueses first starting triangle of the convex envelope.
     
    11761279void Tesselation::GuessStartingTriangle()
    11771280{
    1178         Info FunctionInfo(__func__);
     1281  Info FunctionInfo(__func__);
    11791282  // 4b. create a starting triangle
    11801283  // 4b1. create all distances
     
    11861289
    11871290  // with A chosen, take each pair B,C and sort
    1188   if (A != PointsOnBoundary.end())
    1189     {
    1190       B = A;
    1191       B++;
    1192       for (; B != PointsOnBoundary.end(); B++)
    1193         {
    1194           C = B;
    1195           C++;
    1196           for (; C != PointsOnBoundary.end(); C++)
    1197             {
    1198               tmp = A->second->node->node->DistanceSquared(B->second->node->node);
    1199               distance = tmp * tmp;
    1200               tmp = A->second->node->node->DistanceSquared(C->second->node->node);
    1201               distance += tmp * tmp;
    1202               tmp = B->second->node->node->DistanceSquared(C->second->node->node);
    1203               distance += tmp * tmp;
    1204               DistanceMMap.insert(DistanceMultiMapPair(distance, pair<PointMap::iterator, PointMap::iterator> (B, C)));
    1205             }
    1206         }
    1207     }
     1291  if (A != PointsOnBoundary.end()) {
     1292    B = A;
     1293    B++;
     1294    for (; B != PointsOnBoundary.end(); B++) {
     1295      C = B;
     1296      C++;
     1297      for (; C != PointsOnBoundary.end(); C++) {
     1298        tmp = A->second->node->node->DistanceSquared(B->second->node->node);
     1299        distance = tmp * tmp;
     1300        tmp = A->second->node->node->DistanceSquared(C->second->node->node);
     1301        distance += tmp * tmp;
     1302        tmp = B->second->node->node->DistanceSquared(C->second->node->node);
     1303        distance += tmp * tmp;
     1304        DistanceMMap.insert(DistanceMultiMapPair(distance, pair<PointMap::iterator, PointMap::iterator> (B, C)));
     1305      }
     1306    }
     1307  }
    12081308  //    // listing distances
    12091309  //    Log() << Verbose(1) << "Listing DistanceMMap:";
     
    12151315  // 1. we take from the smallest sum of squared distance as the base line BC (with peak A) onward as the triangle candidate
    12161316  DistanceMultiMap::iterator baseline = DistanceMMap.begin();
    1217   for (; baseline != DistanceMMap.end(); baseline++)
    1218     {
    1219       // we take from the smallest sum of squared distance as the base line BC (with peak A) onward as the triangle candidate
    1220       // 2. next, we have to check whether all points reside on only one side of the triangle
    1221       // 3. construct plane vector
    1222       PlaneVector.MakeNormalVector(A->second->node->node,
    1223           baseline->second.first->second->node->node,
    1224           baseline->second.second->second->node->node);
    1225       Log() << Verbose(2) << "Plane vector of candidate triangle is " << PlaneVector << endl;
    1226       // 4. loop over all points
    1227       double sign = 0.;
    1228       PointMap::iterator checker = PointsOnBoundary.begin();
    1229       for (; checker != PointsOnBoundary.end(); checker++)
    1230         {
    1231           // (neglecting A,B,C)
    1232           if ((checker == A) || (checker == baseline->second.first) || (checker
    1233               == baseline->second.second))
    1234             continue;
    1235           // 4a. project onto plane vector
    1236           TrialVector.CopyVector(checker->second->node->node);
    1237           TrialVector.SubtractVector(A->second->node->node);
    1238           distance = TrialVector.ScalarProduct(&PlaneVector);
    1239           if (fabs(distance) < 1e-4) // we need to have a small epsilon around 0 which is still ok
    1240             continue;
    1241           Log() << Verbose(2) << "Projection of " << checker->second->node->Name << " yields distance of " << distance << "." << endl;
    1242           tmp = distance / fabs(distance);
    1243           // 4b. Any have different sign to than before? (i.e. would lie outside convex hull with this starting triangle)
    1244           if ((sign != 0) && (tmp != sign))
    1245             {
    1246               // 4c. If so, break 4. loop and continue with next candidate in 1. loop
    1247               Log() << Verbose(2) << "Current candidates: "
    1248                   << A->second->node->Name << ","
    1249                   << baseline->second.first->second->node->Name << ","
    1250                   << baseline->second.second->second->node->Name << " leaves "
    1251                   << checker->second->node->Name << " outside the convex hull."
    1252                   << endl;
    1253               break;
    1254             }
    1255           else
    1256             { // note the sign for later
    1257               Log() << Verbose(2) << "Current candidates: "
    1258                   << A->second->node->Name << ","
    1259                   << baseline->second.first->second->node->Name << ","
    1260                   << baseline->second.second->second->node->Name << " leave "
    1261                   << checker->second->node->Name << " inside the convex hull."
    1262                   << endl;
    1263               sign = tmp;
    1264             }
    1265           // 4d. Check whether the point is inside the triangle (check distance to each node
    1266           tmp = checker->second->node->node->DistanceSquared(A->second->node->node);
    1267           int innerpoint = 0;
    1268           if ((tmp < A->second->node->node->DistanceSquared(
    1269               baseline->second.first->second->node->node)) && (tmp
    1270               < A->second->node->node->DistanceSquared(
    1271                   baseline->second.second->second->node->node)))
    1272             innerpoint++;
    1273           tmp = checker->second->node->node->DistanceSquared(
    1274               baseline->second.first->second->node->node);
    1275           if ((tmp < baseline->second.first->second->node->node->DistanceSquared(
    1276               A->second->node->node)) && (tmp
    1277               < baseline->second.first->second->node->node->DistanceSquared(
    1278                   baseline->second.second->second->node->node)))
    1279             innerpoint++;
    1280           tmp = checker->second->node->node->DistanceSquared(
    1281               baseline->second.second->second->node->node);
    1282           if ((tmp < baseline->second.second->second->node->node->DistanceSquared(
    1283               baseline->second.first->second->node->node)) && (tmp
    1284               < baseline->second.second->second->node->node->DistanceSquared(
    1285                   A->second->node->node)))
    1286             innerpoint++;
    1287           // 4e. If so, break 4. loop and continue with next candidate in 1. loop
    1288           if (innerpoint == 3)
    1289             break;
    1290         }
    1291       // 5. come this far, all on same side? Then break 1. loop and construct triangle
    1292       if (checker == PointsOnBoundary.end())
    1293         {
    1294           Log() << Verbose(2) << "Looks like we have a candidate!" << endl;
    1295           break;
    1296         }
    1297     }
    1298   if (baseline != DistanceMMap.end())
    1299     {
    1300       BPS[0] = baseline->second.first->second;
    1301       BPS[1] = baseline->second.second->second;
    1302       BLS[0] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount);
    1303       BPS[0] = A->second;
    1304       BPS[1] = baseline->second.second->second;
    1305       BLS[1] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount);
    1306       BPS[0] = baseline->second.first->second;
    1307       BPS[1] = A->second;
    1308       BLS[2] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount);
    1309 
    1310       // 4b3. insert created triangle
    1311       BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
    1312       TrianglesOnBoundary.insert(TrianglePair(TrianglesOnBoundaryCount, BTS));
    1313       TrianglesOnBoundaryCount++;
    1314       for (int i = 0; i < NDIM; i++)
    1315         {
    1316           LinesOnBoundary.insert(LinePair(LinesOnBoundaryCount, BTS->lines[i]));
    1317           LinesOnBoundaryCount++;
    1318         }
    1319 
    1320       Log() << Verbose(1) << "Starting triangle is " << *BTS << "." << endl;
    1321     }
    1322   else
    1323     {
    1324       eLog() << Verbose(0) << "No starting triangle found." << endl;
    1325     }
     1317  for (; baseline != DistanceMMap.end(); baseline++) {
     1318    // we take from the smallest sum of squared distance as the base line BC (with peak A) onward as the triangle candidate
     1319    // 2. next, we have to check whether all points reside on only one side of the triangle
     1320    // 3. construct plane vector
     1321    PlaneVector.MakeNormalVector(A->second->node->node, baseline->second.first->second->node->node, baseline->second.second->second->node->node);
     1322    DoLog(2) && (Log() << Verbose(2) << "Plane vector of candidate triangle is " << PlaneVector << endl);
     1323    // 4. loop over all points
     1324    double sign = 0.;
     1325    PointMap::iterator checker = PointsOnBoundary.begin();
     1326    for (; checker != PointsOnBoundary.end(); checker++) {
     1327      // (neglecting A,B,C)
     1328      if ((checker == A) || (checker == baseline->second.first) || (checker == baseline->second.second))
     1329        continue;
     1330      // 4a. project onto plane vector
     1331      TrialVector.CopyVector(checker->second->node->node);
     1332      TrialVector.SubtractVector(A->second->node->node);
     1333      distance = TrialVector.ScalarProduct(&PlaneVector);
     1334      if (fabs(distance) < 1e-4) // we need to have a small epsilon around 0 which is still ok
     1335        continue;
     1336      DoLog(2) && (Log() << Verbose(2) << "Projection of " << checker->second->node->Name << " yields distance of " << distance << "." << endl);
     1337      tmp = distance / fabs(distance);
     1338      // 4b. Any have different sign to than before? (i.e. would lie outside convex hull with this starting triangle)
     1339      if ((sign != 0) && (tmp != sign)) {
     1340        // 4c. If so, break 4. loop and continue with next candidate in 1. loop
     1341        DoLog(2) && (Log() << Verbose(2) << "Current candidates: " << A->second->node->Name << "," << baseline->second.first->second->node->Name << "," << baseline->second.second->second->node->Name << " leaves " << checker->second->node->Name << " outside the convex hull." << endl);
     1342        break;
     1343      } else { // note the sign for later
     1344        DoLog(2) && (Log() << Verbose(2) << "Current candidates: " << A->second->node->Name << "," << baseline->second.first->second->node->Name << "," << baseline->second.second->second->node->Name << " leave " << checker->second->node->Name << " inside the convex hull." << endl);
     1345        sign = tmp;
     1346      }
     1347      // 4d. Check whether the point is inside the triangle (check distance to each node
     1348      tmp = checker->second->node->node->DistanceSquared(A->second->node->node);
     1349      int innerpoint = 0;
     1350      if ((tmp < A->second->node->node->DistanceSquared(baseline->second.first->second->node->node)) && (tmp < A->second->node->node->DistanceSquared(baseline->second.second->second->node->node)))
     1351        innerpoint++;
     1352      tmp = checker->second->node->node->DistanceSquared(baseline->second.first->second->node->node);
     1353      if ((tmp < baseline->second.first->second->node->node->DistanceSquared(A->second->node->node)) && (tmp < baseline->second.first->second->node->node->DistanceSquared(baseline->second.second->second->node->node)))
     1354        innerpoint++;
     1355      tmp = checker->second->node->node->DistanceSquared(baseline->second.second->second->node->node);
     1356      if ((tmp < baseline->second.second->second->node->node->DistanceSquared(baseline->second.first->second->node->node)) && (tmp < baseline->second.second->second->node->node->DistanceSquared(A->second->node->node)))
     1357        innerpoint++;
     1358      // 4e. If so, break 4. loop and continue with next candidate in 1. loop
     1359      if (innerpoint == 3)
     1360        break;
     1361    }
     1362    // 5. come this far, all on same side? Then break 1. loop and construct triangle
     1363    if (checker == PointsOnBoundary.end()) {
     1364      DoLog(2) && (Log() << Verbose(2) << "Looks like we have a candidate!" << endl);
     1365      break;
     1366    }
     1367  }
     1368  if (baseline != DistanceMMap.end()) {
     1369    BPS[0] = baseline->second.first->second;
     1370    BPS[1] = baseline->second.second->second;
     1371    BLS[0] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount);
     1372    BPS[0] = A->second;
     1373    BPS[1] = baseline->second.second->second;
     1374    BLS[1] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount);
     1375    BPS[0] = baseline->second.first->second;
     1376    BPS[1] = A->second;
     1377    BLS[2] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount);
     1378
     1379    // 4b3. insert created triangle
     1380    BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
     1381    TrianglesOnBoundary.insert(TrianglePair(TrianglesOnBoundaryCount, BTS));
     1382    TrianglesOnBoundaryCount++;
     1383    for (int i = 0; i < NDIM; i++) {
     1384      LinesOnBoundary.insert(LinePair(LinesOnBoundaryCount, BTS->lines[i]));
     1385      LinesOnBoundaryCount++;
     1386    }
     1387
     1388    DoLog(1) && (Log() << Verbose(1) << "Starting triangle is " << *BTS << "." << endl);
     1389  } else {
     1390    DoeLog(0) && (eLog() << Verbose(0) << "No starting triangle found." << endl);
     1391  }
    13261392}
    13271393;
     
    13421408void Tesselation::TesselateOnBoundary(const PointCloud * const cloud)
    13431409{
    1344         Info FunctionInfo(__func__);
     1410  Info FunctionInfo(__func__);
    13451411  bool flag;
    13461412  PointMap::iterator winner;
     
    13611427        // get peak point with respect to this base line's only triangle
    13621428        BTS = baseline->second->triangles.begin()->second; // there is only one triangle so far
    1363         Log() << Verbose(0) << "Current baseline is between " << *(baseline->second) << "." << endl;
     1429        DoLog(0) && (Log() << Verbose(0) << "Current baseline is between " << *(baseline->second) << "." << endl);
    13641430        for (int i = 0; i < 3; i++)
    13651431          if ((BTS->endpoints[i] != baseline->second->endpoints[0]) && (BTS->endpoints[i] != baseline->second->endpoints[1]))
    13661432            peak = BTS->endpoints[i];
    1367         Log() << Verbose(1) << " and has peak " << *peak << "." << endl;
     1433        DoLog(1) && (Log() << Verbose(1) << " and has peak " << *peak << "." << endl);
    13681434
    13691435        // prepare some auxiliary vectors
     
    13801446          CenterVector.AddVector(BTS->endpoints[i]->node->node);
    13811447        CenterVector.Scale(1. / 3.);
    1382         Log() << Verbose(2) << "CenterVector of base triangle is " << CenterVector << endl;
     1448        DoLog(2) && (Log() << Verbose(2) << "CenterVector of base triangle is " << CenterVector << endl);
    13831449
    13841450        // normal vector of triangle
     
    13871453        BTS->GetNormalVector(NormalVector);
    13881454        NormalVector.CopyVector(&BTS->NormalVector);
    1389         Log() << Verbose(2) << "NormalVector of base triangle is " << NormalVector << endl;
     1455        DoLog(2) && (Log() << Verbose(2) << "NormalVector of base triangle is " << NormalVector << endl);
    13901456
    13911457        // vector in propagation direction (out of triangle)
     
    13971463        if (PropagationVector.ScalarProduct(&TempVector) > 0) // make sure normal propagation vector points outward from baseline
    13981464          PropagationVector.Scale(-1.);
    1399         Log() << Verbose(2) << "PropagationVector of base triangle is " << PropagationVector << endl;
     1465        DoLog(2) && (Log() << Verbose(2) << "PropagationVector of base triangle is " << PropagationVector << endl);
    14001466        winner = PointsOnBoundary.end();
    14011467
     
    14031469        for (PointMap::iterator target = PointsOnBoundary.begin(); target != PointsOnBoundary.end(); target++) {
    14041470          if ((target->second != baseline->second->endpoints[0]) && (target->second != baseline->second->endpoints[1])) { // don't take the same endpoints
    1405             Log() << Verbose(1) << "Target point is " << *(target->second) << ":" << endl;
     1471            DoLog(1) && (Log() << Verbose(1) << "Target point is " << *(target->second) << ":" << endl);
    14061472
    14071473            // first check direction, so that triangles don't intersect
     
    14101476            VirtualNormalVector.ProjectOntoPlane(&NormalVector);
    14111477            TempAngle = VirtualNormalVector.Angle(&PropagationVector);
    1412             Log() << Verbose(2) << "VirtualNormalVector is " << VirtualNormalVector << " and PropagationVector is " << PropagationVector << "." << endl;
    1413             if (TempAngle > (M_PI/2.)) { // no bends bigger than Pi/2 (90 degrees)
    1414               Log() << Verbose(2) << "Angle on triangle plane between propagation direction and base line to " << *(target->second) << " is " << TempAngle << ", bad direction!" << endl;
     1478            DoLog(2) && (Log() << Verbose(2) << "VirtualNormalVector is " << VirtualNormalVector << " and PropagationVector is " << PropagationVector << "." << endl);
     1479            if (TempAngle > (M_PI / 2.)) { // no bends bigger than Pi/2 (90 degrees)
     1480              DoLog(2) && (Log() << Verbose(2) << "Angle on triangle plane between propagation direction and base line to " << *(target->second) << " is " << TempAngle << ", bad direction!" << endl);
    14151481              continue;
    14161482            } else
    1417               Log() << Verbose(2) << "Angle on triangle plane between propagation direction and base line to " << *(target->second) << " is " << TempAngle << ", good direction!" << endl;
     1483              DoLog(2) && (Log() << Verbose(2) << "Angle on triangle plane between propagation direction and base line to " << *(target->second) << " is " << TempAngle << ", good direction!" << endl);
    14181484
    14191485            // check first and second endpoint (if any connecting line goes to target has at least not more than 1 triangle)
     
    14211487            LineChecker[1] = baseline->second->endpoints[1]->lines.find(target->first);
    14221488            if (((LineChecker[0] != baseline->second->endpoints[0]->lines.end()) && (LineChecker[0]->second->triangles.size() == 2))) {
    1423               Log() << Verbose(2) << *(baseline->second->endpoints[0]) << " has line " << *(LineChecker[0]->second) << " to " << *(target->second) << " as endpoint with " << LineChecker[0]->second->triangles.size() << " triangles." << endl;
     1489              DoLog(2) && (Log() << Verbose(2) << *(baseline->second->endpoints[0]) << " has line " << *(LineChecker[0]->second) << " to " << *(target->second) << " as endpoint with " << LineChecker[0]->second->triangles.size() << " triangles." << endl);
    14241490              continue;
    14251491            }
    14261492            if (((LineChecker[1] != baseline->second->endpoints[1]->lines.end()) && (LineChecker[1]->second->triangles.size() == 2))) {
    1427               Log() << Verbose(2) << *(baseline->second->endpoints[1]) << " has line " << *(LineChecker[1]->second) << " to " << *(target->second) << " as endpoint with " << LineChecker[1]->second->triangles.size() << " triangles." << endl;
     1493              DoLog(2) && (Log() << Verbose(2) << *(baseline->second->endpoints[1]) << " has line " << *(LineChecker[1]->second) << " to " << *(target->second) << " as endpoint with " << LineChecker[1]->second->triangles.size() << " triangles." << endl);
    14281494              continue;
    14291495            }
     
    14311497            // check whether the envisaged triangle does not already exist (if both lines exist and have same endpoint)
    14321498            if ((((LineChecker[0] != baseline->second->endpoints[0]->lines.end()) && (LineChecker[1] != baseline->second->endpoints[1]->lines.end()) && (GetCommonEndpoint(LineChecker[0]->second, LineChecker[1]->second) == peak)))) {
    1433               Log() << Verbose(4) << "Current target is peak!" << endl;
     1499              DoLog(4) && (Log() << Verbose(4) << "Current target is peak!" << endl);
    14341500              continue;
    14351501            }
     
    14421508            helper.ProjectOntoPlane(&TempVector);
    14431509            if (fabs(helper.NormSquared()) < MYEPSILON) {
    1444               Log() << Verbose(2) << "Chosen set of vectors is linear dependent." << endl;
     1510              DoLog(2) && (Log() << Verbose(2) << "Chosen set of vectors is linear dependent." << endl);
    14451511              continue;
    14461512            }
     
    14521518            TempVector.AddVector(baseline->second->endpoints[1]->node->node);
    14531519            TempVector.AddVector(target->second->node->node);
    1454             TempVector.Scale(1./3.);
     1520            TempVector.Scale(1. / 3.);
    14551521            TempVector.SubtractVector(Center);
    14561522            // make it always point outward
     
    14591525            // calculate angle
    14601526            TempAngle = NormalVector.Angle(&VirtualNormalVector);
    1461             Log() << Verbose(2) << "NormalVector is " << VirtualNormalVector << " and the angle is " << TempAngle << "." << endl;
     1527            DoLog(2) && (Log() << Verbose(2) << "NormalVector is " << VirtualNormalVector << " and the angle is " << TempAngle << "." << endl);
    14621528            if ((SmallestAngle - TempAngle) > MYEPSILON) { // set to new possible winner
    14631529              SmallestAngle = TempAngle;
    14641530              winner = target;
    1465               Log() << Verbose(2) << "New winner " << *winner->second->node << " due to smaller angle between normal vectors." << endl;
     1531              DoLog(2) && (Log() << Verbose(2) << "New winner " << *winner->second->node << " due to smaller angle between normal vectors." << endl);
    14661532            } else if (fabs(SmallestAngle - TempAngle) < MYEPSILON) { // check the angle to propagation, both possible targets are in one plane! (their normals have same angle)
    14671533              // hence, check the angles to some normal direction from our base line but in this common plane of both targets...
     
    14811547                SmallestAngle = TempAngle;
    14821548                winner = target;
    1483                 Log() << Verbose(2) << "New winner " << *winner->second->node << " due to smaller angle " << TempAngle << " to propagation direction." << endl;
     1549                DoLog(2) && (Log() << Verbose(2) << "New winner " << *winner->second->node << " due to smaller angle " << TempAngle << " to propagation direction." << endl);
    14841550              } else
    1485                 Log() << Verbose(2) << "Keeping old winner " << *winner->second->node << " due to smaller angle to propagation direction." << endl;
     1551                DoLog(2) && (Log() << Verbose(2) << "Keeping old winner " << *winner->second->node << " due to smaller angle to propagation direction." << endl);
    14861552            } else
    1487               Log() << Verbose(2) << "Keeping old winner " << *winner->second->node << " due to smaller angle between normal vectors." << endl;
     1553              DoLog(2) && (Log() << Verbose(2) << "Keeping old winner " << *winner->second->node << " due to smaller angle between normal vectors." << endl);
    14881554          }
    14891555        } // end of loop over all boundary points
     
    14911557        // 5b. The point of the above whose triangle has the greatest angle with the triangle the current line belongs to (it only belongs to one, remember!): New triangle
    14921558        if (winner != PointsOnBoundary.end()) {
    1493           Log() << Verbose(0) << "Winning target point is " << *(winner->second) << " with angle " << SmallestAngle << "." << endl;
     1559          DoLog(0) && (Log() << Verbose(0) << "Winning target point is " << *(winner->second) << " with angle " << SmallestAngle << "." << endl);
    14941560          // create the lins of not yet present
    14951561          BLS[0] = baseline->second;
     
    15211587          TrianglesOnBoundaryCount++;
    15221588        } else {
    1523           eLog() << Verbose(2) << "I could not determine a winner for this baseline " << *(baseline->second) << "." << endl;
     1589          DoeLog(2) && (eLog() << Verbose(2) << "I could not determine a winner for this baseline " << *(baseline->second) << "." << endl);
    15241590        }
    15251591
    15261592        // 5d. If the set of lines is not yet empty, go to 5. and continue
    15271593      } else
    1528         Log() << Verbose(0) << "Baseline candidate " << *(baseline->second) << " has a triangle count of " << baseline->second->triangles.size() << "." << endl;
     1594        DoLog(0) && (Log() << Verbose(0) << "Baseline candidate " << *(baseline->second) << " has a triangle count of " << baseline->second->triangles.size() << "." << endl);
    15291595  } while (flag);
    15301596
    15311597  // exit
    1532   delete(Center);
    1533 };
     1598  delete (Center);
     1599}
     1600;
    15341601
    15351602/** Inserts all points outside of the tesselated surface into it by adding new triangles.
     
    15411608bool Tesselation::InsertStraddlingPoints(const PointCloud *cloud, const LinkedCell *LC)
    15421609{
    1543         Info FunctionInfo(__func__);
     1610  Info FunctionInfo(__func__);
    15441611  Vector Intersection, Normal;
    15451612  TesselPoint *Walker = NULL;
     
    15511618  cloud->GoToFirst();
    15521619  BoundaryPoints = new LinkedCell(this, 5.);
    1553   while (!cloud->IsEnd()) {  // we only have to go once through all points, as boundary can become only bigger
     1620  while (!cloud->IsEnd()) { // we only have to go once through all points, as boundary can become only bigger
    15541621    if (AddFlag) {
    1555       delete(BoundaryPoints);
     1622      delete (BoundaryPoints);
    15561623      BoundaryPoints = new LinkedCell(this, 5.);
    15571624      AddFlag = false;
    15581625    }
    15591626    Walker = cloud->GetPoint();
    1560     Log() << Verbose(0) << "Current point is " << *Walker << "." << endl;
     1627    DoLog(0) && (Log() << Verbose(0) << "Current point is " << *Walker << "." << endl);
    15611628    // get the next triangle
    15621629    triangles = FindClosestTrianglesToVector(Walker->node, BoundaryPoints);
    15631630    BTS = triangles->front();
    15641631    if ((triangles == NULL) || (BTS->ContainsBoundaryPoint(Walker))) {
    1565       Log() << Verbose(0) << "No triangles found, probably a tesselation point itself." << endl;
     1632      DoLog(0) && (Log() << Verbose(0) << "No triangles found, probably a tesselation point itself." << endl);
    15661633      cloud->GoToNext();
    15671634      continue;
    15681635    } else {
    15691636    }
    1570     Log() << Verbose(0) << "Closest triangle is " << *BTS << "." << endl;
     1637    DoLog(0) && (Log() << Verbose(0) << "Closest triangle is " << *BTS << "." << endl);
    15711638    // get the intersection point
    15721639    if (BTS->GetIntersectionInsideTriangle(Center, Walker->node, &Intersection)) {
    1573       Log() << Verbose(0) << "We have an intersection at " << Intersection << "." << endl;
     1640      DoLog(0) && (Log() << Verbose(0) << "We have an intersection at " << Intersection << "." << endl);
    15741641      // we have the intersection, check whether in- or outside of boundary
    15751642      if ((Center->DistanceSquared(Walker->node) - Center->DistanceSquared(&Intersection)) < -MYEPSILON) {
    15761643        // inside, next!
    1577         Log() << Verbose(0) << *Walker << " is inside wrt triangle " << *BTS << "." << endl;
     1644        DoLog(0) && (Log() << Verbose(0) << *Walker << " is inside wrt triangle " << *BTS << "." << endl);
    15781645      } else {
    15791646        // outside!
    1580         Log() << Verbose(0) << *Walker << " is outside wrt triangle " << *BTS << "." << endl;
     1647        DoLog(0) && (Log() << Verbose(0) << *Walker << " is outside wrt triangle " << *BTS << "." << endl);
    15811648        class BoundaryLineSet *OldLines[3], *NewLines[3];
    15821649        class BoundaryPointSet *OldPoints[3], *NewPoint;
    15831650        // store the three old lines and old points
    1584         for (int i=0;i<3;i++) {
     1651        for (int i = 0; i < 3; i++) {
    15851652          OldLines[i] = BTS->lines[i];
    15861653          OldPoints[i] = BTS->endpoints[i];
     
    15881655        Normal.CopyVector(&BTS->NormalVector);
    15891656        // add Walker to boundary points
    1590         Log() << Verbose(0) << "Adding " << *Walker << " to BoundaryPoints." << endl;
     1657        DoLog(0) && (Log() << Verbose(0) << "Adding " << *Walker << " to BoundaryPoints." << endl);
    15911658        AddFlag = true;
    1592         if (AddBoundaryPoint(Walker,0))
     1659        if (AddBoundaryPoint(Walker, 0))
    15931660          NewPoint = BPS[0];
    15941661        else
    15951662          continue;
    15961663        // remove triangle
    1597         Log() << Verbose(0) << "Erasing triangle " << *BTS << "." << endl;
     1664        DoLog(0) && (Log() << Verbose(0) << "Erasing triangle " << *BTS << "." << endl);
    15981665        TrianglesOnBoundary.erase(BTS->Nr);
    1599         delete(BTS);
     1666        delete (BTS);
    16001667        // create three new boundary lines
    1601         for (int i=0;i<3;i++) {
     1668        for (int i = 0; i < 3; i++) {
    16021669          BPS[0] = NewPoint;
    16031670          BPS[1] = OldPoints[i];
    16041671          NewLines[i] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount);
    1605           Log() << Verbose(1) << "Creating new line " << *NewLines[i] << "." << endl;
     1672          DoLog(1) && (Log() << Verbose(1) << "Creating new line " << *NewLines[i] << "." << endl);
    16061673          LinesOnBoundary.insert(LinePair(LinesOnBoundaryCount, NewLines[i])); // no need for check for unique insertion as BPS[0] is definitely a new one
    16071674          LinesOnBoundaryCount++;
    16081675        }
    16091676        // create three new triangle with new point
    1610         for (int i=0;i<3;i++) { // find all baselines
     1677        for (int i = 0; i < 3; i++) { // find all baselines
    16111678          BLS[0] = OldLines[i];
    16121679          int n = 1;
    1613           for (int j=0;j<3;j++) {
     1680          for (int j = 0; j < 3; j++) {
    16141681            if (NewLines[j]->IsConnectedTo(BLS[0])) {
    1615               if (n>2) {
    1616                 eLog() << Verbose(2) << BLS[0] << " connects to all of the new lines?!" << endl;
     1682              if (n > 2) {
     1683                DoeLog(2) && (eLog() << Verbose(2) << BLS[0] << " connects to all of the new lines?!" << endl);
    16171684                return false;
    16181685              } else
     
    16251692          BTS->GetNormalVector(Normal);
    16261693          Normal.Scale(-1.);
    1627           Log() << Verbose(0) << "Created new triangle " << *BTS << "." << endl;
     1694          DoLog(0) && (Log() << Verbose(0) << "Created new triangle " << *BTS << "." << endl);
    16281695          TrianglesOnBoundary.insert(TrianglePair(TrianglesOnBoundaryCount, BTS));
    16291696          TrianglesOnBoundaryCount++;
     
    16311698      }
    16321699    } else { // something is wrong with FindClosestTriangleToPoint!
    1633       eLog() << Verbose(1) << "The closest triangle did not produce an intersection!" << endl;
     1700      DoeLog(1) && (eLog() << Verbose(1) << "The closest triangle did not produce an intersection!" << endl);
    16341701      return false;
    16351702    }
     
    16381705
    16391706  // exit
    1640   delete(Center);
     1707  delete (Center);
    16411708  return true;
    1642 };
     1709}
     1710;
    16431711
    16441712/** Adds a point to the tesselation::PointsOnBoundary list.
     
    16491717bool Tesselation::AddBoundaryPoint(TesselPoint * Walker, const int n)
    16501718{
    1651         Info FunctionInfo(__func__);
     1719  Info FunctionInfo(__func__);
    16521720  PointTestPair InsertUnique;
    16531721  BPS[n] = new class BoundaryPointSet(Walker);
     
    16571725    return true;
    16581726  } else {
    1659     delete(BPS[n]);
     1727    delete (BPS[n]);
    16601728    BPS[n] = InsertUnique.first->second;
    16611729    return false;
     
    16711739void Tesselation::AddTesselationPoint(TesselPoint* Candidate, const int n)
    16721740{
    1673         Info FunctionInfo(__func__);
     1741  Info FunctionInfo(__func__);
    16741742  PointTestPair InsertUnique;
    16751743  TPS[n] = new class BoundaryPointSet(Candidate);
     
    16791747  } else {
    16801748    delete TPS[n];
    1681     Log() << Verbose(0) << "Node " << *((InsertUnique.first)->second->node) << " is already present in PointsOnBoundary." << endl;
     1749    DoLog(0) && (Log() << Verbose(0) << "Node " << *((InsertUnique.first)->second->node) << " is already present in PointsOnBoundary." << endl);
    16821750    TPS[n] = (InsertUnique.first)->second;
    16831751  }
     
    16921760void Tesselation::SetTesselationPoint(TesselPoint* Candidate, const int n) const
    16931761{
    1694         Info FunctionInfo(__func__);
     1762  Info FunctionInfo(__func__);
    16951763  PointMap::const_iterator FindPoint = PointsOnBoundary.find(Candidate->nr);
    16961764  if (FindPoint != PointsOnBoundary.end())
     
    16981766  else
    16991767    TPS[n] = NULL;
    1700 };
     1768}
     1769;
    17011770
    17021771/** Function tries to add line from current Points in BPS to BoundaryLineSet.
    17031772 * If successful it raises the line count and inserts the new line into the BLS,
    17041773 * if unsuccessful, it writes the line which had been present into the BLS, deleting the new constructed one.
     1774 * @param *OptCenter desired OptCenter if there are more than one candidate line
     1775 * @param *candidate third point of the triangle to be, for checking between multiple open line candidates
    17051776 * @param *a first endpoint
    17061777 * @param *b second endpoint
    17071778 * @param n index of Tesselation::BLS giving the line with both endpoints
    17081779 */
    1709 void Tesselation::AddTesselationLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n) {
     1780void Tesselation::AddTesselationLine(const Vector * const OptCenter, const BoundaryPointSet * const candidate, class BoundaryPointSet *a, class BoundaryPointSet *b, const int n)
     1781{
    17101782  bool insertNewLine = true;
    1711 
    17121783  LineMap::iterator FindLine = a->lines.find(b->node->nr);
     1784  BoundaryLineSet *WinningLine = NULL;
    17131785  if (FindLine != a->lines.end()) {
    1714     Log() << Verbose(1) << "INFO: There is at least one line between " << *a << " and " << *b << ": " << *(FindLine->second) << "." << endl;
    1715 
    1716     pair<LineMap::iterator,LineMap::iterator> FindPair;
     1786    DoLog(1) && (Log() << Verbose(1) << "INFO: There is at least one line between " << *a << " and " << *b << ": " << *(FindLine->second) << "." << endl);
     1787
     1788    pair<LineMap::iterator, LineMap::iterator> FindPair;
    17171789    FindPair = a->lines.equal_range(b->node->nr);
    17181790
    1719     for (FindLine = FindPair.first; FindLine != FindPair.second; FindLine++) {
     1791    for (FindLine = FindPair.first; (FindLine != FindPair.second) && (insertNewLine); FindLine++) {
     1792      DoLog(1) && (Log() << Verbose(1) << "INFO: Checking line " << *(FindLine->second) << " ..." << endl);
    17201793      // If there is a line with less than two attached triangles, we don't need a new line.
    1721       if (FindLine->second->triangles.size() < 2) {
    1722         insertNewLine = false;
    1723         Log() << Verbose(0) << "Using existing line " << *FindLine->second << endl;
    1724 
    1725         BPS[0] = FindLine->second->endpoints[0];
    1726         BPS[1] = FindLine->second->endpoints[1];
    1727         BLS[n] = FindLine->second;
    1728 
    1729         // remove existing line from OpenLines
    1730         CandidateMap::iterator CandidateLine = OpenLines.find(BLS[n]);
    1731         if (CandidateLine != OpenLines.end()) {
    1732           Log() << Verbose(1) << " Removing line from OpenLines." << endl;
    1733           delete(CandidateLine->second);
    1734           OpenLines.erase(CandidateLine);
    1735         } else {
    1736           eLog() << Verbose(1) << "Line exists and is attached to less than two triangles, but not in OpenLines!" << endl;
     1794      if (FindLine->second->triangles.size() == 1) {
     1795        CandidateMap::iterator Finder = OpenLines.find(FindLine->second);
     1796        if (!Finder->second->pointlist.empty())
     1797          DoLog(1) && (Log() << Verbose(1) << "INFO: line " << *(FindLine->second) << " is open with candidate " << **(Finder->second->pointlist.begin()) << "." << endl);
     1798        else
     1799          DoLog(1) && (Log() << Verbose(1) << "INFO: line " << *(FindLine->second) << " is open with no candidate." << endl);
     1800        // get open line
     1801        for (TesselPointList::const_iterator CandidateChecker = Finder->second->pointlist.begin(); CandidateChecker != Finder->second->pointlist.end(); ++CandidateChecker) {
     1802          if ((*(CandidateChecker) == candidate->node) && (OptCenter == NULL || OptCenter->DistanceSquared(&Finder->second->OptCenter) < MYEPSILON )) { // stop searching if candidate matches
     1803            DoLog(1) && (Log() << Verbose(1) << "ACCEPT: Candidate " << *(*CandidateChecker) << " has the right center " << Finder->second->OptCenter << "." << endl);
     1804            insertNewLine = false;
     1805            WinningLine = FindLine->second;
     1806            break;
     1807          } else {
     1808            DoLog(1) && (Log() << Verbose(1) << "REJECT: Candidate " << *(*CandidateChecker) << "'s center " << Finder->second->OptCenter << " does not match desired on " << *OptCenter << "." << endl);
     1809          }
    17371810        }
    1738 
    1739         break;
    17401811      }
    17411812    }
     
    17431814
    17441815  if (insertNewLine) {
    1745     AlwaysAddTesselationTriangleLine(a, b, n);
     1816    AddNewTesselationTriangleLine(a, b, n);
     1817  } else {
     1818    AddExistingTesselationTriangleLine(WinningLine, n);
    17461819  }
    17471820}
     
    17561829 * @param n index of Tesselation::BLS giving the line with both endpoints
    17571830 */
    1758 void Tesselation::AlwaysAddTesselationTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n)
    1759 {
    1760         Info FunctionInfo(__func__);
    1761   Log() << Verbose(0) << "Adding open line [" << LinesOnBoundaryCount << "|" << *(a->node) << " and " << *(b->node) << "." << endl;
     1831void Tesselation::AddNewTesselationTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n)
     1832{
     1833  Info FunctionInfo(__func__);
     1834  DoLog(0) && (Log() << Verbose(0) << "Adding open line [" << LinesOnBoundaryCount << "|" << *(a->node) << " and " << *(b->node) << "." << endl);
    17621835  BPS[0] = a;
    17631836  BPS[1] = b;
    1764   BLS[n] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount);  // this also adds the line to the local maps
     1837  BLS[n] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount); // this also adds the line to the local maps
    17651838  // add line to global map
    17661839  LinesOnBoundary.insert(LinePair(LinesOnBoundaryCount, BLS[n]));
     
    17691842  // also add to open lines
    17701843  CandidateForTesselation *CFT = new CandidateForTesselation(BLS[n]);
    1771   OpenLines.insert(pair< BoundaryLineSet *, CandidateForTesselation *> (BLS[n], CFT));
    1772 };
     1844  OpenLines.insert(pair<BoundaryLineSet *, CandidateForTesselation *> (BLS[n], CFT));
     1845}
     1846;
     1847
     1848/** Uses an existing line for a new triangle.
     1849 * Sets Tesselation::BLS[\a n] and removes the lines from Tesselation::OpenLines.
     1850 * \param *FindLine the line to add
     1851 * \param n index of the line to set in Tesselation::BLS
     1852 */
     1853void Tesselation::AddExistingTesselationTriangleLine(class BoundaryLineSet *Line, int n)
     1854{
     1855  Info FunctionInfo(__func__);
     1856  DoLog(0) && (Log() << Verbose(0) << "Using existing line " << *Line << endl);
     1857
     1858  // set endpoints and line
     1859  BPS[0] = Line->endpoints[0];
     1860  BPS[1] = Line->endpoints[1];
     1861  BLS[n] = Line;
     1862  // remove existing line from OpenLines
     1863  CandidateMap::iterator CandidateLine = OpenLines.find(BLS[n]);
     1864  if (CandidateLine != OpenLines.end()) {
     1865    DoLog(1) && (Log() << Verbose(1) << " Removing line from OpenLines." << endl);
     1866    delete (CandidateLine->second);
     1867    OpenLines.erase(CandidateLine);
     1868  } else {
     1869    DoeLog(1) && (eLog() << Verbose(1) << "Line exists and is attached to less than two triangles, but not in OpenLines!" << endl);
     1870  }
     1871}
     1872;
    17731873
    17741874/** Function adds triangle to global list.
     
    17771877void Tesselation::AddTesselationTriangle()
    17781878{
    1779         Info FunctionInfo(__func__);
    1780   Log() << Verbose(1) << "Adding triangle to global TrianglesOnBoundary map." << endl;
     1879  Info FunctionInfo(__func__);
     1880  DoLog(1) && (Log() << Verbose(1) << "Adding triangle to global TrianglesOnBoundary map." << endl);
    17811881
    17821882  // add triangle to global map
     
    17881888
    17891889  // NOTE: add triangle to local maps is done in constructor of BoundaryTriangleSet
    1790 };
     1890}
     1891;
    17911892
    17921893/** Function adds triangle to global list.
     
    17961897void Tesselation::AddTesselationTriangle(const int nr)
    17971898{
    1798         Info FunctionInfo(__func__);
    1799   Log() << Verbose(0) << "Adding triangle to global TrianglesOnBoundary map." << endl;
     1899  Info FunctionInfo(__func__);
     1900  DoLog(0) && (Log() << Verbose(0) << "Adding triangle to global TrianglesOnBoundary map." << endl);
    18001901
    18011902  // add triangle to global map
     
    18061907
    18071908  // NOTE: add triangle to local maps is done in constructor of BoundaryTriangleSet
    1808 };
     1909}
     1910;
    18091911
    18101912/** Removes a triangle from the tesselation.
     
    18151917void Tesselation::RemoveTesselationTriangle(class BoundaryTriangleSet *triangle)
    18161918{
    1817         Info FunctionInfo(__func__);
     1919  Info FunctionInfo(__func__);
    18181920  if (triangle == NULL)
    18191921    return;
    18201922  for (int i = 0; i < 3; i++) {
    18211923    if (triangle->lines[i] != NULL) {
    1822       Log() << Verbose(0) << "Removing triangle Nr." << triangle->Nr << " in line " << *triangle->lines[i] << "." << endl;
     1924      DoLog(0) && (Log() << Verbose(0) << "Removing triangle Nr." << triangle->Nr << " in line " << *triangle->lines[i] << "." << endl);
    18231925      triangle->lines[i]->triangles.erase(triangle->Nr);
    18241926      if (triangle->lines[i]->triangles.empty()) {
    1825           Log() << Verbose(0) << *triangle->lines[i] << " is no more attached to any triangle, erasing." << endl;
    1826           RemoveTesselationLine(triangle->lines[i]);
     1927        DoLog(0) && (Log() << Verbose(0) << *triangle->lines[i] << " is no more attached to any triangle, erasing." << endl);
     1928        RemoveTesselationLine(triangle->lines[i]);
    18271929      } else {
    1828         Log() << Verbose(0) << *triangle->lines[i] << " is still attached to another triangle: ";
    1829         OpenLines.insert(pair< BoundaryLineSet *, CandidateForTesselation *> (triangle->lines[i], NULL));
    1830         for(TriangleMap::iterator TriangleRunner = triangle->lines[i]->triangles.begin(); TriangleRunner != triangle->lines[i]->triangles.end(); TriangleRunner++)
    1831           Log() << Verbose(0) << "[" << (TriangleRunner->second)->Nr << "|" << *((TriangleRunner->second)->endpoints[0]) << ", " << *((TriangleRunner->second)->endpoints[1]) << ", " << *((TriangleRunner->second)->endpoints[2]) << "] \t";
    1832         Log() << Verbose(0) << endl;
    1833 //        for (int j=0;j<2;j++) {
    1834 //          Log() << Verbose(0) << "Lines of endpoint " << *(triangle->lines[i]->endpoints[j]) << ": ";
    1835 //          for(LineMap::iterator LineRunner = triangle->lines[i]->endpoints[j]->lines.begin(); LineRunner != triangle->lines[i]->endpoints[j]->lines.end(); LineRunner++)
    1836 //            Log() << Verbose(0) << "[" << *(LineRunner->second) << "] \t";
    1837 //          Log() << Verbose(0) << endl;
    1838 //        }
     1930        DoLog(0) && (Log() << Verbose(0) << *triangle->lines[i] << " is still attached to another triangle: ");
     1931        OpenLines.insert(pair<BoundaryLineSet *, CandidateForTesselation *> (triangle->lines[i], NULL));
     1932        for (TriangleMap::iterator TriangleRunner = triangle->lines[i]->triangles.begin(); TriangleRunner != triangle->lines[i]->triangles.end(); TriangleRunner++)
     1933          DoLog(0) && (Log() << Verbose(0) << "[" << (TriangleRunner->second)->Nr << "|" << *((TriangleRunner->second)->endpoints[0]) << ", " << *((TriangleRunner->second)->endpoints[1]) << ", " << *((TriangleRunner->second)->endpoints[2]) << "] \t");
     1934        DoLog(0) && (Log() << Verbose(0) << endl);
     1935        //        for (int j=0;j<2;j++) {
     1936        //          Log() << Verbose(0) << "Lines of endpoint " << *(triangle->lines[i]->endpoints[j]) << ": ";
     1937        //          for(LineMap::iterator LineRunner = triangle->lines[i]->endpoints[j]->lines.begin(); LineRunner != triangle->lines[i]->endpoints[j]->lines.end(); LineRunner++)
     1938        //            Log() << Verbose(0) << "[" << *(LineRunner->second) << "] \t";
     1939        //          Log() << Verbose(0) << endl;
     1940        //        }
    18391941      }
    1840       triangle->lines[i] = NULL;  // free'd or not: disconnect
     1942      triangle->lines[i] = NULL; // free'd or not: disconnect
    18411943    } else
    1842       eLog() << Verbose(1) << "This line " << i << " has already been free'd." << endl;
     1944      DoeLog(1) && (eLog() << Verbose(1) << "This line " << i << " has already been free'd." << endl);
    18431945  }
    18441946
    18451947  if (TrianglesOnBoundary.erase(triangle->Nr))
    1846     Log() << Verbose(0) << "Removing triangle Nr. " << triangle->Nr << "." << endl;
    1847   delete(triangle);
    1848 };
     1948    DoLog(0) && (Log() << Verbose(0) << "Removing triangle Nr. " << triangle->Nr << "." << endl);
     1949  delete (triangle);
     1950}
     1951;
    18491952
    18501953/** Removes a line from the tesselation.
     
    18541957void Tesselation::RemoveTesselationLine(class BoundaryLineSet *line)
    18551958{
    1856         Info FunctionInfo(__func__);
     1959  Info FunctionInfo(__func__);
    18571960  int Numbers[2];
    18581961
     
    18751978        for (LineMap::iterator Runner = erasor.first; Runner != erasor.second; Runner++)
    18761979          if ((*Runner).second == line) {
    1877             Log() << Verbose(0) << "Removing Line Nr. " << line->Nr << " in boundary point " << *line->endpoints[i] << "." << endl;
     1980            DoLog(0) && (Log() << Verbose(0) << "Removing Line Nr. " << line->Nr << " in boundary point " << *line->endpoints[i] << "." << endl);
    18781981            line->endpoints[i]->lines.erase(Runner);
    18791982            break;
     
    18811984      } else { // there's just a single line left
    18821985        if (line->endpoints[i]->lines.erase(line->Nr))
    1883           Log() << Verbose(0) << "Removing Line Nr. " << line->Nr << " in boundary point " << *line->endpoints[i] << "." << endl;
     1986          DoLog(0) && (Log() << Verbose(0) << "Removing Line Nr. " << line->Nr << " in boundary point " << *line->endpoints[i] << "." << endl);
    18841987      }
    18851988      if (line->endpoints[i]->lines.empty()) {
    1886         Log() << Verbose(0) << *line->endpoints[i] << " has no more lines it's attached to, erasing." << endl;
     1989        DoLog(0) && (Log() << Verbose(0) << *line->endpoints[i] << " has no more lines it's attached to, erasing." << endl);
    18871990        RemoveTesselationPoint(line->endpoints[i]);
    18881991      } else {
    1889         Log() << Verbose(0) << *line->endpoints[i] << " has still lines it's attached to: ";
    1890         for(LineMap::iterator LineRunner = line->endpoints[i]->lines.begin(); LineRunner != line->endpoints[i]->lines.end(); LineRunner++)
    1891           Log() << Verbose(0) << "[" << *(LineRunner->second) << "] \t";
    1892         Log() << Verbose(0) << endl;
     1992        DoLog(0) && (Log() << Verbose(0) << *line->endpoints[i] << " has still lines it's attached to: ");
     1993        for (LineMap::iterator LineRunner = line->endpoints[i]->lines.begin(); LineRunner != line->endpoints[i]->lines.end(); LineRunner++)
     1994          DoLog(0) && (Log() << Verbose(0) << "[" << *(LineRunner->second) << "] \t");
     1995        DoLog(0) && (Log() << Verbose(0) << endl);
    18931996      }
    1894       line->endpoints[i] = NULL;  // free'd or not: disconnect
     1997      line->endpoints[i] = NULL; // free'd or not: disconnect
    18951998    } else
    1896       eLog() << Verbose(1) << "Endpoint " << i << " has already been free'd." << endl;
     1999      DoeLog(1) && (eLog() << Verbose(1) << "Endpoint " << i << " has already been free'd." << endl);
    18972000  }
    18982001  if (!line->triangles.empty())
    1899     eLog() << Verbose(2) << "Memory Leak! I " << *line << " am still connected to some triangles." << endl;
     2002    DoeLog(2) && (eLog() << Verbose(2) << "Memory Leak! I " << *line << " am still connected to some triangles." << endl);
    19002003
    19012004  if (LinesOnBoundary.erase(line->Nr))
    1902     Log() << Verbose(0) << "Removing line Nr. " << line->Nr << "." << endl;
    1903   delete(line);
    1904 };
     2005    DoLog(0) && (Log() << Verbose(0) << "Removing line Nr. " << line->Nr << "." << endl);
     2006  delete (line);
     2007}
     2008;
    19052009
    19062010/** Removes a point from the tesselation.
     
    19112015void Tesselation::RemoveTesselationPoint(class BoundaryPointSet *point)
    19122016{
    1913         Info FunctionInfo(__func__);
     2017  Info FunctionInfo(__func__);
    19142018  if (point == NULL)
    19152019    return;
    19162020  if (PointsOnBoundary.erase(point->Nr))
    1917     Log() << Verbose(0) << "Removing point Nr. " << point->Nr << "." << endl;
    1918   delete(point);
    1919 };
     2021    DoLog(0) && (Log() << Verbose(0) << "Removing point Nr. " << point->Nr << "." << endl);
     2022  delete (point);
     2023}
     2024;
     2025
     2026/** Checks validity of a given sphere of a candidate line.
     2027 * \sa CandidateForTesselation::CheckValidity(), which is more evolved.
     2028 * We check CandidateForTesselation::OtherOptCenter
     2029 * \param &CandidateLine contains other degenerated candidates which we have to subtract as well
     2030 * \param RADIUS radius of sphere
     2031 * \param *LC LinkedCell structure with other atoms
     2032 * \return true - candidate triangle is degenerated, false - candidate triangle is not degenerated
     2033 */
     2034bool Tesselation::CheckDegeneracy(CandidateForTesselation &CandidateLine, const double RADIUS, const LinkedCell *LC) const
     2035{
     2036  Info FunctionInfo(__func__);
     2037
     2038  DoLog(1) && (Log() << Verbose(1) << "INFO: Checking whether sphere contains no others points ..." << endl);
     2039  bool flag = true;
     2040
     2041  DoLog(1) && (Log() << Verbose(1) << "Check by: draw sphere {" << CandidateLine.OtherOptCenter.x[0] << " " << CandidateLine.OtherOptCenter.x[1] << " " << CandidateLine.OtherOptCenter.x[2] << "} radius " << RADIUS << " resolution 30" << endl);
     2042  // get all points inside the sphere
     2043  TesselPointList *ListofPoints = LC->GetPointsInsideSphere(RADIUS, &CandidateLine.OtherOptCenter);
     2044
     2045  DoLog(1) && (Log() << Verbose(1) << "The following atoms are inside sphere at " << CandidateLine.OtherOptCenter << ":" << endl);
     2046  for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner)
     2047    DoLog(1) && (Log() << Verbose(1) << "  " << *(*Runner) << " with distance " << (*Runner)->node->Distance(&CandidateLine.OtherOptCenter) << "." << endl);
     2048
     2049  // remove triangles's endpoints
     2050  for (int i = 0; i < 2; i++)
     2051    ListofPoints->remove(CandidateLine.BaseLine->endpoints[i]->node);
     2052
     2053  // remove other candidates
     2054  for (TesselPointList::const_iterator Runner = CandidateLine.pointlist.begin(); Runner != CandidateLine.pointlist.end(); ++Runner)
     2055    ListofPoints->remove(*Runner);
     2056
     2057  // check for other points
     2058  if (!ListofPoints->empty()) {
     2059    DoLog(1) && (Log() << Verbose(1) << "CheckDegeneracy: There are still " << ListofPoints->size() << " points inside the sphere." << endl);
     2060    flag = false;
     2061    DoLog(1) && (Log() << Verbose(1) << "External atoms inside of sphere at " << CandidateLine.OtherOptCenter << ":" << endl);
     2062    for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner)
     2063      DoLog(1) && (Log() << Verbose(1) << "  " << *(*Runner) << " with distance " << (*Runner)->node->Distance(&CandidateLine.OtherOptCenter) << "." << endl);
     2064  }
     2065  delete (ListofPoints);
     2066
     2067  return flag;
     2068}
     2069;
    19202070
    19212071/** Checks whether the triangle consisting of the three points is already present.
     
    19302080int Tesselation::CheckPresenceOfTriangle(TesselPoint *Candidates[3]) const
    19312081{
    1932         Info FunctionInfo(__func__);
     2082  Info FunctionInfo(__func__);
    19332083  int adjacentTriangleCount = 0;
    19342084  class BoundaryPointSet *Points[3];
     
    19522102          for (; (FindLine != Points[i]->lines.end()) && (FindLine->first == Points[j]->node->nr); FindLine++) {
    19532103            TriangleMap *triangles = &FindLine->second->triangles;
    1954             Log() << Verbose(1) << "Current line is " << FindLine->first << ": " << *(FindLine->second) << " with triangles " << triangles << "." << endl;
     2104            DoLog(1) && (Log() << Verbose(1) << "Current line is " << FindLine->first << ": " << *(FindLine->second) << " with triangles " << triangles << "." << endl);
    19552105            for (TriangleMap::const_iterator FindTriangle = triangles->begin(); FindTriangle != triangles->end(); FindTriangle++) {
    19562106              if (FindTriangle->second->IsPresentTupel(Points)) {
     
    19582108              }
    19592109            }
    1960             Log() << Verbose(1) << "end." << endl;
     2110            DoLog(1) && (Log() << Verbose(1) << "end." << endl);
    19612111          }
    19622112          // Only one of the triangle lines must be considered for the triangle count.
     
    19682118  }
    19692119
    1970   Log() << Verbose(0) << "Found " << adjacentTriangleCount << " adjacent triangles for the point set." << endl;
     2120  DoLog(0) && (Log() << Verbose(0) << "Found " << adjacentTriangleCount << " adjacent triangles for the point set." << endl);
    19712121  return adjacentTriangleCount;
    1972 };
     2122}
     2123;
    19732124
    19742125/** Checks whether the triangle consisting of the three points is already present.
     
    19822133class BoundaryTriangleSet * Tesselation::GetPresentTriangle(TesselPoint *Candidates[3])
    19832134{
    1984         Info FunctionInfo(__func__);
     2135  Info FunctionInfo(__func__);
    19852136  class BoundaryTriangleSet *triangle = NULL;
    19862137  class BoundaryPointSet *Points[3];
     
    20202171
    20212172  return triangle;
    2022 };
    2023 
     2173}
     2174;
    20242175
    20252176/** Finds the starting triangle for FindNonConvexBorder().
     
    20302181 * \param RADIUS radius of virtual rolling sphere
    20312182 * \param *LC LinkedCell structure with neighbouring TesselPoint's
    2032  */
    2033 void Tesselation::FindStartingTriangle(const double RADIUS, const LinkedCell *LC)
    2034 {
    2035         Info FunctionInfo(__func__);
     2183 * \return true - a starting triangle has been created, false - no valid triple of points found
     2184 */
     2185bool Tesselation::FindStartingTriangle(const double RADIUS, const LinkedCell *LC)
     2186{
     2187  Info FunctionInfo(__func__);
    20362188  int i = 0;
    20372189  TesselPoint* MaxPoint[NDIM];
    20382190  TesselPoint* Temporary;
    20392191  double maxCoordinate[NDIM];
    2040   BoundaryLineSet BaseLine;
     2192  BoundaryLineSet *BaseLine = NULL;
    20412193  Vector helper;
    20422194  Vector Chord;
    20432195  Vector SearchDirection;
    2044   Vector CircleCenter;  // center of the circle, i.e. of the band of sphere's centers
     2196  Vector CircleCenter; // center of the circle, i.e. of the band of sphere's centers
    20452197  Vector CirclePlaneNormal; // normal vector defining the plane this circle lives in
    20462198  Vector SphereCenter;
     
    20552207
    20562208  // 1. searching topmost point with respect to each axis
    2057   for (int i=0;i<NDIM;i++) { // each axis
    2058     LC->n[i] = LC->N[i]-1; // current axis is topmost cell
    2059     for (LC->n[(i+1)%NDIM]=0;LC->n[(i+1)%NDIM]<LC->N[(i+1)%NDIM];LC->n[(i+1)%NDIM]++)
    2060       for (LC->n[(i+2)%NDIM]=0;LC->n[(i+2)%NDIM]<LC->N[(i+2)%NDIM];LC->n[(i+2)%NDIM]++) {
    2061         const LinkedNodes *List = LC->GetCurrentCell();
     2209  for (int i = 0; i < NDIM; i++) { // each axis
     2210    LC->n[i] = LC->N[i] - 1; // current axis is topmost cell
     2211    for (LC->n[(i + 1) % NDIM] = 0; LC->n[(i + 1) % NDIM] < LC->N[(i + 1) % NDIM]; LC->n[(i + 1) % NDIM]++)
     2212      for (LC->n[(i + 2) % NDIM] = 0; LC->n[(i + 2) % NDIM] < LC->N[(i + 2) % NDIM]; LC->n[(i + 2) % NDIM]++) {
     2213        const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
    20622214        //Log() << Verbose(1) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;
    20632215        if (List != NULL) {
    2064           for (LinkedNodes::const_iterator Runner = List->begin();Runner != List->end();Runner++) {
     2216          for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    20652217            if ((*Runner)->node->x[i] > maxCoordinate[i]) {
    2066               Log() << Verbose(1) << "New maximal for axis " << i << " node is " << *(*Runner) << " at " << *(*Runner)->node << "." << endl;
     2218              DoLog(1) && (Log() << Verbose(1) << "New maximal for axis " << i << " node is " << *(*Runner) << " at " << *(*Runner)->node << "." << endl);
    20672219              maxCoordinate[i] = (*Runner)->node->x[i];
    20682220              MaxPoint[i] = (*Runner);
     
    20702222          }
    20712223        } else {
    2072           eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << " is invalid!" << endl;
     2224          DoeLog(1) && (eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << " is invalid!" << endl);
    20732225        }
    20742226      }
    20752227  }
    20762228
    2077   Log() << Verbose(1) << "Found maximum coordinates: ";
    2078   for (int i=0;i<NDIM;i++)
    2079     Log() << Verbose(0) << i << ": " << *MaxPoint[i] << "\t";
    2080   Log() << Verbose(0) << endl;
     2229  DoLog(1) && (Log() << Verbose(1) << "Found maximum coordinates: ");
     2230  for (int i = 0; i < NDIM; i++)
     2231    DoLog(0) && (Log() << Verbose(0) << i << ": " << *MaxPoint[i] << "\t");
     2232  DoLog(0) && (Log() << Verbose(0) << endl);
    20812233
    20822234  BTS = NULL;
    2083   for (int k=0;k<NDIM;k++) {
     2235  for (int k = 0; k < NDIM; k++) {
    20842236    NormalVector.Zero();
    20852237    NormalVector.x[k] = 1.;
    2086     BaseLine.endpoints[0] = new BoundaryPointSet(MaxPoint[k]);
    2087     Log() << Verbose(0) << "Coordinates of start node at " << *BaseLine.endpoints[0]->node << "." << endl;
     2238    BaseLine = new BoundaryLineSet();
     2239    BaseLine->endpoints[0] = new BoundaryPointSet(MaxPoint[k]);
     2240    DoLog(0) && (Log() << Verbose(0) << "Coordinates of start node at " << *BaseLine->endpoints[0]->node << "." << endl);
    20882241
    20892242    double ShortestAngle;
    20902243    ShortestAngle = 999999.; // This will contain the angle, which will be always positive (when looking for second point), when looking for third point this will be the quadrant.
    20912244
    2092     FindSecondPointForTesselation(BaseLine.endpoints[0]->node, NormalVector, Temporary, &ShortestAngle, RADIUS, LC); // we give same point as next candidate as its bonds are looked into in find_second_...
    2093     if (Temporary == NULL)  // have we found a second point?
     2245    Temporary = NULL;
     2246    FindSecondPointForTesselation(BaseLine->endpoints[0]->node, NormalVector, Temporary, &ShortestAngle, RADIUS, LC); // we give same point as next candidate as its bonds are looked into in find_second_...
     2247    if (Temporary == NULL) {
     2248      // have we found a second point?
     2249      delete BaseLine;
    20942250      continue;
    2095     BaseLine.endpoints[1] = new BoundaryPointSet(Temporary);
     2251    }
     2252    BaseLine->endpoints[1] = new BoundaryPointSet(Temporary);
    20962253
    20972254    // construct center of circle
    2098     CircleCenter.CopyVector(BaseLine.endpoints[0]->node->node);
    2099     CircleCenter.AddVector(BaseLine.endpoints[1]->node->node);
     2255    CircleCenter.CopyVector(BaseLine->endpoints[0]->node->node);
     2256    CircleCenter.AddVector(BaseLine->endpoints[1]->node->node);
    21002257    CircleCenter.Scale(0.5);
    21012258
    21022259    // construct normal vector of circle
    2103     CirclePlaneNormal.CopyVector(BaseLine.endpoints[0]->node->node);
    2104     CirclePlaneNormal.SubtractVector(BaseLine.endpoints[1]->node->node);
     2260    CirclePlaneNormal.CopyVector(BaseLine->endpoints[0]->node->node);
     2261    CirclePlaneNormal.SubtractVector(BaseLine->endpoints[1]->node->node);
    21052262
    21062263    double radius = CirclePlaneNormal.NormSquared();
    2107     double CircleRadius = sqrt(RADIUS*RADIUS - radius/4.);
     2264    double CircleRadius = sqrt(RADIUS * RADIUS - radius / 4.);
    21082265
    21092266    NormalVector.ProjectOntoPlane(&CirclePlaneNormal);
    21102267    NormalVector.Normalize();
    2111     ShortestAngle = 2.*M_PI; // This will indicate the quadrant.
     2268    ShortestAngle = 2. * M_PI; // This will indicate the quadrant.
    21122269
    21132270    SphereCenter.CopyVector(&NormalVector);
     
    21172274
    21182275    // look in one direction of baseline for initial candidate
    2119     SearchDirection.MakeNormalVector(&CirclePlaneNormal, &NormalVector);  // whether we look "left" first or "right" first is not important ...
     2276    SearchDirection.MakeNormalVector(&CirclePlaneNormal, &NormalVector); // whether we look "left" first or "right" first is not important ...
    21202277
    21212278    // adding point 1 and point 2 and add the line between them
    2122     Log() << Verbose(0) << "Coordinates of start node at " << *BaseLine.endpoints[0]->node << "." << endl;
    2123     Log() << Verbose(0) << "Found second point is at " << *BaseLine.endpoints[1]->node << ".\n";
     2279    DoLog(0) && (Log() << Verbose(0) << "Coordinates of start node at " << *BaseLine->endpoints[0]->node << "." << endl);
     2280    DoLog(0) && (Log() << Verbose(0) << "Found second point is at " << *BaseLine->endpoints[1]->node << ".\n");
    21242281
    21252282    //Log() << Verbose(1) << "INFO: OldSphereCenter is at " << helper << ".\n";
    2126     CandidateForTesselation OptCandidates(&BaseLine);
     2283    CandidateForTesselation OptCandidates(BaseLine);
    21272284    FindThirdPointForTesselation(NormalVector, SearchDirection, SphereCenter, OptCandidates, NULL, RADIUS, LC);
    2128     Log() << Verbose(0) << "List of third Points is:" << endl;
     2285    DoLog(0) && (Log() << Verbose(0) << "List of third Points is:" << endl);
    21292286    for (TesselPointList::iterator it = OptCandidates.pointlist.begin(); it != OptCandidates.pointlist.end(); it++) {
    2130         Log() << Verbose(0) << " " << *(*it) << endl;
    2131     }
    2132 
    2133     BTS = NULL;
    2134     AddCandidateTriangle(OptCandidates);
    2135 //    delete(BaseLine.endpoints[0]);
    2136 //    delete(BaseLine.endpoints[1]);
    2137 
    2138     if (BTS != NULL) // we have created one starting triangle
     2287      DoLog(0) && (Log() << Verbose(0) << " " << *(*it) << endl);
     2288    }
     2289    if (!OptCandidates.pointlist.empty()) {
     2290      BTS = NULL;
     2291      AddCandidatePolygon(OptCandidates, RADIUS, LC);
     2292    } else {
     2293      delete BaseLine;
     2294      continue;
     2295    }
     2296
     2297    if (BTS != NULL) { // we have created one starting triangle
     2298      delete BaseLine;
    21392299      break;
    2140     else {
     2300    } else {
    21412301      // remove all candidates from the list and then the list itself
    21422302      OptCandidates.pointlist.clear();
    21432303    }
    2144   }
    2145 };
     2304    delete BaseLine;
     2305  }
     2306
     2307  return (BTS != NULL);
     2308}
     2309;
    21462310
    21472311/** Checks for a given baseline and a third point candidate whether baselines of the found triangle don't have even better candidates.
     
    22142378//            if (fabs(OldSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) {
    22152379//              // rotated the wrong way!
    2216 //              eLog() << Verbose(1) << "SearchDirection and RelativeOldSphereCenter are still not orthogonal!" << endl;
     2380//              DoeLog(1) && (eLog()<< Verbose(1) << "SearchDirection and RelativeOldSphereCenter are still not orthogonal!" << endl);
    22172381//            }
    22182382//
     
    22712435//          }
    22722436//        } else {
    2273 //          eLog() << Verbose(2) << "Baseline is connected to two triangles already?" << endl;
     2437//          DoeLog(2) && (eLog()<< Verbose(2) << "Baseline is connected to two triangles already?" << endl);
    22742438//        }
    22752439//      } else {
     
    22782442//    }
    22792443//  } else {
    2280 //    eLog() << Verbose(1) << "Could not find the TesselPoint " << *ThirdNode << "." << endl;
     2444//    DoeLog(1) && (eLog()<< Verbose(1) << "Could not find the TesselPoint " << *ThirdNode << "." << endl);
    22812445//  }
    22822446//
     
    22922456 * @param *LC LinkedCell structure with neighbouring points
    22932457 */
    2294 bool Tesselation::FindNextSuitableTriangle(CandidateForTesselation &CandidateLine, BoundaryTriangleSet &T, const double& RADIUS, const LinkedCell *LC)
    2295 {
    2296         Info FunctionInfo(__func__);
    2297   bool result = true;
    2298 
     2458bool Tesselation::FindNextSuitableTriangle(CandidateForTesselation &CandidateLine, const BoundaryTriangleSet &T, const double& RADIUS, const LinkedCell *LC)
     2459{
     2460  Info FunctionInfo(__func__);
    22992461  Vector CircleCenter;
    23002462  Vector CirclePlaneNormal;
     
    23022464  Vector SearchDirection;
    23032465  Vector helper;
    2304   TesselPoint *ThirdNode = NULL;
     2466  BoundaryPointSet *ThirdPoint = NULL;
    23052467  LineMap::iterator testline;
    23062468  double radius, CircleRadius;
    23072469
    2308   for (int i=0;i<3;i++)
    2309     if ((T.endpoints[i]->node != CandidateLine.BaseLine->endpoints[0]->node) && (T.endpoints[i]->node != CandidateLine.BaseLine->endpoints[1]->node)) {
    2310       ThirdNode = T.endpoints[i]->node;
     2470  for (int i = 0; i < 3; i++)
     2471    if ((T.endpoints[i] != CandidateLine.BaseLine->endpoints[0]) && (T.endpoints[i] != CandidateLine.BaseLine->endpoints[1])) {
     2472      ThirdPoint = T.endpoints[i];
    23112473      break;
    23122474    }
    2313   Log() << Verbose(0) << "Current baseline is " << *CandidateLine.BaseLine << " with ThirdNode " << *ThirdNode << " of triangle " << T << "." << endl;
     2475  DoLog(0) && (Log() << Verbose(0) << "Current baseline is " << *CandidateLine.BaseLine << " with ThirdPoint " << *ThirdPoint << " of triangle " << T << "." << endl);
     2476
     2477  CandidateLine.T = &T;
    23142478
    23152479  // construct center of circle
     
    23242488  // calculate squared radius of circle
    23252489  radius = CirclePlaneNormal.ScalarProduct(&CirclePlaneNormal);
    2326   if (radius/4. < RADIUS*RADIUS) {
     2490  if (radius / 4. < RADIUS * RADIUS) {
    23272491    // construct relative sphere center with now known CircleCenter
    23282492    RelativeSphereCenter.CopyVector(&T.SphereCenter);
    23292493    RelativeSphereCenter.SubtractVector(&CircleCenter);
    23302494
    2331     CircleRadius = RADIUS*RADIUS - radius/4.;
     2495    CircleRadius = RADIUS * RADIUS - radius / 4.;
    23322496    CirclePlaneNormal.Normalize();
    2333     Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl;
    2334 
    2335     Log() << Verbose(1) << "INFO: OldSphereCenter is at " << T.SphereCenter << "." << endl;
     2497    DoLog(1) && (Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl);
     2498
     2499    DoLog(1) && (Log() << Verbose(1) << "INFO: OldSphereCenter is at " << T.SphereCenter << "." << endl);
    23362500
    23372501    // construct SearchDirection and an "outward pointer"
    23382502    SearchDirection.MakeNormalVector(&RelativeSphereCenter, &CirclePlaneNormal);
    23392503    helper.CopyVector(&CircleCenter);
    2340     helper.SubtractVector(ThirdNode->node);
     2504    helper.SubtractVector(ThirdPoint->node->node);
    23412505    if (helper.ScalarProduct(&SearchDirection) < -HULLEPSILON)// ohoh, SearchDirection points inwards!
    23422506      SearchDirection.Scale(-1.);
    2343     Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl;
     2507    DoLog(1) && (Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl);
    23442508    if (fabs(RelativeSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) {
    23452509      // rotated the wrong way!
    2346       eLog() << Verbose(1) << "SearchDirection and RelativeOldSphereCenter are still not orthogonal!" << endl;
     2510      DoeLog(1) && (eLog() << Verbose(1) << "SearchDirection and RelativeOldSphereCenter are still not orthogonal!" << endl);
    23472511    }
    23482512
    23492513    // add third point
    2350     FindThirdPointForTesselation(T.NormalVector, SearchDirection, T.SphereCenter, CandidateLine, ThirdNode, RADIUS, LC);
     2514    FindThirdPointForTesselation(T.NormalVector, SearchDirection, T.SphereCenter, CandidateLine, ThirdPoint, RADIUS, LC);
    23512515
    23522516  } else {
    2353     Log() << Verbose(0) << "Circumcircle for base line " << *CandidateLine.BaseLine << " and base triangle " << T << " is too big!" << endl;
     2517    DoLog(0) && (Log() << Verbose(0) << "Circumcircle for base line " << *CandidateLine.BaseLine << " and base triangle " << T << " is too big!" << endl);
    23542518  }
    23552519
    23562520  if (CandidateLine.pointlist.empty()) {
    2357     eLog() << Verbose(2) << "Could not find a suitable candidate." << endl;
     2521    DoeLog(2) && (eLog() << Verbose(2) << "Could not find a suitable candidate." << endl);
    23582522    return false;
    23592523  }
    2360   Log() << Verbose(0) << "Third Points are: " << endl;
     2524  DoLog(0) && (Log() << Verbose(0) << "Third Points are: " << endl);
    23612525  for (TesselPointList::iterator it = CandidateLine.pointlist.begin(); it != CandidateLine.pointlist.end(); ++it) {
    2362     Log() << Verbose(0) << " " << *(*it) << endl;
     2526    DoLog(0) && (Log() << Verbose(0) << " " << *(*it) << endl);
    23632527  }
    23642528
    23652529  return true;
    2366 
    2367 //  BoundaryLineSet *BaseRay = CandidateLine.BaseLine;
    2368 //  for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) {
    2369 //    Log() << Verbose(0) << "Third point candidate is " << *(*it)->point
    2370 //    << " with circumsphere's center at " << (*it)->OptCenter << "." << endl;
    2371 //    Log() << Verbose(0) << "Baseline is " << *BaseRay << endl;
    2372 //
    2373 //    // check whether all edges of the new triangle still have space for one more triangle (i.e. TriangleCount <2)
    2374 //    TesselPoint *PointCandidates[3];
    2375 //    PointCandidates[0] = (*it)->point;
    2376 //    PointCandidates[1] = BaseRay->endpoints[0]->node;
    2377 //    PointCandidates[2] = BaseRay->endpoints[1]->node;
    2378 //    int existentTrianglesCount = CheckPresenceOfTriangle(PointCandidates);
    2379 //
    2380 //    BTS = NULL;
    2381 //    // check for present edges and whether we reach better candidates from them
    2382 //    //if (HasOtherBaselineBetterCandidate(BaseRay, (*it)->point, ShortestAngle, RADIUS, LC) ) {
    2383 //    if (0) {
    2384 //      result = false;
    2385 //      break;
    2386 //    } else {
    2387 //      // If there is no triangle, add it regularly.
    2388 //      if (existentTrianglesCount == 0) {
    2389 //        AddTesselationPoint((*it)->point, 0);
    2390 //        AddTesselationPoint(BaseRay->endpoints[0]->node, 1);
    2391 //        AddTesselationPoint(BaseRay->endpoints[1]->node, 2);
    2392 //
    2393 //        if (CheckLineCriteriaForDegeneratedTriangle((const BoundaryPointSet ** const )TPS)) {
    2394 //          CandidateLine.point = (*it)->point;
    2395 //          CandidateLine.OptCenter.CopyVector(&((*it)->OptCenter));
    2396 //          CandidateLine.OtherOptCenter.CopyVector(&((*it)->OtherOptCenter));
    2397 //          CandidateLine.ShortestAngle = ShortestAngle;
    2398 //        } else {
    2399 ////          eLog() << Verbose(1) << "This triangle consisting of ";
    2400 ////          Log() << Verbose(0) << *(*it)->point << ", ";
    2401 ////          Log() << Verbose(0) << *BaseRay->endpoints[0]->node << " and ";
    2402 ////          Log() << Verbose(0) << *BaseRay->endpoints[1]->node << " ";
    2403 ////          Log() << Verbose(0) << "exists and is not added, as it 0x80000000006fc150(does not seem helpful!" << endl;
    2404 //          result = false;
    2405 //        }
    2406 //      } else if ((existentTrianglesCount >= 1) && (existentTrianglesCount <= 3)) { // If there is a planar region within the structure, we need this triangle a second time.
    2407 //          AddTesselationPoint((*it)->point, 0);
    2408 //          AddTesselationPoint(BaseRay->endpoints[0]->node, 1);
    2409 //          AddTesselationPoint(BaseRay->endpoints[1]->node, 2);
    2410 //
    2411 //          // We demand that at most one new degenerate line is created and that this line also already exists (which has to be the case due to existentTrianglesCount == 1)
    2412 //          // i.e. at least one of the three lines must be present with TriangleCount <= 1
    2413 //          if (CheckLineCriteriaForDegeneratedTriangle((const BoundaryPointSet ** const)TPS) || CandidateLine.BaseLine->skipped) {
    2414 //            CandidateLine.point = (*it)->point;
    2415 //            CandidateLine.OptCenter.CopyVector(&(*it)->OptCenter);
    2416 //            CandidateLine.OtherOptCenter.CopyVector(&(*it)->OtherOptCenter);
    2417 //            CandidateLine.ShortestAngle = ShortestAngle+2.*M_PI;
    2418 //
    2419 //          } else {
    2420 ////            eLog() << Verbose(1) << "This triangle consisting of " << *(*it)->point << ", " << *BaseRay->endpoints[0]->node << " and " << *BaseRay->endpoints[1]->node << " " << "exists and is not added, as it does not seem helpful!" << endl;
    2421 //            result = false;
    2422 //          }
    2423 //      } else {
    2424 ////        Log() << Verbose(1) << "This triangle consisting of ";
    2425 ////        Log() << Verbose(0) << *(*it)->point << ", ";
    2426 ////        Log() << Verbose(0) << *BaseRay->endpoints[0]->node << " and ";
    2427 ////        Log() << Verbose(0) << *BaseRay->endpoints[1]->node << " ";
    2428 ////        Log() << Verbose(0) << "is invalid!" << endl;
    2429 //        result = false;
    2430 //      }
    2431 //    }
    2432 //
    2433 //    // set baseline to new ray from ref point (here endpoints[0]->node) to current candidate (here (*it)->point))
    2434 //    BaseRay = BLS[0];
    2435 //    if ((BTS != NULL) && (BTS->NormalVector.NormSquared() < MYEPSILON)) {
    2436 //      eLog() << Verbose(1) << "Triangle " << *BTS << " has zero normal vector!" << endl;
    2437 //      exit(255);
    2438 //    }
    2439 //
    2440 //  }
    2441 //
    2442 //  // remove all candidates from the list and then the list itself
    2443 //  class CandidateForTesselation *remover = NULL;
    2444 //  for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) {
    2445 //    remover = *it;
    2446 //    delete(remover);
    2447 //  }
    2448 //  delete(OptCandidates);
    2449   return result;
    2450 };
     2530}
     2531;
     2532
     2533/** Walks through Tesselation::OpenLines() and finds candidates for newly created ones.
     2534 * \param *&LCList atoms in LinkedCell list
     2535 * \param RADIUS radius of the virtual sphere
     2536 * \return true - for all open lines without candidates so far, a candidate has been found,
     2537 *         false - at least one open line without candidate still
     2538 */
     2539bool Tesselation::FindCandidatesforOpenLines(const double RADIUS, const LinkedCell *&LCList)
     2540{
     2541  bool TesselationFailFlag = true;
     2542  CandidateForTesselation *baseline = NULL;
     2543  BoundaryTriangleSet *T = NULL;
     2544
     2545  for (CandidateMap::iterator Runner = OpenLines.begin(); Runner != OpenLines.end(); Runner++) {
     2546    baseline = Runner->second;
     2547    if (baseline->pointlist.empty()) {
     2548      assert((baseline->BaseLine->triangles.size() == 1) && ("Open line without exactly one attached triangle"));
     2549      T = (((baseline->BaseLine->triangles.begin()))->second);
     2550      DoLog(1) && (Log() << Verbose(1) << "Finding best candidate for open line " << *baseline->BaseLine << " of triangle " << *T << endl);
     2551      TesselationFailFlag = TesselationFailFlag && FindNextSuitableTriangle(*baseline, *T, RADIUS, LCList); //the line is there, so there is a triangle, but only one.
     2552    }
     2553  }
     2554  return TesselationFailFlag;
     2555}
     2556;
    24512557
    24522558/** Adds the present line and candidate point from \a &CandidateLine to the Tesselation.
    24532559 * \param CandidateLine triangle to add
    2454  * \NOTE we need the copy operator here as the original CandidateForTesselation is removed in AddTesselationLine()
    2455  */
    2456 void Tesselation::AddCandidateTriangle(CandidateForTesselation CandidateLine)
    2457 {
    2458         Info FunctionInfo(__func__);
     2560 * \param RADIUS Radius of sphere
     2561 * \param *LC LinkedCell structure
     2562 * \NOTE we need the copy operator here as the original CandidateForTesselation is removed in
     2563 * AddTesselationLine() in AddCandidateTriangle()
     2564 */
     2565void Tesselation::AddCandidatePolygon(CandidateForTesselation CandidateLine, const double RADIUS, const LinkedCell *LC)
     2566{
     2567  Info FunctionInfo(__func__);
    24592568  Vector Center;
    24602569  TesselPoint * const TurningPoint = CandidateLine.BaseLine->endpoints[0]->node;
     2570  TesselPointList::iterator Runner;
     2571  TesselPointList::iterator Sprinter;
    24612572
    24622573  // fill the set of neighbours
     
    24672578  TesselPointList *connectedClosestPoints = GetCircleOfSetOfPoints(&SetOfNeighbours, TurningPoint, CandidateLine.BaseLine->endpoints[1]->node->node);
    24682579
     2580  DoLog(0) && (Log() << Verbose(0) << "List of Candidates for Turning Point " << *TurningPoint << ":" << endl);
     2581  for (TesselPointList::iterator TesselRunner = connectedClosestPoints->begin(); TesselRunner != connectedClosestPoints->end(); ++TesselRunner)
     2582    DoLog(0) && (Log() << Verbose(0) << " " << **TesselRunner << endl);
     2583
    24692584  // go through all angle-sorted candidates (in degenerate n-nodes case we may have to add multiple triangles)
    2470   Log() << Verbose(0) << "List of Candidates for Turning Point: " << *TurningPoint << "." << endl;
    2471   for (TesselPointList::iterator TesselRunner = connectedClosestPoints->begin(); TesselRunner != connectedClosestPoints->end(); ++TesselRunner)
    2472     Log() << Verbose(0) << **TesselRunner << endl;
    2473   TesselPointList::iterator Runner = connectedClosestPoints->begin();
    2474   TesselPointList::iterator Sprinter = Runner;
     2585  Runner = connectedClosestPoints->begin();
     2586  Sprinter = Runner;
    24752587  Sprinter++;
    2476   while(Sprinter != connectedClosestPoints->end()) {
    2477     // add the points
     2588  while (Sprinter != connectedClosestPoints->end()) {
     2589    DoLog(0) && (Log() << Verbose(0) << "Current Runner is " << *(*Runner) << " and sprinter is " << *(*Sprinter) << "." << endl);
     2590
    24782591    AddTesselationPoint(TurningPoint, 0);
    2479     AddTesselationPoint((*Runner), 1);
    2480     AddTesselationPoint((*Sprinter), 2);
    2481 
    2482     // add the lines
    2483     AddTesselationLine(TPS[0], TPS[1], 0);
    2484     AddTesselationLine(TPS[0], TPS[2], 1);
    2485     AddTesselationLine(TPS[1], TPS[2], 2);
    2486 
    2487     // add the triangles
    2488     BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
    2489     AddTesselationTriangle();
    2490     BTS->GetCenter(&Center);
    2491     Center.SubtractVector(&CandidateLine.OptCenter);
    2492     BTS->SphereCenter.CopyVector(&CandidateLine.OptCenter);
    2493     BTS->GetNormalVector(Center);
    2494 
    2495     Log() << Verbose(0) << "--> New triangle with " << *BTS << " and normal vector " << BTS->NormalVector << "." << endl;
     2592    AddTesselationPoint(*Runner, 1);
     2593    AddTesselationPoint(*Sprinter, 2);
     2594
     2595    AddCandidateTriangle(CandidateLine, Opt);
     2596
    24962597    Runner = Sprinter;
    24972598    Sprinter++;
    2498     Log() << Verbose(0) << "Current Runner is " << **Runner << "." << endl;
    2499     if (Sprinter != connectedClosestPoints->end())
    2500       Log() << Verbose(0) << " There are still more triangles to add." << endl;
    2501   }
    2502   delete(connectedClosestPoints);
     2599    if (Sprinter != connectedClosestPoints->end()) {
     2600      // fill the internal open lines with its respective candidate (otherwise lines in degenerate case are not picked)
     2601      FindDegeneratedCandidatesforOpenLines(*Sprinter, &CandidateLine.OptCenter); // Assume BTS contains last triangle
     2602      DoLog(0) && (Log() << Verbose(0) << " There are still more triangles to add." << endl);
     2603    }
     2604    // pick candidates for other open lines as well
     2605    FindCandidatesforOpenLines(RADIUS, LC);
     2606
     2607    // check whether we add a degenerate or a normal triangle
     2608    if (CheckDegeneracy(CandidateLine, RADIUS, LC)) {
     2609      // add normal and degenerate triangles
     2610      DoLog(1) && (Log() << Verbose(1) << "Triangle of endpoints " << *TPS[0] << "," << *TPS[1] << " and " << *TPS[2] << " is degenerated, adding both sides." << endl);
     2611      AddCandidateTriangle(CandidateLine, OtherOpt);
     2612
     2613      if (Sprinter != connectedClosestPoints->end()) {
     2614        // fill the internal open lines with its respective candidate (otherwise lines in degenerate case are not picked)
     2615        FindDegeneratedCandidatesforOpenLines(*Sprinter, &CandidateLine.OtherOptCenter);
     2616      }
     2617      // pick candidates for other open lines as well
     2618      FindCandidatesforOpenLines(RADIUS, LC);
     2619    }
     2620  }
     2621  delete (connectedClosestPoints);
    25032622};
     2623
     2624/** for polygons (multiple candidates for a baseline) sets internal edges to the correct next candidate.
     2625 * \param *Sprinter next candidate to which internal open lines are set
     2626 * \param *OptCenter OptCenter for this candidate
     2627 */
     2628void Tesselation::FindDegeneratedCandidatesforOpenLines(TesselPoint * const Sprinter, const Vector * const OptCenter)
     2629{
     2630  Info FunctionInfo(__func__);
     2631
     2632  pair<LineMap::iterator, LineMap::iterator> FindPair = TPS[0]->lines.equal_range(TPS[2]->node->nr);
     2633  for (LineMap::const_iterator FindLine = FindPair.first; FindLine != FindPair.second; FindLine++) {
     2634    DoLog(1) && (Log() << Verbose(1) << "INFO: Checking line " << *(FindLine->second) << " ..." << endl);
     2635    // If there is a line with less than two attached triangles, we don't need a new line.
     2636    if (FindLine->second->triangles.size() == 1) {
     2637      CandidateMap::iterator Finder = OpenLines.find(FindLine->second);
     2638      if (!Finder->second->pointlist.empty())
     2639        DoLog(1) && (Log() << Verbose(1) << "INFO: line " << *(FindLine->second) << " is open with candidate " << **(Finder->second->pointlist.begin()) << "." << endl);
     2640      else {
     2641        DoLog(1) && (Log() << Verbose(1) << "INFO: line " << *(FindLine->second) << " is open with no candidate, setting to next Sprinter" << (*Sprinter) << endl);
     2642        Finder->second->T = BTS;  // is last triangle
     2643        Finder->second->pointlist.push_back(Sprinter);
     2644        Finder->second->ShortestAngle = 0.;
     2645        Finder->second->OptCenter.CopyVector(OptCenter);
     2646      }
     2647    }
     2648  }
     2649};
     2650
     2651/** If a given \a *triangle is degenerated, this adds both sides.
     2652 * i.e. the triangle with same BoundaryPointSet's but NormalVector in opposite direction.
     2653 * Note that endpoints are stored in Tesselation::TPS
     2654 * \param CandidateLine CanddiateForTesselation structure for the desired BoundaryLine
     2655 * \param RADIUS radius of sphere
     2656 * \param *LC pointer to LinkedCell structure
     2657 */
     2658void Tesselation::AddDegeneratedTriangle(CandidateForTesselation &CandidateLine, const double RADIUS, const LinkedCell *LC)
     2659{
     2660  Info FunctionInfo(__func__);
     2661  Vector Center;
     2662  CandidateMap::const_iterator CandidateCheck = OpenLines.end();
     2663  BoundaryTriangleSet *triangle = NULL;
     2664
     2665  /// 1. Create or pick the lines for the first triangle
     2666  DoLog(0) && (Log() << Verbose(0) << "INFO: Creating/Picking lines for first triangle ..." << endl);
     2667  for (int i = 0; i < 3; i++) {
     2668    BLS[i] = NULL;
     2669    DoLog(0) && (Log() << Verbose(0) << "Current line is between " << *TPS[(i + 0) % 3] << " and " << *TPS[(i + 1) % 3] << ":" << endl);
     2670    AddTesselationLine(&CandidateLine.OptCenter, TPS[(i + 2) % 3], TPS[(i + 0) % 3], TPS[(i + 1) % 3], i);
     2671  }
     2672
     2673  /// 2. create the first triangle and NormalVector and so on
     2674  DoLog(0) && (Log() << Verbose(0) << "INFO: Adding first triangle with center at " << CandidateLine.OptCenter << " ..." << endl);
     2675  BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
     2676  AddTesselationTriangle();
     2677
     2678  // create normal vector
     2679  BTS->GetCenter(&Center);
     2680  Center.SubtractVector(&CandidateLine.OptCenter);
     2681  BTS->SphereCenter.CopyVector(&CandidateLine.OptCenter);
     2682  BTS->GetNormalVector(Center);
     2683  // give some verbose output about the whole procedure
     2684  if (CandidateLine.T != NULL)
     2685    DoLog(0) && (Log() << Verbose(0) << "--> New triangle with " << *BTS << " and normal vector " << BTS->NormalVector << ", from " << *CandidateLine.T << " and angle " << CandidateLine.ShortestAngle << "." << endl);
     2686  else
     2687    DoLog(0) && (Log() << Verbose(0) << "--> New starting triangle with " << *BTS << " and normal vector " << BTS->NormalVector << " and no top triangle." << endl);
     2688  triangle = BTS;
     2689
     2690  /// 3. Gather candidates for each new line
     2691  DoLog(0) && (Log() << Verbose(0) << "INFO: Adding candidates to new lines ..." << endl);
     2692  for (int i = 0; i < 3; i++) {
     2693    DoLog(0) && (Log() << Verbose(0) << "Current line is between " << *TPS[(i + 0) % 3] << " and " << *TPS[(i + 1) % 3] << ":" << endl);
     2694    CandidateCheck = OpenLines.find(BLS[i]);
     2695    if ((CandidateCheck != OpenLines.end()) && (CandidateCheck->second->pointlist.empty())) {
     2696      if (CandidateCheck->second->T == NULL)
     2697        CandidateCheck->second->T = triangle;
     2698      FindNextSuitableTriangle(*(CandidateCheck->second), *CandidateCheck->second->T, RADIUS, LC);
     2699    }
     2700  }
     2701
     2702  /// 4. Create or pick the lines for the second triangle
     2703  DoLog(0) && (Log() << Verbose(0) << "INFO: Creating/Picking lines for second triangle ..." << endl);
     2704  for (int i = 0; i < 3; i++) {
     2705    DoLog(0) && (Log() << Verbose(0) << "Current line is between " << *TPS[(i + 0) % 3] << " and " << *TPS[(i + 1) % 3] << ":" << endl);
     2706    AddTesselationLine(&CandidateLine.OtherOptCenter, TPS[(i + 2) % 3], TPS[(i + 0) % 3], TPS[(i + 1) % 3], i);
     2707  }
     2708
     2709  /// 5. create the second triangle and NormalVector and so on
     2710  DoLog(0) && (Log() << Verbose(0) << "INFO: Adding second triangle with center at " << CandidateLine.OtherOptCenter << " ..." << endl);
     2711  BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
     2712  AddTesselationTriangle();
     2713
     2714  BTS->SphereCenter.CopyVector(&CandidateLine.OtherOptCenter);
     2715  // create normal vector in other direction
     2716  BTS->GetNormalVector(&triangle->NormalVector);
     2717  BTS->NormalVector.Scale(-1.);
     2718  // give some verbose output about the whole procedure
     2719  if (CandidateLine.T != NULL)
     2720    DoLog(0) && (Log() << Verbose(0) << "--> New degenerate triangle with " << *BTS << " and normal vector " << BTS->NormalVector << ", from " << *CandidateLine.T << " and angle " << CandidateLine.ShortestAngle << "." << endl);
     2721  else
     2722    DoLog(0) && (Log() << Verbose(0) << "--> New degenerate starting triangle with " << *BTS << " and normal vector " << BTS->NormalVector << " and no top triangle." << endl);
     2723
     2724  /// 6. Adding triangle to new lines
     2725  DoLog(0) && (Log() << Verbose(0) << "INFO: Adding second triangles to new lines ..." << endl);
     2726  for (int i = 0; i < 3; i++) {
     2727    DoLog(0) && (Log() << Verbose(0) << "Current line is between " << *TPS[(i + 0) % 3] << " and " << *TPS[(i + 1) % 3] << ":" << endl);
     2728    CandidateCheck = OpenLines.find(BLS[i]);
     2729    if ((CandidateCheck != OpenLines.end()) && (CandidateCheck->second->pointlist.empty())) {
     2730      if (CandidateCheck->second->T == NULL)
     2731        CandidateCheck->second->T = BTS;
     2732    }
     2733  }
     2734}
     2735;
     2736
     2737/** Adds a triangle to the Tesselation structure from three given TesselPoint's.
     2738 * Note that endpoints are in Tesselation::TPS.
     2739 * \param CandidateLine CandidateForTesselation structure contains other information
     2740 * \param type which opt center to add (i.e. which side) and thus which NormalVector to take
     2741 */
     2742void Tesselation::AddCandidateTriangle(CandidateForTesselation &CandidateLine, enum centers type)
     2743{
     2744  Info FunctionInfo(__func__);
     2745  Vector Center;
     2746  Vector *OptCenter = (type == Opt) ? &CandidateLine.OptCenter : &CandidateLine.OtherOptCenter;
     2747
     2748  // add the lines
     2749  AddTesselationLine(OptCenter, TPS[2], TPS[0], TPS[1], 0);
     2750  AddTesselationLine(OptCenter, TPS[1], TPS[0], TPS[2], 1);
     2751  AddTesselationLine(OptCenter, TPS[0], TPS[1], TPS[2], 2);
     2752
     2753  // add the triangles
     2754  BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
     2755  AddTesselationTriangle();
     2756
     2757  // create normal vector
     2758  BTS->GetCenter(&Center);
     2759  Center.SubtractVector(OptCenter);
     2760  BTS->SphereCenter.CopyVector(OptCenter);
     2761  BTS->GetNormalVector(Center);
     2762
     2763  // give some verbose output about the whole procedure
     2764  if (CandidateLine.T != NULL)
     2765    DoLog(0) && (Log() << Verbose(0) << "--> New" << ((type == OtherOpt) ? " degenerate " : " ") << "triangle with " << *BTS << " and normal vector " << BTS->NormalVector << ", from " << *CandidateLine.T << " and angle " << CandidateLine.ShortestAngle << "." << endl);
     2766  else
     2767    DoLog(0) && (Log() << Verbose(0) << "--> New" << ((type == OtherOpt) ? " degenerate " : " ") << "starting triangle with " << *BTS << " and normal vector " << BTS->NormalVector << " and no top triangle." << endl);
     2768}
     2769;
    25042770
    25052771/** Checks whether the quadragon of the two triangles connect to \a *Base is convex.
     
    25122778class BoundaryPointSet *Tesselation::IsConvexRectangle(class BoundaryLineSet *Base)
    25132779{
    2514         Info FunctionInfo(__func__);
     2780  Info FunctionInfo(__func__);
    25152781  class BoundaryPointSet *Spot = NULL;
    25162782  class BoundaryLineSet *OtherBase;
    25172783  Vector *ClosestPoint;
    25182784
    2519   int m=0;
    2520   for(TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++)
    2521     for (int j=0;j<3;j++) // all of their endpoints and baselines
     2785  int m = 0;
     2786  for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++)
     2787    for (int j = 0; j < 3; j++) // all of their endpoints and baselines
    25222788      if (!Base->ContainsBoundaryPoint(runner->second->endpoints[j])) // and neither of its endpoints
    25232789        BPS[m++] = runner->second->endpoints[j];
    2524   OtherBase = new class BoundaryLineSet(BPS,-1);
    2525 
    2526   Log() << Verbose(1) << "INFO: Current base line is " << *Base << "." << endl;
    2527   Log() << Verbose(1) << "INFO: Other base line is " << *OtherBase << "." << endl;
     2790  OtherBase = new class BoundaryLineSet(BPS, -1);
     2791
     2792  DoLog(1) && (Log() << Verbose(1) << "INFO: Current base line is " << *Base << "." << endl);
     2793  DoLog(1) && (Log() << Verbose(1) << "INFO: Other base line is " << *OtherBase << "." << endl);
    25282794
    25292795  // get the closest point on each line to the other line
     
    25312797
    25322798  // delete the temporary other base line
    2533   delete(OtherBase);
     2799  delete (OtherBase);
    25342800
    25352801  // get the distance vector from Base line to OtherBase line
     
    25382804  BaseLine.CopyVector(Base->endpoints[1]->node->node);
    25392805  BaseLine.SubtractVector(Base->endpoints[0]->node->node);
    2540   for (int i=0;i<2;i++) {
     2806  for (int i = 0; i < 2; i++) {
    25412807    DistanceToIntersection[i].CopyVector(ClosestPoint);
    25422808    DistanceToIntersection[i].SubtractVector(Base->endpoints[i]->node->node);
    25432809    distance[i] = BaseLine.ScalarProduct(&DistanceToIntersection[i]);
    25442810  }
    2545   delete(ClosestPoint);
    2546   if ((distance[0] * distance[1]) > 0)  { // have same sign?
    2547     Log() << Verbose(1) << "REJECT: Both SKPs have same sign: " << distance[0] << " and " << distance[1]  << ". " << *Base << "' rectangle is concave." << endl;
     2811  delete (ClosestPoint);
     2812  if ((distance[0] * distance[1]) > 0) { // have same sign?
     2813    DoLog(1) && (Log() << Verbose(1) << "REJECT: Both SKPs have same sign: " << distance[0] << " and " << distance[1] << ". " << *Base << "' rectangle is concave." << endl);
    25482814    if (distance[0] < distance[1]) {
    25492815      Spot = Base->endpoints[0];
     
    25522818    }
    25532819    return Spot;
    2554   } else {  // different sign, i.e. we are in between
    2555     Log() << Verbose(0) << "ACCEPT: Rectangle of triangles of base line " << *Base << " is convex." << endl;
     2820  } else { // different sign, i.e. we are in between
     2821    DoLog(0) && (Log() << Verbose(0) << "ACCEPT: Rectangle of triangles of base line " << *Base << " is convex." << endl);
    25562822    return NULL;
    25572823  }
    25582824
    2559 };
     2825}
     2826;
    25602827
    25612828void Tesselation::PrintAllBoundaryPoints(ofstream *out) const
    25622829{
    2563         Info FunctionInfo(__func__);
     2830  Info FunctionInfo(__func__);
    25642831  // print all lines
    2565   Log() << Verbose(0) << "Printing all boundary points for debugging:" << endl;
    2566   for (PointMap::const_iterator PointRunner = PointsOnBoundary.begin();PointRunner != PointsOnBoundary.end(); PointRunner++)
    2567     Log() << Verbose(0) << *(PointRunner->second) << endl;
    2568 };
     2832  DoLog(0) && (Log() << Verbose(0) << "Printing all boundary points for debugging:" << endl);
     2833  for (PointMap::const_iterator PointRunner = PointsOnBoundary.begin(); PointRunner != PointsOnBoundary.end(); PointRunner++)
     2834    DoLog(0) && (Log() << Verbose(0) << *(PointRunner->second) << endl);
     2835}
     2836;
    25692837
    25702838void Tesselation::PrintAllBoundaryLines(ofstream *out) const
    25712839{
    2572         Info FunctionInfo(__func__);
     2840  Info FunctionInfo(__func__);
    25732841  // print all lines
    2574   Log() << Verbose(0) << "Printing all boundary lines for debugging:" << endl;
     2842  DoLog(0) && (Log() << Verbose(0) << "Printing all boundary lines for debugging:" << endl);
    25752843  for (LineMap::const_iterator LineRunner = LinesOnBoundary.begin(); LineRunner != LinesOnBoundary.end(); LineRunner++)
    2576     Log() << Verbose(0) << *(LineRunner->second) << endl;
    2577 };
     2844    DoLog(0) && (Log() << Verbose(0) << *(LineRunner->second) << endl);
     2845}
     2846;
    25782847
    25792848void Tesselation::PrintAllBoundaryTriangles(ofstream *out) const
    25802849{
    2581         Info FunctionInfo(__func__);
     2850  Info FunctionInfo(__func__);
    25822851  // print all triangles
    2583   Log() << Verbose(0) << "Printing all boundary triangles for debugging:" << endl;
     2852  DoLog(0) && (Log() << Verbose(0) << "Printing all boundary triangles for debugging:" << endl);
    25842853  for (TriangleMap::const_iterator TriangleRunner = TrianglesOnBoundary.begin(); TriangleRunner != TrianglesOnBoundary.end(); TriangleRunner++)
    2585     Log() << Verbose(0) << *(TriangleRunner->second) << endl;
    2586 };
     2854    DoLog(0) && (Log() << Verbose(0) << *(TriangleRunner->second) << endl);
     2855}
     2856;
    25872857
    25882858/** For a given boundary line \a *Base and its two triangles, picks the central baseline that is "higher".
     
    25932863double Tesselation::PickFarthestofTwoBaselines(class BoundaryLineSet *Base)
    25942864{
    2595         Info FunctionInfo(__func__);
     2865  Info FunctionInfo(__func__);
    25962866  class BoundaryLineSet *OtherBase;
    25972867  Vector *ClosestPoint[2];
    25982868  double volume;
    25992869
    2600   int m=0;
    2601   for(TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++)
    2602     for (int j=0;j<3;j++) // all of their endpoints and baselines
     2870  int m = 0;
     2871  for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++)
     2872    for (int j = 0; j < 3; j++) // all of their endpoints and baselines
    26032873      if (!Base->ContainsBoundaryPoint(runner->second->endpoints[j])) // and neither of its endpoints
    26042874        BPS[m++] = runner->second->endpoints[j];
    2605   OtherBase = new class BoundaryLineSet(BPS,-1);
    2606 
    2607   Log() << Verbose(0) << "INFO: Current base line is " << *Base << "." << endl;
    2608   Log() << Verbose(0) << "INFO: Other base line is " << *OtherBase << "." << endl;
     2875  OtherBase = new class BoundaryLineSet(BPS, -1);
     2876
     2877  DoLog(0) && (Log() << Verbose(0) << "INFO: Current base line is " << *Base << "." << endl);
     2878  DoLog(0) && (Log() << Verbose(0) << "INFO: Other base line is " << *OtherBase << "." << endl);
    26092879
    26102880  // get the closest point on each line to the other line
     
    26212891
    26222892  // delete the temporary other base line and the closest points
    2623   delete(ClosestPoint[0]);
    2624   delete(ClosestPoint[1]);
    2625   delete(OtherBase);
     2893  delete (ClosestPoint[0]);
     2894  delete (ClosestPoint[1]);
     2895  delete (OtherBase);
    26262896
    26272897  if (Distance.NormSquared() < MYEPSILON) { // check for intersection
    2628     Log() << Verbose(0) << "REJECT: Both lines have an intersection: Nothing to do." << endl;
     2898    DoLog(0) && (Log() << Verbose(0) << "REJECT: Both lines have an intersection: Nothing to do." << endl);
    26292899    return false;
    26302900  } else { // check for sign against BaseLineNormal
     
    26322902    BaseLineNormal.Zero();
    26332903    if (Base->triangles.size() < 2) {
    2634       eLog() << Verbose(1) << "Less than two triangles are attached to this baseline!" << endl;
     2904      DoeLog(1) && (eLog() << Verbose(1) << "Less than two triangles are attached to this baseline!" << endl);
    26352905      return 0.;
    26362906    }
    26372907    for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) {
    2638       Log() << Verbose(1) << "INFO: Adding NormalVector " << runner->second->NormalVector << " of triangle " << *(runner->second) << "." << endl;
     2908      DoLog(1) && (Log() << Verbose(1) << "INFO: Adding NormalVector " << runner->second->NormalVector << " of triangle " << *(runner->second) << "." << endl);
    26392909      BaseLineNormal.AddVector(&(runner->second->NormalVector));
    26402910    }
    2641     BaseLineNormal.Scale(1./2.);
     2911    BaseLineNormal.Scale(1. / 2.);
    26422912
    26432913    if (Distance.ScalarProduct(&BaseLineNormal) > MYEPSILON) { // Distance points outwards, hence OtherBase higher than Base -> flip
    2644       Log() << Verbose(0) << "ACCEPT: Other base line would be higher: Flipping baseline." << endl;
     2914      DoLog(0) && (Log() << Verbose(0) << "ACCEPT: Other base line would be higher: Flipping baseline." << endl);
    26452915      // calculate volume summand as a general tetraeder
    26462916      return volume;
    2647     } else {  // Base higher than OtherBase -> do nothing
    2648       Log() << Verbose(0) << "REJECT: Base line is higher: Nothing to do." << endl;
     2917    } else { // Base higher than OtherBase -> do nothing
     2918      DoLog(0) && (Log() << Verbose(0) << "REJECT: Base line is higher: Nothing to do." << endl);
    26492919      return 0.;
    26502920    }
    26512921  }
    2652 };
     2922}
     2923;
    26532924
    26542925/** For a given baseline and its two connected triangles, flips the baseline.
     
    26612932class BoundaryLineSet * Tesselation::FlipBaseline(class BoundaryLineSet *Base)
    26622933{
    2663         Info FunctionInfo(__func__);
     2934  Info FunctionInfo(__func__);
    26642935  class BoundaryLineSet *OldLines[4], *NewLine;
    26652936  class BoundaryPointSet *OldPoints[2];
    26662937  Vector BaseLineNormal;
    26672938  int OldTriangleNrs[2], OldBaseLineNr;
    2668   int i,m;
     2939  int i, m;
    26692940
    26702941  // calculate NormalVector for later use
    26712942  BaseLineNormal.Zero();
    26722943  if (Base->triangles.size() < 2) {
    2673     eLog() << Verbose(1) << "Less than two triangles are attached to this baseline!" << endl;
     2944    DoeLog(1) && (eLog() << Verbose(1) << "Less than two triangles are attached to this baseline!" << endl);
    26742945    return NULL;
    26752946  }
    26762947  for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) {
    2677     Log() << Verbose(1) << "INFO: Adding NormalVector " << runner->second->NormalVector << " of triangle " << *(runner->second) << "." << endl;
     2948    DoLog(1) && (Log() << Verbose(1) << "INFO: Adding NormalVector " << runner->second->NormalVector << " of triangle " << *(runner->second) << "." << endl);
    26782949    BaseLineNormal.AddVector(&(runner->second->NormalVector));
    26792950  }
    2680   BaseLineNormal.Scale(-1./2.); // has to point inside for BoundaryTriangleSet::GetNormalVector()
     2951  BaseLineNormal.Scale(-1. / 2.); // has to point inside for BoundaryTriangleSet::GetNormalVector()
    26812952
    26822953  // get the two triangles
    26832954  // gather four endpoints and four lines
    2684   for (int j=0;j<4;j++)
     2955  for (int j = 0; j < 4; j++)
    26852956    OldLines[j] = NULL;
    2686   for (int j=0;j<2;j++)
     2957  for (int j = 0; j < 2; j++)
    26872958    OldPoints[j] = NULL;
    2688   i=0;
    2689   m=0;
    2690   Log() << Verbose(0) << "The four old lines are: ";
    2691   for(TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++)
    2692     for (int j=0;j<3;j++) // all of their endpoints and baselines
     2959  i = 0;
     2960  m = 0;
     2961  DoLog(0) && (Log() << Verbose(0) << "The four old lines are: ");
     2962  for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++)
     2963    for (int j = 0; j < 3; j++) // all of their endpoints and baselines
    26932964      if (runner->second->lines[j] != Base) { // pick not the central baseline
    26942965        OldLines[i++] = runner->second->lines[j];
    2695         Log() << Verbose(0) << *runner->second->lines[j] << "\t";
     2966        DoLog(0) && (Log() << Verbose(0) << *runner->second->lines[j] << "\t");
    26962967      }
    2697   Log() << Verbose(0) << endl;
    2698   Log() << Verbose(0) << "The two old points are: ";
    2699   for(TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++)
    2700     for (int j=0;j<3;j++) // all of their endpoints and baselines
     2968  DoLog(0) && (Log() << Verbose(0) << endl);
     2969  DoLog(0) && (Log() << Verbose(0) << "The two old points are: ");
     2970  for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++)
     2971    for (int j = 0; j < 3; j++) // all of their endpoints and baselines
    27012972      if (!Base->ContainsBoundaryPoint(runner->second->endpoints[j])) { // and neither of its endpoints
    27022973        OldPoints[m++] = runner->second->endpoints[j];
    2703         Log() << Verbose(0) << *runner->second->endpoints[j] << "\t";
     2974        DoLog(0) && (Log() << Verbose(0) << *runner->second->endpoints[j] << "\t");
    27042975      }
    2705   Log() << Verbose(0) << endl;
     2976  DoLog(0) && (Log() << Verbose(0) << endl);
    27062977
    27072978  // check whether everything is in place to create new lines and triangles
    2708   if (i<4) {
    2709     eLog() << Verbose(1) << "We have not gathered enough baselines!" << endl;
     2979  if (i < 4) {
     2980    DoeLog(1) && (eLog() << Verbose(1) << "We have not gathered enough baselines!" << endl);
    27102981    return NULL;
    27112982  }
    2712   for (int j=0;j<4;j++)
     2983  for (int j = 0; j < 4; j++)
    27132984    if (OldLines[j] == NULL) {
    2714       eLog() << Verbose(1) << "We have not gathered enough baselines!" << endl;
     2985      DoeLog(1) && (eLog() << Verbose(1) << "We have not gathered enough baselines!" << endl);
    27152986      return NULL;
    27162987    }
    2717   for (int j=0;j<2;j++)
     2988  for (int j = 0; j < 2; j++)
    27182989    if (OldPoints[j] == NULL) {
    2719       eLog() << Verbose(1) << "We have not gathered enough endpoints!" << endl;
     2990      DoeLog(1) && (eLog() << Verbose(1) << "We have not gathered enough endpoints!" << endl);
    27202991      return NULL;
    27212992    }
    27222993
    27232994  // remove triangles and baseline removes itself
    2724   Log() << Verbose(0) << "INFO: Deleting baseline " << *Base << " from global list." << endl;
     2995  DoLog(0) && (Log() << Verbose(0) << "INFO: Deleting baseline " << *Base << " from global list." << endl);
    27252996  OldBaseLineNr = Base->Nr;
    2726   m=0;
    2727   for(TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) {
    2728     Log() << Verbose(0) << "INFO: Deleting triangle " << *(runner->second) << "." << endl;
     2997  m = 0;
     2998  for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) {
     2999    DoLog(0) && (Log() << Verbose(0) << "INFO: Deleting triangle " << *(runner->second) << "." << endl);
    27293000    OldTriangleNrs[m++] = runner->second->Nr;
    27303001    RemoveTesselationTriangle(runner->second);
     
    27363007  NewLine = new class BoundaryLineSet(BPS, OldBaseLineNr);
    27373008  LinesOnBoundary.insert(LinePair(OldBaseLineNr, NewLine)); // no need for check for unique insertion as NewLine is definitely a new one
    2738   Log() << Verbose(0) << "INFO: Created new baseline " << *NewLine << "." << endl;
     3009  DoLog(0) && (Log() << Verbose(0) << "INFO: Created new baseline " << *NewLine << "." << endl);
    27393010
    27403011  // construct new triangles with flipped baseline
    2741   i=-1;
     3012  i = -1;
    27423013  if (OldLines[0]->IsConnectedTo(OldLines[2]))
    2743     i=2;
     3014    i = 2;
    27443015  if (OldLines[0]->IsConnectedTo(OldLines[3]))
    2745     i=3;
    2746   if (i!=-1) {
     3016    i = 3;
     3017  if (i != -1) {
    27473018    BLS[0] = OldLines[0];
    27483019    BLS[1] = OldLines[i];
     
    27513022    BTS->GetNormalVector(BaseLineNormal);
    27523023    AddTesselationTriangle(OldTriangleNrs[0]);
    2753     Log() << Verbose(0) << "INFO: Created new triangle " << *BTS << "." << endl;
    2754 
    2755     BLS[0] = (i==2 ? OldLines[3] : OldLines[2]);
     3024    DoLog(0) && (Log() << Verbose(0) << "INFO: Created new triangle " << *BTS << "." << endl);
     3025
     3026    BLS[0] = (i == 2 ? OldLines[3] : OldLines[2]);
    27563027    BLS[1] = OldLines[1];
    27573028    BLS[2] = NewLine;
     
    27593030    BTS->GetNormalVector(BaseLineNormal);
    27603031    AddTesselationTriangle(OldTriangleNrs[1]);
    2761     Log() << Verbose(0) << "INFO: Created new triangle " << *BTS << "." << endl;
     3032    DoLog(0) && (Log() << Verbose(0) << "INFO: Created new triangle " << *BTS << "." << endl);
    27623033  } else {
    2763     eLog() << Verbose(0) << "The four old lines do not connect, something's utterly wrong here!" << endl;
     3034    DoeLog(0) && (eLog() << Verbose(0) << "The four old lines do not connect, something's utterly wrong here!" << endl);
    27643035    return NULL;
    27653036  }
    27663037
    27673038  return NewLine;
    2768 };
    2769 
     3039}
     3040;
    27703041
    27713042/** Finds the second point of starting triangle.
     
    27793050void Tesselation::FindSecondPointForTesselation(TesselPoint* a, Vector Oben, TesselPoint*& OptCandidate, double Storage[3], double RADIUS, const LinkedCell *LC)
    27803051{
    2781         Info FunctionInfo(__func__);
     3052  Info FunctionInfo(__func__);
    27823053  Vector AngleCheck;
    27833054  class TesselPoint* Candidate = NULL;
     
    27883059  int Nupper[NDIM];
    27893060
    2790   if (LC->SetIndexToNode(a)) {  // get cell for the starting point
    2791     for(int i=0;i<NDIM;i++) // store indices of this cell
     3061  if (LC->SetIndexToNode(a)) { // get cell for the starting point
     3062    for (int i = 0; i < NDIM; i++) // store indices of this cell
    27923063      N[i] = LC->n[i];
    27933064  } else {
    2794     eLog() << Verbose(1) << "Point " << *a << " is not found in cell " << LC->index << "." << endl;
     3065    DoeLog(1) && (eLog() << Verbose(1) << "Point " << *a << " is not found in cell " << LC->index << "." << endl);
    27953066    return;
    27963067  }
    27973068  // then go through the current and all neighbouring cells and check the contained points for possible candidates
    2798   for (int i=0;i<NDIM;i++) {
    2799     Nlower[i] = ((N[i]-1) >= 0) ? N[i]-1 : 0;
    2800     Nupper[i] = ((N[i]+1) < LC->N[i]) ? N[i]+1 : LC->N[i]-1;
    2801   }
    2802   Log() << Verbose(0) << "LC Intervals from [" << N[0] << "<->" << LC->N[0] << ", " << N[1] << "<->" << LC->N[1] << ", " << N[2] << "<->" << LC->N[2] << "] :"
    2803     << " [" << Nlower[0] << "," << Nupper[0] << "], " << " [" << Nlower[1] << "," << Nupper[1] << "], " << " [" << Nlower[2] << "," << Nupper[2] << "], " << endl;
     3069  for (int i = 0; i < NDIM; i++) {
     3070    Nlower[i] = ((N[i] - 1) >= 0) ? N[i] - 1 : 0;
     3071    Nupper[i] = ((N[i] + 1) < LC->N[i]) ? N[i] + 1 : LC->N[i] - 1;
     3072  }
     3073  DoLog(0) && (Log() << Verbose(0) << "LC Intervals from [" << N[0] << "<->" << LC->N[0] << ", " << N[1] << "<->" << LC->N[1] << ", " << N[2] << "<->" << LC->N[2] << "] :" << " [" << Nlower[0] << "," << Nupper[0] << "], " << " [" << Nlower[1] << "," << Nupper[1] << "], " << " [" << Nlower[2] << "," << Nupper[2] << "], " << endl);
    28043074
    28053075  for (LC->n[0] = Nlower[0]; LC->n[0] <= Nupper[0]; LC->n[0]++)
    28063076    for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
    28073077      for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
    2808         const LinkedNodes *List = LC->GetCurrentCell();
     3078        const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
    28093079        //Log() << Verbose(1) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;
    28103080        if (List != NULL) {
    2811           for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
     3081          for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    28123082            Candidate = (*Runner);
    28133083            // check if we only have one unique point yet ...
     
    28353105              norm = aCandidate.Norm();
    28363106              // second point shall have smallest angle with respect to Oben vector
    2837               if (norm < RADIUS*2.) {
     3107              if (norm < RADIUS * 2.) {
    28383108                angle = AngleCheck.Angle(&Oben);
    28393109                if (angle < Storage[0]) {
    28403110                  //Log() << Verbose(1) << "Old values of Storage: %lf %lf \n", Storage[0], Storage[1]);
    2841                   Log() << Verbose(1) << "Current candidate is " << *Candidate << ": Is a better candidate with distance " << norm << " and angle " << angle << " to oben " << Oben << ".\n";
     3111                  DoLog(1) && (Log() << Verbose(1) << "Current candidate is " << *Candidate << ": Is a better candidate with distance " << norm << " and angle " << angle << " to oben " << Oben << ".\n");
    28423112                  OptCandidate = Candidate;
    28433113                  Storage[0] = angle;
     
    28543124          }
    28553125        } else {
    2856           Log() << Verbose(0) << "Linked cell list is empty." << endl;
     3126          DoLog(0) && (Log() << Verbose(0) << "Linked cell list is empty." << endl);
    28573127        }
    28583128      }
    2859 };
    2860 
     3129}
     3130;
    28613131
    28623132/** This recursive function finds a third point, to form a triangle with two given ones.
     
    28863156 * @param OldSphereCenter center of sphere for base triangle, relative to center of BaseLine, giving null angle for the parameter circle
    28873157 * @param CandidateLine CandidateForTesselation with the current base line and list of candidates and ShortestAngle
    2888  * @param ThirdNode third point to avoid in search
     3158 * @param ThirdPoint third point to avoid in search
    28893159 * @param RADIUS radius of sphere
    28903160 * @param *LC LinkedCell structure with neighbouring points
    28913161 */
    2892 void Tesselation::FindThirdPointForTesselation(Vector &NormalVector, Vector &SearchDirection, Vector &OldSphereCenter, CandidateForTesselation &CandidateLine, const class TesselPoint  * const ThirdNode, const double RADIUS, const LinkedCell *LC) const
    2893 {
    2894         Info FunctionInfo(__func__);
    2895   Vector CircleCenter;  // center of the circle, i.e. of the band of sphere's centers
     3162void Tesselation::FindThirdPointForTesselation(const Vector &NormalVector, const Vector &SearchDirection, const Vector &OldSphereCenter, CandidateForTesselation &CandidateLine, const class BoundaryPointSet * const ThirdPoint, const double RADIUS, const LinkedCell *LC) const
     3163{
     3164  Info FunctionInfo(__func__);
     3165  Vector CircleCenter; // center of the circle, i.e. of the band of sphere's centers
    28963166  Vector CirclePlaneNormal; // normal vector defining the plane this circle lives in
    28973167  Vector SphereCenter;
    2898   Vector NewSphereCenter;   // center of the sphere defined by the two points of BaseLine and the one of Candidate, first possibility
    2899   Vector OtherNewSphereCenter;   // center of the sphere defined by the two points of BaseLine and the one of Candidate, second possibility
    2900   Vector NewNormalVector;   // normal vector of the Candidate's triangle
     3168  Vector NewSphereCenter; // center of the sphere defined by the two points of BaseLine and the one of Candidate, first possibility
     3169  Vector OtherNewSphereCenter; // center of the sphere defined by the two points of BaseLine and the one of Candidate, second possibility
     3170  Vector NewNormalVector; // normal vector of the Candidate's triangle
    29013171  Vector helper, OptCandidateCenter, OtherOptCandidateCenter;
    29023172  Vector RelativeOldSphereCenter;
     
    29093179  TesselPoint *Candidate = NULL;
    29103180
    2911   Log() << Verbose(1) << "INFO: NormalVector of BaseTriangle is " << NormalVector << "." << endl;
     3181  DoLog(1) && (Log() << Verbose(1) << "INFO: NormalVector of BaseTriangle is " << NormalVector << "." << endl);
     3182
     3183  // copy old center
     3184  CandidateLine.OldCenter.CopyVector(&OldSphereCenter);
     3185  CandidateLine.ThirdPoint = ThirdPoint;
     3186  CandidateLine.pointlist.clear();
    29123187
    29133188  // construct center of circle
     
    29233198  RelativeOldSphereCenter.SubtractVector(&CircleCenter);
    29243199
    2925   // calculate squared radius TesselPoint *ThirdNode,f circle
    2926   radius = CirclePlaneNormal.NormSquared()/4.;
    2927   if (radius < RADIUS*RADIUS) {
    2928     CircleRadius = RADIUS*RADIUS - radius;
     3200  // calculate squared radius TesselPoint *ThirdPoint,f circle
     3201  radius = CirclePlaneNormal.NormSquared() / 4.;
     3202  if (radius < RADIUS * RADIUS) {
     3203    CircleRadius = RADIUS * RADIUS - radius;
    29293204    CirclePlaneNormal.Normalize();
    2930     Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl;
     3205    DoLog(1) && (Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl);
    29313206
    29323207    // test whether old center is on the band's plane
    29333208    if (fabs(RelativeOldSphereCenter.ScalarProduct(&CirclePlaneNormal)) > HULLEPSILON) {
    2934       eLog() << Verbose(1) << "Something's very wrong here: RelativeOldSphereCenter is not on the band's plane as desired by " << fabs(RelativeOldSphereCenter.ScalarProduct(&CirclePlaneNormal)) << "!" << endl;
     3209      DoeLog(1) && (eLog() << Verbose(1) << "Something's very wrong here: RelativeOldSphereCenter is not on the band's plane as desired by " << fabs(RelativeOldSphereCenter.ScalarProduct(&CirclePlaneNormal)) << "!" << endl);
    29353210      RelativeOldSphereCenter.ProjectOntoPlane(&CirclePlaneNormal);
    29363211    }
    29373212    radius = RelativeOldSphereCenter.NormSquared();
    29383213    if (fabs(radius - CircleRadius) < HULLEPSILON) {
    2939       Log() << Verbose(1) << "INFO: RelativeOldSphereCenter is at " << RelativeOldSphereCenter << "." << endl;
     3214      DoLog(1) && (Log() << Verbose(1) << "INFO: RelativeOldSphereCenter is at " << RelativeOldSphereCenter << "." << endl);
    29403215
    29413216      // check SearchDirection
    2942       Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl;
    2943       if (fabs(RelativeOldSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) {  // rotated the wrong way!
    2944         eLog() << Verbose(1) << "SearchDirection and RelativeOldSphereCenter are not orthogonal!" << endl;
     3217      DoLog(1) && (Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl);
     3218      if (fabs(RelativeOldSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) { // rotated the wrong way!
     3219        DoeLog(1) && (eLog() << Verbose(1) << "SearchDirection and RelativeOldSphereCenter are not orthogonal!" << endl);
    29453220      }
    29463221
    29473222      // get cell for the starting point
    29483223      if (LC->SetIndexToVector(&CircleCenter)) {
    2949         for(int i=0;i<NDIM;i++) // store indices of this cell
    2950         N[i] = LC->n[i];
     3224        for (int i = 0; i < NDIM; i++) // store indices of this cell
     3225          N[i] = LC->n[i];
    29513226        //Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl;
    29523227      } else {
    2953         eLog() << Verbose(1) << "Vector " << CircleCenter << " is outside of LinkedCell's bounding box." << endl;
     3228        DoeLog(1) && (eLog() << Verbose(1) << "Vector " << CircleCenter << " is outside of LinkedCell's bounding box." << endl);
    29543229        return;
    29553230      }
    29563231      // then go through the current and all neighbouring cells and check the contained points for possible candidates
    29573232      //Log() << Verbose(1) << "LC Intervals:";
    2958       for (int i=0;i<NDIM;i++) {
    2959         Nlower[i] = ((N[i]-1) >= 0) ? N[i]-1 : 0;
    2960         Nupper[i] = ((N[i]+1) < LC->N[i]) ? N[i]+1 : LC->N[i]-1;
     3233      for (int i = 0; i < NDIM; i++) {
     3234        Nlower[i] = ((N[i] - 1) >= 0) ? N[i] - 1 : 0;
     3235        Nupper[i] = ((N[i] + 1) < LC->N[i]) ? N[i] + 1 : LC->N[i] - 1;
    29613236        //Log() << Verbose(0) << " [" << Nlower[i] << "," << Nupper[i] << "] ";
    29623237      }
     
    29653240        for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
    29663241          for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
    2967             const LinkedNodes *List = LC->GetCurrentCell();
     3242            const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
    29683243            //Log() << Verbose(1) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;
    29693244            if (List != NULL) {
    2970               for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
     3245              for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    29713246                Candidate = (*Runner);
    29723247
    29733248                // check for three unique points
    2974                 Log() << Verbose(2) << "INFO: Current Candidate is " << *Candidate << " for BaseLine " << *CandidateLine.BaseLine << " with OldSphereCenter " << OldSphereCenter << "." << endl;
    2975                 if ((Candidate != CandidateLine.BaseLine->endpoints[0]->node) && (Candidate != CandidateLine.BaseLine->endpoints[1]->node) ){
     3249                DoLog(2) && (Log() << Verbose(2) << "INFO: Current Candidate is " << *Candidate << " for BaseLine " << *CandidateLine.BaseLine << " with OldSphereCenter " << OldSphereCenter << "." << endl);
     3250                if ((Candidate != CandidateLine.BaseLine->endpoints[0]->node) && (Candidate != CandidateLine.BaseLine->endpoints[1]->node)) {
    29763251
    29773252                  // find center on the plane
    29783253                  GetCenterofCircumcircle(&NewPlaneCenter, *CandidateLine.BaseLine->endpoints[0]->node->node, *CandidateLine.BaseLine->endpoints[1]->node->node, *Candidate->node);
    2979                   Log() << Verbose(1) << "INFO: NewPlaneCenter is " << NewPlaneCenter << "." << endl;
    2980 
    2981                   if (NewNormalVector.MakeNormalVector(CandidateLine.BaseLine->endpoints[0]->node->node, CandidateLine.BaseLine->endpoints[1]->node->node, Candidate->node)
    2982                   && (fabs(NewNormalVector.NormSquared()) > HULLEPSILON)
    2983                   ) {
    2984                     Log() << Verbose(1) << "INFO: NewNormalVector is " << NewNormalVector << "." << endl;
     3254                  DoLog(1) && (Log() << Verbose(1) << "INFO: NewPlaneCenter is " << NewPlaneCenter << "." << endl);
     3255
     3256                  if (NewNormalVector.MakeNormalVector(CandidateLine.BaseLine->endpoints[0]->node->node, CandidateLine.BaseLine->endpoints[1]->node->node, Candidate->node) && (fabs(NewNormalVector.NormSquared()) > HULLEPSILON)) {
     3257                    DoLog(1) && (Log() << Verbose(1) << "INFO: NewNormalVector is " << NewNormalVector << "." << endl);
    29853258                    radius = CandidateLine.BaseLine->endpoints[0]->node->node->DistanceSquared(&NewPlaneCenter);
    2986                     Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl;
    2987                     Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl;
    2988                     Log() << Verbose(1) << "INFO: Radius of CircumCenterCircle is " << radius << "." << endl;
    2989                     if (radius < RADIUS*RADIUS) {
     3259                    DoLog(1) && (Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl);
     3260                    DoLog(1) && (Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl);
     3261                    DoLog(1) && (Log() << Verbose(1) << "INFO: Radius of CircumCenterCircle is " << radius << "." << endl);
     3262                    if (radius < RADIUS * RADIUS) {
    29903263                      otherradius = CandidateLine.BaseLine->endpoints[1]->node->node->DistanceSquared(&NewPlaneCenter);
    2991                       if (fabs(radius - otherradius) > HULLEPSILON) {
    2992                         eLog() << Verbose(1) << "Distance to center of circumcircle is not the same from each corner of the triangle: " << fabs(radius-otherradius) << endl;
    2993                       }
    2994                       // construct both new centers
    2995                       NewSphereCenter.CopyVector(&NewPlaneCenter);
    2996                       OtherNewSphereCenter.CopyVector(&NewPlaneCenter);
    2997                       helper.CopyVector(&NewNormalVector);
    2998                       helper.Scale(sqrt(RADIUS*RADIUS - radius));
    2999                       Log() << Verbose(2) << "INFO: Distance of NewPlaneCenter " << NewPlaneCenter << " to either NewSphereCenter is " << helper.Norm() << " of vector " << helper << " with sphere radius " << RADIUS << "." << endl;
    3000                       NewSphereCenter.AddVector(&helper);
    3001                       Log() << Verbose(2) << "INFO: NewSphereCenter is at " << NewSphereCenter << "." << endl;
    3002                       // OtherNewSphereCenter is created by the same vector just in the other direction
    3003                       helper.Scale(-1.);
    3004                       OtherNewSphereCenter.AddVector(&helper);
    3005                       Log() << Verbose(2) << "INFO: OtherNewSphereCenter is at " << OtherNewSphereCenter << "." << endl;
    3006 
    3007                       alpha = GetPathLengthonCircumCircle(CircleCenter, CirclePlaneNormal, CircleRadius, NewSphereCenter, OldSphereCenter, NormalVector, SearchDirection);
    3008                       Otheralpha = GetPathLengthonCircumCircle(CircleCenter, CirclePlaneNormal, CircleRadius, OtherNewSphereCenter, OldSphereCenter, NormalVector, SearchDirection);
    3009                       alpha = min(alpha, Otheralpha);
    3010 
    3011                       // if there is a better candidate, drop the current list and add the new candidate
    3012                       // otherwise ignore the new candidate and keep the list
    3013                       if (CandidateLine.ShortestAngle > (alpha - HULLEPSILON)) {
    3014                         if (fabs(alpha - Otheralpha) > MYEPSILON) {
    3015                           CandidateLine.OptCenter.CopyVector(&NewSphereCenter);
    3016                           CandidateLine.OtherOptCenter.CopyVector(&OtherNewSphereCenter);
     3264                      if (fabs(radius - otherradius) < HULLEPSILON) {
     3265                        // construct both new centers
     3266                        NewSphereCenter.CopyVector(&NewPlaneCenter);
     3267                        OtherNewSphereCenter.CopyVector(&NewPlaneCenter);
     3268                        helper.CopyVector(&NewNormalVector);
     3269                        helper.Scale(sqrt(RADIUS * RADIUS - radius));
     3270                        DoLog(2) && (Log() << Verbose(2) << "INFO: Distance of NewPlaneCenter " << NewPlaneCenter << " to either NewSphereCenter is " << helper.Norm() << " of vector " << helper << " with sphere radius " << RADIUS << "." << endl);
     3271                        NewSphereCenter.AddVector(&helper);
     3272                        DoLog(2) && (Log() << Verbose(2) << "INFO: NewSphereCenter is at " << NewSphereCenter << "." << endl);
     3273                        // OtherNewSphereCenter is created by the same vector just in the other direction
     3274                        helper.Scale(-1.);
     3275                        OtherNewSphereCenter.AddVector(&helper);
     3276                        DoLog(2) && (Log() << Verbose(2) << "INFO: OtherNewSphereCenter is at " << OtherNewSphereCenter << "." << endl);
     3277
     3278                        alpha = GetPathLengthonCircumCircle(CircleCenter, CirclePlaneNormal, CircleRadius, NewSphereCenter, OldSphereCenter, NormalVector, SearchDirection);
     3279                        Otheralpha = GetPathLengthonCircumCircle(CircleCenter, CirclePlaneNormal, CircleRadius, OtherNewSphereCenter, OldSphereCenter, NormalVector, SearchDirection);
     3280                        if ((ThirdPoint != NULL) && (Candidate == ThirdPoint->node)) { // in that case only the other circlecenter is valid
     3281                          if (OldSphereCenter.DistanceSquared(&NewSphereCenter) < OldSphereCenter.DistanceSquared(&OtherNewSphereCenter))
     3282                            alpha = Otheralpha;
     3283                        } else
     3284                          alpha = min(alpha, Otheralpha);
     3285
     3286                        // if there is a better candidate, drop the current list and add the new candidate
     3287                        // otherwise ignore the new candidate and keep the list
     3288                        if (CandidateLine.ShortestAngle > (alpha - HULLEPSILON)) {
     3289                          if (fabs(alpha - Otheralpha) > MYEPSILON) {
     3290                            CandidateLine.OptCenter.CopyVector(&NewSphereCenter);
     3291                            CandidateLine.OtherOptCenter.CopyVector(&OtherNewSphereCenter);
     3292                          } else {
     3293                            CandidateLine.OptCenter.CopyVector(&OtherNewSphereCenter);
     3294                            CandidateLine.OtherOptCenter.CopyVector(&NewSphereCenter);
     3295                          }
     3296                          // if there is an equal candidate, add it to the list without clearing the list
     3297                          if ((CandidateLine.ShortestAngle - HULLEPSILON) < alpha) {
     3298                            CandidateLine.pointlist.push_back(Candidate);
     3299                            DoLog(0) && (Log() << Verbose(0) << "ACCEPT: We have found an equally good candidate: " << *(Candidate) << " with " << alpha << " and circumsphere's center at " << CandidateLine.OptCenter << "." << endl);
     3300                          } else {
     3301                            // remove all candidates from the list and then the list itself
     3302                            CandidateLine.pointlist.clear();
     3303                            CandidateLine.pointlist.push_back(Candidate);
     3304                            DoLog(0) && (Log() << Verbose(0) << "ACCEPT: We have found a better candidate: " << *(Candidate) << " with " << alpha << " and circumsphere's center at " << CandidateLine.OptCenter << "." << endl);
     3305                          }
     3306                          CandidateLine.ShortestAngle = alpha;
     3307                          DoLog(0) && (Log() << Verbose(0) << "INFO: There are " << CandidateLine.pointlist.size() << " candidates in the list now." << endl);
    30173308                        } else {
    3018                           CandidateLine.OptCenter.CopyVector(&OtherNewSphereCenter);
    3019                           CandidateLine.OtherOptCenter.CopyVector(&NewSphereCenter);
     3309                          if ((Candidate != NULL) && (CandidateLine.pointlist.begin() != CandidateLine.pointlist.end())) {
     3310                            DoLog(1) && (Log() << Verbose(1) << "REJECT: Old candidate " << *(*CandidateLine.pointlist.begin()) << " with " << CandidateLine.ShortestAngle << " is better than new one " << *Candidate << " with " << alpha << " ." << endl);
     3311                          } else {
     3312                            DoLog(1) && (Log() << Verbose(1) << "REJECT: Candidate " << *Candidate << " with " << alpha << " was rejected." << endl);
     3313                          }
    30203314                        }
    3021                         // if there is an equal candidate, add it to the list without clearing the list
    3022                         if ((CandidateLine.ShortestAngle - HULLEPSILON) < alpha) {
    3023                           CandidateLine.pointlist.push_back(Candidate);
    3024                           Log() << Verbose(0) << "ACCEPT: We have found an equally good candidate: " << *(Candidate) << " with "
    3025                             << alpha << " and circumsphere's center at " << CandidateLine.OptCenter << "." << endl;
    3026                         } else {
    3027                           // remove all candidates from the list and then the list itself
    3028                           CandidateLine.pointlist.clear();
    3029                           CandidateLine.pointlist.push_back(Candidate);
    3030                           Log() << Verbose(0) << "ACCEPT: We have found a better candidate: " << *(Candidate) << " with "
    3031                             << alpha << " and circumsphere's center at " << CandidateLine.OptCenter << "." << endl;
    3032                         }
    3033                         CandidateLine.ShortestAngle = alpha;
    3034                         Log() << Verbose(0) << "INFO: There are " << CandidateLine.pointlist.size() << " candidates in the list now." << endl;
    30353315                      } else {
    3036                         if ((Candidate != NULL) && (CandidateLine.pointlist.begin() != CandidateLine.pointlist.end())) {
    3037                           Log() << Verbose(1) << "REJECT: Old candidate " << *(Candidate) << " with " << CandidateLine.ShortestAngle << " is better than new one " << *Candidate << " with " << alpha << " ." << endl;
    3038                         } else {
    3039                           Log() << Verbose(1) << "REJECT: Candidate " << *Candidate << " with " << alpha << " was rejected." << endl;
    3040                         }
     3316                        DoLog(1) && (Log() << Verbose(1) << "REJECT: Distance to center of circumcircle is not the same from each corner of the triangle: " << fabs(radius - otherradius) << endl);
    30413317                      }
    30423318                    } else {
    3043                       Log() << Verbose(1) << "REJECT: NewSphereCenter " << NewSphereCenter << " for " << *Candidate << " is too far away: " << radius << "." << endl;
     3319                      DoLog(1) && (Log() << Verbose(1) << "REJECT: NewSphereCenter " << NewSphereCenter << " for " << *Candidate << " is too far away: " << radius << "." << endl);
    30443320                    }
    30453321                  } else {
    3046                     Log() << Verbose(1) << "REJECT: Three points from " << *CandidateLine.BaseLine << " and Candidate " << *Candidate << " are linear-dependent." << endl;
     3322                    DoLog(1) && (Log() << Verbose(1) << "REJECT: Three points from " << *CandidateLine.BaseLine << " and Candidate " << *Candidate << " are linear-dependent." << endl);
    30473323                  }
    30483324                } else {
    3049                   if (ThirdNode != NULL) {
    3050                     Log() << Verbose(1) << "REJECT: Base triangle " << *CandidateLine.BaseLine << " and " << *ThirdNode << " contains Candidate " << *Candidate << "." << endl;
     3325                  if (ThirdPoint != NULL) {
     3326                    DoLog(1) && (Log() << Verbose(1) << "REJECT: Base triangle " << *CandidateLine.BaseLine << " and " << *ThirdPoint << " contains Candidate " << *Candidate << "." << endl);
    30513327                  } else {
    3052                     Log() << Verbose(1) << "REJECT: Base triangle " << *CandidateLine.BaseLine << " contains Candidate " << *Candidate << "." << endl;
     3328                    DoLog(1) && (Log() << Verbose(1) << "REJECT: Base triangle " << *CandidateLine.BaseLine << " contains Candidate " << *Candidate << "." << endl);
    30533329                  }
    30543330                }
     
    30573333          }
    30583334    } else {
    3059       eLog() << Verbose(1) << "The projected center of the old sphere has radius " << radius << " instead of " << CircleRadius << "." << endl;
     3335      DoeLog(1) && (eLog() << Verbose(1) << "The projected center of the old sphere has radius " << radius << " instead of " << CircleRadius << "." << endl);
    30603336    }
    30613337  } else {
    3062     if (ThirdNode != NULL)
    3063       Log() << Verbose(1) << "Circumcircle for base line " << *CandidateLine.BaseLine << " and third node " << *ThirdNode << " is too big!" << endl;
     3338    if (ThirdPoint != NULL)
     3339      DoLog(1) && (Log() << Verbose(1) << "Circumcircle for base line " << *CandidateLine.BaseLine << " and third node " << *ThirdPoint << " is too big!" << endl);
    30643340    else
    3065       Log() << Verbose(1) << "Circumcircle for base line " << *CandidateLine.BaseLine << " is too big!" << endl;
    3066   }
    3067 
    3068   Log() << Verbose(1) << "INFO: Sorting candidate list ..." << endl;
     3341      DoLog(1) && (Log() << Verbose(1) << "Circumcircle for base line " << *CandidateLine.BaseLine << " is too big!" << endl);
     3342  }
     3343
     3344  DoLog(1) && (Log() << Verbose(1) << "INFO: Sorting candidate list ..." << endl);
    30693345  if (CandidateLine.pointlist.size() > 1) {
    30703346    CandidateLine.pointlist.unique();
    30713347    CandidateLine.pointlist.sort(); //SortCandidates);
    30723348  }
    3073 };
     3349
     3350  if ((!CandidateLine.pointlist.empty()) && (!CandidateLine.CheckValidity(RADIUS, LC))) {
     3351    DoeLog(0) && (eLog() << Verbose(0) << "There were other points contained in the rolling sphere as well!" << endl);
     3352    performCriticalExit();
     3353  }
     3354}
     3355;
    30743356
    30753357/** Finds the endpoint two lines are sharing.
     
    30803362class BoundaryPointSet *Tesselation::GetCommonEndpoint(const BoundaryLineSet * line1, const BoundaryLineSet * line2) const
    30813363{
    3082         Info FunctionInfo(__func__);
     3364  Info FunctionInfo(__func__);
    30833365  const BoundaryLineSet * lines[2] = { line1, line2 };
    30843366  class BoundaryPointSet *node = NULL;
     
    30873369  for (int i = 0; i < 2; i++)
    30883370    // for both lines
    3089     for (int j = 0; j < 2; j++)
    3090       { // for both endpoints
    3091         OrderTest = OrderMap.insert(pair<int, class BoundaryPointSet *> (
    3092             lines[i]->endpoints[j]->Nr, lines[i]->endpoints[j]));
    3093         if (!OrderTest.second)
    3094           { // if insertion fails, we have common endpoint
    3095             node = OrderTest.first->second;
    3096             Log() << Verbose(1) << "Common endpoint of lines " << *line1
    3097                 << " and " << *line2 << " is: " << *node << "." << endl;
    3098             j = 2;
    3099             i = 2;
    3100             break;
    3101           }
     3371    for (int j = 0; j < 2; j++) { // for both endpoints
     3372      OrderTest = OrderMap.insert(pair<int, class BoundaryPointSet *> (lines[i]->endpoints[j]->Nr, lines[i]->endpoints[j]));
     3373      if (!OrderTest.second) { // if insertion fails, we have common endpoint
     3374        node = OrderTest.first->second;
     3375        DoLog(1) && (Log() << Verbose(1) << "Common endpoint of lines " << *line1 << " and " << *line2 << " is: " << *node << "." << endl);
     3376        j = 2;
     3377        i = 2;
     3378        break;
    31023379      }
     3380    }
    31033381  return node;
    3104 };
     3382}
     3383;
    31053384
    31063385/** Finds the boundary points that are closest to a given Vector \a *x.
     
    31163395
    31173396  if (LinesOnBoundary.empty()) {
    3118     eLog() << Verbose(1) << "There is no tesselation structure to compare the point with, please create one first." << endl;
     3397    DoeLog(1) && (eLog() << Verbose(1) << "There is no tesselation structure to compare the point with, please create one first." << endl);
    31193398    return NULL;
    31203399  }
     
    31223401  // gather all points close to the desired one
    31233402  LC->SetIndexToVector(x); // ignore status as we calculate bounds below sensibly
    3124   for(int i=0;i<NDIM;i++) // store indices of this cell
     3403  for (int i = 0; i < NDIM; i++) // store indices of this cell
    31253404    N[i] = LC->n[i];
    3126   Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl;
    3127 
     3405  DoLog(1) && (Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl);
    31283406  DistanceToPointMap * points = new DistanceToPointMap;
    31293407  LC->GetNeighbourBounds(Nlower, Nupper);
     
    31323410    for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
    31333411      for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
    3134         const LinkedNodes *List = LC->GetCurrentCell();
     3412        const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
    31353413        //Log() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl;
    31363414        if (List != NULL) {
    3137           for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
     3415          for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    31383416            FindPoint = PointsOnBoundary.find((*Runner)->nr);
    31393417            if (FindPoint != PointsOnBoundary.end()) {
    3140               points->insert(DistanceToPointPair (FindPoint->second->node->node->DistanceSquared(x), FindPoint->second) );
    3141               Log() << Verbose(1) << "INFO: Putting " << *FindPoint->second << " into the list." << endl;
     3418              points->insert(DistanceToPointPair(FindPoint->second->node->node->DistanceSquared(x), FindPoint->second));
     3419              DoLog(1) && (Log() << Verbose(1) << "INFO: Putting " << *FindPoint->second << " into the list." << endl);
    31423420            }
    31433421          }
    31443422        } else {
    3145           eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << " is invalid!" << endl;
     3423          DoeLog(1) && (eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << " is invalid!" << endl);
    31463424        }
    31473425      }
     
    31493427  // check whether we found some points
    31503428  if (points->empty()) {
    3151     eLog() << Verbose(1) << "There is no nearest point: too far away from the surface." << endl;
    3152     delete(points);
     3429    DoeLog(1) && (eLog() << Verbose(1) << "There is no nearest point: too far away from the surface." << endl);
     3430    delete (points);
    31533431    return NULL;
    31543432  }
    31553433  return points;
    3156 };
     3434}
     3435;
    31573436
    31583437/** Finds the boundary line that is closest to a given Vector \a *x.
     
    31643443{
    31653444  Info FunctionInfo(__func__);
    3166 
    31673445  // get closest points
    3168   DistanceToPointMap * points = FindClosestBoundaryPointsToVector(x,LC);
     3446  DistanceToPointMap * points = FindClosestBoundaryPointsToVector(x, LC);
    31693447  if (points == NULL) {
    3170     eLog() << Verbose(1) << "There is no nearest point: too far away from the surface." << endl;
     3448    DoeLog(1) && (eLog() << Verbose(1) << "There is no nearest point: too far away from the surface." << endl);
    31713449    return NULL;
    31723450  }
    31733451
    31743452  // for each point, check its lines, remember closest
    3175   Log() << Verbose(1) << "Finding closest BoundaryLine to " << *x << " ... " << endl;
     3453  DoLog(1) && (Log() << Verbose(1) << "Finding closest BoundaryLine to " << *x << " ... " << endl);
    31763454  BoundaryLineSet *ClosestLine = NULL;
    31773455  double MinDistance = -1.;
     
    32013479        helper.SubtractVector(&Center);
    32023480        const double lengthB = helper.ScalarProduct(&BaseLine);
    3203         if (lengthB*lengthA < 0) { // if have different sign
     3481        if (lengthB * lengthA < 0) { // if have different sign
    32043482          ClosestLine = LineRunner->second;
    32053483          MinDistance = distance;
    3206           Log() << Verbose(1) << "ACCEPT: New closest line is " << *ClosestLine << " with projected distance " << MinDistance << "." << endl;
     3484          DoLog(1) && (Log() << Verbose(1) << "ACCEPT: New closest line is " << *ClosestLine << " with projected distance " << MinDistance << "." << endl);
    32073485        } else {
    3208           Log() << Verbose(1) << "REJECT: Intersection is outside of the line section: " << lengthA << " and " << lengthB << "." << endl;
     3486          DoLog(1) && (Log() << Verbose(1) << "REJECT: Intersection is outside of the line section: " << lengthA << " and " << lengthB << "." << endl);
    32093487        }
    32103488      } else {
    3211         Log() << Verbose(1) << "REJECT: Point is too further away than present line: " << distance << " >> " << MinDistance << "." << endl;
     3489        DoLog(1) && (Log() << Verbose(1) << "REJECT: Point is too further away than present line: " << distance << " >> " << MinDistance << "." << endl);
    32123490      }
    32133491    }
    32143492  }
    3215   delete(points);
     3493  delete (points);
    32163494  // check whether closest line is "too close" :), then it's inside
    32173495  if (ClosestLine == NULL) {
    3218     Log() << Verbose(0) << "Is the only point, no one else is closeby." << endl;
     3496    DoLog(0) && (Log() << Verbose(0) << "Is the only point, no one else is closeby." << endl);
    32193497    return NULL;
    32203498  }
    32213499  return ClosestLine;
    3222 };
    3223 
     3500}
     3501;
    32243502
    32253503/** Finds the triangle that is closest to a given Vector \a *x.
     
    32303508TriangleList * Tesselation::FindClosestTrianglesToVector(const Vector *x, const LinkedCell* LC) const
    32313509{
    3232         Info FunctionInfo(__func__);
    3233 
    3234         // get closest points
    3235         DistanceToPointMap * points = FindClosestBoundaryPointsToVector(x,LC);
     3510  Info FunctionInfo(__func__);
     3511  // get closest points
     3512  DistanceToPointMap * points = FindClosestBoundaryPointsToVector(x, LC);
    32363513  if (points == NULL) {
    3237     eLog() << Verbose(1) << "There is no nearest point: too far away from the surface." << endl;
     3514    DoeLog(1) && (eLog() << Verbose(1) << "There is no nearest point: too far away from the surface." << endl);
    32383515    return NULL;
    32393516  }
    32403517
    32413518  // for each point, check its lines, remember closest
    3242   Log() << Verbose(1) << "Finding closest BoundaryTriangle to " << *x << " ... " << endl;
     3519  DoLog(1) && (Log() << Verbose(1) << "Finding closest BoundaryTriangle to " << *x << " ... " << endl);
    32433520  LineSet ClosestLines;
    32443521  double MinDistance = 1e+16;
     
    32623539      const double lengthEndB = BaseLineIntersection.NormSquared();
    32633540
    3264       if ((lengthEndA > lengthBase) || (lengthEndB > lengthBase) || ((lengthEndA < MYEPSILON) || (lengthEndB < MYEPSILON))) {  // intersection would be outside, take closer endpoint
     3541      if ((lengthEndA > lengthBase) || (lengthEndB > lengthBase) || ((lengthEndA < MYEPSILON) || (lengthEndB < MYEPSILON))) { // intersection would be outside, take closer endpoint
    32653542        const double lengthEnd = Min(lengthEndA, lengthEndB);
    32663543        if (lengthEnd - MinDistance < -MYEPSILON) { // new best line
     
    32683545          ClosestLines.insert(LineRunner->second);
    32693546          MinDistance = lengthEnd;
    3270           Log() << Verbose(1) << "ACCEPT: Line " << *LineRunner->second << " to endpoint " << *LineRunner->second->endpoints[0]->node << " is closer with " << lengthEnd << "." << endl;
    3271         } else if  (fabs(lengthEnd - MinDistance) < MYEPSILON) { // additional best candidate
     3547          DoLog(1) && (Log() << Verbose(1) << "ACCEPT: Line " << *LineRunner->second << " to endpoint " << *LineRunner->second->endpoints[0]->node << " is closer with " << lengthEnd << "." << endl);
     3548        } else if (fabs(lengthEnd - MinDistance) < MYEPSILON) { // additional best candidate
    32723549          ClosestLines.insert(LineRunner->second);
    3273           Log() << Verbose(1) << "ACCEPT: Line " << *LineRunner->second << " to endpoint " << *LineRunner->second->endpoints[1]->node << " is equally good with " << lengthEnd << "." << endl;
     3550          DoLog(1) && (Log() << Verbose(1) << "ACCEPT: Line " << *LineRunner->second << " to endpoint " << *LineRunner->second->endpoints[1]->node << " is equally good with " << lengthEnd << "." << endl);
    32743551        } else { // line is worse
    3275           Log() << Verbose(1) << "REJECT: Line " << *LineRunner->second << " to either endpoints is further away than present closest line candidate: " << lengthEndA << ", " << lengthEndB << ", and distance is longer than baseline:" << lengthBase << "." << endl;
     3552          DoLog(1) && (Log() << Verbose(1) << "REJECT: Line " << *LineRunner->second << " to either endpoints is further away than present closest line candidate: " << lengthEndA << ", " << lengthEndB << ", and distance is longer than baseline:" << lengthBase << "." << endl);
    32763553        }
    32773554      } else { // intersection is closer, calculate
     
    32843561        const double distance = BaseLineIntersection.NormSquared();
    32853562        if (Center.NormSquared() > BaseLine.NormSquared()) {
    3286           eLog() << Verbose(0) << "Algorithmic error: In second case we have intersection outside of baseline!" << endl;
     3563          DoeLog(0) && (eLog() << Verbose(0) << "Algorithmic error: In second case we have intersection outside of baseline!" << endl);
    32873564        }
    32883565        if ((ClosestLines.empty()) || (distance < MinDistance)) {
    32893566          ClosestLines.insert(LineRunner->second);
    32903567          MinDistance = distance;
    3291           Log() << Verbose(1) << "ACCEPT: Intersection in between endpoints, new closest line " << *LineRunner->second << " is " << *ClosestLines.begin() << " with projected distance " << MinDistance << "." << endl;
     3568          DoLog(1) && (Log() << Verbose(1) << "ACCEPT: Intersection in between endpoints, new closest line " << *LineRunner->second << " is " << *ClosestLines.begin() << " with projected distance " << MinDistance << "." << endl);
    32923569        } else {
    3293           Log() << Verbose(2) << "REJECT: Point is further away from line " << *LineRunner->second << " than present closest line: " << distance << " >> " << MinDistance << "." << endl;
     3570          DoLog(2) && (Log() << Verbose(2) << "REJECT: Point is further away from line " << *LineRunner->second << " than present closest line: " << distance << " >> " << MinDistance << "." << endl);
    32943571        }
    32953572      }
    32963573    }
    32973574  }
    3298   delete(points);
     3575  delete (points);
    32993576
    33003577  // check whether closest line is "too close" :), then it's inside
    33013578  if (ClosestLines.empty()) {
    3302     Log() << Verbose(0) << "Is the only point, no one else is closeby." << endl;
     3579    DoLog(0) && (Log() << Verbose(0) << "Is the only point, no one else is closeby." << endl);
    33033580    return NULL;
    33043581  }
     
    33063583  for (LineSet::iterator LineRunner = ClosestLines.begin(); LineRunner != ClosestLines.end(); LineRunner++)
    33073584    for (TriangleMap::iterator Runner = (*LineRunner)->triangles.begin(); Runner != (*LineRunner)->triangles.end(); Runner++) {
    3308     candidates->push_back(Runner->second);
    3309   }
     3585      candidates->push_back(Runner->second);
     3586    }
    33103587  return candidates;
    3311 };
     3588}
     3589;
    33123590
    33133591/** Finds closest triangle to a point.
     
    33153593 * \param *out output stream for debugging
    33163594 * \param *x Vector to look from
     3595 * \param &distance contains found distance on return
    33173596 * \return list of BoundaryTriangleSet of nearest triangles or NULL.
    33183597 */
    33193598class BoundaryTriangleSet * Tesselation::FindClosestTriangleToVector(const Vector *x, const LinkedCell* LC) const
    33203599{
    3321         Info FunctionInfo(__func__);
     3600  Info FunctionInfo(__func__);
    33223601  class BoundaryTriangleSet *result = NULL;
    33233602  TriangleList *triangles = FindClosestTrianglesToVector(x, LC);
     
    33303609
    33313610  // go through all and pick the one with the best alignment to x
    3332   double MinAlignment = 2.*M_PI;
     3611  double MinAlignment = 2. * M_PI;
    33333612  for (TriangleList::iterator Runner = triangles->begin(); Runner != triangles->end(); Runner++) {
    33343613    (*Runner)->GetCenter(&Center);
     
    33393618      result = *Runner;
    33403619      MinAlignment = Alignment;
    3341       Log() << Verbose(1) << "ACCEPT: Triangle " << *result << " is better aligned with " << MinAlignment << "." << endl;
     3620      DoLog(1) && (Log() << Verbose(1) << "ACCEPT: Triangle " << *result << " is better aligned with " << MinAlignment << "." << endl);
    33423621    } else {
    3343       Log() << Verbose(1) << "REJECT: Triangle " << *result << " is worse aligned with " << MinAlignment << "." << endl;
    3344     }
    3345   }
    3346   delete(triangles);
     3622      DoLog(1) && (Log() << Verbose(1) << "REJECT: Triangle " << *result << " is worse aligned with " << MinAlignment << "." << endl);
     3623    }
     3624  }
     3625  delete (triangles);
    33473626
    33483627  return result;
    3349 };
     3628}
     3629;
    33503630
    33513631/** Checks whether the provided Vector is within the Tesselation structure.
     
    33583638bool Tesselation::IsInnerPoint(const Vector &Point, const LinkedCell* const LC) const
    33593639{
    3360   return (GetDistanceSquaredToSurface(Point, LC) < MYEPSILON);
    3361 }
     3640  Info FunctionInfo(__func__);
     3641  TriangleIntersectionList Intersections(&Point, this, LC);
     3642
     3643  return Intersections.IsInside();
     3644}
     3645;
    33623646
    33633647/** Returns the distance to the surface given by the tesselation.
     
    33893673
    33903674  if (triangle == NULL) {// is boundary point or only point in point cloud?
    3391     Log() << Verbose(1) << "No triangle given!" << endl;
     3675    DoLog(1) && (Log() << Verbose(1) << "No triangle given!" << endl);
    33923676    return -1.;
    33933677  } else {
    3394     Log() << Verbose(1) << "INFO: Closest triangle found is " << *triangle << " with normal vector " << triangle->NormalVector << "." << endl;
     3678    DoLog(1) && (Log() << Verbose(1) << "INFO: Closest triangle found is " << *triangle << " with normal vector " << triangle->NormalVector << "." << endl);
    33953679  }
    33963680
    33973681  triangle->GetCenter(&Center);
    3398   Log() << Verbose(2) << "INFO: Central point of the triangle is " << Center << "." << endl;
     3682  DoLog(2) && (Log() << Verbose(2) << "INFO: Central point of the triangle is " << Center << "." << endl);
    33993683  DistanceToCenter.CopyVector(&Center);
    34003684  DistanceToCenter.SubtractVector(&Point);
    3401   Log() << Verbose(2) << "INFO: Vector from point to test to center is " << DistanceToCenter << "." << endl;
     3685  DoLog(2) && (Log() << Verbose(2) << "INFO: Vector from point to test to center is " << DistanceToCenter << "." << endl);
    34023686
    34033687  // check whether we are on boundary
     
    34083692    Center.SubtractVector(&triangle->NormalVector); // points towards MolCenter
    34093693    DistanceToCenter.AddVector(&triangle->NormalVector); // points outside
    3410     Log() << Verbose(1) << "INFO: Calling Intersection with " << Center << " and " << DistanceToCenter << "." << endl;
     3694    DoLog(1) && (Log() << Verbose(1) << "INFO: Calling Intersection with " << Center << " and " << DistanceToCenter << "." << endl);
    34113695    if (triangle->GetIntersectionInsideTriangle(&Center, &DistanceToCenter, &Intersection)) {
    3412       Log() << Verbose(1) << Point << " is inner point: sufficiently close to boundary, " << Intersection << "." << endl;
     3696      DoLog(1) && (Log() << Verbose(1) << Point << " is inner point: sufficiently close to boundary, " << Intersection << "." << endl);
    34133697      return 0.;
    34143698    } else {
    3415       Log() << Verbose(1) << Point << " is NOT an inner point: on triangle plane but outside of triangle bounds." << endl;
     3699      DoLog(1) && (Log() << Verbose(1) << Point << " is NOT an inner point: on triangle plane but outside of triangle bounds." << endl);
    34163700      return false;
    34173701    }
     
    34193703    // calculate smallest distance
    34203704    distance = triangle->GetClosestPointInsideTriangle(&Point, &Intersection);
    3421     Log() << Verbose(1) << "Closest point on triangle is " << Intersection << "." << endl;
     3705    DoLog(1) && (Log() << Verbose(1) << "Closest point on triangle is " << Intersection << "." << endl);
    34223706
    34233707    // then check direction to boundary
    34243708    if (DistanceToCenter.ScalarProduct(&triangle->NormalVector) > MYEPSILON) {
    3425       Log() << Verbose(1) << Point << " is an inner point, " << distance << " below surface." << endl;
     3709      DoLog(1) && (Log() << Verbose(1) << Point << " is an inner point, " << distance << " below surface." << endl);
    34263710      return -distance;
    34273711    } else {
    3428       Log() << Verbose(1) << Point << " is NOT an inner point, " << distance << " above surface." << endl;
     3712      DoLog(1) && (Log() << Verbose(1) << Point << " is NOT an inner point, " << distance << " above surface." << endl);
    34293713      return +distance;
    34303714    }
    34313715  }
    3432 };
    3433 
    3434 /** Calculates distance to a tesselated surface.
     3716}
     3717;
     3718
     3719/** Calculates minimum distance from \a&Point to a tesselated surface.
    34353720 * Combines \sa FindClosestTrianglesToVector() and \sa GetDistanceSquaredToTriangle().
    34363721 * \param &Point point to calculate distance from
     
    34383723 * \return distance squared to closest point on surface
    34393724 */
    3440 double Tesselation::GetDistanceSquaredToSurface(const Vector &Point, const LinkedCell* const LC) const
    3441 {
    3442   BoundaryTriangleSet *triangle = FindClosestTriangleToVector(&Point, LC);
    3443   const double distance = GetDistanceSquaredToTriangle(Point, triangle);
    3444   return Min(distance, LC->RADIUS);
    3445 };
     3725double Tesselation::GetDistanceToSurface(const Vector &Point, const LinkedCell* const LC) const
     3726{
     3727  Info FunctionInfo(__func__);
     3728  TriangleIntersectionList Intersections(&Point, this, LC);
     3729
     3730  return Intersections.GetSmallestDistance();
     3731}
     3732;
     3733
     3734/** Calculates minimum distance from \a&Point to a tesselated surface.
     3735 * Combines \sa FindClosestTrianglesToVector() and \sa GetDistanceSquaredToTriangle().
     3736 * \param &Point point to calculate distance from
     3737 * \param *LC needed for finding closest points fast
     3738 * \return distance squared to closest point on surface
     3739 */
     3740BoundaryTriangleSet * Tesselation::GetClosestTriangleOnSurface(const Vector &Point, const LinkedCell* const LC) const
     3741{
     3742  Info FunctionInfo(__func__);
     3743  TriangleIntersectionList Intersections(&Point, this, LC);
     3744
     3745  return Intersections.GetClosestTriangle();
     3746}
     3747;
    34463748
    34473749/** Gets all points connected to the provided point by triangulation lines.
     
    34533755TesselPointSet * Tesselation::GetAllConnectedPoints(const TesselPoint* const Point) const
    34543756{
    3455         Info FunctionInfo(__func__);
    3456         TesselPointSet *connectedPoints = new TesselPointSet;
     3757  Info FunctionInfo(__func__);
     3758  TesselPointSet *connectedPoints = new TesselPointSet;
    34573759  class BoundaryPointSet *ReferencePoint = NULL;
    34583760  TesselPoint* current;
    34593761  bool takePoint = false;
    3460 
    34613762  // find the respective boundary point
    34623763  PointMap::const_iterator PointRunner = PointsOnBoundary.find(Point->nr);
     
    34643765    ReferencePoint = PointRunner->second;
    34653766  } else {
    3466     eLog() << Verbose(2) << "GetAllConnectedPoints() could not find the BoundaryPoint belonging to " << *Point << "." << endl;
     3767    DoeLog(2) && (eLog() << Verbose(2) << "GetAllConnectedPoints() could not find the BoundaryPoint belonging to " << *Point << "." << endl);
    34673768    ReferencePoint = NULL;
    34683769  }
     
    34703771  // little trick so that we look just through lines connect to the BoundaryPoint
    34713772  // OR fall-back to look through all lines if there is no such BoundaryPoint
    3472   const LineMap *Lines;;
     3773  const LineMap *Lines;
     3774  ;
    34733775  if (ReferencePoint != NULL)
    34743776    Lines = &(ReferencePoint->lines);
     
    34773779  LineMap::const_iterator findLines = Lines->begin();
    34783780  while (findLines != Lines->end()) {
    3479    takePoint = false;
    3480 
    3481    if (findLines->second->endpoints[0]->Nr == Point->nr) {
    3482      takePoint = true;
    3483      current = findLines->second->endpoints[1]->node;
    3484    } else if (findLines->second->endpoints[1]->Nr == Point->nr) {
    3485      takePoint = true;
    3486      current = findLines->second->endpoints[0]->node;
    3487    }
    3488 
    3489    if (takePoint) {
    3490      Log() << Verbose(1) << "INFO: Endpoint " << *current << " of line " << *(findLines->second) << " is enlisted." << endl;
    3491      connectedPoints->insert(current);
    3492    }
    3493 
    3494    findLines++;
     3781    takePoint = false;
     3782
     3783    if (findLines->second->endpoints[0]->Nr == Point->nr) {
     3784      takePoint = true;
     3785      current = findLines->second->endpoints[1]->node;
     3786    } else if (findLines->second->endpoints[1]->Nr == Point->nr) {
     3787      takePoint = true;
     3788      current = findLines->second->endpoints[0]->node;
     3789    }
     3790
     3791    if (takePoint) {
     3792      DoLog(1) && (Log() << Verbose(1) << "INFO: Endpoint " << *current << " of line " << *(findLines->second) << " is enlisted." << endl);
     3793      connectedPoints->insert(current);
     3794    }
     3795
     3796    findLines++;
    34953797  }
    34963798
    34973799  if (connectedPoints->empty()) { // if have not found any points
    3498     eLog() << Verbose(1) << "We have not found any connected points to " << *Point<< "." << endl;
     3800    DoeLog(1) && (eLog() << Verbose(1) << "We have not found any connected points to " << *Point << "." << endl);
    34993801    return NULL;
    35003802  }
    35013803
    35023804  return connectedPoints;
    3503 };
    3504 
     3805}
     3806;
    35053807
    35063808/** Gets all points connected to the provided point by triangulation lines, ordered such that we have the circle round the point.
     
    35183820TesselPointList * Tesselation::GetCircleOfConnectedTriangles(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector * const Reference) const
    35193821{
    3520         Info FunctionInfo(__func__);
     3822  Info FunctionInfo(__func__);
    35213823  map<double, TesselPoint*> anglesOfPoints;
    35223824  TesselPointList *connectedCircle = new TesselPointList;
     
    35253827  Vector OrthogonalVector;
    35263828  Vector helper;
    3527   const TesselPoint * const TrianglePoints[3] = {Point, NULL, NULL};
     3829  const TesselPoint * const TrianglePoints[3] = { Point, NULL, NULL };
    35283830  TriangleList *triangles = NULL;
    35293831
    35303832  if (SetOfNeighbours == NULL) {
    3531     eLog() << Verbose(2) << "Could not find any connected points!" << endl;
    3532     delete(connectedCircle);
     3833    DoeLog(2) && (eLog() << Verbose(2) << "Could not find any connected points!" << endl);
     3834    delete (connectedCircle);
    35333835    return NULL;
    35343836  }
     
    35403842      PlaneNormal.AddVector(&(*Runner)->NormalVector);
    35413843  } else {
    3542     eLog() << Verbose(0) << "Could not find any triangles for point " << *Point << "." << endl;
     3844    DoeLog(0) && (eLog() << Verbose(0) << "Could not find any triangles for point " << *Point << "." << endl);
    35433845    performCriticalExit();
    35443846  }
    3545   PlaneNormal.Scale(1.0/triangles->size());
    3546   Log() << Verbose(1) << "INFO: Calculated PlaneNormal of all circle points is " << PlaneNormal << "." << endl;
     3847  PlaneNormal.Scale(1.0 / triangles->size());
     3848  DoLog(1) && (Log() << Verbose(1) << "INFO: Calculated PlaneNormal of all circle points is " << PlaneNormal << "." << endl);
    35473849  PlaneNormal.Normalize();
    35483850
     
    35533855    AngleZero.ProjectOntoPlane(&PlaneNormal);
    35543856  }
    3555   if ((Reference == NULL) || (AngleZero.NormSquared() < MYEPSILON )) {
    3556     Log() << Verbose(1) << "Using alternatively " << *(*SetOfNeighbours->begin())->node << " as angle 0 referencer." << endl;
     3857  if ((Reference == NULL) || (AngleZero.NormSquared() < MYEPSILON)) {
     3858    DoLog(1) && (Log() << Verbose(1) << "Using alternatively " << *(*SetOfNeighbours->begin())->node << " as angle 0 referencer." << endl);
    35573859    AngleZero.CopyVector((*SetOfNeighbours->begin())->node);
    35583860    AngleZero.SubtractVector(Point->node);
    35593861    AngleZero.ProjectOntoPlane(&PlaneNormal);
    35603862    if (AngleZero.NormSquared() < MYEPSILON) {
    3561       eLog() << Verbose(0) << "CRITIAL: AngleZero is 0 even with alternative reference. The algorithm has to be changed here!" << endl;
     3863      DoeLog(0) && (eLog() << Verbose(0) << "CRITIAL: AngleZero is 0 even with alternative reference. The algorithm has to be changed here!" << endl);
    35623864      performCriticalExit();
    35633865    }
    35643866  }
    3565   Log() << Verbose(1) << "INFO: Reference vector on this plane representing angle 0 is " << AngleZero << "." << endl;
     3867  DoLog(1) && (Log() << Verbose(1) << "INFO: Reference vector on this plane representing angle 0 is " << AngleZero << "." << endl);
    35663868  if (AngleZero.NormSquared() > MYEPSILON)
    35673869    OrthogonalVector.MakeNormalVector(&PlaneNormal, &AngleZero);
    35683870  else
    35693871    OrthogonalVector.MakeNormalVector(&PlaneNormal);
    3570   Log() << Verbose(1) << "INFO: OrthogonalVector on plane is " << OrthogonalVector << "." << endl;
     3872  DoLog(1) && (Log() << Verbose(1) << "INFO: OrthogonalVector on plane is " << OrthogonalVector << "." << endl);
    35713873
    35723874  // go through all connected points and calculate angle
     
    35763878    helper.ProjectOntoPlane(&PlaneNormal);
    35773879    double angle = GetAngle(helper, AngleZero, OrthogonalVector);
    3578     Log() << Verbose(0) << "INFO: Calculated angle is " << angle << " for point " << **listRunner << "." << endl;
    3579     anglesOfPoints.insert(pair<double, TesselPoint*>(angle, (*listRunner)));
    3580   }
    3581 
    3582   for(map<double, TesselPoint*>::iterator AngleRunner = anglesOfPoints.begin(); AngleRunner != anglesOfPoints.end(); AngleRunner++) {
     3880    DoLog(0) && (Log() << Verbose(0) << "INFO: Calculated angle is " << angle << " for point " << **listRunner << "." << endl);
     3881    anglesOfPoints.insert(pair<double, TesselPoint*> (angle, (*listRunner)));
     3882  }
     3883
     3884  for (map<double, TesselPoint*>::iterator AngleRunner = anglesOfPoints.begin(); AngleRunner != anglesOfPoints.end(); AngleRunner++) {
    35833885    connectedCircle->push_back(AngleRunner->second);
    35843886  }
     
    36103912
    36113913  if (SetOfNeighbours == NULL) {
    3612     eLog() << Verbose(2) << "Could not find any connected points!" << endl;
    3613     delete(connectedCircle);
     3914    DoeLog(2) && (eLog() << Verbose(2) << "Could not find any connected points!" << endl);
     3915    delete (connectedCircle);
    36143916    return NULL;
    36153917  }
     
    36223924  }
    36233925
    3624   Log() << Verbose(1) << "INFO: Point is " << *Point << " and Reference is " << *Reference << "." << endl;
     3926  DoLog(1) && (Log() << Verbose(1) << "INFO: Point is " << *Point << " and Reference is " << *Reference << "." << endl);
    36253927  // calculate central point
    3626 
    36273928  TesselPointSet::const_iterator TesselA = SetOfNeighbours->begin();
    36283929  TesselPointSet::const_iterator TesselB = SetOfNeighbours->begin();
     
    36343935  while (TesselC != SetOfNeighbours->end()) {
    36353936    helper.MakeNormalVector((*TesselA)->node, (*TesselB)->node, (*TesselC)->node);
    3636     Log() << Verbose(0) << "Making normal vector out of " << *(*TesselA) << ", " << *(*TesselB) << " and " << *(*TesselC) << ":" << helper << endl;
     3937    DoLog(0) && (Log() << Verbose(0) << "Making normal vector out of " << *(*TesselA) << ", " << *(*TesselB) << " and " << *(*TesselC) << ":" << helper << endl);
    36373938    counter++;
    36383939    TesselA++;
     
    36433944  //Log() << Verbose(0) << "Summed vectors " << center << "; number of points " << connectedPoints.size()
    36443945  //  << "; scale factor " << counter;
    3645   PlaneNormal.Scale(1.0/(double)counter);
    3646 //  Log() << Verbose(1) << "INFO: Calculated center of all circle points is " << center << "." << endl;
    3647 //
    3648 //  // projection plane of the circle is at the closes Point and normal is pointing away from center of all circle points
    3649 //  PlaneNormal.CopyVector(Point->node);
    3650 //  PlaneNormal.SubtractVector(&center);
    3651 //  PlaneNormal.Normalize();
    3652   Log() << Verbose(1) << "INFO: Calculated plane normal of circle is " << PlaneNormal << "." << endl;
     3946  PlaneNormal.Scale(1.0 / (double) counter);
     3947  //  Log() << Verbose(1) << "INFO: Calculated center of all circle points is " << center << "." << endl;
     3948  //
     3949  //  // projection plane of the circle is at the closes Point and normal is pointing away from center of all circle points
     3950  //  PlaneNormal.CopyVector(Point->node);
     3951  //  PlaneNormal.SubtractVector(&center);
     3952  //  PlaneNormal.Normalize();
     3953  DoLog(1) && (Log() << Verbose(1) << "INFO: Calculated plane normal of circle is " << PlaneNormal << "." << endl);
    36533954
    36543955  // construct one orthogonal vector
     
    36583959    AngleZero.ProjectOntoPlane(&PlaneNormal);
    36593960  }
    3660   if ((Reference == NULL) || (AngleZero.NormSquared() < MYEPSILON )) {
    3661     Log() << Verbose(1) << "Using alternatively " << *(*SetOfNeighbours->begin())->node << " as angle 0 referencer." << endl;
     3961  if ((Reference == NULL) || (AngleZero.NormSquared() < MYEPSILON)) {
     3962    DoLog(1) && (Log() << Verbose(1) << "Using alternatively " << *(*SetOfNeighbours->begin())->node << " as angle 0 referencer." << endl);
    36623963    AngleZero.CopyVector((*SetOfNeighbours->begin())->node);
    36633964    AngleZero.SubtractVector(Point->node);
    36643965    AngleZero.ProjectOntoPlane(&PlaneNormal);
    36653966    if (AngleZero.NormSquared() < MYEPSILON) {
    3666       eLog() << Verbose(0) << "CRITIAL: AngleZero is 0 even with alternative reference. The algorithm has to be changed here!" << endl;
     3967      DoeLog(0) && (eLog() << Verbose(0) << "CRITIAL: AngleZero is 0 even with alternative reference. The algorithm has to be changed here!" << endl);
    36673968      performCriticalExit();
    36683969    }
    36693970  }
    3670   Log() << Verbose(1) << "INFO: Reference vector on this plane representing angle 0 is " << AngleZero << "." << endl;
     3971  DoLog(1) && (Log() << Verbose(1) << "INFO: Reference vector on this plane representing angle 0 is " << AngleZero << "." << endl);
    36713972  if (AngleZero.NormSquared() > MYEPSILON)
    36723973    OrthogonalVector.MakeNormalVector(&PlaneNormal, &AngleZero);
    36733974  else
    36743975    OrthogonalVector.MakeNormalVector(&PlaneNormal);
    3675   Log() << Verbose(1) << "INFO: OrthogonalVector on plane is " << OrthogonalVector << "." << endl;
     3976  DoLog(1) && (Log() << Verbose(1) << "INFO: OrthogonalVector on plane is " << OrthogonalVector << "." << endl);
    36763977
    36773978  // go through all connected points and calculate angle
    3678   pair <map<double, TesselPoint*>::iterator, bool > InserterTest;
     3979  pair<map<double, TesselPoint*>::iterator, bool> InserterTest;
    36793980  for (TesselPointSet::iterator listRunner = SetOfNeighbours->begin(); listRunner != SetOfNeighbours->end(); listRunner++) {
    36803981    helper.CopyVector((*listRunner)->node);
     
    36833984    double angle = GetAngle(helper, AngleZero, OrthogonalVector);
    36843985    if (angle > M_PI) // the correction is of no use here (and not desired)
    3685       angle = 2.*M_PI - angle;
    3686     Log() << Verbose(0) << "INFO: Calculated angle between " << helper << " and " << AngleZero << " is " << angle << " for point " << **listRunner << "." << endl;
    3687     InserterTest = anglesOfPoints.insert(pair<double, TesselPoint*>(angle, (*listRunner)));
     3986      angle = 2. * M_PI - angle;
     3987    DoLog(0) && (Log() << Verbose(0) << "INFO: Calculated angle between " << helper << " and " << AngleZero << " is " << angle << " for point " << **listRunner << "." << endl);
     3988    InserterTest = anglesOfPoints.insert(pair<double, TesselPoint*> (angle, (*listRunner)));
    36883989    if (!InserterTest.second) {
    3689       eLog() << Verbose(0) << "GetCircleOfSetOfPoints() got two atoms with same angle: " << *((InserterTest.first)->second) << " and " << (*listRunner) << endl;
     3990      DoeLog(0) && (eLog() << Verbose(0) << "GetCircleOfSetOfPoints() got two atoms with same angle: " << *((InserterTest.first)->second) << " and " << (*listRunner) << endl);
    36903991      performCriticalExit();
    36913992    }
    36923993  }
    36933994
    3694   for(map<double, TesselPoint*>::iterator AngleRunner = anglesOfPoints.begin(); AngleRunner != anglesOfPoints.end(); AngleRunner++) {
     3995  for (map<double, TesselPoint*>::iterator AngleRunner = anglesOfPoints.begin(); AngleRunner != anglesOfPoints.end(); AngleRunner++) {
    36953996    connectedCircle->push_back(AngleRunner->second);
    36963997  }
     
    37074008ListOfTesselPointList * Tesselation::GetPathsOfConnectedPoints(const TesselPoint* const Point) const
    37084009{
    3709         Info FunctionInfo(__func__);
     4010  Info FunctionInfo(__func__);
    37104011  map<double, TesselPoint*> anglesOfPoints;
    3711   list< TesselPointList *> *ListOfPaths = new list< TesselPointList *>;
     4012  list<TesselPointList *> *ListOfPaths = new list<TesselPointList *> ;
    37124013  TesselPointList *connectedPath = NULL;
    37134014  Vector center;
     
    37214022  class BoundaryLineSet *CurrentLine = NULL;
    37224023  class BoundaryLineSet *StartLine = NULL;
    3723 
    37244024  // find the respective boundary point
    37254025  PointMap::const_iterator PointRunner = PointsOnBoundary.find(Point->nr);
     
    37274027    ReferencePoint = PointRunner->second;
    37284028  } else {
    3729     eLog() << Verbose(1) << "GetPathOfConnectedPoints() could not find the BoundaryPoint belonging to " << *Point << "." << endl;
     4029    DoeLog(1) && (eLog() << Verbose(1) << "GetPathOfConnectedPoints() could not find the BoundaryPoint belonging to " << *Point << "." << endl);
    37304030    return NULL;
    37314031  }
    37324032
    3733   map <class BoundaryLineSet *, bool> TouchedLine;
    3734   map <class BoundaryTriangleSet *, bool> TouchedTriangle;
    3735   map <class BoundaryLineSet *, bool>::iterator LineRunner;
    3736   map <class BoundaryTriangleSet *, bool>::iterator TriangleRunner;
     4033  map<class BoundaryLineSet *, bool> TouchedLine;
     4034  map<class BoundaryTriangleSet *, bool> TouchedTriangle;
     4035  map<class BoundaryLineSet *, bool>::iterator LineRunner;
     4036  map<class BoundaryTriangleSet *, bool>::iterator TriangleRunner;
    37374037  for (LineMap::iterator Runner = ReferencePoint->lines.begin(); Runner != ReferencePoint->lines.end(); Runner++) {
    3738     TouchedLine.insert( pair <class BoundaryLineSet *, bool>(Runner->second, false) );
     4038    TouchedLine.insert(pair<class BoundaryLineSet *, bool> (Runner->second, false));
    37394039    for (TriangleMap::iterator Sprinter = Runner->second->triangles.begin(); Sprinter != Runner->second->triangles.end(); Sprinter++)
    3740       TouchedTriangle.insert( pair <class BoundaryTriangleSet *, bool>(Sprinter->second, false) );
     4040      TouchedTriangle.insert(pair<class BoundaryTriangleSet *, bool> (Sprinter->second, false));
    37414041  }
    37424042  if (!ReferencePoint->lines.empty()) {
     
    37444044      LineRunner = TouchedLine.find(runner->second);
    37454045      if (LineRunner == TouchedLine.end()) {
    3746         eLog() << Verbose(1) << "I could not find " << *runner->second << " in the touched list." << endl;
     4046        DoeLog(1) && (eLog() << Verbose(1) << "I could not find " << *runner->second << " in the touched list." << endl);
    37474047      } else if (!LineRunner->second) {
    37484048        LineRunner->second = true;
     
    37524052        StartLine = CurrentLine;
    37534053        CurrentPoint = CurrentLine->GetOtherEndpoint(ReferencePoint);
    3754         Log() << Verbose(1)<< "INFO: Beginning path retrieval at " << *CurrentPoint << " of line " << *CurrentLine << "." << endl;
     4054        DoLog(1) && (Log() << Verbose(1) << "INFO: Beginning path retrieval at " << *CurrentPoint << " of line " << *CurrentLine << "." << endl);
    37554055        do {
    37564056          // push current one
    3757           Log() << Verbose(1) << "INFO: Putting " << *CurrentPoint << " at end of path." << endl;
     4057          DoLog(1) && (Log() << Verbose(1) << "INFO: Putting " << *CurrentPoint << " at end of path." << endl);
    37584058          connectedPath->push_back(CurrentPoint->node);
    37594059
    37604060          // find next triangle
    37614061          for (TriangleMap::iterator Runner = CurrentLine->triangles.begin(); Runner != CurrentLine->triangles.end(); Runner++) {
    3762             Log() << Verbose(1) << "INFO: Inspecting triangle " << *Runner->second << "." << endl;
     4062            DoLog(1) && (Log() << Verbose(1) << "INFO: Inspecting triangle " << *Runner->second << "." << endl);
    37634063            if ((Runner->second != triangle)) { // look for first triangle not equal to old one
    37644064              triangle = Runner->second;
     
    37674067                if (!TriangleRunner->second) {
    37684068                  TriangleRunner->second = true;
    3769                   Log() << Verbose(1) << "INFO: Connecting triangle is " << *triangle << "." << endl;
     4069                  DoLog(1) && (Log() << Verbose(1) << "INFO: Connecting triangle is " << *triangle << "." << endl);
    37704070                  break;
    37714071                } else {
    3772                   Log() << Verbose(1) << "INFO: Skipping " << *triangle << ", as we have already visited it." << endl;
     4072                  DoLog(1) && (Log() << Verbose(1) << "INFO: Skipping " << *triangle << ", as we have already visited it." << endl);
    37734073                  triangle = NULL;
    37744074                }
    37754075              } else {
    3776                 eLog() << Verbose(1) << "I could not find " << *triangle << " in the touched list." << endl;
     4076                DoeLog(1) && (eLog() << Verbose(1) << "I could not find " << *triangle << " in the touched list." << endl);
    37774077                triangle = NULL;
    37784078              }
     
    37824082            break;
    37834083          // find next line
    3784           for (int i=0;i<3;i++) {
     4084          for (int i = 0; i < 3; i++) {
    37854085            if ((triangle->lines[i] != CurrentLine) && (triangle->lines[i]->ContainsBoundaryPoint(ReferencePoint))) { // not the current line and still containing Point
    37864086              CurrentLine = triangle->lines[i];
    3787               Log() << Verbose(1) << "INFO: Connecting line is " << *CurrentLine << "." << endl;
     4087              DoLog(1) && (Log() << Verbose(1) << "INFO: Connecting line is " << *CurrentLine << "." << endl);
    37884088              break;
    37894089            }
     
    37914091          LineRunner = TouchedLine.find(CurrentLine);
    37924092          if (LineRunner == TouchedLine.end())
    3793             eLog() << Verbose(1) << "I could not find " << *CurrentLine << " in the touched list." << endl;
     4093            DoeLog(1) && (eLog() << Verbose(1) << "I could not find " << *CurrentLine << " in the touched list." << endl);
    37944094          else
    37954095            LineRunner->second = true;
     
    37994099        } while (CurrentLine != StartLine);
    38004100        // last point is missing, as it's on start line
    3801         Log() << Verbose(1) << "INFO: Putting " << *CurrentPoint << " at end of path." << endl;
     4101        DoLog(1) && (Log() << Verbose(1) << "INFO: Putting " << *CurrentPoint << " at end of path." << endl);
    38024102        if (StartLine->GetOtherEndpoint(ReferencePoint)->node != connectedPath->back())
    38034103          connectedPath->push_back(StartLine->GetOtherEndpoint(ReferencePoint)->node);
     
    38054105        ListOfPaths->push_back(connectedPath);
    38064106      } else {
    3807         Log() << Verbose(1) << "INFO: Skipping " << *runner->second << ", as we have already visited it." << endl;
     4107        DoLog(1) && (Log() << Verbose(1) << "INFO: Skipping " << *runner->second << ", as we have already visited it." << endl);
    38084108      }
    38094109    }
    38104110  } else {
    3811     eLog() << Verbose(1) << "There are no lines attached to " << *ReferencePoint << "." << endl;
     4111    DoeLog(1) && (eLog() << Verbose(1) << "There are no lines attached to " << *ReferencePoint << "." << endl);
    38124112  }
    38134113
     
    38234123ListOfTesselPointList * Tesselation::GetClosedPathsOfConnectedPoints(const TesselPoint* const Point) const
    38244124{
    3825         Info FunctionInfo(__func__);
     4125  Info FunctionInfo(__func__);
    38264126  list<TesselPointList *> *ListofPaths = GetPathsOfConnectedPoints(Point);
    3827   list<TesselPointList *> *ListofClosedPaths = new list<TesselPointList *>;
     4127  list<TesselPointList *> *ListofClosedPaths = new list<TesselPointList *> ;
    38284128  TesselPointList *connectedPath = NULL;
    38294129  TesselPointList *newPath = NULL;
    38304130  int count = 0;
    3831 
    3832 
    38334131  TesselPointList::iterator CircleRunner;
    38344132  TesselPointList::iterator CircleStart;
    38354133
    3836   for(list<TesselPointList *>::iterator ListRunner = ListofPaths->begin(); ListRunner != ListofPaths->end(); ListRunner++) {
     4134  for (list<TesselPointList *>::iterator ListRunner = ListofPaths->begin(); ListRunner != ListofPaths->end(); ListRunner++) {
    38374135    connectedPath = *ListRunner;
    38384136
    3839     Log() << Verbose(1) << "INFO: Current path is " << connectedPath << "." << endl;
     4137    DoLog(1) && (Log() << Verbose(1) << "INFO: Current path is " << connectedPath << "." << endl);
    38404138
    38414139    // go through list, look for reappearance of starting Point and count
    38424140    CircleStart = connectedPath->begin();
    3843 
    38444141    // go through list, look for reappearance of starting Point and create list
    38454142    TesselPointList::iterator Marker = CircleStart;
     
    38474144      if ((*CircleRunner == *CircleStart) && (CircleRunner != CircleStart)) { // is not the very first point
    38484145        // we have a closed circle from Marker to new Marker
    3849         Log() << Verbose(1) << count+1 << ". closed path consists of: ";
     4146        DoLog(1) && (Log() << Verbose(1) << count + 1 << ". closed path consists of: ");
    38504147        newPath = new TesselPointList;
    38514148        TesselPointList::iterator CircleSprinter = Marker;
    38524149        for (; CircleSprinter != CircleRunner; CircleSprinter++) {
    38534150          newPath->push_back(*CircleSprinter);
    3854           Log() << Verbose(0) << (**CircleSprinter) << " <-> ";
     4151          DoLog(0) && (Log() << Verbose(0) << (**CircleSprinter) << " <-> ");
    38554152        }
    3856         Log() << Verbose(0) << ".." << endl;
     4153        DoLog(0) && (Log() << Verbose(0) << ".." << endl);
    38574154        count++;
    38584155        Marker = CircleRunner;
     
    38634160    }
    38644161  }
    3865   Log() << Verbose(1) << "INFO: " << count << " closed additional path(s) have been created." << endl;
     4162  DoLog(1) && (Log() << Verbose(1) << "INFO: " << count << " closed additional path(s) have been created." << endl);
    38664163
    38674164  // delete list of paths
     
    38694166    connectedPath = *(ListofPaths->begin());
    38704167    ListofPaths->remove(connectedPath);
    3871     delete(connectedPath);
    3872   }
    3873   delete(ListofPaths);
     4168    delete (connectedPath);
     4169  }
     4170  delete (ListofPaths);
    38744171
    38754172  // exit
    38764173  return ListofClosedPaths;
    3877 };
    3878 
     4174}
     4175;
    38794176
    38804177/** Gets all belonging triangles for a given BoundaryPointSet.
     
    38854182TriangleSet *Tesselation::GetAllTriangles(const BoundaryPointSet * const Point) const
    38864183{
    3887         Info FunctionInfo(__func__);
    3888         TriangleSet *connectedTriangles = new TriangleSet;
     4184  Info FunctionInfo(__func__);
     4185  TriangleSet *connectedTriangles = new TriangleSet;
    38894186
    38904187  if (Point == NULL) {
    3891     eLog() << Verbose(1) << "Point given is NULL." << endl;
     4188    DoeLog(1) && (eLog() << Verbose(1) << "Point given is NULL." << endl);
    38924189  } else {
    38934190    // go through its lines and insert all triangles
    38944191    for (LineMap::const_iterator LineRunner = Point->lines.begin(); LineRunner != Point->lines.end(); LineRunner++)
    38954192      for (TriangleMap::iterator TriangleRunner = (LineRunner->second)->triangles.begin(); TriangleRunner != (LineRunner->second)->triangles.end(); TriangleRunner++) {
    3896       connectedTriangles->insert(TriangleRunner->second);
    3897     }
     4193        connectedTriangles->insert(TriangleRunner->second);
     4194      }
    38984195  }
    38994196
    39004197  return connectedTriangles;
    3901 };
    3902 
     4198}
     4199;
    39034200
    39044201/** Removes a boundary point from the envelope while keeping it closed.
     
    39134210 * \return volume added to the volume inside the tesselated surface by the removal
    39144211 */
    3915 double Tesselation::RemovePointFromTesselatedSurface(class BoundaryPointSet *point) {
     4212double Tesselation::RemovePointFromTesselatedSurface(class BoundaryPointSet *point)
     4213{
    39164214  class BoundaryLineSet *line = NULL;
    39174215  class BoundaryTriangleSet *triangle = NULL;
     
    39214219
    39224220  if (point == NULL) {
    3923     eLog() << Verbose(1) << "Cannot remove the point " << point << ", it's NULL!" << endl;
     4221    DoeLog(1) && (eLog() << Verbose(1) << "Cannot remove the point " << point << ", it's NULL!" << endl);
    39244222    return 0.;
    39254223  } else
    3926     Log() << Verbose(0) << "Removing point " << *point << " from tesselated boundary ..." << endl;
     4224    DoLog(0) && (Log() << Verbose(0) << "Removing point " << *point << " from tesselated boundary ..." << endl);
    39274225
    39284226  // copy old location for the volume
     
    39314229  // get list of connected points
    39324230  if (point->lines.empty()) {
    3933     eLog() << Verbose(1) << "Cannot remove the point " << *point << ", it's connected to no lines!" << endl;
     4231    DoeLog(1) && (eLog() << Verbose(1) << "Cannot remove the point " << *point << ", it's connected to no lines!" << endl);
    39344232    return 0.;
    39354233  }
     
    39404238  // gather all triangles
    39414239  for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++)
    3942     count+=LineRunner->second->triangles.size();
     4240    count += LineRunner->second->triangles.size();
    39434241  TriangleMap Candidates;
    39444242  for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) {
     
    39464244    for (TriangleMap::iterator TriangleRunner = line->triangles.begin(); TriangleRunner != line->triangles.end(); TriangleRunner++) {
    39474245      triangle = TriangleRunner->second;
    3948       Candidates.insert( TrianglePair (triangle->Nr, triangle) );
     4246      Candidates.insert(TrianglePair(triangle->Nr, triangle));
    39494247    }
    39504248  }
    39514249
    39524250  // remove all triangles
    3953   count=0;
     4251  count = 0;
    39544252  NormalVector.Zero();
    39554253  for (TriangleMap::iterator Runner = Candidates.begin(); Runner != Candidates.end(); Runner++) {
    3956     Log() << Verbose(1) << "INFO: Removing triangle " << *(Runner->second) << "." << endl;
     4254    DoLog(1) && (Log() << Verbose(1) << "INFO: Removing triangle " << *(Runner->second) << "." << endl);
    39574255    NormalVector.SubtractVector(&Runner->second->NormalVector); // has to point inward
    39584256    RemoveTesselationTriangle(Runner->second);
    39594257    count++;
    39604258  }
    3961   Log() << Verbose(1) << count << " triangles were removed." << endl;
     4259  DoLog(1) && (Log() << Verbose(1) << count << " triangles were removed." << endl);
    39624260
    39634261  list<TesselPointList *>::iterator ListAdvance = ListOfClosedPaths->begin();
     
    39684266  double smallestangle;
    39694267  Vector Point, Reference, OrthogonalVector;
    3970   if (count > 2) {  // less than three triangles, then nothing will be created
     4268  if (count > 2) { // less than three triangles, then nothing will be created
    39714269    class TesselPoint *TriangleCandidates[3];
    39724270    count = 0;
    3973     for ( ; ListRunner != ListOfClosedPaths->end(); ListRunner = ListAdvance) { // go through all closed paths
     4271    for (; ListRunner != ListOfClosedPaths->end(); ListRunner = ListAdvance) { // go through all closed paths
    39744272      if (ListAdvance != ListOfClosedPaths->end())
    39754273        ListAdvance++;
    39764274
    39774275      connectedPath = *ListRunner;
    3978 
    39794276      // re-create all triangles by going through connected points list
    39804277      LineList NewLines;
    3981       for (;!connectedPath->empty();) {
     4278      for (; !connectedPath->empty();) {
    39824279        // search middle node with widest angle to next neighbours
    39834280        EndNode = connectedPath->end();
    39844281        smallestangle = 0.;
    39854282        for (MiddleNode = connectedPath->begin(); MiddleNode != connectedPath->end(); MiddleNode++) {
    3986           Log() << Verbose(1) << "INFO: MiddleNode is " << **MiddleNode << "." << endl;
     4283          DoLog(1) && (Log() << Verbose(1) << "INFO: MiddleNode is " << **MiddleNode << "." << endl);
    39874284          // construct vectors to next and previous neighbour
    39884285          StartNode = MiddleNode;
     
    40054302          angle = GetAngle(Point, Reference, OrthogonalVector);
    40064303          //if (angle < M_PI)  // no wrong-sided triangles, please?
    4007             if(fabs(angle - M_PI) < fabs(smallestangle - M_PI)) { // get straightest angle (i.e. construct those triangles with smallest area first)
    4008               smallestangle = angle;
    4009               EndNode = MiddleNode;
    4010             }
     4304          if (fabs(angle - M_PI) < fabs(smallestangle - M_PI)) { // get straightest angle (i.e. construct those triangles with smallest area first)
     4305            smallestangle = angle;
     4306            EndNode = MiddleNode;
     4307          }
    40114308        }
    40124309        MiddleNode = EndNode;
    40134310        if (MiddleNode == connectedPath->end()) {
    4014           eLog() << Verbose(0) << "CRITICAL: Could not find a smallest angle!" << endl;
     4311          DoeLog(0) && (eLog() << Verbose(0) << "CRITICAL: Could not find a smallest angle!" << endl);
    40154312          performCriticalExit();
    40164313        }
     
    40224319        if (EndNode == connectedPath->end())
    40234320          EndNode = connectedPath->begin();
    4024         Log() << Verbose(2) << "INFO: StartNode is " << **StartNode << "." << endl;
    4025         Log() << Verbose(2) << "INFO: MiddleNode is " << **MiddleNode << "." << endl;
    4026         Log() << Verbose(2) << "INFO: EndNode is " << **EndNode << "." << endl;
    4027         Log() << Verbose(1) << "INFO: Attempting to create triangle " << (*StartNode)->Name << ", " << (*MiddleNode)->Name << " and " << (*EndNode)->Name << "." << endl;
     4321        DoLog(2) && (Log() << Verbose(2) << "INFO: StartNode is " << **StartNode << "." << endl);
     4322        DoLog(2) && (Log() << Verbose(2) << "INFO: MiddleNode is " << **MiddleNode << "." << endl);
     4323        DoLog(2) && (Log() << Verbose(2) << "INFO: EndNode is " << **EndNode << "." << endl);
     4324        DoLog(1) && (Log() << Verbose(1) << "INFO: Attempting to create triangle " << (*StartNode)->Name << ", " << (*MiddleNode)->Name << " and " << (*EndNode)->Name << "." << endl);
    40284325        TriangleCandidates[0] = *StartNode;
    40294326        TriangleCandidates[1] = *MiddleNode;
     
    40314328        triangle = GetPresentTriangle(TriangleCandidates);
    40324329        if (triangle != NULL) {
    4033           eLog() << Verbose(0) << "New triangle already present, skipping!" << endl;
     4330          DoeLog(0) && (eLog() << Verbose(0) << "New triangle already present, skipping!" << endl);
    40344331          StartNode++;
    40354332          MiddleNode++;
     
    40434340          continue;
    40444341        }
    4045         Log() << Verbose(3) << "Adding new triangle points."<< endl;
     4342        DoLog(3) && (Log() << Verbose(3) << "Adding new triangle points." << endl);
    40464343        AddTesselationPoint(*StartNode, 0);
    40474344        AddTesselationPoint(*MiddleNode, 1);
    40484345        AddTesselationPoint(*EndNode, 2);
    4049         Log() << Verbose(3) << "Adding new triangle lines."<< endl;
    4050         AddTesselationLine(TPS[0], TPS[1], 0);
    4051         AddTesselationLine(TPS[0], TPS[2], 1);
     4346        DoLog(3) && (Log() << Verbose(3) << "Adding new triangle lines." << endl);
     4347        AddTesselationLine(NULL, NULL, TPS[0], TPS[1], 0);
     4348        AddTesselationLine(NULL, NULL, TPS[0], TPS[2], 1);
    40524349        NewLines.push_back(BLS[1]);
    4053         AddTesselationLine(TPS[1], TPS[2], 2);
     4350        AddTesselationLine(NULL, NULL, TPS[1], TPS[2], 2);
    40544351        BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
    40554352        BTS->GetNormalVector(NormalVector);
     
    40624359        // prepare nodes for next triangle
    40634360        StartNode = EndNode;
    4064         Log() << Verbose(2) << "Removing " << **MiddleNode << " from closed path, remaining points: " << connectedPath->size() << "." << endl;
     4361        DoLog(2) && (Log() << Verbose(2) << "Removing " << **MiddleNode << " from closed path, remaining points: " << connectedPath->size() << "." << endl);
    40654362        connectedPath->remove(*MiddleNode); // remove the middle node (it is surrounded by triangles)
    40664363        if (connectedPath->size() == 2) { // we are done
     
    40694366          break;
    40704367        } else if (connectedPath->size() < 2) { // something's gone wrong!
    4071           eLog() << Verbose(0) << "CRITICAL: There are only two endpoints left!" << endl;
     4368          DoeLog(0) && (eLog() << Verbose(0) << "CRITICAL: There are only two endpoints left!" << endl);
    40724369          performCriticalExit();
    40734370        } else {
     
    40894386        do {
    40904387          maxgain = 0;
    4091           for(LineList::iterator Runner = NewLines.begin(); Runner != NewLines.end(); Runner++) {
     4388          for (LineList::iterator Runner = NewLines.begin(); Runner != NewLines.end(); Runner++) {
    40924389            tmp = PickFarthestofTwoBaselines(*Runner);
    40934390            if (maxgain < tmp) {
     
    40984395          if (maxgain != 0) {
    40994396            volume += maxgain;
    4100             Log() << Verbose(1) << "Flipping baseline with highest volume" << **Candidate << "." << endl;
     4397            DoLog(1) && (Log() << Verbose(1) << "Flipping baseline with highest volume" << **Candidate << "." << endl);
    41014398            OtherBase = FlipBaseline(*Candidate);
    41024399            NewLines.erase(Candidate);
     
    41074404
    41084405      ListOfClosedPaths->remove(connectedPath);
    4109       delete(connectedPath);
    4110     }
    4111     Log() << Verbose(0) << count << " triangles were created." << endl;
     4406      delete (connectedPath);
     4407    }
     4408    DoLog(0) && (Log() << Verbose(0) << count << " triangles were created." << endl);
    41124409  } else {
    41134410    while (!ListOfClosedPaths->empty()) {
     
    41154412      connectedPath = *ListRunner;
    41164413      ListOfClosedPaths->remove(connectedPath);
    4117       delete(connectedPath);
    4118     }
    4119     Log() << Verbose(0) << "No need to create any triangles." << endl;
    4120   }
    4121   delete(ListOfClosedPaths);
    4122 
    4123   Log() << Verbose(0) << "Removed volume is " << volume << "." << endl;
     4414      delete (connectedPath);
     4415    }
     4416    DoLog(0) && (Log() << Verbose(0) << "No need to create any triangles." << endl);
     4417  }
     4418  delete (ListOfClosedPaths);
     4419
     4420  DoLog(0) && (Log() << Verbose(0) << "Removed volume is " << volume << "." << endl);
    41244421
    41254422  return volume;
    4126 };
    4127 
    4128 
     4423}
     4424;
    41294425
    41304426/**
     
    41384434TriangleList *Tesselation::FindTriangles(const TesselPoint* const Points[3]) const
    41394435{
    4140         Info FunctionInfo(__func__);
    4141         TriangleList *result = new TriangleList;
     4436  Info FunctionInfo(__func__);
     4437  TriangleList *result = new TriangleList;
    41424438  LineMap::const_iterator FindLine;
    41434439  TriangleMap::const_iterator FindTriangle;
     
    41634459      for (int i = 0; i < 3; i++) {
    41644460        if (TrianglePoints[i] != NULL) {
    4165           for (int j = i+1; j < 3; j++) {
     4461          for (int j = i + 1; j < 3; j++) {
    41664462            if (TrianglePoints[j] != NULL) {
    41674463              for (FindLine = TrianglePoints[i]->lines.find(TrianglePoints[j]->node->nr); // is a multimap!
    4168                   (FindLine != TrianglePoints[i]->lines.end()) && (FindLine->first == TrianglePoints[j]->node->nr);
    4169                   FindLine++) {
    4170                 for (FindTriangle = FindLine->second->triangles.begin();
    4171                     FindTriangle != FindLine->second->triangles.end();
    4172                     FindTriangle++) {
     4464              (FindLine != TrianglePoints[i]->lines.end()) && (FindLine->first == TrianglePoints[j]->node->nr); FindLine++) {
     4465                for (FindTriangle = FindLine->second->triangles.begin(); FindTriangle != FindLine->second->triangles.end(); FindTriangle++) {
    41734466                  if (FindTriangle->second->IsPresentTupel(TrianglePoints)) {
    41744467                    result->push_back(FindTriangle->second);
     
    41854478    case 1: // copy all triangles of the respective line
    41864479    {
    4187       int i=0;
     4480      int i = 0;
    41884481      for (; i < 3; i++)
    41894482        if (TrianglePoints[i] == NULL)
    41904483          break;
    4191       for (FindLine = TrianglePoints[(i+1)%3]->lines.find(TrianglePoints[(i+2)%3]->node->nr); // is a multimap!
    4192           (FindLine != TrianglePoints[(i+1)%3]->lines.end()) && (FindLine->first == TrianglePoints[(i+2)%3]->node->nr);
    4193           FindLine++) {
    4194         for (FindTriangle = FindLine->second->triangles.begin();
    4195             FindTriangle != FindLine->second->triangles.end();
    4196             FindTriangle++) {
     4484      for (FindLine = TrianglePoints[(i + 1) % 3]->lines.find(TrianglePoints[(i + 2) % 3]->node->nr); // is a multimap!
     4485      (FindLine != TrianglePoints[(i + 1) % 3]->lines.end()) && (FindLine->first == TrianglePoints[(i + 2) % 3]->node->nr); FindLine++) {
     4486        for (FindTriangle = FindLine->second->triangles.begin(); FindTriangle != FindLine->second->triangles.end(); FindTriangle++) {
    41974487          if (FindTriangle->second->IsPresentTupel(TrianglePoints)) {
    41984488            result->push_back(FindTriangle->second);
     
    42044494    case 2: // copy all triangles of the respective point
    42054495    {
    4206       int i=0;
     4496      int i = 0;
    42074497      for (; i < 3; i++)
    42084498        if (TrianglePoints[i] != NULL)
     
    42224512    }
    42234513    default:
    4224       eLog() << Verbose(0) << "Number of wildcards is greater than 3, cannot happen!" << endl;
     4514      DoeLog(0) && (eLog() << Verbose(0) << "Number of wildcards is greater than 3, cannot happen!" << endl);
    42254515      performCriticalExit();
    42264516      break;
     
    42304520}
    42314521
    4232 struct BoundaryLineSetCompare {
    4233   bool operator() (const BoundaryLineSet * const a, const BoundaryLineSet * const b) {
     4522struct BoundaryLineSetCompare
     4523{
     4524  bool operator()(const BoundaryLineSet * const a, const BoundaryLineSet * const b)
     4525  {
    42344526    int lowerNra = -1;
    42354527    int lowerNrb = -1;
     
    42494541    else if (a->endpoints[lowerNra] > b->endpoints[lowerNrb])
    42504542      return false;
    4251     else {  // both lower-numbered endpoints are the same ...
    4252      if (a->endpoints[(lowerNra+1)%2] < b->endpoints[(lowerNrb+1)%2])
    4253        return true;
    4254      else if (a->endpoints[(lowerNra+1)%2] > b->endpoints[(lowerNrb+1)%2])
    4255        return false;
     4543    else { // both lower-numbered endpoints are the same ...
     4544      if (a->endpoints[(lowerNra + 1) % 2] < b->endpoints[(lowerNrb + 1) % 2])
     4545        return true;
     4546      else if (a->endpoints[(lowerNra + 1) % 2] > b->endpoints[(lowerNrb + 1) % 2])
     4547        return false;
    42564548    }
    42574549    return false;
    4258   };
     4550  }
     4551  ;
    42594552};
    42604553
     
    42694562IndexToIndex * Tesselation::FindAllDegeneratedLines()
    42704563{
    4271         Info FunctionInfo(__func__);
    4272         UniqueLines AllLines;
     4564  Info FunctionInfo(__func__);
     4565  UniqueLines AllLines;
    42734566  IndexToIndex * DegeneratedLines = new IndexToIndex;
    42744567
    42754568  // sanity check
    42764569  if (LinesOnBoundary.empty()) {
    4277     eLog() << Verbose(2) << "FindAllDegeneratedTriangles() was called without any tesselation structure.";
     4570    DoeLog(2) && (eLog() << Verbose(2) << "FindAllDegeneratedTriangles() was called without any tesselation structure.");
    42784571    return DegeneratedLines;
    42794572  }
    4280 
    42814573  LineMap::iterator LineRunner1;
    4282   pair< UniqueLines::iterator, bool> tester;
     4574  pair<UniqueLines::iterator, bool> tester;
    42834575  for (LineRunner1 = LinesOnBoundary.begin(); LineRunner1 != LinesOnBoundary.end(); ++LineRunner1) {
    4284     tester = AllLines.insert( LineRunner1->second );
     4576    tester = AllLines.insert(LineRunner1->second);
    42854577    if (!tester.second) { // found degenerated line
    4286       DegeneratedLines->insert ( pair<int, int> (LineRunner1->second->Nr, (*tester.first)->Nr) );
    4287       DegeneratedLines->insert ( pair<int, int> ((*tester.first)->Nr, LineRunner1->second->Nr) );
     4578      DegeneratedLines->insert(pair<int, int> (LineRunner1->second->Nr, (*tester.first)->Nr));
     4579      DegeneratedLines->insert(pair<int, int> ((*tester.first)->Nr, LineRunner1->second->Nr));
    42884580    }
    42894581  }
     
    42914583  AllLines.clear();
    42924584
    4293   Log() << Verbose(0) << "FindAllDegeneratedLines() found " << DegeneratedLines->size() << " lines." << endl;
     4585  DoLog(0) && (Log() << Verbose(0) << "FindAllDegeneratedLines() found " << DegeneratedLines->size() << " lines." << endl);
    42944586  IndexToIndex::iterator it;
    42954587  for (it = DegeneratedLines->begin(); it != DegeneratedLines->end(); it++) {
     
    42974589    const LineMap::const_iterator Line2 = LinesOnBoundary.find((*it).second);
    42984590    if (Line1 != LinesOnBoundary.end() && Line2 != LinesOnBoundary.end())
    4299       Log() << Verbose(0) << *Line1->second << " => " << *Line2->second << endl;
     4591      DoLog(0) && (Log() << Verbose(0) << *Line1->second << " => " << *Line2->second << endl);
    43004592    else
    4301       eLog() << Verbose(1) << "Either " << (*it).first << " or " << (*it).second << " are not in LinesOnBoundary!" << endl;
     4593      DoeLog(1) && (eLog() << Verbose(1) << "Either " << (*it).first << " or " << (*it).second << " are not in LinesOnBoundary!" << endl);
    43024594  }
    43034595
     
    43134605IndexToIndex * Tesselation::FindAllDegeneratedTriangles()
    43144606{
    4315         Info FunctionInfo(__func__);
     4607  Info FunctionInfo(__func__);
    43164608  IndexToIndex * DegeneratedLines = FindAllDegeneratedLines();
    43174609  IndexToIndex * DegeneratedTriangles = new IndexToIndex;
    4318 
    43194610  TriangleMap::iterator TriangleRunner1, TriangleRunner2;
    43204611  LineMap::iterator Liner;
     
    43314622    for (TriangleRunner1 = line1->triangles.begin(); TriangleRunner1 != line1->triangles.end(); ++TriangleRunner1) {
    43324623      for (TriangleRunner2 = line2->triangles.begin(); TriangleRunner2 != line2->triangles.end(); ++TriangleRunner2) {
    4333         if ((TriangleRunner1->second != TriangleRunner2->second)
    4334           && (TriangleRunner1->second->IsPresentTupel(TriangleRunner2->second))) {
    4335           DegeneratedTriangles->insert( pair<int, int> (TriangleRunner1->second->Nr, TriangleRunner2->second->Nr) );
    4336           DegeneratedTriangles->insert( pair<int, int> (TriangleRunner2->second->Nr, TriangleRunner1->second->Nr) );
     4624        if ((TriangleRunner1->second != TriangleRunner2->second) && (TriangleRunner1->second->IsPresentTupel(TriangleRunner2->second))) {
     4625          DegeneratedTriangles->insert(pair<int, int> (TriangleRunner1->second->Nr, TriangleRunner2->second->Nr));
     4626          DegeneratedTriangles->insert(pair<int, int> (TriangleRunner2->second->Nr, TriangleRunner1->second->Nr));
    43374627        }
    43384628      }
    43394629    }
    43404630  }
    4341   delete(DegeneratedLines);
    4342 
    4343   Log() << Verbose(0) << "FindAllDegeneratedTriangles() found " << DegeneratedTriangles->size() << " triangles:" << endl;
     4631  delete (DegeneratedLines);
     4632
     4633  DoLog(0) && (Log() << Verbose(0) << "FindAllDegeneratedTriangles() found " << DegeneratedTriangles->size() << " triangles:" << endl);
    43444634  IndexToIndex::iterator it;
    43454635  for (it = DegeneratedTriangles->begin(); it != DegeneratedTriangles->end(); it++)
    4346       Log() << Verbose(0) << (*it).first << " => " << (*it).second << endl;
     4636    DoLog(0) && (Log() << Verbose(0) << (*it).first << " => " << (*it).second << endl);
    43474637
    43484638  return DegeneratedTriangles;
     
    43554645void Tesselation::RemoveDegeneratedTriangles()
    43564646{
    4357         Info FunctionInfo(__func__);
     4647  Info FunctionInfo(__func__);
    43584648  IndexToIndex * DegeneratedTriangles = FindAllDegeneratedTriangles();
    43594649  TriangleMap::iterator finder;
    43604650  BoundaryTriangleSet *triangle = NULL, *partnerTriangle = NULL;
    4361   int count  = 0;
    4362 
    4363   for (IndexToIndex::iterator TriangleKeyRunner = DegeneratedTriangles->begin();
    4364     TriangleKeyRunner != DegeneratedTriangles->end(); ++TriangleKeyRunner
    4365   ) {
     4651  int count = 0;
     4652
     4653  for (IndexToIndex::iterator TriangleKeyRunner = DegeneratedTriangles->begin(); TriangleKeyRunner != DegeneratedTriangles->end(); ++TriangleKeyRunner) {
    43664654    finder = TrianglesOnBoundary.find(TriangleKeyRunner->first);
    43674655    if (finder != TrianglesOnBoundary.end())
     
    43804668        trianglesShareLine = trianglesShareLine || triangle->lines[i] == partnerTriangle->lines[j];
    43814669
    4382     if (trianglesShareLine
    4383       && (triangle->endpoints[1]->LinesCount > 2)
    4384       && (triangle->endpoints[2]->LinesCount > 2)
    4385       && (triangle->endpoints[0]->LinesCount > 2)
    4386     ) {
     4670    if (trianglesShareLine && (triangle->endpoints[1]->LinesCount > 2) && (triangle->endpoints[2]->LinesCount > 2) && (triangle->endpoints[0]->LinesCount > 2)) {
    43874671      // check whether we have to fix lines
    43884672      BoundaryTriangleSet *Othertriangle = NULL;
     
    44044688            // the line of triangle receives the degenerated ones
    44054689            triangle->lines[i]->triangles.erase(Othertriangle->Nr);
    4406             triangle->lines[i]->triangles.insert( TrianglePair( partnerTriangle->Nr, partnerTriangle) );
    4407             for (int k=0;k<3;k++)
     4690            triangle->lines[i]->triangles.insert(TrianglePair(partnerTriangle->Nr, partnerTriangle));
     4691            for (int k = 0; k < 3; k++)
    44084692              if (triangle->lines[i] == Othertriangle->lines[k]) {
    44094693                Othertriangle->lines[k] = partnerTriangle->lines[j];
     
    44114695              }
    44124696            // the line of partnerTriangle receives the non-degenerated ones
    4413             partnerTriangle->lines[j]->triangles.erase( partnerTriangle->Nr);
    4414             partnerTriangle->lines[j]->triangles.insert( TrianglePair( Othertriangle->Nr, Othertriangle) );
     4697            partnerTriangle->lines[j]->triangles.erase(partnerTriangle->Nr);
     4698            partnerTriangle->lines[j]->triangles.insert(TrianglePair(Othertriangle->Nr, Othertriangle));
    44154699            partnerTriangle->lines[j] = triangle->lines[i];
    44164700          }
     
    44184702      // erase the pair
    44194703      count += (int) DegeneratedTriangles->erase(triangle->Nr);
    4420       Log() << Verbose(0) << "RemoveDegeneratedTriangles() removes triangle " << *triangle << "." << endl;
     4704      DoLog(0) && (Log() << Verbose(0) << "RemoveDegeneratedTriangles() removes triangle " << *triangle << "." << endl);
    44214705      RemoveTesselationTriangle(triangle);
    44224706      count += (int) DegeneratedTriangles->erase(partnerTriangle->Nr);
    4423       Log() << Verbose(0) << "RemoveDegeneratedTriangles() removes triangle " << *partnerTriangle << "." << endl;
     4707      DoLog(0) && (Log() << Verbose(0) << "RemoveDegeneratedTriangles() removes triangle " << *partnerTriangle << "." << endl);
    44244708      RemoveTesselationTriangle(partnerTriangle);
    44254709    } else {
    4426       Log() << Verbose(0) << "RemoveDegeneratedTriangles() does not remove triangle " << *triangle
    4427         << " and its partner " << *partnerTriangle << " because it is essential for at"
    4428         << " least one of the endpoints to be kept in the tesselation structure." << endl;
    4429     }
    4430   }
    4431   delete(DegeneratedTriangles);
     4710      DoLog(0) && (Log() << Verbose(0) << "RemoveDegeneratedTriangles() does not remove triangle " << *triangle << " and its partner " << *partnerTriangle << " because it is essential for at" << " least one of the endpoints to be kept in the tesselation structure." << endl);
     4711    }
     4712  }
     4713  delete (DegeneratedTriangles);
    44324714  if (count > 0)
    44334715    LastTriangle = NULL;
    44344716
    4435   Log() << Verbose(0) << "RemoveDegeneratedTriangles() removed " << count << " triangles:" << endl;
     4717  DoLog(0) && (Log() << Verbose(0) << "RemoveDegeneratedTriangles() removed " << count << " triangles:" << endl);
    44364718}
    44374719
     
    44464728void Tesselation::AddBoundaryPointByDegeneratedTriangle(class TesselPoint *point, LinkedCell *LC)
    44474729{
    4448         Info FunctionInfo(__func__);
     4730  Info FunctionInfo(__func__);
    44494731  // find nearest boundary point
    44504732  class TesselPoint *BackupPoint = NULL;
     
    44594741    NearestBoundaryPoint = PointRunner->second;
    44604742  } else {
    4461     eLog() << Verbose(1) << "I cannot find the boundary point." << endl;
     4743    DoeLog(1) && (eLog() << Verbose(1) << "I cannot find the boundary point." << endl);
    44624744    return;
    44634745  }
    4464   Log() << Verbose(0) << "Nearest point on boundary is " << NearestPoint->Name << "." << endl;
     4746  DoLog(0) && (Log() << Verbose(0) << "Nearest point on boundary is " << NearestPoint->Name << "." << endl);
    44654747
    44664748  // go through its lines and find the best one to split
     
    44774759    CenterToPoint.SubtractVector(point->node);
    44784760    angle = CenterToPoint.Angle(&BaseLine);
    4479     if (fabs(angle - M_PI/2.) < fabs(BestAngle - M_PI/2.)) {
     4761    if (fabs(angle - M_PI / 2.) < fabs(BestAngle - M_PI / 2.)) {
    44804762      BestAngle = angle;
    44814763      BestLine = Runner->second;
     
    44874769  BestLine->triangles.erase(TempTriangle->Nr);
    44884770  int nr = -1;
    4489   for (int i=0;i<3; i++) {
     4771  for (int i = 0; i < 3; i++) {
    44904772    if (TempTriangle->lines[i] == BestLine) {
    44914773      nr = i;
     
    44954777
    44964778  // create new triangle to connect point (connects automatically with the missing spot of the chosen line)
    4497   Log() << Verbose(2) << "Adding new triangle points."<< endl;
     4779  DoLog(2) && (Log() << Verbose(2) << "Adding new triangle points." << endl);
    44984780  AddTesselationPoint((BestLine->endpoints[0]->node), 0);
    44994781  AddTesselationPoint((BestLine->endpoints[1]->node), 1);
    45004782  AddTesselationPoint(point, 2);
    4501   Log() << Verbose(2) << "Adding new triangle lines."<< endl;
    4502   AddTesselationLine(TPS[0], TPS[1], 0);
    4503   AddTesselationLine(TPS[0], TPS[2], 1);
    4504   AddTesselationLine(TPS[1], TPS[2], 2);
     4783  DoLog(2) && (Log() << Verbose(2) << "Adding new triangle lines." << endl);
     4784  AddTesselationLine(NULL, NULL, TPS[0], TPS[1], 0);
     4785  AddTesselationLine(NULL, NULL, TPS[0], TPS[2], 1);
     4786  AddTesselationLine(NULL, NULL, TPS[1], TPS[2], 2);
    45054787  BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
    45064788  BTS->GetNormalVector(TempTriangle->NormalVector);
    45074789  BTS->NormalVector.Scale(-1.);
    4508   Log() << Verbose(1) << "INFO: NormalVector of new triangle is " << BTS->NormalVector << "." << endl;
     4790  DoLog(1) && (Log() << Verbose(1) << "INFO: NormalVector of new triangle is " << BTS->NormalVector << "." << endl);
    45094791  AddTesselationTriangle();
    45104792
    45114793  // create other side of this triangle and close both new sides of the first created triangle
    4512   Log() << Verbose(2) << "Adding new triangle points."<< endl;
     4794  DoLog(2) && (Log() << Verbose(2) << "Adding new triangle points." << endl);
    45134795  AddTesselationPoint((BestLine->endpoints[0]->node), 0);
    45144796  AddTesselationPoint((BestLine->endpoints[1]->node), 1);
    45154797  AddTesselationPoint(point, 2);
    4516   Log() << Verbose(2) << "Adding new triangle lines."<< endl;
    4517   AddTesselationLine(TPS[0], TPS[1], 0);
    4518   AddTesselationLine(TPS[0], TPS[2], 1);
    4519   AddTesselationLine(TPS[1], TPS[2], 2);
     4798  DoLog(2) && (Log() << Verbose(2) << "Adding new triangle lines." << endl);
     4799  AddTesselationLine(NULL, NULL, TPS[0], TPS[1], 0);
     4800  AddTesselationLine(NULL, NULL, TPS[0], TPS[2], 1);
     4801  AddTesselationLine(NULL, NULL, TPS[1], TPS[2], 2);
    45204802  BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
    45214803  BTS->GetNormalVector(TempTriangle->NormalVector);
    4522   Log() << Verbose(1) << "INFO: NormalVector of other new triangle is " << BTS->NormalVector << "." << endl;
     4804  DoLog(1) && (Log() << Verbose(1) << "INFO: NormalVector of other new triangle is " << BTS->NormalVector << "." << endl);
    45234805  AddTesselationTriangle();
    45244806
    45254807  // add removed triangle to the last open line of the second triangle
    4526   for (int i=0;i<3;i++) { // look for the same line as BestLine (only it's its degenerated companion)
     4808  for (int i = 0; i < 3; i++) { // look for the same line as BestLine (only it's its degenerated companion)
    45274809    if ((BTS->lines[i]->ContainsBoundaryPoint(BestLine->endpoints[0])) && (BTS->lines[i]->ContainsBoundaryPoint(BestLine->endpoints[1]))) {
    4528       if (BestLine == BTS->lines[i]){
    4529         eLog() << Verbose(0) << "BestLine is same as found line, something's wrong here!" << endl;
     4810      if (BestLine == BTS->lines[i]) {
     4811        DoeLog(0) && (eLog() << Verbose(0) << "BestLine is same as found line, something's wrong here!" << endl);
    45304812        performCriticalExit();
    45314813      }
    4532       BTS->lines[i]->triangles.insert( pair<int, class BoundaryTriangleSet *> (TempTriangle->Nr, TempTriangle) );
     4814      BTS->lines[i]->triangles.insert(pair<int, class BoundaryTriangleSet *> (TempTriangle->Nr, TempTriangle));
    45334815      TempTriangle->lines[nr] = BTS->lines[i];
    45344816      break;
    45354817    }
    45364818  }
    4537 };
     4819}
     4820;
    45384821
    45394822/** Writes the envelope to file.
     
    45444827void Tesselation::Output(const char *filename, const PointCloud * const cloud)
    45454828{
    4546         Info FunctionInfo(__func__);
     4829  Info FunctionInfo(__func__);
    45474830  ofstream *tempstream = NULL;
    45484831  string NameofTempFile;
     
    45504833
    45514834  if (LastTriangle != NULL) {
    4552     sprintf(NumberName, "-%04d-%s_%s_%s", (int)TrianglesOnBoundary.size(), LastTriangle->endpoints[0]->node->Name, LastTriangle->endpoints[1]->node->Name, LastTriangle->endpoints[2]->node->Name);
     4835    sprintf(NumberName, "-%04d-%s_%s_%s", (int) TrianglesOnBoundary.size(), LastTriangle->endpoints[0]->node->Name, LastTriangle->endpoints[1]->node->Name, LastTriangle->endpoints[2]->node->Name);
    45534836    if (DoTecplotOutput) {
    45544837      string NameofTempFile(filename);
    45554838      NameofTempFile.append(NumberName);
    4556       for(size_t npos = NameofTempFile.find_first_of(' '); npos != string::npos; npos = NameofTempFile.find(' ', npos))
    4557       NameofTempFile.erase(npos, 1);
     4839      for (size_t npos = NameofTempFile.find_first_of(' '); npos != string::npos; npos = NameofTempFile.find(' ', npos))
     4840        NameofTempFile.erase(npos, 1);
    45584841      NameofTempFile.append(TecplotSuffix);
    4559       Log() << Verbose(0) << "Writing temporary non convex hull to file " << NameofTempFile << ".\n";
     4842      DoLog(0) && (Log() << Verbose(0) << "Writing temporary non convex hull to file " << NameofTempFile << ".\n");
    45604843      tempstream = new ofstream(NameofTempFile.c_str(), ios::trunc);
    45614844      WriteTecplotFile(tempstream, this, cloud, TriangleFilesWritten);
    45624845      tempstream->close();
    45634846      tempstream->flush();
    4564       delete(tempstream);
     4847      delete (tempstream);
    45654848    }
    45664849
     
    45684851      string NameofTempFile(filename);
    45694852      NameofTempFile.append(NumberName);
    4570       for(size_t npos = NameofTempFile.find_first_of(' '); npos != string::npos; npos = NameofTempFile.find(' ', npos))
    4571       NameofTempFile.erase(npos, 1);
     4853      for (size_t npos = NameofTempFile.find_first_of(' '); npos != string::npos; npos = NameofTempFile.find(' ', npos))
     4854        NameofTempFile.erase(npos, 1);
    45724855      NameofTempFile.append(Raster3DSuffix);
    4573       Log() << Verbose(0) << "Writing temporary non convex hull to file " << NameofTempFile << ".\n";
     4856      DoLog(0) && (Log() << Verbose(0) << "Writing temporary non convex hull to file " << NameofTempFile << ".\n");
    45744857      tempstream = new ofstream(NameofTempFile.c_str(), ios::trunc);
    45754858      WriteRaster3dFile(tempstream, this, cloud);
     
    45774860      tempstream->close();
    45784861      tempstream->flush();
    4579       delete(tempstream);
     4862      delete (tempstream);
    45804863    }
    45814864  }
    45824865  if (DoTecplotOutput || DoRaster3DOutput)
    45834866    TriangleFilesWritten++;
    4584 };
    4585 
    4586 struct BoundaryPolygonSetCompare {
    4587   bool operator()(const BoundaryPolygonSet * s1, const BoundaryPolygonSet * s2) const {
     4867}
     4868;
     4869
     4870struct BoundaryPolygonSetCompare
     4871{
     4872  bool operator()(const BoundaryPolygonSet * s1, const BoundaryPolygonSet * s2) const
     4873  {
    45884874    if (s1->endpoints.size() < s2->endpoints.size())
    45894875      return true;
     
    46144900{
    46154901  Info FunctionInfo(__func__);
    4616 
    46174902  /// 2. Go through all BoundaryPointSet's, check their triangles' NormalVector
    46184903  IndexToIndex *DegeneratedTriangles = FindAllDegeneratedTriangles();
    4619   set < BoundaryPointSet *> EndpointCandidateList;
    4620   pair < set < BoundaryPointSet *>::iterator, bool > InsertionTester;
    4621   pair < map < int, Vector *>::iterator, bool > TriangleInsertionTester;
     4904  set<BoundaryPointSet *> EndpointCandidateList;
     4905  pair<set<BoundaryPointSet *>::iterator, bool> InsertionTester;
     4906  pair<map<int, Vector *>::iterator, bool> TriangleInsertionTester;
    46224907  for (PointMap::const_iterator Runner = PointsOnBoundary.begin(); Runner != PointsOnBoundary.end(); Runner++) {
    4623     Log() << Verbose(0) << "Current point is " << *Runner->second << "." << endl;
    4624     map < int, Vector *> TriangleVectors;
     4908    DoLog(0) && (Log() << Verbose(0) << "Current point is " << *Runner->second << "." << endl);
     4909    map<int, Vector *> TriangleVectors;
    46254910    // gather all NormalVectors
    4626     Log() << Verbose(1) << "Gathering triangles ..." << endl;
     4911    DoLog(1) && (Log() << Verbose(1) << "Gathering triangles ..." << endl);
    46274912    for (LineMap::const_iterator LineRunner = (Runner->second)->lines.begin(); LineRunner != (Runner->second)->lines.end(); LineRunner++)
    46284913      for (TriangleMap::const_iterator TriangleRunner = (LineRunner->second)->triangles.begin(); TriangleRunner != (LineRunner->second)->triangles.end(); TriangleRunner++) {
    46294914        if (DegeneratedTriangles->find(TriangleRunner->second->Nr) == DegeneratedTriangles->end()) {
    4630           TriangleInsertionTester = TriangleVectors.insert( pair< int, Vector *> ((TriangleRunner->second)->Nr, &((TriangleRunner->second)->NormalVector)) );
     4915          TriangleInsertionTester = TriangleVectors.insert(pair<int, Vector *> ((TriangleRunner->second)->Nr, &((TriangleRunner->second)->NormalVector)));
    46314916          if (TriangleInsertionTester.second)
    4632             Log() << Verbose(1) << " Adding triangle " << *(TriangleRunner->second) << " to triangles to check-list." << endl;
     4917            DoLog(1) && (Log() << Verbose(1) << " Adding triangle " << *(TriangleRunner->second) << " to triangles to check-list." << endl);
    46334918        } else {
    4634           Log() << Verbose(1) << " NOT adding triangle " << *(TriangleRunner->second) << " as it's a simply degenerated one." << endl;
     4919          DoLog(1) && (Log() << Verbose(1) << " NOT adding triangle " << *(TriangleRunner->second) << " as it's a simply degenerated one." << endl);
    46354920        }
    46364921      }
    46374922    // check whether there are two that are parallel
    4638     Log() << Verbose(1) << "Finding two parallel triangles ..." << endl;
    4639     for (map < int, Vector *>::iterator VectorWalker = TriangleVectors.begin(); VectorWalker != TriangleVectors.end(); VectorWalker++)
    4640       for (map < int, Vector *>::iterator VectorRunner = VectorWalker; VectorRunner != TriangleVectors.end(); VectorRunner++)
     4923    DoLog(1) && (Log() << Verbose(1) << "Finding two parallel triangles ..." << endl);
     4924    for (map<int, Vector *>::iterator VectorWalker = TriangleVectors.begin(); VectorWalker != TriangleVectors.end(); VectorWalker++)
     4925      for (map<int, Vector *>::iterator VectorRunner = VectorWalker; VectorRunner != TriangleVectors.end(); VectorRunner++)
    46414926        if (VectorWalker != VectorRunner) { // skip equals
    4642           const double SCP = VectorWalker->second->ScalarProduct(VectorRunner->second);  // ScalarProduct should result in -1. for degenerated triangles
    4643           Log() << Verbose(1) << "Checking " << *VectorWalker->second<< " against " << *VectorRunner->second << ": " << SCP << endl;
     4927          const double SCP = VectorWalker->second->ScalarProduct(VectorRunner->second); // ScalarProduct should result in -1. for degenerated triangles
     4928          DoLog(1) && (Log() << Verbose(1) << "Checking " << *VectorWalker->second << " against " << *VectorRunner->second << ": " << SCP << endl);
    46444929          if (fabs(SCP + 1.) < ParallelEpsilon) {
    46454930            InsertionTester = EndpointCandidateList.insert((Runner->second));
    46464931            if (InsertionTester.second)
    4647               Log() << Verbose(0) << " Adding " << *Runner->second << " to endpoint candidate list." << endl;
     4932              DoLog(0) && (Log() << Verbose(0) << " Adding " << *Runner->second << " to endpoint candidate list." << endl);
    46484933            // and break out of both loops
    46494934            VectorWalker = TriangleVectors.end();
     
    46604945  BoundaryPointSet *OtherWalker = NULL;
    46614946  BoundaryPolygonSet *Current = NULL;
    4662   stack <BoundaryPointSet*> ToCheckConnecteds;
     4947  stack<BoundaryPointSet*> ToCheckConnecteds;
    46634948  while (!EndpointCandidateList.empty()) {
    46644949    Walker = *(EndpointCandidateList.begin());
    4665     if (Current == NULL) {  // create a new polygon with current candidate
    4666       Log() << Verbose(0) << "Starting new polygon set at point " << *Walker << endl;
     4950    if (Current == NULL) { // create a new polygon with current candidate
     4951      DoLog(0) && (Log() << Verbose(0) << "Starting new polygon set at point " << *Walker << endl);
    46674952      Current = new BoundaryPolygonSet;
    46684953      Current->endpoints.insert(Walker);
     
    46774962      for (LineMap::const_iterator LineWalker = Walker->lines.begin(); LineWalker != Walker->lines.end(); LineWalker++) {
    46784963        OtherWalker = (LineWalker->second)->GetOtherEndpoint(Walker);
    4679         Log() << Verbose(1) << "Checking " << *OtherWalker << endl;
    4680         set < BoundaryPointSet *>::iterator Finder = EndpointCandidateList.find(OtherWalker);
    4681         if (Finder != EndpointCandidateList.end()) {  // found a connected partner
    4682           Log() << Verbose(1) << " Adding to polygon." << endl;
     4964        DoLog(1) && (Log() << Verbose(1) << "Checking " << *OtherWalker << endl);
     4965        set<BoundaryPointSet *>::iterator Finder = EndpointCandidateList.find(OtherWalker);
     4966        if (Finder != EndpointCandidateList.end()) { // found a connected partner
     4967          DoLog(1) && (Log() << Verbose(1) << " Adding to polygon." << endl);
    46834968          Current->endpoints.insert(OtherWalker);
    4684           EndpointCandidateList.erase(Finder);  // remove from candidates
    4685           ToCheckConnecteds.push(OtherWalker);  // but check its partners too
     4969          EndpointCandidateList.erase(Finder); // remove from candidates
     4970          ToCheckConnecteds.push(OtherWalker); // but check its partners too
    46864971        } else {
    4687           Log() << Verbose(1) << " is not connected to " << *Walker << endl;
     4972          DoLog(1) && (Log() << Verbose(1) << " is not connected to " << *Walker << endl);
    46884973        }
    46894974      }
    46904975    }
    46914976
    4692     Log() << Verbose(0) << "Final polygon is " << *Current << endl;
     4977    DoLog(0) && (Log() << Verbose(0) << "Final polygon is " << *Current << endl);
    46934978    ListofDegeneratedPolygons.insert(Current);
    46944979    Current = NULL;
     
    46974982  const int counter = ListofDegeneratedPolygons.size();
    46984983
    4699   Log() << Verbose(0) << "The following " << counter << " degenerated polygons have been found: " << endl;
     4984  DoLog(0) && (Log() << Verbose(0) << "The following " << counter << " degenerated polygons have been found: " << endl);
    47004985  for (UniquePolygonSet::iterator PolygonRunner = ListofDegeneratedPolygons.begin(); PolygonRunner != ListofDegeneratedPolygons.end(); PolygonRunner++)
    4701     Log() << Verbose(0) << " " << **PolygonRunner << endl;
     4986    DoLog(0) && (Log() << Verbose(0) << " " << **PolygonRunner << endl);
    47024987
    47034988  /// 4. Go through all these degenerated polygons
    47044989  for (UniquePolygonSet::iterator PolygonRunner = ListofDegeneratedPolygons.begin(); PolygonRunner != ListofDegeneratedPolygons.end(); PolygonRunner++) {
    4705     stack <int> TriangleNrs;
     4990    stack<int> TriangleNrs;
    47064991    Vector NormalVector;
    47074992    /// 4a. Gather all triangles of this polygon
     
    47104995    // check whether number is bigger than 2, otherwise it's just a simply degenerated one and nothing to do.
    47114996    if (T->size() == 2) {
    4712       Log() << Verbose(1) << " Skipping degenerated polygon, is just a (already simply degenerated) triangle." << endl;
    4713       delete(T);
     4997      DoLog(1) && (Log() << Verbose(1) << " Skipping degenerated polygon, is just a (already simply degenerated) triangle." << endl);
     4998      delete (T);
    47144999      continue;
    47155000    }
     
    47205005    // connections to either polygon ...
    47215006    if (T->size() % 2 != 0) {
    4722       eLog() << Verbose(0) << " degenerated polygon contains an odd number of triangles, probably contains bridging non-degenerated ones, too!" << endl;
     5007      DoeLog(0) && (eLog() << Verbose(0) << " degenerated polygon contains an odd number of triangles, probably contains bridging non-degenerated ones, too!" << endl);
    47235008      performCriticalExit();
    47245009    }
    4725 
    4726     TriangleSet::iterator TriangleWalker = T->begin();  // is the inner iterator
     5010    TriangleSet::iterator TriangleWalker = T->begin(); // is the inner iterator
    47275011    /// 4a. Get NormalVector for one side (this is "front")
    47285012    NormalVector.CopyVector(&(*TriangleWalker)->NormalVector);
    4729     Log() << Verbose(1) << "\"front\" defining triangle is " << **TriangleWalker << " and Normal vector of \"front\" side is " << NormalVector << endl;
     5013    DoLog(1) && (Log() << Verbose(1) << "\"front\" defining triangle is " << **TriangleWalker << " and Normal vector of \"front\" side is " << NormalVector << endl);
    47305014    TriangleWalker++;
    47315015    TriangleSet::iterator TriangleSprinter = TriangleWalker; // is the inner advanced iterator
     
    47365020      triangle = *TriangleWalker;
    47375021      TriangleSprinter++;
    4738       Log() << Verbose(1) << "Current triangle to test for removal: " << *triangle << endl;
     5022      DoLog(1) && (Log() << Verbose(1) << "Current triangle to test for removal: " << *triangle << endl);
    47395023      if (triangle->NormalVector.ScalarProduct(&NormalVector) < 0) { // if from other side, then delete and remove from list
    4740         Log() << Verbose(1) << " Removing ... " << endl;
     5024        DoLog(1) && (Log() << Verbose(1) << " Removing ... " << endl);
    47415025        TriangleNrs.push(triangle->Nr);
    47425026        T->erase(TriangleWalker);
    47435027        RemoveTesselationTriangle(triangle);
    47445028      } else
    4745         Log() << Verbose(1) << " Keeping ... " << endl;
     5029        DoLog(1) && (Log() << Verbose(1) << " Keeping ... " << endl);
    47465030    }
    47475031    /// 4c. Copy all "front" triangles but with inverse NormalVector
    47485032    TriangleWalker = T->begin();
    4749     while (TriangleWalker != T->end()) {  // go through all front triangles
    4750       Log() << Verbose(1) << " Re-creating triangle " << **TriangleWalker << " with NormalVector " << (*TriangleWalker)->NormalVector << endl;
     5033    while (TriangleWalker != T->end()) { // go through all front triangles
     5034      DoLog(1) && (Log() << Verbose(1) << " Re-creating triangle " << **TriangleWalker << " with NormalVector " << (*TriangleWalker)->NormalVector << endl);
    47515035      for (int i = 0; i < 3; i++)
    47525036        AddTesselationPoint((*TriangleWalker)->endpoints[i]->node, i);
    4753       AddTesselationLine(TPS[0], TPS[1], 0);
    4754       AddTesselationLine(TPS[0], TPS[2], 1);
    4755       AddTesselationLine(TPS[1], TPS[2], 2);
     5037      AddTesselationLine(NULL, NULL, TPS[0], TPS[1], 0);
     5038      AddTesselationLine(NULL, NULL, TPS[0], TPS[2], 1);
     5039      AddTesselationLine(NULL, NULL, TPS[1], TPS[2], 2);
    47565040      if (TriangleNrs.empty())
    4757         eLog() << Verbose(0) << "No more free triangle numbers!" << endl;
     5041        DoeLog(0) && (eLog() << Verbose(0) << "No more free triangle numbers!" << endl);
    47585042      BTS = new BoundaryTriangleSet(BLS, TriangleNrs.top()); // copy triangle ...
    47595043      AddTesselationTriangle(); // ... and add
     
    47645048    }
    47655049    if (!TriangleNrs.empty()) {
    4766       eLog() << Verbose(0) << "There have been less triangles created than removed!" << endl;
    4767     }
    4768     delete(T);  // remove the triangleset
    4769   }
    4770 
     5050      DoeLog(0) && (eLog() << Verbose(0) << "There have been less triangles created than removed!" << endl);
     5051    }
     5052    delete (T); // remove the triangleset
     5053  }
    47715054  IndexToIndex * SimplyDegeneratedTriangles = FindAllDegeneratedTriangles();
    4772   Log() << Verbose(0) << "Final list of simply degenerated triangles found, containing " << SimplyDegeneratedTriangles->size() << " triangles:" << endl;
     5055  DoLog(0) && (Log() << Verbose(0) << "Final list of simply degenerated triangles found, containing " << SimplyDegeneratedTriangles->size() << " triangles:" << endl);
    47735056  IndexToIndex::iterator it;
    47745057  for (it = SimplyDegeneratedTriangles->begin(); it != SimplyDegeneratedTriangles->end(); it++)
    4775       Log() << Verbose(0) << (*it).first << " => " << (*it).second << endl;
    4776   delete(SimplyDegeneratedTriangles);
    4777 
     5058    DoLog(0) && (Log() << Verbose(0) << (*it).first << " => " << (*it).second << endl);
     5059  delete (SimplyDegeneratedTriangles);
    47785060  /// 5. exit
    47795061  UniquePolygonSet::iterator PolygonRunner;
    47805062  while (!ListofDegeneratedPolygons.empty()) {
    47815063    PolygonRunner = ListofDegeneratedPolygons.begin();
    4782     delete(*PolygonRunner);
     5064    delete (*PolygonRunner);
    47835065    ListofDegeneratedPolygons.erase(PolygonRunner);
    47845066  }
    47855067
    47865068  return counter;
    4787 };
     5069}
     5070;
  • src/tesselation.hpp

    r13d5a9 r5f612ee  
    4343#define DoTecplotOutput 1
    4444#define DoRaster3DOutput 1
    45 #define DoVRMLOutput 1
     45#define DoVRMLOutput 0
    4646#define TecplotSuffix ".dat"
    4747#define Raster3DSuffix ".r3d"
     
    8989
    9090#define ListOfTesselPointList list<list <TesselPoint *> *>
     91
     92enum centers {Opt, OtherOpt};
    9193
    9294/********************************************** declarations *******************************/
     
    249251  public :
    250252  CandidateForTesselation(BoundaryLineSet* currentBaseLine);
    251   CandidateForTesselation(TesselPoint* candidate, BoundaryLineSet* currentBaseLine, Vector OptCandidateCenter, Vector OtherOptCandidateCenter);
     253  CandidateForTesselation(TesselPoint* candidate, BoundaryLineSet* currentBaseLine, BoundaryPointSet *point, Vector OptCandidateCenter, Vector OtherOptCandidateCenter);
    252254  ~CandidateForTesselation();
    253255
     256  bool CheckValidity(const double RADIUS, const LinkedCell *LC) const;
     257
    254258  TesselPointList pointlist;
    255   BoundaryLineSet *BaseLine;
     259  const BoundaryLineSet * BaseLine;
     260  const BoundaryPointSet * ThirdPoint;
     261  const BoundaryTriangleSet *T;
     262  Vector OldCenter;
    256263  Vector OptCenter;
    257264  Vector OtherOptCenter;
     
    274281    void AddTesselationPoint(TesselPoint* Candidate, const int n);
    275282    void SetTesselationPoint(TesselPoint* Candidate, const int n) const;
    276     void AddTesselationLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n);
    277     void AlwaysAddTesselationTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n);
     283    void AddTesselationLine(const Vector * const OptCenter, const BoundaryPointSet * const candidate, class BoundaryPointSet *a, class BoundaryPointSet *b, const int n);
     284    void AddNewTesselationTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n);
     285    void AddExistingTesselationTriangleLine(class BoundaryLineSet *FindLine, int n);
    278286    void AddTesselationTriangle();
    279287    void AddTesselationTriangle(const int nr);
    280     void AddCandidateTriangle(CandidateForTesselation CandidateLine);
     288    void AddCandidateTriangle(CandidateForTesselation &CandidateLine, enum centers type);
     289    void AddDegeneratedTriangle(CandidateForTesselation &CandidateLine, const double RADIUS, const LinkedCell *LC);
     290    void AddCandidatePolygon(CandidateForTesselation CandidateLine, const double RADIUS, const LinkedCell *LC);
    281291    void RemoveTesselationTriangle(class BoundaryTriangleSet *triangle);
    282292    void RemoveTesselationLine(class BoundaryLineSet *line);
    283293    void RemoveTesselationPoint(class BoundaryPointSet *point);
     294    bool CheckDegeneracy(CandidateForTesselation &CandidateLine, const double RADIUS, const LinkedCell *LC) const;
    284295
    285296
    286297    // concave envelope
    287     void FindStartingTriangle(const double RADIUS, const LinkedCell *LC);
     298    bool FindStartingTriangle(const double RADIUS, const LinkedCell *LC);
    288299    void FindSecondPointForTesselation(class TesselPoint* a, Vector Oben, class TesselPoint*& OptCandidate, double Storage[3], double RADIUS, const LinkedCell *LC);
    289     void FindThirdPointForTesselation(Vector &NormalVector, Vector &SearchDirection, Vector &OldSphereCenter, CandidateForTesselation &CandidateLine, const class TesselPoint  * const ThirdNode, const double RADIUS, const LinkedCell *LC) const;
    290     bool FindNextSuitableTriangle(CandidateForTesselation &CandidateLine, BoundaryTriangleSet &T, const double& RADIUS, const LinkedCell *LC);
     300    void FindThirdPointForTesselation(const Vector &NormalVector, const Vector &SearchDirection, const Vector &OldSphereCenter, CandidateForTesselation &CandidateLine, const class BoundaryPointSet  * const ThirdNode, const double RADIUS, const LinkedCell *LC) const;
     301    bool FindNextSuitableTriangle(CandidateForTesselation &CandidateLine, const BoundaryTriangleSet &T, const double& RADIUS, const LinkedCell *LC);
     302    bool FindCandidatesforOpenLines(const double RADIUS, const LinkedCell *&LCList);
    291303    int CheckPresenceOfTriangle(class TesselPoint *Candidates[3]) const;
    292304    class BoundaryTriangleSet * GetPresentTriangle(TesselPoint *Candidates[3]);
     
    318330    bool IsInnerPoint(const Vector &Point, const LinkedCell* const LC) const;
    319331    double GetDistanceSquaredToTriangle(const Vector &Point, const BoundaryTriangleSet* const triangle) const;
    320     double GetDistanceSquaredToSurface(const Vector &Point, const LinkedCell* const LC) const;
     332    double GetDistanceToSurface(const Vector &Point, const LinkedCell* const LC) const;
     333    BoundaryTriangleSet * GetClosestTriangleOnSurface(const Vector &Point, const LinkedCell* const LC) const;
    321334    bool AddBoundaryPoint(TesselPoint * Walker, const int n);
    322335    DistanceToPointMap * FindClosestBoundaryPointsToVector(const Vector *x, const LinkedCell* LC) const;
     
    362375
    363376    //bool HasOtherBaselineBetterCandidate(const BoundaryLineSet * const BaseRay, const TesselPoint * const OptCandidate, double ShortestAngle, double RADIUS, const LinkedCell * const LC) const;
     377    void FindDegeneratedCandidatesforOpenLines(TesselPoint * const Sprinter, const Vector * const OptCenter);
    364378};
    365379
  • src/tesselationhelpers.cpp

    r13d5a9 r5f612ee  
    8181
    8282  if (fabs(m11) < MYEPSILON)
    83     eLog() << Verbose(1) << "three points are colinear." << endl;
     83    DoeLog(1) && (eLog()<< Verbose(1) << "three points are colinear." << endl);
    8484
    8585  center->x[0] =  0.5 * m12/ m11;
     
    8888
    8989  if (fabs(a.Distance(center) - RADIUS) > MYEPSILON)
    90     eLog() << Verbose(1) << "The given center is further way by " << fabs(a.Distance(center) - RADIUS) << " from a than RADIUS." << endl;
     90    DoeLog(1) && (eLog()<< Verbose(1) << "The given center is further way by " << fabs(a.Distance(center) - RADIUS) << " from a than RADIUS." << endl);
    9191
    9292  gsl_matrix_free(A);
     
    132132  Center->Scale(1./(sin(2.*alpha) + sin(2.*beta) + sin(2.*gamma)));
    133133  NewUmkreismittelpunkt->CopyVector(Center);
    134   Log() << Verbose(1) << "Center of new circumference is " << *NewUmkreismittelpunkt << ".\n";
     134  DoLog(1) && (Log() << Verbose(1) << "Center of new circumference is " << *NewUmkreismittelpunkt << ".\n");
    135135  // Here we calculated center of circumscribing circle, using barycentric coordinates
    136   Log() << Verbose(1) << "Center of circumference is " << *Center << " in direction " << *Direction << ".\n";
     136  DoLog(1) && (Log() << Verbose(1) << "Center of circumference is " << *Center << " in direction " << *Direction << ".\n");
    137137
    138138  TempNormal.CopyVector(&a);
     
    158158  TempNormal.Normalize();
    159159  Restradius = sqrt(RADIUS*RADIUS - Umkreisradius*Umkreisradius);
    160   Log() << Verbose(1) << "Height of center of circumference to center of sphere is " << Restradius << ".\n";
     160  DoLog(1) && (Log() << Verbose(1) << "Height of center of circumference to center of sphere is " << Restradius << ".\n");
    161161  TempNormal.Scale(Restradius);
    162   Log() << Verbose(1) << "Shift vector to sphere of circumference is " << TempNormal << ".\n";
     162  DoLog(1) && (Log() << Verbose(1) << "Shift vector to sphere of circumference is " << TempNormal << ".\n");
    163163
    164164  Center->AddVector(&TempNormal);
    165   Log() << Verbose(1) << "Center of sphere of circumference is " << *Center << ".\n";
     165  DoLog(1) && (Log() << Verbose(1) << "Center of sphere of circumference is " << *Center << ".\n");
    166166  GetSphere(&OtherCenter, a, b, c, RADIUS);
    167   Log() << Verbose(1) << "OtherCenter of sphere of circumference is " << OtherCenter << ".\n";
     167  DoLog(1) && (Log() << Verbose(1) << "OtherCenter of sphere of circumference is " << OtherCenter << ".\n");
    168168};
    169169
     
    192192  //Log() << Verbose(1) << "INFO: alpha = " << alpha/M_PI*180. << ", beta = " << beta/M_PI*180. << ", gamma = " << gamma/M_PI*180. << "." << endl;
    193193  if (fabs(M_PI - alpha - beta - gamma) > HULLEPSILON) {
    194     eLog() << Verbose(1) << "GetCenterofCircumcircle: Sum of angles " << (alpha+beta+gamma)/M_PI*180. << " > 180 degrees by " << fabs(M_PI - alpha - beta - gamma)/M_PI*180. << "!" << endl;
     194    DoeLog(2) && (eLog()<< Verbose(2) << "GetCenterofCircumcircle: Sum of angles " << (alpha+beta+gamma)/M_PI*180. << " > 180 degrees by " << fabs(M_PI - alpha - beta - gamma)/M_PI*180. << "!" << endl);
    195195  }
    196196
     
    236236  // test whether new center is on the parameter circle's plane
    237237  if (fabs(helper.ScalarProduct(&CirclePlaneNormal)) > HULLEPSILON) {
    238     eLog() << Verbose(1) << "Something's very wrong here: NewSphereCenter is not on the band's plane as desired by " <<fabs(helper.ScalarProduct(&CirclePlaneNormal))  << "!" << endl;
     238    DoeLog(1) && (eLog()<< Verbose(1) << "Something's very wrong here: NewSphereCenter is not on the band's plane as desired by " <<fabs(helper.ScalarProduct(&CirclePlaneNormal))  << "!" << endl);
    239239    helper.ProjectOntoPlane(&CirclePlaneNormal);
    240240  }
     
    242242  // test whether the new center vector has length of CircleRadius
    243243  if (fabs(radius - CircleRadius) > HULLEPSILON)
    244     eLog() << Verbose(1) << "The projected center of the new sphere has radius " << radius << " instead of " << CircleRadius << "." << endl;
     244    DoeLog(1) && (eLog()<< Verbose(1) << "The projected center of the new sphere has radius " << radius << " instead of " << CircleRadius << "." << endl);
    245245  alpha = helper.Angle(&RelativeOldSphereCenter);
    246246  // make the angle unique by checking the halfplanes/search direction
    247247  if (helper.ScalarProduct(&SearchDirection) < -HULLEPSILON)  // acos is not unique on [0, 2.*M_PI), hence extra check to decide between two half intervals
    248248    alpha = 2.*M_PI - alpha;
    249   Log() << Verbose(1) << "INFO: RelativeNewSphereCenter is " << helper << ", RelativeOldSphereCenter is " << RelativeOldSphereCenter << " and resulting angle is " << alpha << "." << endl;
     249  DoLog(1) && (Log() << Verbose(1) << "INFO: RelativeNewSphereCenter is " << helper << ", RelativeOldSphereCenter is " << RelativeOldSphereCenter << " and resulting angle is " << alpha << "." << endl);
    250250  radius = helper.Distance(&RelativeOldSphereCenter);
    251251  helper.ProjectOntoPlane(&NormalVector);
    252252  // check whether new center is somewhat away or at least right over the current baseline to prevent intersecting triangles
    253253  if ((radius > HULLEPSILON) || (helper.Norm() < HULLEPSILON)) {
    254     Log() << Verbose(1) << "INFO: Distance between old and new center is " << radius << " and between new center and baseline center is " << helper.Norm() << "." << endl;
     254    DoLog(1) && (Log() << Verbose(1) << "INFO: Distance between old and new center is " << radius << " and between new center and baseline center is " << helper.Norm() << "." << endl);
    255255    return alpha;
    256256  } else {
    257     Log() << Verbose(1) << "INFO: NewSphereCenter " << RelativeNewSphereCenter << " is too close to RelativeOldSphereCenter" << RelativeOldSphereCenter << "." << endl;
     257    DoLog(1) && (Log() << Verbose(1) << "INFO: NewSphereCenter " << RelativeNewSphereCenter << " is too close to RelativeOldSphereCenter" << RelativeOldSphereCenter << "." << endl);
    258258    return 2.*M_PI;
    259259  }
     
    364364
    365365        if (status == GSL_SUCCESS) {
    366           Log() << Verbose(1) << "converged to minimum" <<  endl;
     366          DoLog(1) && (Log() << Verbose(1) << "converged to minimum" <<  endl);
    367367        }
    368368    } while (status == GSL_CONTINUE && iter < 100);
     
    394394
    395395  if (((t1 >= 0) && (t1 <= 1)) && ((t2 >= 0) && (t2 <= 1))) {
    396     Log() << Verbose(1) << "true intersection." << endl;
     396    DoLog(1) && (Log() << Verbose(1) << "true intersection." << endl);
    397397    result = true;
    398398  } else {
    399     Log() << Verbose(1) << "intersection out of region of interest." << endl;
     399    DoLog(1) && (Log() << Verbose(1) << "intersection out of region of interest." << endl);
    400400    result = false;
    401401  }
     
    432432  }
    433433
    434   Log() << Verbose(1) << "INFO: " << point << " has angle " << phi << " with respect to reference " << reference << "." << endl;
     434  DoLog(1) && (Log() << Verbose(1) << "INFO: " << point << " has angle " << phi << " with respect to reference " << reference << "." << endl);
    435435
    436436  return phi;
     
    479479    for (int j=i+1; j<3; j++) {
    480480      if (nodes[i] == NULL) {
    481         Log() << Verbose(1) << "Node nr. " << i << " is not yet present." << endl;
     481        DoLog(1) && (Log() << Verbose(1) << "Node nr. " << i << " is not yet present." << endl);
    482482        result = true;
    483483      } else if (nodes[i]->lines.find(nodes[j]->node->nr) != nodes[i]->lines.end()) {  // there already is a line
     
    493493        }
    494494      } else { // no line
    495         Log() << Verbose(1) << "The line between " << *nodes[i] << " and " << *nodes[j] << " is not yet present, hence no need for a degenerate triangle." << endl;
     495        DoLog(1) && (Log() << Verbose(1) << "The line between " << *nodes[i] << " and " << *nodes[j] << " is not yet present, hence no need for a degenerate triangle." << endl);
    496496        result = true;
    497497      }
    498498    }
    499499  if ((!result) && (counter > 1)) {
    500     Log() << Verbose(1) << "INFO: Degenerate triangle is ok, at least two, here " << counter << ", existing lines are used." << endl;
     500    DoLog(1) && (Log() << Verbose(1) << "INFO: Degenerate triangle is ok, at least two, here " << counter << ", existing lines are used." << endl);
    501501    result = true;
    502502  }
     
    512512//  Vector BaseLineVector, OrthogonalVector, helper;
    513513//  if (candidate1->BaseLine != candidate2->BaseLine) {  // sanity check
    514 //    eLog() << Verbose(1) << "sortCandidates was called for two different baselines: " << candidate1->BaseLine << " and " << candidate2->BaseLine << "." << endl;
     514//    DoeLog(1) && (eLog()<< Verbose(1) << "sortCandidates was called for two different baselines: " << candidate1->BaseLine << " and " << candidate2->BaseLine << "." << endl);
    515515//    //return false;
    516516//    exit(1);
     
    571571  for(int i=0;i<NDIM;i++) // store indices of this cell
    572572    N[i] = LC->n[i];
    573   Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl;
     573  DoLog(1) && (Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl);
    574574
    575575  LC->GetNeighbourBounds(Nlower, Nupper);
     
    578578    for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
    579579      for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
    580         const LinkedNodes *List = LC->GetCurrentCell();
     580        const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
    581581        //Log() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl;
    582582        if (List != NULL) {
    583           for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
     583          for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    584584            helper.CopyVector(Point);
    585585            helper.SubtractVector((*Runner)->node);
     
    626626  for(int i=0;i<NDIM;i++) // store indices of this cell
    627627    N[i] = LC->n[i];
    628   Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl;
     628  DoLog(1) && (Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl);
    629629
    630630  LC->GetNeighbourBounds(Nlower, Nupper);
     
    633633    for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
    634634      for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
    635         const LinkedNodes *List = LC->GetCurrentCell();
     635        const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
    636636        //Log() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl;
    637637        if (List != NULL) {
    638           for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
     638          for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    639639            helper.CopyVector(Point);
    640640            helper.SubtractVector((*Runner)->node);
     
    659659  // output
    660660  if (closestPoint != NULL) {
    661     Log() << Verbose(1) << "Closest point is " << *closestPoint;
     661    DoLog(1) && (Log() << Verbose(1) << "Closest point is " << *closestPoint);
    662662    if (SecondPoint != NULL)
    663       Log() << Verbose(0) << " and second closest is " << *SecondPoint;
    664     Log() << Verbose(0) << "." << endl;
     663      DoLog(0) && (Log() << Verbose(0) << " and second closest is " << *SecondPoint);
     664    DoLog(0) && (Log() << Verbose(0) << "." << endl);
    665665  }
    666666  return closestPoint;
     
    686686  Normal.VectorProduct(&OtherBaseline);
    687687  Normal.Normalize();
    688   Log() << Verbose(1) << "First direction is " << Baseline << ", second direction is " << OtherBaseline << ", normal of intersection plane is " << Normal << "." << endl;
     688  DoLog(1) && (Log() << Verbose(1) << "First direction is " << Baseline << ", second direction is " << OtherBaseline << ", normal of intersection plane is " << Normal << "." << endl);
    689689
    690690  // project one offset point of OtherBase onto this plane (and add plane offset vector)
     
    703703  Normal.CopyVector(Intersection);
    704704  Normal.SubtractVector(Base->endpoints[0]->node->node);
    705   Log() << Verbose(1) << "Found closest point on " << *Base << " at " << *Intersection << ", factor in line is " << fabs(Normal.ScalarProduct(&Baseline)/Baseline.NormSquared()) << "." << endl;
     705  DoLog(1) && (Log() << Verbose(1) << "Found closest point on " << *Base << " at " << *Intersection << ", factor in line is " << fabs(Normal.ScalarProduct(&Baseline)/Baseline.NormSquared()) << "." << endl);
    706706
    707707  return Intersection;
     
    764764    }
    765765  } else {
    766     eLog() << Verbose(1) << "Given vrmlfile is " << vrmlfile << "." << endl;
     766    DoeLog(1) && (eLog()<< Verbose(1) << "Given vrmlfile is " << vrmlfile << "." << endl);
    767767  }
    768768  delete(center);
     
    839839    *rasterfile << "9\n#  terminating special property\n";
    840840  } else {
    841     eLog() << Verbose(1) << "Given rasterfile is " << rasterfile << "." << endl;
     841    DoeLog(1) && (eLog()<< Verbose(1) << "Given rasterfile is " << rasterfile << "." << endl);
    842842  }
    843843  IncludeSphereinRaster3D(rasterfile, Tess, cloud);
     
    862862    } else {
    863863      *tecplot << N << "-";
    864       for (int i=0;i<3;i++)
    865         *tecplot << (i==0 ? "" : "_") << TesselStruct->LastTriangle->endpoints[i]->node->Name;
     864      if (TesselStruct->LastTriangle != NULL) {
     865        for (int i=0;i<3;i++)
     866          *tecplot << (i==0 ? "" : "_") << TesselStruct->LastTriangle->endpoints[i]->node->Name;
     867      } else {
     868        *tecplot << "none";
     869      }
    866870    }
    867871    *tecplot << "\", N=" << TesselStruct->PointsOnBoundary.size() << ", E=" << TesselStruct->TrianglesOnBoundary.size() << ", DATAPACKING=POINT, ZONETYPE=FETRIANGLE" << endl;
     
    881885    *tecplot << endl;
    882886    // print connectivity
    883     Log() << Verbose(1) << "The following triangles were created:" << endl;
     887    DoLog(1) && (Log() << Verbose(1) << "The following triangles were created:" << endl);
    884888    for (TriangleMap::const_iterator runner = TesselStruct->TrianglesOnBoundary.begin(); runner != TesselStruct->TrianglesOnBoundary.end(); runner++) {
    885       Log() << Verbose(1) << " " << runner->second->endpoints[0]->node->Name << "<->" << runner->second->endpoints[1]->node->Name << "<->" << runner->second->endpoints[2]->node->Name << endl;
     889      DoLog(1) && (Log() << Verbose(1) << " " << runner->second->endpoints[0]->node->Name << "<->" << runner->second->endpoints[1]->node->Name << "<->" << runner->second->endpoints[2]->node->Name << endl);
    886890      *tecplot << LookupList[runner->second->endpoints[0]->node->nr] << " " << LookupList[runner->second->endpoints[1]->node->nr] << " " << LookupList[runner->second->endpoints[2]->node->nr] << endl;
    887891    }
     
    904908  for (PointMap::const_iterator PointRunner = TesselStruct->PointsOnBoundary.begin(); PointRunner != TesselStruct->PointsOnBoundary.end(); PointRunner++) {
    905909    point = PointRunner->second;
    906     Log() << Verbose(1) << "INFO: Current point is " << *point << "." << endl;
     910    DoLog(1) && (Log() << Verbose(1) << "INFO: Current point is " << *point << "." << endl);
    907911    point->value = 0;
    908912    for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) {
     
    928932  int counter = 0;
    929933
    930   Log() << Verbose(1) << "Check: List of Baselines with not two connected triangles:" << endl;
     934  DoLog(1) && (Log() << Verbose(1) << "Check: List of Baselines with not two connected triangles:" << endl);
    931935  for (testline = TesselStruct->LinesOnBoundary.begin(); testline != TesselStruct->LinesOnBoundary.end(); testline++) {
    932936    if (testline->second->triangles.size() != 2) {
    933       Log() << Verbose(2) << *testline->second << "\t" << testline->second->triangles.size() << endl;
     937      DoLog(2) && (Log() << Verbose(2) << *testline->second << "\t" << testline->second->triangles.size() << endl);
    934938      counter++;
    935939    }
    936940  }
    937941  if (counter == 0) {
    938     Log() << Verbose(1) << "None." << endl;
     942    DoLog(1) && (Log() << Verbose(1) << "None." << endl);
    939943    result = true;
    940944  }
     
    951955  // check number of endpoints in *P
    952956  if (P->endpoints.size() != 4) {
    953     eLog() << Verbose(1) << "CountTrianglePairContainingPolygon works only on polygons with 4 nodes!" << endl;
     957    DoeLog(1) && (eLog()<< Verbose(1) << "CountTrianglePairContainingPolygon works only on polygons with 4 nodes!" << endl);
    954958    return 0;
    955959  }
     
    957961  // check number of triangles in *T
    958962  if (T->size() < 2) {
    959     eLog() << Verbose(1) << "Not enough triangles to have pairs!" << endl;
     963    DoeLog(1) && (eLog()<< Verbose(1) << "Not enough triangles to have pairs!" << endl);
    960964    return 0;
    961965  }
    962966
    963   Log() << Verbose(0) << "Polygon is " << *P << endl;
     967  DoLog(0) && (Log() << Verbose(0) << "Polygon is " << *P << endl);
    964968  // create each pair, get the endpoints and check whether *P is contained.
    965969  int counter = 0;
     
    977981        const int size = PairTrianglenodes.endpoints.size();
    978982        if (size == 4) {
    979           Log() << Verbose(0) << " Current pair of triangles: " << **Walker << "," << **PairWalker << " with " << size << " distinct endpoints:" << PairTrianglenodes << endl;
     983          DoLog(0) && (Log() << Verbose(0) << " Current pair of triangles: " << **Walker << "," << **PairWalker << " with " << size << " distinct endpoints:" << PairTrianglenodes << endl);
    980984          // now check
    981985          if (PairTrianglenodes.ContainsPresentTupel(P)) {
    982986            counter++;
    983             Log() << Verbose(0) << "  ACCEPT: Matches with " << *P << endl;
     987            DoLog(0) && (Log() << Verbose(0) << "  ACCEPT: Matches with " << *P << endl);
    984988          } else {
    985             Log() << Verbose(0) << "  REJECT: No match with " << *P << endl;
     989            DoLog(0) && (Log() << Verbose(0) << "  REJECT: No match with " << *P << endl);
    986990          }
    987991        } else {
    988           Log() << Verbose(0) << "  REJECT: Less than four endpoints." << endl;
     992          DoLog(0) && (Log() << Verbose(0) << "  REJECT: Less than four endpoints." << endl);
    989993        }
    990994      }
     
    10071011    if (P2->ContainsBoundaryPoint((*Runner))) {
    10081012      counter++;
    1009       Log() << Verbose(1) << *(*Runner) << " of second polygon is found in the first one." << endl;
     1013      DoLog(1) && (Log() << Verbose(1) << *(*Runner) << " of second polygon is found in the first one." << endl);
    10101014      return true;
    10111015    }
     
    10251029    Tester = P1->endpoints.insert((*Runner));
    10261030    if (Tester.second)
    1027       Log() << Verbose(0) << "Inserting endpoint " << *(*Runner) << " into first polygon." << endl;
     1031      DoLog(0) && (Log() << Verbose(0) << "Inserting endpoint " << *(*Runner) << " into first polygon." << endl);
    10281032  }
    10291033  P2->endpoints.clear();
  • src/unittests/AnalysisCorrelationToPointUnitTest.cpp

    r13d5a9 r5f612ee  
    8383
    8484  TestList = World::getInstance().getMolecules();
     85  TestList->insert(TestMolecule);
    8586  TestMolecule->ActiveFlag = true;
    86   TestList->insert(TestMolecule);
    8787
    8888  // init point
     
    122122  // put pair correlation into bins and check with no range
    123123  binmap = BinData( pointmap, 0.5, 0., 0. );
    124   CPPUNIT_ASSERT_EQUAL( (size_t)2, binmap->size() );
    125   //OutputCorrelation ( binmap );
     124  OutputCorrelation ( (ofstream *)&cout, binmap );
     125  CPPUNIT_ASSERT_EQUAL( (size_t)3, binmap->size() );
    126126  tester = binmap->begin();
    127127  CPPUNIT_ASSERT_EQUAL( 1., tester->first );
     
    135135  // ... and check with [0., 2.] range
    136136  binmap = BinData( pointmap, 0.5, 0., 2. );
     137  OutputCorrelation ( (ofstream *)&cout, binmap );
    137138  CPPUNIT_ASSERT_EQUAL( (size_t)5, binmap->size() );
    138   //OutputCorrelation ( binmap );
    139139  tester = binmap->begin();
    140140  CPPUNIT_ASSERT_EQUAL( 0., tester->first );
  • src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp

    r13d5a9 r5f612ee  
    7070
    7171  // construct molecule (tetraeder of hydrogens) base
     72  TestSurfaceMolecule = World::getInstance().createMolecule();
     73  Walker = World::getInstance().createAtom();
     74  Walker->type = hydrogen;
     75  Walker->node->Init(1., 0., 1. );
     76  TestSurfaceMolecule->AddAtom(Walker);
     77  Walker = World::getInstance().createAtom();
     78  Walker->type = hydrogen;
     79  Walker->node->Init(0., 1., 1. );
     80  TestSurfaceMolecule->AddAtom(Walker);
     81  Walker = World::getInstance().createAtom();
     82  Walker->type = hydrogen;
     83  Walker->node->Init(1., 1., 0. );
     84  TestSurfaceMolecule->AddAtom(Walker);
     85  Walker = World::getInstance().createAtom();
     86  Walker->type = hydrogen;
     87  Walker->node->Init(0., 0., 0. );
     88  TestSurfaceMolecule->AddAtom(Walker);
     89
     90  // check that TestMolecule was correctly constructed
     91  CPPUNIT_ASSERT_EQUAL( TestSurfaceMolecule->AtomCount, 4 );
     92
     93  TestList = World::getInstance().getMolecules();
     94  TestSurfaceMolecule->ActiveFlag = true;
     95  TestList->insert(TestSurfaceMolecule);
     96
     97  // init tesselation and linked cell
     98  Surface = new Tesselation;
     99  LC = new LinkedCell(TestSurfaceMolecule, 5.);
     100  FindNonConvexBorder(TestSurfaceMolecule, Surface, (const LinkedCell *&)LC, 2.5, NULL);
     101
     102  // add outer atoms
    72103  TestMolecule = World::getInstance().createMolecule();
    73104  Walker = World::getInstance().createAtom();
    74   Walker->type = hydrogen;
    75   Walker->node->Init(1., 0., 1. );
    76   TestMolecule->AddAtom(Walker);
    77   Walker = World::getInstance().createAtom();
    78   Walker->type = hydrogen;
    79   Walker->node->Init(0., 1., 1. );
    80   TestMolecule->AddAtom(Walker);
    81   Walker = World::getInstance().createAtom();
    82   Walker->type = hydrogen;
    83   Walker->node->Init(1., 1., 0. );
    84   TestMolecule->AddAtom(Walker);
    85   Walker = World::getInstance().createAtom();
    86   Walker->type = hydrogen;
    87   Walker->node->Init(0., 0., 0. );
    88   TestMolecule->AddAtom(Walker);
    89 
    90   // check that TestMolecule was correctly constructed
    91   CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
    92 
    93   TestList = World::getInstance().getMolecules();
     105  Walker->type = carbon;
     106  Walker->node->Init(4., 0., 4. );
     107  TestMolecule->AddAtom(Walker);
     108  Walker = World::getInstance().createAtom();
     109  Walker->type = carbon;
     110  Walker->node->Init(0., 4., 4. );
     111  TestMolecule->AddAtom(Walker);
     112  Walker = World::getInstance().createAtom();
     113  Walker->type = carbon;
     114  Walker->node->Init(4., 4., 0. );
     115  TestMolecule->AddAtom(Walker);
     116  // add inner atoms
     117  Walker = World::getInstance().createAtom();
     118  Walker->type = carbon;
     119  Walker->node->Init(0.5, 0.5, 0.5 );
     120  TestMolecule->AddAtom(Walker);
    94121  TestMolecule->ActiveFlag = true;
    95122  TestList->insert(TestMolecule);
    96 
    97   // init tesselation and linked cell
    98   Surface = new Tesselation;
    99   FindNonConvexBorder(TestMolecule, Surface, (const LinkedCell *&)LC, 2.5, NULL);
    100   LC = new LinkedCell(TestMolecule, 5.);
    101   CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() );
    102   CPPUNIT_ASSERT_EQUAL( (size_t)6, Surface->LinesOnBoundary.size() );
    103   CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->TrianglesOnBoundary.size() );
    104 
    105   // add outer atoms
    106   Walker = World::getInstance().createAtom();
    107   Walker->type = carbon;
    108   Walker->node->Init(4., 0., 4. );
    109   TestMolecule->AddAtom(Walker);
    110   Walker = World::getInstance().createAtom();
    111   Walker->type = carbon;
    112   Walker->node->Init(0., 4., 4. );
    113   TestMolecule->AddAtom(Walker);
    114   Walker = World::getInstance().createAtom();
    115   Walker->type = carbon;
    116   Walker->node->Init(4., 4., 0. );
    117   TestMolecule->AddAtom(Walker);
    118   // add inner atoms
    119   Walker = World::getInstance().createAtom();
    120   Walker->type = carbon;
    121   Walker->node->Init(0.5, 0.5, 0.5 );
    122   TestMolecule->AddAtom(Walker);
    123123
    124124  // init maps
     
    145145
    146146
     147/** Checks whether setup() does the right thing.
     148 */
     149void AnalysisCorrelationToSurfaceUnitTest::SurfaceTest()
     150{
     151  CPPUNIT_ASSERT_EQUAL( 4, TestSurfaceMolecule->AtomCount );
     152  CPPUNIT_ASSERT_EQUAL( 4, TestMolecule->AtomCount );
     153  CPPUNIT_ASSERT_EQUAL( (size_t)2, TestList->ListOfMolecules.size() );
     154  CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->PointsOnBoundary.size() );
     155  CPPUNIT_ASSERT_EQUAL( (size_t)6, Surface->LinesOnBoundary.size() );
     156  CPPUNIT_ASSERT_EQUAL( (size_t)4, Surface->TrianglesOnBoundary.size() );
     157};
     158
    147159void AnalysisCorrelationToSurfaceUnitTest::CorrelationToSurfaceTest()
    148160{
    149161  // do the pair correlation
    150162  surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC );
     163//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    151164  CPPUNIT_ASSERT( surfacemap != NULL );
    152165  CPPUNIT_ASSERT_EQUAL( (size_t)4, surfacemap->size() );
     
    158171  surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC );
    159172  // put pair correlation into bins and check with no range
     173//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    160174  binmap = BinData( surfacemap, 0.5, 0., 0. );
    161175  CPPUNIT_ASSERT_EQUAL( (size_t)1, binmap->size() );
    162   //OutputCorrelation ( binmap );
     176  OutputCorrelation ( (ofstream *)&cout, binmap );
    163177  tester = binmap->begin();
    164178  CPPUNIT_ASSERT_EQUAL( 0., tester->first );
     
    171185  BinPairMap::iterator tester;
    172186  surfacemap = CorrelationToSurface( TestList, hydrogen, Surface, LC );
     187//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    173188  // ... and check with [0., 2.] range
    174189  binmap = BinData( surfacemap, 0.5, 0., 2. );
    175190  CPPUNIT_ASSERT_EQUAL( (size_t)5, binmap->size() );
    176   //OutputCorrelation ( binmap );
     191//  OutputCorrelation ( (ofstream *)&cout, binmap );
    177192  tester = binmap->begin();
    178193  CPPUNIT_ASSERT_EQUAL( 0., tester->first );
     
    188203  BinPairMap::iterator tester;
    189204  surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC );
     205//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    190206  // put pair correlation into bins and check with no range
    191207  binmap = BinData( surfacemap, 0.5, 0., 0. );
    192   CPPUNIT_ASSERT_EQUAL( (size_t)2, binmap->size() );
    193   OutputCorrelation ( (ofstream *)&cout, binmap );
     208  //OutputCorrelation ( (ofstream *)&cout, binmap );
     209  CPPUNIT_ASSERT_EQUAL( (size_t)9, binmap->size() );
    194210  // inside point is first and must have negative value
    195   tester = binmap->lower_bound(2.95); // start depends on the min value and
     211  tester = binmap->lower_bound(4.25-0.5); // start depends on the min value and
    196212  CPPUNIT_ASSERT( tester != binmap->end() );
    197213  CPPUNIT_ASSERT_EQUAL( 3, tester->second );
    198214  // inner point
    199   tester = binmap->lower_bound(-0.5);
     215  tester = binmap->lower_bound(0.);
    200216  CPPUNIT_ASSERT( tester != binmap->end() );
    201217  CPPUNIT_ASSERT_EQUAL( 1, tester->second );
     
    206222  BinPairMap::iterator tester;
    207223  surfacemap = CorrelationToSurface( TestList, carbon, Surface, LC );
     224//  OutputCorrelationToSurface ( (ofstream *)&cout, surfacemap );
    208225  // ... and check with [0., 2.] range
    209226  binmap = BinData( surfacemap, 0.5, -2., 4. );
     227  //OutputCorrelation ( (ofstream *)&cout, binmap );
    210228  CPPUNIT_ASSERT_EQUAL( (size_t)13, binmap->size() );
    211   OutputCorrelation ( (ofstream *)&cout, binmap );
    212229  // three outside points
    213   tester = binmap->lower_bound(3.);
     230  tester = binmap->lower_bound(4.25-0.5);
    214231  CPPUNIT_ASSERT( tester != binmap->end() );
    215232  CPPUNIT_ASSERT_EQUAL( 3, tester->second );
    216233  // inner point
    217   tester = binmap->lower_bound(-0.5);
     234  tester = binmap->lower_bound(0.);
    218235  CPPUNIT_ASSERT( tester != binmap->end() );
    219236  CPPUNIT_ASSERT_EQUAL( 1, tester->second );
    220 
    221 };
     237};
  • src/unittests/AnalysisCorrelationToSurfaceUnitTest.hpp

    r13d5a9 r5f612ee  
    2323{
    2424    CPPUNIT_TEST_SUITE( AnalysisCorrelationToSurfaceUnitTest ) ;
     25    CPPUNIT_TEST ( SurfaceTest );
    2526    CPPUNIT_TEST ( CorrelationToSurfaceTest );
    2627    CPPUNIT_TEST ( CorrelationToSurfaceHydrogenBinNoRangeTest );
     
    3334      void setUp();
    3435      void tearDown();
     36      void SurfaceTest();
    3537      void CorrelationToSurfaceTest();
    3638      void CorrelationToSurfaceHydrogenBinNoRangeTest();
     
    4345      MoleculeListClass *TestList;
    4446      molecule *TestMolecule;
     47      molecule *TestSurfaceMolecule;
    4548      element *hydrogen;
    4649      element *carbon;
  • src/unittests/Makefile.am

    r13d5a9 r5f612ee  
    44AM_CXXFLAGS = $(CPPUNIT_CFLAGS)
    55
    6 MENUTESTS = ActionSequenceTest
     6MENUTESTS = \
     7  ActionSequenceTest
    78
    89TESTS = \
     
    1617  BondGraphUnitTest \
    1718  CacheableTest \
     19  CountBondsUnitTest \
    1820  GSLMatrixSymmetricUnitTest \
    1921  GSLMatrixUnitTest \
     
    2123  InfoUnitTest \
    2224  LinearSystemOfEquationsUnitTest \
     25  LinkedCellUnitTest \
    2326  ListOfBondsUnitTest \
    2427  LogUnitTest \
     
    3639  ${MENUTESTS}
    3740 
    38 
    39      
    4041 
    4142check_PROGRAMS = $(TESTS)
     
    5657  bondgraphunittest.cpp \
    5758  CacheableTest.cpp \
     59  CountBondsUnitTest.cpp \
    5860  gslmatrixsymmetricunittest.cpp \
    5961  gslmatrixunittest.cpp \
     
    6163  infounittest.cpp \
    6264  linearsystemofequationsunittest.cpp \
     65  LinkedCellUnitTest.cpp \
    6366  listofbondsunittest.cpp \
    6467  logunittest.cpp \
     
    7679
    7780TESTHEADERS = \
    78   analysis_correlation.hpp
     81  ActOnAllUnitTest.hpp \
     82  ActionSequenceTest.hpp \
     83  analysisbondsunittest.hpp \
     84  AnalysisCorrelationToPointUnitTest.hpp \
     85  AnalysisCorrelationToSurfaceUnitTest.hpp  \
     86  AnalysisPairCorrelationUnitTest.hpp \
     87  AtomDescriptorTest.hpp \
     88  atomsCalculationTest.hpp \
     89  bondgraphunittest.hpp \
     90  CacheableTest.hpp \
     91  CountBondsUnitTest.hpp \
     92  gslmatrixsymmetricunittest.hpp \
     93  gslmatrixunittest.hpp \
     94  gslvectorunittest.hpp \
     95  infounittest.hpp \
     96  linearsystemofequationsunittest.hpp \
     97  LinkedCellUnitTest.hpp \
     98  listofbondsunittest.hpp \
     99  logunittest.hpp \
     100  manipulateAtomsTest.hpp \
     101  memoryallocatorunittest.hpp  \
     102  memoryusageobserverunittest.hpp \
     103  MoleculeDescriptorTest.hpp \
     104  ObserverTest.hpp \
     105  SingletonTest.hpp \
     106  stackclassunittest.hpp \
     107  tesselationunittest.hpp \
     108  tesselation_boundarytriangleunittest.hpp \
     109  tesselation_insideoutsideunittest.hpp \
     110  vectorunittest.hpp
     111 
    79112
    80113ActOnAllUnitTest_SOURCES = UnitTestMain.cpp ../test/ActOnAllTest.hpp ActOnAllUnitTest.cpp ActOnAllUnitTest.hpp
     
    99132BondGraphUnitTest_LDADD = ${ALLLIBS}
    100133
     134CountBondsUnitTest_SOURCES = UnitTestMain.cpp CountBondsUnitTest.cpp CountBondsUnitTest.hpp
     135CountBondsUnitTest_LDADD = ${ALLLIBS}
     136
    101137GSLMatrixSymmetricUnitTest_SOURCES = UnitTestMain.cpp gslmatrixsymmetricunittest.cpp gslmatrixsymmetricunittest.hpp
    102138GSLMatrixSymmetricUnitTest_LDADD = ${GSLLIBS}
     
    114150LinearSystemOfEquationsUnitTest_LDADD = ${ALLLIBS}
    115151
     152LinkedCellUnitTest_SOURCES = UnitTestMain.cpp LinkedCellUnitTest.cpp LinkedCellUnitTest.hpp
     153LinkedCellUnitTest_LDADD = ${ALLLIBS}
     154
    116155ListOfBondsUnitTest_SOURCES = UnitTestMain.cpp listofbondsunittest.cpp listofbondsunittest.hpp
    117156ListOfBondsUnitTest_LDADD = ${ALLLIBS}
  • src/unittests/bondgraphunittest.cpp

    r13d5a9 r5f612ee  
    2121#include "bondgraph.hpp"
    2222#include "element.hpp"
     23#include "log.hpp"
    2324#include "molecule.hpp"
    2425#include "periodentafel.hpp"
     
    4849  hydrogen = new element;
    4950  hydrogen->Z = 1;
     51  hydrogen->CovalentRadius = 0.23;
     52  hydrogen->VanDerWaalsRadius = 1.09;
    5053  strcpy(hydrogen->name, "hydrogen");
    5154  strcpy(hydrogen->symbol, "H");
    5255  carbon = new element;
    5356  carbon->Z = 2;
     57  carbon->CovalentRadius = 0.68;
     58  carbon->VanDerWaalsRadius = 1.7;
    5459  strcpy(carbon->name, "carbon");
    5560  strcpy(carbon->symbol, "C");
     
    6469  TestMolecule = World::getInstance().createMolecule();
    6570  Walker = World::getInstance().createAtom();
    66   Walker->type = hydrogen;
     71  Walker->type = carbon;
    6772  Walker->node->Init(1., 0., 1. );
    6873  TestMolecule->AddAtom(Walker);
    6974  Walker = World::getInstance().createAtom();
    70   Walker->type = hydrogen;
     75  Walker->type = carbon;
    7176  Walker->node->Init(0., 1., 1. );
    7277  TestMolecule->AddAtom(Walker);
    7378  Walker = World::getInstance().createAtom();
    74   Walker->type = hydrogen;
     79  Walker->type = carbon;
    7580  Walker->node->Init(1., 1., 0. );
    7681  TestMolecule->AddAtom(Walker);
    7782  Walker = World::getInstance().createAtom();
    78   Walker->type = hydrogen;
     83  Walker->type = carbon;
    7984  Walker->node->Init(0., 0., 0. );
    8085  TestMolecule->AddAtom(Walker);
     
    8489
    8590  // create a small file with table
     91  dummyname = new string("dummy.dat");
    8692  filename = new string("test.dat");
    8793  ofstream test(filename->c_str());
     
    99105  remove(filename->c_str());
    100106  delete(filename);
     107  delete(dummyname);
    101108  delete(BG);
    102109
     
    122129/** UnitTest for BondGraphTest::ConstructBondGraph().
    123130 */
    124 void BondGraphTest::ConstructGraphTest()
     131void BondGraphTest::ConstructGraphFromTableTest()
    125132{
    126133  atom *Walker = TestMolecule->start->next;
     
    131138  CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );
    132139};
     140
     141/** UnitTest for BondGraphTest::ConstructBondGraph().
     142 */
     143void BondGraphTest::ConstructGraphFromCovalentRadiiTest()
     144{
     145  atom *Walker = TestMolecule->start->next;
     146  atom *Runner = TestMolecule->end->previous;
     147  CPPUNIT_ASSERT( TestMolecule->end != Walker );
     148  CPPUNIT_ASSERT_EQUAL( false , BG->LoadBondLengthTable(*dummyname) );
     149  CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) );
     150  CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );
     151};
     152
  • src/unittests/bondgraphunittest.hpp

    r13d5a9 r5f612ee  
    2323    CPPUNIT_TEST_SUITE( BondGraphTest) ;
    2424    CPPUNIT_TEST ( LoadTableTest );
    25     CPPUNIT_TEST ( ConstructGraphTest );
     25    CPPUNIT_TEST ( ConstructGraphFromTableTest );
     26    CPPUNIT_TEST ( ConstructGraphFromCovalentRadiiTest );
    2627    CPPUNIT_TEST_SUITE_END();
    2728
     
    3031      void tearDown();
    3132      void LoadTableTest();
    32       void ConstructGraphTest();
     33      void ConstructGraphFromTableTest();
     34      void ConstructGraphFromCovalentRadiiTest();
    3335
    3436private:
     
    4143      BondGraph *BG;
    4244      string *filename;
     45      string *dummyname;
    4346};
    4447
  • src/unittests/gslvectorunittest.cpp

    r13d5a9 r5f612ee  
    117117    CPPUNIT_ASSERT_EQUAL( (double)(3-j), v->Get(j) );
    118118};
     119
     120/** UnitTest for operators.
     121 */
     122void GSLVectorTest::OperatorIsTest()
     123{
     124  GSLVector zero(3);
     125  GSLVector unit(3);
     126  zero.SetZero();
     127  unit.SetZero();
     128  unit.Set(1,1.);
     129  // summation and scaling
     130  CPPUNIT_ASSERT_EQUAL( true, unit.IsOne() );
     131  CPPUNIT_ASSERT_EQUAL( false, zero.IsOne() );
     132  CPPUNIT_ASSERT_EQUAL( false, unit.IsZero() );
     133  CPPUNIT_ASSERT_EQUAL( true, zero.IsZero() );
     134};
     135
     136/** UnitTest for operators.
     137 */
     138void GSLVectorTest::OperatorAlgebraTest()
     139{
     140  GSLVector zero(3);
     141  GSLVector unit(3);
     142  zero.SetZero();
     143  unit.SetZero();
     144  unit.Set(1,1.);
     145  // summation and scaling
     146  CPPUNIT_ASSERT_EQUAL( true, (zero+unit).IsOne() );
     147  CPPUNIT_ASSERT_EQUAL( true, (zero+unit).IsOne() );
     148  CPPUNIT_ASSERT_EQUAL( true, (zero-unit).IsOne() );
     149  CPPUNIT_ASSERT_EQUAL( false, (zero-unit).IsZero() );
     150  CPPUNIT_ASSERT_EQUAL( true, (zero+zero).IsZero() );
     151  CPPUNIT_ASSERT_EQUAL( false, (unit*0.98).IsOne() );
     152  CPPUNIT_ASSERT_EQUAL( false, (0.98*unit).IsOne() );
     153  CPPUNIT_ASSERT_EQUAL( true, (unit*1.).IsOne() );
     154  CPPUNIT_ASSERT_EQUAL( true, (1.*unit).IsOne() );
     155
     156  CPPUNIT_ASSERT_EQUAL( unit, (zero+unit) );
     157  CPPUNIT_ASSERT_EQUAL( zero, (zero+zero) );
     158  CPPUNIT_ASSERT_EQUAL( unit, (unit+zero) );
     159
     160  unit += zero;
     161  CPPUNIT_ASSERT_EQUAL( true, unit.IsOne() );
     162  unit *= 1.;
     163  CPPUNIT_ASSERT_EQUAL( true, unit.IsOne() );
     164};
  • src/unittests/gslvectorunittest.hpp

    r13d5a9 r5f612ee  
    2222    CPPUNIT_TEST (CopyTest );
    2323    CPPUNIT_TEST (ExchangeTest );
     24    CPPUNIT_TEST (OperatorAlgebraTest );
     25    CPPUNIT_TEST (OperatorIsTest );
    2426    CPPUNIT_TEST_SUITE_END();
    2527
     
    3234    void CopyTest();
    3335    void ExchangeTest();
     36    void OperatorIsTest();
     37    void OperatorAlgebraTest();
    3438
    3539private:
  • src/unittests/logunittest.cpp

    r13d5a9 r5f612ee  
    4141{
    4242  logger::getInstance().setVerbosity(2);
    43   Log() << Verbose(0) << "Verbosity level is set to 2." << endl;
    44   Log() << Verbose(0) << "Test level 0" << endl;
    45   Log() << Verbose(1) << "Test level 1" << endl;
    46   Log() << Verbose(2) << "Test level 2" << endl;
    47   Log() << Verbose(3) << "Test level 3" << endl;
    48   Log() << Verbose(4) << "Test level 4" << endl;
     43  DoLog(0) && (Log() << Verbose(0) << "Verbosity level is set to 2." << endl);
     44  DoLog(0) && (Log() << Verbose(0) << "Test level 0" << endl);
     45  DoLog(1) && (Log() << Verbose(1) << "Test level 1" << endl);
     46  DoLog(2) && (Log() << Verbose(2) << "Test level 2" << endl);
     47  DoLog(3) && (Log() << Verbose(3) << "Test level 3" << endl);
     48  DoLog(4) && (Log() << Verbose(4) << "Test level 4" << endl);
    4949
    50   Log() << Verbose(0) << "Output a log message." << endl;
    51   eLog() << Verbose(0) << "Output an error message." << endl;
     50  DoLog(0) && (Log() << Verbose(0) << "Output a log message." << endl);
     51  DoeLog(0) && (eLog()<< Verbose(0) << "Output an error message." << endl);
    5252  setVerbosity(3);
    53   Log() << Verbose(4) << "This should not be printed." << endl;
    54   eLog() << Verbose(4) << "This should not be printed." << endl;
     53  DoLog(4) && (Log() << Verbose(4) << "This should not be printed." << endl);
     54  DoeLog(4) && (eLog()<< Verbose(4) << "This should not be printed." << endl);
    5555};
  • src/unittests/memoryallocatorunittest.cpp

    r13d5a9 r5f612ee  
    5252  char* buffer3 = NULL;
    5353  buffer3 = Malloc<char>(4, "");
    54   Log() << Verbose(0) << buffer3 << endl;
     54  DoLog(0) && (Log() << Verbose(0) << buffer3 << endl);
    5555  Free(&buffer3);
    5656
  • src/unittests/tesselation_boundarytriangleunittest.hpp

    r13d5a9 r5f612ee  
    3636      class BoundaryPointSet *points[3];
    3737      class TesselPoint *tesselpoints[3];
    38       LinkedNodes Corners;
     38      LinkedCell::LinkedNodes Corners;
    3939};
    4040
  • src/unittests/tesselation_insideoutsideunittest.cpp

    r13d5a9 r5f612ee  
    9898  while ((!TesselStruct->OpenLines.empty()) && (OneLoopWithoutSuccessFlag)) {
    9999    // 2a. fill all new OpenLines
    100     Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for candidates:" << endl;
     100    DoLog(1) && (Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for candidates:" << endl);
    101101    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++)
    102       Log() << Verbose(2) << *(Runner->second) << endl;
     102      DoLog(2) && (Log() << Verbose(2) << *(Runner->second) << endl);
    103103
    104104    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
     
    106106      if (baseline->pointlist.empty()) {
    107107        T = (((baseline->BaseLine->triangles.begin()))->second);
    108         Log() << Verbose(1) << "Finding best candidate for open line " << *baseline->BaseLine << " of triangle " << *T << endl;
     108        DoLog(1) && (Log() << Verbose(1) << "Finding best candidate for open line " << *baseline->BaseLine << " of triangle " << *T << endl);
    109109        TesselationFailFlag = TesselStruct->FindNextSuitableTriangle(*baseline, *T, SPHERERADIUS, LinkedList); //the line is there, so there is a triangle, but only one.
    110110      }
     
    113113    // 2b. search for smallest ShortestAngle among all candidates
    114114    double ShortestAngle = 4.*M_PI;
    115     Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for the best candidates:" << endl;
     115    DoLog(1) && (Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for the best candidates:" << endl);
    116116    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++)
    117       Log() << Verbose(2) << *(Runner->second) << endl;
     117      DoLog(2) && (Log() << Verbose(2) << *(Runner->second) << endl);
    118118
    119119    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
     
    127127      OneLoopWithoutSuccessFlag = false;
    128128    else {
    129       TesselStruct->AddCandidateTriangle(*baseline);
     129      TesselStruct->AddCandidatePolygon(*baseline, SPHERERADIUS, LinkedList);
    130130    }
    131131  }
     
    137137  delete(LinkedList);
    138138  delete(TesselStruct);
    139   for (LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) {
     139  for (LinkedCell::LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) {
    140140    delete((*Runner)->node);
    141141    delete(*Runner);
  • src/unittests/tesselation_insideoutsideunittest.hpp

    r13d5a9 r5f612ee  
    3131private:
    3232      class Tesselation *TesselStruct;
    33       LinkedNodes Corners;
     33      LinkedCell::LinkedNodes Corners;
    3434      class LinkedCell *LinkedList;
    3535};
  • src/unittests/tesselationunittest.cpp

    r13d5a9 r5f612ee  
    9595      OneLoopWithoutSuccessFlag = false;
    9696    else {
    97       TesselStruct->AddCandidateTriangle(*baseline);
     97      TesselStruct->AddCandidatePolygon(*baseline, SPHERERADIUS, LinkedList);
    9898    }
    9999  }
     
    105105  delete(LinkedList);
    106106  delete(TesselStruct);
    107   for (LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) {
     107  for (LinkedCell::LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) {
    108108    delete((*Runner)->node);
    109109    delete(*Runner);
  • src/unittests/tesselationunittest.hpp

    r13d5a9 r5f612ee  
    3434private:
    3535      class Tesselation *TesselStruct;
    36       LinkedNodes Corners;
     36      LinkedCell::LinkedNodes Corners;
    3737      class LinkedCell *LinkedList;
    3838};
  • src/vector.cpp

    r13d5a9 r5f612ee  
    1515#include "vector.hpp"
    1616#include "verbose.hpp"
     17#include "World.hpp"
    1718
    1819#include <gsl/gsl_linalg.h>
     
    2627 */
    2728Vector::Vector() { x[0] = x[1] = x[2] = 0.; };
     29
     30/** Constructor of class vector.
     31 */
     32Vector::Vector(const Vector * const a)
     33{
     34  x[0] = a->x[0];
     35  x[1] = a->x[1];
     36  x[2] = a->x[2];
     37};
     38
     39/** Constructor of class vector.
     40 */
     41Vector::Vector(const Vector &a)
     42{
     43  x[0] = a.x[0];
     44  x[1] = a.x[1];
     45  x[2] = a.x[2];
     46};
    2847
    2948/** Constructor of class vector.
     
    234253  Direction.SubtractVector(Origin);
    235254  Direction.Normalize();
    236   Log() << Verbose(1) << "INFO: Direction is " << Direction << "." << endl;
     255  DoLog(1) && (Log() << Verbose(1) << "INFO: Direction is " << Direction << "." << endl);
    237256  //Log() << Verbose(1) << "INFO: PlaneNormal is " << *PlaneNormal << " and PlaneOffset is " << *PlaneOffset << "." << endl;
    238257  factor = Direction.ScalarProduct(PlaneNormal);
    239258  if (fabs(factor) < MYEPSILON) { // Uniqueness: line parallel to plane?
    240     Log() << Verbose(1) << "BAD: Line is parallel to plane, no intersection." << endl;
     259    DoLog(1) && (Log() << Verbose(1) << "BAD: Line is parallel to plane, no intersection." << endl);
    241260    return false;
    242261  }
     
    245264  factor = helper.ScalarProduct(PlaneNormal)/factor;
    246265  if (fabs(factor) < MYEPSILON) { // Origin is in-plane
    247     Log() << Verbose(1) << "GOOD: Origin of line is in-plane." << endl;
     266    DoLog(1) && (Log() << Verbose(1) << "GOOD: Origin of line is in-plane." << endl);
    248267    CopyVector(Origin);
    249268    return true;
     
    252271  Direction.Scale(factor);
    253272  CopyVector(Origin);
    254   Log() << Verbose(1) << "INFO: Scaled direction is " << Direction << "." << endl;
     273  DoLog(1) && (Log() << Verbose(1) << "INFO: Scaled direction is " << Direction << "." << endl);
    255274  AddVector(&Direction);
    256275
     
    259278  helper.SubtractVector(PlaneOffset);
    260279  if (helper.ScalarProduct(PlaneNormal) < MYEPSILON) {
    261     Log() << Verbose(1) << "GOOD: Intersection is " << *this << "." << endl;
     280    DoLog(1) && (Log() << Verbose(1) << "GOOD: Intersection is " << *this << "." << endl);
    262281    return true;
    263282  } else {
    264     eLog() << Verbose(2) << "Intersection point " << *this << " is not on plane." << endl;
     283    DoeLog(2) && (eLog()<< Verbose(2) << "Intersection point " << *this << " is not on plane." << endl);
    265284    return false;
    266285  }
    267286};
    268287
    269 /** Calculates the minimum distance of this vector to the plane.
     288/** Calculates the minimum distance vector of this vector to the plane.
    270289 * \param *out output stream for debugging
    271290 * \param *PlaneNormal normal of plane
    272291 * \param *PlaneOffset offset of plane
    273  * \return distance to plane
    274  */
    275 double Vector::DistanceToPlane(const Vector * const PlaneNormal, const Vector * const PlaneOffset) const
     292 * \return distance vector onto to plane
     293 */
     294Vector Vector::GetDistanceVectorToPlane(const Vector * const PlaneNormal, const Vector * const PlaneOffset) const
    276295{
    277296  Vector temp;
     
    291310    sign = 0.;
    292311
    293   return (temp.Norm()*sign);
     312  temp.Normalize();
     313  temp.Scale(sign);
     314  return temp;
     315};
     316
     317/** Calculates the minimum distance of this vector to the plane.
     318 * \sa Vector::GetDistanceVectorToPlane()
     319 * \param *out output stream for debugging
     320 * \param *PlaneNormal normal of plane
     321 * \param *PlaneOffset offset of plane
     322 * \return distance to plane
     323 */
     324double Vector::DistanceToPlane(const Vector * const PlaneNormal, const Vector * const PlaneOffset) const
     325{
     326  return GetDistanceVectorToPlane(PlaneNormal,PlaneOffset).Norm();
    294327};
    295328
     
    319352 
    320353  //Log() << Verbose(1) << "Coefficent matrix is:" << endl;
     354  //ostream &output = Log() << Verbose(1);
    321355  //for (int i=0;i<4;i++) {
    322356  //  for (int j=0;j<4;j++)
    323   //    cout << "\t" << M->Get(i,j);
    324   //  cout << endl;
     357  //    output << "\t" << M->Get(i,j);
     358  //  output << endl;
    325359  //}
    326360  if (fabs(M->Determinant()) > MYEPSILON) {
    327     Log() << Verbose(1) << "Determinant of coefficient matrix is NOT zero." << endl;
     361    DoLog(1) && (Log() << Verbose(1) << "Determinant of coefficient matrix is NOT zero." << endl);
    328362    return false;
    329363  }
    330364  delete(M);
    331   Log() << Verbose(1) << "INFO: Line1a = " << *Line1a << ", Line1b = " << *Line1b << ", Line2a = " << *Line2a << ", Line2b = " << *Line2b << "." << endl;
     365  DoLog(1) && (Log() << Verbose(1) << "INFO: Line1a = " << *Line1a << ", Line1b = " << *Line1b << ", Line2a = " << *Line2a << ", Line2b = " << *Line2b << "." << endl);
    332366
    333367
     
    345379  d.CopyVector(Line2b);
    346380  d.SubtractVector(Line1b);
    347   Log() << Verbose(1) << "INFO: a = " << a << ", b = " << b << ", c = " << c << "." << endl;
     381  DoLog(1) && (Log() << Verbose(1) << "INFO: a = " << a << ", b = " << b << ", c = " << c << "." << endl);
    348382  if ((a.NormSquared() < MYEPSILON) || (b.NormSquared() < MYEPSILON)) {
    349383   Zero();
    350    Log() << Verbose(1) << "At least one of the lines is ill-defined, i.e. offset equals second vector." << endl;
     384   DoLog(1) && (Log() << Verbose(1) << "At least one of the lines is ill-defined, i.e. offset equals second vector." << endl);
    351385   return false;
    352386  }
     
    361395    if ((factor >= -MYEPSILON) && (factor - 1. < MYEPSILON)) {
    362396      CopyVector(Line2a);
    363       Log() << Verbose(1) << "Lines conincide." << endl;
     397      DoLog(1) && (Log() << Verbose(1) << "Lines conincide." << endl);
    364398      return true;
    365399    } else {
     
    369403      if ((factor >= -MYEPSILON) && (factor - 1. < MYEPSILON)) {
    370404        CopyVector(Line2b);
    371         Log() << Verbose(1) << "Lines conincide." << endl;
     405        DoLog(1) && (Log() << Verbose(1) << "Lines conincide." << endl);
    372406        return true;
    373407      }
    374408    }
    375     Log() << Verbose(1) << "Lines are parallel." << endl;
     409    DoLog(1) && (Log() << Verbose(1) << "Lines are parallel." << endl);
    376410    Zero();
    377411    return false;
     
    385419  temp2.CopyVector(&a);
    386420  temp2.VectorProduct(&b);
    387   Log() << Verbose(1) << "INFO: temp1 = " << temp1 << ", temp2 = " << temp2 << "." << endl;
     421  DoLog(1) && (Log() << Verbose(1) << "INFO: temp1 = " << temp1 << ", temp2 = " << temp2 << "." << endl);
    388422  if (fabs(temp2.NormSquared()) > MYEPSILON)
    389423    s = temp1.ScalarProduct(&temp2)/temp2.NormSquared();
    390424  else
    391425    s = 0.;
    392   Log() << Verbose(1) << "Factor s is " << temp1.ScalarProduct(&temp2) << "/" << temp2.NormSquared() << " = " << s << "." << endl;
     426  DoLog(1) && (Log() << Verbose(1) << "Factor s is " << temp1.ScalarProduct(&temp2) << "/" << temp2.NormSquared() << " = " << s << "." << endl);
    393427
    394428  // construct intersection
     
    396430  Scale(s);
    397431  AddVector(Line1a);
    398   Log() << Verbose(1) << "Intersection is at " << *this << "." << endl;
     432  DoLog(1) && (Log() << Verbose(1) << "Intersection is at " << *this << "." << endl);
    399433
    400434  return true;
     
    665699void Vector::Output() const
    666700{
    667   Log() << Verbose(0) << "(";
     701  DoLog(0) && (Log() << Verbose(0) << "(");
    668702  for (int i=0;i<NDIM;i++) {
    669     Log() << Verbose(0) << x[i];
     703    DoLog(0) && (Log() << Verbose(0) << x[i]);
    670704    if (i != 2)
    671       Log() << Verbose(0) << ",";
    672   }
    673   Log() << Verbose(0) << ")";
     705      DoLog(0) && (Log() << Verbose(0) << ",");
     706  }
     707  DoLog(0) && (Log() << Verbose(0) << ")");
    674708};
    675709
     
    780814      x[i] = C.x[i];
    781815  } else {
    782     eLog() << Verbose(1) << "inverse of matrix does not exists: det A = " << detA << "." << endl;
     816    DoeLog(1) && (eLog()<< Verbose(1) << "inverse of matrix does not exists: det A = " << detA << "." << endl);
    783817  }
    784818};
     
    806840  projection = ScalarProduct(n)/n->ScalarProduct(n);    // remove constancy from n (keep as logical one)
    807841  // withdraw projected vector twice from original one
    808   Log() << Verbose(1) << "Vector: ";
     842  DoLog(1) && (Log() << Verbose(1) << "Vector: ");
    809843  Output();
    810   Log() << Verbose(0) << "\t";
     844  DoLog(0) && (Log() << Verbose(0) << "\t");
    811845  for (int i=NDIM;i--;)
    812846    x[i] -= 2.*projection*n->x[i];
    813   Log() << Verbose(0) << "Projected vector: ";
     847  DoLog(0) && (Log() << Verbose(0) << "Projected vector: ");
    814848  Output();
    815   Log() << Verbose(0) << endl;
     849  DoLog(0) && (Log() << Verbose(0) << endl);
    816850};
    817851
     
    832866  x2.SubtractVector(y2);
    833867  if ((fabs(x1.Norm()) < MYEPSILON) || (fabs(x2.Norm()) < MYEPSILON) || (fabs(x1.Angle(&x2)) < MYEPSILON)) {
    834     eLog() << Verbose(2) << "Given vectors are linear dependent." << endl;
     868    DoeLog(2) && (eLog()<< Verbose(2) << "Given vectors are linear dependent." << endl);
    835869    return false;
    836870  }
     
    866900  Zero();
    867901  if ((fabs(x1.Norm()) < MYEPSILON) || (fabs(x2.Norm()) < MYEPSILON) || (fabs(x1.Angle(&x2)) < MYEPSILON)) {
    868     eLog() << Verbose(2) << "Given vectors are linear dependent." << endl;
     902    DoeLog(2) && (eLog()<< Verbose(2) << "Given vectors are linear dependent." << endl);
    869903    return false;
    870904  }
     
    917951  double norm;
    918952
    919   Log() << Verbose(4);
     953  DoLog(4) && (Log() << Verbose(4));
    920954  GivenVector->Output();
    921   Log() << Verbose(0) << endl;
     955  DoLog(0) && (Log() << Verbose(0) << endl);
    922956  for (j=NDIM;j--;)
    923957    Components[j] = -1;
     
    926960    if (fabs(GivenVector->x[j]) > MYEPSILON)
    927961      Components[Last++] = j;
    928   Log() << Verbose(4) << Last << " Components != 0: (" << Components[0] << "," << Components[1] << "," << Components[2] << ")" << endl;
     962  DoLog(4) && (Log() << Verbose(4) << Last << " Components != 0: (" << Components[0] << "," << Components[1] << "," << Components[2] << ")" << endl);
    929963
    930964  switch(Last) {
     
    9761010
    9771011  for (j=0;j<num;j++) {
    978     Log() << Verbose(1) << j << "th atom's vector: ";
     1012    DoLog(1) && (Log() << Verbose(1) << j << "th atom's vector: ");
    9791013    (vectors[j])->Output();
    980     Log() << Verbose(0) << endl;
     1014    DoLog(0) && (Log() << Verbose(0) << endl);
    9811015  }
    9821016
     
    11041138    j += i+1;
    11051139    do {
    1106       Log() << Verbose(0) << coords[i] << "[0.." << cell_size[j] << "]: ";
     1140      DoLog(0) && (Log() << Verbose(0) << coords[i] << "[0.." << cell_size[j] << "]: ");
    11071141      cin >> x[i];
    11081142    } while (((x[i] < 0) || (x[i] >= cell_size[j])) && (check));
     
    11351169  B2 = cos(beta) * x2->Norm() * c;
    11361170  C = c * c;
    1137   Log() << Verbose(2) << "A " << A << "\tB " << B1 << "\tC " << C << endl;
     1171  DoLog(2) && (Log() << Verbose(2) << "A " << A << "\tB " << B1 << "\tC " << C << endl);
    11381172  int flag = 0;
    11391173  if (fabs(x1->x[0]) < MYEPSILON) { // check for zero components for the later flipping and back-flipping
     
    11741208  D2 = -y->x[0]/x1->x[0]*x1->x[2]+y->x[2];
    11751209  D3 = y->x[0]/x1->x[0]*A-B1;
    1176   Log() << Verbose(2) << "D1 " << D1 << "\tD2 " << D2 << "\tD3 " << D3 << "\n";
     1210  DoLog(2) && (Log() << Verbose(2) << "D1 " << D1 << "\tD2 " << D2 << "\tD3 " << D3 << "\n");
    11771211  if (fabs(D1) < MYEPSILON) {
    1178     Log() << Verbose(2) << "D1 == 0!\n";
     1212    DoLog(2) && (Log() << Verbose(2) << "D1 == 0!\n");
    11791213    if (fabs(D2) > MYEPSILON) {
    1180       Log() << Verbose(3) << "D2 != 0!\n";
     1214      DoLog(3) && (Log() << Verbose(3) << "D2 != 0!\n");
    11811215      x[2] = -D3/D2;
    11821216      E1 = A/x1->x[0] + x1->x[2]/x1->x[0]*D3/D2;
    11831217      E2 = -x1->x[1]/x1->x[0];
    1184       Log() << Verbose(3) << "E1 " << E1 << "\tE2 " << E2 << "\n";
     1218      DoLog(3) && (Log() << Verbose(3) << "E1 " << E1 << "\tE2 " << E2 << "\n");
    11851219      F1 = E1*E1 + 1.;
    11861220      F2 = -E1*E2;
    11871221      F3 = E1*E1 + D3*D3/(D2*D2) - C;
    1188       Log() << Verbose(3) << "F1 " << F1 << "\tF2 " << F2 << "\tF3 " << F3 << "\n";
     1222      DoLog(3) && (Log() << Verbose(3) << "F1 " << F1 << "\tF2 " << F2 << "\tF3 " << F3 << "\n");
    11891223      if (fabs(F1) < MYEPSILON) {
    1190         Log() << Verbose(4) << "F1 == 0!\n";
    1191         Log() << Verbose(4) << "Gleichungssystem linear\n";
     1224        DoLog(4) && (Log() << Verbose(4) << "F1 == 0!\n");
     1225        DoLog(4) && (Log() << Verbose(4) << "Gleichungssystem linear\n");
    11921226        x[1] = F3/(2.*F2);
    11931227      } else {
    11941228        p = F2/F1;
    11951229        q = p*p - F3/F1;
    1196         Log() << Verbose(4) << "p " << p << "\tq " << q << endl;
     1230        DoLog(4) && (Log() << Verbose(4) << "p " << p << "\tq " << q << endl);
    11971231        if (q < 0) {
    1198           Log() << Verbose(4) << "q < 0" << endl;
     1232          DoLog(4) && (Log() << Verbose(4) << "q < 0" << endl);
    11991233          return false;
    12001234        }
     
    12031237      x[0] =  A/x1->x[0] - x1->x[1]/x1->x[0]*x[1] + x1->x[2]/x1->x[0]*x[2];
    12041238    } else {
    1205       Log() << Verbose(2) << "Gleichungssystem unterbestimmt\n";
     1239      DoLog(2) && (Log() << Verbose(2) << "Gleichungssystem unterbestimmt\n");
    12061240      return false;
    12071241    }
     
    12091243    E1 = A/x1->x[0]+x1->x[1]/x1->x[0]*D3/D1;
    12101244    E2 = x1->x[1]/x1->x[0]*D2/D1 - x1->x[2];
    1211     Log() << Verbose(2) << "E1 " << E1 << "\tE2 " << E2 << "\n";
     1245    DoLog(2) && (Log() << Verbose(2) << "E1 " << E1 << "\tE2 " << E2 << "\n");
    12121246    F1 = E2*E2 + D2*D2/(D1*D1) + 1.;
    12131247    F2 = -(E1*E2 + D2*D3/(D1*D1));
    12141248    F3 = E1*E1 + D3*D3/(D1*D1) - C;
    1215     Log() << Verbose(2) << "F1 " << F1 << "\tF2 " << F2 << "\tF3 " << F3 << "\n";
     1249    DoLog(2) && (Log() << Verbose(2) << "F1 " << F1 << "\tF2 " << F2 << "\tF3 " << F3 << "\n");
    12161250    if (fabs(F1) < MYEPSILON) {
    1217       Log() << Verbose(3) << "F1 == 0!\n";
    1218       Log() << Verbose(3) << "Gleichungssystem linear\n";
     1251      DoLog(3) && (Log() << Verbose(3) << "F1 == 0!\n");
     1252      DoLog(3) && (Log() << Verbose(3) << "Gleichungssystem linear\n");
    12191253      x[2] = F3/(2.*F2);
    12201254    } else {
    12211255      p = F2/F1;
    12221256      q = p*p - F3/F1;
    1223       Log() << Verbose(3) << "p " << p << "\tq " << q << endl;
     1257      DoLog(3) && (Log() << Verbose(3) << "p " << p << "\tq " << q << endl);
    12241258      if (q < 0) {
    1225         Log() << Verbose(3) << "q < 0" << endl;
     1259        DoLog(3) && (Log() << Verbose(3) << "q < 0" << endl);
    12261260        return false;
    12271261      }
     
    12611295    for (j=2;j>=0;j--) {
    12621296      k = (i & pot(2,j)) << j;
    1263       Log() << Verbose(2) << "k " << k << "\tpot(2,j) " << pot(2,j) << endl;
     1297      DoLog(2) && (Log() << Verbose(2) << "k " << k << "\tpot(2,j) " << pot(2,j) << endl);
    12641298      sign[j] = (k == 0) ? 1. : -1.;
    12651299    }
    1266     Log() << Verbose(2) << i << ": sign matrix is " << sign[0] << "\t" << sign[1] << "\t" << sign[2] << "\n";
     1300    DoLog(2) && (Log() << Verbose(2) << i << ": sign matrix is " << sign[0] << "\t" << sign[1] << "\t" << sign[2] << "\n");
    12671301    // apply sign matrix
    12681302    for (j=NDIM;j--;)
     
    12701304    // calculate angle and check
    12711305    ang = x2->Angle (this);
    1272     Log() << Verbose(1) << i << "th angle " << ang << "\tbeta " << cos(beta) << " :\t";
     1306    DoLog(1) && (Log() << Verbose(1) << i << "th angle " << ang << "\tbeta " << cos(beta) << " :\t");
    12731307    if (fabs(ang - cos(beta)) < MYEPSILON) {
    12741308      break;
  • src/vector.hpp

    r13d5a9 r5f612ee  
    2727
    2828  Vector();
     29  Vector(const Vector * const a);
     30  Vector(const Vector &a);
    2931  Vector(const double x1, const double x2, const double x3);
    3032  ~Vector();
     
    6769  void LinearCombinationOfVectors(const Vector * const x1, const Vector * const x2, const Vector * const x3, const double * const factors);
    6870  double CutsPlaneAt(const Vector * const A, const Vector * const B, const Vector * const C) const;
     71  Vector GetDistanceVectorToPlane(const Vector * const PlaneNormal, const Vector * const PlaneOffset) const;
    6972  bool GetIntersectionWithPlane(const Vector * const PlaneNormal, const Vector * const PlaneOffset, const Vector * const Origin, const Vector * const LineVector);
    7073  bool GetIntersectionOfTwoLinesOnPlane(const Vector * const Line1a, const Vector * const Line1b, const Vector * const Line2a, const Vector * const Line2b, const Vector *Normal = NULL);
  • src/verbose.cpp

    r13d5a9 r5f612ee  
    1717
    1818/** States whether current output message should be print or not.
    19  * Compares Verbose::Verbosity against \a verbosityLevel.
     19 * Compares Verbose::Verbosity plus Info::verbosity against \a verbosityLevel.
    2020 * \param verbosityLevel given global level of verbosity
    2121 * \return true - do output, false - don't
     
    2626};
    2727
     28/** States whether current error output message should be print or not.
     29 * Compares Verbose::Verbosity against \a verbosityLevel.
     30 * \param verbosityLevel given global level of verbosity
     31 * \return true - do output, false - don't
     32 */
     33bool Verbose::DoErrorOutput(int verbosityLevel) const
     34{
     35  return (verbosityLevel >= Verbosity);
     36};
    2837
    2938/** Operator for the Verbose(arg) call.
  • src/verbose.hpp

    r13d5a9 r5f612ee  
    3737    ostream& print (ostream &ost) const;
    3838    bool DoOutput(int verbosityLevel) const;
     39    bool DoErrorOutput(int verbosityLevel) const;
    3940  private:
    4041    int Verbosity;
  • tests/Tesselations/defs.in

    r13d5a9 r5f612ee  
    2626        if $testdir_exists; then :; else
    2727                mkdir $testdir
    28                 CLEANUP="rm -rf $testdir; $CLEANUP"
     28                CLEANUP="$CLEANUP; rmdir $testdir"
    2929        fi
    3030        cp  @srcdir@/$testdir/* $testdir/
    3131        cd $testdir
    3232        CLEANUP="rm -f stderr stdout diffstderr diffstdout; cd ..; $CLEANUP"
    33         CLEANUP="rm -f *.conf*; $CLEANUP"
     33        CLEANUP="rm -f *.conf*; rm -f NonConvexEnvelope*; rm -f ${testdir}.xyz; rm -f ${testdir}.dbond; $CLEANUP"
    3434fi
    3535
  • tests/regression/Tesselation/3/post/NonConvexEnvelope.dat

    r13d5a9 r5f612ee  
    848430 36 39
    858527 30 39
     8627 30 39
     8716 27 30
     8816 18 30
     8916 18 27
     9018 27 33
     9118 23 33
    86926 7 24
    87936 7 14
     
    951015 7 11
    961022 5 7
    97 27 30 39
    98 16 27 30
    99 16 18 30
    100 16 18 27
    101 18 27 33
    102 18 23 33
    10310336 38 39
    10410436 38 42
  • tests/regression/Tesselation/3/post/NonConvexEnvelope.r3d

    r13d5a9 r5f612ee  
    230230  2.58823 2.50762 1.23707       -2.87097 2.29272 -0.0233288     -4.04457 4.49292 -0.178529      1. 0. 0.
    2312311
     232  2.58823 2.50762 1.23707       -2.87097 2.29272 -0.0233288     -4.04457 4.49292 -0.178529      1. 0. 0.
     2331
     234  1.15633 1.11082 0.326671      2.58823 2.50762 1.23707         -2.87097 2.29272 -0.0233288     1. 0. 0.
     2351
     236  1.15633 1.11082 0.326671      1.03283 1.01972 -2.14533        -2.87097 2.29272 -0.0233288     1. 0. 0.
     2371
     238  1.15633 1.11082 0.326671      1.03283 1.01972 -2.14533        2.58823 2.50762 1.23707         1. 0. 0.
     2391
     240  1.03283 1.01972 -2.14533      2.58823 2.50762 1.23707         5.11553 2.70122 -0.710229       1. 0. 0.
     2411
     242  1.03283 1.01972 -2.14533      3.62023 1.25552 -2.86813        5.11553 2.70122 -0.710229       1. 0. 0.
     2431
    232244  -0.759066 -0.265179 1.48487   -0.287266 -1.67078 2.48017      -3.66127 0.565021 1.57007       1. 0. 0.
    2332451
     
    2512631
    252264  0.790434 -3.69418 1.29027     -1.52417 -3.64138 0.503471      -0.287266 -1.67078 2.48017      1. 0. 0.
    253 1
    254   2.58823 2.50762 1.23707       -2.87097 2.29272 -0.0233288     -4.04457 4.49292 -0.178529      1. 0. 0.
    255 1
    256   1.15633 1.11082 0.326671      2.58823 2.50762 1.23707         -2.87097 2.29272 -0.0233288     1. 0. 0.
    257 1
    258   1.15633 1.11082 0.326671      1.03283 1.01972 -2.14533        -2.87097 2.29272 -0.0233288     1. 0. 0.
    259 1
    260   1.15633 1.11082 0.326671      1.03283 1.01972 -2.14533        2.58823 2.50762 1.23707         1. 0. 0.
    261 1
    262   1.03283 1.01972 -2.14533      2.58823 2.50762 1.23707         5.11553 2.70122 -0.710229       1. 0. 0.
    263 1
    264   1.03283 1.01972 -2.14533      3.62023 1.25552 -2.86813        5.11553 2.70122 -0.710229       1. 0. 0.
    2652651
    266266  -4.83487 2.76522 1.41487      -5.81017 4.57652 0.0304712      -4.04457 4.49292 -0.178529      1. 0. 0.
Note: See TracChangeset for help on using the changeset viewer.