Index: src/Tesselation/unittests/Makefile.am
===================================================================
--- src/Tesselation/unittests/Makefile.am	(revision 0b004b9c4dd37a728f061baad5c2608f74225c66)
+++ src/Tesselation/unittests/Makefile.am	(revision 0b004b9c4dd37a728f061baad5c2608f74225c66)
@@ -0,0 +1,47 @@
+# PLEASE adhere to the alphabetical ordering in this Makefile!
+# Also indentation by a single tab
+
+TESSELATIONTESTSSOURCES = \
+  ../Tesselation/unittests/TesselationUnitTest.cpp \
+  ../Tesselation/unittests/Tesselation_BoundaryTriangleUnitTest.cpp \
+  ../Tesselation/unittests/Tesselation_InsideOutsideUnitTest.cpp
+
+TESSELATIONTESTSHEADERS = \
+	../Tesselation/unittests/TesselationUnitTest.hpp \
+  ../Tesselation/unittests/Tesselation_BoundaryTriangleUnitTest.hpp \
+  ../Tesselation/unittests/Tesselation_InsideOutsideUnitTest.hpp
+
+TESSELATIONTESTS = \
+  TesselationUnitTest \
+  Tesselation_BoundaryTriangleUnitTest \
+  Tesselation_InOutsideUnitTest
+
+TESTS += $(TESSELATIONTESTS)
+check_PROGRAMS += $(TESSELATIONTESTS) 
+noinst_PROGRAMS += $(TESSELATIONTESTS)
+
+TESSELATIONLIBS = \
+	../libMolecuilderUI.la \
+	../libMolecuilder.la \
+	$(top_builddir)/LinearAlgebra/src/LinearAlgebra/libLinearAlgebra.la \
+	${CodePatterns_LIBS} \
+	$(BOOST_LIB)
+
+
+TesselationUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
+	../Tesselation/unittests/TesselationUnitTest.cpp \
+	../Tesselation/unittests/TesselationUnitTest.hpp
+TesselationUnitTest_LDADD = ${TESSELATIONLIBS}
+
+Tesselation_BoundaryTriangleUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
+	../Tesselation/unittests/Tesselation_BoundaryTriangleUnitTest.cpp \
+	../Tesselation/unittests/Tesselation_BoundaryTriangleUnitTest.hpp 
+Tesselation_BoundaryTriangleUnitTest_LDADD = ${TESSELATIONLIBS}
+
+Tesselation_InOutsideUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
+	../Tesselation/unittests/Tesselation_InsideOutsideUnitTest.cpp \
+	../Tesselation/unittests/Tesselation_InsideOutsideUnitTest.hpp
+Tesselation_InOutsideUnitTest_LDADD = ${TESSELATIONLIBS}
+
+
+#AUTOMAKE_OPTIONS = parallel-tests
Index: src/Tesselation/unittests/TesselationUnitTest.cpp
===================================================================
--- src/Tesselation/unittests/TesselationUnitTest.cpp	(revision 0b004b9c4dd37a728f061baad5c2608f74225c66)
+++ src/Tesselation/unittests/TesselationUnitTest.cpp	(revision 0b004b9c4dd37a728f061baad5c2608f74225c66)
@@ -0,0 +1,193 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * TesselationUnitTest.cpp
+ *
+ *  Created on: Aug 26, 2009
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <cstring>
+
+#include "Tesselation/BoundaryLineSet.hpp"
+#include "Tesselation/BoundaryTriangleSet.hpp"
+#include "Tesselation/CandidateForTesselation.hpp"
+#include "CodePatterns/Log.hpp"
+#include "Helpers/defs.hpp"
+#include "PointCloudAdaptor.hpp"
+#include "Tesselation/TesselPoint.hpp"
+
+#include "TesselationUnitTest.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+const double TesselationTest::SPHERERADIUS=2.;
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( TesselationTest );
+
+
+void TesselationTest::setUp()
+{
+  // create corners
+  class TesselPoint *Walker;
+  Walker = new TesselPoint;
+  Walker->setPosition(Vector(1., 0., -1.));
+  Walker->setName("1");
+  Walker->setNr(1);
+  Corners.push_back(Walker);
+  Walker = new TesselPoint;
+  Walker->setPosition(Vector(-1., 1., -1.));
+  Walker->setName("2");
+  Walker->setNr(2);
+  Corners.push_back(Walker);
+  Walker = new TesselPoint;
+  Walker->setPosition(Vector(-1., -1., -1.));
+  Walker->setName("3");
+  Walker->setNr(3);
+  Corners.push_back(Walker);
+  Walker = new TesselPoint;
+  Walker->setPosition(Vector(-1., 0., 1.));
+  Walker->setName("4");
+  Walker->setNr(4);
+  Corners.push_back(Walker);
+
+  // create linkedcell
+  PointCloudAdaptor<TesselPointSTLList> cloud(&Corners, "TesselPointSTLList");
+  LinkedList = new LinkedCell(cloud, 2.*SPHERERADIUS);
+
+  // create tesselation
+  TesselStruct = new Tesselation;
+  CPPUNIT_ASSERT_EQUAL( true, TesselStruct->PointsOnBoundary.empty() );
+  CPPUNIT_ASSERT_EQUAL( true, TesselStruct->LinesOnBoundary.empty() );
+  CPPUNIT_ASSERT_EQUAL( true, TesselStruct->TrianglesOnBoundary.empty() );
+  TesselStruct->FindStartingTriangle(SPHERERADIUS, LinkedList);
+
+  CandidateForTesselation *baseline = NULL;
+  BoundaryTriangleSet *T = NULL;
+  bool OneLoopWithoutSuccessFlag = true;
+  bool TesselationFailFlag = false;
+  while ((!TesselStruct->OpenLines.empty()) && (OneLoopWithoutSuccessFlag)) {
+    // 2a. fill all new OpenLines
+    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
+      baseline = Runner->second;
+      if (baseline->pointlist.empty()) {
+        T = (((baseline->BaseLine->triangles.begin()))->second);
+        TesselationFailFlag = TesselStruct->FindNextSuitableTriangle(*baseline, *T, SPHERERADIUS, LinkedList); //the line is there, so there is a triangle, but only one.
+      }
+    }
+
+    // 2b. search for smallest ShortestAngle among all candidates
+    double ShortestAngle = 4.*M_PI;
+    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
+      if (Runner->second->ShortestAngle < ShortestAngle) {
+        baseline = Runner->second;
+        ShortestAngle = baseline->ShortestAngle;
+      }
+    }
+    if ((ShortestAngle == 4.*M_PI) || (baseline->pointlist.empty()))
+      OneLoopWithoutSuccessFlag = false;
+    else {
+      TesselStruct->AddCandidatePolygon(*baseline, SPHERERADIUS, LinkedList);
+    }
+  }
+};
+
+
+void TesselationTest::tearDown()
+{
+  delete(LinkedList);
+  delete(TesselStruct);
+  for (TesselPointSTLList::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++)
+    delete(*Runner);
+  Corners.clear();
+  logger::purgeInstance();
+  errorLogger::purgeInstance();
+};
+
+/** UnitTest for Contains...()
+ *
+ */
+void TesselationTest::ContainmentTest()
+{
+  class BoundaryPointSet *point = NULL;
+  class BoundaryLineSet *line = NULL;
+
+  // check ContainsBoundaryPoint
+  for(LineMap::iterator Runner = TesselStruct->LinesOnBoundary.begin(); Runner != TesselStruct->LinesOnBoundary.end(); Runner++) {
+    CPPUNIT_ASSERT_EQUAL( true, (Runner->second)->ContainsBoundaryPoint((Runner->second)->endpoints[0]));
+    CPPUNIT_ASSERT_EQUAL( true, (Runner->second)->ContainsBoundaryPoint((Runner->second)->endpoints[1]));
+  }
+  for(TriangleMap::iterator Runner = TesselStruct->TrianglesOnBoundary.begin(); Runner != TesselStruct->TrianglesOnBoundary.end(); Runner++) {
+    for(PointMap::iterator PointRunner = TesselStruct->PointsOnBoundary.begin(); PointRunner != TesselStruct->PointsOnBoundary.end(); PointRunner++) {
+      point = PointRunner->second;
+      for (int i=0;i<3;i++)
+        if (point == (Runner->second)->endpoints[i])
+          point = NULL;
+      if (point != NULL)
+        break;
+    }
+    CPPUNIT_ASSERT_EQUAL( true, (Runner->second)->ContainsBoundaryPoint((Runner->second)->endpoints[0]));
+    CPPUNIT_ASSERT_EQUAL( true, (Runner->second)->ContainsBoundaryPoint((Runner->second)->endpoints[1]));
+    CPPUNIT_ASSERT_EQUAL( true, (Runner->second)->ContainsBoundaryPoint((Runner->second)->endpoints[2]));
+    CPPUNIT_ASSERT_EQUAL( false, (Runner->second)->ContainsBoundaryPoint(point));
+  }
+
+  // check ContainsBoundaryLine
+  for(TriangleMap::iterator Runner = TesselStruct->TrianglesOnBoundary.begin(); Runner != TesselStruct->TrianglesOnBoundary.end(); Runner++) {
+    for(LineMap::iterator LineRunner = TesselStruct->LinesOnBoundary.begin(); LineRunner != TesselStruct->LinesOnBoundary.end(); LineRunner++) {
+      line = LineRunner->second;
+      for (int i=0;i<3;i++)
+        if (line == (Runner->second)->lines[i])
+          line = NULL;
+      if (line != NULL)
+        break;
+    }
+    CPPUNIT_ASSERT_EQUAL( true, (Runner->second)->ContainsBoundaryLine((Runner->second)->lines[0]));
+    CPPUNIT_ASSERT_EQUAL( true, (Runner->second)->ContainsBoundaryLine((Runner->second)->lines[1]));
+    CPPUNIT_ASSERT_EQUAL( true, (Runner->second)->ContainsBoundaryLine((Runner->second)->lines[2]));
+    CPPUNIT_ASSERT_EQUAL( false, (Runner->second)->ContainsBoundaryLine(line));
+  }
+
+  // check IsPresentTupel
+  CPPUNIT_ASSERT_EQUAL( true, true );
+}
+
+/** UnitTest for Tesselation::GetAllTriangles()
+ *
+ */
+void TesselationTest::GetAllTrianglesTest()
+{
+  class BoundaryPointSet *Walker = NULL;
+
+  // check that there are three adjacent triangles for every boundary point
+  for (PointMap::iterator Runner = TesselStruct->PointsOnBoundary.begin(); Runner != TesselStruct->PointsOnBoundary.end(); Runner++) {
+    Walker = Runner->second;
+    set<BoundaryTriangleSet*> *triangles = TesselStruct->GetAllTriangles(Walker);
+    CPPUNIT_ASSERT_EQUAL( (size_t)3, triangles->size() );
+    // check that the returned triangle all contain the Walker
+    for (set<BoundaryTriangleSet*>::iterator TriangleRunner = triangles->begin(); TriangleRunner != triangles->end(); TriangleRunner++)
+      CPPUNIT_ASSERT_EQUAL( true, (*TriangleRunner)->ContainsBoundaryPoint(Walker) );
+    delete(triangles);
+  }
+}
Index: src/Tesselation/unittests/TesselationUnitTest.hpp
===================================================================
--- src/Tesselation/unittests/TesselationUnitTest.hpp	(revision 0b004b9c4dd37a728f061baad5c2608f74225c66)
+++ src/Tesselation/unittests/TesselationUnitTest.hpp	(revision 0b004b9c4dd37a728f061baad5c2608f74225c66)
@@ -0,0 +1,50 @@
+/*
+ * TesselationUnitTest.hpp
+ *
+ *  Created on: Aug 26, 2009
+ *      Author: heber
+ */
+
+#ifndef TESSELATIONUNITTEST_HPP_
+#define TESSELATIONUNITTEST_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+/*********************************************** includes ***********************************/
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "linkedcell.hpp"
+#include "Tesselation/tesselation.hpp"
+
+/********************************************** Test classes **************************************/
+
+class TesselationTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( TesselationTest) ;
+    CPPUNIT_TEST ( GetAllTrianglesTest );
+    CPPUNIT_TEST ( ContainmentTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void GetAllTrianglesTest();
+      void ContainmentTest();
+
+
+private:
+      static const double SPHERERADIUS;
+
+      class Tesselation *TesselStruct;
+      TesselPointSTLList Corners;
+      class LinkedCell *LinkedList;
+};
+
+
+
+#endif /* TESSELATIONUNITTEST_HPP_ */
Index: src/Tesselation/unittests/Tesselation_BoundaryTriangleUnitTest.cpp
===================================================================
--- src/Tesselation/unittests/Tesselation_BoundaryTriangleUnitTest.cpp	(revision 0b004b9c4dd37a728f061baad5c2608f74225c66)
+++ src/Tesselation/unittests/Tesselation_BoundaryTriangleUnitTest.cpp	(revision 0b004b9c4dd37a728f061baad5c2608f74225c66)
@@ -0,0 +1,214 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * Tesselation_BoundaryTriangleUnitTest.cpp
+ *
+ *  Created on: Jan 13, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <cstring>
+#include <iostream>
+
+#include "CodePatterns/Log.hpp"
+#include "Helpers/defs.hpp"
+#include "Tesselation/TesselPoint.hpp"
+#include "Tesselation/BoundaryPointSet.hpp"
+#include "Tesselation/BoundaryLineSet.hpp"
+#include "Tesselation/BoundaryTriangleSet.hpp"
+#include "Tesselation/CandidateForTesselation.hpp"
+
+#include "Tesselation_BoundaryTriangleUnitTest.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+const double TesselationBoundaryTriangleTest::SPHERERADIUS=2.;
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( TesselationBoundaryTriangleTest );
+
+
+void TesselationBoundaryTriangleTest::setUp()
+{
+  setVerbosity(5);
+
+  // create nodes
+  tesselpoints[0] = new TesselPoint;
+  tesselpoints[0]->setPosition(Vector(0., 0., 0.));
+  tesselpoints[0]->setName("1");
+  tesselpoints[0]->setNr(1);
+  points[0] = new BoundaryPointSet(tesselpoints[0]);
+  tesselpoints[1] = new TesselPoint;
+  tesselpoints[1]->setPosition(Vector(0., 1., 0.));
+  tesselpoints[1]->setName("2");
+  tesselpoints[1]->setNr(2);
+  points[1] = new BoundaryPointSet(tesselpoints[1]);
+  tesselpoints[2] = new TesselPoint;
+  tesselpoints[2]->setPosition(Vector(1., 0., 0.));
+  tesselpoints[2]->setName("3");
+  tesselpoints[2]->setNr(3);
+  points[2] = new BoundaryPointSet(tesselpoints[2] );
+
+  // create line
+  lines[0] = new BoundaryLineSet(points[0], points[1], 0);
+  lines[1] = new BoundaryLineSet(points[1], points[2], 1);
+  lines[2] = new BoundaryLineSet(points[0], points[2], 2);
+
+  // create triangle
+  triangle = new BoundaryTriangleSet(lines, 0);
+  triangle->GetNormalVector(Vector(0.,0.,1.));
+};
+
+
+void TesselationBoundaryTriangleTest::tearDown()
+{
+  delete(triangle);
+  for (int i=0;i<3;++i) {
+    // TesselPoint does not delete its vector as it only got a reference
+    delete tesselpoints[i];
+  }
+  logger::purgeInstance();
+  errorLogger::purgeInstance();
+};
+
+/** UnitTest for Tesselation::IsInnerPoint()
+ */
+void TesselationBoundaryTriangleTest::GetClosestPointOnPlaneTest()
+{
+  Vector TestIntersection;
+  Vector Point;
+
+  // simple test on y line
+  Point = Vector(-1.,0.5,0.);
+  CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
+  Point = Vector(0.,0.5,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+  Point = Vector(-4.,0.5,0.);
+  CPPUNIT_ASSERT_EQUAL( 16., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
+  Point = Vector(0.,0.5,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on x line
+  Point = Vector(0.5,-1.,0.);
+  CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
+  Point = Vector(0.5,0.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+  Point = Vector(0.5,-6.,0.);
+  CPPUNIT_ASSERT_EQUAL( 36., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
+  Point = Vector(0.5,0.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on slanted line
+  Point = Vector(1.,1.,0.);
+  CPPUNIT_ASSERT_EQUAL( 0.5, triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
+  Point = Vector(0.5,0.5,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+  Point = Vector(5.,5.,0.);
+  CPPUNIT_ASSERT_EQUAL( 40.5, triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
+  Point = Vector(0.5,0.5,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on first node
+  Point = Vector(-1.,-1.,0.);
+  CPPUNIT_ASSERT_EQUAL( 2., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
+  Point = Vector(0.,0.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on second node
+  Point = Vector(0.,2.,0.);
+  CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
+  Point = Vector(0.,1.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on third node
+  Point = Vector(2.,0.,0.);
+  CPPUNIT_ASSERT_EQUAL( 1., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
+  Point = Vector(1.,0.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+};
+
+/** UnitTest for Tesselation::IsInnerPoint()
+ */
+void TesselationBoundaryTriangleTest::GetClosestPointOffPlaneTest()
+{
+  Vector TestIntersection;
+  Vector Point;
+
+  // straight down/up
+  Point = Vector(1./3.,1./3.,+5.);
+  CPPUNIT_ASSERT_EQUAL( 25. , triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
+  Point = Vector(1./3.,1./3.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+  Point = Vector(1./3.,1./3.,-5.);
+  CPPUNIT_ASSERT_EQUAL( 25. , triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
+  Point = Vector(1./3.,1./3.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on y line
+  Point = Vector(-1.,0.5,+2.);
+  CPPUNIT_ASSERT_EQUAL( 5., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
+  Point = Vector(0.,0.5,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+  Point = Vector(-1.,0.5,-3.);
+  CPPUNIT_ASSERT_EQUAL( 10., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
+  Point = Vector(0.,0.5,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on x line
+  Point = Vector(0.5,-1.,+1.);
+  CPPUNIT_ASSERT_EQUAL( 2., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
+  Point = Vector(0.5,0.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+  Point = Vector(0.5,-1.,-2.);
+  CPPUNIT_ASSERT_EQUAL( 5., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
+  Point = Vector(0.5,0.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on slanted line
+  Point = Vector(1.,1.,+3.);
+  CPPUNIT_ASSERT_EQUAL( 9.5, triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
+  Point = Vector(0.5,0.5,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+  Point = Vector(1.,1.,-4.);
+  CPPUNIT_ASSERT_EQUAL( 16.5, triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
+  Point = Vector(0.5,0.5,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on first node
+  Point = Vector(-1.,-1.,5.);
+  CPPUNIT_ASSERT_EQUAL( 27., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
+  Point = Vector(0.,0.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on second node
+  Point = Vector(0.,2.,5.);
+  CPPUNIT_ASSERT_EQUAL( 26., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
+  Point = Vector(0.,1.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+
+  // simple test on third node
+  Point = Vector(2.,0.,5.);
+  CPPUNIT_ASSERT_EQUAL( 26., triangle->GetClosestPointInsideTriangle(Point, TestIntersection) );
+  Point = Vector(1.,0.,0.);
+  CPPUNIT_ASSERT_EQUAL( true , Point == TestIntersection );
+};
Index: src/Tesselation/unittests/Tesselation_BoundaryTriangleUnitTest.hpp
===================================================================
--- src/Tesselation/unittests/Tesselation_BoundaryTriangleUnitTest.hpp	(revision 0b004b9c4dd37a728f061baad5c2608f74225c66)
+++ src/Tesselation/unittests/Tesselation_BoundaryTriangleUnitTest.hpp	(revision 0b004b9c4dd37a728f061baad5c2608f74225c66)
@@ -0,0 +1,52 @@
+/*
+ * Tesselation_BoundaryTriangleUnitTest.hpp
+ *
+ *  Created on: Jan 13, 2010
+ *      Author: heber
+ */
+
+#ifndef TESSELATION_BOUNDARYTRIANGLEUNITTEST_HPP_
+#define TESSELATION_BOUNDARYTRIANGLEUNITTEST_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+/*********************************************** includes ***********************************/
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "linkedcell.hpp"
+#include "Tesselation/tesselation.hpp"
+
+class TesselPoint;
+
+/********************************************** Test classes **************************************/
+
+class TesselationBoundaryTriangleTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( TesselationBoundaryTriangleTest) ;
+    CPPUNIT_TEST ( GetClosestPointOnPlaneTest );
+    CPPUNIT_TEST ( GetClosestPointOffPlaneTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void GetClosestPointOnPlaneTest();
+      void GetClosestPointOffPlaneTest();
+
+private:
+      static const double SPHERERADIUS;
+
+      class BoundaryTriangleSet *triangle;
+      class BoundaryLineSet *lines[3];
+      class BoundaryPointSet *points[3];
+      class TesselPoint *tesselpoints[3];
+      TesselPointSTLList Corners;
+};
+
+
+#endif /* TESSELATION_BOUNDARYTRIANGLEUNITTEST_HPP_ */
Index: src/Tesselation/unittests/Tesselation_InsideOutsideUnitTest.cpp
===================================================================
--- src/Tesselation/unittests/Tesselation_InsideOutsideUnitTest.cpp	(revision 0b004b9c4dd37a728f061baad5c2608f74225c66)
+++ src/Tesselation/unittests/Tesselation_InsideOutsideUnitTest.cpp	(revision 0b004b9c4dd37a728f061baad5c2608f74225c66)
@@ -0,0 +1,175 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * Tesselation_InsideOutsideUnitTest.cpp
+ *
+ *  Created on: Dec 28, 2009
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <cstring>
+#include <iostream>
+
+#include "Tesselation/BoundaryLineSet.hpp"
+#include "Tesselation/BoundaryTriangleSet.hpp"
+#include "Tesselation/CandidateForTesselation.hpp"
+#include "CodePatterns/Log.hpp"
+#include "CodePatterns/Verbose.hpp"
+#include "Helpers/defs.hpp"
+#include "PointCloudAdaptor.hpp"
+#include "Tesselation/TesselPoint.hpp"
+
+#include "Tesselation_InsideOutsideUnitTest.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+const double TesselationInOutsideTest::SPHERERADIUS=2.;
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( TesselationInOutsideTest );
+
+void TesselationInOutsideTest::setUp()
+{
+  setVerbosity(2);
+
+  // create corners
+  class TesselPoint *Walker;
+  Walker = new TesselPoint;
+  Walker->setPosition(Vector(0., 0., 0.));
+  Walker->setName("1");
+  Walker->setNr(1);
+  Corners.push_back(Walker);
+  Walker = new TesselPoint;
+  Walker->setPosition(Vector(0., 1., 0.));
+  Walker->setName("2");
+  Walker->setNr(2);
+  Corners.push_back(Walker);
+  Walker = new TesselPoint;
+  Walker->setPosition(Vector(1., 0., 0.));
+  Walker->setName("3");
+  Walker->setNr(3);
+  Corners.push_back(Walker);
+  Walker = new TesselPoint;
+  Walker->setPosition(Vector(1., 1., 0.));
+  Walker->setName("4");
+  Walker->setNr(4);
+  Corners.push_back(Walker);
+  Walker = new TesselPoint;
+  Walker->setPosition(Vector(0., 0., 1.));
+  Walker->setName("5");
+  Walker->setNr(5);
+  Corners.push_back(Walker);
+  Walker = new TesselPoint;
+  Walker->setPosition(Vector(0., 1., 1.));
+  Walker->setName("6");
+  Walker->setNr(6);
+  Corners.push_back(Walker);
+  Walker = new TesselPoint;
+  Walker->setPosition(Vector(1., 0., 1.));
+  Walker->setName("7");
+  Walker->setNr(7);
+  Corners.push_back(Walker);
+  Walker = new TesselPoint;
+  Walker->setPosition(Vector(1., 1., 1.));
+  Walker->setName("8");
+  Walker->setNr(8);
+  Corners.push_back(Walker);
+
+  // create linkedcell
+  PointCloudAdaptor< TesselPointSTLList > cloud(&Corners, "TesselPointSTLList");
+  LinkedList = new LinkedCell(cloud, 2.*SPHERERADIUS);
+
+  // create tesselation
+  TesselStruct = new Tesselation;
+  TesselStruct->FindStartingTriangle(SPHERERADIUS, LinkedList);
+
+  CandidateForTesselation *baseline = NULL;
+  BoundaryTriangleSet *T = NULL;
+  bool OneLoopWithoutSuccessFlag = true;
+  bool TesselationFailFlag = false;
+  while ((!TesselStruct->OpenLines.empty()) && (OneLoopWithoutSuccessFlag)) {
+    // 2a. fill all new OpenLines
+    DoLog(1) && (Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for candidates:" << endl);
+    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++)
+      DoLog(2) && (Log() << Verbose(2) << *(Runner->second) << endl);
+
+    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
+      baseline = Runner->second;
+      if (baseline->pointlist.empty()) {
+        T = (((baseline->BaseLine->triangles.begin()))->second);
+        DoLog(1) && (Log() << Verbose(1) << "Finding best candidate for open line " << *baseline->BaseLine << " of triangle " << *T << endl);
+        TesselationFailFlag = TesselStruct->FindNextSuitableTriangle(*baseline, *T, SPHERERADIUS, LinkedList); //the line is there, so there is a triangle, but only one.
+      }
+    }
+
+    // 2b. search for smallest ShortestAngle among all candidates
+    double ShortestAngle = 4.*M_PI;
+    DoLog(1) && (Log() << Verbose(1) << "There are " << TesselStruct->OpenLines.size() << " open lines to scan for the best candidates:" << endl);
+    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++)
+      DoLog(2) && (Log() << Verbose(2) << *(Runner->second) << endl);
+
+    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
+      if (Runner->second->ShortestAngle < ShortestAngle) {
+        baseline = Runner->second;
+        ShortestAngle = baseline->ShortestAngle;
+        //Log() << Verbose(1) << "New best candidate is " << *baseline->BaseLine << " with point " << *baseline->point << " and angle " << baseline->ShortestAngle << endl;
+      }
+    }
+    if ((ShortestAngle == 4.*M_PI) || (baseline->pointlist.empty()))
+      OneLoopWithoutSuccessFlag = false;
+    else {
+      TesselStruct->AddCandidatePolygon(*baseline, SPHERERADIUS, LinkedList);
+    }
+  }
+};
+
+
+void TesselationInOutsideTest::tearDown()
+{
+  delete(LinkedList);
+  delete(TesselStruct);
+  for (TesselPointSTLList::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++)
+    delete(*Runner);
+  Corners.clear();
+  logger::purgeInstance();
+  errorLogger::purgeInstance();
+};
+
+/** UnitTest for Tesselation::IsInnerPoint()
+ */
+void TesselationInOutsideTest::IsInnerPointTest()
+{
+  double n[3];
+  const double boundary = 2.;
+  const double step = 1.;
+
+  // go through the mesh and check each point
+  for (n[0] = -boundary; n[0] <= boundary; n[0]+=step)
+    for (n[1] = -boundary; n[1] <= boundary; n[1]+=step)
+      for (n[2] = -boundary; n[2] <= boundary; n[2]+=step) {
+        if ( ((n[0] >= 0.) && (n[1] >= 0.) && (n[2] >= 0.)) && ((n[0] <= 1.) && (n[1] <= 1.) && (n[2] <= 1.)))
+          CPPUNIT_ASSERT_EQUAL( true , TesselStruct->IsInnerPoint(Vector(n[0], n[1], n[2]), LinkedList) );
+        else
+          CPPUNIT_ASSERT_EQUAL( false , TesselStruct->IsInnerPoint(Vector(n[0], n[1], n[2]), LinkedList) );
+      }
+};
Index: src/Tesselation/unittests/Tesselation_InsideOutsideUnitTest.hpp
===================================================================
--- src/Tesselation/unittests/Tesselation_InsideOutsideUnitTest.hpp	(revision 0b004b9c4dd37a728f061baad5c2608f74225c66)
+++ src/Tesselation/unittests/Tesselation_InsideOutsideUnitTest.hpp	(revision 0b004b9c4dd37a728f061baad5c2608f74225c66)
@@ -0,0 +1,46 @@
+/*
+ * Tesselation_InsideOutsideUnitTest.hpp
+ *
+ *  Created on: Dec 28, 2009
+ *      Author: heber
+ */
+
+#ifndef TESSELATION_INSIDEOUTSIDEUNITTEST_HPP_
+#define TESSELATION_INSIDEOUTSIDEUNITTEST_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+/*********************************************** includes ***********************************/
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "linkedcell.hpp"
+#include "Tesselation/tesselation.hpp"
+
+/********************************************** Test classes **************************************/
+
+class TesselationInOutsideTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( TesselationInOutsideTest) ;
+    CPPUNIT_TEST ( IsInnerPointTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void IsInnerPointTest();
+
+private:
+      static const double SPHERERADIUS;
+
+      class Tesselation *TesselStruct;
+      TesselPointSTLList Corners;
+      class LinkedCell *LinkedList;
+};
+
+
+#endif /* TESSELATION_INSIDEOUTSIDEUNITTEST_HPP_ */
