Changes in / [9fe36b:b8d1aeb]


Ignore:
Files:
26 added
75 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/Actions/small_actions.cpp

    r9fe36b rb8d1aeb  
    5353  return NAME;
    5454}
     55
  • TabularUnified src/Makefile.am

    r9fe36b rb8d1aeb  
    11ATOMSOURCE = atom.cpp atom_atominfo.cpp atom_bondedparticle.cpp atom_bondedparticleinfo.cpp atom_graphnode.cpp atom_graphnodeinfo.cpp atom_particleinfo.cpp atom_trajectoryparticle.cpp atom_trajectoryparticleinfo.cpp
    22ATOMHEADER = atom.hpp atom_atominfo.hpp atom_bondedparticle.hpp atom_bondedparticleinfo.hpp atom_graphnode.hpp atom_graphnodeinfo.hpp atom_particleinfo.hpp atom_trajectoryparticle.hpp atom_trajectoryparticleinfo.hpp
     3
     4LINALGSOURCE = gslmatrix.cpp gslvector.cpp linearsystemofequations.cpp
     5LINALGHEADER = gslmatrix.hpp gslvector.hpp linearsystemofequations.hpp
    36
    47ANALYSISSOURCE = analysis_bonds.cpp analysis_correlation.cpp
     
    3134QTUI_DEFS =
    3235
    33 SOURCE = ${ANALYSISSOURCE} ${ATOMSOURCE} ${PATTERNSOURCE} bond.cpp bondgraph.cpp boundary.cpp config.cpp element.cpp ellipsoid.cpp errorlogger.cpp graph.cpp helpers.cpp leastsquaremin.cpp linkedcell.cpp log.cpp logger.cpp memoryusageobserver.cpp moleculelist.cpp molecule.cpp molecule_dynamics.cpp molecule_fragmentation.cpp molecule_geometry.cpp molecule_graph.cpp molecule_pointcloud.cpp parser.cpp periodentafel.cpp tesselation.cpp tesselationhelpers.cpp vector.cpp verbose.cpp
    34 HEADER = ${ANALYSISHEADER} ${ATOMHEADER} ${PATTERNHEADER} bond.hpp bondgraph.hpp boundary.hpp config.hpp defs.hpp element.hpp ellipsoid.hpp errorlogger.hpp graph.hpp helpers.hpp leastsquaremin.hpp linkedcell.hpp lists.hpp log.hpp logger.hpp memoryallocator.hpp memoryusageobserver.hpp molecule.hpp molecule_template.hpp parser.hpp periodentafel.hpp stackclass.hpp tesselation.hpp tesselationhelpers.hpp vector.hpp verbose.hpp
     36SOURCE = ${ANALYSISSOURCE} ${ATOMSOURCE} ${PATTERNSOURCE} bond.cpp bondgraph.cpp boundary.cpp config.cpp element.cpp ellipsoid.cpp errorlogger.cpp graph.cpp helpers.cpp info.cpp leastsquaremin.cpp linkedcell.cpp log.cpp logger.cpp memoryusageobserver.cpp moleculelist.cpp molecule.cpp molecule_dynamics.cpp molecule_fragmentation.cpp molecule_geometry.cpp molecule_graph.cpp molecule_pointcloud.cpp parser.cpp periodentafel.cpp tesselation.cpp tesselationhelpers.cpp vector.cpp verbose.cpp
     37HEADER = ${ANALYSISHEADER} ${ATOMHEADER} ${PATTERNHEADER} bond.hpp bondgraph.hpp boundary.hpp config.hpp defs.hpp element.hpp ellipsoid.hpp errorlogger.hpp graph.hpp helpers.hpp info.hpp leastsquaremin.hpp linkedcell.hpp lists.hpp log.hpp logger.hpp memoryallocator.hpp memoryusageobserver.hpp molecule.hpp molecule_template.hpp parser.hpp periodentafel.hpp stackclass.hpp tesselation.hpp tesselationhelpers.hpp vector.hpp verbose.hpp
    3538
    3639BOOST_LIB = $(BOOST_LDFLAGS) $(BOOST_MPL_LIB)
    3740INCLUDES = -I$(top_srcdir)/src/unittests
    3841
    39 noinst_LIBRARIES = libmolecuilder.a libmenu.a
     42noinst_LIBRARIES = libmolecuilder.a libgslwrapper.a libmenu.a
    4043bin_PROGRAMS = molecuilder molecuildergui joiner analyzer
    4144molecuilderdir = ${bindir}
    4245libmolecuilder_a_SOURCES = ${SOURCE} ${HEADER}
    4346libmenu_a_SOURCES = ${UISOURCE} ${UIHEADER}
     47libgslwrapper_a_SOURCES = ${LINALGSOURCE} ${LINALGHEADER}
    4448molecuilder_DATA = elements.db valence.db orbitals.db Hbonddistance.db Hbondangle.db
    4549molecuilder_LDFLAGS = $(BOOST_LIB)
    46 molecuilder_SOURCES = ${FACTORYSOURCE} menu.cpp builder.cpp
    47 molecuilder_LDADD = libmolecuilder.a libmenu.a
     50molecuilder_SOURCES = ${FACTORYSOURCE} menu.cpp builder.cpp
     51molecuilder_SOURCES += $(srcdir)/version.c
     52molecuilder_LDADD = libmolecuilder.a libgslwrapper.a libmenu.a
    4853#Stuff for building the GUI using QT
    4954molecuildergui_SOURCES = ${QTUISOURCE} ${FACTORYSOURCE} menu.cpp builder.cpp
     55molecuildergui_SOURCES += $(srcdir)/version.c
    5056molecuildergui_CXXFLAGS = ${QT_CXXFLAGS} ${GLU_CXXFLAGS} -DUSE_GUI_QT
    5157molecuildergui_LDFLAGS = $(BOOST_LIB) ${QT_LDFLAGS} ${GLU_LDFLAGS}
    52 molecuildergui_LDADD = libmolecuilder.a libmenu.a ${QT_LDADD} ${QT_LIB_GUI} -lQtOpenGL ${GLU_LIBS}
     58molecuildergui_LDADD = libmolecuilder.a libgslwrapper.a libmenu.a ${QT_LDADD} ${QT_LIB_GUI} -lQtOpenGL ${GLU_LIBS}
    5359joiner_SOURCES = joiner.cpp datacreator.cpp parser.cpp datacreator.hpp helpers.hpp parser.hpp periodentafel.hpp
    5460joiner_LDADD = libmolecuilder.a
     
    7278#EXTRA_DIST = ${molecuilder_DATA}
    7379
     80FORCE:
     81$(srcdir)/.git-version: FORCE
     82        @if (test -d $(top_srcdir)/../.git && cd $(srcdir) && git describe HEAD) > .git-version-t 2>/dev/null \
     83          && ! diff .git-version-t $(srcdir)/.git-version >/dev/null 2>&1; then \
     84          mv -f .git-version-t $(srcdir)/.git-version; \
     85        else \
     86          rm -f .git-version-t; \
     87        fi
     88
     89EXTRA_DIST = $(srcdir)/.git-version
     90
     91$(srcdir)/version.c: $(srcdir)/.git-version
     92        echo "const char *ESPACKVersion = \"$(PACKAGE_NAME) -- git version: "`cat $(srcdir)/.git-version`"\";" > $@
     93
     94
  • TabularUnified src/UIElements/Dialog.cpp

    r9fe36b rb8d1aeb  
    99
    1010#include "UIElements/Dialog.hpp"
     11
     12#include "vector.hpp"
    1113
    1214using namespace std;
     
    9698}
    9799
     100// Double Queries
     101
     102Dialog::DoubleQuery::DoubleQuery(string title,double *_target) :
     103    Query(title), target(_target)
     104{}
     105
     106Dialog::DoubleQuery::~DoubleQuery() {};
     107
     108void Dialog::DoubleQuery::setResult() {
     109  *target = tmp;
     110}
     111
     112
    98113// Molecule Queries
    99114
     
    110125  *target = tmp;
    111126}
     127
     128// Vector Queries
     129
     130Dialog::VectorQuery::VectorQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check) :
     131  Query(title), target(_target), cellSize(_cellSize), check(_check)
     132{
     133tmp = new Vector();
     134}
     135
     136Dialog::VectorQuery::~VectorQuery()
     137{
     138  delete tmp;
     139}
     140
     141void Dialog::VectorQuery::setResult() {
     142  *target = *tmp;
     143}
  • TabularUnified src/UIElements/Dialog.hpp

    r9fe36b rb8d1aeb  
    1414class MoleculeListClass;
    1515class molecule;
     16class Vector;
    1617
    1718class Dialog
     
    2223
    2324  virtual void queryInt(const char *, int *)=0;
     25  virtual void queryDouble(const char*,double *)=0;
    2426  virtual void queryString(const char*, std::string *)=0;
    2527  virtual void queryMolecule(const char*,molecule**,MoleculeListClass*)=0;
     28  virtual void queryVector(const char*,Vector *,const double *const,bool)=0;
    2629
    2730  virtual bool display();
     
    6770  };
    6871
     72  class DoubleQuery : public Query {
     73  public:
     74    DoubleQuery(std::string title,double *_target);
     75    ~DoubleQuery();
     76    virtual bool handle()=0;
     77    virtual void setResult();
     78  protected:
     79    double tmp;
     80  private:
     81    double *target;
     82  };
     83
    6984  class StringQuery : public Query {
    7085  public:
     
    7893    std::string *target;
    7994  };
     95
    8096
    8197  class MoleculeQuery : public Query {
     
    92108  };
    93109
     110  class VectorQuery : public Query {
     111  public:
     112      VectorQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check);
     113      ~VectorQuery();
     114      virtual bool handle()=0;
     115      virtual void setResult();
     116    protected:
     117      Vector *tmp;
     118      const double *const cellSize;
     119      bool check;
     120    private:
     121      Vector *target;
     122  };
     123
    94124void registerQuery(Query* query);
    95125
  • TabularUnified src/UIElements/QT4/QTDialog.cpp

    r9fe36b rb8d1aeb  
    1010#include <string>
    1111#include <sstream>
     12#include <limits>
    1213
    1314#include <Qt/qboxlayout.h>
    1415#include <Qt/qlabel.h>
    1516#include <Qt/qspinbox.h>
     17#include <QtGui/QDoubleSpinBox>
    1618#include <Qt/qlineedit.h>
    1719#include <Qt/qdialogbuttonbox.h>
     
    7577}
    7678
     79void QTDialog::queryDouble(const char* title, double* target){
     80  registerQuery(new DoubleQTQuery(title,target,inputLayout,this));
     81}
     82
    7783void QTDialog::queryString(const char* title, std::string *target)
    7884{
     
    8490  registerQuery(new MoleculeQTQuery(title,target,molecules,inputLayout,this));
    8591}
     92
     93void QTDialog::queryVector(const char* title, Vector *target,const double *const cellSize, bool check) {
     94  registerQuery(new VectorQTQuery(title,target,cellSize,check,inputLayout,this));
     95}
     96
     97/************************** Query Objects *******************************/
    8698
    8799QTDialog::IntQTQuery::IntQTQuery(string _title,int *_target,QBoxLayout *_parent,QTDialog *_dialog) :
     
    110122bool QTDialog::IntQTQuery::handle()
    111123{
     124  return true;
     125}
     126
     127QTDialog::DoubleQTQuery::DoubleQTQuery(string title,double *_target,QBoxLayout *_parent,QTDialog *_dialog) :
     128    Dialog::DoubleQuery(title,_target),
     129    parent(_parent)
     130{
     131  thisLayout = new QHBoxLayout();
     132  titleLabel = new QLabel(QString(getTitle().c_str()));
     133  inputBox = new QDoubleSpinBox();
     134  inputBox->setValue(0);
     135  inputBox->setRange(-numeric_limits<double>::max(),numeric_limits<double>::max());
     136  inputBox->setDecimals(3);
     137  parent->addLayout(thisLayout);
     138  thisLayout->addWidget(titleLabel);
     139  thisLayout->addWidget(inputBox);
     140
     141  pipe = new DoubleQTQueryPipe(&tmp,_dialog);
     142  pipe->update(inputBox->value());
     143  connect(inputBox,SIGNAL(valueChanged(double)),pipe,SLOT(update(double)));
     144}
     145
     146QTDialog::DoubleQTQuery::~DoubleQTQuery()
     147{
     148  delete pipe;
     149}
     150
     151bool QTDialog::DoubleQTQuery::handle() {
    112152  return true;
    113153}
     
    177217}
    178218
     219QTDialog::VectorQTQuery::VectorQTQuery(std::string title, Vector *_target, const double *const _cellSize, bool _check,QBoxLayout *_parent,QTDialog *_dialog) :
     220    Dialog::VectorQuery(title,_target,_cellSize,_check),
     221    parent(_parent)
     222{
     223  // About the j: I don't know why it was done this way, but it was used this way in Vector::AskPosition, so I reused it
     224  int j = -1;
     225  const char *coords[3] = {"x:","y:","z:"};
     226  mainLayout= new QHBoxLayout();
     227  titleLabel = new QLabel(QString(getTitle().c_str()));
     228  mainLayout->addWidget(titleLabel);
     229  subLayout = new QVBoxLayout();
     230  mainLayout->addLayout(subLayout);
     231  for(int i=0; i<3; i++) {
     232    j+=i+1;
     233    coordLayout[i] = new QHBoxLayout();
     234    subLayout->addLayout(coordLayout[i]);
     235    coordLabel[i] = new QLabel(QString(coords[i]));
     236    coordLayout[i]->addWidget(coordLabel[i]);
     237    coordInput[i] = new QDoubleSpinBox();
     238    coordInput[i]->setRange(0,cellSize[j]);
     239    coordInput[i]->setDecimals(3);
     240    coordLayout[i]->addWidget(coordInput[i]);
     241    pipe[i] = new DoubleQTQueryPipe(&((*tmp)[i]),_dialog);
     242    pipe[i]->update(coordInput[i]->value());
     243    connect(coordInput[i],SIGNAL(valueChanged(double)),pipe[i],SLOT(update(double)));
     244
     245  }
     246  parent->addLayout(mainLayout);
     247}
     248
     249QTDialog::VectorQTQuery::~VectorQTQuery()
     250{}
     251
     252bool QTDialog::VectorQTQuery::handle() {
     253  return true;
     254}
     255
    179256
    180257/*************************** Plumbing *******************************/
     
    203280void IntQTQueryPipe::update(int newInt) {
    204281  (*content) = newInt;
     282  dialog->update();
     283}
     284
     285DoubleQTQueryPipe::DoubleQTQueryPipe(double *_content, QTDialog *_dialog) :
     286  content(_content),
     287  dialog(_dialog)
     288{}
     289
     290DoubleQTQueryPipe::~DoubleQTQueryPipe()
     291{}
     292
     293void DoubleQTQueryPipe::update(double newDbl) {
     294  (*content) = newDbl;
    205295  dialog->update();
    206296}
  • TabularUnified src/UIElements/QT4/QTDialog.hpp

    r9fe36b rb8d1aeb  
    1515class QLabel;
    1616class QSpinBox;
     17class QDoubleSpinBox;
    1718class QLineEdit;
    1819class QComboBox;
     
    2324class StringQTQueryPipe;
    2425class IntQTQueryPipe;
     26class DoubleQTQueryPipe;
    2527class MoleculeQTQueryPipe;
    2628
     
    3436  virtual void queryInt(const char *, int *);
    3537  virtual void queryString(const char*, std::string *);
     38  virtual void queryDouble(const char*,double *);
    3639  virtual void queryMolecule(const char*,molecule**,MoleculeListClass*);
     40  virtual void queryVector(const char*,Vector *,const double *const,bool);
    3741
    3842  virtual bool display();
     
    5357
    5458      IntQTQueryPipe *pipe;
     59    };
     60
     61    class DoubleQTQuery : public Dialog::DoubleQuery {
     62    public:
     63      DoubleQTQuery(std::string title, double *_target,QBoxLayout *_parent,QTDialog *_dialog);
     64      ~DoubleQTQuery();
     65      virtual bool handle();
     66    private:
     67      QBoxLayout *parent;
     68      QBoxLayout *thisLayout;
     69      QLabel *titleLabel;
     70      QDoubleSpinBox *inputBox;
     71
     72      DoubleQTQueryPipe *pipe;
    5573    };
    5674
     
    8199
    82100      MoleculeQTQueryPipe *pipe;
     101    };
     102
     103    class VectorQTQuery : public Dialog::VectorQuery {
     104    public:
     105      VectorQTQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check,QBoxLayout *,QTDialog *);
     106      ~VectorQTQuery();
     107      virtual bool handle();
     108    private:
     109      QBoxLayout *parent;
     110      QBoxLayout *mainLayout;
     111      QLabel *titleLabel;
     112      QBoxLayout *subLayout;
     113      QBoxLayout *coordLayout[3];
     114      QLabel *coordLabel[3];
     115      QDoubleSpinBox *coordInput[3];
     116
     117      DoubleQTQueryPipe *pipe[3];
    83118    };
    84119
     
    124159};
    125160
     161class DoubleQTQueryPipe : public QWidget {
     162  Q_OBJECT
     163public:
     164  DoubleQTQueryPipe(double *_content, QTDialog *_dialog);
     165  ~DoubleQTQueryPipe();
     166
     167public slots:
     168  void update(double);
     169
     170private:
     171  double *content;
     172  QTDialog *dialog;
     173
     174};
    126175
    127176class MoleculeQTQueryPipe : public QWidget {
  • TabularUnified src/UIElements/TextDialog.cpp

    r9fe36b rb8d1aeb  
    3131}
    3232
     33void TextDialog::queryDouble(const char* title, double* target){
     34  registerQuery(new DoubleTextQuery(title,target));
     35}
     36
    3337void TextDialog::queryString(const char* title, string* target){
    3438  registerQuery(new StringTextQuery(title,target));
     
    3741void TextDialog::queryMolecule(const char* title, molecule **target, MoleculeListClass *molecules) {
    3842  registerQuery(new MoleculeTextQuery(title,target,molecules));
     43}
     44
     45void TextDialog::queryVector(const char* title, Vector *target,const double *const cellSize, bool check) {
     46  registerQuery(new VectorTextQuery(title,target,cellSize,check));
    3947}
    4048
     
    6573}
    6674
     75TextDialog::DoubleTextQuery::DoubleTextQuery(string title,double *_target) :
     76    Dialog::DoubleQuery(title,_target)
     77{}
     78
     79TextDialog::DoubleTextQuery::~DoubleTextQuery() {}
     80
     81bool TextDialog::DoubleTextQuery::handle() {
     82  Log() << Verbose(0) << getTitle();
     83  cin >> tmp;
     84  return true;
     85}
     86
    6787TextDialog::MoleculeTextQuery::MoleculeTextQuery(string title, molecule **_target, MoleculeListClass *_molecules) :
    6888    Dialog::MoleculeQuery(title,_target,_molecules)
     
    84104  return (idxOfMol!=-1);
    85105}
     106
     107TextDialog::VectorTextQuery::VectorTextQuery(std::string title, Vector *_target, const double *const _cellSize, bool _check) :
     108    Dialog::VectorQuery(title,_target,_cellSize,_check)
     109{}
     110
     111TextDialog::VectorTextQuery::~VectorTextQuery()
     112{}
     113
     114bool TextDialog::VectorTextQuery::handle() {
     115 tmp->AskPosition(cellSize,check);
     116 return true;
     117}
  • TabularUnified src/UIElements/TextDialog.hpp

    r9fe36b rb8d1aeb  
    2121  virtual void queryInt(const char *, int *);
    2222  virtual void queryString(const char*, std::string *);
     23  virtual void queryDouble(const char*, double*);
    2324  virtual void queryMolecule(const char*,molecule**,MoleculeListClass*);
     25  virtual void queryVector(const char*,Vector *,const double * const,bool);
    2426
    2527protected:
     
    2931    IntTextQuery(std::string title, int *_target);
    3032    ~IntTextQuery();
     33    virtual bool handle();
     34  };
     35
     36  class DoubleTextQuery : public Dialog::DoubleQuery {
     37  public:
     38    DoubleTextQuery(std::string title, double *_target);
     39    ~DoubleTextQuery();
    3140    virtual bool handle();
    3241  };
     
    4554    virtual bool handle();
    4655  };
     56
     57  class VectorTextQuery : public Dialog::VectorQuery {
     58  public:
     59    VectorTextQuery(std::string title,Vector *_target,const double *const _cellSize,bool _check);
     60    ~VectorTextQuery();
     61    virtual bool handle();
     62  };
    4763};
    4864
  • TabularUnified src/analysis_correlation.cpp

    r9fe36b rb8d1aeb  
    1010#include "analysis_correlation.hpp"
    1111#include "element.hpp"
     12#include "info.hpp"
    1213#include "log.hpp"
    1314#include "molecule.hpp"
     
    2829PairCorrelationMap *PairCorrelation(MoleculeListClass * const &molecules, const element * const type1, const element * const type2 )
    2930{
     31  Info FunctionInfo(__func__);
    3032  PairCorrelationMap *outmap = NULL;
    3133  double distance = 0.;
     
    7779PairCorrelationMap *PeriodicPairCorrelation(MoleculeListClass * const &molecules, const element * const type1, const element * const type2, const int ranges[NDIM] )
    7880{
     81  Info FunctionInfo(__func__);
    7982  PairCorrelationMap *outmap = NULL;
    8083  double distance = 0.;
     
    154157CorrelationToPointMap *CorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point )
    155158{
     159  Info FunctionInfo(__func__);
    156160  CorrelationToPointMap *outmap = NULL;
    157161  double distance = 0.;
     
    190194CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point, const int ranges[NDIM] )
    191195{
     196  Info FunctionInfo(__func__);
    192197  CorrelationToPointMap *outmap = NULL;
    193198  double distance = 0.;
     
    243248CorrelationToSurfaceMap *CorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC )
    244249{
     250  Info FunctionInfo(__func__);
    245251  CorrelationToSurfaceMap *outmap = NULL;
    246252  double distance = 0;
     
    261267        Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
    262268        if ((type == NULL) || (Walker->type == type)) {
    263           triangle = Surface->FindClosestTriangleToPoint(Walker->node, LC );
     269          triangle = Surface->FindClosestTriangleToVector(Walker->node, LC );
    264270          if (triangle != NULL) {
    265271            distance = DistanceToTrianglePlane(Walker->node, triangle);
     
    288294CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] )
    289295{
     296  Info FunctionInfo(__func__);
    290297  CorrelationToSurfaceMap *outmap = NULL;
    291298  double distance = 0;
     
    301308  }
    302309  outmap = new CorrelationToSurfaceMap;
     310  double ShortestDistance = 0.;
     311  BoundaryTriangleSet *ShortestTriangle = NULL;
    303312  for (MoleculeList::const_iterator MolWalker = molecules->ListOfMolecules.begin(); MolWalker != molecules->ListOfMolecules.end(); MolWalker++)
    304313    if ((*MolWalker)->ActiveFlag) {
     
    314323          periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    315324          // go through every range in xyz and get distance
     325          ShortestDistance = -1.;
    316326          for (n[0]=-ranges[0]; n[0] <= ranges[0]; n[0]++)
    317327            for (n[1]=-ranges[1]; n[1] <= ranges[1]; n[1]++)
     
    320330                checkX.AddVector(&periodicX);
    321331                checkX.MatrixMultiplication(FullMatrix);
    322                 triangle = Surface->FindClosestTriangleToPoint(&checkX, LC );
    323                 if (triangle != NULL) {
    324                   distance = DistanceToTrianglePlane(&checkX, triangle);
    325                   outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> (Walker, triangle) ) );
     332                triangle = Surface->FindClosestTriangleToVector(&checkX, LC);
     333                distance = Surface->GetDistanceSquaredToTriangle(checkX, triangle);
     334                if ((ShortestDistance == -1.) || (distance < ShortestDistance)) {
     335                  ShortestDistance = distance;
     336                  ShortestTriangle = triangle;
    326337                }
    327           }
     338              }
     339          // insert
     340          ShortestDistance = sqrt(ShortestDistance);
     341          outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (Walker, ShortestTriangle) ) );
     342          //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl;
    328343        }
    329344      }
     
    342357double GetBin ( const double value, const double BinWidth, const double BinStart )
    343358{
     359  Info FunctionInfo(__func__);
    344360  double bin =(double) (floor((value - BinStart)/BinWidth));
    345361  return (bin*BinWidth+BinStart);
     
    353369void OutputCorrelation( ofstream * const file, const BinPairMap * const map )
    354370{
     371  Info FunctionInfo(__func__);
    355372  *file << "# BinStart\tCount" << endl;
    356373  for (BinPairMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
     
    365382void OutputPairCorrelation( ofstream * const file, const PairCorrelationMap * const map )
    366383{
     384  Info FunctionInfo(__func__);
    367385  *file << "# BinStart\tAtom1\tAtom2" << endl;
    368386  for (PairCorrelationMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
     
    377395void OutputCorrelationToPoint( ofstream * const file, const CorrelationToPointMap * const map )
    378396{
     397  Info FunctionInfo(__func__);
    379398  *file << "# BinStart\tAtom::x[i]-point.x[i]" << endl;
    380399  for (CorrelationToPointMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
     
    392411void OutputCorrelationToSurface( ofstream * const file, const CorrelationToSurfaceMap * const map )
    393412{
     413  Info FunctionInfo(__func__);
    394414  *file << "# BinStart\tTriangle" << endl;
    395415  for (CorrelationToSurfaceMap::const_iterator runner = map->begin(); runner != map->end(); ++runner) {
    396     *file << runner->first << "\t" << *(runner->second.second) << endl;
    397   }
    398 };
    399 
     416    *file << runner->first << "\t" << *(runner->second.first) << "\t" << *(runner->second.second) << endl;
     417  }
     418};
     419
  • TabularUnified src/analysis_correlation.hpp

    r9fe36b rb8d1aeb  
    5353double GetBin ( const double value, const double BinWidth, const double BinStart );
    5454void OutputCorrelation( ofstream * const file, const BinPairMap * const map );
    55 void OutputPairCorrelation( ofstream * const file, const BinPairMap * const map );
    56 void OutputCorrelationToPoint( ofstream * const file, const BinPairMap * const map );
    57 void OutputCorrelationToSurface( ofstream * const file, const BinPairMap * const map );
     55void OutputPairCorrelation( ofstream * const file, const PairCorrelationMap * const map );
     56void OutputCorrelationToPoint( ofstream * const file, const CorrelationToPointMap * const map );
     57void OutputCorrelationToSurface( ofstream * const file, const CorrelationToSurfaceMap * const map );
    5858
    5959
  • TabularUnified src/analyzer.cpp

    r9fe36b rb8d1aeb  
    77
    88//============================ INCLUDES ===========================
     9
     10#include <cstring>
    911
    1012#include "datacreator.hpp"
  • TabularUnified src/atom_bondedparticle.cpp

    r9fe36b rb8d1aeb  
    121121  bond *CandidateBond = NULL;
    122122
     123  NoBonds = CountBonds();
    123124  //Log() << Verbose(3) << "Walker " << *this << ": " << (int)this->type->NoValenceOrbitals << " > " << NoBonds << "?" << endl;
    124   NoBonds = CountBonds();
    125125  if ((int)(type->NoValenceOrbitals) > NoBonds) { // we have a mismatch, check all bonding partners for mismatch
    126126    for (BondList::const_iterator Runner = ListOfBonds.begin(); Runner != ListOfBonds.end(); (++Runner)) {
    127127      OtherWalker = (*Runner)->GetOtherAtom(this);
    128128      OtherNoBonds = OtherWalker->CountBonds();
    129       //Log() << Verbose(3) << "OtherWalker " << *OtherWalker << ": " << (int)OtherWalker->type->NoValenceOrbitals << " > " << NoBonds << "?" << endl;
    130       if ((int)(OtherWalker->type->NoValenceOrbitals) > NoBonds) { // check if possible candidate
     129      //Log() << Verbose(3) << "OtherWalker " << *OtherWalker << ": " << (int)OtherWalker->type->NoValenceOrbitals << " > " << OtherNoBonds << "?" << endl;
     130      if ((int)(OtherWalker->type->NoValenceOrbitals) > OtherNoBonds) { // check if possible candidate
    131131        if ((CandidateBond == NULL) || (ListOfBonds.size() > OtherWalker->ListOfBonds.size())) { // pick the one with fewer number of bonds first
    132132          CandidateBond = (*Runner);
     
    137137    if ((CandidateBond != NULL)) {
    138138      CandidateBond->BondDegree++;
    139       Log() << Verbose(2) << "Increased bond degree for bond " << *CandidateBond << "." << endl;
     139      //Log() << Verbose(2) << "Increased bond degree for bond " << *CandidateBond << "." << endl;
    140140    } else {
    141       //Log() << Verbose(2) << "Could not find correct degree for atom " << *this << "." << endl;
     141      eLog() << Verbose(2) << "Could not find correct degree for atom " << *this << "." << endl;
    142142      FalseBondDegree++;
    143143    }
  • TabularUnified src/bondgraph.cpp

    r9fe36b rb8d1aeb  
    1111#include "bondgraph.hpp"
    1212#include "element.hpp"
     13#include "info.hpp"
    1314#include "log.hpp"
    1415#include "molecule.hpp"
     
    3536/** Parses the bond lengths in a given file and puts them int a matrix form.
    3637 * Allocates \a MatrixContainer for BondGraph::BondLengthMatrix, using MatrixContainer::ParseMatrix(),
    37  * but only if parsing is successfull. Otherwise variable is left as NULL.
     38 * but only if parsing is successful. Otherwise variable is left as NULL.
    3839 * \param *out output stream for debugging
    3940 * \param filename file with bond lengths to parse
     
    4243bool BondGraph::LoadBondLengthTable(const string &filename)
    4344{
     45  Info FunctionInfo(__func__);
    4446  bool status = true;
    4547  MatrixContainer *TempContainer = NULL;
     
    5355
    5456  // parse in matrix
    55   status = TempContainer->ParseMatrix(filename.c_str(), 0, 1, 0);
     57  if (status = TempContainer->ParseMatrix(filename.c_str(), 0, 1, 0)) {
     58    Log() << Verbose(1) << "Parsing bond length matrix successful." << endl;
     59  } else {
     60    eLog() << Verbose(1) << "Parsing bond length matrix failed." << endl;
     61  }
    5662
    5763  // find greatest distance
  • TabularUnified src/boundary.cpp

    r9fe36b rb8d1aeb  
    1010#include "element.hpp"
    1111#include "helpers.hpp"
     12#include "info.hpp"
    1213#include "linkedcell.hpp"
    1314#include "log.hpp"
     
    3334double *GetDiametersOfCluster(const Boundaries *BoundaryPtr, const molecule *mol, Tesselation *&TesselStruct, const bool IsAngstroem)
    3435{
     36        Info FunctionInfo(__func__);
    3537  // get points on boundary of NULL was given as parameter
    3638  bool BoundaryFreeFlag = false;
     
    5355  } else {
    5456    BoundaryPoints = BoundaryPtr;
    55     Log() << Verbose(1) << "Using given boundary points set." << endl;
     57    Log() << Verbose(0) << "Using given boundary points set." << endl;
    5658  }
    5759  // determine biggest "diameter" of cluster for each axis
     
    6769          //Log() << Verbose(1) << "Current component is " << component << ", Othercomponent is " << Othercomponent << "." << endl;
    6870          for (Boundaries::const_iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) {
    69               //Log() << Verbose(2) << "Current runner is " << *(runner->second.second) << "." << endl;
     71              //Log() << Verbose(1) << "Current runner is " << *(runner->second.second) << "." << endl;
    7072              // seek for the neighbours pair where the Othercomponent sign flips
    7173              Neighbour = runner;
     
    8284                  DistanceVector.CopyVector(&runner->second.second->x);
    8385                  DistanceVector.SubtractVector(&Neighbour->second.second->x);
    84                   //Log() << Verbose(3) << "OldComponent is " << OldComponent << ", new one is " << DistanceVector.x[Othercomponent] << "." << endl;
     86                  //Log() << Verbose(2) << "OldComponent is " << OldComponent << ", new one is " << DistanceVector.x[Othercomponent] << "." << endl;
    8587                } while ((runner != Neighbour) && (fabs(OldComponent / fabs(
    8688                  OldComponent) - DistanceVector.x[Othercomponent] / fabs(
     
    9193                    OtherNeighbour = BoundaryPoints[axis].end();
    9294                  OtherNeighbour--;
    93                   //Log() << Verbose(2) << "The pair, where the sign of OtherComponent flips, is: " << *(Neighbour->second.second) << " and " << *(OtherNeighbour->second.second) << "." << endl;
     95                  //Log() << Verbose(1) << "The pair, where the sign of OtherComponent flips, is: " << *(Neighbour->second.second) << " and " << *(OtherNeighbour->second.second) << "." << endl;
    9496                  // now we have found the pair: Neighbour and OtherNeighbour
    9597                  OtherVector.CopyVector(&runner->second.second->x);
    9698                  OtherVector.SubtractVector(&OtherNeighbour->second.second->x);
    97                   //Log() << Verbose(2) << "Distances to Neighbour and OtherNeighbour are " << DistanceVector.x[component] << " and " << OtherVector.x[component] << "." << endl;
    98                   //Log() << Verbose(2) << "OtherComponents to Neighbour and OtherNeighbour are " << DistanceVector.x[Othercomponent] << " and " << OtherVector.x[Othercomponent] << "." << endl;
     99                  //Log() << Verbose(1) << "Distances to Neighbour and OtherNeighbour are " << DistanceVector.x[component] << " and " << OtherVector.x[component] << "." << endl;
     100                  //Log() << Verbose(1) << "OtherComponents to Neighbour and OtherNeighbour are " << DistanceVector.x[Othercomponent] << " and " << OtherVector.x[Othercomponent] << "." << endl;
    99101                  // do linear interpolation between points (is exact) to extract exact intersection between Neighbour and OtherNeighbour
    100102                  w1 = fabs(OtherVector.x[Othercomponent]);
     
    103105                      * OtherVector.x[component]) / (w1 + w2));
    104106                  // mark if it has greater diameter
    105                   //Log() << Verbose(2) << "Comparing current greatest " << GreatestDiameter[component] << " to new " << tmp << "." << endl;
     107                  //Log() << Verbose(1) << "Comparing current greatest " << GreatestDiameter[component] << " to new " << tmp << "." << endl;
    106108                  GreatestDiameter[component] = (GreatestDiameter[component]
    107109                      > tmp) ? GreatestDiameter[component] : tmp;
    108110                } //else
    109               //Log() << Verbose(2) << "Saw no sign flip, probably top or bottom node." << endl;
     111              //Log() << Verbose(1) << "Saw no sign flip, probably top or bottom node." << endl;
    110112            }
    111113        }
     
    135137Boundaries *GetBoundaryPoints(const molecule *mol, Tesselation *&TesselStruct)
    136138{
     139        Info FunctionInfo(__func__);
    137140  atom *Walker = NULL;
    138141  PointMap PointsOnBoundary;
     
    149152  double angle = 0.;
    150153
    151   Log() << Verbose(1) << "Finding all boundary points." << endl;
    152154  // 3a. Go through every axis
    153155  for (int axis = 0; axis < NDIM; axis++) {
     
    176178        angle = 0.; // otherwise it's a vector in Axis Direction and unimportant for boundary issues
    177179
    178       //Log() << Verbose(2) << "Checking sign in quadrant : " << ProjectedVector.Projection(&AngleReferenceNormalVector) << "." << endl;
     180      //Log() << Verbose(1) << "Checking sign in quadrant : " << ProjectedVector.Projection(&AngleReferenceNormalVector) << "." << endl;
    179181      if (ProjectedVector.ScalarProduct(&AngleReferenceNormalVector) > 0) {
    180182        angle = 2. * M_PI - angle;
    181183      }
    182       Log() << Verbose(2) << "Inserting " << *Walker << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl;
     184      Log() << Verbose(1) << "Inserting " << *Walker << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl;
    183185      BoundaryTestPair = BoundaryPoints[axis].insert(BoundariesPair(angle, DistancePair (radius, Walker)));
    184186      if (!BoundaryTestPair.second) { // same point exists, check first r, then distance of original vectors to center of gravity
     
    210212    // printing all inserted for debugging
    211213    //    {
    212     //      Log() << Verbose(2) << "Printing list of candidates for axis " << axis << " which we have inserted so far." << endl;
     214    //      Log() << Verbose(1) << "Printing list of candidates for axis " << axis << " which we have inserted so far." << endl;
    213215    //      int i=0;
    214216    //      for(Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) {
    215217    //        if (runner != BoundaryPoints[axis].begin())
    216     //          Log() << Verbose(2) << ", " << i << ": " << *runner->second.second;
     218    //          Log() << Verbose(0) << ", " << i << ": " << *runner->second.second;
    217219    //        else
    218     //          Log() << Verbose(2) << i << ": " << *runner->second.second;
     220    //          Log() << Verbose(0) << i << ": " << *runner->second.second;
    219221    //        i++;
    220222    //      }
    221     //      Log() << Verbose(2) << endl;
     223    //      Log() << Verbose(0) << endl;
    222224    //    }
    223225    // 3c. throw out points whose distance is less than the mean of left and right neighbours
     
    249251          SideA.SubtractVector(MolCenter);
    250252          SideA.ProjectOntoPlane(&AxisVector);
    251           //          Log() << Verbose(0) << "SideA: " << SideA << endl;
     253          //          Log() << Verbose(1) << "SideA: " << SideA << endl;
    252254
    253255          SideB.CopyVector(&right->second.second->x);
    254256          SideB.SubtractVector(MolCenter);
    255257          SideB.ProjectOntoPlane(&AxisVector);
    256           //          Log() << Verbose(0) << "SideB: " << SideB << endl;
     258          //          Log() << Verbose(1) << "SideB: " << SideB << endl;
    257259
    258260          SideC.CopyVector(&left->second.second->x);
    259261          SideC.SubtractVector(&right->second.second->x);
    260262          SideC.ProjectOntoPlane(&AxisVector);
    261           //          Log() << Verbose(0) << "SideC: " << SideC << endl;
     263          //          Log() << Verbose(1) << "SideC: " << SideC << endl;
    262264
    263265          SideH.CopyVector(&runner->second.second->x);
    264266          SideH.SubtractVector(MolCenter);
    265267          SideH.ProjectOntoPlane(&AxisVector);
    266           //          Log() << Verbose(0) << "SideH: " << SideH << endl;
     268          //          Log() << Verbose(1) << "SideH: " << SideH << endl;
    267269
    268270          // calculate each length
     
    277279          const double delta = SideC.Angle(&SideH);
    278280          const double MinDistance = a * sin(beta) / (sin(delta)) * (((alpha < M_PI / 2.) || (gamma < M_PI / 2.)) ? 1. : -1.);
    279           //Log() << Verbose(2) << " 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;
     281          //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;
    280282          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;
    281283          if ((fabs(h / fabs(h) - MinDistance / fabs(MinDistance)) < MYEPSILON) && ((h - MinDistance)) < -MYEPSILON) {
     
    303305void FindConvexBorder(const molecule* mol, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename)
    304306{
     307        Info FunctionInfo(__func__);
    305308  bool BoundaryFreeFlag = false;
    306309  Boundaries *BoundaryPoints = NULL;
    307 
    308   Log() << Verbose(1) << "Begin of FindConvexBorder" << endl;
    309310
    310311  if (TesselStruct != NULL) // free if allocated
     
    317318      BoundaryPoints = GetBoundaryPoints(mol, TesselStruct);
    318319  } else {
    319       Log() << Verbose(1) << "Using given boundary points set." << endl;
     320      Log() << Verbose(0) << "Using given boundary points set." << endl;
    320321  }
    321322
     
    323324  for (int axis=0; axis < NDIM; axis++)
    324325    {
    325       Log() << Verbose(2) << "Printing list of candidates for axis " << axis << " which we have inserted so far." << endl;
     326      Log() << Verbose(1) << "Printing list of candidates for axis " << axis << " which we have inserted so far." << endl;
    326327      int i=0;
    327328      for(Boundaries::iterator runner = BoundaryPoints[axis].begin(); runner != BoundaryPoints[axis].end(); runner++) {
    328329        if (runner != BoundaryPoints[axis].begin())
    329           Log() << Verbose(2) << ", " << i << ": " << *runner->second.second;
     330          Log() << Verbose(0) << ", " << i << ": " << *runner->second.second;
    330331        else
    331           Log() << Verbose(2) << i << ": " << *runner->second.second;
     332          Log() << Verbose(0) << i << ": " << *runner->second.second;
    332333        i++;
    333334      }
    334       Log() << Verbose(2) << endl;
     335      Log() << Verbose(0) << endl;
    335336    }
    336337
     
    341342          eLog() << Verbose(2) << "Point " << *(runner->second.second) << " is already present!" << endl;
    342343
    343   Log() << Verbose(2) << "I found " << TesselStruct->PointsOnBoundaryCount << " points on the convex boundary." << endl;
     344  Log() << Verbose(0) << "I found " << TesselStruct->PointsOnBoundaryCount << " points on the convex boundary." << endl;
    344345  // now we have the whole set of edge points in the BoundaryList
    345346
     
    347348  //  Log() << Verbose(1) << "Listing PointsOnBoundary:";
    348349  //  for(PointMap::iterator runner = PointsOnBoundary.begin(); runner != PointsOnBoundary.end(); runner++) {
    349   //    Log() << Verbose(1) << " " << *runner->second;
     350  //    Log() << Verbose(0) << " " << *runner->second;
    350351  //  }
    351   //  Log() << Verbose(1) << endl;
     352  //  Log() << Verbose(0) << endl;
    352353
    353354  // 3a. guess starting triangle
     
    359360  // 3c. check whether all atoms lay inside the boundary, if not, add to boundary points, segment triangle into three with the new point
    360361  if (!TesselStruct->InsertStraddlingPoints(mol, LCList))
    361     Log() << Verbose(1) << "Insertion of straddling points failed!" << endl;
    362 
    363   Log() << Verbose(2) << "I created " << TesselStruct->TrianglesOnBoundary.size() << " intermediate triangles with " << TesselStruct->LinesOnBoundary.size() << " lines and " << TesselStruct->PointsOnBoundary.size() << " points." << endl;
     362    eLog() << Verbose(1) << "Insertion of straddling points failed!" << endl;
     363
     364  Log() << Verbose(0) << "I created " << TesselStruct->TrianglesOnBoundary.size() << " intermediate triangles with " << TesselStruct->LinesOnBoundary.size() << " lines and " << TesselStruct->PointsOnBoundary.size() << " points." << endl;
    364365
    365366  // 4. Store triangles in tecplot file
     
    411412//    Log() << Verbose(1) << "Correction of concave tesselpoints failed!" << endl;
    412413
    413   Log() << Verbose(2) << "I created " << TesselStruct->TrianglesOnBoundary.size() << " triangles with " << TesselStruct->LinesOnBoundary.size() << " lines and " << TesselStruct->PointsOnBoundary.size() << " points." << endl;
     414  Log() << Verbose(0) << "I created " << TesselStruct->TrianglesOnBoundary.size() << " triangles with " << TesselStruct->LinesOnBoundary.size() << " lines and " << TesselStruct->PointsOnBoundary.size() << " points." << endl;
    414415
    415416  // 4. Store triangles in tecplot file
     
    437438  if (BoundaryFreeFlag)
    438439    delete[] (BoundaryPoints);
    439 
    440   Log() << Verbose(1) << "End of FindConvexBorder" << endl;
    441440};
    442441
     
    450449bool RemoveAllBoundaryPoints(class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename)
    451450{
     451        Info FunctionInfo(__func__);
    452452  int i=0;
    453453  char number[MAXSTRINGSIZE];
     
    460460  PointMap::iterator PointRunner;
    461461  while (!TesselStruct->PointsOnBoundary.empty()) {
    462     Log() << Verbose(2) << "Remaining points are: ";
     462    Log() << Verbose(1) << "Remaining points are: ";
    463463    for (PointMap::iterator PointSprinter = TesselStruct->PointsOnBoundary.begin(); PointSprinter != TesselStruct->PointsOnBoundary.end(); PointSprinter++)
    464       Log() << Verbose(2) << *(PointSprinter->second) << "\t";
    465     Log() << Verbose(2) << endl;
     464      Log() << Verbose(0) << *(PointSprinter->second) << "\t";
     465    Log() << Verbose(0) << endl;
    466466
    467467    PointRunner = TesselStruct->PointsOnBoundary.begin();
     
    503503double ConvexizeNonconvexEnvelope(class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename)
    504504{
     505        Info FunctionInfo(__func__);
    505506  double volume = 0;
    506507  class BoundaryPointSet *point = NULL;
     
    516517  int run = 0;
    517518
    518   Log() << Verbose(0) << "Begin of ConvexizeNonconvexEnvelope" << endl;
    519 
    520519  // check whether there is something to work on
    521520  if (TesselStruct == NULL) {
     
    539538      for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) {
    540539        line = LineRunner->second;
    541         Log() << Verbose(2) << "INFO: Current line of point " << *point << " is " << *line << "." << endl;
     540        Log() << Verbose(1) << "INFO: Current line of point " << *point << " is " << *line << "." << endl;
    542541        if (!line->CheckConvexityCriterion()) {
    543542          // remove the point if needed
     
    604603
    605604  // end
    606   Log() << Verbose(1) << "Volume is " << volume << "." << endl;
    607   Log() << Verbose(0) << "End of ConvexizeNonconvexEnvelope" << endl;
     605  Log() << Verbose(0) << "Volume is " << volume << "." << endl;
    608606  return volume;
    609607};
     
    619617double VolumeOfConvexEnvelope(class Tesselation *TesselStruct, class config *configuration)
    620618{
     619        Info FunctionInfo(__func__);
    621620  bool IsAngstroem = configuration->GetIsAngstroem();
    622621  double volume = 0.;
     
    625624
    626625  // 6a. Every triangle forms a pyramid with the center of gravity as its peak, sum up the volumes
    627   Log() << Verbose(1)
    628       << "Calculating the volume of the pyramids formed out of triangles and center of gravity."
    629       << endl;
    630626  for (TriangleMap::iterator runner = TesselStruct->TrianglesOnBoundary.begin(); runner != TesselStruct->TrianglesOnBoundary.end(); runner++)
    631627    { // go through every triangle, calculate volume of its pyramid with CoG as peak
     
    642638      const double h = x.Norm(); // distance of CoG to triangle
    643639      const double PyramidVolume = (1. / 3.) * G * h; // this formula holds for _all_ pyramids (independent of n-edge base or (not) centered peak)
    644       Log() << Verbose(2) << "Area of triangle is " << setprecision(10) << G << " "
     640      Log() << Verbose(1) << "Area of triangle is " << setprecision(10) << G << " "
    645641          << (IsAngstroem ? "angstrom" : "atomiclength") << "^2, height is "
    646642          << h << " and the volume is " << PyramidVolume << " "
     
    658654 * \param *out output stream for debugging
    659655 * \param *mol molecule with atoms and bonds
    660  * \param *&TesselStruct Tesselation with boundary triangles
     656 * \param *TesselStruct Tesselation with boundary triangles
    661657 * \param *filename prefix of filename
    662658 * \param *extraSuffix intermediate suffix
    663659 */
    664 void StoreTrianglesinFile(const molecule * const mol, const Tesselation *&TesselStruct, const char *filename, const char *extraSuffix)
     660void StoreTrianglesinFile(const molecule * const mol, const Tesselation * const TesselStruct, const char *filename, const char *extraSuffix)
    665661{
     662        Info FunctionInfo(__func__);
    666663  // 4. Store triangles in tecplot file
    667664  if (filename != NULL) {
     
    671668      OutputName.append(TecplotSuffix);
    672669      ofstream *tecplot = new ofstream(OutputName.c_str());
    673       WriteTecplotFile(tecplot, TesselStruct, mol, 0);
     670      WriteTecplotFile(tecplot, TesselStruct, mol, -1);
    674671      tecplot->close();
    675672      delete(tecplot);
     
    698695void PrepareClustersinWater(config *configuration, molecule *mol, double ClusterVolume, double celldensity)
    699696{
     697        Info FunctionInfo(__func__);
    700698  bool IsAngstroem = true;
    701699  double *GreatestDiameter = NULL;
     
    791789 * \param configuration contains box dimensions
    792790 * \param distance[NDIM] distance between filling molecules in each direction
     791 * \param boundary length of boundary zone between molecule and filling mollecules
     792 * \param epsilon distance to surface which is not filled
    793793 * \param RandAtomDisplacement maximum distance for random displacement per atom
    794794 * \param RandMolDisplacement maximum distance for random displacement per filler molecule
     
    796796 * \return *mol pointer to new molecule with filled atoms
    797797 */
    798 molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, double distance[NDIM], double RandomAtomDisplacement, double RandomMolDisplacement, bool DoRandomRotation)
     798molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, const double distance[NDIM], const double boundary, const double RandomAtomDisplacement, const double RandomMolDisplacement, const bool DoRandomRotation)
    799799{
     800        Info FunctionInfo(__func__);
    800801  molecule *Filling = new molecule(filler->elemente);
    801802  Vector CurrentPosition;
     
    815816  class Tesselation *TesselStruct[List->ListOfMolecules.size()];
    816817
    817   Log() << Verbose(0) << "Begin of FillBoxWithMolecule" << endl;
    818 
    819818  i=0;
    820819  for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) {
    821820    Log() << Verbose(1) << "Pre-creating linked cell lists for molecule " << *ListRunner << "." << endl;
    822     LCList[i] = new LinkedCell((*ListRunner), 5.); // get linked cell list
    823     if (TesselStruct[i] == NULL) {
    824       Log() << Verbose(1) << "Pre-creating tesselation for molecule " << *ListRunner << "." << endl;
    825       FindNonConvexBorder((*ListRunner), TesselStruct[i], (const LinkedCell *&)LCList[i], 5., NULL);
    826     }
     821    LCList[i] = new LinkedCell((*ListRunner), 10.); // get linked cell list
     822    Log() << Verbose(1) << "Pre-creating tesselation for molecule " << *ListRunner << "." << endl;
     823    TesselStruct[i] = NULL;
     824    FindNonConvexBorder((*ListRunner), TesselStruct[i], (const LinkedCell *&)LCList[i], 5., NULL);
    827825    i++;
    828826  }
     
    838836  FillerDistance.Init(distance[0], distance[1], distance[2]);
    839837  FillerDistance.InverseMatrixMultiplication(M);
    840   Log() << Verbose(1) << "INFO: Grid steps are ";
    841   for(int i=0;i<NDIM;i++) {
     838  for(int i=0;i<NDIM;i++)
    842839    N[i] = (int) ceil(1./FillerDistance.x[i]);
    843     Log() << Verbose(1) << N[i];
    844     if (i != NDIM-1)
    845       Log() << Verbose(1)<< ", ";
    846     else
    847       Log() << Verbose(1) << "." << endl;
    848   }
     840  Log() << Verbose(1) << "INFO: Grid steps are " << N[0] << ", " << N[1] << ", " << N[2] << "." << endl;
    849841
    850842  // go over [0,1]^3 filler grid
     
    862854          // get linked cell list
    863855          if (TesselStruct[i] == NULL) {
    864             eLog() << Verbose(1) << "TesselStruct of " << (*ListRunner) << " is NULL. Didn't we pre-create it?" << endl;
     856            eLog() << Verbose(0) << "TesselStruct of " << (*ListRunner) << " is NULL. Didn't we pre-create it?" << endl;
    865857            FillIt = false;
    866858          } else {
    867             FillIt = FillIt && (!TesselStruct[i]->IsInnerPoint(CurrentPosition, LCList[i]));
     859            const double distance = (TesselStruct[i]->GetDistanceSquaredToSurface(CurrentPosition, LCList[i]));
     860            FillIt = FillIt && (distance > boundary*boundary);
     861            if (FillIt) {
     862              Log() << Verbose(1) << "INFO: Position at " << CurrentPosition << " is outer point." << endl;
     863            } else {
     864              Log() << Verbose(1) << "INFO: Position at " << CurrentPosition << " is inner point or within boundary." << endl;
     865              break;
     866            }
    868867            i++;
    869868          }
     
    877876          for (int i=0;i<NDIM;i++)
    878877            FillerTranslations.x[i] = RandomMolDisplacement*(rand()/(RAND_MAX/2.) - 1.);
    879           Log() << Verbose(3) << "INFO: Translating this filler by " << FillerTranslations << "." << endl;
     878          Log() << Verbose(2) << "INFO: Translating this filler by " << FillerTranslations << "." << endl;
    880879
    881880          // go through all atoms
     
    934933      }
    935934  Free(&M);
     935
     936  // output to file
     937  TesselStruct[0]->LastTriangle = NULL;
     938  StoreTrianglesinFile(Filling, TesselStruct[0], "Tesselated", ".dat");
     939
    936940  for (size_t i=0;i<List->ListOfMolecules.size();i++) {
    937941        delete(LCList[i]);
    938942        delete(TesselStruct[i]);
    939943  }
    940   Log() << Verbose(0) << "End of FillBoxWithMolecule" << endl;
    941 
    942944  return Filling;
    943945};
     
    951953 * \param RADIUS radius of the virtual sphere
    952954 * \param *filename filename prefix for output of vertex data
    953  */
    954 void FindNonConvexBorder(const molecule* const mol, Tesselation *&TesselStruct, const LinkedCell *&LCList, const double RADIUS, const char *filename = NULL)
     955 * \return true - tesselation successful, false - tesselation failed
     956 */
     957bool FindNonConvexBorder(const molecule* const mol, Tesselation *&TesselStruct, const LinkedCell *&LCList, const double RADIUS, const char *filename = NULL)
    955958{
     959        Info FunctionInfo(__func__);
    956960  bool freeLC = false;
    957   LineMap::iterator baseline;
     961  bool status = false;
     962  CandidateForTesselation *baseline;
    958963  LineMap::iterator testline;
    959   bool OneLoopWithoutSuccessFlag = false;  // marks whether we went once through all baselines without finding any without two triangles
     964  bool OneLoopWithoutSuccessFlag = true;  // marks whether we went once through all baselines without finding any without two triangles
    960965  bool TesselationFailFlag = false;
    961 
    962   Log() << Verbose(1) << "Entering search for non convex hull. " << endl;
     966  BoundaryTriangleSet *T = NULL;
     967
    963968  if (TesselStruct == NULL) {
    964969    Log() << Verbose(1) << "Allocating Tesselation struct ..." << endl;
     
    970975  }
    971976
    972   Log() << Verbose(0) << "Begin of FindNonConvexBorder\n";
    973 
    974977  // initialise Linked Cell
    975978  if (LCList == NULL) {
     
    982985
    983986  // 2. expand from there
    984   baseline = TesselStruct->LinesOnBoundary.begin();
    985   baseline++; // skip first line
    986   while ((baseline != TesselStruct->LinesOnBoundary.end()) || (OneLoopWithoutSuccessFlag)) {
    987     if (baseline->second->triangles.size() == 1) {
    988       CheckListOfBaselines(TesselStruct);
    989       // 3. find next triangle
    990       TesselationFailFlag = TesselStruct->FindNextSuitableTriangle(*(baseline->second), *(((baseline->second->triangles.begin()))->second), RADIUS, LCList); //the line is there, so there is a triangle, but only one.
    991       OneLoopWithoutSuccessFlag = OneLoopWithoutSuccessFlag || TesselationFailFlag;
    992       if (!TesselationFailFlag)
    993         eLog() << Verbose(2) << "FindNextSuitableTriangle failed." << endl;
    994 
    995       // write temporary envelope
    996       if (filename != NULL) {
    997         if ((DoSingleStepOutput && ((TesselStruct->TrianglesOnBoundary.size() % SingleStepWidth == 0)))) { // if we have a new triangle and want to output each new triangle configuration
    998           TesselStruct->Output(filename, mol);
    999         }
     987  while ((!TesselStruct->OpenLines.empty()) && (OneLoopWithoutSuccessFlag)) {
     988    // 2a. fill all new OpenLines
     989    Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for candidates:" << endl;
     990    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++)
     991      Log() << Verbose(2) << *(Runner->second) << endl;
     992
     993    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
     994      baseline = Runner->second;
     995      if (baseline->pointlist.empty()) {
     996        T = (((baseline->BaseLine->triangles.begin()))->second);
     997        Log() << Verbose(1) << "Finding best candidate for open line " << *baseline->BaseLine << " of triangle " << *T << endl;
     998        TesselationFailFlag = TesselStruct->FindNextSuitableTriangle(*baseline, *T, RADIUS, LCList); //the line is there, so there is a triangle, but only one.
    1000999      }
    1001       if (TesselationFailFlag) {
    1002         baseline = TesselStruct->LinesOnBoundary.begin();
    1003         OneLoopWithoutSuccessFlag = false;
    1004         Log() << Verbose(2) << "Baseline set to begin." << endl;
     1000    }
     1001
     1002    // 2b. search for smallest ShortestAngle among all candidates
     1003    double ShortestAngle = 4.*M_PI;
     1004    Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for the best candidates:" << endl;
     1005    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++)
     1006      Log() << Verbose(2) << *(Runner->second) << endl;
     1007
     1008    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
     1009      if (Runner->second->ShortestAngle < ShortestAngle) {
     1010        baseline = Runner->second;
     1011        ShortestAngle = baseline->ShortestAngle;
     1012        //Log() << Verbose(1) << "New best candidate is " << *baseline->BaseLine << " with point " << *baseline->point << " and angle " << baseline->ShortestAngle << endl;
    10051013      }
    1006     } else {
    1007       //Log() << Verbose(1) << "Line " << *baseline->second << " has " << baseline->second->triangles.size() << " triangles adjacent" << endl;
    1008       if (baseline->second->triangles.size() != 2) {
    1009         eLog() << Verbose(0) << "TESSELATION FINISHED WITH INVALID TRIANGLE COUNT!" << endl;
    1010         performCriticalExit();
     1014    }
     1015    if ((ShortestAngle == 4.*M_PI) || (baseline->pointlist.empty()))
     1016      OneLoopWithoutSuccessFlag = false;
     1017    else {
     1018      TesselStruct->AddCandidateTriangle(*baseline);
     1019    }
     1020
     1021    // write temporary envelope
     1022    if (filename != NULL) {
     1023      if ((DoSingleStepOutput && ((TesselStruct->TrianglesOnBoundary.size() % SingleStepWidth == 0)))) { // if we have a new triangle and want to output each new triangle configuration
     1024        TesselStruct->Output(filename, mol);
    10111025      }
    10121026    }
    1013 
    1014     if ((baseline == TesselStruct->LinesOnBoundary.end()) && (OneLoopWithoutSuccessFlag)) {
    1015       baseline = TesselStruct->LinesOnBoundary.begin();   // restart if we reach end due to newly inserted lines
    1016       OneLoopWithoutSuccessFlag = false;
    1017     }
    1018     baseline++;
    1019   }
    1020   // check envelope for consistency
    1021   CheckListOfBaselines(TesselStruct);
    1022 
    1023   // look whether all points are inside of the convex envelope, otherwise add them via degenerated triangles
    1024   //->InsertStraddlingPoints(mol, LCList);
     1027  }
     1028//  // check envelope for consistency
     1029//  status = CheckListOfBaselines(TesselStruct);
     1030//
     1031//  // look whether all points are inside of the convex envelope, otherwise add them via degenerated triangles
     1032//  //->InsertStraddlingPoints(mol, LCList);
    10251033//  mol->GoToFirst();
    10261034//  class TesselPoint *Runner = NULL;
     
    10371045//  }
    10381046
    1039   // Purges surplus triangles.
    1040   TesselStruct->RemoveDegeneratedTriangles();
     1047//  // Purges surplus triangles.
     1048//  TesselStruct->RemoveDegeneratedTriangles();
    10411049
    10421050  // check envelope for consistency
    1043   CheckListOfBaselines(TesselStruct);
     1051  status = CheckListOfBaselines(TesselStruct);
     1052
     1053  // store before correction
     1054  StoreTrianglesinFile(mol, (const Tesselation *&)TesselStruct, filename, "");
     1055
     1056  // correct degenerated polygons
     1057  TesselStruct->CorrectAllDegeneratedPolygons();
     1058
     1059  // check envelope for consistency
     1060  status = CheckListOfBaselines(TesselStruct);
    10441061
    10451062  // write final envelope
     
    10491066  if (freeLC)
    10501067    delete(LCList);
    1051   Log() << Verbose(0) << "End of FindNonConvexBorder\n";
     1068
     1069  return status;
    10521070};
    10531071
     
    10611079Vector* FindEmbeddingHole(MoleculeListClass *mols, molecule *srcmol)
    10621080{
     1081        Info FunctionInfo(__func__);
    10631082  Vector *Center = new Vector;
    10641083  Center->Zero();
  • TabularUnified src/boundary.hpp

    r9fe36b rb8d1aeb  
    3535
    3636#define DEBUG 1
    37 #define DoSingleStepOutput 1
    38 #define SingleStepWidth 1
     37#define DoSingleStepOutput 0
     38#define SingleStepWidth 10
    3939
    4040#define DistancePair pair < double, atom* >
     
    4949
    5050double ConvexizeNonconvexEnvelope(class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename);
    51 molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, double distance[NDIM], double RandAtomDisplacement, double RandMolDisplacement, bool DoRandomRotation);
     51molecule * FillBoxWithMolecule(MoleculeListClass *List, molecule *filler, config &configuration, const double distance[NDIM], const double boundary, const double RandomAtomDisplacement, const double RandomMolDisplacement, const bool DoRandomRotation);
    5252void FindConvexBorder(const molecule* const mol, Tesselation *&TesselStruct, const LinkedCell *LCList, const char *filename);
    5353Vector* FindEmbeddingHole(MoleculeListClass *mols, molecule *srcmol);
    5454void FindNextSuitablePoint(class BoundaryTriangleSet *BaseTriangle, class BoundaryLineSet *BaseLine, atom*& OptCandidate, Vector *OptCandidateCenter, double *ShortestAngle, const double RADIUS, LinkedCell *LC);
    55 void FindNonConvexBorder(const molecule* const mol, Tesselation *&TesselStruct, const LinkedCell *&LC, const double RADIUS, const char *tempbasename);
     55bool FindNonConvexBorder(const molecule* const mol, Tesselation *&TesselStruct, const LinkedCell *&LC, const double RADIUS, const char *tempbasename);
    5656Boundaries *GetBoundaryPoints(const molecule *mol, Tesselation *&TesselStruct);
    5757double * GetDiametersOfCluster(const Boundaries *BoundaryPtr, const molecule *mol, Tesselation *&TesselStruct, const bool IsAngstroem);
    5858void PrepareClustersinWater(config *configuration, molecule *mol, double ClusterVolume, double celldensity);
    5959bool RemoveAllBoundaryPoints(class Tesselation *&TesselStruct, const molecule * const mol, const char * const filename);
    60 void StoreTrianglesinFile(const molecule * const mol, const Tesselation *&TesselStruct, const char *filename, const char *extraSuffix);
     60void StoreTrianglesinFile(const molecule * const mol, const Tesselation * const TesselStruct, const char *filename, const char *extraSuffix);
    6161double VolumeOfConvexEnvelope(class Tesselation *TesselStruct, class config *configuration);
    6262
  • TabularUnified src/builder.cpp

    r9fe36b rb8d1aeb  
    5252using namespace std;
    5353
     54#include <cstring>
     55
    5456#include "analysis_correlation.hpp"
    5557#include "atom.hpp"
     
    7476#include "Actions/MethodAction.hpp"
    7577#include "Actions/small_actions.hpp"
    76 
     78#include "version.h"
     79
     80/********************************************* Subsubmenu routine ************************************/
     81#if 0
     82/** Submenu for adding atoms to the molecule.
     83 * \param *periode periodentafel
     84 * \param *molecule molecules with atoms
     85 */
     86static void AddAtoms(periodentafel *periode, molecule *mol)
     87{
     88  atom *first, *second, *third, *fourth;
     89  Vector **atoms;
     90  Vector x,y,z,n;  // coordinates for absolute point in cell volume
     91  double a,b,c;
     92  char choice;  // menu choice char
     93  bool valid;
     94
     95  Log() << Verbose(0) << "===========ADD ATOM============================" << endl;
     96  Log() << Verbose(0) << " a - state absolute coordinates of atom" << endl;
     97  Log() << Verbose(0) << " b - state relative coordinates of atom wrt to reference point" << endl;
     98  Log() << Verbose(0) << " c - state relative coordinates of atom wrt to already placed atom" << endl;
     99  Log() << Verbose(0) << " d - state two atoms, two angles and a distance" << endl;
     100  Log() << Verbose(0) << " e - least square distance position to a set of atoms" << endl;
     101  Log() << Verbose(0) << "all else - go back" << endl;
     102  Log() << Verbose(0) << "===============================================" << endl;
     103  Log() << Verbose(0) << "Note: Specifiy angles in degrees not multiples of Pi!" << endl;
     104  Log() << Verbose(0) << "INPUT: ";
     105  cin >> choice;
     106
     107  switch (choice) {
     108    default:
     109      eLog() << Verbose(2) << "Not a valid choice." << endl;
     110      break;
     111      case 'a': // absolute coordinates of atom
     112        Log() << Verbose(0) << "Enter absolute coordinates." << endl;
     113        first = new atom;
     114        first->x.AskPosition(mol->cell_size, false);
     115        first->type = periode->AskElement();  // give type
     116        mol->AddAtom(first);  // add to molecule
     117        break;
     118
     119      case 'b': // relative coordinates of atom wrt to reference point
     120        first = new atom;
     121        valid = true;
     122        do {
     123          if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
     124          Log() << Verbose(0) << "Enter reference coordinates." << endl;
     125          x.AskPosition(mol->cell_size, true);
     126          Log() << Verbose(0) << "Enter relative coordinates." << endl;
     127          first->x.AskPosition(mol->cell_size, false);
     128          first->x.AddVector((const Vector *)&x);
     129          Log() << Verbose(0) << "\n";
     130        } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
     131        first->type = periode->AskElement();  // give type
     132        mol->AddAtom(first);  // add to molecule
     133        break;
     134
     135      case 'c': // relative coordinates of atom wrt to already placed atom
     136        first = new atom;
     137        valid = true;
     138        do {
     139          if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
     140          second = mol->AskAtom("Enter atom number: ");
     141          Log() << Verbose(0) << "Enter relative coordinates." << endl;
     142          first->x.AskPosition(mol->cell_size, false);
     143          for (int i=NDIM;i--;) {
     144            first->x.x[i] += second->x.x[i];
     145          }
     146        } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
     147        first->type = periode->AskElement();  // give type
     148        mol->AddAtom(first);  // add to molecule
     149        break;
     150
     151    case 'd': // two atoms, two angles and a distance
     152        first = new atom;
     153        valid = true;
     154        do {
     155          if (!valid) {
     156            eLog() << Verbose(2) << "Resulting coordinates out of cell - " << first->x << endl;
     157          }
     158          Log() << Verbose(0) << "First, we need two atoms, the first atom is the central, while the second is the outer one." << endl;
     159          second = mol->AskAtom("Enter central atom: ");
     160          third = mol->AskAtom("Enter second atom (specifying the axis for first angle): ");
     161          fourth = mol->AskAtom("Enter third atom (specifying a plane for second angle): ");
     162          a = ask_value("Enter distance between central (first) and new atom: ");
     163          b = ask_value("Enter angle between new, first and second atom (degrees): ");
     164          b *= M_PI/180.;
     165          bound(&b, 0., 2.*M_PI);
     166          c = ask_value("Enter second angle between new and normal vector of plane defined by first, second and third atom (degrees): ");
     167          c *= M_PI/180.;
     168          bound(&c, -M_PI, M_PI);
     169          Log() << Verbose(0) << "radius: " << a << "\t phi: " << b*180./M_PI << "\t theta: " << c*180./M_PI << endl;
     170/*
     171          second->Output(1,1,(ofstream *)&cout);
     172          third->Output(1,2,(ofstream *)&cout);
     173          fourth->Output(1,3,(ofstream *)&cout);
     174          n.MakeNormalvector((const vector *)&second->x, (const vector *)&third->x, (const vector *)&fourth->x);
     175          x.Copyvector(&second->x);
     176          x.SubtractVector(&third->x);
     177          x.Copyvector(&fourth->x);
     178          x.SubtractVector(&third->x);
     179
     180          if (!z.SolveSystem(&x,&y,&n, b, c, a)) {
     181            Log() << Verbose(0) << "Failure solving self-dependent linear system!" << endl;
     182            continue;
     183          }
     184          Log() << Verbose(0) << "resulting relative coordinates: ";
     185          z.Output();
     186          Log() << Verbose(0) << endl;
     187          */
     188          // calc axis vector
     189          x.CopyVector(&second->x);
     190          x.SubtractVector(&third->x);
     191          x.Normalize();
     192          Log() << Verbose(0) << "x: ",
     193          x.Output();
     194          Log() << Verbose(0) << endl;
     195          z.MakeNormalVector(&second->x,&third->x,&fourth->x);
     196          Log() << Verbose(0) << "z: ",
     197          z.Output();
     198          Log() << Verbose(0) << endl;
     199          y.MakeNormalVector(&x,&z);
     200          Log() << Verbose(0) << "y: ",
     201          y.Output();
     202          Log() << Verbose(0) << endl;
     203
     204          // rotate vector around first angle
     205          first->x.CopyVector(&x);
     206          first->x.RotateVector(&z,b - M_PI);
     207          Log() << Verbose(0) << "Rotated vector: ",
     208          first->x.Output();
     209          Log() << Verbose(0) << endl;
     210          // remove the projection onto the rotation plane of the second angle
     211          n.CopyVector(&y);
     212          n.Scale(first->x.ScalarProduct(&y));
     213          Log() << Verbose(0) << "N1: ",
     214          n.Output();
     215          Log() << Verbose(0) << endl;
     216          first->x.SubtractVector(&n);
     217          Log() << Verbose(0) << "Subtracted vector: ",
     218          first->x.Output();
     219          Log() << Verbose(0) << endl;
     220          n.CopyVector(&z);
     221          n.Scale(first->x.ScalarProduct(&z));
     222          Log() << Verbose(0) << "N2: ",
     223          n.Output();
     224          Log() << Verbose(0) << endl;
     225          first->x.SubtractVector(&n);
     226          Log() << Verbose(0) << "2nd subtracted vector: ",
     227          first->x.Output();
     228          Log() << Verbose(0) << endl;
     229
     230          // rotate another vector around second angle
     231          n.CopyVector(&y);
     232          n.RotateVector(&x,c - M_PI);
     233          Log() << Verbose(0) << "2nd Rotated vector: ",
     234          n.Output();
     235          Log() << Verbose(0) << endl;
     236
     237          // add the two linear independent vectors
     238          first->x.AddVector(&n);
     239          first->x.Normalize();
     240          first->x.Scale(a);
     241          first->x.AddVector(&second->x);
     242
     243          Log() << Verbose(0) << "resulting coordinates: ";
     244          first->x.Output();
     245          Log() << Verbose(0) << endl;
     246        } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
     247        first->type = periode->AskElement();  // give type
     248        mol->AddAtom(first);  // add to molecule
     249        break;
     250
     251      case 'e': // least square distance position to a set of atoms
     252        first = new atom;
     253        atoms = new (Vector*[128]);
     254        valid = true;
     255        for(int i=128;i--;)
     256          atoms[i] = NULL;
     257        int i=0, j=0;
     258        Log() << Verbose(0) << "Now we need at least three molecules.\n";
     259        do {
     260          Log() << Verbose(0) << "Enter " << i+1 << "th atom: ";
     261          cin >> j;
     262          if (j != -1) {
     263            second = mol->FindAtom(j);
     264            atoms[i++] = &(second->x);
     265          }
     266        } while ((j != -1) && (i<128));
     267        if (i >= 2) {
     268          first->x.LSQdistance((const Vector **)atoms, i);
     269
     270          first->x.Output();
     271          first->type = periode->AskElement();  // give type
     272          mol->AddAtom(first);  // add to molecule
     273        } else {
     274          delete first;
     275          Log() << Verbose(0) << "Please enter at least two vectors!\n";
     276        }
     277        break;
     278  };
     279};
     280
     281/** Submenu for centering the atoms in the molecule.
     282 * \param *mol molecule with all the atoms
     283 */
     284static void CenterAtoms(molecule *mol)
     285{
     286  Vector x, y, helper;
     287  char choice;  // menu choice char
     288
     289  Log() << Verbose(0) << "===========CENTER ATOMS=========================" << endl;
     290  Log() << Verbose(0) << " a - on origin" << endl;
     291  Log() << Verbose(0) << " b - on center of gravity" << endl;
     292  Log() << Verbose(0) << " c - within box with additional boundary" << endl;
     293  Log() << Verbose(0) << " d - within given simulation box" << endl;
     294  Log() << Verbose(0) << "all else - go back" << endl;
     295  Log() << Verbose(0) << "===============================================" << endl;
     296  Log() << Verbose(0) << "INPUT: ";
     297  cin >> choice;
     298
     299  switch (choice) {
     300    default:
     301      Log() << Verbose(0) << "Not a valid choice." << endl;
     302      break;
     303    case 'a':
     304      Log() << Verbose(0) << "Centering atoms in config file on origin." << endl;
     305      mol->CenterOrigin();
     306      break;
     307    case 'b':
     308      Log() << Verbose(0) << "Centering atoms in config file on center of gravity." << endl;
     309      mol->CenterPeriodic();
     310      break;
     311    case 'c':
     312      Log() << Verbose(0) << "Centering atoms in config file within given additional boundary." << endl;
     313      for (int i=0;i<NDIM;i++) {
     314        Log() << Verbose(0) << "Enter axis " << i << " boundary: ";
     315        cin >> y.x[i];
     316      }
     317      mol->CenterEdge(&x);  // make every coordinate positive
     318      mol->Center.AddVector(&y); // translate by boundary
     319      helper.CopyVector(&y);
     320      helper.Scale(2.);
     321      helper.AddVector(&x);
     322      mol->SetBoxDimension(&helper);  // update Box of atoms by boundary
     323      break;
     324    case 'd':
     325      Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
     326      for (int i=0;i<NDIM;i++) {
     327        Log() << Verbose(0) << "Enter axis " << i << " boundary: ";
     328        cin >> x.x[i];
     329      }
     330      // update Box of atoms by boundary
     331      mol->SetBoxDimension(&x);
     332      // center
     333      mol->CenterInBox();
     334      break;
     335  }
     336};
     337
     338/** Submenu for aligning the atoms in the molecule.
     339 * \param *periode periodentafel
     340 * \param *mol molecule with all the atoms
     341 */
     342static void AlignAtoms(periodentafel *periode, molecule *mol)
     343{
     344  atom *first, *second, *third;
     345  Vector x,n;
     346  char choice;  // menu choice char
     347
     348  Log() << Verbose(0) << "===========ALIGN ATOMS=========================" << endl;
     349  Log() << Verbose(0) << " a - state three atoms defining align plane" << endl;
     350  Log() << Verbose(0) << " b - state alignment vector" << endl;
     351  Log() << Verbose(0) << " c - state two atoms in alignment direction" << endl;
     352  Log() << Verbose(0) << " d - align automatically by least square fit" << endl;
     353  Log() << Verbose(0) << "all else - go back" << endl;
     354  Log() << Verbose(0) << "===============================================" << endl;
     355  Log() << Verbose(0) << "INPUT: ";
     356  cin >> choice;
     357
     358  switch (choice) {
     359    default:
     360    case 'a': // three atoms defining mirror plane
     361      first = mol->AskAtom("Enter first atom: ");
     362      second = mol->AskAtom("Enter second atom: ");
     363      third = mol->AskAtom("Enter third atom: ");
     364
     365      n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);
     366      break;
     367    case 'b': // normal vector of mirror plane
     368      Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl;
     369      n.AskPosition(mol->cell_size,0);
     370      n.Normalize();
     371      break;
     372    case 'c': // three atoms defining mirror plane
     373      first = mol->AskAtom("Enter first atom: ");
     374      second = mol->AskAtom("Enter second atom: ");
     375
     376      n.CopyVector((const Vector *)&first->x);
     377      n.SubtractVector((const Vector *)&second->x);
     378      n.Normalize();
     379      break;
     380    case 'd':
     381      char shorthand[4];
     382      Vector a;
     383      struct lsq_params param;
     384      do {
     385        fprintf(stdout, "Enter the element of atoms to be chosen: ");
     386        fscanf(stdin, "%3s", shorthand);
     387      } while ((param.type = periode->FindElement(shorthand)) == NULL);
     388      Log() << Verbose(0) << "Element is " << param.type->name << endl;
     389      mol->GetAlignvector(&param);
     390      for (int i=NDIM;i--;) {
     391        x.x[i] = gsl_vector_get(param.x,i);
     392        n.x[i] = gsl_vector_get(param.x,i+NDIM);
     393      }
     394      gsl_vector_free(param.x);
     395      Log() << Verbose(0) << "Offset vector: ";
     396      x.Output();
     397      Log() << Verbose(0) << endl;
     398      n.Normalize();
     399      break;
     400  };
     401  Log() << Verbose(0) << "Alignment vector: ";
     402  n.Output();
     403  Log() << Verbose(0) << endl;
     404  mol->Align(&n);
     405};
     406
     407/** Submenu for mirroring the atoms in the molecule.
     408 * \param *mol molecule with all the atoms
     409 */
     410static void MirrorAtoms(molecule *mol)
     411{
     412  atom *first, *second, *third;
     413  Vector n;
     414  char choice;  // menu choice char
     415
     416  Log() << Verbose(0) << "===========MIRROR ATOMS=========================" << endl;
     417  Log() << Verbose(0) << " a - state three atoms defining mirror plane" << endl;
     418  Log() << Verbose(0) << " b - state normal vector of mirror plane" << endl;
     419  Log() << Verbose(0) << " c - state two atoms in normal direction" << endl;
     420  Log() << Verbose(0) << "all else - go back" << endl;
     421  Log() << Verbose(0) << "===============================================" << endl;
     422  Log() << Verbose(0) << "INPUT: ";
     423  cin >> choice;
     424
     425  switch (choice) {
     426    default:
     427    case 'a': // three atoms defining mirror plane
     428      first = mol->AskAtom("Enter first atom: ");
     429      second = mol->AskAtom("Enter second atom: ");
     430      third = mol->AskAtom("Enter third atom: ");
     431
     432      n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);
     433      break;
     434    case 'b': // normal vector of mirror plane
     435      Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl;
     436      n.AskPosition(mol->cell_size,0);
     437      n.Normalize();
     438      break;
     439    case 'c': // three atoms defining mirror plane
     440      first = mol->AskAtom("Enter first atom: ");
     441      second = mol->AskAtom("Enter second atom: ");
     442
     443      n.CopyVector((const Vector *)&first->x);
     444      n.SubtractVector((const Vector *)&second->x);
     445      n.Normalize();
     446      break;
     447  };
     448  Log() << Verbose(0) << "Normal vector: ";
     449  n.Output();
     450  Log() << Verbose(0) << endl;
     451  mol->Mirror((const Vector *)&n);
     452};
     453>>>>>>> MenuRefactoring:molecuilder/src/builder.cpp
     454
     455/** Submenu for removing the atoms from the molecule.
     456 * \param *mol molecule with all the atoms
     457 */
     458static void RemoveAtoms(molecule *mol)
     459{
     460  atom *first, *second;
     461  int axis;
     462  double tmp1, tmp2;
     463  char choice;  // menu choice char
     464
     465  Log() << Verbose(0) << "===========REMOVE ATOMS=========================" << endl;
     466  Log() << Verbose(0) << " a - state atom for removal by number" << endl;
     467  Log() << Verbose(0) << " b - keep only in radius around atom" << endl;
     468  Log() << Verbose(0) << " c - remove this with one axis greater value" << endl;
     469  Log() << Verbose(0) << "all else - go back" << endl;
     470  Log() << Verbose(0) << "===============================================" << endl;
     471  Log() << Verbose(0) << "INPUT: ";
     472  cin >> choice;
     473
     474  switch (choice) {
     475    default:
     476    case 'a':
     477      if (mol->RemoveAtom(mol->AskAtom("Enter number of atom within molecule: ")))
     478        Log() << Verbose(1) << "Atom removed." << endl;
     479      else
     480        Log() << Verbose(1) << "Atom not found." << endl;
     481      break;
     482    case 'b':
     483      second = mol->AskAtom("Enter number of atom as reference point: ");
     484      Log() << Verbose(0) << "Enter radius: ";
     485      cin >> tmp1;
     486      first = mol->start;
     487      second = first->next;
     488      while(second != mol->end) {
     489        first = second;
     490        second = first->next;
     491        if (first->x.DistanceSquared((const Vector *)&second->x) > tmp1*tmp1) // distance to first above radius ...
     492          mol->RemoveAtom(first);
     493      }
     494      break;
     495    case 'c':
     496      Log() << Verbose(0) << "Which axis is it: ";
     497      cin >> axis;
     498      Log() << Verbose(0) << "Lower boundary: ";
     499      cin >> tmp1;
     500      Log() << Verbose(0) << "Upper boundary: ";
     501      cin >> tmp2;
     502      first = mol->start;
     503      second = first->next;
     504      while(second != mol->end) {
     505        first = second;
     506        second = first->next;
     507        if ((first->x.x[axis] < tmp1) || (first->x.x[axis] > tmp2)) {// out of boundary ...
     508          //Log() << Verbose(0) << "Atom " << *first << " with " << first->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
     509          mol->RemoveAtom(first);
     510        }
     511      }
     512      break;
     513  };
     514  //mol->Output();
     515  choice = 'r';
     516};
     517
     518/** Submenu for measuring out the atoms in the molecule.
     519 * \param *periode periodentafel
     520 * \param *mol molecule with all the atoms
     521 */
     522static void MeasureAtoms(periodentafel *periode, molecule *mol, config *configuration)
     523{
     524  atom *first, *second, *third;
     525  Vector x,y;
     526  double min[256], tmp1, tmp2, tmp3;
     527  int Z;
     528  char choice;  // menu choice char
     529
     530  Log() << Verbose(0) << "===========MEASURE ATOMS=========================" << endl;
     531  Log() << Verbose(0) << " a - calculate bond length between one atom and all others" << endl;
     532  Log() << Verbose(0) << " b - calculate bond length between two atoms" << endl;
     533  Log() << Verbose(0) << " c - calculate bond angle" << endl;
     534  Log() << Verbose(0) << " d - calculate principal axis of the system" << endl;
     535  Log() << Verbose(0) << " e - calculate volume of the convex envelope" << endl;
     536  Log() << Verbose(0) << " f - calculate temperature from current velocity" << endl;
     537  Log() << Verbose(0) << " g - output all temperatures per step from velocities" << endl;
     538  Log() << Verbose(0) << "all else - go back" << endl;
     539  Log() << Verbose(0) << "===============================================" << endl;
     540  Log() << Verbose(0) << "INPUT: ";
     541  cin >> choice;
     542
     543  switch(choice) {
     544    default:
     545      Log() << Verbose(1) << "Not a valid choice." << endl;
     546      break;
     547    case 'a':
     548      first = mol->AskAtom("Enter first atom: ");
     549      for (int i=MAX_ELEMENTS;i--;)
     550        min[i] = 0.;
     551
     552      second = mol->start;
     553      while ((second->next != mol->end)) {
     554        second = second->next; // advance
     555        Z = second->type->Z;
     556        tmp1 = 0.;
     557        if (first != second) {
     558          x.CopyVector((const Vector *)&first->x);
     559          x.SubtractVector((const Vector *)&second->x);
     560          tmp1 = x.Norm();
     561        }
     562        if ((tmp1 != 0.) && ((min[Z] == 0.) || (tmp1 < min[Z]))) min[Z] = tmp1;
     563        //Log() << Verbose(0) << "Bond length between Atom " << first->nr << " and " << second->nr << ": " << tmp1 << " a.u." << endl;
     564      }
     565      for (int i=MAX_ELEMENTS;i--;)
     566        if (min[i] != 0.) Log() << Verbose(0) << "Minimum Bond length between " << first->type->name << " Atom " << first->nr << " and next Ion of type " << (periode->FindElement(i))->name << ": " << min[i] << " a.u." << endl;
     567      break;
     568
     569    case 'b':
     570      first = mol->AskAtom("Enter first atom: ");
     571      second = mol->AskAtom("Enter second atom: ");
     572      for (int i=NDIM;i--;)
     573        min[i] = 0.;
     574      x.CopyVector((const Vector *)&first->x);
     575      x.SubtractVector((const Vector *)&second->x);
     576      tmp1 = x.Norm();
     577      Log() << Verbose(1) << "Distance vector is ";
     578      x.Output();
     579      Log() << Verbose(0) << "." << endl << "Norm of distance is " << tmp1 << "." << endl;
     580      break;
     581
     582    case 'c':
     583      Log() << Verbose(0) << "Evaluating bond angle between three - first, central, last - atoms." << endl;
     584      first = mol->AskAtom("Enter first atom: ");
     585      second = mol->AskAtom("Enter central atom: ");
     586      third  = mol->AskAtom("Enter last atom: ");
     587      tmp1 = tmp2 = tmp3 = 0.;
     588      x.CopyVector((const Vector *)&first->x);
     589      x.SubtractVector((const Vector *)&second->x);
     590      y.CopyVector((const Vector *)&third->x);
     591      y.SubtractVector((const Vector *)&second->x);
     592      Log() << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ";
     593      Log() << Verbose(0) << (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl;
     594      break;
     595    case 'd':
     596      Log() << Verbose(0) << "Evaluating prinicipal axis." << endl;
     597      Log() << Verbose(0) << "Shall we rotate? [0/1]: ";
     598      cin >> Z;
     599      if ((Z >=0) && (Z <=1))
     600        mol->PrincipalAxisSystem((bool)Z);
     601      else
     602        mol->PrincipalAxisSystem(false);
     603      break;
     604    case 'e':
     605      {
     606        Log() << Verbose(0) << "Evaluating volume of the convex envelope.";
     607        class Tesselation *TesselStruct = NULL;
     608        const LinkedCell *LCList = NULL;
     609        LCList = new LinkedCell(mol, 10.);
     610        FindConvexBorder(mol, TesselStruct, LCList, NULL);
     611        double clustervolume = VolumeOfConvexEnvelope(TesselStruct, configuration);
     612        Log() << Verbose(0) << "The tesselated surface area is " << clustervolume << "." << endl;\
     613        delete(LCList);
     614        delete(TesselStruct);
     615      }
     616      break;
     617    case 'f':
     618      mol->OutputTemperatureFromTrajectories((ofstream *)&cout, mol->MDSteps-1, mol->MDSteps);
     619      break;
     620    case 'g':
     621      {
     622        char filename[255];
     623        Log() << Verbose(0) << "Please enter filename: " << endl;
     624        cin >> filename;
     625        Log() << Verbose(1) << "Storing temperatures in " << filename << "." << endl;
     626        ofstream *output = new ofstream(filename, ios::trunc);
     627        if (!mol->OutputTemperatureFromTrajectories(output, 0, mol->MDSteps))
     628          Log() << Verbose(2) << "File could not be written." << endl;
     629        else
     630          Log() << Verbose(2) << "File stored." << endl;
     631        output->close();
     632        delete(output);
     633      }
     634      break;
     635  }
     636};
     637
     638/** Submenu for measuring out the atoms in the molecule.
     639 * \param *mol molecule with all the atoms
     640 * \param *configuration configuration structure for the to be written config files of all fragments
     641 */
     642static void FragmentAtoms(molecule *mol, config *configuration)
     643{
     644  int Order1;
     645  clock_t start, end;
     646
     647  Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl;
     648  Log() << Verbose(0) << "What's the desired bond order: ";
     649  cin >> Order1;
     650  if (mol->first->next != mol->last) {  // there are bonds
     651    start = clock();
     652    mol->FragmentMolecule(Order1, configuration);
     653    end = clock();
     654    Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
     655  } else
     656    Log() << Verbose(0) << "Connection matrix has not yet been generated!" << endl;
     657};
     658
     659/********************************************** Submenu routine **************************************/
     660
     661/** Submenu for manipulating atoms.
     662 * \param *periode periodentafel
     663 * \param *molecules list of molecules whose atoms are to be manipulated
     664 */
     665static void ManipulateAtoms(periodentafel *periode, MoleculeListClass *molecules, config *configuration)
     666{
     667  atom *first, *second;
     668  molecule *mol = NULL;
     669  Vector x,y,z,n; // coordinates for absolute point in cell volume
     670  double *factor; // unit factor if desired
     671  double bond, minBond;
     672  char choice;  // menu choice char
     673  bool valid;
     674
     675  Log() << Verbose(0) << "=========MANIPULATE ATOMS======================" << endl;
     676  Log() << Verbose(0) << "a - add an atom" << endl;
     677  Log() << Verbose(0) << "r - remove an atom" << endl;
     678  Log() << Verbose(0) << "b - scale a bond between atoms" << endl;
     679  Log() << Verbose(0) << "u - change an atoms element" << endl;
     680  Log() << Verbose(0) << "l - measure lengths, angles, ... for an atom" << endl;
     681  Log() << Verbose(0) << "all else - go back" << endl;
     682  Log() << Verbose(0) << "===============================================" << endl;
     683  if (molecules->NumberOfActiveMolecules() > 1)
     684    eLog() << Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl;
     685  Log() << Verbose(0) << "INPUT: ";
     686  cin >> choice;
     687
     688  switch (choice) {
     689    default:
     690      Log() << Verbose(0) << "Not a valid choice." << endl;
     691      break;
     692
     693    case 'a': // add atom
     694      for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
     695        if ((*ListRunner)->ActiveFlag) {
     696        mol = *ListRunner;
     697        Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
     698        AddAtoms(periode, mol);
     699      }
     700      break;
     701
     702    case 'b': // scale a bond
     703      for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
     704        if ((*ListRunner)->ActiveFlag) {
     705        mol = *ListRunner;
     706        Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
     707        Log() << Verbose(0) << "Scaling bond length between two atoms." << endl;
     708        first = mol->AskAtom("Enter first (fixed) atom: ");
     709        second = mol->AskAtom("Enter second (shifting) atom: ");
     710        minBond = 0.;
     711        for (int i=NDIM;i--;)
     712          minBond += (first->x.x[i]-second->x.x[i])*(first->x.x[i] - second->x.x[i]);
     713        minBond = sqrt(minBond);
     714        Log() << Verbose(0) << "Current Bond length between " << first->type->name << " Atom " << first->nr << " and " << second->type->name << " Atom " << second->nr << ": " << minBond << " a.u." << endl;
     715        Log() << Verbose(0) << "Enter new bond length [a.u.]: ";
     716        cin >> bond;
     717        for (int i=NDIM;i--;) {
     718          second->x.x[i] -= (second->x.x[i]-first->x.x[i])/minBond*(minBond-bond);
     719        }
     720        //Log() << Verbose(0) << "New coordinates of Atom " << second->nr << " are: ";
     721        //second->Output(second->type->No, 1);
     722      }
     723      break;
     724
     725    case 'c': // unit scaling of the metric
     726      for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
     727        if ((*ListRunner)->ActiveFlag) {
     728        mol = *ListRunner;
     729        Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
     730       Log() << Verbose(0) << "Angstroem -> Bohrradius: 1.8897261\t\tBohrradius -> Angstroem: 0.52917721" << endl;
     731       Log() << Verbose(0) << "Enter three factors: ";
     732       factor = new double[NDIM];
     733       cin >> factor[0];
     734       cin >> factor[1];
     735       cin >> factor[2];
     736       valid = true;
     737       mol->Scale((const double ** const)&factor);
     738       delete[](factor);
     739      }
     740     break;
     741
     742    case 'l': // measure distances or angles
     743      for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
     744        if ((*ListRunner)->ActiveFlag) {
     745        mol = *ListRunner;
     746        Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
     747        MeasureAtoms(periode, mol, configuration);
     748      }
     749      break;
     750
     751    case 'r': // remove atom
     752      for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
     753        if ((*ListRunner)->ActiveFlag) {
     754        mol = *ListRunner;
     755        Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
     756        RemoveAtoms(mol);
     757      }
     758      break;
     759
     760    case 'u': // change an atom's element
     761      for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
     762        if ((*ListRunner)->ActiveFlag) {
     763        int Z;
     764        mol = *ListRunner;
     765        Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
     766        first = NULL;
     767        do {
     768          Log() << Verbose(0) << "Change the element of which atom: ";
     769          cin >> Z;
     770        } while ((first = mol->FindAtom(Z)) == NULL);
     771        Log() << Verbose(0) << "New element by atomic number Z: ";
     772        cin >> Z;
     773        first->type = periode->FindElement(Z);
     774        Log() << Verbose(0) << "Atom " << first->nr << "'s element is " << first->type->name << "." << endl;
     775      }
     776      break;
     777  }
     778};
     779
     780/** Submenu for manipulating molecules.
     781 * \param *periode periodentafel
     782 * \param *molecules list of molecule to manipulate
     783 */
     784static void ManipulateMolecules(periodentafel *periode, MoleculeListClass *molecules, config *configuration)
     785{
     786  atom *first = NULL;
     787  Vector x,y,z,n; // coordinates for absolute point in cell volume
     788  int j, axis, count, faktor;
     789  char choice;  // menu choice char
     790  molecule *mol = NULL;
     791  element **Elements;
     792  Vector **vectors;
     793  MoleculeLeafClass *Subgraphs = NULL;
     794
     795  Log() << Verbose(0) << "=========MANIPULATE GLOBALLY===================" << endl;
     796  Log() << Verbose(0) << "c - scale by unit transformation" << endl;
     797  Log() << Verbose(0) << "d - duplicate molecule/periodic cell" << endl;
     798  Log() << Verbose(0) << "f - fragment molecule many-body bond order style" << endl;
     799  Log() << Verbose(0) << "g - center atoms in box" << endl;
     800  Log() << Verbose(0) << "i - realign molecule" << endl;
     801  Log() << Verbose(0) << "m - mirror all molecules" << endl;
     802  Log() << Verbose(0) << "o - create connection matrix" << endl;
     803  Log() << Verbose(0) << "t - translate molecule by vector" << endl;
     804  Log() << Verbose(0) << "all else - go back" << endl;
     805  Log() << Verbose(0) << "===============================================" << endl;
     806  if (molecules->NumberOfActiveMolecules() > 1)
     807    eLog() << Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl;
     808  Log() << Verbose(0) << "INPUT: ";
     809  cin >> choice;
     810
     811  switch (choice) {
     812    default:
     813      Log() << Verbose(0) << "Not a valid choice." << endl;
     814      break;
     815
     816    case 'd': // duplicate the periodic cell along a given axis, given times
     817      for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
     818        if ((*ListRunner)->ActiveFlag) {
     819        mol = *ListRunner;
     820        Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
     821        Log() << Verbose(0) << "State the axis [(+-)123]: ";
     822        cin >> axis;
     823        Log() << Verbose(0) << "State the factor: ";
     824        cin >> faktor;
     825
     826        mol->CountAtoms(); // recount atoms
     827        if (mol->AtomCount != 0) {  // if there is more than none
     828          count = mol->AtomCount;  // is changed becausing of adding, thus has to be stored away beforehand
     829          Elements = new element *[count];
     830          vectors = new Vector *[count];
     831          j = 0;
     832          first = mol->start;
     833          while (first->next != mol->end) { // make a list of all atoms with coordinates and element
     834            first = first->next;
     835            Elements[j] = first->type;
     836            vectors[j] = &first->x;
     837            j++;
     838          }
     839          if (count != j)
     840            eLog() << Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl;
     841          x.Zero();
     842          y.Zero();
     843          y.x[abs(axis)-1] = mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
     844          for (int i=1;i<faktor;i++) {  // then add this list with respective translation factor times
     845            x.AddVector(&y); // per factor one cell width further
     846            for (int k=count;k--;) { // go through every atom of the original cell
     847              first = new atom(); // create a new body
     848              first->x.CopyVector(vectors[k]);  // use coordinate of original atom
     849              first->x.AddVector(&x);     // translate the coordinates
     850              first->type = Elements[k];  // insert original element
     851              mol->AddAtom(first);        // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
     852            }
     853          }
     854          if (mol->first->next != mol->last) // if connect matrix is present already, redo it
     855            mol->CreateAdjacencyList(mol->BondDistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
     856          // free memory
     857          delete[](Elements);
     858          delete[](vectors);
     859          // correct cell size
     860          if (axis < 0) { // if sign was negative, we have to translate everything
     861            x.Zero();
     862            x.AddVector(&y);
     863            x.Scale(-(faktor-1));
     864            mol->Translate(&x);
     865          }
     866          mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
     867        }
     868      }
     869      break;
     870
     871    case 'f':
     872      FragmentAtoms(mol, configuration);
     873      break;
     874
     875    case 'g': // center the atoms
     876      for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
     877        if ((*ListRunner)->ActiveFlag) {
     878        mol = *ListRunner;
     879        Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
     880        CenterAtoms(mol);
     881      }
     882      break;
     883
     884    case 'i': // align all atoms
     885      for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
     886        if ((*ListRunner)->ActiveFlag) {
     887        mol = *ListRunner;
     888        Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
     889        AlignAtoms(periode, mol);
     890      }
     891      break;
     892
     893    case 'm': // mirror atoms along a given axis
     894      for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
     895        if ((*ListRunner)->ActiveFlag) {
     896        mol = *ListRunner;
     897        Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
     898        MirrorAtoms(mol);
     899      }
     900      break;
     901
     902    case 'o': // create the connection matrix
     903      for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
     904        if ((*ListRunner)->ActiveFlag) {
     905          mol = *ListRunner;
     906          double bonddistance;
     907          clock_t start,end;
     908          Log() << Verbose(0) << "What's the maximum bond distance: ";
     909          cin >> bonddistance;
     910          start = clock();
     911          mol->CreateAdjacencyList(bonddistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
     912          end = clock();
     913          Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
     914        }
     915      break;
     916
     917    case 't': // translate all atoms
     918      for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
     919        if ((*ListRunner)->ActiveFlag) {
     920        mol = *ListRunner;
     921        Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
     922        Log() << Verbose(0) << "Enter translation vector." << endl;
     923        x.AskPosition(mol->cell_size,0);
     924        mol->Center.AddVector((const Vector *)&x);
     925     }
     926     break;
     927  }
     928  // Free all
     929  if (Subgraphs != NULL) {  // free disconnected subgraph list of DFS analysis was performed
     930    while (Subgraphs->next != NULL) {
     931      Subgraphs = Subgraphs->next;
     932      delete(Subgraphs->previous);
     933    }
     934    delete(Subgraphs);
     935  }
     936};
     937
     938
     939/** Submenu for creating new molecules.
     940 * \param *periode periodentafel
     941 * \param *molecules list of molecules to add to
     942 */
     943static void EditMolecules(periodentafel *periode, MoleculeListClass *molecules)
     944{
     945  char choice;  // menu choice char
     946  Vector center;
     947  int nr, count;
     948  molecule *mol = NULL;
     949
     950  Log() << Verbose(0) << "==========EDIT MOLECULES=====================" << endl;
     951  Log() << Verbose(0) << "c - create new molecule" << endl;
     952  Log() << Verbose(0) << "l - load molecule from xyz file" << endl;
     953  Log() << Verbose(0) << "n - change molecule's name" << endl;
     954  Log() << Verbose(0) << "N - give molecules filename" << endl;
     955  Log() << Verbose(0) << "p - parse atoms in xyz file into molecule" << endl;
     956  Log() << Verbose(0) << "r - remove a molecule" << endl;
     957  Log() << Verbose(0) << "all else - go back" << endl;
     958  Log() << Verbose(0) << "===============================================" << endl;
     959  Log() << Verbose(0) << "INPUT: ";
     960  cin >> choice;
     961
     962  switch (choice) {
     963    default:
     964      Log() << Verbose(0) << "Not a valid choice." << endl;
     965      break;
     966    case 'c':
     967      mol = new molecule(periode);
     968      molecules->insert(mol);
     969      break;
     970
     971    case 'l': // load from XYZ file
     972      {
     973        char filename[MAXSTRINGSIZE];
     974        Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl;
     975        mol = new molecule(periode);
     976        do {
     977          Log() << Verbose(0) << "Enter file name: ";
     978          cin >> filename;
     979        } while (!mol->AddXYZFile(filename));
     980        mol->SetNameFromFilename(filename);
     981        // center at set box dimensions
     982        mol->CenterEdge(&center);
     983        mol->cell_size[0] = center.x[0];
     984        mol->cell_size[1] = 0;
     985        mol->cell_size[2] = center.x[1];
     986        mol->cell_size[3] = 0;
     987        mol->cell_size[4] = 0;
     988        mol->cell_size[5] = center.x[2];
     989        molecules->insert(mol);
     990      }
     991      break;
     992
     993    case 'n':
     994      {
     995        char filename[MAXSTRINGSIZE];
     996        do {
     997          Log() << Verbose(0) << "Enter index of molecule: ";
     998          cin >> nr;
     999          mol = molecules->ReturnIndex(nr);
     1000        } while (mol == NULL);
     1001        Log() << Verbose(0) << "Enter name: ";
     1002        cin >> filename;
     1003        strcpy(mol->name, filename);
     1004      }
     1005      break;
     1006
     1007    case 'N':
     1008      {
     1009        char filename[MAXSTRINGSIZE];
     1010        do {
     1011          Log() << Verbose(0) << "Enter index of molecule: ";
     1012          cin >> nr;
     1013          mol = molecules->ReturnIndex(nr);
     1014        } while (mol == NULL);
     1015        Log() << Verbose(0) << "Enter name: ";
     1016        cin >> filename;
     1017        mol->SetNameFromFilename(filename);
     1018      }
     1019      break;
     1020
     1021    case 'p': // parse XYZ file
     1022      {
     1023        char filename[MAXSTRINGSIZE];
     1024        mol = NULL;
     1025        do {
     1026          Log() << Verbose(0) << "Enter index of molecule: ";
     1027          cin >> nr;
     1028          mol = molecules->ReturnIndex(nr);
     1029        } while (mol == NULL);
     1030        Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl;
     1031        do {
     1032          Log() << Verbose(0) << "Enter file name: ";
     1033          cin >> filename;
     1034        } while (!mol->AddXYZFile(filename));
     1035        mol->SetNameFromFilename(filename);
     1036      }
     1037      break;
     1038
     1039    case 'r':
     1040      Log() << Verbose(0) << "Enter index of molecule: ";
     1041      cin >> nr;
     1042      count = 1;
     1043      for(MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
     1044        if (nr == (*ListRunner)->IndexNr) {
     1045          mol = *ListRunner;
     1046          molecules->ListOfMolecules.erase(ListRunner);
     1047          delete(mol);
     1048          break;
     1049        }
     1050      break;
     1051  }
     1052};
     1053
     1054
     1055/** Submenu for merging molecules.
     1056 * \param *periode periodentafel
     1057 * \param *molecules list of molecules to add to
     1058 */
     1059static void MergeMolecules(periodentafel *periode, MoleculeListClass *molecules)
     1060{
     1061  char choice;  // menu choice char
     1062
     1063  Log() << Verbose(0) << "===========MERGE MOLECULES=====================" << endl;
     1064  Log() << Verbose(0) << "a - simple add of one molecule to another" << endl;
     1065  Log() << Verbose(0) << "e - embedding merge of two molecules" << endl;
     1066  Log() << Verbose(0) << "m - multi-merge of all molecules" << endl;
     1067  Log() << Verbose(0) << "s - scatter merge of two molecules" << endl;
     1068  Log() << Verbose(0) << "t - simple merge of two molecules" << endl;
     1069  Log() << Verbose(0) << "all else - go back" << endl;
     1070  Log() << Verbose(0) << "===============================================" << endl;
     1071  Log() << Verbose(0) << "INPUT: ";
     1072  cin >> choice;
     1073
     1074  switch (choice) {
     1075    default:
     1076      Log() << Verbose(0) << "Not a valid choice." << endl;
     1077      break;
     1078
     1079    case 'a':
     1080      {
     1081        int src, dest;
     1082        molecule *srcmol = NULL, *destmol = NULL;
     1083        {
     1084          do {
     1085            Log() << Verbose(0) << "Enter index of destination molecule: ";
     1086            cin >> dest;
     1087            destmol = molecules->ReturnIndex(dest);
     1088          } while ((destmol == NULL) && (dest != -1));
     1089          do {
     1090            Log() << Verbose(0) << "Enter index of source molecule to add from: ";
     1091            cin >> src;
     1092            srcmol = molecules->ReturnIndex(src);
     1093          } while ((srcmol == NULL) && (src != -1));
     1094          if ((src != -1) && (dest != -1))
     1095            molecules->SimpleAdd(srcmol, destmol);
     1096        }
     1097      }
     1098      break;
     1099
     1100    case 'e':
     1101      {
     1102        int src, dest;
     1103        molecule *srcmol = NULL, *destmol = NULL;
     1104        do {
     1105          Log() << Verbose(0) << "Enter index of matrix molecule (the variable one): ";
     1106          cin >> src;
     1107          srcmol = molecules->ReturnIndex(src);
     1108        } while ((srcmol == NULL) && (src != -1));
     1109        do {
     1110          Log() << Verbose(0) << "Enter index of molecule to merge into (the fixed one): ";
     1111          cin >> dest;
     1112          destmol = molecules->ReturnIndex(dest);
     1113        } while ((destmol == NULL) && (dest != -1));
     1114        if ((src != -1) && (dest != -1))
     1115          molecules->EmbedMerge(destmol, srcmol);
     1116      }
     1117      break;
     1118
     1119    case 'm':
     1120      {
     1121        int nr;
     1122        molecule *mol = NULL;
     1123        do {
     1124          Log() << Verbose(0) << "Enter index of molecule to merge into: ";
     1125          cin >> nr;
     1126          mol = molecules->ReturnIndex(nr);
     1127        } while ((mol == NULL) && (nr != -1));
     1128        if (nr != -1) {
     1129          int N = molecules->ListOfMolecules.size()-1;
     1130          int *src = new int(N);
     1131          for(MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
     1132            if ((*ListRunner)->IndexNr != nr)
     1133              src[N++] = (*ListRunner)->IndexNr;       
     1134          molecules->SimpleMultiMerge(mol, src, N);
     1135          delete[](src);
     1136        }
     1137      }
     1138      break;
     1139
     1140    case 's':
     1141      Log() << Verbose(0) << "Not implemented yet." << endl;
     1142      break;
     1143
     1144    case 't':
     1145      {
     1146        int src, dest;
     1147        molecule *srcmol = NULL, *destmol = NULL;
     1148        {
     1149          do {
     1150            Log() << Verbose(0) << "Enter index of destination molecule: ";
     1151            cin >> dest;
     1152            destmol = molecules->ReturnIndex(dest);
     1153          } while ((destmol == NULL) && (dest != -1));
     1154          do {
     1155            Log() << Verbose(0) << "Enter index of source molecule to merge into: ";
     1156            cin >> src;
     1157            srcmol = molecules->ReturnIndex(src);
     1158          } while ((srcmol == NULL) && (src != -1));
     1159          if ((src != -1) && (dest != -1))
     1160            molecules->SimpleMerge(srcmol, destmol);
     1161        }
     1162      }
     1163      break;
     1164  }
     1165};
     1166
     1167/********************************************** Test routine **************************************/
     1168
     1169/** Is called always as option 'T' in the menu.
     1170 * \param *molecules list of molecules
     1171 */
     1172static void testroutine(MoleculeListClass *molecules)
     1173{
     1174  // the current test routine checks the functionality of the KeySet&Graph concept:
     1175  // We want to have a multiindex (the KeySet) describing a unique subgraph
     1176  int i, comp, counter=0;
     1177
     1178  // create a clone
     1179  molecule *mol = NULL;
     1180  if (molecules->ListOfMolecules.size() != 0) // clone
     1181    mol = (molecules->ListOfMolecules.front())->CopyMolecule();
     1182  else {
     1183    eLog() << Verbose(0) << "I don't have anything to test on ... ";
     1184    performCriticalExit();
     1185    return;
     1186  }
     1187  atom *Walker = mol->start;
     1188
     1189  // generate some KeySets
     1190  Log() << Verbose(0) << "Generating KeySets." << endl;
     1191  KeySet TestSets[mol->AtomCount+1];
     1192  i=1;
     1193  while (Walker->next != mol->end) {
     1194    Walker = Walker->next;
     1195    for (int j=0;j<i;j++) {
     1196      TestSets[j].insert(Walker->nr);
     1197    }
     1198    i++;
     1199  }
     1200  Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl;
     1201  KeySetTestPair test;
     1202  test = TestSets[mol->AtomCount-1].insert(Walker->nr);
     1203  if (test.second) {
     1204    Log() << Verbose(1) << "Insertion worked?!" << endl;
     1205  } else {
     1206    Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl;
     1207  }
     1208  TestSets[mol->AtomCount].insert(mol->end->previous->nr);
     1209  TestSets[mol->AtomCount].insert(mol->end->previous->previous->previous->nr);
     1210
     1211  // constructing Graph structure
     1212  Log() << Verbose(0) << "Generating Subgraph class." << endl;
     1213  Graph Subgraphs;
     1214
     1215  // insert KeySets into Subgraphs
     1216  Log() << Verbose(0) << "Inserting KeySets into Subgraph class." << endl;
     1217  for (int j=0;j<mol->AtomCount;j++) {
     1218    Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.)));
     1219  }
     1220  Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl;
     1221  GraphTestPair test2;
     1222  test2 = Subgraphs.insert(GraphPair (TestSets[mol->AtomCount],pair<int, double>(counter++, 1.)));
     1223  if (test2.second) {
     1224    Log() << Verbose(1) << "Insertion worked?!" << endl;
     1225  } else {
     1226    Log() << Verbose(1) << "Insertion rejected: Present object is " << (*(test2.first)).second.first << "." << endl;
     1227  }
     1228
     1229  // show graphs
     1230  Log() << Verbose(0) << "Showing Subgraph's contents, checking that it's sorted." << endl;
     1231  Graph::iterator A = Subgraphs.begin();
     1232  while (A !=  Subgraphs.end()) {
     1233    Log() << Verbose(0) << (*A).second.first << ": ";
     1234    KeySet::iterator key = (*A).first.begin();
     1235    comp = -1;
     1236    while (key != (*A).first.end()) {
     1237      if ((*key) > comp)
     1238        Log() << Verbose(0) << (*key) << " ";
     1239      else
     1240        Log() << Verbose(0) << (*key) << "! ";
     1241      comp = (*key);
     1242      key++;
     1243    }
     1244    Log() << Verbose(0) << endl;
     1245    A++;
     1246  }
     1247  delete(mol);
     1248};
     1249
     1250#endif
    771251
    781252/** Parses the command line options.
     
    1031277  int argptr;
    1041278  molecule *mol = NULL;
    105   string BondGraphFileName("");
     1279  string BondGraphFileName("\n");
    1061280  int verbosity = 0;
    1071281  strncpy(configuration.databasepath, LocalPath, MAXSTRINGSIZE-1);
     
    1261300            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;
    1271301            Log() << Verbose(0) << "\t-c x1 x2 x3\tCenter atoms in domain with a minimum distance to boundary of (x1,x2,x3)." << endl;
    128             Log() << Verbose(0) << "\t-C\tPair Correlation analysis." << endl;
     1302            Log() << Verbose(0) << "\t-C <Z> <output> <bin output>\tPair Correlation analysis." << endl;
    1291303            Log() << Verbose(0) << "\t-d x1 x2 x3\tDuplicate cell along each axis by given factor." << endl;
    1301304            Log() << Verbose(0) << "\t-D <bond distance>\tDepth-First-Search Analysis of the molecule, giving cycles and tree/back edges." << endl;
    1311305            Log() << Verbose(0) << "\t-e <file>\tSets the databases path to be parsed (default: ./)." << endl;
    1321306            Log() << Verbose(0) << "\t-E <id> <Z>\tChange atom <id>'s element to <Z>, <id> begins at 0." << endl;
    133             Log() << Verbose(0) << "\t-f/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;
     1307            Log() << Verbose(0) << "\t-f <dist> <order>\tFragments the molecule in BOSSANOVA manner (with/out rings compressed) and stores config files in same dir as config (return code 0 - fragmented, 2 - no fragmentation necessary)." << endl;
     1308            Log() << Verbose(0) << "\t-F <dist_x> <dist_y> <dist_z> <epsilon> <randatom> <randmol> <DoRotate>\tFilling Box with water molecules." << endl;
    1341309            Log() << Verbose(0) << "\t-g <file>\tParses a bond length table from the given file." << endl;
    1351310            Log() << Verbose(0) << "\t-h/-H/-?\tGive this help screen." << endl;
     1311            Log() << Verbose(0) << "\t-I\t Dissect current system of molecules into a set of disconnected (subgraphs of) molecules." << endl;
    1361312            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;
    1371313            Log() << Verbose(0) << "\t-m <0/1>\tCalculate (0)/ Align in(1) PAS with greatest EV along z axis." << endl;
     
    2571433       mol = new molecule(periode);
    2581434       mol->ActiveFlag = true;
     1435       if (ConfigFileName != NULL)
     1436         mol->SetNameFromFilename(ConfigFileName);
    2591437       molecules->insert(mol);
     1438     }
     1439     if (configuration.BG == NULL) {
     1440       configuration.BG = new BondGraph(configuration.GetIsAngstroem());
     1441       if ((!BondGraphFileName.empty()) && (configuration.BG->LoadBondLengthTable(BondGraphFileName))) {
     1442         Log() << Verbose(0) << "Bond length table loaded successfully." << endl;
     1443       } else {
     1444         eLog() << Verbose(1) << "Bond length table loading failed." << endl;
     1445       }
    2601446     }
    2611447
     
    3591545              //argptr+=1;
    3601546              break;
     1547            case 'I':
     1548              Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl;
     1549              // @TODO rather do the dissection afterwards
     1550              molecules->DissectMoleculeIntoConnectedSubgraphs(periode, &configuration);
     1551              mol = NULL;
     1552              if (molecules->ListOfMolecules.size() != 0) {
     1553                for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
     1554                  if ((*ListRunner)->ActiveFlag) {
     1555                    mol = *ListRunner;
     1556                    break;
     1557                  }
     1558              }
     1559              if (mol == NULL) {
     1560                mol = *(molecules->ListOfMolecules.begin());
     1561                mol->ActiveFlag = true;
     1562              }
     1563              break;
    3611564            case 'C':
    3621565              if (ExitFlag == 0) ExitFlag = 1;
     
    3661569                performCriticalExit();
    3671570              } else {
    368                 SaveFlag = false;
    3691571                ofstream output(argv[argptr+1]);
    3701572                ofstream binoutput(argv[argptr+2]);
     
    3861588                counter = 0;
    3871589                for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
    388                   Actives[counter] = (*BigFinder)->ActiveFlag;
     1590                  Actives[counter++] = (*BigFinder)->ActiveFlag;
    3891591                  (*BigFinder)->ActiveFlag = (*BigFinder == Boundary) ? false : true;
    3901592                }
     
    3941596                int ranges[NDIM] = {1,1,1};
    3951597                CorrelationToSurfaceMap *surfacemap = PeriodicCorrelationToSurface( molecules, elemental, TesselStruct, LCList, ranges );
     1598                //OutputCorrelationToSurface(&output, surfacemap);
    3961599                BinPairMap *binmap = BinData( surfacemap, 0.5, 0., 0. );
    3971600                OutputCorrelation ( &binoutput, binmap );
     
    3991602                binoutput.close();
    4001603                for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++)
    401                   (*BigFinder)->ActiveFlag = Actives[counter];
     1604                  (*BigFinder)->ActiveFlag = Actives[counter++];
    4021605                Free(&Actives);
    4031606                delete(LCList);
     
    4221625            case 'F':
    4231626              if (ExitFlag == 0) ExitFlag = 1;
    424               if (argptr+5 >=argc) {
     1627              if (argptr+6 >=argc) {
    4251628                ExitFlag = 255;
    426                 eLog() << Verbose(0) << "Not enough or invalid arguments given for filling box with water: -F <dist_x> <dist_y> <dist_z> <randatom> <randmol> <DoRotate>" << endl;
     1629                eLog() << Verbose(0) << "Not enough or invalid arguments given for filling box with water: -F <dist_x> <dist_y> <dist_z> <boundary> <randatom> <randmol> <DoRotate>" << endl;
    4271630                performCriticalExit();
    4281631              } else {
     
    4301633                Log() << Verbose(1) << "Filling Box with water molecules." << endl;
    4311634                // construct water molecule
    432                 molecule *filler = new molecule(periode);;
     1635                molecule *filler = new molecule(periode);
    4331636                molecule *Filling = NULL;
    4341637                atom *second = NULL, *third = NULL;
     1638//                first = new atom();
     1639//                first->type = periode->FindElement(5);
     1640//                first->x.Zero();
     1641//                filler->AddAtom(first);
    4351642                first = new atom();
    4361643                first->type = periode->FindElement(1);
     
    4511658                for (int i=0;i<NDIM;i++)
    4521659                  distance[i] = atof(argv[argptr+i]);
    453                 Filling = FillBoxWithMolecule(molecules, filler, configuration, distance, atof(argv[argptr+3]), atof(argv[argptr+4]), atoi(argv[argptr+5]));
     1660                Filling = FillBoxWithMolecule(molecules, filler, configuration, distance, atof(argv[argptr+3]), atof(argv[argptr+4]), atof(argv[argptr+5]), atoi(argv[argptr+6]));
    4541661                if (Filling != NULL) {
     1662                  Filling->ActiveFlag = false;
    4551663                  molecules->insert(Filling);
    4561664                }
     
    4991707                start = clock();
    5001708                LCList = new LinkedCell(Boundary, atof(argv[argptr])*2.);
    501                 FindNonConvexBorder(Boundary, T, LCList, atof(argv[argptr]), argv[argptr+1]);
     1709                if (!FindNonConvexBorder(Boundary, T, LCList, atof(argv[argptr]), argv[argptr+1]))
     1710                  ExitFlag = 255;
    5021711                //FindDistributionOfEllipsoids(T, &LCList, N, number, filename.c_str());
    5031712                end = clock();
    5041713                Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
    5051714                delete(LCList);
     1715                delete(T);
    5061716                argptr+=2;
    5071717              }
     
    7992009                if (volume != -1)
    8002010                  ExitFlag = 255;
    801                   eLog() << Verbose(0) << "Not enough arguments given for suspension: -u <density>" << endl;
     2011                  eLog() << Verbose(0) << "Not enough or invalid arguments given for suspension: -u <density>" << endl;
    8022012                  performCriticalExit();
    8032013              } else {
     
    9202130  Action *eraseMoleculeAction = new MethodAction("eraseMoleculeAction",boost::bind(&MoleculeListClass::eraseMolecule,molecules));
    9212131  new ActionMenuItem('r',"remove a molecule",editMoleculesMenu,eraseMoleculeAction);
     2132
    9222133}
    9232134
     
    9712182
    9722183    {
     2184      cout << ESPACKVersion << endl;
     2185
     2186      setVerbosity(0);
     2187
    9732188      menuPopulaters populaters;
    9742189      populaters.MakeEditMoleculesMenu = populateEditMoleculesMenu;
     
    9812196      MainWindow *mainWindow = UIFactory::get()->makeMainWindow(populaters,molecules, configuration, periode, ConfigFileName);
    9822197      mainWindow->display();
     2198
    9832199      delete mainWindow;
    9842200    }
  • TabularUnified src/config.cpp

    r9fe36b rb8d1aeb  
    66
    77#include <stdio.h>
     8#include <cstring>
    89
    910#include "atom.hpp"
     
    2728    char number1[8];
    2829    char number2[8];
    29     char *dummy1, *dummy2;
     30    const char *dummy1, *dummy2;
    3031    //Log() << Verbose(0) << s1 << "  " << s2 << endl;
    3132    dummy1 = strchr(s1, '_')+sizeof(char)*5;  // go just after "Ion_Type"
     
    140141void ConfigFileBuffer::MapIonTypesInBuffer(const int NoAtoms)
    141142{
    142   map<const char *, int, IonTypeCompare> LineList;
     143  map<const char *, int, IonTypeCompare> IonTypeLineMap;
    143144  if (LineMapping == NULL) {
    144145    eLog() << Verbose(0) << "map pointer is NULL: " << LineMapping << endl;
     
    149150  // put all into hashed map
    150151  for (int i=0; i<NoAtoms; ++i) {
    151     LineList.insert(pair<const char *, int> (buffer[CurrentLine+i], CurrentLine+i));
     152    IonTypeLineMap.insert(pair<const char *, int> (buffer[CurrentLine+i], CurrentLine+i));
    152153  }
    153154
    154155  // fill map
    155156  int nr=0;
    156   for (map<const char *, int, IonTypeCompare>::iterator runner = LineList.begin(); runner != LineList.end(); ++runner) {
     157  for (map<const char *, int, IonTypeCompare>::iterator runner = IonTypeLineMap.begin(); runner != IonTypeLineMap.end(); ++runner) {
    157158    if (CurrentLine+nr < NoLines)
    158159      LineMapping[CurrentLine+(nr++)] = runner->second;
     
    10561057
    10571058  // 2. parse the bond graph file if given
    1058   BG = new BondGraph(IsAngstroem);
    1059   if (BG->LoadBondLengthTable(BondGraphFileName)) {
    1060     Log() << Verbose(0) << "Bond length table loaded successfully." << endl;
    1061   } else {
    1062     eLog() << Verbose(1) << "Bond length table loading failed." << endl;
     1059  if (BG == NULL) {
     1060    BG = new BondGraph(IsAngstroem);
     1061    if (BG->LoadBondLengthTable(BondGraphFileName)) {
     1062      Log() << Verbose(0) << "Bond length table loaded successfully." << endl;
     1063    } else {
     1064      eLog() << Verbose(1) << "Bond length table loading failed." << endl;
     1065    }
    10631066  }
    10641067
    10651068  // 3. parse the molecule in
    10661069  LoadMolecule(mol, FileBuffer, periode, FastParsing);
     1070  mol->SetNameFromFilename(filename);
    10671071  mol->ActiveFlag = true;
     1072  MolList->insert(mol);
    10681073
    10691074  // 4. dissect the molecule into connected subgraphs
    1070   MolList->DissectMoleculeIntoConnectedSubgraphs(mol,this);
    1071 
    1072   delete(mol);
     1075  // don't do this here ...
     1076  //MolList->DissectMoleculeIntoConnectedSubgraphs(mol,this);
     1077  //delete(mol);
     1078
    10731079  delete(FileBuffer);
    10741080};
     
    17821788  ofstream output;
    17831789  molecule *mol = new molecule(periode);
     1790  mol->SetNameFromFilename(ConfigFileName);
    17841791
    17851792  if (!strcmp(configpath, GetDefaultPath())) {
     
    17911798  if (ConfigFileName != NULL)
    17921799    strcpy(filename, ConfigFileName);
    1793   else
     1800  if (output == NULL)
    17941801    strcpy(filename,"main_pcp_linux");
    17951802  Log() << Verbose(0) << "Saving as pdb input ";
     
    18021809  if (ConfigFileName != NULL)
    18031810    strcpy(filename, ConfigFileName);
    1804   else
     1811  if (output == NULL)
    18051812    strcpy(filename,"main_pcp_linux");
    18061813  Log() << Verbose(0) << "Saving as tremolo data input ";
     
    18561863    output.open(filename, ios::trunc);
    18571864  }
    1858   else {
     1865  if (output == NULL) {
    18591866    strcpy(filename,"main_pcp_linux");
    18601867    strcat(filename, ".xyz");
     
    18791886  if (ConfigFileName != NULL)
    18801887    strcpy(filename, ConfigFileName);
    1881   else
     1888  if (output == NULL)
    18821889    strcpy(filename,"main_pcp_linux");
    18831890  Log() << Verbose(0) << "Saving as mpqc input ";
     
    22412248              }
    22422249              line++;
    2243             } while (dummy1 != NULL && (dummy1[0] == '#') || (dummy1[0] == '\n'));
     2250            } while ((dummy1 != NULL) && ((dummy1[0] == '#') || (dummy1[0] == '\n')));
    22442251            dummy = dummy1;
    22452252          } else { // simple int, strings or doubles start in the same line
  • TabularUnified src/helpers.hpp

    r9fe36b rb8d1aeb  
    7474  x = y;
    7575  y = tmp;
     76};
     77
     78/** returns greater of the two values.
     79 * \param x first value
     80 * \param y second value
     81 * \return greater of the two (by operator>())
     82 */
     83template <typename T> T Max(T x, T y)
     84{
     85  if (x > y)
     86    return x;
     87  else return y;
     88};
     89
     90/** returns smaller of the two values.
     91 * \param x first value
     92 * \param y second value
     93 * \return smaller of the two (by operator<())
     94 */
     95template <typename T> T Min(T x, T y)
     96{
     97  if (x < y)
     98    return x;
     99  else return y;
    76100};
    77101
  • TabularUnified src/joiner.cpp

    r9fe36b rb8d1aeb  
    77
    88//============================ INCLUDES ===========================
     9
     10#include <cstring>
    911
    1012#include "datacreator.hpp"
  • TabularUnified src/memoryallocator.hpp

    r9fe36b rb8d1aeb  
    1616#endif
    1717
     18#include <cstdlib>
    1819#include <iostream>
    1920#include <iomanip>
  • TabularUnified src/memoryusageobserver.cpp

    r9fe36b rb8d1aeb  
    44 * This class represents a Singleton for observing memory usage.
    55 */
     6
     7#include <cstdlib>
    68
    79#include "log.hpp"
  • TabularUnified src/molecule.cpp

    r9fe36b rb8d1aeb  
    44 *
    55 */
     6
     7#include <cstring>
    68
    79#include "atom.hpp"
     
    599601  else
    600602    molname = filename; // contains no slashes
    601   char *endname = strchr(molname, '.');
     603  const char *endname = strchr(molname, '.');
    602604  if ((endname == NULL) || (endname < molname))
    603605    length = strlen(molname);
  • TabularUnified src/molecule.hpp

    r9fe36b rb8d1aeb  
    114114
    115115  // re-definition of virtual functions from PointCloud
     116  const char * const GetName() const;
    116117  Vector *GetCenter() const ;
    117118  TesselPoint *GetPoint() const ;
    118119  TesselPoint *GetTerminalPoint() const ;
     120  int GetMaxId() const;
    119121  void GoToNext() const ;
    120122  void GoToPrevious() const ;
     
    332334  void Enumerate(ofstream *out);
    333335  void Output(ofstream *out);
    334   void DissectMoleculeIntoConnectedSubgraphs(molecule * const mol, config * const configuration);
     336  void DissectMoleculeIntoConnectedSubgraphs(const periodentafel * const periode, config * const configuration);
    335337  int CountAllAtoms() const;
    336338
  • TabularUnified src/molecule_dynamics.cpp

    r9fe36b rb8d1aeb  
    370370
    371371  // argument minimise the constrained potential in this injective PermutationMap
    372   Log() << Verbose(1) << "Argument minimising the PermutationMap, at current potential " << OldPotential << " ... " << endl;
     372  Log() << Verbose(1) << "Argument minimising the PermutationMap." << endl;
    373373  OldPotential = 1e+10;
    374374  round = 0;
    375375  do {
    376     Log() << Verbose(2) << "Starting round " << ++round << " ... " << endl;
     376    Log() << Verbose(2) << "Starting round " << ++round << ", at current potential " << OldPotential << " ... " << endl;
    377377    OlderPotential = OldPotential;
    378378    do {
  • TabularUnified src/molecule_fragmentation.cpp

    r9fe36b rb8d1aeb  
    55 *      Author: heber
    66 */
     7
     8#include <cstring>
    79
    810#include "atom.hpp"
  • TabularUnified src/molecule_geometry.cpp

    r9fe36b rb8d1aeb  
    101101{
    102102  int Num = 0;
    103   atom *ptr = start->next;  // start at first in list
     103  atom *ptr = start;  // start at first in list
    104104
    105105  Center.Zero();
    106106
    107   if (ptr != end) {   //list not empty?
     107  if (ptr->next != end) {   //list not empty?
    108108    while (ptr->next != end) {  // continue with second if present
    109109      ptr = ptr->next;
  • TabularUnified src/molecule_graph.cpp

    r9fe36b rb8d1aeb  
    11171117  bool status = true;
    11181118  if (ReferenceStack->IsEmpty()) {
    1119     eLog() << Verbose(0) << "ReferenceStack is empty!" << endl;
    1120     performCriticalExit();
     1119    Log() << Verbose(1) << "ReferenceStack is empty!" << endl;
    11211120    return false;
    11221121  }
  • TabularUnified src/molecule_pointcloud.cpp

    r9fe36b rb8d1aeb  
    1313/************************************* Functions for class molecule *********************************/
    1414
     15/** Returns a name for this point cloud, here the molecule's name.
     16 * \return name of point cloud
     17 */
     18const char * const molecule::GetName() const
     19{
     20  return name;
     21};
    1522
    1623/** Determine center of all atoms.
     
    4148{
    4249  return end;
     50};
     51
     52/** Return the greatest index of all atoms in the list.
     53 * \return greatest index
     54 */
     55int molecule::GetMaxId() const
     56{
     57  return last_atom;
    4358};
    4459
  • TabularUnified src/moleculelist.cpp

    r9fe36b rb8d1aeb  
    44 *
    55 */
     6
     7#include <cstring>
    68
    79#include "atom.hpp"
     
    405407  input.open(line.c_str());
    406408  if (input == NULL) {
    407     eLog() << Verbose(0) << endl << "Unable to open " << line << ", is the directory correct?" << endl;
    408     performCriticalExit();
     409    Log() << Verbose(1) << endl << "Unable to open " << line << ", is the directory correct?" << endl;
    409410    return false;
    410411  }
     
    743744/** Dissects given \a *mol into connected subgraphs and inserts them as new molecules but with old atoms into \a this.
    744745 * \param *out output stream for debugging
    745  * \param *mol molecule with atoms to dissect
     746 * \param *periode periodentafel
    746747 * \param *configuration config with BondGraph
    747748 */
    748 void MoleculeListClass::DissectMoleculeIntoConnectedSubgraphs(molecule * const mol, config * const configuration)
    749 {
     749void MoleculeListClass::DissectMoleculeIntoConnectedSubgraphs(const periodentafel * const periode, config * const configuration)
     750{
     751  molecule *mol = new molecule(periode);
     752  atom *Walker = NULL;
     753  atom *Advancer = NULL;
     754  bond *Binder = NULL;
     755  bond *Stepper = NULL;
     756  // 0. gather all atoms into single molecule
     757  for (MoleculeList::iterator MolRunner = ListOfMolecules.begin(); !ListOfMolecules.empty(); MolRunner = ListOfMolecules.begin()) {
     758    // shift all atoms to new molecule
     759    Advancer = (*MolRunner)->start->next;
     760    while (Advancer != (*MolRunner)->end) {
     761      Walker = Advancer;
     762      Advancer = Advancer->next;
     763      Log() << Verbose(3) << "Re-linking " << *Walker << "..." << endl;
     764      unlink(Walker);
     765      Walker->father = Walker;
     766      mol->AddAtom(Walker);    // counting starts at 1
     767    }
     768    // remove all bonds
     769    Stepper = (*MolRunner)->first->next;
     770    while (Stepper != (*MolRunner)->last) {
     771      Binder = Stepper;
     772      Stepper = Stepper->next;
     773      delete(Binder);
     774    }
     775    // remove the molecule
     776    delete(*MolRunner);
     777    ListOfMolecules.erase(MolRunner);
     778  }
     779
    750780  // 1. dissect the molecule into connected subgraphs
    751781  configuration->BG->ConstructBondGraph(mol);
     
    763793  // 4a. create array of molecules to fill
    764794  const int MolCount = Subgraphs->next->Count();
     795  char number[MAXSTRINGSIZE];
    765796  molecule **molecules = Malloc<molecule *>(MolCount, "config::Load() - **molecules");
    766797  for (int i=0;i<MolCount;i++) {
    767798    molecules[i] = (molecule*) new molecule(mol->elemente);
    768799    molecules[i]->ActiveFlag = true;
     800    strncpy(molecules[i]->name, mol->name, MAXSTRINGSIZE);
     801    if (MolCount > 1) {
     802      sprintf(number, "-%d", i+1);
     803      strncat(molecules[i]->name, number, MAXSTRINGSIZE - strlen(mol->name) - 1);
     804    }
     805    cout << "MolName is " << molecules[i]->name << endl;
    769806    insert(molecules[i]);
    770807  }
     
    774811  int *MolMap = Calloc<int>(mol->AtomCount, "config::Load() - *MolMap");
    775812  MoleculeLeafClass *MolecularWalker = Subgraphs;
    776   atom *Walker = NULL;
     813  Walker = NULL;
    777814  while (MolecularWalker->next != NULL) {
    778815    MolecularWalker = MolecularWalker->next;
     
    803840    }
    804841  }
    805   // 4d. we don't need to redo bonds, as they are connected subgraphs and still maintained their ListOfBonds, but we have to remove them from first..last list
    806   bond *Binder = mol->first;
     842  // 4d. we don't need to redo bonds, as they are connected subgraphs and still maintain their ListOfBonds, but we have to remove them from first..last list
     843  Binder = mol->first;
    807844  while (mol->first->next != mol->last) {
    808845    Binder = mol->first->next;
  • TabularUnified src/parser.cpp

    r9fe36b rb8d1aeb  
    66
    77// ======================================= INCLUDES ==========================================
     8
     9#include <cstring>
    810
    911#include "helpers.hpp"
     
    156158
    157159  input.open(name, ios::in);
    158   //Log() << Verbose(0) << "Opening " << name << " ... "  << input << endl;
     160  //Log() << Verbose(1) << "Opening " << name << " ... "  << input << endl;
    159161  if (input == NULL) {
    160     eLog() << Verbose(0) << endl << "Unable to open " << name << ", is the directory correct?" << endl;
    161     performCriticalExit();
     162    eLog() << Verbose(1) << endl << "Unable to open " << name << ", is the directory correct?" << endl;
     163    //performCriticalExit();
    162164    return false;
    163165  }
     
    179181  }
    180182  //Log() << Verbose(0) << line.str() << endl;
    181   //Log() << Verbose(0) << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << "." << endl;
     183  //Log() << Verbose(1) << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << "." << endl;
    182184  if (ColumnCounter[MatrixNr] == 0) {
    183185    eLog() << Verbose(0) << "ColumnCounter[" << MatrixNr << "]: " << ColumnCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl;
     
    195197    }
    196198  }
    197   //Log() << Verbose(0) << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << "." << endl;
     199  //Log() << Verbose(1) << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << "." << endl;
    198200  if (RowCounter[MatrixNr] == 0) {
    199201    eLog() << Verbose(0) << "RowCounter[" << MatrixNr << "]: " << RowCounter[MatrixNr] << " from file " << name << ", this is probably an error!" << endl;
     
    218220      input.getline(filename, 1023);
    219221      stringstream lines(filename);
    220       //Log() << Verbose(0) << "Matrix at level " << j << ":";// << filename << endl;
     222      //Log() << Verbose(2) << "Matrix at level " << j << ":";// << filename << endl;
    221223      for(int k=skipcolumns;k--;)
    222224        lines >> filename;
    223225      for(int k=0;(k<ColumnCounter[MatrixNr]) && (!lines.eof());k++) {
    224226        lines >> Matrix[MatrixNr][j][k];
    225         //Log() << Verbose(0) << " " << setprecision(2) << Matrix[MatrixNr][j][k];;
     227        //Log() << Verbose(1) << " " << setprecision(2) << Matrix[MatrixNr][j][k] << endl;
    226228      }
    227       //Log() << Verbose(0) << endl;
    228229      Matrix[MatrixNr][ RowCounter[MatrixNr] ] = Malloc<double>(ColumnCounter[MatrixNr], "MatrixContainer::ParseMatrix: *Matrix[RowCounter[MatrixNr]][]");
    229230      for(int j=ColumnCounter[MatrixNr];j--;)
  • TabularUnified src/periodentafel.cpp

    r9fe36b rb8d1aeb  
    99#include <iomanip>
    1010#include <fstream>
     11#include <cstring>
    1112
    1213#include "element.hpp"
  • TabularUnified src/tesselation.cpp

    r9fe36b rb8d1aeb  
    99
    1010#include "helpers.hpp"
     11#include "info.hpp"
    1112#include "linkedcell.hpp"
    1213#include "log.hpp"
     
    2223/** Constructor of BoundaryPointSet.
    2324 */
    24 BoundaryPointSet::BoundaryPointSet()
    25 {
    26   LinesCount = 0;
    27   Nr = -1;
    28   value = 0.;
     25BoundaryPointSet::BoundaryPointSet() :
     26    LinesCount(0),
     27    value(0.),
     28    Nr(-1)
     29{
     30        Info FunctionInfo(__func__);
     31        Log() << Verbose(1) << "Adding noname." << endl;
    2932};
    3033
     
    3235 * \param *Walker TesselPoint this boundary point represents
    3336 */
    34 BoundaryPointSet::BoundaryPointSet(TesselPoint * Walker)
    35 {
    36   node = Walker;
    37   LinesCount = 0;
    38   Nr = Walker->nr;
    39   value = 0.;
     37BoundaryPointSet::BoundaryPointSet(TesselPoint * const Walker) :
     38  LinesCount(0),
     39  node(Walker),
     40  value(0.),
     41  Nr(Walker->nr)
     42{
     43        Info FunctionInfo(__func__);
     44  Log() << Verbose(1) << "Adding Node " << *Walker << endl;
    4045};
    4146
     
    4651BoundaryPointSet::~BoundaryPointSet()
    4752{
    48   //Log() << Verbose(5) << "Erasing point nr. " << Nr << "." << endl;
     53        Info FunctionInfo(__func__);
     54  //Log() << Verbose(0) << "Erasing point nr. " << Nr << "." << endl;
    4955  if (!lines.empty())
    5056    eLog() << Verbose(2) << "Memory Leak! I " << *this << " am still connected to some lines." << endl;
     
    5561 * \param *line line to add
    5662 */
    57 void BoundaryPointSet::AddLine(class BoundaryLineSet *line)
    58 {
    59   Log() << Verbose(6) << "Adding " << *this << " to line " << *line << "."
     63void BoundaryPointSet::AddLine(BoundaryLineSet * const line)
     64{
     65        Info FunctionInfo(__func__);
     66  Log() << Verbose(1) << "Adding " << *this << " to line " << *line << "."
    6067      << endl;
    6168  if (line->endpoints[0] == this)
     
    8592/** Constructor of BoundaryLineSet.
    8693 */
    87 BoundaryLineSet::BoundaryLineSet()
    88 {
     94BoundaryLineSet::BoundaryLineSet() :
     95    Nr(-1)
     96{
     97        Info FunctionInfo(__func__);
    8998  for (int i = 0; i < 2; i++)
    9099    endpoints[i] = NULL;
    91   Nr = -1;
    92100};
    93101
     
    97105 * \param number number of the list
    98106 */
    99 BoundaryLineSet::BoundaryLineSet(class BoundaryPointSet *Point[2], const int number)
    100 {
     107BoundaryLineSet::BoundaryLineSet(BoundaryPointSet * const Point[2], const int number)
     108{
     109        Info FunctionInfo(__func__);
    101110  // set number
    102111  Nr = number;
     
    106115  Point[0]->AddLine(this); //Taken out, to check whether we can avoid unwanted double adding.
    107116  Point[1]->AddLine(this); //
     117  // set skipped to false
     118  skipped = false;
    108119  // clear triangles list
    109   Log() << Verbose(5) << "New Line with endpoints " << *this << "." << endl;
     120  Log() << Verbose(0) << "New Line with endpoints " << *this << "." << endl;
     121};
     122
     123/** Constructor of BoundaryLineSet with two endpoints.
     124 * Adds line automatically to each endpoints' LineMap
     125 * \param *Point1 first boundary point
     126 * \param *Point2 second boundary point
     127 * \param number number of the list
     128 */
     129BoundaryLineSet::BoundaryLineSet(BoundaryPointSet * const Point1, BoundaryPointSet * const Point2, const int number)
     130{
     131  Info FunctionInfo(__func__);
     132  // set number
     133  Nr = number;
     134  // set endpoints in ascending order
     135  SetEndpointsOrdered(endpoints, Point1, Point2);
     136  // add this line to the hash maps of both endpoints
     137  Point1->AddLine(this); //Taken out, to check whether we can avoid unwanted double adding.
     138  Point2->AddLine(this); //
     139  // set skipped to false
     140  skipped = false;
     141  // clear triangles list
     142  Log() << Verbose(0) << "New Line with endpoints " << *this << "." << endl;
    110143};
    111144
     
    116149BoundaryLineSet::~BoundaryLineSet()
    117150{
     151        Info FunctionInfo(__func__);
    118152  int Numbers[2];
    119153
     
    134168        for (LineMap::iterator Runner = erasor.first; Runner != erasor.second; Runner++)
    135169          if ((*Runner).second == this) {
    136             //Log() << Verbose(5) << "Removing Line Nr. " << Nr << " in boundary point " << *endpoints[i] << "." << endl;
     170            //Log() << Verbose(0) << "Removing Line Nr. " << Nr << " in boundary point " << *endpoints[i] << "." << endl;
    137171            endpoints[i]->lines.erase(Runner);
    138172            break;
     
    140174      } else { // there's just a single line left
    141175        if (endpoints[i]->lines.erase(Nr)) {
    142           //Log() << Verbose(5) << "Removing Line Nr. " << Nr << " in boundary point " << *endpoints[i] << "." << endl;
     176          //Log() << Verbose(0) << "Removing Line Nr. " << Nr << " in boundary point " << *endpoints[i] << "." << endl;
    143177        }
    144178      }
    145179      if (endpoints[i]->lines.empty()) {
    146         //Log() << Verbose(5) << *endpoints[i] << " has no more lines it's attached to, erasing." << endl;
     180        //Log() << Verbose(0) << *endpoints[i] << " has no more lines it's attached to, erasing." << endl;
    147181        if (endpoints[i] != NULL) {
    148182          delete(endpoints[i]);
     
    159193 * \param *triangle to add
    160194 */
    161 void BoundaryLineSet::AddTriangle(class BoundaryTriangleSet *triangle)
    162 {
    163   Log() << Verbose(6) << "Add " << triangle->Nr << " to line " << *this << "." << endl;
     195void BoundaryLineSet::AddTriangle(BoundaryTriangleSet * const triangle)
     196{
     197        Info FunctionInfo(__func__);
     198  Log() << Verbose(0) << "Add " << triangle->Nr << " to line " << *this << "." << endl;
    164199  triangles.insert(TrianglePair(triangle->Nr, triangle));
    165200};
     
    169204 * \return true - common endpoint present, false - not connected
    170205 */
    171 bool BoundaryLineSet::IsConnectedTo(class BoundaryLineSet *line)
    172 {
     206bool BoundaryLineSet::IsConnectedTo(const BoundaryLineSet * const line) const
     207{
     208        Info FunctionInfo(__func__);
    173209  if ((endpoints[0] == line->endpoints[0]) || (endpoints[1] == line->endpoints[0]) || (endpoints[0] == line->endpoints[1]) || (endpoints[1] == line->endpoints[1]))
    174210    return true;
     
    183219 * \return true - triangles are convex, false - concave or less than two triangles connected
    184220 */
    185 bool BoundaryLineSet::CheckConvexityCriterion()
    186 {
     221bool BoundaryLineSet::CheckConvexityCriterion() const
     222{
     223        Info FunctionInfo(__func__);
    187224  Vector BaseLineCenter, BaseLineNormal, BaseLine, helper[2], NormalCheck;
    188225  // get the two triangles
    189226  if (triangles.size() != 2) {
    190     eLog() << Verbose(1) << "Baseline " << *this << " is connected to less than two triangles, Tesselation incomplete!" << endl;
     227    eLog() << Verbose(0) << "Baseline " << *this << " is connected to less than two triangles, Tesselation incomplete!" << endl;
    191228    return true;
    192229  }
    193230  // check normal vectors
    194231  // have a normal vector on the base line pointing outwards
    195   //Log() << Verbose(3) << "INFO: " << *this << " has vectors at " << *(endpoints[0]->node->node) << " and at " << *(endpoints[1]->node->node) << "." << endl;
     232  //Log() << Verbose(0) << "INFO: " << *this << " has vectors at " << *(endpoints[0]->node->node) << " and at " << *(endpoints[1]->node->node) << "." << endl;
    196233  BaseLineCenter.CopyVector(endpoints[0]->node->node);
    197234  BaseLineCenter.AddVector(endpoints[1]->node->node);
     
    199236  BaseLine.CopyVector(endpoints[0]->node->node);
    200237  BaseLine.SubtractVector(endpoints[1]->node->node);
    201   //Log() << Verbose(3) << "INFO: Baseline is " << BaseLine << " and its center is at " << BaseLineCenter << "." << endl;
     238  //Log() << Verbose(0) << "INFO: Baseline is " << BaseLine << " and its center is at " << BaseLineCenter << "." << endl;
    202239
    203240  BaseLineNormal.Zero();
     
    206243  int i=0;
    207244  class BoundaryPointSet *node = NULL;
    208   for(TriangleMap::iterator runner = triangles.begin(); runner != triangles.end(); runner++) {
    209     //Log() << Verbose(3) << "INFO: NormalVector of " << *(runner->second) << " is " << runner->second->NormalVector << "." << endl;
     245  for(TriangleMap::const_iterator runner = triangles.begin(); runner != triangles.end(); runner++) {
     246    //Log() << Verbose(0) << "INFO: NormalVector of " << *(runner->second) << " is " << runner->second->NormalVector << "." << endl;
    210247    NormalCheck.AddVector(&runner->second->NormalVector);
    211248    NormalCheck.Scale(sign);
     
    214251      BaseLineNormal.CopyVector(&runner->second->NormalVector);   // yes, copy second on top of first
    215252    else {
    216       Log() << Verbose(1) << "CRITICAL: Triangle " << *runner->second << " has zero normal vector!" << endl;
    217       exit(255);
     253      eLog() << Verbose(0) << "Triangle " << *runner->second << " has zero normal vector!" << endl;
    218254    }
    219255    node = runner->second->GetThirdEndpoint(this);
    220256    if (node != NULL) {
    221       //Log() << Verbose(3) << "INFO: Third node for triangle " << *(runner->second) << " is " << *node << " at " << *(node->node->node) << "." << endl;
     257      //Log() << Verbose(0) << "INFO: Third node for triangle " << *(runner->second) << " is " << *node << " at " << *(node->node->node) << "." << endl;
    222258      helper[i].CopyVector(node->node->node);
    223259      helper[i].SubtractVector(&BaseLineCenter);
    224260      helper[i].MakeNormalVector(&BaseLine);  // we want to compare the triangle's heights' angles!
    225       //Log() << Verbose(4) << "INFO: Height vector with respect to baseline is " << helper[i] << "." << endl;
     261      //Log() << Verbose(0) << "INFO: Height vector with respect to baseline is " << helper[i] << "." << endl;
    226262      i++;
    227263    } else {
    228       //eLog() << Verbose(1) << "I cannot find third node in triangle, something's wrong." << endl;
     264      eLog() << Verbose(1) << "I cannot find third node in triangle, something's wrong." << endl;
    229265      return true;
    230266    }
    231267  }
    232   //Log() << Verbose(3) << "INFO: BaselineNormal is " << BaseLineNormal << "." << endl;
     268  //Log() << Verbose(0) << "INFO: BaselineNormal is " << BaseLineNormal << "." << endl;
    233269  if (NormalCheck.NormSquared() < MYEPSILON) {
    234     Log() << Verbose(3) << "ACCEPT: Normalvectors of both triangles are the same: convex." << endl;
     270    Log() << Verbose(0) << "ACCEPT: Normalvectors of both triangles are the same: convex." << endl;
    235271    return true;
    236272  }
     
    238274  double angle = GetAngle(helper[0], helper[1], BaseLineNormal);
    239275  if ((angle - M_PI) > -MYEPSILON) {
    240     Log() << Verbose(3) << "ACCEPT: Angle is greater than pi: convex." << endl;
     276    Log() << Verbose(0) << "ACCEPT: Angle is greater than pi: convex." << endl;
    241277    return true;
    242278  } else {
    243     Log() << Verbose(3) << "REJECT: Angle is less than pi: concave." << endl;
     279    Log() << Verbose(0) << "REJECT: Angle is less than pi: concave." << endl;
    244280    return false;
    245281  }
     
    250286 * \return true - point is of the line, false - is not
    251287 */
    252 bool BoundaryLineSet::ContainsBoundaryPoint(class BoundaryPointSet *point)
    253 {
     288bool BoundaryLineSet::ContainsBoundaryPoint(const BoundaryPointSet * const point) const
     289{
     290        Info FunctionInfo(__func__);
    254291  for(int i=0;i<2;i++)
    255292    if (point == endpoints[i])
     
    262299 * \return NULL - if endpoint not contained in BoundaryLineSet, or pointer to BoundaryPointSet otherwise
    263300 */
    264 class BoundaryPointSet *BoundaryLineSet::GetOtherEndpoint(class BoundaryPointSet *point)
    265 {
     301class BoundaryPointSet *BoundaryLineSet::GetOtherEndpoint(const BoundaryPointSet * const point) const
     302{
     303        Info FunctionInfo(__func__);
    266304  if (endpoints[0] == point)
    267305    return endpoints[1];
     
    286324/** Constructor for BoundaryTriangleSet.
    287325 */
    288 BoundaryTriangleSet::BoundaryTriangleSet()
    289 {
     326BoundaryTriangleSet::BoundaryTriangleSet() :
     327  Nr(-1)
     328{
     329        Info FunctionInfo(__func__);
    290330  for (int i = 0; i < 3; i++)
    291331    {
     
    293333      lines[i] = NULL;
    294334    }
    295   Nr = -1;
    296335};
    297336
     
    300339 * \param number number of triangle
    301340 */
    302 BoundaryTriangleSet::BoundaryTriangleSet(class BoundaryLineSet *line[3], int number)
    303 {
     341BoundaryTriangleSet::BoundaryTriangleSet(class BoundaryLineSet * const line[3], const int number) :
     342  Nr(number)
     343{
     344        Info FunctionInfo(__func__);
    304345  // set number
    305   Nr = number;
    306346  // set lines
    307   Log() << Verbose(5) << "New triangle " << Nr << ":" << endl;
    308   for (int i = 0; i < 3; i++)
    309     {
    310       lines[i] = line[i];
    311       lines[i]->AddTriangle(this);
    312     }
     347  for (int i = 0; i < 3; i++) {
     348    lines[i] = line[i];
     349    lines[i]->AddTriangle(this);
     350  }
    313351  // get ascending order of endpoints
    314   map<int, class BoundaryPointSet *> OrderMap;
     352  PointMap OrderMap;
    315353  for (int i = 0; i < 3; i++)
    316354    // for all three lines
    317     for (int j = 0; j < 2; j++)
    318       { // for both endpoints
    319         OrderMap.insert(pair<int, class BoundaryPointSet *> (
    320             line[i]->endpoints[j]->Nr, line[i]->endpoints[j]));
    321         // and we don't care whether insertion fails
    322       }
     355    for (int j = 0; j < 2; j++) { // for both endpoints
     356      OrderMap.insert(pair<int, class BoundaryPointSet *> (
     357          line[i]->endpoints[j]->Nr, line[i]->endpoints[j]));
     358      // and we don't care whether insertion fails
     359    }
    323360  // set endpoints
    324361  int Counter = 0;
    325   Log() << Verbose(6) << " with end points ";
    326   for (map<int, class BoundaryPointSet *>::iterator runner = OrderMap.begin(); runner
    327       != OrderMap.end(); runner++)
    328     {
    329       endpoints[Counter] = runner->second;
    330       Log() << Verbose(0) << " " << *endpoints[Counter];
    331       Counter++;
    332     }
    333   if (Counter < 3)
    334     {
    335       eLog() << Verbose(0) << "ERROR! We have a triangle with only two distinct endpoints!" << endl;
    336       performCriticalExit();
    337     }
    338   Log() << Verbose(0) << "." << endl;
     362  Log() << Verbose(0) << "New triangle " << Nr << " with end points: " << endl;
     363  for (PointMap::iterator runner = OrderMap.begin(); runner != OrderMap.end(); runner++) {
     364    endpoints[Counter] = runner->second;
     365    Log() << Verbose(0) << " " << *endpoints[Counter] << endl;
     366    Counter++;
     367  }
     368  if (Counter < 3) {
     369    eLog() << Verbose(0) << "We have a triangle with only two distinct endpoints!" << endl;
     370    performCriticalExit();
     371  }
    339372};
    340373
     
    345378BoundaryTriangleSet::~BoundaryTriangleSet()
    346379{
     380        Info FunctionInfo(__func__);
    347381  for (int i = 0; i < 3; i++) {
    348382    if (lines[i] != NULL) {
    349383      if (lines[i]->triangles.erase(Nr)) {
    350         //Log() << Verbose(5) << "Triangle Nr." << Nr << " erased in line " << *lines[i] << "." << endl;
     384        //Log() << Verbose(0) << "Triangle Nr." << Nr << " erased in line " << *lines[i] << "." << endl;
    351385      }
    352386      if (lines[i]->triangles.empty()) {
    353           //Log() << Verbose(5) << *lines[i] << " is no more attached to any triangle, erasing." << endl;
     387          //Log() << Verbose(0) << *lines[i] << " is no more attached to any triangle, erasing." << endl;
    354388          delete (lines[i]);
    355389          lines[i] = NULL;
     
    357391    }
    358392  }
    359   //Log() << Verbose(5) << "Erasing triangle Nr." << Nr << " itself." << endl;
     393  //Log() << Verbose(0) << "Erasing triangle Nr." << Nr << " itself." << endl;
    360394};
    361395
     
    364398 * \param &OtherVector direction vector to make normal vector unique.
    365399 */
    366 void BoundaryTriangleSet::GetNormalVector(Vector &OtherVector)
    367 {
     400void BoundaryTriangleSet::GetNormalVector(const Vector &OtherVector)
     401{
     402        Info FunctionInfo(__func__);
    368403  // get normal vector
    369404  NormalVector.MakeNormalVector(endpoints[0]->node->node, endpoints[1]->node->node, endpoints[2]->node->node);
     
    372407  if (NormalVector.ScalarProduct(&OtherVector) > 0.)
    373408    NormalVector.Scale(-1.);
    374 };
    375 
    376 /** Finds the point on the triangle \a *BTS the line defined by \a *MolCenter and \a *x crosses through.
     409  Log() << Verbose(1) << "Normal Vector is " << NormalVector << "." << endl;
     410};
     411
     412/** Finds the point on the triangle \a *BTS through which the line defined by \a *MolCenter and \a *x crosses.
    377413 * We call Vector::GetIntersectionWithPlane() to receive the intersection point with the plane
    378  * This we test if it's really on the plane and whether it's inside the triangle on the plane or not.
     414 * Thus we test if it's really on the plane and whether it's inside the triangle on the plane or not.
    379415 * The latter is done as follows: We calculate the cross point of one of the triangle's baseline with the line
    380416 * given by the intersection and the third basepoint. Then, we check whether it's on the baseline (i.e. between
     
    386422 * \return true - \a *Intersection contains intersection on plane defined by triangle, false - zero vector if outside of triangle.
    387423 */
    388 bool BoundaryTriangleSet::GetIntersectionInsideTriangle(Vector *MolCenter, Vector *x, Vector *Intersection)
    389 {
     424bool BoundaryTriangleSet::GetIntersectionInsideTriangle(const Vector * const MolCenter, const Vector * const x, Vector * const Intersection) const
     425{
     426  Info FunctionInfo(__func__);
    390427  Vector CrossPoint;
    391428  Vector helper;
    392429
    393430  if (!Intersection->GetIntersectionWithPlane(&NormalVector, endpoints[0]->node->node, MolCenter, x)) {
    394     Log() << Verbose(1) << "Alas! Intersection with plane failed - at least numerically - the intersection is not on the plane!" << endl;
     431    eLog() << Verbose(1) << "Alas! Intersection with plane failed - at least numerically - the intersection is not on the plane!" << endl;
    395432    return false;
    396433  }
    397434
     435  Log() << Verbose(1) << "INFO: Triangle is " << *this << "." << endl;
     436  Log() << Verbose(1) << "INFO: Line is from " << *MolCenter << " to " << *x << "." << endl;
     437  Log() << Verbose(1) << "INFO: Intersection is " << *Intersection << "." << endl;
     438
     439  if (Intersection->DistanceSquared(endpoints[0]->node->node) < MYEPSILON) {
     440    Log() << Verbose(1) << "Intersection coindices with first endpoint." << endl;
     441    return true;
     442  }   else if (Intersection->DistanceSquared(endpoints[1]->node->node) < MYEPSILON) {
     443    Log() << Verbose(1) << "Intersection coindices with second endpoint." << endl;
     444    return true;
     445  }   else if (Intersection->DistanceSquared(endpoints[2]->node->node) < MYEPSILON) {
     446    Log() << Verbose(1) << "Intersection coindices with third endpoint." << endl;
     447    return true;
     448  }
    398449  // Calculate cross point between one baseline and the line from the third endpoint to intersection
    399450  int i=0;
     
    402453      helper.CopyVector(endpoints[(i+1)%3]->node->node);
    403454      helper.SubtractVector(endpoints[i%3]->node->node);
     455      CrossPoint.SubtractVector(endpoints[i%3]->node->node);  // cross point was returned as absolute vector
     456      const double s = CrossPoint.ScalarProduct(&helper)/helper.NormSquared();
     457      Log() << Verbose(1) << "INFO: Factor s is " << s << "." << endl;
     458      if ((s < -MYEPSILON) || ((s-1.) > MYEPSILON)) {
     459        Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << "outside of triangle." << endl;
     460        i=4;
     461        break;
     462      }
     463      i++;
    404464    } else
    405       i++;
    406     if (i>2)
    407465      break;
    408   } while (CrossPoint.NormSquared() < MYEPSILON);
     466  } while (i<3);
    409467  if (i==3) {
    410     eLog() << Verbose(1) << "Could not find any cross points, something's utterly wrong here!" << endl;
    411     exit(255);
    412   }
    413   CrossPoint.SubtractVector(endpoints[i%3]->node->node);  // cross point was returned as absolute vector
    414 
    415   // check whether intersection is inside or not by comparing length of intersection and length of cross point
    416   if ((CrossPoint.NormSquared() - helper.NormSquared()) < MYEPSILON) { // inside
     468    Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << " inside of triangle." << endl;
    417469    return true;
    418   } else { // outside!
    419     Intersection->Zero();
     470  } else {
     471    Log() << Verbose(1) << "INFO: Crosspoint " << CrossPoint << " outside of triangle." << endl;
    420472    return false;
    421473  }
     474};
     475
     476/** Finds the point on the triangle \a *BTS through which the line defined by \a *MolCenter and \a *x crosses.
     477 * We call Vector::GetIntersectionWithPlane() to receive the intersection point with the plane
     478 * Thus we test if it's really on the plane and whether it's inside the triangle on the plane or not.
     479 * The latter is done as follows: We calculate the cross point of one of the triangle's baseline with the line
     480 * given by the intersection and the third basepoint. Then, we check whether it's on the baseline (i.e. between
     481 * the first two basepoints) or not.
     482 * \param *x point
     483 * \param *ClosestPoint desired closest point inside triangle to \a *x, is absolute vector
     484 * \return Distance squared between \a *x and closest point inside triangle
     485 */
     486double BoundaryTriangleSet::GetClosestPointInsideTriangle(const Vector * const x, Vector * const ClosestPoint) const
     487{
     488  Info FunctionInfo(__func__);
     489  Vector Direction;
     490
     491  // 1. get intersection with plane
     492  Log() << Verbose(1) << "INFO: Looking for closest point of triangle " << *this << " to " << *x << "." << endl;
     493  GetCenter(&Direction);
     494  if (!ClosestPoint->GetIntersectionWithPlane(&NormalVector, endpoints[0]->node->node, x, &Direction)) {
     495    ClosestPoint->CopyVector(x);
     496  }
     497
     498  // 2. Calculate in plane part of line (x, intersection)
     499  Vector InPlane;
     500  InPlane.CopyVector(x);
     501  InPlane.SubtractVector(ClosestPoint);  // points from plane intersection to straight-down point
     502  InPlane.ProjectOntoPlane(&NormalVector);
     503  InPlane.AddVector(ClosestPoint);
     504
     505  Log() << Verbose(2) << "INFO: Triangle is " << *this << "." << endl;
     506  Log() << Verbose(2) << "INFO: Line is from " << Direction << " to " << *x << "." << endl;
     507  Log() << Verbose(2) << "INFO: In-plane part is " << InPlane << "." << endl;
     508
     509  // Calculate cross point between one baseline and the desired point such that distance is shortest
     510  double ShortestDistance = -1.;
     511  bool InsideFlag = false;
     512  Vector CrossDirection[3];
     513  Vector CrossPoint[3];
     514  Vector helper;
     515  for (int i=0;i<3;i++) {
     516    // treat direction of line as normal of a (cut)plane and the desired point x as the plane offset, the intersect line with point
     517    Direction.CopyVector(endpoints[(i+1)%3]->node->node);
     518    Direction.SubtractVector(endpoints[i%3]->node->node);
     519    // calculate intersection, line can never be parallel to Direction (is the same vector as PlaneNormal);
     520    CrossPoint[i].GetIntersectionWithPlane(&Direction, &InPlane, endpoints[i%3]->node->node, endpoints[(i+1)%3]->node->node);
     521    CrossDirection[i].CopyVector(&CrossPoint[i]);
     522    CrossDirection[i].SubtractVector(&InPlane);
     523    CrossPoint[i].SubtractVector(endpoints[i%3]->node->node);  // cross point was returned as absolute vector
     524    const double s = CrossPoint[i].ScalarProduct(&Direction)/Direction.NormSquared();
     525    Log() << Verbose(2) << "INFO: Factor s is " << s << "." << endl;
     526    if ((s >= -MYEPSILON) && ((s-1.) <= MYEPSILON)) {
     527      CrossPoint[i].AddVector(endpoints[i%3]->node->node);  // make cross point absolute again
     528      Log() << Verbose(2) << "INFO: Crosspoint is " << CrossPoint[i] << ", intersecting BoundaryLine between " << *endpoints[i%3]->node->node << " and " << *endpoints[(i+1)%3]->node->node << "." << endl;
     529      const double distance = CrossPoint[i].DistanceSquared(x);
     530      if ((ShortestDistance < 0.) || (ShortestDistance > distance)) {
     531        ShortestDistance = distance;
     532        ClosestPoint->CopyVector(&CrossPoint[i]);
     533      }
     534    } else
     535      CrossPoint[i].Zero();
     536  }
     537  InsideFlag = true;
     538  for (int i=0;i<3;i++) {
     539    const double sign = CrossDirection[i].ScalarProduct(&CrossDirection[(i+1)%3]);
     540    const double othersign = CrossDirection[i].ScalarProduct(&CrossDirection[(i+2)%3]);;
     541    if ((sign > -MYEPSILON) && (othersign > -MYEPSILON))  // have different sign
     542      InsideFlag = false;
     543  }
     544  if (InsideFlag) {
     545    ClosestPoint->CopyVector(&InPlane);
     546    ShortestDistance = InPlane.DistanceSquared(x);
     547  } else {  // also check endnodes
     548    for (int i=0;i<3;i++) {
     549      const double distance = x->DistanceSquared(endpoints[i]->node->node);
     550      if ((ShortestDistance < 0.) || (ShortestDistance > distance)) {
     551        ShortestDistance = distance;
     552        ClosestPoint->CopyVector(endpoints[i]->node->node);
     553      }
     554    }
     555  }
     556  Log() << Verbose(1) << "INFO: Closest Point is " << *ClosestPoint << " with shortest squared distance is " << ShortestDistance << "." << endl;
     557  return ShortestDistance;
    422558};
    423559
     
    426562 * \return true - line is of the triangle, false - is not
    427563 */
    428 bool BoundaryTriangleSet::ContainsBoundaryLine(class BoundaryLineSet *line)
    429 {
     564bool BoundaryTriangleSet::ContainsBoundaryLine(const BoundaryLineSet * const line) const
     565{
     566        Info FunctionInfo(__func__);
    430567  for(int i=0;i<3;i++)
    431568    if (line == lines[i])
     
    438575 * \return true - point is of the triangle, false - is not
    439576 */
    440 bool BoundaryTriangleSet::ContainsBoundaryPoint(class BoundaryPointSet *point)
    441 {
     577bool BoundaryTriangleSet::ContainsBoundaryPoint(const BoundaryPointSet * const point) const
     578{
     579        Info FunctionInfo(__func__);
    442580  for(int i=0;i<3;i++)
    443581    if (point == endpoints[i])
     
    450588 * \return true - point is of the triangle, false - is not
    451589 */
    452 bool BoundaryTriangleSet::ContainsBoundaryPoint(class TesselPoint *point)
    453 {
     590bool BoundaryTriangleSet::ContainsBoundaryPoint(const TesselPoint * const point) const
     591{
     592        Info FunctionInfo(__func__);
    454593  for(int i=0;i<3;i++)
    455594    if (point == endpoints[i]->node)
     
    462601 * \return true - is the very triangle, false - is not
    463602 */
    464 bool BoundaryTriangleSet::IsPresentTupel(class BoundaryPointSet *Points[3])
    465 {
     603bool BoundaryTriangleSet::IsPresentTupel(const BoundaryPointSet * const Points[3]) const
     604{
     605        Info FunctionInfo(__func__);
     606        Log() << Verbose(1) << "INFO: Checking " << Points[0] << ","  << Points[1] << "," << Points[2] << " against " << endpoints[0] << "," << endpoints[1] << "," << endpoints[2] << "." << endl;
    466607  return (((endpoints[0] == Points[0])
    467608            || (endpoints[0] == Points[1])
     
    483624 * \return true - is the very triangle, false - is not
    484625 */
    485 bool BoundaryTriangleSet::IsPresentTupel(class BoundaryTriangleSet *T)
    486 {
     626bool BoundaryTriangleSet::IsPresentTupel(const BoundaryTriangleSet * const T) const
     627{
     628        Info FunctionInfo(__func__);
    487629  return (((endpoints[0] == T->endpoints[0])
    488630            || (endpoints[0] == T->endpoints[1])
     
    504646 * \return pointer third endpoint or NULL if line does not belong to triangle.
    505647 */
    506 class BoundaryPointSet *BoundaryTriangleSet::GetThirdEndpoint(class BoundaryLineSet *line)
    507 {
     648class BoundaryPointSet *BoundaryTriangleSet::GetThirdEndpoint(const BoundaryLineSet * const line) const
     649{
     650        Info FunctionInfo(__func__);
    508651  // sanity check
    509652  if (!ContainsBoundaryLine(line))
     
    520663 * \param *center central point on return.
    521664 */
    522 void BoundaryTriangleSet::GetCenter(Vector *center)
    523 {
     665void BoundaryTriangleSet::GetCenter(Vector * const center) const
     666{
     667        Info FunctionInfo(__func__);
    524668  center->Zero();
    525669  for(int i=0;i<3;i++)
    526670    center->AddVector(endpoints[i]->node->node);
    527671  center->Scale(1./3.);
     672  Log() << Verbose(1) << "INFO: Center is at " << *center << "." << endl;
    528673}
    529674
     
    534679ostream &operator <<(ostream &ost, const BoundaryTriangleSet &a)
    535680{
    536   ost << "[" << a.Nr << "|" << a.endpoints[0]->node->Name << " at " << *a.endpoints[0]->node->node << ","
    537       << 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 << "," << a.endpoints[1]->node->Name << "," << a.endpoints[2]->node->Name << "]";
     682//  ost << "[" << a.Nr << "|" << a.endpoints[0]->node->Name << " at " << *a.endpoints[0]->node->node << ","
     683//      << a.endpoints[1]->node->Name << " at " << *a.endpoints[1]->node->node << "," << a.endpoints[2]->node->Name << " at " << *a.endpoints[2]->node->node << "]";
    538684  return ost;
    539685};
    540686
     687// ======================================== Polygons on Boundary =================================
     688
     689/** Constructor for BoundaryPolygonSet.
     690 */
     691BoundaryPolygonSet::BoundaryPolygonSet() :
     692  Nr(-1)
     693{
     694  Info FunctionInfo(__func__);
     695};
     696
     697/** Destructor of BoundaryPolygonSet.
     698 * Just clears endpoints.
     699 * \note When removing triangles from a class Tesselation, use RemoveTesselationTriangle()
     700 */
     701BoundaryPolygonSet::~BoundaryPolygonSet()
     702{
     703  Info FunctionInfo(__func__);
     704  endpoints.clear();
     705  Log() << Verbose(1) << "Erasing polygon Nr." << Nr << " itself." << endl;
     706};
     707
     708/** Calculates the normal vector for this triangle.
     709 * Is made unique by comparison with \a OtherVector to point in the other direction.
     710 * \param &OtherVector direction vector to make normal vector unique.
     711 * \return allocated vector in normal direction
     712 */
     713Vector * BoundaryPolygonSet::GetNormalVector(const Vector &OtherVector) const
     714{
     715  Info FunctionInfo(__func__);
     716  // get normal vector
     717  Vector TemporaryNormal;
     718  Vector *TotalNormal = new Vector;
     719  PointSet::const_iterator Runner[3];
     720  for (int i=0;i<3; i++) {
     721    Runner[i] = endpoints.begin();
     722    for (int j = 0; j<i; j++) { // go as much further
     723      Runner[i]++;
     724      if (Runner[i] == endpoints.end()) {
     725        eLog() << Verbose(0) << "There are less than three endpoints in the polygon!" << endl;
     726        performCriticalExit();
     727      }
     728    }
     729  }
     730  TotalNormal->Zero();
     731  int counter=0;
     732  for (; Runner[2] != endpoints.end(); ) {
     733    TemporaryNormal.MakeNormalVector((*Runner[0])->node->node, (*Runner[1])->node->node, (*Runner[2])->node->node);
     734    for (int i=0;i<3;i++) // increase each of them
     735      Runner[i]++;
     736    TotalNormal->AddVector(&TemporaryNormal);
     737  }
     738  TotalNormal->Scale(1./(double)counter);
     739
     740  // make it always point inward (any offset vector onto plane projected onto normal vector suffices)
     741  if (TotalNormal->ScalarProduct(&OtherVector) > 0.)
     742    TotalNormal->Scale(-1.);
     743  Log() << Verbose(1) << "Normal Vector is " << *TotalNormal << "." << endl;
     744
     745  return TotalNormal;
     746};
     747
     748/** Calculates the center point of the triangle.
     749 * Is third of the sum of all endpoints.
     750 * \param *center central point on return.
     751 */
     752void BoundaryPolygonSet::GetCenter(Vector * const center) const
     753{
     754  Info FunctionInfo(__func__);
     755  center->Zero();
     756  int counter = 0;
     757  for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) {
     758    center->AddVector((*Runner)->node->node);
     759    counter++;
     760  }
     761  center->Scale(1./(double)counter);
     762  Log() << Verbose(1) << "Center is at " << *center << "." << endl;
     763}
     764
     765/** Checks whether the polygons contains all three endpoints of the triangle.
     766 * \param *triangle triangle to test
     767 * \return true - triangle is contained polygon, false - is not
     768 */
     769bool BoundaryPolygonSet::ContainsBoundaryTriangle(const BoundaryTriangleSet * const triangle) const
     770{
     771  Info FunctionInfo(__func__);
     772  return ContainsPresentTupel(triangle->endpoints, 3);
     773};
     774
     775/** Checks whether the polygons contains both endpoints of the line.
     776 * \param *line line to test
     777 * \return true - line is of the triangle, false - is not
     778 */
     779bool BoundaryPolygonSet::ContainsBoundaryLine(const BoundaryLineSet * const line) const
     780{
     781  Info FunctionInfo(__func__);
     782  return ContainsPresentTupel(line->endpoints, 2);
     783};
     784
     785/** Checks whether point is any of the three endpoints this triangle contains.
     786 * \param *point point to test
     787 * \return true - point is of the triangle, false - is not
     788 */
     789bool BoundaryPolygonSet::ContainsBoundaryPoint(const BoundaryPointSet * const point) const
     790{
     791  Info FunctionInfo(__func__);
     792  for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) {
     793    Log() << Verbose(0) << "Checking against " << **Runner << endl;
     794    if (point == (*Runner)) {
     795      Log() << Verbose(0) << " Contained." << endl;
     796      return true;
     797    }
     798  }
     799  Log() << Verbose(0) << " Not contained." << endl;
     800  return false;
     801};
     802
     803/** Checks whether point is any of the three endpoints this triangle contains.
     804 * \param *point TesselPoint to test
     805 * \return true - point is of the triangle, false - is not
     806 */
     807bool BoundaryPolygonSet::ContainsBoundaryPoint(const TesselPoint * const point) const
     808{
     809  Info FunctionInfo(__func__);
     810  for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++)
     811    if (point == (*Runner)->node) {
     812      Log() << Verbose(0) << " Contained." << endl;
     813      return true;
     814    }
     815  Log() << Verbose(0) << " Not contained." << endl;
     816  return false;
     817};
     818
     819/** Checks whether given array of \a *Points coincide with polygons's endpoints.
     820 * \param **Points pointer to an array of BoundaryPointSet
     821 * \param dim dimension of array
     822 * \return true - set of points is contained in polygon, false - is not
     823 */
     824bool BoundaryPolygonSet::ContainsPresentTupel(const BoundaryPointSet * const * Points, const int dim) const
     825{
     826  Info FunctionInfo(__func__);
     827  int counter = 0;
     828  Log() << Verbose(1) << "Polygon is " << *this << endl;
     829  for(int i=0;i<dim;i++) {
     830    Log() << Verbose(1) << " Testing endpoint " << *Points[i] << endl;
     831    if (ContainsBoundaryPoint(Points[i])) {
     832      counter++;
     833    }
     834  }
     835
     836  if (counter == dim)
     837    return true;
     838  else
     839    return false;
     840};
     841
     842/** Checks whether given PointList coincide with polygons's endpoints.
     843 * \param &endpoints PointList
     844 * \return true - set of points is contained in polygon, false - is not
     845 */
     846bool BoundaryPolygonSet::ContainsPresentTupel(const PointSet &endpoints) const
     847{
     848  Info FunctionInfo(__func__);
     849  size_t counter = 0;
     850  Log() << Verbose(1) << "Polygon is " << *this << endl;
     851  for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++) {
     852    Log() << Verbose(1) << " Testing endpoint " << **Runner << endl;
     853    if (ContainsBoundaryPoint(*Runner))
     854      counter++;
     855  }
     856
     857  if (counter == endpoints.size())
     858    return true;
     859  else
     860    return false;
     861};
     862
     863/** Checks whether given set of \a *Points coincide with polygons's endpoints.
     864 * \param *P pointer to BoundaryPolygonSet
     865 * \return true - is the very triangle, false - is not
     866 */
     867bool BoundaryPolygonSet::ContainsPresentTupel(const BoundaryPolygonSet * const P) const
     868{
     869  return ContainsPresentTupel((const PointSet)P->endpoints);
     870};
     871
     872/** Gathers all the endpoints' triangles in a unique set.
     873 * \return set of all triangles
     874 */
     875TriangleSet * BoundaryPolygonSet::GetAllContainedTrianglesFromEndpoints() const
     876{
     877  Info FunctionInfo(__func__);
     878  pair <TriangleSet::iterator, bool> Tester;
     879  TriangleSet *triangles = new TriangleSet;
     880
     881  for(PointSet::const_iterator Runner = endpoints.begin(); Runner != endpoints.end(); Runner++)
     882    for(LineMap::const_iterator Walker = (*Runner)->lines.begin(); Walker != (*Runner)->lines.end(); Walker++)
     883      for(TriangleMap::const_iterator Sprinter = (Walker->second)->triangles.begin(); Sprinter != (Walker->second)->triangles.end(); Sprinter++) {
     884        //Log() << Verbose(0) << " Testing triangle " << *(Sprinter->second) << endl;
     885        if (ContainsBoundaryTriangle(Sprinter->second)) {
     886          Tester = triangles->insert(Sprinter->second);
     887          if (Tester.second)
     888            Log() << Verbose(0) << "Adding triangle " << *(Sprinter->second) << endl;
     889        }
     890      }
     891
     892  Log() << Verbose(1) << "The Polygon of " << endpoints.size() << " endpoints has " << triangles->size() << " unique triangles in total." << endl;
     893  return triangles;
     894};
     895
     896/** Fills the endpoints of this polygon from the triangles attached to \a *line.
     897 * \param *line lines with triangles attached
     898 * \return true - polygon contains endpoints, false - line was NULL
     899 */
     900bool BoundaryPolygonSet::FillPolygonFromTrianglesOfLine(const BoundaryLineSet * const line)
     901{
     902  Info FunctionInfo(__func__);
     903  pair <PointSet::iterator, bool> Tester;
     904  if (line == NULL)
     905    return false;
     906  Log() << Verbose(1) << "Filling polygon from line " << *line << endl;
     907  for(TriangleMap::const_iterator Runner = line->triangles.begin(); Runner != line->triangles.end(); Runner++) {
     908    for (int i=0;i<3;i++) {
     909      Tester = endpoints.insert((Runner->second)->endpoints[i]);
     910      if (Tester.second)
     911        Log() << Verbose(1) << "  Inserting endpoint " << *((Runner->second)->endpoints[i]) << endl;
     912    }
     913  }
     914
     915  return true;
     916};
     917
     918/** output operator for BoundaryPolygonSet.
     919 * \param &ost output stream
     920 * \param &a boundary polygon
     921 */
     922ostream &operator <<(ostream &ost, const BoundaryPolygonSet &a)
     923{
     924  ost << "[" << a.Nr << "|";
     925  for(PointSet::const_iterator Runner = a.endpoints.begin(); Runner != a.endpoints.end();) {
     926   ost << (*Runner)->node->Name;
     927   Runner++;
     928   if (Runner != a.endpoints.end())
     929     ost << ",";
     930  }
     931  ost<< "]";
     932  return ost;
     933};
     934
    541935// =========================================================== class TESSELPOINT ===========================================
    542936
     
    545939TesselPoint::TesselPoint()
    546940{
     941  //Info FunctionInfo(__func__);
    547942  node = NULL;
    548943  nr = -1;
     
    554949TesselPoint::~TesselPoint()
    555950{
     951  //Info FunctionInfo(__func__);
    556952};
    557953
     
    568964ostream & TesselPoint::operator << (ostream &ost)
    569965{
    570   ost << "[" << (Name) << "|" << this << "]";
     966        Info FunctionInfo(__func__);
     967  ost << "[" << (nr) << "|" << this << "]";
    571968  return ost;
    572969};
     
    579976PointCloud::PointCloud()
    580977{
    581 
     978        //Info FunctionInfo(__func__);
    582979};
    583980
     
    586983PointCloud::~PointCloud()
    587984{
    588 
     985        //Info FunctionInfo(__func__);
    589986};
    590987
     
    593990/** Constructor of class CandidateForTesselation.
    594991 */
    595 CandidateForTesselation::CandidateForTesselation(TesselPoint *candidate, BoundaryLineSet* line, Vector OptCandidateCenter, Vector OtherOptCandidateCenter) {
    596   point = candidate;
    597   BaseLine = line;
     992CandidateForTesselation::CandidateForTesselation (BoundaryLineSet* line) :
     993  BaseLine(line),
     994  ShortestAngle(2.*M_PI),
     995  OtherShortestAngle(2.*M_PI)
     996{
     997        Info FunctionInfo(__func__);
     998};
     999
     1000
     1001/** Constructor of class CandidateForTesselation.
     1002 */
     1003CandidateForTesselation::CandidateForTesselation (TesselPoint *candidate, BoundaryLineSet* line, Vector OptCandidateCenter, Vector OtherOptCandidateCenter) :
     1004    BaseLine(line),
     1005    ShortestAngle(2.*M_PI),
     1006    OtherShortestAngle(2.*M_PI)
     1007{
     1008        Info FunctionInfo(__func__);
    5981009  OptCenter.CopyVector(&OptCandidateCenter);
    5991010  OtherOptCenter.CopyVector(&OtherOptCandidateCenter);
     
    6031014 */
    6041015CandidateForTesselation::~CandidateForTesselation() {
    605   point = NULL;
    6061016  BaseLine = NULL;
    6071017};
    6081018
     1019/** output operator for CandidateForTesselation.
     1020 * \param &ost output stream
     1021 * \param &a boundary line
     1022 */
     1023ostream & operator <<(ostream &ost, const  CandidateForTesselation &a)
     1024{
     1025  ost << "[" << a.BaseLine->Nr << "|" << a.BaseLine->endpoints[0]->node->Name << "," << a.BaseLine->endpoints[1]->node->Name << "] with ";
     1026  if (a.pointlist.empty())
     1027    ost << "no candidate.";
     1028  else {
     1029    ost << "candidate";
     1030    if (a.pointlist.size() != 1)
     1031      ost << "s ";
     1032    else
     1033      ost << " ";
     1034    for (TesselPointList::const_iterator Runner = a.pointlist.begin(); Runner != a.pointlist.end(); Runner++)
     1035      ost << *(*Runner) << " ";
     1036    ost << " at angle " << (a.ShortestAngle)<< ".";
     1037  }
     1038
     1039  return ost;
     1040};
     1041
     1042
    6091043// =========================================================== class TESSELATION ===========================================
    6101044
    6111045/** Constructor of class Tesselation.
    6121046 */
    613 Tesselation::Tesselation()
    614 {
    615   PointsOnBoundaryCount = 0;
    616   LinesOnBoundaryCount = 0;
    617   TrianglesOnBoundaryCount = 0;
    618   InternalPointer = PointsOnBoundary.begin();
    619   LastTriangle = NULL;
    620   TriangleFilesWritten = 0;
     1047Tesselation::Tesselation() :
     1048  PointsOnBoundaryCount(0),
     1049  LinesOnBoundaryCount(0),
     1050  TrianglesOnBoundaryCount(0),
     1051  LastTriangle(NULL),
     1052  TriangleFilesWritten(0),
     1053  InternalPointer(PointsOnBoundary.begin())
     1054{
     1055        Info FunctionInfo(__func__);
    6211056}
    6221057;
     
    6271062Tesselation::~Tesselation()
    6281063{
    629   Log() << Verbose(1) << "Free'ing TesselStruct ... " << endl;
     1064        Info FunctionInfo(__func__);
     1065  Log() << Verbose(0) << "Free'ing TesselStruct ... " << endl;
    6301066  for (TriangleMap::iterator runner = TrianglesOnBoundary.begin(); runner != TrianglesOnBoundary.end(); runner++) {
    6311067    if (runner->second != NULL) {
     
    6351071      eLog() << Verbose(1) << "The triangle " << runner->first << " has already been free'd." << endl;
    6361072  }
    637   Log() << Verbose(1) << "This envelope was written to file " << TriangleFilesWritten << " times(s)." << endl;
     1073  Log() << Verbose(0) << "This envelope was written to file " << TriangleFilesWritten << " times(s)." << endl;
    6381074}
    6391075;
     
    6441080Vector * Tesselation::GetCenter(ofstream *out) const
    6451081{
     1082        Info FunctionInfo(__func__);
    6461083  Vector *Center = new Vector(0.,0.,0.);
    6471084  int num=0;
     
    6591096TesselPoint * Tesselation::GetPoint() const
    6601097{
     1098        Info FunctionInfo(__func__);
    6611099  return (InternalPointer->second->node);
    6621100};
     
    6671105TesselPoint * Tesselation::GetTerminalPoint() const
    6681106{
     1107        Info FunctionInfo(__func__);
    6691108  PointMap::const_iterator Runner = PointsOnBoundary.end();
    6701109  Runner--;
     
    6771116void Tesselation::GoToNext() const
    6781117{
     1118        Info FunctionInfo(__func__);
    6791119  if (InternalPointer != PointsOnBoundary.end())
    6801120    InternalPointer++;
     
    6861126void Tesselation::GoToPrevious() const
    6871127{
     1128        Info FunctionInfo(__func__);
    6881129  if (InternalPointer != PointsOnBoundary.begin())
    6891130    InternalPointer--;
     
    6951136void Tesselation::GoToFirst() const
    6961137{
     1138        Info FunctionInfo(__func__);
    6971139  InternalPointer = PointsOnBoundary.begin();
    6981140};
     
    7031145void Tesselation::GoToLast() const
    7041146{
     1147        Info FunctionInfo(__func__);
    7051148  InternalPointer = PointsOnBoundary.end();
    7061149  InternalPointer--;
     
    7121155bool Tesselation::IsEmpty() const
    7131156{
     1157        Info FunctionInfo(__func__);
    7141158  return (PointsOnBoundary.empty());
    7151159};
     
    7201164bool Tesselation::IsEnd() const
    7211165{
     1166        Info FunctionInfo(__func__);
    7221167  return (InternalPointer == PointsOnBoundary.end());
    7231168};
     
    7291174 * \param PointsOnBoundary set of boundary points defining the convex envelope of the cluster
    7301175 */
    731 void
    732 Tesselation::GuessStartingTriangle()
    733 {
     1176void Tesselation::GuessStartingTriangle()
     1177{
     1178        Info FunctionInfo(__func__);
    7341179  // 4b. create a starting triangle
    7351180  // 4b1. create all distances
     
    7781223          baseline->second.first->second->node->node,
    7791224          baseline->second.second->second->node->node);
    780       Log() << Verbose(2) << "Plane vector of candidate triangle is ";
    781       PlaneVector.Output();
    782       Log() << Verbose(0) << endl;
     1225      Log() << Verbose(2) << "Plane vector of candidate triangle is " << PlaneVector << endl;
    7831226      // 4. loop over all points
    7841227      double sign = 0.;
     
    7961239          if (fabs(distance) < 1e-4) // we need to have a small epsilon around 0 which is still ok
    7971240            continue;
    798           Log() << Verbose(3) << "Projection of " << checker->second->node->Name
    799               << " yields distance of " << distance << "." << endl;
     1241          Log() << Verbose(2) << "Projection of " << checker->second->node->Name << " yields distance of " << distance << "." << endl;
    8001242          tmp = distance / fabs(distance);
    8011243          // 4b. Any have different sign to than before? (i.e. would lie outside convex hull with this starting triangle)
     
    8501292      if (checker == PointsOnBoundary.end())
    8511293        {
    852           Log() << Verbose(0) << "Looks like we have a candidate!" << endl;
     1294          Log() << Verbose(2) << "Looks like we have a candidate!" << endl;
    8531295          break;
    8541296        }
     
    8801322  else
    8811323    {
    882       Log() << Verbose(1) << "No starting triangle found." << endl;
    883       exit(255);
     1324      eLog() << Verbose(0) << "No starting triangle found." << endl;
    8841325    }
    8851326}
     
    9011342void Tesselation::TesselateOnBoundary(const PointCloud * const cloud)
    9021343{
     1344        Info FunctionInfo(__func__);
    9031345  bool flag;
    9041346  PointMap::iterator winner;
     
    9191361        // get peak point with respect to this base line's only triangle
    9201362        BTS = baseline->second->triangles.begin()->second; // there is only one triangle so far
    921         Log() << Verbose(2) << "Current baseline is between " << *(baseline->second) << "." << endl;
     1363        Log() << Verbose(0) << "Current baseline is between " << *(baseline->second) << "." << endl;
    9221364        for (int i = 0; i < 3; i++)
    9231365          if ((BTS->endpoints[i] != baseline->second->endpoints[0]) && (BTS->endpoints[i] != baseline->second->endpoints[1]))
    9241366            peak = BTS->endpoints[i];
    925         Log() << Verbose(3) << " and has peak " << *peak << "." << endl;
     1367        Log() << Verbose(1) << " and has peak " << *peak << "." << endl;
    9261368
    9271369        // prepare some auxiliary vectors
     
    9381380          CenterVector.AddVector(BTS->endpoints[i]->node->node);
    9391381        CenterVector.Scale(1. / 3.);
    940         Log() << Verbose(4) << "CenterVector of base triangle is " << CenterVector << endl;
     1382        Log() << Verbose(2) << "CenterVector of base triangle is " << CenterVector << endl;
    9411383
    9421384        // normal vector of triangle
     
    9451387        BTS->GetNormalVector(NormalVector);
    9461388        NormalVector.CopyVector(&BTS->NormalVector);
    947         Log() << Verbose(4) << "NormalVector of base triangle is " << NormalVector << endl;
     1389        Log() << Verbose(2) << "NormalVector of base triangle is " << NormalVector << endl;
    9481390
    9491391        // vector in propagation direction (out of triangle)
     
    9521394        TempVector.CopyVector(&CenterVector);
    9531395        TempVector.SubtractVector(baseline->second->endpoints[0]->node->node); // TempVector is vector on triangle plane pointing from one baseline egde towards center!
    954         //Log() << Verbose(2) << "Projection of propagation onto temp: " << PropagationVector.Projection(&TempVector) << "." << endl;
     1396        //Log() << Verbose(0) << "Projection of propagation onto temp: " << PropagationVector.Projection(&TempVector) << "." << endl;
    9551397        if (PropagationVector.ScalarProduct(&TempVector) > 0) // make sure normal propagation vector points outward from baseline
    9561398          PropagationVector.Scale(-1.);
    957         Log() << Verbose(4) << "PropagationVector of base triangle is " << PropagationVector << endl;
     1399        Log() << Verbose(2) << "PropagationVector of base triangle is " << PropagationVector << endl;
    9581400        winner = PointsOnBoundary.end();
    9591401
     
    9611403        for (PointMap::iterator target = PointsOnBoundary.begin(); target != PointsOnBoundary.end(); target++) {
    9621404          if ((target->second != baseline->second->endpoints[0]) && (target->second != baseline->second->endpoints[1])) { // don't take the same endpoints
    963             Log() << Verbose(3) << "Target point is " << *(target->second) << ":" << endl;
     1405            Log() << Verbose(1) << "Target point is " << *(target->second) << ":" << endl;
    9641406
    9651407            // first check direction, so that triangles don't intersect
     
    9681410            VirtualNormalVector.ProjectOntoPlane(&NormalVector);
    9691411            TempAngle = VirtualNormalVector.Angle(&PropagationVector);
    970             Log() << Verbose(4) << "VirtualNormalVector is " << VirtualNormalVector << " and PropagationVector is " << PropagationVector << "." << endl;
     1412            Log() << Verbose(2) << "VirtualNormalVector is " << VirtualNormalVector << " and PropagationVector is " << PropagationVector << "." << endl;
    9711413            if (TempAngle > (M_PI/2.)) { // no bends bigger than Pi/2 (90 degrees)
    972               Log() << Verbose(4) << "Angle on triangle plane between propagation direction and base line to " << *(target->second) << " is " << TempAngle << ", bad direction!" << endl;
     1414              Log() << Verbose(2) << "Angle on triangle plane between propagation direction and base line to " << *(target->second) << " is " << TempAngle << ", bad direction!" << endl;
    9731415              continue;
    9741416            } else
    975               Log() << Verbose(4) << "Angle on triangle plane between propagation direction and base line to " << *(target->second) << " is " << TempAngle << ", good direction!" << endl;
     1417              Log() << Verbose(2) << "Angle on triangle plane between propagation direction and base line to " << *(target->second) << " is " << TempAngle << ", good direction!" << endl;
    9761418
    9771419            // check first and second endpoint (if any connecting line goes to target has at least not more than 1 triangle)
     
    9791421            LineChecker[1] = baseline->second->endpoints[1]->lines.find(target->first);
    9801422            if (((LineChecker[0] != baseline->second->endpoints[0]->lines.end()) && (LineChecker[0]->second->triangles.size() == 2))) {
    981               Log() << Verbose(4) << *(baseline->second->endpoints[0]) << " has line " << *(LineChecker[0]->second) << " to " << *(target->second) << " as endpoint with " << LineChecker[0]->second->triangles.size() << " triangles." << endl;
     1423              Log() << Verbose(2) << *(baseline->second->endpoints[0]) << " has line " << *(LineChecker[0]->second) << " to " << *(target->second) << " as endpoint with " << LineChecker[0]->second->triangles.size() << " triangles." << endl;
    9821424              continue;
    9831425            }
    9841426            if (((LineChecker[1] != baseline->second->endpoints[1]->lines.end()) && (LineChecker[1]->second->triangles.size() == 2))) {
    985               Log() << Verbose(4) << *(baseline->second->endpoints[1]) << " has line " << *(LineChecker[1]->second) << " to " << *(target->second) << " as endpoint with " << LineChecker[1]->second->triangles.size() << " triangles." << endl;
     1427              Log() << Verbose(2) << *(baseline->second->endpoints[1]) << " has line " << *(LineChecker[1]->second) << " to " << *(target->second) << " as endpoint with " << LineChecker[1]->second->triangles.size() << " triangles." << endl;
    9861428              continue;
    9871429            }
     
    10001442            helper.ProjectOntoPlane(&TempVector);
    10011443            if (fabs(helper.NormSquared()) < MYEPSILON) {
    1002               Log() << Verbose(4) << "Chosen set of vectors is linear dependent." << endl;
     1444              Log() << Verbose(2) << "Chosen set of vectors is linear dependent." << endl;
    10031445              continue;
    10041446            }
     
    10171459            // calculate angle
    10181460            TempAngle = NormalVector.Angle(&VirtualNormalVector);
    1019             Log() << Verbose(4) << "NormalVector is " << VirtualNormalVector << " and the angle is " << TempAngle << "." << endl;
     1461            Log() << Verbose(2) << "NormalVector is " << VirtualNormalVector << " and the angle is " << TempAngle << "." << endl;
    10201462            if ((SmallestAngle - TempAngle) > MYEPSILON) { // set to new possible winner
    10211463              SmallestAngle = TempAngle;
    10221464              winner = target;
    1023               Log() << Verbose(4) << "New winner " << *winner->second->node << " due to smaller angle between normal vectors." << endl;
     1465              Log() << Verbose(2) << "New winner " << *winner->second->node << " due to smaller angle between normal vectors." << endl;
    10241466            } else if (fabs(SmallestAngle - TempAngle) < MYEPSILON) { // check the angle to propagation, both possible targets are in one plane! (their normals have same angle)
    10251467              // hence, check the angles to some normal direction from our base line but in this common plane of both targets...
     
    10391481                SmallestAngle = TempAngle;
    10401482                winner = target;
    1041                 Log() << Verbose(4) << "New winner " << *winner->second->node << " due to smaller angle " << TempAngle << " to propagation direction." << endl;
     1483                Log() << Verbose(2) << "New winner " << *winner->second->node << " due to smaller angle " << TempAngle << " to propagation direction." << endl;
    10421484              } else
    1043                 Log() << Verbose(4) << "Keeping old winner " << *winner->second->node << " due to smaller angle to propagation direction." << endl;
     1485                Log() << Verbose(2) << "Keeping old winner " << *winner->second->node << " due to smaller angle to propagation direction." << endl;
    10441486            } else
    1045               Log() << Verbose(4) << "Keeping old winner " << *winner->second->node << " due to smaller angle between normal vectors." << endl;
     1487              Log() << Verbose(2) << "Keeping old winner " << *winner->second->node << " due to smaller angle between normal vectors." << endl;
    10461488          }
    10471489        } // end of loop over all boundary points
     
    10491491        // 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
    10501492        if (winner != PointsOnBoundary.end()) {
    1051           Log() << Verbose(2) << "Winning target point is " << *(winner->second) << " with angle " << SmallestAngle << "." << endl;
     1493          Log() << Verbose(0) << "Winning target point is " << *(winner->second) << " with angle " << SmallestAngle << "." << endl;
    10521494          // create the lins of not yet present
    10531495          BLS[0] = baseline->second;
     
    10791521          TrianglesOnBoundaryCount++;
    10801522        } else {
    1081           Log() << Verbose(1) << "I could not determine a winner for this baseline " << *(baseline->second) << "." << endl;
     1523          eLog() << Verbose(2) << "I could not determine a winner for this baseline " << *(baseline->second) << "." << endl;
    10821524        }
    10831525
    10841526        // 5d. If the set of lines is not yet empty, go to 5. and continue
    10851527      } else
    1086         Log() << Verbose(2) << "Baseline candidate " << *(baseline->second) << " has a triangle count of " << baseline->second->triangles.size() << "." << endl;
     1528        Log() << Verbose(0) << "Baseline candidate " << *(baseline->second) << " has a triangle count of " << baseline->second->triangles.size() << "." << endl;
    10871529  } while (flag);
    10881530
     
    10991541bool Tesselation::InsertStraddlingPoints(const PointCloud *cloud, const LinkedCell *LC)
    11001542{
     1543        Info FunctionInfo(__func__);
    11011544  Vector Intersection, Normal;
    11021545  TesselPoint *Walker = NULL;
    11031546  Vector *Center = cloud->GetCenter();
    1104   list<BoundaryTriangleSet*> *triangles = NULL;
     1547  TriangleList *triangles = NULL;
    11051548  bool AddFlag = false;
    11061549  LinkedCell *BoundaryPoints = NULL;
    1107 
    1108   Log() << Verbose(1) << "Begin of InsertStraddlingPoints" << endl;
    11091550
    11101551  cloud->GoToFirst();
     
    11171558    }
    11181559    Walker = cloud->GetPoint();
    1119     Log() << Verbose(2) << "Current point is " << *Walker << "." << endl;
     1560    Log() << Verbose(0) << "Current point is " << *Walker << "." << endl;
    11201561    // get the next triangle
    1121     triangles = FindClosestTrianglesToPoint(Walker->node, BoundaryPoints);
     1562    triangles = FindClosestTrianglesToVector(Walker->node, BoundaryPoints);
    11221563    BTS = triangles->front();
    11231564    if ((triangles == NULL) || (BTS->ContainsBoundaryPoint(Walker))) {
    1124       Log() << Verbose(2) << "No triangles found, probably a tesselation point itself." << endl;
     1565      Log() << Verbose(0) << "No triangles found, probably a tesselation point itself." << endl;
    11251566      cloud->GoToNext();
    11261567      continue;
    11271568    } else {
    11281569    }
    1129     Log() << Verbose(2) << "Closest triangle is " << *BTS << "." << endl;
     1570    Log() << Verbose(0) << "Closest triangle is " << *BTS << "." << endl;
    11301571    // get the intersection point
    11311572    if (BTS->GetIntersectionInsideTriangle(Center, Walker->node, &Intersection)) {
    1132       Log() << Verbose(2) << "We have an intersection at " << Intersection << "." << endl;
     1573      Log() << Verbose(0) << "We have an intersection at " << Intersection << "." << endl;
    11331574      // we have the intersection, check whether in- or outside of boundary
    11341575      if ((Center->DistanceSquared(Walker->node) - Center->DistanceSquared(&Intersection)) < -MYEPSILON) {
    11351576        // inside, next!
    1136         Log() << Verbose(2) << *Walker << " is inside wrt triangle " << *BTS << "." << endl;
     1577        Log() << Verbose(0) << *Walker << " is inside wrt triangle " << *BTS << "." << endl;
    11371578      } else {
    11381579        // outside!
    1139         Log() << Verbose(2) << *Walker << " is outside wrt triangle " << *BTS << "." << endl;
     1580        Log() << Verbose(0) << *Walker << " is outside wrt triangle " << *BTS << "." << endl;
    11401581        class BoundaryLineSet *OldLines[3], *NewLines[3];
    11411582        class BoundaryPointSet *OldPoints[3], *NewPoint;
     
    11471588        Normal.CopyVector(&BTS->NormalVector);
    11481589        // add Walker to boundary points
    1149         Log() << Verbose(2) << "Adding " << *Walker << " to BoundaryPoints." << endl;
     1590        Log() << Verbose(0) << "Adding " << *Walker << " to BoundaryPoints." << endl;
    11501591        AddFlag = true;
    11511592        if (AddBoundaryPoint(Walker,0))
     
    11541595          continue;
    11551596        // remove triangle
    1156         Log() << Verbose(2) << "Erasing triangle " << *BTS << "." << endl;
     1597        Log() << Verbose(0) << "Erasing triangle " << *BTS << "." << endl;
    11571598        TrianglesOnBoundary.erase(BTS->Nr);
    11581599        delete(BTS);
     
    11621603          BPS[1] = OldPoints[i];
    11631604          NewLines[i] = new class BoundaryLineSet(BPS, LinesOnBoundaryCount);
    1164           Log() << Verbose(3) << "Creating new line " << *NewLines[i] << "." << endl;
     1605          Log() << Verbose(1) << "Creating new line " << *NewLines[i] << "." << endl;
    11651606          LinesOnBoundary.insert(LinePair(LinesOnBoundaryCount, NewLines[i])); // no need for check for unique insertion as BPS[0] is definitely a new one
    11661607          LinesOnBoundaryCount++;
     
    11731614            if (NewLines[j]->IsConnectedTo(BLS[0])) {
    11741615              if (n>2) {
    1175                 Log() << Verbose(1) << BLS[0] << " connects to all of the new lines?!" << endl;
     1616                eLog() << Verbose(2) << BLS[0] << " connects to all of the new lines?!" << endl;
    11761617                return false;
    11771618              } else
     
    11841625          BTS->GetNormalVector(Normal);
    11851626          Normal.Scale(-1.);
    1186           Log() << Verbose(2) << "Created new triangle " << *BTS << "." << endl;
     1627          Log() << Verbose(0) << "Created new triangle " << *BTS << "." << endl;
    11871628          TrianglesOnBoundary.insert(TrianglePair(TrianglesOnBoundaryCount, BTS));
    11881629          TrianglesOnBoundaryCount++;
     
    11981639  // exit
    11991640  delete(Center);
    1200   Log() << Verbose(1) << "End of InsertStraddlingPoints" << endl;
    12011641  return true;
    12021642};
     
    12091649bool Tesselation::AddBoundaryPoint(TesselPoint * Walker, const int n)
    12101650{
     1651        Info FunctionInfo(__func__);
    12111652  PointTestPair InsertUnique;
    12121653  BPS[n] = new class BoundaryPointSet(Walker);
     
    12301671void Tesselation::AddTesselationPoint(TesselPoint* Candidate, const int n)
    12311672{
     1673        Info FunctionInfo(__func__);
    12321674  PointTestPair InsertUnique;
    12331675  TPS[n] = new class BoundaryPointSet(Candidate);
     
    12371679  } else {
    12381680    delete TPS[n];
    1239     Log() << Verbose(4) << "Node " << *((InsertUnique.first)->second->node) << " is already present in PointsOnBoundary." << endl;
     1681    Log() << Verbose(0) << "Node " << *((InsertUnique.first)->second->node) << " is already present in PointsOnBoundary." << endl;
    12401682    TPS[n] = (InsertUnique.first)->second;
    12411683  }
     
    12501692void Tesselation::SetTesselationPoint(TesselPoint* Candidate, const int n) const
    12511693{
     1694        Info FunctionInfo(__func__);
    12521695  PointMap::const_iterator FindPoint = PointsOnBoundary.find(Candidate->nr);
    12531696  if (FindPoint != PointsOnBoundary.end())
     
    12671710  bool insertNewLine = true;
    12681711
    1269   if (a->lines.find(b->node->nr) != a->lines.end()) {
    1270     LineMap::iterator FindLine = a->lines.find(b->node->nr);
     1712  LineMap::iterator FindLine = a->lines.find(b->node->nr);
     1713  if (FindLine != a->lines.end()) {
     1714    Log() << Verbose(1) << "INFO: There is at least one line between " << *a << " and " << *b << ": " << *(FindLine->second) << "." << endl;
     1715
    12711716    pair<LineMap::iterator,LineMap::iterator> FindPair;
    12721717    FindPair = a->lines.equal_range(b->node->nr);
    1273     Log() << Verbose(5) << "INFO: There is at least one line between " << *a << " and " << *b << ": " << *(FindLine->second) << "." << endl;
    12741718
    12751719    for (FindLine = FindPair.first; FindLine != FindPair.second; FindLine++) {
     
    12771721      if (FindLine->second->triangles.size() < 2) {
    12781722        insertNewLine = false;
    1279         Log() << Verbose(4) << "Using existing line " << *FindLine->second << endl;
     1723        Log() << Verbose(0) << "Using existing line " << *FindLine->second << endl;
    12801724
    12811725        BPS[0] = FindLine->second->endpoints[0];
    12821726        BPS[1] = FindLine->second->endpoints[1];
    12831727        BLS[n] = FindLine->second;
     1728
     1729        // remove existing line from OpenLines
     1730        CandidateMap::iterator CandidateLine = OpenLines.find(BLS[n]);
     1731        if (CandidateLine != OpenLines.end()) {
     1732          Log() << Verbose(1) << " Removing line from OpenLines." << endl;
     1733          delete(CandidateLine->second);
     1734          OpenLines.erase(CandidateLine);
     1735        } else {
     1736          eLog() << Verbose(1) << "Line exists and is attached to less than two triangles, but not in OpenLines!" << endl;
     1737        }
    12841738
    12851739        break;
     
    13041758void Tesselation::AlwaysAddTesselationTriangleLine(class BoundaryPointSet *a, class BoundaryPointSet *b, const int n)
    13051759{
    1306   Log() << Verbose(4) << "Adding line [" << LinesOnBoundaryCount << "|" << *(a->node) << " and " << *(b->node) << "." << endl;
     1760        Info FunctionInfo(__func__);
     1761  Log() << Verbose(0) << "Adding open line [" << LinesOnBoundaryCount << "|" << *(a->node) << " and " << *(b->node) << "." << endl;
    13071762  BPS[0] = a;
    13081763  BPS[1] = b;
     
    13121767  // increase counter
    13131768  LinesOnBoundaryCount++;
     1769  // also add to open lines
     1770  CandidateForTesselation *CFT = new CandidateForTesselation(BLS[n]);
     1771  OpenLines.insert(pair< BoundaryLineSet *, CandidateForTesselation *> (BLS[n], CFT));
    13141772};
    13151773
     
    13191777void Tesselation::AddTesselationTriangle()
    13201778{
     1779        Info FunctionInfo(__func__);
    13211780  Log() << Verbose(1) << "Adding triangle to global TrianglesOnBoundary map." << endl;
    13221781
     
    13371796void Tesselation::AddTesselationTriangle(const int nr)
    13381797{
    1339   Log() << Verbose(1) << "Adding triangle to global TrianglesOnBoundary map." << endl;
     1798        Info FunctionInfo(__func__);
     1799  Log() << Verbose(0) << "Adding triangle to global TrianglesOnBoundary map." << endl;
    13401800
    13411801  // add triangle to global map
     
    13551815void Tesselation::RemoveTesselationTriangle(class BoundaryTriangleSet *triangle)
    13561816{
     1817        Info FunctionInfo(__func__);
    13571818  if (triangle == NULL)
    13581819    return;
    13591820  for (int i = 0; i < 3; i++) {
    13601821    if (triangle->lines[i] != NULL) {
    1361       Log() << Verbose(5) << "Removing triangle Nr." << triangle->Nr << " in line " << *triangle->lines[i] << "." << endl;
     1822      Log() << Verbose(0) << "Removing triangle Nr." << triangle->Nr << " in line " << *triangle->lines[i] << "." << endl;
    13621823      triangle->lines[i]->triangles.erase(triangle->Nr);
    13631824      if (triangle->lines[i]->triangles.empty()) {
    1364           Log() << Verbose(5) << *triangle->lines[i] << " is no more attached to any triangle, erasing." << endl;
     1825          Log() << Verbose(0) << *triangle->lines[i] << " is no more attached to any triangle, erasing." << endl;
    13651826          RemoveTesselationLine(triangle->lines[i]);
    13661827      } else {
    1367         Log() << Verbose(5) << *triangle->lines[i] << " is still attached to another triangle: ";
     1828        Log() << Verbose(0) << *triangle->lines[i] << " is still attached to another triangle: ";
     1829        OpenLines.insert(pair< BoundaryLineSet *, CandidateForTesselation *> (triangle->lines[i], NULL));
    13681830        for(TriangleMap::iterator TriangleRunner = triangle->lines[i]->triangles.begin(); TriangleRunner != triangle->lines[i]->triangles.end(); TriangleRunner++)
    13691831          Log() << Verbose(0) << "[" << (TriangleRunner->second)->Nr << "|" << *((TriangleRunner->second)->endpoints[0]) << ", " << *((TriangleRunner->second)->endpoints[1]) << ", " << *((TriangleRunner->second)->endpoints[2]) << "] \t";
    13701832        Log() << Verbose(0) << endl;
    13711833//        for (int j=0;j<2;j++) {
    1372 //          Log() << Verbose(5) << "Lines of endpoint " << *(triangle->lines[i]->endpoints[j]) << ": ";
     1834//          Log() << Verbose(0) << "Lines of endpoint " << *(triangle->lines[i]->endpoints[j]) << ": ";
    13731835//          for(LineMap::iterator LineRunner = triangle->lines[i]->endpoints[j]->lines.begin(); LineRunner != triangle->lines[i]->endpoints[j]->lines.end(); LineRunner++)
    13741836//            Log() << Verbose(0) << "[" << *(LineRunner->second) << "] \t";
     
    13821844
    13831845  if (TrianglesOnBoundary.erase(triangle->Nr))
    1384     Log() << Verbose(5) << "Removing triangle Nr. " << triangle->Nr << "." << endl;
     1846    Log() << Verbose(0) << "Removing triangle Nr. " << triangle->Nr << "." << endl;
    13851847  delete(triangle);
    13861848};
     
    13921854void Tesselation::RemoveTesselationLine(class BoundaryLineSet *line)
    13931855{
     1856        Info FunctionInfo(__func__);
    13941857  int Numbers[2];
    13951858
     
    14121875        for (LineMap::iterator Runner = erasor.first; Runner != erasor.second; Runner++)
    14131876          if ((*Runner).second == line) {
    1414             Log() << Verbose(5) << "Removing Line Nr. " << line->Nr << " in boundary point " << *line->endpoints[i] << "." << endl;
     1877            Log() << Verbose(0) << "Removing Line Nr. " << line->Nr << " in boundary point " << *line->endpoints[i] << "." << endl;
    14151878            line->endpoints[i]->lines.erase(Runner);
    14161879            break;
     
    14181881      } else { // there's just a single line left
    14191882        if (line->endpoints[i]->lines.erase(line->Nr))
    1420           Log() << Verbose(5) << "Removing Line Nr. " << line->Nr << " in boundary point " << *line->endpoints[i] << "." << endl;
     1883          Log() << Verbose(0) << "Removing Line Nr. " << line->Nr << " in boundary point " << *line->endpoints[i] << "." << endl;
    14211884      }
    14221885      if (line->endpoints[i]->lines.empty()) {
    1423         Log() << Verbose(5) << *line->endpoints[i] << " has no more lines it's attached to, erasing." << endl;
     1886        Log() << Verbose(0) << *line->endpoints[i] << " has no more lines it's attached to, erasing." << endl;
    14241887        RemoveTesselationPoint(line->endpoints[i]);
    14251888      } else {
    1426         Log() << Verbose(5) << *line->endpoints[i] << " has still lines it's attached to: ";
     1889        Log() << Verbose(0) << *line->endpoints[i] << " has still lines it's attached to: ";
    14271890        for(LineMap::iterator LineRunner = line->endpoints[i]->lines.begin(); LineRunner != line->endpoints[i]->lines.end(); LineRunner++)
    14281891          Log() << Verbose(0) << "[" << *(LineRunner->second) << "] \t";
     
    14371900
    14381901  if (LinesOnBoundary.erase(line->Nr))
    1439     Log() << Verbose(5) << "Removing line Nr. " << line->Nr << "." << endl;
     1902    Log() << Verbose(0) << "Removing line Nr. " << line->Nr << "." << endl;
    14401903  delete(line);
    14411904};
     
    14481911void Tesselation::RemoveTesselationPoint(class BoundaryPointSet *point)
    14491912{
     1913        Info FunctionInfo(__func__);
    14501914  if (point == NULL)
    14511915    return;
    14521916  if (PointsOnBoundary.erase(point->Nr))
    1453     Log() << Verbose(5) << "Removing point Nr. " << point->Nr << "." << endl;
     1917    Log() << Verbose(0) << "Removing point Nr. " << point->Nr << "." << endl;
    14541918  delete(point);
    14551919};
     
    14661930int Tesselation::CheckPresenceOfTriangle(TesselPoint *Candidates[3]) const
    14671931{
     1932        Info FunctionInfo(__func__);
    14681933  int adjacentTriangleCount = 0;
    14691934  class BoundaryPointSet *Points[3];
    14701935
    1471   Log() << Verbose(2) << "Begin of CheckPresenceOfTriangle" << endl;
    14721936  // builds a triangle point set (Points) of the end points
    14731937  for (int i = 0; i < 3; i++) {
     
    14881952          for (; (FindLine != Points[i]->lines.end()) && (FindLine->first == Points[j]->node->nr); FindLine++) {
    14891953            TriangleMap *triangles = &FindLine->second->triangles;
    1490             Log() << Verbose(3) << "Current line is " << FindLine->first << ": " << *(FindLine->second) << " with triangles " << triangles << "." << endl;
     1954            Log() << Verbose(1) << "Current line is " << FindLine->first << ": " << *(FindLine->second) << " with triangles " << triangles << "." << endl;
    14911955            for (TriangleMap::const_iterator FindTriangle = triangles->begin(); FindTriangle != triangles->end(); FindTriangle++) {
    14921956              if (FindTriangle->second->IsPresentTupel(Points)) {
     
    14941958              }
    14951959            }
    1496             Log() << Verbose(3) << "end." << endl;
     1960            Log() << Verbose(1) << "end." << endl;
    14971961          }
    14981962          // Only one of the triangle lines must be considered for the triangle count.
    1499           //Log() << Verbose(2) << "Found " << adjacentTriangleCount << " adjacent triangles for the point set." << endl;
     1963          //Log() << Verbose(0) << "Found " << adjacentTriangleCount << " adjacent triangles for the point set." << endl;
    15001964          //return adjacentTriangleCount;
    15011965        }
     
    15041968  }
    15051969
    1506   Log() << Verbose(2) << "Found " << adjacentTriangleCount << " adjacent triangles for the point set." << endl;
    1507   Log() << Verbose(2) << "End of CheckPresenceOfTriangle" << endl;
     1970  Log() << Verbose(0) << "Found " << adjacentTriangleCount << " adjacent triangles for the point set." << endl;
    15081971  return adjacentTriangleCount;
    15091972};
     
    15191982class BoundaryTriangleSet * Tesselation::GetPresentTriangle(TesselPoint *Candidates[3])
    15201983{
     1984        Info FunctionInfo(__func__);
    15211985  class BoundaryTriangleSet *triangle = NULL;
    15221986  class BoundaryPointSet *Points[3];
     
    15482012          }
    15492013          // Only one of the triangle lines must be considered for the triangle count.
    1550           //Log() << Verbose(2) << "Found " << adjacentTriangleCount << " adjacent triangles for the point set." << endl;
     2014          //Log() << Verbose(0) << "Found " << adjacentTriangleCount << " adjacent triangles for the point set." << endl;
    15512015          //return adjacentTriangleCount;
    15522016        }
     
    15692033void Tesselation::FindStartingTriangle(const double RADIUS, const LinkedCell *LC)
    15702034{
    1571   Log() << Verbose(1) << "Begin of FindStartingTriangle\n";
     2035        Info FunctionInfo(__func__);
    15722036  int i = 0;
    1573   TesselPoint* FirstPoint = NULL;
    1574   TesselPoint* SecondPoint = NULL;
    15752037  TesselPoint* MaxPoint[NDIM];
     2038  TesselPoint* Temporary;
    15762039  double maxCoordinate[NDIM];
    1577   Vector Oben;
     2040  BoundaryLineSet BaseLine;
    15782041  Vector helper;
    15792042  Vector Chord;
    15802043  Vector SearchDirection;
    1581 
    1582   Oben.Zero();
     2044  Vector CircleCenter;  // center of the circle, i.e. of the band of sphere's centers
     2045  Vector CirclePlaneNormal; // normal vector defining the plane this circle lives in
     2046  Vector SphereCenter;
     2047  Vector NormalVector;
     2048
     2049  NormalVector.Zero();
    15832050
    15842051  for (i = 0; i < 3; i++) {
     
    15932060      for (LC->n[(i+2)%NDIM]=0;LC->n[(i+2)%NDIM]<LC->N[(i+2)%NDIM];LC->n[(i+2)%NDIM]++) {
    15942061        const LinkedNodes *List = LC->GetCurrentCell();
    1595         //Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;
     2062        //Log() << Verbose(1) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;
    15962063        if (List != NULL) {
    15972064          for (LinkedNodes::const_iterator Runner = List->begin();Runner != List->end();Runner++) {
    15982065            if ((*Runner)->node->x[i] > maxCoordinate[i]) {
    1599               Log() << Verbose(2) << "New maximal for axis " << i << " node is " << *(*Runner) << " at " << *(*Runner)->node << "." << endl;
     2066              Log() << Verbose(1) << "New maximal for axis " << i << " node is " << *(*Runner) << " at " << *(*Runner)->node << "." << endl;
    16002067              maxCoordinate[i] = (*Runner)->node->x[i];
    16012068              MaxPoint[i] = (*Runner);
     
    16082075  }
    16092076
    1610   Log() << Verbose(2) << "Found maximum coordinates: ";
     2077  Log() << Verbose(1) << "Found maximum coordinates: ";
    16112078  for (int i=0;i<NDIM;i++)
    16122079    Log() << Verbose(0) << i << ": " << *MaxPoint[i] << "\t";
     
    16142081
    16152082  BTS = NULL;
    1616   CandidateList *OptCandidates = new CandidateList();
    16172083  for (int k=0;k<NDIM;k++) {
    1618     Oben.Zero();
    1619     Oben.x[k] = 1.;
    1620     FirstPoint = MaxPoint[k];
    1621     Log() << Verbose(1) << "Coordinates of start node at " << *FirstPoint->node << "." << endl;
     2084    NormalVector.Zero();
     2085    NormalVector.x[k] = 1.;
     2086    BaseLine.endpoints[0] = new BoundaryPointSet(MaxPoint[k]);
     2087    Log() << Verbose(0) << "Coordinates of start node at " << *BaseLine.endpoints[0]->node << "." << endl;
    16222088
    16232089    double ShortestAngle;
    1624     TesselPoint* OptCandidate = NULL;
    16252090    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.
    16262091
    1627     FindSecondPointForTesselation(FirstPoint, Oben, OptCandidate, &ShortestAngle, RADIUS, LC); // we give same point as next candidate as its bonds are looked into in find_second_...
    1628     SecondPoint = OptCandidate;
    1629     if (SecondPoint == NULL)  // have we found a second point?
     2092    FindSecondPointForTesselation(BaseLine.endpoints[0]->node, NormalVector, Temporary, &ShortestAngle, RADIUS, LC); // we give same point as next candidate as its bonds are looked into in find_second_...
     2093    if (Temporary == NULL)  // have we found a second point?
    16302094      continue;
    1631 
    1632     helper.CopyVector(FirstPoint->node);
    1633     helper.SubtractVector(SecondPoint->node);
    1634     helper.Normalize();
    1635     Oben.ProjectOntoPlane(&helper);
    1636     Oben.Normalize();
    1637     helper.VectorProduct(&Oben);
     2095    BaseLine.endpoints[1] = new BoundaryPointSet(Temporary);
     2096
     2097    // construct center of circle
     2098    CircleCenter.CopyVector(BaseLine.endpoints[0]->node->node);
     2099    CircleCenter.AddVector(BaseLine.endpoints[1]->node->node);
     2100    CircleCenter.Scale(0.5);
     2101
     2102    // construct normal vector of circle
     2103    CirclePlaneNormal.CopyVector(BaseLine.endpoints[0]->node->node);
     2104    CirclePlaneNormal.SubtractVector(BaseLine.endpoints[1]->node->node);
     2105
     2106    double radius = CirclePlaneNormal.NormSquared();
     2107    double CircleRadius = sqrt(RADIUS*RADIUS - radius/4.);
     2108
     2109    NormalVector.ProjectOntoPlane(&CirclePlaneNormal);
     2110    NormalVector.Normalize();
    16382111    ShortestAngle = 2.*M_PI; // This will indicate the quadrant.
    16392112
    1640     Chord.CopyVector(FirstPoint->node); // bring into calling function
    1641     Chord.SubtractVector(SecondPoint->node);
    1642     double radius = Chord.ScalarProduct(&Chord);
    1643     double CircleRadius = sqrt(RADIUS*RADIUS - radius/4.);
    1644     helper.CopyVector(&Oben);
    1645     helper.Scale(CircleRadius);
    1646     // Now, oben and helper are two orthonormalized vectors in the plane defined by Chord (not normalized)
     2113    SphereCenter.CopyVector(&NormalVector);
     2114    SphereCenter.Scale(CircleRadius);
     2115    SphereCenter.AddVector(&CircleCenter);
     2116    // Now, NormalVector and SphereCenter are two orthonormalized vectors in the plane defined by CirclePlaneNormal (not normalized)
    16472117
    16482118    // look in one direction of baseline for initial candidate
    1649     SearchDirection.MakeNormalVector(&Chord, &Oben);  // whether we look "left" first or "right" first is not important ...
     2119    SearchDirection.MakeNormalVector(&CirclePlaneNormal, &NormalVector);  // whether we look "left" first or "right" first is not important ...
    16502120
    16512121    // adding point 1 and point 2 and add the line between them
    1652     Log() << Verbose(1) << "Coordinates of start node at " << *FirstPoint->node << "." << endl;
    1653     AddTesselationPoint(FirstPoint, 0);
    1654     Log() << Verbose(1) << "Found second point is at " << *SecondPoint->node << ".\n";
    1655     AddTesselationPoint(SecondPoint, 1);
    1656     AddTesselationLine(TPS[0], TPS[1], 0);
    1657 
    1658     //Log() << Verbose(2) << "INFO: OldSphereCenter is at " << helper << ".\n";
    1659     FindThirdPointForTesselation(Oben, SearchDirection, helper, BLS[0], NULL, *&OptCandidates, &ShortestAngle, RADIUS, LC);
    1660     Log() << Verbose(1) << "List of third Points is ";
    1661     for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) {
    1662         Log() << Verbose(0) << " " << *(*it)->point;
    1663     }
    1664     Log() << Verbose(0) << endl;
    1665 
    1666     for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) {
    1667       // add third triangle point
    1668       AddTesselationPoint((*it)->point, 2);
    1669       // add the second and third line
    1670       AddTesselationLine(TPS[1], TPS[2], 1);
    1671       AddTesselationLine(TPS[0], TPS[2], 2);
    1672       // ... and triangles to the Maps of the Tesselation class
    1673       BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
    1674       AddTesselationTriangle();
    1675       // ... and calculate its normal vector (with correct orientation)
    1676       (*it)->OptCenter.Scale(-1.);
    1677       Log() << Verbose(2) << "Anti-Oben is currently " << (*it)->OptCenter << "." << endl;
    1678       BTS->GetNormalVector((*it)->OptCenter);  // vector to compare with should point inwards
    1679       Log() << Verbose(0) << "==> Found starting triangle consists of " << *FirstPoint << ", " << *SecondPoint << " and "
    1680       << *(*it)->point << " with normal vector " << BTS->NormalVector << ".\n";
    1681 
    1682       // if we do not reach the end with the next step of iteration, we need to setup a new first line
    1683       if (it != OptCandidates->end()--) {
    1684         FirstPoint = (*it)->BaseLine->endpoints[0]->node;
    1685         SecondPoint = (*it)->point;
    1686         // adding point 1 and point 2 and the line between them
    1687         AddTesselationPoint(FirstPoint, 0);
    1688         AddTesselationPoint(SecondPoint, 1);
    1689         AddTesselationLine(TPS[0], TPS[1], 0);
    1690       }
    1691       Log() << Verbose(2) << "Projection is " << BTS->NormalVector.ScalarProduct(&Oben) << "." << endl;
    1692     }
     2122    Log() << Verbose(0) << "Coordinates of start node at " << *BaseLine.endpoints[0]->node << "." << endl;
     2123    Log() << Verbose(0) << "Found second point is at " << *BaseLine.endpoints[1]->node << ".\n";
     2124
     2125    //Log() << Verbose(1) << "INFO: OldSphereCenter is at " << helper << ".\n";
     2126    CandidateForTesselation OptCandidates(&BaseLine);
     2127    FindThirdPointForTesselation(NormalVector, SearchDirection, SphereCenter, OptCandidates, NULL, RADIUS, LC);
     2128    Log() << Verbose(0) << "List of third Points is:" << endl;
     2129    for (TesselPointList::iterator it = OptCandidates.pointlist.begin(); it != OptCandidates.pointlist.end(); it++) {
     2130        Log() << Verbose(0) << " " << *(*it) << endl;
     2131    }
     2132
     2133    BTS = NULL;
     2134    AddCandidateTriangle(OptCandidates);
     2135//    delete(BaseLine.endpoints[0]);
     2136//    delete(BaseLine.endpoints[1]);
     2137
    16932138    if (BTS != NULL) // we have created one starting triangle
    16942139      break;
    16952140    else {
    16962141      // remove all candidates from the list and then the list itself
    1697       class CandidateForTesselation *remover = NULL;
    1698       for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) {
    1699         remover = *it;
    1700         delete(remover);
    1701       }
    1702       OptCandidates->clear();
    1703     }
    1704   }
    1705 
    1706   // remove all candidates from the list and then the list itself
    1707   class CandidateForTesselation *remover = NULL;
    1708   for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) {
    1709     remover = *it;
    1710     delete(remover);
    1711   }
    1712   delete(OptCandidates);
    1713   Log() << Verbose(1) << "End of FindStartingTriangle\n";
     2142      OptCandidates.pointlist.clear();
     2143    }
     2144  }
    17142145};
    17152146
    17162147/** Checks for a given baseline and a third point candidate whether baselines of the found triangle don't have even better candidates.
    17172148 * This is supposed to prevent early closing of the tesselation.
    1718  * \param *BaseRay baseline, i.e. not \a *OptCandidate
     2149 * \param CandidateLine CandidateForTesselation with baseline and shortestangle , i.e. not \a *OptCandidate
    17192150 * \param *ThirdNode third point in triangle, not in BoundaryLineSet::endpoints
    1720  * \param ShortestAngle path length on this circle band for the current \a *ThirdNode
    17212151 * \param RADIUS radius of sphere
    17222152 * \param *LC LinkedCell structure
    17232153 * \return true - there is a better candidate (smaller angle than \a ShortestAngle), false - no better TesselPoint candidate found
    17242154 */
    1725 bool Tesselation::HasOtherBaselineBetterCandidate(const BoundaryLineSet * const BaseRay, const TesselPoint * const ThirdNode, double ShortestAngle, double RADIUS, const LinkedCell * const LC) const
    1726 {
    1727   bool result = false;
    1728   Vector CircleCenter;
    1729   Vector CirclePlaneNormal;
    1730   Vector OldSphereCenter;
    1731   Vector SearchDirection;
    1732   Vector helper;
    1733   TesselPoint *OtherOptCandidate = NULL;
    1734   double OtherShortestAngle = 2.*M_PI; // This will indicate the quadrant.
    1735   double radius, CircleRadius;
    1736   BoundaryLineSet *Line = NULL;
    1737   BoundaryTriangleSet *T = NULL;
    1738 
    1739   Log() << Verbose(1) << "Begin of HasOtherBaselineBetterCandidate" << endl;
    1740 
    1741   // check both other lines
    1742   PointMap::const_iterator FindPoint = PointsOnBoundary.find(ThirdNode->nr);
    1743   if (FindPoint != PointsOnBoundary.end()) {
    1744     for (int i=0;i<2;i++) {
    1745       LineMap::const_iterator FindLine = (FindPoint->second)->lines.find(BaseRay->endpoints[0]->node->nr);
    1746       if (FindLine != (FindPoint->second)->lines.end()) {
    1747         Line = FindLine->second;
    1748         Log() << Verbose(1) << "Found line " << *Line << "." << endl;
    1749         if (Line->triangles.size() == 1) {
    1750           T = Line->triangles.begin()->second;
    1751           // construct center of circle
    1752           CircleCenter.CopyVector(Line->endpoints[0]->node->node);
    1753           CircleCenter.AddVector(Line->endpoints[1]->node->node);
    1754           CircleCenter.Scale(0.5);
    1755 
    1756           // construct normal vector of circle
    1757           CirclePlaneNormal.CopyVector(Line->endpoints[0]->node->node);
    1758           CirclePlaneNormal.SubtractVector(Line->endpoints[1]->node->node);
    1759 
    1760           // calculate squared radius of circle
    1761           radius = CirclePlaneNormal.ScalarProduct(&CirclePlaneNormal);
    1762           if (radius/4. < RADIUS*RADIUS) {
    1763             CircleRadius = RADIUS*RADIUS - radius/4.;
    1764             CirclePlaneNormal.Normalize();
    1765             //Log() << Verbose(2) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl;
    1766 
    1767             // construct old center
    1768             GetCenterofCircumcircle(&OldSphereCenter, *T->endpoints[0]->node->node, *T->endpoints[1]->node->node, *T->endpoints[2]->node->node);
    1769             helper.CopyVector(&T->NormalVector);  // normal vector ensures that this is correct center of the two possible ones
    1770             radius = Line->endpoints[0]->node->node->DistanceSquared(&OldSphereCenter);
    1771             helper.Scale(sqrt(RADIUS*RADIUS - radius));
    1772             OldSphereCenter.AddVector(&helper);
    1773             OldSphereCenter.SubtractVector(&CircleCenter);
    1774             //Log() << Verbose(2) << "INFO: OldSphereCenter is at " << OldSphereCenter << "." << endl;
    1775 
    1776             // construct SearchDirection
    1777             SearchDirection.MakeNormalVector(&T->NormalVector, &CirclePlaneNormal);
    1778             helper.CopyVector(Line->endpoints[0]->node->node);
    1779             helper.SubtractVector(ThirdNode->node);
    1780             if (helper.ScalarProduct(&SearchDirection) < -HULLEPSILON)// ohoh, SearchDirection points inwards!
    1781               SearchDirection.Scale(-1.);
    1782             SearchDirection.ProjectOntoPlane(&OldSphereCenter);
    1783             SearchDirection.Normalize();
    1784             Log() << Verbose(2) << "INFO: SearchDirection is " << SearchDirection << "." << endl;
    1785             if (fabs(OldSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) {
    1786               // rotated the wrong way!
    1787               eLog() << Verbose(1) << "SearchDirection and RelativeOldSphereCenter are still not orthogonal!" << endl;
    1788             }
    1789 
    1790             // add third point
    1791             CandidateList *OptCandidates = new CandidateList();
    1792             FindThirdPointForTesselation(T->NormalVector, SearchDirection, OldSphereCenter, Line, ThirdNode, OptCandidates, &OtherShortestAngle, RADIUS, LC);
    1793             for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) {
    1794               if (((*it)->point == BaseRay->endpoints[0]->node) || ((*it)->point == BaseRay->endpoints[1]->node)) // skip if it's the same triangle than suggested
    1795                 continue;
    1796               Log() << Verbose(1) << " Third point candidate is " << *(*it)->point
    1797               << " with circumsphere's center at " << (*it)->OptCenter << "." << endl;
    1798               Log() << Verbose(1) << " Baseline is " << *BaseRay << endl;
    1799 
    1800               // check whether all edges of the new triangle still have space for one more triangle (i.e. TriangleCount <2)
    1801               TesselPoint *PointCandidates[3];
    1802               PointCandidates[0] = (*it)->point;
    1803               PointCandidates[1] = BaseRay->endpoints[0]->node;
    1804               PointCandidates[2] = BaseRay->endpoints[1]->node;
    1805               bool check=false;
    1806               int existentTrianglesCount = CheckPresenceOfTriangle(PointCandidates);
    1807               // If there is no triangle, add it regularly.
    1808               if (existentTrianglesCount == 0) {
    1809                 SetTesselationPoint((*it)->point, 0);
    1810                 SetTesselationPoint(BaseRay->endpoints[0]->node, 1);
    1811                 SetTesselationPoint(BaseRay->endpoints[1]->node, 2);
    1812 
    1813                 if (CheckLineCriteriaForDegeneratedTriangle((const BoundaryPointSet ** const )TPS)) {
    1814                   OtherOptCandidate = (*it)->point;
    1815                   check = true;
    1816                 }
    1817               } else if ((existentTrianglesCount >= 1) && (existentTrianglesCount <= 3)) { // If there is a planar region within the structure, we need this triangle a second time.
    1818                 SetTesselationPoint((*it)->point, 0);
    1819                 SetTesselationPoint(BaseRay->endpoints[0]->node, 1);
    1820                 SetTesselationPoint(BaseRay->endpoints[1]->node, 2);
    1821 
    1822                 // 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)
    1823                 // i.e. at least one of the three lines must be present with TriangleCount <= 1
    1824                 if (CheckLineCriteriaForDegeneratedTriangle((const BoundaryPointSet ** const)TPS)) {
    1825                   OtherOptCandidate = (*it)->point;
    1826                   check = true;
    1827                 }
    1828               }
    1829 
    1830               if (check) {
    1831                 if (ShortestAngle > OtherShortestAngle) {
    1832                   Log() << Verbose(1) << "There is a better candidate than " << *ThirdNode << " with " << ShortestAngle << " from baseline " << *Line << ": " << *OtherOptCandidate << " with " << OtherShortestAngle << "." << endl;
    1833                   result = true;
    1834                   break;
    1835                 }
    1836               }
    1837             }
    1838             delete(OptCandidates);
    1839             if (result)
    1840               break;
    1841           } else {
    1842             Log() << Verbose(1) << "Circumcircle for base line " << *Line << " and base triangle " << T << " is too big!" << endl;
    1843           }
    1844         } else {
    1845           eLog() << Verbose(2) << "Baseline is connected to two triangles already?" << endl;
    1846         }
    1847       } else {
    1848         Log() << Verbose(2) << "No present baseline between " << BaseRay->endpoints[0] << " and candidate " << *ThirdNode << "." << endl;
    1849       }
    1850     }
    1851   } else {
    1852     eLog() << Verbose(1) << "Could not find the TesselPoint " << *ThirdNode << "." << endl;
    1853   }
    1854 
    1855   Log() << Verbose(1) << "End of HasOtherBaselineBetterCandidate" << endl;
    1856 
    1857   return result;
    1858 };
     2155//bool Tesselation::HasOtherBaselineBetterCandidate(CandidateForTesselation &CandidateLine, const TesselPoint * const ThirdNode, double RADIUS, const LinkedCell * const LC) const
     2156//{
     2157//      Info FunctionInfo(__func__);
     2158//  bool result = false;
     2159//  Vector CircleCenter;
     2160//  Vector CirclePlaneNormal;
     2161//  Vector OldSphereCenter;
     2162//  Vector SearchDirection;
     2163//  Vector helper;
     2164//  TesselPoint *OtherOptCandidate = NULL;
     2165//  double OtherShortestAngle = 2.*M_PI; // This will indicate the quadrant.
     2166//  double radius, CircleRadius;
     2167//  BoundaryLineSet *Line = NULL;
     2168//  BoundaryTriangleSet *T = NULL;
     2169//
     2170//  // check both other lines
     2171//  PointMap::const_iterator FindPoint = PointsOnBoundary.find(ThirdNode->nr);
     2172//  if (FindPoint != PointsOnBoundary.end()) {
     2173//    for (int i=0;i<2;i++) {
     2174//      LineMap::const_iterator FindLine = (FindPoint->second)->lines.find(BaseRay->endpoints[0]->node->nr);
     2175//      if (FindLine != (FindPoint->second)->lines.end()) {
     2176//        Line = FindLine->second;
     2177//        Log() << Verbose(0) << "Found line " << *Line << "." << endl;
     2178//        if (Line->triangles.size() == 1) {
     2179//          T = Line->triangles.begin()->second;
     2180//          // construct center of circle
     2181//          CircleCenter.CopyVector(Line->endpoints[0]->node->node);
     2182//          CircleCenter.AddVector(Line->endpoints[1]->node->node);
     2183//          CircleCenter.Scale(0.5);
     2184//
     2185//          // construct normal vector of circle
     2186//          CirclePlaneNormal.CopyVector(Line->endpoints[0]->node->node);
     2187//          CirclePlaneNormal.SubtractVector(Line->endpoints[1]->node->node);
     2188//
     2189//          // calculate squared radius of circle
     2190//          radius = CirclePlaneNormal.ScalarProduct(&CirclePlaneNormal);
     2191//          if (radius/4. < RADIUS*RADIUS) {
     2192//            CircleRadius = RADIUS*RADIUS - radius/4.;
     2193//            CirclePlaneNormal.Normalize();
     2194//            //Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl;
     2195//
     2196//            // construct old center
     2197//            GetCenterofCircumcircle(&OldSphereCenter, *T->endpoints[0]->node->node, *T->endpoints[1]->node->node, *T->endpoints[2]->node->node);
     2198//            helper.CopyVector(&T->NormalVector);  // normal vector ensures that this is correct center of the two possible ones
     2199//            radius = Line->endpoints[0]->node->node->DistanceSquared(&OldSphereCenter);
     2200//            helper.Scale(sqrt(RADIUS*RADIUS - radius));
     2201//            OldSphereCenter.AddVector(&helper);
     2202//            OldSphereCenter.SubtractVector(&CircleCenter);
     2203//            //Log() << Verbose(1) << "INFO: OldSphereCenter is at " << OldSphereCenter << "." << endl;
     2204//
     2205//            // construct SearchDirection
     2206//            SearchDirection.MakeNormalVector(&T->NormalVector, &CirclePlaneNormal);
     2207//            helper.CopyVector(Line->endpoints[0]->node->node);
     2208//            helper.SubtractVector(ThirdNode->node);
     2209//            if (helper.ScalarProduct(&SearchDirection) < -HULLEPSILON)// ohoh, SearchDirection points inwards!
     2210//              SearchDirection.Scale(-1.);
     2211//            SearchDirection.ProjectOntoPlane(&OldSphereCenter);
     2212//            SearchDirection.Normalize();
     2213//            Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl;
     2214//            if (fabs(OldSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) {
     2215//              // rotated the wrong way!
     2216//              eLog() << Verbose(1) << "SearchDirection and RelativeOldSphereCenter are still not orthogonal!" << endl;
     2217//            }
     2218//
     2219//            // add third point
     2220//            FindThirdPointForTesselation(T->NormalVector, SearchDirection, OldSphereCenter, OptCandidates, ThirdNode, RADIUS, LC);
     2221//            for (TesselPointList::iterator it = OptCandidates.pointlist.begin(); it != OptCandidates.pointlist.end(); ++it) {
     2222//              if (((*it) == BaseRay->endpoints[0]->node) || ((*it) == BaseRay->endpoints[1]->node)) // skip if it's the same triangle than suggested
     2223//                continue;
     2224//              Log() << Verbose(0) << " Third point candidate is " << (*it)
     2225//              << " with circumsphere's center at " << (*it)->OptCenter << "." << endl;
     2226//              Log() << Verbose(0) << " Baseline is " << *BaseRay << endl;
     2227//
     2228//              // check whether all edges of the new triangle still have space for one more triangle (i.e. TriangleCount <2)
     2229//              TesselPoint *PointCandidates[3];
     2230//              PointCandidates[0] = (*it);
     2231//              PointCandidates[1] = BaseRay->endpoints[0]->node;
     2232//              PointCandidates[2] = BaseRay->endpoints[1]->node;
     2233//              bool check=false;
     2234//              int existentTrianglesCount = CheckPresenceOfTriangle(PointCandidates);
     2235//              // If there is no triangle, add it regularly.
     2236//              if (existentTrianglesCount == 0) {
     2237//                SetTesselationPoint((*it), 0);
     2238//                SetTesselationPoint(BaseRay->endpoints[0]->node, 1);
     2239//                SetTesselationPoint(BaseRay->endpoints[1]->node, 2);
     2240//
     2241//                if (CheckLineCriteriaForDegeneratedTriangle((const BoundaryPointSet ** const )TPS)) {
     2242//                  OtherOptCandidate = (*it);
     2243//                  check = true;
     2244//                }
     2245//              } else if ((existentTrianglesCount >= 1) && (existentTrianglesCount <= 3)) { // If there is a planar region within the structure, we need this triangle a second time.
     2246//                SetTesselationPoint((*it), 0);
     2247//                SetTesselationPoint(BaseRay->endpoints[0]->node, 1);
     2248//                SetTesselationPoint(BaseRay->endpoints[1]->node, 2);
     2249//
     2250//                // 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)
     2251//                // i.e. at least one of the three lines must be present with TriangleCount <= 1
     2252//                if (CheckLineCriteriaForDegeneratedTriangle((const BoundaryPointSet ** const)TPS)) {
     2253//                  OtherOptCandidate = (*it);
     2254//                  check = true;
     2255//                }
     2256//              }
     2257//
     2258//              if (check) {
     2259//                if (ShortestAngle > OtherShortestAngle) {
     2260//                  Log() << Verbose(0) << "There is a better candidate than " << *ThirdNode << " with " << ShortestAngle << " from baseline " << *Line << ": " << *OtherOptCandidate << " with " << OtherShortestAngle << "." << endl;
     2261//                  result = true;
     2262//                  break;
     2263//                }
     2264//              }
     2265//            }
     2266//            delete(OptCandidates);
     2267//            if (result)
     2268//              break;
     2269//          } else {
     2270//            Log() << Verbose(0) << "Circumcircle for base line " << *Line << " and base triangle " << T << " is too big!" << endl;
     2271//          }
     2272//        } else {
     2273//          eLog() << Verbose(2) << "Baseline is connected to two triangles already?" << endl;
     2274//        }
     2275//      } else {
     2276//        Log() << Verbose(1) << "No present baseline between " << BaseRay->endpoints[0] << " and candidate " << *ThirdNode << "." << endl;
     2277//      }
     2278//    }
     2279//  } else {
     2280//    eLog() << Verbose(1) << "Could not find the TesselPoint " << *ThirdNode << "." << endl;
     2281//  }
     2282//
     2283//  return result;
     2284//};
    18592285
    18602286/** This function finds a triangle to a line, adjacent to an existing one.
    18612287 * @param out output stream for debugging
    1862  * @param Line current baseline to search from
     2288 * @param CandidateLine current cadndiate baseline to search from
    18632289 * @param T current triangle which \a Line is edge of
    18642290 * @param RADIUS radius of the rolling ball
     
    18662292 * @param *LC LinkedCell structure with neighbouring points
    18672293 */
    1868 bool Tesselation::FindNextSuitableTriangle(BoundaryLineSet &Line, BoundaryTriangleSet &T, const double& RADIUS, const LinkedCell *LC)
    1869 {
    1870   Log() << Verbose(0) << "Begin of FindNextSuitableTriangle\n";
     2294bool Tesselation::FindNextSuitableTriangle(CandidateForTesselation &CandidateLine, BoundaryTriangleSet &T, const double& RADIUS, const LinkedCell *LC)
     2295{
     2296        Info FunctionInfo(__func__);
    18712297  bool result = true;
    1872   CandidateList *OptCandidates = new CandidateList();
    18732298
    18742299  Vector CircleCenter;
    18752300  Vector CirclePlaneNormal;
    1876   Vector OldSphereCenter;
     2301  Vector RelativeSphereCenter;
    18772302  Vector SearchDirection;
    18782303  Vector helper;
    18792304  TesselPoint *ThirdNode = NULL;
    18802305  LineMap::iterator testline;
    1881   double ShortestAngle = 2.*M_PI; // This will indicate the quadrant.
    18822306  double radius, CircleRadius;
    18832307
    1884   Log() << Verbose(1) << "Current baseline is " << Line << " of triangle " << T << "." << endl;
    18852308  for (int i=0;i<3;i++)
    1886     if ((T.endpoints[i]->node != Line.endpoints[0]->node) && (T.endpoints[i]->node != Line.endpoints[1]->node))
     2309    if ((T.endpoints[i]->node != CandidateLine.BaseLine->endpoints[0]->node) && (T.endpoints[i]->node != CandidateLine.BaseLine->endpoints[1]->node)) {
    18872310      ThirdNode = T.endpoints[i]->node;
     2311      break;
     2312    }
     2313  Log() << Verbose(0) << "Current baseline is " << *CandidateLine.BaseLine << " with ThirdNode " << *ThirdNode << " of triangle " << T << "." << endl;
    18882314
    18892315  // construct center of circle
    1890   CircleCenter.CopyVector(Line.endpoints[0]->node->node);
    1891   CircleCenter.AddVector(Line.endpoints[1]->node->node);
     2316  CircleCenter.CopyVector(CandidateLine.BaseLine->endpoints[0]->node->node);
     2317  CircleCenter.AddVector(CandidateLine.BaseLine->endpoints[1]->node->node);
    18922318  CircleCenter.Scale(0.5);
    18932319
    18942320  // construct normal vector of circle
    1895   CirclePlaneNormal.CopyVector(Line.endpoints[0]->node->node);
    1896   CirclePlaneNormal.SubtractVector(Line.endpoints[1]->node->node);
     2321  CirclePlaneNormal.CopyVector(CandidateLine.BaseLine->endpoints[0]->node->node);
     2322  CirclePlaneNormal.SubtractVector(CandidateLine.BaseLine->endpoints[1]->node->node);
    18972323
    18982324  // calculate squared radius of circle
    18992325  radius = CirclePlaneNormal.ScalarProduct(&CirclePlaneNormal);
    19002326  if (radius/4. < RADIUS*RADIUS) {
     2327    // construct relative sphere center with now known CircleCenter
     2328    RelativeSphereCenter.CopyVector(&T.SphereCenter);
     2329    RelativeSphereCenter.SubtractVector(&CircleCenter);
     2330
    19012331    CircleRadius = RADIUS*RADIUS - radius/4.;
    19022332    CirclePlaneNormal.Normalize();
    1903     //Log() << Verbose(2) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl;
    1904 
    1905     // construct old center
    1906     GetCenterofCircumcircle(&OldSphereCenter, *T.endpoints[0]->node->node, *T.endpoints[1]->node->node, *T.endpoints[2]->node->node);
    1907     helper.CopyVector(&T.NormalVector);  // normal vector ensures that this is correct center of the two possible ones
    1908     radius = Line.endpoints[0]->node->node->DistanceSquared(&OldSphereCenter);
    1909     helper.Scale(sqrt(RADIUS*RADIUS - radius));
    1910     OldSphereCenter.AddVector(&helper);
    1911     OldSphereCenter.SubtractVector(&CircleCenter);
    1912     //Log() << Verbose(2) << "INFO: OldSphereCenter is at " << OldSphereCenter << "." << endl;
    1913 
    1914     // construct SearchDirection
    1915     SearchDirection.MakeNormalVector(&T.NormalVector, &CirclePlaneNormal);
    1916     helper.CopyVector(Line.endpoints[0]->node->node);
     2333    Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl;
     2334
     2335    Log() << Verbose(1) << "INFO: OldSphereCenter is at " << T.SphereCenter << "." << endl;
     2336
     2337    // construct SearchDirection and an "outward pointer"
     2338    SearchDirection.MakeNormalVector(&RelativeSphereCenter, &CirclePlaneNormal);
     2339    helper.CopyVector(&CircleCenter);
    19172340    helper.SubtractVector(ThirdNode->node);
    19182341    if (helper.ScalarProduct(&SearchDirection) < -HULLEPSILON)// ohoh, SearchDirection points inwards!
    19192342      SearchDirection.Scale(-1.);
    1920     SearchDirection.ProjectOntoPlane(&OldSphereCenter);
    1921     SearchDirection.Normalize();
    1922     Log() << Verbose(2) << "INFO: SearchDirection is " << SearchDirection << "." << endl;
    1923     if (fabs(OldSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) {
     2343    Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl;
     2344    if (fabs(RelativeSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) {
    19242345      // rotated the wrong way!
    19252346      eLog() << Verbose(1) << "SearchDirection and RelativeOldSphereCenter are still not orthogonal!" << endl;
     
    19272348
    19282349    // add third point
    1929     FindThirdPointForTesselation(T.NormalVector, SearchDirection, OldSphereCenter, &Line, ThirdNode, OptCandidates, &ShortestAngle, RADIUS, LC);
     2350    FindThirdPointForTesselation(T.NormalVector, SearchDirection, T.SphereCenter, CandidateLine, ThirdNode, RADIUS, LC);
    19302351
    19312352  } else {
    1932     Log() << Verbose(1) << "Circumcircle for base line " << Line << " and base triangle " << T << " is too big!" << endl;
    1933   }
    1934 
    1935   if (OptCandidates->begin() == OptCandidates->end()) {
     2353    Log() << Verbose(0) << "Circumcircle for base line " << *CandidateLine.BaseLine << " and base triangle " << T << " is too big!" << endl;
     2354  }
     2355
     2356  if (CandidateLine.pointlist.empty()) {
    19362357    eLog() << Verbose(2) << "Could not find a suitable candidate." << endl;
    19372358    return false;
    19382359  }
    1939   Log() << Verbose(1) << "Third Points are ";
    1940   for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) {
    1941     Log() << Verbose(1) << " " << *(*it)->point << endl;
    1942   }
    1943 
    1944   BoundaryLineSet *BaseRay = &Line;
    1945   for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) {
    1946     Log() << Verbose(1) << " Third point candidate is " << *(*it)->point
    1947     << " with circumsphere's center at " << (*it)->OptCenter << "." << endl;
    1948     Log() << Verbose(1) << " Baseline is " << *BaseRay << endl;
    1949 
    1950     // check whether all edges of the new triangle still have space for one more triangle (i.e. TriangleCount <2)
    1951     TesselPoint *PointCandidates[3];
    1952     PointCandidates[0] = (*it)->point;
    1953     PointCandidates[1] = BaseRay->endpoints[0]->node;
    1954     PointCandidates[2] = BaseRay->endpoints[1]->node;
    1955     int existentTrianglesCount = CheckPresenceOfTriangle(PointCandidates);
    1956 
    1957     BTS = NULL;
    1958     // check for present edges and whether we reach better candidates from them
    1959     if (HasOtherBaselineBetterCandidate(BaseRay, (*it)->point, ShortestAngle, RADIUS, LC) ) {
    1960       result = false;
    1961       break;
    1962     } else {
    1963       // If there is no triangle, add it regularly.
    1964       if (existentTrianglesCount == 0) {
    1965         AddTesselationPoint((*it)->point, 0);
    1966         AddTesselationPoint(BaseRay->endpoints[0]->node, 1);
    1967         AddTesselationPoint(BaseRay->endpoints[1]->node, 2);
    1968 
    1969         if (CheckLineCriteriaForDegeneratedTriangle((const BoundaryPointSet ** const )TPS)) {
    1970           AddTesselationLine(TPS[0], TPS[1], 0);
    1971           AddTesselationLine(TPS[0], TPS[2], 1);
    1972           AddTesselationLine(TPS[1], TPS[2], 2);
    1973 
    1974           BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
    1975           AddTesselationTriangle();
    1976           (*it)->OptCenter.Scale(-1.);
    1977           BTS->GetNormalVector((*it)->OptCenter);
    1978           (*it)->OptCenter.Scale(-1.);
    1979 
    1980           Log() << Verbose(0) << "--> New triangle with " << *BTS << " and normal vector " << BTS->NormalVector
    1981             << " for this triangle ... " << endl;
    1982         //Log() << Verbose(1) << "We have "<< TrianglesOnBoundaryCount << " for line " << *BaseRay << "." << endl;
    1983         } else {
    1984           eLog() << Verbose(2) << "This triangle consisting of ";
    1985           Log() << Verbose(0) << *(*it)->point << ", ";
    1986           Log() << Verbose(0) << *BaseRay->endpoints[0]->node << " and ";
    1987           Log() << Verbose(0) << *BaseRay->endpoints[1]->node << " ";
    1988           Log() << Verbose(0) << "exists and is not added, as it does not seem helpful!" << endl;
    1989           result = false;
    1990         }
    1991       } else if ((existentTrianglesCount >= 1) && (existentTrianglesCount <= 3)) { // If there is a planar region within the structure, we need this triangle a second time.
    1992           AddTesselationPoint((*it)->point, 0);
    1993           AddTesselationPoint(BaseRay->endpoints[0]->node, 1);
    1994           AddTesselationPoint(BaseRay->endpoints[1]->node, 2);
    1995 
    1996           // 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)
    1997           // i.e. at least one of the three lines must be present with TriangleCount <= 1
    1998           if (CheckLineCriteriaForDegeneratedTriangle((const BoundaryPointSet ** const)TPS)) {
    1999             AddTesselationLine(TPS[0], TPS[1], 0);
    2000             AddTesselationLine(TPS[0], TPS[2], 1);
    2001             AddTesselationLine(TPS[1], TPS[2], 2);
    2002 
    2003             BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
    2004             AddTesselationTriangle();  // add to global map
    2005 
    2006             (*it)->OtherOptCenter.Scale(-1.);
    2007             BTS->GetNormalVector((*it)->OtherOptCenter);
    2008             (*it)->OtherOptCenter.Scale(-1.);
    2009 
    2010             eLog() << Verbose(2) << "--> WARNING: Special new triangle with " << *BTS << " and normal vector " << BTS->NormalVector << " for this triangle ... " << endl;
    2011             Log() << Verbose(1) << "We have "<< BaseRay->triangles.size() << " for line " << BaseRay << "." << endl;
    2012           } else {
    2013             eLog() << Verbose(2) << "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;
    2014             result = false;
    2015           }
    2016       } else {
    2017         Log() << Verbose(1) << "This triangle consisting of ";
    2018         Log() << Verbose(0) << *(*it)->point << ", ";
    2019         Log() << Verbose(0) << *BaseRay->endpoints[0]->node << " and ";
    2020         Log() << Verbose(0) << *BaseRay->endpoints[1]->node << " ";
    2021         Log() << Verbose(0) << "is invalid!" << endl;
    2022         result = false;
    2023       }
    2024     }
    2025 
    2026     // set baseline to new ray from ref point (here endpoints[0]->node) to current candidate (here (*it)->point))
    2027     BaseRay = BLS[0];
    2028     if ((BTS != NULL) && (BTS->NormalVector.NormSquared() < MYEPSILON)) {
    2029       eLog() << Verbose(1) << "Triangle " << *BTS << " has zero normal vector!" << endl;
    2030       exit(255);
    2031     }
    2032 
    2033   }
    2034 
    2035   // remove all candidates from the list and then the list itself
    2036   class CandidateForTesselation *remover = NULL;
    2037   for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) {
    2038     remover = *it;
    2039     delete(remover);
    2040   }
    2041   delete(OptCandidates);
    2042   Log() << Verbose(0) << "End of FindNextSuitableTriangle\n";
     2360  Log() << Verbose(0) << "Third Points are: " << endl;
     2361  for (TesselPointList::iterator it = CandidateLine.pointlist.begin(); it != CandidateLine.pointlist.end(); ++it) {
     2362    Log() << Verbose(0) << " " << *(*it) << endl;
     2363  }
     2364
     2365  return true;
     2366
     2367//  BoundaryLineSet *BaseRay = CandidateLine.BaseLine;
     2368//  for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) {
     2369//    Log() << Verbose(0) << "Third point candidate is " << *(*it)->point
     2370//    << " with circumsphere's center at " << (*it)->OptCenter << "." << endl;
     2371//    Log() << Verbose(0) << "Baseline is " << *BaseRay << endl;
     2372//
     2373//    // check whether all edges of the new triangle still have space for one more triangle (i.e. TriangleCount <2)
     2374//    TesselPoint *PointCandidates[3];
     2375//    PointCandidates[0] = (*it)->point;
     2376//    PointCandidates[1] = BaseRay->endpoints[0]->node;
     2377//    PointCandidates[2] = BaseRay->endpoints[1]->node;
     2378//    int existentTrianglesCount = CheckPresenceOfTriangle(PointCandidates);
     2379//
     2380//    BTS = NULL;
     2381//    // check for present edges and whether we reach better candidates from them
     2382//    //if (HasOtherBaselineBetterCandidate(BaseRay, (*it)->point, ShortestAngle, RADIUS, LC) ) {
     2383//    if (0) {
     2384//      result = false;
     2385//      break;
     2386//    } else {
     2387//      // If there is no triangle, add it regularly.
     2388//      if (existentTrianglesCount == 0) {
     2389//        AddTesselationPoint((*it)->point, 0);
     2390//        AddTesselationPoint(BaseRay->endpoints[0]->node, 1);
     2391//        AddTesselationPoint(BaseRay->endpoints[1]->node, 2);
     2392//
     2393//        if (CheckLineCriteriaForDegeneratedTriangle((const BoundaryPointSet ** const )TPS)) {
     2394//          CandidateLine.point = (*it)->point;
     2395//          CandidateLine.OptCenter.CopyVector(&((*it)->OptCenter));
     2396//          CandidateLine.OtherOptCenter.CopyVector(&((*it)->OtherOptCenter));
     2397//          CandidateLine.ShortestAngle = ShortestAngle;
     2398//        } else {
     2399////          eLog() << Verbose(1) << "This triangle consisting of ";
     2400////          Log() << Verbose(0) << *(*it)->point << ", ";
     2401////          Log() << Verbose(0) << *BaseRay->endpoints[0]->node << " and ";
     2402////          Log() << Verbose(0) << *BaseRay->endpoints[1]->node << " ";
     2403////          Log() << Verbose(0) << "exists and is not added, as it 0x80000000006fc150(does not seem helpful!" << endl;
     2404//          result = false;
     2405//        }
     2406//      } else if ((existentTrianglesCount >= 1) && (existentTrianglesCount <= 3)) { // If there is a planar region within the structure, we need this triangle a second time.
     2407//          AddTesselationPoint((*it)->point, 0);
     2408//          AddTesselationPoint(BaseRay->endpoints[0]->node, 1);
     2409//          AddTesselationPoint(BaseRay->endpoints[1]->node, 2);
     2410//
     2411//          // We demand that at most one new degenerate line is created and that this line also already exists (which has to be the case due to existentTrianglesCount == 1)
     2412//          // i.e. at least one of the three lines must be present with TriangleCount <= 1
     2413//          if (CheckLineCriteriaForDegeneratedTriangle((const BoundaryPointSet ** const)TPS) || CandidateLine.BaseLine->skipped) {
     2414//            CandidateLine.point = (*it)->point;
     2415//            CandidateLine.OptCenter.CopyVector(&(*it)->OptCenter);
     2416//            CandidateLine.OtherOptCenter.CopyVector(&(*it)->OtherOptCenter);
     2417//            CandidateLine.ShortestAngle = ShortestAngle+2.*M_PI;
     2418//
     2419//          } else {
     2420////            eLog() << Verbose(1) << "This triangle consisting of " << *(*it)->point << ", " << *BaseRay->endpoints[0]->node << " and " << *BaseRay->endpoints[1]->node << " " << "exists and is not added, as it does not seem helpful!" << endl;
     2421//            result = false;
     2422//          }
     2423//      } else {
     2424////        Log() << Verbose(1) << "This triangle consisting of ";
     2425////        Log() << Verbose(0) << *(*it)->point << ", ";
     2426////        Log() << Verbose(0) << *BaseRay->endpoints[0]->node << " and ";
     2427////        Log() << Verbose(0) << *BaseRay->endpoints[1]->node << " ";
     2428////        Log() << Verbose(0) << "is invalid!" << endl;
     2429//        result = false;
     2430//      }
     2431//    }
     2432//
     2433//    // set baseline to new ray from ref point (here endpoints[0]->node) to current candidate (here (*it)->point))
     2434//    BaseRay = BLS[0];
     2435//    if ((BTS != NULL) && (BTS->NormalVector.NormSquared() < MYEPSILON)) {
     2436//      eLog() << Verbose(1) << "Triangle " << *BTS << " has zero normal vector!" << endl;
     2437//      exit(255);
     2438//    }
     2439//
     2440//  }
     2441//
     2442//  // remove all candidates from the list and then the list itself
     2443//  class CandidateForTesselation *remover = NULL;
     2444//  for (CandidateList::iterator it = OptCandidates->begin(); it != OptCandidates->end(); ++it) {
     2445//    remover = *it;
     2446//    delete(remover);
     2447//  }
     2448//  delete(OptCandidates);
    20432449  return result;
     2450};
     2451
     2452/** Adds the present line and candidate point from \a &CandidateLine to the Tesselation.
     2453 * \param CandidateLine triangle to add
     2454 * \NOTE we need the copy operator here as the original CandidateForTesselation is removed in AddTesselationLine()
     2455 */
     2456void Tesselation::AddCandidateTriangle(CandidateForTesselation CandidateLine)
     2457{
     2458        Info FunctionInfo(__func__);
     2459  Vector Center;
     2460  TesselPoint * const TurningPoint = CandidateLine.BaseLine->endpoints[0]->node;
     2461
     2462  // fill the set of neighbours
     2463  TesselPointSet SetOfNeighbours;
     2464  SetOfNeighbours.insert(CandidateLine.BaseLine->endpoints[1]->node);
     2465  for (TesselPointList::iterator Runner = CandidateLine.pointlist.begin(); Runner != CandidateLine.pointlist.end(); Runner++)
     2466    SetOfNeighbours.insert(*Runner);
     2467  TesselPointList *connectedClosestPoints = GetCircleOfSetOfPoints(&SetOfNeighbours, TurningPoint, CandidateLine.BaseLine->endpoints[1]->node->node);
     2468
     2469  // go through all angle-sorted candidates (in degenerate n-nodes case we may have to add multiple triangles)
     2470  Log() << Verbose(0) << "List of Candidates for Turning Point: " << *TurningPoint << "." << endl;
     2471  for (TesselPointList::iterator TesselRunner = connectedClosestPoints->begin(); TesselRunner != connectedClosestPoints->end(); ++TesselRunner)
     2472    Log() << Verbose(0) << **TesselRunner << endl;
     2473  TesselPointList::iterator Runner = connectedClosestPoints->begin();
     2474  TesselPointList::iterator Sprinter = Runner;
     2475  Sprinter++;
     2476  while(Sprinter != connectedClosestPoints->end()) {
     2477    // add the points
     2478    AddTesselationPoint(TurningPoint, 0);
     2479    AddTesselationPoint((*Runner), 1);
     2480    AddTesselationPoint((*Sprinter), 2);
     2481
     2482    // add the lines
     2483    AddTesselationLine(TPS[0], TPS[1], 0);
     2484    AddTesselationLine(TPS[0], TPS[2], 1);
     2485    AddTesselationLine(TPS[1], TPS[2], 2);
     2486
     2487    // add the triangles
     2488    BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
     2489    AddTesselationTriangle();
     2490    BTS->GetCenter(&Center);
     2491    Center.SubtractVector(&CandidateLine.OptCenter);
     2492    BTS->SphereCenter.CopyVector(&CandidateLine.OptCenter);
     2493    BTS->GetNormalVector(Center);
     2494
     2495    Log() << Verbose(0) << "--> New triangle with " << *BTS << " and normal vector " << BTS->NormalVector << "." << endl;
     2496    Runner = Sprinter;
     2497    Sprinter++;
     2498    Log() << Verbose(0) << "Current Runner is " << **Runner << "." << endl;
     2499    if (Sprinter != connectedClosestPoints->end())
     2500      Log() << Verbose(0) << " There are still more triangles to add." << endl;
     2501  }
     2502  delete(connectedClosestPoints);
    20442503};
    20452504
     
    20532512class BoundaryPointSet *Tesselation::IsConvexRectangle(class BoundaryLineSet *Base)
    20542513{
     2514        Info FunctionInfo(__func__);
    20552515  class BoundaryPointSet *Spot = NULL;
    20562516  class BoundaryLineSet *OtherBase;
     
    20642524  OtherBase = new class BoundaryLineSet(BPS,-1);
    20652525
    2066   Log() << Verbose(3) << "INFO: Current base line is " << *Base << "." << endl;
    2067   Log() << Verbose(3) << "INFO: Other base line is " << *OtherBase << "." << endl;
     2526  Log() << Verbose(1) << "INFO: Current base line is " << *Base << "." << endl;
     2527  Log() << Verbose(1) << "INFO: Other base line is " << *OtherBase << "." << endl;
    20682528
    20692529  // get the closest point on each line to the other line
     
    20852545  delete(ClosestPoint);
    20862546  if ((distance[0] * distance[1]) > 0)  { // have same sign?
    2087     Log() << Verbose(3) << "REJECT: Both SKPs have same sign: " << distance[0] << " and " << distance[1]  << ". " << *Base << "' rectangle is concave." << endl;
     2547    Log() << Verbose(1) << "REJECT: Both SKPs have same sign: " << distance[0] << " and " << distance[1]  << ". " << *Base << "' rectangle is concave." << endl;
    20882548    if (distance[0] < distance[1]) {
    20892549      Spot = Base->endpoints[0];
     
    20932553    return Spot;
    20942554  } else {  // different sign, i.e. we are in between
    2095     Log() << Verbose(3) << "ACCEPT: Rectangle of triangles of base line " << *Base << " is convex." << endl;
     2555    Log() << Verbose(0) << "ACCEPT: Rectangle of triangles of base line " << *Base << " is convex." << endl;
    20962556    return NULL;
    20972557  }
     
    21012561void Tesselation::PrintAllBoundaryPoints(ofstream *out) const
    21022562{
     2563        Info FunctionInfo(__func__);
    21032564  // print all lines
    2104   Log() << Verbose(1) << "Printing all boundary points for debugging:" << endl;
     2565  Log() << Verbose(0) << "Printing all boundary points for debugging:" << endl;
    21052566  for (PointMap::const_iterator PointRunner = PointsOnBoundary.begin();PointRunner != PointsOnBoundary.end(); PointRunner++)
    2106     Log() << Verbose(2) << *(PointRunner->second) << endl;
     2567    Log() << Verbose(0) << *(PointRunner->second) << endl;
    21072568};
    21082569
    21092570void Tesselation::PrintAllBoundaryLines(ofstream *out) const
    21102571{
     2572        Info FunctionInfo(__func__);
    21112573  // print all lines
    2112   Log() << Verbose(1) << "Printing all boundary lines for debugging:" << endl;
     2574  Log() << Verbose(0) << "Printing all boundary lines for debugging:" << endl;
    21132575  for (LineMap::const_iterator LineRunner = LinesOnBoundary.begin(); LineRunner != LinesOnBoundary.end(); LineRunner++)
    2114     Log() << Verbose(2) << *(LineRunner->second) << endl;
     2576    Log() << Verbose(0) << *(LineRunner->second) << endl;
    21152577};
    21162578
    21172579void Tesselation::PrintAllBoundaryTriangles(ofstream *out) const
    21182580{
     2581        Info FunctionInfo(__func__);
    21192582  // print all triangles
    2120   Log() << Verbose(1) << "Printing all boundary triangles for debugging:" << endl;
     2583  Log() << Verbose(0) << "Printing all boundary triangles for debugging:" << endl;
    21212584  for (TriangleMap::const_iterator TriangleRunner = TrianglesOnBoundary.begin(); TriangleRunner != TrianglesOnBoundary.end(); TriangleRunner++)
    2122     Log() << Verbose(2) << *(TriangleRunner->second) << endl;
     2585    Log() << Verbose(0) << *(TriangleRunner->second) << endl;
    21232586};
    21242587
     
    21302593double Tesselation::PickFarthestofTwoBaselines(class BoundaryLineSet *Base)
    21312594{
     2595        Info FunctionInfo(__func__);
    21322596  class BoundaryLineSet *OtherBase;
    21332597  Vector *ClosestPoint[2];
     
    21412605  OtherBase = new class BoundaryLineSet(BPS,-1);
    21422606
    2143   Log() << Verbose(3) << "INFO: Current base line is " << *Base << "." << endl;
    2144   Log() << Verbose(3) << "INFO: Other base line is " << *OtherBase << "." << endl;
     2607  Log() << Verbose(0) << "INFO: Current base line is " << *Base << "." << endl;
     2608  Log() << Verbose(0) << "INFO: Other base line is " << *OtherBase << "." << endl;
    21452609
    21462610  // get the closest point on each line to the other line
     
    21622626
    21632627  if (Distance.NormSquared() < MYEPSILON) { // check for intersection
    2164     Log() << Verbose(3) << "REJECT: Both lines have an intersection: Nothing to do." << endl;
     2628    Log() << Verbose(0) << "REJECT: Both lines have an intersection: Nothing to do." << endl;
    21652629    return false;
    21662630  } else { // check for sign against BaseLineNormal
     
    21722636    }
    21732637    for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) {
    2174       Log() << Verbose(4) << "INFO: Adding NormalVector " << runner->second->NormalVector << " of triangle " << *(runner->second) << "." << endl;
     2638      Log() << Verbose(1) << "INFO: Adding NormalVector " << runner->second->NormalVector << " of triangle " << *(runner->second) << "." << endl;
    21752639      BaseLineNormal.AddVector(&(runner->second->NormalVector));
    21762640    }
     
    21782642
    21792643    if (Distance.ScalarProduct(&BaseLineNormal) > MYEPSILON) { // Distance points outwards, hence OtherBase higher than Base -> flip
    2180       Log() << Verbose(2) << "ACCEPT: Other base line would be higher: Flipping baseline." << endl;
     2644      Log() << Verbose(0) << "ACCEPT: Other base line would be higher: Flipping baseline." << endl;
    21812645      // calculate volume summand as a general tetraeder
    21822646      return volume;
    21832647    } else {  // Base higher than OtherBase -> do nothing
    2184       Log() << Verbose(2) << "REJECT: Base line is higher: Nothing to do." << endl;
     2648      Log() << Verbose(0) << "REJECT: Base line is higher: Nothing to do." << endl;
    21852649      return 0.;
    21862650    }
     
    21972661class BoundaryLineSet * Tesselation::FlipBaseline(class BoundaryLineSet *Base)
    21982662{
     2663        Info FunctionInfo(__func__);
    21992664  class BoundaryLineSet *OldLines[4], *NewLine;
    22002665  class BoundaryPointSet *OldPoints[2];
     
    22032668  int i,m;
    22042669
    2205   Log() << Verbose(1) << "Begin of FlipBaseline" << endl;
    2206 
    22072670  // calculate NormalVector for later use
    22082671  BaseLineNormal.Zero();
     
    22122675  }
    22132676  for (TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) {
    2214     Log() << Verbose(4) << "INFO: Adding NormalVector " << runner->second->NormalVector << " of triangle " << *(runner->second) << "." << endl;
     2677    Log() << Verbose(1) << "INFO: Adding NormalVector " << runner->second->NormalVector << " of triangle " << *(runner->second) << "." << endl;
    22152678    BaseLineNormal.AddVector(&(runner->second->NormalVector));
    22162679  }
     
    22252688  i=0;
    22262689  m=0;
    2227   Log() << Verbose(3) << "The four old lines are: ";
     2690  Log() << Verbose(0) << "The four old lines are: ";
    22282691  for(TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++)
    22292692    for (int j=0;j<3;j++) // all of their endpoints and baselines
     
    22332696      }
    22342697  Log() << Verbose(0) << endl;
    2235   Log() << Verbose(3) << "The two old points are: ";
     2698  Log() << Verbose(0) << "The two old points are: ";
    22362699  for(TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++)
    22372700    for (int j=0;j<3;j++) // all of their endpoints and baselines
     
    22592722
    22602723  // remove triangles and baseline removes itself
    2261   Log() << Verbose(3) << "INFO: Deleting baseline " << *Base << " from global list." << endl;
     2724  Log() << Verbose(0) << "INFO: Deleting baseline " << *Base << " from global list." << endl;
    22622725  OldBaseLineNr = Base->Nr;
    22632726  m=0;
    22642727  for(TriangleMap::iterator runner = Base->triangles.begin(); runner != Base->triangles.end(); runner++) {
    2265     Log() << Verbose(3) << "INFO: Deleting triangle " << *(runner->second) << "." << endl;
     2728    Log() << Verbose(0) << "INFO: Deleting triangle " << *(runner->second) << "." << endl;
    22662729    OldTriangleNrs[m++] = runner->second->Nr;
    22672730    RemoveTesselationTriangle(runner->second);
     
    22732736  NewLine = new class BoundaryLineSet(BPS, OldBaseLineNr);
    22742737  LinesOnBoundary.insert(LinePair(OldBaseLineNr, NewLine)); // no need for check for unique insertion as NewLine is definitely a new one
    2275   Log() << Verbose(3) << "INFO: Created new baseline " << *NewLine << "." << endl;
     2738  Log() << Verbose(0) << "INFO: Created new baseline " << *NewLine << "." << endl;
    22762739
    22772740  // construct new triangles with flipped baseline
     
    22882751    BTS->GetNormalVector(BaseLineNormal);
    22892752    AddTesselationTriangle(OldTriangleNrs[0]);
    2290     Log() << Verbose(3) << "INFO: Created new triangle " << *BTS << "." << endl;
     2753    Log() << Verbose(0) << "INFO: Created new triangle " << *BTS << "." << endl;
    22912754
    22922755    BLS[0] = (i==2 ? OldLines[3] : OldLines[2]);
     
    22962759    BTS->GetNormalVector(BaseLineNormal);
    22972760    AddTesselationTriangle(OldTriangleNrs[1]);
    2298     Log() << Verbose(3) << "INFO: Created new triangle " << *BTS << "." << endl;
     2761    Log() << Verbose(0) << "INFO: Created new triangle " << *BTS << "." << endl;
    22992762  } else {
    2300     Log() << Verbose(1) << "The four old lines do not connect, something's utterly wrong here!" << endl;
     2763    eLog() << Verbose(0) << "The four old lines do not connect, something's utterly wrong here!" << endl;
    23012764    return NULL;
    23022765  }
    23032766
    2304   Log() << Verbose(1) << "End of FlipBaseline" << endl;
    23052767  return NewLine;
    23062768};
     
    23172779void Tesselation::FindSecondPointForTesselation(TesselPoint* a, Vector Oben, TesselPoint*& OptCandidate, double Storage[3], double RADIUS, const LinkedCell *LC)
    23182780{
    2319   Log() << Verbose(2) << "Begin of FindSecondPointForTesselation" << endl;
     2781        Info FunctionInfo(__func__);
    23202782  Vector AngleCheck;
    23212783  class TesselPoint* Candidate = NULL;
     
    23382800    Nupper[i] = ((N[i]+1) < LC->N[i]) ? N[i]+1 : LC->N[i]-1;
    23392801  }
    2340   Log() << Verbose(3) << "LC Intervals from [" << N[0] << "<->" << LC->N[0] << ", " << N[1] << "<->" << LC->N[1] << ", " << N[2] << "<->" << LC->N[2] << "] :"
     2802  Log() << Verbose(0) << "LC Intervals from [" << N[0] << "<->" << LC->N[0] << ", " << N[1] << "<->" << LC->N[1] << ", " << N[2] << "<->" << LC->N[2] << "] :"
    23412803    << " [" << Nlower[0] << "," << Nupper[0] << "], " << " [" << Nlower[1] << "," << Nupper[1] << "], " << " [" << Nlower[2] << "," << Nupper[2] << "], " << endl;
    23422804
     
    23452807      for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
    23462808        const LinkedNodes *List = LC->GetCurrentCell();
    2347         //Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;
     2809        //Log() << Verbose(1) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;
    23482810        if (List != NULL) {
    23492811          for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
     
    23762838                angle = AngleCheck.Angle(&Oben);
    23772839                if (angle < Storage[0]) {
    2378                   //Log() << Verbose(3) << "Old values of Storage: %lf %lf \n", Storage[0], Storage[1]);
    2379                   Log() << Verbose(3) << "Current candidate is " << *Candidate << ": Is a better candidate with distance " << norm << " and angle " << angle << " to oben " << Oben << ".\n";
     2840                  //Log() << Verbose(1) << "Old values of Storage: %lf %lf \n", Storage[0], Storage[1]);
     2841                  Log() << Verbose(1) << "Current candidate is " << *Candidate << ": Is a better candidate with distance " << norm << " and angle " << angle << " to oben " << Oben << ".\n";
    23802842                  OptCandidate = Candidate;
    23812843                  Storage[0] = angle;
    2382                   //Log() << Verbose(3) << "Changing something in Storage: %lf %lf. \n", Storage[0], Storage[2]);
     2844                  //Log() << Verbose(1) << "Changing something in Storage: %lf %lf. \n", Storage[0], Storage[2]);
    23832845                } else {
    2384                   //Log() << Verbose(3) << "Current candidate is " << *Candidate << ": Looses with angle " << angle << " to a better candidate " << *OptCandidate << endl;
     2846                  //Log() << Verbose(1) << "Current candidate is " << *Candidate << ": Looses with angle " << angle << " to a better candidate " << *OptCandidate << endl;
    23852847                }
    23862848              } else {
    2387                 //Log() << Verbose(3) << "Current candidate is " << *Candidate << ": Refused due to Radius " << norm << endl;
     2849                //Log() << Verbose(1) << "Current candidate is " << *Candidate << ": Refused due to Radius " << norm << endl;
    23882850              }
    23892851            } else {
    2390               //Log() << Verbose(3) << "Current candidate is " << *Candidate << ": Candidate is equal to first endpoint." << *a << "." << endl;
     2852              //Log() << Verbose(1) << "Current candidate is " << *Candidate << ": Candidate is equal to first endpoint." << *a << "." << endl;
    23912853            }
    23922854          }
    23932855        } else {
    2394           Log() << Verbose(3) << "Linked cell list is empty." << endl;
     2856          Log() << Verbose(0) << "Linked cell list is empty." << endl;
    23952857        }
    23962858      }
    2397   Log() << Verbose(2) << "End of FindSecondPointForTesselation" << endl;
    23982859};
    23992860
     
    24242885 * @param SearchDirection general direction where to search for the next point, relative to center of BaseLine
    24252886 * @param OldSphereCenter center of sphere for base triangle, relative to center of BaseLine, giving null angle for the parameter circle
    2426  * @param BaseLine BoundaryLineSet with the current base line
     2887 * @param CandidateLine CandidateForTesselation with the current base line and list of candidates and ShortestAngle
    24272888 * @param ThirdNode third point to avoid in search
    2428  * @param candidates list of equally good candidates to return
    2429  * @param ShortestAngle the current path length on this circle band for the current OptCandidate
    24302889 * @param RADIUS radius of sphere
    24312890 * @param *LC LinkedCell structure with neighbouring points
    24322891 */
    2433 void Tesselation::FindThirdPointForTesselation(Vector &NormalVector, Vector &SearchDirection, Vector &OldSphereCenter, class BoundaryLineSet *BaseLine, const class TesselPoint  * const ThirdNode, CandidateList* &candidates, double *ShortestAngle, const double RADIUS, const LinkedCell *LC) const
    2434 {
     2892void Tesselation::FindThirdPointForTesselation(Vector &NormalVector, Vector &SearchDirection, Vector &OldSphereCenter, CandidateForTesselation &CandidateLine, const class TesselPoint  * const ThirdNode, const double RADIUS, const LinkedCell *LC) const
     2893{
     2894        Info FunctionInfo(__func__);
    24352895  Vector CircleCenter;  // center of the circle, i.e. of the band of sphere's centers
    24362896  Vector CirclePlaneNormal; // normal vector defining the plane this circle lives in
     
    24402900  Vector NewNormalVector;   // normal vector of the Candidate's triangle
    24412901  Vector helper, OptCandidateCenter, OtherOptCandidateCenter;
     2902  Vector RelativeOldSphereCenter;
     2903  Vector NewPlaneCenter;
    24422904  double CircleRadius; // radius of this circle
    24432905  double radius;
     2906  double otherradius;
    24442907  double alpha, Otheralpha; // angles (i.e. parameter for the circle).
    24452908  int N[NDIM], Nlower[NDIM], Nupper[NDIM];
    24462909  TesselPoint *Candidate = NULL;
    2447   CandidateForTesselation *optCandidate = NULL;
    2448 
    2449   Log() << Verbose(1) << "Begin of FindThirdPointForTesselation" << endl;
    2450 
    2451   Log() << Verbose(2) << "INFO: NormalVector of BaseTriangle is " << NormalVector << "." << endl;
     2910
     2911  Log() << Verbose(1) << "INFO: NormalVector of BaseTriangle is " << NormalVector << "." << endl;
    24522912
    24532913  // construct center of circle
    2454   CircleCenter.CopyVector(BaseLine->endpoints[0]->node->node);
    2455   CircleCenter.AddVector(BaseLine->endpoints[1]->node->node);
     2914  CircleCenter.CopyVector(CandidateLine.BaseLine->endpoints[0]->node->node);
     2915  CircleCenter.AddVector(CandidateLine.BaseLine->endpoints[1]->node->node);
    24562916  CircleCenter.Scale(0.5);
    24572917
    24582918  // construct normal vector of circle
    2459   CirclePlaneNormal.CopyVector(BaseLine->endpoints[0]->node->node);
    2460   CirclePlaneNormal.SubtractVector(BaseLine->endpoints[1]->node->node);
     2919  CirclePlaneNormal.CopyVector(CandidateLine.BaseLine->endpoints[0]->node->node);
     2920  CirclePlaneNormal.SubtractVector(CandidateLine.BaseLine->endpoints[1]->node->node);
     2921
     2922  RelativeOldSphereCenter.CopyVector(&OldSphereCenter);
     2923  RelativeOldSphereCenter.SubtractVector(&CircleCenter);
    24612924
    24622925  // calculate squared radius TesselPoint *ThirdNode,f circle
    2463   radius = CirclePlaneNormal.ScalarProduct(&CirclePlaneNormal);
    2464   if (radius/4. < RADIUS*RADIUS) {
    2465     CircleRadius = RADIUS*RADIUS - radius/4.;
     2926  radius = CirclePlaneNormal.NormSquared()/4.;
     2927  if (radius < RADIUS*RADIUS) {
     2928    CircleRadius = RADIUS*RADIUS - radius;
    24662929    CirclePlaneNormal.Normalize();
    2467     //Log() << Verbose(2) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl;
     2930    Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl;
    24682931
    24692932    // test whether old center is on the band's plane
    2470     if (fabs(OldSphereCenter.ScalarProduct(&CirclePlaneNormal)) > HULLEPSILON) {
    2471       eLog() << Verbose(1) << "Something's very wrong here: OldSphereCenter is not on the band's plane as desired by " << fabs(OldSphereCenter.ScalarProduct(&CirclePlaneNormal)) << "!" << endl;
    2472       OldSphereCenter.ProjectOntoPlane(&CirclePlaneNormal);
    2473     }
    2474     radius = OldSphereCenter.ScalarProduct(&OldSphereCenter);
     2933    if (fabs(RelativeOldSphereCenter.ScalarProduct(&CirclePlaneNormal)) > HULLEPSILON) {
     2934      eLog() << Verbose(1) << "Something's very wrong here: RelativeOldSphereCenter is not on the band's plane as desired by " << fabs(RelativeOldSphereCenter.ScalarProduct(&CirclePlaneNormal)) << "!" << endl;
     2935      RelativeOldSphereCenter.ProjectOntoPlane(&CirclePlaneNormal);
     2936    }
     2937    radius = RelativeOldSphereCenter.NormSquared();
    24752938    if (fabs(radius - CircleRadius) < HULLEPSILON) {
    2476       //Log() << Verbose(2) << "INFO: OldSphereCenter is at " << OldSphereCenter << "." << endl;
     2939      Log() << Verbose(1) << "INFO: RelativeOldSphereCenter is at " << RelativeOldSphereCenter << "." << endl;
    24772940
    24782941      // check SearchDirection
    2479       //Log() << Verbose(2) << "INFO: SearchDirection is " << SearchDirection << "." << endl;
    2480       if (fabs(OldSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) {  // rotated the wrong way!
     2942      Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl;
     2943      if (fabs(RelativeOldSphereCenter.ScalarProduct(&SearchDirection)) > HULLEPSILON) {  // rotated the wrong way!
    24812944        eLog() << Verbose(1) << "SearchDirection and RelativeOldSphereCenter are not orthogonal!" << endl;
    24822945      }
     
    24862949        for(int i=0;i<NDIM;i++) // store indices of this cell
    24872950        N[i] = LC->n[i];
    2488         //Log() << Verbose(2) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl;
     2951        //Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl;
    24892952      } else {
    24902953        eLog() << Verbose(1) << "Vector " << CircleCenter << " is outside of LinkedCell's bounding box." << endl;
     
    24922955      }
    24932956      // then go through the current and all neighbouring cells and check the contained points for possible candidates
    2494       //Log() << Verbose(2) << "LC Intervals:";
     2957      //Log() << Verbose(1) << "LC Intervals:";
    24952958      for (int i=0;i<NDIM;i++) {
    24962959        Nlower[i] = ((N[i]-1) >= 0) ? N[i]-1 : 0;
     
    25032966          for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
    25042967            const LinkedNodes *List = LC->GetCurrentCell();
    2505             //Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;
     2968            //Log() << Verbose(1) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;
    25062969            if (List != NULL) {
    25072970              for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
     
    25092972
    25102973                // check for three unique points
    2511                 //Log() << Verbose(2) << "INFO: Current Candidate is " << *Candidate << " at " << Candidate->node << "." << endl;
    2512                 if ((Candidate != BaseLine->endpoints[0]->node) && (Candidate != BaseLine->endpoints[1]->node) ){
    2513 
    2514                   // construct both new centers
    2515                   GetCenterofCircumcircle(&NewSphereCenter, *BaseLine->endpoints[0]->node->node, *BaseLine->endpoints[1]->node->node, *Candidate->node);
    2516                   OtherNewSphereCenter.CopyVector(&NewSphereCenter);
    2517 
    2518                   if ((NewNormalVector.MakeNormalVector(BaseLine->endpoints[0]->node->node, BaseLine->endpoints[1]->node->node, Candidate->node))
    2519                   && (fabs(NewNormalVector.ScalarProduct(&NewNormalVector)) > HULLEPSILON)
     2974                Log() << Verbose(2) << "INFO: Current Candidate is " << *Candidate << " for BaseLine " << *CandidateLine.BaseLine << " with OldSphereCenter " << OldSphereCenter << "." << endl;
     2975                if ((Candidate != CandidateLine.BaseLine->endpoints[0]->node) && (Candidate != CandidateLine.BaseLine->endpoints[1]->node) ){
     2976
     2977                  // find center on the plane
     2978                  GetCenterofCircumcircle(&NewPlaneCenter, *CandidateLine.BaseLine->endpoints[0]->node->node, *CandidateLine.BaseLine->endpoints[1]->node->node, *Candidate->node);
     2979                  Log() << Verbose(1) << "INFO: NewPlaneCenter is " << NewPlaneCenter << "." << endl;
     2980
     2981                  if (NewNormalVector.MakeNormalVector(CandidateLine.BaseLine->endpoints[0]->node->node, CandidateLine.BaseLine->endpoints[1]->node->node, Candidate->node)
     2982                  && (fabs(NewNormalVector.NormSquared()) > HULLEPSILON)
    25202983                  ) {
    2521                     helper.CopyVector(&NewNormalVector);
    2522                     //Log() << Verbose(2) << "INFO: NewNormalVector is " << NewNormalVector << "." << endl;
    2523                     radius = BaseLine->endpoints[0]->node->node->DistanceSquared(&NewSphereCenter);
     2984                    Log() << Verbose(1) << "INFO: NewNormalVector is " << NewNormalVector << "." << endl;
     2985                    radius = CandidateLine.BaseLine->endpoints[0]->node->node->DistanceSquared(&NewPlaneCenter);
     2986                    Log() << Verbose(1) << "INFO: CircleCenter is at " << CircleCenter << ", CirclePlaneNormal is " << CirclePlaneNormal << " with circle radius " << sqrt(CircleRadius) << "." << endl;
     2987                    Log() << Verbose(1) << "INFO: SearchDirection is " << SearchDirection << "." << endl;
     2988                    Log() << Verbose(1) << "INFO: Radius of CircumCenterCircle is " << radius << "." << endl;
    25242989                    if (radius < RADIUS*RADIUS) {
     2990                      otherradius = CandidateLine.BaseLine->endpoints[1]->node->node->DistanceSquared(&NewPlaneCenter);
     2991                      if (fabs(radius - otherradius) > HULLEPSILON) {
     2992                        eLog() << Verbose(1) << "Distance to center of circumcircle is not the same from each corner of the triangle: " << fabs(radius-otherradius) << endl;
     2993                      }
     2994                      // construct both new centers
     2995                      NewSphereCenter.CopyVector(&NewPlaneCenter);
     2996                      OtherNewSphereCenter.CopyVector(&NewPlaneCenter);
     2997                      helper.CopyVector(&NewNormalVector);
    25252998                      helper.Scale(sqrt(RADIUS*RADIUS - radius));
    2526                       //Log() << Verbose(2) << "INFO: Distance of NewCircleCenter to NewSphereCenter is " << helper.Norm() << " with sphere radius " << RADIUS << "." << endl;
     2999                      Log() << Verbose(2) << "INFO: Distance of NewPlaneCenter " << NewPlaneCenter << " to either NewSphereCenter is " << helper.Norm() << " of vector " << helper << " with sphere radius " << RADIUS << "." << endl;
    25273000                      NewSphereCenter.AddVector(&helper);
    2528                       NewSphereCenter.SubtractVector(&CircleCenter);
    2529                       //Log() << Verbose(2) << "INFO: NewSphereCenter is at " << NewSphereCenter << "." << endl;
    2530 
     3001                      Log() << Verbose(2) << "INFO: NewSphereCenter is at " << NewSphereCenter << "." << endl;
    25313002                      // OtherNewSphereCenter is created by the same vector just in the other direction
    25323003                      helper.Scale(-1.);
    25333004                      OtherNewSphereCenter.AddVector(&helper);
    2534                       OtherNewSphereCenter.SubtractVector(&CircleCenter);
    2535                       //Log() << Verbose(2) << "INFO: OtherNewSphereCenter is at " << OtherNewSphereCenter << "." << endl;
     3005                      Log() << Verbose(2) << "INFO: OtherNewSphereCenter is at " << OtherNewSphereCenter << "." << endl;
    25363006
    25373007                      alpha = GetPathLengthonCircumCircle(CircleCenter, CirclePlaneNormal, CircleRadius, NewSphereCenter, OldSphereCenter, NormalVector, SearchDirection);
    25383008                      Otheralpha = GetPathLengthonCircumCircle(CircleCenter, CirclePlaneNormal, CircleRadius, OtherNewSphereCenter, OldSphereCenter, NormalVector, SearchDirection);
    25393009                      alpha = min(alpha, Otheralpha);
     3010
    25403011                      // if there is a better candidate, drop the current list and add the new candidate
    25413012                      // otherwise ignore the new candidate and keep the list
    2542                       if (*ShortestAngle > (alpha - HULLEPSILON)) {
    2543                         optCandidate = new CandidateForTesselation(Candidate, BaseLine, OptCandidateCenter, OtherOptCandidateCenter);
     3013                      if (CandidateLine.ShortestAngle > (alpha - HULLEPSILON)) {
    25443014                        if (fabs(alpha - Otheralpha) > MYEPSILON) {
    2545                           optCandidate->OptCenter.CopyVector(&NewSphereCenter);
    2546                           optCandidate->OtherOptCenter.CopyVector(&OtherNewSphereCenter);
     3015                          CandidateLine.OptCenter.CopyVector(&NewSphereCenter);
     3016                          CandidateLine.OtherOptCenter.CopyVector(&OtherNewSphereCenter);
    25473017                        } else {
    2548                           optCandidate->OptCenter.CopyVector(&OtherNewSphereCenter);
    2549                           optCandidate->OtherOptCenter.CopyVector(&NewSphereCenter);
     3018                          CandidateLine.OptCenter.CopyVector(&OtherNewSphereCenter);
     3019                          CandidateLine.OtherOptCenter.CopyVector(&NewSphereCenter);
    25503020                        }
    25513021                        // if there is an equal candidate, add it to the list without clearing the list
    2552                         if ((*ShortestAngle - HULLEPSILON) < alpha) {
    2553                           candidates->push_back(optCandidate);
    2554                           Log() << Verbose(2) << "ACCEPT: We have found an equally good candidate: " << *(optCandidate->point) << " with "
    2555                             << alpha << " and circumsphere's center at " << optCandidate->OptCenter << "." << endl;
     3022                        if ((CandidateLine.ShortestAngle - HULLEPSILON) < alpha) {
     3023                          CandidateLine.pointlist.push_back(Candidate);
     3024                          Log() << Verbose(0) << "ACCEPT: We have found an equally good candidate: " << *(Candidate) << " with "
     3025                            << alpha << " and circumsphere's center at " << CandidateLine.OptCenter << "." << endl;
    25563026                        } else {
    25573027                          // remove all candidates from the list and then the list itself
    2558                           class CandidateForTesselation *remover = NULL;
    2559                           for (CandidateList::iterator it = candidates->begin(); it != candidates->end(); ++it) {
    2560                             remover = *it;
    2561                             delete(remover);
    2562                           }
    2563                           candidates->clear();
    2564                           candidates->push_back(optCandidate);
    2565                           Log() << Verbose(2) << "ACCEPT: We have found a better candidate: " << *(optCandidate->point) << " with "
    2566                             << alpha << " and circumsphere's center at " << optCandidate->OptCenter << "." << endl;
     3028                          CandidateLine.pointlist.clear();
     3029                          CandidateLine.pointlist.push_back(Candidate);
     3030                          Log() << Verbose(0) << "ACCEPT: We have found a better candidate: " << *(Candidate) << " with "
     3031                            << alpha << " and circumsphere's center at " << CandidateLine.OptCenter << "." << endl;
    25673032                        }
    2568                         *ShortestAngle = alpha;
    2569                         //Log() << Verbose(2) << "INFO: There are " << candidates->size() << " candidates in the list now." << endl;
     3033                        CandidateLine.ShortestAngle = alpha;
     3034                        Log() << Verbose(0) << "INFO: There are " << CandidateLine.pointlist.size() << " candidates in the list now." << endl;
    25703035                      } else {
    2571                         if ((optCandidate != NULL) && (optCandidate->point != NULL)) {
    2572                           //Log() << Verbose(2) << "REJECT: Old candidate " << *(optCandidate->point) << " with " << *ShortestAngle << " is better than new one " << *Candidate << " with " << alpha << " ." << endl;
     3036                        if ((Candidate != NULL) && (CandidateLine.pointlist.begin() != CandidateLine.pointlist.end())) {
     3037                          Log() << Verbose(1) << "REJECT: Old candidate " << *(Candidate) << " with " << CandidateLine.ShortestAngle << " is better than new one " << *Candidate << " with " << alpha << " ." << endl;
    25733038                        } else {
    2574                           //Log() << Verbose(2) << "REJECT: Candidate " << *Candidate << " with " << alpha << " was rejected." << endl;
     3039                          Log() << Verbose(1) << "REJECT: Candidate " << *Candidate << " with " << alpha << " was rejected." << endl;
    25753040                        }
    25763041                      }
    2577 
    25783042                    } else {
    2579                       //Log() << Verbose(2) << "REJECT: NewSphereCenter " << NewSphereCenter << " for " << *Candidate << " is too far away: " << radius << "." << endl;
     3043                      Log() << Verbose(1) << "REJECT: NewSphereCenter " << NewSphereCenter << " for " << *Candidate << " is too far away: " << radius << "." << endl;
    25803044                    }
    25813045                  } else {
    2582                     //Log() << Verbose(2) << "REJECT: Three points from " << *BaseLine << " and Candidate " << *Candidate << " are linear-dependent." << endl;
     3046                    Log() << Verbose(1) << "REJECT: Three points from " << *CandidateLine.BaseLine << " and Candidate " << *Candidate << " are linear-dependent." << endl;
    25833047                  }
    25843048                } else {
    25853049                  if (ThirdNode != NULL) {
    2586                     //Log() << Verbose(2) << "REJECT: Base triangle " << *BaseLine << " and " << *ThirdNode << " contains Candidate " << *Candidate << "." << endl;
     3050                    Log() << Verbose(1) << "REJECT: Base triangle " << *CandidateLine.BaseLine << " and " << *ThirdNode << " contains Candidate " << *Candidate << "." << endl;
    25873051                  } else {
    2588                     //Log() << Verbose(2) << "REJECT: Base triangle " << *BaseLine << " contains Candidate " << *Candidate << "." << endl;
     3052                    Log() << Verbose(1) << "REJECT: Base triangle " << *CandidateLine.BaseLine << " contains Candidate " << *Candidate << "." << endl;
    25893053                  }
    25903054                }
     
    25973061  } else {
    25983062    if (ThirdNode != NULL)
    2599       Log() << Verbose(2) << "Circumcircle for base line " << *BaseLine << " and third node " << *ThirdNode << " is too big!" << endl;
     3063      Log() << Verbose(1) << "Circumcircle for base line " << *CandidateLine.BaseLine << " and third node " << *ThirdNode << " is too big!" << endl;
    26003064    else
    2601       Log() << Verbose(2) << "Circumcircle for base line " << *BaseLine << " is too big!" << endl;
    2602   }
    2603 
    2604   //Log() << Verbose(2) << "INFO: Sorting candidate list ..." << endl;
    2605   if (candidates->size() > 1) {
    2606     candidates->unique();
    2607     candidates->sort(SortCandidates);
    2608   }
    2609 
    2610   Log() << Verbose(1) << "End of FindThirdPointForTesselation" << endl;
     3065      Log() << Verbose(1) << "Circumcircle for base line " << *CandidateLine.BaseLine << " is too big!" << endl;
     3066  }
     3067
     3068  Log() << Verbose(1) << "INFO: Sorting candidate list ..." << endl;
     3069  if (CandidateLine.pointlist.size() > 1) {
     3070    CandidateLine.pointlist.unique();
     3071    CandidateLine.pointlist.sort(); //SortCandidates);
     3072  }
    26113073};
    26123074
     
    26183080class BoundaryPointSet *Tesselation::GetCommonEndpoint(const BoundaryLineSet * line1, const BoundaryLineSet * line2) const
    26193081{
     3082        Info FunctionInfo(__func__);
    26203083  const BoundaryLineSet * lines[2] = { line1, line2 };
    26213084  class BoundaryPointSet *node = NULL;
    2622   map<int, class BoundaryPointSet *> OrderMap;
    2623   pair<map<int, class BoundaryPointSet *>::iterator, bool> OrderTest;
     3085  PointMap OrderMap;
     3086  PointTestPair OrderTest;
    26243087  for (int i = 0; i < 2; i++)
    26253088    // for both lines
     
    26313094          { // if insertion fails, we have common endpoint
    26323095            node = OrderTest.first->second;
    2633             Log() << Verbose(5) << "Common endpoint of lines " << *line1
     3096            Log() << Verbose(1) << "Common endpoint of lines " << *line1
    26343097                << " and " << *line2 << " is: " << *node << "." << endl;
    26353098            j = 2;
     
    26413104};
    26423105
     3106/** Finds the boundary points that are closest to a given Vector \a *x.
     3107 * \param *out output stream for debugging
     3108 * \param *x Vector to look from
     3109 * \return map of BoundaryPointSet of closest points sorted by squared distance or NULL.
     3110 */
     3111DistanceToPointMap * Tesselation::FindClosestBoundaryPointsToVector(const Vector *x, const LinkedCell* LC) const
     3112{
     3113  Info FunctionInfo(__func__);
     3114  PointMap::const_iterator FindPoint;
     3115  int N[NDIM], Nlower[NDIM], Nupper[NDIM];
     3116
     3117  if (LinesOnBoundary.empty()) {
     3118    eLog() << Verbose(1) << "There is no tesselation structure to compare the point with, please create one first." << endl;
     3119    return NULL;
     3120  }
     3121
     3122  // gather all points close to the desired one
     3123  LC->SetIndexToVector(x); // ignore status as we calculate bounds below sensibly
     3124  for(int i=0;i<NDIM;i++) // store indices of this cell
     3125    N[i] = LC->n[i];
     3126  Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl;
     3127
     3128  DistanceToPointMap * points = new DistanceToPointMap;
     3129  LC->GetNeighbourBounds(Nlower, Nupper);
     3130  //Log() << Verbose(1) << endl;
     3131  for (LC->n[0] = Nlower[0]; LC->n[0] <= Nupper[0]; LC->n[0]++)
     3132    for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
     3133      for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
     3134        const LinkedNodes *List = LC->GetCurrentCell();
     3135        //Log() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl;
     3136        if (List != NULL) {
     3137          for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
     3138            FindPoint = PointsOnBoundary.find((*Runner)->nr);
     3139            if (FindPoint != PointsOnBoundary.end()) {
     3140              points->insert(DistanceToPointPair (FindPoint->second->node->node->DistanceSquared(x), FindPoint->second) );
     3141              Log() << Verbose(1) << "INFO: Putting " << *FindPoint->second << " into the list." << endl;
     3142            }
     3143          }
     3144        } else {
     3145          eLog() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << " is invalid!" << endl;
     3146        }
     3147      }
     3148
     3149  // check whether we found some points
     3150  if (points->empty()) {
     3151    eLog() << Verbose(1) << "There is no nearest point: too far away from the surface." << endl;
     3152    delete(points);
     3153    return NULL;
     3154  }
     3155  return points;
     3156};
     3157
     3158/** Finds the boundary line that is closest to a given Vector \a *x.
     3159 * \param *out output stream for debugging
     3160 * \param *x Vector to look from
     3161 * \return closest BoundaryLineSet or NULL in degenerate case.
     3162 */
     3163BoundaryLineSet * Tesselation::FindClosestBoundaryLineToVector(const Vector *x, const LinkedCell* LC) const
     3164{
     3165  Info FunctionInfo(__func__);
     3166
     3167  // get closest points
     3168  DistanceToPointMap * points = FindClosestBoundaryPointsToVector(x,LC);
     3169  if (points == NULL) {
     3170    eLog() << Verbose(1) << "There is no nearest point: too far away from the surface." << endl;
     3171    return NULL;
     3172  }
     3173
     3174  // for each point, check its lines, remember closest
     3175  Log() << Verbose(1) << "Finding closest BoundaryLine to " << *x << " ... " << endl;
     3176  BoundaryLineSet *ClosestLine = NULL;
     3177  double MinDistance = -1.;
     3178  Vector helper;
     3179  Vector Center;
     3180  Vector BaseLine;
     3181  for (DistanceToPointMap::iterator Runner = points->begin(); Runner != points->end(); Runner++) {
     3182    for (LineMap::iterator LineRunner = Runner->second->lines.begin(); LineRunner != Runner->second->lines.end(); LineRunner++) {
     3183      // calculate closest point on line to desired point
     3184      helper.CopyVector((LineRunner->second)->endpoints[0]->node->node);
     3185      helper.AddVector((LineRunner->second)->endpoints[1]->node->node);
     3186      helper.Scale(0.5);
     3187      Center.CopyVector(x);
     3188      Center.SubtractVector(&helper);
     3189      BaseLine.CopyVector((LineRunner->second)->endpoints[0]->node->node);
     3190      BaseLine.SubtractVector((LineRunner->second)->endpoints[1]->node->node);
     3191      Center.ProjectOntoPlane(&BaseLine);
     3192      const double distance = Center.NormSquared();
     3193      if ((ClosestLine == NULL) || (distance < MinDistance)) {
     3194        // additionally calculate intersection on line (whether it's on the line section or not)
     3195        helper.CopyVector(x);
     3196        helper.SubtractVector((LineRunner->second)->endpoints[0]->node->node);
     3197        helper.SubtractVector(&Center);
     3198        const double lengthA = helper.ScalarProduct(&BaseLine);
     3199        helper.CopyVector(x);
     3200        helper.SubtractVector((LineRunner->second)->endpoints[1]->node->node);
     3201        helper.SubtractVector(&Center);
     3202        const double lengthB = helper.ScalarProduct(&BaseLine);
     3203        if (lengthB*lengthA < 0) {  // if have different sign
     3204          ClosestLine = LineRunner->second;
     3205          MinDistance = distance;
     3206          Log() << Verbose(1) << "ACCEPT: New closest line is " << *ClosestLine << " with projected distance " << MinDistance << "." << endl;
     3207        } else {
     3208          Log() << Verbose(1) << "REJECT: Intersection is outside of the line section: " << lengthA << " and " << lengthB << "." << endl;
     3209        }
     3210      } else {
     3211        Log() << Verbose(1) << "REJECT: Point is too further away than present line: " << distance << " >> " << MinDistance << "." << endl;
     3212      }
     3213    }
     3214  }
     3215  delete(points);
     3216  // check whether closest line is "too close" :), then it's inside
     3217  if (ClosestLine == NULL) {
     3218    Log() << Verbose(0) << "Is the only point, no one else is closeby." << endl;
     3219    return NULL;
     3220  }
     3221  return ClosestLine;
     3222};
     3223
     3224
    26433225/** Finds the triangle that is closest to a given Vector \a *x.
    26443226 * \param *out output stream for debugging
    26453227 * \param *x Vector to look from
    2646  * \return list of BoundaryTriangleSet of nearest triangles or NULL in degenerate case.
    2647  */
    2648 list<BoundaryTriangleSet*> * Tesselation::FindClosestTrianglesToPoint(const Vector *x, const LinkedCell* LC) const
    2649 {
    2650   TesselPoint *trianglePoints[3];
    2651   TesselPoint *SecondPoint = NULL;
    2652   list<BoundaryTriangleSet*> *triangles = NULL;
    2653 
    2654   if (LinesOnBoundary.empty()) {
    2655     Log() << Verbose(0) << "Error: There is no tesselation structure to compare the point with, please create one first.";
     3228 * \return BoundaryTriangleSet of nearest triangle or NULL.
     3229 */
     3230TriangleList * Tesselation::FindClosestTrianglesToVector(const Vector *x, const LinkedCell* LC) const
     3231{
     3232        Info FunctionInfo(__func__);
     3233
     3234        // get closest points
     3235        DistanceToPointMap * points = FindClosestBoundaryPointsToVector(x,LC);
     3236  if (points == NULL) {
     3237    eLog() << Verbose(1) << "There is no nearest point: too far away from the surface." << endl;
    26563238    return NULL;
    26573239  }
    2658   Log() << Verbose(1) << "Finding closest Tesselpoint to " << *x << " ... " << endl;
    2659   trianglePoints[0] = FindClosestPoint(x, SecondPoint, LC);
    2660  
    2661   // check whether closest point is "too close" :), then it's inside
    2662   if (trianglePoints[0] == NULL) {
    2663     Log() << Verbose(2) << "Is the only point, no one else is closeby." << endl;
     3240
     3241  // for each point, check its lines, remember closest
     3242  Log() << Verbose(1) << "Finding closest BoundaryTriangle to " << *x << " ... " << endl;
     3243  LineSet ClosestLines;
     3244  double MinDistance = 1e+16;
     3245  Vector BaseLineIntersection;
     3246  Vector Center;
     3247  Vector BaseLine;
     3248  Vector BaseLineCenter;
     3249  for (DistanceToPointMap::iterator Runner = points->begin(); Runner != points->end(); Runner++) {
     3250    for (LineMap::iterator LineRunner = Runner->second->lines.begin(); LineRunner != Runner->second->lines.end(); LineRunner++) {
     3251
     3252      BaseLine.CopyVector((LineRunner->second)->endpoints[0]->node->node);
     3253      BaseLine.SubtractVector((LineRunner->second)->endpoints[1]->node->node);
     3254      const double lengthBase = BaseLine.NormSquared();
     3255
     3256      BaseLineIntersection.CopyVector(x);
     3257      BaseLineIntersection.SubtractVector((LineRunner->second)->endpoints[0]->node->node);
     3258      const double lengthEndA = BaseLineIntersection.NormSquared();
     3259
     3260      BaseLineIntersection.CopyVector(x);
     3261      BaseLineIntersection.SubtractVector((LineRunner->second)->endpoints[1]->node->node);
     3262      const double lengthEndB = BaseLineIntersection.NormSquared();
     3263
     3264      if ((lengthEndA > lengthBase) || (lengthEndB > lengthBase) || ((lengthEndA < MYEPSILON) || (lengthEndB < MYEPSILON))) {  // intersection would be outside, take closer endpoint
     3265        const double lengthEnd = Min(lengthEndA, lengthEndB);
     3266        if (lengthEnd - MinDistance < -MYEPSILON) { // new best line
     3267          ClosestLines.clear();
     3268          ClosestLines.insert(LineRunner->second);
     3269          MinDistance = lengthEnd;
     3270          Log() << Verbose(1) << "ACCEPT: Line " << *LineRunner->second << " to endpoint " << *LineRunner->second->endpoints[0]->node << " is closer with " << lengthEnd << "." << endl;
     3271        } else if  (fabs(lengthEnd - MinDistance) < MYEPSILON) { // additional best candidate
     3272          ClosestLines.insert(LineRunner->second);
     3273          Log() << Verbose(1) << "ACCEPT: Line " << *LineRunner->second << " to endpoint " << *LineRunner->second->endpoints[1]->node << " is equally good with " << lengthEnd << "." << endl;
     3274        } else { // line is worse
     3275          Log() << Verbose(1) << "REJECT: Line " << *LineRunner->second << " to either endpoints is further away than present closest line candidate: " << lengthEndA << ", " << lengthEndB << ", and distance is longer than baseline:" << lengthBase << "." << endl;
     3276        }
     3277      } else { // intersection is closer, calculate
     3278        // calculate closest point on line to desired point
     3279        BaseLineIntersection.CopyVector(x);
     3280        BaseLineIntersection.SubtractVector((LineRunner->second)->endpoints[1]->node->node);
     3281        Center.CopyVector(&BaseLineIntersection);
     3282        Center.ProjectOntoPlane(&BaseLine);
     3283        BaseLineIntersection.SubtractVector(&Center);
     3284        const double distance = BaseLineIntersection.NormSquared();
     3285        if (Center.NormSquared() > BaseLine.NormSquared()) {
     3286          eLog() << Verbose(0) << "Algorithmic error: In second case we have intersection outside of baseline!" << endl;
     3287        }
     3288        if ((ClosestLines.empty()) || (distance < MinDistance)) {
     3289          ClosestLines.insert(LineRunner->second);
     3290          MinDistance = distance;
     3291          Log() << Verbose(1) << "ACCEPT: Intersection in between endpoints, new closest line " << *LineRunner->second << " is " << *ClosestLines.begin() << " with projected distance " << MinDistance << "." << endl;
     3292        } else {
     3293          Log() << Verbose(2) << "REJECT: Point is further away from line " << *LineRunner->second << " than present closest line: " << distance << " >> " << MinDistance << "." << endl;
     3294        }
     3295      }
     3296    }
     3297  }
     3298  delete(points);
     3299
     3300  // check whether closest line is "too close" :), then it's inside
     3301  if (ClosestLines.empty()) {
     3302    Log() << Verbose(0) << "Is the only point, no one else is closeby." << endl;
    26643303    return NULL;
    26653304  }
    2666   if (trianglePoints[0]->node->DistanceSquared(x) < MYEPSILON) {
    2667     Log() << Verbose(3) << "Point is right on a tesselation point, no nearest triangle." << endl;
    2668     PointMap::const_iterator PointRunner = PointsOnBoundary.find(trianglePoints[0]->nr);
    2669     triangles = new list<BoundaryTriangleSet*>;
    2670     if (PointRunner != PointsOnBoundary.end()) {
    2671       for(LineMap::iterator LineRunner = PointRunner->second->lines.begin(); LineRunner != PointRunner->second->lines.end(); LineRunner++)
    2672         for(TriangleMap::iterator TriangleRunner = LineRunner->second->triangles.begin(); TriangleRunner != LineRunner->second->triangles.end(); TriangleRunner++)
    2673           triangles->push_back(TriangleRunner->second);
    2674       triangles->sort();
    2675       triangles->unique();
    2676     } else {
    2677       PointRunner = PointsOnBoundary.find(SecondPoint->nr);
    2678       trianglePoints[0] = SecondPoint;
    2679       if (PointRunner != PointsOnBoundary.end()) {
    2680         for(LineMap::iterator LineRunner = PointRunner->second->lines.begin(); LineRunner != PointRunner->second->lines.end(); LineRunner++)
    2681           for(TriangleMap::iterator TriangleRunner = LineRunner->second->triangles.begin(); TriangleRunner != LineRunner->second->triangles.end(); TriangleRunner++)
    2682             triangles->push_back(TriangleRunner->second);
    2683         triangles->sort();
    2684         triangles->unique();
    2685       } else {
    2686         eLog() << Verbose(1) << "I cannot find a boundary point to the tessel point " << *trianglePoints[0] << "." << endl;
    2687         return NULL;
    2688       }
    2689     }
    2690   } else {
    2691     list<TesselPoint*> *connectedClosestPoints = GetCircleOfConnectedPoints(trianglePoints[0], x);
    2692     if (connectedClosestPoints != NULL) {
    2693       trianglePoints[1] = connectedClosestPoints->front();
    2694       trianglePoints[2] = connectedClosestPoints->back();
    2695       for (int i=0;i<3;i++) {
    2696         if (trianglePoints[i] == NULL) {
    2697           eLog() << Verbose(1) << "IsInnerPoint encounters serious error, point " << i << " not found." << endl;
    2698         }
    2699         //Log() << Verbose(2) << "List of triangle points:" << endl;
    2700         //Log() << Verbose(3) << *trianglePoints[i] << endl;
    2701       }
    2702 
    2703       triangles = FindTriangles(trianglePoints);
    2704       Log() << Verbose(2) << "List of possible triangles:" << endl;
    2705       for(list<BoundaryTriangleSet*>::iterator Runner = triangles->begin(); Runner != triangles->end(); Runner++)
    2706         Log() << Verbose(3) << **Runner << endl;
    2707 
    2708       delete(connectedClosestPoints);
    2709     } else {
    2710       triangles = NULL;
    2711       Log() << Verbose(1) << "There is no circle of connected points!" << endl;
    2712     }
    2713   }
    2714  
    2715   if ((triangles == NULL) || (triangles->empty())) {
    2716     eLog() << Verbose(1) << "There is no nearest triangle. Please check the tesselation structure.";
    2717     delete(triangles);
    2718     return NULL;
    2719   } else
    2720     return triangles;
     3305  TriangleList * candidates = new TriangleList;
     3306  for (LineSet::iterator LineRunner = ClosestLines.begin(); LineRunner != ClosestLines.end(); LineRunner++)
     3307    for (TriangleMap::iterator Runner = (*LineRunner)->triangles.begin(); Runner != (*LineRunner)->triangles.end(); Runner++) {
     3308    candidates->push_back(Runner->second);
     3309  }
     3310  return candidates;
    27213311};
    27223312
     
    27273317 * \return list of BoundaryTriangleSet of nearest triangles or NULL.
    27283318 */
    2729 class BoundaryTriangleSet * Tesselation::FindClosestTriangleToPoint(const Vector *x, const LinkedCell* LC) const
    2730 {
     3319class BoundaryTriangleSet * Tesselation::FindClosestTriangleToVector(const Vector *x, const LinkedCell* LC) const
     3320{
     3321        Info FunctionInfo(__func__);
    27313322  class BoundaryTriangleSet *result = NULL;
    2732   list<BoundaryTriangleSet*> *triangles = FindClosestTrianglesToPoint(x, LC);
     3323  TriangleList *triangles = FindClosestTrianglesToVector(x, LC);
     3324  TriangleList candidates;
    27333325  Vector Center;
    2734 
    2735   if (triangles == NULL)
     3326  Vector helper;
     3327
     3328  if ((triangles == NULL) || (triangles->empty()))
    27363329    return NULL;
    27373330
    2738   if (triangles->size() == 1) { // there is no degenerate case
    2739     result = triangles->front();
    2740     Log() << Verbose(2) << "Normal Vector of this triangle is " << result->NormalVector << "." << endl;
    2741   } else {
    2742     result = triangles->front();
    2743     result->GetCenter(&Center);
    2744     Center.SubtractVector(x);
    2745     Log() << Verbose(2) << "Normal Vector of this front side is " << result->NormalVector << "." << endl;
    2746     if (Center.ScalarProduct(&result->NormalVector) < 0) {
    2747       result = triangles->back();
    2748       Log() << Verbose(2) << "Normal Vector of this back side is " << result->NormalVector << "." << endl;
    2749       if (Center.ScalarProduct(&result->NormalVector) < 0) {
    2750         eLog() << Verbose(1) << "Front and back side yield NormalVector in wrong direction!" << endl;
    2751       }
     3331  // go through all and pick the one with the best alignment to x
     3332  double MinAlignment = 2.*M_PI;
     3333  for (TriangleList::iterator Runner = triangles->begin(); Runner != triangles->end(); Runner++) {
     3334    (*Runner)->GetCenter(&Center);
     3335    helper.CopyVector(x);
     3336    helper.SubtractVector(&Center);
     3337    const double Alignment = helper.Angle(&(*Runner)->NormalVector);
     3338    if (Alignment < MinAlignment) {
     3339      result = *Runner;
     3340      MinAlignment = Alignment;
     3341      Log() << Verbose(1) << "ACCEPT: Triangle " << *result << " is better aligned with " << MinAlignment << "." << endl;
     3342    } else {
     3343      Log() << Verbose(1) << "REJECT: Triangle " << *result << " is worse aligned with " << MinAlignment << "." << endl;
    27523344    }
    27533345  }
    27543346  delete(triangles);
     3347
    27553348  return result;
    27563349};
    27573350
    2758 /** Checks whether the provided Vector is within the tesselation structure.
     3351/** Checks whether the provided Vector is within the Tesselation structure.
     3352 * Basically calls Tesselation::GetDistanceToSurface() and checks the sign of the return value.
     3353 * @param point of which to check the position
     3354 * @param *LC LinkedCell structure
     3355 *
     3356 * @return true if the point is inside the Tesselation structure, false otherwise
     3357 */
     3358bool Tesselation::IsInnerPoint(const Vector &Point, const LinkedCell* const LC) const
     3359{
     3360  return (GetDistanceSquaredToSurface(Point, LC) < MYEPSILON);
     3361}
     3362
     3363/** Returns the distance to the surface given by the tesselation.
     3364 * Calls FindClosestTriangleToVector() and checks whether the resulting triangle's BoundaryTriangleSet#NormalVector points
     3365 * towards or away from the given \a &Point. Additionally, we check whether it's normal to the normal vector, i.e. on the
     3366 * closest triangle's plane. Then, we have to check whether \a Point is inside the triangle or not to determine whether it's
     3367 * an inside or outside point. This is done by calling BoundaryTriangleSet::GetIntersectionInsideTriangle().
     3368 * In the end we additionally find the point on the triangle who was smallest distance to \a Point:
     3369 *  -# Separate distance from point to center in vector in NormalDirection and on the triangle plane.
     3370 *  -# Check whether vector on triangle plane points inside the triangle or crosses triangle bounds.
     3371 *  -# If inside, take it to calculate closest distance
     3372 *  -# If not, take intersection with BoundaryLine as distance
     3373 *
     3374 * @note distance is squared despite it still contains a sign to determine in-/outside!
    27593375 *
    27603376 * @param point of which to check the position
    27613377 * @param *LC LinkedCell structure
    27623378 *
    2763  * @return true if the point is inside the tesselation structure, false otherwise
    2764  */
    2765 bool Tesselation::IsInnerPoint(const Vector &Point, const LinkedCell* const LC) const
    2766 {
    2767   class BoundaryTriangleSet *result = FindClosestTriangleToPoint(&Point, LC);
     3379 * @return >0 if outside, ==0 if on surface, <0 if inside
     3380 */
     3381double Tesselation::GetDistanceSquaredToTriangle(const Vector &Point, const BoundaryTriangleSet* const triangle) const
     3382{
     3383  Info FunctionInfo(__func__);
    27683384  Vector Center;
    2769 
    2770   if (result == NULL) {// is boundary point or only point in point cloud?
    2771     Log() << Verbose(1) << Point << " is the only point in vicinity." << endl;
    2772     return false;
    2773   }
    2774 
    2775   result->GetCenter(&Center);
    2776   Log() << Verbose(3) << "INFO: Central point of the triangle is " << Center << "." << endl;
    2777   Center.SubtractVector(&Point);
    2778   Log() << Verbose(3) << "INFO: Vector from center to point to test is " << Center << "." << endl;
    2779   if (Center.ScalarProduct(&result->NormalVector) > -MYEPSILON) {
    2780     Log() << Verbose(1) << Point << " is an inner point." << endl;
    2781     return true;
     3385  Vector helper;
     3386  Vector DistanceToCenter;
     3387  Vector Intersection;
     3388  double distance = 0.;
     3389
     3390  if (triangle == NULL) {// is boundary point or only point in point cloud?
     3391    Log() << Verbose(1) << "No triangle given!" << endl;
     3392    return -1.;
    27823393  } else {
    2783     Log() << Verbose(1) << Point << " is NOT an inner point." << endl;
    2784     return false;
    2785   }
    2786 }
    2787 
    2788 /** Checks whether the provided TesselPoint is within the tesselation structure.
    2789  *
    2790  * @param *Point of which to check the position
    2791  * @param *LC Linked Cell structure
    2792  *
    2793  * @return true if the point is inside the tesselation structure, false otherwise
    2794  */
    2795 bool Tesselation::IsInnerPoint(const TesselPoint * const Point, const LinkedCell* const LC) const
    2796 {
    2797   return IsInnerPoint(*(Point->node), LC);
    2798 }
     3394    Log() << Verbose(1) << "INFO: Closest triangle found is " << *triangle << " with normal vector " << triangle->NormalVector << "." << endl;
     3395  }
     3396
     3397  triangle->GetCenter(&Center);
     3398  Log() << Verbose(2) << "INFO: Central point of the triangle is " << Center << "." << endl;
     3399  DistanceToCenter.CopyVector(&Center);
     3400  DistanceToCenter.SubtractVector(&Point);
     3401  Log() << Verbose(2) << "INFO: Vector from point to test to center is " << DistanceToCenter << "." << endl;
     3402
     3403  // check whether we are on boundary
     3404  if (fabs(DistanceToCenter.ScalarProduct(&triangle->NormalVector)) < MYEPSILON) {
     3405    // calculate whether inside of triangle
     3406    DistanceToCenter.CopyVector(&Point);
     3407    Center.CopyVector(&Point);
     3408    Center.SubtractVector(&triangle->NormalVector); // points towards MolCenter
     3409    DistanceToCenter.AddVector(&triangle->NormalVector); // points outside
     3410    Log() << Verbose(1) << "INFO: Calling Intersection with " << Center << " and " << DistanceToCenter << "." << endl;
     3411    if (triangle->GetIntersectionInsideTriangle(&Center, &DistanceToCenter, &Intersection)) {
     3412      Log() << Verbose(1) << Point << " is inner point: sufficiently close to boundary, " << Intersection << "." << endl;
     3413      return 0.;
     3414    } else {
     3415      Log() << Verbose(1) << Point << " is NOT an inner point: on triangle plane but outside of triangle bounds." << endl;
     3416      return false;
     3417    }
     3418  } else {
     3419    // calculate smallest distance
     3420    distance = triangle->GetClosestPointInsideTriangle(&Point, &Intersection);
     3421    Log() << Verbose(1) << "Closest point on triangle is " << Intersection << "." << endl;
     3422
     3423    // then check direction to boundary
     3424    if (DistanceToCenter.ScalarProduct(&triangle->NormalVector) > MYEPSILON) {
     3425      Log() << Verbose(1) << Point << " is an inner point, " << distance << " below surface." << endl;
     3426      return -distance;
     3427    } else {
     3428      Log() << Verbose(1) << Point << " is NOT an inner point, " << distance << " above surface." << endl;
     3429      return +distance;
     3430    }
     3431  }
     3432};
     3433
     3434/** Calculates distance to a tesselated surface.
     3435 * Combines \sa FindClosestTrianglesToVector() and \sa GetDistanceSquaredToTriangle().
     3436 * \param &Point point to calculate distance from
     3437 * \param *LC needed for finding closest points fast
     3438 * \return distance squared to closest point on surface
     3439 */
     3440double Tesselation::GetDistanceSquaredToSurface(const Vector &Point, const LinkedCell* const LC) const
     3441{
     3442  BoundaryTriangleSet *triangle = FindClosestTriangleToVector(&Point, LC);
     3443  const double distance = GetDistanceSquaredToTriangle(Point, triangle);
     3444  return Min(distance, LC->RADIUS);
     3445};
    27993446
    28003447/** Gets all points connected to the provided point by triangulation lines.
     
    28043451 * @return set of the all points linked to the provided one
    28053452 */
    2806 set<TesselPoint*> * Tesselation::GetAllConnectedPoints(const TesselPoint* const Point) const
    2807 {
    2808   set<TesselPoint*> *connectedPoints = new set<TesselPoint*>;
     3453TesselPointSet * Tesselation::GetAllConnectedPoints(const TesselPoint* const Point) const
     3454{
     3455        Info FunctionInfo(__func__);
     3456        TesselPointSet *connectedPoints = new TesselPointSet;
    28093457  class BoundaryPointSet *ReferencePoint = NULL;
    28103458  TesselPoint* current;
    28113459  bool takePoint = false;
    2812 
    2813   Log() << Verbose(3) << "Begin of GetAllConnectedPoints" << endl;
    28143460
    28153461  // find the respective boundary point
     
    28183464    ReferencePoint = PointRunner->second;
    28193465  } else {
    2820     Log() << Verbose(2) << "GetAllConnectedPoints() could not find the BoundaryPoint belonging to " << *Point << "." << endl;
     3466    eLog() << Verbose(2) << "GetAllConnectedPoints() could not find the BoundaryPoint belonging to " << *Point << "." << endl;
    28213467    ReferencePoint = NULL;
    28223468  }
     
    28423488
    28433489   if (takePoint) {
    2844      Log() << Verbose(5) << "INFO: Endpoint " << *current << " of line " << *(findLines->second) << " is enlisted." << endl;
     3490     Log() << Verbose(1) << "INFO: Endpoint " << *current << " of line " << *(findLines->second) << " is enlisted." << endl;
    28453491     connectedPoints->insert(current);
    28463492   }
     
    28493495  }
    28503496
    2851   if (connectedPoints->size() == 0) { // if have not found any points
     3497  if (connectedPoints->empty()) { // if have not found any points
    28523498    eLog() << Verbose(1) << "We have not found any connected points to " << *Point<< "." << endl;
    28533499    return NULL;
    28543500  }
    28553501
    2856   Log() << Verbose(3) << "End of GetAllConnectedPoints" << endl;
    28573502  return connectedPoints;
    28583503};
     
    28663511 *
    28673512 * @param *out output stream for debugging
     3513 * @param *SetOfNeighbours all points for which the angle should be calculated
    28683514 * @param *Point of which get all connected points
    28693515 * @param *Reference Reference vector for zero angle or NULL for no preference
    28703516 * @return list of the all points linked to the provided one
    28713517 */
    2872 list<TesselPoint*> * Tesselation::GetCircleOfConnectedPoints(const TesselPoint* const Point, const Vector * const Reference) const
    2873 {
     3518TesselPointList * Tesselation::GetCircleOfConnectedTriangles(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector * const Reference) const
     3519{
     3520        Info FunctionInfo(__func__);
    28743521  map<double, TesselPoint*> anglesOfPoints;
    2875   set<TesselPoint*> *connectedPoints = GetAllConnectedPoints(Point);
    2876   list<TesselPoint*> *connectedCircle = new list<TesselPoint*>;
     3522  TesselPointList *connectedCircle = new TesselPointList;
     3523  Vector PlaneNormal;
     3524  Vector AngleZero;
     3525  Vector OrthogonalVector;
     3526  Vector helper;
     3527  const TesselPoint * const TrianglePoints[3] = {Point, NULL, NULL};
     3528  TriangleList *triangles = NULL;
     3529
     3530  if (SetOfNeighbours == NULL) {
     3531    eLog() << Verbose(2) << "Could not find any connected points!" << endl;
     3532    delete(connectedCircle);
     3533    return NULL;
     3534  }
     3535
     3536  // calculate central point
     3537  triangles = FindTriangles(TrianglePoints);
     3538  if ((triangles != NULL) && (!triangles->empty())) {
     3539    for (TriangleList::iterator Runner = triangles->begin(); Runner != triangles->end(); Runner++)
     3540      PlaneNormal.AddVector(&(*Runner)->NormalVector);
     3541  } else {
     3542    eLog() << Verbose(0) << "Could not find any triangles for point " << *Point << "." << endl;
     3543    performCriticalExit();
     3544  }
     3545  PlaneNormal.Scale(1.0/triangles->size());
     3546  Log() << Verbose(1) << "INFO: Calculated PlaneNormal of all circle points is " << PlaneNormal << "." << endl;
     3547  PlaneNormal.Normalize();
     3548
     3549  // construct one orthogonal vector
     3550  if (Reference != NULL) {
     3551    AngleZero.CopyVector(Reference);
     3552    AngleZero.SubtractVector(Point->node);
     3553    AngleZero.ProjectOntoPlane(&PlaneNormal);
     3554  }
     3555  if ((Reference == NULL) || (AngleZero.NormSquared() < MYEPSILON )) {
     3556    Log() << Verbose(1) << "Using alternatively " << *(*SetOfNeighbours->begin())->node << " as angle 0 referencer." << endl;
     3557    AngleZero.CopyVector((*SetOfNeighbours->begin())->node);
     3558    AngleZero.SubtractVector(Point->node);
     3559    AngleZero.ProjectOntoPlane(&PlaneNormal);
     3560    if (AngleZero.NormSquared() < MYEPSILON) {
     3561      eLog() << Verbose(0) << "CRITIAL: AngleZero is 0 even with alternative reference. The algorithm has to be changed here!" << endl;
     3562      performCriticalExit();
     3563    }
     3564  }
     3565  Log() << Verbose(1) << "INFO: Reference vector on this plane representing angle 0 is " << AngleZero << "." << endl;
     3566  if (AngleZero.NormSquared() > MYEPSILON)
     3567    OrthogonalVector.MakeNormalVector(&PlaneNormal, &AngleZero);
     3568  else
     3569    OrthogonalVector.MakeNormalVector(&PlaneNormal);
     3570  Log() << Verbose(1) << "INFO: OrthogonalVector on plane is " << OrthogonalVector << "." << endl;
     3571
     3572  // go through all connected points and calculate angle
     3573  for (TesselPointSet::iterator listRunner = SetOfNeighbours->begin(); listRunner != SetOfNeighbours->end(); listRunner++) {
     3574    helper.CopyVector((*listRunner)->node);
     3575    helper.SubtractVector(Point->node);
     3576    helper.ProjectOntoPlane(&PlaneNormal);
     3577    double angle = GetAngle(helper, AngleZero, OrthogonalVector);
     3578    Log() << Verbose(0) << "INFO: Calculated angle is " << angle << " for point " << **listRunner << "." << endl;
     3579    anglesOfPoints.insert(pair<double, TesselPoint*>(angle, (*listRunner)));
     3580  }
     3581
     3582  for(map<double, TesselPoint*>::iterator AngleRunner = anglesOfPoints.begin(); AngleRunner != anglesOfPoints.end(); AngleRunner++) {
     3583    connectedCircle->push_back(AngleRunner->second);
     3584  }
     3585
     3586  return connectedCircle;
     3587}
     3588
     3589/** Gets all points connected to the provided point by triangulation lines, ordered such that we have the circle round the point.
     3590 * Maps them down onto the plane designated by the axis \a *Point and \a *Reference. The center of all points
     3591 * connected in the tesselation to \a *Point is mapped to spherical coordinates with the zero angle being given
     3592 * by the mapped down \a *Reference. Hence, the biggest and the smallest angles are those of the two shanks of the
     3593 * triangle we are looking for.
     3594 *
     3595 * @param *SetOfNeighbours all points for which the angle should be calculated
     3596 * @param *Point of which get all connected points
     3597 * @param *Reference Reference vector for zero angle or NULL for no preference
     3598 * @return list of the all points linked to the provided one
     3599 */
     3600TesselPointList * Tesselation::GetCircleOfSetOfPoints(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector * const Reference) const
     3601{
     3602  Info FunctionInfo(__func__);
     3603  map<double, TesselPoint*> anglesOfPoints;
     3604  TesselPointList *connectedCircle = new TesselPointList;
    28773605  Vector center;
    28783606  Vector PlaneNormal;
     
    28813609  Vector helper;
    28823610
    2883   if (connectedPoints == NULL) {
    2884     Log() << Verbose(2) << "Could not find any connected points!" << endl;
     3611  if (SetOfNeighbours == NULL) {
     3612    eLog() << Verbose(2) << "Could not find any connected points!" << endl;
    28853613    delete(connectedCircle);
    28863614    return NULL;
    28873615  }
    2888   Log() << Verbose(2) << "Begin of GetCircleOfConnectedPoints" << endl;
    2889 
     3616
     3617  // check whether there's something to do
     3618  if (SetOfNeighbours->size() < 3) {
     3619    for (TesselPointSet::iterator TesselRunner = SetOfNeighbours->begin(); TesselRunner != SetOfNeighbours->end(); TesselRunner++)
     3620      connectedCircle->push_back(*TesselRunner);
     3621    return connectedCircle;
     3622  }
     3623
     3624  Log() << Verbose(1) << "INFO: Point is " << *Point << " and Reference is " << *Reference << "." << endl;
    28903625  // calculate central point
    2891   for (set<TesselPoint*>::const_iterator TesselRunner = connectedPoints->begin(); TesselRunner != connectedPoints->end(); TesselRunner++)
    2892     center.AddVector((*TesselRunner)->node);
     3626
     3627  TesselPointSet::const_iterator TesselA = SetOfNeighbours->begin();
     3628  TesselPointSet::const_iterator TesselB = SetOfNeighbours->begin();
     3629  TesselPointSet::const_iterator TesselC = SetOfNeighbours->begin();
     3630  TesselB++;
     3631  TesselC++;
     3632  TesselC++;
     3633  int counter = 0;
     3634  while (TesselC != SetOfNeighbours->end()) {
     3635    helper.MakeNormalVector((*TesselA)->node, (*TesselB)->node, (*TesselC)->node);
     3636    Log() << Verbose(0) << "Making normal vector out of " << *(*TesselA) << ", " << *(*TesselB) << " and " << *(*TesselC) << ":" << helper << endl;
     3637    counter++;
     3638    TesselA++;
     3639    TesselB++;
     3640    TesselC++;
     3641    PlaneNormal.AddVector(&helper);
     3642  }
    28933643  //Log() << Verbose(0) << "Summed vectors " << center << "; number of points " << connectedPoints.size()
    2894   //  << "; scale factor " << 1.0/connectedPoints.size();
    2895   center.Scale(1.0/connectedPoints->size());
    2896   Log() << Verbose(4) << "INFO: Calculated center of all circle points is " << center << "." << endl;
    2897 
    2898   // projection plane of the circle is at the closes Point and normal is pointing away from center of all circle points
    2899   PlaneNormal.CopyVector(Point->node);
    2900   PlaneNormal.SubtractVector(&center);
    2901   PlaneNormal.Normalize();
    2902   Log() << Verbose(4) << "INFO: Calculated plane normal of circle is " << PlaneNormal << "." << endl;
     3644  //  << "; scale factor " << counter;
     3645  PlaneNormal.Scale(1.0/(double)counter);
     3646//  Log() << Verbose(1) << "INFO: Calculated center of all circle points is " << center << "." << endl;
     3647//
     3648//  // projection plane of the circle is at the closes Point and normal is pointing away from center of all circle points
     3649//  PlaneNormal.CopyVector(Point->node);
     3650//  PlaneNormal.SubtractVector(&center);
     3651//  PlaneNormal.Normalize();
     3652  Log() << Verbose(1) << "INFO: Calculated plane normal of circle is " << PlaneNormal << "." << endl;
    29033653
    29043654  // construct one orthogonal vector
     
    29093659  }
    29103660  if ((Reference == NULL) || (AngleZero.NormSquared() < MYEPSILON )) {
    2911     Log() << Verbose(4) << "Using alternatively " << *(*connectedPoints->begin())->node << " as angle 0 referencer." << endl;
    2912     AngleZero.CopyVector((*connectedPoints->begin())->node);
     3661    Log() << Verbose(1) << "Using alternatively " << *(*SetOfNeighbours->begin())->node << " as angle 0 referencer." << endl;
     3662    AngleZero.CopyVector((*SetOfNeighbours->begin())->node);
    29133663    AngleZero.SubtractVector(Point->node);
    29143664    AngleZero.ProjectOntoPlane(&PlaneNormal);
     
    29183668    }
    29193669  }
    2920   Log() << Verbose(4) << "INFO: Reference vector on this plane representing angle 0 is " << AngleZero << "." << endl;
     3670  Log() << Verbose(1) << "INFO: Reference vector on this plane representing angle 0 is " << AngleZero << "." << endl;
    29213671  if (AngleZero.NormSquared() > MYEPSILON)
    29223672    OrthogonalVector.MakeNormalVector(&PlaneNormal, &AngleZero);
    29233673  else
    29243674    OrthogonalVector.MakeNormalVector(&PlaneNormal);
    2925   Log() << Verbose(4) << "INFO: OrthogonalVector on plane is " << OrthogonalVector << "." << endl;
     3675  Log() << Verbose(1) << "INFO: OrthogonalVector on plane is " << OrthogonalVector << "." << endl;
    29263676
    29273677  // go through all connected points and calculate angle
    2928   for (set<TesselPoint*>::iterator listRunner = connectedPoints->begin(); listRunner != connectedPoints->end(); listRunner++) {
     3678  pair <map<double, TesselPoint*>::iterator, bool > InserterTest;
     3679  for (TesselPointSet::iterator listRunner = SetOfNeighbours->begin(); listRunner != SetOfNeighbours->end(); listRunner++) {
    29293680    helper.CopyVector((*listRunner)->node);
    29303681    helper.SubtractVector(Point->node);
    29313682    helper.ProjectOntoPlane(&PlaneNormal);
    29323683    double angle = GetAngle(helper, AngleZero, OrthogonalVector);
    2933     Log() << Verbose(3) << "INFO: Calculated angle is " << angle << " for point " << **listRunner << "." << endl;
    2934     anglesOfPoints.insert(pair<double, TesselPoint*>(angle, (*listRunner)));
     3684    if (angle > M_PI) // the correction is of no use here (and not desired)
     3685      angle = 2.*M_PI - angle;
     3686    Log() << Verbose(0) << "INFO: Calculated angle between " << helper << " and " << AngleZero << " is " << angle << " for point " << **listRunner << "." << endl;
     3687    InserterTest = anglesOfPoints.insert(pair<double, TesselPoint*>(angle, (*listRunner)));
     3688    if (!InserterTest.second) {
     3689      eLog() << Verbose(0) << "GetCircleOfSetOfPoints() got two atoms with same angle: " << *((InserterTest.first)->second) << " and " << (*listRunner) << endl;
     3690      performCriticalExit();
     3691    }
    29353692  }
    29363693
     
    29383695    connectedCircle->push_back(AngleRunner->second);
    29393696  }
    2940 
    2941   delete(connectedPoints);
    2942 
    2943   Log() << Verbose(2) << "End of GetCircleOfConnectedPoints" << endl;
    29443697
    29453698  return connectedCircle;
     
    29523705 * @return list of the all points linked to the provided one
    29533706 */
    2954 list<list<TesselPoint*> *> * Tesselation::GetPathsOfConnectedPoints(const TesselPoint* const Point) const
    2955 {
     3707ListOfTesselPointList * Tesselation::GetPathsOfConnectedPoints(const TesselPoint* const Point) const
     3708{
     3709        Info FunctionInfo(__func__);
    29563710  map<double, TesselPoint*> anglesOfPoints;
    2957   list<list<TesselPoint*> *> *ListOfPaths = new list<list<TesselPoint*> *>;
    2958   list<TesselPoint*> *connectedPath = NULL;
     3711  list< TesselPointList *> *ListOfPaths = new list< TesselPointList *>;
     3712  TesselPointList *connectedPath = NULL;
    29593713  Vector center;
    29603714  Vector PlaneNormal;
     
    29933747      } else if (!LineRunner->second) {
    29943748        LineRunner->second = true;
    2995         connectedPath = new list<TesselPoint*>;
     3749        connectedPath = new TesselPointList;
    29963750        triangle = NULL;
    29973751        CurrentLine = runner->second;
    29983752        StartLine = CurrentLine;
    29993753        CurrentPoint = CurrentLine->GetOtherEndpoint(ReferencePoint);
    3000         Log() << Verbose(3)<< "INFO: Beginning path retrieval at " << *CurrentPoint << " of line " << *CurrentLine << "." << endl;
     3754        Log() << Verbose(1)<< "INFO: Beginning path retrieval at " << *CurrentPoint << " of line " << *CurrentLine << "." << endl;
    30013755        do {
    30023756          // push current one
    3003           Log() << Verbose(3) << "INFO: Putting " << *CurrentPoint << " at end of path." << endl;
     3757          Log() << Verbose(1) << "INFO: Putting " << *CurrentPoint << " at end of path." << endl;
    30043758          connectedPath->push_back(CurrentPoint->node);
    30053759
    30063760          // find next triangle
    30073761          for (TriangleMap::iterator Runner = CurrentLine->triangles.begin(); Runner != CurrentLine->triangles.end(); Runner++) {
    3008             Log() << Verbose(3) << "INFO: Inspecting triangle " << *Runner->second << "." << endl;
     3762            Log() << Verbose(1) << "INFO: Inspecting triangle " << *Runner->second << "." << endl;
    30093763            if ((Runner->second != triangle)) { // look for first triangle not equal to old one
    30103764              triangle = Runner->second;
     
    30133767                if (!TriangleRunner->second) {
    30143768                  TriangleRunner->second = true;
    3015                   Log() << Verbose(3) << "INFO: Connecting triangle is " << *triangle << "." << endl;
     3769                  Log() << Verbose(1) << "INFO: Connecting triangle is " << *triangle << "." << endl;
    30163770                  break;
    30173771                } else {
    3018                   Log() << Verbose(3) << "INFO: Skipping " << *triangle << ", as we have already visited it." << endl;
     3772                  Log() << Verbose(1) << "INFO: Skipping " << *triangle << ", as we have already visited it." << endl;
    30193773                  triangle = NULL;
    30203774                }
     
    30313785            if ((triangle->lines[i] != CurrentLine) && (triangle->lines[i]->ContainsBoundaryPoint(ReferencePoint))) { // not the current line and still containing Point
    30323786              CurrentLine = triangle->lines[i];
    3033               Log() << Verbose(3) << "INFO: Connecting line is " << *CurrentLine << "." << endl;
     3787              Log() << Verbose(1) << "INFO: Connecting line is " << *CurrentLine << "." << endl;
    30343788              break;
    30353789            }
     
    30453799        } while (CurrentLine != StartLine);
    30463800        // last point is missing, as it's on start line
    3047         Log() << Verbose(3) << "INFO: Putting " << *CurrentPoint << " at end of path." << endl;
     3801        Log() << Verbose(1) << "INFO: Putting " << *CurrentPoint << " at end of path." << endl;
    30483802        if (StartLine->GetOtherEndpoint(ReferencePoint)->node != connectedPath->back())
    30493803          connectedPath->push_back(StartLine->GetOtherEndpoint(ReferencePoint)->node);
     
    30513805        ListOfPaths->push_back(connectedPath);
    30523806      } else {
    3053         Log() << Verbose(3) << "INFO: Skipping " << *runner->second << ", as we have already visited it." << endl;
     3807        Log() << Verbose(1) << "INFO: Skipping " << *runner->second << ", as we have already visited it." << endl;
    30543808      }
    30553809    }
     
    30673821 * @return list of the closed paths
    30683822 */
    3069 list<list<TesselPoint*> *> * Tesselation::GetClosedPathsOfConnectedPoints(const TesselPoint* const Point) const
    3070 {
    3071   list<list<TesselPoint*> *> *ListofPaths = GetPathsOfConnectedPoints(Point);
    3072   list<list<TesselPoint*> *> *ListofClosedPaths = new list<list<TesselPoint*> *>;
    3073   list<TesselPoint*> *connectedPath = NULL;
    3074   list<TesselPoint*> *newPath = NULL;
     3823ListOfTesselPointList * Tesselation::GetClosedPathsOfConnectedPoints(const TesselPoint* const Point) const
     3824{
     3825        Info FunctionInfo(__func__);
     3826  list<TesselPointList *> *ListofPaths = GetPathsOfConnectedPoints(Point);
     3827  list<TesselPointList *> *ListofClosedPaths = new list<TesselPointList *>;
     3828  TesselPointList *connectedPath = NULL;
     3829  TesselPointList *newPath = NULL;
    30753830  int count = 0;
    30763831
    30773832
    3078   list<TesselPoint*>::iterator CircleRunner;
    3079   list<TesselPoint*>::iterator CircleStart;
    3080 
    3081   for(list<list<TesselPoint*> *>::iterator ListRunner = ListofPaths->begin(); ListRunner != ListofPaths->end(); ListRunner++) {
     3833  TesselPointList::iterator CircleRunner;
     3834  TesselPointList::iterator CircleStart;
     3835
     3836  for(list<TesselPointList *>::iterator ListRunner = ListofPaths->begin(); ListRunner != ListofPaths->end(); ListRunner++) {
    30823837    connectedPath = *ListRunner;
    30833838
    3084     Log() << Verbose(2) << "INFO: Current path is " << connectedPath << "." << endl;
     3839    Log() << Verbose(1) << "INFO: Current path is " << connectedPath << "." << endl;
    30853840
    30863841    // go through list, look for reappearance of starting Point and count
     
    30883843
    30893844    // go through list, look for reappearance of starting Point and create list
    3090     list<TesselPoint*>::iterator Marker = CircleStart;
     3845    TesselPointList::iterator Marker = CircleStart;
    30913846    for (CircleRunner = CircleStart; CircleRunner != connectedPath->end(); CircleRunner++) {
    30923847      if ((*CircleRunner == *CircleStart) && (CircleRunner != CircleStart)) { // is not the very first point
    30933848        // we have a closed circle from Marker to new Marker
    3094         Log() << Verbose(3) << count+1 << ". closed path consists of: ";
    3095         newPath = new list<TesselPoint*>;
    3096         list<TesselPoint*>::iterator CircleSprinter = Marker;
     3849        Log() << Verbose(1) << count+1 << ". closed path consists of: ";
     3850        newPath = new TesselPointList;
     3851        TesselPointList::iterator CircleSprinter = Marker;
    30973852        for (; CircleSprinter != CircleRunner; CircleSprinter++) {
    30983853          newPath->push_back(*CircleSprinter);
     
    31083863    }
    31093864  }
    3110   Log() << Verbose(3) << "INFO: " << count << " closed additional path(s) have been created." << endl;
     3865  Log() << Verbose(1) << "INFO: " << count << " closed additional path(s) have been created." << endl;
    31113866
    31123867  // delete list of paths
     
    31283883 * \return pointer to allocated list of triangles
    31293884 */
    3130 set<BoundaryTriangleSet*> *Tesselation::GetAllTriangles(const BoundaryPointSet * const Point) const
    3131 {
    3132   set<BoundaryTriangleSet*> *connectedTriangles = new set<BoundaryTriangleSet*>;
     3885TriangleSet *Tesselation::GetAllTriangles(const BoundaryPointSet * const Point) const
     3886{
     3887        Info FunctionInfo(__func__);
     3888        TriangleSet *connectedTriangles = new TriangleSet;
    31333889
    31343890  if (Point == NULL) {
     
    31683924    return 0.;
    31693925  } else
    3170     Log() << Verbose(2) << "Removing point " << *point << " from tesselated boundary ..." << endl;
     3926    Log() << Verbose(0) << "Removing point " << *point << " from tesselated boundary ..." << endl;
    31713927
    31723928  // copy old location for the volume
     
    31793935  }
    31803936
    3181   list<list<TesselPoint*> *> *ListOfClosedPaths = GetClosedPathsOfConnectedPoints(point->node);
    3182   list<TesselPoint*> *connectedPath = NULL;
     3937  list<TesselPointList *> *ListOfClosedPaths = GetClosedPathsOfConnectedPoints(point->node);
     3938  TesselPointList *connectedPath = NULL;
    31833939
    31843940  // gather all triangles
    31853941  for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++)
    31863942    count+=LineRunner->second->triangles.size();
    3187   map<class BoundaryTriangleSet *, int> Candidates;
     3943  TriangleMap Candidates;
    31883944  for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) {
    31893945    line = LineRunner->second;
    31903946    for (TriangleMap::iterator TriangleRunner = line->triangles.begin(); TriangleRunner != line->triangles.end(); TriangleRunner++) {
    31913947      triangle = TriangleRunner->second;
    3192       Candidates.insert( pair<class BoundaryTriangleSet *, int> (triangle, triangle->Nr) );
     3948      Candidates.insert( TrianglePair (triangle->Nr, triangle) );
    31933949    }
    31943950  }
     
    31973953  count=0;
    31983954  NormalVector.Zero();
    3199   for (map<class BoundaryTriangleSet *, int>::iterator Runner = Candidates.begin(); Runner != Candidates.end(); Runner++) {
    3200     Log() << Verbose(3) << "INFO: Removing triangle " << *(Runner->first) << "." << endl;
    3201     NormalVector.SubtractVector(&Runner->first->NormalVector); // has to point inward
    3202     RemoveTesselationTriangle(Runner->first);
     3955  for (TriangleMap::iterator Runner = Candidates.begin(); Runner != Candidates.end(); Runner++) {
     3956    Log() << Verbose(1) << "INFO: Removing triangle " << *(Runner->second) << "." << endl;
     3957    NormalVector.SubtractVector(&Runner->second->NormalVector); // has to point inward
     3958    RemoveTesselationTriangle(Runner->second);
    32033959    count++;
    32043960  }
    32053961  Log() << Verbose(1) << count << " triangles were removed." << endl;
    32063962
    3207   list<list<TesselPoint*> *>::iterator ListAdvance = ListOfClosedPaths->begin();
    3208   list<list<TesselPoint*> *>::iterator ListRunner = ListAdvance;
    3209   map<class BoundaryTriangleSet *, int>::iterator NumberRunner = Candidates.begin();
    3210   list<TesselPoint*>::iterator StartNode, MiddleNode, EndNode;
     3963  list<TesselPointList *>::iterator ListAdvance = ListOfClosedPaths->begin();
     3964  list<TesselPointList *>::iterator ListRunner = ListAdvance;
     3965  TriangleMap::iterator NumberRunner = Candidates.begin();
     3966  TesselPointList::iterator StartNode, MiddleNode, EndNode;
    32113967  double angle;
    32123968  double smallestangle;
     
    32223978
    32233979      // re-create all triangles by going through connected points list
    3224       list<class BoundaryLineSet *> NewLines;
     3980      LineList NewLines;
    32253981      for (;!connectedPath->empty();) {
    32263982        // search middle node with widest angle to next neighbours
     
    32283984        smallestangle = 0.;
    32293985        for (MiddleNode = connectedPath->begin(); MiddleNode != connectedPath->end(); MiddleNode++) {
    3230           Log() << Verbose(3) << "INFO: MiddleNode is " << **MiddleNode << "." << endl;
     3986          Log() << Verbose(1) << "INFO: MiddleNode is " << **MiddleNode << "." << endl;
    32313987          // construct vectors to next and previous neighbour
    32323988          StartNode = MiddleNode;
     
    32564012        MiddleNode = EndNode;
    32574013        if (MiddleNode == connectedPath->end()) {
    3258           Log() << Verbose(1) << "CRITICAL: Could not find a smallest angle!" << endl;
    3259           exit(255);
     4014          eLog() << Verbose(0) << "CRITICAL: Could not find a smallest angle!" << endl;
     4015          performCriticalExit();
    32604016        }
    32614017        StartNode = MiddleNode;
     
    32664022        if (EndNode == connectedPath->end())
    32674023          EndNode = connectedPath->begin();
    3268         Log() << Verbose(4) << "INFO: StartNode is " << **StartNode << "." << endl;
    3269         Log() << Verbose(4) << "INFO: MiddleNode is " << **MiddleNode << "." << endl;
    3270         Log() << Verbose(4) << "INFO: EndNode is " << **EndNode << "." << endl;
    3271         Log() << Verbose(3) << "INFO: Attempting to create triangle " << (*StartNode)->Name << ", " << (*MiddleNode)->Name << " and " << (*EndNode)->Name << "." << endl;
     4024        Log() << Verbose(2) << "INFO: StartNode is " << **StartNode << "." << endl;
     4025        Log() << Verbose(2) << "INFO: MiddleNode is " << **MiddleNode << "." << endl;
     4026        Log() << Verbose(2) << "INFO: EndNode is " << **EndNode << "." << endl;
     4027        Log() << Verbose(1) << "INFO: Attempting to create triangle " << (*StartNode)->Name << ", " << (*MiddleNode)->Name << " and " << (*EndNode)->Name << "." << endl;
    32724028        TriangleCandidates[0] = *StartNode;
    32734029        TriangleCandidates[1] = *MiddleNode;
     
    32754031        triangle = GetPresentTriangle(TriangleCandidates);
    32764032        if (triangle != NULL) {
    3277           eLog() << Verbose(2) << "New triangle already present, skipping!" << endl;
     4033          eLog() << Verbose(0) << "New triangle already present, skipping!" << endl;
    32784034          StartNode++;
    32794035          MiddleNode++;
     
    32874043          continue;
    32884044        }
    3289         Log() << Verbose(5) << "Adding new triangle points."<< endl;
     4045        Log() << Verbose(3) << "Adding new triangle points."<< endl;
    32904046        AddTesselationPoint(*StartNode, 0);
    32914047        AddTesselationPoint(*MiddleNode, 1);
    32924048        AddTesselationPoint(*EndNode, 2);
    3293         Log() << Verbose(5) << "Adding new triangle lines."<< endl;
     4049        Log() << Verbose(3) << "Adding new triangle lines."<< endl;
    32944050        AddTesselationLine(TPS[0], TPS[1], 0);
    32954051        AddTesselationLine(TPS[0], TPS[2], 1);
     
    33064062        // prepare nodes for next triangle
    33074063        StartNode = EndNode;
    3308         Log() << Verbose(4) << "Removing " << **MiddleNode << " from closed path, remaining points: " << connectedPath->size() << "." << endl;
     4064        Log() << Verbose(2) << "Removing " << **MiddleNode << " from closed path, remaining points: " << connectedPath->size() << "." << endl;
    33094065        connectedPath->remove(*MiddleNode); // remove the middle node (it is surrounded by triangles)
    33104066        if (connectedPath->size() == 2) { // we are done
     
    33134069          break;
    33144070        } else if (connectedPath->size() < 2) { // something's gone wrong!
    3315           Log() << Verbose(1) << "CRITICAL: There are only two endpoints left!" << endl;
    3316           exit(255);
     4071          eLog() << Verbose(0) << "CRITICAL: There are only two endpoints left!" << endl;
     4072          performCriticalExit();
    33174073        } else {
    33184074          MiddleNode = StartNode;
     
    33284084      // maximize the inner lines (we preferentially created lines with a huge angle, which is for the tesselation not wanted though useful for the closing)
    33294085      if (NewLines.size() > 1) {
    3330         list<class BoundaryLineSet *>::iterator Candidate;
     4086        LineList::iterator Candidate;
    33314087        class BoundaryLineSet *OtherBase = NULL;
    33324088        double tmp, maxgain;
    33334089        do {
    33344090          maxgain = 0;
    3335           for(list<class BoundaryLineSet *>::iterator Runner = NewLines.begin(); Runner != NewLines.end(); Runner++) {
     4091          for(LineList::iterator Runner = NewLines.begin(); Runner != NewLines.end(); Runner++) {
    33364092            tmp = PickFarthestofTwoBaselines(*Runner);
    33374093            if (maxgain < tmp) {
     
    33424098          if (maxgain != 0) {
    33434099            volume += maxgain;
    3344             Log() << Verbose(3) << "Flipping baseline with highest volume" << **Candidate << "." << endl;
     4100            Log() << Verbose(1) << "Flipping baseline with highest volume" << **Candidate << "." << endl;
    33454101            OtherBase = FlipBaseline(*Candidate);
    33464102            NewLines.erase(Candidate);
     
    33534109      delete(connectedPath);
    33544110    }
    3355     Log() << Verbose(1) << count << " triangles were created." << endl;
     4111    Log() << Verbose(0) << count << " triangles were created." << endl;
    33564112  } else {
    33574113    while (!ListOfClosedPaths->empty()) {
     
    33614117      delete(connectedPath);
    33624118    }
    3363     Log() << Verbose(1) << "No need to create any triangles." << endl;
     4119    Log() << Verbose(0) << "No need to create any triangles." << endl;
    33644120  }
    33654121  delete(ListOfClosedPaths);
    33664122
    3367   Log() << Verbose(1) << "Removed volume is " << volume << "." << endl;
     4123  Log() << Verbose(0) << "Removed volume is " << volume << "." << endl;
    33684124
    33694125  return volume;
     
    33754131 * Finds triangles belonging to the three provided points.
    33764132 *
    3377  * @param *Points[3] list, is expected to contain three points
     4133 * @param *Points[3] list, is expected to contain three points (NULL means wildcard)
    33784134 *
    33794135 * @return triangles which belong to the provided points, will be empty if there are none,
    33804136 *         will usually be one, in case of degeneration, there will be two
    33814137 */
    3382 list<BoundaryTriangleSet*> *Tesselation::FindTriangles(const TesselPoint* const Points[3]) const
    3383 {
    3384   list<BoundaryTriangleSet*> *result = new list<BoundaryTriangleSet*>;
     4138TriangleList *Tesselation::FindTriangles(const TesselPoint* const Points[3]) const
     4139{
     4140        Info FunctionInfo(__func__);
     4141        TriangleList *result = new TriangleList;
    33854142  LineMap::const_iterator FindLine;
    33864143  TriangleMap::const_iterator FindTriangle;
    33874144  class BoundaryPointSet *TrianglePoints[3];
     4145  size_t NoOfWildcards = 0;
    33884146
    33894147  for (int i = 0; i < 3; i++) {
    3390     PointMap::const_iterator FindPoint = PointsOnBoundary.find(Points[i]->nr);
    3391     if (FindPoint != PointsOnBoundary.end()) {
    3392       TrianglePoints[i] = FindPoint->second;
     4148    if (Points[i] == NULL) {
     4149      NoOfWildcards++;
     4150      TrianglePoints[i] = NULL;
    33934151    } else {
    3394       TrianglePoints[i] = NULL;
    3395     }
    3396   }
    3397 
    3398   // checks lines between the points in the Points for their adjacent triangles
    3399   for (int i = 0; i < 3; i++) {
    3400     if (TrianglePoints[i] != NULL) {
    3401       for (int j = i+1; j < 3; j++) {
    3402         if (TrianglePoints[j] != NULL) {
    3403           for (FindLine = TrianglePoints[i]->lines.find(TrianglePoints[j]->node->nr); // is a multimap!
    3404               (FindLine != TrianglePoints[i]->lines.end()) && (FindLine->first == TrianglePoints[j]->node->nr);
    3405               FindLine++) {
    3406             for (FindTriangle = FindLine->second->triangles.begin();
    3407                 FindTriangle != FindLine->second->triangles.end();
    3408                 FindTriangle++) {
    3409               if (FindTriangle->second->IsPresentTupel(TrianglePoints)) {
    3410                 result->push_back(FindTriangle->second);
     4152      PointMap::const_iterator FindPoint = PointsOnBoundary.find(Points[i]->nr);
     4153      if (FindPoint != PointsOnBoundary.end()) {
     4154        TrianglePoints[i] = FindPoint->second;
     4155      } else {
     4156        TrianglePoints[i] = NULL;
     4157      }
     4158    }
     4159  }
     4160
     4161  switch (NoOfWildcards) {
     4162    case 0: // checks lines between the points in the Points for their adjacent triangles
     4163      for (int i = 0; i < 3; i++) {
     4164        if (TrianglePoints[i] != NULL) {
     4165          for (int j = i+1; j < 3; j++) {
     4166            if (TrianglePoints[j] != NULL) {
     4167              for (FindLine = TrianglePoints[i]->lines.find(TrianglePoints[j]->node->nr); // is a multimap!
     4168                  (FindLine != TrianglePoints[i]->lines.end()) && (FindLine->first == TrianglePoints[j]->node->nr);
     4169                  FindLine++) {
     4170                for (FindTriangle = FindLine->second->triangles.begin();
     4171                    FindTriangle != FindLine->second->triangles.end();
     4172                    FindTriangle++) {
     4173                  if (FindTriangle->second->IsPresentTupel(TrianglePoints)) {
     4174                    result->push_back(FindTriangle->second);
     4175                  }
     4176                }
    34114177              }
     4178              // Is it sufficient to consider one of the triangle lines for this.
     4179              return result;
    34124180            }
    34134181          }
    3414           // Is it sufficient to consider one of the triangle lines for this.
    3415           return result;
    34164182        }
    34174183      }
    3418     }
     4184      break;
     4185    case 1: // copy all triangles of the respective line
     4186    {
     4187      int i=0;
     4188      for (; i < 3; i++)
     4189        if (TrianglePoints[i] == NULL)
     4190          break;
     4191      for (FindLine = TrianglePoints[(i+1)%3]->lines.find(TrianglePoints[(i+2)%3]->node->nr); // is a multimap!
     4192          (FindLine != TrianglePoints[(i+1)%3]->lines.end()) && (FindLine->first == TrianglePoints[(i+2)%3]->node->nr);
     4193          FindLine++) {
     4194        for (FindTriangle = FindLine->second->triangles.begin();
     4195            FindTriangle != FindLine->second->triangles.end();
     4196            FindTriangle++) {
     4197          if (FindTriangle->second->IsPresentTupel(TrianglePoints)) {
     4198            result->push_back(FindTriangle->second);
     4199          }
     4200        }
     4201      }
     4202      break;
     4203    }
     4204    case 2: // copy all triangles of the respective point
     4205    {
     4206      int i=0;
     4207      for (; i < 3; i++)
     4208        if (TrianglePoints[i] != NULL)
     4209          break;
     4210      for (LineMap::const_iterator line = TrianglePoints[i]->lines.begin(); line != TrianglePoints[i]->lines.end(); line++)
     4211        for (TriangleMap::const_iterator triangle = line->second->triangles.begin(); triangle != line->second->triangles.end(); triangle++)
     4212          result->push_back(triangle->second);
     4213      result->sort();
     4214      result->unique();
     4215      break;
     4216    }
     4217    case 3: // copy all triangles
     4218    {
     4219      for (TriangleMap::const_iterator triangle = TrianglesOnBoundary.begin(); triangle != TrianglesOnBoundary.end(); triangle++)
     4220        result->push_back(triangle->second);
     4221      break;
     4222    }
     4223    default:
     4224      eLog() << Verbose(0) << "Number of wildcards is greater than 3, cannot happen!" << endl;
     4225      performCriticalExit();
     4226      break;
    34194227  }
    34204228
    34214229  return result;
    34224230}
     4231
     4232struct BoundaryLineSetCompare {
     4233  bool operator() (const BoundaryLineSet * const a, const BoundaryLineSet * const b) {
     4234    int lowerNra = -1;
     4235    int lowerNrb = -1;
     4236
     4237    if (a->endpoints[0] < a->endpoints[1])
     4238      lowerNra = 0;
     4239    else
     4240      lowerNra = 1;
     4241
     4242    if (b->endpoints[0] < b->endpoints[1])
     4243      lowerNrb = 0;
     4244    else
     4245      lowerNrb = 1;
     4246
     4247    if (a->endpoints[lowerNra] < b->endpoints[lowerNrb])
     4248      return true;
     4249    else if (a->endpoints[lowerNra] > b->endpoints[lowerNrb])
     4250      return false;
     4251    else {  // both lower-numbered endpoints are the same ...
     4252     if (a->endpoints[(lowerNra+1)%2] < b->endpoints[(lowerNrb+1)%2])
     4253       return true;
     4254     else if (a->endpoints[(lowerNra+1)%2] > b->endpoints[(lowerNrb+1)%2])
     4255       return false;
     4256    }
     4257    return false;
     4258  };
     4259};
     4260
     4261#define UniqueLines set < class BoundaryLineSet *, BoundaryLineSetCompare>
    34234262
    34244263/**
     
    34284267 *         in the list, once as key and once as value
    34294268 */
    3430 map<int, int> * Tesselation::FindAllDegeneratedLines()
    3431 {
    3432   map<int, class BoundaryLineSet *> AllLines;
    3433   map<int, int> * DegeneratedLines = new map<int, int>;
     4269IndexToIndex * Tesselation::FindAllDegeneratedLines()
     4270{
     4271        Info FunctionInfo(__func__);
     4272        UniqueLines AllLines;
     4273  IndexToIndex * DegeneratedLines = new IndexToIndex;
    34344274
    34354275  // sanity check
    34364276  if (LinesOnBoundary.empty()) {
    3437     Log() << Verbose(1) << "Warning: FindAllDegeneratedTriangles() was called without any tesselation structure.";
     4277    eLog() << Verbose(2) << "FindAllDegeneratedTriangles() was called without any tesselation structure.";
    34384278    return DegeneratedLines;
    34394279  }
    34404280
    34414281  LineMap::iterator LineRunner1;
    3442   pair<LineMap::iterator, bool> tester;
     4282  pair< UniqueLines::iterator, bool> tester;
    34434283  for (LineRunner1 = LinesOnBoundary.begin(); LineRunner1 != LinesOnBoundary.end(); ++LineRunner1) {
    3444     tester = AllLines.insert( pair<int,BoundaryLineSet *> (LineRunner1->second->endpoints[0]->Nr, LineRunner1->second) );
    3445     if ((!tester.second) && (tester.first->second->endpoints[1]->Nr == LineRunner1->second->endpoints[1]->Nr)) { // found degenerated line
    3446       DegeneratedLines->insert ( pair<int, int> (LineRunner1->second->Nr, tester.first->second->Nr) );
    3447       DegeneratedLines->insert ( pair<int, int> (tester.first->second->Nr, LineRunner1->second->Nr) );
     4284    tester = AllLines.insert( LineRunner1->second );
     4285    if (!tester.second) { // found degenerated line
     4286      DegeneratedLines->insert ( pair<int, int> (LineRunner1->second->Nr, (*tester.first)->Nr) );
     4287      DegeneratedLines->insert ( pair<int, int> ((*tester.first)->Nr, LineRunner1->second->Nr) );
    34484288    }
    34494289  }
     
    34514291  AllLines.clear();
    34524292
    3453   Log() << Verbose(1) << "FindAllDegeneratedLines() found " << DegeneratedLines->size() << " lines." << endl;
    3454   map<int,int>::iterator it;
    3455   for (it = DegeneratedLines->begin(); it != DegeneratedLines->end(); it++)
    3456       Log() << Verbose(2) << (*it).first << " => " << (*it).second << endl;
     4293  Log() << Verbose(0) << "FindAllDegeneratedLines() found " << DegeneratedLines->size() << " lines." << endl;
     4294  IndexToIndex::iterator it;
     4295  for (it = DegeneratedLines->begin(); it != DegeneratedLines->end(); it++) {
     4296    const LineMap::const_iterator Line1 = LinesOnBoundary.find((*it).first);
     4297    const LineMap::const_iterator Line2 = LinesOnBoundary.find((*it).second);
     4298    if (Line1 != LinesOnBoundary.end() && Line2 != LinesOnBoundary.end())
     4299      Log() << Verbose(0) << *Line1->second << " => " << *Line2->second << endl;
     4300    else
     4301      eLog() << Verbose(1) << "Either " << (*it).first << " or " << (*it).second << " are not in LinesOnBoundary!" << endl;
     4302  }
    34574303
    34584304  return DegeneratedLines;
     
    34654311 *         in the list, once as key and once as value
    34664312 */
    3467 map<int, int> * Tesselation::FindAllDegeneratedTriangles()
    3468 {
    3469   map<int, int> * DegeneratedLines = FindAllDegeneratedLines();
    3470   map<int, int> * DegeneratedTriangles = new map<int, int>;
     4313IndexToIndex * Tesselation::FindAllDegeneratedTriangles()
     4314{
     4315        Info FunctionInfo(__func__);
     4316  IndexToIndex * DegeneratedLines = FindAllDegeneratedLines();
     4317  IndexToIndex * DegeneratedTriangles = new IndexToIndex;
    34714318
    34724319  TriangleMap::iterator TriangleRunner1, TriangleRunner2;
     
    34744321  class BoundaryLineSet *line1 = NULL, *line2 = NULL;
    34754322
    3476   for (map<int, int>::iterator LineRunner = DegeneratedLines->begin(); LineRunner != DegeneratedLines->end(); ++LineRunner) {
     4323  for (IndexToIndex::iterator LineRunner = DegeneratedLines->begin(); LineRunner != DegeneratedLines->end(); ++LineRunner) {
    34774324    // run over both lines' triangles
    34784325    Liner = LinesOnBoundary.find(LineRunner->first);
     
    34944341  delete(DegeneratedLines);
    34954342
    3496   Log() << Verbose(1) << "FindAllDegeneratedTriangles() found " << DegeneratedTriangles->size() << " triangles:" << endl;
    3497   map<int,int>::iterator it;
     4343  Log() << Verbose(0) << "FindAllDegeneratedTriangles() found " << DegeneratedTriangles->size() << " triangles:" << endl;
     4344  IndexToIndex::iterator it;
    34984345  for (it = DegeneratedTriangles->begin(); it != DegeneratedTriangles->end(); it++)
    3499       Log() << Verbose(2) << (*it).first << " => " << (*it).second << endl;
     4346      Log() << Verbose(0) << (*it).first << " => " << (*it).second << endl;
    35004347
    35014348  return DegeneratedTriangles;
     
    35084355void Tesselation::RemoveDegeneratedTriangles()
    35094356{
    3510   map<int, int> * DegeneratedTriangles = FindAllDegeneratedTriangles();
     4357        Info FunctionInfo(__func__);
     4358  IndexToIndex * DegeneratedTriangles = FindAllDegeneratedTriangles();
    35114359  TriangleMap::iterator finder;
    35124360  BoundaryTriangleSet *triangle = NULL, *partnerTriangle = NULL;
    35134361  int count  = 0;
    35144362
    3515   Log() << Verbose(1) << "Begin of RemoveDegeneratedTriangles" << endl;
    3516 
    3517   for (map<int, int>::iterator TriangleKeyRunner = DegeneratedTriangles->begin();
     4363  for (IndexToIndex::iterator TriangleKeyRunner = DegeneratedTriangles->begin();
    35184364    TriangleKeyRunner != DegeneratedTriangles->end(); ++TriangleKeyRunner
    35194365  ) {
     
    35724418      // erase the pair
    35734419      count += (int) DegeneratedTriangles->erase(triangle->Nr);
    3574       Log() << Verbose(1) << "RemoveDegeneratedTriangles() removes triangle " << *triangle << "." << endl;
     4420      Log() << Verbose(0) << "RemoveDegeneratedTriangles() removes triangle " << *triangle << "." << endl;
    35754421      RemoveTesselationTriangle(triangle);
    35764422      count += (int) DegeneratedTriangles->erase(partnerTriangle->Nr);
    3577       Log() << Verbose(1) << "RemoveDegeneratedTriangles() removes triangle " << *partnerTriangle << "." << endl;
     4423      Log() << Verbose(0) << "RemoveDegeneratedTriangles() removes triangle " << *partnerTriangle << "." << endl;
    35784424      RemoveTesselationTriangle(partnerTriangle);
    35794425    } else {
    3580       Log() << Verbose(1) << "RemoveDegeneratedTriangles() does not remove triangle " << *triangle
     4426      Log() << Verbose(0) << "RemoveDegeneratedTriangles() does not remove triangle " << *triangle
    35814427        << " and its partner " << *partnerTriangle << " because it is essential for at"
    35824428        << " least one of the endpoints to be kept in the tesselation structure." << endl;
     
    35844430  }
    35854431  delete(DegeneratedTriangles);
    3586 
    3587   Log() << Verbose(1) << "RemoveDegeneratedTriangles() removed " << count << " triangles:" << endl;
    3588   Log() << Verbose(1) << "End of RemoveDegeneratedTriangles" << endl;
     4432  if (count > 0)
     4433    LastTriangle = NULL;
     4434
     4435  Log() << Verbose(0) << "RemoveDegeneratedTriangles() removed " << count << " triangles:" << endl;
    35894436}
    35904437
     
    35994446void Tesselation::AddBoundaryPointByDegeneratedTriangle(class TesselPoint *point, LinkedCell *LC)
    36004447{
    3601   Log() << Verbose(2) << "Begin of AddBoundaryPointByDegeneratedTriangle" << endl;
    3602 
     4448        Info FunctionInfo(__func__);
    36034449  // find nearest boundary point
    36044450  class TesselPoint *BackupPoint = NULL;
    3605   class TesselPoint *NearestPoint = FindClosestPoint(point->node, BackupPoint, LC);
     4451  class TesselPoint *NearestPoint = FindClosestTesselPoint(point->node, BackupPoint, LC);
    36064452  class BoundaryPointSet *NearestBoundaryPoint = NULL;
    36074453  PointMap::iterator PointRunner;
     
    36164462    return;
    36174463  }
    3618   Log() << Verbose(2) << "Nearest point on boundary is " << NearestPoint->Name << "." << endl;
     4464  Log() << Verbose(0) << "Nearest point on boundary is " << NearestPoint->Name << "." << endl;
    36194465
    36204466  // go through its lines and find the best one to split
     
    36494495
    36504496  // create new triangle to connect point (connects automatically with the missing spot of the chosen line)
    3651   Log() << Verbose(5) << "Adding new triangle points."<< endl;
     4497  Log() << Verbose(2) << "Adding new triangle points."<< endl;
    36524498  AddTesselationPoint((BestLine->endpoints[0]->node), 0);
    36534499  AddTesselationPoint((BestLine->endpoints[1]->node), 1);
    36544500  AddTesselationPoint(point, 2);
    3655   Log() << Verbose(5) << "Adding new triangle lines."<< endl;
     4501  Log() << Verbose(2) << "Adding new triangle lines."<< endl;
    36564502  AddTesselationLine(TPS[0], TPS[1], 0);
    36574503  AddTesselationLine(TPS[0], TPS[2], 1);
     
    36604506  BTS->GetNormalVector(TempTriangle->NormalVector);
    36614507  BTS->NormalVector.Scale(-1.);
    3662   Log() << Verbose(3) << "INFO: NormalVector of new triangle is " << BTS->NormalVector << "." << endl;
     4508  Log() << Verbose(1) << "INFO: NormalVector of new triangle is " << BTS->NormalVector << "." << endl;
    36634509  AddTesselationTriangle();
    36644510
    36654511  // create other side of this triangle and close both new sides of the first created triangle
    3666   Log() << Verbose(5) << "Adding new triangle points."<< endl;
     4512  Log() << Verbose(2) << "Adding new triangle points."<< endl;
    36674513  AddTesselationPoint((BestLine->endpoints[0]->node), 0);
    36684514  AddTesselationPoint((BestLine->endpoints[1]->node), 1);
    36694515  AddTesselationPoint(point, 2);
    3670   Log() << Verbose(5) << "Adding new triangle lines."<< endl;
     4516  Log() << Verbose(2) << "Adding new triangle lines."<< endl;
    36714517  AddTesselationLine(TPS[0], TPS[1], 0);
    36724518  AddTesselationLine(TPS[0], TPS[2], 1);
     
    36744520  BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
    36754521  BTS->GetNormalVector(TempTriangle->NormalVector);
    3676   Log() << Verbose(3) << "INFO: NormalVector of other new triangle is " << BTS->NormalVector << "." << endl;
     4522  Log() << Verbose(1) << "INFO: NormalVector of other new triangle is " << BTS->NormalVector << "." << endl;
    36774523  AddTesselationTriangle();
    36784524
     
    36814527    if ((BTS->lines[i]->ContainsBoundaryPoint(BestLine->endpoints[0])) && (BTS->lines[i]->ContainsBoundaryPoint(BestLine->endpoints[1]))) {
    36824528      if (BestLine == BTS->lines[i]){
    3683         Log() << Verbose(1) << "CRITICAL: BestLine is same as found line, something's wrong here!" << endl;
    3684         exit(255);
     4529        eLog() << Verbose(0) << "BestLine is same as found line, something's wrong here!" << endl;
     4530        performCriticalExit();
    36854531      }
    36864532      BTS->lines[i]->triangles.insert( pair<int, class BoundaryTriangleSet *> (TempTriangle->Nr, TempTriangle) );
     
    36894535    }
    36904536  }
    3691 
    3692   // exit
    3693   Log() << Verbose(2) << "End of AddBoundaryPointByDegeneratedTriangle" << endl;
    36944537};
    36954538
     
    37014544void Tesselation::Output(const char *filename, const PointCloud * const cloud)
    37024545{
     4546        Info FunctionInfo(__func__);
    37034547  ofstream *tempstream = NULL;
    37044548  string NameofTempFile;
     
    37134557      NameofTempFile.erase(npos, 1);
    37144558      NameofTempFile.append(TecplotSuffix);
    3715       Log() << Verbose(1) << "Writing temporary non convex hull to file " << NameofTempFile << ".\n";
     4559      Log() << Verbose(0) << "Writing temporary non convex hull to file " << NameofTempFile << ".\n";
    37164560      tempstream = new ofstream(NameofTempFile.c_str(), ios::trunc);
    37174561      WriteTecplotFile(tempstream, this, cloud, TriangleFilesWritten);
     
    37274571      NameofTempFile.erase(npos, 1);
    37284572      NameofTempFile.append(Raster3DSuffix);
    3729       Log() << Verbose(1) << "Writing temporary non convex hull to file " << NameofTempFile << ".\n";
     4573      Log() << Verbose(0) << "Writing temporary non convex hull to file " << NameofTempFile << ".\n";
    37304574      tempstream = new ofstream(NameofTempFile.c_str(), ios::trunc);
    37314575      WriteRaster3dFile(tempstream, this, cloud);
     
    37394583    TriangleFilesWritten++;
    37404584};
     4585
     4586struct BoundaryPolygonSetCompare {
     4587  bool operator()(const BoundaryPolygonSet * s1, const BoundaryPolygonSet * s2) const {
     4588    if (s1->endpoints.size() < s2->endpoints.size())
     4589      return true;
     4590    else if (s1->endpoints.size() > s2->endpoints.size())
     4591      return false;
     4592    else { // equality of number of endpoints
     4593      PointSet::const_iterator Walker1 = s1->endpoints.begin();
     4594      PointSet::const_iterator Walker2 = s2->endpoints.begin();
     4595      while ((Walker1 != s1->endpoints.end()) || (Walker2 != s2->endpoints.end())) {
     4596        if ((*Walker1)->Nr < (*Walker2)->Nr)
     4597          return true;
     4598        else if ((*Walker1)->Nr > (*Walker2)->Nr)
     4599          return false;
     4600        Walker1++;
     4601        Walker2++;
     4602      }
     4603      return false;
     4604    }
     4605  }
     4606};
     4607
     4608#define UniquePolygonSet set < BoundaryPolygonSet *, BoundaryPolygonSetCompare>
     4609
     4610/** Finds all degenerated polygons and calls ReTesselateDegeneratedPolygon()/
     4611 * \return number of polygons found
     4612 */
     4613int Tesselation::CorrectAllDegeneratedPolygons()
     4614{
     4615  Info FunctionInfo(__func__);
     4616
     4617  /// 2. Go through all BoundaryPointSet's, check their triangles' NormalVector
     4618  IndexToIndex *DegeneratedTriangles = FindAllDegeneratedTriangles();
     4619  set < BoundaryPointSet *> EndpointCandidateList;
     4620  pair < set < BoundaryPointSet *>::iterator, bool > InsertionTester;
     4621  pair < map < int, Vector *>::iterator, bool > TriangleInsertionTester;
     4622  for (PointMap::const_iterator Runner = PointsOnBoundary.begin(); Runner != PointsOnBoundary.end(); Runner++) {
     4623    Log() << Verbose(0) << "Current point is " << *Runner->second << "." << endl;
     4624    map < int, Vector *> TriangleVectors;
     4625    // gather all NormalVectors
     4626    Log() << Verbose(1) << "Gathering triangles ..." << endl;
     4627    for (LineMap::const_iterator LineRunner = (Runner->second)->lines.begin(); LineRunner != (Runner->second)->lines.end(); LineRunner++)
     4628      for (TriangleMap::const_iterator TriangleRunner = (LineRunner->second)->triangles.begin(); TriangleRunner != (LineRunner->second)->triangles.end(); TriangleRunner++) {
     4629        if (DegeneratedTriangles->find(TriangleRunner->second->Nr) == DegeneratedTriangles->end()) {
     4630          TriangleInsertionTester = TriangleVectors.insert( pair< int, Vector *> ((TriangleRunner->second)->Nr, &((TriangleRunner->second)->NormalVector)) );
     4631          if (TriangleInsertionTester.second)
     4632            Log() << Verbose(1) << " Adding triangle " << *(TriangleRunner->second) << " to triangles to check-list." << endl;
     4633        } else {
     4634          Log() << Verbose(1) << " NOT adding triangle " << *(TriangleRunner->second) << " as it's a simply degenerated one." << endl;
     4635        }
     4636      }
     4637    // check whether there are two that are parallel
     4638    Log() << Verbose(1) << "Finding two parallel triangles ..." << endl;
     4639    for (map < int, Vector *>::iterator VectorWalker = TriangleVectors.begin(); VectorWalker != TriangleVectors.end(); VectorWalker++)
     4640      for (map < int, Vector *>::iterator VectorRunner = VectorWalker; VectorRunner != TriangleVectors.end(); VectorRunner++)
     4641        if (VectorWalker != VectorRunner) { // skip equals
     4642          const double SCP = VectorWalker->second->ScalarProduct(VectorRunner->second);  // ScalarProduct should result in -1. for degenerated triangles
     4643          Log() << Verbose(1) << "Checking " << *VectorWalker->second<< " against " << *VectorRunner->second << ": " << SCP << endl;
     4644          if (fabs(SCP + 1.) < ParallelEpsilon) {
     4645            InsertionTester = EndpointCandidateList.insert((Runner->second));
     4646            if (InsertionTester.second)
     4647              Log() << Verbose(0) << " Adding " << *Runner->second << " to endpoint candidate list." << endl;
     4648            // and break out of both loops
     4649            VectorWalker = TriangleVectors.end();
     4650            VectorRunner = TriangleVectors.end();
     4651            break;
     4652          }
     4653        }
     4654  }
     4655
     4656  /// 3. Find connected endpoint candidates and put them into a polygon
     4657  UniquePolygonSet ListofDegeneratedPolygons;
     4658  BoundaryPointSet *Walker = NULL;
     4659  BoundaryPointSet *OtherWalker = NULL;
     4660  BoundaryPolygonSet *Current = NULL;
     4661  stack <BoundaryPointSet*> ToCheckConnecteds;
     4662  while (!EndpointCandidateList.empty()) {
     4663    Walker = *(EndpointCandidateList.begin());
     4664    if (Current == NULL) {  // create a new polygon with current candidate
     4665      Log() << Verbose(0) << "Starting new polygon set at point " << *Walker << endl;
     4666      Current = new BoundaryPolygonSet;
     4667      Current->endpoints.insert(Walker);
     4668      EndpointCandidateList.erase(Walker);
     4669      ToCheckConnecteds.push(Walker);
     4670    }
     4671
     4672    // go through to-check stack
     4673    while (!ToCheckConnecteds.empty()) {
     4674      Walker = ToCheckConnecteds.top(); // fetch ...
     4675      ToCheckConnecteds.pop(); // ... and remove
     4676      for (LineMap::const_iterator LineWalker = Walker->lines.begin(); LineWalker != Walker->lines.end(); LineWalker++) {
     4677        OtherWalker = (LineWalker->second)->GetOtherEndpoint(Walker);
     4678        Log() << Verbose(1) << "Checking " << *OtherWalker << endl;
     4679        set < BoundaryPointSet *>::iterator Finder = EndpointCandidateList.find(OtherWalker);
     4680        if (Finder != EndpointCandidateList.end()) {  // found a connected partner
     4681          Log() << Verbose(1) << " Adding to polygon." << endl;
     4682          Current->endpoints.insert(OtherWalker);
     4683          EndpointCandidateList.erase(Finder);  // remove from candidates
     4684          ToCheckConnecteds.push(OtherWalker);  // but check its partners too
     4685        } else {
     4686          Log() << Verbose(1) << " is not connected to " << *Walker << endl;
     4687        }
     4688      }
     4689    }
     4690
     4691    Log() << Verbose(0) << "Final polygon is " << *Current << endl;
     4692    ListofDegeneratedPolygons.insert(Current);
     4693    Current = NULL;
     4694  }
     4695
     4696  const int counter = ListofDegeneratedPolygons.size();
     4697
     4698  Log() << Verbose(0) << "The following " << counter << " degenerated polygons have been found: " << endl;
     4699  for (UniquePolygonSet::iterator PolygonRunner = ListofDegeneratedPolygons.begin(); PolygonRunner != ListofDegeneratedPolygons.end(); PolygonRunner++)
     4700    Log() << Verbose(0) << " " << **PolygonRunner << endl;
     4701
     4702  /// 4. Go through all these degenerated polygons
     4703  for (UniquePolygonSet::iterator PolygonRunner = ListofDegeneratedPolygons.begin(); PolygonRunner != ListofDegeneratedPolygons.end(); PolygonRunner++) {
     4704    stack <int> TriangleNrs;
     4705    Vector NormalVector;
     4706    /// 4a. Gather all triangles of this polygon
     4707    TriangleSet *T = (*PolygonRunner)->GetAllContainedTrianglesFromEndpoints();
     4708
     4709    // check whether number is bigger than 2, otherwise it's just a simply degenerated one and nothing to do.
     4710    if (T->size() == 2) {
     4711      Log() << Verbose(1) << " Skipping degenerated polygon, is just a (already simply degenerated) triangle." << endl;
     4712      delete(T);
     4713      continue;
     4714    }
     4715
     4716    // check whether number is even
     4717    // If this case occurs, we have to think about it!
     4718    // The Problem is probably due to two degenerated polygons being connected by a bridging, non-degenerated polygon, as somehow one node has
     4719    // connections to either polygon ...
     4720    if (T->size() % 2 != 0) {
     4721      eLog() << Verbose(0) << " degenerated polygon contains an odd number of triangles, probably contains bridging non-degenerated ones, too!" << endl;
     4722      performCriticalExit();
     4723    }
     4724
     4725    TriangleSet::iterator TriangleWalker = T->begin();  // is the inner iterator
     4726    /// 4a. Get NormalVector for one side (this is "front")
     4727    NormalVector.CopyVector(&(*TriangleWalker)->NormalVector);
     4728    Log() << Verbose(1) << "\"front\" defining triangle is " << **TriangleWalker << " and Normal vector of \"front\" side is " << NormalVector << endl;
     4729    TriangleWalker++;
     4730    TriangleSet::iterator TriangleSprinter = TriangleWalker; // is the inner advanced iterator
     4731    /// 4b. Remove all triangles whose NormalVector is in opposite direction (i.e. "back")
     4732    BoundaryTriangleSet *triangle = NULL;
     4733    while (TriangleSprinter != T->end()) {
     4734      TriangleWalker = TriangleSprinter;
     4735      triangle = *TriangleWalker;
     4736      TriangleSprinter++;
     4737      Log() << Verbose(1) << "Current triangle to test for removal: " << *triangle << endl;
     4738      if (triangle->NormalVector.ScalarProduct(&NormalVector) < 0) { // if from other side, then delete and remove from list
     4739        Log() << Verbose(1) << " Removing ... " << endl;
     4740        TriangleNrs.push(triangle->Nr);
     4741        T->erase(TriangleWalker);
     4742        RemoveTesselationTriangle(triangle);
     4743      } else
     4744        Log() << Verbose(1) << " Keeping ... " << endl;
     4745    }
     4746    /// 4c. Copy all "front" triangles but with inverse NormalVector
     4747    TriangleWalker = T->begin();
     4748    while (TriangleWalker != T->end()) {  // go through all front triangles
     4749      Log() << Verbose(1) << " Re-creating triangle " << **TriangleWalker << " with NormalVector " << (*TriangleWalker)->NormalVector << endl;
     4750      for (int i = 0; i < 3; i++)
     4751        AddTesselationPoint((*TriangleWalker)->endpoints[i]->node, i);
     4752      AddTesselationLine(TPS[0], TPS[1], 0);
     4753      AddTesselationLine(TPS[0], TPS[2], 1);
     4754      AddTesselationLine(TPS[1], TPS[2], 2);
     4755      if (TriangleNrs.empty())
     4756        eLog() << Verbose(0) << "No more free triangle numbers!" << endl;
     4757      BTS = new BoundaryTriangleSet(BLS, TriangleNrs.top()); // copy triangle ...
     4758      AddTesselationTriangle(); // ... and add
     4759      TriangleNrs.pop();
     4760      BTS->NormalVector.CopyVector(&(*TriangleWalker)->NormalVector);
     4761      BTS->NormalVector.Scale(-1.);
     4762      TriangleWalker++;
     4763    }
     4764    if (!TriangleNrs.empty()) {
     4765      eLog() << Verbose(0) << "There have been less triangles created than removed!" << endl;
     4766    }
     4767    delete(T);  // remove the triangleset
     4768  }
     4769
     4770  IndexToIndex * SimplyDegeneratedTriangles = FindAllDegeneratedTriangles();
     4771  Log() << Verbose(0) << "Final list of simply degenerated triangles found, containing " << SimplyDegeneratedTriangles->size() << " triangles:" << endl;
     4772  IndexToIndex::iterator it;
     4773  for (it = SimplyDegeneratedTriangles->begin(); it != SimplyDegeneratedTriangles->end(); it++)
     4774      Log() << Verbose(0) << (*it).first << " => " << (*it).second << endl;
     4775  delete(SimplyDegeneratedTriangles);
     4776
     4777  /// 5. exit
     4778  UniquePolygonSet::iterator PolygonRunner;
     4779  while (!ListofDegeneratedPolygons.empty()) {
     4780    PolygonRunner = ListofDegeneratedPolygons.begin();
     4781    delete(*PolygonRunner);
     4782    ListofDegeneratedPolygons.erase(PolygonRunner);
     4783  }
     4784
     4785  return counter;
     4786};
  • TabularUnified src/tesselation.hpp

    r9fe36b rb8d1aeb  
    2323#include <list>
    2424#include <set>
     25#include <stack>
    2526
    2627#include "atom_particleinfo.hpp"
     
    4748#define VRMLSUffix ".wrl"
    4849
     50#define ParallelEpsilon 1e-3
     51
    4952// ======================================================= some template functions =========================================
    5053
     54#define IndexToIndex map <int, int>
     55
    5156#define PointMap map < int, class BoundaryPointSet * >
     57#define PointSet set < class BoundaryPointSet * >
     58#define PointList list < class BoundaryPointSet * >
    5259#define PointPair pair < int, class BoundaryPointSet * >
    5360#define PointTestPair pair < PointMap::iterator, bool >
     61
    5462#define CandidateList list <class CandidateForTesselation *>
     63#define CandidateMap map <class BoundaryLineSet *, class CandidateForTesselation *>
    5564
    5665#define LineMap multimap < int, class BoundaryLineSet * >
     66#define LineSet set < class BoundaryLineSet * >
     67#define LineList list < class BoundaryLineSet * >
    5768#define LinePair pair < int, class BoundaryLineSet * >
    5869#define LineTestPair pair < LineMap::iterator, bool >
    5970
    6071#define TriangleMap map < int, class BoundaryTriangleSet * >
     72#define TriangleSet set < class BoundaryTriangleSet * >
     73#define TriangleList list < class BoundaryTriangleSet * >
    6174#define TrianglePair pair < int, class BoundaryTriangleSet * >
    6275#define TriangleTestPair pair < TrianglePair::iterator, bool >
    6376
     77#define PolygonMap map < int, class BoundaryPolygonSet * >
     78#define PolygonSet set < class BoundaryPolygonSet * >
     79#define PolygonList list < class BoundaryPolygonSet * >
     80
     81#define DistanceToPointMap multimap <double, class BoundaryPointSet * >
     82#define DistanceToPointPair pair <double, class BoundaryPointSet * >
     83
    6484#define DistanceMultiMap multimap <double, pair < PointMap::iterator, PointMap::iterator> >
    6585#define DistanceMultiMapPair pair <double, pair < PointMap::iterator, PointMap::iterator> >
     86
     87#define TesselPointList list <TesselPoint *>
     88#define TesselPointSet set <TesselPoint *>
     89
     90#define ListOfTesselPointList list<list <TesselPoint *> *>
    6691
    6792/********************************************** declarations *******************************/
     
    83108  public:
    84109    BoundaryPointSet();
    85     BoundaryPointSet(TesselPoint * Walker);
     110    BoundaryPointSet(TesselPoint * const Walker);
    86111    ~BoundaryPointSet();
    87112
    88     void AddLine(class BoundaryLineSet *line);
     113    void AddLine(BoundaryLineSet * const line);
    89114
    90115    LineMap lines;
     
    102127  public:
    103128    BoundaryLineSet();
    104     BoundaryLineSet(class BoundaryPointSet *Point[2], const int number);
     129    BoundaryLineSet(BoundaryPointSet * const Point[2], const int number);
     130    BoundaryLineSet(BoundaryPointSet * const Point1, BoundaryPointSet * const Point2, const int number);
    105131    ~BoundaryLineSet();
    106132
    107     void AddTriangle(class BoundaryTriangleSet *triangle);
    108     bool IsConnectedTo(class BoundaryLineSet *line);
    109     bool ContainsBoundaryPoint(class BoundaryPointSet *point);
    110     bool CheckConvexityCriterion();
    111     class BoundaryPointSet *GetOtherEndpoint(class BoundaryPointSet *);
     133    void AddTriangle(BoundaryTriangleSet * const triangle);
     134    bool IsConnectedTo(const BoundaryLineSet * const line) const;
     135    bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const;
     136    bool CheckConvexityCriterion() const;
     137    class BoundaryPointSet *GetOtherEndpoint(const BoundaryPointSet * const point) const;
    112138
    113139    class BoundaryPointSet *endpoints[2];
    114140    TriangleMap triangles;
    115141    int Nr;
     142    bool skipped;
    116143};
    117144
     
    123150  public:
    124151    BoundaryTriangleSet();
    125     BoundaryTriangleSet(class BoundaryLineSet *line[3], int number);
     152    BoundaryTriangleSet(class BoundaryLineSet * const line[3], const int number);
    126153    ~BoundaryTriangleSet();
    127154
    128     void GetNormalVector(Vector &NormalVector);
    129     void GetCenter(Vector *center);
    130     bool GetIntersectionInsideTriangle(Vector *MolCenter, Vector *x, Vector *Intersection);
    131     bool ContainsBoundaryLine(class BoundaryLineSet *line);
    132     bool ContainsBoundaryPoint(class BoundaryPointSet *point);
    133     bool ContainsBoundaryPoint(class TesselPoint *point);
    134     class BoundaryPointSet *GetThirdEndpoint(class BoundaryLineSet *line);
    135     bool IsPresentTupel(class BoundaryPointSet *Points[3]);
    136     bool IsPresentTupel(class BoundaryTriangleSet *T);
     155    void GetNormalVector(const Vector &NormalVector);
     156    void GetCenter(Vector * const center) const;
     157    bool GetIntersectionInsideTriangle(const Vector * const MolCenter, const Vector * const x, Vector * const Intersection) const;
     158    double GetClosestPointInsideTriangle(const Vector * const x, Vector * const ClosestPoint) const;
     159    bool ContainsBoundaryLine(const BoundaryLineSet * const line) const;
     160    bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const;
     161    bool ContainsBoundaryPoint(const TesselPoint * const point) const;
     162    class BoundaryPointSet *GetThirdEndpoint(const BoundaryLineSet * const line) const;
     163    bool IsPresentTupel(const BoundaryPointSet * const Points[3]) const;
     164    bool IsPresentTupel(const BoundaryTriangleSet * const T) const;
    137165
    138166    class BoundaryPointSet *endpoints[3];
    139167    class BoundaryLineSet *lines[3];
    140168    Vector NormalVector;
     169    Vector SphereCenter;
    141170    int Nr;
    142171};
    143172
    144173ostream & operator << (ostream &ost, const BoundaryTriangleSet &a);
     174
     175
     176// ======================================================== class BoundaryTriangleSet =======================================
     177
     178/** Set of BoundaryPointSet.
     179 * This is just meant as a container for a group of endpoints, extending the node, line, triangle concept. However, this has
     180 * only marginally something to do with the tesselation. Hence, there is no incorporation into the bookkeeping of the Tesselation
     181 * class (i.e. no allocation, no deletion).
     182 * \note we assume that the set of endpoints reside (more or less) on a plane.
     183 */
     184class BoundaryPolygonSet {
     185  public:
     186    BoundaryPolygonSet();
     187    ~BoundaryPolygonSet();
     188
     189    Vector * GetNormalVector(const Vector &NormalVector) const;
     190    void GetCenter(Vector *center) const;
     191    bool ContainsBoundaryLine(const BoundaryLineSet * const line) const;
     192    bool ContainsBoundaryPoint(const BoundaryPointSet * const point) const;
     193    bool ContainsBoundaryPoint(const TesselPoint * const point) const;
     194    bool ContainsBoundaryTriangle(const BoundaryTriangleSet * const point) const;
     195    bool ContainsPresentTupel(const BoundaryPointSet * const * Points, const int dim) const;
     196    bool ContainsPresentTupel(const BoundaryPolygonSet * const P) const;
     197    bool ContainsPresentTupel(const PointSet &endpoints) const;
     198    TriangleSet * GetAllContainedTrianglesFromEndpoints() const;
     199    bool FillPolygonFromTrianglesOfLine(const BoundaryLineSet * const line);
     200
     201    PointSet endpoints;
     202    int Nr;
     203};
     204
     205ostream & operator << (ostream &ost, const BoundaryPolygonSet &a);
    145206
    146207// =========================================================== class TESSELPOINT ===========================================
     
    170231  virtual ~PointCloud();
    171232
     233  virtual const char * const GetName() const { return "unknown"; };
    172234  virtual Vector *GetCenter() const { return NULL; };
    173235  virtual TesselPoint *GetPoint() const { return NULL; };
    174236  virtual TesselPoint *GetTerminalPoint() const { return NULL; };
     237  virtual int GetMaxId() const { return 0; };
    175238  virtual void GoToNext() const {};
    176239  virtual void GoToPrevious() const {};
    177240  virtual void GoToFirst() const {};
    178241  virtual void GoToLast() const {};
    179   virtual bool IsEmpty() const { return false; };
    180   virtual bool IsEnd() const { return false; };
     242  virtual bool IsEmpty() const { return true; };
     243  virtual bool IsEnd() const { return true; };
    181244};
    182245
     
    185248class CandidateForTesselation {
    186249  public :
     250  CandidateForTesselation(BoundaryLineSet* currentBaseLine);
    187251  CandidateForTesselation(TesselPoint* candidate, BoundaryLineSet* currentBaseLine, Vector OptCandidateCenter, Vector OtherOptCandidateCenter);
    188252  ~CandidateForTesselation();
    189253
    190   TesselPoint *point;
     254  TesselPointList pointlist;
    191255  BoundaryLineSet *BaseLine;
    192256  Vector OptCenter;
    193257  Vector OtherOptCenter;
    194 };
     258  double ShortestAngle;
     259  double OtherShortestAngle;
     260};
     261
     262ostream & operator <<(ostream &ost, const  CandidateForTesselation &a);
    195263
    196264// =========================================================== class TESSELATION ===========================================
     
    210278    void AddTesselationTriangle();
    211279    void AddTesselationTriangle(const int nr);
     280    void AddCandidateTriangle(CandidateForTesselation CandidateLine);
    212281    void RemoveTesselationTriangle(class BoundaryTriangleSet *triangle);
    213282    void RemoveTesselationLine(class BoundaryLineSet *line);
     
    218287    void FindStartingTriangle(const double RADIUS, const LinkedCell *LC);
    219288    void FindSecondPointForTesselation(class TesselPoint* a, Vector Oben, class TesselPoint*& OptCandidate, double Storage[3], double RADIUS, const LinkedCell *LC);
    220     void FindThirdPointForTesselation(Vector &NormalVector, Vector &SearchDirection, Vector &OldSphereCenter, class BoundaryLineSet *BaseLine, const class TesselPoint * const ThirdNode, CandidateList* &candidates, double *ShortestAngle, const double RADIUS, const LinkedCell *LC) const;
    221     bool FindNextSuitableTriangle(BoundaryLineSet &Line, BoundaryTriangleSet &T, const 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);
    222291    int CheckPresenceOfTriangle(class TesselPoint *Candidates[3]) const;
    223292    class BoundaryTriangleSet * GetPresentTriangle(TesselPoint *Candidates[3]);
     
    231300    double PickFarthestofTwoBaselines(class BoundaryLineSet *Base);
    232301    class BoundaryPointSet *IsConvexRectangle(class BoundaryLineSet *Base);
    233     map<int, int> * FindAllDegeneratedTriangles();
    234     map<int, int> * FindAllDegeneratedLines();
     302    IndexToIndex * FindAllDegeneratedTriangles();
     303    IndexToIndex * FindAllDegeneratedLines();
    235304    void RemoveDegeneratedTriangles();
    236305    void AddBoundaryPointByDegeneratedTriangle(class TesselPoint *point, LinkedCell *LC);
    237 
    238     set<TesselPoint*> * GetAllConnectedPoints(const TesselPoint* const Point) const;
    239     set<BoundaryTriangleSet*> *GetAllTriangles(const BoundaryPointSet * const Point) const;
    240     list<list<TesselPoint*> *> * GetPathsOfConnectedPoints(const TesselPoint* const Point) const;
    241     list<list<TesselPoint*> *> * GetClosedPathsOfConnectedPoints(const TesselPoint* const Point) const;
    242     list<TesselPoint*> * GetCircleOfConnectedPoints(const TesselPoint* const Point, const Vector * const Reference = NULL) const;
    243     class BoundaryPointSet *GetCommonEndpoint(const BoundaryLineSet * line1, const BoundaryLineSet * line2) const;
    244     list<BoundaryTriangleSet*> *FindTriangles(const TesselPoint* const Points[3]) const;
    245     list<BoundaryTriangleSet*> * FindClosestTrianglesToPoint(const Vector *x, const LinkedCell* LC) const;
    246     class BoundaryTriangleSet * FindClosestTriangleToPoint(const Vector *x, const LinkedCell* LC) const;
     306    int CorrectAllDegeneratedPolygons();
     307
     308    TesselPointSet * GetAllConnectedPoints(const TesselPoint* const Point) const;
     309    TriangleSet * GetAllTriangles(const BoundaryPointSet * const Point) const;
     310    ListOfTesselPointList * GetPathsOfConnectedPoints(const TesselPoint* const Point) const;
     311    ListOfTesselPointList * GetClosedPathsOfConnectedPoints(const TesselPoint* const Point) const;
     312    TesselPointList * GetCircleOfSetOfPoints(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector * const Reference = NULL) const;
     313    TesselPointList * GetCircleOfConnectedTriangles(TesselPointSet *SetOfNeighbours, const TesselPoint* const Point, const Vector * const Reference) const;
     314    class BoundaryPointSet * GetCommonEndpoint(const BoundaryLineSet * line1, const BoundaryLineSet * line2) const;
     315    TriangleList * FindTriangles(const TesselPoint* const Points[3]) const;
     316    TriangleList * FindClosestTrianglesToVector(const Vector *x, const LinkedCell* LC) const;
     317    BoundaryTriangleSet * FindClosestTriangleToVector(const Vector *x, const LinkedCell* LC) const;
    247318    bool IsInnerPoint(const Vector &Point, const LinkedCell* const LC) const;
    248     bool IsInnerPoint(const TesselPoint * const Point, const LinkedCell* const LC) const;
     319    double GetDistanceSquaredToTriangle(const Vector &Point, const BoundaryTriangleSet* const triangle) const;
     320    double GetDistanceSquaredToSurface(const Vector &Point, const LinkedCell* const LC) const;
    249321    bool AddBoundaryPoint(TesselPoint * Walker, const int n);
     322    DistanceToPointMap * FindClosestBoundaryPointsToVector(const Vector *x, const LinkedCell* LC) const;
     323    BoundaryLineSet * FindClosestBoundaryLineToVector(const Vector *x, const LinkedCell* LC) const;
    250324
    251325    // print for debugging
     
    259333    PointMap PointsOnBoundary;
    260334    LineMap LinesOnBoundary;
     335    CandidateMap OpenLines;
    261336    TriangleMap TrianglesOnBoundary;
    262337    int PointsOnBoundaryCount;
     
    286361    mutable PointMap::const_iterator InternalPointer;
    287362
    288     bool HasOtherBaselineBetterCandidate(const BoundaryLineSet * const BaseRay, const TesselPoint * const OptCandidate, double ShortestAngle, double RADIUS, const LinkedCell * const LC) const;
     363    //bool HasOtherBaselineBetterCandidate(const BoundaryLineSet * const BaseRay, const TesselPoint * const OptCandidate, double ShortestAngle, double RADIUS, const LinkedCell * const LC) const;
    289364};
    290365
  • TabularUnified src/tesselationhelpers.cpp

    r9fe36b rb8d1aeb  
    88#include <fstream>
    99
     10#include "info.hpp"
    1011#include "linkedcell.hpp"
    1112#include "log.hpp"
     
    1516#include "verbose.hpp"
    1617
    17 double DetGet(gsl_matrix * const A, const int inPlace) {
     18double DetGet(gsl_matrix * const A, const int inPlace)
     19{
     20        Info FunctionInfo(__func__);
    1821  /*
    1922  inPlace = 1 => A is replaced with the LU decomposed copy.
     
    4548void GetSphere(Vector * const center, const Vector &a, const Vector &b, const Vector &c, const double RADIUS)
    4649{
     50        Info FunctionInfo(__func__);
    4751  gsl_matrix *A = gsl_matrix_calloc(3,3);
    4852  double m11, m12, m13, m14;
     
    111115    const double HalfplaneIndicator, const double AlternativeIndicator, const double alpha, const double beta, const double gamma, const double RADIUS, const double Umkreisradius)
    112116{
     117        Info FunctionInfo(__func__);
    113118  Vector TempNormal, helper;
    114119  double Restradius;
    115120  Vector OtherCenter;
    116   Log() << Verbose(3) << "Begin of GetCenterOfSphere.\n";
    117121  Center->Zero();
    118122  helper.CopyVector(&a);
     
    128132  Center->Scale(1./(sin(2.*alpha) + sin(2.*beta) + sin(2.*gamma)));
    129133  NewUmkreismittelpunkt->CopyVector(Center);
    130   Log() << Verbose(4) << "Center of new circumference is " << *NewUmkreismittelpunkt << ".\n";
     134  Log() << Verbose(1) << "Center of new circumference is " << *NewUmkreismittelpunkt << ".\n";
    131135  // Here we calculated center of circumscribing circle, using barycentric coordinates
    132   Log() << Verbose(4) << "Center of circumference is " << *Center << " in direction " << *Direction << ".\n";
     136  Log() << Verbose(1) << "Center of circumference is " << *Center << " in direction " << *Direction << ".\n";
    133137
    134138  TempNormal.CopyVector(&a);
     
    139143  if (fabs(HalfplaneIndicator) < MYEPSILON)
    140144    {
    141       if ((TempNormal.ScalarProduct(AlternativeDirection) <0 and AlternativeIndicator >0) or (TempNormal.ScalarProduct(AlternativeDirection) >0 and AlternativeIndicator <0))
     145      if ((TempNormal.ScalarProduct(AlternativeDirection) <0 && AlternativeIndicator >0) || (TempNormal.ScalarProduct(AlternativeDirection) >0 && AlternativeIndicator <0))
    142146        {
    143147          TempNormal.Scale(-1);
     
    146150  else
    147151    {
    148       if (TempNormal.ScalarProduct(Direction)<0 && HalfplaneIndicator >0 || TempNormal.ScalarProduct(Direction)>0 && HalfplaneIndicator<0)
     152      if (((TempNormal.ScalarProduct(Direction)<0) && (HalfplaneIndicator >0)) || ((TempNormal.ScalarProduct(Direction)>0) && (HalfplaneIndicator<0)))
    149153        {
    150154          TempNormal.Scale(-1);
     
    154158  TempNormal.Normalize();
    155159  Restradius = sqrt(RADIUS*RADIUS - Umkreisradius*Umkreisradius);
    156   Log() << Verbose(4) << "Height of center of circumference to center of sphere is " << Restradius << ".\n";
     160  Log() << Verbose(1) << "Height of center of circumference to center of sphere is " << Restradius << ".\n";
    157161  TempNormal.Scale(Restradius);
    158   Log() << Verbose(4) << "Shift vector to sphere of circumference is " << TempNormal << ".\n";
     162  Log() << Verbose(1) << "Shift vector to sphere of circumference is " << TempNormal << ".\n";
    159163
    160164  Center->AddVector(&TempNormal);
    161   Log() << Verbose(0) << "Center of sphere of circumference is " << *Center << ".\n";
     165  Log() << Verbose(1) << "Center of sphere of circumference is " << *Center << ".\n";
    162166  GetSphere(&OtherCenter, a, b, c, RADIUS);
    163   Log() << Verbose(0) << "OtherCenter of sphere of circumference is " << OtherCenter << ".\n";
    164   Log() << Verbose(3) << "End of GetCenterOfSphere.\n";
     167  Log() << Verbose(1) << "OtherCenter of sphere of circumference is " << OtherCenter << ".\n";
    165168};
    166169
     
    174177void GetCenterofCircumcircle(Vector * const Center, const Vector &a, const Vector &b, const Vector &c)
    175178{
     179        Info FunctionInfo(__func__);
    176180  Vector helper;
    177181  double alpha, beta, gamma;
     
    186190  beta = M_PI - SideC.Angle(&SideA);
    187191  gamma = M_PI - SideA.Angle(&SideB);
    188   //Log() << Verbose(3) << "INFO: alpha = " << alpha/M_PI*180. << ", beta = " << beta/M_PI*180. << ", gamma = " << gamma/M_PI*180. << "." << endl;
     192  //Log() << Verbose(1) << "INFO: alpha = " << alpha/M_PI*180. << ", beta = " << beta/M_PI*180. << ", gamma = " << gamma/M_PI*180. << "." << endl;
    189193  if (fabs(M_PI - alpha - beta - gamma) > HULLEPSILON) {
    190194    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;
     
    219223double GetPathLengthonCircumCircle(const Vector &CircleCenter, const Vector &CirclePlaneNormal, const double CircleRadius, const Vector &NewSphereCenter, const Vector &OldSphereCenter, const Vector &NormalVector, const Vector &SearchDirection)
    220224{
     225        Info FunctionInfo(__func__);
    221226  Vector helper;
    222227  double radius, alpha;
    223 
    224   helper.CopyVector(&NewSphereCenter);
     228  Vector RelativeOldSphereCenter;
     229  Vector RelativeNewSphereCenter;
     230
     231  RelativeOldSphereCenter.CopyVector(&OldSphereCenter);
     232  RelativeOldSphereCenter.SubtractVector(&CircleCenter);
     233  RelativeNewSphereCenter.CopyVector(&NewSphereCenter);
     234  RelativeNewSphereCenter.SubtractVector(&CircleCenter);
     235  helper.CopyVector(&RelativeNewSphereCenter);
    225236  // test whether new center is on the parameter circle's plane
    226237  if (fabs(helper.ScalarProduct(&CirclePlaneNormal)) > HULLEPSILON) {
     
    228239    helper.ProjectOntoPlane(&CirclePlaneNormal);
    229240  }
    230   radius = helper.ScalarProduct(&helper);
     241  radius = helper.NormSquared();
    231242  // test whether the new center vector has length of CircleRadius
    232243  if (fabs(radius - CircleRadius) > HULLEPSILON)
    233244    eLog() << Verbose(1) << "The projected center of the new sphere has radius " << radius << " instead of " << CircleRadius << "." << endl;
    234   alpha = helper.Angle(&OldSphereCenter);
     245  alpha = helper.Angle(&RelativeOldSphereCenter);
    235246  // make the angle unique by checking the halfplanes/search direction
    236247  if (helper.ScalarProduct(&SearchDirection) < -HULLEPSILON)  // acos is not unique on [0, 2.*M_PI), hence extra check to decide between two half intervals
    237248    alpha = 2.*M_PI - alpha;
    238   //Log() << Verbose(2) << "INFO: RelativeNewSphereCenter is " << helper << ", RelativeOldSphereCenter is " << OldSphereCenter << " and resulting angle is " << alpha << "." << endl;
    239   radius = helper.Distance(&OldSphereCenter);
     249  Log() << Verbose(1) << "INFO: RelativeNewSphereCenter is " << helper << ", RelativeOldSphereCenter is " << RelativeOldSphereCenter << " and resulting angle is " << alpha << "." << endl;
     250  radius = helper.Distance(&RelativeOldSphereCenter);
    240251  helper.ProjectOntoPlane(&NormalVector);
    241252  // check whether new center is somewhat away or at least right over the current baseline to prevent intersecting triangles
    242253  if ((radius > HULLEPSILON) || (helper.Norm() < HULLEPSILON)) {
    243     //Log() << Verbose(2) << "INFO: Distance between old and new center is " << radius << " and between new center and baseline center is " << helper.Norm() << "." << endl;
     254    Log() << Verbose(1) << "INFO: Distance between old and new center is " << radius << " and between new center and baseline center is " << helper.Norm() << "." << endl;
    244255    return alpha;
    245256  } else {
    246     //Log() << Verbose(1) << "INFO: NewSphereCenter " << helper << " is too close to OldSphereCenter" << OldSphereCenter << "." << endl;
     257    Log() << Verbose(1) << "INFO: NewSphereCenter " << RelativeNewSphereCenter << " is too close to RelativeOldSphereCenter" << RelativeOldSphereCenter << "." << endl;
    247258    return 2.*M_PI;
    248259  }
     
    264275double MinIntersectDistance(const gsl_vector * x, void *params)
    265276{
     277        Info FunctionInfo(__func__);
    266278  double retval = 0;
    267279  struct Intersection *I = (struct Intersection *)params;
     
    284296
    285297  retval = HeightA.ScalarProduct(&HeightA) + HeightB.ScalarProduct(&HeightB);
    286   //Log() << Verbose(2) << "MinIntersectDistance called, result: " << retval << endl;
     298  //Log() << Verbose(1) << "MinIntersectDistance called, result: " << retval << endl;
    287299
    288300  return retval;
     
    304316bool existsIntersection(const Vector &point1, const Vector &point2, const Vector &point3, const Vector &point4)
    305317{
     318        Info FunctionInfo(__func__);
    306319  bool result;
    307320
     
    351364
    352365        if (status == GSL_SUCCESS) {
    353           Log() << Verbose(2) << "converged to minimum" <<  endl;
     366          Log() << Verbose(1) << "converged to minimum" <<  endl;
    354367        }
    355368    } while (status == GSL_CONTINUE && iter < 100);
     
    376389  t2 = HeightB.ScalarProduct(&SideB)/SideB.ScalarProduct(&SideB);
    377390
    378   Log() << Verbose(2) << "Intersection " << intersection << " is at "
     391  Log() << Verbose(1) << "Intersection " << intersection << " is at "
    379392    << t1 << " for (" << point1 << "," << point2 << ") and at "
    380393    << t2 << " for (" << point3 << "," << point4 << "): ";
    381394
    382395  if (((t1 >= 0) && (t1 <= 1)) && ((t2 >= 0) && (t2 <= 1))) {
    383     Log() << Verbose(0) << "true intersection." << endl;
     396    Log() << Verbose(1) << "true intersection." << endl;
    384397    result = true;
    385398  } else {
    386     Log() << Verbose(0) << "intersection out of region of interest." << endl;
     399    Log() << Verbose(1) << "intersection out of region of interest." << endl;
    387400    result = false;
    388401  }
     
    407420double GetAngle(const Vector &point, const Vector &reference, const Vector &OrthogonalVector)
    408421{
     422        Info FunctionInfo(__func__);
    409423  if (reference.IsZero())
    410424    return M_PI;
     
    418432  }
    419433
    420   Log() << Verbose(4) << "INFO: " << point << " has angle " << phi << " with respect to reference " << reference << "." << endl;
     434  Log() << Verbose(1) << "INFO: " << point << " has angle " << phi << " with respect to reference " << reference << "." << endl;
    421435
    422436  return phi;
     
    433447double CalculateVolumeofGeneralTetraeder(const Vector &a, const Vector &b, const Vector &c, const Vector &d)
    434448{
     449        Info FunctionInfo(__func__);
    435450  Vector Point, TetraederVector[3];
    436451  double volume;
     
    456471bool CheckLineCriteriaForDegeneratedTriangle(const BoundaryPointSet * const nodes[3])
    457472{
     473        Info FunctionInfo(__func__);
    458474  bool result = false;
    459475  int counter = 0;
     
    482498    }
    483499  if ((!result) && (counter > 1)) {
    484     Log() << Verbose(2) << "INFO: Degenerate triangle is ok, at least two, here " << counter << ", existing lines are used." << endl;
     500    Log() << Verbose(1) << "INFO: Degenerate triangle is ok, at least two, here " << counter << ", existing lines are used." << endl;
    485501    result = true;
    486502  }
     
    489505
    490506
    491 /** Sort function for the candidate list.
    492  */
    493 bool SortCandidates(const CandidateForTesselation* candidate1, const CandidateForTesselation* candidate2)
    494 {
    495   Vector BaseLineVector, OrthogonalVector, helper;
    496   if (candidate1->BaseLine != candidate2->BaseLine) {  // sanity check
    497     eLog() << Verbose(1) << "sortCandidates was called for two different baselines: " << candidate1->BaseLine << " and " << candidate2->BaseLine << "." << endl;
    498     //return false;
    499     exit(1);
    500   }
    501   // create baseline vector
    502   BaseLineVector.CopyVector(candidate1->BaseLine->endpoints[1]->node->node);
    503   BaseLineVector.SubtractVector(candidate1->BaseLine->endpoints[0]->node->node);
    504   BaseLineVector.Normalize();
    505 
    506   // create normal in-plane vector to cope with acos() non-uniqueness on [0,2pi] (note that is pointing in the "right" direction already, hence ">0" test!)
    507   helper.CopyVector(candidate1->BaseLine->endpoints[0]->node->node);
    508   helper.SubtractVector(candidate1->point->node);
    509   OrthogonalVector.CopyVector(&helper);
    510   helper.VectorProduct(&BaseLineVector);
    511   OrthogonalVector.SubtractVector(&helper);
    512   OrthogonalVector.Normalize();
    513 
    514   // calculate both angles and correct with in-plane vector
    515   helper.CopyVector(candidate1->point->node);
    516   helper.SubtractVector(candidate1->BaseLine->endpoints[0]->node->node);
    517   double phi = BaseLineVector.Angle(&helper);
    518   if (OrthogonalVector.ScalarProduct(&helper) > 0) {
    519     phi = 2.*M_PI - phi;
    520   }
    521   helper.CopyVector(candidate2->point->node);
    522   helper.SubtractVector(candidate1->BaseLine->endpoints[0]->node->node);
    523   double psi = BaseLineVector.Angle(&helper);
    524   if (OrthogonalVector.ScalarProduct(&helper) > 0) {
    525     psi = 2.*M_PI - psi;
    526   }
    527 
    528   Log() << Verbose(2) << *candidate1->point << " has angle " << phi << endl;
    529   Log() << Verbose(2) << *candidate2->point << " has angle " << psi << endl;
    530 
    531   // return comparison
    532   return phi < psi;
    533 };
     507///** Sort function for the candidate list.
     508// */
     509//bool SortCandidates(const CandidateForTesselation* candidate1, const CandidateForTesselation* candidate2)
     510//{
     511//      Info FunctionInfo(__func__);
     512//  Vector BaseLineVector, OrthogonalVector, helper;
     513//  if (candidate1->BaseLine != candidate2->BaseLine) {  // sanity check
     514//    eLog() << Verbose(1) << "sortCandidates was called for two different baselines: " << candidate1->BaseLine << " and " << candidate2->BaseLine << "." << endl;
     515//    //return false;
     516//    exit(1);
     517//  }
     518//  // create baseline vector
     519//  BaseLineVector.CopyVector(candidate1->BaseLine->endpoints[1]->node->node);
     520//  BaseLineVector.SubtractVector(candidate1->BaseLine->endpoints[0]->node->node);
     521//  BaseLineVector.Normalize();
     522//
     523//  // create normal in-plane vector to cope with acos() non-uniqueness on [0,2pi] (note that is pointing in the "right" direction already, hence ">0" test!)
     524//  helper.CopyVector(candidate1->BaseLine->endpoints[0]->node->node);
     525//  helper.SubtractVector(candidate1->point->node);
     526//  OrthogonalVector.CopyVector(&helper);
     527//  helper.VectorProduct(&BaseLineVector);
     528//  OrthogonalVector.SubtractVector(&helper);
     529//  OrthogonalVector.Normalize();
     530//
     531//  // calculate both angles and correct with in-plane vector
     532//  helper.CopyVector(candidate1->point->node);
     533//  helper.SubtractVector(candidate1->BaseLine->endpoints[0]->node->node);
     534//  double phi = BaseLineVector.Angle(&helper);
     535//  if (OrthogonalVector.ScalarProduct(&helper) > 0) {
     536//    phi = 2.*M_PI - phi;
     537//  }
     538//  helper.CopyVector(candidate2->point->node);
     539//  helper.SubtractVector(candidate1->BaseLine->endpoints[0]->node->node);
     540//  double psi = BaseLineVector.Angle(&helper);
     541//  if (OrthogonalVector.ScalarProduct(&helper) > 0) {
     542//    psi = 2.*M_PI - psi;
     543//  }
     544//
     545//  Log() << Verbose(1) << *candidate1->point << " has angle " << phi << endl;
     546//  Log() << Verbose(1) << *candidate2->point << " has angle " << psi << endl;
     547//
     548//  // return comparison
     549//  return phi < psi;
     550//};
    534551
    535552/**
     
    541558 * @return point which is second closest to the provided one
    542559 */
    543 TesselPoint* FindSecondClosestPoint(const Vector* Point, const LinkedCell* const LC)
    544 {
     560TesselPoint* FindSecondClosestTesselPoint(const Vector* Point, const LinkedCell* const LC)
     561{
     562        Info FunctionInfo(__func__);
    545563  TesselPoint* closestPoint = NULL;
    546564  TesselPoint* secondClosestPoint = NULL;
     
    553571  for(int i=0;i<NDIM;i++) // store indices of this cell
    554572    N[i] = LC->n[i];
    555   Log() << Verbose(2) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl;
     573  Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl;
    556574
    557575  LC->GetNeighbourBounds(Nlower, Nupper);
    558   //Log() << Verbose(0) << endl;
     576  //Log() << Verbose(1) << endl;
    559577  for (LC->n[0] = Nlower[0]; LC->n[0] <= Nupper[0]; LC->n[0]++)
    560578    for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
    561579      for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
    562580        const LinkedNodes *List = LC->GetCurrentCell();
    563         //Log() << Verbose(3) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl;
     581        //Log() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl;
    564582        if (List != NULL) {
    565583          for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
     
    595613 * @return point which is closest to the provided one, NULL if none found
    596614 */
    597 TesselPoint* FindClosestPoint(const Vector* Point, TesselPoint *&SecondPoint, const LinkedCell* const LC)
    598 {
     615TesselPoint* FindClosestTesselPoint(const Vector* Point, TesselPoint *&SecondPoint, const LinkedCell* const LC)
     616{
     617        Info FunctionInfo(__func__);
    599618  TesselPoint* closestPoint = NULL;
    600619  SecondPoint = NULL;
     
    607626  for(int i=0;i<NDIM;i++) // store indices of this cell
    608627    N[i] = LC->n[i];
    609   Log() << Verbose(3) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl;
     628  Log() << Verbose(1) << "INFO: Center cell is " << N[0] << ", " << N[1] << ", " << N[2] << " with No. " << LC->index << "." << endl;
    610629
    611630  LC->GetNeighbourBounds(Nlower, Nupper);
    612   //Log() << Verbose(0) << endl;
     631  //Log() << Verbose(1) << endl;
    613632  for (LC->n[0] = Nlower[0]; LC->n[0] <= Nupper[0]; LC->n[0]++)
    614633    for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
    615634      for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
    616635        const LinkedNodes *List = LC->GetCurrentCell();
    617         //Log() << Verbose(3) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl;
     636        //Log() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl;
    618637        if (List != NULL) {
    619638          for (LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
    620639            helper.CopyVector(Point);
    621640            helper.SubtractVector((*Runner)->node);
    622             double currentNorm = helper. Norm();
     641            double currentNorm = helper.NormSquared();
    623642            if (currentNorm < distance) {
    624643              secondDistance = distance;
     
    626645              distance = currentNorm;
    627646              closestPoint = (*Runner);
    628               //Log() << Verbose(2) << "INFO: New Nearest Neighbour is " << *closestPoint << "." << endl;
     647              //Log() << Verbose(1) << "INFO: New Nearest Neighbour is " << *closestPoint << "." << endl;
    629648            } else if (currentNorm < secondDistance) {
    630649              secondDistance = currentNorm;
    631650              SecondPoint = (*Runner);
    632               //Log() << Verbose(2) << "INFO: New Second Nearest Neighbour is " << *SecondPoint << "." << endl;
     651              //Log() << Verbose(1) << "INFO: New Second Nearest Neighbour is " << *SecondPoint << "." << endl;
    633652            }
    634653          }
     
    640659  // output
    641660  if (closestPoint != NULL) {
    642     Log() << Verbose(2) << "Closest point is " << *closestPoint;
     661    Log() << Verbose(1) << "Closest point is " << *closestPoint;
    643662    if (SecondPoint != NULL)
    644663      Log() << Verbose(0) << " and second closest is " << *SecondPoint;
     
    656675Vector * GetClosestPointBetweenLine(const BoundaryLineSet * const Base, const BoundaryLineSet * const OtherBase)
    657676{
     677        Info FunctionInfo(__func__);
    658678  // construct the plane of the two baselines (i.e. take both their directional vectors)
    659679  Vector Normal;
     
    666686  Normal.VectorProduct(&OtherBaseline);
    667687  Normal.Normalize();
    668   Log() << Verbose(4) << "First direction is " << Baseline << ", second direction is " << OtherBaseline << ", normal of intersection plane is " << Normal << "." << endl;
     688  Log() << Verbose(1) << "First direction is " << Baseline << ", second direction is " << OtherBaseline << ", normal of intersection plane is " << Normal << "." << endl;
    669689
    670690  // project one offset point of OtherBase onto this plane (and add plane offset vector)
     
    683703  Normal.CopyVector(Intersection);
    684704  Normal.SubtractVector(Base->endpoints[0]->node->node);
    685   Log() << Verbose(3) << "Found closest point on " << *Base << " at " << *Intersection << ", factor in line is " << fabs(Normal.ScalarProduct(&Baseline)/Baseline.NormSquared()) << "." << endl;
     705  Log() << Verbose(1) << "Found closest point on " << *Base << " at " << *Intersection << ", factor in line is " << fabs(Normal.ScalarProduct(&Baseline)/Baseline.NormSquared()) << "." << endl;
    686706
    687707  return Intersection;
     
    696716double DistanceToTrianglePlane(const Vector *x, const BoundaryTriangleSet * const triangle)
    697717{
     718        Info FunctionInfo(__func__);
    698719  double distance = 0.;
    699720  if (x == NULL) {
     
    712733void WriteVrmlFile(ofstream * const vrmlfile, const Tesselation * const Tess, const PointCloud * const cloud)
    713734{
     735        Info FunctionInfo(__func__);
    714736  TesselPoint *Walker = NULL;
    715737  int i;
     
    755777void IncludeSphereinRaster3D(ofstream * const rasterfile, const Tesselation * const Tess, const PointCloud * const cloud)
    756778{
     779        Info FunctionInfo(__func__);
    757780  Vector helper;
    758   // include the current position of the virtual sphere in the temporary raster3d file
    759   Vector *center = cloud->GetCenter();
    760   // make the circumsphere's center absolute again
    761   helper.CopyVector(Tess->LastTriangle->endpoints[0]->node->node);
    762   helper.AddVector(Tess->LastTriangle->endpoints[1]->node->node);
    763   helper.AddVector(Tess->LastTriangle->endpoints[2]->node->node);
    764   helper.Scale(1./3.);
    765   helper.SubtractVector(center);
    766   // and add to file plus translucency object
    767   *rasterfile << "# current virtual sphere\n";
    768   *rasterfile << "8\n  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0\n";
    769   *rasterfile << "2\n  " << helper.x[0] << " " << helper.x[1] << " " << helper.x[2] << "\t" << 5. << "\t1 0 0\n";
    770   *rasterfile << "9\n  terminating special property\n";
    771   delete(center);
     781
     782  if (Tess->LastTriangle != NULL) {
     783    // include the current position of the virtual sphere in the temporary raster3d file
     784    Vector *center = cloud->GetCenter();
     785    // make the circumsphere's center absolute again
     786    helper.CopyVector(Tess->LastTriangle->endpoints[0]->node->node);
     787    helper.AddVector(Tess->LastTriangle->endpoints[1]->node->node);
     788    helper.AddVector(Tess->LastTriangle->endpoints[2]->node->node);
     789    helper.Scale(1./3.);
     790    helper.SubtractVector(center);
     791    // and add to file plus translucency object
     792    *rasterfile << "# current virtual sphere\n";
     793    *rasterfile << "8\n  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0\n";
     794    *rasterfile << "2\n  " << helper.x[0] << " " << helper.x[1] << " " << helper.x[2] << "\t" << 5. << "\t1 0 0\n";
     795    *rasterfile << "9\n  terminating special property\n";
     796    delete(center);
     797  }
    772798};
    773799
     
    780806void WriteRaster3dFile(ofstream * const rasterfile, const Tesselation * const Tess, const PointCloud * const cloud)
    781807{
     808        Info FunctionInfo(__func__);
    782809  TesselPoint *Walker = NULL;
    783810  int i;
     
    825852void WriteTecplotFile(ofstream * const tecplot, const Tesselation * const TesselStruct, const PointCloud * const cloud, const int N)
    826853{
     854        Info FunctionInfo(__func__);
    827855  if ((tecplot != NULL) && (TesselStruct != NULL)) {
    828856    // write header
    829857    *tecplot << "TITLE = \"3D CONVEX SHELL\"" << endl;
    830858    *tecplot << "VARIABLES = \"X\" \"Y\" \"Z\" \"U\"" << endl;
    831     *tecplot << "ZONE T=\"" << N << "-";
    832     for (int i=0;i<3;i++)
    833       *tecplot << (i==0 ? "" : "_") << TesselStruct->LastTriangle->endpoints[i]->node->Name;
     859    *tecplot << "ZONE T=\"";
     860    if (N < 0) {
     861      *tecplot << cloud->GetName();
     862    } else {
     863      *tecplot << N << "-";
     864      for (int i=0;i<3;i++)
     865        *tecplot << (i==0 ? "" : "_") << TesselStruct->LastTriangle->endpoints[i]->node->Name;
     866    }
    834867    *tecplot << "\", N=" << TesselStruct->PointsOnBoundary.size() << ", E=" << TesselStruct->TrianglesOnBoundary.size() << ", DATAPACKING=POINT, ZONETYPE=FETRIANGLE" << endl;
    835     int i=0;
    836     for (cloud->GoToFirst(); !cloud->IsEnd(); cloud->GoToNext(), i++);
     868    int i=cloud->GetMaxId();
    837869    int *LookupList = new int[i];
    838870    for (cloud->GoToFirst(), i=0; !cloud->IsEnd(); cloud->GoToNext(), i++)
     
    840872
    841873    // print atom coordinates
    842     Log() << Verbose(2) << "The following triangles were created:";
    843874    int Counter = 1;
    844875    TesselPoint *Walker = NULL;
     
    850881    *tecplot << endl;
    851882    // print connectivity
     883    Log() << Verbose(1) << "The following triangles were created:" << endl;
    852884    for (TriangleMap::const_iterator runner = TesselStruct->TrianglesOnBoundary.begin(); runner != TesselStruct->TrianglesOnBoundary.end(); runner++) {
    853       Log() << Verbose(0) << " " << runner->second->endpoints[0]->node->Name << "<->" << runner->second->endpoints[1]->node->Name << "<->" << runner->second->endpoints[2]->node->Name;
     885      Log() << Verbose(1) << " " << runner->second->endpoints[0]->node->Name << "<->" << runner->second->endpoints[1]->node->Name << "<->" << runner->second->endpoints[2]->node->Name << endl;
    854886      *tecplot << LookupList[runner->second->endpoints[0]->node->nr] << " " << LookupList[runner->second->endpoints[1]->node->nr] << " " << LookupList[runner->second->endpoints[2]->node->nr] << endl;
    855887    }
    856888    delete[] (LookupList);
    857     Log() << Verbose(0) << endl;
    858889  }
    859890};
     
    866897void CalculateConcavityPerBoundaryPoint(const Tesselation * const TesselStruct)
    867898{
     899        Info FunctionInfo(__func__);
    868900  class BoundaryPointSet *point = NULL;
    869901  class BoundaryLineSet *line = NULL;
    870902
    871   //Log() << Verbose(2) << "Begin of CalculateConcavityPerBoundaryPoint" << endl;
    872903  // calculate remaining concavity
    873904  for (PointMap::const_iterator PointRunner = TesselStruct->PointsOnBoundary.begin(); PointRunner != TesselStruct->PointsOnBoundary.end(); PointRunner++) {
     
    877908    for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) {
    878909      line = LineRunner->second;
    879       //Log() << Verbose(2) << "INFO: Current line of point " << *point << " is " << *line << "." << endl;
     910      //Log() << Verbose(1) << "INFO: Current line of point " << *point << " is " << *line << "." << endl;
    880911      if (!line->CheckConvexityCriterion())
    881912        point->value += 1;
    882913    }
    883914  }
    884   //Log() << Verbose(2) << "End of CalculateConcavityPerBoundaryPoint" << endl;
    885915};
    886916
     
    893923bool CheckListOfBaselines(const Tesselation * const TesselStruct)
    894924{
     925        Info FunctionInfo(__func__);
    895926  LineMap::const_iterator testline;
    896927  bool result = false;
     
    900931  for (testline = TesselStruct->LinesOnBoundary.begin(); testline != TesselStruct->LinesOnBoundary.end(); testline++) {
    901932    if (testline->second->triangles.size() != 2) {
    902       Log() << Verbose(1) << *testline->second << "\t" << testline->second->triangles.size() << endl;
     933      Log() << Verbose(2) << *testline->second << "\t" << testline->second->triangles.size() << endl;
    903934      counter++;
    904935    }
     
    911942}
    912943
     944/** Counts the number of triangle pairs that contain the given polygon.
     945 * \param *P polygon with endpoints to look for
     946 * \param *T set of triangles to create pairs from containing \a *P
     947 */
     948int CountTrianglePairContainingPolygon(const BoundaryPolygonSet * const P, const TriangleSet * const T)
     949{
     950  Info FunctionInfo(__func__);
     951  // check number of endpoints in *P
     952  if (P->endpoints.size() != 4) {
     953    eLog() << Verbose(1) << "CountTrianglePairContainingPolygon works only on polygons with 4 nodes!" << endl;
     954    return 0;
     955  }
     956
     957  // check number of triangles in *T
     958  if (T->size() < 2) {
     959    eLog() << Verbose(1) << "Not enough triangles to have pairs!" << endl;
     960    return 0;
     961  }
     962
     963  Log() << Verbose(0) << "Polygon is " << *P << endl;
     964  // create each pair, get the endpoints and check whether *P is contained.
     965  int counter = 0;
     966  PointSet Trianglenodes;
     967  class BoundaryPolygonSet PairTrianglenodes;
     968  for(TriangleSet::iterator Walker = T->begin(); Walker != T->end(); Walker++) {
     969    for (int i=0;i<3;i++)
     970      Trianglenodes.insert((*Walker)->endpoints[i]);
     971
     972    for(TriangleSet::iterator PairWalker = Walker; PairWalker != T->end(); PairWalker++) {
     973      if (Walker != PairWalker) { // skip first
     974        PairTrianglenodes.endpoints = Trianglenodes;
     975        for (int i=0;i<3;i++)
     976          PairTrianglenodes.endpoints.insert((*PairWalker)->endpoints[i]);
     977        const int size = PairTrianglenodes.endpoints.size();
     978        if (size == 4) {
     979          Log() << Verbose(0) << " Current pair of triangles: " << **Walker << "," << **PairWalker << " with " << size << " distinct endpoints:" << PairTrianglenodes << endl;
     980          // now check
     981          if (PairTrianglenodes.ContainsPresentTupel(P)) {
     982            counter++;
     983            Log() << Verbose(0) << "  ACCEPT: Matches with " << *P << endl;
     984          } else {
     985            Log() << Verbose(0) << "  REJECT: No match with " << *P << endl;
     986          }
     987        } else {
     988          Log() << Verbose(0) << "  REJECT: Less than four endpoints." << endl;
     989        }
     990      }
     991    }
     992    Trianglenodes.clear();
     993  }
     994  return counter;
     995};
     996
     997/** Checks whether two give polygons have two or more points in common.
     998 * \param *P1 first polygon
     999 * \param *P2 second polygon
     1000 * \return true - are connected, false = are note
     1001 */
     1002bool ArePolygonsEdgeConnected(const BoundaryPolygonSet * const P1, const BoundaryPolygonSet * const P2)
     1003{
     1004  Info FunctionInfo(__func__);
     1005  int counter = 0;
     1006  for(PointSet::const_iterator Runner = P1->endpoints.begin(); Runner != P1->endpoints.end(); Runner++) {
     1007    if (P2->ContainsBoundaryPoint((*Runner))) {
     1008      counter++;
     1009      Log() << Verbose(1) << *(*Runner) << " of second polygon is found in the first one." << endl;
     1010      return true;
     1011    }
     1012  }
     1013  return false;
     1014};
     1015
     1016/** Combines second into the first and deletes the second.
     1017 * \param *P1 first polygon, contains all nodes on return
     1018 * \param *&P2 second polygon, is deleted.
     1019 */
     1020void CombinePolygons(BoundaryPolygonSet * const P1, BoundaryPolygonSet * &P2)
     1021{
     1022  Info FunctionInfo(__func__);
     1023  pair <PointSet::iterator, bool> Tester;
     1024  for(PointSet::iterator Runner = P2->endpoints.begin(); Runner != P2->endpoints.end(); Runner++) {
     1025    Tester = P1->endpoints.insert((*Runner));
     1026    if (Tester.second)
     1027      Log() << Verbose(0) << "Inserting endpoint " << *(*Runner) << " into first polygon." << endl;
     1028  }
     1029  P2->endpoints.clear();
     1030  delete(P2);
     1031};
     1032
  • TabularUnified src/tesselationhelpers.hpp

    r9fe36b rb8d1aeb  
    5959bool CheckLineCriteriaForDegeneratedTriangle(const BoundaryPointSet * const nodes[3]);
    6060bool SortCandidates(const CandidateForTesselation* candidate1, const CandidateForTesselation *candidate2);
    61 TesselPoint* FindClosestPoint(const Vector* Point, TesselPoint *&SecondPoint, const LinkedCell* const LC);
    62 TesselPoint* FindSecondClosestPoint(const Vector*, const LinkedCell* const LC);
     61TesselPoint* FindClosestTesselPoint(const Vector* Point, TesselPoint *&SecondPoint, const LinkedCell* const LC);
     62TesselPoint* FindSecondClosestTesselPoint(const Vector*, const LinkedCell* const LC);
    6363Vector * GetClosestPointBetweenLine(const BoundaryLineSet * const Base, const BoundaryLineSet * const OtherBase);
    6464
     
    7272bool CheckListOfBaselines(const Tesselation * const TesselStruct);
    7373
     74int CountTrianglePairContainingPolygon(const BoundaryPolygonSet * const P, const TriangleSet * const T);
     75bool ArePolygonsEdgeConnected(const BoundaryPolygonSet * const P1, const BoundaryPolygonSet * const P2);
     76void CombinePolygons(BoundaryPolygonSet * const P1, BoundaryPolygonSet * &P2);
     77
    7478
    7579#endif /* TESSELATIONHELPERS_HPP_ */
  • TabularUnified src/unittests/AnalysisCorrelationToPointUnitTest.cpp

    r9fe36b rb8d1aeb  
    1111#include <cppunit/extensions/TestFactoryRegistry.h>
    1212#include <cppunit/ui/text/TestRunner.h>
     13
     14#include <cstring>
    1315
    1416#include "analysis_correlation.hpp"
  • TabularUnified src/unittests/AnalysisCorrelationToSurfaceUnitTest.cpp

    r9fe36b rb8d1aeb  
    1111#include <cppunit/extensions/TestFactoryRegistry.h>
    1212#include <cppunit/ui/text/TestRunner.h>
     13
     14#include <cstring>
    1315
    1416#include "analysis_correlation.hpp"
  • TabularUnified src/unittests/AnalysisPairCorrelationUnitTest.cpp

    r9fe36b rb8d1aeb  
    1111#include <cppunit/extensions/TestFactoryRegistry.h>
    1212#include <cppunit/ui/text/TestRunner.h>
     13
     14#include <cstring>
    1315
    1416#include "analysis_correlation.hpp"
  • TabularUnified src/unittests/Makefile.am

    r9fe36b rb8d1aeb  
    66MENUTESTS = ActionSequenceTest
    77
    8 TESTS = ActOnAllUnitTest AnalysisBondsUnitTests AnalysisCorrelationToPointUnitTest AnalysisCorrelationToSurfaceUnitTest AnalysisPairCorrelationUnitTest BondGraphUnitTest ListOfBondsUnitTest LogUnitTest MemoryUsageObserverUnitTest MemoryAllocatorUnitTest StackClassUnitTest VectorUnitTest ObserverTest $(MENUTESTS)
     8
     9TESTS = \
     10  ActOnAllUnitTest \
     11  AnalysisBondsUnitTests \
     12  AnalysisCorrelationToPointUnitTest \
     13  AnalysisCorrelationToSurfaceUnitTest \
     14  AnalysisPairCorrelationUnitTest \
     15  BondGraphUnitTest \
     16  GSLMatrixSymmetricUnitTest \
     17  GSLMatrixUnitTest \
     18  GSLVectorUnitTest \
     19  InfoUnitTest \
     20  LinearSystemOfEquationsUnitTest \
     21  ListOfBondsUnitTest \
     22  LogUnitTest \
     23  MemoryUsageObserverUnitTest \
     24  MemoryAllocatorUnitTest \
     25  StackClassUnitTest \
     26  TesselationUnitTest \
     27  Tesselation_BoundaryTriangleUnitTest \
     28  Tesselation_InOutsideUnitTest \
     29  VectorUnitTest \
     30  ObserverTest \
     31  ${MENUTESTS}
     32   
     33 
    934check_PROGRAMS = $(TESTS)
    1035noinst_PROGRAMS = $(TESTS)
    1136
    1237ActOnAllUnitTest_SOURCES = ../test/ActOnAllTest.hpp ActOnAllUnitTest.cpp ActOnAllUnitTest.hpp
    13 ActOnAllUnitTest_LDADD = ../libmolecuilder.a
     38ActOnAllUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
    1439
    1540AnalysisBondsUnitTests_SOURCES = analysisbondsunittest.cpp analysisbondsunittest.hpp
    16 AnalysisBondsUnitTests_LDADD = ../libmolecuilder.a
     41AnalysisBondsUnitTests_LDADD = ../libmolecuilder.a ../libgslwrapper.a
    1742
    1843AnalysisCorrelationToPointUnitTest_SOURCES = analysis_correlation.hpp AnalysisCorrelationToPointUnitTest.cpp AnalysisCorrelationToPointUnitTest.hpp
    19 AnalysisCorrelationToPointUnitTest_LDADD = ../libmolecuilder.a
     44AnalysisCorrelationToPointUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
    2045
    2146AnalysisCorrelationToSurfaceUnitTest_SOURCES = analysis_correlation.hpp AnalysisCorrelationToSurfaceUnitTest.cpp AnalysisCorrelationToSurfaceUnitTest.hpp
    22 AnalysisCorrelationToSurfaceUnitTest_LDADD = ../libmolecuilder.a
     47AnalysisCorrelationToSurfaceUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
    2348
    2449AnalysisPairCorrelationUnitTest_SOURCES = analysis_correlation.hpp AnalysisPairCorrelationUnitTest.cpp AnalysisPairCorrelationUnitTest.hpp
    25 AnalysisPairCorrelationUnitTest_LDADD = ../libmolecuilder.a
     50AnalysisPairCorrelationUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
    2651
    2752BondGraphUnitTest_SOURCES = bondgraphunittest.cpp bondgraphunittest.hpp
    28 BondGraphUnitTest_LDADD = ../libmolecuilder.a
     53BondGraphUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
     54
     55GSLMatrixSymmetricUnitTest_SOURCES = gslmatrixsymmetricunittest.cpp gslmatrixsymmetricunittest.hpp
     56GSLMatrixSymmetricUnitTest_LDADD = ../libgslwrapper.a
     57
     58GSLMatrixUnitTest_SOURCES = gslmatrixunittest.cpp gslmatrixunittest.hpp
     59GSLMatrixUnitTest_LDADD = ../libgslwrapper.a
     60
     61GSLVectorUnitTest_SOURCES = gslvectorunittest.cpp gslvectorunittest.hpp
     62GSLVectorUnitTest_LDADD = ../libgslwrapper.a
     63
     64InfoUnitTest_SOURCES = infounittest.cpp infounittest.hpp
     65InfoUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
     66
     67LinearSystemOfEquationsUnitTest_SOURCES = linearsystemofequationsunittest.cpp linearsystemofequationsunittest.hpp
     68LinearSystemOfEquationsUnitTest_LDADD = ../libgslwrapper.a ../libmolecuilder.a
    2969
    3070ListOfBondsUnitTest_SOURCES = listofbondsunittest.cpp listofbondsunittest.hpp
    31 ListOfBondsUnitTest_LDADD = ../libmolecuilder.a
     71ListOfBondsUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
    3272
    3373LogUnitTest_SOURCES = logunittest.cpp logunittest.hpp
    34 LogUnitTest_LDADD = ../libmolecuilder.a
     74LogUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
    3575
    3676MemoryAllocatorUnitTest_SOURCES = memoryallocatorunittest.cpp memoryallocatorunittest.hpp
    37 MemoryAllocatorUnitTest_LDADD = ../libmolecuilder.a
     77MemoryAllocatorUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
    3878
    3979MemoryUsageObserverUnitTest_SOURCES = memoryusageobserverunittest.cpp memoryusageobserverunittest.hpp
    40 MemoryUsageObserverUnitTest_LDADD = ../libmolecuilder.a
     80MemoryUsageObserverUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
    4181
    4282StackClassUnitTest_SOURCES = stackclassunittest.cpp stackclassunittest.hpp
    43 StackClassUnitTest_LDADD = ../libmolecuilder.a
     83StackClassUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
     84
     85TesselationUnitTest_SOURCES = tesselationunittest.cpp tesselationunittest.hpp
     86TesselationUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
     87
     88Tesselation_BoundaryTriangleUnitTest_SOURCES = tesselation_boundarytriangleunittest.cpp tesselation_boundarytriangleunittest.hpp
     89Tesselation_BoundaryTriangleUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
     90
     91Tesselation_InOutsideUnitTest_SOURCES = tesselation_insideoutsideunittest.cpp tesselation_insideoutsideunittest.hpp
     92Tesselation_InOutsideUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
    4493
    4594VectorUnitTest_SOURCES = vectorunittest.cpp vectorunittest.hpp
    46 VectorUnitTest_LDADD = ../libmolecuilder.a
     95VectorUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a
    4796
    4897ActionSequenceTest_SOURCES = ActionSequenceTest.cpp ActionSequenceTest.hpp
  • TabularUnified src/unittests/analysisbondsunittest.cpp

    r9fe36b rb8d1aeb  
    1414#include <iostream>
    1515#include <stdio.h>
     16#include <cstring>
    1617
    1718#include "analysis_bonds.hpp"
  • TabularUnified src/unittests/bondgraphunittest.cpp

    r9fe36b rb8d1aeb  
    1414#include <iostream>
    1515#include <stdio.h>
     16#include <cstring>
    1617
    1718#include "atom.hpp"
  • TabularUnified src/unittests/listofbondsunittest.cpp

    r9fe36b rb8d1aeb  
    1111#include <cppunit/extensions/TestFactoryRegistry.h>
    1212#include <cppunit/ui/text/TestRunner.h>
     13
     14#include <cstring>
    1315
    1416#include "listofbondsunittest.hpp"
  • TabularUnified src/unittests/tesselationunittest.cpp

    r9fe36b rb8d1aeb  
    1212#include <cppunit/extensions/TestFactoryRegistry.h>
    1313#include <cppunit/ui/text/TestRunner.h>
     14
     15#include <cstring>
    1416
    1517#include "defs.hpp"
     
    3032  class TesselPoint *Walker;
    3133  Walker = new TesselPoint;
    32   Walker->node = new Vector(1., 0., 0.);
    33   Walker->Name = new char[3];
     34  Walker->node = new Vector(1., 0., -1.);
     35  Walker->Name = Malloc<char>(3, "TesselationTest::setUp");
    3436  strcpy(Walker->Name, "1");
    3537  Walker->nr = 1;
    3638  Corners.push_back(Walker);
    3739  Walker = new TesselPoint;
    38   Walker->node = new Vector(-1., 1., 0.);
    39   Walker->Name = new char[3];
     40  Walker->node = new Vector(-1., 1., -1.);
     41  Walker->Name = Malloc<char>(3, "TesselationTest::setUp");
    4042  strcpy(Walker->Name, "2");
    4143  Walker->nr = 2;
    4244  Corners.push_back(Walker);
    4345  Walker = new TesselPoint;
    44   Walker->node = new Vector(-1., -1., 0.);
    45   Walker->Name = new char[3];
     46  Walker->node = new Vector(-1., -1., -1.);
     47  Walker->Name = Malloc<char>(3, "TesselationTest::setUp");
    4648  strcpy(Walker->Name, "3");
    4749  Walker->nr = 3;
     
    4951  Walker = new TesselPoint;
    5052  Walker->node = new Vector(-1., 0., 1.);
    51   Walker->Name = new char[3];
     53  Walker->Name = Malloc<char>(3, "TesselationTest::setUp");
    5254  strcpy(Walker->Name, "4");
    5355  Walker->nr = 4;
     
    5961  // create tesselation
    6062  TesselStruct = new Tesselation;
    61   TesselStruct->PointsOnBoundary.clear();
    62   TesselStruct->LinesOnBoundary.clear();
    63   TesselStruct->TrianglesOnBoundary.clear();
     63  CPPUNIT_ASSERT_EQUAL( true, TesselStruct->PointsOnBoundary.empty() );
     64  CPPUNIT_ASSERT_EQUAL( true, TesselStruct->LinesOnBoundary.empty() );
     65  CPPUNIT_ASSERT_EQUAL( true, TesselStruct->TrianglesOnBoundary.empty() );
    6466  TesselStruct->FindStartingTriangle(SPHERERADIUS, LinkedList);
    65   bool flag = false;
    6667
    67   LineMap::iterator baseline = TesselStruct->LinesOnBoundary.begin();
    68   while (baseline != TesselStruct->LinesOnBoundary.end()) {
    69     if (baseline->second->triangles.size() == 1) {
    70       flag = TesselStruct->FindNextSuitableTriangle(*(baseline->second), *(((baseline->second->triangles.begin()))->second), SPHERERADIUS, LinkedList); //the line is there, so there is a triangle, but only one.
     68  CandidateForTesselation *baseline = NULL;
     69  BoundaryTriangleSet *T = NULL;
     70  bool OneLoopWithoutSuccessFlag = true;
     71  bool TesselationFailFlag = false;
     72  while ((!TesselStruct->OpenLines.empty()) && (OneLoopWithoutSuccessFlag)) {
     73    // 2a. fill all new OpenLines
     74    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
     75      baseline = Runner->second;
     76      if (baseline->pointlist.empty()) {
     77        T = (((baseline->BaseLine->triangles.begin()))->second);
     78        TesselationFailFlag = TesselStruct->FindNextSuitableTriangle(*baseline, *T, SPHERERADIUS, LinkedList); //the line is there, so there is a triangle, but only one.
     79      }
    7180    }
    72     baseline++;
    73     if ((baseline == TesselStruct->LinesOnBoundary.end()) && (flag)) {
    74       baseline = TesselStruct->LinesOnBoundary.begin();   // restart if we reach end due to newly inserted lines
    75       flag = false;
     81
     82    // 2b. search for smallest ShortestAngle among all candidates
     83    double ShortestAngle = 4.*M_PI;
     84    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
     85      if (Runner->second->ShortestAngle < ShortestAngle) {
     86        baseline = Runner->second;
     87        ShortestAngle = baseline->ShortestAngle;
     88      }
     89    }
     90    if ((ShortestAngle == 4.*M_PI) || (baseline->pointlist.empty()))
     91      OneLoopWithoutSuccessFlag = false;
     92    else {
     93      TesselStruct->AddCandidateTriangle(*baseline);
    7694    }
    7795  }
     
    84102  delete(TesselStruct);
    85103  for (LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) {
    86     delete[]((*Runner)->Name);
    87104    delete((*Runner)->node);
    88105    delete(*Runner);
    89106  }
    90107  Corners.clear();
    91 };
    92 
    93 /** UnitTest for Tesselation::IsInnerPoint()
    94  */
    95 void TesselationTest::IsInnerPointTest()
    96 {
    97   // true inside points
    98   CPPUNIT_ASSERT_EQUAL( true, TesselStruct->IsInnerPoint(Vector(0.,0.,0.), LinkedList) );
    99   CPPUNIT_ASSERT_EQUAL( true, TesselStruct->IsInnerPoint(Vector(0.5,0.,0.), LinkedList) );
    100   CPPUNIT_ASSERT_EQUAL( true, TesselStruct->IsInnerPoint(Vector(0.,0.5,0.), LinkedList) );
    101   CPPUNIT_ASSERT_EQUAL( true, TesselStruct->IsInnerPoint(Vector(0.,0.,0.5), LinkedList) );
    102 
    103   // corners
    104   for (LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++)
    105     CPPUNIT_ASSERT_EQUAL( true, TesselStruct->IsInnerPoint((*Runner), LinkedList) );
    106 
    107   // true outside points
    108   CPPUNIT_ASSERT_EQUAL( false, TesselStruct->IsInnerPoint(Vector(0.,5.,0.), LinkedList) );
    109   CPPUNIT_ASSERT_EQUAL( false, TesselStruct->IsInnerPoint(Vector(0.,0.,5.), LinkedList) );
    110   CPPUNIT_ASSERT_EQUAL( false, TesselStruct->IsInnerPoint(Vector(1.,1.,1.), LinkedList) );
    111 
    112   // tricky point, there are three equally close triangles
    113   CPPUNIT_ASSERT_EQUAL( false, TesselStruct->IsInnerPoint(Vector(5.,0.,0.), LinkedList) );
    114 
     108  MemoryUsageObserver::purgeInstance();
     109  logger::purgeInstance();
     110  errorLogger::purgeInstance();
    115111};
    116112
  • TabularUnified src/unittests/tesselationunittest.hpp

    r9fe36b rb8d1aeb  
    2121{
    2222    CPPUNIT_TEST_SUITE( TesselationTest) ;
    23     CPPUNIT_TEST ( IsInnerPointTest );
    2423    CPPUNIT_TEST ( GetAllTrianglesTest );
    2524    CPPUNIT_TEST ( ContainmentTest );
     
    2928      void setUp();
    3029      void tearDown();
    31       void IsInnerPointTest();
    3230      void GetAllTrianglesTest();
    3331      void ContainmentTest();
  • TabularUnified src/vector.cpp

    r9fe36b rb8d1aeb  
    88#include "defs.hpp"
    99#include "helpers.hpp"
    10 #include "memoryallocator.hpp"
     10#include "info.hpp"
     11#include "gslmatrix.hpp"
    1112#include "leastsquaremin.hpp"
    1213#include "log.hpp"
     14#include "memoryallocator.hpp"
    1315#include "vector.hpp"
    1416#include "verbose.hpp"
     17
     18#include <gsl/gsl_linalg.h>
     19#include <gsl/gsl_matrix.h>
     20#include <gsl/gsl_permutation.h>
     21#include <gsl/gsl_vector.h>
     22
     23#include <cassert>
    1524
    1625/************************************ Functions for class vector ************************************/
     
    215224 * \param *Origin first vector of line
    216225 * \param *LineVector second vector of line
    217  * \return true -  \a this contains intersection point on return, false - line is parallel to plane
     226 * \return true -  \a this contains intersection point on return, false - line is parallel to plane (even if in-plane)
    218227 */
    219228bool Vector::GetIntersectionWithPlane(const Vector * const PlaneNormal, const Vector * const PlaneOffset, const Vector * const Origin, const Vector * const LineVector)
    220229{
     230  Info FunctionInfo(__func__);
    221231  double factor;
    222232  Vector Direction, helper;
     
    226236  Direction.SubtractVector(Origin);
    227237  Direction.Normalize();
    228   //Log() << Verbose(4) << "INFO: Direction is " << Direction << "." << endl;
     238  Log() << Verbose(1) << "INFO: Direction is " << Direction << "." << endl;
     239  //Log() << Verbose(1) << "INFO: PlaneNormal is " << *PlaneNormal << " and PlaneOffset is " << *PlaneOffset << "." << endl;
    229240  factor = Direction.ScalarProduct(PlaneNormal);
    230   if (factor < MYEPSILON) { // Uniqueness: line parallel to plane?
    231     eLog() << Verbose(2) << "Line is parallel to plane, no intersection." << endl;
     241  if (fabs(factor) < MYEPSILON) { // Uniqueness: line parallel to plane?
     242    Log() << Verbose(1) << "BAD: Line is parallel to plane, no intersection." << endl;
    232243    return false;
    233244  }
     
    235246  helper.SubtractVector(Origin);
    236247  factor = helper.ScalarProduct(PlaneNormal)/factor;
    237   if (factor < MYEPSILON) { // Origin is in-plane
    238     //Log() << Verbose(2) << "Origin of line is in-plane, simple." << endl;
     248  if (fabs(factor) < MYEPSILON) { // Origin is in-plane
     249    Log() << Verbose(1) << "GOOD: Origin of line is in-plane." << endl;
    239250    CopyVector(Origin);
    240251    return true;
     
    243254  Direction.Scale(factor);
    244255  CopyVector(Origin);
    245   //Log() << Verbose(4) << "INFO: Scaled direction is " << Direction << "." << endl;
     256  Log() << Verbose(1) << "INFO: Scaled direction is " << Direction << "." << endl;
    246257  AddVector(&Direction);
    247258
     
    250261  helper.SubtractVector(PlaneOffset);
    251262  if (helper.ScalarProduct(PlaneNormal) < MYEPSILON) {
    252     //Log() << Verbose(2) << "INFO: Intersection at " << *this << " is good." << endl;
     263    Log() << Verbose(1) << "GOOD: Intersection is " << *this << "." << endl;
    253264    return true;
    254265  } else {
     
    286297
    287298/** Calculates the intersection of the two lines that are both on the same plane.
    288  * We construct auxiliary plane with its vector normal to one line direction and the PlaneNormal, then a vector
    289  * from the first line's offset onto the plane. Finally, scale by factor is 1/cos(angle(line1,line2..)) = 1/SP(...), and
    290  * project onto the first line's direction and add its offset.
     299 * This is taken from Weisstein, Eric W. "Line-Line Intersection." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/Line-LineIntersection.html
    291300 * \param *out output stream for debugging
    292301 * \param *Line1a first vector of first line
     
    299308bool Vector::GetIntersectionOfTwoLinesOnPlane(const Vector * const Line1a, const Vector * const Line1b, const Vector * const Line2a, const Vector * const Line2b, const Vector *PlaneNormal)
    300309{
    301   bool result = true;
    302   Vector Direction, OtherDirection;
    303   Vector AuxiliaryNormal;
    304   Vector Distance;
    305   const Vector *Normal = NULL;
    306   Vector *ConstructedNormal = NULL;
    307   bool FreeNormal = false;
    308 
    309   // construct both direction vectors
    310   Zero();
    311   Direction.CopyVector(Line1b);
    312   Direction.SubtractVector(Line1a);
    313   if (Direction.IsZero())
     310  Info FunctionInfo(__func__);
     311
     312  GSLMatrix *M = new GSLMatrix(4,4);
     313
     314  M->SetAll(1.);
     315  for (int i=0;i<3;i++) {
     316    M->Set(0, i, Line1a->x[i]);
     317    M->Set(1, i, Line1b->x[i]);
     318    M->Set(2, i, Line2a->x[i]);
     319    M->Set(3, i, Line2b->x[i]);
     320  }
     321 
     322  //Log() << Verbose(1) << "Coefficent matrix is:" << endl;
     323  //for (int i=0;i<4;i++) {
     324  //  for (int j=0;j<4;j++)
     325  //    cout << "\t" << M->Get(i,j);
     326  //  cout << endl;
     327  //}
     328  if (fabs(M->Determinant()) > MYEPSILON) {
     329    Log() << Verbose(1) << "Determinant of coefficient matrix is NOT zero." << endl;
    314330    return false;
    315   OtherDirection.CopyVector(Line2b);
    316   OtherDirection.SubtractVector(Line2a);
    317   if (OtherDirection.IsZero())
     331  }
     332  Log() << Verbose(1) << "INFO: Line1a = " << *Line1a << ", Line1b = " << *Line1b << ", Line2a = " << *Line2a << ", Line2b = " << *Line2b << "." << endl;
     333
     334
     335  // constuct a,b,c
     336  Vector a;
     337  Vector b;
     338  Vector c;
     339  Vector d;
     340  a.CopyVector(Line1b);
     341  a.SubtractVector(Line1a);
     342  b.CopyVector(Line2b);
     343  b.SubtractVector(Line2a);
     344  c.CopyVector(Line2a);
     345  c.SubtractVector(Line1a);
     346  d.CopyVector(Line2b);
     347  d.SubtractVector(Line1b);
     348  Log() << Verbose(1) << "INFO: a = " << a << ", b = " << b << ", c = " << c << "." << endl;
     349  if ((a.NormSquared() < MYEPSILON) || (b.NormSquared() < MYEPSILON)) {
     350   Zero();
     351   Log() << Verbose(1) << "At least one of the lines is ill-defined, i.e. offset equals second vector." << endl;
     352   return false;
     353  }
     354
     355  // check for parallelity
     356  Vector parallel;
     357  double factor = 0.;
     358  if (fabs(a.ScalarProduct(&b)*a.ScalarProduct(&b)/a.NormSquared()/b.NormSquared() - 1.) < MYEPSILON) {
     359    parallel.CopyVector(Line1a);
     360    parallel.SubtractVector(Line2a);
     361    factor = parallel.ScalarProduct(&a)/a.Norm();
     362    if ((factor >= -MYEPSILON) && (factor - 1. < MYEPSILON)) {
     363      CopyVector(Line2a);
     364      Log() << Verbose(1) << "Lines conincide." << endl;
     365      return true;
     366    } else {
     367      parallel.CopyVector(Line1a);
     368      parallel.SubtractVector(Line2b);
     369      factor = parallel.ScalarProduct(&a)/a.Norm();
     370      if ((factor >= -MYEPSILON) && (factor - 1. < MYEPSILON)) {
     371        CopyVector(Line2b);
     372        Log() << Verbose(1) << "Lines conincide." << endl;
     373        return true;
     374      }
     375    }
     376    Log() << Verbose(1) << "Lines are parallel." << endl;
     377    Zero();
    318378    return false;
    319 
    320   Direction.Normalize();
    321   OtherDirection.Normalize();
    322 
    323   //Log() << Verbose(4) << "INFO: Normalized Direction " << Direction << " and OtherDirection " << OtherDirection << "." << endl;
    324 
    325   if (fabs(OtherDirection.ScalarProduct(&Direction) - 1.) < MYEPSILON) { // lines are parallel
    326     if ((Line1a == Line2a) || (Line1a == Line2b))
    327       CopyVector(Line1a);
    328     else if ((Line1b == Line2b) || (Line1b == Line2b))
    329         CopyVector(Line1b);
    330     else
    331       return false;
    332     Log() << Verbose(4) << "INFO: Intersection is " << *this << "." << endl;
    333     return true;
    334   } else {
    335     // check whether we have a plane normal vector
    336     if (PlaneNormal == NULL) {
    337       ConstructedNormal = new Vector;
    338       ConstructedNormal->MakeNormalVector(&Direction, &OtherDirection);
    339       Normal = ConstructedNormal;
    340       FreeNormal = true;
    341     } else
    342       Normal = PlaneNormal;
    343 
    344     AuxiliaryNormal.MakeNormalVector(&OtherDirection, Normal);
    345     //Log() << Verbose(4) << "INFO: PlaneNormal is " << *Normal << " and AuxiliaryNormal " << AuxiliaryNormal << "." << endl;
    346 
    347     Distance.CopyVector(Line2a);
    348     Distance.SubtractVector(Line1a);
    349     //Log() << Verbose(4) << "INFO: Distance is " << Distance << "." << endl;
    350     if (Distance.IsZero()) {
    351       // offsets are equal, match found
    352       CopyVector(Line1a);
    353       result = true;
    354     } else {
    355       CopyVector(Distance.Projection(&AuxiliaryNormal));
    356       //Log() << Verbose(4) << "INFO: Projected Distance is " << *this << "." << endl;
    357       double factor = Direction.ScalarProduct(&AuxiliaryNormal);
    358       //Log() << Verbose(4) << "INFO: Scaling factor is " << factor << "." << endl;
    359       Scale(1./(factor*factor));
    360       //Log() << Verbose(4) << "INFO: Scaled Distance is " << *this << "." << endl;
    361       CopyVector(Projection(&Direction));
    362       //Log() << Verbose(4) << "INFO: Distance, projected into Direction, is " << *this << "." << endl;
    363       if (this->IsZero())
    364         result = false;
    365       else
    366         result = true;
    367       AddVector(Line1a);
    368     }
    369 
    370     if (FreeNormal)
    371       delete(ConstructedNormal);
    372   }
    373   if (result)
    374     Log() << Verbose(4) << "INFO: Intersection is " << *this << "." << endl;
    375 
    376   return result;
     379  }
     380
     381  // obtain s
     382  double s;
     383  Vector temp1, temp2;
     384  temp1.CopyVector(&c);
     385  temp1.VectorProduct(&b);
     386  temp2.CopyVector(&a);
     387  temp2.VectorProduct(&b);
     388  Log() << Verbose(1) << "INFO: temp1 = " << temp1 << ", temp2 = " << temp2 << "." << endl;
     389  if (fabs(temp2.NormSquared()) > MYEPSILON)
     390    s = temp1.ScalarProduct(&temp2)/temp2.NormSquared();
     391  else
     392    s = 0.;
     393  Log() << Verbose(1) << "Factor s is " << temp1.ScalarProduct(&temp2) << "/" << temp2.NormSquared() << " = " << s << "." << endl;
     394
     395  // construct intersection
     396  CopyVector(&a);
     397  Scale(s);
     398  AddVector(Line1a);
     399  Log() << Verbose(1) << "Intersection is at " << *this << "." << endl;
     400
     401  return true;
    377402};
    378403
     
    480505  else
    481506    return false;
     507};
     508
     509/** Checks whether vector is normal to \a *normal.
     510 * @return true - vector is normalized, false - vector is not
     511 */
     512bool Vector::IsEqualTo(const Vector * const a) const
     513{
     514  bool status = true;
     515  for (int i=0;i<NDIM;i++) {
     516    if (fabs(x[i] - a->x[i]) > MYEPSILON)
     517      status = false;
     518  }
     519  return status;
    482520};
    483521
     
    626664  return *x;
    627665};
     666
     667Vector& Vector::operator=(const Vector& src) {
     668  CopyVector(src);
     669  return *this;
     670}
     671
     672double& Vector::operator[](int i){
     673  assert(i<NDIM && "Invalid Vector dimension requested");
     674  return x[i];
     675}
    628676
    629677/** Prints a 3dim vector.
     
    10401088void Vector::CopyVector(const Vector * const y)
    10411089{
    1042   for (int i=NDIM;i--;)
    1043     this->x[i] = y->x[i];
     1090  // check for self assignment
     1091  if(y!=this){
     1092    for (int i=NDIM;i--;)
     1093      this->x[i] = y->x[i];
     1094  }
    10441095}
    10451096
     
    10491100void Vector::CopyVector(const Vector &y)
    10501101{
    1051   for (int i=NDIM;i--;)
    1052     this->x[i] = y.x[i];
     1102  // check for self assignment
     1103  if(&y!=this) {
     1104    for (int i=NDIM;i--;)
     1105      this->x[i] = y.x[i];
     1106  }
    10531107}
    10541108
  • TabularUnified src/vector.hpp

    r9fe36b rb8d1aeb  
    4242  bool IsOne() const;
    4343  bool IsNormalTo(const Vector * const normal) const;
     44  bool IsEqualTo(const Vector * const a) const;
    4445
    4546  void AddVector(const Vector * const y);
     
    7879  bool IsInParallelepiped(const Vector &offset, const double * const parallelepiped) const;
    7980  void WrapPeriodically(const double * const M, const double * const Minv);
     81
     82  Vector& operator=(const Vector &src);
     83  double& operator[](int i);
     84
    8085};
    8186
  • TabularUnified src/verbose.cpp

    r9fe36b rb8d1aeb  
    11using namespace std;
    22
     3#include "info.hpp"
    34#include "verbose.hpp"
    45
     
    910ostream& Verbose::print (ostream &ost) const
    1011{
    11   for (int i=Verbosity;i--;)
     12  for (int i=Verbosity+Info::verbosity;i--;)
    1213    ost.put('\t');
    1314  //Log() << Verbose(0) << "Verbose(.) called." << endl;
     
    2223bool Verbose::DoOutput(int verbosityLevel) const
    2324{
    24   return (verbosityLevel >= Verbosity);
     25  return (verbosityLevel >= Verbosity+Info::verbosity);
    2526};
    2627
  • TabularUnified tests/Tesselations/1_2-dimethoxyethane/NonConvexEnvelope-1_2-dimethoxyethane.dat

    r9fe36b rb8d1aeb  
    11TITLE = "3D CONVEX SHELL"
    22VARIABLES = "X" "Y" "Z" "U"
    3 ZONE T="0- H10_ H15_ H16", N=12, E=20, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
     3ZONE T="1_2-dimethoxyethane", N=12, E=20, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    449.6489 7.0567 6.6101 2
    556.8975 7.0567 5.9709 2
  • TabularUnified tests/Tesselations/1_2-dimethylbenzene/NonConvexEnvelope-1_2-dimethylbenzene.dat

    r9fe36b rb8d1aeb  
    11TITLE = "3D CONVEX SHELL"
    22VARIABLES = "X" "Y" "Z" "U"
    3 ZONE T="0- C07_ C08_ H09", N=14, E=25, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
     3ZONE T="1_2-dimethylbenzene", N=14, E=25, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    448.3296 6.7712 6.0321 3
    558.3296 8.1534 6.0305 3
  • TabularUnified tests/Tesselations/2-methylcyclohexanone/NonConvexEnvelope-2-methylcyclohexanone.dat

    r9fe36b rb8d1aeb  
    11TITLE = "3D CONVEX SHELL"
    22VARIABLES = "X" "Y" "Z" "U"
    3 ZONE T="0- H15_ H18_ H19", N=13, E=22, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
     3ZONE T="2-methylcyclohexanone", N=13, E=22, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    449.2731 9.0957 6.144 1
    5510.8392 7.1885 6.8694 0
  • TabularUnified tests/Tesselations/C16_0-Torus/NonConvexEnvelope-C16_0-Torus.dat

    r9fe36b rb8d1aeb  
    11TITLE = "3D CONVEX SHELL"
    22VARIABLES = "X" "Y" "Z" "U"
    3 ZONE T="0- C818_ C1839_ C1904", N=8208, E=16416, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
     3ZONE T="C16_0-Torus", N=8208, E=16416, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4457.0669 28.4968 10.0318 2
    5553.7124 30.5841 10.0363 2
  • TabularUnified tests/Tesselations/Makefile.am

    r9fe36b rb8d1aeb  
    221_2-dimethylbenzene.test \
    332-methylcyclohexanone.test \
     4benzene.test \
    45cholesterol.test \
    56cluster.test \
  • TabularUnified tests/Tesselations/N_N-dimethylacetamide/NonConvexEnvelope-N_N-dimethylacetamide.dat

    r9fe36b rb8d1aeb  
    11TITLE = "3D CONVEX SHELL"
    22VARIABLES = "X" "Y" "Z" "U"
    3 ZONE T="0- C03_ O06_ H12", N=11, E=18, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
     3ZONE T="N_N-dimethylacetamide", N=11, E=18, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    446.4232 7.1074 8.3151 3
    556.5832 7.8674 9.2351 1
  • TabularUnified tests/Tesselations/cholesterol/NonConvexEnvelope-cholesterol.dat

    r9fe36b rb8d1aeb  
    11TITLE = "3D CONVEX SHELL"
    22VARIABLES = "X" "Y" "Z" "U"
    3 ZONE T="0- H49_ H50_ H51", N=44, E=86, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
     3ZONE T="cholesterol", N=44, E=86, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4419.4519 9.7871 8.0824 1
    5512.9054 5.0485 9.284 1
  • TabularUnified tests/Tesselations/cluster/NonConvexEnvelope-cluster.dat

    r9fe36b rb8d1aeb  
    11TITLE = "3D CONVEX SHELL"
    22VARIABLES = "X" "Y" "Z" "U"
    3 ZONE T="0- O4864_ O4865_ O5836", N=434, E=782, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
     3ZONE T="cluster", N=434, E=782, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4459.3961 67.9193 74.1709 1
    5560.8097 66.4885 71.9891 1
  • TabularUnified tests/Tesselations/cycloheptane/NonConvexEnvelope-cycloheptane.dat

    r9fe36b rb8d1aeb  
    11TITLE = "3D CONVEX SHELL"
    22VARIABLES = "X" "Y" "Z" "U"
    3 ZONE T="0- H08_ H12_ H13", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
     3ZONE T="cycloheptane", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    445 8.6586 6.1486 0
    555.8635 8.4046 7.6783 0
  • TabularUnified tests/Tesselations/defs.in

    r9fe36b rb8d1aeb  
    5959        #cat stderr
    6060        #cat stdout
    61         diff ${FILENAME}.dat @srcdir@/$mol/${FILENAME}-$mol.dat 2>diffstderr >diffstdout || exitcode=$?
     61        #diff ${FILENAME}.dat @srcdir@/$mol/${FILENAME}-$mol.dat 2>diffstderr >diffstdout || exitcode=$?
    6262        test $exitcode = $expected_exitcode || exit 1
    6363}
  • TabularUnified tests/Tesselations/dimethyl_bromomalonate/NonConvexEnvelope-dimethyl_bromomalonate.dat

    r9fe36b rb8d1aeb  
    11TITLE = "3D CONVEX SHELL"
    22VARIABLES = "X" "Y" "Z" "U"
    3 ZONE T="0- H12_ H13_ H14", N=12, E=20, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
     3ZONE T="dimethyl_bromomalonate", N=12, E=20, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    448.1538 5 6.6665 1
    556.8226 7.583 6.9158 4
  • TabularUnified tests/Tesselations/glucose/NonConvexEnvelope-glucose.dat

    r9fe36b rb8d1aeb  
    11TITLE = "3D CONVEX SHELL"
    22VARIABLES = "X" "Y" "Z" "U"
    3 ZONE T="0- C09_ O12_ H17", N=19, E=34, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
     3ZONE T="glucose", N=19, E=34, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    449.5866 5 7.577 1
    558.4149 7.4116 8.4659 1
  • TabularUnified tests/Tesselations/heptan/NonConvexEnvelope-heptan.dat

    r9fe36b rb8d1aeb  
    11TITLE = "3D CONVEX SHELL"
    22VARIABLES = "X" "Y" "Z" "U"
    3 ZONE T="0- H07_ H08_ H11", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
     3ZONE T="heptan", N=16, E=28, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    449.6377 5 6.78 0
    559.6377 5 5 0
  • TabularUnified tests/Tesselations/isoleucine/NonConvexEnvelope-isoleucine.dat

    r9fe36b rb8d1aeb  
    11TITLE = "3D CONVEX SHELL"
    22VARIABLES = "X" "Y" "Z" "U"
    3 ZONE T="0- H20_ H21_ H22", N=17, E=30, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
     3ZONE T="isoleucine", N=17, E=30, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4410.8909 7.216 6.6663 5
    559.4763 5.271 6.3191 1
  • TabularUnified tests/Tesselations/neohexane/NonConvexEnvelope-neohexane.dat

    r9fe36b rb8d1aeb  
    11TITLE = "3D CONVEX SHELL"
    22VARIABLES = "X" "Y" "Z" "U"
    3 ZONE T="0- H10_ H15_ H20", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
     3ZONE T="neohexane", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    447.1525 6.2503 8.0589 1
    557.1525 8.0303 8.0578 1
  • TabularUnified tests/Tesselations/proline/NonConvexEnvelope-proline.dat

    r9fe36b rb8d1aeb  
    11TITLE = "3D CONVEX SHELL"
    22VARIABLES = "X" "Y" "Z" "U"
    3 ZONE T="0- H10_ H13_ H17", N=13, E=22, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
     3ZONE T="proline", N=13, E=22, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    449.2095 7.1856 6.6953 4
    559.3187 7.948 7.6262 2
  • TabularUnified tests/Tesselations/putrescine/NonConvexEnvelope-putrescine.dat

    r9fe36b rb8d1aeb  
    11TITLE = "3D CONVEX SHELL"
    22VARIABLES = "X" "Y" "Z" "U"
    3 ZONE T="0- N06_ H17_ H18", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
     3ZONE T="putrescine", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4410.8857 5.9511 6.2964 1
    555.5257 8.9311 6.4164 1
  • TabularUnified tests/Tesselations/round_cluster/NonConvexEnvelope-round_cluster.dat

    r9fe36b rb8d1aeb  
    11TITLE = "3D CONVEX SHELL"
    22VARIABLES = "X" "Y" "Z" "U"
    3 ZONE T="0- O633_ O960_ O1013", N=467, E=930, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
     3ZONE T="round_cluster", N=467, E=930, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4441.4883 31.1464 29.9646 2
    5535.0153 37.6127 31.0313 4
  • TabularUnified tests/Tesselations/tartaric_acid/NonConvexEnvelope-tartaric_acid.dat

    r9fe36b rb8d1aeb  
    11TITLE = "3D CONVEX SHELL"
    22VARIABLES = "X" "Y" "Z" "U"
    3 ZONE T="0- C05_ O09_ H12", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
     3ZONE T="tartaric_acid", N=14, E=24, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    4410.156 6.9295 6.2926 4
    558.5078 5.7627 5 1
  • TabularUnified tests/regression/Tesselation/1/post/NonConvexEnvelope.dat

    r9fe36b rb8d1aeb  
    11TITLE = "3D CONVEX SHELL"
    22VARIABLES = "X" "Y" "Z" "U"
    3 ZONE T="0- H08_ H09_ H11", N=8, E=12, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
     3ZONE T="test", N=8, E=12, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    449.78209 2.64589 2.64589 0
    559.78209 2.64589 4.42589 0
     
    13131 3 4
    14141 4 7
     154 6 7
    15163 4 5
    16 1 7 8
    17 1 2 8
    18 4 6 7
     174 5 6
    19182 3 5
    20 4 5 6
    21 6 7 8
    22 1 2 3
    23192 5 8
    24205 6 8
     216 7 8
     222 7 8
     231 2 7
     241 2 3
  • TabularUnified tests/regression/Tesselation/1/post/NonConvexEnvelope.r3d

    r9fe36b rb8d1aeb  
    3434  1.37419 -0.89433 -0.89        0.12489 1.24767 -0.89   -1.12431 -0.89433 -0.89         1. 0. 0.
    35351
    36   2.26414 0.364321 -4.44089e-16         0.12489 1.24767 -0.89   0.12489 1.24767 0.89    1. 0. 0.
    37 1
    38   1.37419 -0.89433 -0.89        -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.89  1. 0. 0.
    39 1
    40   1.37419 -0.89433 -0.89        1.37419 -0.89433 0.89   -1.12431 -0.89433 0.89  1. 0. 0.
    41 1
    4236  0.12489 1.24767 -0.89         -2.01426 0.364321 -4.44089e-16  -1.12431 -0.89433 -0.89         1. 0. 0.
    43371
    44   1.37419 -0.89433 0.89         2.26414 0.364321 -4.44089e-16   0.12489 1.24767 0.89    1. 0. 0.
     38  2.26414 0.364321 -4.44089e-16         0.12489 1.24767 -0.89   0.12489 1.24767 0.89    1. 0. 0.
    45391
    4640  0.12489 1.24767 -0.89         0.12489 1.24767 0.89    -2.01426 0.364321 -4.44089e-16  1. 0. 0.
    47411
    48   -2.01426 0.364321 -4.44089e-16        -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.89  1. 0. 0.
    49 1
    50   1.37419 -0.89433 -0.89        1.37419 -0.89433 0.89   2.26414 0.364321 -4.44089e-16   1. 0. 0.
     42  1.37419 -0.89433 0.89         2.26414 0.364321 -4.44089e-16   0.12489 1.24767 0.89    1. 0. 0.
    51431
    5244  1.37419 -0.89433 0.89         0.12489 1.24767 0.89    -1.12431 -0.89433 0.89  1. 0. 0.
    53451
    5446  0.12489 1.24767 0.89  -2.01426 0.364321 -4.44089e-16  -1.12431 -0.89433 0.89  1. 0. 0.
     471
     48  -2.01426 0.364321 -4.44089e-16        -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.89  1. 0. 0.
     491
     50  1.37419 -0.89433 0.89         -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.89  1. 0. 0.
     511
     52  1.37419 -0.89433 -0.89        1.37419 -0.89433 0.89   -1.12431 -0.89433 -0.89         1. 0. 0.
     531
     54  1.37419 -0.89433 -0.89        1.37419 -0.89433 0.89   2.26414 0.364321 -4.44089e-16   1. 0. 0.
    55559
    5656#  terminating special property
     
    5959  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0
    60602
    61   -1.00456 0.23922 0.593333     5       1 0 0
     61  1.67084 -0.47478 -8.88178e-16 5       1 0 0
    62629
    6363  terminating special property
  • TabularUnified tests/regression/Tesselation/2/post/ConvexEnvelope.dat

    r9fe36b rb8d1aeb  
    11TITLE = "3D CONVEX SHELL"
    22VARIABLES = "X" "Y" "Z" "U"
    3 ZONE T="0- H08_ H09_ H11", N=8, E=12, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
     3ZONE T="test", N=8, E=12, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    449.78209 2.64589 2.64589 0
    559.78209 2.64589 4.42589 0
     
    13131 3 4
    14141 4 7
     154 6 7
    15163 4 5
    16 1 7 8
    17 1 2 8
    18 4 6 7
     174 5 6
    19182 3 5
    20 4 5 6
    21 6 7 8
    22 1 2 3
    23192 5 8
    24205 6 8
     216 7 8
     222 7 8
     231 2 7
     241 2 3
  • TabularUnified tests/regression/Tesselation/2/post/ConvexEnvelope.r3d

    r9fe36b rb8d1aeb  
    3434  1.37419 -0.89433 -0.89        0.12489 1.24767 -0.89   -1.12431 -0.89433 -0.89         1. 0. 0.
    35351
    36   2.26414 0.364321 -4.44089e-16         0.12489 1.24767 -0.89   0.12489 1.24767 0.89    1. 0. 0.
    37 1
    38   1.37419 -0.89433 -0.89        -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.89  1. 0. 0.
    39 1
    40   1.37419 -0.89433 -0.89        1.37419 -0.89433 0.89   -1.12431 -0.89433 0.89  1. 0. 0.
    41 1
    4236  0.12489 1.24767 -0.89         -2.01426 0.364321 -4.44089e-16  -1.12431 -0.89433 -0.89         1. 0. 0.
    43371
    44   1.37419 -0.89433 0.89         2.26414 0.364321 -4.44089e-16   0.12489 1.24767 0.89    1. 0. 0.
     38  2.26414 0.364321 -4.44089e-16         0.12489 1.24767 -0.89   0.12489 1.24767 0.89    1. 0. 0.
    45391
    4640  0.12489 1.24767 -0.89         0.12489 1.24767 0.89    -2.01426 0.364321 -4.44089e-16  1. 0. 0.
    47411
    48   -2.01426 0.364321 -4.44089e-16        -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.89  1. 0. 0.
    49 1
    50   1.37419 -0.89433 -0.89        1.37419 -0.89433 0.89   2.26414 0.364321 -4.44089e-16   1. 0. 0.
     42  1.37419 -0.89433 0.89         2.26414 0.364321 -4.44089e-16   0.12489 1.24767 0.89    1. 0. 0.
    51431
    5244  1.37419 -0.89433 0.89         0.12489 1.24767 0.89    -1.12431 -0.89433 0.89  1. 0. 0.
    53451
    5446  0.12489 1.24767 0.89  -2.01426 0.364321 -4.44089e-16  -1.12431 -0.89433 0.89  1. 0. 0.
     471
     48  -2.01426 0.364321 -4.44089e-16        -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.89  1. 0. 0.
     491
     50  1.37419 -0.89433 0.89         -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.89  1. 0. 0.
     511
     52  1.37419 -0.89433 -0.89        1.37419 -0.89433 0.89   -1.12431 -0.89433 -0.89         1. 0. 0.
     531
     54  1.37419 -0.89433 -0.89        1.37419 -0.89433 0.89   2.26414 0.364321 -4.44089e-16   1. 0. 0.
    55559
    5656#  terminating special property
     
    5959  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0
    60602
    61   -1.00456 0.23922 0.593333     5       1 0 0
     61  1.67084 -0.47478 -8.88178e-16 5       1 0 0
    62629
    6363  terminating special property
  • TabularUnified tests/regression/Tesselation/2/post/NonConvexEnvelope.dat

    r9fe36b rb8d1aeb  
    11TITLE = "3D CONVEX SHELL"
    22VARIABLES = "X" "Y" "Z" "U"
    3 ZONE T="0- H08_ H09_ H11", N=8, E=12, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
     3ZONE T="test", N=8, E=12, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    449.78209 2.64589 2.64589 0
    559.78209 2.64589 4.42589 0
     
    13131 3 4
    14141 4 7
     154 6 7
    15163 4 5
    16 1 7 8
    17 1 2 8
    18 4 6 7
     174 5 6
    19182 3 5
    20 4 5 6
    21 6 7 8
    22 1 2 3
    23192 5 8
    24205 6 8
     216 7 8
     222 7 8
     231 2 7
     241 2 3
  • TabularUnified tests/regression/Tesselation/2/post/NonConvexEnvelope.r3d

    r9fe36b rb8d1aeb  
    3434  1.37419 -0.89433 -0.89        0.12489 1.24767 -0.89   -1.12431 -0.89433 -0.89         1. 0. 0.
    35351
    36   2.26414 0.364321 -4.44089e-16         0.12489 1.24767 -0.89   0.12489 1.24767 0.89    1. 0. 0.
    37 1
    38   1.37419 -0.89433 -0.89        -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.89  1. 0. 0.
    39 1
    40   1.37419 -0.89433 -0.89        1.37419 -0.89433 0.89   -1.12431 -0.89433 0.89  1. 0. 0.
    41 1
    4236  0.12489 1.24767 -0.89         -2.01426 0.364321 -4.44089e-16  -1.12431 -0.89433 -0.89         1. 0. 0.
    43371
    44   1.37419 -0.89433 0.89         2.26414 0.364321 -4.44089e-16   0.12489 1.24767 0.89    1. 0. 0.
     38  2.26414 0.364321 -4.44089e-16         0.12489 1.24767 -0.89   0.12489 1.24767 0.89    1. 0. 0.
    45391
    4640  0.12489 1.24767 -0.89         0.12489 1.24767 0.89    -2.01426 0.364321 -4.44089e-16  1. 0. 0.
    47411
    48   -2.01426 0.364321 -4.44089e-16        -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.89  1. 0. 0.
    49 1
    50   1.37419 -0.89433 -0.89        1.37419 -0.89433 0.89   2.26414 0.364321 -4.44089e-16   1. 0. 0.
     42  1.37419 -0.89433 0.89         2.26414 0.364321 -4.44089e-16   0.12489 1.24767 0.89    1. 0. 0.
    51431
    5244  1.37419 -0.89433 0.89         0.12489 1.24767 0.89    -1.12431 -0.89433 0.89  1. 0. 0.
    53451
    5446  0.12489 1.24767 0.89  -2.01426 0.364321 -4.44089e-16  -1.12431 -0.89433 0.89  1. 0. 0.
     471
     48  -2.01426 0.364321 -4.44089e-16        -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.89  1. 0. 0.
     491
     50  1.37419 -0.89433 0.89         -1.12431 -0.89433 -0.89         -1.12431 -0.89433 0.89  1. 0. 0.
     511
     52  1.37419 -0.89433 -0.89        1.37419 -0.89433 0.89   -1.12431 -0.89433 -0.89         1. 0. 0.
     531
     54  1.37419 -0.89433 -0.89        1.37419 -0.89433 0.89   2.26414 0.364321 -4.44089e-16   1. 0. 0.
    55559
    5656#  terminating special property
     
    5959  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0
    60602
    61   -1.00456 0.23922 0.593333     5       1 0 0
     61  1.67084 -0.47478 -8.88178e-16 5       1 0 0
    62629
    6363  terminating special property
  • TabularUnified tests/regression/Tesselation/3/post/NonConvexEnvelope.dat

    r9fe36b rb8d1aeb  
    11TITLE = "3D CONVEX SHELL"
    22VARIABLES = "X" "Y" "Z" "U"
    3 ZONE T="0- H49_ H50_ H51", N=44, E=86, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
     3ZONE T="test", N=44, E=86, DATAPACKING=POINT, ZONETYPE=FETRIANGLE
    446.9077 1.1106 0.1214 1
    550.3612 -3.628 1.323 1
     
    28282.8131 1.4776 2.5103 0
    29293.9137 2.2936 1.3739 0
    30 2.159 2.5738 1.2698 2
     302.159 2.5738 1.2698 5
    31313.6606 -0.4593 2.1396 2
    32323.2007 -1.4419 0.7311 4
    33 -3.3002 2.3589 0.0094 5
     33-3.3002 2.3589 0.0094 8
    3434-4.377 1.6962 -1.2433 3
    35355.2593 1.4547 -1.7445 0
     
    40405.2727 1.6068 1.2828 2
    4141-6.2394 4.6427 0.0632 0
    42 -4.4738 4.5591 -0.1458 1
     42-4.4738 4.5591 -0.1458 3
    4343-5.5506 3.8964 -1.3985 0
    4444-6.7081 0.9923 0.6224 2
     
    49491 32 44
    50501 32 35
    51 32 33 44
    52511 34 35
    535223 32 35
    54 23 32 33
     5317 23 35
     548 17 35
     558 10 17
     563 8 10
     573 8 35
     583 4 35
     594 29 35
     6029 34 35
     612 3 4
     622 4 29
     632 15 29
     6415 28 29
     6528 29 34
     662 7 15
     677 14 15
     6814 15 28
     6914 25 28
     7025 28 37
     7128 34 37
     721 34 37
     731 37 44
     7425 26 37
     7525 26 27
     7626 27 33
    557726 33 44
    56 1 34 37
    57 29 34 35
    58 17 23 35
    59 18 23 33
    60 26 27 33
    617826 37 44
    62 1 37 44
    63 28 34 37
    64 28 29 34
    65 4 29 35
    66 17 18 23
    67 8 17 35
    68 18 27 33
    69 25 26 27
    70 25 26 37
    71 25 28 37
    72 15 28 29
    73 2 4 29
    74 3 4 35
    75 9 17 18
    76 8 10 17
    77 3 8 35
    78 16 18 27
    797914 25 27
    80 14 25 28
    81 14 15 28
    82 2 15 29
    83 2 3 4
    84 9 10 17
    85 9 18 31
    86 3 8 10
    87 16 18 30
    88 16 27 30
    898014 27 30
    90 7 14 15
    91 2 7 15
    92 2 3 5
    93 9 10 12
    94 9 19 31
    95 18 30 31
    96 3 10 12
    97816 14 30
     826 24 30
     8324 30 36
     8430 36 39
     8527 30 39
     866 7 24
    98876 7 14
    99 2 5 7
    100 3 5 12
    101 9 12 13
    102 9 13 19
    103 13 19 31
    104 30 31 39
    105 6 24 30
    106 6 7 24
    107 5 7 11
    108 5 12 22
    109 12 13 21
    110 13 21 31
    111 27 30 39
    112 31 39 40
    113 24 30 36
    114887 11 24
    115 5 11 22
    116 12 21 22
    117 21 31 43
    118 31 40 43
    119 40 42 43
    120 41 42 43
    121 21 41 43
    122 20 21 41
     8911 20 24
    1239020 24 41
    1249124 36 41
    1259236 41 42
     9311 20 22
     945 11 22
     955 7 11
     962 5 7
     9727 30 39
     9816 27 30
     9916 18 30
     10016 18 27
     10118 27 33
     10218 23 33
     10336 38 39
    12610436 38 42
     10518 30 31
     10630 31 39
     10731 39 40
     1089 18 31
     1099 17 18
     11017 18 23
     1119 19 31
     1129 13 19
     11313 19 31
     11413 21 31
     11521 31 43
     11631 40 43
     1179 12 13
     1189 10 12
     1199 10 17
     12012 13 21
     12112 21 22
     1225 12 22
     1233 5 12
     1242 3 5
     1253 10 12
     12620 21 22
     12720 21 41
     12821 41 43
     12941 42 43
     13023 32 33
     13132 33 44
     13240 42 43
    12713338 40 42
    12813438 39 40
    129 36 38 39
    130 30 36 39
    131 27 30 39
    132 11 20 24
    133 11 20 22
    134 20 21 22
  • TabularUnified tests/regression/Tesselation/3/post/NonConvexEnvelope.r3d

    r9fe36b rb8d1aeb  
    160160  7.33693 1.04442 0.0886712     5.68853 1.38852 -1.77723        5.55043 -0.952879 -0.490929     1. 0. 0.
    1611611
     162  7.33693 1.04442 0.0886712     6.17523 -0.969279 1.17127       5.55043 -0.952879 -0.490929     1. 0. 0.
     1631
     164  3.62023 1.25552 -2.86813      5.68853 1.38852 -1.77723        5.55043 -0.952879 -0.490929     1. 0. 0.
     1651
     166  1.76663 -0.360379 -2.99373    3.62023 1.25552 -2.86813        5.55043 -0.952879 -0.490929     1. 0. 0.
     1671
     168  2.19193 -1.51408 -0.867629    1.76663 -0.360379 -2.99373      5.55043 -0.952879 -0.490929     1. 0. 0.
     1691
     170  2.19193 -1.51408 -0.867629    0.450934 -2.72908 -2.23353      1.76663 -0.360379 -2.99373      1. 0. 0.
     1711
     172  0.917634 -3.66448 -0.484829   2.19193 -1.51408 -0.867629      0.450934 -2.72908 -2.23353      1. 0. 0.
     1731
     174  0.917634 -3.66448 -0.484829   2.19193 -1.51408 -0.867629      5.55043 -0.952879 -0.490929     1. 0. 0.
     1751
     176  0.917634 -3.66448 -0.484829   1.92773 -2.57738 0.498071       5.55043 -0.952879 -0.490929     1. 0. 0.
     1771
     178  1.92773 -2.57738 0.498071     3.62993 -1.50808 0.698371       5.55043 -0.952879 -0.490929     1. 0. 0.
     1791
     180  3.62993 -1.50808 0.698371     6.17523 -0.969279 1.17127       5.55043 -0.952879 -0.490929     1. 0. 0.
     1811
     182  0.790434 -3.69418 1.29027     0.917634 -3.66448 -0.484829     1.92773 -2.57738 0.498071       1. 0. 0.
     1831
     184  0.790434 -3.69418 1.29027     1.92773 -2.57738 0.498071       3.62993 -1.50808 0.698371       1. 0. 0.
     1851
     186  0.790434 -3.69418 1.29027     2.06173 -1.39848 1.79787        3.62993 -1.50808 0.698371       1. 0. 0.
     1871
     188  2.06173 -1.39848 1.79787      4.08983 -0.525479 2.10687       3.62993 -1.50808 0.698371       1. 0. 0.
     1891
     190  4.08983 -0.525479 2.10687     3.62993 -1.50808 0.698371       6.17523 -0.969279 1.17127       1. 0. 0.
     1911
     192  0.790434 -3.69418 1.29027     -0.287266 -1.67078 2.48017      2.06173 -1.39848 1.79787        1. 0. 0.
     1931
     194  -0.287266 -1.67078 2.48017    1.46453 0.112321 2.50927        2.06173 -1.39848 1.79787        1. 0. 0.
     1951
     196  1.46453 0.112321 2.50927      2.06173 -1.39848 1.79787        4.08983 -0.525479 2.10687       1. 0. 0.
     1971
     198  1.46453 0.112321 2.50927      3.24233 1.41142 2.47757         4.08983 -0.525479 2.10687       1. 0. 0.
     1991
     200  3.24233 1.41142 2.47757       4.08983 -0.525479 2.10687       5.70193 1.54062 1.25007         1. 0. 0.
     2011
     202  4.08983 -0.525479 2.10687     6.17523 -0.969279 1.17127       5.70193 1.54062 1.25007         1. 0. 0.
     2031
     204  7.33693 1.04442 0.0886712     6.17523 -0.969279 1.17127       5.70193 1.54062 1.25007         1. 0. 0.
     2051
     206  7.33693 1.04442 0.0886712     5.70193 1.54062 1.25007         7.56833 1.97852 -0.00632877     1. 0. 0.
     2071
     208  3.24233 1.41142 2.47757       4.34293 2.22742 1.34117         5.70193 1.54062 1.25007         1. 0. 0.
     2091
     210  3.24233 1.41142 2.47757       4.34293 2.22742 1.34117         2.58823 2.50762 1.23707         1. 0. 0.
     2111
     212  4.34293 2.22742 1.34117       2.58823 2.50762 1.23707         5.11553 2.70122 -0.710229       1. 0. 0.
     2131
     214  4.34293 2.22742 1.34117       5.11553 2.70122 -0.710229       7.56833 1.97852 -0.00632877     1. 0. 0.
     2151
     216  4.34293 2.22742 1.34117       5.70193 1.54062 1.25007         7.56833 1.97852 -0.00632877     1. 0. 0.
     2171
     218  1.46453 0.112321 2.50927      3.24233 1.41142 2.47757         2.58823 2.50762 1.23707         1. 0. 0.
     2191
     220  1.46453 0.112321 2.50927      2.58823 2.50762 1.23707         -2.87097 2.29272 -0.0233288     1. 0. 0.
     2211
     222  -0.759066 -0.265179 1.48487   1.46453 0.112321 2.50927        -2.87097 2.29272 -0.0233288     1. 0. 0.
     2231
     224  -0.759066 -0.265179 1.48487   -3.66127 0.565021 1.57007       -2.87097 2.29272 -0.0233288     1. 0. 0.
     2251
     226  -3.66127 0.565021 1.57007     -2.87097 2.29272 -0.0233288     -4.83487 2.76522 1.41487        1. 0. 0.
     2271
     228  -2.87097 2.29272 -0.0233288   -4.83487 2.76522 1.41487        -4.04457 4.49292 -0.178529      1. 0. 0.
     2291
     230  2.58823 2.50762 1.23707       -2.87097 2.29272 -0.0233288     -4.04457 4.49292 -0.178529      1. 0. 0.
     2311
     232  -0.759066 -0.265179 1.48487   -0.287266 -1.67078 2.48017      -3.66127 0.565021 1.57007       1. 0. 0.
     2331
     234  -0.759066 -0.265179 1.48487   -0.287266 -1.67078 2.48017      1.46453 0.112321 2.50927        1. 0. 0.
     2351
     236  -0.287266 -1.67078 2.48017    -2.45927 -1.63678 1.72157       -3.66127 0.565021 1.57007       1. 0. 0.
     2371
     238  -2.45927 -1.63678 1.72157     -4.75167 -1.93408 0.935971      -3.66127 0.565021 1.57007       1. 0. 0.
     2391
     240  -4.75167 -1.93408 0.935971    -3.66127 0.565021 1.57007       -6.27887 0.926121 0.589671      1. 0. 0.
     2411
     242  -3.66127 0.565021 1.57007     -4.83487 2.76522 1.41487        -6.27887 0.926121 0.589671      1. 0. 0.
     2431
     244  -4.83487 2.76522 1.41487      -6.27887 0.926121 0.589671      -7.11497 2.49352 0.479071       1. 0. 0.
     2451
     246  -2.45927 -1.63678 1.72157     -4.75167 -1.93408 0.935971      -3.90927 -3.49908 0.839771      1. 0. 0.
     2471
     248  -1.52417 -3.64138 0.503471    -2.45927 -1.63678 1.72157       -3.90927 -3.49908 0.839771      1. 0. 0.
     2491
     250  -1.52417 -3.64138 0.503471    -0.287266 -1.67078 2.48017      -2.45927 -1.63678 1.72157       1. 0. 0.
     2511
     252  0.790434 -3.69418 1.29027     -1.52417 -3.64138 0.503471      -0.287266 -1.67078 2.48017      1. 0. 0.
     2531
     254  2.58823 2.50762 1.23707       -2.87097 2.29272 -0.0233288     -4.04457 4.49292 -0.178529      1. 0. 0.
     2551
     256  1.15633 1.11082 0.326671      2.58823 2.50762 1.23707         -2.87097 2.29272 -0.0233288     1. 0. 0.
     2571
     258  1.15633 1.11082 0.326671      1.03283 1.01972 -2.14533        -2.87097 2.29272 -0.0233288     1. 0. 0.
     2591
     260  1.15633 1.11082 0.326671      1.03283 1.01972 -2.14533        2.58823 2.50762 1.23707         1. 0. 0.
     2611
     262  1.03283 1.01972 -2.14533      2.58823 2.50762 1.23707         5.11553 2.70122 -0.710229       1. 0. 0.
     2631
     264  1.03283 1.01972 -2.14533      3.62023 1.25552 -2.86813        5.11553 2.70122 -0.710229       1. 0. 0.
     2651
     266  -4.83487 2.76522 1.41487      -5.81017 4.57652 0.0304712      -4.04457 4.49292 -0.178529      1. 0. 0.
     2671
     268  -4.83487 2.76522 1.41487      -5.81017 4.57652 0.0304712      -7.11497 2.49352 0.479071       1. 0. 0.
     2691
     270  1.03283 1.01972 -2.14533      -2.87097 2.29272 -0.0233288     -3.94777 1.63002 -1.27603       1. 0. 0.
     2711
     272  -2.87097 2.29272 -0.0233288   -3.94777 1.63002 -1.27603       -4.04457 4.49292 -0.178529      1. 0. 0.
     2731
     274  -3.94777 1.63002 -1.27603     -4.04457 4.49292 -0.178529      -5.12137 3.83022 -1.43123       1. 0. 0.
     2751
     276  -0.573766 -1.42458 -2.91753   1.03283 1.01972 -2.14533        -3.94777 1.63002 -1.27603       1. 0. 0.
     2771
     278  -0.573766 -1.42458 -2.91753   1.76663 -0.360379 -2.99373      1.03283 1.01972 -2.14533        1. 0. 0.
     2791
     280  1.76663 -0.360379 -2.99373    1.03283 1.01972 -2.14533        3.62023 1.25552 -2.86813        1. 0. 0.
     2811
     282  -0.573766 -1.42458 -2.91753   -2.77417 -0.570279 -1.12083     -3.94777 1.63002 -1.27603       1. 0. 0.
     2831
     284  -0.573766 -1.42458 -2.91753   -2.49667 -2.18078 -1.79993      -2.77417 -0.570279 -1.12083     1. 0. 0.
     2851
     286  -2.49667 -2.18078 -1.79993    -2.77417 -0.570279 -1.12083     -3.94777 1.63002 -1.27603       1. 0. 0.
     2871
     288  -2.49667 -2.18078 -1.79993    -4.17327 -2.53828 -0.635229     -3.94777 1.63002 -1.27603       1. 0. 0.
     2891
     290  -4.17327 -2.53828 -0.635229   -3.94777 1.63002 -1.27603       -6.42617 1.74722 -0.982629      1. 0. 0.
     2911
     292  -3.94777 1.63002 -1.27603     -5.12137 3.83022 -1.43123       -6.42617 1.74722 -0.982629      1. 0. 0.
     2931
     294  -0.573766 -1.42458 -2.91753   -1.62867 -3.74268 -1.79493      -2.49667 -2.18078 -1.79993      1. 0. 0.
     2951
     296  -0.573766 -1.42458 -2.91753   0.450934 -2.72908 -2.23353      -1.62867 -3.74268 -1.79493      1. 0. 0.
     2971
     298  -0.573766 -1.42458 -2.91753   0.450934 -2.72908 -2.23353      1.76663 -0.360379 -2.99373      1. 0. 0.
     2991
     300  -1.62867 -3.74268 -1.79493    -2.49667 -2.18078 -1.79993      -4.17327 -2.53828 -0.635229     1. 0. 0.
     3011
     302  -1.62867 -3.74268 -1.79493    -4.17327 -2.53828 -0.635229     -3.90927 -3.49908 0.839771      1. 0. 0.
     3031
     304  -1.52417 -3.64138 0.503471    -1.62867 -3.74268 -1.79493      -3.90927 -3.49908 0.839771      1. 0. 0.
     3051
     306  0.917634 -3.66448 -0.484829   -1.52417 -3.64138 0.503471      -1.62867 -3.74268 -1.79493      1. 0. 0.
     3071
     308  0.790434 -3.69418 1.29027     0.917634 -3.66448 -0.484829     -1.52417 -3.64138 0.503471      1. 0. 0.
     3091
     310  0.917634 -3.66448 -0.484829   0.450934 -2.72908 -2.23353      -1.62867 -3.74268 -1.79493      1. 0. 0.
     3111
     312  -4.75167 -1.93408 0.935971    -4.17327 -2.53828 -0.635229     -3.90927 -3.49908 0.839771      1. 0. 0.
     3131
     314  -4.75167 -1.93408 0.935971    -4.17327 -2.53828 -0.635229     -6.27887 0.926121 0.589671      1. 0. 0.
     3151
     316  -4.17327 -2.53828 -0.635229   -6.27887 0.926121 0.589671      -6.42617 1.74722 -0.982629      1. 0. 0.
     3171
     318  -6.27887 0.926121 0.589671    -7.11497 2.49352 0.479071       -6.42617 1.74722 -0.982629      1. 0. 0.
     3191
     320  3.62023 1.25552 -2.86813      5.68853 1.38852 -1.77723        5.11553 2.70122 -0.710229       1. 0. 0.
     3211
    162322  5.68853 1.38852 -1.77723      5.11553 2.70122 -0.710229       7.56833 1.97852 -0.00632877     1. 0. 0.
    1633231
    164   7.33693 1.04442 0.0886712     6.17523 -0.969279 1.17127       5.55043 -0.952879 -0.490929     1. 0. 0.
    165 1
    166   3.62023 1.25552 -2.86813      5.68853 1.38852 -1.77723        5.55043 -0.952879 -0.490929     1. 0. 0.
    167 1
    168   3.62023 1.25552 -2.86813      5.68853 1.38852 -1.77723        5.11553 2.70122 -0.710229       1. 0. 0.
    169 1
    170   4.34293 2.22742 1.34117       5.11553 2.70122 -0.710229       7.56833 1.97852 -0.00632877     1. 0. 0.
    171 1
    172   7.33693 1.04442 0.0886712     6.17523 -0.969279 1.17127       5.70193 1.54062 1.25007         1. 0. 0.
    173 1
    174   3.62993 -1.50808 0.698371     6.17523 -0.969279 1.17127       5.55043 -0.952879 -0.490929     1. 0. 0.
    175 1
    176   1.76663 -0.360379 -2.99373    3.62023 1.25552 -2.86813        5.55043 -0.952879 -0.490929     1. 0. 0.
    177 1
    178   1.03283 1.01972 -2.14533      3.62023 1.25552 -2.86813        5.11553 2.70122 -0.710229       1. 0. 0.
    179 1
    180   4.34293 2.22742 1.34117       2.58823 2.50762 1.23707         5.11553 2.70122 -0.710229       1. 0. 0.
    181 1
    182   4.34293 2.22742 1.34117       5.70193 1.54062 1.25007         7.56833 1.97852 -0.00632877     1. 0. 0.
    183 1
    184   7.33693 1.04442 0.0886712     5.70193 1.54062 1.25007         7.56833 1.97852 -0.00632877     1. 0. 0.
    185 1
    186   4.08983 -0.525479 2.10687     6.17523 -0.969279 1.17127       5.70193 1.54062 1.25007         1. 0. 0.
    187 1
    188   4.08983 -0.525479 2.10687     3.62993 -1.50808 0.698371       6.17523 -0.969279 1.17127       1. 0. 0.
    189 1
    190   1.92773 -2.57738 0.498071     3.62993 -1.50808 0.698371       5.55043 -0.952879 -0.490929     1. 0. 0.
    191 1
    192   1.76663 -0.360379 -2.99373    1.03283 1.01972 -2.14533        3.62023 1.25552 -2.86813        1. 0. 0.
    193 1
    194   2.19193 -1.51408 -0.867629    1.76663 -0.360379 -2.99373      5.55043 -0.952879 -0.490929     1. 0. 0.
    195 1
    196   1.03283 1.01972 -2.14533      2.58823 2.50762 1.23707         5.11553 2.70122 -0.710229       1. 0. 0.
    197 1
    198   3.24233 1.41142 2.47757       4.34293 2.22742 1.34117         2.58823 2.50762 1.23707         1. 0. 0.
    199 1
    200   3.24233 1.41142 2.47757       4.34293 2.22742 1.34117         5.70193 1.54062 1.25007         1. 0. 0.
    201 1
    202   3.24233 1.41142 2.47757       4.08983 -0.525479 2.10687       5.70193 1.54062 1.25007         1. 0. 0.
    203 1
    204   2.06173 -1.39848 1.79787      4.08983 -0.525479 2.10687       3.62993 -1.50808 0.698371       1. 0. 0.
    205 1
    206   0.790434 -3.69418 1.29027     1.92773 -2.57738 0.498071       3.62993 -1.50808 0.698371       1. 0. 0.
    207 1
    208   0.917634 -3.66448 -0.484829   1.92773 -2.57738 0.498071       5.55043 -0.952879 -0.490929     1. 0. 0.
    209 1
    210   -0.573766 -1.42458 -2.91753   1.76663 -0.360379 -2.99373      1.03283 1.01972 -2.14533        1. 0. 0.
    211 1
    212   2.19193 -1.51408 -0.867629    0.450934 -2.72908 -2.23353      1.76663 -0.360379 -2.99373      1. 0. 0.
    213 1
    214   0.917634 -3.66448 -0.484829   2.19193 -1.51408 -0.867629      5.55043 -0.952879 -0.490929     1. 0. 0.
    215 1
    216   1.15633 1.11082 0.326671      1.03283 1.01972 -2.14533        2.58823 2.50762 1.23707         1. 0. 0.
    217 1
    218   1.46453 0.112321 2.50927      3.24233 1.41142 2.47757         2.58823 2.50762 1.23707         1. 0. 0.
    219 1
    220   1.46453 0.112321 2.50927      3.24233 1.41142 2.47757         4.08983 -0.525479 2.10687       1. 0. 0.
    221 1
    222   1.46453 0.112321 2.50927      2.06173 -1.39848 1.79787        4.08983 -0.525479 2.10687       1. 0. 0.
    223 1
    224   0.790434 -3.69418 1.29027     2.06173 -1.39848 1.79787        3.62993 -1.50808 0.698371       1. 0. 0.
    225 1
    226   0.790434 -3.69418 1.29027     0.917634 -3.66448 -0.484829     1.92773 -2.57738 0.498071       1. 0. 0.
    227 1
    228   -0.573766 -1.42458 -2.91753   0.450934 -2.72908 -2.23353      1.76663 -0.360379 -2.99373      1. 0. 0.
    229 1
    230   -0.573766 -1.42458 -2.91753   1.03283 1.01972 -2.14533        -3.94777 1.63002 -1.27603       1. 0. 0.
    231 1
    232   0.917634 -3.66448 -0.484829   2.19193 -1.51408 -0.867629      0.450934 -2.72908 -2.23353      1. 0. 0.
    233 1
    234   1.15633 1.11082 0.326671      1.03283 1.01972 -2.14533        -2.87097 2.29272 -0.0233288     1. 0. 0.
    235 1
    236   1.15633 1.11082 0.326671      2.58823 2.50762 1.23707         -2.87097 2.29272 -0.0233288     1. 0. 0.
    237 1
    238   1.46453 0.112321 2.50927      2.58823 2.50762 1.23707         -2.87097 2.29272 -0.0233288     1. 0. 0.
    239 1
    240   -0.287266 -1.67078 2.48017    1.46453 0.112321 2.50927        2.06173 -1.39848 1.79787        1. 0. 0.
    241 1
    242   0.790434 -3.69418 1.29027     -0.287266 -1.67078 2.48017      2.06173 -1.39848 1.79787        1. 0. 0.
    243 1
    244   0.790434 -3.69418 1.29027     0.917634 -3.66448 -0.484829     -1.52417 -3.64138 0.503471      1. 0. 0.
    245 1
    246   -0.573766 -1.42458 -2.91753   0.450934 -2.72908 -2.23353      -1.62867 -3.74268 -1.79493      1. 0. 0.
    247 1
    248   -0.573766 -1.42458 -2.91753   -2.77417 -0.570279 -1.12083     -3.94777 1.63002 -1.27603       1. 0. 0.
    249 1
    250   1.03283 1.01972 -2.14533      -2.87097 2.29272 -0.0233288     -3.94777 1.63002 -1.27603       1. 0. 0.
    251 1
    252   0.917634 -3.66448 -0.484829   0.450934 -2.72908 -2.23353      -1.62867 -3.74268 -1.79493      1. 0. 0.
    253 1
    254   -0.759066 -0.265179 1.48487   1.46453 0.112321 2.50927        -2.87097 2.29272 -0.0233288     1. 0. 0.
    255 1
    256   -0.759066 -0.265179 1.48487   -0.287266 -1.67078 2.48017      1.46453 0.112321 2.50927        1. 0. 0.
    257 1
    258   0.790434 -3.69418 1.29027     -1.52417 -3.64138 0.503471      -0.287266 -1.67078 2.48017      1. 0. 0.
    259 1
    260   0.917634 -3.66448 -0.484829   -1.52417 -3.64138 0.503471      -1.62867 -3.74268 -1.79493      1. 0. 0.
    261 1
    262   -0.573766 -1.42458 -2.91753   -1.62867 -3.74268 -1.79493      -2.49667 -2.18078 -1.79993      1. 0. 0.
    263 1
    264   -0.573766 -1.42458 -2.91753   -2.49667 -2.18078 -1.79993      -2.77417 -0.570279 -1.12083     1. 0. 0.
    265 1
    266   -2.49667 -2.18078 -1.79993    -2.77417 -0.570279 -1.12083     -3.94777 1.63002 -1.27603       1. 0. 0.
    267 1
    268   -2.87097 2.29272 -0.0233288   -3.94777 1.63002 -1.27603       -4.04457 4.49292 -0.178529      1. 0. 0.
    269 1
    270   -0.759066 -0.265179 1.48487   -3.66127 0.565021 1.57007       -2.87097 2.29272 -0.0233288     1. 0. 0.
    271 1
    272   -0.759066 -0.265179 1.48487   -0.287266 -1.67078 2.48017      -3.66127 0.565021 1.57007       1. 0. 0.
    273 1
    274   -1.52417 -3.64138 0.503471    -0.287266 -1.67078 2.48017      -2.45927 -1.63678 1.72157       1. 0. 0.
    275 1
    276   -1.52417 -3.64138 0.503471    -1.62867 -3.74268 -1.79493      -3.90927 -3.49908 0.839771      1. 0. 0.
    277 1
    278   -1.62867 -3.74268 -1.79493    -2.49667 -2.18078 -1.79993      -4.17327 -2.53828 -0.635229     1. 0. 0.
    279 1
    280   -2.49667 -2.18078 -1.79993    -4.17327 -2.53828 -0.635229     -3.94777 1.63002 -1.27603       1. 0. 0.
    281 1
    282   2.58823 2.50762 1.23707       -2.87097 2.29272 -0.0233288     -4.04457 4.49292 -0.178529      1. 0. 0.
    283 1
    284   -3.94777 1.63002 -1.27603     -4.04457 4.49292 -0.178529      -5.12137 3.83022 -1.43123       1. 0. 0.
    285 1
    286   -3.66127 0.565021 1.57007     -2.87097 2.29272 -0.0233288     -4.83487 2.76522 1.41487        1. 0. 0.
    287 1
    288   -0.287266 -1.67078 2.48017    -2.45927 -1.63678 1.72157       -3.66127 0.565021 1.57007       1. 0. 0.
    289 1
    290   -1.52417 -3.64138 0.503471    -2.45927 -1.63678 1.72157       -3.90927 -3.49908 0.839771      1. 0. 0.
    291 1
    292   -1.62867 -3.74268 -1.79493    -4.17327 -2.53828 -0.635229     -3.90927 -3.49908 0.839771      1. 0. 0.
    293 1
    294   -4.17327 -2.53828 -0.635229   -3.94777 1.63002 -1.27603       -6.42617 1.74722 -0.982629      1. 0. 0.
    295 1
    296   -3.94777 1.63002 -1.27603     -5.12137 3.83022 -1.43123       -6.42617 1.74722 -0.982629      1. 0. 0.
    297 1
    298324  -5.12137 3.83022 -1.43123     -7.11497 2.49352 0.479071       -6.42617 1.74722 -0.982629      1. 0. 0.
    2993251
    300   -6.27887 0.926121 0.589671    -7.11497 2.49352 0.479071       -6.42617 1.74722 -0.982629      1. 0. 0.
    301 1
    302   -4.17327 -2.53828 -0.635229   -6.27887 0.926121 0.589671      -6.42617 1.74722 -0.982629      1. 0. 0.
    303 1
    304   -4.75167 -1.93408 0.935971    -4.17327 -2.53828 -0.635229     -6.27887 0.926121 0.589671      1. 0. 0.
    305 1
    306   -4.75167 -1.93408 0.935971    -3.66127 0.565021 1.57007       -6.27887 0.926121 0.589671      1. 0. 0.
    307 1
    308   -3.66127 0.565021 1.57007     -4.83487 2.76522 1.41487        -6.27887 0.926121 0.589671      1. 0. 0.
    309 1
    310   -4.83487 2.76522 1.41487      -6.27887 0.926121 0.589671      -7.11497 2.49352 0.479071       1. 0. 0.
    311 1
    312   -4.83487 2.76522 1.41487      -5.81017 4.57652 0.0304712      -7.11497 2.49352 0.479071       1. 0. 0.
    313 1
    314326  -5.81017 4.57652 0.0304712    -5.12137 3.83022 -1.43123       -7.11497 2.49352 0.479071       1. 0. 0.
    3153271
    316328  -5.81017 4.57652 0.0304712    -4.04457 4.49292 -0.178529      -5.12137 3.83022 -1.43123       1. 0. 0.
    317 1
    318   -4.83487 2.76522 1.41487      -5.81017 4.57652 0.0304712      -4.04457 4.49292 -0.178529      1. 0. 0.
    319 1
    320   -2.87097 2.29272 -0.0233288   -4.83487 2.76522 1.41487        -4.04457 4.49292 -0.178529      1. 0. 0.
    321 1
    322   2.58823 2.50762 1.23707       -2.87097 2.29272 -0.0233288     -4.04457 4.49292 -0.178529      1. 0. 0.
    323 1
    324   -2.45927 -1.63678 1.72157     -4.75167 -1.93408 0.935971      -3.66127 0.565021 1.57007       1. 0. 0.
    325 1
    326   -2.45927 -1.63678 1.72157     -4.75167 -1.93408 0.935971      -3.90927 -3.49908 0.839771      1. 0. 0.
    327 1
    328   -4.75167 -1.93408 0.935971    -4.17327 -2.53828 -0.635229     -3.90927 -3.49908 0.839771      1. 0. 0.
    3293299
    330330#  terminating special property
     
    333333  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0
    3343342
    335   -4.27807 -2.65715 0.380171    5       1 0 0
     335  -4.99203 4.29989 -0.526429    5       1 0 0
    3363369
    337337  terminating special property
  • TabularUnified tests/testsuite.at

    r9fe36b rb8d1aeb  
    1212AT_CHECK([pwd],[ignore],[ignore])
    1313AT_CHECK([../../molecuilder -v], 0, [stdout], [ignore])
    14 AT_CHECK([fgrep molecuilder stdout], 0, [ignore], [ignore])
     14AT_CHECK([fgrep olecuilder stdout], 0, [ignore], [ignore])
    1515AT_CHECK([../../molecuilder -h], 0, [stdout], [ignore])
    1616AT_CHECK([fgrep "Give this help screen" stdout], 0, [ignore], [ignore])
    17 AT_CHECK([../../molecuilder -e], 0, [ignore], [stderr])
     17AT_CHECK([../../molecuilder -e], 255, [ignore], [stderr])
    1818AT_CHECK([fgrep "Not enough or invalid arguments" stderr], 0, [ignore], [ignore])
    1919AT_CHECK([../../molecuilder test.conf], 0, [stdout], [stderr])
     
    7878AT_SETUP([Simple configuration - invalid commands on present configs])
    7979AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/regression/Simple_configuration/7/pre/test.conf .], 0)
    80 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -t -s -b -E -c -b -a -U -T -u], 255, [ignore], [stderr])
    81 AT_CHECK([fgrep -c "Not enough or invalid" stderr], 0, [9
    82 ], [ignore])
     80AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -t], 255, [ignore], [stderr])
     81AT_CHECK([fgrep -c "CRITICAL: Not enough or invalid" stderr], 0, [ignore], [ignore])
     82AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -s -b -E -c -b -a -U -T -u], 255, [ignore], [stderr])
     83AT_CHECK([fgrep -c "CRITICAL: Not enough or invalid" stderr], 0, [ignore], [ignore])
     84AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -b -E -c -b -a -U -T -u], 255, [ignore], [stderr])
     85AT_CHECK([fgrep -c "CRITICAL: Not enough or invalid" stderr], 0, [ignore], [ignore])
     86AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -E -c -b -a -U -T -u], 255, [ignore], [stderr])
     87AT_CHECK([fgrep -c "CRITICAL: Not enough or invalid" stderr], 0, [ignore], [ignore])
     88AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -c -b -a -U -T -u], 255, [ignore], [stderr])
     89AT_CHECK([fgrep -c "CRITICAL: Not enough or invalid" stderr], 0, [ignore], [ignore])
     90AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -b -a -U -T -u], 255, [ignore], [stderr])
     91AT_CHECK([fgrep -c "CRITICAL: Not enough or invalid" stderr], 0, [ignore], [ignore])
     92AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -a -U -T -u], 255, [ignore], [stderr])
     93AT_CHECK([fgrep -c "CRITICAL: Not enough or invalid" stderr], 0, [ignore], [ignore])
     94AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -U -T -u], 255, [ignore], [stderr])
     95AT_CHECK([fgrep -c "CRITICAL: Not enough or invalid" stderr], 0, [ignore], [ignore])
     96AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -T -u], 255, [ignore], [stderr])
     97AT_CHECK([fgrep -c "CRITICAL: Not enough or invalid" stderr], 0, [ignore], [ignore])
     98AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -u], 255, [ignore], [stderr])
     99AT_CHECK([fgrep -c "CRITICAL: Not enough or invalid" stderr], 0, [ignore], [ignore])
    83100AT_CLEANUP
    84101
     
    88105AT_SETUP([Graph - DFS analysis])
    89106AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/regression/Graph/1/pre/test.conf .], 0)
    90 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -D 2.], 0, [stdout], [stderr])
     107AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -vvv -D 2.], 0, [stdout], [stderr])
    91108AT_CHECK([fgrep -c "No rings were detected in the molecular structure." stdout], 0, [1
    92109], [ignore])
     
    134151AT_CHECK([file=ConvexEnvelope.dat; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/regression/Tesselation/2/post/$file], 0, [ignore], [ignore])
    135152AT_CHECK([file=ConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/regression/Tesselation/2/post/$file], 0, [ignore], [ignore])
    136 AT_CHECK([fgrep "RESULT: The summed volume is 16.401577 angstrom^3" stdout], 0, [ignore], [ignore])
     153AT_CHECK([fgrep "tesselated volume area is 16.4016 angstrom^3" stdout], 0, [ignore], [ignore])
    137154AT_CHECK([diff ConvexEnvelope.dat NonConvexEnvelope.dat], 0, [ignore], [ignore])
    138155AT_CLEANUP
     
    152169#AT_CHECK([file=ConvexEnvelope.dat; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/regression/Tesselation/4/post/$file], 0, [ignore], [ignore])
    153170#AT_CHECK([file=ConvexEnvelope.r3d; diff $file ${abs_top_srcdir}/${AUTOTEST_PATH}/regression/Tesselation/4/post/$file], 0, [ignore], [ignore])
    154 #AT_CHECK([fgrep "RESULT: The summed volume is 16.401577 angstrom^3" stdout], 0, [ignore], [ignore])
     171#AT_CHECK([fgrep "tesselated volume area is 16.4016 angstrom^3" stdout], 0, [ignore], [ignore])
    155172#AT_CLEANUP
    156173
Note: See TracChangeset for help on using the changeset viewer.