Index: src/Tesselation/tesselation.cpp
===================================================================
--- src/Tesselation/tesselation.cpp	(revision cead3fe0679f2e6b3b53a7300f42efde4b3cc552)
+++ src/Tesselation/tesselation.cpp	(revision 613790861011df25a40877f5c6bfb2156def7a8c)
@@ -2331,8 +2331,7 @@
   }
 
-  if ((!CandidateLine.pointlist.empty()) && (!CandidateLine.CheckValidity(RADIUS, LC))) {
-    ELOG(0, "There were other points contained in the rolling sphere as well!");
-    performCriticalExit();
-  }
+  ASSERT(CandidateLine.pointlist.empty() || (CandidateLine.CheckValidity(RADIUS, LC)),
+      std::string("Tesselation::FindThirdPointForTesselation()")
+      +std::string("There were other points contained in the rolling sphere as well!"));
 }
 ;
@@ -2820,11 +2819,9 @@
   // calculate central point
   triangles = FindTriangles(TrianglePoints);
-  if ((triangles != NULL) && (!triangles->empty())) {
-    for (TriangleList::iterator Runner = triangles->begin(); Runner != triangles->end(); Runner++)
-      PlaneNormal += (*Runner)->NormalVector;
-  } else {
-    ELOG(0, "Could not find any triangles for point " << *Point << ".");
-    performCriticalExit();
-  }
+  ASSERT((triangles == NULL) || (triangles->empty()),
+      std::string("Tesselation::GetCircleOfConnectedTriangles()")
+      +std::string("Could not find any triangles for point "+toString(*Point)+"."));
+  for (TriangleList::iterator Runner = triangles->begin(); Runner != triangles->end(); Runner++)
+    PlaneNormal += (*Runner)->NormalVector;
   PlaneNormal.Scale(1.0 / triangles->size());
   LOG(4, "DEBUG: Calculated PlaneNormal of all circle points is " << PlaneNormal << ".");
@@ -2838,8 +2835,8 @@
     AngleZero = ((*SetOfNeighbours->begin())->getPosition()) - (Point->getPosition());
     AngleZero.ProjectOntoPlane(PlaneNormal);
-    if (AngleZero.NormSquared() < MYEPSILON) {
-      ELOG(0, "CRITIAL: AngleZero is 0 even with alternative reference. The algorithm has to be changed here!");
-      performCriticalExit();
-    }
+    ASSERT (AngleZero.NormSquared() > MYEPSILON,
+        std::string("Tesselation::GetCircleOfConnectedTriangles() - ")
+        +std::string("AngleZero is 0 even with alternative reference.")
+        +std::string("The algorithm has to be changed here!"));
   }
   LOG(4, "DEBUG: Reference vector on this plane representing angle 0 is " << AngleZero << ".");
@@ -2940,8 +2937,8 @@
     AngleZero = ((*SetOfNeighbours->begin())->getPosition()) - (Point->getPosition());
     AngleZero.ProjectOntoPlane(PlaneNormal);
-    if (AngleZero.NormSquared() < MYEPSILON) {
-      ELOG(0, "CRITIAL: AngleZero is 0 even with alternative reference. The algorithm has to be changed here!");
-      performCriticalExit();
-    }
+    ASSERT(AngleZero.NormSquared() > MYEPSILON,
+        std::string("Tesselation::GetCircleOfSetOfPoints() - ")
+        +std::string("AngleZero is 0 even with alternative reference.")
+        +std::string("The algorithm has to be changed here!"));
   }
   LOG(4, "DEBUG: Reference vector on this plane representing angle 0 is " << AngleZero << ".");
@@ -2962,8 +2959,8 @@
     LOG(4, "DEBUG: Calculated angle between " << helper << " and " << AngleZero << " is " << angle << " for point " << **listRunner << ".");
     InserterTest = anglesOfPoints.insert(pair<double, TesselPoint*> (angle, (*listRunner)));
