Index: src/tesselation.cpp
===================================================================
--- src/tesselation.cpp	(revision fff733ba0da4911da79885991c417b12b441b071)
+++ src/tesselation.cpp	(revision 34c43ab2d4d21658cd8b9c3134bf2f845cacdcfc)
@@ -23,27 +23,28 @@
 #include <iomanip>
 
-#include "Helpers/helpers.hpp"
-#include "CodePatterns/Info.hpp"
 #include "BoundaryPointSet.hpp"
 #include "BoundaryLineSet.hpp"
 #include "BoundaryTriangleSet.hpp"
 #include "BoundaryPolygonSet.hpp"
-#include "TesselPoint.hpp"
 #include "CandidateForTesselation.hpp"
-#include "PointCloud.hpp"
-#include "linkedcell.hpp"
+#include "CodePatterns/Assert.hpp"
+#include "CodePatterns/Info.hpp"
+#include "CodePatterns/IteratorAdaptors.hpp"
 #include "CodePatterns/Log.hpp"
-#include "tesselation.hpp"
-#include "tesselationhelpers.hpp"
-#include "triangleintersectionlist.hpp"
+#include "CodePatterns/Verbose.hpp"
+#include "Exceptions/LinearDependenceException.hpp"
+#include "Helpers/fast_functions.hpp"
+#include "Helpers/helpers.hpp"
+#include "IPointCloud.hpp"
 #include "LinearAlgebra/Vector.hpp"
 #include "LinearAlgebra/Line.hpp"
 #include "LinearAlgebra/vector_ops.hpp"
-#include "CodePatterns/Verbose.hpp"
 #include "LinearAlgebra/Plane.hpp"
-#include "Exceptions/LinearDependenceException.hpp"
-#include "CodePatterns/Assert.hpp"
-
-#include "Helpers/fast_functions.hpp"
+#include "linkedcell.hpp"
+#include "PointCloudAdaptor.hpp"
+#include "tesselation.hpp"
+#include "tesselationhelpers.hpp"
+#include "TesselPoint.hpp"
+#include "triangleintersectionlist.hpp"
 
 class molecule;
@@ -86,100 +87,4 @@
   DoLog(0) && (Log() << Verbose(0) << "This envelope was written to file " << TriangleFilesWritten << " times(s)." << endl);
 }
-;
-
-TesselPoint * Tesselation::getValue(const_iterator &rhs) const
-{
-  return (*rhs).second->node;
-}
-
-TesselPoint * Tesselation::getValue(iterator &rhs) const
-{
-  return (*rhs).second->node;
-}
-
-const char * const Tesselation::GetName() const
-{
-  return "unknown";
-}
-
-/** PointCloud implementation of GetCenter
- * Uses PointsOnBoundary and STL stuff.
- */
-Vector * Tesselation::GetCenter() const
-{
-  Info FunctionInfo(__func__);
-  Vector *Center = new Vector(0., 0., 0.);
-  int num = 0;
-  for (GoToFirst(); (!IsEnd()); GoToNext()) {
-    (*Center) += (GetPoint()->getPosition());
-    num++;
-  }
-  Center->Scale(1. / num);
-  return Center;
-}
-;
-
-/** PointCloud implementation of GoPoint
- * Uses PointsOnBoundary and STL stuff.
- */
-TesselPoint * Tesselation::GetPoint() const
-{
-  Info FunctionInfo(__func__);
-  return (InternalPointer->second->node);
-}
-;
-
-int Tesselation::GetMaxId() const
-{
-  int max_id = 0;
-  for (PointMap::const_iterator iter = PointsOnBoundary.begin();
-      iter != PointsOnBoundary.end();
-      ++iter) {
-    if ((iter->second)->node->nr > max_id)
-      (iter->second)->node->nr = max_id;
-  }
-  return max_id;
-}
-
-/** PointCloud implementation of GoToNext.
- * Uses PointsOnBoundary and STL stuff.
- */
-void Tesselation::GoToNext() const
-{
-  Info FunctionInfo(__func__);
-  if (InternalPointer != PointsOnBoundary.end())
-    InternalPointer++;
-}
-;
-
-/** PointCloud implementation of GoToFirst.
- * Uses PointsOnBoundary and STL stuff.
- */
-void Tesselation::GoToFirst() const
-{
-  Info FunctionInfo(__func__);
-  InternalPointer = PointsOnBoundary.begin();
-}
-;
-
-/** PointCloud implementation of IsEmpty.
- * Uses PointsOnBoundary and STL stuff.
- */
-bool Tesselation::IsEmpty() const
-{
-  Info FunctionInfo(__func__);
-  return (PointsOnBoundary.empty());
-}
-;
-
-/** PointCloud implementation of IsLast.
- * Uses PointsOnBoundary and STL stuff.
- */
-bool Tesselation::IsEnd() const
-{
-  Info FunctionInfo(__func__);
-  return (InternalPointer == PointsOnBoundary.end());
-}
-;
 
 /** Gueses first starting triangle of the convex envelope.
@@ -318,5 +223,5 @@
  * \param *cloud cluster of points
  */
