Changes in / [70378e:d6c485]


Ignore:
Location:
src
Files:
4 added
61 edited

Legend:

Unmodified
Added
Removed
  • src/World.cpp

    r70378e rd6c485  
    66 */
    77
     8#include <string.h>
     9
     10#include "defs.hpp"
    811#include "World.hpp"
    912
    1013double *World::cell_size = 0;
     14char *World::DefaultName = 0;
    1115
    1216/** Constructor of World.
     
    1620{
    1721  cell_size = new double[6];
     22  cell_size[0] = 20.;
     23  cell_size[1] = 0.;
     24  cell_size[2] = 20.;
     25  cell_size[3] = 0.;
     26  cell_size[4] = 0.;
     27  cell_size[5] = 20.;
     28  DefaultName = new char[MAXSTRINGSIZE];
     29  strcpy(DefaultName, "none");
    1830};
    1931
     
    2436{
    2537  delete[](cell_size);
     38  delete[](DefaultName);
    2639};
    2740
  • src/World.hpp

    r70378e rd6c485  
    3232
    3333  static double *cell_size;
     34  static char *DefaultName;
    3435
    3536private:
  • src/analysis_bonds.cpp

    r70378e rd6c485  
    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

    r70378e rd6c485  
    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

    r70378e rd6c485  
    3636
    3737  if (molecules->ListOfMolecules.empty()) {
    38     eLog() << Verbose(1) <<"No molecule given." << endl;
     38    DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl);
    3939    return outmap;
    4040  }
     
    4242  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    4343    if ((*MolWalker)->ActiveFlag) {
    44       eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    45       atom *Walker = (*MolWalker)->start;
    46       while (Walker->next != (*MolWalker)->end) {
    47         Walker = Walker->next;
    48         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);
    4949        if ((type1 == NULL) || (Walker->type == type1)) {
    5050          for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++)
    5151            if ((*MolOtherWalker)->ActiveFlag) {
    52               Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl;
     52              DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
    5353              atom *OtherWalker = (*MolOtherWalker)->start;
    5454              while (OtherWalker->next != (*MolOtherWalker)->end) { // only go up to Walker
    5555                OtherWalker = OtherWalker->next;
    56                 Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl;
     56                DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl);
    5757                if (Walker->nr < OtherWalker->nr)
    5858                  if ((type2 == NULL) || (OtherWalker->type == type2)) {
     
    9292
    9393  if (molecules->ListOfMolecules.empty()) {
    94     eLog() << Verbose(1) <<"No molecule given." << endl;
     94    DoeLog(1) && (eLog()<< Verbose(1) <<"No molecule given." << endl);
    9595    return outmap;
    9696  }
     
    100100      double * FullMatrix = ReturnFullMatrixforSymmetric(World::get()->cell_size);
    101101      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    102       eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    103       atom *Walker = (*MolWalker)->start;
    104       while (Walker->next != (*MolWalker)->end) {
    105         Walker = Walker->next;
    106         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);
    107107        if ((type1 == NULL) || (Walker->type == type1)) {
    108108          periodicX.CopyVector(Walker->node);
     
    117117                for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++)
    118118                  if ((*MolOtherWalker)->ActiveFlag) {
    119                     Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl;
     119                    DoLog(2) && (Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl);
    120120                    atom *OtherWalker = (*MolOtherWalker)->start;
    121121                    while (OtherWalker->next != (*MolOtherWalker)->end) { // only go up to Walker
    122122                      OtherWalker = OtherWalker->next;
    123                       Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl;
     123                      DoLog(3) && (Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl);
    124124                      if (Walker->nr < OtherWalker->nr)
    125125                        if ((type2 == NULL) || (OtherWalker->type == type2)) {
     
    164164
    165165  if (molecules->ListOfMolecules.empty()) {
    166     Log() << Verbose(1) <<"No molecule given." << endl;
     166    DoLog(1) && (Log() << Verbose(1) <<"No molecule given." << endl);
    167167    return outmap;
    168168  }
     
    170170  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    171171    if ((*MolWalker)->ActiveFlag) {
    172       Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    173       atom *Walker = (*MolWalker)->start;
    174       while (Walker->next != (*MolWalker)->end) {
    175         Walker = Walker->next;
    176         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);
    177177        if ((type == NULL) || (Walker->type == type)) {
    178178          distance = Walker->node->PeriodicDistance(point, World::get()->cell_size);
    179           Log() << Verbose(4) << "Current distance is " << distance << "." << endl;
     179          DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
    180180          outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) );
    181181        }
     
    204204
    205205  if (molecules->ListOfMolecules.empty()) {
    206     Log() << Verbose(1) <<"No molecule given." << endl;
     206    DoLog(1) && (Log() << Verbose(1) <<"No molecule given." << endl);
    207207    return outmap;
    208208  }
     
    212212      double * FullMatrix = ReturnFullMatrixforSymmetric(World::get()->cell_size);
    213213      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    214       Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    215       atom *Walker = (*MolWalker)->start;
    216       while (Walker->next != (*MolWalker)->end) {
    217         Walker = Walker->next;
    218         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);
    219219        if ((type == NULL) || (Walker->type == type)) {
    220220          periodicX.CopyVector(Walker->node);
     
    228228                checkX.MatrixMultiplication(FullMatrix);
    229229                distance = checkX.Distance(point);
    230                 Log() << Verbose(4) << "Current distance is " << distance << "." << endl;
     230                DoLog(4) && (Log() << Verbose(4) << "Current distance is " << distance << "." << endl);
    231231                outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) );
    232232              }
     
    257257
    258258  if ((Surface == NULL) || (LC == NULL) || (molecules->ListOfMolecules.empty())) {
    259     eLog() << 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);
    260260    return outmap;
    261261  }
     
    263263  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    264264    if ((*MolWalker)->ActiveFlag) {
    265       Log() << Verbose(1) << "Current molecule is " << (*MolWalker)->name << "." << endl;
     265      DoLog(1) && (Log() << Verbose(1) << "Current molecule is " << (*MolWalker)->name << "." << endl);
    266266      atom *Walker = (*MolWalker)->start;
    267267      while (Walker->next != (*MolWalker)->end) {
     
    276276      }
    277277    } else
    278       Log() << Verbose(1) << "molecule " << (*MolWalker)->name << " is not active." << endl;
     278      DoLog(1) && (Log() << Verbose(1) << "molecule " << (*MolWalker)->name << " is not active." << endl);
    279279
    280280
     
    307307
    308308  if ((Surface == NULL) || (LC == NULL) || (molecules->ListOfMolecules.empty())) {
    309     Log() << Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl;
     309    DoLog(1) && (Log() << Verbose(1) <<"No Tesselation, no LinkedCell or no molecule given." << endl);
    310310    return outmap;
    311311  }
     
    317317      double * FullMatrix = ReturnFullMatrixforSymmetric(World::get()->cell_size);
    318318      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    319       Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    320       atom *Walker = (*MolWalker)->start;
    321       while (Walker->next != (*MolWalker)->end) {
    322         Walker = Walker->next;
    323         Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
     319      DoLog(2) && (Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl);
     320      atom *Walker = (*MolWalker)->start;
     321      while (Walker->next != (*MolWalker)->end) {
     322        Walker = Walker->next;
     323        DoLog(3) && (Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl);
    324324        if ((type == NULL) || (Walker->type == type)) {
    325325          periodicX.CopyVector(Walker->node);
     
    333333                checkX.AddVector(&periodicX);
    334334                checkX.MatrixMultiplication(FullMatrix);
    335                 triangle = Surface->FindClosestTriangleToVector(&checkX, LC);
    336                 distance = Surface->GetDistanceSquaredToTriangle(checkX, triangle);
     335                TriangleIntersectionList Intersections(&checkX,Surface,LC);
     336                distance = Intersections.GetSmallestDistance();
     337                triangle = Intersections.GetClosestTriangle();
    337338                if ((ShortestDistance == -1.) || (distance < ShortestDistance)) {
    338339                  ShortestDistance = distance;
     
    341342              }
    342343          // insert
    343           ShortestDistance = sqrt(ShortestDistance);
    344344          outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (Walker, ShortestTriangle) ) );
    345345          //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl;
     
    353353};
    354354
    355 /** Returns the start of the bin for a given value.
     355/** Returns the index of the bin for a given value.
    356356 * \param value value whose bin to look for
    357357 * \param BinWidth width of bin
    358358 * \param BinStart first bin
    359359 */
    360 double GetBin ( const double value, const double BinWidth, const double BinStart )
    361 {
    362   Info FunctionInfo(__func__);
    363   double bin =(double) (floor((value - BinStart)/BinWidth));
    364   return (bin*BinWidth+BinStart);
     360int GetBin ( const double value, const double BinWidth, const double BinStart )
     361{
     362  Info FunctionInfo(__func__);
     363  int bin =(int) (floor((value - BinStart)/BinWidth));
     364  return (bin);
    365365};
    366366
  • src/analysis_correlation.hpp

    r70378e rd6c485  
    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

    r70378e rd6c485  
    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_bondedparticle.cpp

    r70378e rd6c485  
    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

    r70378e rd6c485  
    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

    r70378e rd6c485  
    2222ostream & operator << (ostream &ost, const ParticleInfo &a)
    2323{
    24   ost << "[" << a.Name << "|" << &a << "]";
     24  if (a.Name == NULL)
     25    ost << "[NULL]";
     26  else
     27    ost << "[" << a.Name << "|" << &a << "]";
    2528  return ost;
    2629};
     
    2831ostream & ParticleInfo::operator << (ostream &ost) const
    2932{
    30   ost << "[" << Name << "|" << this << "]";
     33  if (Name == NULL)
     34    ost << "[NULL]";
     35  else
     36    ost << "[" << Name << "|" << this << "]";
    3137  return ost;
    3238};
  • src/atom_trajectoryparticle.cpp

    r70378e rd6c485  
    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

    r70378e rd6c485  
    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

    r70378e rd6c485  
    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

    r70378e rd6c485  
    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
    r70378e rd6c485  
    5757  } else {
    5858    BoundaryPoints = BoundaryPtr;
    59     Log() << Verbose(0) << "Using given boundary points set." << endl;
     59    DoLog(0) && (Log() << Verbose(0) << "Using given boundary points set." << endl);
    6060  }
    6161  // determine biggest "diameter" of cluster for each axis
     
    163163    AngleReferenceNormalVector.x[(axis + 2) % NDIM] = 1.;
    164164
    165     Log() << Verbose(1) << "Axisvector is " << AxisVector << " and AngleReferenceVector is " << AngleReferenceVector << ", and AngleReferenceNormalVector is " << AngleReferenceNormalVector << "." << endl;
     165    DoLog(1) && (Log() << Verbose(1) << "Axisvector is " << AxisVector << " and AngleReferenceVector is " << AngleReferenceVector << ", and AngleReferenceNormalVector is " << AngleReferenceNormalVector << "." << endl);
    166166
    167167    // 3b. construct set of all points, transformed into cylindrical system and with left and right neighbours
     
    184184        angle = 2. * M_PI - angle;
    185185      }
    186       Log() << Verbose(1) << "Inserting " << *Walker << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl;
     186      DoLog(1) && (Log() << Verbose(1) << "Inserting " << *Walker << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl);
    187187      BoundaryTestPair = BoundaryPoints[axis].insert(BoundariesPair(angle, DistancePair (radius, Walker)));
    188188      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;
     189        DoLog(2) && (Log() << Verbose(2) << "Encountered two vectors whose projection onto axis " << axis << " is equal: " << endl);
     190        DoLog(2) && (Log() << Verbose(2) << "Present vector: " << *BoundaryTestPair.first->second.second << endl);
     191        DoLog(2) && (Log() << Verbose(2) << "New vector: " << *Walker << endl);
    192192        const double ProjectedVectorNorm = ProjectedVector.NormSquared();
    193193        if ((ProjectedVectorNorm - BoundaryTestPair.first->second.first) > MYEPSILON) {
    194194          BoundaryTestPair.first->second.first = ProjectedVectorNorm;
    195195          BoundaryTestPair.first->second.second = Walker;
    196           Log() << Verbose(2) << "Keeping new vector due to larger projected distance " << ProjectedVectorNorm << "." << endl;
     196          DoLog(2) && (Log() << Verbose(2) << "Keeping new vector due to larger projected distance " << ProjectedVectorNorm << "." << endl);
    197197        } else if (fabs(ProjectedVectorNorm - BoundaryTestPair.first->second.first) < MYEPSILON) {
    198198          helper.CopyVector(&Walker->x);
     
    203203          if (helper.NormSquared() < oldhelperNorm) {
    204204            BoundaryTestPair.first->second.second = Walker;
    205             Log() << Verbose(2) << "Keeping new vector due to larger distance to molecule center " << helper.NormSquared() << "." << endl;
     205            DoLog(2) && (Log() << Verbose(2) << "Keeping new vector due to larger distance to molecule center " << helper.NormSquared() << "." << endl);
    206206          } else {
    207             Log() << Verbose(2) << "Keeping present vector due to larger distance to molecule center " << oldhelperNorm << "." << endl;
     207            DoLog(2) && (Log() << Verbose(2) << "Keeping present vector due to larger distance to molecule center " << oldhelperNorm << "." << endl);
    208208          }
    209209        } else {
    210           Log() << Verbose(2) << "Keeping present vector due to larger projected distance " << ProjectedVectorNorm << "." << endl;
     210          DoLog(2) && (Log() << Verbose(2) << "Keeping present vector due to larger projected distance " << ProjectedVectorNorm << "." << endl);
    211211        }
    212212      }
     
    227227    // 3c. throw out points whose distance is less than the mean of left and right neighbours
    228228    bool flag = false;
    229     Log() << Verbose(1) << "Looking for candidates to kick out by convex condition ... " << endl;
     229    DoLog(1) && (Log() << Verbose(1) << "Looking for candidates to kick out by convex condition ... " << endl);
    230230    do { // do as long as we still throw one out per round
    231231      flag = false;
     
    282282          const double MinDistance = a * sin(beta) / (sin(delta)) * (((alpha < M_PI / 2.) || (gamma < M_PI / 2.)) ? 1. : -1.);
    283283          //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;
     284          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);
    285285          if ((fabs(h / fabs(h) - MinDistance / fabs(MinDistance)) < MYEPSILON) && ((h - MinDistance)) < -MYEPSILON) {
    286286            // throw out point
    287             Log() << Verbose(1) << "Throwing out " << *runner->second.second << "." << endl;
     287            DoLog(1) && (Log() << Verbose(1) << "Throwing out " << *runner->second.second << "." << endl);
    288288            BoundaryPoints[axis].erase(runner);
    289289            flag = true;
     
    320320      BoundaryPoints = GetBoundaryPoints(mol, TesselStruct);
    321321  } else {
    322       Log() << Verbose(0) << "Using given boundary points set." << endl;
     322      DoLog(0) && (Log() << Verbose(0) << "Using given boundary points set." << endl);
    323323  }
    324324
     
    326326  for (int axis=0; axis < NDIM; axis++)
    327327    {
    328       Log() << Verbose(1) << "Printing list of candidates for axis " << axis << " which we have inserted so far." << endl;
     328      DoLog(1) && (Log() << Verbose(1) << "Printing list of candidates for axis " << axis << " which we have inserted so far." << endl);
    329329      int i=0;
    330330      for(Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) {
    331331        if (runner != BoundaryPoints[axis].begin())
    332           Log() << Verbose(0) << ", " << i << ": " << *runner->second.second;
     332          DoLog(0) && (Log() << Verbose(0) << ", " << i << ": " << *runner->second.second);
    333333        else
    334           Log() << Verbose(0) << i << ": " << *runner->second.second;
     334          DoLog(0) && (Log() << Verbose(0) << i << ": " << *runner->second.second);
    335335        i++;
    336336      }
    337       Log() << Verbose(0) << endl;
     337      DoLog(0) && (Log() << Verbose(0) << endl);
    338338    }
    339339
     
    342342    for (Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++)
    343343        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;
     344          DoeLog(2) && (eLog()<< Verbose(2) << "Point " << *(runner->second.second) << " is already present!" << endl);
     345
     346  DoLog(0) && (Log() << Verbose(0) << "I found " << TesselStruct->PointsOnBoundaryCount << " points on the convex boundary." << endl);
    347347  // now we have the whole set of edge points in the BoundaryList
    348348
     
    362362  // 3c. check whether all atoms lay inside the boundary, if not, add to boundary points, segment triangle into three with the new point
    363363  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;
     364    DoeLog(1) && (eLog()<< Verbose(1) << "Insertion of straddling points failed!" << endl);
     365
     366  DoLog(0) && (Log() << Verbose(0) << "I created " << TesselStruct->TrianglesOnBoundary.size() << " intermediate triangles with " << TesselStruct->LinesOnBoundary.size() << " lines and " << TesselStruct->PointsOnBoundary.size() << " points." << endl);
    367367
    368368  // 4. Store triangles in tecplot file
     
    395395    for (LineMap::iterator LineRunner = TesselStruct->LinesOnBoundary.begin(); LineRunner != TesselStruct->LinesOnBoundary.end(); LineRunner++) {
    396396      line = LineRunner->second;
    397       Log() << Verbose(1) << "INFO: Current line is " << *line << "." << endl;
     397      DoLog(1) && (Log() << Verbose(1) << "INFO: Current line is " << *line << "." << endl);
    398398      if (!line->CheckConvexityCriterion()) {
    399         Log() << Verbose(1) << "... line " << *line << " is concave, flipping it." << endl;
     399        DoLog(1) && (Log() << Verbose(1) << "... line " << *line << " is concave, flipping it." << endl);
    400400
    401401        // flip the line
    402402        if (TesselStruct->PickFarthestofTwoBaselines(line) == 0.)
    403           eLog() << Verbose(1) << "Correction of concave baselines failed!" << endl;
     403          DoeLog(1) && (eLog()<< Verbose(1) << "Correction of concave baselines failed!" << endl);
    404404        else {
    405405          TesselStruct->FlipBaseline(line);
    406           Log() << Verbose(1) << "INFO: Correction of concave baselines worked." << endl;
     406          DoLog(1) && (Log() << Verbose(1) << "INFO: Correction of concave baselines worked." << endl);
    407407        }
    408408      }
     
    414414//    Log() << Verbose(1) << "Correction of concave tesselpoints failed!" << endl;
    415415
    416   Log() << Verbose(0) << "I created " << TesselStruct->TrianglesOnBoundary.size() << " triangles with " << TesselStruct->LinesOnBoundary.size() << " lines and " << TesselStruct->PointsOnBoundary.size() << " points." << endl;
     416  DoLog(0) && (Log() << Verbose(0) << "I created " << TesselStruct->TrianglesOnBoundary.size() << " triangles with " << TesselStruct->LinesOnBoundary.size() << " lines and " << TesselStruct->PointsOnBoundary.size() << " points." << endl);
    417417
    418418  // 4. Store triangles in tecplot file
     
    456456
    457457  if ((TesselStruct == NULL) || (TesselStruct->PointsOnBoundary.empty())) {
    458     eLog() << Verbose(1) << "TesselStruct is empty." << endl;
     458    DoeLog(1) && (eLog()<< Verbose(1) << "TesselStruct is empty." << endl);
    459459    return false;
    460460  }
     
    462462  PointMap::iterator PointRunner;
    463463  while (!TesselStruct->PointsOnBoundary.empty()) {
    464     Log() << Verbose(1) << "Remaining points are: ";
     464    DoLog(1) && (Log() << Verbose(1) << "Remaining points are: ");
    465465    for (PointMap::iterator PointSprinter = TesselStruct->PointsOnBoundary.begin(); PointSprinter != TesselStruct->PointsOnBoundary.end(); PointSprinter++)
    466       Log() << Verbose(0) << *(PointSprinter->second) << "\t";
    467     Log() << Verbose(0) << endl;
     466      DoLog(0) && (Log() << Verbose(0) << *(PointSprinter->second) << "\t");
     467    DoLog(0) && (Log() << Verbose(0) << endl);
    468468
    469469    PointRunner = TesselStruct->PointsOnBoundary.begin();
     
    521521  // check whether there is something to work on
    522522  if (TesselStruct == NULL) {
    523     eLog() << Verbose(1) << "TesselStruct is empty!" << endl;
     523    DoeLog(1) && (eLog()<< Verbose(1) << "TesselStruct is empty!" << endl);
    524524    return volume;
    525525  }
     
    537537      PointAdvance++;
    538538      point = PointRunner->second;
    539       Log() << Verbose(1) << "INFO: Current point is " << *point << "." << endl;
     539      DoLog(1) && (Log() << Verbose(1) << "INFO: Current point is " << *point << "." << endl);
    540540      for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) {
    541541        line = LineRunner->second;
    542         Log() << Verbose(1) << "INFO: Current line of point " << *point << " is " << *line << "." << endl;
     542        DoLog(1) && (Log() << Verbose(1) << "INFO: Current line of point " << *point << " is " << *line << "." << endl);
    543543        if (!line->CheckConvexityCriterion()) {
    544544          // remove the point if needed
    545           Log() << Verbose(1) << "... point " << *point << " cannot be on convex envelope." << endl;
     545          DoLog(1) && (Log() << Verbose(1) << "... point " << *point << " cannot be on convex envelope." << endl);
    546546          volume += TesselStruct->RemovePointFromTesselatedSurface(point);
    547547          sprintf(dummy, "-first-%d", ++run);
     
    564564      LineAdvance++;
    565565      line = LineRunner->second;
    566       Log() << Verbose(1) << "INFO: Picking farthest baseline for line is " << *line << "." << endl;
     566      DoLog(1) && (Log() << Verbose(1) << "INFO: Picking farthest baseline for line is " << *line << "." << endl);
    567567      // take highest of both lines
    568568      if (TesselStruct->IsConvexRectangle(line) == NULL) {
     
    605605
    606606  // end
    607   Log() << Verbose(0) << "Volume is " << volume << "." << endl;
     607  DoLog(0) && (Log() << Verbose(0) << "Volume is " << volume << "." << endl);
    608608  return volume;
    609609};
     
    734734      totalmass += Walker->type->mass;
    735735  }
    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;
     736  DoLog(0) && (Log() << Verbose(0) << "RESULT: The summed mass is " << setprecision(10) << totalmass << " atomicmassunit." << endl);
     737  DoLog(0) && (Log() << Verbose(0) << "RESULT: The average density is " << setprecision(10) << totalmass / clustervolume << " atomicmassunit/" << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl);
    738738
    739739  // solve cubic polynomial
    740   Log() << Verbose(1) << "Solving equidistant suspension in water problem ..." << endl;
     740  DoLog(1) && (Log() << Verbose(1) << "Solving equidistant suspension in water problem ..." << endl);
    741741  if (IsAngstroem)
    742742    cellvolume = (TotalNoClusters * totalmass / SOLVENTDENSITY_A - (totalmass / clustervolume)) / (celldensity - 1);
    743743  else
    744744    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;
     745  DoLog(1) && (Log() << Verbose(1) << "Cellvolume needed for a density of " << celldensity << " g/cm^3 is " << cellvolume << " " << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl);
    746746
    747747  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;
     748  DoLog(1) && (Log() << Verbose(1) << "Minimum volume of the convex envelope contained in a rectangular box is " << minimumvolume << " atomicmassunit/" << (IsAngstroem ? "angstrom" : "atomiclength") << "^3." << endl);
    749749  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;
     750    DoeLog(1) && (eLog()<< Verbose(1) << "the containing box already has a greater volume than the envisaged cell volume!" << endl);
     751    DoLog(0) && (Log() << Verbose(0) << "Setting Box dimensions to minimum possible, the greatest diameters." << endl);
    752752    for (int i = 0; i < NDIM; i++)
    753753      BoxLengths.x[i] = GreatestDiameter[i];
     
    761761    double x2 = 0.;
    762762    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;
     763      DoLog(0) && (Log() << Verbose(0) << "RESULT: The resulting spacing is: " << x0 << " ." << endl);
    764764    else {
    765       Log() << Verbose(0) << "RESULT: The resulting spacings are: " << x0 << " and " << x1 << " and " << x2 << " ." << endl;
     765      DoLog(0) && (Log() << Verbose(0) << "RESULT: The resulting spacings are: " << x0 << " and " << x1 << " and " << x2 << " ." << endl);
    766766      x0 = x2; // sorted in ascending order
    767767    }
     
    774774
    775775    // set new box dimensions
    776     Log() << Verbose(0) << "Translating to box with these boundaries." << endl;
     776    DoLog(0) && (Log() << Verbose(0) << "Translating to box with these boundaries." << endl);
    777777    mol->SetBoxDimension(&BoxLengths);
    778778    mol->CenterInBox();
     
    780780  // update Box of atoms by boundary
    781781  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;
     782  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);
    783783};
    784784
     
    822822  for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++)
    823823    if ((*ListRunner)->AtomCount > 0) {
    824       Log() << Verbose(1) << "Pre-creating linked cell lists for molecule " << *ListRunner << "." << endl;
     824      DoLog(1) && (Log() << Verbose(1) << "Pre-creating linked cell lists for molecule " << *ListRunner << "." << endl);
    825825      LCList[(*ListRunner)] = new LinkedCell((*ListRunner), 10.); // get linked cell list
    826       Log() << Verbose(1) << "Pre-creating tesselation for molecule " << *ListRunner << "." << endl;
     826      DoLog(1) && (Log() << Verbose(1) << "Pre-creating tesselation for molecule " << *ListRunner << "." << endl);
    827827      TesselStruct[(*ListRunner)] = NULL;
    828828      FindNonConvexBorder((*ListRunner), TesselStruct[(*ListRunner)], (const LinkedCell *&)LCList[(*ListRunner)], 5., NULL);
     
    832832  filler->CenterEdge(&Inserter);
    833833  filler->Center.Zero();
     834  DoLog(2) && (Log() << Verbose(2) << "INFO: Filler molecule has the following bonds:" << endl);
     835  Binder = filler->first;
     836  while(Binder->next != filler->last) {
     837    Binder = Binder->next;
     838    DoLog(2) && (Log() << Verbose(2) << "  " << *Binder << endl);
     839  }
    834840
    835841  filler->CountAtoms();
     
    841847  for(int i=0;i<NDIM;i++)
    842848    N[i] = (int) ceil(1./FillerDistance.x[i]);
    843   Log() << Verbose(1) << "INFO: Grid steps are " << N[0] << ", " << N[1] << ", " << N[2] << "." << endl;
     849  DoLog(1) && (Log() << Verbose(1) << "INFO: Grid steps are " << N[0] << ", " << N[1] << ", " << N[2] << "." << endl);
    844850
    845851  // initialize seed of random number generator to current time
     
    856862        for (int i=0;i<NDIM;i++)
    857863          FillerTranslations.x[i] = RandomMolDisplacement*(rand()/(RAND_MAX/2.) - 1.);
    858         Log() << Verbose(2) << "INFO: Current Position is " << CurrentPosition << "+" << FillerTranslations << "." << endl;
     864        DoLog(2) && (Log() << Verbose(2) << "INFO: Current Position is " << CurrentPosition << "+" << FillerTranslations << "." << endl);
    859865
    860866        // go through all atoms
     
    911917          // insert into Filling
    912918          if (FillIt) {
    913             Log() << Verbose(1) << "INFO: Position at " << Inserter << " is outer point." << endl;
     919            DoLog(1) && (Log() << Verbose(1) << "INFO: Position at " << Inserter << " is outer point." << endl);
    914920            // copy atom ...
    915921            CopyAtoms[Walker->nr] = new atom(Walker);
    916922            CopyAtoms[Walker->nr]->x.CopyVector(&Inserter);
    917923            Filling->AddAtom(CopyAtoms[Walker->nr]);
    918             Log() << Verbose(4) << "Filling atom " << *Walker << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[Walker->nr]->x) << "." << endl;
     924            DoLog(4) && (Log() << Verbose(4) << "Filling atom " << *Walker << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[Walker->nr]->x) << "." << endl);
    919925          } else {
    920             Log() << Verbose(1) << "INFO: Position at " << Inserter << " is inner point, within boundary or outside of MaxDistance." << endl;
     926            DoLog(1) && (Log() << Verbose(1) << "INFO: Position at " << Inserter << " is inner point, within boundary or outside of MaxDistance." << endl);
    921927            CopyAtoms[Walker->nr] = NULL;
    922928            continue;
    923929          }
    924 
    925           // go through all bonds and add as well
    926           Binder = filler->first;
    927           while(Binder->next != filler->last) {
    928             Binder = Binder->next;
    929             if ((CopyAtoms[Binder->leftatom->nr] != NULL) && (CopyAtoms[Binder->rightatom->nr] != NULL)) {
    930               Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl;
    931               Filling->AddBond(CopyAtoms[Binder->leftatom->nr], CopyAtoms[Binder->rightatom->nr], Binder->BondDegree);
    932             }
     930        }
     931        // go through all bonds and add as well
     932        Binder = filler->first;
     933        while(Binder->next != filler->last) {
     934          Binder = Binder->next;
     935          if ((CopyAtoms[Binder->leftatom->nr] != NULL) && (CopyAtoms[Binder->rightatom->nr] != NULL)) {
     936            Log()  << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl;
     937            Filling->AddBond(CopyAtoms[Binder->leftatom->nr], CopyAtoms[Binder->rightatom->nr], Binder->BondDegree);
    933938          }
    934939        }
     
    955960  bool freeLC = false;
    956961  bool status = false;
    957   CandidateForTesselation *baseline;
    958   LineMap::iterator testline;
     962  CandidateForTesselation *baseline = NULL;
    959963  bool OneLoopWithoutSuccessFlag = true;  // marks whether we went once through all baselines without finding any without two triangles
    960964  bool TesselationFailFlag = false;
    961   BoundaryTriangleSet *T = NULL;
    962965
    963966  if (TesselStruct == NULL) {
    964     Log() << Verbose(1) << "Allocating Tesselation struct ..." << endl;
     967    DoLog(1) && (Log() << Verbose(1) << "Allocating Tesselation struct ..." << endl);
    965968    TesselStruct= new Tesselation;
    966969  } else {
    967970    delete(TesselStruct);
    968     Log() << Verbose(1) << "Re-Allocating Tesselation struct ..." << endl;
     971    DoLog(1) && (Log() << Verbose(1) << "Re-Allocating Tesselation struct ..." << endl);
    969972    TesselStruct = new Tesselation;
    970973  }
     
    977980
    978981  // 1. get starting triangle
    979   TesselStruct->FindStartingTriangle(RADIUS, LCList);
     982  if (!TesselStruct->FindStartingTriangle(RADIUS, LCList)) {
     983    DoeLog(0) && (eLog() << Verbose(0) << "No valid starting triangle found." << endl);
     984    //performCriticalExit();
     985  }
     986  if (filename != NULL) {
     987    if ((DoSingleStepOutput && ((TesselStruct->TrianglesOnBoundary.size() % SingleStepWidth == 0)))) { // if we have a new triangle and want to output each new triangle configuration
     988      TesselStruct->Output(filename, mol);
     989    }
     990  }
    980991
    981992  // 2. expand from there
    982993  while ((!TesselStruct->OpenLines.empty()) && (OneLoopWithoutSuccessFlag)) {
    983     // 2a. fill all new OpenLines
    984     Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for candidates:" << endl;
     994    (cerr << "There are " <<  TesselStruct->TrianglesOnBoundary.size() << " triangles and " << TesselStruct->OpenLines.size() << " open lines to scan for candidates." << endl);
     995    // 2a. print OpenLines without candidates
     996    DoLog(1) && (Log() << Verbose(1) << "There are the following open lines to scan for a candidates:" << endl);
    985997    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++)
    986       Log() << Verbose(2) << *(Runner->second) << endl;
    987 
    988     for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
    989       baseline = Runner->second;
    990       if (baseline->pointlist.empty()) {
    991         T = (((baseline->BaseLine->triangles.begin()))->second);
    992         Log() << Verbose(1) << "Finding best candidate for open line " << *baseline->BaseLine << " of triangle " << *T << endl;
    993         TesselationFailFlag = TesselStruct->FindNextSuitableTriangle(*baseline, *T, RADIUS, LCList); //the line is there, so there is a triangle, but only one.
    994       }
    995     }
    996 
    997     // 2b. search for smallest ShortestAngle among all candidates
     998      if (Runner->second->pointlist.empty())
     999        DoLog(1) && (Log() << Verbose(1) << " " << *(Runner->second) << endl);
     1000
     1001    // 2b. find best candidate for each OpenLine
     1002    TesselationFailFlag = TesselStruct->FindCandidatesforOpenLines(RADIUS, LCList);
     1003
     1004    // 2c. print OpenLines with candidates again
     1005    DoLog(1) && (Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for the best candidates:" << endl);
     1006    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++)
     1007      DoLog(1) && (Log() << Verbose(1) << " " << *(Runner->second) << endl);
     1008
     1009    // 2d. search for smallest ShortestAngle among all candidates
    9981010    double ShortestAngle = 4.*M_PI;
    999     Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for the best candidates:" << endl;
    1000     for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++)
    1001       Log() << Verbose(2) << *(Runner->second) << endl;
    1002 
    10031011    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
    10041012      if (Runner->second->ShortestAngle < ShortestAngle) {
    10051013        baseline = Runner->second;
    10061014        ShortestAngle = baseline->ShortestAngle;
    1007         //Log() << Verbose(1) << "New best candidate is " << *baseline->BaseLine << " with point " << *baseline->point << " and angle " << baseline->ShortestAngle << endl;
     1015        DoLog(1) && (Log() << Verbose(1) << "New best candidate is " << *baseline->BaseLine << " with point " << *(*baseline->pointlist.begin()) << " and angle " << baseline->ShortestAngle << endl);
    10081016      }
    10091017    }
     1018    // 2e. if we found one, add candidate
    10101019    if ((ShortestAngle == 4.*M_PI) || (baseline->pointlist.empty()))
    10111020      OneLoopWithoutSuccessFlag = false;
    10121021    else {
    1013       TesselStruct->AddCandidateTriangle(*baseline);
    1014     }
    1015 
    1016     // write temporary envelope
     1022      TesselStruct->AddCandidatePolygon(*baseline, RADIUS, LCList);
     1023    }
     1024
     1025    // 2f. write temporary envelope
    10171026    if (filename != NULL) {
    10181027      if ((DoSingleStepOutput && ((TesselStruct->TrianglesOnBoundary.size() % SingleStepWidth == 0)))) { // if we have a new triangle and want to output each new triangle configuration
     
    10491058  StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, "");
    10501059
    1051   // correct degenerated polygons
    1052   TesselStruct->CorrectAllDegeneratedPolygons();
    1053 
    1054   // check envelope for consistency
    1055   status = CheckListOfBaselines(TesselStruct);
     1060//  // correct degenerated polygons
     1061//  TesselStruct->CorrectAllDegeneratedPolygons();
     1062//
     1063//  // check envelope for consistency
     1064//  status = CheckListOfBaselines(TesselStruct);
    10561065
    10571066  // write final envelope
  • src/builder.cpp

    r70378e rd6c485  
    5252#include <cstring>
    5353
     54#include "analysis_bonds.hpp"
    5455#include "analysis_correlation.hpp"
    5556#include "atom.hpp"
     
    8586  bool valid;
    8687
    87   Log() << Verbose(0) << "===========ADD ATOM============================" << endl;
    88   Log() << Verbose(0) << " a - state absolute coordinates of atom" << endl;
    89   Log() << Verbose(0) << " b - state relative coordinates of atom wrt to reference point" << endl;
    90   Log() << Verbose(0) << " c - state relative coordinates of atom wrt to already placed atom" << endl;
    91   Log() << Verbose(0) << " d - state two atoms, two angles and a distance" << endl;
    92   Log() << Verbose(0) << " e - least square distance position to a set of atoms" << endl;
    93   Log() << Verbose(0) << "all else - go back" << endl;
    94   Log() << Verbose(0) << "===============================================" << endl;
    95   Log() << Verbose(0) << "Note: Specifiy angles in degrees not multiples of Pi!" << endl;
    96   Log() << Verbose(0) << "INPUT: ";
     88  cout << Verbose(0) << "===========ADD ATOM============================" << endl;
     89  cout << Verbose(0) << " a - state absolute coordinates of atom" << endl;
     90  cout << Verbose(0) << " b - state relative coordinates of atom wrt to reference point" << endl;
     91  cout << Verbose(0) << " c - state relative coordinates of atom wrt to already placed atom" << endl;
     92  cout << Verbose(0) << " d - state two atoms, two angles and a distance" << endl;
     93  cout << Verbose(0) << " e - least square distance position to a set of atoms" << endl;
     94  cout << Verbose(0) << "all else - go back" << endl;
     95  cout << Verbose(0) << "===============================================" << endl;
     96  cout << Verbose(0) << "Note: Specifiy angles in degrees not multiples of Pi!" << endl;
     97  cout << Verbose(0) << "INPUT: ";
    9798  cin >> choice;
    9899
    99100  switch (choice) {
    100101    default:
    101       eLog() << Verbose(2) << "Not a valid choice." << endl;
     102      DoeLog(2) && (eLog()<< Verbose(2) << "Not a valid choice." << endl);
    102103      break;
    103104      case 'a': // absolute coordinates of atom
    104         Log() << Verbose(0) << "Enter absolute coordinates." << endl;
     105        cout << Verbose(0) << "Enter absolute coordinates." << endl;
    105106        first = new atom;
    106107        first->x.AskPosition(World::get()->cell_size, false);
     
    113114        valid = true;
    114115        do {
    115           if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
    116           Log() << Verbose(0) << "Enter reference coordinates." << endl;
     116          if (!valid) DoeLog(2) && (eLog()<< Verbose(2) << "Resulting position out of cell." << endl);
     117          cout << Verbose(0) << "Enter reference coordinates." << endl;
    117118          x.AskPosition(World::get()->cell_size, true);
    118           Log() << Verbose(0) << "Enter relative coordinates." << endl;
     119          cout << Verbose(0) << "Enter relative coordinates." << endl;
    119120          first->x.AskPosition(World::get()->cell_size, false);
    120121          first->x.AddVector((const Vector *)&x);
    121           Log() << Verbose(0) << "\n";
     122          cout << Verbose(0) << "\n";
    122123        } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
    123124        first->type = periode->AskElement();  // give type
     
    129130        valid = true;
    130131        do {
    131           if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
     132          if (!valid) DoeLog(2) && (eLog()<< Verbose(2) << "Resulting position out of cell." << endl);
    132133          second = mol->AskAtom("Enter atom number: ");
    133           Log() << Verbose(0) << "Enter relative coordinates." << endl;
     134          DoLog(0) && (Log() << Verbose(0) << "Enter relative coordinates." << endl);
    134135          first->x.AskPosition(World::get()->cell_size, false);
    135136          for (int i=NDIM;i--;) {
     
    146147        do {
    147148          if (!valid) {
    148             eLog() << Verbose(2) << "Resulting coordinates out of cell - " << first->x << endl;
     149            DoeLog(2) && (eLog()<< Verbose(2) << "Resulting coordinates out of cell - " << first->x << endl);
    149150          }
    150           Log() << Verbose(0) << "First, we need two atoms, the first atom is the central, while the second is the outer one." << endl;
     151          cout << Verbose(0) << "First, we need two atoms, the first atom is the central, while the second is the outer one." << endl;
    151152          second = mol->AskAtom("Enter central atom: ");
    152153          third = mol->AskAtom("Enter second atom (specifying the axis for first angle): ");
     
    159160          c *= M_PI/180.;
    160161          bound(&c, -M_PI, M_PI);
    161           Log() << Verbose(0) << "radius: " << a << "\t phi: " << b*180./M_PI << "\t theta: " << c*180./M_PI << endl;
     162          cout << Verbose(0) << "radius: " << a << "\t phi: " << b*180./M_PI << "\t theta: " << c*180./M_PI << endl;
    162163/*
    163164          second->Output(1,1,(ofstream *)&cout);
     
    171172
    172173          if (!z.SolveSystem(&x,&y,&n, b, c, a)) {
    173             Log() << Verbose(0) << "Failure solving self-dependent linear system!" << endl;
     174         coutg() << Verbose(0) << "Failure solving self-dependent linear system!" << endl;
    174175            continue;
    175176          }
    176           Log() << Verbose(0) << "resulting relative coordinates: ";
     177          DoLog(0) && (Log() << Verbose(0) << "resulting relative coordinates: ");
    177178          z.Output();
    178           Log() << Verbose(0) << endl;
     179          DoLog(0) && (Log() << Verbose(0) << endl);
    179180          */
    180181          // calc axis vector
     
    184185          Log() << Verbose(0) << "x: ",
    185186          x.Output();
    186           Log() << Verbose(0) << endl;
     187          DoLog(0) && (Log() << Verbose(0) << endl);
    187188          z.MakeNormalVector(&second->x,&third->x,&fourth->x);
    188189          Log() << Verbose(0) << "z: ",
    189190          z.Output();
    190           Log() << Verbose(0) << endl;
     191          DoLog(0) && (Log() << Verbose(0) << endl);
    191192          y.MakeNormalVector(&x,&z);
    192193          Log() << Verbose(0) << "y: ",
    193194          y.Output();
    194           Log() << Verbose(0) << endl;
     195          DoLog(0) && (Log() << Verbose(0) << endl);
    195196
    196197          // rotate vector around first angle
     
    199200          Log() << Verbose(0) << "Rotated vector: ",
    200201          first->x.Output();
    201           Log() << Verbose(0) << endl;
     202          DoLog(0) && (Log() << Verbose(0) << endl);
    202203          // remove the projection onto the rotation plane of the second angle
    203204          n.CopyVector(&y);
     
    205206          Log() << Verbose(0) << "N1: ",
    206207          n.Output();
    207           Log() << Verbose(0) << endl;
     208          DoLog(0) && (Log() << Verbose(0) << endl);
    208209          first->x.SubtractVector(&n);
    209210          Log() << Verbose(0) << "Subtracted vector: ",
    210211          first->x.Output();
    211           Log() << Verbose(0) << endl;
     212          DoLog(0) && (Log() << Verbose(0) << endl);
    212213          n.CopyVector(&z);
    213214          n.Scale(first->x.ScalarProduct(&z));
    214215          Log() << Verbose(0) << "N2: ",
    215216          n.Output();
    216           Log() << Verbose(0) << endl;
     217          DoLog(0) && (Log() << Verbose(0) << endl);
    217218          first->x.SubtractVector(&n);
    218219          Log() << Verbose(0) << "2nd subtracted vector: ",
    219220          first->x.Output();
    220           Log() << Verbose(0) << endl;
     221          DoLog(0) && (Log() << Verbose(0) << endl);
    221222
    222223          // rotate another vector around second angle
     
    225226          Log() << Verbose(0) << "2nd Rotated vector: ",
    226227          n.Output();
    227           Log() << Verbose(0) << endl;
     228          DoLog(0) && (Log() << Verbose(0) << endl);
    228229
    229230          // add the two linear independent vectors
     
    233234          first->x.AddVector(&second->x);
    234235
    235           Log() << Verbose(0) << "resulting coordinates: ";
     236          DoLog(0) && (Log() << Verbose(0) << "resulting coordinates: ");
    236237          first->x.Output();
    237           Log() << Verbose(0) << endl;
     238          DoLog(0) && (Log() << Verbose(0) << endl);
    238239        } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
    239240        first->type = periode->AskElement();  // give type
     
    248249          atoms[i] = NULL;
    249250        int i=0, j=0;
    250         Log() << Verbose(0) << "Now we need at least three molecules.\n";
     251        cout << Verbose(0) << "Now we need at least three molecules.\n";
    251252        do {
    252           Log() << Verbose(0) << "Enter " << i+1 << "th atom: ";
     253          cout << Verbose(0) << "Enter " << i+1 << "th atom: ";
    253254          cin >> j;
    254255          if (j != -1) {
     
    265266        } else {
    266267          delete first;
    267           Log() << Verbose(0) << "Please enter at least two vectors!\n";
     268          cout << Verbose(0) << "Please enter at least two vectors!\n";
    268269        }
    269270        break;
     
    279280  char choice;  // menu choice char
    280281
    281   Log() << Verbose(0) << "===========CENTER ATOMS=========================" << endl;
    282   Log() << Verbose(0) << " a - on origin" << endl;
    283   Log() << Verbose(0) << " b - on center of gravity" << endl;
    284   Log() << Verbose(0) << " c - within box with additional boundary" << endl;
    285   Log() << Verbose(0) << " d - within given simulation box" << endl;
    286   Log() << Verbose(0) << "all else - go back" << endl;
    287   Log() << Verbose(0) << "===============================================" << endl;
    288   Log() << Verbose(0) << "INPUT: ";
     282  cout << Verbose(0) << "===========CENTER ATOMS=========================" << endl;
     283  cout << Verbose(0) << " a - on origin" << endl;
     284  cout << Verbose(0) << " b - on center of gravity" << endl;
     285  cout << Verbose(0) << " c - within box with additional boundary" << endl;
     286  cout << Verbose(0) << " d - within given simulation box" << endl;
     287  cout << Verbose(0) << "all else - go back" << endl;
     288  cout << Verbose(0) << "===============================================" << endl;
     289  cout << Verbose(0) << "INPUT: ";
    289290  cin >> choice;
    290291
    291292  switch (choice) {
    292293    default:
    293       Log() << Verbose(0) << "Not a valid choice." << endl;
     294      cout << Verbose(0) << "Not a valid choice." << endl;
    294295      break;
    295296    case 'a':
    296       Log() << Verbose(0) << "Centering atoms in config file on origin." << endl;
     297      cout << Verbose(0) << "Centering atoms in config file on origin." << endl;
    297298      mol->CenterOrigin();
    298299      break;
    299300    case 'b':
    300       Log() << Verbose(0) << "Centering atoms in config file on center of gravity." << endl;
     301      cout << Verbose(0) << "Centering atoms in config file on center of gravity." << endl;
    301302      mol->CenterPeriodic();
    302303      break;
    303304    case 'c':
    304       Log() << Verbose(0) << "Centering atoms in config file within given additional boundary." << endl;
     305      cout << Verbose(0) << "Centering atoms in config file within given additional boundary." << endl;
    305306      for (int i=0;i<NDIM;i++) {
    306         Log() << Verbose(0) << "Enter axis " << i << " boundary: ";
     307        cout << Verbose(0) << "Enter axis " << i << " boundary: ";
    307308        cin >> y.x[i];
    308309      }
     
    315316      break;
    316317    case 'd':
    317       Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
     318      cout << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
    318319      for (int i=0;i<NDIM;i++) {
    319         Log() << Verbose(0) << "Enter axis " << i << " boundary: ";
     320        cout << Verbose(0) << "Enter axis " << i << " boundary: ";
    320321        cin >> x.x[i];
    321322      }
     
    338339  char choice;  // menu choice char
    339340
    340   Log() << Verbose(0) << "===========ALIGN ATOMS=========================" << endl;
    341   Log() << Verbose(0) << " a - state three atoms defining align plane" << endl;
    342   Log() << Verbose(0) << " b - state alignment vector" << endl;
    343   Log() << Verbose(0) << " c - state two atoms in alignment direction" << endl;
    344   Log() << Verbose(0) << " d - align automatically by least square fit" << endl;
    345   Log() << Verbose(0) << "all else - go back" << endl;
    346   Log() << Verbose(0) << "===============================================" << endl;
    347   Log() << Verbose(0) << "INPUT: ";
     341  cout << Verbose(0) << "===========ALIGN ATOMS=========================" << endl;
     342  cout << Verbose(0) << " a - state three atoms defining align plane" << endl;
     343  cout << Verbose(0) << " b - state alignment vector" << endl;
     344  cout << Verbose(0) << " c - state two atoms in alignment direction" << endl;
     345  cout << Verbose(0) << " d - align automatically by least square fit" << endl;
     346  cout << Verbose(0) << "all else - go back" << endl;
     347  cout << Verbose(0) << "===============================================" << endl;
     348  cout << Verbose(0) << "INPUT: ";
    348349  cin >> choice;
    349350
     
    358359      break;
    359360    case 'b': // normal vector of mirror plane
    360       Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl;
     361      cout << Verbose(0) << "Enter normal vector of mirror plane." << endl;
    361362      n.AskPosition(World::get()->cell_size,0);
    362363      n.Normalize();
     
    378379        fscanf(stdin, "%3s", shorthand);
    379380      } while ((param.type = periode->FindElement(shorthand)) == NULL);
    380       Log() << Verbose(0) << "Element is " << param.type->name << endl;
     381      cout << Verbose(0) << "Element is " << param.type->name << endl;
    381382      mol->GetAlignvector(&param);
    382383      for (int i=NDIM;i--;) {
     
    385386      }
    386387      gsl_vector_free(param.x);
    387       Log() << Verbose(0) << "Offset vector: ";
     388      cout << Verbose(0) << "Offset vector: ";
    388389      x.Output();
    389       Log() << Verbose(0) << endl;
     390      DoLog(0) && (Log() << Verbose(0) << endl);
    390391      n.Normalize();
    391392      break;
    392393  };
    393   Log() << Verbose(0) << "Alignment vector: ";
     394  DoLog(0) && (Log() << Verbose(0) << "Alignment vector: ");
    394395  n.Output();
    395   Log() << Verbose(0) << endl;
     396  DoLog(0) && (Log() << Verbose(0) << endl);
    396397  mol->Align(&n);
    397398};
     
    406407  char choice;  // menu choice char
    407408
    408   Log() << Verbose(0) << "===========MIRROR ATOMS=========================" << endl;
    409   Log() << Verbose(0) << " a - state three atoms defining mirror plane" << endl;
    410   Log() << Verbose(0) << " b - state normal vector of mirror plane" << endl;
    411   Log() << Verbose(0) << " c - state two atoms in normal direction" << endl;
    412   Log() << Verbose(0) << "all else - go back" << endl;
    413   Log() << Verbose(0) << "===============================================" << endl;
    414   Log() << Verbose(0) << "INPUT: ";
     409  DoLog(0) && (Log() << Verbose(0) << "===========MIRROR ATOMS=========================" << endl);
     410  DoLog(0) && (Log() << Verbose(0) << " a - state three atoms defining mirror plane" << endl);
     411  DoLog(0) && (Log() << Verbose(0) << " b - state normal vector of mirror plane" << endl);
     412  DoLog(0) && (Log() << Verbose(0) << " c - state two atoms in normal direction" << endl);
     413  DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
     414  DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
     415  DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    415416  cin >> choice;
    416417
     
    425426      break;
    426427    case 'b': // normal vector of mirror plane
    427       Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl;
     428      DoLog(0) && (Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl);
    428429      n.AskPosition(World::get()->cell_size,0);
    429430      n.Normalize();
     
    438439      break;
    439440  };
    440   Log() << Verbose(0) << "Normal vector: ";
     441  DoLog(0) && (Log() << Verbose(0) << "Normal vector: ");
    441442  n.Output();
    442   Log() << Verbose(0) << endl;
     443  DoLog(0) && (Log() << Verbose(0) << endl);
    443444  mol->Mirror((const Vector *)&n);
    444445};
     
    454455  char choice;  // menu choice char
    455456
    456   Log() << Verbose(0) << "===========REMOVE ATOMS=========================" << endl;
    457   Log() << Verbose(0) << " a - state atom for removal by number" << endl;
    458   Log() << Verbose(0) << " b - keep only in radius around atom" << endl;
    459   Log() << Verbose(0) << " c - remove this with one axis greater value" << endl;
    460   Log() << Verbose(0) << "all else - go back" << endl;
    461   Log() << Verbose(0) << "===============================================" << endl;
    462   Log() << Verbose(0) << "INPUT: ";
     457  DoLog(0) && (Log() << Verbose(0) << "===========REMOVE ATOMS=========================" << endl);
     458  DoLog(0) && (Log() << Verbose(0) << " a - state atom for removal by number" << endl);
     459  DoLog(0) && (Log() << Verbose(0) << " b - keep only in radius around atom" << endl);
     460  DoLog(0) && (Log() << Verbose(0) << " c - remove this with one axis greater value" << endl);
     461  DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
     462  DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
     463  DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    463464  cin >> choice;
    464465
     
    467468    case 'a':
    468469      if (mol->RemoveAtom(mol->AskAtom("Enter number of atom within molecule: ")))
    469         Log() << Verbose(1) << "Atom removed." << endl;
     470        DoLog(1) && (Log() << Verbose(1) << "Atom removed." << endl);
    470471      else
    471         Log() << Verbose(1) << "Atom not found." << endl;
     472        DoLog(1) && (Log() << Verbose(1) << "Atom not found." << endl);
    472473      break;
    473474    case 'b':
    474475      second = mol->AskAtom("Enter number of atom as reference point: ");
    475       Log() << Verbose(0) << "Enter radius: ";
     476      DoLog(0) && (Log() << Verbose(0) << "Enter radius: ");
    476477      cin >> tmp1;
    477478      first = mol->start;
     
    485486      break;
    486487    case 'c':
    487       Log() << Verbose(0) << "Which axis is it: ";
     488      DoLog(0) && (Log() << Verbose(0) << "Which axis is it: ");
    488489      cin >> axis;
    489       Log() << Verbose(0) << "Lower boundary: ";
     490      DoLog(0) && (Log() << Verbose(0) << "Lower boundary: ");
    490491      cin >> tmp1;
    491       Log() << Verbose(0) << "Upper boundary: ";
     492      DoLog(0) && (Log() << Verbose(0) << "Upper boundary: ");
    492493      cin >> tmp2;
    493494      first = mol->start;
     
    519520  char choice;  // menu choice char
    520521
    521   Log() << Verbose(0) << "===========MEASURE ATOMS=========================" << endl;
    522   Log() << Verbose(0) << " a - calculate bond length between one atom and all others" << endl;
    523   Log() << Verbose(0) << " b - calculate bond length between two atoms" << endl;
    524   Log() << Verbose(0) << " c - calculate bond angle" << endl;
    525   Log() << Verbose(0) << " d - calculate principal axis of the system" << endl;
    526   Log() << Verbose(0) << " e - calculate volume of the convex envelope" << endl;
    527   Log() << Verbose(0) << " f - calculate temperature from current velocity" << endl;
    528   Log() << Verbose(0) << " g - output all temperatures per step from velocities" << endl;
    529   Log() << Verbose(0) << "all else - go back" << endl;
    530   Log() << Verbose(0) << "===============================================" << endl;
    531   Log() << Verbose(0) << "INPUT: ";
     522  DoLog(0) && (Log() << Verbose(0) << "===========MEASURE ATOMS=========================" << endl);
     523  DoLog(0) && (Log() << Verbose(0) << " a - calculate bond length between one atom and all others" << endl);
     524  DoLog(0) && (Log() << Verbose(0) << " b - calculate bond length between two atoms" << endl);
     525  DoLog(0) && (Log() << Verbose(0) << " c - calculate bond angle" << endl);
     526  DoLog(0) && (Log() << Verbose(0) << " d - calculate principal axis of the system" << endl);
     527  DoLog(0) && (Log() << Verbose(0) << " e - calculate volume of the convex envelope" << endl);
     528  DoLog(0) && (Log() << Verbose(0) << " f - calculate temperature from current velocity" << endl);
     529  DoLog(0) && (Log() << Verbose(0) << " g - output all temperatures per step from velocities" << endl);
     530  DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
     531  DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
     532  DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    532533  cin >> choice;
    533534
    534535  switch(choice) {
    535536    default:
    536       Log() << Verbose(1) << "Not a valid choice." << endl;
     537      DoLog(1) && (Log() << Verbose(1) << "Not a valid choice." << endl);
    537538      break;
    538539    case 'a':
     
    566567      x.SubtractVector((const Vector *)&second->x);
    567568      tmp1 = x.Norm();
    568       Log() << Verbose(1) << "Distance vector is ";
     569      DoLog(1) && (Log() << Verbose(1) << "Distance vector is ");
    569570      x.Output();
    570       Log() << Verbose(0) << "." << endl << "Norm of distance is " << tmp1 << "." << endl;
     571      DoLog(0) && (Log() << Verbose(0) << "." << endl << "Norm of distance is " << tmp1 << "." << endl);
    571572      break;
    572573
    573574    case 'c':
    574       Log() << Verbose(0) << "Evaluating bond angle between three - first, central, last - atoms." << endl;
     575      DoLog(0) && (Log() << Verbose(0) << "Evaluating bond angle between three - first, central, last - atoms." << endl);
    575576      first = mol->AskAtom("Enter first atom: ");
    576577      second = mol->AskAtom("Enter central atom: ");
     
    581582      y.CopyVector((const Vector *)&third->x);
    582583      y.SubtractVector((const Vector *)&second->x);
    583       Log() << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ";
    584       Log() << Verbose(0) << (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl;
     584      DoLog(0) && (Log() << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ");
     585      DoLog(0) && (Log() << Verbose(0) << (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl);
    585586      break;
    586587    case 'd':
    587       Log() << Verbose(0) << "Evaluating prinicipal axis." << endl;
    588       Log() << Verbose(0) << "Shall we rotate? [0/1]: ";
     588      DoLog(0) && (Log() << Verbose(0) << "Evaluating prinicipal axis." << endl);
     589      DoLog(0) && (Log() << Verbose(0) << "Shall we rotate? [0/1]: ");
    589590      cin >> Z;
    590591      if ((Z >=0) && (Z <=1))
     
    595596    case 'e':
    596597      {
    597         Log() << Verbose(0) << "Evaluating volume of the convex envelope.";
     598        DoLog(0) && (Log() << Verbose(0) << "Evaluating volume of the convex envelope.");
    598599        class Tesselation *TesselStruct = NULL;
    599600        const LinkedCell *LCList = NULL;
     
    601602        FindConvexBorder(mol, TesselStruct, LCList, NULL);
    602603        double clustervolume = VolumeOfConvexEnvelope(TesselStruct, configuration);
    603         Log() << Verbose(0) << "The tesselated surface area is " << clustervolume << "." << endl;\
     604        DoLog(0) && (Log() << Verbose(0) << "The tesselated surface area is " << clustervolume << "." << endl);\
    604605        delete(LCList);
    605606        delete(TesselStruct);
     
    612613      {
    613614        char filename[255];
    614         Log() << Verbose(0) << "Please enter filename: " << endl;
     615        DoLog(0) && (Log() << Verbose(0) << "Please enter filename: " << endl);
    615616        cin >> filename;
    616         Log() << Verbose(1) << "Storing temperatures in " << filename << "." << endl;
     617        DoLog(1) && (Log() << Verbose(1) << "Storing temperatures in " << filename << "." << endl);
    617618        ofstream *output = new ofstream(filename, ios::trunc);
    618619        if (!mol->OutputTemperatureFromTrajectories(output, 0, mol->MDSteps))
    619           Log() << Verbose(2) << "File could not be written." << endl;
     620          DoLog(2) && (Log() << Verbose(2) << "File could not be written." << endl);
    620621        else
    621           Log() << Verbose(2) << "File stored." << endl;
     622          DoLog(2) && (Log() << Verbose(2) << "File stored." << endl);
    622623        output->close();
    623624        delete(output);
     
    636637  clock_t start, end;
    637638
    638   Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl;
    639   Log() << Verbose(0) << "What's the desired bond order: ";
     639  DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl);
     640  DoLog(0) && (Log() << Verbose(0) << "What's the desired bond order: ");
    640641  cin >> Order1;
    641642  if (mol->first->next != mol->last) {  // there are bonds
     
    643644    mol->FragmentMolecule(Order1, configuration);
    644645    end = clock();
    645     Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
     646    DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);
    646647  } else
    647     Log() << Verbose(0) << "Connection matrix has not yet been generated!" << endl;
     648    DoLog(0) && (Log() << Verbose(0) << "Connection matrix has not yet been generated!" << endl);
    648649};
    649650
     
    664665  bool valid;
    665666
    666   Log() << Verbose(0) << "=========MANIPULATE ATOMS======================" << endl;
    667   Log() << Verbose(0) << "a - add an atom" << endl;
    668   Log() << Verbose(0) << "r - remove an atom" << endl;
    669   Log() << Verbose(0) << "b - scale a bond between atoms" << endl;
    670   Log() << Verbose(0) << "t - turn an atom round another bond" << endl;
    671   Log() << Verbose(0) << "u - change an atoms element" << endl;
    672   Log() << Verbose(0) << "l - measure lengths, angles, ... for an atom" << endl;
    673   Log() << Verbose(0) << "all else - go back" << endl;
    674   Log() << Verbose(0) << "===============================================" << endl;
     667  DoLog(0) && (Log() << Verbose(0) << "=========MANIPULATE ATOMS======================" << endl);
     668  DoLog(0) && (Log() << Verbose(0) << "a - add an atom" << endl);
     669  DoLog(0) && (Log() << Verbose(0) << "r - remove an atom" << endl);
     670  DoLog(0) && (Log() << Verbose(0) << "b - scale a bond between atoms" << endl);
     671  DoLog(0) && (Log() << Verbose(0) << "t - turn an atom round another bond" << endl);
     672  DoLog(0) && (Log() << Verbose(0) << "u - change an atoms element" << endl);
     673  DoLog(0) && (Log() << Verbose(0) << "l - measure lengths, angles, ... for an atom" << endl);
     674  DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
     675  DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
    675676  if (molecules->NumberOfActiveMolecules() > 1)
    676     eLog() << Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl;
    677   Log() << Verbose(0) << "INPUT: ";
     677    DoeLog(2) && (eLog()<< Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl);
     678  DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    678679  cin >> choice;
    679680
    680681  switch (choice) {
    681682    default:
    682       Log() << Verbose(0) << "Not a valid choice." << endl;
     683      DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl);
    683684      break;
    684685
     
    687688        if ((*ListRunner)->ActiveFlag) {
    688689        mol = *ListRunner;
    689         Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
     690        DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    690691        AddAtoms(periode, mol);
    691692      }
     
    696697        if ((*ListRunner)->ActiveFlag) {
    697698        mol = *ListRunner;
    698         Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
    699         Log() << Verbose(0) << "Scaling bond length between two atoms." << endl;
     699        DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
     700        DoLog(0) && (Log() << Verbose(0) << "Scaling bond length between two atoms." << endl);
    700701        first = mol->AskAtom("Enter first (fixed) atom: ");
    701702        second = mol->AskAtom("Enter second (shifting) atom: ");
     
    704705          minBond += (first->x.x[i]-second->x.x[i])*(first->x.x[i] - second->x.x[i]);
    705706        minBond = sqrt(minBond);
    706         Log() << Verbose(0) << "Current Bond length between " << first->type->name << " Atom " << first->nr << " and " << second->type->name << " Atom " << second->nr << ": " << minBond << " a.u." << endl;
    707         Log() << Verbose(0) << "Enter new bond length [a.u.]: ";
     707        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);
     708        DoLog(0) && (Log() << Verbose(0) << "Enter new bond length [a.u.]: ");
    708709        cin >> bond;
    709710        for (int i=NDIM;i--;) {
     
    719720        if ((*ListRunner)->ActiveFlag) {
    720721        mol = *ListRunner;
    721         Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
    722        Log() << Verbose(0) << "Angstroem -> Bohrradius: 1.8897261\t\tBohrradius -> Angstroem: 0.52917721" << endl;
    723        Log() << Verbose(0) << "Enter three factors: ";
     722        DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
     723       DoLog(0) && (Log() << Verbose(0) << "Angstroem -> Bohrradius: 1.8897261\t\tBohrradius -> Angstroem: 0.52917721" << endl);
     724       DoLog(0) && (Log() << Verbose(0) << "Enter three factors: ");
    724725       factor = new double[NDIM];
    725726       cin >> factor[0];
     
    736737        if ((*ListRunner)->ActiveFlag) {
    737738        mol = *ListRunner;
    738         Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
     739        DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    739740        MeasureAtoms(periode, mol, configuration);
    740741      }
     
    745746        if ((*ListRunner)->ActiveFlag) {
    746747        mol = *ListRunner;
    747         Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
     748        DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    748749        RemoveAtoms(mol);
    749750      }
     
    754755        if ((*ListRunner)->ActiveFlag) {
    755756          mol = *ListRunner;
    756           Log() << Verbose(0) << "Turning atom around another bond - first is atom to turn, second (central) and third specify bond" << endl;
     757          DoLog(0) && (Log() << Verbose(0) << "Turning atom around another bond - first is atom to turn, second (central) and third specify bond" << endl);
    757758          first = mol->AskAtom("Enter turning atom: ");
    758759          second = mol->AskAtom("Enter central atom: ");
     
    788789        int Z;
    789790        mol = *ListRunner;
    790         Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
     791        DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    791792        first = NULL;
    792793        do {
    793           Log() << Verbose(0) << "Change the element of which atom: ";
     794          DoLog(0) && (Log() << Verbose(0) << "Change the element of which atom: ");
    794795          cin >> Z;
    795796        } while ((first = mol->FindAtom(Z)) == NULL);
    796         Log() << Verbose(0) << "New element by atomic number Z: ";
     797        DoLog(0) && (Log() << Verbose(0) << "New element by atomic number Z: ");
    797798        cin >> Z;
    798799        first->type = periode->FindElement(Z);
    799         Log() << Verbose(0) << "Atom " << first->nr << "'s element is " << first->type->name << "." << endl;
     800        DoLog(0) && (Log() << Verbose(0) << "Atom " << first->nr << "'s element is " << first->type->name << "." << endl);
    800801      }
    801802      break;
     
    818819  MoleculeLeafClass *Subgraphs = NULL;
    819820
    820   Log() << Verbose(0) << "=========MANIPULATE GLOBALLY===================" << endl;
    821   Log() << Verbose(0) << "c - scale by unit transformation" << endl;
    822   Log() << Verbose(0) << "d - duplicate molecule/periodic cell" << endl;
    823   Log() << Verbose(0) << "f - fragment molecule many-body bond order style" << endl;
    824   Log() << Verbose(0) << "g - center atoms in box" << endl;
    825   Log() << Verbose(0) << "i - realign molecule" << endl;
    826   Log() << Verbose(0) << "m - mirror all molecules" << endl;
    827   Log() << Verbose(0) << "o - create connection matrix" << endl;
    828   Log() << Verbose(0) << "t - translate molecule by vector" << endl;
    829   Log() << Verbose(0) << "all else - go back" << endl;
    830   Log() << Verbose(0) << "===============================================" << endl;
     821  DoLog(0) && (Log() << Verbose(0) << "=========MANIPULATE GLOBALLY===================" << endl);
     822  DoLog(0) && (Log() << Verbose(0) << "c - scale by unit transformation" << endl);
     823  DoLog(0) && (Log() << Verbose(0) << "d - duplicate molecule/periodic cell" << endl);
     824  DoLog(0) && (Log() << Verbose(0) << "f - fragment molecule many-body bond order style" << endl);
     825  DoLog(0) && (Log() << Verbose(0) << "g - center atoms in box" << endl);
     826  DoLog(0) && (Log() << Verbose(0) << "i - realign molecule" << endl);
     827  DoLog(0) && (Log() << Verbose(0) << "m - mirror all molecules" << endl);
     828  DoLog(0) && (Log() << Verbose(0) << "o - create connection matrix" << endl);
     829  DoLog(0) && (Log() << Verbose(0) << "t - translate molecule by vector" << endl);
     830  DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
     831  DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
    831832  if (molecules->NumberOfActiveMolecules() > 1)
    832     eLog() << Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl;
    833   Log() << Verbose(0) << "INPUT: ";
     833    DoeLog(2) && (eLog()<< Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl);
     834  DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    834835  cin >> choice;
    835836
    836837  switch (choice) {
    837838    default:
    838       Log() << Verbose(0) << "Not a valid choice." << endl;
     839      DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl);
    839840      break;
    840841
     
    843844        if ((*ListRunner)->ActiveFlag) {
    844845        mol = *ListRunner;
    845         Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
    846         Log() << Verbose(0) << "State the axis [(+-)123]: ";
     846        DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
     847        DoLog(0) && (Log() << Verbose(0) << "State the axis [(+-)123]: ");
    847848        cin >> axis;
    848         Log() << Verbose(0) << "State the factor: ";
     849        DoLog(0) && (Log() << Verbose(0) << "State the factor: ");
    849850        cin >> faktor;
    850851
     
    863864          }
    864865          if (count != j)
    865             eLog() << Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl;
     866            DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl);
    866867          x.Zero();
    867868          y.Zero();
     
    902903        if ((*ListRunner)->ActiveFlag) {
    903904        mol = *ListRunner;
    904         Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
     905        DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    905906        CenterAtoms(mol);
    906907      }
     
    911912        if ((*ListRunner)->ActiveFlag) {
    912913        mol = *ListRunner;
    913         Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
     914        DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    914915        AlignAtoms(periode, mol);
    915916      }
     
    920921        if ((*ListRunner)->ActiveFlag) {
    921922        mol = *ListRunner;
    922         Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
     923        DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
    923924        MirrorAtoms(mol);
    924925      }
     
    931932          double bonddistance;
    932933          clock_t start,end;
    933           Log() << Verbose(0) << "What's the maximum bond distance: ";
     934          DoLog(0) && (Log() << Verbose(0) << "What's the maximum bond distance: ");
    934935          cin >> bonddistance;
    935936          start = clock();
    936937          mol->CreateAdjacencyList(bonddistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
    937938          end = clock();
    938           Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
     939          DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);
    939940        }
    940941      break;
     
    944945        if ((*ListRunner)->ActiveFlag) {
    945946        mol = *ListRunner;
    946         Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
    947         Log() << Verbose(0) << "Enter translation vector." << endl;
     947        DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl);
     948        DoLog(0) && (Log() << Verbose(0) << "Enter translation vector." << endl);
    948949        x.AskPosition(World::get()->cell_size,0);
    949950        mol->Center.AddVector((const Vector *)&x);
     
    973974  molecule *mol = NULL;
    974975
    975   Log() << Verbose(0) << "==========EDIT MOLECULES=====================" << endl;
    976   Log() << Verbose(0) << "c - create new molecule" << endl;
    977   Log() << Verbose(0) << "l - load molecule from xyz file" << endl;
    978   Log() << Verbose(0) << "n - change molecule's name" << endl;
    979   Log() << Verbose(0) << "N - give molecules filename" << endl;
    980   Log() << Verbose(0) << "p - parse atoms in xyz file into molecule" << endl;
    981   Log() << Verbose(0) << "r - remove a molecule" << endl;
    982   Log() << Verbose(0) << "all else - go back" << endl;
    983   Log() << Verbose(0) << "===============================================" << endl;
    984   Log() << Verbose(0) << "INPUT: ";
     976  DoLog(0) && (Log() << Verbose(0) << "==========EDIT MOLECULES=====================" << endl);
     977  DoLog(0) && (Log() << Verbose(0) << "c - create new molecule" << endl);
     978  DoLog(0) && (Log() << Verbose(0) << "l - load molecule from xyz file" << endl);
     979  DoLog(0) && (Log() << Verbose(0) << "n - change molecule's name" << endl);
     980  DoLog(0) && (Log() << Verbose(0) << "N - give molecules filename" << endl);
     981  DoLog(0) && (Log() << Verbose(0) << "p - parse atoms in xyz file into molecule" << endl);
     982  DoLog(0) && (Log() << Verbose(0) << "r - remove a molecule" << endl);
     983  DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
     984  DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
     985  DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    985986  cin >> choice;
    986987
    987988  switch (choice) {
    988989    default:
    989       Log() << Verbose(0) << "Not a valid choice." << endl;
     990      DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl);
    990991      break;
    991992    case 'c':
     
    997998      {
    998999        char filename[MAXSTRINGSIZE];
    999         Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl;
     1000        DoLog(0) && (Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl);
    10001001        mol = new molecule(periode);
    10011002        do {
    1002           Log() << Verbose(0) << "Enter file name: ";
     1003          DoLog(0) && (Log() << Verbose(0) << "Enter file name: ");
    10031004          cin >> filename;
    10041005        } while (!mol->AddXYZFile(filename));
     
    10211022        char filename[MAXSTRINGSIZE];
    10221023        do {
    1023           Log() << Verbose(0) << "Enter index of molecule: ";
     1024          DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: ");
    10241025          cin >> nr;
    10251026          mol = molecules->ReturnIndex(nr);
    10261027        } while (mol == NULL);
    1027         Log() << Verbose(0) << "Enter name: ";
     1028        DoLog(0) && (Log() << Verbose(0) << "Enter name: ");
    10281029        cin >> filename;
    10291030        strcpy(mol->name, filename);
     
    10351036        char filename[MAXSTRINGSIZE];
    10361037        do {
    1037           Log() << Verbose(0) << "Enter index of molecule: ";
     1038          DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: ");
    10381039          cin >> nr;
    10391040          mol = molecules->ReturnIndex(nr);
    10401041        } while (mol == NULL);
    1041         Log() << Verbose(0) << "Enter name: ";
     1042        DoLog(0) && (Log() << Verbose(0) << "Enter name: ");
    10421043        cin >> filename;
    10431044        mol->SetNameFromFilename(filename);
     
    10501051        mol = NULL;
    10511052        do {
    1052           Log() << Verbose(0) << "Enter index of molecule: ";
     1053          DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: ");
    10531054          cin >> nr;
    10541055          mol = molecules->ReturnIndex(nr);
    10551056        } while (mol == NULL);
    1056         Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl;
     1057        DoLog(0) && (Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl);
    10571058        do {
    1058           Log() << Verbose(0) << "Enter file name: ";
     1059          DoLog(0) && (Log() << Verbose(0) << "Enter file name: ");
    10591060          cin >> filename;
    10601061        } while (!mol->AddXYZFile(filename));
     
    10641065
    10651066    case 'r':
    1066       Log() << Verbose(0) << "Enter index of molecule: ";
     1067      DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: ");
    10671068      cin >> nr;
    10681069      count = 1;
     
    10871088  char choice;  // menu choice char
    10881089
    1089   Log() << Verbose(0) << "===========MERGE MOLECULES=====================" << endl;
    1090   Log() << Verbose(0) << "a - simple add of one molecule to another" << endl;
    1091   Log() << Verbose(0) << "e - embedding merge of two molecules" << endl;
    1092   Log() << Verbose(0) << "m - multi-merge of all molecules" << endl;
    1093   Log() << Verbose(0) << "s - scatter merge of two molecules" << endl;
    1094   Log() << Verbose(0) << "t - simple merge of two molecules" << endl;
    1095   Log() << Verbose(0) << "all else - go back" << endl;
    1096   Log() << Verbose(0) << "===============================================" << endl;
    1097   Log() << Verbose(0) << "INPUT: ";
     1090  DoLog(0) && (Log() << Verbose(0) << "===========MERGE MOLECULES=====================" << endl);
     1091  DoLog(0) && (Log() << Verbose(0) << "a - simple add of one molecule to another" << endl);
     1092  DoLog(0) && (Log() << Verbose(0) << "b - count the number of bonds of two elements" << endl);
     1093  DoLog(0) && (Log() << Verbose(0) << "B - count the number of bonds of three elements " << endl);
     1094  DoLog(0) && (Log() << Verbose(0) << "e - embedding merge of two molecules" << endl);
     1095  DoLog(0) && (Log() << Verbose(0) << "h - count the number of hydrogen bonds" << endl);
     1096  DoLog(0) && (Log() << Verbose(0) << "b - count the number of hydrogen bonds" << endl);
     1097  DoLog(0) && (Log() << Verbose(0) << "m - multi-merge of all molecules" << endl);
     1098  DoLog(0) && (Log() << Verbose(0) << "s - scatter merge of two molecules" << endl);
     1099  DoLog(0) && (Log() << Verbose(0) << "t - simple merge of two molecules" << endl);
     1100  DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl);
     1101  DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
     1102  DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    10981103  cin >> choice;
    10991104
    11001105  switch (choice) {
    11011106    default:
    1102       Log() << Verbose(0) << "Not a valid choice." << endl;
     1107      DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl);
    11031108      break;
    11041109
     
    11091114        {
    11101115          do {
    1111             Log() << Verbose(0) << "Enter index of destination molecule: ";
     1116            DoLog(0) && (Log() << Verbose(0) << "Enter index of destination molecule: ");
    11121117            cin >> dest;
    11131118            destmol = molecules->ReturnIndex(dest);
    11141119          } while ((destmol == NULL) && (dest != -1));
    11151120          do {
    1116             Log() << Verbose(0) << "Enter index of source molecule to add from: ";
     1121            DoLog(0) && (Log() << Verbose(0) << "Enter index of source molecule to add from: ");
    11171122            cin >> src;
    11181123            srcmol = molecules->ReturnIndex(src);
     
    11241129      break;
    11251130
     1131    case 'b':
     1132      {
     1133        const int nr = 2;
     1134        char *names[nr] = {"first", "second"};
     1135        int Z[nr];
     1136        element *elements[nr];
     1137        for (int i=0;i<nr;i++) {
     1138          Z[i] = 0;
     1139          do {
     1140            cout << "Enter " << names[i] << " element: ";
     1141            cin >> Z[i];
     1142          } while ((Z[i] <= 0) && (Z[i] > MAX_ELEMENTS));
     1143          elements[i] = periode->FindElement(Z[i]);
     1144        }
     1145        const int count = CountBondsOfTwo(molecules, elements[0], elements[1]);
     1146        cout << endl << "There are " << count << " ";
     1147        for (int i=0;i<nr;i++) {
     1148          if (i==0)
     1149            cout << elements[i]->symbol;
     1150          else
     1151            cout << "-" << elements[i]->symbol;
     1152        }
     1153        cout << " bonds." << endl;
     1154      }
     1155    break;
     1156
     1157    case 'B':
     1158      {
     1159        const int nr = 3;
     1160        char *names[nr] = {"first", "second", "third"};
     1161        int Z[nr];
     1162        element *elements[nr];
     1163        for (int i=0;i<nr;i++) {
     1164          Z[i] = 0;
     1165          do {
     1166            cout << "Enter " << names[i] << " element: ";
     1167            cin >> Z[i];
     1168          } while ((Z[i] <= 0) && (Z[i] > MAX_ELEMENTS));
     1169          elements[i] = periode->FindElement(Z[i]);
     1170        }
     1171        const int count = CountBondsOfThree(molecules, elements[0], elements[1], elements[2]);
     1172        cout << endl << "There are " << count << " ";
     1173        for (int i=0;i<nr;i++) {
     1174          if (i==0)
     1175            cout << elements[i]->symbol;
     1176          else
     1177            cout << "-" << elements[i]->symbol;
     1178        }
     1179        cout << " bonds." << endl;
     1180      }
     1181    break;
     1182
    11261183    case 'e':
    11271184      {
     
    11291186        molecule *srcmol = NULL, *destmol = NULL;
    11301187        do {
    1131           Log() << Verbose(0) << "Enter index of matrix molecule (the variable one): ";
     1188          DoLog(0) && (Log() << Verbose(0) << "Enter index of matrix molecule (the variable one): ");
    11321189          cin >> src;
    11331190          srcmol = molecules->ReturnIndex(src);
    11341191        } while ((srcmol == NULL) && (src != -1));
    11351192        do {
    1136           Log() << Verbose(0) << "Enter index of molecule to merge into (the fixed one): ";
     1193          DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule to merge into (the fixed one): ");
    11371194          cin >> dest;
    11381195          destmol = molecules->ReturnIndex(dest);
     
    11431200      break;
    11441201
     1202    case 'h':
     1203      {
     1204        int Z;
     1205        cout << "Please enter interface element: ";
     1206        cin >> Z;
     1207        element * const InterfaceElement = periode->FindElement(Z);
     1208        cout << endl << "There are " << CountHydrogenBridgeBonds(molecules, InterfaceElement) << " hydrogen bridges with connections to " << (InterfaceElement != 0 ? InterfaceElement->name : "None") << "." << endl;
     1209      }
     1210      break;
     1211
    11451212    case 'm':
    11461213      {
     
    11481215        molecule *mol = NULL;
    11491216        do {
    1150           Log() << Verbose(0) << "Enter index of molecule to merge into: ";
     1217          DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule to merge into: ");
    11511218          cin >> nr;
    11521219          mol = molecules->ReturnIndex(nr);
     
    11651232
    11661233    case 's':
    1167       Log() << Verbose(0) << "Not implemented yet." << endl;
     1234      DoLog(0) && (Log() << Verbose(0) << "Not implemented yet." << endl);
    11681235      break;
    11691236
     
    11741241        {
    11751242          do {
    1176             Log() << Verbose(0) << "Enter index of destination molecule: ";
     1243            DoLog(0) && (Log() << Verbose(0) << "Enter index of destination molecule: ");
    11771244            cin >> dest;
    11781245            destmol = molecules->ReturnIndex(dest);
    11791246          } while ((destmol == NULL) && (dest != -1));
    11801247          do {
    1181             Log() << Verbose(0) << "Enter index of source molecule to merge into: ";
     1248            DoLog(0) && (Log() << Verbose(0) << "Enter index of source molecule to merge into: ");
    11821249            cin >> src;
    11831250            srcmol = molecules->ReturnIndex(src);
     
    12081275    mol = (molecules->ListOfMolecules.front())->CopyMolecule();
    12091276  else {
    1210     eLog() << Verbose(0) << "I don't have anything to test on ... ";
     1277    DoeLog(0) && (eLog()<< Verbose(0) << "I don't have anything to test on ... ");
    12111278    performCriticalExit();
    12121279    return;
     
    12151282
    12161283  // generate some KeySets
    1217   Log() << Verbose(0) << "Generating KeySets." << endl;
     1284  DoLog(0) && (Log() << Verbose(0) << "Generating KeySets." << endl);
    12181285  KeySet TestSets[mol->AtomCount+1];
    12191286  i=1;
     
    12251292    i++;
    12261293  }
    1227   Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl;
     1294  DoLog(0) && (Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl);
    12281295  KeySetTestPair test;
    12291296  test = TestSets[mol->AtomCount-1].insert(Walker->nr);
    12301297  if (test.second) {
    1231     Log() << Verbose(1) << "Insertion worked?!" << endl;
     1298    DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl);
    12321299  } else {
    1233     Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl;
     1300    DoLog(1) && (Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl);
    12341301  }
    12351302  TestSets[mol->AtomCount].insert(mol->end->previous->nr);
     
    12371304
    12381305  // constructing Graph structure
    1239   Log() << Verbose(0) << "Generating Subgraph class." << endl;
     1306  DoLog(0) && (Log() << Verbose(0) << "Generating Subgraph class." << endl);
    12401307  Graph Subgraphs;
    12411308
    12421309  // insert KeySets into Subgraphs
    1243   Log() << Verbose(0) << "Inserting KeySets into Subgraph class." << endl;
     1310  DoLog(0) && (Log() << Verbose(0) << "Inserting KeySets into Subgraph class." << endl);
    12441311  for (int j=0;j<mol->AtomCount;j++) {
    12451312    Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.)));
    12461313  }
    1247   Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl;
     1314  DoLog(0) && (Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl);
    12481315  GraphTestPair test2;
    12491316  test2 = Subgraphs.insert(GraphPair (TestSets[mol->AtomCount],pair<int, double>(counter++, 1.)));
    12501317  if (test2.second) {
    1251     Log() << Verbose(1) << "Insertion worked?!" << endl;
     1318    DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl);
    12521319  } else {
    1253     Log() << Verbose(1) << "Insertion rejected: Present object is " << (*(test2.first)).second.first << "." << endl;
     1320    DoLog(1) && (Log() << Verbose(1) << "Insertion rejected: Present object is " << (*(test2.first)).second.first << "." << endl);
    12541321  }
    12551322
    12561323  // show graphs
    1257   Log() << Verbose(0) << "Showing Subgraph's contents, checking that it's sorted." << endl;
     1324  DoLog(0) && (Log() << Verbose(0) << "Showing Subgraph's contents, checking that it's sorted." << endl);
    12581325  Graph::iterator A = Subgraphs.begin();
    12591326  while (A !=  Subgraphs.end()) {
    1260     Log() << Verbose(0) << (*A).second.first << ": ";
     1327    DoLog(0) && (Log() << Verbose(0) << (*A).second.first << ": ");
    12611328    KeySet::iterator key = (*A).first.begin();
    12621329    comp = -1;
    12631330    while (key != (*A).first.end()) {
    12641331      if ((*key) > comp)
    1265         Log() << Verbose(0) << (*key) << " ";
     1332        DoLog(0) && (Log() << Verbose(0) << (*key) << " ");
    12661333      else
    1267         Log() << Verbose(0) << (*key) << "! ";
     1334        DoLog(0) && (Log() << Verbose(0) << (*key) << "! ");
    12681335      comp = (*key);
    12691336      key++;
    12701337    }
    1271     Log() << Verbose(0) << endl;
     1338    DoLog(0) && (Log() << Verbose(0) << endl);
    12721339    A++;
    12731340  }
     
    12891356
    12901357  if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) {
    1291     eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl;
     1358    DoeLog(2) && (eLog()<< Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl);
    12921359  }
    12931360
     
    12981365  if (output == NULL)
    12991366    strcpy(filename,"main_pcp_linux");
    1300   Log() << Verbose(0) << "Saving as pdb input ";
     1367  DoLog(0) && (Log() << Verbose(0) << "Saving as pdb input ");
    13011368  if (configuration->SavePDB(filename, molecules))
    1302     Log() << Verbose(0) << "done." << endl;
     1369    DoLog(0) && (Log() << Verbose(0) << "done." << endl);
    13031370  else
    1304     Log() << Verbose(0) << "failed." << endl;
     1371    DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
    13051372
    13061373  // then save as tremolo data file
     
    13091376  if (output == NULL)
    13101377    strcpy(filename,"main_pcp_linux");
    1311   Log() << Verbose(0) << "Saving as tremolo data input ";
     1378  DoLog(0) && (Log() << Verbose(0) << "Saving as tremolo data input ");
    13121379  if (configuration->SaveTREMOLO(filename, molecules))
    1313     Log() << Verbose(0) << "done." << endl;
     1380    DoLog(0) && (Log() << Verbose(0) << "done." << endl);
    13141381  else
    1315     Log() << Verbose(0) << "failed." << endl;
     1382    DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
    13161383
    13171384  // translate each to its center and merge all molecules in MoleculeListClass into this molecule
     
    13331400  }
    13341401
    1335   Log() << Verbose(0) << "Storing configuration ... " << endl;
     1402  DoLog(0) && (Log() << Verbose(0) << "Storing configuration ... " << endl);
    13361403  // get correct valence orbitals
    13371404  mol->CalculateOrbitals(*configuration);
     
    13491416  output.close();
    13501417  output.clear();
    1351   Log() << Verbose(0) << "Saving of config file ";
     1418  DoLog(0) && (Log() << Verbose(0) << "Saving of config file ");
    13521419  if (configuration->Save(filename, periode, mol))
    1353     Log() << Verbose(0) << "successful." << endl;
     1420    DoLog(0) && (Log() << Verbose(0) << "successful." << endl);
    13541421  else
    1355     Log() << Verbose(0) << "failed." << endl;
     1422    DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
    13561423
    13571424  // and save to xyz file
     
    13661433    output.open(filename, ios::trunc);
    13671434  }
    1368   Log() << Verbose(0) << "Saving of XYZ file ";
     1435  DoLog(0) && (Log() << Verbose(0) << "Saving of XYZ file ");
    13691436  if (mol->MDSteps <= 1) {
    13701437    if (mol->OutputXYZ(&output))
    1371       Log() << Verbose(0) << "successful." << endl;
     1438      DoLog(0) && (Log() << Verbose(0) << "successful." << endl);
    13721439    else
    1373       Log() << Verbose(0) << "failed." << endl;
     1440      DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
    13741441  } else {
    13751442    if (mol->OutputTrajectoriesXYZ(&output))
    1376       Log() << Verbose(0) << "successful." << endl;
     1443      DoLog(0) && (Log() << Verbose(0) << "successful." << endl);
    13771444    else
    1378       Log() << Verbose(0) << "failed." << endl;
     1445      DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
    13791446  }
    13801447  output.close();
     
    13861453  if (output == NULL)
    13871454    strcpy(filename,"main_pcp_linux");
    1388   Log() << Verbose(0) << "Saving as mpqc input ";
     1455  DoLog(0) && (Log() << Verbose(0) << "Saving as mpqc input ");
    13891456  if (configuration->SaveMPQC(filename, mol))
    1390     Log() << Verbose(0) << "done." << endl;
     1457    DoLog(0) && (Log() << Verbose(0) << "done." << endl);
    13911458  else
    1392     Log() << Verbose(0) << "failed." << endl;
     1459    DoLog(0) && (Log() << Verbose(0) << "failed." << endl);
    13931460
    13941461  if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) {
    1395     eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl;
     1462    DoeLog(2) && (eLog()<< Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl);
    13961463  }
    13971464
     
    14351502    do {
    14361503      if (argv[argptr][0] == '-') {
    1437         Log() << Verbose(0) << "Recognized command line argument: " << argv[argptr][1] << ".\n";
     1504        DoLog(0) && (Log() << Verbose(0) << "Recognized command line argument: " << argv[argptr][1] << ".\n");
    14381505        argptr++;
    14391506        switch(argv[argptr-1][1]) {
     
    14411508          case 'H':
    14421509          case '?':
    1443             Log() << Verbose(0) << "MoleCuilder suite" << endl << "==================" << endl << endl;
    1444             Log() << Verbose(0) << "Usage: " << argv[0] << "[config file] [-{acefpsthH?vfrp}] [further arguments]" << endl;
    1445             Log() << Verbose(0) << "or simply " << argv[0] << " without arguments for interactive session." << endl;
    1446             Log() << Verbose(0) << "\t-a Z x1 x2 x3\tAdd new atom of element Z at coordinates (x1,x2,x3)." << endl;
    1447             Log() << Verbose(0) << "\t-A <source>\tCreate adjacency list from bonds parsed from 'dbond'-style file." <<endl;
    1448             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;
    1449             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;
    1450             Log() << Verbose(0) << "\t-c x1 x2 x3\tCenter atoms in domain with a minimum distance to boundary of (x1,x2,x3)." << endl;
    1451             Log() << Verbose(0) << "\t-C <type> [params] <output> <bin output> <BinWidth> <BinStart> <BinEnd>\tPair Correlation analysis." << endl;
    1452             Log() << Verbose(0) << "\t-d x1 x2 x3\tDuplicate cell along each axis by given factor." << endl;
    1453             Log() << Verbose(0) << "\t-D <bond distance>\tDepth-First-Search Analysis of the molecule, giving cycles and tree/back edges." << endl;
    1454             Log() << Verbose(0) << "\t-e <file>\tSets the databases path to be parsed (default: ./)." << endl;
    1455             Log() << Verbose(0) << "\t-E <id> <Z>\tChange atom <id>'s element to <Z>, <id> begins at 0." << endl;
    1456             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;
    1457             Log() << Verbose(0) << "\t-F <xyz of filler> <dist_x> <dist_y> <dist_z> <epsilon> <randatom> <randmol> <DoRotate>\tFilling Box with water molecules." << endl;
    1458             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;
    1459             Log() << Verbose(0) << "\t-g <file>\tParses a bond length table from the given file." << endl;
    1460             Log() << Verbose(0) << "\t-h/-H/-?\tGive this help screen." << endl;
    1461             Log() << Verbose(0) << "\t-I\t Dissect current system of molecules into a set of disconnected (subgraphs of) molecules." << endl;
    1462             Log() << Verbose(0) << "\t-j\t<path> Store all bonds to file." << endl;
    1463             Log() << Verbose(0) << "\t-J\t<path> Store adjacency per atom to file." << endl;
    1464             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;
    1465             Log() << Verbose(0) << "\t-m <0/1>\tCalculate (0)/ Align in(1) PAS with greatest EV along z axis." << endl;
    1466             Log() << Verbose(0) << "\t-M <basis>\tSetting basis to store to MPQC config files." << endl;
    1467             Log() << Verbose(0) << "\t-n\tFast parsing (i.e. no trajectories are looked for)." << endl;
    1468             Log() << Verbose(0) << "\t-N <radius> <file>\tGet non-convex-envelope." << endl;
    1469             Log() << Verbose(0) << "\t-o <out>\tGet volume of the convex envelope (and store to tecplot file)." << endl;
    1470             Log() << Verbose(0) << "\t-O\tCenter atoms in origin." << endl;
    1471             Log() << Verbose(0) << "\t-p <file>\tParse given xyz file and create raw config file from it." << endl;
    1472             Log() << Verbose(0) << "\t-P <file>\tParse given forces file and append as an MD step to config file via Verlet." << endl;
    1473             Log() << Verbose(0) << "\t-r <id>\t\tRemove an atom with given id." << endl;
    1474             Log() << Verbose(0) << "\t-R <id> <radius>\t\tRemove all atoms out of sphere around a given one." << endl;
    1475             Log() << Verbose(0) << "\t-s x1 x2 x3\tScale all atom coordinates by this vector (x1,x2,x3)." << endl;
    1476             Log() << Verbose(0) << "\t-S <file> Store temperatures from the config file in <file>." << endl;
    1477             Log() << Verbose(0) << "\t-t x1 x2 x3\tTranslate all atoms by this vector (x1,x2,x3)." << endl;
    1478             Log() << Verbose(0) << "\t-T x1 x2 x3\tTranslate periodically all atoms by this vector (x1,x2,x3)." << endl;
    1479             Log() << Verbose(0) << "\t-u rho\tsuspend in water solution and output necessary cell lengths, average density rho and repetition." << endl;
    1480             Log() << Verbose(0) << "\t-v\t\tsets verbosity (more is more)." << endl;
    1481             Log() << Verbose(0) << "\t-V\t\tGives version information." << endl;
    1482             Log() << Verbose(0) << "Note: config files must not begin with '-' !" << endl;
     1510            DoLog(0) && (Log() << Verbose(0) << "MoleCuilder suite" << endl << "==================" << endl << endl);
     1511            DoLog(0) && (Log() << Verbose(0) << "Usage: " << argv[0] << "[config file] [-{acefpsthH?vfrp}] [further arguments]" << endl);
     1512            DoLog(0) && (Log() << Verbose(0) << "or simply " << argv[0] << " without arguments for interactive session." << endl);
     1513            DoLog(0) && (Log() << Verbose(0) << "\t-a Z x1 x2 x3\tAdd new atom of element Z at coordinates (x1,x2,x3)." << endl);
     1514            DoLog(0) && (Log() << Verbose(0) << "\t-A <source>\tCreate adjacency list from bonds parsed from 'dbond'-style file." <<endl);
     1515            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);
     1516            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);
     1517            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);
     1518            DoLog(0) && (Log() << Verbose(0) << "\t-C <type> [params] <output> <bin output> <BinWidth> <BinStart> <BinEnd>\tPair Correlation analysis." << endl);
     1519            DoLog(0) && (Log() << Verbose(0) << "\t-d x1 x2 x3\tDuplicate cell along each axis by given factor." << endl);
     1520            DoLog(0) && (Log() << Verbose(0) << "\t-D <bond distance>\tDepth-First-Search Analysis of the molecule, giving cycles and tree/back edges." << endl);
     1521            DoLog(0) && (Log() << Verbose(0) << "\t-e <file>\tSets the databases path to be parsed (default: ./)." << endl);
     1522            DoLog(0) && (Log() << Verbose(0) << "\t-E <id> <Z>\tChange atom <id>'s element to <Z>, <id> begins at 0." << endl);
     1523            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);
     1524            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);
     1525            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);
     1526            DoLog(0) && (Log() << Verbose(0) << "\t-g <file>\tParses a bond length table from the given file." << endl);
     1527            DoLog(0) && (Log() << Verbose(0) << "\t-h/-H/-?\tGive this help screen." << endl);
     1528            DoLog(0) && (Log() << Verbose(0) << "\t-I\t Dissect current system of molecules into a set of disconnected (subgraphs of) molecules." << endl);
     1529            DoLog(0) && (Log() << Verbose(0) << "\t-j\t<path> Store all bonds to file." << endl);
     1530            DoLog(0) && (Log() << Verbose(0) << "\t-J\t<path> Store adjacency per atom to file." << endl);
     1531            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);
     1532            DoLog(0) && (Log() << Verbose(0) << "\t-m <0/1>\tCalculate (0)/ Align in(1) PAS with greatest EV along z axis." << endl);
     1533            DoLog(0) && (Log() << Verbose(0) << "\t-M <basis>\tSetting basis to store to MPQC config files." << endl);
     1534            DoLog(0) && (Log() << Verbose(0) << "\t-n\tFast parsing (i.e. no trajectories are looked for)." << endl);
     1535            DoLog(0) && (Log() << Verbose(0) << "\t-N <radius> <file>\tGet non-convex-envelope." << endl);
     1536            DoLog(0) && (Log() << Verbose(0) << "\t-o <out>\tGet volume of the convex envelope (and store to tecplot file)." << endl);
     1537            DoLog(0) && (Log() << Verbose(0) << "\t-O\tCenter atoms in origin." << endl);
     1538            DoLog(0) && (Log() << Verbose(0) << "\t-p <file>\tParse given xyz file and create raw config file from it." << endl);
     1539            DoLog(0) && (Log() << Verbose(0) << "\t-P <file>\tParse given forces file and append as an MD step to config file via Verlet." << endl);
     1540            DoLog(0) && (Log() << Verbose(0) << "\t-r <id>\t\tRemove an atom with given id." << endl);
     1541            DoLog(0) && (Log() << Verbose(0) << "\t-R <id> <radius>\t\tRemove all atoms out of sphere around a given one." << endl);
     1542            DoLog(0) && (Log() << Verbose(0) << "\t-s x1 x2 x3\tScale all atom coordinates by this vector (x1,x2,x3)." << endl);
     1543            DoLog(0) && (Log() << Verbose(0) << "\t-S <file> Store temperatures from the config file in <file>." << endl);
     1544            DoLog(0) && (Log() << Verbose(0) << "\t-t x1 x2 x3\tTranslate all atoms by this vector (x1,x2,x3)." << endl);
     1545            DoLog(0) && (Log() << Verbose(0) << "\t-T x1 x2 x3\tTranslate periodically all atoms by this vector (x1,x2,x3)." << endl);
     1546            DoLog(0) && (Log() << Verbose(0) << "\t-u rho\tsuspend in water solution and output necessary cell lengths, average density rho and repetition." << endl);
     1547            DoLog(0) && (Log() << Verbose(0) << "\t-v\t\tsets verbosity (more is more)." << endl);
     1548            DoLog(0) && (Log() << Verbose(0) << "\t-V\t\tGives version information." << endl);
     1549            DoLog(0) && (Log() << Verbose(0) << "\t-X\t\tset default name of a molecule." << endl);
     1550            DoLog(0) && (Log() << Verbose(0) << "Note: config files must not begin with '-' !" << endl);
    14831551            return (1);
    14841552            break;
     
    14881556            }
    14891557            setVerbosity(verbosity);
    1490             Log() << Verbose(0) << "Setting verbosity to " << verbosity << "." << endl;
     1558            DoLog(0) && (Log() << Verbose(0) << "Setting verbosity to " << verbosity << "." << endl);
    14911559            break;
    14921560          case 'V':
    1493             Log() << Verbose(0) << argv[0] << " " << VERSIONSTRING << endl;
    1494             Log() << Verbose(0) << "Build your own molecule position set." << endl;
     1561            DoLog(0) && (Log() << Verbose(0) << argv[0] << " " << VERSIONSTRING << endl);
     1562            DoLog(0) && (Log() << Verbose(0) << "Build your own molecule position set." << endl);
    14951563            return (1);
     1564            break;
     1565          case 'B':
     1566            if (ExitFlag == 0) ExitFlag = 1;
     1567            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])) ) {
     1568              ExitFlag = 255;
     1569              DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for bounding in box: -B <xx> <xy> <xz> <yy> <yz> <zz>" << endl);
     1570              performCriticalExit();
     1571            } else {
     1572              SaveFlag = true;
     1573              j = -1;
     1574              DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl);
     1575              double * const cell_size = World::get()->cell_size;
     1576              for (int i=0;i<6;i++) {
     1577                cell_size[i] = atof(argv[argptr+i]);
     1578              }
     1579              argptr+=6;
     1580            }
    14961581            break;
    14971582          case 'e':
    14981583            if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    1499               eLog() << Verbose(0) << "Not enough or invalid arguments for specifying element db: -e <db file>" << endl;
     1584              DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for specifying element db: -e <db file>" << endl);
    15001585              performCriticalExit();
    15011586            } else {
    1502               Log() << Verbose(0) << "Using " << argv[argptr] << " as elements database." << endl;
     1587              DoLog(0) && (Log() << Verbose(0) << "Using " << argv[argptr] << " as elements database." << endl);
    15031588              strncpy (configuration.databasepath, argv[argptr], MAXSTRINGSIZE-1);
    15041589              argptr+=1;
     
    15071592          case 'g':
    15081593            if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    1509               eLog() << Verbose(0) << "Not enough or invalid arguments for specifying bond length table: -g <table file>" << endl;
     1594              DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for specifying bond length table: -g <table file>" << endl);
    15101595              performCriticalExit();
    15111596            } else {
    15121597              BondGraphFileName = argv[argptr];
    1513               Log() << Verbose(0) << "Using " << BondGraphFileName << " as bond length table." << endl;
     1598              DoLog(0) && (Log() << Verbose(0) << "Using " << BondGraphFileName << " as bond length table." << endl);
    15141599              argptr+=1;
    15151600            }
    15161601            break;
    15171602          case 'n':
    1518             Log() << Verbose(0) << "I won't parse trajectories." << endl;
     1603            DoLog(0) && (Log() << Verbose(0) << "I won't parse trajectories." << endl);
    15191604            configuration.FastParsing = true;
     1605            break;
     1606          case 'X':
     1607            {
     1608              char **name = &(World::get()->DefaultName);
     1609              delete[](*name);
     1610              const int length = strlen(argv[argptr]);
     1611              *name = new char[length+2];
     1612              strncpy(*name, argv[argptr], length);
     1613              DoLog(0) && (Log() << Verbose(0) << "Default name of new molecules set to " << *name << "." << endl);
     1614            }
    15201615            break;
    15211616          default:   // no match? Step on
     
    15291624    // 3a. Parse the element database
    15301625    if (periode->LoadPeriodentafel(configuration.databasepath)) {
    1531       Log() << Verbose(0) << "Element list loaded successfully." << endl;
     1626      DoLog(0) && (Log() << Verbose(0) << "Element list loaded successfully." << endl);
    15321627      //periode->Output();
    15331628    } else {
    1534       Log() << Verbose(0) << "Element list loading failed." << endl;
     1629      DoLog(0) && (Log() << Verbose(0) << "Element list loading failed." << endl);
    15351630      return 1;
    15361631    }
     
    15381633    if (argv[1][0] != '-') {
    15391634      // simply create a new molecule, wherein the config file is loaded and the manipulation takes place
    1540       Log() << Verbose(0) << "Config file given." << endl;
     1635      DoLog(0) && (Log() << Verbose(0) << "Config file given." << endl);
    15411636      test.open(argv[1], ios::in);
    15421637      if (test == NULL) {
     
    15441639        output.open(argv[1], ios::out);
    15451640        if (output == NULL) {
    1546           Log() << Verbose(1) << "Specified config file " << argv[1] << " not found." << endl;
     1641          DoLog(1) && (Log() << Verbose(1) << "Specified config file " << argv[1] << " not found." << endl);
    15471642          configPresent = absent;
    15481643        } else {
    1549           Log() << Verbose(0) << "Empty configuration file." << endl;
     1644          DoLog(0) && (Log() << Verbose(0) << "Empty configuration file." << endl);
    15501645          ConfigFileName = argv[1];
    15511646          configPresent = empty;
     
    15551650        test.close();
    15561651        ConfigFileName = argv[1];
    1557         Log() << Verbose(1) << "Specified config file found, parsing ... ";
     1652        DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... ");
    15581653        switch (configuration.TestSyntax(ConfigFileName, periode)) {
    15591654          case 1:
    1560             Log() << Verbose(0) << "new syntax." << endl;
     1655            DoLog(0) && (Log() << Verbose(0) << "new syntax." << endl);
    15611656            configuration.Load(ConfigFileName, BondGraphFileName, periode, molecules);
    15621657            configPresent = present;
    15631658            break;
    15641659          case 0:
    1565             Log() << Verbose(0) << "old syntax." << endl;
     1660            DoLog(0) && (Log() << Verbose(0) << "old syntax." << endl);
    15661661            configuration.LoadOld(ConfigFileName, BondGraphFileName, periode, molecules);
    15671662            configPresent = present;
    15681663            break;
    15691664          default:
    1570             Log() << Verbose(0) << "Unknown syntax or empty, yet present file." << endl;
     1665            DoLog(0) && (Log() << Verbose(0) << "Unknown syntax or empty, yet present file." << endl);
    15711666            configPresent = empty;
    15721667       }
     
    15921687       configuration.BG = new BondGraph(configuration.GetIsAngstroem());
    15931688       if ((!BondGraphFileName.empty()) && (configuration.BG->LoadBondLengthTable(BondGraphFileName))) {
    1594          Log() << Verbose(0) << "Bond length table loaded successfully." << endl;
     1689         DoLog(0) && (Log() << Verbose(0) << "Bond length table loaded successfully." << endl);
    15951690       } else {
    1596          eLog() << Verbose(1) << "Bond length table loading failed." << endl;
     1691         DoeLog(1) && (eLog()<< Verbose(1) << "Bond length table loading failed." << endl);
    15971692       }
    15981693     }
     
    16011696    argptr = 1;
    16021697    do {
    1603       Log() << Verbose(0) << "Current Command line argument: " << argv[argptr] << "." << endl;
     1698      DoLog(0) && (Log() << Verbose(0) << "Current Command line argument: " << argv[argptr] << "." << endl);
    16041699      if (argv[argptr][0] == '-') {
    16051700        argptr++;
     
    16101705              if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    16111706                ExitFlag = 255;
    1612                 eLog() << Verbose(0) << "Not enough arguments for parsing: -p <xyz file>" << endl;
     1707                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough arguments for parsing: -p <xyz file>" << endl);
    16131708                performCriticalExit();
    16141709              } else {
    16151710                SaveFlag = true;
    1616                 Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl;
     1711                DoLog(1) && (Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl);
    16171712                if (!mol->AddXYZFile(argv[argptr]))
    1618                   Log() << Verbose(2) << "File not found." << endl;
     1713                  DoLog(2) && (Log() << Verbose(2) << "File not found." << endl);
    16191714                else {
    1620                   Log() << Verbose(2) << "File found and parsed." << endl;
     1715                  DoLog(2) && (Log() << Verbose(2) << "File found and parsed." << endl);
    16211716                  configPresent = present;
    16221717                }
     
    16271722              if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3]))) {
    16281723                ExitFlag = 255;
    1629                 eLog() << Verbose(0) << "Not enough or invalid arguments for adding atom: -a <element> <x> <y> <z>" << endl;
     1724                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for adding atom: -a <element> <x> <y> <z>" << endl);
    16301725                performCriticalExit();
    16311726              } else {
    16321727                SaveFlag = true;
    1633                 Log() << Verbose(1) << "Adding new atom with element " << argv[argptr] << " at (" << argv[argptr+1] << "," << argv[argptr+2] << "," << argv[argptr+3] << "), ";
     1728                DoLog(1) && (Log() << Verbose(1) << "Adding new atom with element " << argv[argptr] << " at (" << argv[argptr+1] << "," << argv[argptr+2] << "," << argv[argptr+3] << "), ");
    16341729                first = new atom;
    16351730                first->type = periode->FindElement(atoi(argv[argptr]));
    16361731                if (first->type != NULL)
    1637                   Log() << Verbose(2) << "found element " << first->type->name << endl;
     1732                  DoLog(2) && (Log() << Verbose(2) << "found element " << first->type->name << endl);
    16381733                for (int i=NDIM;i--;)
    16391734                  first->x.x[i] = atof(argv[argptr+1+i]);
     
    16431738                    configPresent = present;
    16441739                } else
    1645                   eLog() << Verbose(1) << "Could not find the specified element." << endl;
     1740                  DoeLog(1) && (eLog()<< Verbose(1) << "Could not find the specified element." << endl);
    16461741                argptr+=4;
    16471742              }
     
    16561751              if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    16571752                ExitFlag = 255;
    1658                 eLog() << Verbose(0) << "Not enough or invalid arguments given for setting MPQC basis: -B <basis name>" << endl;
     1753                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for setting MPQC basis: -B <basis name>" << endl);
    16591754                performCriticalExit();
    16601755              } else {
    16611756                configuration.basis = argv[argptr];
    1662                 Log() << Verbose(1) << "Setting MPQC basis to " << configuration.basis << "." << endl;
     1757                DoLog(1) && (Log() << Verbose(1) << "Setting MPQC basis to " << configuration.basis << "." << endl);
    16631758                argptr+=1;
    16641759              }
     
    16671762              if (ExitFlag == 0) ExitFlag = 1;
    16681763              {
    1669                 Log() << Verbose(1) << "Depth-First-Search Analysis." << endl;
     1764                DoLog(1) && (Log() << Verbose(1) << "Depth-First-Search Analysis." << endl);
    16701765                MoleculeLeafClass *Subgraphs = NULL;      // list of subgraphs from DFS analysis
    16711766                int *MinimumRingSize = new int[mol->AtomCount];
     
    16981793              break;
    16991794            case 'I':
    1700               Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl;
     1795              DoLog(1) && (Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl);
    17011796              // @TODO rather do the dissection afterwards
    17021797              molecules->DissectMoleculeIntoConnectedSubgraphs(periode, &configuration);
     
    17091804                  }
    17101805              }
    1711               if (mol == NULL) {
     1806              if ((mol == NULL) && (!molecules->ListOfMolecules.empty())) {
    17121807                mol = *(molecules->ListOfMolecules.begin());
    1713                 mol->ActiveFlag = true;
     1808                if (mol != NULL)
     1809                  mol->ActiveFlag = true;
    17141810              }
    17151811              break;
    17161812            case 'C':
    1717               if (ExitFlag == 0) ExitFlag = 1;
    1718               if ((argptr >= argc)) {
    1719                 ExitFlag = 255;
    1720                 eLog() << Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C <type: E/P/S> [more params] <output> <bin output> <BinStart> <BinEnd>" << endl;
    1721                 performCriticalExit();
    1722               } else {
    1723                 switch(argv[argptr][0]) {
    1724                   case 'E':
    1725                     {
    1726                       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] == '-')) {
    1727                         ExitFlag = 255;
    1728                         eLog() << Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C E <Z1> <Z2> <output> <bin output>" << endl;
    1729                         performCriticalExit();
    1730                       } else {
    1731                         ofstream output(argv[argptr+3]);
    1732                         ofstream binoutput(argv[argptr+4]);
    1733                         const double BinStart = atof(argv[argptr+5]);
    1734                         const double BinEnd = atof(argv[argptr+6]);
    1735 
    1736                         element *elemental = periode->FindElement((const int) atoi(argv[argptr+1]));
    1737                         element *elemental2 = periode->FindElement((const int) atoi(argv[argptr+2]));
    1738                         PairCorrelationMap *correlationmap = PairCorrelation(molecules, elemental, elemental2);
    1739                         //OutputCorrelationToSurface(&output, correlationmap);
    1740                         BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd );
    1741                         OutputCorrelation ( &binoutput, binmap );
    1742                         output.close();
    1743                         binoutput.close();
    1744                         delete(binmap);
    1745                         delete(correlationmap);
    1746                         argptr+=7;
     1813              {
     1814                int ranges[3] = {1, 1, 1};
     1815                bool periodic = (argv[argptr-1][2] =='p');
     1816                if (ExitFlag == 0) ExitFlag = 1;
     1817                if ((argptr >= argc)) {
     1818                  ExitFlag = 255;
     1819                  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);
     1820                  performCriticalExit();
     1821                } else {
     1822                  switch(argv[argptr][0]) {
     1823                    case 'E':
     1824                      {
     1825                        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] == '-')) {
     1826                          ExitFlag = 255;
     1827                          DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C E <Z1> <Z2> <output> <bin output>" << endl);
     1828                          performCriticalExit();
     1829                        } else {
     1830                          ofstream output(argv[argptr+3]);
     1831                          ofstream binoutput(argv[argptr+4]);
     1832                          const double BinStart = atof(argv[argptr+5]);
     1833                          const double BinEnd = atof(argv[argptr+6]);
     1834
     1835                          element *elemental = periode->FindElement((const int) atoi(argv[argptr+1]));
     1836                          element *elemental2 = periode->FindElement((const int) atoi(argv[argptr+2]));
     1837                          PairCorrelationMap *correlationmap = NULL;
     1838                          if (periodic)
     1839                            correlationmap = PeriodicPairCorrelation(molecules, elemental, elemental2, ranges);
     1840                          else
     1841                            correlationmap = PairCorrelation(molecules, elemental, elemental2);
     1842                          //OutputCorrelationToSurface(&output, correlationmap);
     1843                          BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd );
     1844                          OutputCorrelation ( &binoutput, binmap );
     1845                          output.close();
     1846                          binoutput.close();
     1847                          delete(binmap);
     1848                          delete(correlationmap);
     1849                          argptr+=7;
     1850                        }
    17471851                      }
    1748                     }
    1749                     break;
    1750 
    1751                   case 'P':
    1752                     {
    1753                       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] == '-')) {
    1754                         ExitFlag = 255;
    1755                         eLog() << Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C P <Z1> <x> <y> <z> <output> <bin output>" << endl;
    1756                         performCriticalExit();
    1757                       } else {
    1758                         ofstream output(argv[argptr+5]);
    1759                         ofstream binoutput(argv[argptr+6]);
    1760                         const double BinStart = atof(argv[argptr+7]);
    1761                         const double BinEnd = atof(argv[argptr+8]);
    1762 
    1763                         element *elemental = periode->FindElement((const int) atoi(argv[argptr+1]));
    1764                         Vector *Point = new Vector((const double) atof(argv[argptr+1]),(const double) atof(argv[argptr+2]),(const double) atof(argv[argptr+3]));
    1765                         CorrelationToPointMap *correlationmap = CorrelationToPoint(molecules, elemental, Point);
    1766                         //OutputCorrelationToSurface(&output, correlationmap);
    1767                         BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd );
    1768                         OutputCorrelation ( &binoutput, binmap );
    1769                         output.close();
    1770                         binoutput.close();
    1771                         delete(Point);
    1772                         delete(binmap);
    1773                         delete(correlationmap);
    1774                         argptr+=9;
     1852                      break;
     1853
     1854                    case 'P':
     1855                      {
     1856                        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] == '-')) {
     1857                          ExitFlag = 255;
     1858                          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);
     1859                          performCriticalExit();
     1860                        } else {
     1861                          ofstream output(argv[argptr+5]);
     1862                          ofstream binoutput(argv[argptr+6]);
     1863                          const double BinStart = atof(argv[argptr+7]);
     1864                          const double BinEnd = atof(argv[argptr+8]);
     1865
     1866                          element *elemental = periode->FindElement((const int) atoi(argv[argptr+1]));
     1867                          Vector *Point = new Vector((const double) atof(argv[argptr+1]),(const double) atof(argv[argptr+2]),(const double) atof(argv[argptr+3]));
     1868                          CorrelationToPointMap *correlationmap = NULL;
     1869                          if (periodic)
     1870                            correlationmap  = PeriodicCorrelationToPoint(molecules, elemental, Point, ranges);
     1871                          else
     1872                            correlationmap = CorrelationToPoint(molecules, elemental, Point);
     1873                          //OutputCorrelationToSurface(&output, correlationmap);
     1874                          BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd );
     1875                          OutputCorrelation ( &binoutput, binmap );
     1876                          output.close();
     1877                          binoutput.close();
     1878                          delete(Point);
     1879                          delete(binmap);
     1880                          delete(correlationmap);
     1881                          argptr+=9;
     1882                        }
    17751883                      }
    1776                     }
    1777                     break;
    1778 
    1779                   case 'S':
    1780                     {
    1781                       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] == '-')) {
    1782                         ExitFlag = 255;
    1783                         eLog() << Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C S <Z> <output> <bin output> <BinWidth> <BinStart> <BinEnd>" << endl;
    1784                         performCriticalExit();
    1785                       } else {
    1786                         ofstream output(argv[argptr+2]);
    1787                         ofstream binoutput(argv[argptr+3]);
    1788                         const double radius = 4.;
    1789                         const double BinWidth = atof(argv[argptr+4]);
    1790                         const double BinStart = atof(argv[argptr+5]);
    1791                         const double BinEnd = atof(argv[argptr+6]);
    1792                         double LCWidth = 20.;
    1793                         if (BinEnd > 0) {
    1794                           if (BinEnd > 2.*radius)
    1795                               LCWidth = BinEnd;
     1884                      break;
     1885
     1886                    case 'S':
     1887                      {
     1888                        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] == '-')) {
     1889                          ExitFlag = 255;
     1890                          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);
     1891                          performCriticalExit();
     1892                        } else {
     1893                          ofstream output(argv[argptr+2]);
     1894                          ofstream binoutput(argv[argptr+3]);
     1895                          const double radius = 4.;
     1896                          const double BinWidth = atof(argv[argptr+4]);
     1897                          const double BinStart = atof(argv[argptr+5]);
     1898                          const double BinEnd = atof(argv[argptr+6]);
     1899                          double LCWidth = 20.;
     1900                          if (BinEnd > 0) {
     1901                            if (BinEnd > 2.*radius)
     1902                                LCWidth = BinEnd;
     1903                            else
     1904                              LCWidth = 2.*radius;
     1905                          }
     1906
     1907                          // get the boundary
     1908                          class molecule *Boundary = NULL;
     1909                          class Tesselation *TesselStruct = NULL;
     1910                          const LinkedCell *LCList = NULL;
     1911                          // find biggest molecule
     1912                          int counter  = 0;
     1913                          for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
     1914                            if ((Boundary == NULL) || (Boundary->AtomCount < (*BigFinder)->AtomCount)) {
     1915                              Boundary = *BigFinder;
     1916                            }
     1917                            counter++;
     1918                          }
     1919                          bool *Actives = Malloc<bool>(counter, "ParseCommandLineOptions() - case C -- *Actives");
     1920                          counter = 0;
     1921                          for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
     1922                            Actives[counter++] = (*BigFinder)->ActiveFlag;
     1923                            (*BigFinder)->ActiveFlag = (*BigFinder == Boundary) ? false : true;
     1924                          }
     1925                          LCList = new LinkedCell(Boundary, LCWidth);
     1926                          element *elemental = periode->FindElement((const int) atoi(argv[argptr+1]));
     1927                          FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL);
     1928                          CorrelationToSurfaceMap *surfacemap = NULL;
     1929                          if (periodic)
     1930                            surfacemap = PeriodicCorrelationToSurface( molecules, elemental, TesselStruct, LCList, ranges);
    17961931                          else
    1797                             LCWidth = 2.*radius;
     1932                            surfacemap = CorrelationToSurface( molecules, elemental, TesselStruct, LCList);
     1933                          OutputCorrelationToSurface(&output, surfacemap);
     1934                          // check whether radius was appropriate
     1935                          {
     1936                            double start; double end;
     1937                            GetMinMax( surfacemap, start, end);
     1938                            if (LCWidth < end)
     1939                              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);
     1940                          }
     1941                          BinPairMap *binmap = BinData( surfacemap, BinWidth, BinStart, BinEnd );
     1942                          OutputCorrelation ( &binoutput, binmap );
     1943                          output.close();
     1944                          binoutput.close();
     1945                          for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++)
     1946                            (*BigFinder)->ActiveFlag = Actives[counter++];
     1947                          Free(&Actives);
     1948                          delete(LCList);
     1949                          delete(TesselStruct);
     1950                          delete(binmap);
     1951                          delete(surfacemap);
     1952                          argptr+=7;
    17981953                        }
    1799 
    1800                         // get the boundary
    1801                         class molecule *Boundary = NULL;
    1802                         class Tesselation *TesselStruct = NULL;
    1803                         const LinkedCell *LCList = NULL;
    1804                         // find biggest molecule
    1805                         int counter  = 0;
    1806                         for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
    1807                           if ((Boundary == NULL) || (Boundary->AtomCount < (*BigFinder)->AtomCount)) {
    1808                             Boundary = *BigFinder;
    1809                           }
    1810                           counter++;
    1811                         }
    1812                         bool *Actives = Malloc<bool>(counter, "ParseCommandLineOptions() - case C -- *Actives");
    1813                         counter = 0;
    1814                         for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
    1815                           Actives[counter++] = (*BigFinder)->ActiveFlag;
    1816                           (*BigFinder)->ActiveFlag = (*BigFinder == Boundary) ? false : true;
    1817                         }
    1818                         LCList = new LinkedCell(Boundary, LCWidth);
    1819                         element *elemental = periode->FindElement((const int) atoi(argv[argptr+1]));
    1820                         FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL);
    1821                         //int ranges[NDIM] = {1,1,1};
    1822                         CorrelationToSurfaceMap *surfacemap = CorrelationToSurface( molecules, elemental, TesselStruct, LCList); // for Periodic..(): ..., ranges );
    1823                         OutputCorrelationToSurface(&output, surfacemap);
    1824                         // check whether radius was appropriate
    1825                         {
    1826                         double start; double end;
    1827                         GetMinMax( surfacemap, start, end);
    1828                         if (LCWidth < end)
    1829                           eLog() << Verbose(1) << "Linked Cell width is smaller than the found range of values! Bins can only be correct up to: " << radius << "." << endl;
    1830                         }
    1831                         BinPairMap *binmap = BinData( surfacemap, BinWidth, BinStart, BinEnd );
    1832                         OutputCorrelation ( &binoutput, binmap );
    1833                         output.close();
    1834                         binoutput.close();
    1835                         for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++)
    1836                           (*BigFinder)->ActiveFlag = Actives[counter++];
    1837                         Free(&Actives);
    1838                         delete(LCList);
    1839                         delete(TesselStruct);
    1840                         delete(binmap);
    1841                         delete(surfacemap);
    1842                         argptr+=7;
    18431954                      }
    1844                     }
    1845                     break;
    1846 
    1847                   default:
    1848                     ExitFlag = 255;
    1849                     eLog() << Verbose(0) << "Invalid type given for pair correlation analysis: -C <type: E/P/S> [more params] <output> <bin output>" << endl;
    1850                     performCriticalExit();
    1851                     break;
     1955                      break;
     1956
     1957                    default:
     1958                      ExitFlag = 255;
     1959                      DoeLog(0) && (eLog()<< Verbose(0) << "Invalid type given for pair correlation analysis: -C <type: E/P/S> [more params] <output> <bin output>" << endl);
     1960                      performCriticalExit();
     1961                      break;
     1962                  }
    18521963                }
    1853               }
    1854               break;
     1964                break;
     1965              }
    18551966            case 'E':
    18561967              if (ExitFlag == 0) ExitFlag = 1;
    18571968              if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (argv[argptr+1][0] == '-')) {
    18581969                ExitFlag = 255;
    1859                 eLog() << Verbose(0) << "Not enough or invalid arguments given for changing element: -E <atom nr.> <element>" << endl;
     1970                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for changing element: -E <atom nr.> <element>" << endl);
    18601971                performCriticalExit();
    18611972              } else {
    18621973                SaveFlag = true;
    1863                 Log() << Verbose(1) << "Changing atom " << argv[argptr] << " to element " << argv[argptr+1] << "." << endl;
     1974                DoLog(1) && (Log() << Verbose(1) << "Changing atom " << argv[argptr] << " to element " << argv[argptr+1] << "." << endl);
    18641975                first = mol->FindAtom(atoi(argv[argptr]));
    18651976                first->type = periode->FindElement(atoi(argv[argptr+1]));
     
    18701981              if (ExitFlag == 0) ExitFlag = 1;
    18711982              MaxDistance = -1;
    1872               if (argv[argptr-1][2] == 'F') {
     1983              if (argv[argptr-1][2] == 'F') { // option is -FF?
    18731984                // fetch first argument as max distance to surface
    18741985                MaxDistance = atof(argv[argptr++]);
    1875                 Log() << Verbose(0) << "Filling with maximum layer distance of " << MaxDistance << "." << endl;
     1986                DoLog(0) && (Log() << Verbose(0) << "Filling with maximum layer distance of " << MaxDistance << "." << endl);
    18761987              }
    18771988              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]))) {
    18781989                ExitFlag = 255;
    1879                 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;
     1990                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);
    18801991                performCriticalExit();
    18811992              } else {
    18821993                SaveFlag = true;
    1883                 Log() << Verbose(1) << "Filling Box with water molecules." << endl;
     1994                DoLog(1) && (Log() << Verbose(1) << "Filling Box with water molecules." << endl);
    18841995                // construct water molecule
    18851996                molecule *filler = new molecule(periode);
    18861997                if (!filler->AddXYZFile(argv[argptr])) {
    1887                   eLog() << Verbose(0) << "Could not parse filler molecule from " << argv[argptr] << "." << endl;
     1998                  DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse filler molecule from " << argv[argptr] << "." << endl);
    18881999                }
    18892000                filler->SetNameFromFilename(argv[argptr]);
     
    19072018              if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    19082019                ExitFlag =255;
    1909                 eLog() << Verbose(0) << "Missing source file for bonds in molecule: -A <bond sourcefile>" << endl;
     2020                DoeLog(0) && (eLog()<< Verbose(0) << "Missing source file for bonds in molecule: -A <bond sourcefile>" << endl);
    19102021                performCriticalExit();
    19112022              } else {
    1912                 Log() << Verbose(0) << "Parsing bonds from " << argv[argptr] << "." << endl;
     2023                DoLog(0) && (Log() << Verbose(0) << "Parsing bonds from " << argv[argptr] << "." << endl);
    19132024                ifstream *input = new ifstream(argv[argptr]);
    19142025                mol->CreateAdjacencyListFromDbondFile(input);
     
    19222033              if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    19232034                ExitFlag =255;
    1924                 eLog() << Verbose(0) << "Missing path of adjacency file: -j <path>" << endl;
     2035                DoeLog(0) && (eLog()<< Verbose(0) << "Missing path of adjacency file: -j <path>" << endl);
    19252036                performCriticalExit();
    19262037              } else {
    1927                 Log() << Verbose(0) << "Storing adjacency to path " << argv[argptr] << "." << endl;
     2038                DoLog(0) && (Log() << Verbose(0) << "Storing adjacency to path " << argv[argptr] << "." << endl);
    19282039                configuration.BG->ConstructBondGraph(mol);
    1929                 mol->StoreAdjacencyToFile(argv[argptr]);
     2040                mol->StoreAdjacencyToFile(NULL, argv[argptr]);
    19302041                argptr+=1;
    19312042              }
     
    19362047              if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    19372048                ExitFlag =255;
    1938                 eLog() << Verbose(0) << "Missing path of bonds file: -j <path>" << endl;
     2049                DoeLog(0) && (eLog()<< Verbose(0) << "Missing path of bonds file: -j <path>" << endl);
    19392050                performCriticalExit();
    19402051              } else {
    1941                 Log() << Verbose(0) << "Storing bonds to path " << argv[argptr] << "." << endl;
     2052                DoLog(0) && (Log() << Verbose(0) << "Storing bonds to path " << argv[argptr] << "." << endl);
    19422053                configuration.BG->ConstructBondGraph(mol);
    1943                 mol->StoreBondsToFile(argv[argptr]);
     2054                mol->StoreBondsToFile(NULL, argv[argptr]);
    19442055                argptr+=1;
    19452056              }
     
    19502061              if ((argptr+1 >= argc) || (argv[argptr+1][0] == '-')){
    19512062                ExitFlag = 255;
    1952                 eLog() << Verbose(0) << "Not enough or invalid arguments given for non-convex envelope: -o <radius> <tecplot output file>" << endl;
     2063                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for non-convex envelope: -o <radius> <tecplot output file>" << endl);
    19532064                performCriticalExit();
    19542065              } else {
     
    19582069                //string filename(argv[argptr+1]);
    19592070                //filename.append(".csv");
    1960                 Log() << Verbose(0) << "Evaluating non-convex envelope of biggest molecule.";
    1961                 Log() << Verbose(1) << "Using rolling ball of radius " << atof(argv[argptr]) << " and storing tecplot data in " << argv[argptr+1] << "." << endl;
     2071                DoLog(0) && (Log() << Verbose(0) << "Evaluating non-convex envelope of biggest molecule.");
     2072                DoLog(1) && (Log() << Verbose(1) << "Using rolling ball of radius " << atof(argv[argptr]) << " and storing tecplot data in " << argv[argptr+1] << "." << endl);
    19622073                // find biggest molecule
    19632074                int counter  = 0;
     
    19692080                  counter++;
    19702081                }
    1971                 Log() << Verbose(1) << "Biggest molecule has " << Boundary->AtomCount << " atoms." << endl;
     2082                DoLog(1) && (Log() << Verbose(1) << "Biggest molecule has " << Boundary->AtomCount << " atoms." << endl);
    19722083                start = clock();
    19732084                LCList = new LinkedCell(Boundary, atof(argv[argptr])*2.);
     
    19762087                //FindDistributionOfEllipsoids(T, &LCList, N, number, filename.c_str());
    19772088                end = clock();
    1978                 Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
     2089                DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);
    19792090                delete(LCList);
    19802091                delete(T);
     
    19862097              if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    19872098                ExitFlag = 255;
    1988                 eLog() << Verbose(0) << "Not enough or invalid arguments given for storing tempature: -S <temperature file>" << endl;
     2099                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for storing tempature: -S <temperature file>" << endl);
    19892100                performCriticalExit();
    19902101              } else {
    1991                 Log() << Verbose(1) << "Storing temperatures in " << argv[argptr] << "." << endl;
     2102                DoLog(1) && (Log() << Verbose(1) << "Storing temperatures in " << argv[argptr] << "." << endl);
    19922103                ofstream *output = new ofstream(argv[argptr], ios::trunc);
    19932104                if (!mol->OutputTemperatureFromTrajectories(output, 0, mol->MDSteps))
    1994                   Log() << Verbose(2) << "File could not be written." << endl;
     2105                  DoLog(2) && (Log() << Verbose(2) << "File could not be written." << endl);
    19952106                else
    1996                   Log() << Verbose(2) << "File stored." << endl;
     2107                  DoLog(2) && (Log() << Verbose(2) << "File stored." << endl);
    19972108                output->close();
    19982109                delete(output);
     
    20042115              if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    20052116                ExitFlag = 255;
    2006                 eLog() << Verbose(0) << "Not enough or invalid arguments given for storing tempature: -L <step0> <step1> <prefix> <identity mapping?>" << endl;
     2117                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for storing tempature: -L <step0> <step1> <prefix> <identity mapping?>" << endl);
    20072118                performCriticalExit();
    20082119              } else {
    20092120                SaveFlag = true;
    2010                 Log() << Verbose(1) << "Linear interpolation between configuration " << argv[argptr] << " and " << argv[argptr+1] << "." << endl;
     2121                DoLog(1) && (Log() << Verbose(1) << "Linear interpolation between configuration " << argv[argptr] << " and " << argv[argptr+1] << "." << endl);
    20112122                if (atoi(argv[argptr+3]) == 1)
    2012                   Log() << Verbose(1) << "Using Identity for the permutation map." << endl;
     2123                  DoLog(1) && (Log() << Verbose(1) << "Using Identity for the permutation map." << endl);
    20132124                if (!mol->LinearInterpolationBetweenConfiguration(atoi(argv[argptr]), atoi(argv[argptr+1]), argv[argptr+2], configuration, atoi(argv[argptr+3])) == 1 ? true : false)
    2014                   Log() << Verbose(2) << "Could not store " << argv[argptr+2] << " files." << endl;
     2125                  DoLog(2) && (Log() << Verbose(2) << "Could not store " << argv[argptr+2] << " files." << endl);
    20152126                else
    2016                   Log() << Verbose(2) << "Steps created and " << argv[argptr+2] << " files stored." << endl;
     2127                  DoLog(2) && (Log() << Verbose(2) << "Steps created and " << argv[argptr+2] << " files stored." << endl);
    20172128                argptr+=4;
    20182129              }
     
    20222133              if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    20232134                ExitFlag = 255;
    2024                 eLog() << Verbose(0) << "Not enough or invalid arguments given for parsing and integrating forces: -P <forces file>" << endl;
     2135                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for parsing and integrating forces: -P <forces file>" << endl);
    20252136                performCriticalExit();
    20262137              } else {
    20272138                SaveFlag = true;
    2028                 Log() << Verbose(1) << "Parsing forces file and Verlet integrating." << endl;
     2139                DoLog(1) && (Log() << Verbose(1) << "Parsing forces file and Verlet integrating." << endl);
    20292140                if (!mol->VerletForceIntegration(argv[argptr], configuration))
    2030                   Log() << Verbose(2) << "File not found." << endl;
     2141                  DoLog(2) && (Log() << Verbose(2) << "File not found." << endl);
    20312142                else
    2032                   Log() << Verbose(2) << "File found and parsed." << endl;
     2143                  DoLog(2) && (Log() << Verbose(2) << "File found and parsed." << endl);
    20332144                argptr+=1;
    20342145              }
     
    20382149              if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])))  {
    20392150                ExitFlag = 255;
    2040                 eLog() << Verbose(0) << "Not enough or invalid arguments given for removing atoms: -R <id> <distance>" << endl;
     2151                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for removing atoms: -R <id> <distance>" << endl);
    20412152                performCriticalExit();
    20422153              } else {
    20432154                SaveFlag = true;
    2044                 Log() << Verbose(1) << "Removing atoms around " << argv[argptr] << " with radius " << argv[argptr+1] << "." << endl;
     2155                DoLog(1) && (Log() << Verbose(1) << "Removing atoms around " << argv[argptr] << " with radius " << argv[argptr+1] << "." << endl);
    20452156                double tmp1 = atof(argv[argptr+1]);
    20462157                atom *third = mol->FindAtom(atoi(argv[argptr]));
     
    20552166                  }
    20562167                } else {
    2057                   eLog() << Verbose(1) << "Removal failed due to missing atoms on molecule or wrong id." << endl;
     2168                  DoeLog(1) && (eLog()<< Verbose(1) << "Removal failed due to missing atoms on molecule or wrong id." << endl);
    20582169                }
    20592170                argptr+=2;
     
    20642175              if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
    20652176                ExitFlag = 255;
    2066                 eLog() << Verbose(0) << "Not enough or invalid arguments given for translation: -t <x> <y> <z>" << endl;
     2177                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for translation: -t <x> <y> <z>" << endl);
    20672178                performCriticalExit();
    20682179              } else {
    20692180                if (ExitFlag == 0) ExitFlag = 1;
    20702181                SaveFlag = true;
    2071                 Log() << Verbose(1) << "Translating all ions by given vector." << endl;
     2182                DoLog(1) && (Log() << Verbose(1) << "Translating all ions by given vector." << endl);
    20722183                for (int i=NDIM;i--;)
    20732184                  x.x[i] = atof(argv[argptr+i]);
     
    20802191              if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
    20812192                ExitFlag = 255;
    2082                 eLog() << Verbose(0) << "Not enough or invalid arguments given for periodic translation: -T <x> <y> <z>" << endl;
     2193                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for periodic translation: -T <x> <y> <z>" << endl);
    20832194                performCriticalExit();
    20842195              } else {
    20852196                if (ExitFlag == 0) ExitFlag = 1;
    20862197                SaveFlag = true;
    2087                 Log() << Verbose(1) << "Translating all ions periodically by given vector." << endl;
     2198                DoLog(1) && (Log() << Verbose(1) << "Translating all ions periodically by given vector." << endl);
    20882199                for (int i=NDIM;i--;)
    20892200                  x.x[i] = atof(argv[argptr+i]);
     
    20962207              if ((argptr >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
    20972208                ExitFlag = 255;
    2098                 eLog() << Verbose(0) << "Not enough or invalid arguments given for scaling: -s <factor_x> [factor_y] [factor_z]" << endl;
     2209                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for scaling: -s <factor_x> [factor_y] [factor_z]" << endl);
    20992210                performCriticalExit();
    21002211              } else {
    21012212                SaveFlag = true;
    21022213                j = -1;
    2103                 Log() << Verbose(1) << "Scaling all ion positions by factor." << endl;
     2214                DoLog(1) && (Log() << Verbose(1) << "Scaling all ion positions by factor." << endl);
    21042215                factor = new double[NDIM];
    21052216                factor[0] = atof(argv[argptr]);
     
    21212232              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])) ) {
    21222233                ExitFlag = 255;
    2123                 eLog() << Verbose(0) << "Not enough or invalid arguments given for centering in box: -b <xx> <xy> <xz> <yy> <yz> <zz>" << endl;
     2234                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for centering in box: -b <xx> <xy> <xz> <yy> <yz> <zz>" << endl);
    21242235                performCriticalExit();
    21252236              } else {
    21262237                SaveFlag = true;
    21272238                j = -1;
    2128                 Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
     2239                DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl);
    21292240                double * const cell_size = World::get()->cell_size;
    21302241                for (int i=0;i<6;i++) {
     
    21402251              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])) ) {
    21412252                ExitFlag = 255;
    2142                 eLog() << Verbose(0) << "Not enough or invalid arguments given for bounding in box: -B <xx> <xy> <xz> <yy> <yz> <zz>" << endl;
     2253                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for bounding in box: -B <xx> <xy> <xz> <yy> <yz> <zz>" << endl);
    21432254                performCriticalExit();
    21442255              } else {
    21452256                SaveFlag = true;
    21462257                j = -1;
    2147                 Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
     2258                DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl);
    21482259                double * const cell_size = World::get()->cell_size;
    21492260                for (int i=0;i<6;i++) {
     
    21592270              if ((argptr+2 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
    21602271                ExitFlag = 255;
    2161                 eLog() << Verbose(0) << "Not enough or invalid arguments given for centering with boundary: -c <boundary_x> <boundary_y> <boundary_z>" << endl;
     2272                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for centering with boundary: -c <boundary_x> <boundary_y> <boundary_z>" << endl);
    21622273                performCriticalExit();
    21632274              } else {
    21642275                SaveFlag = true;
    21652276                j = -1;
    2166                 Log() << Verbose(1) << "Centering atoms in config file within given additional boundary." << endl;
     2277                DoLog(1) && (Log() << Verbose(1) << "Centering atoms in config file within given additional boundary." << endl);
    21672278                // make every coordinate positive
    21682279                mol->CenterEdge(&x);
     
    21842295              if (ExitFlag == 0) ExitFlag = 1;
    21852296              SaveFlag = true;
    2186               Log() << Verbose(1) << "Centering atoms on edge and setting box dimensions." << endl;
     2297              DoLog(1) && (Log() << Verbose(1) << "Centering atoms on edge and setting box dimensions." << endl);
    21872298              x.Zero();
    21882299              mol->CenterEdge(&x);
     
    21942305              if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])))  {
    21952306                ExitFlag = 255;
    2196                 eLog() << Verbose(0) << "Not enough or invalid arguments given for removing atoms: -r <id>" << endl;
     2307                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for removing atoms: -r <id>" << endl);
    21972308                performCriticalExit();
    21982309              } else {
    21992310                SaveFlag = true;
    2200                 Log() << Verbose(1) << "Removing atom " << argv[argptr] << "." << endl;
     2311                DoLog(1) && (Log() << Verbose(1) << "Removing atom " << argv[argptr] << "." << endl);
    22012312                atom *first = mol->FindAtom(atoi(argv[argptr]));
    22022313                mol->RemoveAtom(first);
     
    22082319              if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1]))) {
    22092320                ExitFlag = 255;
    2210                 eLog() << Verbose(0) << "Not enough or invalid arguments for fragmentation: -f <max. bond distance> <bond order>" << endl;
     2321                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for fragmentation: -f <max. bond distance> <bond order>" << endl);
    22112322                performCriticalExit();
    22122323              } else {
    2213                 Log() << Verbose(0) << "Fragmenting molecule with bond distance " << argv[argptr] << " angstroem, order of " << argv[argptr+1] << "." << endl;
    2214                 Log() << Verbose(0) << "Creating connection matrix..." << endl;
     2324                DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with bond distance " << argv[argptr] << " angstroem, order of " << argv[argptr+1] << "." << endl);
     2325                DoLog(0) && (Log() << Verbose(0) << "Creating connection matrix..." << endl);
    22152326                start = clock();
    22162327                mol->CreateAdjacencyList(atof(argv[argptr++]), configuration.GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
    2217                 Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl;
     2328                DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl);
    22182329                if (mol->first->next != mol->last) {
    22192330                  ExitFlag = mol->FragmentMolecule(atoi(argv[argptr]), &configuration);
    22202331                }
    22212332                end = clock();
    2222                 Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
     2333                DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl);
    22232334                argptr+=2;
    22242335              }
     
    22282339              j = atoi(argv[argptr++]);
    22292340              if ((j<0) || (j>1)) {
    2230                 eLog() << Verbose(1) << "Argument of '-m' should be either 0 for no-rotate or 1 for rotate." << endl;
     2341                DoeLog(1) && (eLog()<< Verbose(1) << "Argument of '-m' should be either 0 for no-rotate or 1 for rotate." << endl);
    22312342                j = 0;
    22322343              }
    22332344              if (j) {
    22342345                SaveFlag = true;
    2235                 Log() << Verbose(0) << "Converting to prinicipal axis system." << endl;
     2346                DoLog(0) && (Log() << Verbose(0) << "Converting to prinicipal axis system." << endl);
    22362347              } else
    2237                 Log() << Verbose(0) << "Evaluating prinicipal axis." << endl;
     2348                DoLog(0) && (Log() << Verbose(0) << "Evaluating prinicipal axis." << endl);
    22382349              mol->PrincipalAxisSystem((bool)j);
    22392350              break;
     
    22422353              if ((argptr+1 >= argc) || (argv[argptr][0] == '-')){
    22432354                ExitFlag = 255;
    2244                 eLog() << Verbose(0) << "Not enough or invalid arguments given for convex envelope: -o <convex output file> <non-convex output file>" << endl;
     2355                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for convex envelope: -o <convex output file> <non-convex output file>" << endl);
    22452356                performCriticalExit();
    22462357              } else {
    22472358                class Tesselation *TesselStruct = NULL;
    22482359                const LinkedCell *LCList = NULL;
    2249                 Log() << Verbose(0) << "Evaluating volume of the convex envelope.";
    2250                 Log() << Verbose(1) << "Storing tecplot convex data in " << argv[argptr] << "." << endl;
    2251                 Log() << Verbose(1) << "Storing tecplot non-convex data in " << argv[argptr+1] << "." << endl;
     2360                DoLog(0) && (Log() << Verbose(0) << "Evaluating volume of the convex envelope.");
     2361                DoLog(1) && (Log() << Verbose(1) << "Storing tecplot convex data in " << argv[argptr] << "." << endl);
     2362                DoLog(1) && (Log() << Verbose(1) << "Storing tecplot non-convex data in " << argv[argptr+1] << "." << endl);
    22522363                LCList = new LinkedCell(mol, 10.);
    22532364                //FindConvexBorder(mol, LCList, argv[argptr]);
     
    22562367                double volumedifference = ConvexizeNonconvexEnvelope(TesselStruct, mol, argv[argptr]);
    22572368                double clustervolume = VolumeOfConvexEnvelope(TesselStruct, &configuration);
    2258                 Log() << Verbose(0) << "The tesselated volume area is " << clustervolume << " " << (configuration.GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl;
    2259                 Log() << Verbose(0) << "The non-convex tesselated volume area is " << clustervolume-volumedifference << " " << (configuration.GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl;
     2369                DoLog(0) && (Log() << Verbose(0) << "The tesselated volume area is " << clustervolume << " " << (configuration.GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl);
     2370                DoLog(0) && (Log() << Verbose(0) << "The non-convex tesselated volume area is " << clustervolume-volumedifference << " " << (configuration.GetIsAngstroem() ? "angstrom" : "atomiclength") << "^3." << endl);
    22602371                delete(TesselStruct);
    22612372                delete(LCList);
     
    22672378              if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) ) {
    22682379                ExitFlag = 255;
    2269                 eLog() << Verbose(0) << "Not enough or invalid arguments given for suspension with specified volume: -U <volume> <density>" << endl;
     2380                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for suspension with specified volume: -U <volume> <density>" << endl);
    22702381                performCriticalExit();
    22712382              } else {
    22722383                volume = atof(argv[argptr++]);
    2273                 Log() << Verbose(0) << "Using " << volume << " angstrom^3 as the volume instead of convex envelope one's." << endl;
     2384                DoLog(0) && (Log() << Verbose(0) << "Using " << volume << " angstrom^3 as the volume instead of convex envelope one's." << endl);
    22742385              }
    22752386            case 'u':
     
    22782389                if (volume != -1)
    22792390                  ExitFlag = 255;
    2280                   eLog() << Verbose(0) << "Not enough or invalid arguments given for suspension: -u <density>" << endl;
     2391                  DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for suspension: -u <density>" << endl);
    22812392                  performCriticalExit();
    22822393              } else {
    22832394                double density;
    22842395                SaveFlag = true;
    2285                 Log() << Verbose(0) << "Evaluating necessary cell volume for a cluster suspended in water.";
     2396                DoLog(0) && (Log() << Verbose(0) << "Evaluating necessary cell volume for a cluster suspended in water.");
    22862397                density = atof(argv[argptr++]);
    22872398                if (density < 1.0) {
    2288                   eLog() << Verbose(1) << "Density must be greater than 1.0g/cm^3 !" << endl;
     2399                  DoeLog(1) && (eLog()<< Verbose(1) << "Density must be greater than 1.0g/cm^3 !" << endl);
    22892400                  density = 1.3;
    22902401                }
     
    22922403//                  repetition[i] = atoi(argv[argptr++]);
    22932404//                  if (repetition[i] < 1)
    2294 //                    eLog() << Verbose(1) << "repetition value must be greater 1!" << endl;
     2405//                    DoeLog(1) && (eLog()<< Verbose(1) << "repetition value must be greater 1!" << endl);
    22952406//                  repetition[i] = 1;
    22962407//                }
     
    23022413              if ((argptr+2 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {
    23032414                ExitFlag = 255;
    2304                 eLog() << Verbose(0) << "Not enough or invalid arguments given for repeating cells: -d <repeat_x> <repeat_y> <repeat_z>" << endl;
     2415                DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for repeating cells: -d <repeat_x> <repeat_y> <repeat_z>" << endl);
    23052416                performCriticalExit();
    23062417              } else {
     
    23132424                  Vector ** vectors;
    23142425                  if (faktor < 1) {
    2315                     eLog() << Verbose(1) << "Repetition factor mus be greater than 1!" << endl;
     2426                    DoeLog(1) && (eLog()<< Verbose(1) << "Repetition factor mus be greater than 1!" << endl);
    23162427                    faktor = 1;
    23172428                  }
     
    23302441                    }
    23312442                    if (count != j)
    2332                       eLog() << Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl;
     2443                      DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl);
    23332444                    x.Zero();
    23342445                    y.Zero();
     
    23712482  } else {  // no arguments, hence scan the elements db
    23722483    if (periode->LoadPeriodentafel(configuration.databasepath))
    2373       Log() << Verbose(0) << "Element list loaded successfully." << endl;
     2484      DoLog(0) && (Log() << Verbose(0) << "Element list loaded successfully." << endl);
    23742485    else
    2375       Log() << Verbose(0) << "Element list loading failed." << endl;
     2486      DoLog(0) && (Log() << Verbose(0) << "Element list loading failed." << endl);
    23762487    configuration.RetrieveConfigPathAndName("main_pcp_linux");
    23772488  }
     
    23962507
    23972508  cout << ESPACKVersion << endl;
     2509
     2510  DoLog(1) && (Log() << Verbose(1) << "test" << endl);
     2511  DoLog(3) && (Log() << Verbose(1) << "test");
    23982512
    23992513  setVerbosity(0);
     
    24252539    double * const cell_size = World::get()->cell_size;
    24262540    if (cell_size[0] == 0.) {
    2427       Log() << Verbose(0) << "enter lower tridiagonal form of basis matrix" << endl << endl;
     2541      DoLog(0) && (Log() << Verbose(0) << "enter lower tridiagonal form of basis matrix" << endl << endl);
    24282542      for (int i=0;i<6;i++) {
    2429         Log() << Verbose(1) << "Cell size" << i << ": ";
     2543        DoLog(1) && (Log() << Verbose(1) << "Cell size" << i << ": ");
    24302544        cin >> cell_size[i];
    24312545      }
     
    24382552
    24392553  // now the main construction loop
    2440   Log() << Verbose(0) << endl << "Now comes the real construction..." << endl;
     2554  DoLog(0) && (Log() << Verbose(0) << endl << "Now comes the real construction..." << endl);
    24412555  do {
    2442     Log() << Verbose(0) << endl << endl;
    2443     Log() << Verbose(0) << "============Molecule list=======================" << endl;
     2556    DoLog(0) && (Log() << Verbose(0) << endl << endl);
     2557    DoLog(0) && (Log() << Verbose(0) << "============Molecule list=======================" << endl);
    24442558    molecules->Enumerate((ofstream *)&cout);
    2445     Log() << Verbose(0) << "============Menu===============================" << endl;
    2446     Log() << Verbose(0) << "a - set molecule (in)active" << endl;
    2447     Log() << Verbose(0) << "e - edit molecules (load, parse, save)" << endl;
    2448     Log() << Verbose(0) << "g - globally manipulate atoms in molecule" << endl;
    2449     Log() << Verbose(0) << "M - Merge molecules" << endl;
    2450     Log() << Verbose(0) << "m - manipulate atoms" << endl;
    2451     Log() << Verbose(0) << "-----------------------------------------------" << endl;
    2452     Log() << Verbose(0) << "c - edit the current configuration" << endl;
    2453     Log() << Verbose(0) << "-----------------------------------------------" << endl;
    2454     Log() << Verbose(0) << "s - save current setup to config file" << endl;
    2455     Log() << Verbose(0) << "T - call the current test routine" << endl;
    2456     Log() << Verbose(0) << "q - quit" << endl;
    2457     Log() << Verbose(0) << "===============================================" << endl;
    2458     Log() << Verbose(0) << "Input: ";
     2559    DoLog(0) && (Log() << Verbose(0) << "============Menu===============================" << endl);
     2560    DoLog(0) && (Log() << Verbose(0) << "a - set molecule (in)active" << endl);
     2561    DoLog(0) && (Log() << Verbose(0) << "e - edit molecules (load, parse, save)" << endl);
     2562    DoLog(0) && (Log() << Verbose(0) << "g - globally manipulate atoms in molecule" << endl);
     2563    DoLog(0) && (Log() << Verbose(0) << "M - Merge molecules" << endl);
     2564    DoLog(0) && (Log() << Verbose(0) << "m - manipulate atoms" << endl);
     2565    DoLog(0) && (Log() << Verbose(0) << "-----------------------------------------------" << endl);
     2566    DoLog(0) && (Log() << Verbose(0) << "c - edit the current configuration" << endl);
     2567    DoLog(0) && (Log() << Verbose(0) << "-----------------------------------------------" << endl);
     2568    DoLog(0) && (Log() << Verbose(0) << "s - save current setup to config file" << endl);
     2569    DoLog(0) && (Log() << Verbose(0) << "T - call the current test routine" << endl);
     2570    DoLog(0) && (Log() << Verbose(0) << "q - quit" << endl);
     2571    DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl);
     2572    DoLog(0) && (Log() << Verbose(0) << "Input: ");
    24592573    cin >> choice;
    24602574
     
    24622576      case 'a':  // (in)activate molecule
    24632577        {
    2464           Log() << Verbose(0) << "Enter index of molecule: ";
     2578          DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: ");
    24652579          cin >> j;
    24662580          for(MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
     
    25082622  // save element data base
    25092623  if (periode->StorePeriodentafel(configuration->databasepath)) //ElementsFileName
    2510     Log() << Verbose(0) << "Saving of elements.db successful." << endl;
     2624    DoLog(0) && (Log() << Verbose(0) << "Saving of elements.db successful." << endl);
    25112625  else
    2512     Log() << Verbose(0) << "Saving of elements.db failed." << endl;
     2626    DoLog(0) && (Log() << Verbose(0) << "Saving of elements.db failed." << endl);
    25132627
    25142628  delete(molecules); // also free's all molecules contained
  • src/config.cpp

    r70378e rd6c485  
    7474  file= new ifstream(filename);
    7575  if (file == NULL) {
    76     eLog() << Verbose(1) << "config file " << filename << " missing!" << endl;
     76    DoeLog(1) && (eLog()<< Verbose(1) << "config file " << filename << " missing!" << endl);
    7777    return;
    7878  }
     
    8585  file->clear();
    8686  file->seekg(file_position, ios::beg);
    87   Log() << Verbose(1) << NoLines-1 << " lines were recognized." << endl;
     87  DoLog(1) && (Log() << Verbose(1) << NoLines-1 << " lines were recognized." << endl);
    8888
    8989  // allocate buffer's 1st dimension
    9090  if (buffer != NULL) {
    91     eLog() << Verbose(1) << "FileBuffer->buffer is not NULL!" << endl;
     91    DoeLog(1) && (eLog()<< Verbose(1) << "FileBuffer->buffer is not NULL!" << endl);
    9292    return;
    9393  } else
     
    105105    lines++;
    106106  } while((!file->eof()) && (lines < NoLines));
    107   Log() << Verbose(1) << lines-1 << " lines were read into the buffer." << endl;
     107  DoLog(1) && (Log() << Verbose(1) << lines-1 << " lines were read into the buffer." << endl);
    108108
    109109  // close and exit
     
    144144  map<const char *, int, IonTypeCompare> IonTypeLineMap;
    145145  if (LineMapping == NULL) {
    146     eLog() << Verbose(0) << "map pointer is NULL: " << LineMapping << endl;
     146    DoeLog(0) && (eLog()<< Verbose(0) << "map pointer is NULL: " << LineMapping << endl);
    147147    performCriticalExit();
    148148    return;
     
    160160      LineMapping[CurrentLine+(nr++)] = runner->second;
    161161    else {
    162       eLog() << Verbose(0) << "config::MapIonTypesInBuffer - NoAtoms is wrong: We are past the end of the file!" << endl;
     162      DoeLog(0) && (eLog()<< Verbose(0) << "config::MapIonTypesInBuffer - NoAtoms is wrong: We are past the end of the file!" << endl);
    163163      performCriticalExit();
    164164    }
     
    250250        Thermostat = None;
    251251      } else {
    252         Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl;
     252        DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    253253        Thermostat = None;
    254254      }
     
    258258        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read scaling frequency
    259259      } else {
    260         Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl;
     260        DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    261261        Thermostat = None;
    262262      }
     
    266266        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read collision rate
    267267      } else {
    268         Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl;
     268        DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    269269        Thermostat = None;
    270270      }
     
    274274        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read gamma
    275275        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;
     276          DoLog(2) && (Log() << Verbose(2) << "Extended Stochastic Thermostat detected with interpolation coefficient " << alpha << "." << endl);
    277277        } else {
    278278          alpha = 1.;
    279279        }
    280280      } else {
    281         Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl;
     281        DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    282282        Thermostat = None;
    283283      }
     
    287287        ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read \tau_T
    288288      } else {
    289         Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl;
     289        DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    290290        Thermostat = None;
    291291      }
     
    296296        alpha = 0.;
    297297      } else {
    298         Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl;
     298        DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);
    299299        Thermostat = None;
    300300      }
    301301    } else {
    302       Log() << Verbose(1) << " Warning: thermostat name was not understood!" << endl;
     302      DoLog(1) && (Log() << Verbose(1) << " Warning: thermostat name was not understood!" << endl);
    303303      Thermostat = None;
    304304    }
    305305  } else {
    306306    if ((MaxOuterStep > 0) && (TargetTemp != 0))
    307       Log() << Verbose(2) <<  "No thermostat chosen despite finite temperature MD, falling back to None." << endl;
     307      DoLog(2) && (Log() << Verbose(2) <<  "No thermostat chosen despite finite temperature MD, falling back to None." << endl);
    308308    Thermostat = None;
    309309  }
     
    321321
    322322  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;
     323    DoLog(0) && (Log() << Verbose(0) << "===========EDIT CONFIGURATION============================" << endl);
     324    DoLog(0) && (Log() << Verbose(0) << " A - mainname (prefix for all runtime files)" << endl);
     325    DoLog(0) && (Log() << Verbose(0) << " B - Default path (for runtime files)" << endl);
     326    DoLog(0) && (Log() << Verbose(0) << " C - Path of pseudopotential files" << endl);
     327    DoLog(0) && (Log() << Verbose(0) << " D - Number of coefficient sharing processes" << endl);
     328    DoLog(0) && (Log() << Verbose(0) << " E - Number of wave function sharing processes" << endl);
     329    DoLog(0) && (Log() << Verbose(0) << " F - 0: Don't output density for OpenDX, 1: do" << endl);
     330    DoLog(0) && (Log() << Verbose(0) << " G - 0: Don't output physical data, 1: do" << endl);
     331    DoLog(0) && (Log() << Verbose(0) << " H - 0: Don't output densities of each unperturbed orbital for OpenDX, 1: do" << endl);
     332    DoLog(0) && (Log() << Verbose(0) << " I - 0: Don't output current density for OpenDX, 1: do" << endl);
     333    DoLog(0) && (Log() << Verbose(0) << " J - 0: Don't do the full current calculation, 1: do" << endl);
     334    DoLog(0) && (Log() << Verbose(0) << " K - 0: Don't do perturbation calculation to obtain susceptibility and shielding, 1: do" << endl);
     335    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);
     336    DoLog(0) && (Log() << Verbose(0) << " M - Absolute begin of unphysical sawtooth transfer for position operator within cell" << endl);
     337    DoLog(0) && (Log() << Verbose(0) << " N - (0,1,2) x,y,z-plane to do two-dimensional current vector cut" << endl);
     338    DoLog(0) && (Log() << Verbose(0) << " O - Absolute position along vector cut axis for cut plane" << endl);
     339    DoLog(0) && (Log() << Verbose(0) << " P - Additional Gram-Schmidt-Orthonormalization to stabilize numerics" << endl);
     340    DoLog(0) && (Log() << Verbose(0) << " Q - Initial integer value of random number generator" << endl);
     341    DoLog(0) && (Log() << Verbose(0) << " R - for perturbation 0, for structure optimization defines upper limit of iterations" << endl);
     342    DoLog(0) && (Log() << Verbose(0) << " T - Output visual after ...th step" << endl);
     343    DoLog(0) && (Log() << Verbose(0) << " U - Output source densities of wave functions after ...th step" << endl);
     344    DoLog(0) && (Log() << Verbose(0) << " X - minimization iterations per wave function, if unsure leave at default value 0" << endl);
     345    DoLog(0) && (Log() << Verbose(0) << " Y - tolerance value for total spread in iterative Jacobi diagonalization" << endl);
     346    DoLog(0) && (Log() << Verbose(0) << " Z - Maximum number of minimization iterations" << endl);
     347    DoLog(0) && (Log() << Verbose(0) << " a - Relative change in total energy to stop min. iteration" << endl);
     348    DoLog(0) && (Log() << Verbose(0) << " b - Relative change in kinetic energy to stop min. iteration" << endl);
     349    DoLog(0) && (Log() << Verbose(0) << " c - Check stop conditions every ..th step during min. iteration" << endl);
     350    DoLog(0) && (Log() << Verbose(0) << " e - Maximum number of minimization iterations during initial level" << endl);
     351    DoLog(0) && (Log() << Verbose(0) << " f - Relative change in total energy to stop min. iteration during initial level" << endl);
     352    DoLog(0) && (Log() << Verbose(0) << " g - Relative change in kinetic energy to stop min. iteration during initial level" << endl);
     353    DoLog(0) && (Log() << Verbose(0) << " h - Check stop conditions every ..th step during min. iteration during initial level" << endl);
    354354//    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: ";
     355    DoLog(0) && (Log() << Verbose(0) << " k - Energy cutoff of plane wave basis in Hartree" << endl);
     356    DoLog(0) && (Log() << Verbose(0) << " l - Maximum number of levels in multi-level-ansatz" << endl);
     357    DoLog(0) && (Log() << Verbose(0) << " m - Factor by which grid nodes increase between standard and upper level" << endl);
     358    DoLog(0) && (Log() << Verbose(0) << " n - 0: Don't use RiemannTensor, 1: Do" << endl);
     359    DoLog(0) && (Log() << Verbose(0) << " o - Factor by which grid nodes increase between Riemann and standard(?) level" << endl);
     360    DoLog(0) && (Log() << Verbose(0) << " p - Number of Riemann levels" << endl);
     361    DoLog(0) && (Log() << Verbose(0) << " r - 0: Don't Use RiemannTensor, 1: Do" << endl);
     362    DoLog(0) && (Log() << Verbose(0) << " s - 0: Doubly occupied orbitals, 1: Up-/Down-Orbitals" << endl);
     363    DoLog(0) && (Log() << Verbose(0) << " t - Number of orbitals (depends pn SpinType)" << endl);
     364    DoLog(0) && (Log() << Verbose(0) << " u - Number of SpinUp orbitals (depends on SpinType)" << endl);
     365    DoLog(0) && (Log() << Verbose(0) << " v - Number of SpinDown orbitals (depends on SpinType)" << endl);
     366    DoLog(0) && (Log() << Verbose(0) << " w - Number of additional, unoccupied orbitals" << endl);
     367    DoLog(0) && (Log() << Verbose(0) << " x - radial cutoff for ewald summation in Bohrradii" << endl);
     368    DoLog(0) && (Log() << Verbose(0) << " y - 0: Don't do structure optimization beforehand, 1: Do" << endl);
     369    DoLog(0) && (Log() << Verbose(0) << " z - 0: Units are in Bohr radii, 1: units are in Aengstrom" << endl);
     370    DoLog(0) && (Log() << Verbose(0) << " i - 0: Coordinates given in file are absolute, 1: ... are relative to unit cell" << endl);
     371    DoLog(0) && (Log() << Verbose(0) << "=========================================================" << endl);
     372    DoLog(0) && (Log() << Verbose(0) << "INPUT: ");
    373373    cin >> choice;
    374374
    375375    switch (choice) {
    376376        case 'A': // mainname
    377           Log() << Verbose(0) << "Old: " << config::mainname << "\t new: ";
     377          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::mainname << "\t new: ");
    378378          cin >> config::mainname;
    379379          break;
    380380        case 'B': // defaultpath
    381           Log() << Verbose(0) << "Old: " << config::defaultpath << "\t new: ";
     381          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::defaultpath << "\t new: ");
    382382          cin >> config::defaultpath;
    383383          break;
    384384        case 'C': // pseudopotpath
    385           Log() << Verbose(0) << "Old: " << config::pseudopotpath << "\t new: ";
     385          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::pseudopotpath << "\t new: ");
    386386          cin >> config::pseudopotpath;
    387387          break;
    388388
    389389        case 'D': // ProcPEGamma
    390           Log() << Verbose(0) << "Old: " << config::ProcPEGamma << "\t new: ";
     390          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::ProcPEGamma << "\t new: ");
    391391          cin >> config::ProcPEGamma;
    392392          break;
    393393        case 'E': // ProcPEPsi
    394           Log() << Verbose(0) << "Old: " << config::ProcPEPsi << "\t new: ";
     394          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::ProcPEPsi << "\t new: ");
    395395          cin >> config::ProcPEPsi;
    396396          break;
    397397        case 'F': // DoOutVis
    398           Log() << Verbose(0) << "Old: " << config::DoOutVis << "\t new: ";
     398          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::DoOutVis << "\t new: ");
    399399          cin >> config::DoOutVis;
    400400          break;
    401401        case 'G': // DoOutMes
    402           Log() << Verbose(0) << "Old: " << config::DoOutMes << "\t new: ";
     402          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::DoOutMes << "\t new: ");
    403403          cin >> config::DoOutMes;
    404404          break;
    405405        case 'H': // DoOutOrbitals
    406           Log() << Verbose(0) << "Old: " << config::DoOutOrbitals << "\t new: ";
     406          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::DoOutOrbitals << "\t new: ");
    407407          cin >> config::DoOutOrbitals;
    408408          break;
    409409        case 'I': // DoOutCurrent
    410           Log() << Verbose(0) << "Old: " << config::DoOutCurrent << "\t new: ";
     410          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::DoOutCurrent << "\t new: ");
    411411          cin >> config::DoOutCurrent;
    412412          break;
    413413        case 'J': // DoFullCurrent
    414           Log() << Verbose(0) << "Old: " << config::DoFullCurrent << "\t new: ";
     414          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::DoFullCurrent << "\t new: ");
    415415          cin >> config::DoFullCurrent;
    416416          break;
    417417        case 'K': // DoPerturbation
    418           Log() << Verbose(0) << "Old: " << config::DoPerturbation << "\t new: ";
     418          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::DoPerturbation << "\t new: ");
    419419          cin >> config::DoPerturbation;
    420420          break;
    421421        case 'L': // CommonWannier
    422           Log() << Verbose(0) << "Old: " << config::CommonWannier << "\t new: ";
     422          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::CommonWannier << "\t new: ");
    423423          cin >> config::CommonWannier;
    424424          break;
    425425        case 'M': // SawtoothStart
    426           Log() << Verbose(0) << "Old: " << config::SawtoothStart << "\t new: ";
     426          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::SawtoothStart << "\t new: ");
    427427          cin >> config::SawtoothStart;
    428428          break;
    429429        case 'N': // VectorPlane
    430           Log() << Verbose(0) << "Old: " << config::VectorPlane << "\t new: ";
     430          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::VectorPlane << "\t new: ");
    431431          cin >> config::VectorPlane;
    432432          break;
    433433        case 'O': // VectorCut
    434           Log() << Verbose(0) << "Old: " << config::VectorCut << "\t new: ";
     434          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::VectorCut << "\t new: ");
    435435          cin >> config::VectorCut;
    436436          break;
    437437        case 'P': // UseAddGramSch
    438           Log() << Verbose(0) << "Old: " << config::UseAddGramSch << "\t new: ";
     438          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::UseAddGramSch << "\t new: ");
    439439          cin >> config::UseAddGramSch;
    440440          break;
    441441        case 'Q': // Seed
    442           Log() << Verbose(0) << "Old: " << config::Seed << "\t new: ";
     442          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::Seed << "\t new: ");
    443443          cin >> config::Seed;
    444444          break;
    445445
    446446        case 'R': // MaxOuterStep
    447           Log() << Verbose(0) << "Old: " << config::MaxOuterStep << "\t new: ";
     447          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::MaxOuterStep << "\t new: ");
    448448          cin >> config::MaxOuterStep;
    449449          break;
    450450        case 'T': // OutVisStep
    451           Log() << Verbose(0) << "Old: " << config::OutVisStep << "\t new: ";
     451          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::OutVisStep << "\t new: ");
    452452          cin >> config::OutVisStep;
    453453          break;
    454454        case 'U': // OutSrcStep
    455           Log() << Verbose(0) << "Old: " << config::OutSrcStep << "\t new: ";
     455          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::OutSrcStep << "\t new: ");
    456456          cin >> config::OutSrcStep;
    457457          break;
    458458        case 'X': // MaxPsiStep
    459           Log() << Verbose(0) << "Old: " << config::MaxPsiStep << "\t new: ";
     459          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::MaxPsiStep << "\t new: ");
    460460          cin >> config::MaxPsiStep;
    461461          break;
    462462        case 'Y': // EpsWannier
    463           Log() << Verbose(0) << "Old: " << config::EpsWannier << "\t new: ";
     463          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::EpsWannier << "\t new: ");
    464464          cin >> config::EpsWannier;
    465465          break;
    466466
    467467        case 'Z': // MaxMinStep
    468           Log() << Verbose(0) << "Old: " << config::MaxMinStep << "\t new: ";
     468          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::MaxMinStep << "\t new: ");
    469469          cin >> config::MaxMinStep;
    470470          break;
    471471        case 'a': // RelEpsTotalEnergy
    472           Log() << Verbose(0) << "Old: " << config::RelEpsTotalEnergy << "\t new: ";
     472          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::RelEpsTotalEnergy << "\t new: ");
    473473          cin >> config::RelEpsTotalEnergy;
    474474          break;
    475475        case 'b': // RelEpsKineticEnergy
    476           Log() << Verbose(0) << "Old: " << config::RelEpsKineticEnergy << "\t new: ";
     476          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::RelEpsKineticEnergy << "\t new: ");
    477477          cin >> config::RelEpsKineticEnergy;
    478478          break;
    479479        case 'c': // MaxMinStopStep
    480           Log() << Verbose(0) << "Old: " << config::MaxMinStopStep << "\t new: ";
     480          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::MaxMinStopStep << "\t new: ");
    481481          cin >> config::MaxMinStopStep;
    482482          break;
    483483        case 'e': // MaxInitMinStep
    484           Log() << Verbose(0) << "Old: " << config::MaxInitMinStep << "\t new: ";
     484          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::MaxInitMinStep << "\t new: ");
    485485          cin >> config::MaxInitMinStep;
    486486          break;
    487487        case 'f': // InitRelEpsTotalEnergy
    488           Log() << Verbose(0) << "Old: " << config::InitRelEpsTotalEnergy << "\t new: ";
     488          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::InitRelEpsTotalEnergy << "\t new: ");
    489489          cin >> config::InitRelEpsTotalEnergy;
    490490          break;
    491491        case 'g': // InitRelEpsKineticEnergy
    492           Log() << Verbose(0) << "Old: " << config::InitRelEpsKineticEnergy << "\t new: ";
     492          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::InitRelEpsKineticEnergy << "\t new: ");
    493493          cin >> config::InitRelEpsKineticEnergy;
    494494          break;
    495495        case 'h': // InitMaxMinStopStep
    496           Log() << Verbose(0) << "Old: " << config::InitMaxMinStopStep << "\t new: ";
     496          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::InitMaxMinStopStep << "\t new: ");
    497497          cin >> config::InitMaxMinStopStep;
    498498          break;
     
    508508
    509509        case 'k': // ECut
    510           Log() << Verbose(0) << "Old: " << config::ECut << "\t new: ";
     510          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::ECut << "\t new: ");
    511511          cin >> config::ECut;
    512512          break;
    513513        case 'l': // MaxLevel
    514           Log() << Verbose(0) << "Old: " << config::MaxLevel << "\t new: ";
     514          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::MaxLevel << "\t new: ");
    515515          cin >> config::MaxLevel;
    516516          break;
    517517        case 'm': // RiemannTensor
    518           Log() << Verbose(0) << "Old: " << config::RiemannTensor << "\t new: ";
     518          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::RiemannTensor << "\t new: ");
    519519          cin >> config::RiemannTensor;
    520520          break;
    521521        case 'n': // LevRFactor
    522           Log() << Verbose(0) << "Old: " << config::LevRFactor << "\t new: ";
     522          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::LevRFactor << "\t new: ");
    523523          cin >> config::LevRFactor;
    524524          break;
    525525        case 'o': // RiemannLevel
    526           Log() << Verbose(0) << "Old: " << config::RiemannLevel << "\t new: ";
     526          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::RiemannLevel << "\t new: ");
    527527          cin >> config::RiemannLevel;
    528528          break;
    529529        case 'p': // Lev0Factor
    530           Log() << Verbose(0) << "Old: " << config::Lev0Factor << "\t new: ";
     530          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::Lev0Factor << "\t new: ");
    531531          cin >> config::Lev0Factor;
    532532          break;
    533533        case 'r': // RTActualUse
    534           Log() << Verbose(0) << "Old: " << config::RTActualUse << "\t new: ";
     534          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::RTActualUse << "\t new: ");
    535535          cin >> config::RTActualUse;
    536536          break;
    537537        case 's': // PsiType
    538           Log() << Verbose(0) << "Old: " << config::PsiType << "\t new: ";
     538          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::PsiType << "\t new: ");
    539539          cin >> config::PsiType;
    540540          break;
    541541        case 't': // MaxPsiDouble
    542           Log() << Verbose(0) << "Old: " << config::MaxPsiDouble << "\t new: ";
     542          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::MaxPsiDouble << "\t new: ");
    543543          cin >> config::MaxPsiDouble;
    544544          break;
    545545        case 'u': // PsiMaxNoUp
    546           Log() << Verbose(0) << "Old: " << config::PsiMaxNoUp << "\t new: ";
     546          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::PsiMaxNoUp << "\t new: ");
    547547          cin >> config::PsiMaxNoUp;
    548548          break;
    549549        case 'v': // PsiMaxNoDown
    550           Log() << Verbose(0) << "Old: " << config::PsiMaxNoDown << "\t new: ";
     550          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::PsiMaxNoDown << "\t new: ");
    551551          cin >> config::PsiMaxNoDown;
    552552          break;
    553553        case 'w': // AddPsis
    554           Log() << Verbose(0) << "Old: " << config::AddPsis << "\t new: ";
     554          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::AddPsis << "\t new: ");
    555555          cin >> config::AddPsis;
    556556          break;
    557557
    558558        case 'x': // RCut
    559           Log() << Verbose(0) << "Old: " << config::RCut << "\t new: ";
     559          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::RCut << "\t new: ");
    560560          cin >> config::RCut;
    561561          break;
    562562        case 'y': // StructOpt
    563           Log() << Verbose(0) << "Old: " << config::StructOpt << "\t new: ";
     563          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::StructOpt << "\t new: ");
    564564          cin >> config::StructOpt;
    565565          break;
    566566        case 'z': // IsAngstroem
    567           Log() << Verbose(0) << "Old: " << config::IsAngstroem << "\t new: ";
     567          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::IsAngstroem << "\t new: ");
    568568          cin >> config::IsAngstroem;
    569569          break;
    570570        case 'i': // RelativeCoord
    571           Log() << Verbose(0) << "Old: " << config::RelativeCoord << "\t new: ";
     571          DoLog(0) && (Log() << Verbose(0) << "Old: " << config::RelativeCoord << "\t new: ");
    572572          cin >> config::RelativeCoord;
    573573          break;
     
    648648  }
    649649  strcpy(configname, ptr);
    650   Log() << Verbose(0) << "Found configpath: " << configpath << ", dir slash was found at " << last << ", config name is " << configname << "." << endl;
     650  DoLog(0) && (Log() << Verbose(0) << "Found configpath: " << configpath << ", dir slash was found at " << last << ", config name is " << configname << "." << endl);
    651651  delete[](buffer);
    652652};
     
    659659{
    660660  if (FileBuffer != NULL) {
    661     eLog() << Verbose(2) << "deleting present FileBuffer in PrepareFileBuffer()." << endl;
     661    DoeLog(2) && (eLog()<< Verbose(2) << "deleting present FileBuffer in PrepareFileBuffer()." << endl);
    662662    delete(FileBuffer);
    663663  }
     
    685685
    686686  if (mol == NULL) {
    687     eLog() << Verbose(0) << "Molecule is not allocated in LoadMolecule(), exit.";
     687    DoeLog(0) && (eLog()<< Verbose(0) << "Molecule is not allocated in LoadMolecule(), exit.");
    688688    performCriticalExit();
    689689  }
     
    691691  ParseForParameter(verbose,FileBuffer,"MaxTypes", 0, 1, 1, int_type, &(MaxTypes), 1, critical);
    692692  if (MaxTypes == 0) {
    693     eLog() << Verbose(1) << "There are no atoms according to MaxTypes in this config file." << endl;
     693    DoeLog(1) && (eLog()<< Verbose(1) << "There are no atoms according to MaxTypes in this config file." << endl);
    694694    //performCriticalExit();
    695695  } else {
    696696    // prescan number of ions per type
    697     Log() << Verbose(0) << "Prescanning ions per type: " << endl;
     697    DoLog(0) && (Log() << Verbose(0) << "Prescanning ions per type: " << endl);
    698698    int NoAtoms = 0;
    699699    for (int i=0; i < MaxTypes; i++) {
     
    702702      ParseForParameter(verbose,FileBuffer, name, 0, 2, 1, int_type, &Z, 1, critical);
    703703      elementhash[i] = periode->FindElement(Z);
    704       Log() << Verbose(1) << i << ". Z = " << elementhash[i]->Z << " with " << No[i] << " ions." << endl;
     704      DoLog(1) && (Log() << Verbose(1) << i << ". Z = " << elementhash[i]->Z << " with " << No[i] << " ions." << endl);
    705705      NoAtoms += No[i];
    706706    }
     
    710710    sprintf(name,"Ion_Type%i",MaxTypes);
    711711    if (!ParseForParameter(verbose,FileBuffer, (const char*)name, 1, 1, 1, int_type, &value[0], 1, critical)) {
    712       eLog() << Verbose(0) << "There are no atoms in the config file!" << endl;
     712      DoeLog(0) && (eLog()<< Verbose(0) << "There are no atoms in the config file!" << endl);
    713713      performCriticalExit();
    714714      return;
     
    728728      bool status = true;
    729729      while (status) {
    730         Log() << Verbose(0) << "Currently parsing MD step " << repetition << "." << endl;
     730        DoLog(0) && (Log() << Verbose(0) << "Currently parsing MD step " << repetition << "." << endl);
    731731        for (int i=0; i < MaxTypes; i++) {
    732732          sprintf(name,"Ion_Type%i",i+1);
     
    794794      }
    795795      repetition--;
    796       Log() << Verbose(0) << "Found " << repetition << " trajectory steps." << endl;
     796      DoLog(0) && (Log() << Verbose(0) << "Found " << repetition << " trajectory steps." << endl);
    797797      if (repetition <= 1)  // if onyl one step, desactivate use of trajectories
    798798        mol->MDSteps = 0;
     
    806806              ParseForParameter(verbose,FileBuffer, "Ion_Type1_1", 0, 3, 1, double_type, &value[2], repetition, (repetition == 0) ? critical : optional))
    807807        repetition++;
    808       Log() << Verbose(0) << "I found " << repetition << " times the keyword Ion_Type1_1." << endl;
     808      DoLog(0) && (Log() << Verbose(0) << "I found " << repetition << " times the keyword Ion_Type1_1." << endl);
    809809      // parse in molecule coordinates
    810810      for (int i=0; i < MaxTypes; i++) {
     
    855855  ifstream *file = new ifstream(filename);
    856856  if (file == NULL) {
    857     eLog() << Verbose(1) << "config file " << filename << " missing!" << endl;
     857    DoeLog(1) && (eLog()<< Verbose(1) << "config file " << filename << " missing!" << endl);
    858858    return;
    859859  }
     
    10631063    BG = new BondGraph(IsAngstroem);
    10641064    if (BG->LoadBondLengthTable(BondGraphFileName)) {
    1065       Log() << Verbose(0) << "Bond length table loaded successfully." << endl;
     1065      DoLog(0) && (Log() << Verbose(0) << "Bond length table loaded successfully." << endl);
    10661066    } else {
    1067       eLog() << Verbose(1) << "Bond length table loading failed." << endl;
     1067      DoeLog(1) && (eLog()<< Verbose(1) << "Bond length table loading failed." << endl);
    10681068    }
    10691069  }
     
    10941094  ifstream *file = new ifstream(filename);
    10951095  if (file == NULL) {
    1096     eLog() << Verbose(1) << "config file " << filename << " missing!" << endl;
     1096    DoeLog(1) && (eLog()<< Verbose(1) << "config file " << filename << " missing!" << endl);
    10971097    return;
    10981098  }
     
    12541254  BG = new BondGraph(IsAngstroem);
    12551255  if (BG->LoadBondLengthTable(BondGraphFileName)) {
    1256     Log() << Verbose(0) << "Bond length table loaded successfully." << endl;
     1256    DoLog(0) && (Log() << Verbose(0) << "Bond length table loaded successfully." << endl);
    12571257  } else {
    1258     Log() << Verbose(0) << "Bond length table loading failed." << endl;
     1258    DoLog(0) && (Log() << Verbose(0) << "Bond length table loading failed." << endl);
    12591259  }
    12601260
     
    12631263  for (i=MAX_ELEMENTS;i--;)
    12641264    elementhash[i] = NULL;
    1265   Log() << Verbose(0) << "Parsing Ions ..." << endl;
     1265  DoLog(0) && (Log() << Verbose(0) << "Parsing Ions ..." << endl);
    12661266  No=0;
    12671267  found = 0;
    12681268  while (getline(*file,zeile,'\n')) {
    12691269    if (zeile.find("Ions_Data") == 0) {
    1270       Log() << Verbose(1) << "found Ions_Data...begin parsing" << endl;
     1270      DoLog(1) && (Log() << Verbose(1) << "found Ions_Data...begin parsing" << endl);
    12711271      found ++;
    12721272    }
     
    12821282      input >> b;     // element mass
    12831283      elementhash[No] = periode->FindElement(Z);
    1284       Log() << Verbose(1) << "AtomNo: " << AtomNo << "\tZ: " << Z << "\ta:" << a << "\tl:"  << l << "\b:" << b << "\tElement:" << elementhash[No] << "\t:" << endl;
     1284      DoLog(1) && (Log() << Verbose(1) << "AtomNo: " << AtomNo << "\tZ: " << Z << "\ta:" << a << "\tl:"  << l << "\b:" << b << "\tElement:" << elementhash[No] << "\t:" << endl);
    12851285      for(i=0;i<AtomNo;i++) {
    12861286        if (!getline(*file,zeile,'\n')) {// parse on and on
    1287           Log() << Verbose(2) << "Error: Too few items in ionic list of element" << elementhash[No] << "." << endl << "Exiting." << endl;
     1287          DoLog(2) && (Log() << Verbose(2) << "Error: Too few items in ionic list of element" << elementhash[No] << "." << endl << "Exiting." << endl);
    12881288          // return 1;
    12891289        } else {
     
    14331433    return result;
    14341434  } else {
    1435     eLog() << Verbose(1) << "Cannot open output file:" << filename << endl;
     1435    DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open output file:" << filename << endl);
    14361436    return false;
    14371437  }
     
    14551455    output = new ofstream(fname->str().c_str(), ios::out);
    14561456    if (output == NULL) {
    1457       eLog() << Verbose(1) << "Cannot open mpqc output file:" << fname << endl;
     1457      DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open mpqc output file:" << fname << endl);
    14581458      delete(fname);
    14591459      return false;
     
    14981498    output = new ofstream(fname->str().c_str(), ios::out);
    14991499    if (output == NULL) {
    1500       eLog() << Verbose(1) << "Cannot open mpqc hessian output file:" << fname << endl;
     1500      DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open mpqc hessian output file:" << fname << endl);
    15011501      delete(fname);
    15021502      return false;
     
    15541554  f = fopen(name, "w" );
    15551555  if (f == NULL) {
    1556     eLog() << Verbose(1) << "Cannot open pdb output file:" << name << endl;
     1556    DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open pdb output file:" << name << endl);
    15571557    return false;
    15581558  }
     
    16091609  f = fopen(name, "w" );
    16101610  if (f == NULL) {
    1611     eLog() << Verbose(1) << "Cannot open pdb output file:" << name << endl;
     1611    DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open pdb output file:" << name << endl);
    16121612    Free(&elementNo);
    16131613    return false;
     
    16461646/** Stores all atoms in a TREMOLO data input file.
    16471647 * Note that this format cannot be parsed again.
     1648 * Note that TREMOLO does not like Id starting at 0, but at 1. Atoms with Id 0 are discarded!
    16481649 * \param *filename name of file (without ".in" suffix!)
    16491650 * \param *mol pointer to molecule
     
    16581659  output = new ofstream(fname->str().c_str(), ios::out);
    16591660  if (output == NULL) {
    1660     eLog() << Verbose(1) << "Cannot open tremolo output file:" << fname << endl;
     1661    DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open tremolo output file:" << fname << endl);
    16611662    delete(fname);
    16621663    return false;
     
    17001701/** Stores all atoms from all molecules in a TREMOLO data input file.
    17011702 * Note that this format cannot be parsed again.
     1703 * Note that TREMOLO does not like Id starting at 0, but at 1. Atoms with Id 0 are discarded!
    17021704 * \param *filename name of file (without ".in" suffix!)
    17031705 * \param *MolList pointer to MoleculeListClass containing all atoms
     
    17121714  output = new ofstream(fname->str().c_str(), ios::out);
    17131715  if (output == NULL) {
    1714     eLog() << Verbose(1) << "Cannot open tremolo output file:" << fname << endl;
     1716    DoeLog(1) && (eLog()<< Verbose(1) << "Cannot open tremolo output file:" << fname << endl);
    17151717    delete(fname);
    17161718    return false;
     
    17521754      while (Walker->next != (*MolWalker)->end) {
    17531755        Walker = Walker->next;
    1754         *output << AtomNo << "\t";
     1756        *output << AtomNo+1 << "\t";
    17551757        *output << Walker->Name << "\t";
    17561758        *output << (*MolWalker)->name << "\t";
    1757         *output << MolCounter << "\t";
     1759        *output << MolCounter+1 << "\t";
    17581760        *output << Walker->node->x[0] << "\t" << Walker->node->x[1] << "\t" << Walker->node->x[2] << "\t";
    17591761        *output << (double)Walker->type->Valence << "\t";
    17601762        *output << Walker->type->symbol << "\t";
    17611763        for (BondList::iterator runner = Walker->ListOfBonds.begin(); runner != Walker->ListOfBonds.end(); runner++)
    1762           *output << LocalNotoGlobalNoMap[MolCounter][ (*runner)->GetOtherAtom(Walker)->nr ] << "\t";
     1764          *output << LocalNotoGlobalNoMap[MolCounter][ (*runner)->GetOtherAtom(Walker)->nr ]+1 << "\t";
    17631765        for(int i=Walker->ListOfBonds.size(); i < MaxNeighbours; i++)
    17641766          *output << "-\t";
  • src/datacreator.cpp

    r70378e rd6c485  
    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

    r70378e rd6c485  
    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

    r70378e rd6c485  
    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

    r70378e rd6c485  
    8181  int verbosityLevel = l.verbosity;
    8282  l.nix->clear();
    83   if (v.DoOutput(verbosityLevel)) {
     83  if (v.DoErrorOutput(verbosityLevel)) {
    8484    switch(v.Verbosity) {
    8585      case 0:
     
    104104  int verbosityLevel = l->verbosity;
    105105  l->nix->clear();
    106   if (v.DoOutput(verbosityLevel)) {
     106  if (v.DoErrorOutput(verbosityLevel)) {
    107107    switch(v.Verbosity) {
    108108      case 0:
     
    113113        break;
    114114      case 2:
     115      default:
    115116        cerr << "WARNING: ";
    116         break;
    117       default:
    118117        break;
    119118    }
  • src/graph.cpp

    r70378e rd6c485  
    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/helpers.cpp

    r70378e rd6c485  
    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

    r70378e rd6c485  
    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

    r70378e rd6c485  
    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

    r70378e rd6c485  
    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

    r70378e rd6c485  
    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

    r70378e rd6c485  
    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

    r70378e rd6c485  
    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

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

    r70378e rd6c485  
    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

    r70378e rd6c485  
    4646  for(int i=MAX_ELEMENTS;i--;)
    4747    ElementsInMolecule[i] = 0;
    48   strcpy(name,"none");
     48  strcpy(name,World::get()->DefaultName);
    4949};
    5050
     
    194194  BondRescale = TopOrigin->type->HBondDistance[TopBond->BondDegree-1];
    195195  if (BondRescale == -1) {
    196     eLog() << Verbose(1) << "There is no typical hydrogen bond distance in replacing bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") of degree " << TopBond->BondDegree << "!" << endl;
     196    DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond distance in replacing bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") of degree " << TopBond->BondDegree << "!" << endl);
    197197    return false;
    198198    BondRescale = bondlength;
     
    237237            SecondOtherAtom = (*Runner)->GetOtherAtom(TopOrigin);
    238238          } else {
    239             eLog() << Verbose(2) << "Detected more than four bonds for atom " << TopOrigin->Name;
     239            DoeLog(2) && (eLog()<< Verbose(2) << "Detected more than four bonds for atom " << TopOrigin->Name);
    240240          }
    241241        }
     
    274274      bondangle = TopOrigin->type->HBondAngle[1];
    275275      if (bondangle == -1) {
    276         eLog() << Verbose(1) << "There is no typical hydrogen bond angle in replacing bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") of degree " << TopBond->BondDegree << "!" << endl;
     276        DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond angle in replacing bond (" << TopOrigin->Name << "<->" << TopReplacement->Name << ") of degree " << TopBond->BondDegree << "!" << endl);
    277277        return false;
    278278        bondangle = 0;
     
    396396      break;
    397397    default:
    398       eLog() << Verbose(1) << "BondDegree does not state single, double or triple bond!" << endl;
     398      DoeLog(1) && (eLog()<< Verbose(1) << "BondDegree does not state single, double or triple bond!" << endl);
    399399      AllWentWell = false;
    400400      break;
     
    429429  input = new istringstream(line);
    430430  *input >> NumberOfAtoms;
    431   Log() << Verbose(0) << "Parsing " << NumberOfAtoms << " atoms in file." << endl;
     431  DoLog(0) && (Log() << Verbose(0) << "Parsing " << NumberOfAtoms << " atoms in file." << endl);
    432432  getline(xyzfile,line,'\n'); // Read comment
    433   Log() << Verbose(1) << "Comment: " << line << endl;
     433  DoLog(1) && (Log() << Verbose(1) << "Comment: " << line << endl);
    434434
    435435  if (MDSteps == 0) // no atoms yet present
     
    447447    Walker->type = elemente->FindElement(shorthand);
    448448    if (Walker->type == NULL) {
    449       eLog() << Verbose(1) << "Could not parse the element at line: '" << line << "', setting to H.";
     449      DoeLog(1) && (eLog()<< Verbose(1) << "Could not parse the element at line: '" << line << "', setting to H.");
    450450      Walker->type = elemente->FindElement(1);
    451451    }
     
    543543    add(Binder, last);
    544544  } else {
    545     eLog() << Verbose(1) << "Could not add bond between " << atom1->Name << " and " << atom2->Name << " as one or both are not present in the molecule." << endl;
     545    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);
    546546  }
    547547  return Binder;
     
    555555bool molecule::RemoveBond(bond *pointer)
    556556{
    557   //eLog() << Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl;
     557  //DoeLog(1) && (eLog()<< Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl);
    558558  pointer->leftatom->RegisterBond(pointer);
    559559  pointer->rightatom->RegisterBond(pointer);
     
    569569bool molecule::RemoveBonds(atom *BondPartner)
    570570{
    571   //eLog() << Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl;
     571  //DoeLog(1) && (eLog()<< Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl);
    572572  BondList::const_iterator ForeRunner;
    573573  while (!BondPartner->ListOfBonds.empty()) {
     
    622622    AtomCount--;
    623623  } else
    624     eLog() << Verbose(1) << "Atom " << pointer->Name << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl;
     624    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);
    625625  if (ElementsInMolecule[pointer->type->Z] == 0)  // was last atom of this element?
    626626    ElementCount--;
     
    640640    ElementsInMolecule[pointer->type->Z]--; // decrease number of atom of this element
    641641  else
    642     eLog() << Verbose(1) << "Atom " << pointer->Name << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl;
     642    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);
    643643  if (ElementsInMolecule[pointer->type->Z] == 0)  // was last atom of this element?
    644644    ElementCount--;
     
    665665    return walker;
    666666  } else {
    667     Log() << Verbose(0) << "Atom not found in list." << endl;
     667    DoLog(0) && (Log() << Verbose(0) << "Atom not found in list." << endl);
    668668    return NULL;
    669669  }
     
    681681    //mol->Output((ofstream *)&cout);
    682682    //Log() << Verbose(0) << "===============================================" << endl;
    683     Log() << Verbose(0) << text;
     683    DoLog(0) && (Log() << Verbose(0) << text);
    684684    cin >> No;
    685685    ion = this->FindAtom(No);
     
    770770void molecule::OutputListOfBonds() const
    771771{
    772   Log() << Verbose(2) << endl << "From Contents of ListOfBonds, all non-hydrogen atoms:" << endl;
     772  DoLog(2) && (Log() << Verbose(2) << endl << "From Contents of ListOfBonds, all non-hydrogen atoms:" << endl);
    773773  ActOnAllAtoms (&atom::OutputBondOfAtom );
    774   Log() << Verbose(0) << endl;
     774  DoLog(0) && (Log() << Verbose(0) << endl);
    775775};
    776776
     
    829829  }
    830830  if ((AtomCount == 0) || (i != AtomCount)) {
    831     Log() << Verbose(3) << "Mismatch in AtomCount " << AtomCount << " and recounted number " << i << ", renaming all." << endl;
     831    DoLog(3) && (Log() << Verbose(3) << "Mismatch in AtomCount " << AtomCount << " and recounted number " << i << ", renaming all." << endl);
    832832    AtomCount = i;
    833833
     
    845845        Walker->Name = Malloc<char>(6, "molecule::CountAtoms: *walker->Name");
    846846        sprintf(Walker->Name, "%2s%02d", Walker->type->symbol, Walker->nr+1);
    847         Log() << Verbose(3) << "Naming atom nr. " << Walker->nr << " " << Walker->Name << "." << endl;
     847        DoLog(3) && (Log() << Verbose(3) << "Naming atom nr. " << Walker->nr << " " << Walker->Name << "." << endl);
    848848        i++;
    849849      }
    850850    } else
    851       Log() << Verbose(3) << "AtomCount is still " << AtomCount << ", thus counting nothing." << endl;
     851      DoLog(3) && (Log() << Verbose(3) << "AtomCount is still " << AtomCount << ", thus counting nothing." << endl);
    852852  }
    853853};
     
    909909  bool result = true; // status of comparison
    910910
    911   Log() << Verbose(3) << "Begin of IsEqualToWithinThreshold." << endl;
     911  DoLog(3) && (Log() << Verbose(3) << "Begin of IsEqualToWithinThreshold." << endl);
    912912  /// first count both their atoms and elements and update lists thereby ...
    913913  //Log() << Verbose(0) << "Counting atoms, updating list" << endl;
     
    921921  if (result) {
    922922    if (AtomCount != OtherMolecule->AtomCount) {
    923       Log() << Verbose(4) << "AtomCounts don't match: " << AtomCount << " == " << OtherMolecule->AtomCount << endl;
     923      DoLog(4) && (Log() << Verbose(4) << "AtomCounts don't match: " << AtomCount << " == " << OtherMolecule->AtomCount << endl);
    924924      result = false;
    925925    } else Log() << Verbose(4) << "AtomCounts match: " << AtomCount << " == " << OtherMolecule->AtomCount << endl;
     
    928928  if (result) {
    929929    if (ElementCount != OtherMolecule->ElementCount) {
    930       Log() << Verbose(4) << "ElementCount don't match: " << ElementCount << " == " << OtherMolecule->ElementCount << endl;
     930      DoLog(4) && (Log() << Verbose(4) << "ElementCount don't match: " << ElementCount << " == " << OtherMolecule->ElementCount << endl);
    931931      result = false;
    932932    } else Log() << Verbose(4) << "ElementCount match: " << ElementCount << " == " << OtherMolecule->ElementCount << endl;
     
    940940    }
    941941    if (flag < MAX_ELEMENTS) {
    942       Log() << Verbose(4) << "ElementsInMolecule don't match." << endl;
     942      DoLog(4) && (Log() << Verbose(4) << "ElementsInMolecule don't match." << endl);
    943943      result = false;
    944944    } else Log() << Verbose(4) << "ElementsInMolecule match." << endl;
     
    946946  /// then determine and compare center of gravity for each molecule ...
    947947  if (result) {
    948     Log() << Verbose(5) << "Calculating Centers of Gravity" << endl;
     948    DoLog(5) && (Log() << Verbose(5) << "Calculating Centers of Gravity" << endl);
    949949    DeterminePeriodicCenter(CenterOfGravity);
    950950    OtherMolecule->DeterminePeriodicCenter(OtherCenterOfGravity);
    951     Log() << Verbose(5) << "Center of Gravity: ";
     951    DoLog(5) && (Log() << Verbose(5) << "Center of Gravity: ");
    952952    CenterOfGravity.Output();
    953     Log() << Verbose(0) << endl << Verbose(5) << "Other Center of Gravity: ";
     953    DoLog(0) && (Log() << Verbose(0) << endl << Verbose(5) << "Other Center of Gravity: ");
    954954    OtherCenterOfGravity.Output();
    955     Log() << Verbose(0) << endl;
     955    DoLog(0) && (Log() << Verbose(0) << endl);
    956956    if (CenterOfGravity.DistanceSquared(&OtherCenterOfGravity) > threshold*threshold) {
    957       Log() << Verbose(4) << "Centers of gravity don't match." << endl;
     957      DoLog(4) && (Log() << Verbose(4) << "Centers of gravity don't match." << endl);
    958958      result = false;
    959959    }
     
    962962  /// ... then make a list with the euclidian distance to this center for each atom of both molecules
    963963  if (result) {
    964     Log() << Verbose(5) << "Calculating distances" << endl;
     964    DoLog(5) && (Log() << Verbose(5) << "Calculating distances" << endl);
    965965    Distances = Calloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: Distances");
    966966    OtherDistances = Calloc<double>(AtomCount, "molecule::IsEqualToWithinThreshold: OtherDistances");
     
    969969
    970970    /// ... sort each list (using heapsort (o(N log N)) from GSL)
    971     Log() << Verbose(5) << "Sorting distances" << endl;
     971    DoLog(5) && (Log() << Verbose(5) << "Sorting distances" << endl);
    972972    PermMap = Calloc<size_t>(AtomCount, "molecule::IsEqualToWithinThreshold: *PermMap");
    973973    OtherPermMap = Calloc<size_t>(AtomCount, "molecule::IsEqualToWithinThreshold: *OtherPermMap");
     
    975975    gsl_heapsort_index (OtherPermMap, OtherDistances, AtomCount, sizeof(double), CompareDoubles);
    976976    PermutationMap = Calloc<int>(AtomCount, "molecule::IsEqualToWithinThreshold: *PermutationMap");
    977     Log() << Verbose(5) << "Combining Permutation Maps" << endl;
     977    DoLog(5) && (Log() << Verbose(5) << "Combining Permutation Maps" << endl);
    978978    for(int i=AtomCount;i--;)
    979979      PermutationMap[PermMap[i]] = (int) OtherPermMap[i];
    980980
    981981    /// ... and compare them step by step, whether the difference is individually(!) below \a threshold for all
    982     Log() << Verbose(4) << "Comparing distances" << endl;
     982    DoLog(4) && (Log() << Verbose(4) << "Comparing distances" << endl);
    983983    flag = 0;
    984984    for (int i=0;i<AtomCount;i++) {
    985       Log() << Verbose(5) << "Distances squared: |" << Distances[PermMap[i]] << " - " << OtherDistances[OtherPermMap[i]] << "| = " << fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) << " ?<? " <<  threshold << endl;
     985      DoLog(5) && (Log() << Verbose(5) << "Distances squared: |" << Distances[PermMap[i]] << " - " << OtherDistances[OtherPermMap[i]] << "| = " << fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) << " ?<? " <<  threshold << endl);
    986986      if (fabs(Distances[PermMap[i]] - OtherDistances[OtherPermMap[i]]) > threshold*threshold)
    987987        flag = 1;
     
    999999  }
    10001000  /// return pointer to map if all distances were below \a threshold
    1001   Log() << Verbose(3) << "End of IsEqualToWithinThreshold." << endl;
     1001  DoLog(3) && (Log() << Verbose(3) << "End of IsEqualToWithinThreshold." << endl);
    10021002  if (result) {
    1003     Log() << Verbose(3) << "Result: Equal." << endl;
     1003    DoLog(3) && (Log() << Verbose(3) << "Result: Equal." << endl);
    10041004    return PermutationMap;
    10051005  } else {
    1006     Log() << Verbose(3) << "Result: Not equal." << endl;
     1006    DoLog(3) && (Log() << Verbose(3) << "Result: Not equal." << endl);
    10071007    return NULL;
    10081008  }
     
    10191019{
    10201020  atom *Walker = NULL, *OtherWalker = NULL;
    1021   Log() << Verbose(3) << "Begin of GetFatherAtomicMap." << endl;
     1021  DoLog(3) && (Log() << Verbose(3) << "Begin of GetFatherAtomicMap." << endl);
    10221022  int *AtomicMap = Malloc<int>(AtomCount, "molecule::GetAtomicMap: *AtomicMap");
    10231023  for (int i=AtomCount;i--;)
     
    10261026    for (int i=AtomCount;i--;) // no need as -1 means already that there is trivial correspondence
    10271027      AtomicMap[i] = i;
    1028     Log() << Verbose(4) << "Map is trivial." << endl;
     1028    DoLog(4) && (Log() << Verbose(4) << "Map is trivial." << endl);
    10291029  } else {
    1030     Log() << Verbose(4) << "Map is ";
     1030    DoLog(4) && (Log() << Verbose(4) << "Map is ");
    10311031    Walker = start;
    10321032    while (Walker->next != end) {
     
    10451045        }
    10461046      }
    1047       Log() << Verbose(0) << AtomicMap[Walker->nr] << "\t";
    1048     }
    1049     Log() << Verbose(0) << endl;
    1050   }
    1051   Log() << Verbose(3) << "End of GetFatherAtomicMap." << endl;
     1047      DoLog(0) && (Log() << Verbose(0) << AtomicMap[Walker->nr] << "\t");
     1048    }
     1049    DoLog(0) && (Log() << Verbose(0) << endl);
     1050  }
     1051  DoLog(3) && (Log() << Verbose(3) << "End of GetFatherAtomicMap." << endl);
    10521052  return AtomicMap;
    10531053};
  • src/molecule.hpp

    r70378e rd6c485  
    268268  int FragmentMolecule(int Order, config *configuration);
    269269  bool CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, char *path = NULL);
    270   bool StoreBondsToFile(char *path);
    271   bool StoreAdjacencyToFile(char *path);
     270  bool StoreBondsToFile(char *path, char *filename);
     271  bool StoreAdjacencyToFile(char *path, char *filename);
    272272  bool CheckAdjacencyFileAgainstMolecule(char *path, atom **ListOfAtoms);
    273273  bool ParseOrderAtSiteFromFile(char *path);
  • src/molecule_dynamics.cpp

    r70378e rd6c485  
    207207    doubles++;
    208208  if (doubles >0)
    209     Log() << Verbose(2) << "Found " << doubles << " Doubles." << endl;
     209    DoLog(2) && (Log() << Verbose(2) << "Found " << doubles << " Doubles." << endl);
    210210  Free(&DoubleList);
    211211//  Log() << Verbose(2) << zeile1.str() << endl << zeile2.str() << endl;
     
    249249    Params.DoubleList[Params.DistanceList[Walker->nr]->begin()->second->nr]++;            // increase this target's source count (>1? not injective)
    250250    Params.DistanceIterators[Walker->nr] = Params.DistanceList[Walker->nr]->begin();    // and remember which one we picked
    251     Log() << Verbose(2) << *Walker << " starts with distance " << Params.DistanceList[Walker->nr]->begin()->first << "." << endl;
     251    DoLog(2) && (Log() << Verbose(2) << *Walker << " starts with distance " << Params.DistanceList[Walker->nr]->begin()->first << "." << endl);
    252252  }
    253253};
     
    277277      Params.DistanceIterators[Walker->nr] = NewBase;
    278278      OldPotential = Potential;
    279       Log() << Verbose(3) << "Found a new permutation, new potential is " << OldPotential << "." << endl;
     279      DoLog(3) && (Log() << Verbose(3) << "Found a new permutation, new potential is " << OldPotential << "." << endl);
    280280    }
    281281  }
     
    306306  for (int i=mol->AtomCount; i--;) // now each single entry in the DoubleList should be <=1
    307307    if (Params.DoubleList[i] > 1) {
    308       eLog() << Verbose(0) << "Failed to create an injective PermutationMap!" << endl;
     308      DoeLog(0) && (eLog()<< Verbose(0) << "Failed to create an injective PermutationMap!" << endl);
    309309      performCriticalExit();
    310310    }
    311   Log() << Verbose(1) << "done." << endl;
     311  DoLog(1) && (Log() << Verbose(1) << "done." << endl);
    312312};
    313313
     
    358358  Params.PenaltyConstants[2] = 1e+7;    // just a huge penalty
    359359  // generate the distance list
    360   Log() << Verbose(1) << "Allocating, initializting and filling the distance list ... " << endl;
     360  DoLog(1) && (Log() << Verbose(1) << "Allocating, initializting and filling the distance list ... " << endl);
    361361  FillDistanceList(this, Params);
    362362
     
    365365
    366366  // make the PermutationMap injective by checking whether we have a non-zero constants[2] term in it
    367   Log() << Verbose(1) << "Making the PermutationMap injective ... " << endl;
     367  DoLog(1) && (Log() << Verbose(1) << "Making the PermutationMap injective ... " << endl);
    368368  MakeInjectivePermutation(this, Params);
    369369  Free(&Params.DoubleList);
    370370
    371371  // argument minimise the constrained potential in this injective PermutationMap
    372   Log() << Verbose(1) << "Argument minimising the PermutationMap." << endl;
     372  DoLog(1) && (Log() << Verbose(1) << "Argument minimising the PermutationMap." << endl);
    373373  OldPotential = 1e+10;
    374374  round = 0;
    375375  do {
    376     Log() << Verbose(2) << "Starting round " << ++round << ", at current potential " << OldPotential << " ... " << endl;
     376    DoLog(2) && (Log() << Verbose(2) << "Starting round " << ++round << ", at current potential " << OldPotential << " ... " << endl);
    377377    OlderPotential = OldPotential;
    378378    do {
     
    424424            } else {
    425425              Params.DistanceIterators[Runner->nr] = Rider;  // if successful also move the pointer in the iterator list
    426               Log() << Verbose(3) << "Found a better permutation, new potential is " << Potential << " vs." << OldPotential << "." << endl;
     426              DoLog(3) && (Log() << Verbose(3) << "Found a better permutation, new potential is " << Potential << " vs." << OldPotential << "." << endl);
    427427              OldPotential = Potential;
    428428            }
    429429            if (Potential > Params.PenaltyConstants[2]) {
    430               eLog() << Verbose(1) << "The two-step permutation procedure did not maintain injectivity!" << endl;
     430              DoeLog(1) && (eLog()<< Verbose(1) << "The two-step permutation procedure did not maintain injectivity!" << endl);
    431431              exit(255);
    432432            }
    433433            //Log() << Verbose(0) << endl;
    434434          } else {
    435             eLog() << Verbose(1) << *Runner << " was not the owner of " << *Sprinter << "!" << endl;
     435            DoeLog(1) && (eLog()<< Verbose(1) << *Runner << " was not the owner of " << *Sprinter << "!" << endl);
    436436            exit(255);
    437437          }
     
    443443    } while (Walker->next != end);
    444444  } while ((OlderPotential - OldPotential) > 1e-3);
    445   Log() << Verbose(1) << "done." << endl;
     445  DoLog(1) && (Log() << Verbose(1) << "done." << endl);
    446446
    447447
     
    466466{
    467467  /// evaluate forces (only the distance to target dependent part) with the final PermutationMap
    468   Log() << Verbose(1) << "Calculating forces and adding onto ForceMatrix ... " << endl;
     468  DoLog(1) && (Log() << Verbose(1) << "Calculating forces and adding onto ForceMatrix ... " << endl);
    469469  ActOnAllAtoms( &atom::EvaluateConstrainedForce, startstep, endstep, PermutationMap, Force );
    470   Log() << Verbose(1) << "done." << endl;
     470  DoLog(1) && (Log() << Verbose(1) << "done." << endl);
    471471};
    472472
     
    503503
    504504  // go through all steps and add the molecular configuration to the list and to the Trajectories of \a this molecule
    505   Log() << Verbose(1) << "Filling intermediate " << MaxSteps << " steps with MDSteps of " << MDSteps << "." << endl;
     505  DoLog(1) && (Log() << Verbose(1) << "Filling intermediate " << MaxSteps << " steps with MDSteps of " << MDSteps << "." << endl);
    506506  for (int step = 0; step <= MaxSteps; step++) {
    507507    mol = new molecule(elemente);
     
    568568    // parse file into ForceMatrix
    569569    if (!Force.ParseMatrix(file, 0,0,0)) {
    570       eLog() << Verbose(0) << "Could not parse Force Matrix file " << file << "." << endl;
     570      DoeLog(0) && (eLog()<< Verbose(0) << "Could not parse Force Matrix file " << file << "." << endl);
    571571      performCriticalExit();
    572572      return false;
    573573    }
    574574    if (Force.RowCounter[0] != AtomCount) {
    575       eLog() << Verbose(0) << "Mismatch between number of atoms in file " << Force.RowCounter[0] << " and in molecule " << AtomCount << "." << endl;
     575      DoeLog(0) && (eLog()<< Verbose(0) << "Mismatch between number of atoms in file " << Force.RowCounter[0] << " and in molecule " << AtomCount << "." << endl);
    576576      performCriticalExit();
    577577      return false;
     
    652652  switch(Thermostat) {
    653653     case None:
    654       Log() << Verbose(2) <<  "Applying no thermostat..." << endl;
     654      DoLog(2) && (Log() << Verbose(2) <<  "Applying no thermostat..." << endl);
    655655      break;
    656656     case Woodcock:
    657657      if ((configuration.ScaleTempStep > 0) && ((MDSteps-1) % configuration.ScaleTempStep == 0)) {
    658         Log() << Verbose(2) <<  "Applying Woodcock thermostat..." << endl;
     658        DoLog(2) && (Log() << Verbose(2) <<  "Applying Woodcock thermostat..." << endl);
    659659        ActOnAllAtoms( &atom::Thermostat_Woodcock, sqrt(ScaleTempFactor), MDSteps, &ekin );
    660660      }
    661661      break;
    662662     case Gaussian:
    663       Log() << Verbose(2) <<  "Applying Gaussian thermostat..." << endl;
     663      DoLog(2) && (Log() << Verbose(2) <<  "Applying Gaussian thermostat..." << endl);
    664664      ActOnAllAtoms( &atom::Thermostat_Gaussian_init, MDSteps, &G, &E );
    665665
    666       Log() << Verbose(1) << "Gaussian Least Constraint constant is " << G/E << "." << endl;
     666      DoLog(1) && (Log() << Verbose(1) << "Gaussian Least Constraint constant is " << G/E << "." << endl);
    667667      ActOnAllAtoms( &atom::Thermostat_Gaussian_least_constraint, MDSteps, G/E, &ekin, &configuration);
    668668
    669669      break;
    670670     case Langevin:
    671       Log() << Verbose(2) <<  "Applying Langevin thermostat..." << endl;
     671      DoLog(2) && (Log() << Verbose(2) <<  "Applying Langevin thermostat..." << endl);
    672672      // init random number generator
    673673      gsl_rng_env_setup();
     
    679679
    680680     case Berendsen:
    681       Log() << Verbose(2) <<  "Applying Berendsen-VanGunsteren thermostat..." << endl;
     681      DoLog(2) && (Log() << Verbose(2) <<  "Applying Berendsen-VanGunsteren thermostat..." << endl);
    682682      ActOnAllAtoms( &atom::Thermostat_Berendsen, MDSteps, ScaleTempFactor, &ekin, &configuration );
    683683      break;
    684684
    685685     case NoseHoover:
    686       Log() << Verbose(2) <<  "Applying Nose-Hoover thermostat..." << endl;
     686      DoLog(2) && (Log() << Verbose(2) <<  "Applying Nose-Hoover thermostat..." << endl);
    687687      // dynamically evolve alpha (the additional degree of freedom)
    688688      delta_alpha = 0.;
     
    690690      delta_alpha = (delta_alpha - (3.*AtomCount+1.) * configuration.TargetTemp)/(configuration.HooverMass*Units2Electronmass);
    691691      configuration.alpha += delta_alpha*configuration.Deltat;
    692       Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration.alpha << "." << endl;
     692      DoLog(3) && (Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration.alpha << "." << endl);
    693693      // apply updated alpha as additional force
    694694      ActOnAllAtoms( &atom::Thermostat_NoseHoover_scale, MDSteps, &ekin, &configuration );
    695695      break;
    696696  }
    697   Log() << Verbose(1) << "Kinetic energy is " << ekin << "." << endl;
    698 };
     697  DoLog(1) && (Log() << Verbose(1) << "Kinetic energy is " << ekin << "." << endl);
     698};
  • src/molecule_fragmentation.cpp

    r70378e rd6c485  
    4444  }
    4545  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;
     46  DoLog(1) && (Log() << Verbose(1) << "Upper limit for this subgraph is " << FragmentCount << " for " << NoNonHydrogen << " non-H atoms with maximum bond degree of " << c << "." << endl);
    4747  return FragmentCount;
    4848};
     
    6868    } // else it's "-1" or else and thus must not be added
    6969  }
    70   Log() << Verbose(1) << "The scanned KeySet is ";
     70  DoLog(1) && (Log() << Verbose(1) << "The scanned KeySet is ");
    7171  for(KeySet::iterator runner = CurrentSet.begin(); runner != CurrentSet.end(); runner++) {
    72     Log() << Verbose(0) << (*runner) << "\t";
    73   }
    74   Log() << Verbose(0) << endl;
     72    DoLog(0) && (Log() << Verbose(0) << (*runner) << "\t");
     73  }
     74  DoLog(0) && (Log() << Verbose(0) << endl);
    7575  return (status != 0);
    7676};
     
    100100
    101101  // 1st pass: open file and read
    102   Log() << Verbose(1) << "Parsing the KeySet file ... " << endl;
     102  DoLog(1) && (Log() << Verbose(1) << "Parsing the KeySet file ... " << endl);
    103103  sprintf(filename, "%s/%s%s", path, FRAGMENTPREFIX, KEYSETFILE);
    104104  InputFile.open(filename);
     
    113113        testGraphInsert = FragmentList->insert(GraphPair (CurrentSet,pair<int,double>(NumberOfFragments++,1)));  // store fragment number and current factor
    114114        if (!testGraphInsert.second) {
    115           eLog() << Verbose(0) << "KeySet file must be corrupt as there are two equal key sets therein!" << endl;
     115          DoeLog(0) && (eLog()<< Verbose(0) << "KeySet file must be corrupt as there are two equal key sets therein!" << endl);
    116116          performCriticalExit();
    117117        }
     
    122122    InputFile.clear();
    123123    Free(&buffer);
    124     Log() << Verbose(1) << "done." << endl;
     124    DoLog(1) && (Log() << Verbose(1) << "done." << endl);
    125125  } else {
    126     Log() << Verbose(1) << "File " << filename << " not found." << endl;
     126    DoLog(1) && (Log() << Verbose(1) << "File " << filename << " not found." << endl);
    127127    status = false;
    128128  }
     
    154154
    155155  // 2nd pass: open TEFactors file and read
    156   Log() << Verbose(1) << "Parsing the TEFactors file ... " << endl;
     156  DoLog(1) && (Log() << Verbose(1) << "Parsing the TEFactors file ... " << endl);
    157157  sprintf(filename, "%s/%s%s", path, FRAGMENTPREFIX, TEFACTORSFILE);
    158158  InputFile.open(filename);
     
    164164        InputFile >> TEFactor;
    165165        (*runner).second.second = TEFactor;
    166         Log() << Verbose(2) << "Setting " << ++NumberOfFragments << " fragment's TEFactor to " << (*runner).second.second << "." << endl;
     166        DoLog(2) && (Log() << Verbose(2) << "Setting " << ++NumberOfFragments << " fragment's TEFactor to " << (*runner).second.second << "." << endl);
    167167      } else {
    168168        status = false;
     
    172172    // 4. Free and done
    173173    InputFile.close();
    174     Log() << Verbose(1) << "done." << endl;
     174    DoLog(1) && (Log() << Verbose(1) << "done." << endl);
    175175  } else {
    176     Log() << Verbose(1) << "File " << filename << " not found." << endl;
     176    DoLog(1) && (Log() << Verbose(1) << "File " << filename << " not found." << endl);
    177177    status = false;
    178178  }
     
    202202  line += KEYSETFILE;
    203203  output.open(line.c_str(), ios::out);
    204   Log() << Verbose(1) << "Saving key sets of the total graph ... ";
     204  DoLog(1) && (Log() << Verbose(1) << "Saving key sets of the total graph ... ");
    205205  if(output != NULL) {
    206206    for(Graph::iterator runner = KeySetList.begin(); runner != KeySetList.end(); runner++) {
     
    212212      output << endl;
    213213    }
    214     Log() << Verbose(0) << "done." << endl;
     214    DoLog(0) && (Log() << Verbose(0) << "done." << endl);
    215215  } else {
    216     eLog() << Verbose(0) << "Unable to open " << line << " for writing keysets!" << endl;
     216    DoeLog(0) && (eLog()<< Verbose(0) << "Unable to open " << line << " for writing keysets!" << endl);
    217217    performCriticalExit();
    218218    status = false;
     
    243243  line += TEFACTORSFILE;
    244244  output.open(line.c_str(), ios::out);
    245   Log() << Verbose(1) << "Saving TEFactors of the total graph ... ";
     245  DoLog(1) && (Log() << Verbose(1) << "Saving TEFactors of the total graph ... ");
    246246  if(output != NULL) {
    247247    for(Graph::iterator runner = KeySetList.begin(); runner != KeySetList.end(); runner++)
    248248      output << (*runner).second.second << endl;
    249     Log() << Verbose(1) << "done." << endl;
     249    DoLog(1) && (Log() << Verbose(1) << "done." << endl);
    250250  } else {
    251     Log() << Verbose(1) << "failed to open " << line << "." << endl;
     251    DoLog(1) && (Log() << Verbose(1) << "failed to open " << line << "." << endl);
    252252    status = false;
    253253  }
     
    293293        (*PresentItem).second.first = fabs(Value);
    294294        (*PresentItem).second.second = FragOrder;
    295         Log() << Verbose(2) << "Updated element (" <<  (*PresentItem).first << ",[" << (*PresentItem).second.first << "," << (*PresentItem).second.second << "])." << endl;
     295        DoLog(2) && (Log() << Verbose(2) << "Updated element (" <<  (*PresentItem).first << ",[" << (*PresentItem).second.first << "," << (*PresentItem).second.second << "])." << endl);
    296296      } else {
    297         Log() << Verbose(2) << "Did not update element " <<  (*PresentItem).first << " as " << FragOrder << " is less than or equal to " << (*PresentItem).second.second << "." << endl;
     297        DoLog(2) && (Log() << Verbose(2) << "Did not update element " <<  (*PresentItem).first << " as " << FragOrder << " is less than or equal to " << (*PresentItem).second.second << "." << endl);
    298298      }
    299299    } else {
    300       Log() << Verbose(2) << "Inserted element (" <<  (*PresentItem).first << ",[" << (*PresentItem).second.first << "," << (*PresentItem).second.second << "])." << endl;
     300      DoLog(2) && (Log() << Verbose(2) << "Inserted element (" <<  (*PresentItem).first << ",[" << (*PresentItem).second.first << "," << (*PresentItem).second.second << "])." << endl);
    301301    }
    302302  } else {
    303     Log() << Verbose(1) << "No Fragment under No. " << No << "found." << endl;
     303    DoLog(1) && (Log() << Verbose(1) << "No Fragment under No. " << No << "found." << endl);
    304304  }
    305305};
     
    360360  atom *Walker = mol->start;
    361361  map<double, pair<int,int> > *FinalRootCandidates = new map<double, pair<int,int> > ;
    362   Log() << Verbose(1) << "Root candidate list is: " << endl;
     362  DoLog(1) && (Log() << Verbose(1) << "Root candidate list is: " << endl);
    363363  for(map<int, pair<double,int> >::iterator runner = AdaptiveCriteriaList->begin(); runner != AdaptiveCriteriaList->end(); runner++) {
    364364    Walker = mol->FindAtom((*runner).first);
     
    366366      //if ((*runner).second.second >= Walker->AdaptiveOrder) { // only insert if this is an "active" root site for the current order
    367367      if (!Walker->MaxOrder) {
    368         Log() << Verbose(2) << "(" << (*runner).first << ",[" << (*runner).second.first << "," << (*runner).second.second << "])" << endl;
     368        DoLog(2) && (Log() << Verbose(2) << "(" << (*runner).first << ",[" << (*runner).second.first << "," << (*runner).second.second << "])" << endl);
    369369        FinalRootCandidates->insert( make_pair( (*runner).second.first, pair<int,int>((*runner).first, (*runner).second.second) ) );
    370370      } else {
    371         Log() << Verbose(2) << "Excluding (" << *Walker << ", " << (*runner).first << ",[" << (*runner).second.first << "," << (*runner).second.second << "]), as it has reached its maximum order." << endl;
     371        DoLog(2) && (Log() << Verbose(2) << "Excluding (" << *Walker << ", " << (*runner).first << ",[" << (*runner).second.first << "," << (*runner).second.second << "]), as it has reached its maximum order." << endl);
    372372      }
    373373    } else {
    374       eLog() << Verbose(0) << "Atom No. " << (*runner).second.first << " was not found in this molecule." << endl;
     374      DoeLog(0) && (eLog()<< Verbose(0) << "Atom No. " << (*runner).second.first << " was not found in this molecule." << endl);
    375375      performCriticalExit();
    376376    }
     
    397397    Walker = mol->FindAtom(No);
    398398    //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;
     399      DoLog(2) && (Log() << Verbose(2) << "Root " << No << " is still above threshold (10^{" << Order <<"}: " << runner->first << ", setting entry " << No << " of Atom mask to true." << endl);
    400400      AtomMask[No] = true;
    401401      status = true;
     
    413413void PrintAtomMask(bool *AtomMask, int AtomCount)
    414414{
    415   Log() << Verbose(2) << "              ";
     415  DoLog(2) && (Log() << Verbose(2) << "              ");
    416416  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: ";
     417    DoLog(0) && (Log() << Verbose(0) << (i % 10));
     418  DoLog(0) && (Log() << Verbose(0) << endl);
     419  DoLog(2) && (Log() << Verbose(2) << "Atom mask is: ");
    420420  for(int i=0;i<AtomCount;i++)
    421     Log() << Verbose(0) << (AtomMask[i] ? "t" : "f");
    422   Log() << Verbose(0) << endl;
     421    DoLog(0) && (Log() << Verbose(0) << (AtomMask[i] ? "t" : "f"));
     422  DoLog(0) && (Log() << Verbose(0) << endl);
    423423};
    424424
     
    447447    // transmorph graph keyset list into indexed KeySetList
    448448    if (GlobalKeySetList == NULL) {
    449       eLog() << Verbose(1) << "Given global key set list (graph) is NULL!" << endl;
     449      DoeLog(1) && (eLog()<< Verbose(1) << "Given global key set list (graph) is NULL!" << endl);
    450450      return false;
    451451    }
     
    455455    map<int, pair<double,int> > *AdaptiveCriteriaList = ScanAdaptiveFileIntoMap(path, *IndexKeySetList); // (Root No., (Value, Order)) !
    456456    if (AdaptiveCriteriaList->empty()) {
    457       eLog() << Verbose(2) << "Unable to parse file, incrementing all." << endl;
     457      DoeLog(2) && (eLog()<< Verbose(2) << "Unable to parse file, incrementing all." << endl);
    458458      while (Walker->next != end) {
    459459        Walker = Walker->next;
     
    493493    if (!status) {
    494494      if (Order == 0)
    495         Log() << Verbose(1) << "Single stepping done." << endl;
     495        DoLog(1) && (Log() << Verbose(1) << "Single stepping done." << endl);
    496496      else
    497         Log() << Verbose(1) << "Order at every site is already equal or above desired order " << Order << "." << endl;
     497        DoLog(1) && (Log() << Verbose(1) << "Order at every site is already equal or above desired order " << Order << "." << endl);
    498498    }
    499499  }
     
    512512{
    513513  if (SortIndex != NULL) {
    514     Log() << Verbose(1) << "SortIndex is " << SortIndex << " and not NULL as expected." << endl;
     514    DoLog(1) && (Log() << Verbose(1) << "SortIndex is " << SortIndex << " and not NULL as expected." << endl);
    515515    return false;
    516516  }
     
    563563  bool *AtomMask = NULL;
    564564
    565   Log() << Verbose(0) << endl;
     565  DoLog(0) && (Log() << Verbose(0) << endl);
    566566#ifdef ADDHYDROGEN
    567   Log() << Verbose(0) << "I will treat hydrogen special and saturate dangling bonds with it." << endl;
     567  DoLog(0) && (Log() << Verbose(0) << "I will treat hydrogen special and saturate dangling bonds with it." << endl);
    568568#else
    569   Log() << Verbose(0) << "Hydrogen is treated just like the rest of the lot." << endl;
     569  DoLog(0) && (Log() << Verbose(0) << "Hydrogen is treated just like the rest of the lot." << endl);
    570570#endif
    571571
     
    593593    // fill the bond structure of the individually stored subgraphs
    594594  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;
     595    DoLog(0) && (Log() << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl);
    596596    LocalBackEdgeStack = new StackClass<bond *> (MolecularWalker->Leaf->BondCount);
    597597//    // check the list of local atoms for debugging
     
    602602//      else
    603603//        Log() << Verbose(0) << "\t" << ListOfLocalAtoms[FragmentCounter][i]->Name;
    604     Log() << Verbose(0) << "Gathering local back edges for subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl;
     604    DoLog(0) && (Log() << Verbose(0) << "Gathering local back edges for subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl);
    605605    MolecularWalker->Leaf->PickLocalBackEdges(ListOfLocalAtoms[FragmentCounter++], BackEdgeStack, LocalBackEdgeStack);
    606     Log() << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl;
     606    DoLog(0) && (Log() << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl);
    607607    MolecularWalker->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize);
    608     Log() << Verbose(0) << "Done with Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl;
     608    DoLog(0) && (Log() << Verbose(0) << "Done with Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl);
    609609    delete(LocalBackEdgeStack);
    610610  }
     
    637637    while (MolecularWalker->next != NULL) {
    638638      MolecularWalker = MolecularWalker->next;
    639       Log() << Verbose(1) << "Fragmenting subgraph " << MolecularWalker << "." << endl;
     639      DoLog(1) && (Log() << Verbose(1) << "Fragmenting subgraph " << MolecularWalker << "." << endl);
    640640      //MolecularWalker->Leaf->OutputListOfBonds(out);  // output atom::ListOfBonds for debugging
    641641      if (MolecularWalker->Leaf->first->next != MolecularWalker->Leaf->last) {
    642642        // call BOSSANOVA method
    643         Log() << Verbose(0) << endl << " ========== BOND ENERGY of subgraph " << FragmentCounter << " ========================= " << endl;
     643        DoLog(0) && (Log() << Verbose(0) << endl << " ========== BOND ENERGY of subgraph " << FragmentCounter << " ========================= " << endl);
    644644        MolecularWalker->Leaf->FragmentBOSSANOVA(FragmentList[FragmentCounter], RootStack[FragmentCounter], MinimumRingSize);
    645645      } else {
    646         eLog() << Verbose(1) << "Subgraph " << MolecularWalker << " has no atoms!" << endl;
     646        DoeLog(1) && (eLog()<< Verbose(1) << "Subgraph " << MolecularWalker << " has no atoms!" << endl);
    647647      }
    648648      FragmentCounter++;  // next fragment list
    649649    }
    650650  }
    651   Log() << Verbose(2) << "CheckOrder is " << CheckOrder << "." << endl;
     651  DoLog(2) && (Log() << Verbose(2) << "CheckOrder is " << CheckOrder << "." << endl);
    652652  delete[](RootStack);
    653653  delete[](AtomMask);
     
    680680  for(Graph::iterator runner = TotalGraph.begin(); runner != TotalGraph.end(); runner++) {
    681681    KeySet test = (*runner).first;
    682     Log() << Verbose(0) << "Fragment No." << (*runner).second.first << " with TEFactor " << (*runner).second.second << "." << endl;
     682    DoLog(0) && (Log() << Verbose(0) << "Fragment No." << (*runner).second.first << " with TEFactor " << (*runner).second.second << "." << endl);
    683683    BondFragments->insert(StoreFragmentFromKeySet(test, configuration));
    684684    k++;
    685685  }
    686   Log() << Verbose(0) << k << "/" << BondFragments->ListOfMolecules.size() << " fragments generated from the keysets." << endl;
     686  DoLog(0) && (Log() << Verbose(0) << k << "/" << BondFragments->ListOfMolecules.size() << " fragments generated from the keysets." << endl);
    687687
    688688  // ===== 9. Save fragments' configuration and keyset files et al to disk ===
     
    691691    CreateMappingLabelsToConfigSequence(SortIndex);
    692692
    693     Log() << Verbose(1) << "Writing " << BondFragments->ListOfMolecules.size() << " possible bond fragmentation configs" << endl;
     693    DoLog(1) && (Log() << Verbose(1) << "Writing " << BondFragments->ListOfMolecules.size() << " possible bond fragmentation configs" << endl);
    694694    if (BondFragments->OutputConfigForListOfFragments(configuration, SortIndex))
    695       Log() << Verbose(1) << "All configs written." << endl;
     695      DoLog(1) && (Log() << Verbose(1) << "All configs written." << endl);
    696696    else
    697       Log() << Verbose(1) << "Some config writing failed." << endl;
     697      DoLog(1) && (Log() << Verbose(1) << "Some config writing failed." << endl);
    698698
    699699    // store force index reference file
     
    704704
    705705    // store Adjacency file
    706     StoreAdjacencyToFile(configuration->configpath);
     706    char *filename = Malloc<char> (MAXSTRINGSIZE, "molecule::FragmentMolecule - *filename");
     707    strcpy(filename, FRAGMENTPREFIX);
     708    strcat(filename, ADJACENCYFILE);
     709    StoreAdjacencyToFile(configuration->configpath, filename);
     710    Free(&filename);
    707711
    708712    // store Hydrogen saturation correction file
     
    716720
    717721    // free memory for bond part
    718     Log() << Verbose(1) << "Freeing bond memory" << endl;
     722    DoLog(1) && (Log() << Verbose(1) << "Freeing bond memory" << endl);
    719723    delete(FragmentList); // remove bond molecule from memory
    720724    Free(&SortIndex);
    721725  } else {
    722     Log() << Verbose(1) << "FragmentList is zero on return, splitting failed." << endl;
     726    DoLog(1) && (Log() << Verbose(1) << "FragmentList is zero on return, splitting failed." << endl);
    723727  }
    724728  delete(BondFragments);
    725   Log() << Verbose(0) << "End of bond fragmentation." << endl;
     729  DoLog(0) && (Log() << Verbose(0) << "End of bond fragmentation." << endl);
    726730
    727731  return ((int)(!FragmentationToDo)+1);    // 1 - continue, 2 - stop (no fragmentation occured)
     
    742746  line << path << "/" << FRAGMENTPREFIX << ORDERATSITEFILE;
    743747  file.open(line.str().c_str());
    744   Log() << Verbose(1) << "Writing OrderAtSite " << ORDERATSITEFILE << " ... " << endl;
     748  DoLog(1) && (Log() << Verbose(1) << "Writing OrderAtSite " << ORDERATSITEFILE << " ... " << endl);
    745749  if (file != NULL) {
    746750    ActOnAllAtoms( &atom::OutputOrder, &file );
    747751    file.close();
    748     Log() << Verbose(1) << "done." << endl;
     752    DoLog(1) && (Log() << Verbose(1) << "done." << endl);
    749753    return true;
    750754  } else {
    751     Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl;
     755    DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl);
    752756    return false;
    753757  }
     
    770774  ifstream file;
    771775
    772   Log() << Verbose(1) << "Begin of ParseOrderAtSiteFromFile" << endl;
     776  DoLog(1) && (Log() << Verbose(1) << "Begin of ParseOrderAtSiteFromFile" << endl);
    773777  line << path << "/" << FRAGMENTPREFIX << ORDERATSITEFILE;
    774778  file.open(line.str().c_str());
     
    791795    SetAtomValueToIndexedArray( MaxArray, &atom::nr, &atom::MaxOrder );
    792796
    793     Log() << Verbose(1) << "done." << endl;
     797    DoLog(1) && (Log() << Verbose(1) << "done." << endl);
    794798    status = true;
    795799  } else {
    796     Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl;
     800    DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl);
    797801    status = false;
    798802  }
     
    800804  Free(&MaxArray);
    801805
    802   Log() << Verbose(1) << "End of ParseOrderAtSiteFromFile" << endl;
     806  DoLog(1) && (Log() << Verbose(1) << "End of ParseOrderAtSiteFromFile" << endl);
    803807  return status;
    804808};
     
    817821  int SP, Removal;
    818822
    819   Log() << Verbose(2) << "Looking for removal candidate." << endl;
     823  DoLog(2) && (Log() << Verbose(2) << "Looking for removal candidate." << endl);
    820824  SP = -1; //0;  // not -1, so that Root is never removed
    821825  Removal = -1;
     
    902906      }
    903907    } else {
    904       eLog() << Verbose(1) << "Son " << Runner->Name << " has father " << FatherOfRunner->Name << " but its entry in SonList is " << SonList[FatherOfRunner->nr] << "!" << endl;
     908      DoeLog(1) && (eLog()<< Verbose(1) << "Son " << Runner->Name << " has father " << FatherOfRunner->Name << " but its entry in SonList is " << SonList[FatherOfRunner->nr] << "!" << endl);
    905909    }
    906910    if ((LonelyFlag) && (Leaf->AtomCount > 1)) {
    907       Log() << Verbose(0) << *Runner << "has got bonds only to hydrogens!" << endl;
     911      DoLog(0) && (Log() << Verbose(0) << *Runner << "has got bonds only to hydrogens!" << endl);
    908912    }
    909913#ifdef ADDHYDROGEN
     
    10521056    TouchedList[j] = -1;
    10531057  }
    1054   Log() << Verbose(2) << "Remaining local nr.s on snake stack are: ";
     1058  DoLog(2) && (Log() << Verbose(2) << "Remaining local nr.s on snake stack are: ");
    10551059  for(KeySet::iterator runner = FragmentSet->begin(); runner != FragmentSet->end(); runner++)
    1056     Log() << Verbose(0) << (*runner) << " ";
    1057   Log() << Verbose(0) << endl;
     1060    DoLog(0) && (Log() << Verbose(0) << (*runner) << " ");
     1061  DoLog(0) && (Log() << Verbose(0) << endl);
    10581062  TouchedIndex = 0; // set Index to 0 for list of atoms added on this level
    10591063};
     
    11321136        Log() << Verbose(1+verbosity) << "Enough items on stack for a fragment!" << endl;
    11331137        // store fragment as a KeySet
    1134         Log() << Verbose(2) << "Found a new fragment[" << FragmentSearch->FragmentCounter << "], local nr.s are: ";
     1138        DoLog(2) && (Log() << Verbose(2) << "Found a new fragment[" << FragmentSearch->FragmentCounter << "], local nr.s are: ");
    11351139        for(KeySet::iterator runner = FragmentSearch->FragmentSet->begin(); runner != FragmentSearch->FragmentSet->end(); runner++)
    1136           Log() << Verbose(0) << (*runner) << " ";
    1137         Log() << Verbose(0) << endl;
     1140          DoLog(0) && (Log() << Verbose(0) << (*runner) << " ");
     1141        DoLog(0) && (Log() << Verbose(0) << endl);
    11381142        //if (!CheckForConnectedSubgraph(FragmentSearch->FragmentSet))
    1139           //eLog() << Verbose(1) << "The found fragment is not a connected subgraph!" << endl;
     1143          //DoeLog(1) && (eLog()<< Verbose(1) << "The found fragment is not a connected subgraph!" << endl);
    11401144        InsertFragmentIntoGraph(FragmentSearch);
    11411145      }
     
    12171221{
    12181222  bond *Binder = NULL;
    1219   Log() << Verbose(0) << "Free'ing all found lists. and resetting index lists" << endl;
     1223  DoLog(0) && (Log() << Verbose(0) << "Free'ing all found lists. and resetting index lists" << endl);
    12201224  for(int i=Order;i--;) {
    1221     Log() << Verbose(1) << "Current SP level is " << i << ": ";
     1225    DoLog(1) && (Log() << Verbose(1) << "Current SP level is " << i << ": ");
    12221226    Binder = FragmentSearch.BondsPerSPList[2*i];
    12231227    while (Binder->next != FragmentSearch.BondsPerSPList[2*i+1]) {
     
    12301234    cleanup(FragmentSearch.BondsPerSPList[2*i], FragmentSearch.BondsPerSPList[2*i+1]);
    12311235    // also start and end node
    1232     Log() << Verbose(0) << "cleaned." << endl;
     1236    DoLog(0) && (Log() << Verbose(0) << "cleaned." << endl);
    12331237  }
    12341238};
     
    12601264  int SP = -1;
    12611265
    1262   Log() << Verbose(0) << "Starting BFS analysis ..." << endl;
     1266  DoLog(0) && (Log() << Verbose(0) << "Starting BFS analysis ..." << endl);
    12631267  for (SP = 0; SP < (Order-1); SP++) {
    1264     Log() << Verbose(1) << "New SP level reached: " << SP << ", creating new SP list with " << FragmentSearch.BondsPerSPCount[SP] << " item(s)";
     1268    DoLog(1) && (Log() << Verbose(1) << "New SP level reached: " << SP << ", creating new SP list with " << FragmentSearch.BondsPerSPCount[SP] << " item(s)");
    12651269    if (SP > 0) {
    1266       Log() << Verbose(0) << ", old level closed with " << FragmentSearch.BondsPerSPCount[SP-1] << " item(s)." << endl;
     1270      DoLog(0) && (Log() << Verbose(0) << ", old level closed with " << FragmentSearch.BondsPerSPCount[SP-1] << " item(s)." << endl);
    12671271      FragmentSearch.BondsPerSPCount[SP] = 0;
    12681272    } else
    1269       Log() << Verbose(0) << "." << endl;
     1273      DoLog(0) && (Log() << Verbose(0) << "." << endl);
    12701274
    12711275    RemainingWalkers = FragmentSearch.BondsPerSPCount[SP];
     
    12771281      Predecessor = CurrentEdge->leftatom;    // ... and leftatom is predecessor
    12781282      AtomKeyNr = Walker->nr;
    1279       Log() << Verbose(0) << "Current Walker is: " << *Walker << " with nr " << Walker->nr << " and SP of " << SP << ", with " << RemainingWalkers << " remaining walkers on this level." << endl;
     1283      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);
    12801284      // check for new sp level
    12811285      // go through all its bonds
    1282       Log() << Verbose(1) << "Going through all bonds of Walker." << endl;
     1286      DoLog(1) && (Log() << Verbose(1) << "Going through all bonds of Walker." << endl);
    12831287      for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
    12841288        OtherWalker = (*Runner)->GetOtherAtom(Walker);
     
    12881292  #endif
    12891293                                                              ) {  // skip hydrogens and restrict to fragment
    1290           Log() << Verbose(2) << "Current partner is " << *OtherWalker << " with nr " << OtherWalker->nr << " in bond " << *(*Runner) << "." << endl;
     1294          DoLog(2) && (Log() << Verbose(2) << "Current partner is " << *OtherWalker << " with nr " << OtherWalker->nr << " in bond " << *(*Runner) << "." << endl);
    12911295          // set the label if not set (and push on root stack as well)
    12921296          if ((OtherWalker != Predecessor) && (OtherWalker->GetTrueFather()->nr > RootKeyNr)) { // only pass through those with label bigger than Root's
    12931297            FragmentSearch.ShortestPathList[OtherWalker->nr] = SP+1;
    1294             Log() << Verbose(3) << "Set Shortest Path to " << FragmentSearch.ShortestPathList[OtherWalker->nr] << "." << endl;
     1298            DoLog(3) && (Log() << Verbose(3) << "Set Shortest Path to " << FragmentSearch.ShortestPathList[OtherWalker->nr] << "." << endl);
    12951299            // add the bond in between to the SP list
    12961300            Binder = new bond(Walker, OtherWalker); // create a new bond in such a manner, that bond::rightatom is always the one more distant
    12971301            add(Binder, FragmentSearch.BondsPerSPList[2*(SP+1)+1]);
    12981302            FragmentSearch.BondsPerSPCount[SP+1]++;
    1299             Log() << Verbose(3) << "Added its bond to SP list, having now " << FragmentSearch.BondsPerSPCount[SP+1] << " item(s)." << endl;
     1303            DoLog(3) && (Log() << Verbose(3) << "Added its bond to SP list, having now " << FragmentSearch.BondsPerSPCount[SP+1] << " item(s)." << endl);
    13001304          } else {
    13011305            if (OtherWalker != Predecessor)
    1302               Log() << Verbose(3) << "Not passing on, as index of " << *OtherWalker << " " << OtherWalker->GetTrueFather()->nr << " is smaller than that of Root " << RootKeyNr << "." << endl;
     1306              DoLog(3) && (Log() << Verbose(3) << "Not passing on, as index of " << *OtherWalker << " " << OtherWalker->GetTrueFather()->nr << " is smaller than that of Root " << RootKeyNr << "." << endl);
    13031307            else
    1304               Log() << Verbose(3) << "This is my predecessor " << *Predecessor << "." << endl;
     1308              DoLog(3) && (Log() << Verbose(3) << "This is my predecessor " << *Predecessor << "." << endl);
    13051309          }
    13061310        } else Log() << Verbose(2) << "Is not in the restricted keyset or skipping hydrogen " << *OtherWalker << "." << endl;
     
    13181322{
    13191323  bond *Binder = NULL;
    1320   Log() << Verbose(0) << "Printing all found lists." << endl;
     1324  DoLog(0) && (Log() << Verbose(0) << "Printing all found lists." << endl);
    13211325  for(int i=1;i<Order;i++) {    // skip the root edge in the printing
    13221326    Binder = FragmentSearch.BondsPerSPList[2*i];
    1323     Log() << Verbose(1) << "Current SP level is " << i << "." << endl;
     1327    DoLog(1) && (Log() << Verbose(1) << "Current SP level is " << i << "." << endl);
    13241328    while (Binder->next != FragmentSearch.BondsPerSPList[2*i+1]) {
    13251329      Binder = Binder->next;
    1326       Log() << Verbose(2) << *Binder << endl;
     1330      DoLog(2) && (Log() << Verbose(2) << *Binder << endl);
    13271331    }
    13281332  }
     
    13681372  int Counter = FragmentSearch.FragmentCounter; // mark current value of counter
    13691373
    1370   Log() << Verbose(0) << endl;
    1371   Log() << Verbose(0) << "Begin of PowerSetGenerator with order " << Order << " at Root " << *FragmentSearch.Root << "." << endl;
     1374  DoLog(0) && (Log() << Verbose(0) << endl);
     1375  DoLog(0) && (Log() << Verbose(0) << "Begin of PowerSetGenerator with order " << Order << " at Root " << *FragmentSearch.Root << "." << endl);
    13721376
    13731377  SetSPList(Order, FragmentSearch);
     
    13811385  // creating fragments with the found edge sets  (may be done in reverse order, faster)
    13821386  int SP = CountNumbersInBondsList(Order, FragmentSearch);
    1383   Log() << Verbose(0) << "Total number of edges is " << SP << "." << endl;
     1387  DoLog(0) && (Log() << Verbose(0) << "Total number of edges is " << SP << "." << endl);
    13841388  if (SP >= (Order-1)) {
    13851389    // start with root (push on fragment stack)
    1386     Log() << Verbose(0) << "Starting fragment generation with " << *FragmentSearch.Root << ", local nr is " << FragmentSearch.Root->nr << "." << endl;
     1390    DoLog(0) && (Log() << Verbose(0) << "Starting fragment generation with " << *FragmentSearch.Root << ", local nr is " << FragmentSearch.Root->nr << "." << endl);
    13871391    FragmentSearch.FragmentSet->clear();
    1388     Log() << Verbose(0) << "Preparing subset for this root and calling generator." << endl;
     1392    DoLog(0) && (Log() << Verbose(0) << "Preparing subset for this root and calling generator." << endl);
    13891393
    13901394    // prepare the subset and call the generator
     
    13961400    Free(&BondsList);
    13971401  } else {
    1398     Log() << Verbose(0) << "Not enough total number of edges to build " << Order << "-body fragments." << endl;
     1402    DoLog(0) && (Log() << Verbose(0) << "Not enough total number of edges to build " << Order << "-body fragments." << endl);
    13991403  }
    14001404
    14011405  // as FragmentSearch structure is used only once, we don't have to clean it anymore
    14021406  // remove root from stack
    1403   Log() << Verbose(0) << "Removing root again from stack." << endl;
     1407  DoLog(0) && (Log() << Verbose(0) << "Removing root again from stack." << endl);
    14041408  FragmentSearch.FragmentSet->erase(FragmentSearch.Root->nr);
    14051409
     
    14081412
    14091413  // return list
    1410   Log() << Verbose(0) << "End of PowerSetGenerator." << endl;
     1414  DoLog(0) && (Log() << Verbose(0) << "End of PowerSetGenerator." << endl);
    14111415  return (FragmentSearch.FragmentCounter - Counter);
    14121416};
     
    14541458  atom *Walker = NULL;
    14551459
    1456   Log() << Verbose(0) << "Combining the lists of all orders per order and finally into a single one." << endl;
     1460  DoLog(0) && (Log() << Verbose(0) << "Combining the lists of all orders per order and finally into a single one." << endl);
    14571461  if (FragmentList == NULL) {
    14581462    FragmentList = new Graph;
     
    14871491void FreeAllOrdersList(Graph ***FragmentLowerOrdersList, KeyStack &RootStack, molecule *mol)
    14881492{
    1489   Log() << Verbose(1) << "Free'ing the lists of all orders per order." << endl;
     1493  DoLog(1) && (Log() << Verbose(1) << "Free'ing the lists of all orders per order." << endl);
    14901494  int RootNr = 0;
    14911495  int RootKeyNr = 0;
     
    15401544  struct UniqueFragments FragmentSearch;
    15411545
    1542   Log() << Verbose(0) << "Begin of FragmentBOSSANOVA." << endl;
     1546  DoLog(0) && (Log() << Verbose(0) << "Begin of FragmentBOSSANOVA." << endl);
    15431547
    15441548  // FragmentLowerOrdersList is a 2D-array of pointer to MoleculeListClass objects, one dimension represents the ANOVA expansion of a single order (i.e. 5)
     
    15901594
    15911595      // create top order where nothing is reduced
    1592       Log() << Verbose(0) << "==============================================================================================================" << endl;
    1593       Log() << Verbose(0) << "Creating KeySets of Bond Order " << Order << " for " << *Walker << ", " << (RootStack.size()-RootNr) << " Roots remaining." << endl; // , NumLevels is " << NumLevels << "
     1596      DoLog(0) && (Log() << Verbose(0) << "==============================================================================================================" << endl);
     1597      DoLog(0) && (Log() << Verbose(0) << "Creating KeySets of Bond Order " << Order << " for " << *Walker << ", " << (RootStack.size()-RootNr) << " Roots remaining." << endl); // , NumLevels is " << NumLevels << "
    15941598
    15951599      // Create list of Graphs of current Bond Order (i.e. F_{ij})
     
    16011605
    16021606      // output resulting number
    1603       Log() << Verbose(1) << "Number of resulting KeySets is: " << NumMoleculesOfOrder[RootNr] << "." << endl;
     1607      DoLog(1) && (Log() << Verbose(1) << "Number of resulting KeySets is: " << NumMoleculesOfOrder[RootNr] << "." << endl);
    16041608      if (NumMoleculesOfOrder[RootNr] != 0) {
    16051609        NumMolecules = 0;
     
    16181622    }
    16191623  }
    1620   Log() << Verbose(0) << "==============================================================================================================" << endl;
    1621   Log() << Verbose(1) << "Total number of resulting molecules is: " << TotalNumMolecules << "." << endl;
    1622   Log() << Verbose(0) << "==============================================================================================================" << endl;
     1624  DoLog(0) && (Log() << Verbose(0) << "==============================================================================================================" << endl);
     1625  DoLog(1) && (Log() << Verbose(1) << "Total number of resulting molecules is: " << TotalNumMolecules << "." << endl);
     1626  DoLog(0) && (Log() << Verbose(0) << "==============================================================================================================" << endl);
    16231627
    16241628  // cleanup FragmentSearch structure
     
    16381642  Free(&NumMoleculesOfOrder);
    16391643
    1640   Log() << Verbose(0) << "End of FragmentBOSSANOVA." << endl;
     1644  DoLog(0) && (Log() << Verbose(0) << "End of FragmentBOSSANOVA." << endl);
    16411645};
    16421646
     
    16621666  bool flag = true;
    16631667
    1664   Log() << Verbose(2) << "Begin of ScanForPeriodicCorrection." << endl;
     1668  DoLog(2) && (Log() << Verbose(2) << "Begin of ScanForPeriodicCorrection." << endl);
    16651669
    16661670  ColorList = Calloc<enum Shading>(AtomCount, "molecule::ScanForPeriodicCorrection: *ColorList");
     
    16801684          OtherBinder = Binder->next; // note down binding partner for later re-insertion
    16811685          unlink(Binder);   // unlink bond
    1682           Log() << Verbose(2) << "Correcting at bond " << *Binder << "." << endl;
     1686          DoLog(2) && (Log() << Verbose(2) << "Correcting at bond " << *Binder << "." << endl);
    16831687          flag = true;
    16841688          break;
     
    16961700      //Log() << Verbose(3) << "Translation vector is ";
    16971701      Translationvector.Output();
    1698       Log() << Verbose(0) << endl;
     1702      DoLog(0) && (Log() << Verbose(0) << endl);
    16991703      // apply to all atoms of first component via BFS
    17001704      for (int i=AtomCount;i--;)
     
    17181722      link(Binder, OtherBinder);
    17191723    } else {
    1720       Log() << Verbose(3) << "No corrections for this fragment." << endl;
     1724      DoLog(3) && (Log() << Verbose(3) << "No corrections for this fragment." << endl);
    17211725    }
    17221726    //delete(CompStack);
     
    17271731  Free(&ColorList);
    17281732  Free(&matrix);
    1729   Log() << Verbose(2) << "End of ScanForPeriodicCorrection." << endl;
    1730 };
     1733  DoLog(2) && (Log() << Verbose(2) << "End of ScanForPeriodicCorrection." << endl);
     1734};
  • src/molecule_geometry.cpp

    r70378e rd6c485  
    280280              if ((fabs(tmp)) > BondDistance) {
    281281                flag = false;
    282                 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);
    283283                if (tmp > 0)
    284284                  Translationvector.x[j] -= 1.;
     
    291291        Testvector.MatrixMultiplication(matrix);
    292292        Center.AddVector(&Testvector);
    293         Log() << Verbose(1) << "vector is: ";
     293        DoLog(1) && (Log() << Verbose(1) << "vector is: ");
    294294        Testvector.Output();
    295         Log() << Verbose(0) << endl;
     295        DoLog(0) && (Log() << Verbose(0) << endl);
    296296#ifdef ADDHYDROGEN
    297297        // now also change all hydrogens
     
    303303            Testvector.MatrixMultiplication(matrix);
    304304            Center.AddVector(&Testvector);
    305             Log() << Verbose(1) << "Hydrogen vector is: ";
     305            DoLog(1) && (Log() << Verbose(1) << "Hydrogen vector is: ");
    306306            Testvector.Output();
    307             Log() << Verbose(0) << endl;
     307            DoLog(0) && (Log() << Verbose(0) << endl);
    308308          }
    309309        }
     
    352352  }
    353353  // print InertiaTensor for debugging
    354   Log() << Verbose(0) << "The inertia tensor is:" << endl;
     354  DoLog(0) && (Log() << Verbose(0) << "The inertia tensor is:" << endl);
    355355  for(int i=0;i<NDIM;i++) {
    356356    for(int j=0;j<NDIM;j++)
    357       Log() << Verbose(0) << InertiaTensor[i*NDIM+j] << " ";
    358     Log() << Verbose(0) << endl;
    359   }
    360   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);
    361361
    362362  // diagonalize to determine principal axis system
     
    370370
    371371  for(int i=0;i<NDIM;i++) {
    372     Log() << Verbose(1) << "eigenvalue = " << gsl_vector_get(eval, i);
    373     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);
    374374  }
    375375
    376376  // check whether we rotate or not
    377377  if (DoRotate) {
    378     Log() << Verbose(1) << "Transforming molecule into PAS ... ";
     378    DoLog(1) && (Log() << Verbose(1) << "Transforming molecule into PAS ... ");
    379379    // the eigenvectors specify the transformation matrix
    380380    ActOnAllVectors( &Vector::MatrixMultiplication, (const double *) evec->data );
    381     Log() << Verbose(0) << "done." << endl;
     381    DoLog(0) && (Log() << Verbose(0) << "done." << endl);
    382382
    383383    // summing anew for debugging (resulting matrix has to be diagonal!)
     
    404404    }
    405405    // print InertiaTensor for debugging
    406     Log() << Verbose(0) << "The inertia tensor is:" << endl;
     406    DoLog(0) && (Log() << Verbose(0) << "The inertia tensor is:" << endl);
    407407    for(int i=0;i<NDIM;i++) {
    408408      for(int j=0;j<NDIM;j++)
    409         Log() << Verbose(0) << InertiaTensor[i*NDIM+j] << " ";
    410       Log() << Verbose(0) << endl;
    411     }
    412     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);
    413413  }
    414414
     
    433433
    434434  // rotate on z-x plane
    435   Log() << Verbose(0) << "Begin of Aligning all atoms." << endl;
     435  DoLog(0) && (Log() << Verbose(0) << "Begin of Aligning all atoms." << endl);
    436436  alpha = atan(-n->x[0]/n->x[2]);
    437   Log() << Verbose(1) << "Z-X-angle: " << alpha << " ... ";
     437  DoLog(1) && (Log() << Verbose(1) << "Z-X-angle: " << alpha << " ... ");
    438438  while (ptr->next != end) {
    439439    ptr = ptr->next;
     
    451451  n->x[0] =  cos(alpha) * tmp +  sin(alpha) * n->x[2];
    452452  n->x[2] = -sin(alpha) * tmp +  cos(alpha) * n->x[2];
    453   Log() << Verbose(1) << "alignment vector after first rotation: ";
     453  DoLog(1) && (Log() << Verbose(1) << "alignment vector after first rotation: ");
    454454  n->Output();
    455   Log() << Verbose(0) << endl;
     455  DoLog(0) && (Log() << Verbose(0) << endl);
    456456
    457457  // rotate on z-y plane
    458458  ptr = start;
    459459  alpha = atan(-n->x[1]/n->x[2]);
    460   Log() << Verbose(1) << "Z-Y-angle: " << alpha << " ... ";
     460  DoLog(1) && (Log() << Verbose(1) << "Z-Y-angle: " << alpha << " ... ");
    461461  while (ptr->next != end) {
    462462    ptr = ptr->next;
     
    475475  n->x[2] = -sin(alpha) * tmp +  cos(alpha) * n->x[2];
    476476
    477   Log() << Verbose(1) << "alignment vector after second rotation: ";
     477  DoLog(1) && (Log() << Verbose(1) << "alignment vector after second rotation: ");
    478478  n->Output();
    479   Log() << Verbose(1) << endl;
    480   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);
    481481};
    482482
  • src/molecule_graph.cpp

    r70378e rd6c485  
    5959
    6060  if (!input) {
    61     Log() << Verbose(1) << "Opening silica failed \n";
     61    DoLog(1) && (Log() << Verbose(1) << "Opening silica failed \n");
    6262  };
    6363
    6464  *input >> ws >> atom1;
    6565  *input >> ws >> atom2;
    66   Log() << Verbose(1) << "Scanning file\n";
     66  DoLog(1) && (Log() << Verbose(1) << "Scanning file\n");
    6767  while (!input->eof()) // Check whether we read everything already
    6868  {
     
    115115
    116116  BondDistance = bonddistance; // * ((IsAngstroem) ? 1. : 1./AtomicLengthToAngstroem);
    117   Log() << Verbose(0) << "Begin of CreateAdjacencyList." << endl;
     117  DoLog(0) && (Log() << Verbose(0) << "Begin of CreateAdjacencyList." << endl);
    118118  // remove every bond from the list
    119119  bond *Binder = NULL;
     
    128128  // count atoms in molecule = dimension of matrix (also give each unique name and continuous numbering)
    129129  CountAtoms();
    130   Log() << Verbose(1) << "AtomCount " << AtomCount << " and bonddistance is " << bonddistance << "." << endl;
     130  DoLog(1) && (Log() << Verbose(1) << "AtomCount " << AtomCount << " and bonddistance is " << bonddistance << "." << endl);
    131131
    132132  if ((AtomCount > 1) && (bonddistance > 1.)) {
    133     Log() << Verbose(2) << "Creating Linked Cell structure ... " << endl;
     133    DoLog(2) && (Log() << Verbose(2) << "Creating Linked Cell structure ... " << endl);
    134134    LC = new LinkedCell(this, bonddistance);
    135135
    136136    // create a list to map Tesselpoint::nr to atom *
    137     Log() << Verbose(2) << "Creating TesselPoint to atom map ... " << endl;
     137    DoLog(2) && (Log() << Verbose(2) << "Creating TesselPoint to atom map ... " << endl);
    138138    AtomMap = Calloc<atom *> (AtomCount, "molecule::CreateAdjacencyList - **AtomCount");
    139139    Walker = start;
     
    144144
    145145    // 3a. go through every cell
    146     Log() << Verbose(2) << "Celling ... " << endl;
     146    DoLog(2) && (Log() << Verbose(2) << "Celling ... " << endl);
    147147    for (LC->n[0] = 0; LC->n[0] < LC->N[0]; LC->n[0]++)
    148148      for (LC->n[1] = 0; LC->n[1] < LC->N[1]; LC->n[1]++)
    149149        for (LC->n[2] = 0; LC->n[2] < LC->N[2]; LC->n[2]++) {
    150           const 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;
     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;
    152152          if (List != NULL) {
    153             for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
     153            for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    154154              Walker = AtomMap[(*Runner)->nr];
    155               //Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl;
     155//              Log() << Verbose(0) << "Current Atom is " << *Walker << "." << endl;
    156156              // 3c. check for possible bond between each atom in this and every one in the 27 cells
    157157              for (n[0] = -1; n[0] <= 1; n[0]++)
    158158                for (n[1] = -1; n[1] <= 1; n[1]++)
    159159                  for (n[2] = -1; n[2] <= 1; n[2]++) {
    160                     const 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;
     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;
    162162                    if (OtherList != NULL) {
    163                       for (LinkedNodes::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) {
     163                      for (LinkedCell::LinkedNodes::const_iterator OtherRunner = OtherList->begin(); OtherRunner != OtherList->end(); OtherRunner++) {
    164164                        if ((*OtherRunner)->nr > Walker->nr) {
    165165                          OtherWalker = AtomMap[(*OtherRunner)->nr];
    166                           //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;
    167169                          (BG->*minmaxdistance)(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem);
    168                           const double distance = OtherWalker->x.PeriodicDistanceSquared(&(Walker->x), cell_size);
    169170                          const bool status = (distance <= MaxDistance * MaxDistance) && (distance >= MinDistance * MinDistance);
    170                           if ((OtherWalker->father->nr > Walker->father->nr) && (status)) { // create bond if distance is smaller
    171                             //Log() << Verbose(1) << "Adding Bond between " << *Walker << " and " << *OtherWalker << " in distance " << sqrt(distance) << "." << endl;
    172                             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                            }
    173179                          } else {
    174                             //Log() << Verbose(1) << "Not Adding: Wrong label order or distance too great." << endl;
     180//                            Log() << Verbose(1) << "Not Adding: Wrong order of labels." << endl;
    175181                          }
    176182                        }
     
    183189    Free(&AtomMap);
    184190    delete (LC);
    185     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);
    186192
    187193    // correct bond degree by comparing valence and bond degree
    188     Log() << Verbose(2) << "Correcting bond degree ... " << endl;
     194    DoLog(2) && (Log() << Verbose(2) << "Correcting bond degree ... " << endl);
    189195    CorrectBondDegree();
    190196
     
    192198    ActOnAllAtoms( &atom::OutputBondOfAtom );
    193199  } else
    194     Log() << Verbose(1) << "AtomCount is " << AtomCount << ", thus no bonds, no connections!." << endl;
    195   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);
    196202  if (free_BG)
    197203    delete(BG);
     
    204210void molecule::OutputBondsList() const
    205211{
    206   Log() << Verbose(1) << endl << "From contents of bond chain list:";
     212  DoLog(1) && (Log() << Verbose(1) << endl << "From contents of bond chain list:");
    207213  bond *Binder = first;
    208214  while (Binder->next != last) {
    209215    Binder = Binder->next;
    210     Log() << Verbose(0) << *Binder << "\t" << endl;
    211   }
    212   Log() << Verbose(0) << endl;
     216    DoLog(0) && (Log() << Verbose(0) << *Binder << "\t" << endl);
     217  }
     218  DoLog(0) && (Log() << Verbose(0) << endl);
    213219}
    214220;
     
    227233
    228234  if (BondCount != 0) {
    229     Log() << Verbose(1) << "Correcting Bond degree of each bond ... " << endl;
     235    DoLog(1) && (Log() << Verbose(1) << "Correcting Bond degree of each bond ... " << endl);
    230236    do {
    231237      OldNo = No;
    232238      No = SumPerAtom( &atom::CorrectBondDegree );
    233239    } while (OldNo != No);
    234     Log() << Verbose(0) << " done." << endl;
     240    DoLog(0) && (Log() << Verbose(0) << " done." << endl);
    235241  } else {
    236     Log() << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << AtomCount << " atoms." << endl;
    237   }
    238   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);
    239245
    240246  return (No);
     
    255261  bond *Binder = first;
    256262  if ((Binder->next != last) && (Binder->next->Type == Undetermined)) {
    257     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);
    258264    Subgraphs = DepthFirstSearchAnalysis(BackEdgeStack);
    259265    while (Subgraphs->next != NULL) {
     
    310316    Walker->GraphNr = DFS.CurrentGraphNr;
    311317    Walker->LowpointNr = DFS.CurrentGraphNr;
    312     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);
    313319    DFS.AtomStack->Push(Walker);
    314320    DFS.CurrentGraphNr++;
     
    337343    if (Binder == NULL)
    338344      break;
    339     Log() << Verbose(2) << "Current Unused Bond is " << *Binder << "." << endl;
     345    DoLog(2) && (Log() << Verbose(2) << "Current Unused Bond is " << *Binder << "." << endl);
    340346    // (4) Mark Binder used, ...
    341347    Binder->MarkUsed(black);
    342348    OtherAtom = Binder->GetOtherAtom(Walker);
    343     Log() << Verbose(2) << "(4) OtherAtom is " << OtherAtom->Name << "." << endl;
     349    DoLog(2) && (Log() << Verbose(2) << "(4) OtherAtom is " << OtherAtom->Name << "." << endl);
    344350    if (OtherAtom->GraphNr != -1) {
    345351      // (4a) ... if "other" atom has been visited (GraphNr != 0), set lowpoint to minimum of both, go to (3)
     
    347353      DFS.BackEdgeStack->Push(Binder);
    348354      Walker->LowpointNr = (Walker->LowpointNr < OtherAtom->GraphNr) ? Walker->LowpointNr : OtherAtom->GraphNr;
    349       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);
    350356    } else {
    351357      // (4b) ... otherwise set OtherAtom as Ancestor of Walker and Walker as OtherAtom, go to (2)
     
    353359      OtherAtom->Ancestor = Walker;
    354360      Walker = OtherAtom;
    355       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);
    356362      break;
    357363    }
     
    375381
    376382  // (5) if Ancestor of Walker is ...
    377   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);
    378384
    379385  if (Walker->Ancestor->GraphNr != DFS.Root->GraphNr) {
     
    382388      // (6a) set Ancestor's Lowpoint number to minimum of of its Ancestor and itself, go to Step(8)
    383389      Walker->Ancestor->LowpointNr = (Walker->Ancestor->LowpointNr < Walker->LowpointNr) ? Walker->Ancestor->LowpointNr : Walker->LowpointNr;
    384       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);
    385391    } else {
    386392      // (7) (Ancestor of Walker is a separating vertex, remove all from stack till Walker (including), these and Ancestor form a component
    387393      Walker->Ancestor->SeparationVertex = true;
    388       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);
    389395      mol->SetNextComponentNumber(Walker->Ancestor, DFS.ComponentNumber);
    390       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);
    391397      mol->SetNextComponentNumber(Walker, DFS.ComponentNumber);
    392       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);
    393399      do {
    394400        OtherAtom = DFS.AtomStack->PopLast();
    395401        LeafWalker->Leaf->AddCopyAtom(OtherAtom);
    396402        mol->SetNextComponentNumber(OtherAtom, DFS.ComponentNumber);
    397         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);
    398404      } while (OtherAtom != Walker);
    399405      DFS.ComponentNumber++;
    400406    }
    401407    // (8) Walker becomes its Ancestor, go to (3)
    402     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);
    403409    Walker = Walker->Ancestor;
    404410    DFS.BackStepping = true;
     
    424430    //DFS.AtomStack->Output(out);
    425431    mol->SetNextComponentNumber(DFS.Root, DFS.ComponentNumber);
    426     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);
    427433    mol->SetNextComponentNumber(Walker, DFS.ComponentNumber);
    428     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);
    429435    do {
    430436      OtherAtom = DFS.AtomStack->PopLast();
    431437      LeafWalker->Leaf->AddCopyAtom(OtherAtom);
    432438      mol->SetNextComponentNumber(OtherAtom, DFS.ComponentNumber);
    433       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);
    434440    } while (OtherAtom != Walker);
    435441    DFS.ComponentNumber++;
     
    438444    Walker = DFS.Root;
    439445    Binder = mol->FindNextUnused(Walker);
    440     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);
    441447    if (Binder != NULL) { // Root is separation vertex
    442       Log() << Verbose(1) << "(11) Root is a separation vertex." << endl;
     448      DoLog(1) && (Log() << Verbose(1) << "(11) Root is a separation vertex." << endl);
    443449      Walker->SeparationVertex = true;
    444450    }
     
    495501  bond *Binder = NULL;
    496502
    497   Log() << Verbose(0) << "Begin of DepthFirstSearchAnalysis" << endl;
     503  if (AtomCount == 0)
     504    return SubGraphs;
     505  DoLog(0) && (Log() << Verbose(0) << "Begin of DepthFirstSearchAnalysis" << endl);
    498506  DepthFirstSearchAnalysis_Init(DFS, this);
    499507
     
    517525
    518526        if (Binder == NULL) {
    519           Log() << Verbose(2) << "No more Unused Bonds." << endl;
     527          DoLog(2) && (Log() << Verbose(2) << "No more Unused Bonds." << endl);
    520528          break;
    521529        } else
     
    534542
    535543    // From OldGraphNr to CurrentGraphNr ranges an disconnected subgraph
    536     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);
    537545    LeafWalker->Leaf->Output((ofstream *)&cout);
    538     Log() << Verbose(0) << endl;
     546    DoLog(0) && (Log() << Verbose(0) << endl);
    539547
    540548    // step on to next root
     
    554562  // free all and exit
    555563  DepthFirstSearchAnalysis_Finalize(DFS);
    556   Log() << Verbose(0) << "End of DepthFirstSearchAnalysis" << endl;
     564  DoLog(0) && (Log() << Verbose(0) << "End of DepthFirstSearchAnalysis" << endl);
    557565  return SubGraphs;
    558566}
     
    580588void molecule::OutputGraphInfoPerAtom() const
    581589{
    582   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);
    583591  ActOnAllAtoms( &atom::OutputGraphInfo );
    584592}
     
    590598void molecule::OutputGraphInfoPerBond() const
    591599{
    592   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);
    593601  bond *Binder = first;
    594602  while (Binder->next != last) {
    595603    Binder = Binder->next;
    596     Log() << Verbose(2) << ((Binder->Type == TreeEdge) ? "TreeEdge " : "BackEdge ") << *Binder << ": <";
    597     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.");
    598606    Binder->leftatom->OutputComponentNumber();
    599     Log() << Verbose(0) << " ===  ";
    600     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.");
    601609    Binder->rightatom->OutputComponentNumber();
    602     Log() << Verbose(0) << ">." << endl;
     610    DoLog(0) && (Log() << Verbose(0) << ">." << endl);
    603611    if (Binder->Cyclic) // cyclic ??
    604       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);
    605613  }
    606614}
     
    676684  do { // look for Root
    677685    Walker = BFS.BFSStack->PopFirst();
    678     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);
    679687    for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
    680688      if ((*Runner) != BackEdge) { // only walk along DFS spanning tree (otherwise we always find SP of one being backedge Binder)
     
    683691        if (OtherAtom->type->Z != 1) {
    684692#endif
    685         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);
    686694        if (BFS.ColorList[OtherAtom->nr] == white) {
    687695          BFS.TouchedStack->Push(OtherAtom);
     
    689697          BFS.PredecessorList[OtherAtom->nr] = Walker; // Walker is the predecessor
    690698          BFS.ShortestPathList[OtherAtom->nr] = BFS.ShortestPathList[Walker->nr] + 1;
    691           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);
    692700          //if (BFS.ShortestPathList[OtherAtom->nr] < MinimumRingSize[Walker->GetTrueFather()->nr]) { // Check for maximum distance
    693           Log() << Verbose(3) << "Putting OtherAtom into queue." << endl;
     701          DoLog(3) && (Log() << Verbose(3) << "Putting OtherAtom into queue." << endl);
    694702          BFS.BFSStack->Push(OtherAtom);
    695703          //}
    696704        } else {
    697           Log() << Verbose(3) << "Not Adding, has already been visited." << endl;
     705          DoLog(3) && (Log() << Verbose(3) << "Not Adding, has already been visited." << endl);
    698706        }
    699707        if (OtherAtom == BFS.Root)
     
    701709#ifdef ADDHYDROGEN
    702710      } else {
    703         Log() << Verbose(2) << "Skipping hydrogen atom " << *OtherAtom << "." << endl;
     711        DoLog(2) && (Log() << Verbose(2) << "Skipping hydrogen atom " << *OtherAtom << "." << endl);
    704712        BFS.ColorList[OtherAtom->nr] = black;
    705713      }
    706714#endif
    707715      } else {
    708         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);
    709717      }
    710718    }
    711719    BFS.ColorList[Walker->nr] = black;
    712     Log() << Verbose(1) << "Coloring Walker " << Walker->Name << " black." << endl;
     720    DoLog(1) && (Log() << Verbose(1) << "Coloring Walker " << Walker->Name << " black." << endl);
    713721    if (OtherAtom == BFS.Root) { // if we have found the root, check whether this cycle wasn't already found beforehand
    714722      // step through predecessor list
     
    720728      }
    721729      if (OtherAtom == BackEdge->rightatom) { // if each atom in found cycle is cyclic, loop's been found before already
    722         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);
    723731        do {
    724732          OtherAtom = BFS.TouchedStack->PopLast();
    725733          if (BFS.PredecessorList[OtherAtom->nr] == Walker) {
    726             Log() << Verbose(4) << "Removing " << *OtherAtom << " from lists and stacks." << endl;
     734            DoLog(4) && (Log() << Verbose(4) << "Removing " << *OtherAtom << " from lists and stacks." << endl);
    727735            BFS.PredecessorList[OtherAtom->nr] = NULL;
    728736            BFS.ShortestPathList[OtherAtom->nr] = -1;
     
    758766    RingSize = 1;
    759767    BFS.Root->GetTrueFather()->IsCyclic = true;
    760     Log() << Verbose(1) << "Found ring contains: ";
     768    DoLog(1) && (Log() << Verbose(1) << "Found ring contains: ");
    761769    Walker = BFS.Root;
    762770    while (Walker != BackEdge->rightatom) {
    763       Log() << Verbose(0) << Walker->Name << " <-> ";
     771      DoLog(0) && (Log() << Verbose(0) << Walker->Name << " <-> ");
    764772      Walker = BFS.PredecessorList[Walker->nr];
    765773      Walker->GetTrueFather()->IsCyclic = true;
    766774      RingSize++;
    767775    }
    768     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);
    769777    // walk through all and set MinimumRingSize
    770778    Walker = BFS.Root;
     
    778786      MinRingSize = RingSize;
    779787  } else {
    780     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);
    781789  }
    782790};
     
    856864
    857865      }
    858       Log() << Verbose(1) << "Minimum ring size of " << *Root << " is " << MinimumRingSize[Root->GetTrueFather()->nr] << "." << endl;
    859     }
    860     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);
    861869  } else
    862     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);
    863871}
    864872;
     
    888896  //BackEdgeStack->Output(out);
    889897
    890   Log() << Verbose(1) << "Analysing cycles ... " << endl;
     898  DoLog(1) && (Log() << Verbose(1) << "Analysing cycles ... " << endl);
    891899  NumCycles = 0;
    892900  while (!BackEdgeStack->IsEmpty()) {
     
    899907    ResetBFSAccounting(Walker, BFS);
    900908
    901     Log() << Verbose(1) << "---------------------------------------------------------------------------------------------------------" << endl;
     909    DoLog(1) && (Log() << Verbose(1) << "---------------------------------------------------------------------------------------------------------" << endl);
    902910    OtherAtom = NULL;
    903911    CyclicStructureAnalysis_CyclicBFSFromRootToRoot(BackEdge, BFS);
     
    929937    }
    930938    if (i == vertex->ListOfBonds.size()) {
    931       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);
    932940      performCriticalExit();
    933941    }
    934942  } else {
    935     eLog() << Verbose(0) << "Error: Given vertex is NULL!" << endl;
     943    DoeLog(0) && (eLog()<< Verbose(0) << "Error: Given vertex is NULL!" << endl);
    936944    performCriticalExit();
    937945  }
     
    971979void OutputAlreadyVisited(int *list)
    972980{
    973   Log() << Verbose(4) << "Already Visited Bonds:\t";
     981  DoLog(4) && (Log() << Verbose(4) << "Already Visited Bonds:\t");
    974982  for (int i = 1; i <= list[0]; i++)
    975     Log() << Verbose(0) << list[i] << "  ";
    976   Log() << Verbose(0) << endl;
     983    DoLog(0) && (Log() << Verbose(0) << list[i] << "  ");
     984  DoLog(0) && (Log() << Verbose(0) << endl);
    977985}
    978986;
     
    980988/** Storing the bond structure of a molecule to file.
    981989 * Simply stores Atom::nr and then the Atom::nr of all bond partners per line.
    982  * \param *out output stream for debugging
    983990 * \param *path path to file
     991 * \param *filename name of file
    984992 * \return true - file written successfully, false - writing failed
    985993 */
    986 bool molecule::StoreAdjacencyToFile(char *path)
     994bool molecule::StoreAdjacencyToFile(char *path, char *filename)
    987995{
    988996  ofstream AdjacencyFile;
     
    990998  bool status = true;
    991999
    992   line << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE;
     1000  if (path != NULL)
     1001    line << path << "/" << filename;
     1002  else
     1003    line << filename;
    9931004  AdjacencyFile.open(line.str().c_str(), ios::out);
    994   Log() << Verbose(1) << "Saving adjacency list ... ";
     1005  DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... ");
    9951006  if (AdjacencyFile != NULL) {
    9961007    AdjacencyFile << "m\tn" << endl;
    9971008    ActOnAllAtoms(&atom::OutputAdjacency, &AdjacencyFile);
    9981009    AdjacencyFile.close();
    999     Log() << Verbose(1) << "done." << endl;
     1010    DoLog(1) && (Log() << Verbose(1) << "done." << endl);
    10001011  } else {
    1001     Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl;
     1012    DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl);
    10021013    status = false;
    10031014  }
     
    10091020/** Storing the bond structure of a molecule to file.
    10101021 * Simply stores Atom::nr and then the Atom::nr of all bond partners, one per line.
    1011  * \param *out output stream for debugging
    10121022 * \param *path path to file
     1023 * \param *filename name of file
    10131024 * \return true - file written successfully, false - writing failed
    10141025 */
    1015 bool molecule::StoreBondsToFile(char *path)
     1026bool molecule::StoreBondsToFile(char *path, char *filename)
    10161027{
    10171028  ofstream BondFile;
     
    10191030  bool status = true;
    10201031
    1021   line << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE;
     1032  if (path != NULL)
     1033    line << path << "/" << filename;
     1034  else
     1035    line << filename;
    10221036  BondFile.open(line.str().c_str(), ios::out);
    1023   Log() << Verbose(1) << "Saving adjacency list ... ";
     1037  DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... ");
    10241038  if (BondFile != NULL) {
    10251039    BondFile << "m\tn" << endl;
    10261040    ActOnAllAtoms(&atom::OutputBonds, &BondFile);
    10271041    BondFile.close();
    1028     Log() << Verbose(1) << "done." << endl;
     1042    DoLog(1) && (Log() << Verbose(1) << "done." << endl);
    10291043  } else {
    1030     Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl;
     1044    DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl);
    10311045    status = false;
    10321046  }
     
    10411055  filename << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE;
    10421056  File.open(filename.str().c_str(), ios::out);
    1043   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 ... ");
    10441058  if (File == NULL)
    10451059    return false;
     
    10821096    //Log() << Verbose(0) << endl;
    10831097  } else {
    1084     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);
    10851099    status = false;
    10861100  }
     
    11051119
    11061120  if (!CheckAdjacencyFileAgainstMolecule_Init(path, File, CurrentBonds)) {
    1107     Log() << Verbose(1) << "Adjacency file not found." << endl;
     1121    DoLog(1) && (Log() << Verbose(1) << "Adjacency file not found." << endl);
    11081122    return true;
    11091123  }
     
    11311145
    11321146  if (status) { // if equal we parse the KeySetFile
    1133     Log() << Verbose(1) << "done: Equal." << endl;
     1147    DoLog(1) && (Log() << Verbose(1) << "done: Equal." << endl);
    11341148  } else
    1135     Log() << Verbose(1) << "done: Not equal by " << NonMatchNumber << " atoms." << endl;
     1149    DoLog(1) && (Log() << Verbose(1) << "done: Not equal by " << NonMatchNumber << " atoms." << endl);
    11361150  return status;
    11371151}
     
    11491163  bool status = true;
    11501164  if (ReferenceStack->IsEmpty()) {
    1151     Log() << Verbose(1) << "ReferenceStack is empty!" << endl;
     1165    DoLog(1) && (Log() << Verbose(1) << "ReferenceStack is empty!" << endl);
    11521166    return false;
    11531167  }
     
    11641178        if (OtherAtom == ListOfLocalAtoms[(*Runner)->rightatom->nr]) { // found the bond
    11651179          LocalStack->Push((*Runner));
    1166           Log() << Verbose(3) << "Found local edge " << *(*Runner) << "." << endl;
     1180          DoLog(3) && (Log() << Verbose(3) << "Found local edge " << *(*Runner) << "." << endl);
    11671181          break;
    11681182        }
    11691183      }
    11701184    Binder = ReferenceStack->PopFirst(); // loop the stack for next item
    1171     Log() << Verbose(3) << "Current candidate edge " << Binder << "." << endl;
     1185    DoLog(3) && (Log() << Verbose(3) << "Current candidate edge " << Binder << "." << endl);
    11721186    ReferenceStack->Push(Binder);
    11731187  } while (FirstBond != Binder);
     
    12181232  BFS.PredecessorList[OtherAtom->nr] = Walker; // Walker is the predecessor
    12191233  BFS.ShortestPathList[OtherAtom->nr] = BFS.ShortestPathList[Walker->nr] + 1;
    1220   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);
    12211235  if ((((BFS.ShortestPathList[OtherAtom->nr] < BFS.BondOrder) && (Binder != Bond)))) { // Check for maximum distance
    1222     Log() << Verbose(3);
     1236    DoLog(3) && (Log() << Verbose(3));
    12231237    if (AddedAtomList[OtherAtom->nr] == NULL) { // add if it's not been so far
    12241238      AddedAtomList[OtherAtom->nr] = Mol->AddCopyAtom(OtherAtom);
    1225       Log() << Verbose(0) << "Added OtherAtom " << OtherAtom->Name;
     1239      DoLog(0) && (Log() << Verbose(0) << "Added OtherAtom " << OtherAtom->Name);
    12261240      AddedBondList[Binder->nr] = Mol->CopyBond(AddedAtomList[Walker->nr], AddedAtomList[OtherAtom->nr], Binder);
    1227       Log() << Verbose(0) << " and bond " << *(AddedBondList[Binder->nr]) << ", ";
     1241      DoLog(0) && (Log() << Verbose(0) << " and bond " << *(AddedBondList[Binder->nr]) << ", ");
    12281242    } 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)
    1229       Log() << Verbose(0) << "Not adding OtherAtom " << OtherAtom->Name;
     1243      DoLog(0) && (Log() << Verbose(0) << "Not adding OtherAtom " << OtherAtom->Name);
    12301244      if (AddedBondList[Binder->nr] == NULL) {
    12311245        AddedBondList[Binder->nr] = Mol->CopyBond(AddedAtomList[Walker->nr], AddedAtomList[OtherAtom->nr], Binder);
    1232         Log() << Verbose(0) << ", added Bond " << *(AddedBondList[Binder->nr]);
     1246        DoLog(0) && (Log() << Verbose(0) << ", added Bond " << *(AddedBondList[Binder->nr]));
    12331247      } else
    1234         Log() << Verbose(0) << ", not added Bond ";
    1235     }
    1236     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);
    12371251    BFS.BFSStack->Push(OtherAtom);
    12381252  } else { // out of bond order, then replace
     
    12401254      BFS.ColorList[OtherAtom->nr] = white; // unmark if it has not been queued/added, to make it available via its other bonds (cyclic)
    12411255    if (Binder == Bond)
    1242       Log() << Verbose(3) << "Not Queueing, is the Root bond";
     1256      DoLog(3) && (Log() << Verbose(3) << "Not Queueing, is the Root bond");
    12431257    else if (BFS.ShortestPathList[OtherAtom->nr] >= BFS.BondOrder)
    1244       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);
    12451259    if (!Binder->Cyclic)
    1246       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);
    12471261    if (AddedBondList[Binder->nr] == NULL) {
    12481262      if ((AddedAtomList[OtherAtom->nr] != NULL)) { // .. whether we add or saturate
     
    12611275void BreadthFirstSearchAdd_VisitedNode(molecule *Mol, struct BFSAccounting &BFS, atom *&Walker, atom *&OtherAtom, bond *&Binder, bond *&Bond, atom **&AddedAtomList, bond **&AddedBondList, bool IsAngstroem)
    12621276{
    1263   Log() << Verbose(3) << "Not Adding, has already been visited." << endl;
     1277  DoLog(3) && (Log() << Verbose(3) << "Not Adding, has already been visited." << endl);
    12641278  // This has to be a cyclic bond, check whether it's present ...
    12651279  if (AddedBondList[Binder->nr] == NULL) {
     
    13071321    // followed by n+1 till top of stack.
    13081322    Walker = BFS.BFSStack->PopFirst(); // pop oldest added
    1309     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);
    13101324    for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
    13111325      if ((*Runner) != NULL) { // don't look at bond equal NULL
    13121326        Binder = (*Runner);
    13131327        OtherAtom = (*Runner)->GetOtherAtom(Walker);
    1314         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);
    13151329        if (BFS.ColorList[OtherAtom->nr] == white) {
    13161330          BreadthFirstSearchAdd_UnvisitedNode(Mol, BFS, Walker, OtherAtom, Binder, Bond, AddedAtomList, AddedBondList, IsAngstroem);
     
    13211335    }
    13221336    BFS.ColorList[Walker->nr] = black;
    1323     Log() << Verbose(1) << "Coloring Walker " << Walker->Name << " black." << endl;
     1337    DoLog(1) && (Log() << Verbose(1) << "Coloring Walker " << Walker->Name << " black." << endl);
    13241338  }
    13251339  BreadthFirstSearchAdd_Free(BFS);
     
    13461360  // reset parent list
    13471361  ParentList = Calloc<atom*> (AtomCount, "molecule::BuildInducedSubgraph_Init: **ParentList");
    1348   Log() << Verbose(3) << "Resetting ParentList." << endl;
     1362  DoLog(3) && (Log() << Verbose(3) << "Resetting ParentList." << endl);
    13491363}
    13501364;
     
    13531367{
    13541368  // fill parent list with sons
    1355   Log() << Verbose(3) << "Filling Parent List." << endl;
     1369  DoLog(3) && (Log() << Verbose(3) << "Filling Parent List." << endl);
    13561370  atom *Walker = mol->start;
    13571371  while (Walker->next != mol->end) {
     
    13591373    ParentList[Walker->father->nr] = Walker;
    13601374    // Outputting List for debugging
    1361     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);
    13621376  }
    13631377
     
    13771391  atom *OtherAtom = NULL;
    13781392  // check each entry of parent list and if ok (one-to-and-onto matching) create bonds
    1379   Log() << Verbose(3) << "Creating bonds." << endl;
     1393  DoLog(3) && (Log() << Verbose(3) << "Creating bonds." << endl);
    13801394  Walker = Father->start;
    13811395  while (Walker->next != Father->end) {
     
    13881402          OtherAtom = (*Runner)->GetOtherAtom(Walker);
    13891403          if (ParentList[OtherAtom->nr] != NULL) { // if otheratom is also a father of an atom on this molecule, create the bond
    1390             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);
    13911405            mol->AddBond(ParentList[Walker->nr], ParentList[OtherAtom->nr], (*Runner)->BondDegree);
    13921406          }
     
    14131427  atom **ParentList = NULL;
    14141428
    1415   Log() << Verbose(2) << "Begin of BuildInducedSubgraph." << endl;
     1429  DoLog(2) && (Log() << Verbose(2) << "Begin of BuildInducedSubgraph." << endl);
    14161430  BuildInducedSubgraph_Init(ParentList, Father->AtomCount);
    14171431  BuildInducedSubgraph_FillParentList(this, Father, ParentList);
    14181432  status = BuildInducedSubgraph_CreateBondsFromParent(this, Father, ParentList);
    14191433  BuildInducedSubgraph_Finalize(ParentList);
    1420   Log() << Verbose(2) << "End of BuildInducedSubgraph." << endl;
     1434  DoLog(2) && (Log() << Verbose(2) << "End of BuildInducedSubgraph." << endl);
    14211435  return status;
    14221436}
     
    14351449  int size;
    14361450
    1437   Log() << Verbose(1) << "Begin of CheckForConnectedSubgraph" << endl;
    1438   Log() << Verbose(2) << "Disconnected atom: ";
     1451  DoLog(1) && (Log() << Verbose(1) << "Begin of CheckForConnectedSubgraph" << endl);
     1452  DoLog(2) && (Log() << Verbose(2) << "Disconnected atom: ");
    14391453
    14401454  // count number of atoms in graph
     
    14581472      }
    14591473      if (!BondStatus) {
    1460         Log() << Verbose(0) << (*Walker) << endl;
     1474        DoLog(0) && (Log() << Verbose(0) << (*Walker) << endl);
    14611475        return false;
    14621476      }
    14631477    }
    14641478  else {
    1465     Log() << Verbose(0) << "none." << endl;
     1479    DoLog(0) && (Log() << Verbose(0) << "none." << endl);
    14661480    return true;
    14671481  }
    1468   Log() << Verbose(0) << "none." << endl;
    1469 
    1470   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);
    14711485
    14721486  return true;
  • src/moleculelist.cpp

    r70378e rd6c485  
    3636MoleculeListClass::~MoleculeListClass()
    3737{
    38   Log() << Verbose(3) << this << ": Freeing ListOfMolcules." << endl;
     38  DoLog(3) && (Log() << Verbose(3) << this << ": Freeing ListOfMolcules." << endl);
    3939  for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
    40     Log() << Verbose(4) << "ListOfMolecules: Freeing " << *ListRunner << "." << endl;
     40    DoLog(4) && (Log() << Verbose(4) << "ListOfMolecules: Freeing " << *ListRunner << "." << endl);
    4141    delete (*ListRunner);
    4242  }
    43   Log() << Verbose(4) << "Freeing ListOfMolecules." << endl;
     43  DoLog(4) && (Log() << Verbose(4) << "Freeing ListOfMolecules." << endl);
    4444  ListOfMolecules.clear(); // empty list
    4545};
     
    145145
    146146  // header
    147   Log() << Verbose(0) << "Index\tName\t\tAtoms\tFormula\tCenter\tSize" << endl;
    148   Log() << Verbose(0) << "-----------------------------------------------" << endl;
     147  DoLog(0) && (Log() << Verbose(0) << "Index\tName\t\tAtoms\tFormula\tCenter\tSize" << endl);
     148  DoLog(0) && (Log() << Verbose(0) << "-----------------------------------------------" << endl);
    149149  if (ListOfMolecules.size() == 0)
    150     Log() << Verbose(0) << "\tNone" << endl;
     150    DoLog(0) && (Log() << Verbose(0) << "\tNone" << endl);
    151151  else {
    152152    Origin.Zero();
     
    165165      }
    166166      // output Index, Name, number of atoms, chemical formula
    167       Log() << Verbose(0) << ((*ListRunner)->ActiveFlag ? "*" : " ") << (*ListRunner)->IndexNr << "\t" << (*ListRunner)->name << "\t\t" << (*ListRunner)->AtomCount << "\t";
     167      DoLog(0) && (Log() << Verbose(0) << ((*ListRunner)->ActiveFlag ? "*" : " ") << (*ListRunner)->IndexNr << "\t" << (*ListRunner)->name << "\t\t" << (*ListRunner)->AtomCount << "\t");
    168168      Elemental = (*ListRunner)->elemente->end;
    169169      while(Elemental->previous != (*ListRunner)->elemente->start) {
    170170        Elemental = Elemental->previous;
    171171        if (Counts[Elemental->Z] != 0)
    172           Log() << Verbose(0) << Elemental->symbol << Counts[Elemental->Z];
     172          DoLog(0) && (Log() << Verbose(0) << Elemental->symbol << Counts[Elemental->Z]);
    173173      }
    174174      // Center and size
    175       Log() << Verbose(0) << "\t" << (*ListRunner)->Center << "\t" << sqrt(size) << endl;
     175      DoLog(0) && (Log() << Verbose(0) << "\t" << (*ListRunner)->Center << "\t" << sqrt(size) << endl);
    176176    }
    177177  }
     
    314314  Tesselation *TesselStruct = NULL;
    315315  if ((srcmol == NULL) || (mol == NULL)) {
    316     eLog() << Verbose(1) << "Either fixed or variable molecule is given as NULL." << endl;
     316    DoeLog(1) && (eLog()<< Verbose(1) << "Either fixed or variable molecule is given as NULL." << endl);
    317317    return false;
    318318  }
     
    322322  FindNonConvexBorder(mol, TesselStruct, (const LinkedCell *&)LCList, 4., NULL);
    323323  if (TesselStruct == NULL) {
    324     eLog() << Verbose(1) << "Could not tesselate the fixed molecule." << endl;
     324    DoeLog(1) && (eLog()<< Verbose(1) << "Could not tesselate the fixed molecule." << endl);
    325325    return false;
    326326  }
     
    339339  while (Walker->next != srcmol->end) {
    340340    Walker = Walker->next;
    341     Log() << Verbose(2) << "INFO: Current Walker is " << *Walker << "." << endl;
     341    DoLog(2) && (Log() << Verbose(2) << "INFO: Current Walker is " << *Walker << "." << endl);
    342342    if (!TesselStruct->IsInnerPoint(Walker->x, LCList)) {
    343343      CopyAtoms[Walker->nr] = new atom(Walker);
     
    348348    }
    349349  }
    350   Log() << Verbose(1) << nr << " of " << srcmol->AtomCount << " atoms have been merged.";
     350  DoLog(1) && (Log() << Verbose(1) << nr << " of " << srcmol->AtomCount << " atoms have been merged.");
    351351
    352352  // go through all bonds and add as well
     
    354354  while(Binder->next != srcmol->last) {
    355355    Binder = Binder->next;
    356     Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl;
     356    DoLog(3) && (Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl);
    357357    mol->AddBond(CopyAtoms[Binder->leftatom->nr], CopyAtoms[Binder->rightatom->nr], Binder->BondDegree);
    358358  }
     
    366366void MoleculeListClass::Output(ofstream *out)
    367367{
    368   Log() << Verbose(1) << "MoleculeList: ";
     368  DoLog(1) && (Log() << Verbose(1) << "MoleculeList: ");
    369369  for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++)
    370     Log() << Verbose(0) << *ListRunner << "\t";
    371   Log() << Verbose(0) << endl;
     370    DoLog(0) && (Log() << Verbose(0) << *ListRunner << "\t");
     371  DoLog(0) && (Log() << Verbose(0) << endl);
    372372};
    373373
     
    395395  char *FragmentNumber = NULL;
    396396
    397   Log() << Verbose(1) << "Saving hydrogen saturation correction ... ";
     397  DoLog(1) && (Log() << Verbose(1) << "Saving hydrogen saturation correction ... ");
    398398  // 0. parse in fit constant files that should have the same dimension as the final energy files
    399399  // 0a. find dimension of matrices with constants
     
    405405  input.open(line.c_str());
    406406  if (input == NULL) {
    407     Log() << Verbose(1) << endl << "Unable to open " << line << ", is the directory correct?" << endl;
     407    DoLog(1) && (Log() << Verbose(1) << endl << "Unable to open " << line << ", is the directory correct?" << endl);
    408408    return false;
    409409  }
     
    422422    b++;
    423423  }
    424   Log() << Verbose(0) << "I recognized " << a << " columns and " << b << " rows, ";
     424  DoLog(0) && (Log() << Verbose(0) << "I recognized " << a << " columns and " << b << " rows, ");
    425425  input.close();
    426426
     
    443443    input.open(line.c_str());
    444444    if (input == NULL) {
    445       eLog() << Verbose(0) << endl << "Unable to open " << line << ", is the directory correct?" << endl;
     445      DoeLog(0) && (eLog()<< Verbose(0) << endl << "Unable to open " << line << ", is the directory correct?" << endl);
    446446      performCriticalExit();
    447447      return false;
     
    465465  }
    466466  for (int k = 0; k < 3; k++) {
    467     Log() << Verbose(0) << "Constants " << k << ":" << endl;
     467    DoLog(0) && (Log() << Verbose(0) << "Constants " << k << ":" << endl);
    468468    for (int j = 0; j < b; j++) {
    469469      for (int i = 0; i < a; i++) {
    470         Log() << Verbose(0) << FitConstant[k][i][j] << "\t";
     470        DoLog(0) && (Log() << Verbose(0) << FitConstant[k][i][j] << "\t");
    471471      }
    472       Log() << Verbose(0) << endl;
    473     }
    474     Log() << Verbose(0) << endl;
     472      DoLog(0) && (Log() << Verbose(0) << endl);
     473    }
     474    DoLog(0) && (Log() << Verbose(0) << endl);
    475475  }
    476476
     
    560560  }
    561561  Free(&FitConstant);
    562   Log() << Verbose(0) << "done." << endl;
     562  DoLog(0) && (Log() << Verbose(0) << "done." << endl);
    563563  return true;
    564564};
     
    580580
    581581  // open file for the force factors
    582   Log() << Verbose(1) << "Saving  force factors ... ";
     582  DoLog(1) && (Log() << Verbose(1) << "Saving  force factors ... ");
    583583  line << path << "/" << FRAGMENTPREFIX << FORCESFILE;
    584584  ForcesFile.open(line.str().c_str(), ios::out);
     
    608608    }
    609609    ForcesFile.close();
    610     Log() << Verbose(1) << "done." << endl;
     610    DoLog(1) && (Log() << Verbose(1) << "done." << endl);
    611611  } else {
    612612    status = false;
    613     Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl;
     613    DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl);
    614614  }
    615615  ForcesFile.close();
     
    652652      strcpy(PathBackup, path);
    653653    else {
    654       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);
    655655      performCriticalExit();
    656656    }
     
    663663    sprintf(FragmentName, "%s/%s%s.conf.xyz", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);
    664664    outputFragment.open(FragmentName, ios::out);
    665     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 ...");
    666666    if ((intermediateResult = (*ListRunner)->OutputXYZ(&outputFragment)))
    667       Log() << Verbose(0) << " done." << endl;
     667      DoLog(0) && (Log() << Verbose(0) << " done." << endl);
    668668    else
    669       Log() << Verbose(0) << " failed." << endl;
     669      DoLog(0) && (Log() << Verbose(0) << " failed." << endl);
    670670    result = result && intermediateResult;
    671671    outputFragment.close();
     
    673673
    674674    // list atoms in fragment for debugging
    675     Log() << Verbose(2) << "Contained atoms: ";
     675    DoLog(2) && (Log() << Verbose(2) << "Contained atoms: ");
    676676    Walker = (*ListRunner)->start;
    677677    while (Walker->next != (*ListRunner)->end) {
    678678      Walker = Walker->next;
    679       Log() << Verbose(0) << Walker->Name << " ";
    680     }
    681     Log() << Verbose(0) << endl;
     679      DoLog(0) && (Log() << Verbose(0) << Walker->Name << " ");
     680    }
     681    DoLog(0) && (Log() << Verbose(0) << endl);
    682682
    683683    // center on edge
     
    703703    // and save as config
    704704    sprintf(FragmentName, "%s/%s%s.conf", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);
    705     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 ...");
    706706    if ((intermediateResult = configuration->Save(FragmentName, (*ListRunner)->elemente, (*ListRunner))))
    707       Log() << Verbose(0) << " done." << endl;
     707      DoLog(0) && (Log() << Verbose(0) << " done." << endl);
    708708    else
    709       Log() << Verbose(0) << " failed." << endl;
     709      DoLog(0) && (Log() << Verbose(0) << " failed." << endl);
    710710    result = result && intermediateResult;
    711711
     
    715715    // and save as mpqc input file
    716716    sprintf(FragmentName, "%s/%s%s.conf", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);
    717     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 ...");
    718718    if ((intermediateResult = configuration->SaveMPQC(FragmentName, (*ListRunner))))
    719       Log() << Verbose(2) << " done." << endl;
     719      DoLog(2) && (Log() << Verbose(2) << " done." << endl);
    720720    else
    721       Log() << Verbose(0) << " failed." << endl;
     721      DoLog(0) && (Log() << Verbose(0) << " failed." << endl);
    722722
    723723    result = result && intermediateResult;
     
    726726    Free(&FragmentNumber);
    727727  }
    728   Log() << Verbose(0) << " done." << endl;
     728  DoLog(0) && (Log() << Verbose(0) << " done." << endl);
    729729
    730730  // printing final number
    731   Log() << Verbose(2) << "Final number of fragments: " << FragmentCounter << "." << endl;
     731  DoLog(2) && (Log() << Verbose(2) << "Final number of fragments: " << FragmentCounter << "." << endl);
    732732
    733733  // restore cell_size
     
    768768      Walker = Advancer;
    769769      Advancer = Advancer->next;
    770       Log() << Verbose(3) << "Re-linking " << *Walker << "..." << endl;
     770      DoLog(3) && (Log() << Verbose(3) << "Re-linking " << *Walker << "..." << endl);
    771771      unlink(Walker);
    772772      Walker->father = Walker;
     
    786786
    787787  // 1. dissect the molecule into connected subgraphs
    788   configuration->BG->ConstructBondGraph(mol);
     788  if (!configuration->BG->ConstructBondGraph(mol)) {
     789    delete (mol);
     790    DoeLog(1) && (eLog()<< Verbose(1) << "There are no bonds." << endl);
     791    return;
     792  }
    789793
    790794  // 2. scan for connected subgraphs
     
    793797  Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack);
    794798  delete(BackEdgeStack);
     799  if ((Subgraphs == NULL) || (Subgraphs->next == NULL)) {
     800    delete (mol);
     801    DoeLog(1) && (eLog()<< Verbose(1) << "There are no atoms." << endl);
     802    return;
     803  }
    795804
    796805  // 3. dissect (the following construct is needed to have the atoms not in the order of the DFS, but in
     
    810819      strncat(molecules[i]->name, number, MAXSTRINGSIZE - strlen(mol->name) - 1);
    811820    }
    812     cout << "MolName is " << molecules[i]->name << endl;
     821    DoLog(1) && (Log() << Verbose(1) << "MolName is " << molecules[i]->name << endl);
    813822    insert(molecules[i]);
    814823  }
     
    834843    Walker = mol->start->next;
    835844    if ((Walker->nr <0) || (Walker->nr >= mol->AtomCount)) {
    836       eLog() << Verbose(0) << "Index of atom " << *Walker << " is invalid!" << endl;
     845      DoeLog(0) && (eLog()<< Verbose(0) << "Index of atom " << *Walker << " is invalid!" << endl);
    837846      performCriticalExit();
    838847    }
    839848    FragmentCounter = MolMap[Walker->nr];
    840849    if (FragmentCounter != 0) {
    841       Log() << Verbose(3) << "Re-linking " << *Walker << "..." << endl;
     850      DoLog(3) && (Log() << Verbose(3) << "Re-linking " << *Walker << "..." << endl);
    842851      unlink(Walker);
    843852      molecules[FragmentCounter-1]->AddAtom(Walker);    // counting starts at 1
    844853    } else {
    845       eLog() << Verbose(0) << "Atom " << *Walker << " not associated to molecule!" << endl;
     854      DoeLog(0) && (eLog()<< Verbose(0) << "Atom " << *Walker << " not associated to molecule!" << endl);
    846855      performCriticalExit();
    847856    }
     
    864873  Free(&MolMap);
    865874  Free(&molecules);
    866   Log() << Verbose(1) << "I scanned " << FragmentCounter << " molecules." << endl;
     875  DoLog(1) && (Log() << Verbose(1) << "I scanned " << FragmentCounter << " molecules." << endl);
    867876};
    868877
     
    973982  int AtomNo;
    974983
    975   Log() << Verbose(1) << "Begin of FillBondStructureFromReference." << endl;
     984  DoLog(1) && (Log() << Verbose(1) << "Begin of FillBondStructureFromReference." << endl);
    976985  // fill ListOfLocalAtoms if NULL was given
    977986  if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->AtomCount, FreeList)) {
    978     Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl;
     987    DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl);
    979988    return false;
    980989  }
    981990
    982991  if (status) {
    983     Log() << Verbose(1) << "Creating adjacency list for subgraph " << Leaf << "." << endl;
     992    DoLog(1) && (Log() << Verbose(1) << "Creating adjacency list for subgraph " << Leaf << "." << endl);
    984993    // remove every bond from the list
    985994    bond *Binder = NULL;
     
    10021011            Leaf->AddBond(Walker, OtherWalker, (*Runner)->BondDegree);
    10031012        } else {
    1004           Log() << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << FragmentCounter << "][" << (*Runner)->GetOtherAtom(Walker->GetTrueFather())->nr << "] is NULL!" << endl;
     1013          DoLog(1) && (Log() << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << FragmentCounter << "][" << (*Runner)->GetOtherAtom(Walker->GetTrueFather())->nr << "] is NULL!" << endl);
    10051014          status = false;
    10061015        }
     
    10151024      Free(&ListOfLocalAtoms);
    10161025  }
    1017   Log() << Verbose(1) << "End of FillBondStructureFromReference." << endl;
     1026  DoLog(1) && (Log() << Verbose(1) << "End of FillBondStructureFromReference." << endl);
    10181027  return status;
    10191028};
     
    10481057        next->FillRootStackForSubgraphs(RootStack, AtomMask, ++FragmentCounter);
    10491058    } else {
    1050       Log() << Verbose(1) << "Rootstack[" << FragmentCounter << "] is NULL." << endl;
     1059      DoLog(1) && (Log() << Verbose(1) << "Rootstack[" << FragmentCounter << "] is NULL." << endl);
    10511060      return false;
    10521061    }
     
    10541063    return true;
    10551064  } else {
    1056     Log() << Verbose(1) << "Rootstack is NULL." << endl;
     1065    DoLog(1) && (Log() << Verbose(1) << "Rootstack is NULL." << endl);
    10571066    return false;
    10581067  }
     
    11041113  int KeySetCounter = 0;
    11051114
    1106   Log() << Verbose(1) << "Begin of AssignKeySetsToFragment." << endl;
     1115  DoLog(1) && (Log() << Verbose(1) << "Begin of AssignKeySetsToFragment." << endl);
    11071116  // fill ListOfLocalAtoms if NULL was given
    11081117  if (!FillListOfLocalAtoms(ListOfLocalAtoms, FragmentCounter, reference->AtomCount, FreeList)) {
    1109     Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl;
     1118    DoLog(1) && (Log() << Verbose(1) << "Filling of ListOfLocalAtoms failed." << endl);
    11101119    return false;
    11111120  }
     
    11351144    delete (TempSet);
    11361145    if (KeySetCounter == 0) {// if there are no keysets, delete the list
    1137       Log() << Verbose(1) << "KeySetCounter is zero, deleting FragmentList." << endl;
     1146      DoLog(1) && (Log() << Verbose(1) << "KeySetCounter is zero, deleting FragmentList." << endl);
    11381147      delete (FragmentList[FragmentCounter]);
    11391148    } else
    1140       Log() << Verbose(1) << KeySetCounter << " keysets were assigned to subgraph " << FragmentCounter << "." << endl;
     1149      DoLog(1) && (Log() << Verbose(1) << KeySetCounter << " keysets were assigned to subgraph " << FragmentCounter << "." << endl);
    11411150    FragmentCounter++;
    11421151    if (next != NULL)
     
    11441153    FragmentCounter--;
    11451154  } else
    1146     Log() << Verbose(1) << "KeySetList is NULL or empty." << endl;
     1155    DoLog(1) && (Log() << Verbose(1) << "KeySetList is NULL or empty." << endl);
    11471156
    11481157  if ((FreeList) && (ListOfLocalAtoms != NULL)) {
     
    11521161      Free(&ListOfLocalAtoms);
    11531162  }
    1154   Log() << Verbose(1) << "End of AssignKeySetsToFragment." << endl;
     1163  DoLog(1) && (Log() << Verbose(1) << "End of AssignKeySetsToFragment." << endl);
    11551164  return status;
    11561165};
     
    11651174void MoleculeLeafClass::TranslateIndicesToGlobalIDs(Graph **FragmentList, int &FragmentCounter, int &TotalNumberOfKeySets, Graph &TotalGraph)
    11661175{
    1167   Log() << Verbose(1) << "Begin of TranslateIndicesToGlobalIDs." << endl;
     1176  DoLog(1) && (Log() << Verbose(1) << "Begin of TranslateIndicesToGlobalIDs." << endl);
    11681177  KeySet *TempSet = new KeySet;
    11691178  if (FragmentList[FragmentCounter] != NULL) {
     
    11761185    delete (TempSet);
    11771186  } else {
    1178     Log() << Verbose(1) << "FragmentList is NULL." << endl;
     1187    DoLog(1) && (Log() << Verbose(1) << "FragmentList is NULL." << endl);
    11791188  }
    11801189  if (next != NULL)
    11811190    next->TranslateIndicesToGlobalIDs(FragmentList, ++FragmentCounter, TotalNumberOfKeySets, TotalGraph);
    11821191  FragmentCounter--;
    1183   Log() << Verbose(1) << "End of TranslateIndicesToGlobalIDs." << endl;
     1192  DoLog(1) && (Log() << Verbose(1) << "End of TranslateIndicesToGlobalIDs." << endl);
    11841193};
    11851194
  • src/parser.cpp

    r70378e rd6c485  
    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

    r70378e rd6c485  
    4949  pointer->sort = &pointer->Z;
    5050  if (pointer->Z < 1 && pointer->Z >= MAX_ELEMENTS)
    51     Log() << Verbose(0) << "Invalid Z number!\n";
     51    DoLog(0) && (Log() << Verbose(0) << "Invalid Z number!\n");
    5252  return add(pointer, end);
    5353};
     
    104104  int Z;
    105105  do {
    106     Log() << Verbose(0) << "Atomic number Z: ";
     106    DoLog(0) && (Log() << Verbose(0) << "Atomic number Z: ");
    107107    cin >> Z;
    108108    walker = this->FindElement(Z);  // give type
     
    118118  element *walker = NULL;
    119119  int Z = -1;
    120   Log() << Verbose(0) << "Atomic number: " << Z << endl;
     120  DoLog(0) && (Log() << Verbose(0) << "Atomic number: " << Z << endl);
    121121  cin >> Z;
    122122  walker = FindElement(Z);
    123123  if (walker == NULL) {
    124     Log() << Verbose(0) << "Element not found in database, please enter." << endl;
     124    DoLog(0) && (Log() << Verbose(0) << "Element not found in database, please enter." << endl);
    125125    walker = new element;
    126126    walker->Z = Z;
    127     Log() << Verbose(0) << "Mass: " << endl;
     127    DoLog(0) && (Log() << Verbose(0) << "Mass: " << endl);
    128128    cin >> walker->mass;
    129     Log() << Verbose(0) << "Name [max 64 chars]: " << endl;
     129    DoLog(0) && (Log() << Verbose(0) << "Name [max 64 chars]: " << endl);
    130130    cin >> walker->name;
    131     Log() << Verbose(0) << "Short form [max 3 chars]: " << endl;
     131    DoLog(0) && (Log() << Verbose(0) << "Short form [max 3 chars]: " << endl);
    132132    cin >> walker->symbol;
    133133    periodentafel::AddElement(walker);
     
    198198    infile.getline(header1, MAXSTRINGSIZE);
    199199    infile.getline(header2, MAXSTRINGSIZE); // skip first two header lines
    200     Log() << Verbose(0) <<  "Parsed elements:";
     200    DoLog(0) && (Log() << Verbose(0) <<  "Parsed elements:");
    201201    while (!infile.eof()) {
    202202      element *neues = new element;
     
    220220      //infile >> ws;
    221221      infile >> ws;
    222       Log() << Verbose(0) << " " << neues->symbol;
     222      DoLog(0) && (Log() << Verbose(0) << " " << neues->symbol);
    223223      //neues->Output((ofstream *)&cout);
    224224      if ((neues->Z > 0) && (neues->Z < MAX_ELEMENTS))
    225225        periodentafel::AddElement(neues);
    226226      else {
    227         Log() << Verbose(0) << "Could not parse element: ";
     227        DoLog(0) && (Log() << Verbose(0) << "Could not parse element: ");
    228228        neues->Output((ofstream *)&cout);
    229229        delete(neues);
    230230      }
    231231    }
    232     Log() << Verbose(0) << endl;
     232    DoLog(0) && (Log() << Verbose(0) << endl);
    233233    infile.close();
    234234    infile.clear();
     
    314314
    315315  if (!otherstatus)
    316     eLog() << Verbose(2) << "Something went wrong while parsing the other databases!" << endl;
     316    DoeLog(2) && (eLog()<< Verbose(2) << "Something went wrong while parsing the other databases!" << endl);
    317317
    318318  return status;
  • src/stackclass.hpp

    r70378e rd6c485  
    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

    r70378e rd6c485  
    77
    88#include <fstream>
     9#include <assert.h>
    910
    1011#include "helpers.hpp"
     
    2526 */
    2627BoundaryPointSet::BoundaryPointSet() :
    27     LinesCount(0),
    28     value(0.),
    29     Nr(-1)
    30 {
    31         Info FunctionInfo(__func__);
    32         Log() << Verbose(1) << "Adding noname." << endl;
    33 };
     28  LinesCount(0), value(0.), Nr(-1)
     29{
     30  Info FunctionInfo(__func__);
     31  DoLog(1) && (Log() << Verbose(1) << "Adding noname." << endl);
     32}
     33;
    3434
    3535/** Constructor of BoundaryPointSet with Tesselpoint.
     
    3737 */
    3838BoundaryPointSet::BoundaryPointSet(TesselPoint * const Walker) :
    39   LinesCount(0),
    40   node(Walker),
    41   value(0.),
    42   Nr(Walker->nr)
    43 {
    44         Info FunctionInfo(__func__);
    45   Log() << Verbose(1) << "Adding Node " << *Walker << endl;
    46 };
     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;
    4745
    4846/** Destructor of BoundaryPointSet.
     
    5250BoundaryPointSet::~BoundaryPointSet()
    5351{
    54         Info FunctionInfo(__func__);
     52  Info FunctionInfo(__func__);
    5553  //Log() << Verbose(0) << "Erasing point nr. " << Nr << "." << endl;
    5654  if (!lines.empty())
    57     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);
    5856  node = NULL;
    59 };
     57}
     58;
    6059
    6160/** Add a line to the LineMap of this point.
     
    6463void BoundaryPointSet::AddLine(BoundaryLineSet * const line)
    6564{
    66         Info FunctionInfo(__func__);
    67   Log() << Verbose(1) << "Adding " << *this << " to line " << *line << "."
    68       << endl;
    69   if (line->endpoints[0] == this)
    70     {
    71       lines.insert(LinePair(line->endpoints[1]->Nr, line));
    72     }
    73   else
    74     {
    75       lines.insert(LinePair(line->endpoints[0]->Nr, line));
    76     }
     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  }
    7772  LinesCount++;
    78 };
     73}
     74;
    7975
    8076/** output operator for BoundaryPointSet.
     
    9490 */
    9591BoundaryLineSet::BoundaryLineSet() :
    96     Nr(-1)
    97 {
    98         Info FunctionInfo(__func__);
     92  Nr(-1)
     93{
     94  Info FunctionInfo(__func__);
    9995  for (int i = 0; i < 2; i++)
    10096    endpoints[i] = NULL;
    101 };
     97}
     98;
    10299
    103100/** Constructor of BoundaryLineSet with two endpoints.
     
    108105BoundaryLineSet::BoundaryLineSet(BoundaryPointSet * const Point[2], const int number)
    109106{
    110         Info FunctionInfo(__func__);
     107  Info FunctionInfo(__func__);
    111108  // set number
    112109  Nr = number;
     
    119116  skipped = false;
    120117  // clear triangles list
    121   Log() << Verbose(0) << "New Line with endpoints " << *this << "." << endl;
    122 };
     118  DoLog(0) && (Log() << Verbose(0) << "New Line with endpoints " << *this << "." << endl);
     119}
     120;
    123121
    124122/** Constructor of BoundaryLineSet with two endpoints.
     
    141139  skipped = false;
    142140  // clear triangles list
    143   Log() << Verbose(0) << "New Line with endpoints " << *this << "." << endl;
    144 };
     141  DoLog(0) && (Log() << Verbose(0) << "New Line with endpoints " << *this << "." << endl);
     142}
     143;
    145144
    146145/** Destructor for BoundaryLineSet.
     
    150149BoundaryLineSet::~BoundaryLineSet()
    151150{
    152         Info FunctionInfo(__func__);
     151  Info FunctionInfo(__func__);
    153152  int Numbers[2];
    154153
     
    181180        //Log() << Verbose(0) << *endpoints[i] << " has no more lines it's attached to, erasing." << endl;
    182181        if (endpoints[i] != NULL) {
    183           delete(endpoints[i]);
     182          delete (endpoints[i]);
    184183          endpoints[i] = NULL;
    185184        }
     
    188187  }
    189188  if (!triangles.empty())
    190     eLog() << Verbose(2) << "Memory Leak! I " << *this << " am still connected to some triangles." << endl;
    191 };
     189    DoeLog(2) && (eLog() << Verbose(2) << "Memory Leak! I " << *this << " am still connected to some triangles." << endl);
     190}
     191;
    192192
    193193/** Add triangle to TriangleMap of this boundary line.
     
    196196void BoundaryLineSet::AddTriangle(BoundaryTriangleSet * const triangle)
    197197{
    198         Info FunctionInfo(__func__);
    199   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);
    200200  triangles.insert(TrianglePair(triangle->Nr, triangle));
    201 };
     201}
     202;
    202203
    203204/** Checks whether we have a common endpoint with given \a *line.
     
    207208bool BoundaryLineSet::IsConnectedTo(const BoundaryLineSet * const line) const
    208209{
    209         Info FunctionInfo(__func__);
     210  Info FunctionInfo(__func__);
    210211  if ((endpoints[0] == line->endpoints[0]) || (endpoints[1] == line->endpoints[0]) || (endpoints[0] == line->endpoints[1]) || (endpoints[1] == line->endpoints[1]))
    211212    return true;
    212213  else
    213214    return false;
    214 };
     215}
     216;
    215217
    216218/** Checks whether the adjacent triangles of a baseline are convex or not.
     
    222224bool BoundaryLineSet::CheckConvexityCriterion() const
    223225{
    224         Info FunctionInfo(__func__);
     226  Info FunctionInfo(__func__);
    225227  Vector BaseLineCenter, BaseLineNormal, BaseLine, helper[2], NormalCheck;
    226228  // get the two triangles
    227229  if (triangles.size() != 2) {
    228     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);
    229231    return true;
    230232  }
     
    234236  BaseLineCenter.CopyVector(endpoints[0]->node->node);
    235237  BaseLineCenter.AddVector(endpoints[1]->node->node);
    236   BaseLineCenter.Scale(1./2.);
     238  BaseLineCenter.Scale(1. / 2.);
    237239  BaseLine.CopyVector(endpoints[0]->node->node);
    238240  BaseLine.SubtractVector(endpoints[1]->node->node);
     
    242244  NormalCheck.Zero();
    243245  double sign = -1.;
    244   int i=0;
     246  int i = 0;
    245247  class BoundaryPointSet *node = NULL;
    246   for(TriangleMap::const_iterator runner = triangles.begin(); runner != triangles.end(); runner++) {
     248  for (TriangleMap::const_iterator runner = triangles.begin(); runner != triangles.end(); runner++) {
    247249    //Log() << Verbose(0) << "INFO: NormalVector of " << *(runner->second) << " is " << runner->second->NormalVector << "." << endl;
    248250    NormalCheck.AddVector(&runner->second->NormalVector);
     
    250252    sign = -sign;
    251253    if (runner->second->NormalVector.NormSquared() > MYEPSILON)
    252       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
    253255    else {
    254       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);
    255257    }
    256258    node = runner->second->GetThirdEndpoint(this);
     
    259261      helper[i].CopyVector(node->node->node);
    260262      helper[i].SubtractVector(&BaseLineCenter);
    261       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!
    262264      //Log() << Verbose(0) << "INFO: Height vector with respect to baseline is " << helper[i] << "." << endl;
    263265      i++;
    264266    } else {
    265       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);
    266268      return true;
    267269    }
     
    269271  //Log() << Verbose(0) << "INFO: BaselineNormal is " << BaseLineNormal << "." << endl;
    270272  if (NormalCheck.NormSquared() < MYEPSILON) {
    271     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);
    272274    return true;
    273275  }
     
    275277  double angle = GetAngle(helper[0], helper[1], BaseLineNormal);
    276278  if ((angle - M_PI) > -MYEPSILON) {
    277     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);
    278280    return true;
    279281  } else {
    280     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);
    281283    return false;
    282284  }
     
    289291bool BoundaryLineSet::ContainsBoundaryPoint(const BoundaryPointSet * const point) const
    290292{
    291         Info FunctionInfo(__func__);
    292   for(int i=0;i<2;i++)
     293  Info FunctionInfo(__func__);
     294  for (int i = 0; i < 2; i++)
    293295    if (point == endpoints[i])
    294296      return true;
    295297  return false;
    296 };
     298}
     299;
    297300
    298301/** Returns other endpoint of the line.
     
    302305class BoundaryPointSet *BoundaryLineSet::GetOtherEndpoint(const BoundaryPointSet * const point) const
    303306{
    304         Info FunctionInfo(__func__);
     307  Info FunctionInfo(__func__);
    305308  if (endpoints[0] == point)
    306309    return endpoints[1];
     
    309312  else
    310313    return NULL;
    311 };
     314}
     315;
    312316
    313317/** output operator for BoundaryLineSet.
     
    315319 * \param &a boundary line
    316320 */
    317 ostream & operator <<(ostream &ost, const  BoundaryLineSet &a)
     321ostream & operator <<(ostream &ost, const BoundaryLineSet &a)
    318322{
    319323  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 << "]";
    320324  return ost;
    321 };
     325}
     326;
    322327
    323328// ======================================== Triangles on Boundary =================================
     
    328333  Nr(-1)
    329334{
    330         Info FunctionInfo(__func__);
    331   for (int i = 0; i < 3; i++)
    332     {
    333       endpoints[i] = NULL;
    334       lines[i] = NULL;
    335     }
    336 };
     335  Info FunctionInfo(__func__);
     336  for (int i = 0; i < 3; i++) {
     337    endpoints[i] = NULL;
     338    lines[i] = NULL;
     339  }
     340}
     341;
    337342
    338343/** Constructor for BoundaryTriangleSet with three lines.
     
    343348  Nr(number)
    344349{
    345         Info FunctionInfo(__func__);
     350  Info FunctionInfo(__func__);
    346351  // set number
    347352  // set lines
     
    355360    // for all three lines
    356361    for (int j = 0; j < 2; j++) { // for both endpoints
    357       OrderMap.insert(pair<int, class BoundaryPointSet *> (
    358           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]));
    359363      // and we don't care whether insertion fails
    360364    }
    361365  // set endpoints
    362366  int Counter = 0;
    363   Log() << Verbose(0) << "New triangle " << Nr << " with end points: " << endl;
     367  DoLog(0) && (Log() << Verbose(0) << "New triangle " << Nr << " with end points: " << endl);
    364368  for (PointMap::iterator runner = OrderMap.begin(); runner != OrderMap.end(); runner++) {
    365369    endpoints[Counter] = runner->second;
    366     Log() << Verbose(0) << " " << *endpoints[Counter] << endl;
     370    DoLog(0) && (Log() << Verbose(0) << " " << *endpoints[Counter] << endl);
    367371    Counter++;
    368372  }
    369373  if (Counter < 3) {
    370     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);
    371375    performCriticalExit();
    372376  }
    373 };
     377}
     378;
    374379
    375380/** Destructor of BoundaryTriangleSet.
     
    379384BoundaryTriangleSet::~BoundaryTriangleSet()
    380385{
    381         Info FunctionInfo(__func__);
     386  Info FunctionInfo(__func__);
    382387  for (int i = 0; i < 3; i++) {
    383388    if (lines[i] != NULL) {
     
    386391      }
    387392      if (lines[i]->triangles.empty()) {
    388           //Log() << Verbose(0) << *lines[i] << " is no more attached to any triangle, erasing." << endl;
    389           delete (lines[i]);
    390           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;
    391396      }
    392397    }
    393398  }
    394399  //Log() << Verbose(0) << "Erasing triangle Nr." << Nr << " itself." << endl;
    395 };
     400}
     401;
    396402
    397403/** Calculates the normal vector for this triangle.
     
    401407void BoundaryTriangleSet::GetNormalVector(const Vector &OtherVector)
    402408{
    403         Info FunctionInfo(__func__);
     409  Info FunctionInfo(__func__);
    404410  // get normal vector
    405411  NormalVector.MakeNormalVector(endpoints[0]->node->node, endpoints[1]->node->node, endpoints[2]->node->node);
     
    408414  if (NormalVector.ScalarProduct(&OtherVector) > 0.)
    409415    NormalVector.Scale(-1.);
    410   Log() << Verbose(1) << "Normal Vector is " << NormalVector << "." << endl;
    411 };
     416  DoLog(1) && (Log() << Verbose(1) << "Normal Vector is " << NormalVector << "." << endl);
     417}
     418;
    412419
    413420/** Finds the point on the triangle \a *BTS through which the line defined by \a *MolCenter and \a *x crosses.
     
    430437
    431438  if (!Intersection->GetIntersectionWithPlane(&NormalVector, endpoints[0]->node->node, MolCenter, x)) {
    432     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);
    433440    return false;
    434441  }
    435442
    436   Log() << Verbose(1) << "INFO: Triangle is " << *this << "." << endl;
    437   Log() << Verbose(1) << "INFO: Line is from " << *MolCenter << " to " << *x << "." << endl;
    438   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);
    439446
    440447  if (Intersection->DistanceSquared(endpoints[0]->node->node) < MYEPSILON) {
    441     Log() << Verbose(1) << "Intersection coindices with first endpoint." << endl;
     448    DoLog(1) && (Log() << Verbose(1) << "Intersection coindices with first endpoint." << endl);
    442449    return true;
    443   }   else if (Intersection->DistanceSquared(endpoints[1]->node->node) < MYEPSILON) {
    444     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);
    445452    return true;
    446   }   else if (Intersection->DistanceSquared(endpoints[2]->node->node) < MYEPSILON) {
    447     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);
    448455    return true;
    449456  }
    450457  // Calculate cross point between one baseline and the line from the third endpoint to intersection
    451   int i=0;
     458  int i = 0;
    452459  do {
    453     if (CrossPoint.GetIntersectionOfTwoLinesOnPlane(endpoints[i%3]->node->node, endpoints[(i+1)%3]->node->node, endpoints[(i+2)%3]->node->node, Intersection, &NormalVector)) {
    454       helper.CopyVector(endpoints[(i+1)%3]->node->node);
    455       helper.SubtractVector(endpoints[i%3]->node->node);
    456       CrossPoint.SubtractVector(endpoints[i%3]->node->node); // cross point was returned as absolute vector
    457       const double s = CrossPoint.ScalarProduct(&helper)/helper.NormSquared();
    458       Log() << Verbose(1) << "INFO: Factor s is " << s << "." << endl;
    459       if ((s < -MYEPSILON) || ((s-1.) > MYEPSILON)) {
    460         Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << "outside of triangle." << endl;
    461         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;
    462469        break;
    463470      }
    464471      i++;
    465     } else 
     472    } else
    466473      break;
    467   } while (i<3);
    468   if (i==3) {
    469     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);
    470477    return true;
    471478  } else {
    472     Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << " outside of triangle." << endl;
     479    DoLog(1) && (Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << " outside of triangle." << endl);
    473480    return false;
    474481  }
    475 };
     482}
     483;
    476484
    477485/** Finds the point on the triangle to the point \a *x.
     
    493501
    494502  // 1. get intersection with plane
    495   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);
    496504  GetCenter(&Direction);
    497505  if (!ClosestPoint->GetIntersectionWithPlane(&NormalVector, endpoints[0]->node->node, x, &Direction)) {
     
    502510  Vector InPlane;
    503511  InPlane.CopyVector(x);
    504   InPlane.SubtractVector(ClosestPoint);  // points from plane intersection to straight-down point
     512  InPlane.SubtractVector(ClosestPoint); // points from plane intersection to straight-down point
    505513  InPlane.ProjectOntoPlane(&NormalVector);
    506514  InPlane.AddVector(ClosestPoint);
    507515
    508   Log() << Verbose(2) << "INFO: Triangle is " << *this << "." << endl;
    509   Log() << Verbose(2) << "INFO: Line is from " << Direction << " to " << *x << "." << endl;
    510   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);
    511519
    512520  // Calculate cross point between one baseline and the desired point such that distance is shortest
     
    516524  Vector CrossPoint[3];
    517525  Vector helper;
    518   for (int i=0;i<3;i++) {
     526  for (int i = 0; i < 3; i++) {
    519527    // treat direction of line as normal of a (cut)plane and the desired point x as the plane offset, the intersect line with point
    520     Direction.CopyVector(endpoints[(i+1)%3]->node->node);
    521     Direction.SubtractVector(endpoints[i%3]->node->node);
     528    Direction.CopyVector(endpoints[(i + 1) % 3]->node->node);
     529    Direction.SubtractVector(endpoints[i % 3]->node->node);
    522530    // calculate intersection, line can never be parallel to Direction (is the same vector as PlaneNormal);
    523     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);
    524532    CrossDirection[i].CopyVector(&CrossPoint[i]);
    525533    CrossDirection[i].SubtractVector(&InPlane);
    526     CrossPoint[i].SubtractVector(endpoints[i%3]->node->node); // cross point was returned as absolute vector
    527     const double s = CrossPoint[i].ScalarProduct(&Direction)/Direction.NormSquared();
    528     Log() << Verbose(2) << "INFO: Factor s is " << s << "." << endl;
    529     if ((s >= -MYEPSILON) && ((s-1.) <= MYEPSILON)) {
    530       CrossPoint[i].AddVector(endpoints[i%3]->node->node); // make cross point absolute again
    531       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);
    532540      const double distance = CrossPoint[i].DistanceSquared(x);
    533541      if ((ShortestDistance < 0.) || (ShortestDistance > distance)) {
     
    539547  }
    540548  InsideFlag = true;
    541   for (int i=0;i<3;i++) {
    542     const double sign = CrossDirection[i].ScalarProduct(&CrossDirection[(i+1)%3]);
    543     const double othersign = CrossDirection[i].ScalarProduct(&CrossDirection[(i+2)%3]);;
    544     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
    545554      InsideFlag = false;
    546555  }
     
    548557    ClosestPoint->CopyVector(&InPlane);
    549558    ShortestDistance = InPlane.DistanceSquared(x);
    550   } else {  // also check endnodes
    551     for (int i=0;i<3;i++) {
     559  } else { // also check endnodes
     560    for (int i = 0; i < 3; i++) {
    552561      const double distance = x->DistanceSquared(endpoints[i]->node->node);
    553562      if ((ShortestDistance < 0.) || (ShortestDistance > distance)) {
     
    557566    }
    558567  }
    559   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);
    560569  return ShortestDistance;
    561 };
     570}
     571;
    562572
    563573/** Checks whether lines is any of the three boundary lines this triangle contains.
     
    567577bool BoundaryTriangleSet::ContainsBoundaryLine(const BoundaryLineSet * const line) const
    568578{
    569         Info FunctionInfo(__func__);
    570   for(int i=0;i<3;i++)
     579  Info FunctionInfo(__func__);
     580  for (int i = 0; i < 3; i++)
    571581    if (line == lines[i])
    572582      return true;
    573583  return false;
    574 };
     584}
     585;
    575586
    576587/** Checks whether point is any of the three endpoints this triangle contains.
     
    580591bool BoundaryTriangleSet::ContainsBoundaryPoint(const BoundaryPointSet * const point) const
    581592{
    582         Info FunctionInfo(__func__);
    583   for(int i=0;i<3;i++)
     593  Info FunctionInfo(__func__);
     594  for (int i = 0; i < 3; i++)
    584595    if (point == endpoints[i])
    585596      return true;
    586597  return false;
    587 };
     598}
     599;
    588600
    589601/** Checks whether point is any of the three endpoints this triangle contains.
     
    593605bool BoundaryTriangleSet::ContainsBoundaryPoint(const TesselPoint * const point) const
    594606{
    595         Info FunctionInfo(__func__);
    596   for(int i=0;i<3;i++)
     607  Info FunctionInfo(__func__);
     608  for (int i = 0; i < 3; i++)
    597609    if (point == endpoints[i]->node)
    598610      return true;
    599611  return false;
    600 };
     612}
     613;
    601614
    602615/** Checks whether three given \a *Points coincide with triangle's endpoints.
     
    606619bool BoundaryTriangleSet::IsPresentTupel(const BoundaryPointSet * const Points[3]) const
    607620{
    608         Info FunctionInfo(__func__);
    609         Log() << Verbose(1) << "INFO: Checking " << Points[0] << ","  << Points[1] << "," << Points[2] << " against " << endpoints[0] << "," << endpoints[1] << "," << endpoints[2] << "." << endl;
    610   return (((endpoints[0] == Points[0])
    611             || (endpoints[0] == Points[1])
    612             || (endpoints[0] == Points[2])
    613           ) && (
    614             (endpoints[1] == Points[0])
    615             || (endpoints[1] == Points[1])
    616             || (endpoints[1] == Points[2])
    617           ) && (
    618             (endpoints[2] == Points[0])
    619             || (endpoints[2] == Points[1])
    620             || (endpoints[2] == Points[2])
    621 
    622           ));
    623 };
     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;
    624628
    625629/** Checks whether three given \a *Points coincide with triangle's endpoints.
     
    629633bool BoundaryTriangleSet::IsPresentTupel(const BoundaryTriangleSet * const T) const
    630634{
    631         Info FunctionInfo(__func__);
    632   return (((endpoints[0] == T->endpoints[0])
    633             || (endpoints[0] == T->endpoints[1])
    634             || (endpoints[0] == T->endpoints[2])
    635           ) && (
    636             (endpoints[1] == T->endpoints[0])
    637             || (endpoints[1] == T->endpoints[1])
    638             || (endpoints[1] == T->endpoints[2])
    639           ) && (
    640             (endpoints[2] == T->endpoints[0])
    641             || (endpoints[2] == T->endpoints[1])
    642             || (endpoints[2] == T->endpoints[2])
    643 
    644           ));
    645 };
     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;
    646641
    647642/** Returns the endpoint which is not contained in the given \a *line.
     
    651646class BoundaryPointSet *BoundaryTriangleSet::GetThirdEndpoint(const BoundaryLineSet * const line) const
    652647{
    653         Info FunctionInfo(__func__);
     648  Info FunctionInfo(__func__);
    654649  // sanity check
    655650  if (!ContainsBoundaryLine(line))
    656651    return NULL;
    657   for(int i=0;i<3;i++)
     652  for (int i = 0; i < 3; i++)
    658653    if (!line->ContainsBoundaryPoint(endpoints[i]))
    659654      return endpoints[i];
    660655  // actually, that' impossible :)
    661656  return NULL;
    662 };
     657}
     658;
    663659
    664660/** Calculates the center point of the triangle.
     
    668664void BoundaryTriangleSet::GetCenter(Vector * const center) const
    669665{
    670         Info FunctionInfo(__func__);
     666  Info FunctionInfo(__func__);
    671667  center->Zero();
    672   for(int i=0;i<3;i++)
     668  for (int i = 0; i < 3; i++)
    673669    center->AddVector(endpoints[i]->node->node);
    674   center->Scale(1./3.);
    675   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);
    676672}
    677673
     
    683679{
    684680  ost << "[" << a.Nr << "|" << a.endpoints[0]->node->Name << "," << a.endpoints[1]->node->Name << "," << a.endpoints[2]->node->Name << "]";
    685 //  ost << "[" << a.Nr << "|" << a.endpoints[0]->node->Name << " at " << *a.endpoints[0]->node->node << ","
    686 //      << 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 << "]";
    687683  return ost;
    688 };
     684}
     685;
    689686
    690687// ======================================== Polygons on Boundary =================================
     
    696693{
    697694  Info FunctionInfo(__func__);
    698 };
     695}
     696;
    699697
    700698/** Destructor of BoundaryPolygonSet.
     
    706704  Info FunctionInfo(__func__);
    707705  endpoints.clear();
    708   Log() << Verbose(1) << "Erasing polygon Nr." << Nr << " itself." << endl;
    709 };
     706  DoLog(1) && (Log() << Verbose(1) << "Erasing polygon Nr." << Nr << " itself." << endl);
     707}
     708;
    710709
    711710/** Calculates the normal vector for this triangle.
     
    721720  Vector *TotalNormal = new Vector;
    722721  PointSet::const_iterator Runner[3];
    723   for (int i=0;i<3; i++) {
     722  for (int i = 0; i < 3; i++) {
    724723    Runner[i] = endpoints.begin();
    725     for (int j = 0; j<i; j++) { // go as much further
     724    for (int j = 0; j < i; j++) { // go as much further
    726725      Runner[i]++;
    727726      if (Runner[i] == endpoints.end()) {
    728         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);
    729728        performCriticalExit();
    730729      }
     
    732731  }
    733732  TotalNormal->Zero();
    734   int counter=0;
    735   for (; Runner[2] != endpoints.end(); ) {
     733  int counter = 0;
     734  for (; Runner[2] != endpoints.end();) {
    736735    TemporaryNormal.MakeNormalVector((*Runner[0])->node->node, (*Runner[1])->node->node, (*Runner[2])->node->node);
    737     for (int i=0;i<3;i++) // increase each of them
     736    for (int i = 0; i < 3; i++) // increase each of them
    738737      Runner[i]++;
    739738    TotalNormal->AddVector(&TemporaryNormal);
    740739  }
    741   TotalNormal->Scale(1./(double)counter);
     740  TotalNormal->Scale(1. / (double) counter);
    742741
    743742  // make it always point inward (any offset vector onto plane projected onto normal vector suffices)
    744743  if (TotalNormal->ScalarProduct(&OtherVector) > 0.)
    745744    TotalNormal->Scale(-1.);
    746   Log() << Verbose(1) << "Normal Vector is " << *TotalNormal << "." << endl;
     745  DoLog(1) && (Log() << Verbose(1) << "Normal Vector is " << *TotalNormal << "." << endl);
    747746
    748747  return TotalNormal;
    749 };
     748}
     749;
    750750
    751751/** Calculates the center point of the triangle.
     
    758758  center->Zero();
    759759  int counter = 0;
    760   for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) {
     760  for (PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) {
    761761    center->AddVector((*Runner)->node->node);
    762762    counter++;
    763763  }
    764   center->Scale(1./(double)counter);
    765   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);
    766766}
    767767
     
    774774  Info FunctionInfo(__func__);
    775775  return ContainsPresentTupel(triangle->endpoints, 3);
    776 };
     776}
     777;
    777778
    778779/** Checks whether the polygons contains both endpoints of the line.
     
    784785  Info FunctionInfo(__func__);
    785786  return ContainsPresentTupel(line->endpoints, 2);
    786 };
     787}
     788;
    787789
    788790/** Checks whether point is any of the three endpoints this triangle contains.
     
    793795{
    794796  Info FunctionInfo(__func__);
    795   for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) {
    796     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);
    797799    if (point == (*Runner)) {
    798       Log() << Verbose(0) << " Contained." << endl;
     800      DoLog(0) && (Log() << Verbose(0) << " Contained." << endl);
    799801      return true;
    800802    }
    801803  }
    802   Log() << Verbose(0) << " Not contained." << endl;
     804  DoLog(0) && (Log() << Verbose(0) << " Not contained." << endl);
    803805  return false;
    804 };
     806}
     807;
    805808
    806809/** Checks whether point is any of the three endpoints this triangle contains.
     
    811814{
    812815  Info FunctionInfo(__func__);
    813   for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++)
     816  for (PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++)
    814817    if (point == (*Runner)->node) {
    815       Log() << Verbose(0) << " Contained." << endl;
     818      DoLog(0) && (Log() << Verbose(0) << " Contained." << endl);
    816819      return true;
    817820    }
    818   Log() << Verbose(0) << " Not contained." << endl;
     821  DoLog(0) && (Log() << Verbose(0) << " Not contained." << endl);
    819822  return false;
    820 };
     823}
     824;
    821825
    822826/** Checks whether given array of \a *Points coincide with polygons's endpoints.
     
    829833  Info FunctionInfo(__func__);
    830834  int counter = 0;
    831   Log() << Verbose(1) << "Polygon is " << *this << endl;
    832   for(int i=0;i<dim;i++) {
    833     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);
    834838    if (ContainsBoundaryPoint(Points[i])) {
    835839      counter++;
     
    841845  else
    842846    return false;
    843 };
     847}
     848;
    844849
    845850/** Checks whether given PointList coincide with polygons's endpoints.
     
    851856  Info FunctionInfo(__func__);
    852857  size_t counter = 0;
    853   Log() << Verbose(1) << "Polygon is " << *this << endl;
    854   for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) {
    855     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);
    856861    if (ContainsBoundaryPoint(*Runner))
    857862      counter++;
     
    862867  else
    863868    return false;
    864 };
     869}
     870;
    865871
    866872/** Checks whether given set of \a *Points coincide with polygons's endpoints.
     
    870876bool BoundaryPolygonSet::ContainsPresentTupel(const BoundaryPolygonSet * const P) const
    871877{
    872   return ContainsPresentTupel((const PointSet)P->endpoints);
    873 };
     878  return ContainsPresentTupel((const PointSet) P->endpoints);
     879}
     880;
    874881
    875882/** Gathers all the endpoints' triangles in a unique set.
     
    879886{
    880887  Info FunctionInfo(__func__);
    881   pair <TriangleSet::iterator, bool> Tester;
     888  pair<TriangleSet::iterator, bool> Tester;
    882889  TriangleSet *triangles = new TriangleSet;
    883890
    884   for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++)
    885     for(LineMap::const_iterator Walker = (*Runner)->lines.begin(); Walker != (*Runner)->lines.end(); Walker++)
    886       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++) {
    887894        //Log() << Verbose(0) << " Testing triangle " << *(Sprinter->second) << endl;
    888895        if (ContainsBoundaryTriangle(Sprinter->second)) {
    889896          Tester = triangles->insert(Sprinter->second);
    890897          if (Tester.second)
    891             Log() << Verbose(0) << "Adding triangle " << *(Sprinter->second) << endl;
     898            DoLog(0) && (Log() << Verbose(0) << "Adding triangle " << *(Sprinter->second) << endl);
    892899        }
    893900      }
    894901
    895   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);
    896903  return triangles;
    897 };
     904}
     905;
    898906
    899907/** Fills the endpoints of this polygon from the triangles attached to \a *line.
     
    904912{
    905913  Info FunctionInfo(__func__);
    906   pair <PointSet::iterator, bool> Tester;
     914  pair<PointSet::iterator, bool> Tester;
    907915  if (line == NULL)
    908916    return false;
    909   Log() << Verbose(1) << "Filling polygon from line " << *line << endl;
    910   for(TriangleMap::const_iterator Runner = line->triangles.begin(); Runner != line->triangles.end(); Runner++) {
    911     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++) {
    912920      Tester = endpoints.insert((Runner->second)->endpoints[i]);
    913921      if (Tester.second)
    914         Log() << Verbose(1) << "  Inserting endpoint " << *((Runner->second)->endpoints[i]) << endl;
     922        DoLog(1) && (Log() << Verbose(1) << "  Inserting endpoint " << *((Runner->second)->endpoints[i]) << endl);
    915923    }
    916924  }
    917925
    918926  return true;
    919 };
     927}
     928;
    920929
    921930/** output operator for BoundaryPolygonSet.
     
    926935{
    927936  ost << "[" << a.Nr << "|";
    928   for(PointSet::const_iterator Runner = a.endpoints.begin(); Runner != a.endpoints.end();) {
    929    ost << (*Runner)->node->Name;
    930    Runner++;
    931    if (Runner != a.endpoints.end())
    932      ost << ",";
    933   }
    934   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 << "]";
    935944  return ost;
    936 };
     945}
     946;
    937947
    938948// =========================================================== class TESSELPOINT ===========================================
     
    945955  node = NULL;
    946956  nr = -1;
    947   Name =  NULL;
    948 };
     957  Name = NULL;
     958}
     959;
    949960
    950961/** Destructor for class TesselPoint.
     
    953964{
    954965  //Info FunctionInfo(__func__);
    955 };
     966}
     967;
    956968
    957969/** Prints LCNode to screen.
    958970 */
    959 ostream & operator << (ostream &ost, const TesselPoint &a)
     971ostream & operator <<(ostream &ost, const TesselPoint &a)
    960972{
    961973  ost << "[" << (a.Name) << "|" << a.Name << " at " << *a.node << "]";
    962974  return ost;
    963 };
     975}
     976;
    964977
    965978/** Prints LCNode to screen.
    966979 */
    967 ostream & TesselPoint::operator << (ostream &ost)
    968 {
    969         Info FunctionInfo(__func__);
     980ostream & TesselPoint::operator <<(ostream &ost)
     981{
     982  Info FunctionInfo(__func__);
    970983  ost << "[" << (nr) << "|" << this << "]";
    971984  return ost;
    972 };
    973 
     985}
     986;
    974987
    975988// =========================================================== class POINTCLOUD ============================================
     
    979992PointCloud::PointCloud()
    980993{
    981         //Info FunctionInfo(__func__);
    982 };
     994  //Info FunctionInfo(__func__);
     995}
     996;
    983997
    984998/** Destructor for class PointCloud.
     
    9861000PointCloud::~PointCloud()
    9871001{
    988         //Info FunctionInfo(__func__);
    989 };
     1002  //Info FunctionInfo(__func__);
     1003}
     1004;
    9901005
    9911006// ============================ CandidateForTesselation =============================
     
    9931008/** Constructor of class CandidateForTesselation.
    9941009 */
    995 CandidateForTesselation::CandidateForTesselation (BoundaryLineSet* line) :
    996   BaseLine(line),
    997   ShortestAngle(2.*M_PI),
    998   OtherShortestAngle(2.*M_PI)
    999 {
    1000         Info FunctionInfo(__func__);
    1001 };
    1002 
     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;
    10031016
    10041017/** Constructor of class CandidateForTesselation.
    10051018 */
    1006 CandidateForTesselation::CandidateForTesselation (TesselPoint *candidate, BoundaryLineSet* line, Vector OptCandidateCenter, Vector OtherOptCandidateCenter) :
    1007     BaseLine(line),
    1008     ShortestAngle(2.*M_PI),
    1009     OtherShortestAngle(2.*M_PI)
    1010 {
    1011         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__);
    10121023  OptCenter.CopyVector(&OptCandidateCenter);
    10131024  OtherOptCenter.CopyVector(&OtherOptCandidateCenter);
    1014 };
     1025}
     1026;
    10151027
    10161028/** Destructor for class CandidateForTesselation.
    10171029 */
    1018 CandidateForTesselation::~CandidateForTesselation() {
    1019   BaseLine = NULL;
    1020 };
     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;
    10211118
    10221119/** output operator for CandidateForTesselation.
     
    10241121 * \param &a boundary line
    10251122 */
    1026 ostream & operator <<(ostream &ost, const  CandidateForTesselation &a)
     1123ostream & operator <<(ostream &ost, const CandidateForTesselation &a)
    10271124{
    10281125  ost << "[" << a.BaseLine->Nr << "|" << a.BaseLine->endpoints[0]->node->Name << "," << a.BaseLine->endpoints[1]->node->Name << "] with ";
     
    10371134    for (TesselPointList::const_iterator Runner = a.pointlist.begin(); Runner != a.pointlist.end(); Runner++)
    10381135      ost << *(*Runner) << " ";
    1039     ost << " at angle " << (a.ShortestAngle)<< ".";
     1136    ost << " at angle " << (a.ShortestAngle) << ".";
    10401137  }
    10411138
    10421139  return ost;
    1043 };
    1044 
     1140}
     1141;
    10451142
    10461143// =========================================================== class TESSELATION ===========================================
     
    10491146 */
    10501147Tesselation::Tesselation() :
    1051   PointsOnBoundaryCount(0),
    1052   LinesOnBoundaryCount(0),
    1053   TrianglesOnBoundaryCount(0),
    1054   LastTriangle(NULL),
    1055   TriangleFilesWritten(0),
    1056   InternalPointer(PointsOnBoundary.begin())
    1057 {
    1058         Info FunctionInfo(__func__);
     1148  PointsOnBoundaryCount(0), LinesOnBoundaryCount(0), TrianglesOnBoundaryCount(0), LastTriangle(NULL), TriangleFilesWritten(0), InternalPointer(PointsOnBoundary.begin())
     1149{
     1150  Info FunctionInfo(__func__);
    10591151}
    10601152;
     
    10651157Tesselation::~Tesselation()
    10661158{
    1067         Info FunctionInfo(__func__);
    1068   Log() << Verbose(0) << "Free'ing TesselStruct ... " << endl;
     1159  Info FunctionInfo(__func__);
     1160  DoLog(0) && (Log() << Verbose(0) << "Free'ing TesselStruct ... " << endl);
    10691161  for (TriangleMap::iterator runner = TrianglesOnBoundary.begin(); runner != TrianglesOnBoundary.end(); runner++) {
    10701162    if (runner->second != NULL) {
     
    10721164      runner->second = NULL;
    10731165    } else
    1074       eLog() << Verbose(1) << "The triangle " << runner->first << " has already been free'd." << endl;
    1075   }
    1076   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);
    10771169}
    10781170;
     
    10801172/** PointCloud implementation of GetCenter
    10811173 * Uses PointsOnBoundary and STL stuff.
    1082  */   
     1174 */
    10831175Vector * Tesselation::GetCenter(ofstream *out) const
    10841176{
    1085         Info FunctionInfo(__func__);
    1086   Vector *Center = new Vector(0.,0.,0.);
    1087   int num=0;
     1177  Info FunctionInfo(__func__);
     1178  Vector *Center = new Vector(0., 0., 0.);
     1179  int num = 0;
    10881180  for (GoToFirst(); (!IsEnd()); GoToNext()) {
    10891181    Center->AddVector(GetPoint()->node);
    10901182    num++;
    10911183  }
    1092   Center->Scale(1./num);
     1184  Center->Scale(1. / num);
    10931185  return Center;
    1094 };
     1186}
     1187;
    10951188
    10961189/** PointCloud implementation of GoPoint
    10971190 * Uses PointsOnBoundary and STL stuff.
    1098  */   
     1191 */
    10991192TesselPoint * Tesselation::GetPoint() const
    11001193{
    1101         Info FunctionInfo(__func__);
     1194  Info FunctionInfo(__func__);
    11021195  return (InternalPointer->second->node);
    1103 };
     1196}
     1197;
    11041198
    11051199/** PointCloud implementation of GetTerminalPoint.
    11061200 * Uses PointsOnBoundary and STL stuff.
    1107  */   
     1201 */
    11081202TesselPoint * Tesselation::GetTerminalPoint() const
    11091203{
    1110         Info FunctionInfo(__func__);
     1204  Info FunctionInfo(__func__);
    11111205  PointMap::const_iterator Runner = PointsOnBoundary.end();
    11121206  Runner--;
    11131207  return (Runner->second->node);
    1114 };
     1208}
     1209;
    11151210
    11161211/** PointCloud implementation of GoToNext.
    11171212 * Uses PointsOnBoundary and STL stuff.
    1118  */   
     1213 */
    11191214void Tesselation::GoToNext() const
    11201215{
    1121         Info FunctionInfo(__func__);
     1216  Info FunctionInfo(__func__);
    11221217  if (InternalPointer != PointsOnBoundary.end())
    11231218    InternalPointer++;
    1124 };
     1219}
     1220;
    11251221
    11261222/** PointCloud implementation of GoToPrevious.
    11271223 * Uses PointsOnBoundary and STL stuff.
    1128  */   
     1224 */
    11291225void Tesselation::GoToPrevious() const
    11301226{
    1131         Info FunctionInfo(__func__);
     1227  Info FunctionInfo(__func__);
    11321228  if (InternalPointer != PointsOnBoundary.begin())
    11331229    InternalPointer--;
    1134 };
     1230}
     1231;
    11351232
    11361233/** PointCloud implementation of GoToFirst.
    11371234 * Uses PointsOnBoundary and STL stuff.
    1138  */   
     1235 */
    11391236void Tesselation::GoToFirst() const
    11401237{
    1141         Info FunctionInfo(__func__);
     1238  Info FunctionInfo(__func__);
    11421239  InternalPointer = PointsOnBoundary.begin();
    1143 };
     1240}
     1241;
    11441242
    11451243/** PointCloud implementation of GoToLast.
     
    11481246void Tesselation::GoToLast() const
    11491247{
    1150         Info FunctionInfo(__func__);
     1248  Info FunctionInfo(__func__);
    11511249  InternalPointer = PointsOnBoundary.end();
    11521250  InternalPointer--;
    1153 };
     1251}
     1252;
    11541253
    11551254/** PointCloud implementation of IsEmpty.
    11561255 * Uses PointsOnBoundary and STL stuff.
    1157  */   
     1256 */
    11581257bool Tesselation::IsEmpty() const
    11591258{
    1160         Info FunctionInfo(__func__);
     1259  Info FunctionInfo(__func__);
    11611260  return (PointsOnBoundary.empty());
    1162 };
     1261}
     1262;
    11631263
    11641264/** PointCloud implementation of IsLast.
    11651265 * Uses PointsOnBoundary and STL stuff.
    1166  */   
     1266 */
    11671267bool Tesselation::IsEnd() const
    11681268{
    1169         Info FunctionInfo(__func__);
     1269  Info FunctionInfo(__func__);
    11701270  return (InternalPointer == PointsOnBoundary.end());
    1171 };
    1172 
     1271}
     1272;
    11731273
    11741274/** Gueses first starting triangle of the convex envelope.
     
    11791279void Tesselation::GuessStartingTriangle()
    11801280{
    1181         Info FunctionInfo(__func__);
     1281  Info FunctionInfo(__func__);
    11821282  // 4b. create a starting triangle
    11831283  // 4b1. create all distances
     
    11891289
    11901290  // with A chosen, take each pair B,C and sort
    1191   if (A != PointsOnBoundary.end())
    1192     {
    1193       B = A;
    1194       B++;
    1195       for (; B != PointsOnBoundary.end(); B++)
    1196         {
    1197           C = B;
    1198           C++;
    1199           for (; C != PointsOnBoundary.end(); C++)
    1200             {
    1201               tmp = A->second->node->node->DistanceSquared(B->second->node->node);
    1202               distance = tmp * tmp;
    1203               tmp = A->second->node->node->DistanceSquared(C->second->node->node);
    1204               distance += tmp * tmp;
    1205               tmp = B->second->node->node->DistanceSquared(C->second->node->node);
    1206               distance += tmp * tmp;
    1207               DistanceMMap.insert(DistanceMultiMapPair(distance, pair<PointMap::iterator, PointMap::iterator> (B, C)));
    1208             }
    1209         }
    1210     }
     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  }
    12111308  //    // listing distances
    12121309  //    Log() << Verbose(1) << "Listing DistanceMMap:";
     
    12181315  // 1. we take from the smallest sum of squared distance as the base line BC (with peak A) onward as the triangle candidate
    12191316  DistanceMultiMap::iterator baseline = DistanceMMap.begin();
    1220   for (; baseline != DistanceMMap.end(); baseline++)
    1221     {
    1222       // we take from the smallest sum of squared distance as the base line BC (with peak A) onward as the triangle candidate
    1223       // 2. next, we have to check whether all points reside on only one side of the triangle
    1224       // 3. construct plane vector
    1225       PlaneVector.MakeNormalVector(A->second->node->node,
    1226           baseline->second.first->second->node->node,
    1227           baseline->second.second->second->node->node);
    1228       Log() << Verbose(2) << "Plane vector of candidate triangle is " << PlaneVector << endl;
    1229       // 4. loop over all points
    1230       double sign = 0.;
    1231       PointMap::iterator checker = PointsOnBoundary.begin();
    1232       for (; checker != PointsOnBoundary.end(); checker++)
    1233         {
    1234           // (neglecting A,B,C)
    1235           if ((checker == A) || (checker == baseline->second.first) || (checker
    1236               == baseline->second.second))
    1237             continue;
    1238           // 4a. project onto plane vector
    1239           TrialVector.CopyVector(checker->second->node->node);
    1240           TrialVector.SubtractVector(A->second->node->node);
    1241           distance = TrialVector.ScalarProduct(&PlaneVector);
    1242           if (fabs(distance) < 1e-4) // we need to have a small epsilon around 0 which is still ok
    1243             continue;
    1244           Log() << Verbose(2) << "Projection of " << checker->second->node->Name << " yields distance of " << distance << "." << endl;
    1245           tmp = distance / fabs(distance);
    1246           // 4b. Any have different sign to than before? (i.e. would lie outside convex hull with this starting triangle)
    1247           if ((sign != 0) && (tmp != sign))
    1248             {
    1249               // 4c. If so, break 4. loop and continue with next candidate in 1. loop
    1250               Log() << Verbose(2) << "Current candidates: "
    1251                   << A->second->node->Name << ","
    1252                   << baseline->second.first->second->node->Name << ","
    1253                   << baseline->second.second->second->node->Name << " leaves "
    1254                   << checker->second->node->Name << " outside the convex hull."
    1255                   << endl;
    1256               break;
    1257             }
    1258           else
    1259             { // note the sign for later
    1260               Log() << Verbose(2) << "Current candidates: "
    1261                   << A->second->node->Name << ","
    1262                   << baseline->second.first->second->node->Name << ","
    1263                   << baseline->second.second->second->node->Name << " leave "
    1264                   << checker->second->node->Name << " inside the convex hull."
    1265                   << endl;
    1266               sign = tmp;
    1267             }
    1268           // 4d. Check whether the point is inside the triangle (check distance to each node
    1269           tmp = checker->second->node->node->DistanceSquared(A->second->node->node);
    1270           int innerpoint = 0;
    1271           if ((tmp < A->second->node->node->DistanceSquared(
    1272               baseline->second.first->second->node->node)) && (tmp
    1273               < A->second->node->node->DistanceSquared(
    1274                   baseline->second.second->second->node->node)))
    1275             innerpoint++;
    1276           tmp = checker->second->node->node->DistanceSquared(
    1277               baseline->second.first->second->node->node);
    1278           if ((tmp < baseline->second.first->second->node->node->DistanceSquared(
    1279               A->second->node->node)) && (tmp
    1280               < baseline->second.first->second->node->node->DistanceSquared(
    1281                   baseline->second.second->second->node->node)))
    1282             innerpoint++;
    1283           tmp = checker->second->node->node->DistanceSquared(
    1284               baseline->second.second->second->node->node);
    1285           if ((tmp < baseline->second.second->second->node->node->DistanceSquared(
    1286               baseline->second.first->second->node->node)) && (tmp
    1287               < baseline->second.second->second->node->node->DistanceSquared(
    1288                   A->second->node->node)))
    1289             innerpoint++;
    1290           // 4e. If so, break 4. loop and continue with next candidate in 1. loop
    1291           if (innerpoint == 3)
    1292             break;
    1293         }
    1294       // 5. come this far, all on same side? Then break 1. loop and construct triangle
    1295       if (checker == PointsOnBoundary.end())
    1296         {
    1297           Log() << Verbose(2) << "Looks like we have a candidate!" << endl;
    1298           break;
    1299         }
    1300     }
    1301   if (baseline != DistanceMMap.end())
    1302     {
    1303       BPS[0] = baseline->second.first->second;
    1304       BPS[1] = baseline->second.second->second;
    1305       BLS[0] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount);
    1306       BPS[0] = A->second;
    1307       BPS[1] = baseline->second.second->second;
    1308       BLS[1] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount);
    1309       BPS[0] = baseline->second.first->second;
    1310       BPS[1] = A->second;
    1311       BLS[2] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount);
    1312 
    1313       // 4b3. insert created triangle
    1314       BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
    1315       TrianglesOnBoundary.insert(TrianglePair(TrianglesOnBoundaryCount, BTS));
    1316       TrianglesOnBoundaryCount++;
    1317       for (int i = 0; i < NDIM; i++)
    1318         {
    1319           LinesOnBoundary.insert(LinePair(LinesOnBoundaryCount, BTS->lines[i]));
    1320           LinesOnBoundaryCount++;
    1321         }
    1322 
    1323       Log() << Verbose(1) << "Starting triangle is " << *BTS << "." << endl;
    1324     }
    1325   else
    1326     {
    1327       eLog() << Verbose(0) << "No starting triangle found." << endl;
    1328     }
     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  }
    13291392}
    13301393;
     
    13451408void Tesselation::TesselateOnBoundary(const PointCloud * const cloud)
    13461409{
    1347         Info FunctionInfo(__func__);
     1410  Info FunctionInfo(__func__);
    13481411  bool flag;
    13491412  PointMap::iterator winner;
     
    13641427        // get peak point with respect to this base line's only triangle
    13651428        BTS = baseline->second->triangles.begin()->second; // there is only one triangle so far
    1366         Log() << Verbose(0) << "Current baseline is between " << *(baseline->second) << "." << endl;
     1429        DoLog(0) && (Log() << Verbose(0) << "Current baseline is between " << *(baseline->second) << "." << endl);
    13671430        for (int i = 0; i < 3; i++)
    13681431          if ((BTS->endpoints[i] != baseline->second->endpoints[0]) && (BTS->endpoints[i] != baseline->second->endpoints[1]))
    13691432            peak = BTS->endpoints[i];
    1370         Log() << Verbose(1) << " and has peak " << *peak << "." << endl;
     1433        DoLog(1) && (Log() << Verbose(1) << " and has peak " << *peak << "." << endl);
    13711434
    13721435        // prepare some auxiliary vectors
     
    13831446          CenterVector.AddVector(BTS->endpoints[i]->node->node);
    13841447        CenterVector.Scale(1. / 3.);
    1385         Log() << Verbose(2) << "CenterVector of base triangle is " << CenterVector << endl;
     1448        DoLog(2) && (Log() << Verbose(2) << "CenterVector of base triangle is " << CenterVector << endl);
    13861449
    13871450        // normal vector of triangle
     
    13901453        BTS->GetNormalVector(NormalVector);
    13911454        NormalVector.CopyVector(&BTS->NormalVector);
    1392         Log() << Verbose(2) << "NormalVector of base triangle is " << NormalVector << endl;
     1455        DoLog(2) && (Log() << Verbose(2) << "NormalVector of base triangle is " << NormalVector << endl);
    13931456
    13941457        // vector in propagation direction (out of triangle)
     
    14001463        if (PropagationVector.ScalarProduct(&TempVector) > 0) // make sure normal propagation vector points outward from baseline
    14011464          PropagationVector.Scale(-1.);
    1402         Log() << Verbose(2) << "PropagationVector of base triangle is " << PropagationVector << endl;
     1465        DoLog(2) && (Log() << Verbose(2) << "PropagationVector of base triangle is " << PropagationVector << endl);
    14031466        winner = PointsOnBoundary.end();
    14041467
     
    14061469        for (PointMap::iterator target = PointsOnBoundary.begin(); target != PointsOnBoundary.end(); target++) {
    14071470          if ((target->second != baseline->second->endpoints[0]) && (target->second != baseline->second->endpoints[1])) { // don't take the same endpoints
    1408             Log() << Verbose(1) << "Target point is " << *(target->second) << ":" << endl;
     1471            DoLog(1) && (Log() << Verbose(1) << "Target point is " << *(target->second) << ":" << endl);
    14091472
    14101473            // first check direction, so that triangles don't intersect
     
    14131476            VirtualNormalVector.ProjectOntoPlane(&NormalVector);
    14141477            TempAngle = VirtualNormalVector.Angle(&PropagationVector);
    1415             Log() << Verbose(2) << "VirtualNormalVector is " << VirtualNormalVector << " and PropagationVector is " << PropagationVector << "." << endl;
    1416             if (TempAngle > (M_PI/2.)) { // no bends bigger than Pi/2 (90 degrees)
    1417               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);
    14181481              continue;
    14191482            } else
    1420               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);
    14211484
    14221485            // check first and second endpoint (if any connecting line goes to target has at least not more than 1 triangle)
     
    14241487            LineChecker[1] = baseline->second->endpoints[1]->lines.find(target->first);
    14251488            if (((LineChecker[0] != baseline->second->endpoints[0]->lines.end()) && (LineChecker[0]->second->triangles.size() == 2))) {
    1426               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);
    14271490              continue;
    14281491            }
    14291492            if (((LineChecker[1] != baseline->second->endpoints[1]->lines.end()) && (LineChecker[1]->second->triangles.size() == 2))) {
    1430               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);
    14311494              continue;
    14321495            }
     
    14341497            // check whether the envisaged triangle does not already exist (if both lines exist and have same endpoint)
    14351498            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)))) {
    1436               Log() << Verbose(4) << "Current target is peak!" << endl;
     1499              DoLog(4) && (Log() << Verbose(4) << "Current target is peak!" << endl);
    14371500              continue;
    14381501            }
     
    14451508            helper.ProjectOntoPlane(&TempVector);
    14461509            if (fabs(helper.NormSquared()) < MYEPSILON) {
    1447               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);
    14481511              continue;
    14491512            }
     
    14551518            TempVector.AddVector(baseline->second->endpoints[1]->node->node);
    14561519            TempVector.AddVector(target->second->node->node);
    1457             TempVector.Scale(1./3.);
     1520            TempVector.Scale(1. / 3.);
    14581521            TempVector.SubtractVector(Center);
    14591522            // make it always point outward
     
    14621525            // calculate angle
    14631526            TempAngle = NormalVector.Angle(&VirtualNormalVector);
    1464             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);
    14651528            if ((SmallestAngle - TempAngle) > MYEPSILON) { // set to new possible winner
    14661529              SmallestAngle = TempAngle;
    14671530              winner = target;
    1468               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);
    14691532            } else if (fabs(SmallestAngle - TempAngle) < MYEPSILON) { // check the angle to propagation, both possible targets are in one plane! (their normals have same angle)
    14701533              // hence, check the angles to some normal direction from our base line but in this common plane of both targets...
     
    14841547                SmallestAngle = TempAngle;
    14851548                winner = target;
    1486                 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);
    14871550              } else
    1488                 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);
    14891552            } else
    1490               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);
    14911554          }
    14921555        } // end of loop over all boundary points
     
    14941557        // 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
    14951558        if (winner != PointsOnBoundary.end()) {
    1496           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);
    14971560          // create the lins of not yet present
    14981561          BLS[0] = baseline->second;
     
    15241587          TrianglesOnBoundaryCount++;
    15251588        } else {
    1526           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);
    15271590        }
    15281591
    15291592        // 5d. If the set of lines is not yet empty, go to 5. and continue
    15301593      } else
    1531         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);
    15321595  } while (flag);
    15331596
    15341597  // exit
    1535   delete(Center);
    1536 };
     1598  delete (Center);
     1599}
     1600;
    15371601
    15381602/** Inserts all points outside of the tesselated surface into it by adding new triangles.
     
    15441608bool Tesselation::InsertStraddlingPoints(const PointCloud *cloud, const LinkedCell *LC)
    15451609{
    1546         Info FunctionInfo(__func__);
     1610  Info FunctionInfo(__func__);
    15471611  Vector Intersection, Normal;
    15481612  TesselPoint *Walker = NULL;
     
    15541618  cloud->GoToFirst();
    15551619  BoundaryPoints = new LinkedCell(this, 5.);
    1556   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
    15571621    if (AddFlag) {
    1558       delete(BoundaryPoints);
     1622      delete (BoundaryPoints);
    15591623      BoundaryPoints = new LinkedCell(this, 5.);
    15601624      AddFlag = false;
    15611625    }
    15621626    Walker = cloud->GetPoint();
    1563     Log() << Verbose(0) << "Current point is " << *Walker << "." << endl;
     1627    DoLog(0) && (Log() << Verbose(0) << "Current point is " << *Walker << "." << endl);
    15641628    // get the next triangle
    15651629    triangles = FindClosestTrianglesToVector(Walker->node, BoundaryPoints);
    15661630    BTS = triangles->front();
    15671631    if ((triangles == NULL) || (BTS->ContainsBoundaryPoint(Walker))) {
    1568       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);
    15691633      cloud->GoToNext();
    15701634      continue;
    15711635    } else {
    15721636    }
    1573     Log() << Verbose(0) << "Closest triangle is " << *BTS << "." << endl;
     1637    DoLog(0) && (Log() << Verbose(0) << "Closest triangle is " << *BTS << "." << endl);
    15741638    // get the intersection point
    15751639    if (BTS->GetIntersectionInsideTriangle(Center, Walker->node, &Intersection)) {
    1576       Log() << Verbose(0) << "We have an intersection at " << Intersection << "." << endl;
     1640      DoLog(0) && (Log() << Verbose(0) << "We have an intersection at " << Intersection << "." << endl);
    15771641      // we have the intersection, check whether in- or outside of boundary
    15781642      if ((Center->DistanceSquared(Walker->node) - Center->DistanceSquared(&Intersection)) < -MYEPSILON) {
    15791643        // inside, next!
    1580         Log() << Verbose(0) << *Walker << " is inside wrt triangle " << *BTS << "." << endl;
     1644        DoLog(0) && (Log() << Verbose(0) << *Walker << " is inside wrt triangle " << *BTS << "." << endl);
    15811645      } else {
    15821646        // outside!
    1583         Log() << Verbose(0) << *Walker << " is outside wrt triangle " << *BTS << "." << endl;
     1647        DoLog(0) && (Log() << Verbose(0) << *Walker << " is outside wrt triangle " << *BTS << "." << endl);
    15841648        class BoundaryLineSet *OldLines[3], *NewLines[3];
    15851649        class BoundaryPointSet *OldPoints[3], *NewPoint;
    15861650        // store the three old lines and old points
    1587         for (int i=0;i<3;i++) {
     1651        for (int i = 0; i < 3; i++) {
    15881652          OldLines[i] = BTS->lines[i];
    15891653          OldPoints[i] = BTS->endpoints[i];
     
    15911655        Normal.CopyVector(&BTS->NormalVector);
    15921656        // add Walker to boundary points
    1593         Log() << Verbose(0) << "Adding " << *Walker << " to BoundaryPoints." << endl;
     1657        DoLog(0) && (Log() << Verbose(0) << "Adding " << *Walker << " to BoundaryPoints." << endl);
    15941658        AddFlag = true;
    1595         if (AddBoundaryPoint(Walker,0))
     1659        if (AddBoundaryPoint(Walker, 0))
    15961660          NewPoint = BPS[0];
    15971661        else
    15981662          continue;
    15991663        // remove triangle
    1600         Log() << Verbose(0) << "Erasing triangle " << *BTS << "." << endl;
     1664        DoLog(0) && (Log() << Verbose(0) << "Erasing triangle " << *BTS << "." << endl);
    16011665        TrianglesOnBoundary.erase(BTS->Nr);
    1602         delete(BTS);
     1666        delete (BTS);
    16031667        // create three new boundary lines
    1604         for (int i=0;i<3;i++) {
     1668        for (int i = 0; i < 3; i++) {
    16051669          BPS[0] = NewPoint;
    16061670          BPS[1] = OldPoints[i];
    16071671          NewLines[i] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount);
    1608           Log() << Verbose(1) << "Creating new line " << *NewLines[i] << "." << endl;
     1672          DoLog(1) && (Log() << Verbose(1) << "Creating new line " << *NewLines[i] << "." << endl);
    16091673          LinesOnBoundary.insert(LinePair(LinesOnBoundaryCount, NewLines[i])); // no need for check for unique insertion as BPS[0] is definitely a new one
    16101674          LinesOnBoundaryCount++;
    16111675        }
    16121676        // create three new triangle with new point
    1613         for (int i=0;i<3;i++) { // find all baselines
     1677        for (int i = 0; i < 3; i++) { // find all baselines
    16141678          BLS[0] = OldLines[i];
    16151679          int n = 1;
    1616           for (int j=0;j<3;j++) {
     1680          for (int j = 0; j < 3; j++) {
    16171681            if (NewLines[j]->IsConnectedTo(BLS[0])) {
    1618               if (n>2) {
    1619                 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);
    16201684                return false;
    16211685              } else
     
    16281692          BTS->GetNormalVector(Normal);
    16291693          Normal.Scale(-1.);
    1630           Log() << Verbose(0) << "Created new triangle " << *BTS << "." << endl;
     1694          DoLog(0) && (Log() << Verbose(0) << "Created new triangle " << *BTS << "." << endl);
    16311695          TrianglesOnBoundary.insert(TrianglePair(TrianglesOnBoundaryCount, BTS));
    16321696          TrianglesOnBoundaryCount++;
     
    16341698      }
    16351699    } else { // something is wrong with FindClosestTriangleToPoint!
    1636       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);
    16371701      return false;
    16381702    }
     
    16411705
    16421706  // exit
    1643   delete(Center);
     1707  delete (Center);
    16441708  return true;
    1645 };
     1709}
     1710;
    16461711
    16471712/** Adds a point to the tesselation::PointsOnBoundary list.
     
    16521717bool Tesselation::AddBoundaryPoint(TesselPoint * Walker, const int n)
    16531718{
    1654         Info FunctionInfo(__func__);
     1719  Info FunctionInfo(__func__);
    16551720  PointTestPair InsertUnique;
    16561721  BPS[n] = new class BoundaryPointSet(Walker);
     
    16601725    return true;
    16611726  } else {
    1662     delete(BPS[n]);
     1727    delete (BPS[n]);
    16631728    BPS[n] = InsertUnique.first->second;
    16641729    return false;
     
    16741739void Tesselation::AddTesselationPoint(TesselPoint* Candidate, const int n)
    16751740{
    1676         Info FunctionInfo(__func__);
     1741  Info FunctionInfo(__func__);
    16771742  PointTestPair InsertUnique;
    16781743  TPS[n] = new class BoundaryPointSet(Candidate);
     
    16821747  } else {
    16831748    delete TPS[n];
    1684     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);
    16851750    TPS[n] = (InsertUnique.first)->second;
    16861751  }
     
    16951760void Tesselation::SetTesselationPoint(TesselPoint* Candidate, const int n) const
    16961761{
    1697         Info FunctionInfo(__func__);
     1762  Info FunctionInfo(__func__);
    16981763  PointMap::const_iterator FindPoint = PointsOnBoundary.find(Candidate->nr);
    16991764  if (FindPoint != PointsOnBoundary.end())
     
    17011766  else
    17021767    TPS[n] = NULL;
    1703 };
     1768}
     1769;
    17041770
    17051771/** Function tries to add line from current Points in BPS to BoundaryLineSet.
    17061772 * If successful it raises the line count and inserts the new line into the BLS,
    17071773 * 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
    17081776 * @param *a first endpoint
    17091777 * @param *b second endpoint
    17101778 * @param n index of Tesselation::BLS giving the line with both endpoints
    17111779 */
    1712 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{
    17131782  bool insertNewLine = true;
    1714 
    17151783  LineMap::iterator FindLine = a->lines.find(b->node->nr);
     1784  BoundaryLineSet *WinningLine = NULL;
    17161785  if (FindLine != a->lines.end()) {
    1717     Log() << Verbose(1) << "INFO: There is at least one line between " << *a << " and " << *b << ": " << *(FindLine->second) << "." << endl;
    1718 
    1719     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;
    17201789    FindPair = a->lines.equal_range(b->node->nr);
    17211790
    1722     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);
    17231793      // If there is a line with less than two attached triangles, we don't need a new line.
    1724       if (FindLine->second->triangles.size() < 2) {
    1725         insertNewLine = false;
    1726         Log() << Verbose(0) << "Using existing line " << *FindLine->second << endl;
    1727 
    1728         BPS[0] = FindLine->second->endpoints[0];
    1729         BPS[1] = FindLine->second->endpoints[1];
    1730         BLS[n] = FindLine->second;
    1731 
    1732         // remove existing line from OpenLines
    1733         CandidateMap::iterator CandidateLine = OpenLines.find(BLS[n]);
    1734         if (CandidateLine != OpenLines.end()) {
    1735           Log() << Verbose(1) << " Removing line from OpenLines." << endl;
    1736           delete(CandidateLine->second);
    1737           OpenLines.erase(CandidateLine);
    1738         } else {
    1739           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          }
    17401810        }
    1741 
    1742         break;
    17431811      }
    17441812    }
     
    17461814
    17471815  if (insertNewLine) {
    1748     AlwaysAddTesselationTriangleLine(a, b, n);
     1816    AddNewTesselationTriangleLine(a, b, n);
     1817  } else {
     1818    AddExistingTesselationTriangleLine(WinningLine, n);
    17491819  }
    17501820}
     
    17591829 * @param n index of Tesselation::BLS giving the line with both endpoints
    17601830 */
    1761 void Tesselation::AlwaysAddTesselationTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n)
    1762 {
    1763         Info FunctionInfo(__func__);
    1764   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);
    17651835  BPS[0] = a;
    17661836  BPS[1] = b;
    1767   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
    17681838  // add line to global map
    17691839  LinesOnBoundary.insert(LinePair(LinesOnBoundaryCount, BLS[n]));
     
    17721842  // also add to open lines
    17731843  CandidateForTesselation *CFT = new CandidateForTesselation(BLS[n]);
    1774   OpenLines.insert(pair< BoundaryLineSet *, CandidateForTesselation *> (BLS[n], CFT));
    1775 };
     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;
    17761873
    17771874/** Function adds triangle to global list.
     
    17801877void Tesselation::AddTesselationTriangle()
    17811878{
    1782         Info FunctionInfo(__func__);
    1783   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);
    17841881
    17851882  // add triangle to global map
     
    17911888
    17921889  // NOTE: add triangle to local maps is done in constructor of BoundaryTriangleSet
    1793 };
     1890}
     1891;
    17941892
    17951893/** Function adds triangle to global list.
     
    17991897void Tesselation::AddTesselationTriangle(const int nr)
    18001898{
    1801         Info FunctionInfo(__func__);
    1802   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);
    18031901
    18041902  // add triangle to global map
     
    18091907
    18101908  // NOTE: add triangle to local maps is done in constructor of BoundaryTriangleSet
    1811 };
     1909}
     1910;
    18121911
    18131912/** Removes a triangle from the tesselation.
     
    18181917void Tesselation::RemoveTesselationTriangle(class BoundaryTriangleSet *triangle)
    18191918{
    1820         Info FunctionInfo(__func__);
     1919  Info FunctionInfo(__func__);
    18211920  if (triangle == NULL)
    18221921    return;
    18231922  for (int i = 0; i < 3; i++) {
    18241923    if (triangle->lines[i] != NULL) {
    1825       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);
    18261925      triangle->lines[i]->triangles.erase(triangle->Nr);
    18271926      if (triangle->lines[i]->triangles.empty()) {
    1828           Log() << Verbose(0) << *triangle->lines[i] << " is no more attached to any triangle, erasing." << endl;
    1829           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]);
    18301929      } else {
    1831         Log() << Verbose(0) << *triangle->lines[i] << " is still attached to another triangle: ";
    1832         OpenLines.insert(pair< BoundaryLineSet *, CandidateForTesselation *> (triangle->lines[i], NULL));
    1833         for(TriangleMap::iterator TriangleRunner = triangle->lines[i]->triangles.begin(); TriangleRunner != triangle->lines[i]->triangles.end(); TriangleRunner++)
    1834           Log() << Verbose(0) << "[" << (TriangleRunner->second)->Nr << "|" << *((TriangleRunner->second)->endpoints[0]) << ", " << *((TriangleRunner->second)->endpoints[1]) << ", " << *((TriangleRunner->second)->endpoints[2]) << "] \t";
    1835         Log() << Verbose(0) << endl;
    1836 //        for (int j=0;j<2;j++) {
    1837 //          Log() << Verbose(0) << "Lines of endpoint " << *(triangle->lines[i]->endpoints[j]) << ": ";
    1838 //          for(LineMap::iterator LineRunner = triangle->lines[i]->endpoints[j]->lines.begin(); LineRunner != triangle->lines[i]->endpoints[j]->lines.end(); LineRunner++)
    1839 //            Log() << Verbose(0) << "[" << *(LineRunner->second) << "] \t";
    1840 //          Log() << Verbose(0) << endl;
    1841 //        }
     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        //        }
    18421941      }
    1843       triangle->lines[i] = NULL;  // free'd or not: disconnect
     1942      triangle->lines[i] = NULL; // free'd or not: disconnect
    18441943    } else
    1845       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);
    18461945  }
    18471946
    18481947  if (TrianglesOnBoundary.erase(triangle->Nr))
    1849     Log() << Verbose(0) << "Removing triangle Nr. " << triangle->Nr << "." << endl;
    1850   delete(triangle);
    1851 };
     1948    DoLog(0) && (Log() << Verbose(0) << "Removing triangle Nr. " << triangle->Nr << "." << endl);
     1949  delete (triangle);
     1950}
     1951;
    18521952
    18531953/** Removes a line from the tesselation.
     
    18571957void Tesselation::RemoveTesselationLine(class BoundaryLineSet *line)
    18581958{
    1859         Info FunctionInfo(__func__);
     1959  Info FunctionInfo(__func__);
    18601960  int Numbers[2];
    18611961
     
    18781978        for (LineMap::iterator Runner = erasor.first; Runner != erasor.second; Runner++)
    18791979          if ((*Runner).second == line) {
    1880             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);
    18811981            line->endpoints[i]->lines.erase(Runner);
    18821982            break;
     
    18841984      } else { // there's just a single line left
    18851985        if (line->endpoints[i]->lines.erase(line->Nr))
    1886           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);
    18871987      }
    18881988      if (line->endpoints[i]->lines.empty()) {
    1889         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);
    18901990        RemoveTesselationPoint(line->endpoints[i]);
    18911991      } else {
    1892         Log() << Verbose(0) << *line->endpoints[i] << " has still lines it's attached to: ";
    1893         for(LineMap::iterator LineRunner = line->endpoints[i]->lines.begin(); LineRunner != line->endpoints[i]->lines.end(); LineRunner++)
    1894           Log() << Verbose(0) << "[" << *(LineRunner->second) << "] \t";
    1895         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);
    18961996      }
    1897       line->endpoints[i] = NULL;  // free'd or not: disconnect
     1997      line->endpoints[i] = NULL; // free'd or not: disconnect
    18981998    } else
    1899       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);
    19002000  }
    19012001  if (!line->triangles.empty())
    1902     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);
    19032003
    19042004  if (LinesOnBoundary.erase(line->Nr))
    1905     Log() << Verbose(0) << "Removing line Nr. " << line->Nr << "." << endl;
    1906   delete(line);
    1907 };
     2005    DoLog(0) && (Log() << Verbose(0) << "Removing line Nr. " << line->Nr << "." << endl);
     2006  delete (line);
     2007}
     2008;
    19082009
    19092010/** Removes a point from the tesselation.
     
    19142015void Tesselation::RemoveTesselationPoint(class BoundaryPointSet *point)
    19152016{
    1916         Info FunctionInfo(__func__);
     2017  Info FunctionInfo(__func__);
    19172018  if (point == NULL)
    19182019    return;
    19192020  if (PointsOnBoundary.erase(point->Nr))
    1920     Log() << Verbose(0) << "Removing point Nr. " << point->Nr << "." << endl;
    1921   delete(point);
    1922 };
     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;
    19232070
    19242071/** Checks whether the triangle consisting of the three points is already present.
     
    19332080int Tesselation::CheckPresenceOfTriangle(TesselPoint *Candidates[3]) const
    19342081{
    1935         Info FunctionInfo(__func__);
     2082  Info FunctionInfo(__func__);
    19362083  int adjacentTriangleCount = 0;
    19372084  class BoundaryPointSet *Points[3];
     
    19552102          for (; (FindLine != Points[i]->lines.end()) && (FindLine->first == Points[j]->node->nr); FindLine++) {
    19562103            TriangleMap *triangles = &FindLine->second->triangles;
    1957             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);
    19582105            for (TriangleMap::const_iterator FindTriangle = triangles->begin(); FindTriangle != triangles->end(); FindTriangle++) {
    19592106              if (FindTriangle->second->IsPresentTupel(Points)) {
     
    19612108              }
    19622109            }
    1963             Log() << Verbose(1) << "end." << endl;
     2110            DoLog(1) && (Log() << Verbose(1) << "end." << endl);
    19642111          }
    19652112          // Only one of the triangle lines must be considered for the triangle count.
     
    19712118  }
    19722119
    1973   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);
    19742121  return adjacentTriangleCount;
    1975 };
     2122}
     2123;
    19762124
    19772125/** Checks whether the triangle consisting of the three points is already present.
     
    19852133class BoundaryTriangleSet * Tesselation::GetPresentTriangle(TesselPoint *Candidates[3])
    19862134{
    1987         Info FunctionInfo(__func__);
     2135  Info FunctionInfo(__func__);
    19882136  class BoundaryTriangleSet *triangle = NULL;
    19892137  class BoundaryPointSet *Points[3];
     
    20232171
    20242172  return triangle;
    2025 };
    2026 
     2173}
     2174;
    20272175
    20282176/** Finds the starting triangle for FindNonConvexBorder().
     
    20332181 * \param RADIUS radius of virtual rolling sphere
    20342182 * \param *LC LinkedCell structure with neighbouring TesselPoint's
    2035  */
    2036 void Tesselation::FindStartingTriangle(const double RADIUS, const LinkedCell *LC)
    2037 {
    2038         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__);
    20392188  int i = 0;
    20402189  TesselPoint* MaxPoint[NDIM];
    20412190  TesselPoint* Temporary;
    20422191  double maxCoordinate[NDIM];
    2043   BoundaryLineSet BaseLine;
     2192  BoundaryLineSet *BaseLine = NULL;
    20442193  Vector helper;
    20452194  Vector Chord;
    20462195  Vector SearchDirection;
    2047   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
    20482197  Vector CirclePlaneNormal; // normal vector defining the plane this circle lives in
    20492198  Vector SphereCenter;
     
    20582207
    20592208  // 1. searching topmost point with respect to each axis
    2060   for (int i=0;i<NDIM;i++) { // each axis
    2061     LC->n[i] = LC->N[i]-1; // current axis is topmost cell
    2062     for (LC->n[(i+1)%NDIM]=0;LC->n[(i+1)%NDIM]<LC->N[(i+1)%NDIM];LC->n[(i+1)%NDIM]++)
    2063       for (LC->n[(i+2)%NDIM]=0;LC->n[(i+2)%NDIM]<LC->N[(i+2)%NDIM];LC->n[(i+2)%NDIM]++) {
    2064         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();
    20652214        //Log() << Verbose(1) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;
    20662215        if (List != NULL) {
    2067           for (LinkedNodes::const_iterator Runner = List->begin();Runner != List->end();Runner++) {
     2216          for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    20682217            if ((*Runner)->node->x[i] > maxCoordinate[i]) {
    2069               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);
    20702219              maxCoordinate[i] = (*Runner)->node->x[i];
    20712220              MaxPoint[i] = (*Runner);
     
    20732222          }
    20742223        } else {
    2075           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);
    20762225        }
    20772226      }
    20782227  }
    20792228
    2080   Log() << Verbose(1) << "Found maximum coordinates: ";
    2081   for (int i=0;i<NDIM;i++)
    2082     Log() << Verbose(0) << i << ": " << *MaxPoint[i] << "\t";
    2083   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);
    20842233
    20852234  BTS = NULL;
    2086   for (int k=0;k<NDIM;k++) {
     2235  for (int k = 0; k < NDIM; k++) {
    20872236    NormalVector.Zero();
    20882237    NormalVector.x[k] = 1.;
    2089     BaseLine.endpoints[0] = new BoundaryPointSet(MaxPoint[k]);
    2090     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);
    20912241
    20922242    double ShortestAngle;
    20932243    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.
    20942244
    2095     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_...
    2096     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;
    20972250      continue;
    2098     BaseLine.endpoints[1] = new BoundaryPointSet(Temporary);
     2251    }
     2252    BaseLine->endpoints[1] = new BoundaryPointSet(Temporary);
    20992253
    21002254    // construct center of circle
    2101     CircleCenter.CopyVector(BaseLine.endpoints[0]->node->node);
    2102     CircleCenter.AddVector(BaseLine.endpoints[1]->node->node);
     2255    CircleCenter.CopyVector(BaseLine->endpoints[0]->node->node);
     2256    CircleCenter.AddVector(BaseLine->endpoints[1]->node->node);
    21032257    CircleCenter.Scale(0.5);
    21042258
    21052259    // construct normal vector of circle
    2106     CirclePlaneNormal.CopyVector(BaseLine.endpoints[0]->node->node);
    2107     CirclePlaneNormal.SubtractVector(BaseLine.endpoints[1]->node->node);
     2260    CirclePlaneNormal.CopyVector(BaseLine->endpoints[0]->node->node);
     2261    CirclePlaneNormal.SubtractVector(BaseLine->endpoints[1]->node->node);
    21082262
    21092263    double radius = CirclePlaneNormal.NormSquared();
    2110     double CircleRadius = sqrt(RADIUS*RADIUS - radius/4.);
     2264    double CircleRadius = sqrt(RADIUS * RADIUS - radius / 4.);
    21112265
    21122266    NormalVector.ProjectOntoPlane(&CirclePlaneNormal);
    21132267    NormalVector.Normalize();
    2114     ShortestAngle = 2.*M_PI; // This will indicate the quadrant.
     2268    ShortestAngle = 2. * M_PI; // This will indicate the quadrant.
    21152269
    21162270    SphereCenter.CopyVector(&NormalVector);
     
    21202274
    21212275    // look in one direction of baseline for initial candidate
    2122     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 ...
    21232277
    21242278    // adding point 1 and point 2 and add the line between them
    2125     Log() << Verbose(0) << "Coordinates of start node at " << *BaseLine.endpoints[0]->node << "." << endl;
    2126     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");
    21272281
    21282282    //Log() << Verbose(1) << "INFO: OldSphereCenter is at " << helper << ".\n";
    2129     CandidateForTesselation OptCandidates(&BaseLine);
     2283    CandidateForTesselation OptCandidates(BaseLine);
    21302284    FindThirdPointForTesselation(NormalVector, SearchDirection, SphereCenter, OptCandidates, NULL, RADIUS, LC);
    2131     Log() << Verbose(0) << "List of third Points is:" << endl;
     2285    DoLog(0) && (Log() << Verbose(0) << "List of third Points is:" << endl);
    21322286    for (TesselPointList::iterator it = OptCandidates.pointlist.begin(); it != OptCandidates.pointlist.end(); it++) {
    2133         Log() << Verbose(0) << " " << *(*it) << endl;
    2134     }
    2135 
    2136     BTS = NULL;
    2137     AddCandidateTriangle(OptCandidates);
    2138 //    delete(BaseLine.endpoints[0]);
    2139 //    delete(BaseLine.endpoints[1]);
    2140 
    2141     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;
    21422299      break;
    2143     else {
     2300    } else {
    21442301      // remove all candidates from the list and then the list itself
    21452302      OptCandidates.pointlist.clear();
    21462303    }
    2147   }
    2148 };
     2304    delete BaseLine;
     2305  }
     2306
     2307  return (BTS != NULL);
     2308}
     2309;
    21492310
    21502311/** Checks for a given baseline and a third point candidate whether baselines of the found triangle don't have even better candidates.
     
    22172378//            if (fabs(OldSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) {
    22182379//              // rotated the wrong way!
    2219 //              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);
    22202381//            }
    22212382//
     
    22742435//          }
    22752436//        } else {
    2276 //          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);
    22772438//        }
    22782439//      } else {
     
    22812442//    }
    22822443//  } else {
    2283 //    eLog() << Verbose(1) << "Could not find the TesselPoint " << *ThirdNode << "." << endl;
     2444//    DoeLog(1) && (eLog()<< Verbose(1) << "Could not find the TesselPoint " << *ThirdNode << "." << endl);
    22842445//  }
    22852446//
     
    22952456 * @param *LC LinkedCell structure with neighbouring points
    22962457 */
    2297 bool Tesselation::FindNextSuitableTriangle(CandidateForTesselation &CandidateLine, BoundaryTriangleSet &T, const double& RADIUS, const LinkedCell *LC)
    2298 {
    2299         Info FunctionInfo(__func__);
    2300   bool result = true;
    2301 
     2458bool Tesselation::FindNextSuitableTriangle(CandidateForTesselation &CandidateLine, const BoundaryTriangleSet &T, const double& RADIUS, const LinkedCell *LC)
     2459{
     2460  Info FunctionInfo(__func__);
    23022461  Vector CircleCenter;
    23032462  Vector CirclePlaneNormal;
     
    23052464  Vector SearchDirection;
    23062465  Vector helper;
    2307   TesselPoint *ThirdNode = NULL;
     2466  BoundaryPointSet *ThirdPoint = NULL;
    23082467  LineMap::iterator testline;
    23092468  double radius, CircleRadius;
    23102469
    2311   for (int i=0;i<3;i++)
    2312     if ((T.endpoints[i]->node != CandidateLine.BaseLine->endpoints[0]->node) && (T.endpoints[i]->node != CandidateLine.BaseLine->endpoints[1]->node)) {
    2313       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];
    23142473      break;
    23152474    }
    2316   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;
    23172478
    23182479  // construct center of circle
     
    23272488  // calculate squared radius of circle
    23282489  radius = CirclePlaneNormal.ScalarProduct(&CirclePlaneNormal);
    2329   if (radius/4. < RADIUS*RADIUS) {
     2490  if (radius / 4. < RADIUS * RADIUS) {
    23302491    // construct relative sphere center with now known CircleCenter
    23312492    RelativeSphereCenter.CopyVector(&T.SphereCenter);
    23322493    RelativeSphereCenter.SubtractVector(&CircleCenter);
    23332494
    2334     CircleRadius = RADIUS*RADIUS - radius/4.;
     2495    CircleRadius = RADIUS * RADIUS - radius / 4.;
    23352496    CirclePlaneNormal.Normalize();
    2336     Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl;
    2337 
    2338     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);
    23392500
    23402501    // construct SearchDirection and an "outward pointer"
    23412502    SearchDirection.MakeNormalVector(&RelativeSphereCenter, &CirclePlaneNormal);
    23422503    helper.CopyVector(&CircleCenter);
    2343     helper.SubtractVector(ThirdNode->node);
     2504    helper.SubtractVector(ThirdPoint->node->node);
    23442505    if (helper.ScalarProduct(&SearchDirection) < -HULLEPSILON)// ohoh, SearchDirection points inwards!
    23452506      SearchDirection.Scale(-1.);
    2346     Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl;
     2507    DoLog(1) && (Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl);
    23472508    if (fabs(RelativeSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) {
    23482509      // rotated the wrong way!
    2349       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);
    23502511    }
    23512512
    23522513    // add third point
    2353     FindThirdPointForTesselation(T.NormalVector, SearchDirection, T.SphereCenter, CandidateLine, ThirdNode, RADIUS, LC);
     2514    FindThirdPointForTesselation(T.NormalVector, SearchDirection, T.SphereCenter, CandidateLine, ThirdPoint, RADIUS, LC);
    23542515
    23552516  } else {
    2356     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);
    23572518  }
    23582519
    23592520  if (CandidateLine.pointlist.empty()) {
    2360     eLog() << Verbose(2) << "Could not find a suitable candidate." << endl;
     2521    DoeLog(2) && (eLog() << Verbose(2) << "Could not find a suitable candidate." << endl);
    23612522    return false;
    23622523  }
    2363   Log() << Verbose(0) << "Third Points are: " << endl;
     2524  DoLog(0) && (Log() << Verbose(0) << "Third Points are: " << endl);
    23642525  for (TesselPointList::iterator it = CandidateLine.pointlist.begin(); it != CandidateLine.pointlist.end(); ++it) {
    2365     Log() << Verbose(0) << " " << *(*it) << endl;
     2526    DoLog(0) && (Log() << Verbose(0) << " " << *(*it) << endl);
    23662527  }
    23672528
    23682529  return true;
    2369 
    2370 //  BoundaryLineSet *BaseRay = CandidateLine.BaseLine;
    2371 //  for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) {
    2372 //    Log() << Verbose(0) << "Third point candidate is " << *(*it)->point
    2373 //    << " with circumsphere's center at " << (*it)->OptCenter << "." << endl;
    2374 //    Log() << Verbose(0) << "Baseline is " << *BaseRay << endl;
    2375 //
    2376 //    // check whether all edges of the new triangle still have space for one more triangle (i.e. TriangleCount <2)
    2377 //    TesselPoint *PointCandidates[3];
    2378 //    PointCandidates[0] = (*it)->point;
    2379 //    PointCandidates[1] = BaseRay->endpoints[0]->node;
    2380 //    PointCandidates[2] = BaseRay->endpoints[1]->node;
    2381 //    int existentTrianglesCount = CheckPresenceOfTriangle(PointCandidates);
    2382 //
    2383 //    BTS = NULL;
    2384 //    // check for present edges and whether we reach better candidates from them
    2385 //    //if (HasOtherBaselineBetterCandidate(BaseRay, (*it)->point, ShortestAngle, RADIUS, LC) ) {
    2386 //    if (0) {
    2387 //      result = false;
    2388 //      break;
    2389 //    } else {
    2390 //      // If there is no triangle, add it regularly.
    2391 //      if (existentTrianglesCount == 0) {
    2392 //        AddTesselationPoint((*it)->point, 0);
    2393 //        AddTesselationPoint(BaseRay->endpoints[0]->node, 1);
    2394 //        AddTesselationPoint(BaseRay->endpoints[1]->node, 2);
    2395 //
    2396 //        if (CheckLineCriteriaForDegeneratedTriangle((const BoundaryPointSet ** const )TPS)) {
    2397 //          CandidateLine.point = (*it)->point;
    2398 //          CandidateLine.OptCenter.CopyVector(&((*it)->OptCenter));
    2399 //          CandidateLine.OtherOptCenter.CopyVector(&((*it)->OtherOptCenter));
    2400 //          CandidateLine.ShortestAngle = ShortestAngle;
    2401 //        } else {
    2402 ////          eLog() << Verbose(1) << "This triangle consisting of ";
    2403 ////          Log() << Verbose(0) << *(*it)->point << ", ";
    2404 ////          Log() << Verbose(0) << *BaseRay->endpoints[0]->node << " and ";
    2405 ////          Log() << Verbose(0) << *BaseRay->endpoints[1]->node << " ";
    2406 ////          Log() << Verbose(0) << "exists and is not added, as it 0x80000000006fc150(does not seem helpful!" << endl;
    2407 //          result = false;
    2408 //        }
    2409 //      } else if ((existentTrianglesCount >= 1) && (existentTrianglesCount <= 3)) { // If there is a planar region within the structure, we need this triangle a second time.
    2410 //          AddTesselationPoint((*it)->point, 0);
    2411 //          AddTesselationPoint(BaseRay->endpoints[0]->node, 1);
    2412 //          AddTesselationPoint(BaseRay->endpoints[1]->node, 2);
    2413 //
    2414 //          // 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)
    2415 //          // i.e. at least one of the three lines must be present with TriangleCount <= 1
    2416 //          if (CheckLineCriteriaForDegeneratedTriangle((const BoundaryPointSet ** const)TPS) || CandidateLine.BaseLine->skipped) {
    2417 //            CandidateLine.point = (*it)->point;
    2418 //            CandidateLine.OptCenter.CopyVector(&(*it)->OptCenter);
    2419 //            CandidateLine.OtherOptCenter.CopyVector(&(*it)->OtherOptCenter);
    2420 //            CandidateLine.ShortestAngle = ShortestAngle+2.*M_PI;
    2421 //
    2422 //          } else {
    2423 ////            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;
    2424 //            result = false;
    2425 //          }
    2426 //      } else {
    2427 ////        Log() << Verbose(1) << "This triangle consisting of ";
    2428 ////        Log() << Verbose(0) << *(*it)->point << ", ";
    2429 ////        Log() << Verbose(0) << *BaseRay->endpoints[0]->node << " and ";
    2430 ////        Log() << Verbose(0) << *BaseRay->endpoints[1]->node << " ";
    2431 ////        Log() << Verbose(0) << "is invalid!" << endl;
    2432 //        result = false;
    2433 //      }
    2434 //    }
    2435 //
    2436 //    // set baseline to new ray from ref point (here endpoints[0]->node) to current candidate (here (*it)->point))
    2437 //    BaseRay = BLS[0];
    2438 //    if ((BTS != NULL) && (BTS->NormalVector.NormSquared() < MYEPSILON)) {
    2439 //      eLog() << Verbose(1) << "Triangle " << *BTS << " has zero normal vector!" << endl;
    2440 //      exit(255);
    2441 //    }
    2442 //
    2443 //  }
    2444 //
    2445 //  // remove all candidates from the list and then the list itself
    2446 //  class CandidateForTesselation *remover = NULL;
    2447 //  for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) {
    2448 //    remover = *it;
    2449 //    delete(remover);
    2450 //  }
    2451 //  delete(OptCandidates);
    2452   return result;
    2453 };
     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;
    24542557
    24552558/** Adds the present line and candidate point from \a &CandidateLine to the Tesselation.
    24562559 * \param CandidateLine triangle to add
    2457  * \NOTE we need the copy operator here as the original CandidateForTesselation is removed in AddTesselationLine()
    2458  */
    2459 void Tesselation::AddCandidateTriangle(CandidateForTesselation CandidateLine)
    2460 {
    2461         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__);
    24622568  Vector Center;
    24632569  TesselPoint * const TurningPoint = CandidateLine.BaseLine->endpoints[0]->node;
     2570  TesselPointList::iterator Runner;
     2571  TesselPointList::iterator Sprinter;
    24642572
    24652573  // fill the set of neighbours
     
    24702578  TesselPointList *connectedClosestPoints = GetCircleOfSetOfPoints(&SetOfNeighbours, TurningPoint, CandidateLine.BaseLine->endpoints[1]->node->node);
    24712579
     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
    24722584  // go through all angle-sorted candidates (in degenerate n-nodes case we may have to add multiple triangles)
    2473   Log() << Verbose(0) << "List of Candidates for Turning Point: " << *TurningPoint << "." << endl;
    2474   for (TesselPointList::iterator TesselRunner = connectedClosestPoints->begin(); TesselRunner != connectedClosestPoints->end(); ++TesselRunner)
    2475     Log() << Verbose(0) << **TesselRunner << endl;
    2476   TesselPointList::iterator Runner = connectedClosestPoints->begin();
    2477   TesselPointList::iterator Sprinter = Runner;
     2585  Runner = connectedClosestPoints->begin();
     2586  Sprinter = Runner;
    24782587  Sprinter++;
    2479   while(Sprinter != connectedClosestPoints->end()) {
    2480     // add the points
     2588  while (Sprinter != connectedClosestPoints->end()) {
     2589    DoLog(0) && (Log() << Verbose(0) << "Current Runner is " << *(*Runner) << " and sprinter is " << *(*Sprinter) << "." << endl);
     2590
    24812591    AddTesselationPoint(TurningPoint, 0);
    2482     AddTesselationPoint((*Runner), 1);
    2483     AddTesselationPoint((*Sprinter), 2);
    2484 
    2485     // add the lines
    2486     AddTesselationLine(TPS[0], TPS[1], 0);
    2487     AddTesselationLine(TPS[0], TPS[2], 1);
    2488     AddTesselationLine(TPS[1], TPS[2], 2);
    2489 
    2490     // add the triangles
    2491     BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
    2492     AddTesselationTriangle();
    2493     BTS->GetCenter(&Center);
    2494     Center.SubtractVector(&CandidateLine.OptCenter);
    2495     BTS->SphereCenter.CopyVector(&CandidateLine.OptCenter);
    2496     BTS->GetNormalVector(Center);
    2497 
    2498     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
    24992597    Runner = Sprinter;
    25002598    Sprinter++;
    2501     Log() << Verbose(0) << "Current Runner is " << **Runner << "." << endl;
    2502     if (Sprinter != connectedClosestPoints->end())
    2503       Log() << Verbose(0) << " There are still more triangles to add." << endl;
    2504   }
    2505   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);
    25062622};
     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;
    25072770
    25082771/** Checks whether the quadragon of the two triangles connect to \a *Base is convex.
     
    25152778class BoundaryPointSet *Tesselation::IsConvexRectangle(class BoundaryLineSet *Base)
    25162779{
    2517         Info FunctionInfo(__func__);
     2780  Info FunctionInfo(__func__);
    25182781  class BoundaryPointSet *Spot = NULL;
    25192782  class BoundaryLineSet *OtherBase;
    25202783  Vector *ClosestPoint;
    25212784
    2522   int m=0;
    2523   for(TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++)
    2524     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
    25252788      if (!Base->ContainsBoundaryPoint(runner->second->endpoints[j])) // and neither of its endpoints
    25262789        BPS[m++] = runner->second->endpoints[j];
    2527   OtherBase = new class BoundaryLineSet(BPS,-1);
    2528 
    2529   Log() << Verbose(1) << "INFO: Current base line is " << *Base << "." << endl;
    2530   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);
    25312794
    25322795  // get the closest point on each line to the other line
     
    25342797
    25352798  // delete the temporary other base line
    2536   delete(OtherBase);
     2799  delete (OtherBase);
    25372800
    25382801  // get the distance vector from Base line to OtherBase line
     
    25412804  BaseLine.CopyVector(Base->endpoints[1]->node->node);
    25422805  BaseLine.SubtractVector(Base->endpoints[0]->node->node);
    2543   for (int i=0;i<2;i++) {
     2806  for (int i = 0; i < 2; i++) {
    25442807    DistanceToIntersection[i].CopyVector(ClosestPoint);
    25452808    DistanceToIntersection[i].SubtractVector(Base->endpoints[i]->node->node);
    25462809    distance[i] = BaseLine.ScalarProduct(&DistanceToIntersection[i]);
    25472810  }
    2548   delete(ClosestPoint);
    2549   if ((distance[0] * distance[1]) > 0)  { // have same sign?
    2550     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);
    25512814    if (distance[0] < distance[1]) {
    25522815      Spot = Base->endpoints[0];
     
    25552818    }
    25562819    return Spot;
    2557   } else {  // different sign, i.e. we are in between
    2558     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);
    25592822    return NULL;
    25602823  }
    25612824
    2562 };
     2825}
     2826;
    25632827
    25642828void Tesselation::PrintAllBoundaryPoints(ofstream *out) const
    25652829{
    2566         Info FunctionInfo(__func__);
     2830  Info FunctionInfo(__func__);
    25672831  // print all lines
    2568   Log() << Verbose(0) << "Printing all boundary points for debugging:" << endl;
    2569   for (PointMap::const_iterator PointRunner = PointsOnBoundary.begin();PointRunner != PointsOnBoundary.end(); PointRunner++)
    2570     Log() << Verbose(0) << *(PointRunner->second) << endl;
    2571 };
     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;
    25722837
    25732838void Tesselation::PrintAllBoundaryLines(ofstream *out) const
    25742839{
    2575         Info FunctionInfo(__func__);
     2840  Info FunctionInfo(__func__);
    25762841  // print all lines
    2577   Log() << Verbose(0) << "Printing all boundary lines for debugging:" << endl;
     2842  DoLog(0) && (Log() << Verbose(0) << "Printing all boundary lines for debugging:" << endl);
    25782843  for (LineMap::const_iterator LineRunner = LinesOnBoundary.begin(); LineRunner != LinesOnBoundary.end(); LineRunner++)
    2579     Log() << Verbose(0) << *(LineRunner->second) << endl;
    2580 };
     2844    DoLog(0) && (Log() << Verbose(0) << *(LineRunner->second) << endl);
     2845}
     2846;
    25812847
    25822848void Tesselation::PrintAllBoundaryTriangles(ofstream *out) const
    25832849{
    2584         Info FunctionInfo(__func__);
     2850  Info FunctionInfo(__func__);
    25852851  // print all triangles
    2586   Log() << Verbose(0) << "Printing all boundary triangles for debugging:" << endl;
     2852  DoLog(0) && (Log() << Verbose(0) << "Printing all boundary triangles for debugging:" << endl);
    25872853  for (TriangleMap::const_iterator TriangleRunner = TrianglesOnBoundary.begin(); TriangleRunner != TrianglesOnBoundary.end(); TriangleRunner++)
    2588     Log() << Verbose(0) << *(TriangleRunner->second) << endl;
    2589 };
     2854    DoLog(0) && (Log() << Verbose(0) << *(TriangleRunner->second) << endl);
     2855}
     2856;
    25902857
    25912858/** For a given boundary line \a *Base and its two triangles, picks the central baseline that is "higher".
     
    25962863double Tesselation::PickFarthestofTwoBaselines(class BoundaryLineSet *Base)
    25972864{
    2598         Info FunctionInfo(__func__);
     2865  Info FunctionInfo(__func__);
    25992866  class BoundaryLineSet *OtherBase;
    26002867  Vector *ClosestPoint[2];
    26012868  double volume;
    26022869
    2603   int m=0;
    2604   for(TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++)
    2605     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
    26062873      if (!Base->ContainsBoundaryPoint(runner->second->endpoints[j])) // and neither of its endpoints
    26072874        BPS[m++] = runner->second->endpoints[j];
    2608   OtherBase = new class BoundaryLineSet(BPS,-1);
    2609 
    2610   Log() << Verbose(0) << "INFO: Current base line is " << *Base << "." << endl;
    2611   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);
    26122879
    26132880  // get the closest point on each line to the other line
     
    26242891
    26252892  // delete the temporary other base line and the closest points
    2626   delete(ClosestPoint[0]);
    2627   delete(ClosestPoint[1]);
    2628   delete(OtherBase);
     2893  delete (ClosestPoint[0]);
     2894  delete (ClosestPoint[1]);
     2895  delete (OtherBase);
    26292896
    26302897  if (Distance.NormSquared() < MYEPSILON) { // check for intersection
    2631     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);
    26322899    return false;
    26332900  } else { // check for sign against BaseLineNormal
     
    26352902    BaseLineNormal.Zero();
    26362903    if (Base->triangles.size() < 2) {
    2637       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);
    26382905      return 0.;
    26392906    }
    26402907    for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) {
    2641       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);
    26422909      BaseLineNormal.AddVector(&(runner->second->NormalVector));
    26432910    }
    2644     BaseLineNormal.Scale(1./2.);
     2911    BaseLineNormal.Scale(1. / 2.);
    26452912
    26462913    if (Distance.ScalarProduct(&BaseLineNormal) > MYEPSILON) { // Distance points outwards, hence OtherBase higher than Base -> flip
    2647       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);
    26482915      // calculate volume summand as a general tetraeder
    26492916      return volume;
    2650     } else {  // Base higher than OtherBase -> do nothing
    2651       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);
    26522919      return 0.;
    26532920    }
    26542921  }
    2655 };
     2922}
     2923;
    26562924
    26572925/** For a given baseline and its two connected triangles, flips the baseline.
     
    26642932class BoundaryLineSet * Tesselation::FlipBaseline(class BoundaryLineSet *Base)
    26652933{
    2666         Info FunctionInfo(__func__);
     2934  Info FunctionInfo(__func__);
    26672935  class BoundaryLineSet *OldLines[4], *NewLine;
    26682936  class BoundaryPointSet *OldPoints[2];
    26692937  Vector BaseLineNormal;
    26702938  int OldTriangleNrs[2], OldBaseLineNr;
    2671   int i,m;
     2939  int i, m;
    26722940
    26732941  // calculate NormalVector for later use
    26742942  BaseLineNormal.Zero();
    26752943  if (Base->triangles.size() < 2) {
    2676     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);
    26772945    return NULL;
    26782946  }
    26792947  for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) {
    2680     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);
    26812949    BaseLineNormal.AddVector(&(runner->second->NormalVector));
    26822950  }
    2683   BaseLineNormal.Scale(-1./2.); // has to point inside for BoundaryTriangleSet::GetNormalVector()
     2951  BaseLineNormal.Scale(-1. / 2.); // has to point inside for BoundaryTriangleSet::GetNormalVector()
    26842952
    26852953  // get the two triangles
    26862954  // gather four endpoints and four lines
    2687   for (int j=0;j<4;j++)
     2955  for (int j = 0; j < 4; j++)
    26882956    OldLines[j] = NULL;
    2689   for (int j=0;j<2;j++)
     2957  for (int j = 0; j < 2; j++)
    26902958    OldPoints[j] = NULL;
    2691   i=0;
    2692   m=0;
    2693   Log() << Verbose(0) << "The four old lines are: ";
    2694   for(TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++)
    2695     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
    26962964      if (runner->second->lines[j] != Base) { // pick not the central baseline
    26972965        OldLines[i++] = runner->second->lines[j];
    2698         Log() << Verbose(0) << *runner->second->lines[j] << "\t";
     2966        DoLog(0) && (Log() << Verbose(0) << *runner->second->lines[j] << "\t");
    26992967      }
    2700   Log() << Verbose(0) << endl;
    2701   Log() << Verbose(0) << "The two old points are: ";
    2702   for(TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++)
    2703     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
    27042972      if (!Base->ContainsBoundaryPoint(runner->second->endpoints[j])) { // and neither of its endpoints
    27052973        OldPoints[m++] = runner->second->endpoints[j];
    2706         Log() << Verbose(0) << *runner->second->endpoints[j] << "\t";
     2974        DoLog(0) && (Log() << Verbose(0) << *runner->second->endpoints[j] << "\t");
    27072975      }
    2708   Log() << Verbose(0) << endl;
     2976  DoLog(0) && (Log() << Verbose(0) << endl);
    27092977
    27102978  // check whether everything is in place to create new lines and triangles
    2711   if (i<4) {
    2712     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);
    27132981    return NULL;
    27142982  }
    2715   for (int j=0;j<4;j++)
     2983  for (int j = 0; j < 4; j++)
    27162984    if (OldLines[j] == NULL) {
    2717       eLog() << Verbose(1) << "We have not gathered enough baselines!" << endl;
     2985      DoeLog(1) && (eLog() << Verbose(1) << "We have not gathered enough baselines!" << endl);
    27182986      return NULL;
    27192987    }
    2720   for (int j=0;j<2;j++)
     2988  for (int j = 0; j < 2; j++)
    27212989    if (OldPoints[j] == NULL) {
    2722       eLog() << Verbose(1) << "We have not gathered enough endpoints!" << endl;
     2990      DoeLog(1) && (eLog() << Verbose(1) << "We have not gathered enough endpoints!" << endl);
    27232991      return NULL;
    27242992    }
    27252993
    27262994  // remove triangles and baseline removes itself
    2727   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);
    27282996  OldBaseLineNr = Base->Nr;
    2729   m=0;
    2730   for(TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) {
    2731     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);
    27323000    OldTriangleNrs[m++] = runner->second->Nr;
    27333001    RemoveTesselationTriangle(runner->second);
     
    27393007  NewLine = new class BoundaryLineSet(BPS, OldBaseLineNr);
    27403008  LinesOnBoundary.insert(LinePair(OldBaseLineNr, NewLine)); // no need for check for unique insertion as NewLine is definitely a new one
    2741   Log() << Verbose(0) << "INFO: Created new baseline " << *NewLine << "." << endl;
     3009  DoLog(0) && (Log() << Verbose(0) << "INFO: Created new baseline " << *NewLine << "." << endl);
    27423010
    27433011  // construct new triangles with flipped baseline
    2744   i=-1;
     3012  i = -1;
    27453013  if (OldLines[0]->IsConnectedTo(OldLines[2]))
    2746     i=2;
     3014    i = 2;
    27473015  if (OldLines[0]->IsConnectedTo(OldLines[3]))
    2748     i=3;
    2749   if (i!=-1) {
     3016    i = 3;
     3017  if (i != -1) {
    27503018    BLS[0] = OldLines[0];
    27513019    BLS[1] = OldLines[i];
     
    27543022    BTS->GetNormalVector(BaseLineNormal);
    27553023    AddTesselationTriangle(OldTriangleNrs[0]);
    2756     Log() << Verbose(0) << "INFO: Created new triangle " << *BTS << "." << endl;
    2757 
    2758     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]);
    27593027    BLS[1] = OldLines[1];
    27603028    BLS[2] = NewLine;
     
    27623030    BTS->GetNormalVector(BaseLineNormal);
    27633031    AddTesselationTriangle(OldTriangleNrs[1]);
    2764     Log() << Verbose(0) << "INFO: Created new triangle " << *BTS << "." << endl;
     3032    DoLog(0) && (Log() << Verbose(0) << "INFO: Created new triangle " << *BTS << "." << endl);
    27653033  } else {
    2766     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);
    27673035    return NULL;
    27683036  }
    27693037
    27703038  return NewLine;
    2771 };
    2772 
     3039}
     3040;
    27733041
    27743042/** Finds the second point of starting triangle.
     
    27823050void Tesselation::FindSecondPointForTesselation(TesselPoint* a, Vector Oben, TesselPoint*& OptCandidate, double Storage[3], double RADIUS, const LinkedCell *LC)
    27833051{
    2784         Info FunctionInfo(__func__);
     3052  Info FunctionInfo(__func__);
    27853053  Vector AngleCheck;
    27863054  class TesselPoint* Candidate = NULL;
     
    27913059  int Nupper[NDIM];
    27923060
    2793   if (LC->SetIndexToNode(a)) {  // get cell for the starting point
    2794     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
    27953063      N[i] = LC->n[i];
    27963064  } else {
    2797     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);
    27983066    return;
    27993067  }
    28003068  // then go through the current and all neighbouring cells and check the contained points for possible candidates
    2801   for (int i=0;i<NDIM;i++) {
    2802     Nlower[i] = ((N[i]-1) >= 0) ? N[i]-1 : 0;
    2803     Nupper[i] = ((N[i]+1) < LC->N[i]) ? N[i]+1 : LC->N[i]-1;
    2804   }
    2805   Log() << Verbose(0) << "LC Intervals from [" << N[0] << "<->" << LC->N[0] << ", " << N[1] << "<->" << LC->N[1] << ", " << N[2] << "<->" << LC->N[2] << "] :"
    2806     << " [" << 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);
    28073074
    28083075  for (LC->n[0] = Nlower[0]; LC->n[0] <= Nupper[0]; LC->n[0]++)
    28093076    for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
    28103077      for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
    2811         const LinkedNodes *List = LC->GetCurrentCell();
     3078        const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
    28123079        //Log() << Verbose(1) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;
    28133080        if (List != NULL) {
    2814           for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
     3081          for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    28153082            Candidate = (*Runner);
    28163083            // check if we only have one unique point yet ...
     
    28383105              norm = aCandidate.Norm();
    28393106              // second point shall have smallest angle with respect to Oben vector
    2840               if (norm < RADIUS*2.) {
     3107              if (norm < RADIUS * 2.) {
    28413108                angle = AngleCheck.Angle(&Oben);
    28423109                if (angle < Storage[0]) {
    28433110                  //Log() << Verbose(1) << "Old values of Storage: %lf %lf \n", Storage[0], Storage[1]);
    2844                   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");
    28453112                  OptCandidate = Candidate;
    28463113                  Storage[0] = angle;
     
    28573124          }
    28583125        } else {
    2859           Log() << Verbose(0) << "Linked cell list is empty." << endl;
     3126          DoLog(0) && (Log() << Verbose(0) << "Linked cell list is empty." << endl);
    28603127        }
    28613128      }
    2862 };
    2863 
     3129}
     3130;
    28643131
    28653132/** This recursive function finds a third point, to form a triangle with two given ones.
     
    28893156 * @param OldSphereCenter center of sphere for base triangle, relative to center of BaseLine, giving null angle for the parameter circle
    28903157 * @param CandidateLine CandidateForTesselation with the current base line and list of candidates and ShortestAngle
    2891  * @param ThirdNode third point to avoid in search
     3158 * @param ThirdPoint third point to avoid in search
    28923159 * @param RADIUS radius of sphere
    28933160 * @param *LC LinkedCell structure with neighbouring points
    28943161 */
    2895 void Tesselation::FindThirdPointForTesselation(Vector &NormalVector, Vector &SearchDirection, Vector &OldSphereCenter, CandidateForTesselation &CandidateLine, const class TesselPoint  * const ThirdNode, const double RADIUS, const LinkedCell *LC) const
    2896 {
    2897         Info FunctionInfo(__func__);
    2898   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
    28993166  Vector CirclePlaneNormal; // normal vector defining the plane this circle lives in
    29003167  Vector SphereCenter;
    2901   Vector NewSphereCenter;   // center of the sphere defined by the two points of BaseLine and the one of Candidate, first possibility
    2902   Vector OtherNewSphereCenter;   // center of the sphere defined by the two points of BaseLine and the one of Candidate, second possibility
    2903   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
    29043171  Vector helper, OptCandidateCenter, OtherOptCandidateCenter;
    29053172  Vector RelativeOldSphereCenter;
     
    29123179  TesselPoint *Candidate = NULL;
    29133180
    2914   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();
    29153187
    29163188  // construct center of circle
     
    29263198  RelativeOldSphereCenter.SubtractVector(&CircleCenter);
    29273199
    2928   // calculate squared radius TesselPoint *ThirdNode,f circle
    2929   radius = CirclePlaneNormal.NormSquared()/4.;
    2930   if (radius < RADIUS*RADIUS) {
    2931     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;
    29323204    CirclePlaneNormal.Normalize();
    2933     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);
    29343206
    29353207    // test whether old center is on the band's plane
    29363208    if (fabs(RelativeOldSphereCenter.ScalarProduct(&CirclePlaneNormal)) > HULLEPSILON) {
    2937       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);
    29383210      RelativeOldSphereCenter.ProjectOntoPlane(&CirclePlaneNormal);
    29393211    }
    29403212    radius = RelativeOldSphereCenter.NormSquared();
    29413213    if (fabs(radius - CircleRadius) < HULLEPSILON) {
    2942       Log() << Verbose(1) << "INFO: RelativeOldSphereCenter is at " << RelativeOldSphereCenter << "." << endl;
     3214      DoLog(1) && (Log() << Verbose(1) << "INFO: RelativeOldSphereCenter is at " << RelativeOldSphereCenter << "." << endl);
    29433215
    29443216      // check SearchDirection
    2945       Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl;
    2946       if (fabs(RelativeOldSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) {  // rotated the wrong way!
    2947         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);
    29483220      }
    29493221
    29503222      // get cell for the starting point
    29513223      if (LC->SetIndexToVector(&CircleCenter)) {
    2952         for(int i=0;i<NDIM;i++) // store indices of this cell
    2953         N[i] = LC->n[i];
     3224        for (int i = 0; i < NDIM; i++) // store indices of this cell
     3225          N[i] = LC->n[i];
    29543226        //Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl;
    29553227      } else {
    2956         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);
    29573229        return;
    29583230      }
    29593231      // then go through the current and all neighbouring cells and check the contained points for possible candidates
    29603232      //Log() << Verbose(1) << "LC Intervals:";
    2961       for (int i=0;i<NDIM;i++) {
    2962         Nlower[i] = ((N[i]-1) >= 0) ? N[i]-1 : 0;
    2963         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;
    29643236        //Log() << Verbose(0) << " [" << Nlower[i] << "," << Nupper[i] << "] ";
    29653237      }
     
    29683240        for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
    29693241          for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
    2970             const LinkedNodes *List = LC->GetCurrentCell();
     3242            const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
    29713243            //Log() << Verbose(1) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;
    29723244            if (List != NULL) {
    2973               for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
     3245              for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    29743246                Candidate = (*Runner);
    29753247
    29763248                // check for three unique points
    2977                 Log() << Verbose(2) << "INFO: Current Candidate is " << *Candidate << " for BaseLine " << *CandidateLine.BaseLine << " with OldSphereCenter " << OldSphereCenter << "." << endl;
    2978                 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)) {
    29793251
    29803252                  // find center on the plane
    29813253                  GetCenterofCircumcircle(&NewPlaneCenter, *CandidateLine.BaseLine->endpoints[0]->node->node, *CandidateLine.BaseLine->endpoints[1]->node->node, *Candidate->node);
    2982                   Log() << Verbose(1) << "INFO: NewPlaneCenter is " << NewPlaneCenter << "." << endl;
    2983 
    2984                   if (NewNormalVector.MakeNormalVector(CandidateLine.BaseLine->endpoints[0]->node->node, CandidateLine.BaseLine->endpoints[1]->node->node, Candidate->node)
    2985                   && (fabs(NewNormalVector.NormSquared()) > HULLEPSILON)
    2986                   ) {
    2987                     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);
    29883258                    radius = CandidateLine.BaseLine->endpoints[0]->node->node->DistanceSquared(&NewPlaneCenter);
    2989                     Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl;
    2990                     Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl;
    2991                     Log() << Verbose(1) << "INFO: Radius of CircumCenterCircle is " << radius << "." << endl;
    2992                     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) {
    29933263                      otherradius = CandidateLine.BaseLine->endpoints[1]->node->node->DistanceSquared(&NewPlaneCenter);
    2994                       if (fabs(radius - otherradius) > HULLEPSILON) {
    2995                         eLog() << Verbose(1) << "Distance to center of circumcircle is not the same from each corner of the triangle: " << fabs(radius-otherradius) << endl;
    2996                       }
    2997                       // construct both new centers
    2998                       NewSphereCenter.CopyVector(&NewPlaneCenter);
    2999                       OtherNewSphereCenter.CopyVector(&NewPlaneCenter);
    3000                       helper.CopyVector(&NewNormalVector);
    3001                       helper.Scale(sqrt(RADIUS*RADIUS - radius));
    3002                       Log() << Verbose(2) << "INFO: Distance of NewPlaneCenter " << NewPlaneCenter << " to either NewSphereCenter is " << helper.Norm() << " of vector " << helper << " with sphere radius " << RADIUS << "." << endl;
    3003                       NewSphereCenter.AddVector(&helper);
    3004                       Log() << Verbose(2) << "INFO: NewSphereCenter is at " << NewSphereCenter << "." << endl;
    3005                       // OtherNewSphereCenter is created by the same vector just in the other direction
    3006                       helper.Scale(-1.);
    3007                       OtherNewSphereCenter.AddVector(&helper);
    3008                       Log() << Verbose(2) << "INFO: OtherNewSphereCenter is at " << OtherNewSphereCenter << "." << endl;
    3009 
    3010                       alpha = GetPathLengthonCircumCircle(CircleCenter, CirclePlaneNormal, CircleRadius, NewSphereCenter, OldSphereCenter, NormalVector, SearchDirection);
    3011                       Otheralpha = GetPathLengthonCircumCircle(CircleCenter, CirclePlaneNormal, CircleRadius, OtherNewSphereCenter, OldSphereCenter, NormalVector, SearchDirection);
    3012                       alpha = min(alpha, Otheralpha);
    3013 
    3014                       // if there is a better candidate, drop the current list and add the new candidate
    3015                       // otherwise ignore the new candidate and keep the list
    3016                       if (CandidateLine.ShortestAngle > (alpha - HULLEPSILON)) {
    3017                         if (fabs(alpha - Otheralpha) > MYEPSILON) {
    3018                           CandidateLine.OptCenter.CopyVector(&NewSphereCenter);
    3019                           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);
    30203308                        } else {
    3021                           CandidateLine.OptCenter.CopyVector(&OtherNewSphereCenter);
    3022                           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                          }
    30233314                        }
    3024                         // if there is an equal candidate, add it to the list without clearing the list
    3025                         if ((CandidateLine.ShortestAngle - HULLEPSILON) < alpha) {
    3026                           CandidateLine.pointlist.push_back(Candidate);
    3027                           Log() << Verbose(0) << "ACCEPT: We have found an equally good candidate: " << *(Candidate) << " with "
    3028                             << alpha << " and circumsphere's center at " << CandidateLine.OptCenter << "." << endl;
    3029                         } else {
    3030                           // remove all candidates from the list and then the list itself
    3031                           CandidateLine.pointlist.clear();
    3032                           CandidateLine.pointlist.push_back(Candidate);
    3033                           Log() << Verbose(0) << "ACCEPT: We have found a better candidate: " << *(Candidate) << " with "
    3034                             << alpha << " and circumsphere's center at " << CandidateLine.OptCenter << "." << endl;
    3035                         }
    3036                         CandidateLine.ShortestAngle = alpha;
    3037                         Log() << Verbose(0) << "INFO: There are " << CandidateLine.pointlist.size() << " candidates in the list now." << endl;
    30383315                      } else {
    3039                         if ((Candidate != NULL) && (CandidateLine.pointlist.begin() != CandidateLine.pointlist.end())) {
    3040                           Log() << Verbose(1) << "REJECT: Old candidate " << *(Candidate) << " with " << CandidateLine.ShortestAngle << " is better than new one " << *Candidate << " with " << alpha << " ." << endl;
    3041                         } else {
    3042                           Log() << Verbose(1) << "REJECT: Candidate " << *Candidate << " with " << alpha << " was rejected." << endl;
    3043                         }
     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);
    30443317                      }
    30453318                    } else {
    3046                       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);
    30473320                    }
    30483321                  } else {
    3049                     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);
    30503323                  }
    30513324                } else {
    3052                   if (ThirdNode != NULL) {
    3053                     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);
    30543327                  } else {
    3055                     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);
    30563329                  }
    30573330                }
     
    30603333          }
    30613334    } else {
    3062       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);
    30633336    }
    30643337  } else {
    3065     if (ThirdNode != NULL)
    3066       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);
    30673340    else
    3068       Log() << Verbose(1) << "Circumcircle for base line " << *CandidateLine.BaseLine << " is too big!" << endl;
    3069   }
    3070 
    3071   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);
    30723345  if (CandidateLine.pointlist.size() > 1) {
    30733346    CandidateLine.pointlist.unique();
    30743347    CandidateLine.pointlist.sort(); //SortCandidates);
    30753348  }
    3076 };
     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;
    30773356
    30783357/** Finds the endpoint two lines are sharing.
     
    30833362class BoundaryPointSet *Tesselation::GetCommonEndpoint(const BoundaryLineSet * line1, const BoundaryLineSet * line2) const
    30843363{
    3085         Info FunctionInfo(__func__);
     3364  Info FunctionInfo(__func__);
    30863365  const BoundaryLineSet * lines[2] = { line1, line2 };
    30873366  class BoundaryPointSet *node = NULL;
     
    30903369  for (int i = 0; i < 2; i++)
    30913370    // for both lines
    3092     for (int j = 0; j < 2; j++)
    3093       { // for both endpoints
    3094         OrderTest = OrderMap.insert(pair<int, class BoundaryPointSet *> (
    3095             lines[i]->endpoints[j]->Nr, lines[i]->endpoints[j]));
    3096         if (!OrderTest.second)
    3097           { // if insertion fails, we have common endpoint
    3098             node = OrderTest.first->second;
    3099             Log() << Verbose(1) << "Common endpoint of lines " << *line1
    3100                 << " and " << *line2 << " is: " << *node << "." << endl;
    3101             j = 2;
    3102             i = 2;
    3103             break;
    3104           }
     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;
    31053379      }
     3380    }
    31063381  return node;
    3107 };
     3382}
     3383;
    31083384
    31093385/** Finds the boundary points that are closest to a given Vector \a *x.
     
    31193395
    31203396  if (LinesOnBoundary.empty()) {
    3121     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);
    31223398    return NULL;
    31233399  }
     
    31253401  // gather all points close to the desired one
    31263402  LC->SetIndexToVector(x); // ignore status as we calculate bounds below sensibly
    3127   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
    31283404    N[i] = LC->n[i];
    3129   Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl;
    3130 
     3405  DoLog(1) && (Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl);
    31313406  DistanceToPointMap * points = new DistanceToPointMap;
    31323407  LC->GetNeighbourBounds(Nlower, Nupper);
     
    31353410    for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
    31363411      for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
    3137         const LinkedNodes *List = LC->GetCurrentCell();
     3412        const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
    31383413        //Log() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl;
    31393414        if (List != NULL) {
    3140           for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
     3415          for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    31413416            FindPoint = PointsOnBoundary.find((*Runner)->nr);
    31423417            if (FindPoint != PointsOnBoundary.end()) {
    3143               points->insert(DistanceToPointPair (FindPoint->second->node->node->DistanceSquared(x), FindPoint->second) );
    3144               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);
    31453420            }
    31463421          }
    31473422        } else {
    3148           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);
    31493424        }
    31503425      }
     
    31523427  // check whether we found some points
    31533428  if (points->empty()) {
    3154     eLog() << Verbose(1) << "There is no nearest point: too far away from the surface." << endl;
    3155     delete(points);
     3429    DoeLog(1) && (eLog() << Verbose(1) << "There is no nearest point: too far away from the surface." << endl);
     3430    delete (points);
    31563431    return NULL;
    31573432  }
    31583433  return points;
    3159 };
     3434}
     3435;
    31603436
    31613437/** Finds the boundary line that is closest to a given Vector \a *x.
     
    31673443{
    31683444  Info FunctionInfo(__func__);
    3169 
    31703445  // get closest points
    3171   DistanceToPointMap * points = FindClosestBoundaryPointsToVector(x,LC);
     3446  DistanceToPointMap * points = FindClosestBoundaryPointsToVector(x, LC);
    31723447  if (points == NULL) {
    3173     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);
    31743449    return NULL;
    31753450  }
    31763451
    31773452  // for each point, check its lines, remember closest
    3178   Log() << Verbose(1) << "Finding closest BoundaryLine to " << *x << " ... " << endl;
     3453  DoLog(1) && (Log() << Verbose(1) << "Finding closest BoundaryLine to " << *x << " ... " << endl);
    31793454  BoundaryLineSet *ClosestLine = NULL;
    31803455  double MinDistance = -1.;
     
    32043479        helper.SubtractVector(&Center);
    32053480        const double lengthB = helper.ScalarProduct(&BaseLine);
    3206         if (lengthB*lengthA < 0) { // if have different sign
     3481        if (lengthB * lengthA < 0) { // if have different sign
    32073482          ClosestLine = LineRunner->second;
    32083483          MinDistance = distance;
    3209           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);
    32103485        } else {
    3211           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);
    32123487        }
    32133488      } else {
    3214         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);
    32153490      }
    32163491    }
    32173492  }
    3218   delete(points);
     3493  delete (points);
    32193494  // check whether closest line is "too close" :), then it's inside
    32203495  if (ClosestLine == NULL) {
    3221     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);
    32223497    return NULL;
    32233498  }
    32243499  return ClosestLine;
    3225 };
     3500}
     3501;
    32263502
    32273503/** Finds the triangle that is closest to a given Vector \a *x.
     
    32323508TriangleList * Tesselation::FindClosestTrianglesToVector(const Vector *x, const LinkedCell* LC) const
    32333509{
    3234         Info FunctionInfo(__func__);
    3235 
    3236         // get closest points
    3237         DistanceToPointMap * points = FindClosestBoundaryPointsToVector(x,LC);
     3510  Info FunctionInfo(__func__);
     3511  // get closest points
     3512  DistanceToPointMap * points = FindClosestBoundaryPointsToVector(x, LC);
    32383513  if (points == NULL) {
    3239     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);
    32403515    return NULL;
    32413516  }
    32423517
    32433518  // for each point, check its lines, remember closest
    3244   Log() << Verbose(1) << "Finding closest BoundaryTriangle to " << *x << " ... " << endl;
     3519  DoLog(1) && (Log() << Verbose(1) << "Finding closest BoundaryTriangle to " << *x << " ... " << endl);
    32453520  LineSet ClosestLines;
    32463521  double MinDistance = 1e+16;
     
    32643539      const double lengthEndB = BaseLineIntersection.NormSquared();
    32653540
    3266       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
    32673542        const double lengthEnd = Min(lengthEndA, lengthEndB);
    32683543        if (lengthEnd - MinDistance < -MYEPSILON) { // new best line
     
    32703545          ClosestLines.insert(LineRunner->second);
    32713546          MinDistance = lengthEnd;
    3272           Log() << Verbose(1) << "ACCEPT: Line " << *LineRunner->second << " to endpoint " << *LineRunner->second->endpoints[0]->node << " is closer with " << lengthEnd << "." << endl;
    3273         } 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
    32743549          ClosestLines.insert(LineRunner->second);
    3275           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);
    32763551        } else { // line is worse
    3277           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);
    32783553        }
    32793554      } else { // intersection is closer, calculate
     
    32863561        const double distance = BaseLineIntersection.NormSquared();
    32873562        if (Center.NormSquared() > BaseLine.NormSquared()) {
    3288           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);
    32893564        }
    32903565        if ((ClosestLines.empty()) || (distance < MinDistance)) {
    32913566          ClosestLines.insert(LineRunner->second);
    32923567          MinDistance = distance;
    3293           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);
    32943569        } else {
    3295           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);
    32963571        }
    32973572      }
    32983573    }
    32993574  }
    3300   delete(points);
     3575  delete (points);
    33013576
    33023577  // check whether closest line is "too close" :), then it's inside
    33033578  if (ClosestLines.empty()) {
    3304     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);
    33053580    return NULL;
    33063581  }
     
    33083583  for (LineSet::iterator LineRunner = ClosestLines.begin(); LineRunner != ClosestLines.end(); LineRunner++)
    33093584    for (TriangleMap::iterator Runner = (*LineRunner)->triangles.begin(); Runner != (*LineRunner)->triangles.end(); Runner++) {
    3310     candidates->push_back(Runner->second);
    3311   }
     3585      candidates->push_back(Runner->second);
     3586    }
    33123587  return candidates;
    3313 };
     3588}
     3589;
    33143590
    33153591/** Finds closest triangle to a point.
     
    33223598class BoundaryTriangleSet * Tesselation::FindClosestTriangleToVector(const Vector *x, const LinkedCell* LC) const
    33233599{
    3324         Info FunctionInfo(__func__);
     3600  Info FunctionInfo(__func__);
    33253601  class BoundaryTriangleSet *result = NULL;
    33263602  TriangleList *triangles = FindClosestTrianglesToVector(x, LC);
     
    33333609
    33343610  // go through all and pick the one with the best alignment to x
    3335   double MinAlignment = 2.*M_PI;
     3611  double MinAlignment = 2. * M_PI;
    33363612  for (TriangleList::iterator Runner = triangles->begin(); Runner != triangles->end(); Runner++) {
    33373613    (*Runner)->GetCenter(&Center);
     
    33423618      result = *Runner;
    33433619      MinAlignment = Alignment;
    3344       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);
    33453621    } else {
    3346       Log() << Verbose(1) << "REJECT: Triangle " << *result << " is worse aligned with " << MinAlignment << "." << endl;
    3347     }
    3348   }
    3349   delete(triangles);
     3622      DoLog(1) && (Log() << Verbose(1) << "REJECT: Triangle " << *result << " is worse aligned with " << MinAlignment << "." << endl);
     3623    }
     3624  }
     3625  delete (triangles);
    33503626
    33513627  return result;
    3352 };
     3628}
     3629;
    33533630
    33543631/** Checks whether the provided Vector is within the Tesselation structure.
     
    33623639{
    33633640  Info FunctionInfo(__func__);
    3364   TriangleIntersectionList Intersections(&Point,this,LC);
     3641  TriangleIntersectionList Intersections(&Point, this, LC);
    33653642
    33663643  return Intersections.IsInside();
    3367 };
     3644}
     3645;
    33683646
    33693647/** Returns the distance to the surface given by the tesselation.
     
    33953673
    33963674  if (triangle == NULL) {// is boundary point or only point in point cloud?
    3397     Log() << Verbose(1) << "No triangle given!" << endl;
     3675    DoLog(1) && (Log() << Verbose(1) << "No triangle given!" << endl);
    33983676    return -1.;
    33993677  } else {
    3400     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);
    34013679  }
    34023680
    34033681  triangle->GetCenter(&Center);
    3404   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);
    34053683  DistanceToCenter.CopyVector(&Center);
    34063684  DistanceToCenter.SubtractVector(&Point);
    3407   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);
    34083686
    34093687  // check whether we are on boundary
     
    34143692    Center.SubtractVector(&triangle->NormalVector); // points towards MolCenter
    34153693    DistanceToCenter.AddVector(&triangle->NormalVector); // points outside
    3416     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);
    34173695    if (triangle->GetIntersectionInsideTriangle(&Center, &DistanceToCenter, &Intersection)) {
    3418       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);
    34193697      return 0.;
    34203698    } else {
    3421       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);
    34223700      return false;
    34233701    }
     
    34253703    // calculate smallest distance
    34263704    distance = triangle->GetClosestPointInsideTriangle(&Point, &Intersection);
    3427     Log() << Verbose(1) << "Closest point on triangle is " << Intersection << "." << endl;
     3705    DoLog(1) && (Log() << Verbose(1) << "Closest point on triangle is " << Intersection << "." << endl);
    34283706
    34293707    // then check direction to boundary
    34303708    if (DistanceToCenter.ScalarProduct(&triangle->NormalVector) > MYEPSILON) {
    3431       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);
    34323710      return -distance;
    34333711    } else {
    3434       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);
    34353713      return +distance;
    34363714    }
    34373715  }
    3438 };
     3716}
     3717;
    34393718
    34403719/** Calculates minimum distance from \a&Point to a tesselated surface.
     
    34473726{
    34483727  Info FunctionInfo(__func__);
    3449   TriangleIntersectionList Intersections(&Point,this,LC);
     3728  TriangleIntersectionList Intersections(&Point, this, LC);
    34503729
    34513730  return Intersections.GetSmallestDistance();
    3452 };
     3731}
     3732;
    34533733
    34543734/** Calculates minimum distance from \a&Point to a tesselated surface.
     
    34613741{
    34623742  Info FunctionInfo(__func__);
    3463   TriangleIntersectionList Intersections(&Point,this,LC);
     3743  TriangleIntersectionList Intersections(&Point, this, LC);
    34643744
    34653745  return Intersections.GetClosestTriangle();
    3466 };
     3746}
     3747;
    34673748
    34683749/** Gets all points connected to the provided point by triangulation lines.
     
    34743755TesselPointSet * Tesselation::GetAllConnectedPoints(const TesselPoint* const Point) const
    34753756{
    3476         Info FunctionInfo(__func__);
    3477         TesselPointSet *connectedPoints = new TesselPointSet;
     3757  Info FunctionInfo(__func__);
     3758  TesselPointSet *connectedPoints = new TesselPointSet;
    34783759  class BoundaryPointSet *ReferencePoint = NULL;
    34793760  TesselPoint* current;
    34803761  bool takePoint = false;
    3481 
    34823762  // find the respective boundary point
    34833763  PointMap::const_iterator PointRunner = PointsOnBoundary.find(Point->nr);
     
    34853765    ReferencePoint = PointRunner->second;
    34863766  } else {
    3487     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);
    34883768    ReferencePoint = NULL;
    34893769  }
     
    34913771  // little trick so that we look just through lines connect to the BoundaryPoint
    34923772  // OR fall-back to look through all lines if there is no such BoundaryPoint
    3493   const LineMap *Lines;;
     3773  const LineMap *Lines;
     3774  ;
    34943775  if (ReferencePoint != NULL)
    34953776    Lines = &(ReferencePoint->lines);
     
    34983779  LineMap::const_iterator findLines = Lines->begin();
    34993780  while (findLines != Lines->end()) {
    3500    takePoint = false;
    3501 
    3502    if (findLines->second->endpoints[0]->Nr == Point->nr) {
    3503      takePoint = true;
    3504      current = findLines->second->endpoints[1]->node;
    3505    } else if (findLines->second->endpoints[1]->Nr == Point->nr) {
    3506      takePoint = true;
    3507      current = findLines->second->endpoints[0]->node;
    3508    }
    3509 
    3510    if (takePoint) {
    3511      Log() << Verbose(1) << "INFO: Endpoint " << *current << " of line " << *(findLines->second) << " is enlisted." << endl;
    3512      connectedPoints->insert(current);
    3513    }
    3514 
    3515    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++;
    35163797  }
    35173798
    35183799  if (connectedPoints->empty()) { // if have not found any points
    3519     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);
    35203801    return NULL;
    35213802  }
    35223803
    35233804  return connectedPoints;
    3524 };
    3525 
     3805}
     3806;
    35263807
    35273808/** Gets all points connected to the provided point by triangulation lines, ordered such that we have the circle round the point.
     
    35393820TesselPointList * Tesselation::GetCircleOfConnectedTriangles(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector * const Reference) const
    35403821{
    3541         Info FunctionInfo(__func__);
     3822  Info FunctionInfo(__func__);
    35423823  map<double, TesselPoint*> anglesOfPoints;
    35433824  TesselPointList *connectedCircle = new TesselPointList;
     
    35463827  Vector OrthogonalVector;
    35473828  Vector helper;
    3548   const TesselPoint * const TrianglePoints[3] = {Point, NULL, NULL};
     3829  const TesselPoint * const TrianglePoints[3] = { Point, NULL, NULL };
    35493830  TriangleList *triangles = NULL;
    35503831
    35513832  if (SetOfNeighbours == NULL) {
    3552     eLog() << Verbose(2) << "Could not find any connected points!" << endl;
    3553     delete(connectedCircle);
     3833    DoeLog(2) && (eLog() << Verbose(2) << "Could not find any connected points!" << endl);
     3834    delete (connectedCircle);
    35543835    return NULL;
    35553836  }
     
    35613842      PlaneNormal.AddVector(&(*Runner)->NormalVector);
    35623843  } else {
    3563     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);
    35643845    performCriticalExit();
    35653846  }
    3566   PlaneNormal.Scale(1.0/triangles->size());
    3567   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);
    35683849  PlaneNormal.Normalize();
    35693850
     
    35743855    AngleZero.ProjectOntoPlane(&PlaneNormal);
    35753856  }
    3576   if ((Reference == NULL) || (AngleZero.NormSquared() < MYEPSILON )) {
    3577     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);
    35783859    AngleZero.CopyVector((*SetOfNeighbours->begin())->node);
    35793860    AngleZero.SubtractVector(Point->node);
    35803861    AngleZero.ProjectOntoPlane(&PlaneNormal);
    35813862    if (AngleZero.NormSquared() < MYEPSILON) {
    3582       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);
    35833864      performCriticalExit();
    35843865    }
    35853866  }
    3586   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);
    35873868  if (AngleZero.NormSquared() > MYEPSILON)
    35883869    OrthogonalVector.MakeNormalVector(&PlaneNormal, &AngleZero);
    35893870  else
    35903871    OrthogonalVector.MakeNormalVector(&PlaneNormal);
    3591   Log() << Verbose(1) << "INFO: OrthogonalVector on plane is " << OrthogonalVector << "." << endl;
     3872  DoLog(1) && (Log() << Verbose(1) << "INFO: OrthogonalVector on plane is " << OrthogonalVector << "." << endl);
    35923873
    35933874  // go through all connected points and calculate angle
     
    35973878    helper.ProjectOntoPlane(&PlaneNormal);
    35983879    double angle = GetAngle(helper, AngleZero, OrthogonalVector);
    3599     Log() << Verbose(0) << "INFO: Calculated angle is " << angle << " for point " << **listRunner << "." << endl;
    3600     anglesOfPoints.insert(pair<double, TesselPoint*>(angle, (*listRunner)));
    3601   }
    3602 
    3603   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++) {
    36043885    connectedCircle->push_back(AngleRunner->second);
    36053886  }
     
    36313912
    36323913  if (SetOfNeighbours == NULL) {
    3633     eLog() << Verbose(2) << "Could not find any connected points!" << endl;
    3634     delete(connectedCircle);
     3914    DoeLog(2) && (eLog() << Verbose(2) << "Could not find any connected points!" << endl);
     3915    delete (connectedCircle);
    36353916    return NULL;
    36363917  }
     
    36433924  }
    36443925
    3645   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);
    36463927  // calculate central point
    3647 
    36483928  TesselPointSet::const_iterator TesselA = SetOfNeighbours->begin();
    36493929  TesselPointSet::const_iterator TesselB = SetOfNeighbours->begin();
     
    36553935  while (TesselC != SetOfNeighbours->end()) {
    36563936    helper.MakeNormalVector((*TesselA)->node, (*TesselB)->node, (*TesselC)->node);
    3657     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);
    36583938    counter++;
    36593939    TesselA++;
     
    36643944  //Log() << Verbose(0) << "Summed vectors " << center << "; number of points " << connectedPoints.size()
    36653945  //  << "; scale factor " << counter;
    3666   PlaneNormal.Scale(1.0/(double)counter);
    3667 //  Log() << Verbose(1) << "INFO: Calculated center of all circle points is " << center << "." << endl;
    3668 //
    3669 //  // projection plane of the circle is at the closes Point and normal is pointing away from center of all circle points
    3670 //  PlaneNormal.CopyVector(Point->node);
    3671 //  PlaneNormal.SubtractVector(&center);
    3672 //  PlaneNormal.Normalize();
    3673   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);
    36743954
    36753955  // construct one orthogonal vector
     
    36793959    AngleZero.ProjectOntoPlane(&PlaneNormal);
    36803960  }
    3681   if ((Reference == NULL) || (AngleZero.NormSquared() < MYEPSILON )) {
    3682     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);
    36833963    AngleZero.CopyVector((*SetOfNeighbours->begin())->node);
    36843964    AngleZero.SubtractVector(Point->node);
    36853965    AngleZero.ProjectOntoPlane(&PlaneNormal);
    36863966    if (AngleZero.NormSquared() < MYEPSILON) {
    3687       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);
    36883968      performCriticalExit();
    36893969    }
    36903970  }
    3691   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);
    36923972  if (AngleZero.NormSquared() > MYEPSILON)
    36933973    OrthogonalVector.MakeNormalVector(&PlaneNormal, &AngleZero);
    36943974  else
    36953975    OrthogonalVector.MakeNormalVector(&PlaneNormal);
    3696   Log() << Verbose(1) << "INFO: OrthogonalVector on plane is " << OrthogonalVector << "." << endl;
     3976  DoLog(1) && (Log() << Verbose(1) << "INFO: OrthogonalVector on plane is " << OrthogonalVector << "." << endl);
    36973977
    36983978  // go through all connected points and calculate angle
    3699   pair <map<double, TesselPoint*>::iterator, bool > InserterTest;
     3979  pair<map<double, TesselPoint*>::iterator, bool> InserterTest;
    37003980  for (TesselPointSet::iterator listRunner = SetOfNeighbours->begin(); listRunner != SetOfNeighbours->end(); listRunner++) {
    37013981    helper.CopyVector((*listRunner)->node);
     
    37043984    double angle = GetAngle(helper, AngleZero, OrthogonalVector);
    37053985    if (angle > M_PI) // the correction is of no use here (and not desired)
    3706       angle = 2.*M_PI - angle;
    3707     Log() << Verbose(0) << "INFO: Calculated angle between " << helper << " and " << AngleZero << " is " << angle << " for point " << **listRunner << "." << endl;
    3708     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)));
    37093989    if (!InserterTest.second) {
    3710       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);
    37113991      performCriticalExit();
    37123992    }
    37133993  }
    37143994
    3715   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++) {
    37163996    connectedCircle->push_back(AngleRunner->second);
    37173997  }
     
    37284008ListOfTesselPointList * Tesselation::GetPathsOfConnectedPoints(const TesselPoint* const Point) const
    37294009{
    3730         Info FunctionInfo(__func__);
     4010  Info FunctionInfo(__func__);
    37314011  map<double, TesselPoint*> anglesOfPoints;
    3732   list< TesselPointList *> *ListOfPaths = new list< TesselPointList *>;
     4012  list<TesselPointList *> *ListOfPaths = new list<TesselPointList *> ;
    37334013  TesselPointList *connectedPath = NULL;
    37344014  Vector center;
     
    37424022  class BoundaryLineSet *CurrentLine = NULL;
    37434023  class BoundaryLineSet *StartLine = NULL;
    3744 
    37454024  // find the respective boundary point
    37464025  PointMap::const_iterator PointRunner = PointsOnBoundary.find(Point->nr);
     
    37484027    ReferencePoint = PointRunner->second;
    37494028  } else {
    3750     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);
    37514030    return NULL;
    37524031  }
    37534032
    3754   map <class BoundaryLineSet *, bool> TouchedLine;
    3755   map <class BoundaryTriangleSet *, bool> TouchedTriangle;
    3756   map <class BoundaryLineSet *, bool>::iterator LineRunner;
    3757   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;
    37584037  for (LineMap::iterator Runner = ReferencePoint->lines.begin(); Runner != ReferencePoint->lines.end(); Runner++) {
    3759     TouchedLine.insert( pair <class BoundaryLineSet *, bool>(Runner->second, false) );
     4038    TouchedLine.insert(pair<class BoundaryLineSet *, bool> (Runner->second, false));
    37604039    for (TriangleMap::iterator Sprinter = Runner->second->triangles.begin(); Sprinter != Runner->second->triangles.end(); Sprinter++)
    3761       TouchedTriangle.insert( pair <class BoundaryTriangleSet *, bool>(Sprinter->second, false) );
     4040      TouchedTriangle.insert(pair<class BoundaryTriangleSet *, bool> (Sprinter->second, false));
    37624041  }
    37634042  if (!ReferencePoint->lines.empty()) {
     
    37654044      LineRunner = TouchedLine.find(runner->second);
    37664045      if (LineRunner == TouchedLine.end()) {
    3767         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);
    37684047      } else if (!LineRunner->second) {
    37694048        LineRunner->second = true;
     
    37734052        StartLine = CurrentLine;
    37744053        CurrentPoint = CurrentLine->GetOtherEndpoint(ReferencePoint);
    3775         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);
    37764055        do {
    37774056          // push current one
    3778           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);
    37794058          connectedPath->push_back(CurrentPoint->node);
    37804059
    37814060          // find next triangle
    37824061          for (TriangleMap::iterator Runner = CurrentLine->triangles.begin(); Runner != CurrentLine->triangles.end(); Runner++) {
    3783             Log() << Verbose(1) << "INFO: Inspecting triangle " << *Runner->second << "." << endl;
     4062            DoLog(1) && (Log() << Verbose(1) << "INFO: Inspecting triangle " << *Runner->second << "." << endl);
    37844063            if ((Runner->second != triangle)) { // look for first triangle not equal to old one
    37854064              triangle = Runner->second;
     
    37884067                if (!TriangleRunner->second) {
    37894068                  TriangleRunner->second = true;
    3790                   Log() << Verbose(1) << "INFO: Connecting triangle is " << *triangle << "." << endl;
     4069                  DoLog(1) && (Log() << Verbose(1) << "INFO: Connecting triangle is " << *triangle << "." << endl);
    37914070                  break;
    37924071                } else {
    3793                   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);
    37944073                  triangle = NULL;
    37954074                }
    37964075              } else {
    3797                 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);
    37984077                triangle = NULL;
    37994078              }
     
    38034082            break;
    38044083          // find next line
    3805           for (int i=0;i<3;i++) {
     4084          for (int i = 0; i < 3; i++) {
    38064085            if ((triangle->lines[i] != CurrentLine) && (triangle->lines[i]->ContainsBoundaryPoint(ReferencePoint))) { // not the current line and still containing Point
    38074086              CurrentLine = triangle->lines[i];
    3808               Log() << Verbose(1) << "INFO: Connecting line is " << *CurrentLine << "." << endl;
     4087              DoLog(1) && (Log() << Verbose(1) << "INFO: Connecting line is " << *CurrentLine << "." << endl);
    38094088              break;
    38104089            }
     
    38124091          LineRunner = TouchedLine.find(CurrentLine);
    38134092          if (LineRunner == TouchedLine.end())
    3814             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);
    38154094          else
    38164095            LineRunner->second = true;
     
    38204099        } while (CurrentLine != StartLine);
    38214100        // last point is missing, as it's on start line
    3822         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);
    38234102        if (StartLine->GetOtherEndpoint(ReferencePoint)->node != connectedPath->back())
    38244103          connectedPath->push_back(StartLine->GetOtherEndpoint(ReferencePoint)->node);
     
    38264105        ListOfPaths->push_back(connectedPath);
    38274106      } else {
    3828         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);
    38294108      }
    38304109    }
    38314110  } else {
    3832     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);
    38334112  }
    38344113
     
    38444123ListOfTesselPointList * Tesselation::GetClosedPathsOfConnectedPoints(const TesselPoint* const Point) const
    38454124{
    3846         Info FunctionInfo(__func__);
     4125  Info FunctionInfo(__func__);
    38474126  list<TesselPointList *> *ListofPaths = GetPathsOfConnectedPoints(Point);
    3848   list<TesselPointList *> *ListofClosedPaths = new list<TesselPointList *>;
     4127  list<TesselPointList *> *ListofClosedPaths = new list<TesselPointList *> ;
    38494128  TesselPointList *connectedPath = NULL;
    38504129  TesselPointList *newPath = NULL;
    38514130  int count = 0;
    3852 
    3853 
    38544131  TesselPointList::iterator CircleRunner;
    38554132  TesselPointList::iterator CircleStart;
    38564133
    3857   for(list<TesselPointList *>::iterator ListRunner = ListofPaths->begin(); ListRunner != ListofPaths->end(); ListRunner++) {
     4134  for (list<TesselPointList *>::iterator ListRunner = ListofPaths->begin(); ListRunner != ListofPaths->end(); ListRunner++) {
    38584135    connectedPath = *ListRunner;
    38594136
    3860     Log() << Verbose(1) << "INFO: Current path is " << connectedPath << "." << endl;
     4137    DoLog(1) && (Log() << Verbose(1) << "INFO: Current path is " << connectedPath << "." << endl);
    38614138
    38624139    // go through list, look for reappearance of starting Point and count
    38634140    CircleStart = connectedPath->begin();
    3864 
    38654141    // go through list, look for reappearance of starting Point and create list
    38664142    TesselPointList::iterator Marker = CircleStart;
     
    38684144      if ((*CircleRunner == *CircleStart) && (CircleRunner != CircleStart)) { // is not the very first point
    38694145        // we have a closed circle from Marker to new Marker
    3870         Log() << Verbose(1) << count+1 << ". closed path consists of: ";
     4146        DoLog(1) && (Log() << Verbose(1) << count + 1 << ". closed path consists of: ");
    38714147        newPath = new TesselPointList;
    38724148        TesselPointList::iterator CircleSprinter = Marker;
    38734149        for (; CircleSprinter != CircleRunner; CircleSprinter++) {
    38744150          newPath->push_back(*CircleSprinter);
    3875           Log() << Verbose(0) << (**CircleSprinter) << " <-> ";
     4151          DoLog(0) && (Log() << Verbose(0) << (**CircleSprinter) << " <-> ");
    38764152        }
    3877         Log() << Verbose(0) << ".." << endl;
     4153        DoLog(0) && (Log() << Verbose(0) << ".." << endl);
    38784154        count++;
    38794155        Marker = CircleRunner;
     
    38844160    }
    38854161  }
    3886   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);
    38874163
    38884164  // delete list of paths
     
    38904166    connectedPath = *(ListofPaths->begin());
    38914167    ListofPaths->remove(connectedPath);
    3892     delete(connectedPath);
    3893   }
    3894   delete(ListofPaths);
     4168    delete (connectedPath);
     4169  }
     4170  delete (ListofPaths);
    38954171
    38964172  // exit
    38974173  return ListofClosedPaths;
    3898 };
    3899 
     4174}
     4175;
    39004176
    39014177/** Gets all belonging triangles for a given BoundaryPointSet.
     
    39064182TriangleSet *Tesselation::GetAllTriangles(const BoundaryPointSet * const Point) const
    39074183{
    3908         Info FunctionInfo(__func__);
    3909         TriangleSet *connectedTriangles = new TriangleSet;
     4184  Info FunctionInfo(__func__);
     4185  TriangleSet *connectedTriangles = new TriangleSet;
    39104186
    39114187  if (Point == NULL) {
    3912     eLog() << Verbose(1) << "Point given is NULL." << endl;
     4188    DoeLog(1) && (eLog() << Verbose(1) << "Point given is NULL." << endl);
    39134189  } else {
    39144190    // go through its lines and insert all triangles
    39154191    for (LineMap::const_iterator LineRunner = Point->lines.begin(); LineRunner != Point->lines.end(); LineRunner++)
    39164192      for (TriangleMap::iterator TriangleRunner = (LineRunner->second)->triangles.begin(); TriangleRunner != (LineRunner->second)->triangles.end(); TriangleRunner++) {
    3917       connectedTriangles->insert(TriangleRunner->second);
    3918     }
     4193        connectedTriangles->insert(TriangleRunner->second);
     4194      }
    39194195  }
    39204196
    39214197  return connectedTriangles;
    3922 };
    3923 
     4198}
     4199;
    39244200
    39254201/** Removes a boundary point from the envelope while keeping it closed.
     
    39344210 * \return volume added to the volume inside the tesselated surface by the removal
    39354211 */
    3936 double Tesselation::RemovePointFromTesselatedSurface(class BoundaryPointSet *point) {
     4212double Tesselation::RemovePointFromTesselatedSurface(class BoundaryPointSet *point)
     4213{
    39374214  class BoundaryLineSet *line = NULL;
    39384215  class BoundaryTriangleSet *triangle = NULL;
     
    39424219
    39434220  if (point == NULL) {
    3944     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);
    39454222    return 0.;
    39464223  } else
    3947     Log() << Verbose(0) << "Removing point " << *point << " from tesselated boundary ..." << endl;
     4224    DoLog(0) && (Log() << Verbose(0) << "Removing point " << *point << " from tesselated boundary ..." << endl);
    39484225
    39494226  // copy old location for the volume
     
    39524229  // get list of connected points
    39534230  if (point->lines.empty()) {
    3954     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);
    39554232    return 0.;
    39564233  }
     
    39614238  // gather all triangles
    39624239  for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++)
    3963     count+=LineRunner->second->triangles.size();
     4240    count += LineRunner->second->triangles.size();
    39644241  TriangleMap Candidates;
    39654242  for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) {
     
    39674244    for (TriangleMap::iterator TriangleRunner = line->triangles.begin(); TriangleRunner != line->triangles.end(); TriangleRunner++) {
    39684245      triangle = TriangleRunner->second;
    3969       Candidates.insert( TrianglePair (triangle->Nr, triangle) );
     4246      Candidates.insert(TrianglePair(triangle->Nr, triangle));
    39704247    }
    39714248  }
    39724249
    39734250  // remove all triangles
    3974   count=0;
     4251  count = 0;
    39754252  NormalVector.Zero();
    39764253  for (TriangleMap::iterator Runner = Candidates.begin(); Runner != Candidates.end(); Runner++) {
    3977     Log() << Verbose(1) << "INFO: Removing triangle " << *(Runner->second) << "." << endl;
     4254    DoLog(1) && (Log() << Verbose(1) << "INFO: Removing triangle " << *(Runner->second) << "." << endl);
    39784255    NormalVector.SubtractVector(&Runner->second->NormalVector); // has to point inward
    39794256    RemoveTesselationTriangle(Runner->second);
    39804257    count++;
    39814258  }
    3982   Log() << Verbose(1) << count << " triangles were removed." << endl;
     4259  DoLog(1) && (Log() << Verbose(1) << count << " triangles were removed." << endl);
    39834260
    39844261  list<TesselPointList *>::iterator ListAdvance = ListOfClosedPaths->begin();
     
    39894266  double smallestangle;
    39904267  Vector Point, Reference, OrthogonalVector;
    3991   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
    39924269    class TesselPoint *TriangleCandidates[3];
    39934270    count = 0;
    3994     for ( ; ListRunner != ListOfClosedPaths->end(); ListRunner = ListAdvance) { // go through all closed paths
     4271    for (; ListRunner != ListOfClosedPaths->end(); ListRunner = ListAdvance) { // go through all closed paths
    39954272      if (ListAdvance != ListOfClosedPaths->end())
    39964273        ListAdvance++;
    39974274
    39984275      connectedPath = *ListRunner;
    3999 
    40004276      // re-create all triangles by going through connected points list
    40014277      LineList NewLines;
    4002       for (;!connectedPath->empty();) {
     4278      for (; !connectedPath->empty();) {
    40034279        // search middle node with widest angle to next neighbours
    40044280        EndNode = connectedPath->end();
    40054281        smallestangle = 0.;
    40064282        for (MiddleNode = connectedPath->begin(); MiddleNode != connectedPath->end(); MiddleNode++) {
    4007           Log() << Verbose(1) << "INFO: MiddleNode is " << **MiddleNode << "." << endl;
     4283          DoLog(1) && (Log() << Verbose(1) << "INFO: MiddleNode is " << **MiddleNode << "." << endl);
    40084284          // construct vectors to next and previous neighbour
    40094285          StartNode = MiddleNode;
     
    40264302          angle = GetAngle(Point, Reference, OrthogonalVector);
    40274303          //if (angle < M_PI)  // no wrong-sided triangles, please?
    4028             if(fabs(angle - M_PI) < fabs(smallestangle - M_PI)) { // get straightest angle (i.e. construct those triangles with smallest area first)
    4029               smallestangle = angle;
    4030               EndNode = MiddleNode;
    4031             }
     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          }
    40324308        }
    40334309        MiddleNode = EndNode;
    40344310        if (MiddleNode == connectedPath->end()) {
    4035           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);
    40364312          performCriticalExit();
    40374313        }
     
    40434319        if (EndNode == connectedPath->end())
    40444320          EndNode = connectedPath->begin();
    4045         Log() << Verbose(2) << "INFO: StartNode is " << **StartNode << "." << endl;
    4046         Log() << Verbose(2) << "INFO: MiddleNode is " << **MiddleNode << "." << endl;
    4047         Log() << Verbose(2) << "INFO: EndNode is " << **EndNode << "." << endl;
    4048         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);
    40494325        TriangleCandidates[0] = *StartNode;
    40504326        TriangleCandidates[1] = *MiddleNode;
     
    40524328        triangle = GetPresentTriangle(TriangleCandidates);
    40534329        if (triangle != NULL) {
    4054           eLog() << Verbose(0) << "New triangle already present, skipping!" << endl;
     4330          DoeLog(0) && (eLog() << Verbose(0) << "New triangle already present, skipping!" << endl);
    40554331          StartNode++;
    40564332          MiddleNode++;
     
    40644340          continue;
    40654341        }
    4066         Log() << Verbose(3) << "Adding new triangle points."<< endl;
     4342        DoLog(3) && (Log() << Verbose(3) << "Adding new triangle points." << endl);
    40674343        AddTesselationPoint(*StartNode, 0);
    40684344        AddTesselationPoint(*MiddleNode, 1);
    40694345        AddTesselationPoint(*EndNode, 2);
    4070         Log() << Verbose(3) << "Adding new triangle lines."<< endl;
    4071         AddTesselationLine(TPS[0], TPS[1], 0);
    4072         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);
    40734349        NewLines.push_back(BLS[1]);
    4074         AddTesselationLine(TPS[1], TPS[2], 2);
     4350        AddTesselationLine(NULL, NULL, TPS[1], TPS[2], 2);
    40754351        BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
    40764352        BTS->GetNormalVector(NormalVector);
     
    40834359        // prepare nodes for next triangle
    40844360        StartNode = EndNode;
    4085         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);
    40864362        connectedPath->remove(*MiddleNode); // remove the middle node (it is surrounded by triangles)
    40874363        if (connectedPath->size() == 2) { // we are done
     
    40904366          break;
    40914367        } else if (connectedPath->size() < 2) { // something's gone wrong!
    4092           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);
    40934369          performCriticalExit();
    40944370        } else {
     
    41104386        do {
    41114387          maxgain = 0;
    4112           for(LineList::iterator Runner = NewLines.begin(); Runner != NewLines.end(); Runner++) {
     4388          for (LineList::iterator Runner = NewLines.begin(); Runner != NewLines.end(); Runner++) {
    41134389            tmp = PickFarthestofTwoBaselines(*Runner);
    41144390            if (maxgain < tmp) {
     
    41194395          if (maxgain != 0) {
    41204396            volume += maxgain;
    4121             Log() << Verbose(1) << "Flipping baseline with highest volume" << **Candidate << "." << endl;
     4397            DoLog(1) && (Log() << Verbose(1) << "Flipping baseline with highest volume" << **Candidate << "." << endl);
    41224398            OtherBase = FlipBaseline(*Candidate);
    41234399            NewLines.erase(Candidate);
     
    41284404
    41294405      ListOfClosedPaths->remove(connectedPath);
    4130       delete(connectedPath);
    4131     }
    4132     Log() << Verbose(0) << count << " triangles were created." << endl;
     4406      delete (connectedPath);
     4407    }
     4408    DoLog(0) && (Log() << Verbose(0) << count << " triangles were created." << endl);
    41334409  } else {
    41344410    while (!ListOfClosedPaths->empty()) {
     
    41364412      connectedPath = *ListRunner;
    41374413      ListOfClosedPaths->remove(connectedPath);
    4138       delete(connectedPath);
    4139     }
    4140     Log() << Verbose(0) << "No need to create any triangles." << endl;
    4141   }
    4142   delete(ListOfClosedPaths);
    4143 
    4144   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);
    41454421
    41464422  return volume;
    4147 };
    4148 
    4149 
     4423}
     4424;
    41504425
    41514426/**
     
    41594434TriangleList *Tesselation::FindTriangles(const TesselPoint* const Points[3]) const
    41604435{
    4161         Info FunctionInfo(__func__);
    4162         TriangleList *result = new TriangleList;
     4436  Info FunctionInfo(__func__);
     4437  TriangleList *result = new TriangleList;
    41634438  LineMap::const_iterator FindLine;
    41644439  TriangleMap::const_iterator FindTriangle;
     
    41844459      for (int i = 0; i < 3; i++) {
    41854460        if (TrianglePoints[i] != NULL) {
    4186           for (int j = i+1; j < 3; j++) {
     4461          for (int j = i + 1; j < 3; j++) {
    41874462            if (TrianglePoints[j] != NULL) {
    41884463              for (FindLine = TrianglePoints[i]->lines.find(TrianglePoints[j]->node->nr); // is a multimap!
    4189                   (FindLine != TrianglePoints[i]->lines.end()) && (FindLine->first == TrianglePoints[j]->node->nr);
    4190                   FindLine++) {
    4191                 for (FindTriangle = FindLine->second->triangles.begin();
    4192                     FindTriangle != FindLine->second->triangles.end();
    4193                     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++) {
    41944466                  if (FindTriangle->second->IsPresentTupel(TrianglePoints)) {
    41954467                    result->push_back(FindTriangle->second);
     
    42064478    case 1: // copy all triangles of the respective line
    42074479    {
    4208       int i=0;
     4480      int i = 0;
    42094481      for (; i < 3; i++)
    42104482        if (TrianglePoints[i] == NULL)
    42114483          break;
    4212       for (FindLine = TrianglePoints[(i+1)%3]->lines.find(TrianglePoints[(i+2)%3]->node->nr); // is a multimap!
    4213           (FindLine != TrianglePoints[(i+1)%3]->lines.end()) && (FindLine->first == TrianglePoints[(i+2)%3]->node->nr);
    4214           FindLine++) {
    4215         for (FindTriangle = FindLine->second->triangles.begin();
    4216             FindTriangle != FindLine->second->triangles.end();
    4217             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++) {
    42184487          if (FindTriangle->second->IsPresentTupel(TrianglePoints)) {
    42194488            result->push_back(FindTriangle->second);
     
    42254494    case 2: // copy all triangles of the respective point
    42264495    {
    4227       int i=0;
     4496      int i = 0;
    42284497      for (; i < 3; i++)
    42294498        if (TrianglePoints[i] != NULL)
     
    42434512    }
    42444513    default:
    4245       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);
    42464515      performCriticalExit();
    42474516      break;
     
    42514520}
    42524521
    4253 struct BoundaryLineSetCompare {
    4254   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  {
    42554526    int lowerNra = -1;
    42564527    int lowerNrb = -1;
     
    42704541    else if (a->endpoints[lowerNra] > b->endpoints[lowerNrb])
    42714542      return false;
    4272     else {  // both lower-numbered endpoints are the same ...
    4273      if (a->endpoints[(lowerNra+1)%2] < b->endpoints[(lowerNrb+1)%2])
    4274        return true;
    4275      else if (a->endpoints[(lowerNra+1)%2] > b->endpoints[(lowerNrb+1)%2])
    4276        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;
    42774548    }
    42784549    return false;
    4279   };
     4550  }
     4551  ;
    42804552};
    42814553
     
    42904562IndexToIndex * Tesselation::FindAllDegeneratedLines()
    42914563{
    4292         Info FunctionInfo(__func__);
    4293         UniqueLines AllLines;
     4564  Info FunctionInfo(__func__);
     4565  UniqueLines AllLines;
    42944566  IndexToIndex * DegeneratedLines = new IndexToIndex;
    42954567
    42964568  // sanity check
    42974569  if (LinesOnBoundary.empty()) {
    4298     eLog() << Verbose(2) << "FindAllDegeneratedTriangles() was called without any tesselation structure.";
     4570    DoeLog(2) && (eLog() << Verbose(2) << "FindAllDegeneratedTriangles() was called without any tesselation structure.");
    42994571    return DegeneratedLines;
    43004572  }
    4301 
    43024573  LineMap::iterator LineRunner1;
    4303   pair< UniqueLines::iterator, bool> tester;
     4574  pair<UniqueLines::iterator, bool> tester;
    43044575  for (LineRunner1 = LinesOnBoundary.begin(); LineRunner1 != LinesOnBoundary.end(); ++LineRunner1) {
    4305     tester = AllLines.insert( LineRunner1->second );
     4576    tester = AllLines.insert(LineRunner1->second);
    43064577    if (!tester.second) { // found degenerated line
    4307       DegeneratedLines->insert ( pair<int, int> (LineRunner1->second->Nr, (*tester.first)->Nr) );
    4308       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));
    43094580    }
    43104581  }
     
    43124583  AllLines.clear();
    43134584
    4314   Log() << Verbose(0) << "FindAllDegeneratedLines() found " << DegeneratedLines->size() << " lines." << endl;
     4585  DoLog(0) && (Log() << Verbose(0) << "FindAllDegeneratedLines() found " << DegeneratedLines->size() << " lines." << endl);
    43154586  IndexToIndex::iterator it;
    43164587  for (it = DegeneratedLines->begin(); it != DegeneratedLines->end(); it++) {
     
    43184589    const LineMap::const_iterator Line2 = LinesOnBoundary.find((*it).second);
    43194590    if (Line1 != LinesOnBoundary.end() && Line2 != LinesOnBoundary.end())
    4320       Log() << Verbose(0) << *Line1->second << " => " << *Line2->second << endl;
     4591      DoLog(0) && (Log() << Verbose(0) << *Line1->second << " => " << *Line2->second << endl);
    43214592    else
    4322       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);
    43234594  }
    43244595
     
    43344605IndexToIndex * Tesselation::FindAllDegeneratedTriangles()
    43354606{
    4336         Info FunctionInfo(__func__);
     4607  Info FunctionInfo(__func__);
    43374608  IndexToIndex * DegeneratedLines = FindAllDegeneratedLines();
    43384609  IndexToIndex * DegeneratedTriangles = new IndexToIndex;
    4339 
    43404610  TriangleMap::iterator TriangleRunner1, TriangleRunner2;
    43414611  LineMap::iterator Liner;
     
    43524622    for (TriangleRunner1 = line1->triangles.begin(); TriangleRunner1 != line1->triangles.end(); ++TriangleRunner1) {
    43534623      for (TriangleRunner2 = line2->triangles.begin(); TriangleRunner2 != line2->triangles.end(); ++TriangleRunner2) {
    4354         if ((TriangleRunner1->second != TriangleRunner2->second)
    4355           && (TriangleRunner1->second->IsPresentTupel(TriangleRunner2->second))) {
    4356           DegeneratedTriangles->insert( pair<int, int> (TriangleRunner1->second->Nr, TriangleRunner2->second->Nr) );
    4357           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));
    43584627        }
    43594628      }
    43604629    }
    43614630  }
    4362   delete(DegeneratedLines);
    4363 
    4364   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);
    43654634  IndexToIndex::iterator it;
    43664635  for (it = DegeneratedTriangles->begin(); it != DegeneratedTriangles->end(); it++)
    4367       Log() << Verbose(0) << (*it).first << " => " << (*it).second << endl;
     4636    DoLog(0) && (Log() << Verbose(0) << (*it).first << " => " << (*it).second << endl);
    43684637
    43694638  return DegeneratedTriangles;
     
    43764645void Tesselation::RemoveDegeneratedTriangles()
    43774646{
    4378         Info FunctionInfo(__func__);
     4647  Info FunctionInfo(__func__);
    43794648  IndexToIndex * DegeneratedTriangles = FindAllDegeneratedTriangles();
    43804649  TriangleMap::iterator finder;
    43814650  BoundaryTriangleSet *triangle = NULL, *partnerTriangle = NULL;
    4382   int count  = 0;
    4383 
    4384   for (IndexToIndex::iterator TriangleKeyRunner = DegeneratedTriangles->begin();
    4385     TriangleKeyRunner != DegeneratedTriangles->end(); ++TriangleKeyRunner
    4386   ) {
     4651  int count = 0;
     4652
     4653  for (IndexToIndex::iterator TriangleKeyRunner = DegeneratedTriangles->begin(); TriangleKeyRunner != DegeneratedTriangles->end(); ++TriangleKeyRunner) {
    43874654    finder = TrianglesOnBoundary.find(TriangleKeyRunner->first);
    43884655    if (finder != TrianglesOnBoundary.end())
     
    44014668        trianglesShareLine = trianglesShareLine || triangle->lines[i] == partnerTriangle->lines[j];
    44024669
    4403     if (trianglesShareLine
    4404       && (triangle->endpoints[1]->LinesCount > 2)
    4405       && (triangle->endpoints[2]->LinesCount > 2)
    4406       && (triangle->endpoints[0]->LinesCount > 2)
    4407     ) {
     4670    if (trianglesShareLine && (triangle->endpoints[1]->LinesCount > 2) && (triangle->endpoints[2]->LinesCount > 2) && (triangle->endpoints[0]->LinesCount > 2)) {
    44084671      // check whether we have to fix lines
    44094672      BoundaryTriangleSet *Othertriangle = NULL;
     
    44254688            // the line of triangle receives the degenerated ones
    44264689            triangle->lines[i]->triangles.erase(Othertriangle->Nr);
    4427             triangle->lines[i]->triangles.insert( TrianglePair( partnerTriangle->Nr, partnerTriangle) );
    4428             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++)
    44294692              if (triangle->lines[i] == Othertriangle->lines[k]) {
    44304693                Othertriangle->lines[k] = partnerTriangle->lines[j];
     
    44324695              }
    44334696            // the line of partnerTriangle receives the non-degenerated ones
    4434             partnerTriangle->lines[j]->triangles.erase( partnerTriangle->Nr);
    4435             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));
    44364699            partnerTriangle->lines[j] = triangle->lines[i];
    44374700          }
     
    44394702      // erase the pair
    44404703      count += (int) DegeneratedTriangles->erase(triangle->Nr);
    4441       Log() << Verbose(0) << "RemoveDegeneratedTriangles() removes triangle " << *triangle << "." << endl;
     4704      DoLog(0) && (Log() << Verbose(0) << "RemoveDegeneratedTriangles() removes triangle " << *triangle << "." << endl);
    44424705      RemoveTesselationTriangle(triangle);
    44434706      count += (int) DegeneratedTriangles->erase(partnerTriangle->Nr);
    4444       Log() << Verbose(0) << "RemoveDegeneratedTriangles() removes triangle " << *partnerTriangle << "." << endl;
     4707      DoLog(0) && (Log() << Verbose(0) << "RemoveDegeneratedTriangles() removes triangle " << *partnerTriangle << "." << endl);
    44454708      RemoveTesselationTriangle(partnerTriangle);
    44464709    } else {
    4447       Log() << Verbose(0) << "RemoveDegeneratedTriangles() does not remove triangle " << *triangle
    4448         << " and its partner " << *partnerTriangle << " because it is essential for at"
    4449         << " least one of the endpoints to be kept in the tesselation structure." << endl;
    4450     }
    4451   }
    4452   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);
    44534714  if (count > 0)
    44544715    LastTriangle = NULL;
    44554716
    4456   Log() << Verbose(0) << "RemoveDegeneratedTriangles() removed " << count << " triangles:" << endl;
     4717  DoLog(0) && (Log() << Verbose(0) << "RemoveDegeneratedTriangles() removed " << count << " triangles:" << endl);
    44574718}
    44584719
     
    44674728void Tesselation::AddBoundaryPointByDegeneratedTriangle(class TesselPoint *point, LinkedCell *LC)
    44684729{
    4469         Info FunctionInfo(__func__);
     4730  Info FunctionInfo(__func__);
    44704731  // find nearest boundary point
    44714732  class TesselPoint *BackupPoint = NULL;
     
    44804741    NearestBoundaryPoint = PointRunner->second;
    44814742  } else {
    4482     eLog() << Verbose(1) << "I cannot find the boundary point." << endl;
     4743    DoeLog(1) && (eLog() << Verbose(1) << "I cannot find the boundary point." << endl);
    44834744    return;
    44844745  }
    4485   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);
    44864747
    44874748  // go through its lines and find the best one to split
     
    44984759    CenterToPoint.SubtractVector(point->node);
    44994760    angle = CenterToPoint.Angle(&BaseLine);
    4500     if (fabs(angle - M_PI/2.) < fabs(BestAngle - M_PI/2.)) {
     4761    if (fabs(angle - M_PI / 2.) < fabs(BestAngle - M_PI / 2.)) {
    45014762      BestAngle = angle;
    45024763      BestLine = Runner->second;
     
    45084769  BestLine->triangles.erase(TempTriangle->Nr);
    45094770  int nr = -1;
    4510   for (int i=0;i<3; i++) {
     4771  for (int i = 0; i < 3; i++) {
    45114772    if (TempTriangle->lines[i] == BestLine) {
    45124773      nr = i;
     
    45164777
    45174778  // create new triangle to connect point (connects automatically with the missing spot of the chosen line)
    4518   Log() << Verbose(2) << "Adding new triangle points."<< endl;
     4779  DoLog(2) && (Log() << Verbose(2) << "Adding new triangle points." << endl);
    45194780  AddTesselationPoint((BestLine->endpoints[0]->node), 0);
    45204781  AddTesselationPoint((BestLine->endpoints[1]->node), 1);
    45214782  AddTesselationPoint(point, 2);
    4522   Log() << Verbose(2) << "Adding new triangle lines."<< endl;
    4523   AddTesselationLine(TPS[0], TPS[1], 0);
    4524   AddTesselationLine(TPS[0], TPS[2], 1);
    4525   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);
    45264787  BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
    45274788  BTS->GetNormalVector(TempTriangle->NormalVector);
    45284789  BTS->NormalVector.Scale(-1.);
    4529   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);
    45304791  AddTesselationTriangle();
    45314792
    45324793  // create other side of this triangle and close both new sides of the first created triangle
    4533   Log() << Verbose(2) << "Adding new triangle points."<< endl;
     4794  DoLog(2) && (Log() << Verbose(2) << "Adding new triangle points." << endl);
    45344795  AddTesselationPoint((BestLine->endpoints[0]->node), 0);
    45354796  AddTesselationPoint((BestLine->endpoints[1]->node), 1);
    45364797  AddTesselationPoint(point, 2);
    4537   Log() << Verbose(2) << "Adding new triangle lines."<< endl;
    4538   AddTesselationLine(TPS[0], TPS[1], 0);
    4539   AddTesselationLine(TPS[0], TPS[2], 1);
    4540   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);
    45414802  BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
    45424803  BTS->GetNormalVector(TempTriangle->NormalVector);
    4543   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);
    45444805  AddTesselationTriangle();
    45454806
    45464807  // add removed triangle to the last open line of the second triangle
    4547   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)
    45484809    if ((BTS->lines[i]->ContainsBoundaryPoint(BestLine->endpoints[0])) && (BTS->lines[i]->ContainsBoundaryPoint(BestLine->endpoints[1]))) {
    4549       if (BestLine == BTS->lines[i]){
    4550         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);
    45514812        performCriticalExit();
    45524813      }
    4553       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));
    45544815      TempTriangle->lines[nr] = BTS->lines[i];
    45554816      break;
    45564817    }
    45574818  }
    4558 };
     4819}
     4820;
    45594821
    45604822/** Writes the envelope to file.
     
    45654827void Tesselation::Output(const char *filename, const PointCloud * const cloud)
    45664828{
    4567         Info FunctionInfo(__func__);
     4829  Info FunctionInfo(__func__);
    45684830  ofstream *tempstream = NULL;
    45694831  string NameofTempFile;
     
    45714833
    45724834  if (LastTriangle != NULL) {
    4573     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);
    45744836    if (DoTecplotOutput) {
    45754837      string NameofTempFile(filename);
    45764838      NameofTempFile.append(NumberName);
    4577       for(size_t npos = NameofTempFile.find_first_of(' '); npos != string::npos; npos = NameofTempFile.find(' ', npos))
    4578       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);
    45794841      NameofTempFile.append(TecplotSuffix);
    4580       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");
    45814843      tempstream = new ofstream(NameofTempFile.c_str(), ios::trunc);
    45824844      WriteTecplotFile(tempstream, this, cloud, TriangleFilesWritten);
    45834845      tempstream->close();
    45844846      tempstream->flush();
    4585       delete(tempstream);
     4847      delete (tempstream);
    45864848    }
    45874849
     
    45894851      string NameofTempFile(filename);
    45904852      NameofTempFile.append(NumberName);
    4591       for(size_t npos = NameofTempFile.find_first_of(' '); npos != string::npos; npos = NameofTempFile.find(' ', npos))
    4592       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);
    45934855      NameofTempFile.append(Raster3DSuffix);
    4594       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");
    45954857      tempstream = new ofstream(NameofTempFile.c_str(), ios::trunc);
    45964858      WriteRaster3dFile(tempstream, this, cloud);
     
    45984860      tempstream->close();
    45994861      tempstream->flush();
    4600       delete(tempstream);
     4862      delete (tempstream);
    46014863    }
    46024864  }
    46034865  if (DoTecplotOutput || DoRaster3DOutput)
    46044866    TriangleFilesWritten++;
    4605 };
    4606 
    4607 struct BoundaryPolygonSetCompare {
    4608   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  {
    46094874    if (s1->endpoints.size() < s2->endpoints.size())
    46104875      return true;
     
    46354900{
    46364901  Info FunctionInfo(__func__);
    4637 
    46384902  /// 2. Go through all BoundaryPointSet's, check their triangles' NormalVector
    46394903  IndexToIndex *DegeneratedTriangles = FindAllDegeneratedTriangles();
    4640   set < BoundaryPointSet *> EndpointCandidateList;
    4641   pair < set < BoundaryPointSet *>::iterator, bool > InsertionTester;
    4642   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;
    46434907  for (PointMap::const_iterator Runner = PointsOnBoundary.begin(); Runner != PointsOnBoundary.end(); Runner++) {
    4644     Log() << Verbose(0) << "Current point is " << *Runner->second << "." << endl;
    4645     map < int, Vector *> TriangleVectors;
     4908    DoLog(0) && (Log() << Verbose(0) << "Current point is " << *Runner->second << "." << endl);
     4909    map<int, Vector *> TriangleVectors;
    46464910    // gather all NormalVectors
    4647     Log() << Verbose(1) << "Gathering triangles ..." << endl;
     4911    DoLog(1) && (Log() << Verbose(1) << "Gathering triangles ..." << endl);
    46484912    for (LineMap::const_iterator LineRunner = (Runner->second)->lines.begin(); LineRunner != (Runner->second)->lines.end(); LineRunner++)
    46494913      for (TriangleMap::const_iterator TriangleRunner = (LineRunner->second)->triangles.begin(); TriangleRunner != (LineRunner->second)->triangles.end(); TriangleRunner++) {
    46504914        if (DegeneratedTriangles->find(TriangleRunner->second->Nr) == DegeneratedTriangles->end()) {
    4651           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)));
    46524916          if (TriangleInsertionTester.second)
    4653             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);
    46544918        } else {
    4655           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);
    46564920        }
    46574921      }
    46584922    // check whether there are two that are parallel
    4659     Log() << Verbose(1) << "Finding two parallel triangles ..." << endl;
    4660     for (map < int, Vector *>::iterator VectorWalker = TriangleVectors.begin(); VectorWalker != TriangleVectors.end(); VectorWalker++)
    4661       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++)
    46624926        if (VectorWalker != VectorRunner) { // skip equals
    4663           const double SCP = VectorWalker->second->ScalarProduct(VectorRunner->second);  // ScalarProduct should result in -1. for degenerated triangles
    4664           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);
    46654929          if (fabs(SCP + 1.) < ParallelEpsilon) {
    46664930            InsertionTester = EndpointCandidateList.insert((Runner->second));
    46674931            if (InsertionTester.second)
    4668               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);
    46694933            // and break out of both loops
    46704934            VectorWalker = TriangleVectors.end();
     
    46744938        }
    46754939  }
    4676 
     4940  delete (DegeneratedTriangles);
    46774941  /// 3. Find connected endpoint candidates and put them into a polygon
    46784942  UniquePolygonSet ListofDegeneratedPolygons;
     
    46804944  BoundaryPointSet *OtherWalker = NULL;
    46814945  BoundaryPolygonSet *Current = NULL;
    4682   stack <BoundaryPointSet*> ToCheckConnecteds;
     4946  stack<BoundaryPointSet*> ToCheckConnecteds;
    46834947  while (!EndpointCandidateList.empty()) {
    46844948    Walker = *(EndpointCandidateList.begin());
    4685     if (Current == NULL) {  // create a new polygon with current candidate
    4686       Log() << Verbose(0) << "Starting new polygon set at point " << *Walker << endl;
     4949    if (Current == NULL) { // create a new polygon with current candidate
     4950      DoLog(0) && (Log() << Verbose(0) << "Starting new polygon set at point " << *Walker << endl);
    46874951      Current = new BoundaryPolygonSet;
    46884952      Current->endpoints.insert(Walker);
     
    46974961      for (LineMap::const_iterator LineWalker = Walker->lines.begin(); LineWalker != Walker->lines.end(); LineWalker++) {
    46984962        OtherWalker = (LineWalker->second)->GetOtherEndpoint(Walker);
    4699         Log() << Verbose(1) << "Checking " << *OtherWalker << endl;
    4700         set < BoundaryPointSet *>::iterator Finder = EndpointCandidateList.find(OtherWalker);
    4701         if (Finder != EndpointCandidateList.end()) {  // found a connected partner
    4702           Log() << Verbose(1) << " Adding to polygon." << endl;
     4963        DoLog(1) && (Log() << Verbose(1) << "Checking " << *OtherWalker << endl);
     4964        set<BoundaryPointSet *>::iterator Finder = EndpointCandidateList.find(OtherWalker);
     4965        if (Finder != EndpointCandidateList.end()) { // found a connected partner
     4966          DoLog(1) && (Log() << Verbose(1) << " Adding to polygon." << endl);
    47034967          Current->endpoints.insert(OtherWalker);
    4704           EndpointCandidateList.erase(Finder);  // remove from candidates
    4705           ToCheckConnecteds.push(OtherWalker);  // but check its partners too
     4968          EndpointCandidateList.erase(Finder); // remove from candidates
     4969          ToCheckConnecteds.push(OtherWalker); // but check its partners too
    47064970        } else {
    4707           Log() << Verbose(1) << " is not connected to " << *Walker << endl;
     4971          DoLog(1) && (Log() << Verbose(1) << " is not connected to " << *Walker << endl);
    47084972        }
    47094973      }
    47104974    }
    47114975
    4712     Log() << Verbose(0) << "Final polygon is " << *Current << endl;
     4976    DoLog(0) && (Log() << Verbose(0) << "Final polygon is " << *Current << endl);
    47134977    ListofDegeneratedPolygons.insert(Current);
    47144978    Current = NULL;
     
    47174981  const int counter = ListofDegeneratedPolygons.size();
    47184982
    4719   Log() << Verbose(0) << "The following " << counter << " degenerated polygons have been found: " << endl;
     4983  DoLog(0) && (Log() << Verbose(0) << "The following " << counter << " degenerated polygons have been found: " << endl);
    47204984  for (UniquePolygonSet::iterator PolygonRunner = ListofDegeneratedPolygons.begin(); PolygonRunner != ListofDegeneratedPolygons.end(); PolygonRunner++)
    4721     Log() << Verbose(0) << " " << **PolygonRunner << endl;
     4985    DoLog(0) && (Log() << Verbose(0) << " " << **PolygonRunner << endl);
    47224986
    47234987  /// 4. Go through all these degenerated polygons
    47244988  for (UniquePolygonSet::iterator PolygonRunner = ListofDegeneratedPolygons.begin(); PolygonRunner != ListofDegeneratedPolygons.end(); PolygonRunner++) {
    4725     stack <int> TriangleNrs;
     4989    stack<int> TriangleNrs;
    47264990    Vector NormalVector;
    47274991    /// 4a. Gather all triangles of this polygon
     
    47304994    // check whether number is bigger than 2, otherwise it's just a simply degenerated one and nothing to do.
    47314995    if (T->size() == 2) {
    4732       Log() << Verbose(1) << " Skipping degenerated polygon, is just a (already simply degenerated) triangle." << endl;
    4733       delete(T);
     4996      DoLog(1) && (Log() << Verbose(1) << " Skipping degenerated polygon, is just a (already simply degenerated) triangle." << endl);
     4997      delete (T);
    47344998      continue;
    47354999    }
     
    47405004    // connections to either polygon ...
    47415005    if (T->size() % 2 != 0) {
    4742       eLog() << Verbose(0) << " degenerated polygon contains an odd number of triangles, probably contains bridging non-degenerated ones, too!" << endl;
     5006      DoeLog(0) && (eLog() << Verbose(0) << " degenerated polygon contains an odd number of triangles, probably contains bridging non-degenerated ones, too!" << endl);
    47435007      performCriticalExit();
    47445008    }
    4745 
    4746     TriangleSet::iterator TriangleWalker = T->begin();  // is the inner iterator
     5009    TriangleSet::iterator TriangleWalker = T->begin(); // is the inner iterator
    47475010    /// 4a. Get NormalVector for one side (this is "front")
    47485011    NormalVector.CopyVector(&(*TriangleWalker)->NormalVector);
    4749     Log() << Verbose(1) << "\"front\" defining triangle is " << **TriangleWalker << " and Normal vector of \"front\" side is " << NormalVector << endl;
     5012    DoLog(1) && (Log() << Verbose(1) << "\"front\" defining triangle is " << **TriangleWalker << " and Normal vector of \"front\" side is " << NormalVector << endl);
    47505013    TriangleWalker++;
    47515014    TriangleSet::iterator TriangleSprinter = TriangleWalker; // is the inner advanced iterator
     
    47565019      triangle = *TriangleWalker;
    47575020      TriangleSprinter++;
    4758       Log() << Verbose(1) << "Current triangle to test for removal: " << *triangle << endl;
     5021      DoLog(1) && (Log() << Verbose(1) << "Current triangle to test for removal: " << *triangle << endl);
    47595022      if (triangle->NormalVector.ScalarProduct(&NormalVector) < 0) { // if from other side, then delete and remove from list
    4760         Log() << Verbose(1) << " Removing ... " << endl;
     5023        DoLog(1) && (Log() << Verbose(1) << " Removing ... " << endl);
    47615024        TriangleNrs.push(triangle->Nr);
    47625025        T->erase(TriangleWalker);
    47635026        RemoveTesselationTriangle(triangle);
    47645027      } else
    4765         Log() << Verbose(1) << " Keeping ... " << endl;
     5028        DoLog(1) && (Log() << Verbose(1) << " Keeping ... " << endl);
    47665029    }
    47675030    /// 4c. Copy all "front" triangles but with inverse NormalVector
    47685031    TriangleWalker = T->begin();
    4769     while (TriangleWalker != T->end()) {  // go through all front triangles
    4770       Log() << Verbose(1) << " Re-creating triangle " << **TriangleWalker << " with NormalVector " << (*TriangleWalker)->NormalVector << endl;
     5032    while (TriangleWalker != T->end()) { // go through all front triangles
     5033      DoLog(1) && (Log() << Verbose(1) << " Re-creating triangle " << **TriangleWalker << " with NormalVector " << (*TriangleWalker)->NormalVector << endl);
    47715034      for (int i = 0; i < 3; i++)
    47725035        AddTesselationPoint((*TriangleWalker)->endpoints[i]->node, i);
    4773       AddTesselationLine(TPS[0], TPS[1], 0);
    4774       AddTesselationLine(TPS[0], TPS[2], 1);
    4775       AddTesselationLine(TPS[1], TPS[2], 2);
     5036      AddTesselationLine(NULL, NULL, TPS[0], TPS[1], 0);
     5037      AddTesselationLine(NULL, NULL, TPS[0], TPS[2], 1);
     5038      AddTesselationLine(NULL, NULL, TPS[1], TPS[2], 2);
    47765039      if (TriangleNrs.empty())
    4777         eLog() << Verbose(0) << "No more free triangle numbers!" << endl;
     5040        DoeLog(0) && (eLog() << Verbose(0) << "No more free triangle numbers!" << endl);
    47785041      BTS = new BoundaryTriangleSet(BLS, TriangleNrs.top()); // copy triangle ...
    47795042      AddTesselationTriangle(); // ... and add
     
    47845047    }
    47855048    if (!TriangleNrs.empty()) {
    4786       eLog() << Verbose(0) << "There have been less triangles created than removed!" << endl;
    4787     }
    4788     delete(T);  // remove the triangleset
    4789   }
    4790 
     5049      DoeLog(0) && (eLog() << Verbose(0) << "There have been less triangles created than removed!" << endl);
     5050    }
     5051    delete (T); // remove the triangleset
     5052  }
    47915053  IndexToIndex * SimplyDegeneratedTriangles = FindAllDegeneratedTriangles();
    4792   Log() << Verbose(0) << "Final list of simply degenerated triangles found, containing " << SimplyDegeneratedTriangles->size() << " triangles:" << endl;
     5054  DoLog(0) && (Log() << Verbose(0) << "Final list of simply degenerated triangles found, containing " << SimplyDegeneratedTriangles->size() << " triangles:" << endl);
    47935055  IndexToIndex::iterator it;
    47945056  for (it = SimplyDegeneratedTriangles->begin(); it != SimplyDegeneratedTriangles->end(); it++)
    4795       Log() << Verbose(0) << (*it).first << " => " << (*it).second << endl;
    4796   delete(SimplyDegeneratedTriangles);
    4797 
     5057    DoLog(0) && (Log() << Verbose(0) << (*it).first << " => " << (*it).second << endl);
     5058  delete (SimplyDegeneratedTriangles);
    47985059  /// 5. exit
    47995060  UniquePolygonSet::iterator PolygonRunner;
    48005061  while (!ListofDegeneratedPolygons.empty()) {
    48015062    PolygonRunner = ListofDegeneratedPolygons.begin();
    4802     delete(*PolygonRunner);
     5063    delete (*PolygonRunner);
    48035064    ListofDegeneratedPolygons.erase(PolygonRunner);
    48045065  }
    48055066
    48065067  return counter;
    4807 };
     5068}
     5069;
  • src/tesselation.hpp

    r70378e rd6c485  
    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]);
     
    363375
    364376    //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);
    365378};
    366379
  • src/tesselationhelpers.cpp

    r70378e rd6c485  
    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/triangleintersectionlist.cpp

    r70378e rd6c485  
    119119  DistanceToPointMap * points = Tess->FindClosestBoundaryPointsToVector(Point,Vicinity);
    120120  if (points == NULL) {
    121     eLog() << Verbose(1) << "There is no nearest point: too far away from the surface." << endl;
     121    DoeLog(1) && (eLog()<< Verbose(1) << "There is no nearest point: too far away from the surface." << endl);
    122122    return;
    123123  }
     
    135135    Intersection = new Vector;
    136136    (*TriangleRunner)->GetClosestPointInsideTriangle(Point, Intersection);
    137     //cout << "Intersection between " << *Point << " and " << **TriangleRunner << " is at " << *Intersection << "." << endl;
     137    //Log() << Verbose(1) << "Intersection between " << *Point << " and " << **TriangleRunner << " is at " << *Intersection << "." << endl;
    138138    IntersectionList.insert( pair<BoundaryTriangleSet *, Vector * > (*TriangleRunner, Intersection) );
    139139  }
     
    150150
    151151  //for (DistanceTriangleMap::const_iterator runner = DistanceList.begin(); runner != DistanceList.end(); runner++)
    152   //  cout << (*runner).first << " away from " << *(*runner).second << endl;
     152  //  Log() << Verbose(1) << (*runner).first << " away from " << *(*runner).second << endl;
    153153};
    154154
  • src/unittests/AnalysisCorrelationToPointUnitTest.cpp

    r70378e rd6c485  
    118118  // put pair correlation into bins and check with no range
    119119  binmap = BinData( pointmap, 0.5, 0., 0. );
    120   CPPUNIT_ASSERT_EQUAL( (size_t)2, binmap->size() );
    121   //OutputCorrelation ( binmap );
     120  OutputCorrelation ( (ofstream *)&cout, binmap );
     121  CPPUNIT_ASSERT_EQUAL( (size_t)3, binmap->size() );
    122122  tester = binmap->begin();
    123123  CPPUNIT_ASSERT_EQUAL( 1., tester->first );
     
    131131  // ... and check with [0., 2.] range
    132132  binmap = BinData( pointmap, 0.5, 0., 2. );
     133  OutputCorrelation ( (ofstream *)&cout, binmap );
    133134  CPPUNIT_ASSERT_EQUAL( (size_t)5, binmap->size() );
    134   //OutputCorrelation ( binmap );
    135135  tester = binmap->begin();
    136136  CPPUNIT_ASSERT_EQUAL( 0., tester->first );
  • src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp

    r70378e rd6c485  
    197197  // put pair correlation into bins and check with no range
    198198  binmap = BinData( surfacemap, 0.5, 0., 0. );
    199   CPPUNIT_ASSERT_EQUAL( (size_t)2, binmap->size() );
    200   OutputCorrelation ( (ofstream *)&cout, binmap );
     199  //OutputCorrelation ( (ofstream *)&cout, binmap );
     200  CPPUNIT_ASSERT_EQUAL( (size_t)9, binmap->size() );
    201201  // inside point is first and must have negative value
    202202  tester = binmap->lower_bound(4.25-0.5); // start depends on the min value and
     
    216216  // ... and check with [0., 2.] range
    217217  binmap = BinData( surfacemap, 0.5, -2., 4. );
     218  //OutputCorrelation ( (ofstream *)&cout, binmap );
    218219  CPPUNIT_ASSERT_EQUAL( (size_t)13, binmap->size() );
    219 //  OutputCorrelation ( (ofstream *)&cout, binmap );
    220220  // three outside points
    221221  tester = binmap->lower_bound(4.25-0.5);
  • src/unittests/Makefile.am

    r70378e rd6c485  
    1111  AnalysisPairCorrelationUnitTest \
    1212  BondGraphUnitTest \
     13  CountBondsUnitTest \
    1314  GSLMatrixSymmetricUnitTest \
    1415  GSLMatrixUnitTest \
     
    1617  InfoUnitTest \
    1718  LinearSystemOfEquationsUnitTest \
     19  LinkedCellUnitTest \
    1820  ListOfBondsUnitTest \
    1921  LogUnitTest \
     
    4749BondGraphUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
    4850
     51CountBondsUnitTest_SOURCES = CountBondsUnitTest.cpp CountBondsUnitTest.hpp
     52CountBondsUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
     53
    4954GSLMatrixSymmetricUnitTest_SOURCES = gslmatrixsymmetricunittest.cpp gslmatrixsymmetricunittest.hpp
    5055GSLMatrixSymmetricUnitTest_LDADD = ../libgslwrapper.a
     
    6065
    6166LinearSystemOfEquationsUnitTest_SOURCES = linearsystemofequationsunittest.cpp linearsystemofequationsunittest.hpp
    62 LinearSystemOfEquationsUnitTest_LDADD = ../libgslwrapper.a ../libmolecuilder.a
     67LinearSystemOfEquationsUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
     68
     69LinkedCellUnitTest_SOURCES = LinkedCellUnitTest.cpp LinkedCellUnitTest.hpp
     70LinkedCellUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
    6371
    6472ListOfBondsUnitTest_SOURCES = listofbondsunittest.cpp listofbondsunittest.hpp
  • src/unittests/analysisbondsunittest.cpp

    r70378e rd6c485  
    4848  strcpy(hydrogen->symbol, "H");
    4949  carbon = new element;
    50   carbon->Z = 1;
     50  carbon->Z = 2;
    5151  carbon->Valence = 4;
    5252  carbon->NoValenceOrbitals = 4;
  • src/unittests/bondgraphunittest.cpp

    r70378e rd6c485  
    2020#include "bondgraph.hpp"
    2121#include "element.hpp"
     22#include "log.hpp"
    2223#include "molecule.hpp"
    2324#include "periodentafel.hpp"
     
    4243  hydrogen = new element;
    4344  hydrogen->Z = 1;
     45  hydrogen->CovalentRadius = 0.23;
     46  hydrogen->VanDerWaalsRadius = 1.09;
    4447  strcpy(hydrogen->name, "hydrogen");
    4548  strcpy(hydrogen->symbol, "H");
    4649  carbon = new element;
    47   carbon->Z = 1;
     50  carbon->Z = 2;
     51  carbon->CovalentRadius = 0.68;
     52  carbon->VanDerWaalsRadius = 1.7;
    4853  strcpy(carbon->name, "carbon");
    4954  strcpy(carbon->symbol, "C");
     
    5863  TestMolecule = new molecule(tafel);
    5964  Walker = new atom();
    60   Walker->type = hydrogen;
     65  Walker->type = carbon;
    6166  Walker->node->Init(1., 0., 1. );
    6267  TestMolecule->AddAtom(Walker);
    6368  Walker = new atom();
    64   Walker->type = hydrogen;
     69  Walker->type = carbon;
    6570  Walker->node->Init(0., 1., 1. );
    6671  TestMolecule->AddAtom(Walker);
    6772  Walker = new atom();
    68   Walker->type = hydrogen;
     73  Walker->type = carbon;
    6974  Walker->node->Init(1., 1., 0. );
    7075  TestMolecule->AddAtom(Walker);
    7176  Walker = new atom();
    72   Walker->type = hydrogen;
     77  Walker->type = carbon;
    7378  Walker->node->Init(0., 0., 0. );
    7479  TestMolecule->AddAtom(Walker);
     
    7883
    7984  // create a small file with table
     85  dummyname = new string("dummy.dat");
    8086  filename = new string("test.dat");
    8187  ofstream test(filename->c_str());
     
    9399  remove(filename->c_str());
    94100  delete(filename);
     101  delete(dummyname);
    95102  delete(BG);
    96103
     
    114121/** UnitTest for BondGraphTest::ConstructBondGraph().
    115122 */
    116 void BondGraphTest::ConstructGraphTest()
     123void BondGraphTest::ConstructGraphFromTableTest()
    117124{
    118125  atom *Walker = TestMolecule->start->next;
     
    120127  CPPUNIT_ASSERT( TestMolecule->end != Walker );
    121128  CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) );
     129  CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) );
     130  CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );
     131};
     132
     133/** UnitTest for BondGraphTest::ConstructBondGraph().
     134 */
     135void BondGraphTest::ConstructGraphFromCovalentRadiiTest()
     136{
     137  atom *Walker = TestMolecule->start->next;
     138  atom *Runner = TestMolecule->end->previous;
     139  CPPUNIT_ASSERT( TestMolecule->end != Walker );
     140  CPPUNIT_ASSERT_EQUAL( false , BG->LoadBondLengthTable(*dummyname) );
    122141  CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) );
    123142  CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );
  • src/unittests/bondgraphunittest.hpp

    r70378e rd6c485  
    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/logunittest.cpp

    r70378e rd6c485  
    3535{
    3636  logger::getInstance()->setVerbosity(2);
    37   Log() << Verbose(0) << "Verbosity level is set to 2." << endl;
    38   Log() << Verbose(0) << "Test level 0" << endl;
    39   Log() << Verbose(1) << "Test level 1" << endl;
    40   Log() << Verbose(2) << "Test level 2" << endl;
    41   Log() << Verbose(3) << "Test level 3" << endl;
    42   Log() << Verbose(4) << "Test level 4" << endl;
     37  DoLog(0) && (Log() << Verbose(0) << "Verbosity level is set to 2." << endl);
     38  DoLog(0) && (Log() << Verbose(0) << "Test level 0" << endl);
     39  DoLog(1) && (Log() << Verbose(1) << "Test level 1" << endl);
     40  DoLog(2) && (Log() << Verbose(2) << "Test level 2" << endl);
     41  DoLog(3) && (Log() << Verbose(3) << "Test level 3" << endl);
     42  DoLog(4) && (Log() << Verbose(4) << "Test level 4" << endl);
    4343
    44   Log() << Verbose(0) << "Output a log message." << endl;
    45   eLog() << Verbose(0) << "Output an error message." << endl;
     44  DoLog(0) && (Log() << Verbose(0) << "Output a log message." << endl);
     45  DoeLog(0) && (eLog()<< Verbose(0) << "Output an error message." << endl);
    4646  setVerbosity(3);
    47   Log() << Verbose(4) << "This should not be printed." << endl;
    48   eLog() << Verbose(4) << "This should not be printed." << endl;
     47  DoLog(4) && (Log() << Verbose(4) << "This should not be printed." << endl);
     48  DoeLog(4) && (eLog()<< Verbose(4) << "This should not be printed." << endl);
    4949};
    5050
  • src/unittests/memoryallocatorunittest.cpp

    r70378e rd6c485  
    4646  char* buffer3 = NULL;
    4747  buffer3 = Malloc<char>(4, "");
    48   Log() << Verbose(0) << buffer3 << endl;
     48  DoLog(0) && (Log() << Verbose(0) << buffer3 << endl);
    4949  Free(&buffer3);
    5050
  • src/unittests/tesselation_boundarytriangleunittest.hpp

    r70378e rd6c485  
    3535      class BoundaryLineSet *lines[3];
    3636      class BoundaryPointSet *points[3];
    37       LinkedNodes Corners;
     37      LinkedCell::LinkedNodes Corners;
    3838};
    3939
  • src/unittests/tesselation_insideoutsideunittest.cpp

    r70378e rd6c485  
    9494  while ((!TesselStruct->OpenLines.empty()) && (OneLoopWithoutSuccessFlag)) {
    9595    // 2a. fill all new OpenLines
    96     Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for candidates:" << endl;
     96    DoLog(1) && (Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for candidates:" << endl);
    9797    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++)
    98       Log() << Verbose(2) << *(Runner->second) << endl;
     98      DoLog(2) && (Log() << Verbose(2) << *(Runner->second) << endl);
    9999
    100100    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
     
    102102      if (baseline->pointlist.empty()) {
    103103        T = (((baseline->BaseLine->triangles.begin()))->second);
    104         Log() << Verbose(1) << "Finding best candidate for open line " << *baseline->BaseLine << " of triangle " << *T << endl;
     104        DoLog(1) && (Log() << Verbose(1) << "Finding best candidate for open line " << *baseline->BaseLine << " of triangle " << *T << endl);
    105105        TesselationFailFlag = TesselStruct->FindNextSuitableTriangle(*baseline, *T, SPHERERADIUS, LinkedList); //the line is there, so there is a triangle, but only one.
    106106      }
     
    109109    // 2b. search for smallest ShortestAngle among all candidates
    110110    double ShortestAngle = 4.*M_PI;
    111     Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for the best candidates:" << endl;
     111    DoLog(1) && (Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for the best candidates:" << endl);
    112112    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++)
    113       Log() << Verbose(2) << *(Runner->second) << endl;
     113      DoLog(2) && (Log() << Verbose(2) << *(Runner->second) << endl);
    114114
    115115    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
     
    123123      OneLoopWithoutSuccessFlag = false;
    124124    else {
    125       TesselStruct->AddCandidateTriangle(*baseline);
     125      TesselStruct->AddCandidatePolygon(*baseline, SPHERERADIUS, LinkedList);
    126126    }
    127127  }
     
    133133  delete(LinkedList);
    134134  delete(TesselStruct);
    135   for (LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) {
     135  for (LinkedCell::LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) {
    136136    delete((*Runner)->node);
    137137    delete(*Runner);
  • src/unittests/tesselation_insideoutsideunittest.hpp

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

    r70378e rd6c485  
    9191      OneLoopWithoutSuccessFlag = false;
    9292    else {
    93       TesselStruct->AddCandidateTriangle(*baseline);
     93      TesselStruct->AddCandidatePolygon(*baseline, SPHERERADIUS, LinkedList);
    9494    }
    9595  }
     
    101101  delete(LinkedList);
    102102  delete(TesselStruct);
    103   for (LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) {
     103  for (LinkedCell::LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) {
    104104    delete((*Runner)->node);
    105105    delete(*Runner);
  • src/unittests/tesselationunittest.hpp

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

    r70378e rd6c485  
    253253  Direction.SubtractVector(Origin);
    254254  Direction.Normalize();
    255   Log() << Verbose(1) << "INFO: Direction is " << Direction << "." << endl;
     255  DoLog(1) && (Log() << Verbose(1) << "INFO: Direction is " << Direction << "." << endl);
    256256  //Log() << Verbose(1) << "INFO: PlaneNormal is " << *PlaneNormal << " and PlaneOffset is " << *PlaneOffset << "." << endl;
    257257  factor = Direction.ScalarProduct(PlaneNormal);
    258258  if (fabs(factor) < MYEPSILON) { // Uniqueness: line parallel to plane?
    259     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);
    260260    return false;
    261261  }
     
    264264  factor = helper.ScalarProduct(PlaneNormal)/factor;
    265265  if (fabs(factor) < MYEPSILON) { // Origin is in-plane
    266     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);
    267267    CopyVector(Origin);
    268268    return true;
     
    271271  Direction.Scale(factor);
    272272  CopyVector(Origin);
    273   Log() << Verbose(1) << "INFO: Scaled direction is " << Direction << "." << endl;
     273  DoLog(1) && (Log() << Verbose(1) << "INFO: Scaled direction is " << Direction << "." << endl);
    274274  AddVector(&Direction);
    275275
     
    278278  helper.SubtractVector(PlaneOffset);
    279279  if (helper.ScalarProduct(PlaneNormal) < MYEPSILON) {
    280     Log() << Verbose(1) << "GOOD: Intersection is " << *this << "." << endl;
     280    DoLog(1) && (Log() << Verbose(1) << "GOOD: Intersection is " << *this << "." << endl);
    281281    return true;
    282282  } else {
    283     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);
    284284    return false;
    285285  }
     
    352352 
    353353  //Log() << Verbose(1) << "Coefficent matrix is:" << endl;
     354  //ostream &output = Log() << Verbose(1);
    354355  //for (int i=0;i<4;i++) {
    355356  //  for (int j=0;j<4;j++)
    356   //    cout << "\t" << M->Get(i,j);
    357   //  cout << endl;
     357  //    output << "\t" << M->Get(i,j);
     358  //  output << endl;
    358359  //}
    359360  if (fabs(M->Determinant()) > MYEPSILON) {
    360     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);
    361362    return false;
    362363  }
    363   Log() << Verbose(1) << "INFO: Line1a = " << *Line1a << ", Line1b = " << *Line1b << ", Line2a = " << *Line2a << ", Line2b = " << *Line2b << "." << endl;
     364  DoLog(1) && (Log() << Verbose(1) << "INFO: Line1a = " << *Line1a << ", Line1b = " << *Line1b << ", Line2a = " << *Line2a << ", Line2b = " << *Line2b << "." << endl);
    364365
    365366
     
    377378  d.CopyVector(Line2b);
    378379  d.SubtractVector(Line1b);
    379   Log() << Verbose(1) << "INFO: a = " << a << ", b = " << b << ", c = " << c << "." << endl;
     380  DoLog(1) && (Log() << Verbose(1) << "INFO: a = " << a << ", b = " << b << ", c = " << c << "." << endl);
    380381  if ((a.NormSquared() < MYEPSILON) || (b.NormSquared() < MYEPSILON)) {
    381382   Zero();
    382    Log() << Verbose(1) << "At least one of the lines is ill-defined, i.e. offset equals second vector." << endl;
     383   DoLog(1) && (Log() << Verbose(1) << "At least one of the lines is ill-defined, i.e. offset equals second vector." << endl);
    383384   return false;
    384385  }
     
    393394    if ((factor >= -MYEPSILON) && (factor - 1. < MYEPSILON)) {
    394395      CopyVector(Line2a);
    395       Log() << Verbose(1) << "Lines conincide." << endl;
     396      DoLog(1) && (Log() << Verbose(1) << "Lines conincide." << endl);
    396397      return true;
    397398    } else {
     
    401402      if ((factor >= -MYEPSILON) && (factor - 1. < MYEPSILON)) {
    402403        CopyVector(Line2b);
    403         Log() << Verbose(1) << "Lines conincide." << endl;
     404        DoLog(1) && (Log() << Verbose(1) << "Lines conincide." << endl);
    404405        return true;
    405406      }
    406407    }
    407     Log() << Verbose(1) << "Lines are parallel." << endl;
     408    DoLog(1) && (Log() << Verbose(1) << "Lines are parallel." << endl);
    408409    Zero();
    409410    return false;
     
    417418  temp2.CopyVector(&a);
    418419  temp2.VectorProduct(&b);
    419   Log() << Verbose(1) << "INFO: temp1 = " << temp1 << ", temp2 = " << temp2 << "." << endl;
     420  DoLog(1) && (Log() << Verbose(1) << "INFO: temp1 = " << temp1 << ", temp2 = " << temp2 << "." << endl);
    420421  if (fabs(temp2.NormSquared()) > MYEPSILON)
    421422    s = temp1.ScalarProduct(&temp2)/temp2.NormSquared();
    422423  else
    423424    s = 0.;
    424   Log() << Verbose(1) << "Factor s is " << temp1.ScalarProduct(&temp2) << "/" << temp2.NormSquared() << " = " << s << "." << endl;
     425  DoLog(1) && (Log() << Verbose(1) << "Factor s is " << temp1.ScalarProduct(&temp2) << "/" << temp2.NormSquared() << " = " << s << "." << endl);
    425426
    426427  // construct intersection
     
    428429  Scale(s);
    429430  AddVector(Line1a);
    430   Log() << Verbose(1) << "Intersection is at " << *this << "." << endl;
     431  DoLog(1) && (Log() << Verbose(1) << "Intersection is at " << *this << "." << endl);
    431432
    432433  return true;
     
    701702void Vector::Output() const
    702703{
    703   Log() << Verbose(0) << "(";
     704  DoLog(0) && (Log() << Verbose(0) << "(");
    704705  for (int i=0;i<NDIM;i++) {
    705     Log() << Verbose(0) << x[i];
     706    DoLog(0) && (Log() << Verbose(0) << x[i]);
    706707    if (i != 2)
    707       Log() << Verbose(0) << ",";
    708   }
    709   Log() << Verbose(0) << ")";
     708      DoLog(0) && (Log() << Verbose(0) << ",");
     709  }
     710  DoLog(0) && (Log() << Verbose(0) << ")");
    710711};
    711712
     
    816817      x[i] = C.x[i];
    817818  } else {
    818     eLog() << Verbose(1) << "inverse of matrix does not exists: det A = " << detA << "." << endl;
     819    DoeLog(1) && (eLog()<< Verbose(1) << "inverse of matrix does not exists: det A = " << detA << "." << endl);
    819820  }
    820821};
     
    842843  projection = ScalarProduct(n)/n->ScalarProduct(n);    // remove constancy from n (keep as logical one)
    843844  // withdraw projected vector twice from original one
    844   Log() << Verbose(1) << "Vector: ";
     845  DoLog(1) && (Log() << Verbose(1) << "Vector: ");
    845846  Output();
    846   Log() << Verbose(0) << "\t";
     847  DoLog(0) && (Log() << Verbose(0) << "\t");
    847848  for (int i=NDIM;i--;)
    848849    x[i] -= 2.*projection*n->x[i];
    849   Log() << Verbose(0) << "Projected vector: ";
     850  DoLog(0) && (Log() << Verbose(0) << "Projected vector: ");
    850851  Output();
    851   Log() << Verbose(0) << endl;
     852  DoLog(0) && (Log() << Verbose(0) << endl);
    852853};
    853854
     
    868869  x2.SubtractVector(y2);
    869870  if ((fabs(x1.Norm()) < MYEPSILON) || (fabs(x2.Norm()) < MYEPSILON) || (fabs(x1.Angle(&x2)) < MYEPSILON)) {
    870     eLog() << Verbose(2) << "Given vectors are linear dependent." << endl;
     871    DoeLog(2) && (eLog()<< Verbose(2) << "Given vectors are linear dependent." << endl);
    871872    return false;
    872873  }
     
    902903  Zero();
    903904  if ((fabs(x1.Norm()) < MYEPSILON) || (fabs(x2.Norm()) < MYEPSILON) || (fabs(x1.Angle(&x2)) < MYEPSILON)) {
    904     eLog() << Verbose(2) << "Given vectors are linear dependent." << endl;
     905    DoeLog(2) && (eLog()<< Verbose(2) << "Given vectors are linear dependent." << endl);
    905906    return false;
    906907  }
     
    953954  double norm;
    954955
    955   Log() << Verbose(4);
     956  DoLog(4) && (Log() << Verbose(4));
    956957  GivenVector->Output();
    957   Log() << Verbose(0) << endl;
     958  DoLog(0) && (Log() << Verbose(0) << endl);
    958959  for (j=NDIM;j--;)
    959960    Components[j] = -1;
     
    962963    if (fabs(GivenVector->x[j]) > MYEPSILON)
    963964      Components[Last++] = j;
    964   Log() << Verbose(4) << Last << " Components != 0: (" << Components[0] << "," << Components[1] << "," << Components[2] << ")" << endl;
     965  DoLog(4) && (Log() << Verbose(4) << Last << " Components != 0: (" << Components[0] << "," << Components[1] << "," << Components[2] << ")" << endl);
    965966
    966967  switch(Last) {
     
    10121013
    10131014  for (j=0;j<num;j++) {
    1014     Log() << Verbose(1) << j << "th atom's vector: ";
     1015    DoLog(1) && (Log() << Verbose(1) << j << "th atom's vector: ");
    10151016    (vectors[j])->Output();
    1016     Log() << Verbose(0) << endl;
     1017    DoLog(0) && (Log() << Verbose(0) << endl);
    10171018  }
    10181019
     
    11341135    j += i+1;
    11351136    do {
    1136       Log() << Verbose(0) << coords[i] << "[0.." << cell_size[j] << "]: ";
     1137      DoLog(0) && (Log() << Verbose(0) << coords[i] << "[0.." << cell_size[j] << "]: ");
    11371138      cin >> x[i];
    11381139    } while (((x[i] < 0) || (x[i] >= cell_size[j])) && (check));
     
    11651166  B2 = cos(beta) * x2->Norm() * c;
    11661167  C = c * c;
    1167   Log() << Verbose(2) << "A " << A << "\tB " << B1 << "\tC " << C << endl;
     1168  DoLog(2) && (Log() << Verbose(2) << "A " << A << "\tB " << B1 << "\tC " << C << endl);
    11681169  int flag = 0;
    11691170  if (fabs(x1->x[0]) < MYEPSILON) { // check for zero components for the later flipping and back-flipping
     
    12041205  D2 = -y->x[0]/x1->x[0]*x1->x[2]+y->x[2];
    12051206  D3 = y->x[0]/x1->x[0]*A-B1;
    1206   Log() << Verbose(2) << "D1 " << D1 << "\tD2 " << D2 << "\tD3 " << D3 << "\n";
     1207  DoLog(2) && (Log() << Verbose(2) << "D1 " << D1 << "\tD2 " << D2 << "\tD3 " << D3 << "\n");
    12071208  if (fabs(D1) < MYEPSILON) {
    1208     Log() << Verbose(2) << "D1 == 0!\n";
     1209    DoLog(2) && (Log() << Verbose(2) << "D1 == 0!\n");
    12091210    if (fabs(D2) > MYEPSILON) {
    1210       Log() << Verbose(3) << "D2 != 0!\n";
     1211      DoLog(3) && (Log() << Verbose(3) << "D2 != 0!\n");
    12111212      x[2] = -D3/D2;
    12121213      E1 = A/x1->x[0] + x1->x[2]/x1->x[0]*D3/D2;
    12131214      E2 = -x1->x[1]/x1->x[0];
    1214       Log() << Verbose(3) << "E1 " << E1 << "\tE2 " << E2 << "\n";
     1215      DoLog(3) && (Log() << Verbose(3) << "E1 " << E1 << "\tE2 " << E2 << "\n");
    12151216      F1 = E1*E1 + 1.;
    12161217      F2 = -E1*E2;
    12171218      F3 = E1*E1 + D3*D3/(D2*D2) - C;
    1218       Log() << Verbose(3) << "F1 " << F1 << "\tF2 " << F2 << "\tF3 " << F3 << "\n";
     1219      DoLog(3) && (Log() << Verbose(3) << "F1 " << F1 << "\tF2 " << F2 << "\tF3 " << F3 << "\n");
    12191220      if (fabs(F1) < MYEPSILON) {
    1220         Log() << Verbose(4) << "F1 == 0!\n";
    1221         Log() << Verbose(4) << "Gleichungssystem linear\n";
     1221        DoLog(4) && (Log() << Verbose(4) << "F1 == 0!\n");
     1222        DoLog(4) && (Log() << Verbose(4) << "Gleichungssystem linear\n");
    12221223        x[1] = F3/(2.*F2);
    12231224      } else {
    12241225        p = F2/F1;
    12251226        q = p*p - F3/F1;
    1226         Log() << Verbose(4) << "p " << p << "\tq " << q << endl;
     1227        DoLog(4) && (Log() << Verbose(4) << "p " << p << "\tq " << q << endl);
    12271228        if (q < 0) {
    1228           Log() << Verbose(4) << "q < 0" << endl;
     1229          DoLog(4) && (Log() << Verbose(4) << "q < 0" << endl);
    12291230          return false;
    12301231        }
     
    12331234      x[0] =  A/x1->x[0] - x1->x[1]/x1->x[0]*x[1] + x1->x[2]/x1->x[0]*x[2];
    12341235    } else {
    1235       Log() << Verbose(2) << "Gleichungssystem unterbestimmt\n";
     1236      DoLog(2) && (Log() << Verbose(2) << "Gleichungssystem unterbestimmt\n");
    12361237      return false;
    12371238    }
     
    12391240    E1 = A/x1->x[0]+x1->x[1]/x1->x[0]*D3/D1;
    12401241    E2 = x1->x[1]/x1->x[0]*D2/D1 - x1->x[2];
    1241     Log() << Verbose(2) << "E1 " << E1 << "\tE2 " << E2 << "\n";
     1242    DoLog(2) && (Log() << Verbose(2) << "E1 " << E1 << "\tE2 " << E2 << "\n");
    12421243    F1 = E2*E2 + D2*D2/(D1*D1) + 1.;
    12431244    F2 = -(E1*E2 + D2*D3/(D1*D1));
    12441245    F3 = E1*E1 + D3*D3/(D1*D1) - C;
    1245     Log() << Verbose(2) << "F1 " << F1 << "\tF2 " << F2 << "\tF3 " << F3 << "\n";
     1246    DoLog(2) && (Log() << Verbose(2) << "F1 " << F1 << "\tF2 " << F2 << "\tF3 " << F3 << "\n");
    12461247    if (fabs(F1) < MYEPSILON) {
    1247       Log() << Verbose(3) << "F1 == 0!\n";
    1248       Log() << Verbose(3) << "Gleichungssystem linear\n";
     1248      DoLog(3) && (Log() << Verbose(3) << "F1 == 0!\n");
     1249      DoLog(3) && (Log() << Verbose(3) << "Gleichungssystem linear\n");
    12491250      x[2] = F3/(2.*F2);
    12501251    } else {
    12511252      p = F2/F1;
    12521253      q = p*p - F3/F1;
    1253       Log() << Verbose(3) << "p " << p << "\tq " << q << endl;
     1254      DoLog(3) && (Log() << Verbose(3) << "p " << p << "\tq " << q << endl);
    12541255      if (q < 0) {
    1255         Log() << Verbose(3) << "q < 0" << endl;
     1256        DoLog(3) && (Log() << Verbose(3) << "q < 0" << endl);
    12561257        return false;
    12571258      }
     
    12911292    for (j=2;j>=0;j--) {
    12921293      k = (i & pot(2,j)) << j;
    1293       Log() << Verbose(2) << "k " << k << "\tpot(2,j) " << pot(2,j) << endl;
     1294      DoLog(2) && (Log() << Verbose(2) << "k " << k << "\tpot(2,j) " << pot(2,j) << endl);
    12941295      sign[j] = (k == 0) ? 1. : -1.;
    12951296    }
    1296     Log() << Verbose(2) << i << ": sign matrix is " << sign[0] << "\t" << sign[1] << "\t" << sign[2] << "\n";
     1297    DoLog(2) && (Log() << Verbose(2) << i << ": sign matrix is " << sign[0] << "\t" << sign[1] << "\t" << sign[2] << "\n");
    12971298    // apply sign matrix
    12981299    for (j=NDIM;j--;)
     
    13001301    // calculate angle and check
    13011302    ang = x2->Angle (this);
    1302     Log() << Verbose(1) << i << "th angle " << ang << "\tbeta " << cos(beta) << " :\t";
     1303    DoLog(1) && (Log() << Verbose(1) << i << "th angle " << ang << "\tbeta " << cos(beta) << " :\t");
    13031304    if (fabs(ang - cos(beta)) < MYEPSILON) {
    13041305      break;
  • src/verbose.cpp

    r70378e rd6c485  
    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

    r70378e rd6c485  
    3737    ostream& print (ostream &ost) const;
    3838    bool DoOutput(int verbosityLevel) const;
     39    bool DoErrorOutput(int verbosityLevel) const;
    3940  private:
    4041    int Verbosity;
Note: See TracChangeset for help on using the changeset viewer.