-    if (!InserterTest.second) {
-      ELOG(0, "GetCircleOfSetOfPoints() got two atoms with same angle: " << *((InserterTest.first)->second) << " and " << (*listRunner));
-      performCriticalExit();
-    }
+    ASSERT(InserterTest.second,
+        std::string("Tesselation::GetCircleOfSetOfPoints() - ")
+        +std::string("got two atoms with same angle "+toString(*((InserterTest.first)->second)))
+        +std::string(" and "+toString((*listRunner))));
   }
 
@@ -3304,6 +3301,11 @@
         TriangleCandidates[2] = *EndNode;
         triangle = GetPresentTriangle(TriangleCandidates);
-        if (triangle != NULL) {
-          ELOG(0, "New triangle already present, skipping!");
+	if (triangle != NULL) {
+          // check orientation of normal vector (that points inside)
+          ASSERT( triangle->NormalVector.ScalarProduct(NormalVector) > std::numeric_limits<double>::epsilon()*1e2,
+              "Tesselation::RemovePointFromTesselatedSurface() - New triangle with same orientation already present as "
+              +toString(*triangle)+"!");
+        }
+        if (0) {
           StartNode++;
           MiddleNode++;
@@ -3338,11 +3340,10 @@
         LOG(2, "Removing " << **MiddleNode << " from closed path, remaining points: " << connectedPath->size() << ".");
         connectedPath->remove(*MiddleNode); // remove the middle node (it is surrounded by triangles)
+        ASSERT(connectedPath->size() >= 2,
+            "Tesselation::RemovePointFromTesselatedSurface() - There are only two endpoints left!");
         if (connectedPath->size() == 2) { // we are done
           connectedPath->remove(*StartNode); // remove the start node
           connectedPath->remove(*EndNode); // remove the end node
           break;
-        } else if (connectedPath->size() < 2) { // something's gone wrong!
-          ELOG(0, "CRITICAL: There are only two endpoints left!");
-          performCriticalExit();
         } else {
           MiddleNode = StartNode;
@@ -3489,6 +3490,6 @@
     }
     default:
-      ELOG(0, "Number of wildcards is greater than 3, cannot happen!");
-      performCriticalExit();
+      ASSERT(0,
+          "Tesselation::FindTriangles() - Number of wildcards is greater than 3, cannot happen!");
       break;
   }
@@ -3791,8 +3792,7 @@
   for (int i = 0; i < 3; i++) { // look for the same line as BestLine (only it's its degenerated companion)
     if ((BTS->lines[i]->ContainsBoundaryPoint(BestLine->endpoints[0])) && (BTS->lines[i]->ContainsBoundaryPoint(BestLine->endpoints[1]))) {
-      if (BestLine == BTS->lines[i]) {
-        ELOG(0, "BestLine is same as found line, something's wrong here!");
-        performCriticalExit();
-      }
+      ASSERT(BestLine != BTS->lines[i],
+          std::string("Tesselation::AddBoundaryPointByDegeneratedTriangle() - ")
+          +std::string("BestLine is same as found line, something's wrong here!"));
       BTS->lines[i]->triangles.insert(pair<int, class BoundaryTriangleSet *> (TempTriangle->Nr, TempTriangle));
       TempTriangle->lines[nr] = BTS->lines[i];
@@ -3993,8 +3993,8 @@
     // The Problem is probably due to two degenerated polygons being connected by a bridging, non-degenerated polygon, as somehow one node has
     // connections to either polygon ...
-    if (T->size() % 2 != 0) {
-      ELOG(0, " degenerated polygon contains an odd number of triangles, probably contains bridging non-degenerated ones, too!");
-      performCriticalExit();
-    }
+    ASSERT (T->size() % 2 == 0,
+        std::string("Tesselation::CorrectAllDegeneratedPolygons() - ")
+        +std::string(" degenerated polygon contains an odd number of triangles,")
+        +std::string(" probably contains bridging non-degenerated ones, too!"));
     TriangleSet::iterator TriangleWalker = T->begin(); // is the inner iterator
     /// 4a. Get NormalVector for one side (this is "front")