-void Tesselation::TesselateOnBoundary(const PointCloud * const cloud)
+void Tesselation::TesselateOnBoundary(IPointCloud & cloud)
 {
   Info FunctionInfo(__func__);
@@ -328,5 +233,5 @@
   LineMap::iterator LineChecker[2];
 
-  Center = cloud->GetCenter();
+  Center = cloud.GetCenter();
   // create a first tesselation with the given BoundaryPoints
   do {
@@ -509,10 +414,10 @@
  * \return true - all straddling points insert, false - something went wrong
  */
-bool Tesselation::InsertStraddlingPoints(const PointCloud *cloud, const LinkedCell *LC)
+bool Tesselation::InsertStraddlingPoints(IPointCloud & cloud, const LinkedCell *LC)
 {
   Info FunctionInfo(__func__);
   Vector Intersection, Normal;
   TesselPoint *Walker = NULL;
-  Vector *Center = cloud->GetCenter();
+  Vector *Center = cloud.GetCenter();
   TriangleList *triangles = NULL;
   bool AddFlag = false;
@@ -520,13 +425,14 @@
   bool SuccessFlag = true;
 
-  cloud->GoToFirst();
-  BoundaryPoints = new LinkedCell(*this, 5.);
-  while (!cloud->IsEnd()) { // we only have to go once through all points, as boundary can become only bigger
+  cloud.GoToFirst();
+  PointCloudAdaptor< Tesselation, MapValueIterator<Tesselation::iterator> > newcloud(this);
+  BoundaryPoints = new LinkedCell(newcloud, 5.);
+  while (!cloud.IsEnd()) { // we only have to go once through all points, as boundary can become only bigger
     if (AddFlag) {
       delete (BoundaryPoints);
-      BoundaryPoints = new LinkedCell(*this, 5.);
+      BoundaryPoints = new LinkedCell(newcloud, 5.);
       AddFlag = false;
     }
-    Walker = cloud->GetPoint();
+    Walker = cloud.GetPoint();
     DoLog(0) && (Log() << Verbose(0) << "Current point is " << *Walker << "." << endl);
     // get the next triangle
@@ -539,5 +445,5 @@
     if ((BTS == NULL) || (BTS->ContainsBoundaryPoint(Walker))) {
       DoLog(0) && (Log() << Verbose(0) << "No triangles found, probably a tesselation point itself." << endl);
-      cloud->GoToNext();
+      cloud.GoToNext();
       continue;
     } else {
@@ -610,5 +516,5 @@
       break;
     }
-    cloud->GoToNext();
+    cloud.GoToNext();
   }
 
@@ -1122,8 +1028,8 @@
     for (LC->n[map[1]] = 0; LC->n[map[1]] < LC->N[map[1]]; LC->n[map[1]]++)
       for (LC->n[map[2]] = 0; LC->n[map[2]] < LC->N[map[2]]; LC->n[map[2]]++) {
-        const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
+        const TesselPointSTLList *List = LC->GetCurrentCell();
         //Log() << Verbose(1) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;
         if (List != NULL) {
-          for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
+          for (TesselPointSTLList::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
             if ((*Runner)->at(map[0]) > maxCoordinate[map[0]]) {
               DoLog(1) && (Log() << Verbose(1) << "New maximal for axis " << map[0] << " node is " << *(*Runner) << " at " << (*Runner)->getPosition() << "." << endl);
@@ -1982,8 +1888,8 @@
     for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
       for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
-        const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
+        const TesselPointSTLList *List = LC->GetCurrentCell();
         //Log() << Verbose(1) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;
         if (List != NULL) {
-          for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
+          for (TesselPointSTLList::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
             Candidate = (*Runner);
             // check if we only have one unique point yet ...
@@ -2140,8 +2046,8 @@
         for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
           for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
-            const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
+            const TesselPointSTLList *List = LC->GetCurrentCell();
             //Log() << Verbose(1) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;
             if (List != NULL) {
-              for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
+              for (TesselPointSTLList::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
                 Candidate = (*Runner);
 
@@ -2313,8 +2219,8 @@
     for (LC->n[1] = Nlower[1]; LC->n[1] <= Nupper[1]; LC->n[1]++)
       for (LC->n[2] = Nlower[2]; LC->n[2] <= Nupper[2]; LC->n[2]++) {
-        const LinkedCell::LinkedNodes *List = LC->GetCurrentCell();
+        const TesselPointSTLList *List = LC->GetCurrentCell();
         //Log() << Verbose(1) << "The current cell " << LC->n[0] << "," << LC->n[1] << "," << LC->n[2] << endl;
         if (List != NULL) {
-          for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
+          for (TesselPointSTLList::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
             FindPoint = PointsOnBoundary.find((*Runner)->nr);
             if (FindPoint != PointsOnBoundary.end()) {
@@ -3710,7 +3616,7 @@
  * \param *out otuput stream for debugging
  * \param *filename basename of output file
- * \param *cloud PointCloud structure with all nodes
- */
-void Tesselation::Output(const char *filename, const PointCloud * const cloud)
+ * \param *cloud IPointCloud structure with all nodes
+ */
+void Tesselation::Output(const char *filename, IPointCloud & cloud)
 {
   Info FunctionInfo(__func__);
